Refactor: Introduce FullScreenContainedLoader and use rememberUpdatedState
This commit introduces `FullScreenContainedLoader` and replaces usages of `FullScreenLoader` where appropriate. It also updates several composables to use `rememberUpdatedState` for lambda parameters to ensure the latest versions are used. Additionally, the following changes are included: - Add a setting to show/hide the attachment button in the chat input bar. - Implement navigation to `PhotoViewScreen` when a photo attachment is clicked in a message. - Add "Copy link" and "Copy image" actions to `PhotoViewScreen`. - Remove unused settings and their corresponding logic from `SettingsViewModel` and `UserSettings`.
This commit is contained in:
@@ -96,6 +96,13 @@ object AppSettings {
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_SHOW_EMOJI_BUTTON, value)
|
||||
|
||||
var showAttachmentButton: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_SHOW_ATTACHMENT_BUTTON,
|
||||
SettingsKeys.DEFAULT_VALUE_SHOW_ATTACHMENT_BUTTON
|
||||
)
|
||||
set(value) = put(SettingsKeys.KEY_SHOW_ATTACHMENT_BUTTON, value)
|
||||
|
||||
var enableHaptic: Boolean
|
||||
get() = get(
|
||||
SettingsKeys.KEY_ENABLE_HAPTIC,
|
||||
|
||||
@@ -11,6 +11,10 @@ object SettingsKeys {
|
||||
const val DEFAULT_VALUE_USE_CONTACT_NAMES = false
|
||||
const val KEY_SHOW_EMOJI_BUTTON = "show_emoji_button"
|
||||
const val DEFAULT_VALUE_KEY_SHOW_EMOJI_BUTTON = false
|
||||
const val KEY_SHOW_ATTACHMENT_BUTTON = "show_attachment_button"
|
||||
const val DEFAULT_VALUE_SHOW_ATTACHMENT_BUTTON = false
|
||||
const val KEY_SHOW_RECORD_VOICE_BUTTON = "show_record_voice_button"
|
||||
const val DEFAULT_VALUE_SHOW_RECORD_VOICE_BUTTON = false
|
||||
|
||||
const val KEY_APPEARANCE = "appearance"
|
||||
const val KEY_APPEARANCE_MULTILINE = "appearance_multiline"
|
||||
|
||||
@@ -14,15 +14,10 @@ interface UserSettings {
|
||||
val enableDynamicColors: StateFlow<Boolean>
|
||||
val appLanguage: StateFlow<String>
|
||||
|
||||
val fastText: StateFlow<String>
|
||||
|
||||
val sendOnlineStatus: StateFlow<Boolean>
|
||||
|
||||
val showAlertAfterCrash: StateFlow<Boolean>
|
||||
val longPollInBackground: StateFlow<Boolean>
|
||||
val useBlur: StateFlow<Boolean>
|
||||
val showEmojiButton: StateFlow<Boolean>
|
||||
val showTimeInActionMessages: StateFlow<Boolean>
|
||||
val useSystemFont: StateFlow<Boolean>
|
||||
val enableAnimations: StateFlow<Boolean>
|
||||
val showDebugCategory: StateFlow<Boolean>
|
||||
@@ -35,15 +30,10 @@ interface UserSettings {
|
||||
fun onEnableDynamicColorsChanged(enable: Boolean)
|
||||
fun onAppLanguageChanged(language: String)
|
||||
|
||||
fun onFastTextChanged(text: String)
|
||||
|
||||
fun onSendOnlineStatusChanged(send: Boolean)
|
||||
|
||||
fun onShowAlertAfterCrashChanged(show: Boolean)
|
||||
fun onLongPollInBackgroundChanged(inBackground: Boolean)
|
||||
fun onUseBlurChanged(use: Boolean)
|
||||
fun onShowEmojiButtonChanged(show: Boolean)
|
||||
fun onShowTimeInActionMessagesChanged(show: Boolean)
|
||||
fun onUseSystemFontChanged(use: Boolean)
|
||||
fun onShowDebugCategoryChanged(show: Boolean)
|
||||
}
|
||||
@@ -58,16 +48,11 @@ class UserSettingsImpl : UserSettings {
|
||||
override val enableDynamicColors = MutableStateFlow(AppSettings.Appearance.enableDynamicColors)
|
||||
override val appLanguage = MutableStateFlow(AppSettings.Appearance.appLanguage)
|
||||
|
||||
override val fastText = MutableStateFlow(AppSettings.Features.fastText)
|
||||
|
||||
override val sendOnlineStatus = MutableStateFlow(AppSettings.Activity.sendOnlineStatus)
|
||||
|
||||
override val showAlertAfterCrash = MutableStateFlow(AppSettings.Debug.showAlertAfterCrash)
|
||||
override val longPollInBackground = MutableStateFlow(AppSettings.Experimental.longPollInBackground)
|
||||
override val longPollInBackground =
|
||||
MutableStateFlow(AppSettings.Experimental.longPollInBackground)
|
||||
override val useBlur = MutableStateFlow(AppSettings.Experimental.useBlur)
|
||||
override val showEmojiButton = MutableStateFlow(AppSettings.General.showEmojiButton)
|
||||
override val showTimeInActionMessages =
|
||||
MutableStateFlow(AppSettings.Experimental.showTimeInActionMessages)
|
||||
override val useSystemFont = MutableStateFlow(AppSettings.Appearance.useSystemFont)
|
||||
override val enableAnimations = MutableStateFlow(AppSettings.Experimental.moreAnimations)
|
||||
override val showDebugCategory = MutableStateFlow(AppSettings.Debug.showDebugCategory)
|
||||
@@ -96,18 +81,10 @@ class UserSettingsImpl : UserSettings {
|
||||
appLanguage.value = language
|
||||
}
|
||||
|
||||
override fun onFastTextChanged(text: String) {
|
||||
fastText.value = text
|
||||
}
|
||||
|
||||
override fun onSendOnlineStatusChanged(send: Boolean) {
|
||||
sendOnlineStatus.value = send
|
||||
}
|
||||
|
||||
override fun onShowAlertAfterCrashChanged(show: Boolean) {
|
||||
showAlertAfterCrash.value = show
|
||||
}
|
||||
|
||||
override fun onLongPollInBackgroundChanged(inBackground: Boolean) {
|
||||
longPollInBackground.value = inBackground
|
||||
}
|
||||
@@ -116,14 +93,6 @@ class UserSettingsImpl : UserSettings {
|
||||
useBlur.value = use
|
||||
}
|
||||
|
||||
override fun onShowEmojiButtonChanged(show: Boolean) {
|
||||
showEmojiButton.value = show
|
||||
}
|
||||
|
||||
override fun onShowTimeInActionMessagesChanged(show: Boolean) {
|
||||
showTimeInActionMessages.value = show
|
||||
}
|
||||
|
||||
override fun onUseSystemFontChanged(use: Boolean) {
|
||||
useSystemFont.value = use
|
||||
}
|
||||
|
||||
+35
-8
@@ -5,13 +5,27 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.material3.ContainedLoadingIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
||||
import androidx.compose.material3.LoadingIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
@Preview
|
||||
fun FullScreenContainedLoader(modifier: Modifier = Modifier) {
|
||||
Box(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.navigationBarsPadding(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
ContainedLoader()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun FullScreenLoader(modifier: Modifier = Modifier) {
|
||||
Box(
|
||||
@@ -20,15 +34,28 @@ fun FullScreenLoader(modifier: Modifier = Modifier) {
|
||||
.navigationBarsPadding(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
ContainedLoadingIndicator(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
indicatorColor = MaterialTheme.colorScheme.primaryContainer
|
||||
)
|
||||
Loader()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
private fun FullScreenLoaderPreview() {
|
||||
FullScreenLoader()
|
||||
@Preview
|
||||
fun ContainedLoader(modifier: Modifier = Modifier) {
|
||||
ContainedLoadingIndicator(
|
||||
modifier = modifier,
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
indicatorColor = MaterialTheme.colorScheme.primaryContainer
|
||||
)
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
||||
@Composable
|
||||
@Preview
|
||||
fun Loader(modifier: Modifier = Modifier) {
|
||||
LoadingIndicator(
|
||||
modifier = modifier,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
<string name="settings_general_title">Основное</string>
|
||||
<string name="settings_general_contact_names_title">Использовать имена контактов</string>
|
||||
<string name="settings_general_contact_names_summary">Приложение будет использовать доступные имена контактов для пользователей</string>
|
||||
<string name="settings_general_show_attachment_button_summary">Показывать кнопку вложений на панели чата</string>
|
||||
<string name="settings_general_enable_haptic_title">Включить тактильную отдачу</string>
|
||||
<string name="settings_appearance_title">Внешний вид</string>
|
||||
<string name="settings_appearance_multiline_title">Многострочные заголовки и сообщения</string>
|
||||
@@ -272,4 +273,8 @@
|
||||
<string name="regular">Обычный</string>
|
||||
<string name="login_sign_up">Регистрация</string>
|
||||
<string name="login_forgot_password">Забыли пароль?</string>
|
||||
<string name="settings_general_show_attachment_button_title">Показывать кнопку вложений</string>
|
||||
<string name="action_copy_link">Скопировать ссылку</string>
|
||||
<string name="action_copy">Скопировать</string>
|
||||
<string name="action_copy_image">Скопировать изображение</string>
|
||||
</resources>
|
||||
|
||||
@@ -260,6 +260,8 @@
|
||||
<string name="settings_general_contact_names_summary">App will use available contact names for users</string>
|
||||
<string name="settings_general_show_emoji_button_title">Show emoji button</string>
|
||||
<string name="settings_general_show_emoji_button_summary">Show emoji button in chat panel</string>
|
||||
<string name="settings_general_show_attachment_button_title">Show attachment button</string>
|
||||
<string name="settings_general_show_attachment_button_summary">Show attachment button in chat panel</string>
|
||||
<string name="settings_general_enable_haptic_title">Enable haptic</string>
|
||||
<string name="settings_appearance_title">Appearance</string>
|
||||
<string name="settings_appearance_multiline_title">Multiline titles and messages</string>
|
||||
@@ -348,4 +350,8 @@
|
||||
<string name="regular">Regular</string>
|
||||
<string name="login_sign_up">Sign up</string>
|
||||
<string name="login_forgot_password">Forgot password?</string>
|
||||
|
||||
<string name="action_copy_link">Copy link</string>
|
||||
<string name="action_copy">Copy</string>
|
||||
<string name="action_copy_image">Copy image</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user