From dd4b64d56a1f3cd2c1c8530f0a4268e1f8fb604e Mon Sep 17 00:00:00 2001 From: another-simple-pixel Date: Sat, 16 May 2026 13:54:13 -0700 Subject: [PATCH] UserPicker: merge SecondSection + GlobalSettings into one card on portrait Both Android and desktop portrait now show address, preferences, (desktop: inactive-users grid), profiles, link mobile / use from desktop, and settings inside a single SectionView card. Desktop landscape keeps the side-by-side two-card layout. --- .../common/views/chatlist/UserPicker.kt | 146 +++++++++--------- 1 file changed, 70 insertions(+), 76 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt index a67386ecf5..fcf26a1687 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/UserPicker.kt @@ -272,32 +272,24 @@ fun UserPicker( } @Composable - fun SecondSection() { + fun SecondSectionBody() { val inactiveUsers = users.filter { !it.user.activeUser } - val splitForDesktopGrid = appPlatform.isDesktop && inactiveUsers.isNotEmpty() - - SectionView { - UserPickerOptionRow( - painterResource(MR.images.ic_qr_code), - if (chatModel.userAddress.value != null) generalGetString(MR.strings.your_simplex_contact_address) else generalGetString(MR.strings.create_simplex_address), - showCustomModal { it, close -> UserAddressView(it, shareViaProfile = it.currentUser.value!!.addressShared, close = close) }, disabled = stopped - ) - UserPickerOptionRow( - painterResource(MR.images.ic_toggle_on), - stringResource(MR.strings.chat_preferences), - click = if (stopped) null else ({ - showCustomModal { m, close -> - PreferencesView(m, m.currentUser.value ?: return@showCustomModal, close) - }() - }), - disabled = stopped - ) - if (!splitForDesktopGrid) { - ProfilesOptionRow() - } - } - - if (splitForDesktopGrid) { + UserPickerOptionRow( + painterResource(MR.images.ic_qr_code), + if (chatModel.userAddress.value != null) generalGetString(MR.strings.your_simplex_contact_address) else generalGetString(MR.strings.create_simplex_address), + showCustomModal { it, close -> UserAddressView(it, shareViaProfile = it.currentUser.value!!.addressShared, close = close) }, disabled = stopped + ) + UserPickerOptionRow( + painterResource(MR.images.ic_toggle_on), + stringResource(MR.strings.chat_preferences), + click = if (stopped) null else ({ + showCustomModal { m, close -> + PreferencesView(m, m.currentUser.value ?: return@showCustomModal, close) + }() + }), + disabled = stopped + ) + if (appPlatform.isDesktop && inactiveUsers.isNotEmpty()) { Column(modifier = Modifier.padding(vertical = DEFAULT_PADDING_HALF)) { UserPickerUsersSection( users = inactiveUsers, @@ -306,18 +298,20 @@ fun UserPicker( stopped = stopped ) } - SectionView { ProfilesOptionRow() } } + ProfilesOptionRow() } if (appPlatform.isDesktop || windowOrientation() == WindowOrientation.PORTRAIT) { Column { FirstSection() - SecondSection() - GlobalSettingsSection( - userPickerState = userPickerState, - setPerformLA = setPerformLA, - ) + SectionView { + SecondSectionBody() + GlobalSettingsBody( + userPickerState = userPickerState, + setPerformLA = setPerformLA, + ) + } } } else { Column { @@ -325,16 +319,18 @@ fun UserPicker( Row { Box(Modifier.weight(1f)) { Column { - SecondSection() + SectionView { SecondSectionBody() } } } VerticalDivider() Box(Modifier.weight(1f)) { Column { - GlobalSettingsSection( - userPickerState = userPickerState, - setPerformLA = setPerformLA, - ) + SectionView { + GlobalSettingsBody( + userPickerState = userPickerState, + setPerformLA = setPerformLA, + ) + } } } } @@ -353,55 +349,53 @@ fun userPickerAlpha(): Float { } @Composable -private fun GlobalSettingsSection( +private fun GlobalSettingsBody( userPickerState: MutableStateFlow, setPerformLA: (Boolean) -> Unit, ) { val stopped = remember { chatModel.chatRunning }.value == false - SectionView { - if (appPlatform.isAndroid) { - val text = generalGetString(MR.strings.settings_section_title_use_from_desktop).lowercase().capitalize(Locale.current) + if (appPlatform.isAndroid) { + val text = generalGetString(MR.strings.settings_section_title_use_from_desktop).lowercase().capitalize(Locale.current) - UserPickerOptionRow( - painterResource(MR.images.ic_desktop), - text, - click = { - ModalManager.start.showCustomModal { close -> - ConnectDesktopView(close) - } - }, - disabled = stopped - ) - } else { - UserPickerOptionRow( - icon = painterResource(MR.images.ic_smartphone_300), - text = stringResource(if (remember { chat.simplex.common.platform.chatModel.remoteHosts }.isEmpty()) MR.strings.link_a_mobile else MR.strings.linked_mobiles), - click = { - userPickerState.value = AnimatedViewState.HIDING - ModalManager.start.showModal { - ConnectMobileView() - } - }, - disabled = stopped - ) - } - - SectionItemView( + UserPickerOptionRow( + painterResource(MR.images.ic_desktop), + text, click = { - ModalManager.start.showModalCloseable { close -> - SettingsView(chatModel, setPerformLA, close) + ModalManager.start.showCustomModal { close -> + ConnectDesktopView(close) } }, - padding = if (appPlatform.isDesktop) PaddingValues(start = DEFAULT_PADDING * 1.7f, end = DEFAULT_PADDING + 2.dp) else PaddingValues(start = DEFAULT_PADDING, end = DEFAULT_PADDING_HALF) - ) { - val text = generalGetString(MR.strings.settings_section_title_settings).lowercase().capitalize(Locale.current) - Icon(painterResource(MR.images.ic_settings), text, tint = MaterialTheme.colors.secondary) - TextIconSpaced() - Text(text, color = Color.Unspecified) - Spacer(Modifier.weight(1f)) - ColorModeSwitcher() - } + disabled = stopped + ) + } else { + UserPickerOptionRow( + icon = painterResource(MR.images.ic_smartphone_300), + text = stringResource(if (remember { chat.simplex.common.platform.chatModel.remoteHosts }.isEmpty()) MR.strings.link_a_mobile else MR.strings.linked_mobiles), + click = { + userPickerState.value = AnimatedViewState.HIDING + ModalManager.start.showModal { + ConnectMobileView() + } + }, + disabled = stopped + ) + } + + SectionItemView( + click = { + ModalManager.start.showModalCloseable { close -> + SettingsView(chatModel, setPerformLA, close) + } + }, + padding = if (appPlatform.isDesktop) PaddingValues(start = DEFAULT_PADDING * 1.7f, end = DEFAULT_PADDING + 2.dp) else PaddingValues(start = DEFAULT_PADDING, end = DEFAULT_PADDING_HALF) + ) { + val text = generalGetString(MR.strings.settings_section_title_settings).lowercase().capitalize(Locale.current) + Icon(painterResource(MR.images.ic_settings), text, tint = MaterialTheme.colors.secondary) + TextIconSpaced() + Text(text, color = Color.Unspecified) + Spacer(Modifier.weight(1f)) + ColorModeSwitcher() } }