mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-26 09:44:55 +00:00
color mode switcher
This commit is contained in:
+10
-5
@@ -34,6 +34,7 @@ import chat.simplex.common.platform.*
|
||||
import chat.simplex.common.views.CreateProfile
|
||||
import chat.simplex.common.views.remote.*
|
||||
import chat.simplex.common.views.usersettings.*
|
||||
import chat.simplex.common.views.usersettings.AppearanceScope.ColorModeSwitcher
|
||||
import chat.simplex.res.MR
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
import kotlinx.coroutines.*
|
||||
@@ -391,11 +392,15 @@ fun UserPicker(
|
||||
}
|
||||
if (showSettings) {
|
||||
Divider(Modifier.padding(DEFAULT_PADDING))
|
||||
UserPickerOptionRow(
|
||||
painterResource(MR.images.ic_settings),
|
||||
generalGetString(MR.strings.settings_section_title_settings).lowercase().capitalize(Locale.current),
|
||||
settingsClicked
|
||||
)
|
||||
|
||||
val text = generalGetString(MR.strings.settings_section_title_settings).lowercase().capitalize(Locale.current)
|
||||
SectionItemView(settingsClicked) {
|
||||
Icon(painterResource(MR.images.ic_settings), text, tint = MenuTextColor)
|
||||
TextIconSpaced()
|
||||
Text(text, color = MenuTextColor)
|
||||
Spacer(Modifier.weight(1f))
|
||||
ColorModeSwitcher()
|
||||
}
|
||||
}
|
||||
if (showCancel) {
|
||||
CancelPickerItem(cancelClicked)
|
||||
|
||||
+31
@@ -9,6 +9,7 @@ import SectionView
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.grid.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.MaterialTheme.colors
|
||||
@@ -606,6 +607,36 @@ object AppearanceScope {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ColorModeSwitcher() {
|
||||
val currentTheme by CurrentColors.collectAsState()
|
||||
var themeMode = currentTheme.base.mode;
|
||||
|
||||
if (appPrefs.currentTheme.get() === DefaultTheme.SYSTEM_THEME_NAME) {
|
||||
themeMode = if (systemInDarkThemeCurrently) DefaultThemeMode.DARK else DefaultThemeMode.LIGHT
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.clip(CircleShape)
|
||||
.combinedClickable(
|
||||
onClick = {
|
||||
ThemeManager.applyTheme(if (themeMode == DefaultThemeMode.LIGHT) appPrefs.systemDarkTheme.get()!! else DefaultTheme.LIGHT.themeName)
|
||||
saveThemeToDatabase(null)
|
||||
},
|
||||
onLongClick = {
|
||||
ThemeManager.applyTheme(DefaultTheme.SYSTEM_THEME_NAME)
|
||||
saveThemeToDatabase(null)
|
||||
}
|
||||
)
|
||||
.size(44.dp * fontSizeSqrtMultiplier),
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Icon(painterResource(MR.images.ic_light_mode), stringResource(MR.strings.color_mode_light), tint = MenuTextColor)
|
||||
}
|
||||
}
|
||||
|
||||
private var updateBackendJob: Job = Job()
|
||||
private fun saveThemeToDatabase(themeUserDestination: Pair<Long, ThemeModeOverrides?>?) {
|
||||
val remoteHostId = chatModel.remoteHostId()
|
||||
|
||||
Reference in New Issue
Block a user