2022-01-31 21:28:07 +00:00
|
|
|
//
|
|
|
|
// SettingsView.swift
|
|
|
|
// SimpleX
|
|
|
|
//
|
|
|
|
// Created by Evgeny Poberezkin on 31/01/2022.
|
|
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2022-11-11 12:30:10 +04:00
|
|
|
import StoreKit
|
2022-05-31 07:55:13 +01:00
|
|
|
import SimpleXChat
|
2022-01-31 21:28:07 +00:00
|
|
|
|
2022-02-11 07:42:00 +00:00
|
|
|
let simplexTeamURL = URL(string: "simplex:/contact#/?v=1&smp=smp%3A%2F%2FPQUV2eL0t7OStZOoAsPEV2QYWt4-xilbakvGUGOItUo%3D%40smp6.simplex.im%2FK1rslx-m5bpXVIdMZg9NLUZ_8JBm8xTt%23MCowBQYDK2VuAyEALDeVe-sG8mRY22LsXlPgiwTNs9dbiLrNuA7f3ZMAJ2w%3D")!
|
|
|
|
|
2022-03-18 09:23:01 +00:00
|
|
|
let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
|
|
|
|
|
|
|
|
let appBuild = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String
|
|
|
|
|
2022-05-28 22:09:46 +04:00
|
|
|
let DEFAULT_SHOW_LA_NOTICE = "showLocalAuthenticationNotice"
|
|
|
|
let DEFAULT_LA_NOTICE_SHOWN = "localAuthenticationNoticeShown"
|
2024-07-31 13:54:47 +01:00
|
|
|
let DEFAULT_PERFORM_LA = "performLocalAuthentication" // deprecated, moved to app group
|
2023-04-12 12:22:55 +02:00
|
|
|
let DEFAULT_LA_MODE = "localAuthenticationMode"
|
|
|
|
let DEFAULT_LA_LOCK_DELAY = "localAuthenticationLockDelay"
|
2023-05-09 10:33:30 +02:00
|
|
|
let DEFAULT_LA_SELF_DESTRUCT = "localAuthenticationSelfDestruct"
|
|
|
|
let DEFAULT_LA_SELF_DESTRUCT_DISPLAY_NAME = "localAuthenticationSelfDestructDisplayName"
|
2022-11-25 21:43:10 +00:00
|
|
|
let DEFAULT_NOTIFICATION_ALERT_SHOWN = "notificationAlertShown"
|
2022-05-27 16:36:33 +01:00
|
|
|
let DEFAULT_WEBRTC_POLICY_RELAY = "webrtcPolicyRelay"
|
2022-09-21 10:19:13 +01:00
|
|
|
let DEFAULT_WEBRTC_ICE_SERVERS = "webrtcICEServers"
|
2023-03-14 11:12:40 +03:00
|
|
|
let DEFAULT_CALL_KIT_CALLS_IN_RECENTS = "callKitCallsInRecents"
|
2024-03-11 21:17:28 +07:00
|
|
|
let DEFAULT_PRIVACY_ACCEPT_IMAGES = "privacyAcceptImages" // unused. Use GROUP_DEFAULT_PRIVACY_ACCEPT_IMAGES instead
|
2024-07-31 13:54:47 +01:00
|
|
|
let DEFAULT_PRIVACY_LINK_PREVIEWS = "privacyLinkPreviews" // deprecated, moved to app group
|
2022-11-24 17:14:56 +00:00
|
|
|
let DEFAULT_PRIVACY_SIMPLEX_LINK_MODE = "privacySimplexLinkMode"
|
2023-08-17 15:04:17 +04:00
|
|
|
let DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS = "privacyShowChatPreviews"
|
|
|
|
let DEFAULT_PRIVACY_SAVE_LAST_DRAFT = "privacySaveLastDraft"
|
2022-11-25 14:31:37 +00:00
|
|
|
let DEFAULT_PRIVACY_PROTECT_SCREEN = "privacyProtectScreen"
|
2023-07-13 23:48:25 +01:00
|
|
|
let DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET = "privacyDeliveryReceiptsSet"
|
2024-07-26 14:38:22 +07:00
|
|
|
let DEFAULT_PRIVACY_MEDIA_BLUR_RADIUS = "privacyMediaBlurRadius"
|
2022-05-30 12:32:11 +01:00
|
|
|
let DEFAULT_EXPERIMENTAL_CALLS = "experimentalCalls"
|
2022-06-24 13:52:20 +01:00
|
|
|
let DEFAULT_CHAT_ARCHIVE_NAME = "chatArchiveName"
|
|
|
|
let DEFAULT_CHAT_ARCHIVE_TIME = "chatArchiveTime"
|
|
|
|
let DEFAULT_CHAT_V3_DB_MIGRATION = "chatV3DBMigration"
|
2022-08-02 17:00:12 +04:00
|
|
|
let DEFAULT_DEVELOPER_TOOLS = "developerTools"
|
2022-09-17 16:41:20 +04:00
|
|
|
let DEFAULT_ENCRYPTION_STARTED = "encryptionStarted"
|
|
|
|
let DEFAULT_ENCRYPTION_STARTED_AT = "encryptionStartedAt"
|
2024-07-03 22:42:13 +01:00
|
|
|
let DEFAULT_ACCENT_COLOR_RED = "accentColorRed" // deprecated, only used for migration
|
|
|
|
let DEFAULT_ACCENT_COLOR_GREEN = "accentColorGreen" // deprecated, only used for migration
|
|
|
|
let DEFAULT_ACCENT_COLOR_BLUE = "accentColorBlue" // deprecated, only used for migration
|
|
|
|
let DEFAULT_USER_INTERFACE_STYLE = "userInterfaceStyle" // deprecated, only used for migration
|
2024-04-24 21:20:26 +01:00
|
|
|
let DEFAULT_PROFILE_IMAGE_CORNER_RADIUS = "profileImageCornerRadius"
|
2022-09-22 08:36:39 +01:00
|
|
|
let DEFAULT_CONNECT_VIA_LINK_TAB = "connectViaLinkTab"
|
2022-12-17 14:02:07 +00:00
|
|
|
let DEFAULT_LIVE_MESSAGE_ALERT_SHOWN = "liveMessageAlertShown"
|
2023-03-22 15:58:01 +00:00
|
|
|
let DEFAULT_SHOW_HIDDEN_PROFILES_NOTICE = "showHiddenProfilesNotice"
|
|
|
|
let DEFAULT_SHOW_MUTE_PROFILE_ALERT = "showMuteProfileAlert"
|
2022-12-26 14:08:01 +00:00
|
|
|
let DEFAULT_WHATS_NEW_VERSION = "defaultWhatsNewVersion"
|
2023-05-05 12:56:48 +04:00
|
|
|
let DEFAULT_ONBOARDING_STAGE = "onboardingStage"
|
2024-03-12 23:25:06 +07:00
|
|
|
let DEFAULT_MIGRATION_TO_STAGE = "migrationToStage"
|
|
|
|
let DEFAULT_MIGRATION_FROM_STAGE = "migrationFromStage"
|
2023-05-15 16:07:55 +04:00
|
|
|
let DEFAULT_CUSTOM_DISAPPEARING_MESSAGE_TIME = "customDisappearingMessageTime"
|
2023-06-19 11:13:30 +01:00
|
|
|
let DEFAULT_SHOW_UNREAD_AND_FAVORITES = "showUnreadAndFavorites"
|
2023-11-16 16:53:44 +00:00
|
|
|
let DEFAULT_DEVICE_NAME_FOR_REMOTE_ACCESS = "deviceNameForRemoteAccess"
|
|
|
|
let DEFAULT_CONFIRM_REMOTE_SESSIONS = "confirmRemoteSessions"
|
|
|
|
let DEFAULT_CONNECT_REMOTE_VIA_MULTICAST = "connectRemoteViaMulticast"
|
2023-11-23 21:22:29 +00:00
|
|
|
let DEFAULT_CONNECT_REMOTE_VIA_MULTICAST_AUTO = "connectRemoteViaMulticastAuto"
|
2024-05-15 16:09:42 +04:00
|
|
|
let DEFAULT_SHOW_SENT_VIA_RPOXY = "showSentViaProxy"
|
2024-07-03 16:59:46 +04:00
|
|
|
let DEFAULT_SHOW_SUBSCRIPTION_PERCENTAGE = "showSubscriptionPercentage"
|
2022-05-27 16:36:33 +01:00
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
let DEFAULT_CURRENT_THEME = "currentTheme"
|
|
|
|
let DEFAULT_SYSTEM_DARK_THEME = "systemDarkTheme"
|
|
|
|
let DEFAULT_CURRENT_THEME_IDS = "currentThemeIds"
|
|
|
|
let DEFAULT_THEME_OVERRIDES = "themeOverrides"
|
|
|
|
|
2024-03-11 21:17:28 +07:00
|
|
|
let ANDROID_DEFAULT_CALL_ON_LOCK_SCREEN = "androidCallOnLockScreen"
|
|
|
|
|
2022-05-30 09:05:02 +01:00
|
|
|
let appDefaults: [String: Any] = [
|
2022-05-28 22:09:46 +04:00
|
|
|
DEFAULT_SHOW_LA_NOTICE: false,
|
|
|
|
DEFAULT_LA_NOTICE_SHOWN: false,
|
2022-05-28 14:58:52 +04:00
|
|
|
DEFAULT_PERFORM_LA: false,
|
2023-04-12 12:22:55 +02:00
|
|
|
DEFAULT_LA_MODE: LAMode.system.rawValue,
|
|
|
|
DEFAULT_LA_LOCK_DELAY: 30,
|
2023-05-09 10:33:30 +02:00
|
|
|
DEFAULT_LA_SELF_DESTRUCT: false,
|
2022-11-25 21:43:10 +00:00
|
|
|
DEFAULT_NOTIFICATION_ALERT_SHOWN: false,
|
2022-05-30 08:59:04 +01:00
|
|
|
DEFAULT_WEBRTC_POLICY_RELAY: true,
|
2023-03-14 11:12:40 +03:00
|
|
|
DEFAULT_CALL_KIT_CALLS_IN_RECENTS: false,
|
2022-05-30 08:59:04 +01:00
|
|
|
DEFAULT_PRIVACY_ACCEPT_IMAGES: true,
|
2022-05-30 12:32:11 +01:00
|
|
|
DEFAULT_PRIVACY_LINK_PREVIEWS: true,
|
2023-04-12 12:22:55 +02:00
|
|
|
DEFAULT_PRIVACY_SIMPLEX_LINK_MODE: SimpleXLinkMode.description.rawValue,
|
2023-08-17 15:04:17 +04:00
|
|
|
DEFAULT_PRIVACY_SHOW_CHAT_PREVIEWS: true,
|
|
|
|
DEFAULT_PRIVACY_SAVE_LAST_DRAFT: true,
|
2022-12-24 15:41:31 +00:00
|
|
|
DEFAULT_PRIVACY_PROTECT_SCREEN: false,
|
2023-07-13 23:48:25 +01:00
|
|
|
DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET: false,
|
2024-07-26 14:38:22 +07:00
|
|
|
DEFAULT_PRIVACY_MEDIA_BLUR_RADIUS: 0,
|
2022-06-24 13:52:20 +01:00
|
|
|
DEFAULT_EXPERIMENTAL_CALLS: false,
|
2023-04-12 12:22:55 +02:00
|
|
|
DEFAULT_CHAT_V3_DB_MIGRATION: V3DBMigrationState.offer.rawValue,
|
2022-08-20 21:55:06 +01:00
|
|
|
DEFAULT_DEVELOPER_TOOLS: false,
|
2022-09-17 16:41:20 +04:00
|
|
|
DEFAULT_ENCRYPTION_STARTED: false,
|
2024-04-24 21:20:26 +01:00
|
|
|
DEFAULT_PROFILE_IMAGE_CORNER_RADIUS: defaultProfileImageCorner,
|
2023-04-12 12:22:55 +02:00
|
|
|
DEFAULT_CONNECT_VIA_LINK_TAB: ConnectViaLinkTab.scan.rawValue,
|
2023-03-22 15:58:01 +00:00
|
|
|
DEFAULT_LIVE_MESSAGE_ALERT_SHOWN: false,
|
|
|
|
DEFAULT_SHOW_HIDDEN_PROFILES_NOTICE: true,
|
|
|
|
DEFAULT_SHOW_MUTE_PROFILE_ALERT: true,
|
2023-05-05 12:56:48 +04:00
|
|
|
DEFAULT_ONBOARDING_STAGE: OnboardingStage.onboardingComplete.rawValue,
|
2023-05-15 16:07:55 +04:00
|
|
|
DEFAULT_CUSTOM_DISAPPEARING_MESSAGE_TIME: 300,
|
2023-11-16 16:53:44 +00:00
|
|
|
DEFAULT_SHOW_UNREAD_AND_FAVORITES: false,
|
|
|
|
DEFAULT_CONFIRM_REMOTE_SESSIONS: false,
|
2023-11-23 21:22:29 +00:00
|
|
|
DEFAULT_CONNECT_REMOTE_VIA_MULTICAST: true,
|
|
|
|
DEFAULT_CONNECT_REMOTE_VIA_MULTICAST_AUTO: true,
|
2024-05-15 16:09:42 +04:00
|
|
|
DEFAULT_SHOW_SENT_VIA_RPOXY: false,
|
2024-07-03 16:59:46 +04:00
|
|
|
DEFAULT_SHOW_SUBSCRIPTION_PERCENTAGE: false,
|
2024-07-03 22:42:13 +01:00
|
|
|
ANDROID_DEFAULT_CALL_ON_LOCK_SCREEN: AppSettingsLockScreenCalls.show.rawValue,
|
|
|
|
|
|
|
|
DEFAULT_THEME_OVERRIDES: "{}",
|
|
|
|
DEFAULT_CURRENT_THEME: DefaultTheme.SYSTEM_THEME_NAME,
|
|
|
|
DEFAULT_SYSTEM_DARK_THEME: DefaultTheme.DARK.themeName,
|
|
|
|
DEFAULT_CURRENT_THEME_IDS: "{}"
|
2022-05-27 16:36:33 +01:00
|
|
|
]
|
2022-05-07 16:10:57 +01:00
|
|
|
|
ios: rework UX of creating new connection (#3482)
* ios: connection UI (wip)
* custom search
* rework invite
* connect paste link ui
* scan rework, process errors, other fixes
* scan layout
* clear link on cancel
* improved search
* further improve search
* animation
* connect on paste in search
* layout
* layout
* layout
* layout, add conn
* delete unused invitation, create used invitation chat
* remove old views
* regular paste button
* new chat menu
* previews
* increase spacing
* animation, fix alerts
* swipe
* change text
* less sensitive gesture
* layout
* search cancel button transition
* slow down chat list animation (uses deprecated modifiers)
* icons
* update code scanner, layout
* manage camera permissions
* ask to delete unused invitation
* comment
* remove onDismiss
* don't filter chats on link in search, allow to paste text with link
* cleanup link after connection
* filter chat by link
* revert change
* show link descr
* disabled search
* underline
* filter own group
* simplify
* no animation
* add delay, move createInvitation
* update library
* possible fix for ios 15
* add explicit frame to qr code
* update library
* Revert "add explicit frame to qr code"
This reverts commit 95c7d31e47b3da39b5985cd57638885c45b77de1.
* remove comment
* fix pasteboardHasURLs, disable paste button based on it
* align help texts with changed button names
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
* update library
* Revert "fix pasteboardHasURLs, disable paste button based on it"
This reverts commit 46f63572e90dbf460faab9ce694181209712bd00.
* remove unused var
* restore disabled
* export localizations
---------
Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
Co-authored-by: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com>
2023-12-29 16:29:49 +04:00
|
|
|
// not used anymore
|
|
|
|
enum ConnectViaLinkTab: String {
|
|
|
|
case scan
|
|
|
|
case paste
|
|
|
|
}
|
|
|
|
|
2022-11-24 17:14:56 +00:00
|
|
|
enum SimpleXLinkMode: String, Identifiable {
|
|
|
|
case description
|
|
|
|
case full
|
|
|
|
case browser
|
|
|
|
|
2023-10-17 12:56:12 +04:00
|
|
|
static var values: [SimpleXLinkMode] = [.description, .full]
|
2022-11-24 17:14:56 +00:00
|
|
|
|
|
|
|
public var id: Self { self }
|
|
|
|
|
|
|
|
var text: LocalizedStringKey {
|
|
|
|
switch self {
|
|
|
|
case .description: return "Description"
|
|
|
|
case .full: return "Full link"
|
|
|
|
case .browser: return "Via browser"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-09 09:52:09 +01:00
|
|
|
private var indent: CGFloat = 36
|
|
|
|
|
2022-06-24 13:52:20 +01:00
|
|
|
let chatArchiveTimeDefault = DateDefault(defaults: UserDefaults.standard, forKey: DEFAULT_CHAT_ARCHIVE_TIME)
|
|
|
|
|
2022-09-17 16:41:20 +04:00
|
|
|
let encryptionStartedDefault = BoolDefault(defaults: UserDefaults.standard, forKey: DEFAULT_ENCRYPTION_STARTED)
|
|
|
|
|
|
|
|
let encryptionStartedAtDefault = DateDefault(defaults: UserDefaults.standard, forKey: DEFAULT_ENCRYPTION_STARTED_AT)
|
|
|
|
|
2022-09-22 08:36:39 +01:00
|
|
|
let connectViaLinkTabDefault = EnumDefault<ConnectViaLinkTab>(defaults: UserDefaults.standard, forKey: DEFAULT_CONNECT_VIA_LINK_TAB, withDefault: .scan)
|
|
|
|
|
2022-11-24 17:14:56 +00:00
|
|
|
let privacySimplexLinkModeDefault = EnumDefault<SimpleXLinkMode>(defaults: UserDefaults.standard, forKey: DEFAULT_PRIVACY_SIMPLEX_LINK_MODE, withDefault: .description)
|
|
|
|
|
2023-04-12 12:22:55 +02:00
|
|
|
let privacyLocalAuthModeDefault = EnumDefault<LAMode>(defaults: UserDefaults.standard, forKey: DEFAULT_LA_MODE, withDefault: .system)
|
|
|
|
|
2023-07-13 23:48:25 +01:00
|
|
|
let privacyDeliveryReceiptsSet = BoolDefault(defaults: UserDefaults.standard, forKey: DEFAULT_PRIVACY_DELIVERY_RECEIPTS_SET)
|
|
|
|
|
2023-05-05 12:56:48 +04:00
|
|
|
let onboardingStageDefault = EnumDefault<OnboardingStage>(defaults: UserDefaults.standard, forKey: DEFAULT_ONBOARDING_STAGE, withDefault: .onboardingComplete)
|
|
|
|
|
2023-05-15 16:07:55 +04:00
|
|
|
let customDisappearingMessageTimeDefault = IntDefault(defaults: UserDefaults.standard, forKey: DEFAULT_CUSTOM_DISAPPEARING_MESSAGE_TIME)
|
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
let currentThemeDefault = StringDefault(defaults: UserDefaults.standard, forKey: DEFAULT_CURRENT_THEME, withDefault: DefaultTheme.SYSTEM_THEME_NAME)
|
|
|
|
let systemDarkThemeDefault = StringDefault(defaults: UserDefaults.standard, forKey: DEFAULT_SYSTEM_DARK_THEME, withDefault: DefaultTheme.DARK.themeName)
|
|
|
|
let currentThemeIdsDefault = CodableDefault<[String: String]>(defaults: UserDefaults.standard, forKey: DEFAULT_CURRENT_THEME_IDS, withDefault: [:] )
|
|
|
|
let themeOverridesDefault: CodableDefault<[ThemeOverrides]> = CodableDefault(defaults: UserDefaults.standard, forKey: DEFAULT_THEME_OVERRIDES, withDefault: [])
|
|
|
|
|
2022-07-10 14:28:00 +01:00
|
|
|
func setGroupDefaults() {
|
|
|
|
privacyAcceptImagesGroupDefault.set(UserDefaults.standard.bool(forKey: DEFAULT_PRIVACY_ACCEPT_IMAGES))
|
2024-07-31 13:54:47 +01:00
|
|
|
performLAGroupDefault.set(UserDefaults.standard.bool(forKey: DEFAULT_PERFORM_LA))
|
|
|
|
privacyLinkPreviewsGroupDefault.set(UserDefaults.standard.bool(forKey: DEFAULT_PRIVACY_LINK_PREVIEWS))
|
|
|
|
profileImageCornerRadiusGroupDefault.set(UserDefaults.standard.double(forKey: DEFAULT_PROFILE_IMAGE_CORNER_RADIUS))
|
2022-07-10 14:28:00 +01:00
|
|
|
}
|
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
public class StringDefault {
|
|
|
|
var defaults: UserDefaults
|
|
|
|
var key: String
|
|
|
|
var defaultValue: String
|
|
|
|
|
|
|
|
public init(defaults: UserDefaults = UserDefaults.standard, forKey: String, withDefault: String) {
|
|
|
|
self.defaults = defaults
|
|
|
|
self.key = forKey
|
|
|
|
self.defaultValue = withDefault
|
|
|
|
}
|
|
|
|
|
|
|
|
public func get() -> String {
|
|
|
|
defaults.string(forKey: key) ?? defaultValue
|
|
|
|
}
|
|
|
|
|
|
|
|
public func set(_ value: String) {
|
|
|
|
defaults.set(value, forKey: key)
|
|
|
|
defaults.synchronize()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CodableDefault<T: Codable> {
|
|
|
|
var defaults: UserDefaults
|
|
|
|
var key: String
|
|
|
|
var defaultValue: T
|
|
|
|
|
|
|
|
public init(defaults: UserDefaults = UserDefaults.standard, forKey: String, withDefault: T) {
|
|
|
|
self.defaults = defaults
|
|
|
|
self.key = forKey
|
|
|
|
self.defaultValue = withDefault
|
|
|
|
}
|
|
|
|
|
|
|
|
var cache: T? = nil
|
|
|
|
|
|
|
|
public func get() -> T {
|
|
|
|
if let cache {
|
|
|
|
return cache
|
|
|
|
} else if let value = defaults.string(forKey: key) {
|
|
|
|
let res = decodeJSON(value) ?? defaultValue
|
|
|
|
cache = res
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
return defaultValue
|
|
|
|
}
|
|
|
|
|
|
|
|
public func set(_ value: T) {
|
|
|
|
defaults.set(encodeJSON(value), forKey: key)
|
|
|
|
cache = value
|
|
|
|
//defaults.synchronize()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-31 21:28:07 +00:00
|
|
|
struct SettingsView: View {
|
2022-02-12 15:59:43 +00:00
|
|
|
@Environment(\.colorScheme) var colorScheme
|
2022-01-31 21:28:07 +00:00
|
|
|
@EnvironmentObject var chatModel: ChatModel
|
2022-11-11 12:30:10 +04:00
|
|
|
@EnvironmentObject var sceneDelegate: SceneDelegate
|
2024-07-03 22:42:13 +01:00
|
|
|
@EnvironmentObject var theme: AppTheme
|
2022-02-11 07:42:00 +00:00
|
|
|
@Binding var showSettings: Bool
|
2024-03-11 21:17:28 +07:00
|
|
|
@State private var showProgress: Bool = false
|
2022-01-31 21:28:07 +00:00
|
|
|
|
|
|
|
var body: some View {
|
2023-04-12 12:22:55 +02:00
|
|
|
ZStack {
|
|
|
|
settingsView()
|
2024-03-11 21:17:28 +07:00
|
|
|
if showProgress {
|
|
|
|
progressView()
|
|
|
|
}
|
2023-04-12 12:22:55 +02:00
|
|
|
if let la = chatModel.laRequest {
|
|
|
|
LocalAuthView(authRequest: la)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-02-03 07:16:29 +00:00
|
|
|
|
2023-04-12 12:22:55 +02:00
|
|
|
@ViewBuilder func settingsView() -> some View {
|
2024-01-19 22:52:13 +07:00
|
|
|
let user = chatModel.currentUser
|
2022-06-24 13:52:20 +01:00
|
|
|
NavigationView {
|
2022-02-03 07:16:29 +00:00
|
|
|
List {
|
2024-07-03 22:42:13 +01:00
|
|
|
Section(header: Text("You").foregroundColor(theme.colors.secondary)) {
|
2024-01-19 22:52:13 +07:00
|
|
|
if let user = user {
|
|
|
|
NavigationLink {
|
|
|
|
UserProfile()
|
|
|
|
.navigationTitle("Your current profile")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground())
|
2024-01-19 22:52:13 +07:00
|
|
|
} label: {
|
|
|
|
ProfilePreview(profileOf: user)
|
|
|
|
.padding(.leading, -8)
|
|
|
|
}
|
2022-02-03 07:16:29 +00:00
|
|
|
}
|
2022-06-24 13:52:20 +01:00
|
|
|
|
2023-01-20 12:38:38 +00:00
|
|
|
NavigationLink {
|
2024-01-19 22:52:13 +07:00
|
|
|
UserProfilesView(showSettings: $showSettings)
|
2023-01-20 12:38:38 +00:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("person.crop.rectangle.stack", color: theme.colors.secondary) { Text("Your chat profiles") }
|
2023-01-20 12:38:38 +00:00
|
|
|
}
|
|
|
|
|
2022-06-24 13:52:20 +01:00
|
|
|
|
2024-01-19 22:52:13 +07:00
|
|
|
if let user = user {
|
|
|
|
NavigationLink {
|
|
|
|
UserAddressView(shareViaProfile: user.addressShared)
|
|
|
|
.navigationTitle("SimpleX address")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2024-01-19 22:52:13 +07:00
|
|
|
.navigationBarTitleDisplayMode(.large)
|
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("qrcode", color: theme.colors.secondary) { Text("Your SimpleX address") }
|
2024-01-19 22:52:13 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
NavigationLink {
|
|
|
|
PreferencesView(profile: user.profile, preferences: user.fullPreferences, currentPreferences: user.fullPreferences)
|
|
|
|
.navigationTitle("Your preferences")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2024-01-19 22:52:13 +07:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("switch.2", color: theme.colors.secondary) { Text("Chat preferences") }
|
2024-01-19 22:52:13 +07:00
|
|
|
}
|
2022-06-24 13:52:20 +01:00
|
|
|
}
|
2023-11-16 16:53:44 +00:00
|
|
|
|
|
|
|
NavigationLink {
|
|
|
|
ConnectDesktopView(viaSettings: true)
|
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("desktopcomputer", color: theme.colors.secondary) { Text("Use from desktop") }
|
2023-11-16 16:53:44 +00:00
|
|
|
}
|
2024-03-11 21:17:28 +07:00
|
|
|
|
|
|
|
NavigationLink {
|
2024-03-12 23:25:06 +07:00
|
|
|
MigrateFromDevice(showSettings: $showSettings, showProgressOnSettings: $showProgress)
|
2024-03-11 21:17:28 +07:00
|
|
|
.navigationTitle("Migrate device")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2024-03-11 21:17:28 +07:00
|
|
|
.navigationBarTitleDisplayMode(.large)
|
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("tray.and.arrow.up", color: theme.colors.secondary) { Text("Migrate to another device") }
|
2024-03-11 21:17:28 +07:00
|
|
|
}
|
2022-02-03 07:16:29 +00:00
|
|
|
}
|
2022-11-17 06:57:27 +00:00
|
|
|
.disabled(chatModel.chatRunning != true)
|
2024-03-11 21:17:28 +07:00
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
Section(header: Text("Settings").foregroundColor(theme.colors.secondary)) {
|
2022-06-27 10:28:30 +01:00
|
|
|
NavigationLink {
|
|
|
|
NotificationsView()
|
|
|
|
.navigationTitle("Notifications")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2022-06-27 10:28:30 +01:00
|
|
|
} label: {
|
|
|
|
HStack {
|
|
|
|
notificationsIcon()
|
|
|
|
Text("Notifications")
|
|
|
|
}
|
|
|
|
}
|
2022-11-17 06:57:27 +00:00
|
|
|
.disabled(chatModel.chatRunning != true)
|
|
|
|
|
|
|
|
NavigationLink {
|
|
|
|
NetworkAndServers()
|
|
|
|
.navigationTitle("Network & servers")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2022-11-17 06:57:27 +00:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("externaldrive.connected.to.line.below", color: theme.colors.secondary) { Text("Network & servers") }
|
2022-11-17 06:57:27 +00:00
|
|
|
}
|
|
|
|
.disabled(chatModel.chatRunning != true)
|
|
|
|
|
2022-07-05 15:24:51 +04:00
|
|
|
NavigationLink {
|
|
|
|
CallSettings()
|
|
|
|
.navigationTitle("Your calls")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2022-07-05 15:24:51 +04:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("video", color: theme.colors.secondary) { Text("Audio & video calls") }
|
2022-05-29 08:06:56 +01:00
|
|
|
}
|
2022-11-17 06:57:27 +00:00
|
|
|
.disabled(chatModel.chatRunning != true)
|
|
|
|
|
2022-05-30 08:59:04 +01:00
|
|
|
NavigationLink {
|
|
|
|
PrivacySettings()
|
|
|
|
.navigationTitle("Your privacy")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2022-05-30 08:59:04 +01:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("lock", color: theme.colors.secondary) { Text("Privacy & security") }
|
2022-05-28 14:58:52 +04:00
|
|
|
}
|
2022-11-17 06:57:27 +00:00
|
|
|
.disabled(chatModel.chatRunning != true)
|
|
|
|
|
2022-08-03 17:46:05 +01:00
|
|
|
if UIApplication.shared.supportsAlternateIcons {
|
|
|
|
NavigationLink {
|
|
|
|
AppearanceSettings()
|
|
|
|
.navigationTitle("Appearance")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2022-08-03 17:46:05 +01:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("sun.max", color: theme.colors.secondary) { Text("Appearance") }
|
2022-08-03 17:46:05 +01:00
|
|
|
}
|
2022-11-17 06:57:27 +00:00
|
|
|
.disabled(chatModel.chatRunning != true)
|
2022-08-03 17:46:05 +01:00
|
|
|
}
|
2022-11-17 06:57:27 +00:00
|
|
|
|
|
|
|
chatDatabaseRow()
|
2022-03-10 15:45:40 +04:00
|
|
|
}
|
2022-02-03 07:16:29 +00:00
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
Section(header: Text("Help").foregroundColor(theme.colors.secondary)) {
|
2024-01-19 22:52:13 +07:00
|
|
|
if let user = user {
|
|
|
|
NavigationLink {
|
|
|
|
ChatHelp(showSettings: $showSettings)
|
|
|
|
.navigationTitle("Welcome \(user.displayName)!")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground())
|
2024-01-19 22:52:13 +07:00
|
|
|
.frame(maxHeight: .infinity, alignment: .top)
|
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("questionmark", color: theme.colors.secondary) { Text("How to use it") }
|
2024-01-19 22:52:13 +07:00
|
|
|
}
|
2022-05-09 09:52:09 +01:00
|
|
|
}
|
|
|
|
NavigationLink {
|
2022-12-26 14:08:01 +00:00
|
|
|
WhatsNewView(viaSettings: true)
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground())
|
2022-12-26 14:08:01 +00:00
|
|
|
.navigationBarTitleDisplayMode(.inline)
|
2022-05-09 09:52:09 +01:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("plus", color: theme.colors.secondary) { Text("What's new") }
|
2022-02-11 07:42:00 +00:00
|
|
|
}
|
2022-02-25 07:16:19 +00:00
|
|
|
NavigationLink {
|
2022-12-26 14:08:01 +00:00
|
|
|
SimpleXInfo(onboarding: false)
|
|
|
|
.navigationBarTitle("", displayMode: .inline)
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground())
|
2022-02-25 07:16:19 +00:00
|
|
|
.frame(maxHeight: .infinity, alignment: .top)
|
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("info", color: theme.colors.secondary) { Text("About SimpleX Chat") }
|
2022-02-25 07:16:19 +00:00
|
|
|
}
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("number", color: theme.colors.secondary) {
|
2022-11-11 12:30:10 +04:00
|
|
|
Button("Send questions and ideas") {
|
2022-02-11 07:42:00 +00:00
|
|
|
showSettings = false
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
UIApplication.shared.open(simplexTeamURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-06-24 13:52:20 +01:00
|
|
|
.disabled(chatModel.chatRunning != true)
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("envelope", color: theme.colors.secondary) { Text("[Send us email](mailto:chat@simplex.chat)") }
|
2022-02-11 07:42:00 +00:00
|
|
|
}
|
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
Section(header: Text("Support SimpleX Chat").foregroundColor(theme.colors.secondary)) {
|
|
|
|
settingsRow("keyboard", color: theme.colors.secondary) { Text("[Contribute](https://github.com/simplex-chat/simplex-chat#contribute)") }
|
|
|
|
settingsRow("star", color: theme.colors.secondary) {
|
2022-11-11 12:30:10 +04:00
|
|
|
Button("Rate the app") {
|
|
|
|
if let scene = sceneDelegate.windowScene {
|
|
|
|
SKStoreReviewController.requestReview(in: scene)
|
|
|
|
}
|
|
|
|
}
|
2022-08-02 17:00:12 +04:00
|
|
|
}
|
2022-05-09 09:52:09 +01:00
|
|
|
ZStack(alignment: .leading) {
|
2022-02-12 15:59:43 +00:00
|
|
|
Image(colorScheme == .dark ? "github_light" : "github")
|
2022-02-11 07:42:00 +00:00
|
|
|
.resizable()
|
|
|
|
.frame(width: 24, height: 24)
|
2022-05-28 09:06:38 +01:00
|
|
|
.opacity(0.5)
|
2024-07-03 22:42:13 +01:00
|
|
|
.colorMultiply(theme.colors.secondary)
|
2022-11-11 12:30:10 +04:00
|
|
|
Text("[Star on GitHub](https://github.com/simplex-chat/simplex-chat)")
|
2022-05-09 09:52:09 +01:00
|
|
|
.padding(.leading, indent)
|
2022-02-04 16:31:08 +00:00
|
|
|
}
|
2022-11-11 12:30:10 +04:00
|
|
|
}
|
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
Section(header: Text("Develop").foregroundColor(theme.colors.secondary)) {
|
2023-03-27 18:34:48 +01:00
|
|
|
NavigationLink {
|
|
|
|
DeveloperView()
|
|
|
|
.navigationTitle("Developer tools")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2023-03-27 18:34:48 +01:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
settingsRow("chevron.left.forwardslash.chevron.right", color: theme.colors.secondary) { Text("Developer tools") }
|
2022-11-11 12:30:10 +04:00
|
|
|
}
|
2023-01-22 18:34:01 +00:00
|
|
|
NavigationLink {
|
|
|
|
VersionView()
|
|
|
|
.navigationBarTitle("App version")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground())
|
2023-01-22 18:34:01 +00:00
|
|
|
} label: {
|
|
|
|
Text("v\(appVersion ?? "?") (\(appBuild ?? "?"))")
|
|
|
|
}
|
2022-02-04 16:31:08 +00:00
|
|
|
}
|
2022-02-03 07:16:29 +00:00
|
|
|
}
|
2022-02-04 16:31:08 +00:00
|
|
|
.navigationTitle("Your settings")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2022-05-09 09:52:09 +01:00
|
|
|
}
|
2023-08-17 18:21:05 +01:00
|
|
|
.onDisappear {
|
|
|
|
chatModel.showingTerminal = false
|
|
|
|
chatModel.terminalItems = []
|
|
|
|
}
|
2022-08-23 18:18:12 +04:00
|
|
|
}
|
2022-11-17 06:57:27 +00:00
|
|
|
|
|
|
|
private func chatDatabaseRow() -> some View {
|
|
|
|
NavigationLink {
|
|
|
|
DatabaseView(showSettings: $showSettings, chatItemTTL: chatModel.chatItemTTL)
|
|
|
|
.navigationTitle("Your chat database")
|
2024-07-03 22:42:13 +01:00
|
|
|
.modifier(ThemedBackground(grouped: true))
|
2022-11-17 06:57:27 +00:00
|
|
|
} label: {
|
2024-07-03 22:42:13 +01:00
|
|
|
let color: Color = chatModel.chatDbEncrypted == false ? .orange : theme.colors.secondary
|
2022-11-17 06:57:27 +00:00
|
|
|
settingsRow("internaldrive", color: color) {
|
|
|
|
HStack {
|
|
|
|
Text("Database passphrase & export")
|
|
|
|
Spacer()
|
|
|
|
if chatModel.chatRunning == false {
|
|
|
|
Image(systemName: "exclamationmark.octagon.fill").foregroundColor(.red)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-23 18:18:12 +04:00
|
|
|
|
2024-03-11 21:17:28 +07:00
|
|
|
private func progressView() -> some View {
|
|
|
|
VStack {
|
|
|
|
ProgressView().scaleEffect(2)
|
|
|
|
}
|
|
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity )
|
|
|
|
}
|
|
|
|
|
2022-08-23 18:18:12 +04:00
|
|
|
private enum NotificationAlert {
|
2022-04-22 13:46:05 +01:00
|
|
|
case enable
|
|
|
|
case error(LocalizedStringKey, String)
|
|
|
|
}
|
|
|
|
|
2022-04-23 06:32:16 +01:00
|
|
|
private func notificationsIcon() -> some View {
|
|
|
|
let icon: String
|
|
|
|
let color: Color
|
|
|
|
switch (chatModel.tokenStatus) {
|
|
|
|
case .new:
|
|
|
|
icon = "bolt"
|
2024-07-03 22:42:13 +01:00
|
|
|
color = theme.colors.secondary
|
2022-04-23 06:32:16 +01:00
|
|
|
case .registered:
|
|
|
|
icon = "bolt.fill"
|
2024-07-03 22:42:13 +01:00
|
|
|
color = theme.colors.secondary
|
2022-04-23 06:32:16 +01:00
|
|
|
case .invalid:
|
|
|
|
icon = "bolt.slash"
|
2024-07-03 22:42:13 +01:00
|
|
|
color = theme.colors.secondary
|
2022-04-23 06:32:16 +01:00
|
|
|
case .confirmed:
|
|
|
|
icon = "bolt.fill"
|
|
|
|
color = .yellow
|
|
|
|
case .active:
|
|
|
|
icon = "bolt.fill"
|
|
|
|
color = .green
|
|
|
|
case .expired:
|
|
|
|
icon = "bolt.slash.fill"
|
2024-07-03 22:42:13 +01:00
|
|
|
color = theme.colors.secondary
|
2022-07-01 09:49:30 +01:00
|
|
|
case .none:
|
|
|
|
icon = "bolt"
|
2024-07-03 22:42:13 +01:00
|
|
|
color = theme.colors.secondary
|
2022-04-23 06:32:16 +01:00
|
|
|
}
|
|
|
|
return Image(systemName: icon)
|
|
|
|
.padding(.trailing, 9)
|
|
|
|
.foregroundColor(color)
|
|
|
|
}
|
2022-01-31 21:28:07 +00:00
|
|
|
}
|
|
|
|
|
2024-07-03 22:42:13 +01:00
|
|
|
func settingsRow<Content : View>(_ icon: String, color: Color/* = .secondary*/, content: @escaping () -> Content) -> some View {
|
2022-05-30 08:59:04 +01:00
|
|
|
ZStack(alignment: .leading) {
|
2023-11-16 16:53:44 +00:00
|
|
|
Image(systemName: icon).frame(maxWidth: 24, maxHeight: 24, alignment: .center)
|
|
|
|
.symbolRenderingMode(.monochrome)
|
|
|
|
.foregroundColor(color)
|
2022-05-30 08:59:04 +01:00
|
|
|
content().padding(.leading, indent)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-24 19:34:27 +01:00
|
|
|
struct ProfilePreview: View {
|
|
|
|
var profileOf: NamedChat
|
2024-07-03 22:42:13 +01:00
|
|
|
var color = Color(uiColor: .tertiarySystemGroupedBackground)
|
2022-05-24 19:34:27 +01:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
HStack {
|
2024-04-24 21:20:26 +01:00
|
|
|
ProfileImage(imageStr: profileOf.image, size: 44, color: color)
|
2022-05-24 19:34:27 +01:00
|
|
|
.padding(.trailing, 6)
|
|
|
|
.padding(.vertical, 6)
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
Text(profileOf.displayName)
|
|
|
|
.fontWeight(.bold)
|
|
|
|
.font(.title2)
|
2023-10-04 17:45:39 +01:00
|
|
|
if profileOf.fullName != "" && profileOf.fullName != profileOf.displayName {
|
|
|
|
Text(profileOf.fullName)
|
|
|
|
}
|
2022-05-24 19:34:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-31 21:28:07 +00:00
|
|
|
struct SettingsView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
let chatModel = ChatModel()
|
2022-02-08 09:19:25 +00:00
|
|
|
chatModel.currentUser = User.sampleData
|
2022-02-11 07:42:00 +00:00
|
|
|
@State var showSettings = false
|
|
|
|
|
|
|
|
return SettingsView(showSettings: $showSettings)
|
2022-01-31 21:28:07 +00:00
|
|
|
.environmentObject(chatModel)
|
|
|
|
}
|
|
|
|
}
|