diff --git a/app/src/main/kotlin/com/tutpro/baresip/AboutScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/AboutScreen.kt index 6059326d..90cb0cd1 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AboutScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AboutScreen.kt @@ -58,7 +58,6 @@ private fun AboutScreen(onBack: () -> Unit) { title = { Text( text = stringResource(R.string.about_title), - color = LocalCustomColors.current.light, fontWeight = FontWeight.Bold ) }, @@ -67,12 +66,13 @@ private fun AboutScreen(onBack: () -> Unit) { Icon( imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null, - tint = LocalCustomColors.current.light ) } }, colors = TopAppBarDefaults.topAppBarColors( - containerColor = LocalCustomColors.current.primary + containerColor = LocalCustomColors.current.primary, + titleContentColor = LocalCustomColors.current.onPrimary, + navigationIconContentColor = LocalCustomColors.current.onPrimary, ), windowInsets = WindowInsets(0, 0, 0, 0) ) diff --git a/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt index e4d83ebe..c5df78b1 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AccountsScreen.kt @@ -1,7 +1,6 @@ package com.tutpro.baresip import android.content.Context -import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -15,18 +14,19 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack +import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.outlined.Clear import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.SmallFloatingActionButton @@ -40,10 +40,8 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight @@ -109,7 +107,6 @@ fun AccountsScreen(navController: NavController) { ) } - @Composable fun AccountsContent(contentPadding: PaddingValues, navController: NavController) { @@ -174,8 +171,8 @@ fun AccountsContent(contentPadding: PaddingValues, navController: NavController) } showDialog.value = true }, - containerColor = LocalCustomColors.current.background, - contentColor = LocalCustomColors.current.secondary + containerColor = MaterialTheme.colorScheme.errorContainer, + contentColor = MaterialTheme.colorScheme.onErrorContainer ) { Icon( Icons.Filled.Delete, @@ -282,22 +279,23 @@ fun NewAccount(navController: NavController) { keyboardType = KeyboardType.Text, ) ) - Image( - painter = painterResource(id = R.drawable.plus), - contentDescription = "Add", - contentScale = ContentScale.Crop, - modifier = Modifier.size(48.dp) - .clickable( - onClick = { - val account = createNew(ctx, newAor.trim()) - if (account != null) { - navController.navigate("account/${account.aor}/new") - newAor = "" - focusManager.clearFocus() - } - } - ) - ) + SmallFloatingActionButton( + onClick = { + val account = createNew(ctx, newAor.trim()) + if (account != null) { + navController.navigate("account/${account.aor}/new") + newAor = "" + focusManager.clearFocus() + } + }, + containerColor = MaterialTheme.colorScheme.secondaryContainer, + contentColor = MaterialTheme.colorScheme.onSecondaryContainer + ) { + Icon( + imageVector = Icons.Filled.Add, + contentDescription = stringResource(R.string.add) + ) + } } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt index 2cff2746..993c7300 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/AudioScreen.kt @@ -97,16 +97,20 @@ private fun AudioScreen( title = { Text( text = stringResource(R.string.audio_settings), - color = LocalCustomColors.current.light, fontWeight = FontWeight.Bold ) }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = LocalCustomColors.current.primary, + navigationIconContentColor = LocalCustomColors.current.onPrimary, + titleContentColor = LocalCustomColors.current.onPrimary, + actionIconContentColor = LocalCustomColors.current.onPrimary + ), navigationIcon = { IconButton(onClick = onBack) { Icon( imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null, - tint = LocalCustomColors.current.light ) } }, @@ -115,14 +119,10 @@ private fun AudioScreen( IconButton(onClick = checkOnClick) { Icon( imageVector = Icons.Filled.Check, - tint = LocalCustomColors.current.light, contentDescription = "Check" ) } }, - colors = TopAppBarDefaults.topAppBarColors( - containerColor = LocalCustomColors.current.primary - ) ) } } diff --git a/app/src/main/kotlin/com/tutpro/baresip/CodecsScreen.kt b/app/src/main/kotlin/com/tutpro/baresip/CodecsScreen.kt index a493d850..4f0d11cd 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CodecsScreen.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CodecsScreen.kt @@ -118,12 +118,14 @@ private fun CodecsScreen( stringResource(R.string.audio_codecs) else stringResource(R.string.video_codecs), - color = LocalCustomColors.current.light, fontWeight = FontWeight.Bold ) }, colors = TopAppBarDefaults.topAppBarColors( - containerColor = LocalCustomColors.current.primary + containerColor = LocalCustomColors.current.primary, + navigationIconContentColor = LocalCustomColors.current.onPrimary, + titleContentColor = LocalCustomColors.current.onPrimary, + actionIconContentColor = LocalCustomColors.current.onPrimary ), windowInsets = WindowInsets(0, 0, 0, 0), navigationIcon = { @@ -131,7 +133,6 @@ private fun CodecsScreen( Icon( imageVector = Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back", - tint = LocalCustomColors.current.light ) } }, @@ -141,7 +142,6 @@ private fun CodecsScreen( }) { Icon( imageVector = Icons.Filled.Check, - tint = LocalCustomColors.current.light, contentDescription = "Check" ) } diff --git a/app/src/main/kotlin/com/tutpro/baresip/CustomColors.kt b/app/src/main/kotlin/com/tutpro/baresip/CustomColors.kt index f50ef031..52fa1753 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CustomColors.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CustomColors.kt @@ -6,11 +6,33 @@ import androidx.compose.runtime.compositionLocalOf @Immutable data class CustomColors( + // standard colors val primary: Color = Color.Unspecified, val onPrimary: Color = Color.Unspecified, + val primaryContainer: Color = Color.Unspecified, + val onPrimaryContainer: Color = Color.Unspecified, + val secondary: Color = Color.Unspecified, + val onSecondary: Color = Color.Unspecified, + val secondaryContainer: Color = Color.Unspecified, + val onSecondaryContainer: Color = Color.Unspecified, + val tertiary: Color = Color.Unspecified, + val onTertiary: Color = Color.Unspecified, + val tertiaryContainer: Color = Color.Unspecified, + val onTertiaryContainer: Color = Color.Unspecified, + val error: Color = Color.Unspecified, + val onError: Color = Color.Unspecified, + val errorContainer: Color = Color.Unspecified, + val onErrorContainer: Color = Color.Unspecified, + val background: Color = Color.Unspecified, + val onBackground: Color = Color.Unspecified, + val surface: Color = Color.Unspecified, + val onSurface: Color = Color.Unspecified, + val surfaceVariant: Color = Color.Unspecified, + val onSurfaceVariant: Color = Color.Unspecified, + val outline: Color = Color.Unspecified, + // custom colors val primaryDark: Color = Color.Unspecified, val primaryLight: Color = Color.Unspecified, - val secondary: Color = Color.Unspecified, val secondaryDark: Color = Color.Unspecified, val secondaryLight: Color = Color.Unspecified, val gray: Color = Color.Unspecified, @@ -18,11 +40,6 @@ data class CustomColors( val grayLight: Color = Color.Unspecified, val accent: Color = Color.Unspecified, val baresip: Color = Color.Unspecified, - val white: Color = Color.Unspecified, - val black: Color = Color.Unspecified, - val strong: Color = Color.Unspecified, - val green: Color = Color.Unspecified, - val red: Color = Color.Unspecified, val trafficGreen: Color = Color.Unspecified, val trafficYellow: Color = Color.Unspecified, val trafficRed: Color = Color.Unspecified, @@ -34,20 +51,37 @@ data class CustomColors( val itemText: Color = Color.Unspecified, val alertText: Color = Color.Unspecified, val codec: Color = Color.Unspecified, - val background: Color = Color.Unspecified, - val onBackground: Color = Color.Unspecified, val cardBackground: Color = Color.Unspecified, val textFieldBackground: Color = Color.Unspecified, val popupBackground: Color = Color.Unspecified, - val alert: Color = Color.Unspecified, - val actionbar: Color = Color.Unspecified, + val alert: Color = Color.Unspecified ) val light_primary = Color(0xff0ca1fd) val light_on_primary = Color(0xffe0e0e0) +val light_primary_container = Color(0xFFA1CBE6) +val light_on_primary_container = Color(0xFF032133) +val light_secondary = Color(0xFF00B9A1) +val light_on_secondary = Color(0xffe0e0e0) +val light_secondary_container = Color(0xFF9DE6DC) +val light_on_secondary_container = Color(0xFF00332C) +val light_tertiary = Color(0xFF7D5260) +val light_on_tertiary = Color(0xffe0e0e0) +val light_tertiary_container = Color(0xFFE6CDD5) +val light_on_tertiary_container = Color(0xFF332227) +val light_error = Color(0xFFF77445) +val light_on_error = Color(0xffe0e0e0) +val light_error_container = Color(0xFFE6BFB1) +val light_on_error_container = Color(0xFF33180E) +val light_background = Color(0xFFFCFCFC) +val light_on_background = Color(0xFF313233) +val light_surface = Color(0xFFfbfcfc) +val light_on_surface = Color(0xFF313233) +val light_surfaceVariant = Color(0xFFd8e0e6) +val light_on_surfaceVariant = Color(0xFF535f66) +val light_outline = Color(0xFF7c8e99) val light_primary_dark = Color(0xff0073c9) val light_primary_light = Color(0xff6ad2ff) -val light_secondary = Color(0xFF00B9A1) val light_secondary_dark = Color(0xFF008873) val light_secondary_light = Color(0xff5cecd2) val light_gray = Color(0xff9e9e9e) @@ -58,19 +92,36 @@ val light_light = Color(0xfffcfcfc) val light_dark = Color(0xFF383838) val light_spinner_divider = light_gray val light_item_text = light_dark -val light_background = light_light - -val light_on_background = Color(0xFF00B9A1) val light_textfield_background = light_gray_light val light_card_background = light_gray_light val light_popup_background = light_secondary_dark val light_alert = light_primary -val dark_primary = Color(0xff0073c9) -val dark_on_primary = Color(0xffe0e0e0) +val dark_primary = Color(0xFF84C1E6) +val dark_on_primary = Color(0xFF04314C) +val dark_primary_container = Color(0xFF054166) +val dark_on_primary_container = Color(0xFFA1CBE6) +val dark_secondary = Color(0xFF7FE6D8) +val dark_on_secondary = Color(0xFF004C43) +val dark_secondary_container = Color(0xFF006659) +val dark_on_secondary_container = Color(0xFF9DE6DC) +val dark_tertiary = Color(0xFFE6C3CE) +val dark_on_tertiary = Color(0xFF4C323B) +val dark_tertiary_container = Color(0xFF66434F) +val dark_on_tertiary_container = Color(0xFFE6CDD5) +val dark_error = Color(0xFFE6AF9C) +val dark_on_error = Color(0xFF4C2415) +val dark_error_container = Color(0xFF66301D) +val dark_on_error_container = Color(0xFFE6BFB1) +val dark_background = Color(0xFF313233) +val dark_on_background = Color(0xFFe2e4e6) +val dark_surface = Color(0xFF313233) +val dark_on_surface = Color(0xFFe2e4e6) +val dark_surfaceVariant = Color(0xFF535f66) +val dark_on_surfaceVariant = Color(0xFFd2dee6) +val dark_outline = Color(0xFF9daab3) val dark_primary_dark = Color(0xff00008b) val dark_primary_light = Color(0xff0ca1fd) -val dark_secondary = Color(0xFF00B9A1) val dark_secondary_dark = Color(0xFF008873) val dark_secondary_light = Color(0xff5cecd2) val dark_gray = Color(0xff9e9e9e) @@ -81,8 +132,6 @@ val dark_light = dark_gray_light val dark_dark = Color(0xFF121212) val dark_spinner_divider = dark_gray_dark val dark_item_text = dark_gray_light -val dark_background = dark_dark -val dark_on_background = Color(0xFF00B9A1) val dark_textfield_background = dark_gray val dark_card_background = dark_gray_dark val dark_popup_background = dark_secondary_dark @@ -91,9 +140,30 @@ val dark_alert = dark_primary_light val LightCustomColors = CustomColors( primary = light_primary, onPrimary = light_on_primary, + primaryContainer = light_primary_container, + onPrimaryContainer = light_on_primary_container, + secondary = light_secondary, + onSecondary = light_on_secondary, + secondaryContainer = light_secondary_container, + onSecondaryContainer = light_on_secondary_container, + tertiary = light_tertiary, + onTertiary = light_on_tertiary, + tertiaryContainer = light_tertiary_container, + onTertiaryContainer = light_on_tertiary_container, + error = light_error, + onError = light_on_error, + errorContainer = light_error_container, + onErrorContainer = light_on_error_container, + background = light_background, + onBackground = light_on_background, + surface = light_surface, + onSurface = light_on_surface, + surfaceVariant = light_surfaceVariant, + onSurfaceVariant = light_on_surfaceVariant, + outline = light_outline, + primaryDark = light_primary_dark, primaryLight = light_primary_light, - secondary = light_secondary, secondaryDark = light_secondary_dark, secondaryLight = light_secondary_light, gray = light_gray, @@ -104,8 +174,6 @@ val LightCustomColors = CustomColors( dark = light_dark, spinnerDivider = light_spinner_divider, itemText = light_item_text, - background = light_background, - onBackground = light_on_background, cardBackground = light_card_background, textFieldBackground = light_textfield_background, popupBackground = light_popup_background, @@ -115,9 +183,30 @@ val LightCustomColors = CustomColors( val DarkCustomColors = CustomColors( primary = dark_primary, onPrimary = dark_on_primary, + primaryContainer = dark_primary_container, + onPrimaryContainer = dark_on_primary_container, + secondary = dark_secondary, + onSecondary = dark_on_secondary, + secondaryContainer = dark_secondary_container, + onSecondaryContainer = dark_on_secondary_container, + tertiary = dark_tertiary, + onTertiary = dark_on_tertiary, + tertiaryContainer = dark_tertiary_container, + onTertiaryContainer = dark_on_tertiary_container, + error = dark_error, + onError = dark_on_error, + errorContainer = dark_error_container, + onErrorContainer = dark_on_error_container, + background = dark_background, + onBackground = dark_on_background, + surface = dark_surface, + onSurface = dark_on_surface, + surfaceVariant = dark_surfaceVariant, + onSurfaceVariant = dark_on_surfaceVariant, + outline = dark_outline, + primaryDark = dark_primary_dark, primaryLight = dark_primary_light, - secondary = dark_secondary, secondaryDark = dark_secondary_dark, secondaryLight = dark_secondary_light, gray = dark_gray, @@ -128,8 +217,6 @@ val DarkCustomColors = CustomColors( dark = dark_dark, spinnerDivider = dark_spinner_divider, itemText = dark_item_text, - background = dark_background, - onBackground = dark_on_background, cardBackground = dark_card_background, textFieldBackground = dark_textfield_background, popupBackground = dark_popup_background, diff --git a/app/src/main/kotlin/com/tutpro/baresip/CustomElements.kt b/app/src/main/kotlin/com/tutpro/baresip/CustomElements.kt index ec684e75..96a26f11 100644 --- a/app/src/main/kotlin/com/tutpro/baresip/CustomElements.kt +++ b/app/src/main/kotlin/com/tutpro/baresip/CustomElements.kt @@ -9,7 +9,6 @@ import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.Canvas import androidx.compose.foundation.Image import androidx.compose.foundation.ScrollState -import androidx.compose.foundation.background import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -22,10 +21,10 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.itemsIndexed -import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions @@ -39,6 +38,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon import androidx.compose.material3.IconButton +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextFieldDefaults import androidx.compose.material3.Surface @@ -82,7 +82,6 @@ import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.compose.ui.window.DialogProperties -import androidx.core.content.ContextCompat.getString object CustomElements { @@ -148,10 +147,7 @@ object CustomElements { DropdownMenu( expanded = expanded, onDismissRequest = onDismissRequest, - containerColor = LocalCustomColors.current.onPrimary, - modifier = Modifier.background( - LocalCustomColors.current.popupBackground.copy(alpha = 0.95f) - ) + containerColor = MaterialTheme.colorScheme.surfaceContainer ) { val itemsIterator = items.iterator() while (itemsIterator.hasNext()) { @@ -160,13 +156,13 @@ object CustomElements { text = { Text( text = item, - color = LocalCustomColors.current.light, + color = MaterialTheme.colorScheme.onSurface, fontSize = 16.sp ) }, onClick = { onItemClick(item) } ) if (itemsIterator.hasNext()) - HorizontalDivider(color = LocalCustomColors.current.spinnerDivider) + HorizontalDivider(color = MaterialTheme.colorScheme.outlineVariant) } } } @@ -288,9 +284,7 @@ object CustomElements { ) { if (showDialog.value) { BasicAlertDialog( - onDismissRequest = { - showDialog.value = false - }, + onDismissRequest = { showDialog.value = false }, content = { Card( modifier = Modifier @@ -298,27 +292,55 @@ object CustomElements { .padding(top = 16.dp, start = 16.dp, end = 16.dp, bottom = 0.dp), shape = RoundedCornerShape(16.dp), colors = CardDefaults.cardColors( - containerColor = LocalCustomColors.current.cardBackground + containerColor = MaterialTheme.colorScheme.surfaceContainer ) ) { Column(modifier = Modifier.padding(16.dp)) { Text( text = title, + modifier = Modifier.fillMaxWidth(), + textAlign = TextAlign.Start, fontSize = 20.sp, - color = LocalCustomColors.current.alert, + color = MaterialTheme.colorScheme.onSurface ) Spacer(modifier = Modifier.height(16.dp)) Text( text = message, + modifier = Modifier.fillMaxWidth(), + textAlign = TextAlign.Start, fontSize = 16.sp, - color = LocalCustomColors.current.itemText, + color = MaterialTheme.colorScheme.onSurfaceVariant ) Spacer(modifier = Modifier.height(16.dp)) - if (negativeButtonText.isNotEmpty() && neutralButtonText.isNotEmpty()) { - Column( + if (positiveButtonText.isNotEmpty()) { + Row( modifier = Modifier.fillMaxWidth(), - horizontalAlignment = Alignment.End + horizontalArrangement = Arrangement.End ) { + if (negativeButtonText.isNotEmpty()) { + TextButton(onClick = { + onNegativeClicked() + showDialog.value = false + }) { + Text( + text = negativeButtonText.uppercase(), + fontSize = 14.sp, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + } + if (neutralButtonText.isNotEmpty()) { + TextButton(onClick = { + onNeutralClicked() + showDialog.value = false + }) { + Text( + text = neutralButtonText.uppercase(), + fontSize = 14.sp, + color = MaterialTheme.colorScheme.primary + ) + } + } TextButton(onClick = { onPositiveClicked() showDialog.value = false @@ -326,70 +348,11 @@ object CustomElements { Text( text = positiveButtonText.uppercase(), fontSize = 14.sp, - color = LocalCustomColors.current.alert, - ) - } - TextButton(onClick = { - onNeutralClicked() - showDialog.value = false - }) { - Text( - text = neutralButtonText.uppercase(), - fontSize = 14.sp, - color = LocalCustomColors.current.alert - ) - } - TextButton(onClick = { - onNegativeClicked() - showDialog.value = false - }) { - Text( - text = negativeButtonText.uppercase(), - fontSize = 14.sp, - color = LocalCustomColors.current.gray + color = MaterialTheme.colorScheme.primary, ) } } } - else - if (positiveButtonText.isNotEmpty()) - Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.End - ) { - if (negativeButtonText.isNotEmpty()) - TextButton(onClick = { - onNegativeClicked() - showDialog.value = false - }) { - Text( - text = negativeButtonText.uppercase(), - fontSize = 14.sp, - color = LocalCustomColors.current.gray - ) - } - if (neutralButtonText.isNotEmpty()) - TextButton(onClick = { - onNeutralClicked() - showDialog.value = false - }) { - Text( - text = neutralButtonText.uppercase(), - fontSize = 14.sp, - color = LocalCustomColors.current.alert - ) - } - TextButton(onClick = { - onPositiveClicked() - showDialog.value = false - }) { - Text( - text = positiveButtonText.uppercase(), - fontSize = 14.sp, - color = LocalCustomColors.current.alert, - ) - } - } } } } @@ -419,23 +382,21 @@ object CustomElements { .padding(top = 16.dp, start = 16.dp, end = 16.dp, bottom = 0.dp), shape = RoundedCornerShape(16.dp), colors = CardDefaults.cardColors( - containerColor = LocalCustomColors.current.cardBackground + containerColor = MaterialTheme.colorScheme.surfaceContainer ) ) { Column(modifier = Modifier.padding(16.dp)) { Text( text = title, fontSize = 20.sp, - color = LocalCustomColors.current.alert, + color = MaterialTheme.colorScheme.onSurface, textAlign = TextAlign.Start, modifier = Modifier.fillMaxWidth() ) Spacer(modifier = Modifier.height(16.dp)) - val lazyListState = rememberLazyListState() LazyColumn( modifier = Modifier.fillMaxWidth(), - horizontalAlignment = Alignment.End, - state = lazyListState, + horizontalAlignment = Alignment.End ) { itemsIndexed(items) { index, item -> TextButton( @@ -443,26 +404,33 @@ object CustomElements { onItemClicked(index) openDialog.value = false }, - modifier = Modifier.align(Alignment.End) + modifier = Modifier.fillMaxWidth() ) { Text( text = item, - color = LocalCustomColors.current.itemText, + color = MaterialTheme.colorScheme.onSurface, + modifier = Modifier.fillMaxWidth(), + textAlign = TextAlign.Start ) } } } if (neutralButtonText.isNotEmpty()) { - TextButton( - onClick = { - onNeutralClicked() - openDialog.value = false - }, - modifier = Modifier.align(Alignment.End)){ - Text( - text = neutralButtonText.uppercase(), - color = LocalCustomColors.current.gray, - ) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.End + ) { + TextButton( + onClick = { + onNeutralClicked() + openDialog.value = false + } + ) { + Text( + text = neutralButtonText.uppercase(), + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } } } } @@ -486,130 +454,127 @@ object CustomElements { ) { val showPassword = remember { mutableStateOf(false) } val focusRequester = remember { FocusRequester() } - BasicAlertDialog( - properties = DialogProperties( - dismissOnBackPress = false, - dismissOnClickOutside = false, - ), - onDismissRequest = { - keyboardController?.hide() - showPasswordDialog.value = false - } - ) { - Card( - modifier = Modifier - .fillMaxWidth() - .padding(top = 16.dp, start = 16.dp, end = 16.dp, bottom = 0.dp), - shape = RoundedCornerShape(16.dp), - colors = CardDefaults.cardColors( - containerColor = LocalCustomColors.current.cardBackground - ) - ) { - Column(modifier = Modifier.padding(16.dp)) { - Text( - text = title, - fontSize = 20.sp, - modifier = Modifier.padding(top = 16.dp, bottom = 16.dp), - color = LocalCustomColors.current.alert, - ) - if (message != "") - Text( - text = message, - fontSize = 16.sp, - modifier = Modifier.padding(16.dp), - color = LocalCustomColors.current.itemText, - ) - OutlinedTextField( - value = password.value, - singleLine = true, - colors = OutlinedTextFieldDefaults.colors( - focusedContainerColor = LocalCustomColors.current.textFieldBackground, - unfocusedContainerColor = LocalCustomColors.current.textFieldBackground, - cursorColor = LocalCustomColors.current.primary, - ), - onValueChange = { - password.value = it - }, - visualTransformation = if (showPassword.value) - VisualTransformation.None - else - PasswordVisualTransformation(), - trailingIcon = { - IconButton(onClick = { - showPassword.value = !showPassword.value - showPasswordDialog.value = true - }) { - Icon( - if (showPassword.value) - ImageVector.vectorResource(R.drawable.visibility) - else - ImageVector.vectorResource(R.drawable.visibility_off), - contentDescription = "Visibility", - tint = LocalCustomColors.current.grayDark + if (showPasswordDialog.value) { + BasicAlertDialog( + properties = DialogProperties( + dismissOnBackPress = false, + dismissOnClickOutside = false, + ), + onDismissRequest = { + keyboardController?.hide() + showPasswordDialog.value = false + } + ) { + Card( + modifier = Modifier + .fillMaxWidth() + .padding(top = 16.dp, start = 16.dp, end = 16.dp, bottom = 0.dp), + shape = RoundedCornerShape(16.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceContainer + ) + ) { + Column(modifier = Modifier.padding(16.dp)) { + Text( + text = title, + fontSize = 20.sp, + modifier = Modifier.padding(top = 16.dp, bottom = 16.dp), + color = MaterialTheme.colorScheme.onSurface, + ) + if (message.isNotEmpty()) + Text( + text = message, + fontSize = 16.sp, + modifier = Modifier.padding(16.dp), + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + OutlinedTextField( + value = password.value, + singleLine = true, + colors = OutlinedTextFieldDefaults.colors( + cursorColor = MaterialTheme.colorScheme.primary, + ), + onValueChange = { + password.value = it + }, + visualTransformation = if (showPassword.value) + VisualTransformation.None + else + PasswordVisualTransformation(), + trailingIcon = { + IconButton(onClick = { + showPassword.value = !showPassword.value + }) { + Icon( + imageVector = if (showPassword.value) + ImageVector.vectorResource(R.drawable.visibility) + else + ImageVector.vectorResource(R.drawable.visibility_off), + contentDescription = "Visibility", + tint = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + }, + modifier = Modifier + .fillMaxWidth() + .padding(start = 4.dp, end = 4.dp, top = 12.dp, bottom = 2.dp) + .focusRequester(focusRequester), + textStyle = TextStyle( + fontSize = 18.sp, + color = MaterialTheme.colorScheme.onSurface + ), + keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text) + ) + LaunchedEffect(key1 = Unit) { + focusRequester.requestFocus() + keyboardController?.show() + } + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.End + ) { + TextButton( + onClick = { + keyboardController?.hide() + showPasswordDialog.value = false + cancelAction() + }, + ) { + Text( + text = stringResource(R.string.cancel), + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + Spacer(modifier = Modifier.width(8.dp)) + TextButton( + onClick = { + keyboardController?.hide() + showPasswordDialog.value = false + password.value = password.value.trim() + if (!Account.checkAuthPass(password.value)) { + Toast.makeText( + ctx, + String.format( + ctx.getString(R.string.invalid_authentication_password), + password.value + ), + Toast.LENGTH_SHORT + ).show() + password.value = "" + } + okAction() + }, + ) { + Text( + text = stringResource(R.string.ok), + color = MaterialTheme.colorScheme.primary ) } - }, - modifier = Modifier - .fillMaxWidth() - .padding(start = 4.dp, end = 4.dp, top = 12.dp, bottom = 2.dp) - .focusRequester(focusRequester), - textStyle = TextStyle( - fontSize = 18.sp, - color = LocalCustomColors.current.dark - ), - keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text) - ) - LaunchedEffect(key1 = Unit) { - focusRequester.requestFocus() - keyboardController?.show() - } - Row( - horizontalArrangement = Arrangement.Start - ) { - TextButton( - onClick = { - keyboardController?.hide() - showPasswordDialog.value = false - cancelAction() - }, - ) { - Text( - text = stringResource(R.string.cancel), - color = LocalCustomColors.current.gray - ) - } - Spacer(modifier = Modifier.weight(1f)) - TextButton( - onClick = { - keyboardController?.hide() - showPasswordDialog.value = false - password.value = password.value.trim() - if (!Account.checkAuthPass(password.value)) { - Toast.makeText( - ctx, - String.format( - getString( - ctx, - R.string.invalid_authentication_password - ), password.value - ), - Toast.LENGTH_SHORT - ).show() - password.value = "" - } - okAction() - }, - ) { - Text( - text = stringResource(R.string.ok), - color = LocalCustomColors.current.alert - ) } } } } } } - }