1.0.0 - Material you rework
This commit is contained in:
@@ -77,8 +77,7 @@ fun UserProfileScreen(
|
||||
UserProfileContent(
|
||||
state = state,
|
||||
onEvent = viewModel::onEvent,
|
||||
onSelectImage = { imagePickerLauncher.launch("image/*") },
|
||||
onNavigateBack = { navigator.navigateUp() }
|
||||
onSelectImage = { imagePickerLauncher.launch("image/*") }
|
||||
)
|
||||
}
|
||||
|
||||
@@ -88,53 +87,53 @@ private fun UserProfileContent(
|
||||
state: UserProfileScreenState,
|
||||
onEvent: (ProfileScreenEvent) -> Unit,
|
||||
onSelectImage: () -> Unit,
|
||||
onNavigateBack: () -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.background(MaterialTheme.colorScheme.background)
|
||||
) {
|
||||
// Top App Bar
|
||||
TopAppBar(
|
||||
title = { Text("Profile") },
|
||||
navigationIcon = {
|
||||
IconButton(onClick = onNavigateBack) {
|
||||
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
if (!state.isChangingPassword) {
|
||||
if (state.isEditing) {
|
||||
TextButton(onClick = { onEvent(ProfileScreenEvent.CancelEditing) }) {
|
||||
Text("Cancel")
|
||||
}
|
||||
TextButton(
|
||||
onClick = { onEvent(ProfileScreenEvent.SaveProfile) },
|
||||
enabled = state.isProfileFormValid && !state.isLoading
|
||||
) {
|
||||
Text("Save")
|
||||
}
|
||||
} else {
|
||||
IconButton(onClick = { onEvent(ProfileScreenEvent.StartEditing) }) {
|
||||
Icon(Icons.Default.Edit, contentDescription = "Edit")
|
||||
}
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text("Profile") },
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.surface,
|
||||
titleContentColor = MaterialTheme.colorScheme.onSurface,
|
||||
navigationIconContentColor = MaterialTheme.colorScheme.onSurface,
|
||||
actionIconContentColor = MaterialTheme.colorScheme.onSurface,
|
||||
)
|
||||
)
|
||||
},
|
||||
floatingActionButton = {
|
||||
if (!state.isChangingPassword) {
|
||||
if (state.isEditing) {
|
||||
ExtendedFloatingActionButton(
|
||||
text = { Text("Save") },
|
||||
icon = { Icon(Icons.Default.Check, contentDescription = null) },
|
||||
onClick = { onEvent(ProfileScreenEvent.SaveProfile) },
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
contentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
expanded = true,
|
||||
)
|
||||
} else {
|
||||
FloatingActionButton(onClick = { onEvent(ProfileScreenEvent.StartEditing) }) {
|
||||
Icon(Icons.Default.Edit, contentDescription = "Edit")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
) { paddingValues ->
|
||||
// Content
|
||||
if (state.isLoading) {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
} else {
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(paddingValues),
|
||||
contentPadding = PaddingValues(16.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user