More consistency on modal bottom sheets colors

This commit is contained in:
Jackson Harper
2024-01-08 14:41:42 +08:00
parent 89d126734c
commit 291a424c58
4 changed files with 96 additions and 61 deletions

View File

@ -27,6 +27,7 @@ import app.omnivore.omnivore.R
import app.omnivore.omnivore.ui.save.SaveState
import app.omnivore.omnivore.ui.save.SaveViewModel
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AddLinkSheetContent(
viewModel: SaveViewModel,
@ -84,42 +85,47 @@ fun AddLinkSheetContent(
viewModel.saveURL(url)
}
Surface(
androidx.compose.material.Scaffold(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background),
) {
.background(MaterialTheme.colorScheme.primaryContainer),
topBar = {
CenterAlignedTopAppBar(
title = {
Text(stringResource(R.string.add_link_sheet_title))
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.background
),
navigationIcon = {
TextButton(onClick = onCancel) {
Text(text = stringResource(R.string.label_selection_sheet_action_cancel))
}
},
actions = {
TextButton(onClick = { addLink(textFieldValue.text) }) {
Text(stringResource(R.string.add_link_sheet_action_add_link))
}
}
)
}
) { paddingValues ->
Column(
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 5.dp)
.background(MaterialTheme.colorScheme.background)
.padding(horizontal = 10.dp)
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
TextButton(onClick = onCancel) {
Text(text = stringResource(R.string.add_link_sheet_action_cancel))
}
Text(stringResource(R.string.add_link_sheet_title), fontWeight = FontWeight.ExtraBold)
TextButton(onClick = { addLink(textFieldValue.text) }) {
Text(stringResource(R.string.add_link_sheet_action_add_link))
}
}
if (isSaving.value == true) {
Spacer(modifier = Modifier.width(16.dp))
CircularProgressIndicator(
modifier = Modifier
.height(16.dp)
.width(16.dp),
strokeWidth = 2.dp,
color = MaterialTheme.colorScheme.primary
)
@ -129,18 +135,29 @@ fun AddLinkSheetContent(
value = textFieldValue,
placeholder = { Text(stringResource(R.string.add_link_sheet_text_field_placeholder)) },
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
leadingIcon = { Icon(imageVector = Icons.Default.Link, contentDescription = "linkIcon") },
leadingIcon = {
Icon(
imageVector = Icons.Default.Link,
contentDescription = "linkIcon"
)
},
onValueChange = { textFieldValue = it },
modifier = Modifier.focusRequester(focusRequester).padding(top = 24.dp).fillMaxWidth()
modifier = Modifier
.focusRequester(focusRequester)
.padding(top = 24.dp)
.padding(horizontal = 10.dp)
.fillMaxWidth()
)
if (clipboardText != null) {
Button(
modifier = Modifier.padding(top = 10.dp),
modifier = Modifier.padding(top = 10.dp) .padding(horizontal = 10.dp)
,
onClick = {
textFieldValue = TextFieldValue(
text = clipboardText,
selection = TextRange(clipboardText.length))
selection = TextRange(clipboardText.length)
)
}
) {
Text(stringResource(R.string.add_link_sheet_action_paste_from_clipboard))

View File

@ -296,7 +296,7 @@ fun LabelsSelectionSheetContent(
topBar = {
CenterAlignedTopAppBar(
title = {
Text(titleText, fontWeight = FontWeight.ExtraBold)
Text(titleText)
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.background
@ -324,7 +324,7 @@ fun LabelsSelectionSheetContent(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background)
.padding(horizontal = paddingValues.calculateTopPadding())
.padding(horizontal = 10.dp)
) {
ChipTextField(
state = state,
@ -363,6 +363,7 @@ fun LabelsSelectionSheetContent(
modifier = Modifier
.defaultMinSize(minHeight = 45.dp)
.fillMaxWidth()
.padding(top = 24.dp)
.padding(horizontal = 10.dp)
.focusRequester(focusRequester)
// .onFocusEvent {
@ -410,7 +411,7 @@ fun LabelsSelectionSheetContent(
}
}
.padding(horizontal = 10.dp)
.padding(top = 10.dp, bottom = 5.dp)
.padding(top = 24.dp, bottom = 5.dp)
)
{
Icon(

View File

@ -18,6 +18,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.MutableLiveData
import app.omnivore.omnivore.R
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun EditInfoSheetContent(
savedItemId: String?,
@ -68,44 +69,47 @@ fun EditInfoSheetContent(
}
}
Surface(
androidx.compose.material.Scaffold(
modifier = Modifier
.fillMaxSize()
.background(MaterialTheme.colorScheme.background),
) {
.background(MaterialTheme.colorScheme.primaryContainer),
topBar = {
CenterAlignedTopAppBar(
title = {
Text(stringResource(R.string.edit_info_sheet_title))
},
colors = TopAppBarDefaults.topAppBarColors(
containerColor = MaterialTheme.colorScheme.background
),
navigationIcon = {
TextButton(onClick = onCancel) {
Text(text = stringResource(R.string.edit_info_sheet_action_cancel))
}
},
actions = {
TextButton(onClick = {
val newTitle = titleTextFieldValue.text
val newAuthor = authorTextFieldValue.text.ifEmpty { null }
val newDescription = descriptionTextFieldValue.text.ifEmpty { null }
savedItemId?.let {
viewModel.editInfo(it, newTitle, newAuthor, newDescription)
}
}) {
Text(stringResource(R.string.edit_info_sheet_action_save))
}
}
)
}
) { paddingValues ->
Column(
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.fillMaxSize()
.padding(horizontal = 16.dp)
.background(MaterialTheme.colorScheme.background)
.padding(horizontal = 10.dp)
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
) {
TextButton(onClick = onCancel) {
Text(text = stringResource(R.string.edit_info_sheet_action_cancel))
}
Text(stringResource(R.string.edit_info_sheet_title), fontWeight = FontWeight.ExtraBold)
TextButton(onClick = {
val newTitle = titleTextFieldValue.text
val newAuthor = authorTextFieldValue.text.ifEmpty { null }
val newDescription = descriptionTextFieldValue.text.ifEmpty { null }
savedItemId?.let {
viewModel.editInfo(it, newTitle, newAuthor, newDescription)
}
}) {
Text(stringResource(R.string.edit_info_sheet_action_save))
}
}
if (isUpdating.value == true) {
Spacer(modifier = Modifier.width(16.dp))
CircularProgressIndicator(

View File

@ -155,7 +155,7 @@ fun LabelBottomSheet(
) {
ModalBottomSheet(
onDismissRequest = { onDismiss() },
containerColor = Color.Transparent,
containerColor = MaterialTheme.colorScheme.background,
sheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true
),
@ -215,7 +215,14 @@ fun AddLinkBottomSheet(
saveViewModel: SaveViewModel,
onDismiss: () -> Unit = {}
) {
ModalBottomSheet(onDismissRequest = { onDismiss() }) {
ModalBottomSheet(
onDismissRequest = { onDismiss() },
containerColor = MaterialTheme.colorScheme.background,
sheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true
),
) {
AddLinkSheetContent(
viewModel = saveViewModel,
onCancel = {
@ -237,7 +244,13 @@ fun EditBottomSheet(
libraryViewModel: LibraryViewModel,
onDismiss: () -> Unit = {}
) {
ModalBottomSheet(onDismissRequest = { onDismiss() }) {
ModalBottomSheet(
onDismissRequest = { onDismiss() },
containerColor = MaterialTheme.colorScheme.background,
sheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true
),
) {
val currentSavedItemData = libraryViewModel.currentSavedItemUnderEdit()
EditInfoSheetContent(
savedItemId = currentSavedItemData?.savedItem?.savedItemId,