From adc8b00d6d77bc661daaa7755e41ff51b5c47036 Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Tue, 10 Oct 2023 11:58:07 +0200 Subject: [PATCH] Use SwiftLint --- .swiftlint.yml | 32 +++ Linphone.xcodeproj/project.pbxproj | 86 ++++--- Linphone/Core/CoreContext.swift | 24 +- Linphone/LinphoneApp.swift | 44 ++-- Linphone/Localizable.xcstrings | 26 +- Linphone/SplashScreen.swift | 38 +-- Linphone/UI/Assistant/AssistantView.swift | 16 +- .../Assistant/Fragments/LoginFragment.swift | 139 +++++----- .../Fragments/ProfileModeFragment.swift | 238 +++++++++--------- .../Fragments/QrCodeScannerFragment.swift | 46 ++-- .../Fragments/RegisterFragment.swift | 6 +- .../ThirdPartySipAccountLoginFragment.swift | 95 ++++--- .../ThirdPartySipAccountWarningFragment.swift | 188 +++++++------- .../Viewmodel/AccountLoginViewModel.swift | 58 ++--- .../UI/Assistant/Viewmodel/QRScanner.swift | 43 ++-- .../Viewmodel}/QRScannerController.swift | 60 ++--- Linphone/UI/Main/Contacts/ContactsView.swift | 40 +-- Linphone/UI/Main/ContentView.swift | 10 +- .../UI/Main/Fragments/PopupLoadingView.swift | 50 ++-- Linphone/UI/Main/Fragments/PopupView.swift | 105 ++++---- Linphone/UI/Main/Fragments/ToastView.swift | 56 ++--- Linphone/UI/Main/History/HistoryView.swift | 40 +-- .../Main/Viewmodel/SharedMainViewModel.swift | 56 ++--- .../Fragments/WelcomePage1Fragment.swift | 8 +- .../Fragments/WelcomePage2Fragment.swift | 6 +- .../Fragments/WelcomePage3Fragment.swift | 6 +- Linphone/UI/Welcome/WelcomeView.swift | 20 +- Linphone/Utils/ColorExtension.swift | 132 +++++----- Linphone/Utils/PermissionManager.swift | 4 +- Linphone/Utils/TextExtension.swift | 204 +++++++-------- Podfile | 8 + 31 files changed, 984 insertions(+), 900 deletions(-) create mode 100644 .swiftlint.yml rename Linphone/{Utils => UI/Assistant/Viewmodel}/QRScannerController.swift (70%) diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 000000000..0133ab567 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,32 @@ +disabled_rules: +- trailing_whitespace +opt_in_rules: +- empty_count +- empty_string +excluded: +- Carthage +- Pods +- SwiftLint/Common/3rdPartyLib +line_length: + warning: 150 + error: 200 + ignores_function_declarations: true + ignores_comments: true + ignores_urls: true +function_body_length: + warning: 300 + error: 500 +function_parameter_count: + warning: 6 + error: 8 +type_body_length: + warning: 300 + error: 500 +file_length: + warning: 1000 + error: 1500 + ignore_comment_only_lines: true +cyclomatic_complexity: + warning: 15 + error: 25 +reporter: "xcode" diff --git a/Linphone.xcodeproj/project.pbxproj b/Linphone.xcodeproj/project.pbxproj index 47c1b6328..461240c2c 100644 --- a/Linphone.xcodeproj/project.pbxproj +++ b/Linphone.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - 2B416B2E7C90375B792A28AE /* Pods_Linphone.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C08FB4788AD667D35BAE64D /* Pods_Linphone.framework */; }; + 0DF2F35F000C9BBAE8FCB4A0 /* Pods_Linphone.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7C92C314A5427A62F953EB70 /* Pods_Linphone.framework */; }; D70C93DE2AC2D0F60063CA3B /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = D70C93DD2AC2D0F60063CA3B /* Localizable.xcstrings */; }; D717071E2AC5922E0037746F /* ColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D717071D2AC5922E0037746F /* ColorExtension.swift */; }; D71707202AC5989C0037746F /* TextExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D717071F2AC5989C0037746F /* TextExtension.swift */; }; @@ -47,8 +47,9 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 2C08FB4788AD667D35BAE64D /* Pods_Linphone.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Linphone.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - BC39A28B26EDB00C91AB7756 /* Pods-Linphone.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Linphone.release.xcconfig"; path = "Target Support Files/Pods-Linphone/Pods-Linphone.release.xcconfig"; sourceTree = ""; }; + 3A132937ACADB95696E2F906 /* Pods-Linphone.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Linphone.debug.xcconfig"; path = "Target Support Files/Pods-Linphone/Pods-Linphone.debug.xcconfig"; sourceTree = ""; }; + 3E2758142B8F42856C3A34DF /* Pods-Linphone.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Linphone.release.xcconfig"; path = "Target Support Files/Pods-Linphone/Pods-Linphone.release.xcconfig"; sourceTree = ""; }; + 7C92C314A5427A62F953EB70 /* Pods_Linphone.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Linphone.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D70C93DD2AC2D0F60063CA3B /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = ""; }; D717071D2AC5922E0037746F /* ColorExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorExtension.swift; sourceTree = ""; }; D717071F2AC5989C0037746F /* TextExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextExtension.swift; sourceTree = ""; }; @@ -88,7 +89,6 @@ D7DA67612ACCB2FA00E95002 /* LoginFragment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginFragment.swift; sourceTree = ""; }; D7DA67632ACCB31700E95002 /* ProfileModeFragment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileModeFragment.swift; sourceTree = ""; }; D7FB55102AD447FD00A5AB15 /* RegisterFragment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisterFragment.swift; sourceTree = ""; }; - FBDE73581C1DC4F98CC3DF3A /* Pods-Linphone.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Linphone.debug.xcconfig"; path = "Target Support Files/Pods-Linphone/Pods-Linphone.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -96,17 +96,17 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2B416B2E7C90375B792A28AE /* Pods_Linphone.framework in Frameworks */, + 0DF2F35F000C9BBAE8FCB4A0 /* Pods_Linphone.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 9FFD5E6302DF1093E1CB7311 /* Frameworks */ = { + 1110B8CBF3C1BFD76F8BBFB2 /* Frameworks */ = { isa = PBXGroup; children = ( - 2C08FB4788AD667D35BAE64D /* Pods_Linphone.framework */, + 7C92C314A5427A62F953EB70 /* Pods_Linphone.framework */, ); name = Frameworks; sourceTree = ""; @@ -114,8 +114,8 @@ A31AF2AB8C6A3D7B7EA3B424 /* Pods */ = { isa = PBXGroup; children = ( - FBDE73581C1DC4F98CC3DF3A /* Pods-Linphone.debug.xcconfig */, - BC39A28B26EDB00C91AB7756 /* Pods-Linphone.release.xcconfig */, + 3A132937ACADB95696E2F906 /* Pods-Linphone.debug.xcconfig */, + 3E2758142B8F42856C3A34DF /* Pods-Linphone.release.xcconfig */, ); path = Pods; sourceTree = ""; @@ -126,7 +126,6 @@ D717071D2AC5922E0037746F /* ColorExtension.swift */, D717071F2AC5989C0037746F /* TextExtension.swift */, D74C9D002ACB098C0021626A /* PermissionManager.swift */, - D72343312ACEFF58009AA24E /* QRScannerController.swift */, ); path = Utils; sourceTree = ""; @@ -137,7 +136,7 @@ D719ABB52ABC67BF00B41C10 /* Linphone */, D719ABB42ABC67BF00B41C10 /* Products */, A31AF2AB8C6A3D7B7EA3B424 /* Pods */, - 9FFD5E6302DF1093E1CB7311 /* Frameworks */, + 1110B8CBF3C1BFD76F8BBFB2 /* Frameworks */, ); sourceTree = ""; }; @@ -220,6 +219,7 @@ children = ( D719ABCE2ABC779A00B41C10 /* AccountLoginViewModel.swift */, D72343332ACEFFC3009AA24E /* QRScanner.swift */, + D72343312ACEFF58009AA24E /* QRScannerController.swift */, ); path = Viewmodel; sourceTree = ""; @@ -310,11 +310,12 @@ isa = PBXNativeTarget; buildConfigurationList = D719ABC22ABC67BF00B41C10 /* Build configuration list for PBXNativeTarget "Linphone" */; buildPhases = ( - 5387C360B232ECCFFE549C7A /* [CP] Check Pods Manifest.lock */, + EAE6BD221624F991B659AC2E /* [CP] Check Pods Manifest.lock */, D719ABAF2ABC67BF00B41C10 /* Sources */, D719ABB02ABC67BF00B41C10 /* Frameworks */, D719ABB12ABC67BF00B41C10 /* Resources */, - C6890D9F62DE340F66542619 /* [CP] Embed Pods Frameworks */, + D7FB55122AD53FE200A5AB15 /* Run Script */, + A35AE8ABA69001024776F16C /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -378,7 +379,43 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 5387C360B232ECCFFE549C7A /* [CP] Check Pods Manifest.lock */ = { + A35AE8ABA69001024776F16C /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Linphone/Pods-Linphone-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Linphone/Pods-Linphone-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Linphone/Pods-Linphone-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + D7FB55122AD53FE200A5AB15 /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 12; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\nif which swiftlint > /dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n"; + }; + EAE6BD221624F991B659AC2E /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -400,23 +437,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - C6890D9F62DE340F66542619 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Linphone/Pods-Linphone-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Linphone/Pods-Linphone-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Linphone/Pods-Linphone-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -572,7 +592,7 @@ }; D719ABC32ABC67BF00B41C10 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FBDE73581C1DC4F98CC3DF3A /* Pods-Linphone.debug.xcconfig */; + baseConfigurationReference = 3A132937ACADB95696E2F906 /* Pods-Linphone.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -616,7 +636,7 @@ }; D719ABC42ABC67BF00B41C10 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = BC39A28B26EDB00C91AB7756 /* Pods-Linphone.release.xcconfig */; + baseConfigurationReference = 3E2758142B8F42856C3A34DF /* Pods-Linphone.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; diff --git a/Linphone/Core/CoreContext.swift b/Linphone/Core/CoreContext.swift index cfa03dd68..f20316b7f 100644 --- a/Linphone/Core/CoreContext.swift +++ b/Linphone/Core/CoreContext.swift @@ -19,18 +19,18 @@ import linphonesw -final class CoreContext : ObservableObject { +final class CoreContext: ObservableObject { static let shared = CoreContext() var mCore: Core! - var mRegistrationDelegate : CoreDelegate! - var mConfigurationDelegate : CoreDelegate! + var mRegistrationDelegate: CoreDelegate! + var mConfigurationDelegate: CoreDelegate! var coreVersion: String = Core.getVersion - @Published var loggedIn : Bool = false - @Published var loggingInProgress : Bool = false - @Published var toastMessage : String = "" + @Published var loggedIn: Bool = false + @Published var loggingInProgress: Bool = false + @Published var toastMessage: String = "" private init() {} @@ -47,23 +47,23 @@ final class CoreContext : ObservableObject { mRegistrationDelegate = CoreDelegateStub( - onConfiguringStatus: { (core: Core, state: Config.ConfiguringState, message: String) in + onConfiguringStatus: {(_: Core, state: Config.ConfiguringState, message: String) in NSLog("New configuration state is \(state) = \(message)\n") - if (state == .Successful) { + if state == .Successful { self.toastMessage = "Successful" } else { self.toastMessage = "Failed" } }, - onAccountRegistrationStateChanged: { (core: Core, account: Account, state: RegistrationState, message: String) in + onAccountRegistrationStateChanged: {(_: Core, account: Account, state: RegistrationState, message: String) in // If account has been configured correctly, we will go through Progress and Ok states // Otherwise, we will be Failed. - NSLog("New registration state is \(state) for user id \( String(describing: account.params?.identityAddress?.asString()))\n") - if (state == .Ok) { + NSLog("New registration state is \(state) for user id \( String(describing: account.params?.identityAddress?.asString())) = \(message)\n") + if state == .Ok { self.loggingInProgress = false self.loggedIn = true - } else if (state == .Progress) { + } else if state == .Progress { self.loggingInProgress = true } else { self.toastMessage = "Registration failed" diff --git a/Linphone/LinphoneApp.swift b/Linphone/LinphoneApp.swift index 56b0c0ad3..87b0a4007 100644 --- a/Linphone/LinphoneApp.swift +++ b/Linphone/LinphoneApp.swift @@ -1,21 +1,21 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of linphone-iphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of linphone-iphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import SwiftUI @@ -25,14 +25,14 @@ struct LinphoneApp: App { @ObservedObject private var coreContext = CoreContext.shared @State private var isActive = false - var body: some Scene { - WindowGroup { + var body: some Scene { + WindowGroup { if isActive { ContentView(sharedMainViewModel: SharedMainViewModel()) .toast(isShowing: $coreContext.toastMessage) - }else { + } else { SplashScreen(isActive: $isActive) } - } - } + } + } } diff --git a/Linphone/Localizable.xcstrings b/Linphone/Localizable.xcstrings index c46a0bdf1..6490fa139 100644 --- a/Linphone/Localizable.xcstrings +++ b/Linphone/Localizable.xcstrings @@ -3,9 +3,15 @@ "strings" : { "" : { + }, + " et " : { + }, " or " : { + }, + "." : { + }, "[Forgotten password?](https://subscribe.linphone.org/)" : { @@ -131,15 +137,8 @@ "Domain" : { }, - "En continuant, vous acceptez ces conditions, %@ et %@." : { - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "new", - "value" : "En continuant, vous acceptez ces conditions, %1$@ et %2$@." - } - } - } + "En continuant, vous acceptez ces conditions, " : { + }, "Error" : { @@ -220,21 +219,12 @@ }, "Skip" : { - }, - "Some features require a Linphone account, such as group messaging, video conferences...\n\nThese features are hidden when you register with a third party SIP account.\n\nTo enable it in a commercial projet, please contact us. " : { - }, "Start" : { }, "TCP" : { - }, - "Texte explicatif du default mode : lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam velit sapien, egestas sit amet dictum eget, condimentum a ligula." : { - - }, - "Texte explicatif du interoperable mode : lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam velit sapien, egestas sit amet dictum eget, condimentum a ligula." : { - }, "The user name or password is incorrects" : { diff --git a/Linphone/SplashScreen.swift b/Linphone/SplashScreen.swift index 4f537a833..64d59e258 100644 --- a/Linphone/SplashScreen.swift +++ b/Linphone/SplashScreen.swift @@ -1,21 +1,21 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import SwiftUI @@ -25,7 +25,7 @@ struct SplashScreen: View { @Binding var isActive: Bool var body: some View { - GeometryReader { geometry in + GeometryReader { _ in VStack { Spacer() HStack { @@ -50,5 +50,5 @@ struct SplashScreen: View { } #Preview { - SplashScreen(isActive: .constant(true)) + SplashScreen(isActive: .constant(true)) } diff --git a/Linphone/UI/Assistant/AssistantView.swift b/Linphone/UI/Assistant/AssistantView.swift index 57da277ae..c3cc5e2bd 100644 --- a/Linphone/UI/Assistant/AssistantView.swift +++ b/Linphone/UI/Assistant/AssistantView.swift @@ -20,19 +20,19 @@ import SwiftUI struct AssistantView: View { - - @ObservedObject var sharedMainViewModel : SharedMainViewModel + + @ObservedObject var sharedMainViewModel: SharedMainViewModel @ObservedObject private var coreContext = CoreContext.shared - - var body: some View { - if (sharedMainViewModel.displayProfileMode && coreContext.loggedIn){ - ProfileModeFragment(sharedMainViewModel: sharedMainViewModel) + + var body: some View { + if sharedMainViewModel.displayProfileMode && coreContext.loggedIn { + ProfileModeFragment(sharedMainViewModel: sharedMainViewModel) } else { LoginFragment(accountLoginViewModel: AccountLoginViewModel(), sharedMainViewModel: sharedMainViewModel) } - } + } } #Preview { - AssistantView(sharedMainViewModel: SharedMainViewModel()) + AssistantView(sharedMainViewModel: SharedMainViewModel()) } diff --git a/Linphone/UI/Assistant/Fragments/LoginFragment.swift b/Linphone/UI/Assistant/Fragments/LoginFragment.swift index d11ff1b79..b340a8ad4 100644 --- a/Linphone/UI/Assistant/Fragments/LoginFragment.swift +++ b/Linphone/UI/Assistant/Fragments/LoginFragment.swift @@ -22,13 +22,13 @@ import SwiftUI struct LoginFragment: View { @ObservedObject private var coreContext = CoreContext.shared - @ObservedObject var accountLoginViewModel : AccountLoginViewModel - @ObservedObject var sharedMainViewModel : SharedMainViewModel + @ObservedObject var accountLoginViewModel: AccountLoginViewModel + @ObservedObject var sharedMainViewModel: SharedMainViewModel @State private var isSecured: Bool = true - @FocusState var isNameFocused:Bool - @FocusState var isPasswordFocused:Bool + @FocusState var isNameFocused: Bool + @FocusState var isPasswordFocused: Bool @State private var isShowPopup = false @@ -62,7 +62,7 @@ struct LoginFragment: View { .default_text_style_700(styleSize: 15) .padding(.bottom, -5) - TextField("username", text : $accountLoginViewModel.username) + TextField("username", text: $accountLoginViewModel.username) .default_text_style(styleSize: 15) .disabled(coreContext.loggedIn) .frame(height: 25) @@ -72,7 +72,7 @@ struct LoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(isNameFocused ? Color.orange_main_500 : Color.gray_200, lineWidth: 1) + .stroke(isNameFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) ) .padding(.bottom) .focused($isNameFocused) @@ -95,15 +95,16 @@ struct LoginFragment: View { .focused($isPasswordFocused) } } + Button(action: { isSecured.toggle() - }) { + }, label: { Image(self.isSecured ? "eye-slash" : "eye") .renderingMode(.template) .resizable() - .foregroundStyle(Color.gray_main2_500) + .foregroundStyle(Color.grayMain2c500) .frame(width: 20, height: 20) - } + }) } .disabled(coreContext.loggedIn) .padding(.horizontal, 20) @@ -112,26 +113,21 @@ struct LoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(isPasswordFocused ? Color.orange_main_500 : Color.gray_200, lineWidth: 1) + .stroke(isPasswordFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) ) .padding(.bottom) - Button(action: { - if (self.coreContext.loggedIn){ - self.accountLoginViewModel.unregister() - self.accountLoginViewModel.delete() - } else { - self.accountLoginViewModel.login() - } - }) { + Button(action: { + self.accountLoginViewModel.login() + }, label: { Text(coreContext.loggedIn ? "Log out" : "assistant_account_login") .default_text_style_white_600(styleSize: 20) .frame(height: 35) .frame(maxWidth: .infinity) - } + }) .padding(.horizontal, 20) .padding(.vertical, 10) - .background((accountLoginViewModel.username.isEmpty || accountLoginViewModel.passwd.isEmpty) ? Color.orange_main_100 : Color.orange_main_500) + .background((accountLoginViewModel.username.isEmpty || accountLoginViewModel.passwd.isEmpty) ? Color.orangeMain100 : Color.orangeMain500) .cornerRadius(60) .disabled(accountLoginViewModel.username.isEmpty || accountLoginViewModel.passwd.isEmpty) .padding(.bottom) @@ -139,21 +135,21 @@ struct LoginFragment: View { HStack { Text("[Forgotten password?](https://subscribe.linphone.org/)") .underline() - .tint(Color.gray_main2_600) + .tint(Color.grayMain2c600) .default_text_style_600(styleSize: 15) - .foregroundStyle(Color.gray_main2_500) + .foregroundStyle(Color.grayMain2c500) } .frame(maxWidth: .infinity) .padding(.bottom, 30) HStack { - VStack{ + VStack { Divider() } Text(" or ") .default_text_style(styleSize: 15) - .foregroundStyle(Color.gray_main2_500) - VStack{ + .foregroundStyle(Color.grayMain2c500) + VStack { Divider() } } @@ -166,7 +162,7 @@ struct LoginFragment: View { Image("qr-code") .renderingMode(.template) .resizable() - .foregroundStyle(Color.orange_main_500) + .foregroundStyle(Color.orangeMain500) .frame(width: 20, height: 20) Text("Scan QR code") @@ -183,19 +179,21 @@ struct LoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(Color.orange_main_500, lineWidth: 1) + .stroke(Color.orangeMain500, lineWidth: 1) ) .padding(.bottom) - .simultaneousGesture(TapGesture().onEnded{ - self.linkActive = "QR" - if !sharedMainViewModel.generalTermsAccepted { - withAnimation { - self.isShowPopup.toggle() + .simultaneousGesture( + TapGesture().onEnded { + self.linkActive = "QR" + if !sharedMainViewModel.generalTermsAccepted { + withAnimation { + self.isShowPopup.toggle() + } + } else { + self.isLinkQRActive = true } - } else { - self.isLinkQRActive = true } - }) + ) NavigationLink(isActive: $isLinkSIPActive, destination: { ThirdPartySipAccountWarningFragment(sharedMainViewModel: sharedMainViewModel, accountLoginViewModel: accountLoginViewModel) @@ -213,19 +211,21 @@ struct LoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(Color.orange_main_500, lineWidth: 1) + .stroke(Color.orangeMain500, lineWidth: 1) ) .padding(.bottom) - .simultaneousGesture(TapGesture().onEnded{ - self.linkActive = "SIP" - if !sharedMainViewModel.generalTermsAccepted { - withAnimation { - self.isShowPopup.toggle() + .simultaneousGesture( + TapGesture().onEnded { + self.linkActive = "SIP" + if !sharedMainViewModel.generalTermsAccepted { + withAnimation { + self.isShowPopup.toggle() + } + } else { + self.isLinkSIPActive = true } - } else { - self.isLinkSIPActive = true } - }) + ) Spacer() @@ -235,7 +235,7 @@ struct LoginFragment: View { Text("Not account yet?") .default_text_style(styleSize: 15) - .foregroundStyle(Color.gray_main2_700) + .foregroundStyle(Color.grayMain2c700) .padding(.horizontal, 10) NavigationLink(destination: RegisterFragment(), isActive: $isLinkREGActive, label: {Text("Register") @@ -249,19 +249,21 @@ struct LoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(Color.orange_main_500, lineWidth: 1) + .stroke(Color.orangeMain500, lineWidth: 1) ) .padding(.horizontal, 10) - .simultaneousGesture(TapGesture().onEnded{ - self.linkActive = "REG" - if !sharedMainViewModel.generalTermsAccepted { - withAnimation { - self.isShowPopup.toggle() + .simultaneousGesture( + TapGesture().onEnded { + self.linkActive = "REG" + if !sharedMainViewModel.generalTermsAccepted { + withAnimation { + self.isShowPopup.toggle() + } + } else { + self.isLinkREGActive = true } - } else { - self.isLinkREGActive = true - } - }) + } + ) Spacer() } @@ -274,14 +276,25 @@ struct LoginFragment: View { } if self.isShowPopup { - PopupView(sharedMainViewModel: sharedMainViewModel, isShowPopup: $isShowPopup, title: Text("Conditions de service"), content: Text("En continuant, vous acceptez ces conditions, \(Text("[notre politique de confidentialité](https://linphone.org/privacy-policy)").underline()) et \(Text("[nos conditions d’utilisation](https://linphone.org/general-terms)").underline())."), titleFirstButton: Text("Deny all"), actionFirstButton: {self.isShowPopup.toggle()}, titleSecondButton: Text("Accept all"), actionSecondButton: {acceptGeneralTerms()}) - .background(.black.opacity(0.65)) - .onTapGesture { - self.isShowPopup.toggle() - } + let contentPopup1 = Text("En continuant, vous acceptez ces conditions, ") + let contentPopup2 = Text("[notre politique de confidentialité](https://linphone.org/privacy-policy)").underline() + let contentPopup3 = Text(" et ") + let contentPopup4 = Text("[nos conditions d’utilisation](https://linphone.org/general-terms)").underline() + let contentPopup5 = Text(".") + PopupView(sharedMainViewModel: sharedMainViewModel, isShowPopup: $isShowPopup, + title: Text("Conditions de service"), + content: contentPopup1 + contentPopup2 + contentPopup3 + contentPopup4 + contentPopup5, + titleFirstButton: Text("Deny all"), + actionFirstButton: {self.isShowPopup.toggle()}, + titleSecondButton: Text("Accept all"), + actionSecondButton: {acceptGeneralTerms()}) + .background(.black.opacity(0.65)) + .onTapGesture { + self.isShowPopup.toggle() + } } } - .onAppear{ + .onAppear { sharedMainViewModel.changeDisplayProfileMode() } @@ -291,7 +304,7 @@ struct LoginFragment: View { } if !coreContext.loggingInProgress && !coreContext.loggedIn { - ZStack{ + ZStack { }.onAppear { self.accountLoginViewModel.unregister() @@ -303,7 +316,7 @@ struct LoginFragment: View { .navigationViewStyle(StackNavigationViewStyle()) } - func acceptGeneralTerms(){ + func acceptGeneralTerms() { sharedMainViewModel.changeGeneralTerms() self.isShowPopup.toggle() switch linkActive { diff --git a/Linphone/UI/Assistant/Fragments/ProfileModeFragment.swift b/Linphone/UI/Assistant/Fragments/ProfileModeFragment.swift index 8f07c6c28..0eec8a5e0 100644 --- a/Linphone/UI/Assistant/Fragments/ProfileModeFragment.swift +++ b/Linphone/UI/Assistant/Fragments/ProfileModeFragment.swift @@ -20,138 +20,152 @@ import SwiftUI struct ProfileModeFragment: View { - - @ObservedObject var sharedMainViewModel : SharedMainViewModel - - @State var options: Int = 1 - @State private var isShowPopup = false - @State private var isShowPopupForDefault = true - - var body: some View { - GeometryReader { geometry in - ScrollView(.vertical) { - VStack { - ZStack { - Image("mountain") - .resizable() - .scaledToFill() - .frame(width: geometry.size.width, height: 100) - .clipped() - Text("Personnalize your profil mode") - .default_text_style_white_800(styleSize: 20) - .padding(.top, -10) - Text("You will change this mode later") - .default_text_style_white(styleSize: 15) - .padding(.top, 40) - } - .padding(.top, 35) - .padding(.bottom, 10) - - VStack (spacing: 10) { - Button(action: { - options = 1 - }) { - HStack { - Image(options == 1 ? "radio-button-fill" : "radio-button") - Text("Default") - .profile_mode_text_style_gray_800(styleSize: 16) - Image("info") - .resizable() - .frame(width: 25, height: 25) - .onTapGesture { - withAnimation { - self.isShowPopupForDefault = true - self.isShowPopup.toggle() - } - } - Spacer() - } - } - - HStack { - Text("Chiffrement de bout en bout de tous vos échanges, grâce au mode default vos communications sont à l’abri des regards.") - .profile_mode_text_style_gray(styleSize: 15) - } - .frame(maxWidth: .infinity, alignment: .leading) - .padding(.horizontal, 16) - .padding(.vertical, 20) - .background(Color.gray_100) - .cornerRadius(15) - .padding(.bottom, 5) - - Image("profile-mode") - .resizable() - .frame(width: 150, height: 60) - .padding() - - Button(action: { - options = 2 - }) { - HStack { - Image(options == 2 ? "radio-button-fill" : "radio-button") - Text("Interoperable") - .profile_mode_text_style_gray_800(styleSize: 16) - Image("info") - .resizable() - .frame(width: 25, height: 25) - .onTapGesture { - withAnimation { - self.isShowPopupForDefault = false - self.isShowPopup.toggle() - } - } - Spacer() - } - } - - HStack { - Text("Ce mode vous permet d’être interopérable avec d’autres services SIP.\nVos communications seront chiffrées de point à point. ") - .profile_mode_text_style_gray(styleSize: 15) - } - .frame(maxWidth: .infinity, alignment: .leading) - .padding(.horizontal, 16) - .padding(.vertical, 20) - .background(Color.gray_100) - .cornerRadius(15) - } + + @ObservedObject var sharedMainViewModel: SharedMainViewModel + + @State var options: Int = 1 + @State private var isShowPopup = false + @State private var isShowPopupForDefault = true + + var body: some View { + GeometryReader { geometry in + ScrollView(.vertical) { + VStack { + ZStack { + Image("mountain") + .resizable() + .scaledToFill() + .frame(width: geometry.size.width, height: 100) + .clipped() + Text("Personnalize your profil mode") + .default_text_style_white_800(styleSize: 20) + .padding(.top, -10) + Text("You will change this mode later") + .default_text_style_white(styleSize: 15) + .padding(.top, 40) + } + .padding(.top, 35) + .padding(.bottom, 10) + + VStack(spacing: 10) { + Button(action: { + options = 1 + }, label: { + HStack { + Image(options == 1 ? "radio-button-fill" : "radio-button") + Text("Default") + .profile_mode_text_style_gray_800(styleSize: 16) + Image("info") + .resizable() + .frame(width: 25, height: 25) + .onTapGesture { + withAnimation { + self.isShowPopupForDefault = true + self.isShowPopup.toggle() + } + } + Spacer() + } + }) + + HStack { + Text("Chiffrement de bout en bout de tous vos échanges, grâce au mode default vos communications sont à l’abri des regards.") + .profile_mode_text_style_gray(styleSize: 15) + } + .frame(maxWidth: .infinity, alignment: .leading) + .padding(.horizontal, 16) + .padding(.vertical, 20) + .background(Color.gray100) + .cornerRadius(15) + .padding(.bottom, 5) + + Image("profile-mode") + .resizable() + .frame(width: 150, height: 60) + .padding() + + Button(action: { + options = 2 + }, label: { + HStack { + Image(options == 2 ? "radio-button-fill" : "radio-button") + Text("Interoperable") + .profile_mode_text_style_gray_800(styleSize: 16) + Image("info") + .resizable() + .frame(width: 25, height: 25) + .onTapGesture { + withAnimation { + self.isShowPopupForDefault = false + self.isShowPopup.toggle() + } + } + Spacer() + } + }) + + HStack { + Text("Ce mode vous permet d’être interopérable avec d’autres services SIP.\nVos communications seront chiffrées de point à point. ") + .profile_mode_text_style_gray(styleSize: 15) + } + .frame(maxWidth: .infinity, alignment: .leading) + .padding(.horizontal, 16) + .padding(.vertical, 20) + .background(Color.gray100) + .cornerRadius(15) + } .frame(maxWidth: sharedMainViewModel.maxWidth) - .padding() + .padding() Spacer() - Button(action: { + Button(action: { sharedMainViewModel.changeHideProfileMode() - }) { + }, label: { Text("Continue") .default_text_style_white_600(styleSize: 20) .frame(height: 35) .frame(maxWidth: .infinity) - } + }) .padding(.horizontal, 20) .padding(.vertical, 10) - .background(Color.orange_main_500) + .background(Color.orangeMain500) .cornerRadius(60) .padding(.horizontal) .padding(.bottom, geometry.safeAreaInsets.bottom.isEqual(to: 0.0) ? 20 : 0) .frame(maxWidth: sharedMainViewModel.maxWidth) - } + } .frame(minHeight: geometry.size.height) - } + } .onAppear { UserDefaults.standard.set(false, forKey: "display_profile_mode") } - - if self.isShowPopup { - PopupView(sharedMainViewModel: sharedMainViewModel, isShowPopup: $isShowPopup, title: Text(isShowPopupForDefault ? "Default mode" : "Interoperable mode"), content: Text(isShowPopupForDefault ? "Texte explicatif du default mode : lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam velit sapien, egestas sit amet dictum eget, condimentum a ligula." : "Texte explicatif du interoperable mode : lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam velit sapien, egestas sit amet dictum eget, condimentum a ligula."), titleFirstButton: nil, actionFirstButton: {}, titleSecondButton: Text("Close"), actionSecondButton: {self.isShowPopup.toggle()}) - .background(.black.opacity(0.65)) - .onTapGesture { - self.isShowPopup.toggle() - } - } - } - } + + if self.isShowPopup { + PopupView(sharedMainViewModel: sharedMainViewModel, isShowPopup: $isShowPopup, + title: Text(isShowPopupForDefault ? "Default mode" : "Interoperable mode"), + content: Text( + isShowPopupForDefault + ? "Texte explicatif du default mode : lorem ipsum dolor sit amet, consectetur adipiscing elit." + + "Etiam velit sapien, egestas sit amet dictum eget, condimentum a ligula." + : "Texte explicatif du interoperable mode : lorem ipsum dolor sit amet, consectetur adipiscing elit." + + " Etiam velit sapien, egestas sit amet dictum eget, condimentum a ligula."), + titleFirstButton: nil, + actionFirstButton: {}, + titleSecondButton: Text("Close"), + actionSecondButton: { + self.isShowPopup.toggle() + } + ) + .background(.black.opacity(0.65)) + .onTapGesture { + self.isShowPopup.toggle() + } + } + } + } } #Preview { - ProfileModeFragment(sharedMainViewModel: SharedMainViewModel()) + ProfileModeFragment(sharedMainViewModel: SharedMainViewModel()) } diff --git a/Linphone/UI/Assistant/Fragments/QrCodeScannerFragment.swift b/Linphone/UI/Assistant/Fragments/QrCodeScannerFragment.swift index 08bde763e..d5c9ad36e 100644 --- a/Linphone/UI/Assistant/Fragments/QrCodeScannerFragment.swift +++ b/Linphone/UI/Assistant/Fragments/QrCodeScannerFragment.swift @@ -1,21 +1,21 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import SwiftUI @@ -26,8 +26,8 @@ struct QrCodeScannerFragment: View { @Environment(\.dismiss) var dismiss @State var scanResult = "Scan a QR code" - - var body: some View { + + var body: some View { ZStack(alignment: .top) { QRScanner(result: $scanResult) @@ -35,7 +35,7 @@ struct QrCodeScannerFragment: View { .default_text_style_white_800(styleSize: 20) .padding(.top, 175) - HStack{ + HStack { Button { dismiss() } label: { @@ -55,15 +55,15 @@ struct QrCodeScannerFragment: View { .navigationBarHidden(true) if coreContext.toastMessage == "Successful" { - ZStack{ + ZStack { }.onAppear { dismiss() } } - } + } } #Preview { - QrCodeScannerFragment() + QrCodeScannerFragment() } diff --git a/Linphone/UI/Assistant/Fragments/RegisterFragment.swift b/Linphone/UI/Assistant/Fragments/RegisterFragment.swift index ac7146ce7..8b80a1101 100644 --- a/Linphone/UI/Assistant/Fragments/RegisterFragment.swift +++ b/Linphone/UI/Assistant/Fragments/RegisterFragment.swift @@ -23,12 +23,12 @@ struct RegisterFragment: View { .frame(width: geometry.size.width, height: 100) .clipped() - VStack (alignment: .leading) { + VStack(alignment: .leading) { HStack { Image("caret-left") .renderingMode(.template) .resizable() - .foregroundStyle(Color.gray_main2_500) + .foregroundStyle(Color.grayMain2c500) .frame(width: 25, height: 25, alignment: .leading) .padding(.top, -65) .onTapGesture { @@ -60,5 +60,5 @@ struct RegisterFragment: View { } #Preview { - RegisterFragment() + RegisterFragment() } diff --git a/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift b/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift index 77aeacdf6..b8be41481 100644 --- a/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift +++ b/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift @@ -21,23 +21,23 @@ import SwiftUI struct ThirdPartySipAccountLoginFragment: View { - @ObservedObject var sharedMainViewModel : SharedMainViewModel - @ObservedObject private var coreContext = CoreContext.shared - @ObservedObject var accountLoginViewModel : AccountLoginViewModel - - @Environment(\.dismiss) var dismiss - - @State private var isSecured: Bool = true - - @FocusState var isNameFocused:Bool - @FocusState var isPasswordFocused:Bool - @FocusState var isDomainFocused:Bool - @FocusState var isDisplayNameFocused:Bool - - var body: some View { - GeometryReader { geometry in - ScrollView(.vertical) { - VStack { + @ObservedObject var sharedMainViewModel: SharedMainViewModel + @ObservedObject private var coreContext = CoreContext.shared + @ObservedObject var accountLoginViewModel: AccountLoginViewModel + + @Environment(\.dismiss) var dismiss + + @State private var isSecured: Bool = true + + @FocusState var isNameFocused: Bool + @FocusState var isPasswordFocused: Bool + @FocusState var isDomainFocused: Bool + @FocusState var isDisplayNameFocused: Bool + + var body: some View { + GeometryReader { geometry in + ScrollView(.vertical) { + VStack { ZStack { Image("mountain") .resizable() @@ -45,12 +45,12 @@ struct ThirdPartySipAccountLoginFragment: View { .frame(width: geometry.size.width, height: 100) .clipped() - VStack (alignment: .leading) { + VStack(alignment: .leading) { HStack { Image("caret-left") .renderingMode(.template) .resizable() - .foregroundStyle(Color.gray_main2_500) + .foregroundStyle(Color.grayMain2c500) .frame(width: 25, height: 25, alignment: .leading) .padding(.top, -65) .onTapGesture { @@ -73,13 +73,13 @@ struct ThirdPartySipAccountLoginFragment: View { } .padding(.top, 35) .padding(.bottom, 10) - + VStack(alignment: .leading) { Text(String(localized: "username")+"*") .default_text_style_700(styleSize: 15) .padding(.bottom, -5) - TextField("username", text : $accountLoginViewModel.username) + TextField("username", text: $accountLoginViewModel.username) .default_text_style(styleSize: 15) .disabled(coreContext.loggedIn) .frame(height: 25) @@ -89,7 +89,7 @@ struct ThirdPartySipAccountLoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(isNameFocused ? Color.orange_main_500 : Color.gray_200, lineWidth: 1) + .stroke(isNameFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) ) .padding(.bottom) .focused($isNameFocused) @@ -114,13 +114,13 @@ struct ThirdPartySipAccountLoginFragment: View { } Button(action: { isSecured.toggle() - }) { + }, label: { Image(self.isSecured ? "eye-slash" : "eye") .renderingMode(.template) .resizable() - .foregroundStyle(Color.gray_main2_500) + .foregroundStyle(Color.grayMain2c500) .frame(width: 20, height: 20) - } + }) } .disabled(coreContext.loggedIn) .padding(.horizontal, 20) @@ -129,7 +129,7 @@ struct ThirdPartySipAccountLoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(isPasswordFocused ? Color.orange_main_500 : Color.gray_200, lineWidth: 1) + .stroke(isPasswordFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) ) .padding(.bottom) @@ -137,7 +137,7 @@ struct ThirdPartySipAccountLoginFragment: View { .default_text_style_700(styleSize: 15) .padding(.bottom, -5) - TextField("sip.linphone.org", text : $accountLoginViewModel.domain) + TextField("sip.linphone.org", text: $accountLoginViewModel.domain) .default_text_style(styleSize: 15) .disabled(coreContext.loggedIn) .frame(height: 25) @@ -147,7 +147,7 @@ struct ThirdPartySipAccountLoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(isDomainFocused ? Color.orange_main_500 : Color.gray_200, lineWidth: 1) + .stroke(isDomainFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) ) .padding(.bottom) .focused($isDomainFocused) @@ -156,7 +156,7 @@ struct ThirdPartySipAccountLoginFragment: View { .default_text_style_700(styleSize: 15) .padding(.bottom, -5) - TextField("Display Name", text : $accountLoginViewModel.displayName) + TextField("Display Name", text: $accountLoginViewModel.displayName) .default_text_style(styleSize: 15) .disabled(coreContext.loggedIn) .frame(height: 25) @@ -166,7 +166,7 @@ struct ThirdPartySipAccountLoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(isDisplayNameFocused ? Color.orange_main_500 : Color.gray_200, lineWidth: 1) + .stroke(isDisplayNameFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) ) .padding(.bottom) .focused($isDisplayNameFocused) @@ -186,7 +186,7 @@ struct ThirdPartySipAccountLoginFragment: View { Image("caret-down") .renderingMode(.template) .resizable() - .foregroundStyle(Color.gray_main2_500) + .foregroundStyle(Color.grayMain2c500) .frame(width: 20, height: 20) } .frame(height: 25) @@ -196,43 +196,40 @@ struct ThirdPartySipAccountLoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(Color.gray_200, lineWidth: 1) + .stroke(Color.gray200, lineWidth: 1) ) .padding(.bottom) Spacer() - Button(action: { - if (self.coreContext.loggedIn){ - self.accountLoginViewModel.unregister() - self.accountLoginViewModel.delete() - } else { - self.accountLoginViewModel.login() - } - + Button(action: { + self.accountLoginViewModel.login() accountLoginViewModel.domain = "sip.linphone.org" accountLoginViewModel.transportType = "TLS" - }) { + }, label: { Text(coreContext.loggedIn ? "Log out" : "assistant_account_login") .default_text_style_white_600(styleSize: 20) .frame(height: 35) .frame(maxWidth: .infinity) - } + }) .padding(.horizontal, 20) .padding(.vertical, 10) - .background((accountLoginViewModel.username.isEmpty || accountLoginViewModel.passwd.isEmpty || accountLoginViewModel.domain.isEmpty) ? Color.orange_main_100 : Color.orange_main_500) + .background( + (accountLoginViewModel.username.isEmpty || accountLoginViewModel.passwd.isEmpty || accountLoginViewModel.domain.isEmpty) + ? Color.orangeMain100 + : Color.orangeMain500) .cornerRadius(60) .disabled(accountLoginViewModel.username.isEmpty || accountLoginViewModel.passwd.isEmpty || accountLoginViewModel.domain.isEmpty) .padding(.bottom, geometry.safeAreaInsets.bottom.isEqual(to: 0.0) ? 20 : 0) } .frame(maxWidth: sharedMainViewModel.maxWidth) - .padding(.horizontal, 20) - } + .padding(.horizontal, 20) + } .frame(minHeight: geometry.size.height) - } - } - .navigationBarHidden(true) - } + } + } + .navigationBarHidden(true) + } } #Preview { diff --git a/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountWarningFragment.swift b/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountWarningFragment.swift index 63fe6d911..4ce290e27 100644 --- a/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountWarningFragment.swift +++ b/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountWarningFragment.swift @@ -21,17 +21,17 @@ import SwiftUI struct ThirdPartySipAccountWarningFragment: View { - @ObservedObject var sharedMainViewModel : SharedMainViewModel - @ObservedObject private var coreContext = CoreContext.shared - @ObservedObject var accountLoginViewModel : AccountLoginViewModel - - @Environment(\.dismiss) var dismiss - - var body: some View { - NavigationView { - GeometryReader { geometry in - ScrollView(.vertical) { - VStack { + @ObservedObject var sharedMainViewModel: SharedMainViewModel + @ObservedObject private var coreContext = CoreContext.shared + @ObservedObject var accountLoginViewModel: AccountLoginViewModel + + @Environment(\.dismiss) var dismiss + + var body: some View { + NavigationView { + GeometryReader { geometry in + ScrollView(.vertical) { + VStack { ZStack { Image("mountain") .resizable() @@ -39,12 +39,12 @@ struct ThirdPartySipAccountWarningFragment: View { .frame(width: geometry.size.width, height: 100) .clipped() - VStack (alignment: .leading) { + VStack(alignment: .leading) { HStack { Image("caret-left") .renderingMode(.template) .resizable() - .foregroundStyle(Color.gray_main2_500) + .foregroundStyle(Color.grayMain2c500) .frame(width: 25, height: 25, alignment: .leading) .padding(.top, -65) .onTapGesture { @@ -67,94 +67,96 @@ struct ThirdPartySipAccountWarningFragment: View { .padding(.bottom, 10) Spacer() - - VStack(alignment: .leading) { - HStack { - Spacer() - HStack(alignment: .center) { - Image("conversation") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.gray_main2_500) - .frame(width: 20, height: 20, alignment: .leading) - .onTapGesture { - withAnimation { - dismiss() - } - } - } - .padding(16) - .background(Color.gray_main2_200) - .cornerRadius(40) - .padding(.horizontal) - - HStack(alignment: .center) { - Image("video-call") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.gray_main2_500) - .frame(width: 20, height: 20, alignment: .leading) - .onTapGesture { - withAnimation { - dismiss() - } - } - } - .padding(16) - .background(Color.gray_main2_200) - .cornerRadius(40) - .padding(.horizontal) - - Spacer() - } - .padding(.bottom, 40) - - Text("Some features require a Linphone account, such as group messaging, video conferences...\n\nThese features are hidden when you register with a third party SIP account.\n\nTo enable it in a commercial projet, please contact us. ") - .default_text_style(styleSize: 15) - .multilineTextAlignment(.center) - .padding(.bottom) - - HStack { - Spacer() - - HStack { - Text("[linphone.org/contact](https://linphone.org/contact)") - .tint(Color.orange_main_500) - .default_text_style_orange_600(styleSize: 15) - .frame(height: 35) - } - .padding(.horizontal, 15) - .cornerRadius(60) - .overlay( - RoundedRectangle(cornerRadius: 60) - .inset(by: 0.5) - .stroke(Color.orange_main_500, lineWidth: 1) - ) - - Spacer() - } - .padding(.vertical) - } + + VStack(alignment: .leading) { + HStack { + Spacer() + HStack(alignment: .center) { + Image("conversation") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c500) + .frame(width: 20, height: 20, alignment: .leading) + .onTapGesture { + withAnimation { + dismiss() + } + } + } + .padding(16) + .background(Color.grayMain2c200) + .cornerRadius(40) + .padding(.horizontal) + + HStack(alignment: .center) { + Image("video-call") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c500) + .frame(width: 20, height: 20, alignment: .leading) + .onTapGesture { + withAnimation { + dismiss() + } + } + } + .padding(16) + .background(Color.grayMain2c200) + .cornerRadius(40) + .padding(.horizontal) + + Spacer() + } + .padding(.bottom, 40) + + Text("Some features require a Linphone account, such as group messaging, video conferences...\n\n" + + "These features are hidden when you register with a third party SIP account.\n\n" + + "To enable it in a commercial projet, please contact us. ") + .default_text_style(styleSize: 15) + .multilineTextAlignment(.center) + .padding(.bottom) + + HStack { + Spacer() + + HStack { + Text("[linphone.org/contact](https://linphone.org/contact)") + .tint(Color.orangeMain500) + .default_text_style_orange_600(styleSize: 15) + .frame(height: 35) + } + .padding(.horizontal, 15) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(Color.orangeMain500, lineWidth: 1) + ) + + Spacer() + } + .padding(.vertical) + } .frame(maxWidth: sharedMainViewModel.maxWidth) - .padding(.horizontal, 20) + .padding(.horizontal, 20) Spacer() - Button(action: { + Button(action: { dismiss() - }) { + }, label: { Text("I prefere create an account") .default_text_style_orange_600(styleSize: 20) .frame(height: 35) .frame(maxWidth: .infinity) - } + }) .padding(.horizontal, 20) .padding(.vertical, 10) .cornerRadius(60) .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(Color.orange_main_500, lineWidth: 1) + .stroke(Color.orangeMain500, lineWidth: 1) ) .frame(maxWidth: sharedMainViewModel.maxWidth) .padding(.horizontal) @@ -170,19 +172,19 @@ struct ThirdPartySipAccountWarningFragment: View { }) .padding(.horizontal, 20) .padding(.vertical, 10) - .background(Color.orange_main_500) + .background(Color.orangeMain500) .cornerRadius(60) .frame(maxWidth: sharedMainViewModel.maxWidth) .padding(.horizontal) .padding(.bottom, geometry.safeAreaInsets.bottom.isEqual(to: 0.0) ? 20 : 0) - } + } .frame(minHeight: geometry.size.height) - } - } - } + } + } + } .navigationViewStyle(StackNavigationViewStyle()) - .navigationBarHidden(true) - } + .navigationBarHidden(true) + } } #Preview { diff --git a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift index 7a6da1d2d..6f778145a 100644 --- a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift +++ b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift @@ -1,34 +1,34 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import linphonesw import SwiftUI -class AccountLoginViewModel : ObservableObject { +class AccountLoginViewModel: ObservableObject { private var coreContext = CoreContext.shared - @Published var username : String = "" - @Published var passwd : String = "" - @Published var domain : String = "sip.linphone.org" - @Published var displayName : String = "" - @Published var transportType : String = "TLS" + @Published var username: String = "" + @Published var passwd: String = "" + @Published var domain: String = "sip.linphone.org" + @Published var displayName: String = "" + @Published var transportType: String = "TLS" init() {} @@ -37,10 +37,12 @@ class AccountLoginViewModel : ObservableObject { // Get the transport protocol to use. // TLS is strongly recommended // Only use UDP if you don't have the choice - var transport : TransportType - if (transportType == "TLS") { transport = TransportType.Tls } - else if (transportType == "TCP") { transport = TransportType.Tcp } - else { transport = TransportType.Udp } + var transport: TransportType + if transportType == "TLS" { + transport = TransportType.Tls + } else if transportType == "TCP" { + transport = TransportType.Tcp + } else { transport = TransportType.Udp } // To configure a SIP account, we need an Account object and an AuthInfo object // The first one is how to connect to the proxy server, the second one stores the credentials @@ -58,7 +60,7 @@ class AccountLoginViewModel : ObservableObject { // A SIP account is identified by an identity address that we can construct from the username and domain let identity = try Factory.Instance.createAddress(addr: String("sip:" + username + "@" + domain)) - try! accountParams.setIdentityaddress(newValue: identity) + try accountParams.setIdentityaddress(newValue: identity) // We also need to configure where the proxy server is located let address = try Factory.Instance.createAddress(addr: String("sip:" + domain)) diff --git a/Linphone/UI/Assistant/Viewmodel/QRScanner.swift b/Linphone/UI/Assistant/Viewmodel/QRScanner.swift index 2d754e89d..d5dd78159 100644 --- a/Linphone/UI/Assistant/Viewmodel/QRScanner.swift +++ b/Linphone/UI/Assistant/Viewmodel/QRScanner.swift @@ -1,21 +1,21 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import Foundation import SwiftUI @@ -54,13 +54,15 @@ class Coordinator: NSObject, AVCaptureMetadataOutputObjectsDelegate { func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) { // Check if the metadataObjects array is not nil and it contains at least one object. - if metadataObjects.count == 0 { + if metadataObjects.isEmpty { scanResult = "Scan a QR code" return } // Get the metadata object. - let metadataObj = metadataObjects[0] as! AVMetadataMachineReadableCodeObject + guard let metadataObj = metadataObjects[0] as? AVMetadataMachineReadableCodeObject else { + return + } if metadataObj.type == AVMetadataObject.ObjectType.qr, let result = metadataObj.stringValue { @@ -68,12 +70,11 @@ class Coordinator: NSObject, AVCaptureMetadataOutputObjectsDelegate { if let url = NSURL(string: result) { if UIApplication.shared.canOpenURL(url as URL) { lastResult = result - //scanResult = result do { try coreContext.mCore.setProvisioninguri(newValue: result) coreContext.mCore.stop() try coreContext.mCore.start() - }catch { + } catch { } diff --git a/Linphone/Utils/QRScannerController.swift b/Linphone/UI/Assistant/Viewmodel/QRScannerController.swift similarity index 70% rename from Linphone/Utils/QRScannerController.swift rename to Linphone/UI/Assistant/Viewmodel/QRScannerController.swift index 9bf9f3e7e..1a4042241 100644 --- a/Linphone/Utils/QRScannerController.swift +++ b/Linphone/UI/Assistant/Viewmodel/QRScannerController.swift @@ -1,21 +1,21 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import Foundation import SwiftUI @@ -25,52 +25,52 @@ class QRScannerController: UIViewController { var captureSession = AVCaptureSession() var videoPreviewLayer: AVCaptureVideoPreviewLayer? var qrCodeFrameView: UIView? - + var delegate: AVCaptureMetadataOutputObjectsDelegate? - + override func viewDidLoad() { super.viewDidLoad() - + // Get the back-facing camera for capturing videos guard let captureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .back) else { print("Failed to get the camera device") return } - + let videoInput: AVCaptureDeviceInput - + do { // Get an instance of the AVCaptureDeviceInput class using the previous device object. videoInput = try AVCaptureDeviceInput(device: captureDevice) - + } catch { // If any error occurs, simply print it out and don't continue any more. print(error) return } - + // Set the input device on the capture session. captureSession.addInput(videoInput) - + // Initialize a AVCaptureMetadataOutput object and set it as the output device to the capture session. let captureMetadataOutput = AVCaptureMetadataOutput() captureSession.addOutput(captureMetadataOutput) - + // Set delegate and use the default dispatch queue to execute the call back captureMetadataOutput.setMetadataObjectsDelegate(delegate, queue: DispatchQueue.main) captureMetadataOutput.metadataObjectTypes = [ .qr ] - + // Initialize the video preview layer and add it as a sublayer to the viewPreview view's layer. videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession) videoPreviewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill videoPreviewLayer?.frame = view.layer.bounds view.layer.addSublayer(videoPreviewLayer!) - + // Start video capture. DispatchQueue.global(qos: .background).async { self.captureSession.startRunning() } - + } - + } diff --git a/Linphone/UI/Main/Contacts/ContactsView.swift b/Linphone/UI/Main/Contacts/ContactsView.swift index 32124a5b3..1c5d3495a 100644 --- a/Linphone/UI/Main/Contacts/ContactsView.swift +++ b/Linphone/UI/Main/Contacts/ContactsView.swift @@ -1,26 +1,26 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of linphone-iphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of linphone-iphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import SwiftUI struct ContactsView: View { - var body: some View { + var body: some View { VStack { Spacer() Image("linphone") @@ -28,9 +28,9 @@ struct ContactsView: View { Text("Contacts View") Spacer() } - } + } } #Preview { - ContactsView() + ContactsView() } diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index 4290116a5..ccb8e9a67 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -21,15 +21,15 @@ import SwiftUI struct ContentView: View { - @ObservedObject var sharedMainViewModel : SharedMainViewModel + @ObservedObject var sharedMainViewModel: SharedMainViewModel @ObservedObject private var coreContext = CoreContext.shared var body: some View { if !sharedMainViewModel.welcomeViewDisplayed { WelcomeView(sharedMainViewModel: sharedMainViewModel) - } else if coreContext.mCore.defaultAccount == nil || sharedMainViewModel.displayProfileMode { - AssistantView(sharedMainViewModel: sharedMainViewModel) - } else { + } else if coreContext.mCore.defaultAccount == nil || sharedMainViewModel.displayProfileMode { + AssistantView(sharedMainViewModel: sharedMainViewModel) + } else { TabView { ContactsView() .tabItem { @@ -46,5 +46,5 @@ struct ContentView: View { } #Preview { - ContentView(sharedMainViewModel: SharedMainViewModel()) + ContentView(sharedMainViewModel: SharedMainViewModel()) } diff --git a/Linphone/UI/Main/Fragments/PopupLoadingView.swift b/Linphone/UI/Main/Fragments/PopupLoadingView.swift index 60c921245..99f4f063e 100644 --- a/Linphone/UI/Main/Fragments/PopupLoadingView.swift +++ b/Linphone/UI/Main/Fragments/PopupLoadingView.swift @@ -1,41 +1,41 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import SwiftUI struct PopupLoadingView: View { - @ObservedObject var sharedMainViewModel : SharedMainViewModel + @ObservedObject var sharedMainViewModel: SharedMainViewModel - var body: some View { + var body: some View { GeometryReader { geometry in - VStack (alignment: .leading){ - + VStack(alignment: .leading) { + ProgressView() .controlSize(.large) - .progressViewStyle(CircularProgressViewStyle(tint: Color.orange_main_500)) + .progressViewStyle(CircularProgressViewStyle(tint: Color.orangeMain500)) .frame(maxWidth: .infinity) .padding(.top) .padding(.bottom) Text("Opération en cours...") - .tint(Color.gray_main2_600) + .tint(Color.grayMain2c600) .default_text_style(styleSize: 15) .frame(maxWidth: .infinity) } @@ -46,11 +46,11 @@ struct PopupLoadingView: View { .padding(.horizontal) .frame(maxHeight: .infinity) .frame(maxWidth: .infinity) - .shadow(color: Color.orange_main_500, radius: 0, x: 0, y: 2) + .shadow(color: Color.orangeMain500, radius: 0, x: 0, y: 2) .frame(maxWidth: sharedMainViewModel.maxWidth) .position(x: geometry.size.width / 2, y: geometry.size.height / 2) } - } + } } #Preview { diff --git a/Linphone/UI/Main/Fragments/PopupView.swift b/Linphone/UI/Main/Fragments/PopupView.swift index b3a521285..dbfd53afa 100644 --- a/Linphone/UI/Main/Fragments/PopupView.swift +++ b/Linphone/UI/Main/Fragments/PopupView.swift @@ -22,70 +22,69 @@ import Photos struct PopupView: View { - @ObservedObject var sharedMainViewModel : SharedMainViewModel + @ObservedObject var sharedMainViewModel: SharedMainViewModel var permissionManager = PermissionManager.shared @Binding var isShowPopup: Bool - var title: Text - var content: Text? - - var titleFirstButton: Text? - var actionFirstButton: () -> () - - var titleSecondButton: Text? - var actionSecondButton: () -> () + var title: Text + var content: Text? + + var titleFirstButton: Text? + var actionFirstButton: () -> Void + + var titleSecondButton: Text? + var actionSecondButton: () -> Void var body: some View { GeometryReader { geometry in - VStack (alignment: .leading) { - title + VStack(alignment: .leading) { + title .default_text_style_800(styleSize: 16) .frame(alignment: .leading) .padding(.bottom, 2) - if content != nil { content - .tint(Color.gray_main2_600) + .tint(Color.grayMain2c600) .default_text_style(styleSize: 15) .padding(.bottom, 20) } - if titleFirstButton != nil { - Button(action: { - actionFirstButton() - }) { - titleFirstButton - .default_text_style_orange_600(styleSize: 20) - .frame(height: 35) - .frame(maxWidth: .infinity) - } - .padding(.horizontal, 20) - .padding(.vertical, 10) - .cornerRadius(60) - .overlay( - RoundedRectangle(cornerRadius: 60) - .inset(by: 0.5) - .stroke(Color.orange_main_500, lineWidth: 1) - ) - .padding(.bottom, 10) - } - - if titleSecondButton != nil { - Button(action: { - actionSecondButton() - }) { - titleSecondButton - .default_text_style_white_600(styleSize: 20) - .frame(height: 35) - .frame(maxWidth: .infinity) - } - .padding(.horizontal, 20) - .padding(.vertical, 10) - .background(Color.orange_main_500) - .cornerRadius(60) - } + if titleFirstButton != nil { + Button(action: { + actionFirstButton() + }, label: { + titleFirstButton + .default_text_style_orange_600(styleSize: 20) + .frame(height: 35) + .frame(maxWidth: .infinity) + }) + .padding(.horizontal, 20) + .padding(.vertical, 10) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(Color.orangeMain500, lineWidth: 1) + ) + .padding(.bottom, 10) + } + + if titleSecondButton != nil { + Button(action: { + actionSecondButton() + }, label: { + titleSecondButton + .default_text_style_white_600(styleSize: 20) + .frame(height: 35) + .frame(maxWidth: .infinity) + }) + .padding(.horizontal, 20) + .padding(.vertical, 10) + .background(Color.orangeMain500) + .cornerRadius(60) + } } .padding(.horizontal, 20) .padding(.vertical, 20) @@ -93,7 +92,7 @@ struct PopupView: View { .cornerRadius(20) .padding(.horizontal) .frame(maxHeight: .infinity) - .shadow(color: Color.orange_main_500, radius: 0, x: 0, y: 2) + .shadow(color: Color.orangeMain500, radius: 0, x: 0, y: 2) .frame(maxWidth: sharedMainViewModel.maxWidth) .position(x: geometry.size.width / 2, y: geometry.size.height / 2) } @@ -101,6 +100,12 @@ struct PopupView: View { } #Preview { - PopupView(sharedMainViewModel: SharedMainViewModel(), isShowPopup: .constant(true), title: Text("Title"), content: Text("Content"), titleFirstButton: Text("Deny all"), actionFirstButton: {}, titleSecondButton: Text("Accept all"), actionSecondButton: {}) - .background(.black.opacity(0.65)) + PopupView(sharedMainViewModel: SharedMainViewModel(), isShowPopup: .constant(true), + title: Text("Title"), + content: Text("Content"), + titleFirstButton: Text("Deny all"), + actionFirstButton: {}, + titleSecondButton: Text("Accept all"), + actionSecondButton: {}) + .background(.black.opacity(0.65)) } diff --git a/Linphone/UI/Main/Fragments/ToastView.swift b/Linphone/UI/Main/Fragments/ToastView.swift index 16b4c9bbd..ab092763d 100644 --- a/Linphone/UI/Main/Fragments/ToastView.swift +++ b/Linphone/UI/Main/Fragments/ToastView.swift @@ -1,27 +1,27 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import SwiftUI struct ToastView: ViewModifier { - @ObservedObject var sharedMainViewModel : SharedMainViewModel + @ObservedObject var sharedMainViewModel: SharedMainViewModel @Binding var isShowing: String @@ -44,35 +44,35 @@ struct ToastView: ViewModifier { case "Successful": Text("QR code validated!") .multilineTextAlignment(.center) - .foregroundStyle(Color.green_success_500) + .foregroundStyle(Color.greenSuccess500) .default_text_style(styleSize: 15) .padding(8) - + case "Failed": Text("Invalid QR code!") .multilineTextAlignment(.center) - .foregroundStyle(Color.red_danger_500) + .foregroundStyle(Color.redDanger500) .default_text_style(styleSize: 15) .padding(8) - + case "Invalide URI": Text("Invalide URI") .multilineTextAlignment(.center) - .foregroundStyle(Color.red_danger_500) + .foregroundStyle(Color.redDanger500) .default_text_style(styleSize: 15) .padding(8) case "Registration failed": Text("The user name or password is incorrects") .multilineTextAlignment(.center) - .foregroundStyle(Color.red_danger_500) + .foregroundStyle(Color.redDanger500) .default_text_style(styleSize: 15) .padding(8) - + default: Text("Error") .multilineTextAlignment(.center) - .foregroundStyle(Color.red_danger_500) + .foregroundStyle(Color.redDanger500) .default_text_style(styleSize: 15) .padding(8) } @@ -83,10 +83,10 @@ struct ToastView: ViewModifier { .overlay( RoundedRectangle(cornerRadius: 50) .inset(by: 0.5) - .stroke(isShowing == "Successful" ? Color.green_success_500 : Color.red_danger_500, lineWidth: 1) + .stroke(isShowing == "Successful" ? Color.greenSuccess500 : Color.redDanger500, lineWidth: 1) ) .onTapGesture { - isShowing = "" + isShowing = "" } .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 2) { diff --git a/Linphone/UI/Main/History/HistoryView.swift b/Linphone/UI/Main/History/HistoryView.swift index a42cc26a2..de3a16833 100644 --- a/Linphone/UI/Main/History/HistoryView.swift +++ b/Linphone/UI/Main/History/HistoryView.swift @@ -1,21 +1,21 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import SwiftUI @@ -23,7 +23,7 @@ struct HistoryView: View { @ObservedObject private var coreContext = CoreContext.shared - var body: some View { + var body: some View { VStack { Spacer() Image("linphone") @@ -31,9 +31,9 @@ struct HistoryView: View { Text("History View") Spacer() } - } + } } #Preview { - HistoryView() + HistoryView() } diff --git a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift index ffde7651c..5e8f6d39a 100644 --- a/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift +++ b/Linphone/UI/Main/Viewmodel/SharedMainViewModel.swift @@ -1,25 +1,25 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import linphonesw -class SharedMainViewModel : ObservableObject { +class SharedMainViewModel: ObservableObject { @Published var welcomeViewDisplayed = false @Published var generalTermsAccepted = false @@ -29,7 +29,7 @@ class SharedMainViewModel : ObservableObject { init() { let preferences = UserDefaults.standard - + let welcomeViewKey = "welcome_view" if preferences.object(forKey: welcomeViewKey) == nil { @@ -37,7 +37,7 @@ class SharedMainViewModel : ObservableObject { } else { welcomeViewDisplayed = preferences.bool(forKey: welcomeViewKey) } - + let generalTermsKey = "general_terms" if preferences.object(forKey: generalTermsKey) == nil { @@ -55,33 +55,33 @@ class SharedMainViewModel : ObservableObject { } } - func changeWelcomeView(){ + func changeWelcomeView() { let preferences = UserDefaults.standard - + welcomeViewDisplayed = true let welcomeViewKey = "welcome_view" preferences.set(welcomeViewDisplayed, forKey: welcomeViewKey) } - func changeGeneralTerms(){ + func changeGeneralTerms() { let preferences = UserDefaults.standard - + generalTermsAccepted = true let generalTermsKey = "general_terms" preferences.set(generalTermsAccepted, forKey: generalTermsKey) } - func changeDisplayProfileMode(){ + func changeDisplayProfileMode() { let preferences = UserDefaults.standard - + displayProfileMode = true let displayProfileModeKey = "display_profile_mode" preferences.set(displayProfileMode, forKey: displayProfileModeKey) } - func changeHideProfileMode(){ + func changeHideProfileMode() { let preferences = UserDefaults.standard - + displayProfileMode = false let displayProfileModeKey = "display_profile_mode" preferences.set(displayProfileMode, forKey: displayProfileModeKey) diff --git a/Linphone/UI/Welcome/Fragments/WelcomePage1Fragment.swift b/Linphone/UI/Welcome/Fragments/WelcomePage1Fragment.swift index 69b58d13e..aabdc6503 100644 --- a/Linphone/UI/Welcome/Fragments/WelcomePage1Fragment.swift +++ b/Linphone/UI/Welcome/Fragments/WelcomePage1Fragment.swift @@ -20,20 +20,20 @@ import Foundation import SwiftUI -struct WelcomePage1Fragment: View{ +struct WelcomePage1Fragment: View { - var body: some View{ + var body: some View { VStack { Spacer() VStack { Image("linphone") .renderingMode(.template) .resizable() - .foregroundStyle(Color.orange_main_500) + .foregroundStyle(Color.orangeMain500) .frame(width: 100, height: 100) Text("Linphone") .welcome_text_style_gray_800(styleSize: 30) - .padding(.bottom, 20) + .padding(.bottom, 20) Text("Une application de communication **sécurisée**, **open source** et **française**.") .welcome_text_style_gray(styleSize: 15) .multilineTextAlignment(.center) diff --git a/Linphone/UI/Welcome/Fragments/WelcomePage2Fragment.swift b/Linphone/UI/Welcome/Fragments/WelcomePage2Fragment.swift index fa309bcd9..45f1e8fa2 100644 --- a/Linphone/UI/Welcome/Fragments/WelcomePage2Fragment.swift +++ b/Linphone/UI/Welcome/Fragments/WelcomePage2Fragment.swift @@ -22,18 +22,18 @@ import SwiftUI struct WelcomePage2Fragment: View { - var body: some View{ + var body: some View { VStack { Spacer() VStack { Image("secure-image") .renderingMode(.template) .resizable() - .foregroundStyle(Color.orange_main_500) + .foregroundStyle(Color.orangeMain500) .frame(width: 70, height: 100) Text("Sécurisé") .welcome_text_style_gray_800(styleSize: 30) - .padding(.bottom, 20) + .padding(.bottom, 20) Text("Vos communications sont en sécurité grâce aux **Chiffrement de bout en bout**.") .welcome_text_style_gray(styleSize: 15) .multilineTextAlignment(.center) diff --git a/Linphone/UI/Welcome/Fragments/WelcomePage3Fragment.swift b/Linphone/UI/Welcome/Fragments/WelcomePage3Fragment.swift index 803af3968..1f9256037 100644 --- a/Linphone/UI/Welcome/Fragments/WelcomePage3Fragment.swift +++ b/Linphone/UI/Welcome/Fragments/WelcomePage3Fragment.swift @@ -22,18 +22,18 @@ import SwiftUI struct WelcomePage3Fragment: View { - var body: some View{ + var body: some View { VStack { Spacer() VStack { Image("open-source") .renderingMode(.template) .resizable() - .foregroundStyle(Color.orange_main_500) + .foregroundStyle(Color.orangeMain500) .frame(width: 100, height: 100) Text("Open source") .welcome_text_style_gray_800(styleSize: 30) - .padding(.bottom, 20) + .padding(.bottom, 20) Text("Une application open source et un **service gratuit** depuis **2001**.") .welcome_text_style_gray(styleSize: 15) .multilineTextAlignment(.center) diff --git a/Linphone/UI/Welcome/WelcomeView.swift b/Linphone/UI/Welcome/WelcomeView.swift index 7797f187e..b568f88f7 100644 --- a/Linphone/UI/Welcome/WelcomeView.swift +++ b/Linphone/UI/Welcome/WelcomeView.swift @@ -19,9 +19,9 @@ import SwiftUI -struct WelcomeView: View{ +struct WelcomeView: View { - @ObservedObject var sharedMainViewModel : SharedMainViewModel + @ObservedObject var sharedMainViewModel: SharedMainViewModel var permissionManager = PermissionManager.shared @@ -38,7 +38,7 @@ struct WelcomeView: View{ .frame(width: geometry.size.width, height: 100) .clipped() - VStack (alignment: .trailing) { + VStack(alignment: .trailing) { Text("Skip") .underline() .default_text_style_600(styleSize: 15) @@ -68,7 +68,7 @@ struct WelcomeView: View{ Spacer() - VStack{ + VStack { TabView(selection: $index) { ForEach((0..<3), id: \.self) { index in if index == 0 { @@ -91,7 +91,7 @@ struct WelcomeView: View{ Spacer() - Button(action: { + Button(action: { if index < 2 { withAnimation { index += 1 @@ -99,15 +99,15 @@ struct WelcomeView: View{ } else if index == 2 { permissionManager.cameraRequestPermission() } - }) { + }, label: { Text(index == 2 ? "Start" : "Next") .default_text_style_white_600(styleSize: 20) .frame(height: 35) .frame(maxWidth: .infinity) - } + }) .padding(.horizontal, 20) .padding(.vertical, 10) - .background(Color.orange_main_500) + .background(Color.orangeMain500) .cornerRadius(60) .padding(.horizontal) .padding(.bottom, geometry.safeAreaInsets.bottom.isEqual(to: 0.0) ? 20 : 0) @@ -126,7 +126,7 @@ struct WelcomeView: View{ } func setupAppearance() { - UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(Color.orange_main_500) + UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(Color.orangeMain500) if #available(iOS 16.0, *) { let dotCurrentImage = UIImage(named: "current-dot") @@ -140,7 +140,7 @@ struct WelcomeView: View{ UIPageControl.appearance().setIndicatorImage(dotImage, forPage: 1) UIPageControl.appearance().setIndicatorImage(dotImage, forPage: 2) } - UIPageControl.appearance().pageIndicatorTintColor = UIColor(Color.gray_main2_200) + UIPageControl.appearance().pageIndicatorTintColor = UIColor(Color.grayMain2c200) } } diff --git a/Linphone/Utils/ColorExtension.swift b/Linphone/Utils/ColorExtension.swift index 4846fbfb1..19fc96c2e 100644 --- a/Linphone/Utils/ColorExtension.swift +++ b/Linphone/Utils/ColorExtension.swift @@ -1,91 +1,91 @@ /* -* Copyright (c) 2010-2023 Belledonne Communications SARL. -* -* This file is part of Linphone -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (c) 2010-2023 Belledonne Communications SARL. + * + * This file is part of Linphone + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ import Foundation import SwiftUI extension Color { - static let transparent_color = Color(hex: "#00000000") + static let transparentColor = Color(hex: "#00000000") static let black = Color(hex: "#000000") static let white = Color(hex: "#FFFFFF") - - static let orange_main_700 = Color(hex: "#B72D00") - static let orange_main_500 = Color(hex: "#FF5E00") - static let orange_main_300 = Color(hex: "#FFB266") - static let orange_main_100 = Color(hex: "#FFEACB") - static let orange_main_100_alpha_50 = Color(hex: "#80FFEACB") - - static let gray_main2_800 = Color(hex: "#22334D") - static let gray_main2_800_alpha_65 = Color(hex: "#A622334D") - static let gray_main2_700 = Color(hex: "#364860") - static let gray_main2_600 = Color(hex: "#4E6074") - static let gray_main2_500 = Color(hex: "#6C7A87") - static let gray_main2_400 = Color(hex: "#9AABB5") - static let gray_main2_300 = Color(hex: "#C0D1D9") - static let gray_main2_200 = Color(hex: "#DFECF2") - static let gray_main2_100 = Color(hex: "#EEF6F8") - - static let gray_100 = Color(hex: "#F9F9F9") - static let gray_200 = Color(hex: "#EDEDED") - static let gray_300 = Color(hex: "#C9C9C9") - static let gray_400 = Color(hex: "#949494") - static let gray_500 = Color(hex: "#4E4E4E") - static let gray_600 = Color(hex: "#2E3030") - static let gray_900 = Color(hex: "#070707") - - static let red_danger_200 = Color(hex: "#F5CCBE") - static let red_danger_500 = Color(hex: "#DD5F5F") - static let red_danger_700 = Color(hex: "#9E3548") - - static let green_success_500 = Color(hex: "#4FAE80") - static let green_success_700 = Color(hex: "#377D71") - static let green_success_200 = Color(hex: "#ACF5C1") - - static let blue_info_500 = Color(hex: "#4AA8FF") - - static let orange_warning_600 = Color(hex: "#DBB820") - - static let orange_away = Color(hex: "#FFA645") + + static let orangeMain700 = Color(hex: "#B72D00") + static let orangeMain500 = Color(hex: "#FF5E00") + static let orangeMain300 = Color(hex: "#FFB266") + static let orangeMain100 = Color(hex: "#FFEACB") + static let orangeMain100Alpha50 = Color(hex: "#80FFEACB") + + static let grayMain2c800 = Color(hex: "#22334D") + static let grayMain2c800Alpha65 = Color(hex: "#A622334D") + static let grayMain2c700 = Color(hex: "#364860") + static let grayMain2c600 = Color(hex: "#4E6074") + static let grayMain2c500 = Color(hex: "#6C7A87") + static let grayMain2c400 = Color(hex: "#9AABB5") + static let grayMain2c300 = Color(hex: "#C0D1D9") + static let grayMain2c200 = Color(hex: "#DFECF2") + static let grayMain2c100 = Color(hex: "#EEF6F8") + + static let gray100 = Color(hex: "#F9F9F9") + static let gray200 = Color(hex: "#EDEDED") + static let gray300 = Color(hex: "#C9C9C9") + static let gray400 = Color(hex: "#949494") + static let gray500 = Color(hex: "#4E4E4E") + static let gray600 = Color(hex: "#2E3030") + static let gray900 = Color(hex: "#070707") + + static let redDanger200 = Color(hex: "#F5CCBE") + static let redDanger500 = Color(hex: "#DD5F5F") + static let redDanger700 = Color(hex: "#9E3548") + + static let greenSuccess500 = Color(hex: "#4FAE80") + static let greenSuccess700 = Color(hex: "#377D71") + static let greenSuccess200 = Color(hex: "#ACF5C1") + + static let blueInfo500 = Color(hex: "#4AA8FF") + + static let orangeWarning600 = Color(hex: "#DBB820") + + static let orangeAway = Color(hex: "#FFA645") init(hex: String) { let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted) var int: UInt64 = 0 Scanner(string: hex).scanHexInt64(&int) - let a, r, g, b: UInt64 + let alpha, red, green, blue: UInt64 switch hex.count { case 3: // RGB (12-bit) - (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) + (alpha, red, green, blue) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) case 6: // RGB (24-bit) - (a, r, g, b) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) + (alpha, red, green, blue) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF) case 8: // ARGB (32-bit) - (a, r, g, b) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) + (alpha, red, green, blue) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF) default: - (a, r, g, b) = (1, 1, 1, 0) + (alpha, red, green, blue) = (1, 1, 1, 0) } - + self.init( .sRGB, - red: Double(r) / 255, - green: Double(g) / 255, - blue: Double(b) / 255, - opacity: Double(a) / 255 + red: Double(red) / 255, + green: Double(green) / 255, + blue: Double(blue) / 255, + opacity: Double(alpha) / 255 ) } } diff --git a/Linphone/Utils/PermissionManager.swift b/Linphone/Utils/PermissionManager.swift index 6a830e412..a39833010 100644 --- a/Linphone/Utils/PermissionManager.swift +++ b/Linphone/Utils/PermissionManager.swift @@ -20,7 +20,7 @@ import Foundation import Photos -class PermissionManager : ObservableObject { +class PermissionManager: ObservableObject { static let shared = PermissionManager() @@ -29,7 +29,7 @@ class PermissionManager : ObservableObject { private init() {} - func photoLibraryRequestPermission(){ + func photoLibraryRequestPermission() { PHPhotoLibrary.requestAuthorization(for: .readWrite, handler: {status in DispatchQueue.main.async { self.photoLibraryPermissionGranted = (status == .authorized || status == .limited || status == .restricted) diff --git a/Linphone/Utils/TextExtension.swift b/Linphone/Utils/TextExtension.swift index ac514e2a2..e9d58ae0b 100644 --- a/Linphone/Utils/TextExtension.swift +++ b/Linphone/Utils/TextExtension.swift @@ -21,96 +21,96 @@ import Foundation import SwiftUI extension View { - - func default_text_style_300(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Light", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) - } - - func default_text_style(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Regular", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) - } - - func default_text_style_500(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Medium", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) - } - - func default_text_style_600(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-SemiBold", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) - } - - func default_text_style_700(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Bold", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) - } - - func default_text_style_800(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) - } - - func default_text_style_white_300(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Light", size: styleSize)) - .foregroundStyle(Color.white) - } - - func default_text_style_white(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Regular", size: styleSize)) - .foregroundStyle(Color.white) - } - - func default_text_style_white_500(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Medium", size: styleSize)) - .foregroundStyle(Color.white) - } - - func default_text_style_white_600(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-SemiBold", size: styleSize)) - .foregroundStyle(Color.white) - } - - func default_text_style_white_700(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Bold", size: styleSize)) - .foregroundStyle(Color.white) - } - - func default_text_style_white_800(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) - .foregroundStyle(Color.white) - } - - func default_text_style_orange_300(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Light", size: styleSize)) - .foregroundStyle(Color.orange_main_500) - } - - func default_text_style_orange(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Regular", size: styleSize)) - .foregroundStyle(Color.orange_main_500) - } - - func default_text_style_orange_500(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Medium", size: styleSize)) - .foregroundStyle(Color.orange_main_500) - } - - func default_text_style_orange_600(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-SemiBold", size: styleSize)) - .foregroundStyle(Color.orange_main_500) - } - - func default_text_style_orange_700(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Bold", size: styleSize)) - .foregroundStyle(Color.orange_main_500) - } - - func default_text_style_orange_800(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) - .foregroundStyle(Color.orange_main_500) - } + + func default_text_style_300(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Light", size: styleSize)) + .foregroundStyle(Color.grayMain2c600) + } + + func default_text_style(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Regular", size: styleSize)) + .foregroundStyle(Color.grayMain2c600) + } + + func default_text_style_500(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Medium", size: styleSize)) + .foregroundStyle(Color.grayMain2c600) + } + + func default_text_style_600(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-SemiBold", size: styleSize)) + .foregroundStyle(Color.grayMain2c600) + } + + func default_text_style_700(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Bold", size: styleSize)) + .foregroundStyle(Color.grayMain2c600) + } + + func default_text_style_800(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) + .foregroundStyle(Color.grayMain2c600) + } + + func default_text_style_white_300(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Light", size: styleSize)) + .foregroundStyle(Color.white) + } + + func default_text_style_white(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Regular", size: styleSize)) + .foregroundStyle(Color.white) + } + + func default_text_style_white_500(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Medium", size: styleSize)) + .foregroundStyle(Color.white) + } + + func default_text_style_white_600(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-SemiBold", size: styleSize)) + .foregroundStyle(Color.white) + } + + func default_text_style_white_700(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Bold", size: styleSize)) + .foregroundStyle(Color.white) + } + + func default_text_style_white_800(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) + .foregroundStyle(Color.white) + } + + func default_text_style_orange_300(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Light", size: styleSize)) + .foregroundStyle(Color.orangeMain500) + } + + func default_text_style_orange(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Regular", size: styleSize)) + .foregroundStyle(Color.orangeMain500) + } + + func default_text_style_orange_500(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Medium", size: styleSize)) + .foregroundStyle(Color.orangeMain500) + } + + func default_text_style_orange_600(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-SemiBold", size: styleSize)) + .foregroundStyle(Color.orangeMain500) + } + + func default_text_style_orange_700(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Bold", size: styleSize)) + .foregroundStyle(Color.orangeMain500) + } + + func default_text_style_orange_800(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) + .foregroundStyle(Color.orangeMain500) + } func welcome_text_style_white_800(styleSize: CGFloat) -> some View { self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) @@ -119,21 +119,21 @@ extension View { func welcome_text_style_gray_800(styleSize: CGFloat) -> some View { self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) + .foregroundStyle(Color.grayMain2c600) } func welcome_text_style_gray(styleSize: CGFloat) -> some View { self.font(Font.custom("NotoSans-Regular", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) + .foregroundStyle(Color.grayMain2c600) + } + + func profile_mode_text_style_gray_800(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) + .foregroundStyle(Color.gray900) + } + + func profile_mode_text_style_gray(styleSize: CGFloat) -> some View { + self.font(Font.custom("NotoSans-Regular", size: styleSize)) + .foregroundStyle(Color.grayMain2c600) } - - func profile_mode_text_style_gray_800(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-ExtraBold", size: styleSize)) - .foregroundStyle(Color.gray_900) - } - - func profile_mode_text_style_gray(styleSize: CGFloat) -> some View { - self.font(Font.custom("NotoSans-Regular", size: styleSize)) - .foregroundStyle(Color.gray_main2_600) - } } diff --git a/Podfile b/Podfile index 4ecc8821a..18951b82a 100644 --- a/Podfile +++ b/Podfile @@ -23,3 +23,11 @@ target 'Linphone' do basic_pods end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0' + end + end +end \ No newline at end of file