#18 Basic structure of editing profile screen
This commit is contained in:
parent
3ff4f82298
commit
8ad82dda43
5 changed files with 83 additions and 5 deletions
|
@ -19,6 +19,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||
import androidx.compose.ui.text.input.VisualTransformation
|
||||
import be.ugent.sel.studeez.common.ext.fieldModifier
|
||||
|
||||
@Composable
|
||||
fun BasicField(
|
||||
|
@ -36,6 +37,20 @@ fun BasicField(
|
|||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun LabelledInputField(
|
||||
value: String,
|
||||
onNewValue: (String) -> Unit,
|
||||
@StringRes label: Int
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = value,
|
||||
onValueChange = onNewValue,
|
||||
label = { Text(text = stringResource(id = label)) },
|
||||
modifier = Modifier.fieldModifier()
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun UsernameField(
|
||||
value: String,
|
||||
|
|
|
@ -1,22 +1,44 @@
|
|||
package be.ugent.sel.studeez.screens.profile
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.common.composable.BasicButton
|
||||
import be.ugent.sel.studeez.common.composable.BasicTextButton
|
||||
import be.ugent.sel.studeez.common.composable.LabelledInputField
|
||||
import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate
|
||||
import be.ugent.sel.studeez.common.ext.textButton
|
||||
import be.ugent.sel.studeez.resources
|
||||
import be.ugent.sel.studeez.ui.theme.StudeezTheme
|
||||
|
||||
@Composable
|
||||
fun EditProfileScreen(
|
||||
goBack: () -> Unit
|
||||
goBack: () -> Unit,
|
||||
viewModel: ProfileEditViewModel = hiltViewModel()
|
||||
) {
|
||||
val uiState by viewModel.uiState
|
||||
|
||||
SecondaryScreenTemplate(
|
||||
title = resources().getString(R.string.editing_profile),
|
||||
popUp = goBack
|
||||
) {
|
||||
Text(text = "TODO")
|
||||
Column {
|
||||
LabelledInputField(
|
||||
value = uiState.username,
|
||||
onNewValue = viewModel::onUsernameChange,
|
||||
label = R.string.username
|
||||
)
|
||||
|
||||
BasicTextButton(text = R.string.save, Modifier.textButton()) {} // TODO
|
||||
BasicTextButton(text = R.string.delete_profile, Modifier.textButton()) {} // TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,8 +46,8 @@ fun EditProfileScreen(
|
|||
@Composable
|
||||
fun EditProfileScreenComposable() {
|
||||
StudeezTheme {
|
||||
EditProfileScreen {
|
||||
EditProfileScreen (
|
||||
{}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package be.ugent.sel.studeez.screens.profile
|
||||
|
||||
data class ProfileEditUiState (
|
||||
val username: String = ""
|
||||
)
|
|
@ -0,0 +1,31 @@
|
|||
package be.ugent.sel.studeez.screens.profile
|
||||
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import be.ugent.sel.studeez.domain.LogService
|
||||
import be.ugent.sel.studeez.screens.StudeezViewModel
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class ProfileEditViewModel @Inject constructor(
|
||||
logService: LogService
|
||||
) : StudeezViewModel(logService) {
|
||||
|
||||
var uiState = mutableStateOf(ProfileEditUiState())
|
||||
private set
|
||||
|
||||
private val username
|
||||
get() = uiState.value.username
|
||||
|
||||
fun onUsernameChange(newValue: String) {
|
||||
uiState.value = uiState.value.copy(username = newValue)
|
||||
}
|
||||
|
||||
fun onSaveClick() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
fun onDeleteClick() {
|
||||
// TODO
|
||||
}
|
||||
}
|
|
@ -7,11 +7,15 @@
|
|||
<string name="repeat_password">Repeat password</string>
|
||||
<string name="generic_error">Something wrong happened. Please try again.</string>
|
||||
<string name="email_error">Please insert a valid email.</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="try_again">Try again</string>
|
||||
<string name="go_back">Go back</string>
|
||||
<string name="menu">Menu</string>
|
||||
|
||||
<!-- Actions -->
|
||||
<string name="confirm">Confirm</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
|
||||
<!-- SignUpScreen -->
|
||||
<string name="create_account">Create account</string>
|
||||
<string name="password_error">Your password should have at least six characters and include one digit, one lower case letter and one upper case letter.</string>
|
||||
|
@ -41,6 +45,7 @@
|
|||
<string name="no_username">Unknown username</string>
|
||||
<string name="edit_profile">Edit profile</string>
|
||||
<string name="editing_profile">Editing profile</string>
|
||||
<string name="delete_profile">Delete profile</string>
|
||||
|
||||
<!-- Friends -->
|
||||
<string name="friends">Friends</string>
|
||||
|
|
Reference in a new issue