From baa585357f55937a869ee0273e51bf093d62eb86 Mon Sep 17 00:00:00 2001 From: Diogo Date: Thu, 10 Oct 2024 19:01:31 +0100 Subject: [PATCH] multiplatform: disable chat buttons on user picker when chat is stopped (#5017) * ios: disable chat buttons on user picker when chat is stopped * small change * disable use from desktop on android when chat stopped --- .../ios/Shared/Views/ChatList/UserPicker.swift | 18 ++++++++++++------ .../common/views/chatlist/UserPicker.kt | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/UserPicker.swift b/apps/ios/Shared/Views/ChatList/UserPicker.swift index b7818bfac4..cfcfe851f3 100644 --- a/apps/ios/Shared/Views/ChatList/UserPicker.swift +++ b/apps/ios/Shared/Views/ChatList/UserPicker.swift @@ -33,6 +33,7 @@ struct UserPicker: View { .sorted(using: KeyPathComparator(\.user.activeOrder, order: .reverse)) let sectionWidth = max(frameWidth - sectionHorizontalPadding * 2, 0) let currentUserWidth = max(frameWidth - sectionHorizontalPadding - rowPadding * 2 - 14 - imageSize, 0) + let stopped = m.chatRunning != true VStack(spacing: sectionSpacing) { if let user = m.currentUser { StickyScrollView(resetScroll: $resetScroll) { @@ -46,10 +47,14 @@ struct UserPicker: View { .frame(width: otherUsers.isEmpty ? sectionWidth : currentUserWidth, alignment: .leading) .modifier(ListRow { activeSheet = .currentProfile }) .clipShape(sectionShape) + .disabled(stopped) + .opacity(stopped ? 0.4 : 1) ForEach(otherUsers) { u in userView(u, size: imageSize) .frame(maxWidth: sectionWidth * 0.618) .fixedSize() + .disabled(stopped) + .opacity(stopped ? 0.4 : 1) } } .padding(.horizontal, sectionHorizontalPadding) @@ -60,10 +65,10 @@ struct UserPicker: View { .onPreferenceChange(DetermineWidth.Key.self) { frameWidth = $0 } } VStack(spacing: 0) { - openSheetOnTap("qrcode", title: m.userAddress == nil ? "Create SimpleX address" : "Your SimpleX address", sheet: .address) - openSheetOnTap("switch.2", title: "Chat preferences", sheet: .chatPreferences) - openSheetOnTap("person.crop.rectangle.stack", title: "Your chat profiles", sheet: .chatProfiles) - openSheetOnTap("desktopcomputer", title: "Use from desktop", sheet: .useFromDesktop) + openSheetOnTap("qrcode", title: m.userAddress == nil ? "Create SimpleX address" : "Your SimpleX address", sheet: .address, disabled: stopped) + openSheetOnTap("switch.2", title: "Chat preferences", sheet: .chatPreferences, disabled: stopped) + openSheetOnTap("person.crop.rectangle.stack", title: "Your chat profiles", sheet: .chatProfiles, disabled: stopped) + openSheetOnTap("desktopcomputer", title: "Use from desktop", sheet: .useFromDesktop, disabled: stopped) ZStack(alignment: .trailing) { openSheetOnTap("gearshape", title: "Settings", sheet: .settings, showDivider: false) Image(systemName: colorScheme == .light ? "sun.max" : "moon.fill") @@ -149,15 +154,16 @@ struct UserPicker: View { .clipShape(sectionShape) } - private func openSheetOnTap(_ icon: String, title: LocalizedStringKey, sheet: UserPickerSheet, showDivider: Bool = true) -> some View { + private func openSheetOnTap(_ icon: String, title: LocalizedStringKey, sheet: UserPickerSheet, showDivider: Bool = true, disabled: Bool = false) -> some View { ZStack(alignment: .bottom) { settingsRow(icon, color: theme.colors.secondary) { - Text(title).foregroundColor(.primary) + Text(title).foregroundColor(.primary).opacity(disabled ? 0.4 : 1) } .frame(maxWidth: .infinity, alignment: .leading) .padding(.horizontal, rowPadding) .padding(.vertical, rowVerticalPadding) .modifier(ListRow { activeSheet = sheet }) + .disabled(disabled) if showDivider { Divider().padding(.leading, 52) } 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 8546dc4fb3..4a3bce7752 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 @@ -341,7 +341,8 @@ private fun GlobalSettingsSection( ModalManager.start.showCustomModal { close -> ConnectDesktopView(close) } - } + }, + disabled = stopped ) } else { UserPickerOptionRow(