#18 add edit profile button

This commit is contained in:
Tibo De Peuter 2023-04-16 13:02:09 +02:00
parent f82e83867c
commit 3900e3c18a
4 changed files with 49 additions and 4 deletions

View file

@ -1,8 +1,10 @@
package be.ugent.sel.studeez.common.composable
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Edit
import androidx.compose.material.icons.filled.Menu
import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope
@ -20,6 +22,7 @@ fun PrimaryScreenTemplate(
title: String,
open: (String) -> Unit,
openAndPopUp: (String, String) -> Unit,
action: @Composable RowScope.() -> Unit,
content: @Composable (PaddingValues) -> Unit
) {
val scaffoldState: ScaffoldState = rememberScaffoldState()
@ -39,7 +42,8 @@ fun PrimaryScreenTemplate(
contentDescription = resources().getString(R.string.menu)
)
}
}
},
actions = action
) },
drawerContent = {
@ -62,7 +66,13 @@ fun PrimaryScreenPreview() {
PrimaryScreenTemplate(
"Preview screen",
{ _ -> {}},
{ _, _ -> {}}
{ _, _ -> {}},
{ IconButton(onClick = { /*TODO*/ }) {
Icon(
imageVector = Icons.Default.Edit,
contentDescription = "Edit"
)
}}
) {}
}
}

View file

@ -1,5 +1,9 @@
package be.ugent.sel.studeez.screens.home
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Person
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
@ -18,10 +22,21 @@ fun HomeScreen(
PrimaryScreenTemplate(
title = resources().getString(R.string.home),
open = open,
openAndPopUp = openAndPopUp
openAndPopUp = openAndPopUp,
action = { FriendsAction() }
) {
BasicButton(R.string.start_session, Modifier.basicButton()) {
viewModel.onStartSessionClick(open)
}
}
}
@Composable
fun FriendsAction () {
IconButton(onClick = { /*TODO*/ }) {
Icon(
imageVector = Icons.Default.Person,
contentDescription = resources().getString(R.string.friends)
)
}
}

View file

@ -1,5 +1,9 @@
package be.ugent.sel.studeez.screens.profile
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Edit
import androidx.compose.runtime.*
import androidx.hilt.navigation.compose.hiltViewModel
import be.ugent.sel.studeez.R
@ -22,8 +26,20 @@ fun ProfileScreen(
PrimaryScreenTemplate(
title = resources().getString(AppText.profile),
open = open,
openAndPopUp = openAndPopUp
openAndPopUp = openAndPopUp,
action = { EditAction() }
) {
Headline(text = (username ?: resources().getString(R.string.no_username)))
}
}
@Composable
fun EditAction() {
IconButton(onClick = { /*TODO*/ }) {
Icon(
imageVector = Icons.Default.Edit,
contentDescription = resources().getString(AppText.edit_profile)
)
}
}

View file

@ -39,6 +39,10 @@
<!-- Profile -->
<string name="profile">Profile</string>
<string name="no_username">Unknown username</string>
<string name="edit_profile">Edit profile</string>
<!-- Friends -->
<string name="friends">Friends</string>
<!-- Drawer / SideMenu -->
<string name="log_out">Log out</string>