diff --git a/.github/workflows/swift-lint.yml b/.github/workflows/swift-lint.yml new file mode 100644 index 0000000000..a4d9ae573b --- /dev/null +++ b/.github/workflows/swift-lint.yml @@ -0,0 +1,31 @@ +name: Swift Lint + +on: + pull_request: + branches: [ develop, master, feature/* ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + swift_lint: + runs-on: macos-14 + env: + FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT: 60 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install SwiftLint + run: brew install swiftlint + + - name: Pod Install + uses: ./.github/actions/pod-install + + - name: Swift Lint + run: bundle exec fastlane cru_shared_lane_swift_lint config_file:./.swiftlint.yml raise_if_swiftlint_error:true \ No newline at end of file diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000000..bc19ca4712 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,142 @@ +# By default, SwiftLint uses a set of sensible default rules you can adjust: +disabled_rules: # rule identifiers turned on by default to exclude from running + - cyclomatic_complexity #disabling for now as this touches many files. + - empty_enum_arguments #disabling for now as this touches many files. + - function_body_length #disabling for now as this touches many files. + - function_parameter_count #disabling for now as this touches many files. + - inclusive_language + - multiple_closures_with_trailing_closure #disabling for now as this touches many files. + - opening_brace #disabling for now as this touches many files. + - redundant_string_enum_value + - statement_position #disabling for now as this touches many files. + - todo #disabling for now as this touches many files. + - trailing_whitespace #disabling for now as this touches many files. Command swiftlint --fix is a way to fix whitespace. + - unused_closure_parameter #disabling for now as this touches many files. +opt_in_rules: # some rules are turned off by default, so you need to opt-in + - closure_end_indentation + # - closure_spacing #disabling for now as this touches many files. + - collection_alignment + - comma_inheritance + - conditional_returns_on_newline + # - convenience_type #disabling for now as this touches many files. + - discouraged_none_name + - discouraged_object_literal + # - empty_count #disabling for now as this touches many files. + - empty_string + - enum_case_associated_values_count + # - explicit_enum_raw_value #disabling for now as this touches many files. + # - explicit_type_interface + - fallthrough + - fatal_error_message + - file_name_no_space + # - file_types_order #Curious about this one. ~Levi + - first_where + - force_unwrapping + - function_default_parameter_at_end + - ibinspectable_in_extension + - identical_operands + # - implicit_return #disabling for now as this touches many files. + - implicitly_unwrapped_optional + - indentation_width + - last_where + - let_var_whitespace + - literal_expression_end_indentation + # - multiline_arguments #Disabling this rule as UIView.animate would fail when using animate and completion together. + # - multiline_arguments_brackets #disabling for now as this touches many files. + - multiline_function_chains + - multiline_literal_brackets + - multiline_parameters + - multiline_parameters_brackets + - no_extension_access_modifier + # - no_magic_numbers #disabling for now as this touches many files. + # - one_declaration_per_file #SwiftUI Preview breaks this, may need to update preview to use macros. + - operator_usage_whitespace + # - prefer_self_in_static_references #disabling for now as this touches many files. + - prefer_self_type_over_type_of_self + - private_action + - private_outlet + - private_subject + - private_swiftui_state + # - sorted_enum_cases #disabling for now as this touches many files. + - strict_fileprivate + - switch_case_on_newline + - toggle_bool + # - trailing_closure #disabling for now as this touches many files. + - unowned_variable_capture + - weak_delegate + - yoda_condition + +# Alternatively, specify all rules explicitly by uncommenting this option: +# only_rules: # delete `disabled_rules` & `opt_in_rules` if using this +# - empty_parameters +# - vertical_whitespace + +analyzer_rules: # rules run by `swiftlint analyze` + - capture_variable + - explicit_self + - unused_import + +# Case-sensitive paths to include during linting. Directory paths supplied on the +# command line will be ignored. +included: + - godtools/App +excluded: # case-sensitive paths to ignore during linting. Takes precedence over `included` + - godtools/App/Flows/Flow/FlowStep.swift + - Carthage + - Pods + - Sources/ExcludedFolder + - Sources/ExcludedFile.swift + - Sources/*/ExcludedFile.swift # exclude files with a wildcard + +# If true, SwiftLint will not fail if no lintable files are found. +allow_zero_lintable_files: false + +# If true, SwiftLint will treat all warnings as errors. +strict: false + +# The path to a baseline file, which will be used to filter out detected violations. +baseline: Baseline.json + +# The path to save detected violations to as a new baseline. +write_baseline: Baseline.json + +# If true, SwiftLint will check for updates after linting or analyzing. +check_for_updates: true + +# configurable rules can be customized from this configuration file +# binary rules can set their severity level +force_cast: warning # implicitly +force_try: + severity: warning # explicitly +# rules that have both warning and error levels, can set just the warning level +# implicitly +line_length: 1200 +# they can set both implicitly with an array +type_body_length: + - 500 # warning + - 600 # error +# or they can set both explicitly +file_length: + warning: 1500 + error: 2000 +# naming rules can set warnings/errors for min_length and max_length +# additionally they can set excluded names +type_name: + min_length: 4 # only warning + max_length: # warning and error + warning: 80 + error: 90 + excluded: iPhone # excluded via string + allowed_symbols: ["_"] # these are allowed in type names +identifier_name: + min_length: # only min_length + warning: 1 + error: 1 # only error + max_length: # warning and error + warning: 80 + error: 90 + excluded: # excluded via string array + - id + - URL + - GlobalAPIKey +reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, codeclimate, junit, html, emoji, sonarqube, markdown, github-actions-logging, summary) \ No newline at end of file diff --git a/godtools/App/AppBuild/AppBuild.swift b/godtools/App/AppBuild/AppBuild.swift index f0e5848b37..eed6e64bc8 100644 --- a/godtools/App/AppBuild/AppBuild.swift +++ b/godtools/App/AppBuild/AppBuild.swift @@ -31,13 +31,13 @@ class AppBuild { configuration = .release } else if let buildConfiguration = buildConfiguration { - configuration = buildConfiguration + configuration = buildConfiguration } else if isDebug { configuration = .staging } else { - configuration = .release + configuration = .release } switch configuration { diff --git a/godtools/App/AppBuild/AppBuildConfiguration.swift b/godtools/App/AppBuild/AppBuildConfiguration.swift index 50afd2c4a0..497af5d61e 100644 --- a/godtools/App/AppBuild/AppBuildConfiguration.swift +++ b/godtools/App/AppBuild/AppBuildConfiguration.swift @@ -11,7 +11,7 @@ import Foundation enum AppBuildConfiguration { case analyticsLogging - case staging case production case release + case staging } diff --git a/godtools/App/AppBuild/AppEnvironment.swift b/godtools/App/AppBuild/AppEnvironment.swift index 3adc3f9eeb..b38fdc6aa5 100644 --- a/godtools/App/AppBuild/AppEnvironment.swift +++ b/godtools/App/AppBuild/AppEnvironment.swift @@ -10,6 +10,6 @@ import Foundation enum AppEnvironment { - case staging case production + case staging } diff --git a/godtools/App/AppDelegate.swift b/godtools/App/AppDelegate.swift index c43a451765..a5644b968b 100644 --- a/godtools/App/AppDelegate.swift +++ b/godtools/App/AppDelegate.swift @@ -92,9 +92,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let uiTestsDeepLinkString: String? = ProcessInfo.processInfo.environment[LaunchEnvironmentKey.urlDeeplink.value] - if let uiTestsDeepLinkString = uiTestsDeepLinkString, !uiTestsDeepLinkString.isEmpty, - let url = URL(string: uiTestsDeepLinkString) { - + if let uiTestsDeepLinkString = uiTestsDeepLinkString, !uiTestsDeepLinkString.isEmpty, let url = URL(string: uiTestsDeepLinkString) { _ = appDeepLinkingService.parseDeepLinkAndNotify(incomingDeepLink: .url(incomingUrl: IncomingDeepLinkUrl(url: url))) } @@ -156,12 +154,12 @@ extension AppDelegate { appDiContainer.dataLayer.getSharedAppsFlyer().registerUninstall(deviceToken: deviceToken) } - func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) { + func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { appDiContainer.dataLayer.getSharedAppsFlyer().handlePushNotification(userInfo: userInfo) } - func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { + func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { appDiContainer.dataLayer.getSharedAppsFlyer().handlePushNotification(userInfo: userInfo) } @@ -177,8 +175,7 @@ extension AppDelegate { let successfullyHandledQuickAction: Bool - if let toolDeepLinkUrlString = ToolShortcutLinksView.getToolDeepLinkUrl(shortcutItem: shortcutItem), - let toolDeepLinkUrl = URL(string: toolDeepLinkUrlString) { + if let toolDeepLinkUrlString = ToolShortcutLinksView.getToolDeepLinkUrl(shortcutItem: shortcutItem), let toolDeepLinkUrl = URL(string: toolDeepLinkUrlString) { let trackActionAnalyticsUseCase: TrackActionAnalyticsUseCase = appDiContainer.domainLayer.getTrackActionAnalyticsUseCase() @@ -212,7 +209,7 @@ extension AppDelegate { extension AppDelegate { - func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { + func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool { appDiContainer.dataLayer.getSharedAppsFlyer().handleOpenUrl(url: url, options: options) diff --git a/godtools/App/Features/Account/Data/UserAuthentication/AuthenticationProvider/Providers/AppleAuthentication+AuthenticationProviderInterface.swift b/godtools/App/Features/Account/Data/UserAuthentication/AuthenticationProvider/Providers/AppleAuthentication+AuthenticationProviderInterface.swift index 6572840fef..6df2eb9f54 100644 --- a/godtools/App/Features/Account/Data/UserAuthentication/AuthenticationProvider/Providers/AppleAuthentication+AuthenticationProviderInterface.swift +++ b/godtools/App/Features/Account/Data/UserAuthentication/AuthenticationProvider/Providers/AppleAuthentication+AuthenticationProviderInterface.swift @@ -55,7 +55,7 @@ extension AppleAuthentication: AuthenticationProviderInterface { func authenticatePublisher(presentingViewController: UIViewController) -> AnyPublisher { return authenticatePublisher() - .flatMap ({ (response: AppleAuthenticationResponse) -> AnyPublisher in + .flatMap({ (response: AppleAuthenticationResponse) -> AnyPublisher in if response.isCancelled { return Fail(error: NSError.userCancelledError()) diff --git a/godtools/App/Features/Account/Domain/Entities/AuthUserDomainModel.swift b/godtools/App/Features/Account/Domain/Entities/AuthUserDomainModel.swift index 01a1ac2fcd..0918b42c45 100644 --- a/godtools/App/Features/Account/Domain/Entities/AuthUserDomainModel.swift +++ b/godtools/App/Features/Account/Domain/Entities/AuthUserDomainModel.swift @@ -17,4 +17,3 @@ struct AuthUserDomainModel { let name: String? let ssoGuid: String? } - diff --git a/godtools/App/Features/AppLanguage/Data-DomainInterface/GetDownloadableLanguagesListRepository.swift b/godtools/App/Features/AppLanguage/Data-DomainInterface/GetDownloadableLanguagesListRepository.swift index 11afdcb360..cf3046d159 100644 --- a/godtools/App/Features/AppLanguage/Data-DomainInterface/GetDownloadableLanguagesListRepository.swift +++ b/godtools/App/Features/AppLanguage/Data-DomainInterface/GetDownloadableLanguagesListRepository.swift @@ -36,39 +36,40 @@ class GetDownloadableLanguagesListRepository: GetDownloadableLanguagesListReposi ) .map { _ in - return self.languagesRepository.getLanguages().compactMap { language in - - let numberToolsAvailable = self.getNumberToolsAvailable(for: language.code) - if numberToolsAvailable == 0 { - return nil + return self.languagesRepository.getLanguages() + .compactMap { language in + + let numberToolsAvailable = self.getNumberToolsAvailable(for: language.code) + if numberToolsAvailable == 0 { + return nil + } + + let languageNameInOwnLanguage = self.getTranslatedLanguageName.getLanguageName( + language: language, + translatedInLanguage: language.code + ) + let languageNameInAppLanguage = self.getTranslatedLanguageName.getLanguageName( + language: language, + translatedInLanguage: currentAppLanguage + ) + + let toolsAvailableText = self.getToolsAvailableText(numberOfTools: numberToolsAvailable, translatedIn: currentAppLanguage) + + let downloadStatus = self.getDownloadStatus(for: language.id) + + return DownloadableLanguageListItemDomainModel( + languageId: language.id, + languageCode: language.languageCode, + languageNameInOwnLanguage: languageNameInOwnLanguage, + languageNameInAppLanguage: languageNameInAppLanguage, + toolsAvailableText: toolsAvailableText, + downloadStatus: downloadStatus + ) + } + .sorted { language1, language2 in + + return self.getSortOrder(language1: language1, language2: language2) } - - let languageNameInOwnLanguage = self.getTranslatedLanguageName.getLanguageName( - language: language, - translatedInLanguage: language.code - ) - let languageNameInAppLanguage = self.getTranslatedLanguageName.getLanguageName( - language: language, - translatedInLanguage: currentAppLanguage - ) - - let toolsAvailableText = self.getToolsAvailableText(numberOfTools: numberToolsAvailable, translatedIn: currentAppLanguage) - - let downloadStatus = self.getDownloadStatus(for: language.id) - - return DownloadableLanguageListItemDomainModel( - languageId: language.id, - languageCode: language.languageCode, - languageNameInOwnLanguage: languageNameInOwnLanguage, - languageNameInAppLanguage: languageNameInAppLanguage, - toolsAvailableText: toolsAvailableText, - downloadStatus: downloadStatus - ) - } - .sorted { language1, language2 in - - return self.getSortOrder(language1: language1, language2: language2) - } } .eraseToAnyPublisher() } diff --git a/godtools/App/Features/AppLanguage/Data/AppLanguagesRepository/Cache/RealmAppLanguagesCache.swift b/godtools/App/Features/AppLanguage/Data/AppLanguagesRepository/Cache/RealmAppLanguagesCache.swift index 8a95cac53e..8f961ca9ab 100644 --- a/godtools/App/Features/AppLanguage/Data/AppLanguagesRepository/Cache/RealmAppLanguagesCache.swift +++ b/godtools/App/Features/AppLanguage/Data/AppLanguagesRepository/Cache/RealmAppLanguagesCache.swift @@ -20,8 +20,9 @@ class RealmAppLanguagesCache { } func observeChangesPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmAppLanguage.self).objectWillChange - .eraseToAnyPublisher() + return realmDatabase.openRealm() + .objects(RealmAppLanguage.self) + .objectWillChange .prepend(Void()) .eraseToAnyPublisher() } diff --git a/godtools/App/Features/AppLanguage/Data/DownloadedLanguagesRepository/Cache/RealmDownloadedLanguagesCache.swift b/godtools/App/Features/AppLanguage/Data/DownloadedLanguagesRepository/Cache/RealmDownloadedLanguagesCache.swift index 4585155983..2c816ece24 100644 --- a/godtools/App/Features/AppLanguage/Data/DownloadedLanguagesRepository/Cache/RealmDownloadedLanguagesCache.swift +++ b/godtools/App/Features/AppLanguage/Data/DownloadedLanguagesRepository/Cache/RealmDownloadedLanguagesCache.swift @@ -21,7 +21,8 @@ class RealmDownloadedLanguagesCache { func getDownloadedLanguagesChangedPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmDownloadedLanguage.self) + return realmDatabase.openRealm() + .objects(RealmDownloadedLanguage.self) .objectWillChange .eraseToAnyPublisher() } @@ -45,7 +46,11 @@ class RealmDownloadedLanguagesCache { func getDownloadedLanguage(languageId: String) -> DownloadedLanguageDataModel? { - guard let downloadedLanguage = realmDatabase.openRealm().object(ofType: RealmDownloadedLanguage.self, forPrimaryKey: languageId) else { return nil } + guard let downloadedLanguage = realmDatabase.openRealm() + .object(ofType: RealmDownloadedLanguage.self, forPrimaryKey: languageId) else { + + return nil + } return DownloadedLanguageDataModel(realmDownloadedLanguage: downloadedLanguage) } diff --git a/godtools/App/Features/AppLanguage/Data/UserAppLanguageRepository/Cache/RealmUserAppLanguageCache.swift b/godtools/App/Features/AppLanguage/Data/UserAppLanguageRepository/Cache/RealmUserAppLanguageCache.swift index fee922b611..dffd44f6f2 100644 --- a/godtools/App/Features/AppLanguage/Data/UserAppLanguageRepository/Cache/RealmUserAppLanguageCache.swift +++ b/godtools/App/Features/AppLanguage/Data/UserAppLanguageRepository/Cache/RealmUserAppLanguageCache.swift @@ -40,7 +40,9 @@ class RealmUserAppLanguageCache { func getLanguageChangedPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmUserAppLanguage.self).objectWillChange + return realmDatabase.openRealm() + .objects(RealmUserAppLanguage.self) + .objectWillChange .map { _ in Void() } diff --git a/godtools/App/Features/AppLanguage/Domain/Entities/DownloadableLanguageListItemDomainModel.swift b/godtools/App/Features/AppLanguage/Domain/Entities/DownloadableLanguageListItemDomainModel.swift index 8f3d77351f..3b91398a7d 100644 --- a/godtools/App/Features/AppLanguage/Domain/Entities/DownloadableLanguageListItemDomainModel.swift +++ b/godtools/App/Features/AppLanguage/Domain/Entities/DownloadableLanguageListItemDomainModel.swift @@ -49,7 +49,10 @@ extension DownloadableLanguageListItemDomainModel: Identifiable { } func wasDownloadedBefore(date: Date) -> Bool { - guard let downloadedAt = downloadStatus.downloadedAt else { return false } + + guard let downloadedAt = downloadStatus.downloadedAt else { + return false + } return downloadedAt < date } diff --git a/godtools/App/Features/AppLanguage/Domain/UseCases/ViewLanguageSettingsUseCase.swift b/godtools/App/Features/AppLanguage/Domain/UseCases/ViewLanguageSettingsUseCase.swift index 6c7eaef53e..7dacc959a9 100644 --- a/godtools/App/Features/AppLanguage/Domain/UseCases/ViewLanguageSettingsUseCase.swift +++ b/godtools/App/Features/AppLanguage/Domain/UseCases/ViewLanguageSettingsUseCase.swift @@ -14,7 +14,7 @@ class ViewLanguageSettingsUseCase { private let getInterfaceStringsRepository: GetLanguageSettingsInterfaceStringsRepositoryInterface private let getDownloadedLanguagesListRepositoryInterface: GetDownloadedLanguagesListRepositoryInterface - init(getInterfaceStringsRepository: GetLanguageSettingsInterfaceStringsRepositoryInterface, getDownloadedLanguagesListRepositoryInterface: GetDownloadedLanguagesListRepositoryInterface) { + init(getInterfaceStringsRepository: GetLanguageSettingsInterfaceStringsRepositoryInterface, getDownloadedLanguagesListRepositoryInterface: GetDownloadedLanguagesListRepositoryInterface) { self.getInterfaceStringsRepository = getInterfaceStringsRepository self.getDownloadedLanguagesListRepositoryInterface = getDownloadedLanguagesListRepositoryInterface diff --git a/godtools/App/Features/AppLanguage/Presentation/ConfirmAppLanguage/ConfirmAppLanguageView.swift b/godtools/App/Features/AppLanguage/Presentation/ConfirmAppLanguage/ConfirmAppLanguageView.swift index a360485e9b..5acf01493b 100644 --- a/godtools/App/Features/AppLanguage/Presentation/ConfirmAppLanguage/ConfirmAppLanguageView.swift +++ b/godtools/App/Features/AppLanguage/Presentation/ConfirmAppLanguage/ConfirmAppLanguageView.swift @@ -64,7 +64,7 @@ struct ConfirmAppLanguageView: View { HStack(spacing: buttonSpacing) { - let buttonWidth = (geometry.size.width - buttonSpacing - 2*horizontalPadding) / 2 + let buttonWidth = (geometry.size.width - buttonSpacing - 2 * horizontalPadding) / 2 GTWhiteButton(title: viewModel.nevermindButtonTitle, fontSize: 15, width: buttonWidth, height: 48) { @@ -97,5 +97,5 @@ struct ConfirmAppLanguageView: View { } .font(FontLibrary.sfProTextRegular.font(size: fontSize)) .foregroundColor(ColorPalette.gtGrey.color) - } + } } diff --git a/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/DownloadableLanguagesViewModel.swift b/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/DownloadableLanguagesViewModel.swift index cf1653bfc0..fbbe858781 100644 --- a/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/DownloadableLanguagesViewModel.swift +++ b/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/DownloadableLanguagesViewModel.swift @@ -171,5 +171,3 @@ extension DownloadableLanguagesViewModel { .store(in: &DownloadableLanguagesViewModel.backgrounDownloadCancellables) } } - - diff --git a/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/DownloadableLanguageItemView.swift b/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/DownloadableLanguageItemView.swift index dcba6d09e8..4c949f219e 100644 --- a/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/DownloadableLanguageItemView.swift +++ b/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/DownloadableLanguageItemView.swift @@ -164,9 +164,11 @@ struct DownloadableLanguageItemView: View { private func startProgressAnimationTimer() { progressAnimationTimer = Timer.scheduledTimer(withTimeInterval: 0.2, repeats: true, block: { timer in - guard let downloadProgress = self.animationDownloadProgress, - let progressTarget = self.downloadProgressTarget - else { return } + + guard let downloadProgress = self.animationDownloadProgress, let progressTarget = self.downloadProgressTarget else { + + return + } if downloadProgress < progressTarget { @@ -180,7 +182,10 @@ struct DownloadableLanguageItemView: View { } private func stopProgressAnimationTimer() { - guard progressAnimationTimer != nil else { return } + + guard progressAnimationTimer != nil else { + return + } progressAnimationTimer?.invalidate() progressAnimationTimer = nil @@ -193,9 +198,8 @@ struct DownloadableLanguageItemView: View { } private func shouldContinueDownloadProgressAnimation() -> Bool { - guard isVisible, - let animationDownloadProgress = animationDownloadProgress - else { + + guard isVisible, let animationDownloadProgress = animationDownloadProgress else { return false } diff --git a/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/LanguageDownloadIcon.swift b/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/LanguageDownloadIcon.swift index 6ec5691ea3..83d2769bb4 100644 --- a/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/LanguageDownloadIcon.swift +++ b/godtools/App/Features/AppLanguage/Presentation/DownloadableLanguages/Subviews/LanguageDownloadIcon.swift @@ -131,7 +131,10 @@ struct LanguageDownloadIcon: View { private func shouldFinishAnimatingDownloadProgress() -> Bool { - guard let animationDownloadProgress = animationDownloadProgress else { return false } + guard let animationDownloadProgress = animationDownloadProgress else { + return false + } + return animationDownloadProgress <= 1 } } diff --git a/godtools/App/Features/AppLanguage/Presentation/LanguageSettings/Subviews/LanguageSettingsAppInterfaceLanguage/Subviews/AppInterfaceLanguageButtonView.swift b/godtools/App/Features/AppLanguage/Presentation/LanguageSettings/Subviews/LanguageSettingsAppInterfaceLanguage/Subviews/AppInterfaceLanguageButtonView.swift index e614f53d7e..9ab9667ebd 100644 --- a/godtools/App/Features/AppLanguage/Presentation/LanguageSettings/Subviews/LanguageSettingsAppInterfaceLanguage/Subviews/AppInterfaceLanguageButtonView.swift +++ b/godtools/App/Features/AppLanguage/Presentation/LanguageSettings/Subviews/LanguageSettingsAppInterfaceLanguage/Subviews/AppInterfaceLanguageButtonView.swift @@ -69,4 +69,3 @@ struct AppInterfaceLanguageButtonView: View { } } } - diff --git a/godtools/App/Features/Articles/Presentation/ArticleCategories/ArticleCategoriesView.swift b/godtools/App/Features/Articles/Presentation/ArticleCategories/ArticleCategoriesView.swift index 632a8a6be7..9401701c3a 100644 --- a/godtools/App/Features/Articles/Presentation/ArticleCategories/ArticleCategoriesView.swift +++ b/godtools/App/Features/Articles/Presentation/ArticleCategories/ArticleCategoriesView.swift @@ -117,9 +117,14 @@ extension ArticleCategoriesView: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell: ArticleCategoryCell = categoriesTableView.dequeueReusableCell( + guard let cell = categoriesTableView.dequeueReusableCell( withIdentifier: ArticleCategoryCell.reuseIdentifier, - for: indexPath) as! ArticleCategoryCell + for: indexPath) as? ArticleCategoryCell else { + + assertionFailure("Failed to dequeue reusable cell with identifier :\(ArticleCategoryCell.reuseIdentifier)") + + return UITableViewCell() + } let cellViewModel: ArticleCategoryCellViewModel = viewModel.categoryWillAppear(index: indexPath.row) diff --git a/godtools/App/Features/Articles/Presentation/ArticleDebug/ArticleDebugView.swift b/godtools/App/Features/Articles/Presentation/ArticleDebug/ArticleDebugView.swift index 02f3c8ab8c..497f9a3e8b 100644 --- a/godtools/App/Features/Articles/Presentation/ArticleDebug/ArticleDebugView.swift +++ b/godtools/App/Features/Articles/Presentation/ArticleDebug/ArticleDebugView.swift @@ -53,5 +53,3 @@ struct ArticleDebugView: View { } } } - - diff --git a/godtools/App/Features/Articles/Presentation/Articles/ArticlesView.swift b/godtools/App/Features/Articles/Presentation/Articles/ArticlesView.swift index d62f1f1852..352127b656 100644 --- a/godtools/App/Features/Articles/Presentation/Articles/ArticlesView.swift +++ b/godtools/App/Features/Articles/Presentation/Articles/ArticlesView.swift @@ -116,9 +116,14 @@ extension ArticlesView: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell: ArticleCell = articlesTableView.dequeueReusableCell( + guard let cell: ArticleCell = articlesTableView.dequeueReusableCell( withIdentifier: ArticleCell.reuseIdentifier, - for: indexPath) as! ArticleCell + for: indexPath) as? ArticleCell else { + + assertionFailure("Failed to dequeue reusable cell with identifier :\(ArticleCell.reuseIdentifier)") + + return UITableViewCell() + } cell.configure(viewModel: viewModel.articleWillAppear(index: indexPath.row)) diff --git a/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebView.swift b/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebView.swift index 4ac50146e3..5a6d6f9d17 100644 --- a/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebView.swift +++ b/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebView.swift @@ -12,8 +12,8 @@ import WebKit class ArticleWebView: AppViewController { private let viewModel: ArticleWebViewModel - - private var webView: WKWebView! + private let webView: WKWebView = WKWebView(frame: UIScreen.main.bounds) + private var currentViewState: ArticleWebViewState? @IBOutlet weak private var loadingView: UIActivityIndicatorView! @@ -24,7 +24,6 @@ class ArticleWebView: AppViewController { init(viewModel: ArticleWebViewModel, navigationBar: AppNavigationBar?) { - self.webView = WKWebView(frame: UIScreen.main.bounds) self.viewModel = viewModel super.init(nibName: String(describing: ArticleWebView.self), bundle: nil, navigationBar: navigationBar) @@ -94,7 +93,7 @@ class ArticleWebView: AppViewController { switch currentViewState { - case .errorMessage( _, _): + case .errorMessage( _, _): errorTitleLabel.text = "" errorMessageLabel.text = "" setErrorViewHidden(hidden: true) diff --git a/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebViewModel.swift b/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebViewModel.swift index 3d8aff6a45..0144ea1178 100644 --- a/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebViewModel.swift +++ b/godtools/App/Features/Articles/Presentation/ArticlesWeb/ArticleWebViewModel.swift @@ -223,14 +223,14 @@ extension ArticleWebViewModel { extension ArticleWebViewModel: WKNavigationDelegate { - func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation) { stopDisplayArticleTimer() viewState.accept(value: .viewingArticle) } - func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { + func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation, withError error: Error) { stopDisplayArticleTimer() diff --git a/godtools/App/Features/Articles/Presentation/LoadingArticle/LoadingArticleView.swift b/godtools/App/Features/Articles/Presentation/LoadingArticle/LoadingArticleView.swift index b66e40baab..09e175c0cd 100644 --- a/godtools/App/Features/Articles/Presentation/LoadingArticle/LoadingArticleView.swift +++ b/godtools/App/Features/Articles/Presentation/LoadingArticle/LoadingArticleView.swift @@ -22,9 +22,4 @@ class LoadingArticleView: LoadingView { required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - - override func setupLayout() { - super.setupLayout() - } } - diff --git a/godtools/App/Features/Dashboard/Domain/Entities/ToolDomainModel.swift b/godtools/App/Features/Dashboard/Domain/Entities/ToolDomainModel.swift index 4a145d2209..1eb65ed846 100644 --- a/godtools/App/Features/Dashboard/Domain/Entities/ToolDomainModel.swift +++ b/godtools/App/Features/Dashboard/Domain/Entities/ToolDomainModel.swift @@ -28,8 +28,8 @@ struct ToolDomainModel: ToolListItemDomainModelInterface { } extension ToolDomainModel: Equatable { - static func ==(lhs: ToolDomainModel, rhs: ToolDomainModel) -> Bool { - return lhs.dataModelId == rhs.dataModelId + static func == (this: ToolDomainModel, that: ToolDomainModel) -> Bool { + return this.dataModelId == that.dataModelId } } diff --git a/godtools/App/Features/Dashboard/Domain/UseCases/DisableOptInOnboardingBannerUseCase.swift b/godtools/App/Features/Dashboard/Domain/UseCases/DisableOptInOnboardingBannerUseCase.swift index 971a2bff25..889e9c1305 100644 --- a/godtools/App/Features/Dashboard/Domain/UseCases/DisableOptInOnboardingBannerUseCase.swift +++ b/godtools/App/Features/Dashboard/Domain/UseCases/DisableOptInOnboardingBannerUseCase.swift @@ -8,7 +8,6 @@ import Foundation - class DisableOptInOnboardingBannerUseCase { private let optInOnboardingBannerEnabledRepository: OptInOnboardingBannerEnabledRepository diff --git a/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureView.swift b/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureView.swift index 7d321fc6c4..eb99c99677 100644 --- a/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureView.swift +++ b/godtools/App/Features/Dashboard/Presentation/ChooseYourOwnAdventure/ChooseYourOwnAdventureView.swift @@ -38,10 +38,6 @@ class ChooseYourOwnAdventureView: MobileContentPagesView { pageNavigationView.gestureScrollingEnabled = false } - override func setupBinding() { - super.setupBinding() - } - func languageTapped(index: Int) { viewModel.languageTapped(index: index) } diff --git a/godtools/App/Features/Dashboard/Presentation/Dashboard/DashboardViewModel.swift b/godtools/App/Features/Dashboard/Presentation/Dashboard/DashboardViewModel.swift index f1b5245c1e..5c26357d5f 100644 --- a/godtools/App/Features/Dashboard/Presentation/Dashboard/DashboardViewModel.swift +++ b/godtools/App/Features/Dashboard/Presentation/Dashboard/DashboardViewModel.swift @@ -63,7 +63,9 @@ class DashboardViewModel: ObservableObject { $currentTab.eraseToAnyPublisher() .sink { [weak self] currentTab in - guard let self = self else { return } + guard let self = self else { + return + } dashboardTabObserver.send(self.tabs[currentTab]) } diff --git a/godtools/App/Features/Dashboard/Presentation/Tool/ToolView.swift b/godtools/App/Features/Dashboard/Presentation/Tool/ToolView.swift index cecb1d0087..6f3498e140 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tool/ToolView.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tool/ToolView.swift @@ -30,10 +30,6 @@ class ToolView: MobileContentPagesView { print("view didload: \(type(of: self))") } - override func setupLayout() { - super.setupLayout() - } - override func setupBinding() { super.setupBinding() @@ -52,10 +48,6 @@ class ToolView: MobileContentPagesView { } } - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - } - override func didConfigurePageView(pageView: MobileContentPageView) { if let toolPageView = pageView as? ToolPageView { toolPageView.setToolPageDelegate(delegate: self) diff --git a/godtools/App/Features/Dashboard/Presentation/Tool/ToolViewModel.swift b/godtools/App/Features/Dashboard/Presentation/Tool/ToolViewModel.swift index 0a376bb2d2..56f429377b 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tool/ToolViewModel.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tool/ToolViewModel.swift @@ -125,11 +125,13 @@ class ToolViewModel: MobileContentPagesViewModel { } private func getPageRenderer(language: LanguageDomainModel) -> MobileContentPageRenderer? { - for pageRenderer in renderer.value.pageRenderers { - if pageRenderer.language.localeIdentifier.lowercased() == language.localeIdentifier.lowercased() { - return pageRenderer - } + + let languageLocaleId: String = language.localeIdentifier.lowercased() + + for pageRenderer in renderer.value.pageRenderers where pageRenderer.language.localeIdentifier.lowercased() == languageLocaleId { + return pageRenderer } + return nil } diff --git a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift index 167972fc5e..0f86e06700 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardView.swift @@ -168,7 +168,7 @@ struct ToolCardView: View { }) } - }//end ZStack + }// end ZStack .frame(width: cardWidth) .cornerRadius(cornerRadius) .shadow(color: Color.black.opacity(0.25), radius: 4, y: 2) diff --git a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardViewModel.swift b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardViewModel.swift index 82174dceb9..fa797d5897 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardViewModel.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tools/Subviews/ToolCard/ToolCardViewModel.swift @@ -23,7 +23,7 @@ class ToolCardViewModel: ObservableObject { @Published var isFavorited = false @Published var name: String = "" @Published var category: String = "" - @Published var languageAvailability: String? = nil + @Published var languageAvailability: String? @Published var detailsButtonTitle: String = "" @Published var openButtonTitle: String = "" diff --git a/godtools/App/Features/Dashboard/Presentation/Tools/ToolsViewModel.swift b/godtools/App/Features/Dashboard/Presentation/Tools/ToolsViewModel.swift index 004d2018f7..865cabd5e9 100644 --- a/godtools/App/Features/Dashboard/Presentation/Tools/ToolsViewModel.swift +++ b/godtools/App/Features/Dashboard/Presentation/Tools/ToolsViewModel.swift @@ -14,7 +14,7 @@ class ToolsViewModel: ObservableObject { typealias ToolId = String - private static var favoriteToolCancellables: Dictionary = Dictionary() + private static var favoriteToolCancellables: [ToolId: AnyCancellable?] = Dictionary() private let resourcesRepository: ResourcesRepository private let viewToolsUseCase: ViewToolsUseCase @@ -74,7 +74,7 @@ class ToolsViewModel: ObservableObject { $toolFilterCategorySelection.eraseToAnyPublisher().dropFirst(), $toolFilterLanguageSelection.eraseToAnyPublisher().dropFirst() ) - .map{ (appLanguage, toolFilterCategory, toolFilterLanguage) in + .map { (appLanguage, toolFilterCategory, toolFilterLanguage) in Publishers.CombineLatest( viewToolsUseCase.viewPublisher( diff --git a/godtools/App/Features/DownloadToolProgress/Data-DomainInterface/GetDownloadToolProgressInterfaceStringsRepository.swift b/godtools/App/Features/DownloadToolProgress/Data-DomainInterface/GetDownloadToolProgressInterfaceStringsRepository.swift index f07a5f7852..148c1678fd 100644 --- a/godtools/App/Features/DownloadToolProgress/Data-DomainInterface/GetDownloadToolProgressInterfaceStringsRepository.swift +++ b/godtools/App/Features/DownloadToolProgress/Data-DomainInterface/GetDownloadToolProgressInterfaceStringsRepository.swift @@ -56,7 +56,7 @@ class GetDownloadToolProgressInterfaceStringsRepository: GetDownloadToolProgress } let interfaceStrings = DownloadToolProgressInterfaceStringsDomainModel( - downloadMessage: downloadMessage + downloadMessage: downloadMessage ) return Just(interfaceStrings) diff --git a/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesView.swift b/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesView.swift index 8893e88bbd..7ce382c4b7 100644 --- a/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesView.swift +++ b/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesView.swift @@ -64,9 +64,10 @@ struct FavoritesView: View { geometry: geometry, contentHorizontalInsets: contentHorizontalInsets, lessonTappedClosure: { (featuredLesson: FeaturedLessonDomainModel) in - - viewModel.featuredLessonTapped(featuredLesson: featuredLesson) - }) + + viewModel.featuredLessonTapped(featuredLesson: featuredLesson) + } + ) .padding([.top], 30) YourFavoriteToolsView( diff --git a/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesViewModel.swift b/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesViewModel.swift index c144420eaf..73dd328f5d 100644 --- a/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesViewModel.swift +++ b/godtools/App/Features/Favorites/Presentation/Favorites/FavoritesViewModel.swift @@ -158,7 +158,7 @@ class FavoritesViewModel: ObservableObject { data: [ AnalyticsConstants.Keys.source: AnalyticsConstants.Sources.featured, AnalyticsConstants.Keys.tool: featuredLesson.analyticsToolName - ] + ] ) } diff --git a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/FeaturedLessons/FeaturedLessonsView.swift b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/FeaturedLessons/FeaturedLessonsView.swift index d96aad9177..c4fc28fac7 100644 --- a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/FeaturedLessons/FeaturedLessonsView.swift +++ b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/FeaturedLessons/FeaturedLessonsView.swift @@ -44,8 +44,9 @@ struct FeaturedLessonsView: View { geometry: geometry, cardTappedClosure: { - lessonTappedClosure?(featuredLesson) - }) + lessonTappedClosure?(featuredLesson) + } + ) } } .padding([.top], lessonCardSpacing) diff --git a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/OpenTutorialBanner/OpenTutorialBannerView.swift b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/OpenTutorialBanner/OpenTutorialBannerView.swift index a76cec7640..5fc3e34b45 100644 --- a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/OpenTutorialBanner/OpenTutorialBannerView.swift +++ b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/OpenTutorialBanner/OpenTutorialBannerView.swift @@ -38,7 +38,7 @@ struct OpenTutorialBannerView: View { .font(FontLibrary.sfProTextRegular.font(size: 17)) .onTapGesture { openTutorialTappedClosure?() - } + } Image(ImageCatalog.openTutorialArrow.name) .resizable() diff --git a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/Subviews/NoFavoriteTools/NoFavoriteToolsView.swift b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/Subviews/NoFavoriteTools/NoFavoriteToolsView.swift index d5bbab84a8..26ac2a3a81 100644 --- a/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/Subviews/NoFavoriteTools/NoFavoriteToolsView.swift +++ b/godtools/App/Features/Favorites/Presentation/Favorites/Subviews/YourFavoriteTools/Subviews/NoFavoriteTools/NoFavoriteToolsView.swift @@ -20,7 +20,7 @@ struct NoFavoriteToolsView: View { var body: some View { ZStack { - Color(.sRGB, red: 243/256, green: 243/256, blue: 243/256, opacity: 1) + Color(.sRGB, red: 243 / 256, green: 243 / 256, blue: 243 / 256, opacity: 1) VStack(spacing: 4) { diff --git a/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/Cache/RealmGlobalAnalyticsCache.swift b/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/Cache/RealmGlobalAnalyticsCache.swift index fecec67d53..af3974db36 100644 --- a/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/Cache/RealmGlobalAnalyticsCache.swift +++ b/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/Cache/RealmGlobalAnalyticsCache.swift @@ -21,7 +21,9 @@ class RealmGlobalAnalyticsCache { func getGlobalAnalyticsChangedPublisher(id: String) -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmGlobalAnalytics.self).objectWillChange + return realmDatabase.openRealm() + .objects(RealmGlobalAnalytics.self) + .objectWillChange .map { _ in return self.getGlobalAnalytics(id: id) diff --git a/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/GlobalAnalyticsRepository.swift b/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/GlobalAnalyticsRepository.swift index ade3a88f14..80f4d4b480 100644 --- a/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/GlobalAnalyticsRepository.swift +++ b/godtools/App/Features/GlobalActivity/Data/GlobalAnalyticsRepository/GlobalAnalyticsRepository.swift @@ -27,7 +27,6 @@ class GlobalAnalyticsRepository { getGlobalAnalyticsFromRemotePublisher() .sink { value in - } receiveValue: { value in } diff --git a/godtools/App/Features/GlobalActivity/DependencyContainer/GlobalActivityDataLayerDependencies.swift b/godtools/App/Features/GlobalActivity/DependencyContainer/GlobalActivityDataLayerDependencies.swift index 307f750ba8..2154696f72 100644 --- a/godtools/App/Features/GlobalActivity/DependencyContainer/GlobalActivityDataLayerDependencies.swift +++ b/godtools/App/Features/GlobalActivity/DependencyContainer/GlobalActivityDataLayerDependencies.swift @@ -22,7 +22,7 @@ class GlobalActivityDataLayerDependencies { private func getGlobalAnalyticsRepository() -> GlobalAnalyticsRepository { return GlobalAnalyticsRepository( - api: MobileContentGlobalAnalyticsApi( + api: MobileContentGlobalAnalyticsApi( baseUrl: coreDataLayer.getAppConfig().getMobileContentApiBaseUrl(), ignoreCacheSession: coreDataLayer.getSharedIgnoreCacheSession() ), diff --git a/godtools/App/Features/LearnToShareTool/Data-DomainInterface/GetLearnToShareToolTutorialItemsRepository.swift b/godtools/App/Features/LearnToShareTool/Data-DomainInterface/GetLearnToShareToolTutorialItemsRepository.swift index 93661da592..bcf8a05b19 100644 --- a/godtools/App/Features/LearnToShareTool/Data-DomainInterface/GetLearnToShareToolTutorialItemsRepository.swift +++ b/godtools/App/Features/LearnToShareTool/Data-DomainInterface/GetLearnToShareToolTutorialItemsRepository.swift @@ -32,7 +32,7 @@ class GetLearnToShareToolTutorialItemsRepository: GetLearnToShareToolTutorialIte ), LearnToShareToolItemDomainModel( imageName: nil, - animationName: "training_tip_callout", + animationName: "training_tip_callout", title: localizationServices.stringForLocaleElseEnglish(localeIdentifier: localeId, key: "learn_to_share_tool.tips_light_the_way.title"), message: localizationServices.stringForLocaleElseEnglish(localeIdentifier: localeId, key: "learn_to_share_tool.tips_light_the_way.message") ), diff --git a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/LearnToShareToolViewModel.swift b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/LearnToShareToolViewModel.swift index 4ba4f730ad..36902d1f2f 100644 --- a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/LearnToShareToolViewModel.swift +++ b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/LearnToShareToolViewModel.swift @@ -121,7 +121,7 @@ extension LearnToShareToolViewModel { return } - currentPage = currentPage - 1 + currentPage -= 1 } @objc func closeTapped() { @@ -134,7 +134,7 @@ extension LearnToShareToolViewModel { flowDelegate?.navigate(step: .continueTappedFromLearnToShareTool(toolId: toolId, primaryLanguage: toolPrimaryLanguage, parallelLanguage: toolParallelLanguage, selectedLanguageIndex: toolSelectedLanguageIndex)) } else { - currentPage = currentPage + 1 + currentPage += 1 } } } diff --git a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemAssetContent.swift b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemAssetContent.swift index 39ebdbc196..e6023730fb 100644 --- a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemAssetContent.swift +++ b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemAssetContent.swift @@ -12,5 +12,5 @@ enum LearnToShareToolItemAssetContent { case animation(viewModel: AnimatedViewModel) case image(image: Image) - case none + case noAsset } diff --git a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemView.swift b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemView.swift index c2a6d831e5..787c41b034 100644 --- a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemView.swift +++ b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemView.swift @@ -42,7 +42,7 @@ struct LearnToShareToolItemView: View { .resizable() .scaledToFit() - case .none: + case .noAsset: Rectangle() .fill(.clear) diff --git a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemViewModel.swift b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemViewModel.swift index 68c485fb2f..a23cf35400 100644 --- a/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemViewModel.swift +++ b/godtools/App/Features/LearnToShareTool/Presentation/LearnToShareTool/Subviews/LearnToShareToolItem/LearnToShareToolItemViewModel.swift @@ -37,7 +37,7 @@ class LearnToShareToolItemViewModel: ObservableObject { } else { - assetContent = .none + assetContent = .noAsset } } diff --git a/godtools/App/Features/LessonEvaluation/Domain/UseCases/GetLessonEvaluatedUseCase.swift b/godtools/App/Features/LessonEvaluation/Domain/UseCases/GetLessonEvaluatedUseCase.swift index fd54b72e4d..d8cf3c39bb 100644 --- a/godtools/App/Features/LessonEvaluation/Domain/UseCases/GetLessonEvaluatedUseCase.swift +++ b/godtools/App/Features/LessonEvaluation/Domain/UseCases/GetLessonEvaluatedUseCase.swift @@ -11,9 +11,9 @@ import Combine class GetLessonEvaluatedUseCase { - private let getLessonEvaluatedRepositoryInterface: GetLessonEvaluatedRepositoryInterface + private let getLessonEvaluatedRepositoryInterface: GetLessonEvaluatedRepositoryInterface - init(getLessonEvaluatedRepositoryInterface: GetLessonEvaluatedRepositoryInterface) { + init(getLessonEvaluatedRepositoryInterface: GetLessonEvaluatedRepositoryInterface) { self.getLessonEvaluatedRepositoryInterface = getLessonEvaluatedRepositoryInterface } diff --git a/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationView.swift b/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationView.swift index b4338125bb..c1497cd78a 100644 --- a/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationView.swift +++ b/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationView.swift @@ -39,7 +39,8 @@ struct LessonEvaluationView: View { buttonSize: closeButtonSize, tapped: { viewModel.closeTapped() - }) + } + ) .padding([.top], closeButtonTop) .padding([.trailing], 5) } diff --git a/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationViewModel.swift b/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationViewModel.swift index 431655a2d8..e93e6b2fba 100644 --- a/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationViewModel.swift +++ b/godtools/App/Features/LessonEvaluation/Presentation/LessonEvaluation/LessonEvaluationViewModel.swift @@ -36,7 +36,7 @@ class LessonEvaluationViewModel: ObservableObject { @Published var noButtonTitle: String = "" @Published var shareFaithReadiness: String = "" @Published var sendFeedbackButtonTitle: String = "" - @Published var readyToShareFaithScale: SpiritualConversationReadinessScaleDomainModel? = nil + @Published var readyToShareFaithScale: SpiritualConversationReadinessScaleDomainModel? @Published var readyToShareFaithScaleIntValue: Int = 6 init(flowDelegate: FlowDelegate, lessonId: String, pageIndexReached: Int, getCurrentAppLanguageUseCase: GetCurrentAppLanguageUseCase, getLessonEvaluationInterfaceStringsUseCase: GetLessonEvaluationInterfaceStringsUseCase, didChangeScaleForSpiritualConversationReadinessUseCase: DidChangeScaleForSpiritualConversationReadinessUseCase, evaluateLessonUseCase: EvaluateLessonUseCase, cancelLessonEvaluationUseCase: CancelLessonEvaluationUseCase) { diff --git a/godtools/App/Features/Lessons/Presentation/Lesson/LessonViewModel.swift b/godtools/App/Features/Lessons/Presentation/Lesson/LessonViewModel.swift index a41659192d..7393e71278 100644 --- a/godtools/App/Features/Lessons/Presentation/Lesson/LessonViewModel.swift +++ b/godtools/App/Features/Lessons/Presentation/Lesson/LessonViewModel.swift @@ -18,7 +18,7 @@ class LessonViewModel: MobileContentPagesViewModel { self.flowDelegate = flowDelegate - super.init(renderer: renderer,initialPage: initialPage, resourcesRepository: resourcesRepository, translationsRepository: translationsRepository, mobileContentEventAnalytics: mobileContentEventAnalytics, getCurrentAppLanguageUseCase: getCurrentAppLanguageUseCase, getTranslatedLanguageName: getTranslatedLanguageName, initialPageRenderingType: .visiblePages, trainingTipsEnabled: trainingTipsEnabled, incrementUserCounterUseCase: incrementUserCounterUseCase, selectedLanguageIndex: nil) + super.init(renderer: renderer, initialPage: initialPage, resourcesRepository: resourcesRepository, translationsRepository: translationsRepository, mobileContentEventAnalytics: mobileContentEventAnalytics, getCurrentAppLanguageUseCase: getCurrentAppLanguageUseCase, getTranslatedLanguageName: getTranslatedLanguageName, initialPageRenderingType: .visiblePages, trainingTipsEnabled: trainingTipsEnabled, incrementUserCounterUseCase: incrementUserCounterUseCase, selectedLanguageIndex: nil) } deinit { diff --git a/godtools/App/Features/Lessons/Presentation/Lessons/LessonsView.swift b/godtools/App/Features/Lessons/Presentation/Lessons/LessonsView.swift index ea592916a3..80b8cfe259 100644 --- a/godtools/App/Features/Lessons/Presentation/Lessons/LessonsView.swift +++ b/godtools/App/Features/Lessons/Presentation/Lessons/LessonsView.swift @@ -53,8 +53,9 @@ struct LessonsView: View { geometry: geometry, cardTappedClosure: { - viewModel.lessonCardTapped(lessonListItem: lessonListItem) - }) + viewModel.lessonCardTapped(lessonListItem: lessonListItem) + } + ) } } .padding([.top], lessonCardSpacing) diff --git a/godtools/App/Features/Menu/Domain/UseCases/GetUserAccountDetailsUseCase/GetUserAccountDetailsUseCase.swift b/godtools/App/Features/Menu/Domain/UseCases/GetUserAccountDetailsUseCase/GetUserAccountDetailsUseCase.swift index e1c72454f2..ab573493e3 100644 --- a/godtools/App/Features/Menu/Domain/UseCases/GetUserAccountDetailsUseCase/GetUserAccountDetailsUseCase.swift +++ b/godtools/App/Features/Menu/Domain/UseCases/GetUserAccountDetailsUseCase/GetUserAccountDetailsUseCase.swift @@ -24,12 +24,16 @@ class GetUserAccountDetailsUseCase { func getUserAccountDetailsPublisher(appLanguage: AppLanguageDomainModel) -> AnyPublisher { return Publishers.CombineLatest( - repository.getAuthUserDetailsFromRemotePublisher().prepend(UserDetailsDataModel.emptyDataModel()) + repository + .getAuthUserDetailsFromRemotePublisher() + .prepend(UserDetailsDataModel.emptyDataModel()) .catch({ _ in return Just(UserDetailsDataModel.emptyDataModel()) .eraseToAnyPublisher() }), - repository.getAuthUserDetailsChangedPublisher().prepend(nil) + repository + .getAuthUserDetailsChangedPublisher() + .prepend(nil) ) .flatMap({ (remoteUserDetails: UserDetailsDataModel, changedUserDetails: UserDetailsDataModel?) -> AnyPublisher in diff --git a/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityStatsUseCase/UserActivityStatDomainModel.swift b/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityStatsUseCase/UserActivityStatDomainModel.swift index aca3b34b1a..af112a1e72 100644 --- a/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityStatsUseCase/UserActivityStatDomainModel.swift +++ b/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityStatsUseCase/UserActivityStatDomainModel.swift @@ -24,4 +24,3 @@ extension UserActivityStatDomainModel: Identifiable { return text } } - diff --git a/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityUseCase/GetUserActivityUseCase.swift b/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityUseCase/GetUserActivityUseCase.swift index e3786b339a..b46b6980c8 100644 --- a/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityUseCase/GetUserActivityUseCase.swift +++ b/godtools/App/Features/Menu/Domain/UseCases/GetUserActivityUseCase/GetUserActivityUseCase.swift @@ -30,15 +30,14 @@ class GetUserActivityUseCase { return userCounterRepository .getUserCountersChanged(reloadFromRemote: true) .flatMap { _ in - + let allUserCounters = self.getAllUserCounters() - + let userActivityDomainModel = self.getUserActivityDomainModel(from: allUserCounters, translatedInAppLanguage: appLanguage) - - return Just(userActivityDomainModel) - - } - .eraseToAnyPublisher() + + return Just(userActivityDomainModel) + } + .eraseToAnyPublisher() } private func getAllUserCounters() -> [UserCounterDomainModel] { diff --git a/godtools/App/Features/Menu/Presentation/Menu/Subviews/MenuItemView.swift b/godtools/App/Features/Menu/Presentation/Menu/Subviews/MenuItemView.swift index 5a5dc1b28c..d1dfbb462c 100644 --- a/godtools/App/Features/Menu/Presentation/Menu/Subviews/MenuItemView.swift +++ b/godtools/App/Features/Menu/Presentation/Menu/Subviews/MenuItemView.swift @@ -60,4 +60,3 @@ struct MenuItemView: View { } } } - diff --git a/godtools/App/Features/Menu/Presentation/WebContent/WebContentView.swift b/godtools/App/Features/Menu/Presentation/WebContent/WebContentView.swift index 6a7756eac6..433bdb58a7 100644 --- a/godtools/App/Features/Menu/Presentation/WebContent/WebContentView.swift +++ b/godtools/App/Features/Menu/Presentation/WebContent/WebContentView.swift @@ -12,14 +12,12 @@ import WebKit class WebContentView: AppViewController { private let viewModel: WebContentViewModel - - private var webView: WKWebView! + private let webView: WKWebView = WKWebView(frame: UIScreen.main.bounds) @IBOutlet weak private var loadingView: UIActivityIndicatorView! init(viewModel: WebContentViewModel, navigationBar: AppNavigationBar?) { - self.webView = WKWebView(frame: UIScreen.main.bounds) self.viewModel = viewModel super.init(nibName: String(describing: WebContentView.self), bundle: nil, navigationBar: navigationBar) @@ -87,7 +85,7 @@ class WebContentView: AppViewController { extension WebContentView: WKNavigationDelegate { - func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + func webView(_ webView: WKWebView, didFinish navigation: WKNavigation) { finishedLoadingWebView() } diff --git a/godtools/App/Features/PersistUserToolLanguageSettings/Data/UserToolSettingsRepository/Cache/RealmUserToolSettings.swift b/godtools/App/Features/PersistUserToolLanguageSettings/Data/UserToolSettingsRepository/Cache/RealmUserToolSettings.swift index 82614e16ce..908c77b953 100644 --- a/godtools/App/Features/PersistUserToolLanguageSettings/Data/UserToolSettingsRepository/Cache/RealmUserToolSettings.swift +++ b/godtools/App/Features/PersistUserToolLanguageSettings/Data/UserToolSettingsRepository/Cache/RealmUserToolSettings.swift @@ -14,7 +14,7 @@ class RealmUserToolSettings: Object { @Persisted var createdAt: Date = Date() @Persisted var toolId: String = "" @Persisted var primaryLanguageId: String = "" - @Persisted var parallelLanguageId: String? = nil + @Persisted var parallelLanguageId: String? @Persisted var selectedLanguageId: String = "" override static func primaryKey() -> String? { diff --git a/godtools/App/Features/Shareables/Domain/Entities/ShareableDomainModel.swift b/godtools/App/Features/Shareables/Domain/Entities/ShareableDomainModel.swift index a75b66d6a2..e36cf48562 100644 --- a/godtools/App/Features/Shareables/Domain/Entities/ShareableDomainModel.swift +++ b/godtools/App/Features/Shareables/Domain/Entities/ShareableDomainModel.swift @@ -22,7 +22,7 @@ extension ShareableDomainModel: Identifiable { } extension ShareableDomainModel: Equatable { - static func ==(lhs: ShareableDomainModel, rhs: ShareableDomainModel) -> Bool { - return lhs.dataModelId == rhs.dataModelId + static func == (this: ShareableDomainModel, that: ShareableDomainModel) -> Bool { + return this.dataModelId == that.dataModelId } } diff --git a/godtools/App/Features/ToolDetails/Data-DomainInterface/GetToolDetailsLearnToShareToolIsAvailableRepository.swift b/godtools/App/Features/ToolDetails/Data-DomainInterface/GetToolDetailsLearnToShareToolIsAvailableRepository.swift index affea26241..d19676639e 100644 --- a/godtools/App/Features/ToolDetails/Data-DomainInterface/GetToolDetailsLearnToShareToolIsAvailableRepository.swift +++ b/godtools/App/Features/ToolDetails/Data-DomainInterface/GetToolDetailsLearnToShareToolIsAvailableRepository.swift @@ -30,7 +30,7 @@ class GetToolDetailsLearnToShareToolIsAvailableRepository: GetToolDetailsLearnTo let includeRelatedFiles: Bool = false return translationsRepository.getTranslationManifestFromCache(translation: translation, manifestParserType: manifestParserType, includeRelatedFiles: includeRelatedFiles) - .catch ({ (cacheError: Error) -> AnyPublisher in + .catch({ (cacheError: Error) -> AnyPublisher in return self.translationsRepository.getTranslationManifestFromRemote( translation: translation, diff --git a/godtools/App/Features/ToolDetails/Presentation/ToolDetails/Subviews/ToolDetailsToggleFavoriteButton.swift b/godtools/App/Features/ToolDetails/Presentation/ToolDetails/Subviews/ToolDetailsToggleFavoriteButton.swift index 4303460588..6715784972 100644 --- a/godtools/App/Features/ToolDetails/Presentation/ToolDetails/Subviews/ToolDetailsToggleFavoriteButton.swift +++ b/godtools/App/Features/ToolDetails/Presentation/ToolDetails/Subviews/ToolDetailsToggleFavoriteButton.swift @@ -62,4 +62,3 @@ struct ToolDetailsToggleFavoriteButton: View { ) } } - diff --git a/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsView.swift b/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsView.swift index be42c9b73b..c13e0d39bf 100644 --- a/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsView.swift +++ b/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsView.swift @@ -42,50 +42,49 @@ struct ToolDetailsView: View { ToolDetailsMediaView(viewModel: viewModel, width: geometry.size.width) VStack(alignment: .center, spacing: 0) { - - ToolDetailsTitleHeaderView(viewModel: viewModel) - .padding(EdgeInsets(top: 40, leading: contentInsets.leading, bottom: 0, trailing: contentInsets.trailing)) - - ToolDetailsPrimaryButtonsView(viewModel: viewModel, primaryButtonWidth: contentWidth) - .padding(EdgeInsets(top: 16, leading: contentInsets.leading, bottom: 0, trailing: contentInsets.trailing)) - - SegmentControl(selectedIndex: $selectedSegmentIndex, segments: viewModel.segments, segmentTappedClosure: { (index: Int) in - - viewModel.segmentTapped(index: index) - }) - .padding(EdgeInsets(top: 50, leading: 0, bottom: 0, trailing: 0)) - } - .background(Rectangle() - .fill(Color.white) - .shadow(color: Color.black.opacity(0.3), radius: 4, x: 0, y: 1) - .mask(Rectangle().padding(.bottom, -8)) - ) - - Rectangle() - .frame(width: geometry.size.width, height: 20) - .foregroundColor(.clear) - - switch viewModel.selectedSegment { - - case .about: - ToolDetailsAboutView( + + ToolDetailsTitleHeaderView(viewModel: viewModel) + .padding(EdgeInsets(top: 40, leading: contentInsets.leading, bottom: 0, trailing: contentInsets.trailing)) + + ToolDetailsPrimaryButtonsView(viewModel: viewModel, primaryButtonWidth: contentWidth) + .padding(EdgeInsets(top: 16, leading: contentInsets.leading, bottom: 0, trailing: contentInsets.trailing)) + + SegmentControl(selectedIndex: $selectedSegmentIndex, segments: viewModel.segments, segmentTappedClosure: { (index: Int) in + viewModel.segmentTapped(index: index) + }) + .padding(EdgeInsets(top: 50, leading: 0, bottom: 0, trailing: 0)) + } + .background(Rectangle() + .fill(Color.white) + .shadow(color: Color.black.opacity(0.3), radius: 4, x: 0, y: 1) + .mask(Rectangle().padding(.bottom, -8)) + ) + + Rectangle() + .frame(width: geometry.size.width, height: 20) + .foregroundColor(.clear) + + switch viewModel.selectedSegment { + + case .about: + ToolDetailsAboutView( viewModel: viewModel, geometry: geometry - ) - - case .versions: - ToolDetailsVersionsView( + ) + + case .versions: + ToolDetailsVersionsView( viewModel: viewModel, geometry: geometry, toolVersionTappedClosure: { scrollViewReader.scrollTo(ToolDetailsView.scrollToTopViewId) } - ) - } - - Rectangle() - .frame(width: geometry.size.width, height: 20) - .foregroundColor(.clear) + ) + } + + Rectangle() + .frame(width: geometry.size.width, height: 20) + .foregroundColor(.clear) } .frame(width: geometry.size.width) } diff --git a/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsViewModel.swift b/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsViewModel.swift index aee500d493..f193e6e71b 100644 --- a/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsViewModel.swift +++ b/godtools/App/Features/ToolDetails/Presentation/ToolDetails/ToolDetailsViewModel.swift @@ -14,7 +14,7 @@ class ToolDetailsViewModel: ObservableObject { typealias ToolId = String - private static var toggleToolFavoritedCancellables: Dictionary = Dictionary() + private static var toggleToolFavoritedCancellables: [ToolId: AnyCancellable?] = Dictionary() private let getCurrentAppLanguageUseCase: GetCurrentAppLanguageUseCase private let viewToolDetailsUseCase: ViewToolDetailsUseCase diff --git a/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteSharePublisher/TractRemoteSharePublisher.swift b/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteSharePublisher/TractRemoteSharePublisher.swift index 77b6b3a389..b99728864f 100644 --- a/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteSharePublisher/TractRemoteSharePublisher.swift +++ b/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteSharePublisher/TractRemoteSharePublisher.swift @@ -141,7 +141,7 @@ class TractRemoteSharePublisher: NSObject { } } - // MARK: Timeout Timer + // MARK: Timeout Timer private func startTimeoutTimer() { @@ -173,7 +173,7 @@ class TractRemoteSharePublisher: NSObject { if loggingEnabled { print("\n TractRemoteSharePublisher \(method)") if let label = label, let labelValue = labelValue { - print(" \(label): \(labelValue)") + print(" \(label): \(labelValue)") } } } diff --git a/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteShareSubscriber/TractRemoteShareSubscriber.swift b/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteShareSubscriber/TractRemoteShareSubscriber.swift index eeb1b0e9ff..47ad9b61cb 100644 --- a/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteShareSubscriber/TractRemoteShareSubscriber.swift +++ b/godtools/App/Features/ToolScreenShare/Data/TractRemoteShare/TractRemoteShareSubscriber/TractRemoteShareSubscriber.swift @@ -112,7 +112,7 @@ class TractRemoteShareSubscriber: NSObject { } } - // MARK: Timeout Timer + // MARK: Timeout Timer private func startTimeoutTimer() { @@ -146,7 +146,7 @@ class TractRemoteShareSubscriber: NSObject { if loggingEnabled { print("\n TractRemoteShareSubscriber \(method)") if let label = label, let labelValue = labelValue { - print(" \(label): \(labelValue)") + print(" \(label): \(labelValue)") } } } diff --git a/godtools/App/Features/ToolScreenShare/Presentation/ToolScreenShareTutorial/ToolScreenShareTutorialViewModel.swift b/godtools/App/Features/ToolScreenShare/Presentation/ToolScreenShareTutorial/ToolScreenShareTutorialViewModel.swift index 95823361bb..b194459ffb 100644 --- a/godtools/App/Features/ToolScreenShare/Presentation/ToolScreenShareTutorial/ToolScreenShareTutorialViewModel.swift +++ b/godtools/App/Features/ToolScreenShare/Presentation/ToolScreenShareTutorial/ToolScreenShareTutorialViewModel.swift @@ -147,7 +147,7 @@ extension ToolScreenShareTutorialViewModel { } private func nextPageTapped() { - currentPage = currentPage + 1 + currentPage += 1 } private func shareLinkTapped() { diff --git a/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguageDomainModel.swift b/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguageDomainModel.swift index 11feecd5c9..a9ebcabaec 100644 --- a/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguageDomainModel.swift +++ b/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguageDomainModel.swift @@ -21,7 +21,7 @@ extension ToolSettingsToolLanguageDomainModel: Identifiable { } extension ToolSettingsToolLanguageDomainModel: Equatable { - static func ==(lhs: ToolSettingsToolLanguageDomainModel, rhs: ToolSettingsToolLanguageDomainModel) -> Bool { - return lhs.dataModelId == rhs.dataModelId + static func == (this: ToolSettingsToolLanguageDomainModel, that: ToolSettingsToolLanguageDomainModel) -> Bool { + return this.dataModelId == that.dataModelId } } diff --git a/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguagesListTypeDomainModel.swift b/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguagesListTypeDomainModel.swift index 69f0db176e..edfb3730c4 100644 --- a/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguagesListTypeDomainModel.swift +++ b/godtools/App/Features/ToolSettings/Domain/Entities/ToolSettingsToolLanguagesListTypeDomainModel.swift @@ -10,6 +10,6 @@ import Foundation enum ToolSettingsToolLanguagesListTypeDomainModel { - case choosePrimaryLanguage case chooseParallelLanguage + case choosePrimaryLanguage } diff --git a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsChooseLanguage/ToolSettingsChooseLanguageView.swift b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsChooseLanguage/ToolSettingsChooseLanguageView.swift index 993072a0d0..f8eff5599f 100644 --- a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsChooseLanguage/ToolSettingsChooseLanguageView.swift +++ b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsChooseLanguage/ToolSettingsChooseLanguageView.swift @@ -28,7 +28,7 @@ struct ToolSettingsChooseLanguageView: View { var body: some View { VStack(alignment: .leading, spacing: 0) { - VStack (alignment: .leading, spacing: 4) { + VStack(alignment: .leading, spacing: 4) { Text(viewModel.chooseLanguageTitle) .foregroundColor(ColorPalette.gtGrey.color) .font(FontLibrary.sfProTextRegular.font(size: 19)) diff --git a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/Subviews/ToolSettingsOption/ToolSettingsOptionViewTitleColorStyle.swift b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/Subviews/ToolSettingsOption/ToolSettingsOptionViewTitleColorStyle.swift index d97fd29c55..d92794b44b 100644 --- a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/Subviews/ToolSettingsOption/ToolSettingsOptionViewTitleColorStyle.swift +++ b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/Subviews/ToolSettingsOption/ToolSettingsOptionViewTitleColorStyle.swift @@ -10,8 +10,8 @@ import SwiftUI enum ToolSettingsOptionViewTitleColorStyle { - case lightBackground case darkBackground + case lightBackground func getColor() -> Color { switch self { diff --git a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift index 62a877b2b1..476344700a 100644 --- a/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift +++ b/godtools/App/Features/ToolSettings/Presentation/ToolSettings/Subviews/ToolSettingsOptions/ToolSettingsOptionsView.swift @@ -24,8 +24,8 @@ struct ToolSettingsOptionsView: View { var body: some View { - VStack (alignment: .leading, spacing: 0) { - ScrollView (.horizontal, showsIndicators: false) { + VStack(alignment: .leading, spacing: 0) { + ScrollView(.horizontal, showsIndicators: false) { HStack { ToolSettingsOptionView( diff --git a/godtools/App/Features/ToolTraining/Presentation/ToolTrainingView.swift b/godtools/App/Features/ToolTraining/Presentation/ToolTrainingView.swift index be50de6811..4c3abc50b1 100644 --- a/godtools/App/Features/ToolTraining/Presentation/ToolTrainingView.swift +++ b/godtools/App/Features/ToolTraining/Presentation/ToolTrainingView.swift @@ -193,9 +193,14 @@ extension ToolTrainingView: PageNavigationCollectionViewDelegate { func pageNavigation(pageNavigation: PageNavigationCollectionView, cellForPageAt indexPath: IndexPath) -> UICollectionViewCell { - let cell: ToolTrainingTipView = pageNavigation.getReusablePageCell( + guard let cell = pageNavigation.getReusablePageCell( cellReuseIdentifier: ToolTrainingTipView.reuseIdentifier, - indexPath: indexPath) as! ToolTrainingTipView + indexPath: indexPath) as? ToolTrainingTipView else { + + assertionFailure("Failed to dequeue reusable cell with identifier :\(ToolTrainingTipView.reuseIdentifier)") + + return UICollectionViewCell() + } let mobileContentView: MobileContentView? = viewModel.tipPageWillAppear( page: indexPath.row, diff --git a/godtools/App/Features/ToolTraining/Subviews/ToolTrainingTipView.swift b/godtools/App/Features/ToolTraining/Subviews/ToolTrainingTipView.swift index 2347fd6a23..7509dbaf50 100644 --- a/godtools/App/Features/ToolTraining/Subviews/ToolTrainingTipView.swift +++ b/godtools/App/Features/ToolTraining/Subviews/ToolTrainingTipView.swift @@ -15,10 +15,6 @@ class ToolTrainingTipView: UICollectionViewCell { private var mobileContentView: MobileContentView? - override func awakeFromNib() { - super.awakeFromNib() - } - override func prepareForReuse() { super.prepareForReuse() diff --git a/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterCategoriesRepository.swift b/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterCategoriesRepository.swift index d121ad331c..ddbf18d667 100644 --- a/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterCategoriesRepository.swift +++ b/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterCategoriesRepository.swift @@ -43,7 +43,9 @@ class GetToolFilterCategoriesRepository: GetToolFilterCategoriesRepositoryInterf func getCategoryFilter(from categoryId: String?, translatedInAppLanguage: AppLanguageDomainModel) -> CategoryFilterDomainModel? { - guard let categoryId = categoryId else { return nil } + guard let categoryId = categoryId else { + return nil + } return createCategoryDomainModel(with: categoryId, translatedInAppLanguage: translatedInAppLanguage, filteredByLanguageId: nil) } diff --git a/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterLanguagesRepository.swift b/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterLanguagesRepository.swift index 91b287ec34..1a46712f8a 100644 --- a/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterLanguagesRepository.swift +++ b/godtools/App/Features/ToolsFilter/Data-DomainInterface/GetToolFilterLanguagesRepository.swift @@ -48,7 +48,7 @@ class GetToolFilterLanguagesRepository: GetToolFilterLanguagesRepositoryInterfac func getLanguageFilter(from languageId: String?, translatedInAppLanguage: AppLanguageDomainModel) -> LanguageFilterDomainModel? { guard let languageId = languageId, - let language = languagesRepository.getLanguage(id: languageId) + let language = languagesRepository.getLanguage(id: languageId) else { return nil } @@ -64,7 +64,7 @@ extension GetToolFilterLanguagesRepository { private func getLanguageFilterPublisher(from languageId: String?, translatedInAppLanguage: AppLanguageDomainModel) -> AnyPublisher { guard let languageId = languageId, - let language = languagesRepository.getLanguage(id: languageId) + let language = languagesRepository.getLanguage(id: languageId) else { return Just(nil) .eraseToAnyPublisher() diff --git a/godtools/App/Features/ToolsFilter/Data/UserToolFiltersRepository/Cache/RealmUserToolFiltersCache.swift b/godtools/App/Features/ToolsFilter/Data/UserToolFiltersRepository/Cache/RealmUserToolFiltersCache.swift index 8bc6980d0b..93bb3b8100 100644 --- a/godtools/App/Features/ToolsFilter/Data/UserToolFiltersRepository/Cache/RealmUserToolFiltersCache.swift +++ b/godtools/App/Features/ToolsFilter/Data/UserToolFiltersRepository/Cache/RealmUserToolFiltersCache.swift @@ -20,14 +20,16 @@ class RealmUserToolFiltersCache { func getUserToolCategoryFilterChangedPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmUserToolCategoryFilter.self) + return realmDatabase.openRealm() + .objects(RealmUserToolCategoryFilter.self) .objectWillChange .eraseToAnyPublisher() } func getUserToolLanguageFilterChangedPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmUserToolLanguageFilter.self) + return realmDatabase.openRealm() + .objects(RealmUserToolLanguageFilter.self) .objectWillChange .eraseToAnyPublisher() } diff --git a/godtools/App/Features/ToolsFilter/DependencyContainer/ToolsFilterFeatureDataLayerDependencies.swift b/godtools/App/Features/ToolsFilter/DependencyContainer/ToolsFilterFeatureDataLayerDependencies.swift index 7078d6d8e2..5d48f98d17 100644 --- a/godtools/App/Features/ToolsFilter/DependencyContainer/ToolsFilterFeatureDataLayerDependencies.swift +++ b/godtools/App/Features/ToolsFilter/DependencyContainer/ToolsFilterFeatureDataLayerDependencies.swift @@ -77,7 +77,7 @@ class ToolsFilterFeatureDataLayerDependencies { return getToolFilterCategoriesRepository() } - func getToolFilterCategoriesInterfaceStringsRepositoryInterface() -> GetToolFilterCategoriesInterfaceStringsRepositoryInterface { + func getToolFilterCategoriesInterfaceStringsRepositoryInterface() -> GetToolFilterCategoriesInterfaceStringsRepositoryInterface { return getToolFilterCategoriesInterfaceStringsRepository() } @@ -85,7 +85,7 @@ class ToolsFilterFeatureDataLayerDependencies { return getToolFilterLanguagesRepository() } - func getToolFilterLanguagesInterfaceStringsRepositoryInterface() -> GetToolFilterLanguagesInterfaceStringsRepositoryInterface { + func getToolFilterLanguagesInterfaceStringsRepositoryInterface() -> GetToolFilterLanguagesInterfaceStringsRepositoryInterface { return getToolFilterLanguagesInterfaceStringsRepository() } diff --git a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/Subviews/ToolFilterCategorySelectionRowView/ToolFilterCategorySelectionRowView.swift b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/Subviews/ToolFilterCategorySelectionRowView/ToolFilterCategorySelectionRowView.swift index a7e991fb0e..5ff6fa9a32 100644 --- a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/Subviews/ToolFilterCategorySelectionRowView/ToolFilterCategorySelectionRowView.swift +++ b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/Subviews/ToolFilterCategorySelectionRowView/ToolFilterCategorySelectionRowView.swift @@ -44,4 +44,3 @@ struct ToolFilterCategorySelectionRowView: View { } } } - diff --git a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionView.swift b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionView.swift index c0aaca640b..537b7accba 100644 --- a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionView.swift +++ b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionView.swift @@ -48,4 +48,3 @@ struct ToolFilterCategorySelectionView: View { .environment(\.layoutDirection, ApplicationLayout.shared.layoutDirection) } } - diff --git a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionViewModel.swift b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionViewModel.swift index 167fc0eee2..6077e888a7 100644 --- a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionViewModel.swift +++ b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterCategorySelectionView/ToolFilterCategorySelectionViewModel.swift @@ -32,8 +32,7 @@ class ToolFilterCategorySelectionViewModel: ObservableObject { @Published var navTitle: String = "" @Published var categorySearchResults: [CategoryFilterDomainModel] = [CategoryFilterDomainModel]() - init(viewToolFilterCategoriesUseCase: ViewToolFilterCategoriesUseCase, searchToolFilterCategoriesUseCase: SearchToolFilterCategoriesUseCase, getUserToolFiltersUseCase: GetUserToolFiltersUseCase -, storeUserToolFiltersUseCase: StoreUserToolFiltersUseCase, getCurrentAppLanguageUseCase: GetCurrentAppLanguageUseCase, viewSearchBarUseCase: ViewSearchBarUseCase, flowDelegate: FlowDelegate) { + init(viewToolFilterCategoriesUseCase: ViewToolFilterCategoriesUseCase, searchToolFilterCategoriesUseCase: SearchToolFilterCategoriesUseCase, getUserToolFiltersUseCase: GetUserToolFiltersUseCase, storeUserToolFiltersUseCase: StoreUserToolFiltersUseCase, getCurrentAppLanguageUseCase: GetCurrentAppLanguageUseCase, viewSearchBarUseCase: ViewSearchBarUseCase, flowDelegate: FlowDelegate) { self.viewToolFilterCategoriesUseCase = viewToolFilterCategoriesUseCase self.searchToolFilterCategoriesUseCase = searchToolFilterCategoriesUseCase diff --git a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterLanguageSelectionView/ToolFilterLanguageSelectionViewModel.swift b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterLanguageSelectionView/ToolFilterLanguageSelectionViewModel.swift index f441da80bc..e577ac8c69 100644 --- a/godtools/App/Features/ToolsFilter/Presentation/ToolFilterLanguageSelectionView/ToolFilterLanguageSelectionViewModel.swift +++ b/godtools/App/Features/ToolsFilter/Presentation/ToolFilterLanguageSelectionView/ToolFilterLanguageSelectionViewModel.swift @@ -32,7 +32,7 @@ class ToolFilterLanguageSelectionViewModel: ObservableObject { @Published var searchText: String = "" @Published var navTitle: String = "" - init(viewToolFilterLanguagesUseCase: ViewToolFilterLanguagesUseCase, searchToolFilterLanguagesUseCase: SearchToolFilterLanguagesUseCase, getUserToolFiltersUseCase: GetUserToolFiltersUseCase, storeUserToolFilterUseCase: StoreUserToolFiltersUseCase, getCurrentAppLanguageUseCase: GetCurrentAppLanguageUseCase, viewSearchBarUseCase: ViewSearchBarUseCase, flowDelegate: FlowDelegate) { + init(viewToolFilterLanguagesUseCase: ViewToolFilterLanguagesUseCase, searchToolFilterLanguagesUseCase: SearchToolFilterLanguagesUseCase, getUserToolFiltersUseCase: GetUserToolFiltersUseCase, storeUserToolFilterUseCase: StoreUserToolFiltersUseCase, getCurrentAppLanguageUseCase: GetCurrentAppLanguageUseCase, viewSearchBarUseCase: ViewSearchBarUseCase, flowDelegate: FlowDelegate) { self.viewToolFilterLanguagesUseCase = viewToolFilterLanguagesUseCase self.searchToolFilterLanguagesUseCase = searchToolFilterLanguagesUseCase @@ -75,7 +75,10 @@ class ToolFilterLanguageSelectionViewModel: ObservableObject { .switchToLatest() .receive(on: DispatchQueue.main) .sink { [weak self] viewLanguageFiltersDomainModel in - guard let self = self else { return } + + guard let self = self else { + return + } let interfaceStrings = viewLanguageFiltersDomainModel.interfaceStrings diff --git a/godtools/App/Features/Tutorial/Presentation/Tutorial/TutorialViewModel.swift b/godtools/App/Features/Tutorial/Presentation/Tutorial/TutorialViewModel.swift index 3690a12136..53a2123b00 100644 --- a/godtools/App/Features/Tutorial/Presentation/Tutorial/TutorialViewModel.swift +++ b/godtools/App/Features/Tutorial/Presentation/Tutorial/TutorialViewModel.swift @@ -157,7 +157,7 @@ extension TutorialViewModel { @objc func backTapped() { if !isOnFirstPage { - currentPage = currentPage - 1 + currentPage -= 1 } } @@ -196,7 +196,7 @@ extension TutorialViewModel { flowDelegate?.navigate(step: .startUsingGodToolsTappedFromTutorial) } else { - currentPage = currentPage + 1 + currentPage += 1 } } } diff --git a/godtools/App/Flows/App/AppFlow.swift b/godtools/App/Flows/App/AppFlow.swift index fcf9d5f7db..0c640bd787 100644 --- a/godtools/App/Flows/App/AppFlow.swift +++ b/godtools/App/Flows/App/AppFlow.swift @@ -978,7 +978,7 @@ extension AppFlow { getCurrentAppLanguageUseCase: appDiContainer.feature.appLanguage.domainLayer.getCurrentAppLanguageUseCase(), viewSearchBarUseCase: appDiContainer.domainLayer.getViewSearchBarUseCase(), flowDelegate: self - ) + ) let view = ToolFilterCategorySelectionView(viewModel: viewModel) diff --git a/godtools/App/Flows/DownloadToolTranslations/DownloadToolTranslationsFlow.swift b/godtools/App/Flows/DownloadToolTranslations/DownloadToolTranslationsFlow.swift index 3f28fd08fb..2aa086edbd 100644 --- a/godtools/App/Flows/DownloadToolTranslations/DownloadToolTranslationsFlow.swift +++ b/godtools/App/Flows/DownloadToolTranslations/DownloadToolTranslationsFlow.swift @@ -133,4 +133,3 @@ class DownloadToolTranslationsFlow: Flow { downloadToolProgressModal = nil } } - diff --git a/godtools/App/Flows/Flow+PresentNativeMailApp/Flow+PresentNativeMailApp.swift b/godtools/App/Flows/Flow+PresentNativeMailApp/Flow+PresentNativeMailApp.swift index 5d29c2e6c6..1975255f61 100644 --- a/godtools/App/Flows/Flow+PresentNativeMailApp/Flow+PresentNativeMailApp.swift +++ b/godtools/App/Flows/Flow+PresentNativeMailApp/Flow+PresentNativeMailApp.swift @@ -38,4 +38,3 @@ extension Flow { navigationController.present(view, animated: true) } } - diff --git a/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift b/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift index 3240d34079..8ac57d6f07 100644 --- a/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift +++ b/godtools/App/Flows/ToolScreenShare/ToolScreenShareFlow.swift @@ -139,8 +139,7 @@ class ToolScreenShareFlow: Flow { let tractRemoteShareURLBuilder: TractRemoteShareURLBuilder = appDiContainer.feature.toolScreenShare.dataLayer.getTractRemoteShareURLBuilder() - guard let domainModel = shareToolScreenShareSessionDomainModel, - let remoteShareUrl = tractRemoteShareURLBuilder.buildRemoteShareURL(toolId: toolSettingsObserver.toolId, primaryLanguageId: toolSettingsObserver.languages.primaryLanguageId, parallelLanguageId: toolSettingsObserver.languages.parallelLanguageId, selectedLanguageId: toolSettingsObserver.languages.selectedLanguageId, page: toolSettingsObserver.pageNumber, subscriberChannelId: channel.subscriberChannelId) else { + guard let domainModel = shareToolScreenShareSessionDomainModel, let remoteShareUrl = tractRemoteShareURLBuilder.buildRemoteShareURL(toolId: toolSettingsObserver.toolId, primaryLanguageId: toolSettingsObserver.languages.primaryLanguageId, parallelLanguageId: toolSettingsObserver.languages.parallelLanguageId, selectedLanguageId: toolSettingsObserver.languages.selectedLanguageId, page: toolSettingsObserver.pageNumber, subscriberChannelId: channel.subscriberChannelId) else { let viewModel = AlertMessageViewModel( title: "Error", diff --git a/godtools/App/Preview/Data/RealmDatabase/SwiftUIPreviewDatabase.swift b/godtools/App/Preview/Data/RealmDatabase/SwiftUIPreviewDatabase.swift index 0d3acfd16c..6ccb9a29e3 100644 --- a/godtools/App/Preview/Data/RealmDatabase/SwiftUIPreviewDatabase.swift +++ b/godtools/App/Preview/Data/RealmDatabase/SwiftUIPreviewDatabase.swift @@ -33,17 +33,17 @@ class SwiftUIPreviewDatabase: RealmDatabase { private func getResources() -> [RealmResource] { - let resource_1 = RealmResource() + let resourceKgpGospel = RealmResource() - resource_1.abbreviation = "kgp" - resource_1.attrCategory = "gospel" - resource_1.attrSpotlight = true - resource_1.id = "1" - resource_1.name = "Preview Resource" - resource_1.resourceDescription = "" - resource_1.totalViews = 12579 + resourceKgpGospel.abbreviation = "kgp" + resourceKgpGospel.attrCategory = "gospel" + resourceKgpGospel.attrSpotlight = true + resourceKgpGospel.id = "1" + resourceKgpGospel.name = "Preview Resource" + resourceKgpGospel.resourceDescription = "" + resourceKgpGospel.totalViews = 12579 - return [resource_1] + return [resourceKgpGospel] } private func getLanguages() -> [RealmLanguage] { diff --git a/godtools/App/Services/Analytics/AppsFlyer/AppsFlyerAnalytics.swift b/godtools/App/Services/Analytics/AppsFlyer/AppsFlyerAnalytics.swift index 442b80f4f0..eedd464f59 100644 --- a/godtools/App/Services/Analytics/AppsFlyer/AppsFlyerAnalytics.swift +++ b/godtools/App/Services/Analytics/AppsFlyer/AppsFlyerAnalytics.swift @@ -57,7 +57,7 @@ class AppsFlyerAnalytics: NSObject { } } - func trackAction(actionName: String, data: [String : Any]?) { + func trackAction(actionName: String, data: [String: Any]?) { serialQueue.async { [weak self] in @@ -77,13 +77,17 @@ class AppsFlyerAnalytics: NSObject { private func log(method: String, label: String?, labelValue: String?, data: [String: Any]?) { if loggingEnabled { + print("\nAppsFlyer \(method)") + if let label = label, let labelValue = labelValue { - print(" \(label): \(labelValue)") + print(" \(label): \(labelValue)") } + if let data = data { print(" data: \(data)") } + if let customData = appsFlyer.appsFlyerLib.customData { print(" customData: \(customData)") } diff --git a/godtools/App/Services/Analytics/Firebase/FirebaseAnalytics.swift b/godtools/App/Services/Analytics/Firebase/FirebaseAnalytics.swift index 70bd443de3..b5197a29d3 100644 --- a/godtools/App/Services/Analytics/Firebase/FirebaseAnalytics.swift +++ b/godtools/App/Services/Analytics/Firebase/FirebaseAnalytics.swift @@ -71,7 +71,7 @@ class FirebaseAnalytics { previousTrackedScreenName = screenName } - func trackAction(screenName: String, siteSection: String, siteSubSection: String, contentLanguage: String?, secondaryContentLanguage: String?, actionName: String, data: [String : Any]?) { + func trackAction(screenName: String, siteSection: String, siteSubSection: String, contentLanguage: String?, secondaryContentLanguage: String?, actionName: String, data: [String: Any]?) { internalTrackEvent( screenName: screenName, @@ -129,10 +129,8 @@ class FirebaseAnalytics { var parameters: [String: Any] = baseParameters if let data = data { - for (key, value) in data { - if parameters[key] == nil { - parameters[key] = value - } + for (key, value) in data where parameters[key] == nil { + parameters[key] = value } } @@ -192,10 +190,13 @@ class FirebaseAnalytics { private func log(method: String, label: String?, labelValue: String?, data: [String: Any]?) { if loggingEnabled { + print("\nFirebaseAnalytics \(method)") + if let label = label, let labelValue = labelValue { - print(" \(label): \(labelValue)") + print(" \(label): \(labelValue)") } + if let data = data { print(" data: \(data)") } diff --git a/godtools/App/Services/FirebaseDebugArguments/FirebaseDebugArguments.swift b/godtools/App/Services/FirebaseDebugArguments/FirebaseDebugArguments.swift index ce113492df..6c70c8a728 100644 --- a/godtools/App/Services/FirebaseDebugArguments/FirebaseDebugArguments.swift +++ b/godtools/App/Services/FirebaseDebugArguments/FirebaseDebugArguments.swift @@ -31,10 +31,8 @@ class FirebaseDebugArguments { var newArguments: [String] = toArguments - for argument in arguments { - if !newArguments.contains(argument) { - newArguments.append(argument) - } + for argument in arguments where !newArguments.contains(argument) { + newArguments.append(argument) } return newArguments diff --git a/godtools/App/Services/Renderer/Analytics/Systems/User/MobileContentRendererUserAnalytics.swift b/godtools/App/Services/Renderer/Analytics/Systems/User/MobileContentRendererUserAnalytics.swift index e8268ea888..91d5c886cd 100644 --- a/godtools/App/Services/Renderer/Analytics/Systems/User/MobileContentRendererUserAnalytics.swift +++ b/godtools/App/Services/Renderer/Analytics/Systems/User/MobileContentRendererUserAnalytics.swift @@ -27,7 +27,7 @@ extension MobileContentRendererUserAnalytics: MobileContentRendererAnalyticsSyst private static let lessonCompletionsActionPrefix = "lesson_completions" - func trackMobileContentAction(screenName: String, siteSection: String, action: String, data: [String : Any]?) { + func trackMobileContentAction(screenName: String, siteSection: String, action: String, data: [String: Any]?) { guard action.hasPrefix(MobileContentRendererUserAnalytics.lessonCompletionsActionPrefix) else { return diff --git a/godtools/App/Services/Renderer/Navigation/MobileContentRendererNavigation.swift b/godtools/App/Services/Renderer/Navigation/MobileContentRendererNavigation.swift index aee33f8953..8f6d6b3764 100644 --- a/godtools/App/Services/Renderer/Navigation/MobileContentRendererNavigation.swift +++ b/godtools/App/Services/Renderer/Navigation/MobileContentRendererNavigation.swift @@ -153,7 +153,8 @@ class MobileContentRendererNavigation { localizationServices: appDiContainer.dataLayer.getLocalizationServices(), closeTappedClosure: { [weak self] in self?.dismissToolTraining() - }) + } + ) let view = ToolTrainingView(viewModel: viewModel) @@ -183,4 +184,3 @@ extension MobileContentRendererNavigation: MobileContentRendererNavigationDelega } } - diff --git a/godtools/App/Services/Renderer/Renderer/MobileContentPageRenderer.swift b/godtools/App/Services/Renderer/Renderer/MobileContentPageRenderer.swift index 0fb07706ca..1a4ad7faeb 100644 --- a/godtools/App/Services/Renderer/Renderer/MobileContentPageRenderer.swift +++ b/godtools/App/Services/Renderer/Renderer/MobileContentPageRenderer.swift @@ -69,11 +69,9 @@ class MobileContentPageRenderer { let pageModel: Page = pageModels[pageIndex] - for listener in pageModel.listeners { - - if eventIds.contains(listener) { - return pageIndex - } + for listener in pageModel.listeners where eventIds.contains(listener) { + + return pageIndex } } diff --git a/godtools/App/Services/Renderer/Renderer/MobileContentRenderer.swift b/godtools/App/Services/Renderer/Renderer/MobileContentRenderer.swift index 3ba72e850c..206f92530c 100644 --- a/godtools/App/Services/Renderer/Renderer/MobileContentRenderer.swift +++ b/godtools/App/Services/Renderer/Renderer/MobileContentRenderer.swift @@ -70,4 +70,3 @@ class MobileContentRenderer { ) } } - diff --git a/godtools/App/Services/Renderer/Views/Lesson/Views/Page/LessonPageView.swift b/godtools/App/Services/Renderer/Views/Lesson/Views/Page/LessonPageView.swift index 3ebace3a44..ffdc22307c 100644 --- a/godtools/App/Services/Renderer/Views/Lesson/Views/Page/LessonPageView.swift +++ b/godtools/App/Services/Renderer/Views/Lesson/Views/Page/LessonPageView.swift @@ -57,11 +57,6 @@ class LessonPageView: MobileContentPageView { contentContainerView.backgroundColor = .clear } - override func setupBinding() { - super.setupBinding() - - } - // MARK: - MobileContentView override func renderChild(childView: MobileContentView) { diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/BackgroundImage/MobileContentBackgroundImageView.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/BackgroundImage/MobileContentBackgroundImageView.swift index 5d840df958..00fd3fa0e7 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/BackgroundImage/MobileContentBackgroundImageView.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/BackgroundImage/MobileContentBackgroundImageView.swift @@ -77,7 +77,7 @@ class MobileContentBackgroundImageView: UIImageView { lastRenderedParentBounds = parentBounds } - override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { + override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) { guard let parentView = self.superview else { return diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/CardCollectionPage/MobileContentCardCollectionPageView.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/CardCollectionPage/MobileContentCardCollectionPageView.swift index edcc84c676..f66c19e7a6 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/CardCollectionPage/MobileContentCardCollectionPageView.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/CardCollectionPage/MobileContentCardCollectionPageView.swift @@ -180,9 +180,14 @@ extension MobileContentCardCollectionPageView: PageNavigationCollectionViewDeleg func pageNavigation(pageNavigation: PageNavigationCollectionView, cellForPageAt indexPath: IndexPath) -> UICollectionViewCell { - let cell: MobileContentCardCollectionPageItemView = cardPageNavigationView.getReusablePageCell( + guard let cell = cardPageNavigationView.getReusablePageCell( cellReuseIdentifier: MobileContentCardCollectionPageItemView.reuseIdentifier, - indexPath: indexPath) as! MobileContentCardCollectionPageItemView + indexPath: indexPath) as? MobileContentCardCollectionPageItemView else { + + assertionFailure("Failed to dequeue reusable cell with identifier :\(MobileContentCardCollectionPageItemView.reuseIdentifier)") + + return UICollectionViewCell() + } if let cardView = viewModel.cardWillAppear(card: indexPath.row) as? MobileContentCardCollectionPageCardView { cell.configure(cardView: cardView) diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentAccordion/MobileContentAccordionView.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentAccordion/MobileContentAccordionView.swift index 0b1bb8abad..4c09023e08 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentAccordion/MobileContentAccordionView.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentAccordion/MobileContentAccordionView.swift @@ -42,11 +42,11 @@ class MobileContentAccordionView: MobileContentView { } var isRevealingSectionText: Bool { - for sectionView in sectionViews { - if !sectionView.contentIsHidden { - return true - } + + for sectionView in sectionViews where !sectionView.contentIsHidden { + return true } + return false } diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentButton/Models/MobileContentButtonIcon.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentButton/Models/MobileContentButtonIcon.swift index 1ce9847e03..b91c1b6c14 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentButton/Models/MobileContentButtonIcon.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentButton/Models/MobileContentButtonIcon.swift @@ -15,4 +15,3 @@ struct MobileContentButtonIcon { let gravity: Gravity.Horizontal let image: UIImage } - diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoView.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoView.swift index c80d4b3bb3..40feba5ba0 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoView.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoView.swift @@ -65,7 +65,6 @@ class MobileContentEmbeddedVideoView: MobileContentView { } } - // MARK: - YTPlayerViewDelegate extension MobileContentEmbeddedVideoView: YTPlayerViewDelegate { @@ -92,4 +91,3 @@ extension MobileContentEmbeddedVideoView: YTPlayerViewDelegate { } } - diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoViewModel.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoViewModel.swift index d425e486f8..cdb5ee3ecc 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoViewModel.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentEmbeddedVideo/MobileContentEmbeddedVideoViewModel.swift @@ -42,7 +42,7 @@ class MobileContentEmbeddedVideoViewModel: MobileContentViewModel { return id } - var youtubePlayerParameters: [String : Any] { + var youtubePlayerParameters: [String: Any] { let playsInFullScreen = 0 diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentStack/MobileContentStackView.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentStack/MobileContentStackView.swift index 21c4bb65e9..dd6f76b871 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentStack/MobileContentStackView.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/ContentStack/MobileContentStackView.swift @@ -325,7 +325,7 @@ extension MobileContentStackView { } } - override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { + override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) { guard let objectValue = object as? NSObject else { return @@ -552,10 +552,9 @@ extension MobileContentStackView { } } - for childView in childViews { - if childView.visibilityState == .visible { - addTopAndBottomConstraintsToChildView(childView: childView) - } + for childView in childViews where childView.visibilityState == .visible { + + addTopAndBottomConstraintsToChildView(childView: childView) } childrenParentView.layoutIfNeeded() diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/MobileContentViewModel.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/MobileContentViewModel.swift index 23b53956c6..6781fdccb3 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/MobileContentViewModel.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/MobileContentViewModel.swift @@ -93,8 +93,7 @@ extension MobileContentViewModel { func getClickableAnalyticsEvents() -> [AnalyticsEvent] { - guard let clickableModel = baseModel as? Clickable, clickableModel.isClickable, - let modelHasAnalyticsEvents = clickableModel as? HasAnalyticsEvents else { + guard let clickableModel = baseModel as? Clickable, clickableModel.isClickable, let modelHasAnalyticsEvents = clickableModel as? HasAnalyticsEvents else { return Array() } diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesView.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesView.swift index 5c0c6479ce..1d4fb14fe2 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesView.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesView.swift @@ -124,9 +124,7 @@ class MobileContentPagesView: AppViewController { weakSelf.pageNavigationView.scrollToPage(pageNavigation: navigationEvent.pageNavigation, completion: { (completedNavigation: PageNavigationCollectionViewNavigationCompleted) in - if let pagePositions = navigationEvent.pagePositions, - let pageCell = completedNavigation.pageCell as? MobileContentPageCell, - let pageView = pageCell.mobileContentView as? MobileContentPageView { + if let pagePositions = navigationEvent.pagePositions, let pageCell = completedNavigation.pageCell as? MobileContentPageCell, let pageView = pageCell.mobileContentView as? MobileContentPageView { pageView.setPositionStateForViewHierarchy( positionState: pagePositions, @@ -159,9 +157,7 @@ class MobileContentPagesView: AppViewController { for cell in visiblePageCells { - if let pageCell = cell as? MobileContentPageCell, - let pageView = pageCell.mobileContentView as? MobileContentPageView, - let indexPath = pageNavigationView.getIndexPathForPageCell(pageCell: pageCell) { + if let pageCell = cell as? MobileContentPageCell, let pageView = pageCell.mobileContentView as? MobileContentPageView, let indexPath = pageNavigationView.getIndexPathForPageCell(pageCell: pageCell) { let page: Int = indexPath.row let currentPagePositions: MobileContentViewPositionState = pageView.getPositionStateForViewHierarchy() @@ -224,9 +220,14 @@ extension MobileContentPagesView: PageNavigationCollectionViewDelegate { func pageNavigation(pageNavigation: PageNavigationCollectionView, cellForPageAt indexPath: IndexPath) -> UICollectionViewCell { - let cell: MobileContentPageCell = pageNavigationView.getReusablePageCell( + guard let cell = pageNavigationView.getReusablePageCell( cellReuseIdentifier: MobileContentPageCell.reuseIdentifier, - indexPath: indexPath) as! MobileContentPageCell + indexPath: indexPath) as? MobileContentPageCell else { + + assertionFailure("Failed to dequeue reusable cell with identifier :\(MobileContentPageCell.reuseIdentifier)") + + return UICollectionViewCell() + } let pageNumber: Int = indexPath.row diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesViewModel.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesViewModel.swift index 73c6c4b465..55d4915114 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesViewModel.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/Pages/MobileContentPagesViewModel.swift @@ -540,7 +540,7 @@ class MobileContentPagesViewModel: NSObject, ObservableObject { return nil } - let renderPageResult: Result = currentPageRenderer.value.renderPageModel( + let renderPageResult: Result = currentPageRenderer.value.renderPageModel( pageModel: pageModels[page], page: page, numberOfPages: pageModels.count, @@ -743,7 +743,9 @@ extension MobileContentPagesViewModel { private func countLanguageUsage(localeId: String) { - if languageUsageAlreadyCountedThisSession(localeId: localeId) { return } + if languageUsageAlreadyCountedThisSession(localeId: localeId) { + return + } let locale = Locale(identifier: localeId) diff --git a/godtools/App/Services/Renderer/Views/MobileContent/Views/Spacer/MobileContentSpacerView.swift b/godtools/App/Services/Renderer/Views/MobileContent/Views/Spacer/MobileContentSpacerView.swift index 3621a7937a..014ab399e0 100644 --- a/godtools/App/Services/Renderer/Views/MobileContent/Views/Spacer/MobileContentSpacerView.swift +++ b/godtools/App/Services/Renderer/Views/MobileContent/Views/Spacer/MobileContentSpacerView.swift @@ -13,7 +13,7 @@ class MobileContentSpacerView: MobileContentView { private let viewModel: MobileContentSpacerViewModel - private var heightConstraint: NSLayoutConstraint! + private var heightConstraint: NSLayoutConstraint? init(viewModel: MobileContentSpacerViewModel) { @@ -23,7 +23,7 @@ class MobileContentSpacerView: MobileContentView { super.init(viewModel: viewModel, frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.size.width, height: height)) - heightConstraint = NSLayoutConstraint( + let heightConstraint = NSLayoutConstraint( item: self, attribute: .height, relatedBy: .equal, @@ -36,6 +36,8 @@ class MobileContentSpacerView: MobileContentView { heightConstraint.priority = UILayoutPriority(1000) addConstraint(heightConstraint) + + self.heightConstraint = heightConstraint } required init?(coder: NSCoder) { @@ -47,7 +49,7 @@ class MobileContentSpacerView: MobileContentView { } func setHeight(height: CGFloat) { - heightConstraint.constant = height + heightConstraint?.constant = height } // MARK: - MobileContentView @@ -56,4 +58,3 @@ class MobileContentSpacerView: MobileContentView { return .spacer } } - diff --git a/godtools/App/Services/Renderer/Views/Tool/Views/Cards/ToolPageCardsView.swift b/godtools/App/Services/Renderer/Views/Tool/Views/Cards/ToolPageCardsView.swift index 064de0e083..ea89da4422 100644 --- a/godtools/App/Services/Renderer/Views/Tool/Views/Cards/ToolPageCardsView.swift +++ b/godtools/App/Services/Renderer/Views/Tool/Views/Cards/ToolPageCardsView.swift @@ -553,11 +553,9 @@ extension ToolPageCardsView { setCurrentCardPosition(cardPosition: showingCardAtPosition, animated: animated) - for cardPosition in 0 ..< renderedCards.count { + for cardPosition in 0 ..< renderedCards.count where cardPosition <= showingCardAtPosition { - if cardPosition <= showingCardAtPosition { - cardTopConstraints[cardPosition].constant = getCardTopConstant(state: .showingKeyboard, cardPosition: cardPosition) - } + cardTopConstraints[cardPosition].constant = getCardTopConstant(state: .showingKeyboard, cardPosition: cardPosition) } case .collapseAllCards: diff --git a/godtools/App/Services/Renderer/Views/Tool/Views/Form/ToolPageFormViewModel.swift b/godtools/App/Services/Renderer/Views/Tool/Views/Form/ToolPageFormViewModel.swift index 99968d16ef..e7ed6f3dfc 100644 --- a/godtools/App/Services/Renderer/Views/Tool/Views/Form/ToolPageFormViewModel.swift +++ b/godtools/App/Services/Renderer/Views/Tool/Views/Form/ToolPageFormViewModel.swift @@ -65,7 +65,6 @@ class ToolPageFormViewModel: MobileContentFormViewModel { return } - let languageId: Int = Int(renderedPageContext.language.id) ?? 0 let followUpModel = FollowUpModel( diff --git a/godtools/App/Services/Renderer/Views/Tool/Views/Page/ToolPageView.swift b/godtools/App/Services/Renderer/Views/Tool/Views/Page/ToolPageView.swift index 04eb413cf7..1fa4e916e6 100644 --- a/godtools/App/Services/Renderer/Views/Tool/Views/Page/ToolPageView.swift +++ b/godtools/App/Services/Renderer/Views/Tool/Views/Page/ToolPageView.swift @@ -81,10 +81,6 @@ class ToolPageView: MobileContentPageView { setCallToActionHidden(hidden: true, animated: false) } - override func setupBinding() { - super.setupBinding() - } - override func getPositionState() -> MobileContentViewPositionState { let cardPosition: Int? = cardsView?.getCurrentCardPosition() diff --git a/godtools/App/Services/Renderer/Views/Training/Views/TrainingTip/TrainingTipView.swift b/godtools/App/Services/Renderer/Views/Training/Views/TrainingTip/TrainingTipView.swift index fb33894e73..dfae3e3dd6 100644 --- a/godtools/App/Services/Renderer/Views/Training/Views/TrainingTip/TrainingTipView.swift +++ b/godtools/App/Services/Renderer/Views/Training/Views/TrainingTip/TrainingTipView.swift @@ -22,7 +22,6 @@ class TrainingTipView: MobileContentView, NibBased { super.init(viewModel: viewModel, frame: CGRect(x: 0, y: 0, width: 100, height: 100)) loadNib() - setupLayout() setupBinding() tipButton.addTarget(self, action: #selector(handleTip(button:)), for: .touchUpInside) @@ -32,10 +31,6 @@ class TrainingTipView: MobileContentView, NibBased { fatalError("init(coder:) has not been implemented") } - private func setupLayout() { - - } - private func setupBinding() { viewModel.trainingTipBackgroundImage.addObserver(self) { [weak self] (backgroundImage: UIImage?) in @@ -58,13 +53,7 @@ class TrainingTipView: MobileContentView, NibBased { // MARK: - MobileContentView - override func renderChild(childView: MobileContentView) { - super.renderChild(childView: childView) - } - override var heightConstraintType: MobileContentViewHeightConstraintType { return .equalToSize(size: CGSize(width: 50, height: 50)) } - - // MARK: - } diff --git a/godtools/App/Services/WebSocket/ActionCableChannelPublisher.swift b/godtools/App/Services/WebSocket/ActionCableChannelPublisher.swift index 69a00f6e6f..8d6b988ced 100644 --- a/godtools/App/Services/WebSocket/ActionCableChannelPublisher.swift +++ b/godtools/App/Services/WebSocket/ActionCableChannelPublisher.swift @@ -132,7 +132,7 @@ class ActionCableChannelPublisher: NSObject, WebSocketChannelPublisherType { addTextSignalObserver() let stringChannel = "{ \"channel\": \"PublishChannel\",\"channelId\": \"\(channelId)\" }" - let message = ["command" : "subscribe", "identifier": stringChannel] + let message = ["command": "subscribe", "identifier": stringChannel] publishChannelIdentifier = stringChannel diff --git a/godtools/App/Services/WebSocket/ActionCableChannelSubscriber.swift b/godtools/App/Services/WebSocket/ActionCableChannelSubscriber.swift index 1c10e6ac92..eff19ffc6b 100644 --- a/godtools/App/Services/WebSocket/ActionCableChannelSubscriber.swift +++ b/godtools/App/Services/WebSocket/ActionCableChannelSubscriber.swift @@ -112,7 +112,7 @@ class ActionCableChannelSubscriber: NSObject, WebSocketChannelSubscriberType { isSubscribingToChannel = channelId let strChannel = "{ \"channel\": \"SubscribeChannel\",\"channelId\": \"\(channelId)\" }" - let message = ["command" : "subscribe","identifier": strChannel] + let message = ["command": "subscribe", "identifier": strChannel] do { diff --git a/godtools/App/Share/AnimationTransitions/FadeAnimationTransition.swift b/godtools/App/Share/AnimationTransitions/FadeAnimationTransition.swift index 838d0ef7c1..535935e7f9 100644 --- a/godtools/App/Share/AnimationTransitions/FadeAnimationTransition.swift +++ b/godtools/App/Share/AnimationTransitions/FadeAnimationTransition.swift @@ -37,7 +37,7 @@ class FadeAnimationTransition: NSObject, UIViewControllerAnimatedTransitioning { let fromView: UIView = fromViewController.view let toView: UIView = toViewController.view - switch (self.fade) { + switch fade { case .fadeIn: diff --git a/godtools/App/Share/Common/FileCache/FileCache+SSZipArchive.swift b/godtools/App/Share/Common/FileCache/FileCache+SSZipArchive.swift index 96364d83bf..a40dd5b7ce 100644 --- a/godtools/App/Share/Common/FileCache/FileCache+SSZipArchive.swift +++ b/godtools/App/Share/Common/FileCache/FileCache+SSZipArchive.swift @@ -105,10 +105,11 @@ extension FileCache { let location: FileCacheLocation = FileCacheLocation(relativeUrlString: relativeUrlString) - switch storeFile(location: location, data: data) { + case .success( _): storedFileLocations.append(location) + case .failure(let error): return .failure(error) } diff --git a/godtools/App/Share/Common/FileCache/FileCache.swift b/godtools/App/Share/Common/FileCache/FileCache.swift index 6ad732c5b0..62a75daa8f 100644 --- a/godtools/App/Share/Common/FileCache/FileCache.swift +++ b/godtools/App/Share/Common/FileCache/FileCache.swift @@ -269,7 +269,7 @@ class FileCache { // delete directory since contents were moved do { - try fileManager.removeItem(at: childDirectory) + try fileManager.removeItem(at: childDirectory) } catch let error { return error diff --git a/godtools/App/Share/Common/Json/JsonServices.swift b/godtools/App/Share/Common/Json/JsonServices.swift index 5fe2d943c3..e7e00a2774 100644 --- a/godtools/App/Share/Common/Json/JsonServices.swift +++ b/godtools/App/Share/Common/Json/JsonServices.swift @@ -134,7 +134,7 @@ struct JsonServices: JsonServicesType { // MARK: - Decoding - func decodeArray(fileName: String?) -> [T] where T : Decodable { + func decodeArray(fileName: String?) -> [T] where T: Decodable { let result: Result<[T], Error> = decodeArray(fileName: fileName) @@ -147,7 +147,7 @@ struct JsonServices: JsonServicesType { } } - func decodeArray(fileName: String?) -> Result<[T], Error> where T : Decodable { + func decodeArray(fileName: String?) -> Result<[T], Error> where T: Decodable { let dataResult: Result = getJsonData(fileName: fileName) @@ -168,7 +168,7 @@ struct JsonServices: JsonServicesType { } } - func decodeArray(data: Data?) -> [T] where T : Decodable { + func decodeArray(data: Data?) -> [T] where T: Decodable { let result: Result<[T], Error> = decodeArray(data: data) @@ -181,7 +181,7 @@ struct JsonServices: JsonServicesType { } } - func decodeArray(data: Data?) -> Result<[T], Error> where T : Decodable { + func decodeArray(data: Data?) -> Result<[T], Error> where T: Decodable { guard let data = data else { return .success([]) @@ -196,7 +196,7 @@ struct JsonServices: JsonServicesType { } } - func decodeObject(data: Data?) -> T? where T : Decodable { + func decodeObject(data: Data?) -> T? where T: Decodable { let result: Result = decodeObject(data: data) @@ -209,7 +209,7 @@ struct JsonServices: JsonServicesType { } } - func decodeObject(data: Data?) -> Result where T : Decodable { + func decodeObject(data: Data?) -> Result where T: Decodable { guard let data = data else { return .success(nil) @@ -224,7 +224,7 @@ struct JsonServices: JsonServicesType { } } - func decodeJsonObject(jsonObject: [String: Any], options: JSONSerialization.WritingOptions = []) -> T? where T : Decodable { + func decodeJsonObject(jsonObject: [String: Any], options: JSONSerialization.WritingOptions = []) -> T? where T: Decodable { let result: Result = decodeJsonObject(jsonObject: jsonObject, options: options) @@ -237,7 +237,7 @@ struct JsonServices: JsonServicesType { } } - func decodeJsonObject(jsonObject: [String: Any], options: JSONSerialization.WritingOptions = []) -> Result where T : Decodable { + func decodeJsonObject(jsonObject: [String: Any], options: JSONSerialization.WritingOptions = []) -> Result where T: Decodable { do { let jsonData: Data = try JSONSerialization.data(withJSONObject: jsonObject, options: options) @@ -250,9 +250,9 @@ struct JsonServices: JsonServicesType { // MARK: - Encoding - func encode(object: T, options: JSONSerialization.ReadingOptions = []) -> [String : Any] where T : Encodable { + func encode(object: T, options: JSONSerialization.ReadingOptions = []) -> [String: Any] where T: Encodable { - let result: Result<[String : Any], Error> = encode(object: object, options: options) + let result: Result<[String: Any], Error> = encode(object: object, options: options) switch result { case .success(let data): @@ -263,7 +263,7 @@ struct JsonServices: JsonServicesType { } } - func encode(object: T, options: JSONSerialization.ReadingOptions = []) -> Result<[String : Any], Error> where T : Encodable { + func encode(object: T, options: JSONSerialization.ReadingOptions = []) -> Result<[String: Any], Error> where T: Encodable { do { diff --git a/godtools/App/Share/Common/KeyboardObserver/KeyboardNotificationObserver.swift b/godtools/App/Share/Common/KeyboardObserver/KeyboardNotificationObserver.swift index a7dd3d513f..ab3ce0e1ff 100644 --- a/godtools/App/Share/Common/KeyboardObserver/KeyboardNotificationObserver.swift +++ b/godtools/App/Share/Common/KeyboardObserver/KeyboardNotificationObserver.swift @@ -140,7 +140,7 @@ extension KeyboardNotificationObserver { @objc func handleNotification(notification: Notification) { if notification.name == UIResponder.keyboardWillShowNotification { - log(string:"\nKeyboardNotificationObserver: UIKeyboardWillShow()") + log(string: "\nKeyboardNotificationObserver: UIKeyboardWillShow()") if let keyboardInfo = notification.userInfo { if let keyboardAnimationDurationNumber = keyboardInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber { @@ -164,7 +164,7 @@ extension KeyboardNotificationObserver { } else if notification.name == UIResponder.keyboardDidShowNotification { - log(string:"\nKeyboardNotificationObserver: UIKeyboardDidShow()") + log(string: "\nKeyboardNotificationObserver: UIKeyboardDidShow()") keyboardIsUp = true @@ -178,7 +178,7 @@ extension KeyboardNotificationObserver { } else if notification.name == UIResponder.keyboardWillHideNotification { - log(string:"\nKeyboardNotificationObserver: UIKeyboardWillHide()") + log(string: "\nKeyboardNotificationObserver: UIKeyboardWillHide()") keyboardIsUp = false @@ -196,7 +196,7 @@ extension KeyboardNotificationObserver { } else if notification.name == UIResponder.keyboardDidChangeFrameNotification { - log(string:"\nKeyboardNotificationObserver: UIKeyboardDidChangeFrame()") + log(string: "\nKeyboardNotificationObserver: UIKeyboardDidChangeFrame()") if keyboardIsUp { updateKeyboardHeightIfNeededFromKeyboardNotification( diff --git a/godtools/App/Share/Common/KeyboardObserver/KeyboardState.swift b/godtools/App/Share/Common/KeyboardObserver/KeyboardState.swift index e6d4b9c67a..0476e2aa0d 100644 --- a/godtools/App/Share/Common/KeyboardObserver/KeyboardState.swift +++ b/godtools/App/Share/Common/KeyboardObserver/KeyboardState.swift @@ -10,8 +10,8 @@ import Foundation enum KeyboardState { - case willShow - case willHide - case didShow case didHide + case didShow + case willHide + case willShow } diff --git a/godtools/App/Share/Common/Oberservables/ObservableValue.swift b/godtools/App/Share/Common/Oberservables/ObservableValue.swift index beb257a270..62b0a8b6dc 100644 --- a/godtools/App/Share/Common/Oberservables/ObservableValue.swift +++ b/godtools/App/Share/Common/Oberservables/ObservableValue.swift @@ -12,7 +12,7 @@ class ObservableValue { typealias Handler = ((_ value: T) -> Void) - private(set) var value : T + private(set) var value: T private var observers = [String: Handler]() diff --git a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Collection/Collection+SafeLookup.swift b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Collection/Collection+SafeLookup.swift index 851eb56c4f..9a167f4397 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Collection/Collection+SafeLookup.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Collection/Collection+SafeLookup.swift @@ -8,9 +8,9 @@ import Foundation -public extension Collection where Indices.Iterator.Element == Index { +extension Collection where Indices.Iterator.Element == Index { - subscript (safe index: Index) -> Iterator.Element? { + public subscript (safe index: Index) -> Iterator.Element? { return indices.contains(index) ? self[index] : nil } } diff --git a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/Error+Code.swift b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/Error+Code.swift index 9e23ef2f24..51e95f09da 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/Error+Code.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/Error+Code.swift @@ -8,7 +8,7 @@ import Foundation -public extension Error { +extension Error { var code: Int { return (self as NSError).code diff --git a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/NSError+WithDescription.swift b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/NSError+WithDescription.swift index cc45653857..e6d39c9202 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/NSError+WithDescription.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Error/NSError+WithDescription.swift @@ -8,7 +8,7 @@ import Foundation -public extension NSError { +extension NSError { static func errorWithDescription(description: String) -> NSError { diff --git a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Locale/Locale+Extensions.swift b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Locale/Locale+Extensions.swift index a29765d64f..2b4b2fb718 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Locale/Locale+Extensions.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/Foundation/Locale/Locale+Extensions.swift @@ -8,24 +8,24 @@ import Foundation -public extension Locale { +extension Locale { - var isBaseLanguage: Bool { + public var isBaseLanguage: Bool { let isBaseLanguage: Bool = isMissingRegionCode && isMissingScriptCode return isBaseLanguage } - var isEnglishLanguage: Bool { + public var isEnglishLanguage: Bool { return languageCode == "en" } - var isMissingRegionCode: Bool { + public var isMissingRegionCode: Bool { return regionCode?.isEmpty ?? true } - var isMissingScriptCode: Bool { + public var isMissingScriptCode: Bool { return scriptCode?.isEmpty ?? true } @@ -43,15 +43,15 @@ public extension Locale { return languageCodesMatch } - func scriptCodeIsEqualToLocaleScriptCode(locale: Locale) -> Bool { + public func scriptCodeIsEqualToLocaleScriptCode(locale: Locale) -> Bool { return locale.scriptCode?.lowercased() == scriptCode?.lowercased() } - func regionCodeIsEqualToLocaleRegionCode(locale: Locale) -> Bool { + public func regionCodeIsEqualToLocaleRegionCode(locale: Locale) -> Bool { return locale.regionCode?.lowercased() == regionCode?.lowercased() } - func isEqualTo(locale: Locale) -> Bool { + public func isEqualTo(locale: Locale) -> Bool { let languageCodesMatch: Bool = languageCodeIsEqualToLocaleLanguageCode(locale: locale) let scriptCodesMatch: Bool = scriptCodeIsEqualToLocaleScriptCode(locale: locale) @@ -60,12 +60,12 @@ public extension Locale { return languageCodesMatch && scriptCodesMatch && regionCodesMatch } - func baseLanguageIsEqualToLocaleBaseLanguage(locale: Locale) -> Bool { + public func baseLanguageIsEqualToLocaleBaseLanguage(locale: Locale) -> Bool { return languageCodeIsEqualToLocaleLanguageCode(locale: locale) } - func baseLanguageAndScriptCodesAreEqualTo(locale: Locale) -> Bool { + public func baseLanguageAndScriptCodesAreEqualTo(locale: Locale) -> Bool { let baseLanguagesMatch: Bool = baseLanguageIsEqualToLocaleBaseLanguage(locale: locale) let scriptCodesMatch: Bool = locale.scriptCode?.lowercased() == scriptCode?.lowercased() diff --git a/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Color/Color+RGB.swift b/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Color/Color+RGB.swift index 5dd2e44b66..b78c95a19b 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Color/Color+RGB.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Color/Color+RGB.swift @@ -9,7 +9,7 @@ import Foundation import SwiftUI -public extension Color { +extension Color { static func getColorWithRGB(red: CGFloat, green: CGFloat, blue: CGFloat, opacity: CGFloat) -> Color { Color(.sRGB, red: red / 255, green: green / 255, blue: blue / 255, opacity: opacity) diff --git a/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Image/Image+OptionalUIImage.swift b/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Image/Image+OptionalUIImage.swift index 2f419c112a..8db4ece242 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Image/Image+OptionalUIImage.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/SwiftUI/Image/Image+OptionalUIImage.swift @@ -8,7 +8,7 @@ import SwiftUI -public extension Image { +extension Image { static func from(uiImage: UIImage?) -> Image? { diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIButton/UIButton+ImageColor.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIButton/UIButton+ImageColor.swift index bf70ca3f05..6d26fec4e2 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIButton/UIButton+ImageColor.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIButton/UIButton+ImageColor.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIButton { +extension UIButton { func setImageColor(color: UIColor) { diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIColor/UIColor+HexColor.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIColor/UIColor+HexColor.swift index b17ba8bb7b..535ebcc82e 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIColor/UIColor+HexColor.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIColor/UIColor+HexColor.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIColor { +extension UIColor { static func hexColor(hexValue: Int, alpha: CGFloat = 1) -> UIColor { let red: Int = (hexValue >> 16) & 0xff diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+CreateImageWithColor.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+CreateImageWithColor.swift index 6daf52dac7..b54c51149b 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+CreateImageWithColor.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+CreateImageWithColor.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIImage { +extension UIImage { static func createImageWithColor(color: UIColor) -> UIImage? { diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+ScalePresevingAspectRatio.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+ScalePresevingAspectRatio.swift index fe7b9c5d26..24b3c5b6db 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+ScalePresevingAspectRatio.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImage/UIImage+ScalePresevingAspectRatio.swift @@ -8,33 +8,34 @@ import UIKit -public extension UIImage { - //found here: https://www.advancedswift.com/resize-uiimage-no-stretching-swift/ +extension UIImage { + // found here: https://www.advancedswift.com/resize-uiimage-no-stretching-swift/ func scalePreservingAspectRatio(targetSize: CGSize) -> UIImage { - // Determine the scale factor that preserves aspect ratio - let widthRatio = targetSize.width / size.width - let heightRatio = targetSize.height / size.height - - let scaleFactor = min(widthRatio, heightRatio) - - // Compute the new image size that preserves aspect ratio - let scaledImageSize = CGSize( - width: size.width * scaleFactor, - height: size.height * scaleFactor - ) + + // Determine the scale factor that preserves aspect ratio + let widthRatio = targetSize.width / size.width + let heightRatio = targetSize.height / size.height + + let scaleFactor = min(widthRatio, heightRatio) + + // Compute the new image size that preserves aspect ratio + let scaledImageSize = CGSize( + width: size.width * scaleFactor, + height: size.height * scaleFactor + ) - // Draw and return the resized UIImage - let renderer = UIGraphicsImageRenderer( - size: scaledImageSize - ) + // Draw and return the resized UIImage + let renderer = UIGraphicsImageRenderer( + size: scaledImageSize + ) - let scaledImage = renderer.image { _ in - self.draw(in: CGRect( - origin: .zero, - size: scaledImageSize - )) - } - - return scaledImage + let scaledImage = renderer.image { _ in + self.draw(in: CGRect( + origin: .zero, + size: scaledImageSize + )) } + + return scaledImage + } } diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImageView/UIImageView+ImageColor.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImageView/UIImageView+ImageColor.swift index a9ecef8956..3d927fc00e 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImageView/UIImageView+ImageColor.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIImageView/UIImageView+ImageColor.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIImageView { +extension UIImageView { func setImageColor(color: UIColor) { diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UILabel/UILabel+AttributedString.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UILabel/UILabel+AttributedString.swift index 57a33a6ed1..9f6971afd4 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UILabel/UILabel+AttributedString.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UILabel/UILabel+AttributedString.swift @@ -8,7 +8,7 @@ import UIKit -public extension UILabel { +extension UILabel { private func getAttributedString() -> NSMutableAttributedString { @@ -18,7 +18,7 @@ public extension UILabel { private func getRangeOfString(string: String) -> NSRange { guard let text = self.text else { - return NSMakeRange(0, 0) + return NSRange(location: 0, length: 0) } return (text as NSString).range(of: string) diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UITextView/UITextView+AttributedString.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UITextView/UITextView+AttributedString.swift index ce34d00d16..f40390ad87 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UITextView/UITextView+AttributedString.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UITextView/UITextView+AttributedString.swift @@ -8,7 +8,7 @@ import UIKit -public extension UITextView { +extension UITextView { private func getAttributedString() -> NSMutableAttributedString { return attributedText.mutableCopy() as? NSMutableAttributedString ?? NSMutableAttributedString() diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Animations.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Animations.swift index ff77bb8b4b..a114cc5ebc 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Animations.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Animations.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIView { +extension UIView { func animateHidden(hidden: Bool, animated: Bool) { diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Constraints.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Constraints.swift index ba29cb898a..cf02e421c3 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Constraints.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+Constraints.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIView { +extension UIView { func constrainEdgesToView(view: UIView, edgeInsets: UIEdgeInsets = .zero, horizontalConstraintType: UIViewHorizontalContraintType = .leadingAndTrailing) { diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+DrawBorder.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+DrawBorder.swift index 41a09fdcb4..d39b7d8077 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+DrawBorder.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIView/UIView+DrawBorder.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIView { +extension UIView { func drawBorder(color: UIColor = UIColor.red) { layer.borderWidth = 1 diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+Containment.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+Containment.swift index f61849b7ce..47256e301c 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+Containment.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+Containment.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIViewController { +extension UIViewController { func addChildController(child: UIViewController, toView: UIView? = nil) { addChild(child) diff --git a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+DismissPresented.swift b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+DismissPresented.swift index 09c921af2f..eb47ae2cc9 100644 --- a/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+DismissPresented.swift +++ b/godtools/App/Share/Common/SharedAppleExtensions/UIKit/UIViewController/UIViewController+DismissPresented.swift @@ -8,7 +8,7 @@ import UIKit -public extension UIViewController { +extension UIViewController { // Helper ensures completion will always be called. I believe if animated is false when calling UIKit's UIViewController.dismiss(animated:) the completion closure will never be called. diff --git a/godtools/App/Share/Data/AppsFlyer/AppsFlyer.swift b/godtools/App/Share/Data/AppsFlyer/AppsFlyer.swift index cf900230c3..88353a3278 100644 --- a/godtools/App/Share/Data/AppsFlyer/AppsFlyer.swift +++ b/godtools/App/Share/Data/AppsFlyer/AppsFlyer.swift @@ -47,7 +47,7 @@ class AppsFlyer { appsFlyerLib.useUninstallSandbox = configuration.shouldUseUninstallSandbox } - func handleOpenUrl(url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) { + func handleOpenUrl(url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) { appsFlyerLib.handleOpen(url, options: options) } @@ -59,7 +59,7 @@ class AppsFlyer { appsFlyerLib.registerUninstall(deviceToken) } - func handlePushNotification(userInfo: [AnyHashable : Any]) { + func handlePushNotification(userInfo: [AnyHashable: Any]) { appsFlyerLib.handlePushNotification(userInfo) } } diff --git a/godtools/App/Share/Data/ArticlesRepository/Articles/Cache/ArticleAemCache.swift b/godtools/App/Share/Data/ArticlesRepository/Articles/Cache/ArticleAemCache.swift index 473f30318b..ebd1f6e857 100644 --- a/godtools/App/Share/Data/ArticlesRepository/Articles/Cache/ArticleAemCache.swift +++ b/godtools/App/Share/Data/ArticlesRepository/Articles/Cache/ArticleAemCache.swift @@ -45,7 +45,6 @@ class ArticleAemCache { return getAemCacheObject(realm: realm, aemUri: aemUri) } - private func getAemCacheObject(realm: Realm, aemUri: String) -> ArticleAemCacheObject? { guard let realmAemData = realm.object(ofType: RealmArticleAemData.self, forPrimaryKey: aemUri) else { @@ -91,11 +90,7 @@ class ArticleAemCache { let dataIsNotCached: Bool let uuidChanged: Bool - if let aemCacheObject = self.getAemCacheObject(realm: realm, aemUri: aemData.aemUri), - let cachedUUID = aemCacheObject.aemData.articleJcrContent?.uuid, - let uuid = aemData.articleJcrContent?.uuid, - !cachedUUID.isEmpty, - !uuid.isEmpty { + if let aemCacheObject = self.getAemCacheObject(realm: realm, aemUri: aemData.aemUri), let cachedUUID = aemCacheObject.aemData.articleJcrContent?.uuid, let uuid = aemData.articleJcrContent?.uuid, !cachedUUID.isEmpty, !uuid.isEmpty { dataIsNotCached = false uuidChanged = cachedUUID != uuid diff --git a/godtools/App/Share/Data/ArticlesRepository/Articles/Downloader/Parsers/ArticleAemDataParser.swift b/godtools/App/Share/Data/ArticlesRepository/Articles/Downloader/Parsers/ArticleAemDataParser.swift index 6cb569bf04..cf51a6030c 100644 --- a/godtools/App/Share/Data/ArticlesRepository/Articles/Downloader/Parsers/ArticleAemDataParser.swift +++ b/godtools/App/Share/Data/ArticlesRepository/Articles/Downloader/Parsers/ArticleAemDataParser.swift @@ -92,32 +92,30 @@ class ArticleAemDataParser { } /* - - NOTE: - - The below preferred variatons are root level keys found in the json structure that is getting parsed. - - It appears that each variation can be appended to an aem import src url in order to load an html page per platform. - - For example, take the following aem import src url: - - https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers- - - We obtain the json by appending a number representing the maximum amount of levels the json structure will return like so: - - https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers-.10.json (10 levels). - - We can also append variations 'master' or ('godtools' or 'godtools-variation') to the import src url to load an html page like so: - - master - https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers-/master.html - - //godtools - https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers-/godtools.html - - //godtools-variation - https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/can-you-explain-the-trinity--/godtools-variation.html - + NOTE: + + The below preferred variatons are root level keys found in the json structure that is getting parsed. + + It appears that each variation can be appended to an aem import src url in order to load an html page per platform. + + For example, take the following aem import src url: + + https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers- + + We obtain the json by appending a number representing the maximum amount of levels the json structure will return like so: + + https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers-.10.json (10 levels). + + We can also append variations 'master' or ('godtools' or 'godtools-variation') to the import src url to load an html page like so: + + master + https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers-/master.html + + //godtools + https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/does-god-answer-our-prayers-/godtools.html + + //godtools-variation + https://www.cru.org/content/experience-fragments/shared-library/language-masters/en/how-to-know-god/what-is-christianity/can-you-explain-the-trinity--/godtools-variation.html */ private func getPreferredVariation(aemUrl: URL, aemJson: [String: Any]) -> String? { @@ -126,12 +124,9 @@ class ArticleAemDataParser { for variation in preferredVariationOrder { - for (rootKey, _) in aemJson { + for (rootKey, _) in aemJson where rootKey == variation { - if rootKey == variation { - - return rootKey - } + return rootKey } } diff --git a/godtools/App/Share/Data/ArticlesRepository/Categories/Models/CategoryArticleUUID.swift b/godtools/App/Share/Data/ArticlesRepository/Categories/Models/CategoryArticleUUID.swift index a52f294890..20ce76def9 100644 --- a/godtools/App/Share/Data/ArticlesRepository/Categories/Models/CategoryArticleUUID.swift +++ b/godtools/App/Share/Data/ArticlesRepository/Categories/Models/CategoryArticleUUID.swift @@ -19,7 +19,7 @@ struct CategoryArticleUUID { } extension CategoryArticleUUID: Equatable { - static func ==(lhs: CategoryArticleUUID, rhs: CategoryArticleUUID) -> Bool { - return lhs.uuidString == rhs.uuidString + static func == (this: CategoryArticleUUID, that: CategoryArticleUUID) -> Bool { + return this.uuidString == that.uuidString } } diff --git a/godtools/App/Share/Data/ArticlesRepository/Categories/RealmCache/RealmCategoryArticlesCache.swift b/godtools/App/Share/Data/ArticlesRepository/Categories/RealmCache/RealmCategoryArticlesCache.swift index 2524208d8c..6c880a2d62 100644 --- a/godtools/App/Share/Data/ArticlesRepository/Categories/RealmCache/RealmCategoryArticlesCache.swift +++ b/godtools/App/Share/Data/ArticlesRepository/Categories/RealmCache/RealmCategoryArticlesCache.swift @@ -21,7 +21,8 @@ class RealmCategoryArticlesCache { func getCategoryArticles(categoryId: String, languageCode: String) -> [CategoryArticleModel] { - return realmDatabase.openRealm().objects(RealmCategoryArticle.self) + return realmDatabase.openRealm() + .objects(RealmCategoryArticle.self) .filter(NSPredicate(format: "categoryId == %@ AND languageCode == %@", categoryId, languageCode)) .map({CategoryArticleModel(realmModel: $0)}) } @@ -110,6 +111,6 @@ class RealmCategoryArticlesCache { completion(errors) - }//end realm background + }// end realm background } } diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/AppsFlyerDeepLinkValue/AppsFlyerDeepLinkValueParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/AppsFlyerDeepLinkValue/AppsFlyerDeepLinkValueParser.swift index f5f38df550..4ec5da8034 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/AppsFlyerDeepLinkValue/AppsFlyerDeepLinkValueParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/AppsFlyerDeepLinkValue/AppsFlyerDeepLinkValueParser.swift @@ -16,7 +16,7 @@ class AppsFlyerDeepLinkValueParser: DeepLinkAppsFlyerParserType { } - func parse(data: [AnyHashable : Any]) -> ParsedDeepLinkType? { + func parse(data: [AnyHashable: Any]) -> ParsedDeepLinkType? { guard let deepLinkValue = data["deep_link_value"] as? String else { return nil diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/ArticleAemPath/ArticleAemPathDeepLinkParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/ArticleAemPath/ArticleAemPathDeepLinkParser.swift index 2292f61369..f6a1d489e0 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/ArticleAemPath/ArticleAemPathDeepLinkParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/ArticleAemPath/ArticleAemPathDeepLinkParser.swift @@ -14,7 +14,7 @@ class ArticleAemPathDeepLinkParser: DeepLinkUrlParserType { } - func parse(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + func parse(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { guard let aemUri = queryParameters["uri"] as? String else { return nil diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/DashboardPath/DashboardPathDeepLinkParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/DashboardPath/DashboardPathDeepLinkParser.swift index 202c4398ed..50e4ce3824 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/DashboardPath/DashboardPathDeepLinkParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/DashboardPath/DashboardPathDeepLinkParser.swift @@ -14,7 +14,7 @@ class DashboardPathDeepLinkParser: DeepLinkUrlParserType { } - func parse(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + func parse(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { guard let dashboardPathIndex = pathComponents.firstIndex(of: DashboardDeepLinkDashboardPath.dashboard.rawValue) else { return nil diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/GodtoolsApp/Lessons/GodToolsAppLessonsPathDeepLinkParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/GodtoolsApp/Lessons/GodToolsAppLessonsPathDeepLinkParser.swift index 3a069e5ef2..b8eb28a830 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/GodtoolsApp/Lessons/GodToolsAppLessonsPathDeepLinkParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/GodtoolsApp/Lessons/GodToolsAppLessonsPathDeepLinkParser.swift @@ -14,7 +14,7 @@ class GodToolsAppLessonsPathDeepLinkParser: DeepLinkUrlParserType { } - func parse(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + func parse(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { guard pathComponents.first == "lessons" else { return nil diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/KnowGod/KnowGodDeepLinkParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/KnowGod/KnowGodDeepLinkParser.swift index ac01ebff91..7d502e7897 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/KnowGod/KnowGodDeepLinkParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/KnowGod/KnowGodDeepLinkParser.swift @@ -14,7 +14,7 @@ class KnowGodDeepLinkParser: DeepLinkUrlParserType { } - func parse(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + func parse(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { if pathComponents.first == "lessons" { @@ -26,7 +26,7 @@ class KnowGodDeepLinkParser: DeepLinkUrlParserType { } } - private func parseLesson(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + private func parseLesson(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { guard let resourceAbbreviation = pathComponents[safe: 1] else { return nil @@ -54,7 +54,7 @@ class KnowGodDeepLinkParser: DeepLinkUrlParserType { return .tool(toolDeepLink: toolDeepLink) } - private func parseTract(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + private func parseTract(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { let knowGodQueryParameters: KnowGodTractDeepLinkQueryParameters? = JsonServices().decodeJsonObject(jsonObject: queryParameters) diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/LanguageSettings/LanguageSettingsDeepLinkParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/LanguageSettings/LanguageSettingsDeepLinkParser.swift index 54d3e9e6be..30e2e2e09b 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/LanguageSettings/LanguageSettingsDeepLinkParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/LanguageSettings/LanguageSettingsDeepLinkParser.swift @@ -14,7 +14,7 @@ class LanguageSettingsDeepLinkParser: DeepLinkUrlParserType { } - func parse(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + func parse(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { return .languageSettings } diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/Legacy/LegacyAppsFlyerDeepLinkValueParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/Legacy/LegacyAppsFlyerDeepLinkValueParser.swift index b8887df9ab..18cad2fda1 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/Legacy/LegacyAppsFlyerDeepLinkValueParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/Legacy/LegacyAppsFlyerDeepLinkValueParser.swift @@ -14,16 +14,14 @@ class LegacyAppsFlyerDeepLinkValueParser: DeepLinkAppsFlyerParserType { } - func parse(data: [AnyHashable : Any]) -> ParsedDeepLinkType? { + func parse(data: [AnyHashable: Any]) -> ParsedDeepLinkType? { let resourceAbbreviation: String? if let deepLinkValue = data["deep_link_value"] as? String { resourceAbbreviation = deepLinkValue } - else if let link = data["link"] as? String, - let linkComponents = URLComponents(string: link), - let deepLinkValue = linkComponents.queryItems?.first(where: { $0.name == "deep_link_value" })?.value { + else if let link = data["link"] as? String, let linkComponents = URLComponents(string: link), let deepLinkValue = linkComponents.queryItems?.first(where: { $0.name == "deep_link_value" })?.value { resourceAbbreviation = deepLinkValue } diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/ToolPath/ToolPathDeepLinkParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/ToolPath/ToolPathDeepLinkParser.swift index ae50ed5889..9d737c4fb5 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/ToolPath/ToolPathDeepLinkParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/ToolPath/ToolPathDeepLinkParser.swift @@ -14,7 +14,7 @@ class ToolPathDeepLinkParser: DeepLinkUrlParserType { } - func parse(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + func parse(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { guard let toolPathIndex = pathComponents.firstIndex(of: "tool") else { return nil @@ -24,8 +24,7 @@ class ToolPathDeepLinkParser: DeepLinkUrlParserType { return nil } - guard let resourceAbbreviation = pathComponents[safe: toolPathIndex + 2], - let language = pathComponents[safe: toolPathIndex + 3] else { + guard let resourceAbbreviation = pathComponents[safe: toolPathIndex + 2], let language = pathComponents[safe: toolPathIndex + 3] else { return nil } diff --git a/godtools/App/Share/Data/DeepLinkingService/Parsers/UITests/UITestsDeepLinkParser.swift b/godtools/App/Share/Data/DeepLinkingService/Parsers/UITests/UITestsDeepLinkParser.swift index 5ca9ad3425..d77532d5b9 100644 --- a/godtools/App/Share/Data/DeepLinkingService/Parsers/UITests/UITestsDeepLinkParser.swift +++ b/godtools/App/Share/Data/DeepLinkingService/Parsers/UITests/UITestsDeepLinkParser.swift @@ -14,7 +14,7 @@ class UITestsDeepLinkParser: DeepLinkUrlParserType { } - func parse(url: URL, pathComponents: [String], queryParameters: [String : Any]) -> ParsedDeepLinkType? { + func parse(url: URL, pathComponents: [String], queryParameters: [String: Any]) -> ParsedDeepLinkType? { let appLanguage: AppLanguageDomainModel = (queryParameters["appLanguageCode"] as? String) ?? LanguageCodeDomainModel.english.value diff --git a/godtools/App/Share/Data/FavoritedResourcesRepository/Cache/RealmFavoritedResourcesCache.swift b/godtools/App/Share/Data/FavoritedResourcesRepository/Cache/RealmFavoritedResourcesCache.swift index c345c777cb..90e888e561 100644 --- a/godtools/App/Share/Data/FavoritedResourcesRepository/Cache/RealmFavoritedResourcesCache.swift +++ b/godtools/App/Share/Data/FavoritedResourcesRepository/Cache/RealmFavoritedResourcesCache.swift @@ -25,7 +25,9 @@ class RealmFavoritedResourcesCache { func getFavoritedResourcesChangedPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmFavoritedResource.self).objectWillChange + return realmDatabase.openRealm() + .objects(RealmFavoritedResource.self) + .objectWillChange .eraseToAnyPublisher() } @@ -39,7 +41,9 @@ class RealmFavoritedResourcesCache { func getFavoritedResource(resourceId: String) -> FavoritedResourceDataModel? { - guard let realmFavoritedResource = realmDatabase.openRealm().object(ofType: RealmFavoritedResource.self, forPrimaryKey: resourceId) else { + guard let realmFavoritedResource = realmDatabase.openRealm() + .object(ofType: RealmFavoritedResource.self, forPrimaryKey: resourceId) else { + return nil } @@ -48,19 +52,22 @@ class RealmFavoritedResourcesCache { func getResourceIsFavorited(id: String) -> Bool { - return realmDatabase.openRealm().object(ofType: RealmFavoritedResource.self, forPrimaryKey: id) != nil + return realmDatabase.openRealm() + .object(ofType: RealmFavoritedResource.self, forPrimaryKey: id) != nil } func getFavoritedResourcesSortedByCreatedAt(ascendingOrder: Bool) -> [FavoritedResourceDataModel] { - return realmDatabase.openRealm().objects(RealmFavoritedResource.self) + return realmDatabase.openRealm() + .objects(RealmFavoritedResource.self) .sorted(byKeyPath: #keyPath(RealmFavoritedResource.createdAt), ascending: ascendingOrder) .map({FavoritedResourceDataModel(realmFavoritedResource: $0)}) } func getFavoritedResourcesSortedByCreatedAtPublisher(ascendingOrder: Bool) -> AnyPublisher<[FavoritedResourceDataModel], Never> { - let favoritedResources: [FavoritedResourceDataModel] = realmDatabase.openRealm().objects(RealmFavoritedResource.self) + let favoritedResources: [FavoritedResourceDataModel] = realmDatabase.openRealm() + .objects(RealmFavoritedResource.self) .sorted(byKeyPath: #keyPath(RealmFavoritedResource.createdAt), ascending: ascendingOrder) .map({ return FavoritedResourceDataModel(realmFavoritedResource: $0) diff --git a/godtools/App/Share/Data/LanguagesRepository/Api/Models/LanguageModel.swift b/godtools/App/Share/Data/LanguagesRepository/Api/Models/LanguageModel.swift index a77d6f2c31..327e49aa68 100644 --- a/godtools/App/Share/Data/LanguagesRepository/Api/Models/LanguageModel.swift +++ b/godtools/App/Share/Data/LanguagesRepository/Api/Models/LanguageModel.swift @@ -52,7 +52,7 @@ struct LanguageModel: LanguageModelType, Codable { tempCode = "fil-x-taglish" } - code = tempCode//try attributesContainer?.decodeIfPresent(BCP47LanguageIdentifier.self, forKey: .code) ?? "" // TODO: (GT-2399) Remove tempCode and replace with commented out line. + code = tempCode// try attributesContainer?.decodeIfPresent(BCP47LanguageIdentifier.self, forKey: .code) ?? "" // TODO: (GT-2399) Remove tempCode and replace with commented out line. direction = try attributesContainer?.decodeIfPresent(String.self, forKey: .direction) ?? "" name = try attributesContainer?.decodeIfPresent(String.self, forKey: .name) ?? "" } @@ -68,7 +68,7 @@ struct LanguageModel: LanguageModelType, Codable { } extension LanguageModel: Equatable { - static func ==(lhs: LanguageModel, rhs: LanguageModel) -> Bool { - return lhs.id == rhs.id + static func == (this: LanguageModel, that: LanguageModel) -> Bool { + return this.id == that.id } } diff --git a/godtools/App/Share/Data/LanguagesRepository/Cache/RealmLanguagesCache.swift b/godtools/App/Share/Data/LanguagesRepository/Cache/RealmLanguagesCache.swift index 3621b11f69..b174ee2134 100644 --- a/godtools/App/Share/Data/LanguagesRepository/Cache/RealmLanguagesCache.swift +++ b/godtools/App/Share/Data/LanguagesRepository/Cache/RealmLanguagesCache.swift @@ -22,17 +22,23 @@ class RealmLanguagesCache { } var numberOfLanguages: Int { - return realmDatabase.openRealm().objects(RealmLanguage.self).count + return realmDatabase.openRealm() + .objects(RealmLanguage.self) + .count } func getLanguagesChanged() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmLanguage.self).objectWillChange + return realmDatabase.openRealm() + .objects(RealmLanguage.self) + .objectWillChange .eraseToAnyPublisher() } func getLanguage(id: String) -> LanguageModel? { - guard let realmLanguage = realmDatabase.openRealm().object(ofType: RealmLanguage.self, forPrimaryKey: id) else { + guard let realmLanguage = realmDatabase.openRealm() + .object(ofType: RealmLanguage.self, forPrimaryKey: id) else { + return nil } @@ -41,7 +47,10 @@ class RealmLanguagesCache { func getLanguage(code: String) -> LanguageModel? { - guard let realmLanguage = realmDatabase.openRealm().objects(RealmLanguage.self).filter(NSPredicate(format: "code".appending(" = [c] %@"), code.lowercased())).first else { + guard let realmLanguage = realmDatabase.openRealm() + .objects(RealmLanguage.self).filter(NSPredicate(format: "code".appending(" = [c] %@"), code.lowercased())) + .first else { + return nil } @@ -50,16 +59,17 @@ class RealmLanguagesCache { func getLanguages(ids: [String]) -> [LanguageModel] { - return realmDatabase.openRealm().objects(RealmLanguage.self) + return realmDatabase.openRealm() + .objects(RealmLanguage.self) .filter("id IN %@", ids) - .map{ + .map { LanguageModel(model: $0) } } func getLanguages(languageCodes: [String]) -> [LanguageModel] { - return languageCodes.compactMap({getLanguage(code:$0)}) + return languageCodes.compactMap({ getLanguage(code: $0) }) } func getLanguages(realm: Realm? = nil) -> [LanguageModel] { diff --git a/godtools/App/Share/Data/LaunchCountRepository/Cache/LaunchCountCache.swift b/godtools/App/Share/Data/LaunchCountRepository/Cache/LaunchCountCache.swift index 2d7563b20e..d20b3cb160 100644 --- a/godtools/App/Share/Data/LaunchCountRepository/Cache/LaunchCountCache.swift +++ b/godtools/App/Share/Data/LaunchCountRepository/Cache/LaunchCountCache.swift @@ -34,7 +34,7 @@ class LaunchCountCache { } } -private extension UserDefaults { +extension UserDefaults { private static let launchCountCacheKey: String = "LaunchCountCache.launchCountCacheKey" diff --git a/godtools/App/Share/Data/OptInOnboardingBannerEnabledRepository/OptInOnboardingBannerEnabledCache.swift b/godtools/App/Share/Data/OptInOnboardingBannerEnabledRepository/OptInOnboardingBannerEnabledCache.swift index dcfb334254..d469513900 100644 --- a/godtools/App/Share/Data/OptInOnboardingBannerEnabledRepository/OptInOnboardingBannerEnabledCache.swift +++ b/godtools/App/Share/Data/OptInOnboardingBannerEnabledRepository/OptInOnboardingBannerEnabledCache.swift @@ -25,7 +25,7 @@ class OptInOnboardingBannerEnabledCache { } } -private extension UserDefaults { +extension UserDefaults { private static let enabledCacheKey: String = "keyOpenTutorialCalloutDisabled" diff --git a/godtools/App/Share/Data/ResourcesRepository/Api/Models/ResourceModel.swift b/godtools/App/Share/Data/ResourcesRepository/Api/Models/ResourceModel.swift index b1770f6452..d2b1799faf 100644 --- a/godtools/App/Share/Data/ResourcesRepository/Api/Models/ResourceModel.swift +++ b/godtools/App/Share/Data/ResourcesRepository/Api/Models/ResourceModel.swift @@ -188,8 +188,8 @@ struct ResourceModel: ResourceModelType, Decodable, Identifiable { } extension ResourceModel: Equatable { - static func ==(lhs: ResourceModel, rhs: ResourceModel) -> Bool { - return lhs.id == rhs.id + static func == (this: ResourceModel, that: ResourceModel) -> Bool { + return this.id == that.id } } diff --git a/godtools/App/Share/Data/ResourcesRepository/Cache/RealmResourcesCache.swift b/godtools/App/Share/Data/ResourcesRepository/Cache/RealmResourcesCache.swift index 1c242bc90a..7d667597de 100644 --- a/godtools/App/Share/Data/ResourcesRepository/Cache/RealmResourcesCache.swift +++ b/godtools/App/Share/Data/ResourcesRepository/Cache/RealmResourcesCache.swift @@ -26,13 +26,17 @@ class RealmResourcesCache { } func getResourcesChangedPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmResource.self).objectWillChange + return realmDatabase.openRealm() + .objects(RealmResource.self) + .objectWillChange .eraseToAnyPublisher() } func getResource(id: String) -> ResourceModel? { - guard let realmResource = realmDatabase.openRealm().object(ofType: RealmResource.self, forPrimaryKey: id) else { + guard let realmResource = realmDatabase.openRealm() + .object(ofType: RealmResource.self, forPrimaryKey: id) else { + return nil } @@ -41,7 +45,11 @@ class RealmResourcesCache { func getResource(abbreviation: String) -> ResourceModel? { - guard let realmResource = realmDatabase.openRealm().objects(RealmResource.self).filter("\(#keyPath(RealmResource.abbreviation)) = '\(abbreviation)'").first else { + guard let realmResource = realmDatabase.openRealm() + .objects(RealmResource.self) + .filter("\(#keyPath(RealmResource.abbreviation)) = '\(abbreviation)'") + .first else { + return nil } @@ -50,15 +58,18 @@ class RealmResourcesCache { func getResources(ids: [String]) -> [ResourceModel] { - return realmDatabase.openRealm().objects(RealmResource.self) + return realmDatabase.openRealm() + .objects(RealmResource.self) .filter("\(#keyPath(RealmResource.id)) IN %@", ids) - .map{ + .map { ResourceModel(model: $0) } } func getResources(sorted: Bool = false) -> [ResourceModel] { - var realmResources = realmDatabase.openRealm().objects(RealmResource.self) + + var realmResources = realmDatabase.openRealm() + .objects(RealmResource.self) if sorted { realmResources = realmResources.sorted(byKeyPath: #keyPath(RealmResource.attrDefaultOrder), ascending: true) @@ -68,13 +79,15 @@ class RealmResourcesCache { } func getResources(with metaToolIds: [String?]) -> [ResourceModel] { - return realmDatabase.openRealm().objects(RealmResource.self) + return realmDatabase.openRealm() + .objects(RealmResource.self) .filter(NSPredicate(format: "%K IN %@", #keyPath(RealmResource.metatoolId), metaToolIds)) .map { ResourceModel(model: $0)} } func getResources(with resourceType: ResourceType) -> [ResourceModel] { - return realmDatabase.openRealm().objects(RealmResource.self) + return realmDatabase.openRealm() + .objects(RealmResource.self) .where { $0.resourceType == resourceType.rawValue } .map { ResourceModel(model: $0) } } @@ -328,7 +341,7 @@ extension RealmResourcesCache { let realm: Realm = realmDatabase.openRealm() - return realm.objects(RealmResource.self).filter(filterPredicate).map{ + return realm.objects(RealmResource.self).filter(filterPredicate).map { ResourceModel(model: $0) } } diff --git a/godtools/App/Share/Data/ResourcesSHA256FileCache/ResourcesSHA256FileCache.swift b/godtools/App/Share/Data/ResourcesSHA256FileCache/ResourcesSHA256FileCache.swift index 53b735d3ca..efd265f0a7 100644 --- a/godtools/App/Share/Data/ResourcesSHA256FileCache/ResourcesSHA256FileCache.swift +++ b/godtools/App/Share/Data/ResourcesSHA256FileCache/ResourcesSHA256FileCache.swift @@ -180,8 +180,7 @@ class ResourcesSHA256FileCache { continue } - if let existingRealmSHA256File = realm.object(ofType: RealmSHA256File.self, forPrimaryKey: filenameWithPathExtension), - !existingRealmSHA256File.translations.contains(realmTranslation) { + if let existingRealmSHA256File = realm.object(ofType: RealmSHA256File.self, forPrimaryKey: filenameWithPathExtension), !existingRealmSHA256File.translations.contains(realmTranslation) { existingRealmSHA256File.translations.append(realmTranslation) } diff --git a/godtools/App/Share/Data/TrackDownloadedTranslationsRepository/Cache/TrackDownloadedTranslationsCache.swift b/godtools/App/Share/Data/TrackDownloadedTranslationsRepository/Cache/TrackDownloadedTranslationsCache.swift index a6f1a71b73..331ac7059a 100644 --- a/godtools/App/Share/Data/TrackDownloadedTranslationsRepository/Cache/TrackDownloadedTranslationsCache.swift +++ b/godtools/App/Share/Data/TrackDownloadedTranslationsRepository/Cache/TrackDownloadedTranslationsCache.swift @@ -46,8 +46,7 @@ class TrackDownloadedTranslationsCache { let downloadedTranslation: RealmDownloadedTranslation = RealmDownloadedTranslation() - guard let languageId = translation.language?.id, !languageId.isEmpty, - let resourceId = translation.resource?.id, !resourceId.isEmpty else { + guard let languageId = translation.language?.id, !languageId.isEmpty, let resourceId = translation.resource?.id, !resourceId.isEmpty else { return [] } diff --git a/godtools/App/Share/Data/TranslationsRepository/Cache/RealmTranslationsCache.swift b/godtools/App/Share/Data/TranslationsRepository/Cache/RealmTranslationsCache.swift index d09b358b48..9e036f1c3b 100644 --- a/godtools/App/Share/Data/TranslationsRepository/Cache/RealmTranslationsCache.swift +++ b/godtools/App/Share/Data/TranslationsRepository/Cache/RealmTranslationsCache.swift @@ -20,7 +20,9 @@ class RealmTranslationsCache { func getTranslation(id: String) -> TranslationModel? { - guard let realmTranslation = realmDatabase.openRealm().object(ofType: RealmTranslation.self, forPrimaryKey: id) else { + guard let realmTranslation = realmDatabase.openRealm() + .object(ofType: RealmTranslation.self, forPrimaryKey: id) else { + return nil } @@ -29,16 +31,18 @@ class RealmTranslationsCache { func getTranslations(ids: [String]) -> [TranslationModel] { - return realmDatabase.openRealm().objects(RealmTranslation.self) + return realmDatabase.openRealm() + .objects(RealmTranslation.self) .filter("id IN %@", ids) - .map{ + .map { TranslationModel(model: $0) } } func getTranslationsSortedByLatestVersion(resourceId: String, languageId: String) -> [TranslationModel] { - guard let realmResource = realmDatabase.openRealm().object(ofType: RealmResource.self, forPrimaryKey: resourceId) else { + guard let realmResource = realmDatabase.openRealm() + .object(ofType: RealmResource.self, forPrimaryKey: resourceId) else { return Array() } @@ -52,7 +56,8 @@ class RealmTranslationsCache { func getTranslationsSortedByLatestVersion(resourceId: String, languageCode: String) -> [TranslationModel] { - guard let realmResource = realmDatabase.openRealm().object(ofType: RealmResource.self, forPrimaryKey: resourceId) else { + guard let realmResource = realmDatabase.openRealm() + .object(ofType: RealmResource.self, forPrimaryKey: resourceId) else { return Array() } diff --git a/godtools/App/Share/Data/TranslationsRepository/TranslationsRepository.swift b/godtools/App/Share/Data/TranslationsRepository/TranslationsRepository.swift index a56e3d0871..771c885ef8 100644 --- a/godtools/App/Share/Data/TranslationsRepository/TranslationsRepository.swift +++ b/godtools/App/Share/Data/TranslationsRepository/TranslationsRepository.swift @@ -238,10 +238,7 @@ extension TranslationsRepository { let latestDownloadedTranslation: TranslationModel? - if shouldFallbackToLatestDownloadedTranslation, - let resourceId = translation.resource?.id, - let languageId = translation.language?.id, - let latestTrackedDownloadedTranslation = self.trackDownloadedTranslationsRepository.getLatestDownloadedTranslation(resourceId: resourceId, languageId: languageId) { + if shouldFallbackToLatestDownloadedTranslation, let resourceId = translation.resource?.id, let languageId = translation.language?.id, let latestTrackedDownloadedTranslation = self.trackDownloadedTranslationsRepository.getLatestDownloadedTranslation(resourceId: resourceId, languageId: languageId) { latestDownloadedTranslation = self.getTranslation(id: latestTrackedDownloadedTranslation.translationId) } diff --git a/godtools/App/Share/Data/UserCountersRepository/Cache/RealmUserCountersCache.swift b/godtools/App/Share/Data/UserCountersRepository/Cache/RealmUserCountersCache.swift index 8a4058b629..6a4916e753 100644 --- a/godtools/App/Share/Data/UserCountersRepository/Cache/RealmUserCountersCache.swift +++ b/godtools/App/Share/Data/UserCountersRepository/Cache/RealmUserCountersCache.swift @@ -23,14 +23,17 @@ class RealmUserCountersCache { func getUserCountersChanged() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmUserCounter.self) + return realmDatabase.openRealm() + .objects(RealmUserCounter.self) .objectWillChange .eraseToAnyPublisher() } func getUserCounter(id: String) -> UserCounterDataModel? { - guard let realmUserCounter = realmDatabase.openRealm().object(ofType: RealmUserCounter.self, forPrimaryKey: id) else { + guard let realmUserCounter = realmDatabase.openRealm() + .object(ofType: RealmUserCounter.self, forPrimaryKey: id) else { + return nil } @@ -39,13 +42,15 @@ class RealmUserCountersCache { func getAllUserCounters() -> [UserCounterDataModel] { - return realmDatabase.openRealm().objects(RealmUserCounter.self) + return realmDatabase.openRealm() + .objects(RealmUserCounter.self) .map { UserCounterDataModel(realmUserCounter: $0) } } func getUserCountersWithIncrementGreaterThanZero() -> [UserCounterDataModel] { - return realmDatabase.openRealm().objects(RealmUserCounter.self) + return realmDatabase.openRealm() + .objects(RealmUserCounter.self) .filter(NSPredicate(format: "%K > 0", #keyPath(RealmUserCounter.incrementValue))) .map { UserCounterDataModel(realmUserCounter: $0) } } diff --git a/godtools/App/Share/Data/UserCountersRepository/UserCountersRepository.swift b/godtools/App/Share/Data/UserCountersRepository/UserCountersRepository.swift index 7b16a31bce..d893f30d12 100644 --- a/godtools/App/Share/Data/UserCountersRepository/UserCountersRepository.swift +++ b/godtools/App/Share/Data/UserCountersRepository/UserCountersRepository.swift @@ -33,21 +33,19 @@ class UserCountersRepository { } func getUserCountersChanged(reloadFromRemote: Bool) -> AnyPublisher { + + if reloadFromRemote { - if reloadFromRemote { - - fetchRemoteUserCounters() - .sink(receiveCompletion: { _ in - - }, receiveValue: { _ in - - }) - .store(in: &cancellables) - - } - - return cache.getUserCountersChanged() + fetchRemoteUserCounters() + .sink(receiveCompletion: { _ in + }, receiveValue: { _ in + + }) + .store(in: &cancellables) } + + return cache.getUserCountersChanged() + } func getUserCounters() -> [UserCounterDataModel] { diff --git a/godtools/App/Share/Data/UserDetailsRepository/Cache/RealmUserDetailsCache.swift b/godtools/App/Share/Data/UserDetailsRepository/Cache/RealmUserDetailsCache.swift index 14712610e7..92666cc89f 100644 --- a/godtools/App/Share/Data/UserDetailsRepository/Cache/RealmUserDetailsCache.swift +++ b/godtools/App/Share/Data/UserDetailsRepository/Cache/RealmUserDetailsCache.swift @@ -23,7 +23,9 @@ class RealmUserDetailsCache { func getAuthUserDetailsChangedPublisher() -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmUserDetails.self).objectWillChange + return realmDatabase.openRealm() + .objects(RealmUserDetails.self) + .objectWillChange .map { _ in return self.getAuthUserDetails() } @@ -32,7 +34,9 @@ class RealmUserDetailsCache { func getUserDetailsChangedPublisher(id: String) -> AnyPublisher { - return realmDatabase.openRealm().objects(RealmUserDetails.self).objectWillChange + return realmDatabase.openRealm() + .objects(RealmUserDetails.self) + .objectWillChange .map { _ in let realmObject: RealmUserDetails? = self.realmDatabase.readObject(primaryKey: id) diff --git a/godtools/App/Share/Data/WebArchiveQueue/HTMLDocument+ResourceUrls.swift b/godtools/App/Share/Data/WebArchiveQueue/HTMLDocument+ResourceUrls.swift index 58a2e3ae80..2ff50d5a04 100644 --- a/godtools/App/Share/Data/WebArchiveQueue/HTMLDocument+ResourceUrls.swift +++ b/godtools/App/Share/Data/WebArchiveQueue/HTMLDocument+ResourceUrls.swift @@ -14,10 +14,10 @@ extension HTMLDocument { func getHTMLReferences(host: String, includeJavascript: Bool) -> [String] { var references: [String] = Array() - references += xpath("//img[@src]").compactMap{ $0["src"] } // images - references += xpath("//link[@rel='stylesheet'][@href]").compactMap{ $0["href"] } // css + references += xpath("//img[@src]").compactMap { $0["src"] } // images + references += xpath("//link[@rel='stylesheet'][@href]").compactMap { $0["href"] } // css if includeJavascript { - references += xpath("//script[@src]").compactMap{ $0["src"] } // javascript + references += xpath("//script[@src]").compactMap { $0["src"] } // javascript } return references.map { ref in diff --git a/godtools/App/Share/Data/WebArchiveQueue/WebArchiveQueueResult.swift b/godtools/App/Share/Data/WebArchiveQueue/WebArchiveQueueResult.swift index a9bd348196..0b92d0d9a5 100644 --- a/godtools/App/Share/Data/WebArchiveQueue/WebArchiveQueueResult.swift +++ b/godtools/App/Share/Data/WebArchiveQueue/WebArchiveQueueResult.swift @@ -15,11 +15,11 @@ struct WebArchiveQueueResult { let totalAttemptedArchives: Int var networkFailed: Bool { - for operationError in failedArchives { - if operationError.networkFailed { - return true - } + + for operationError in failedArchives where operationError.networkFailed { + return true } + return false } } diff --git a/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/DetermineToolTranslationsToDownload/DetermineDeepLinkedToolTranslationsToDownload.swift b/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/DetermineToolTranslationsToDownload/DetermineDeepLinkedToolTranslationsToDownload.swift index 65ad8848b7..937b12647a 100644 --- a/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/DetermineToolTranslationsToDownload/DetermineDeepLinkedToolTranslationsToDownload.swift +++ b/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/DetermineToolTranslationsToDownload/DetermineDeepLinkedToolTranslationsToDownload.swift @@ -60,8 +60,7 @@ class DetermineDeepLinkedToolTranslationsToDownload: DetermineToolTranslationsTo return primaryTranslation } - else if let appLanguage = userAppLanguageRepository.getCachedLanguage(), - let appLanguageTranslation = translationsRepository.getLatestTranslation(resourceId: resource.id, languageCode: appLanguage.languageId) { + else if let appLanguage = userAppLanguageRepository.getCachedLanguage(), let appLanguageTranslation = translationsRepository.getLatestTranslation(resourceId: resource.id, languageCode: appLanguage.languageId) { return appLanguageTranslation } diff --git a/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/GetToolTranslationsFilesUseCase.swift b/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/GetToolTranslationsFilesUseCase.swift index 03829194a2..985760c39e 100644 --- a/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/GetToolTranslationsFilesUseCase.swift +++ b/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/GetToolTranslationsFilesUseCase.swift @@ -145,6 +145,3 @@ class GetToolTranslationsFilesUseCase { return sortedLanguageTranslationManifests } } - - - diff --git a/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/ToolTranslationsDomainModel.swift b/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/ToolTranslationsDomainModel.swift index 296ebcdfae..11695d4a71 100644 --- a/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/ToolTranslationsDomainModel.swift +++ b/godtools/App/Share/Domain/UseCases/GetToolTranslationsFilesUseCase/ToolTranslationsDomainModel.swift @@ -13,4 +13,3 @@ struct ToolTranslationsDomainModel { let tool: ResourceModel let languageTranslationManifests: [MobileContentRendererLanguageTranslationManifest] } - diff --git a/godtools/App/Share/Domain/UseCases/ViewSearchBarUseCase.swift b/godtools/App/Share/Domain/UseCases/ViewSearchBarUseCase.swift index 116b60b276..0106da340c 100644 --- a/godtools/App/Share/Domain/UseCases/ViewSearchBarUseCase.swift +++ b/godtools/App/Share/Domain/UseCases/ViewSearchBarUseCase.swift @@ -20,10 +20,11 @@ class ViewSearchBarUseCase { func viewPublisher(appLanguage: AppLanguageDomainModel) -> AnyPublisher { - return self.getInterfaceStringsRepository.getStringsPublisher(translateInAppLanguage: appLanguage).map { - - return ViewSearchBarDomainModel(interfaceStrings: $0) - } - .eraseToAnyPublisher() + return self.getInterfaceStringsRepository + .getStringsPublisher(translateInAppLanguage: appLanguage) + .map { + return ViewSearchBarDomainModel(interfaceStrings: $0) + } + .eraseToAnyPublisher() } } diff --git a/godtools/App/Share/Extensions/View+CornerRadius.swift b/godtools/App/Share/Extensions/View+CornerRadius.swift index 4155428142..9d593846b9 100644 --- a/godtools/App/Share/Extensions/View+CornerRadius.swift +++ b/godtools/App/Share/Extensions/View+CornerRadius.swift @@ -8,7 +8,7 @@ import SwiftUI -public extension View { +extension View { func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View { clipShape( RoundedCorner(radius: radius, corners: corners) ) diff --git a/godtools/App/Share/SwiftUI Views/FullScreenVideoView/FullScreenVideoView.swift b/godtools/App/Share/SwiftUI Views/FullScreenVideoView/FullScreenVideoView.swift index 081ffaef7a..0d333b479c 100644 --- a/godtools/App/Share/SwiftUI Views/FullScreenVideoView/FullScreenVideoView.swift +++ b/godtools/App/Share/SwiftUI Views/FullScreenVideoView/FullScreenVideoView.swift @@ -44,7 +44,6 @@ struct FullScreenVideoView: View { }) .frame(width: videoWidth, height: videoHeight) - Spacer() } } diff --git a/godtools/App/Share/SwiftUI Views/LanguageSupportedText/LanguageSupportedText.swift b/godtools/App/Share/SwiftUI Views/LanguageSupportedText/LanguageSupportedText.swift index e81e921759..3f8e2e50fd 100644 --- a/godtools/App/Share/SwiftUI Views/LanguageSupportedText/LanguageSupportedText.swift +++ b/godtools/App/Share/SwiftUI Views/LanguageSupportedText/LanguageSupportedText.swift @@ -18,7 +18,7 @@ struct LanguageSupportedText: View { HStack(alignment: .bottom, spacing: 4) { Text(languageName) - Image(isSupported ? ImageCatalog.languageAvailableCheck.name: ImageCatalog.languageUnavailableX.name) + Image(isSupported ? ImageCatalog.languageAvailableCheck.name : ImageCatalog.languageUnavailableX.name) .padding(EdgeInsets(top: 0, leading: 0, bottom: 4, trailing: 0)) } } diff --git a/godtools/App/Share/SwiftUI Views/SearchBar/SearchBarLegacy.swift b/godtools/App/Share/SwiftUI Views/SearchBar/SearchBarLegacy.swift index ea275edd34..3197c03f2c 100644 --- a/godtools/App/Share/SwiftUI Views/SearchBar/SearchBarLegacy.swift +++ b/godtools/App/Share/SwiftUI Views/SearchBar/SearchBarLegacy.swift @@ -74,4 +74,3 @@ struct SearchBarLegacy: View { } } } - diff --git a/godtools/App/Share/SwiftUI Views/TwoRowHStack/TwoRowHStack.swift b/godtools/App/Share/SwiftUI Views/TwoRowHStack/TwoRowHStack.swift index af20eac7df..fa64af3b37 100644 --- a/godtools/App/Share/SwiftUI Views/TwoRowHStack/TwoRowHStack.swift +++ b/godtools/App/Share/SwiftUI Views/TwoRowHStack/TwoRowHStack.swift @@ -15,7 +15,7 @@ struct TwoRowHStack: View { private let spacing: CGFloat private let content: (Int) -> Content - init(itemCount: Int, spacing: CGFloat, @ViewBuilder content:@escaping (Int) -> Content) { + init(itemCount: Int, spacing: CGFloat, @ViewBuilder content: @escaping (Int) -> Content) { self.itemCount = itemCount self.numberOfColumns = Int(ceil(Double(itemCount) / 2)) diff --git a/godtools/App/Share/SwiftUI Views/VideoView/VideoViewRepresentable.swift b/godtools/App/Share/SwiftUI Views/VideoView/VideoViewRepresentable.swift index 36f296117e..28d4666210 100644 --- a/godtools/App/Share/SwiftUI Views/VideoView/VideoViewRepresentable.swift +++ b/godtools/App/Share/SwiftUI Views/VideoView/VideoViewRepresentable.swift @@ -71,7 +71,6 @@ struct VideoViewRepresentable: UIViewRepresentable { if animated { UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseOut) { - //animations videoViewRep.loadingView.alpha = loadingViewAlpha } completion: { (finished: Bool) in if finished && hidden { diff --git a/godtools/App/Share/Views/LoadingView/LoadingView.swift b/godtools/App/Share/Views/LoadingView/LoadingView.swift index eef024ce21..7b750d984e 100644 --- a/godtools/App/Share/Views/LoadingView/LoadingView.swift +++ b/godtools/App/Share/Views/LoadingView/LoadingView.swift @@ -43,4 +43,3 @@ class LoadingView: AppViewController { loadingView.startAnimating() } } - diff --git a/godtools/App/Share/Views/Navigation/NavigationBar/NavBarItems/NavBarItem/ButtonsWithImage/AppLottieBarItem.swift b/godtools/App/Share/Views/Navigation/NavigationBar/NavBarItems/NavBarItem/ButtonsWithImage/AppLottieBarItem.swift index 472ace442a..8d9c3ecd8e 100644 --- a/godtools/App/Share/Views/Navigation/NavigationBar/NavBarItems/NavBarItem/ButtonsWithImage/AppLottieBarItem.swift +++ b/godtools/App/Share/Views/Navigation/NavigationBar/NavBarItems/NavBarItem/ButtonsWithImage/AppLottieBarItem.swift @@ -39,4 +39,3 @@ class AppLottieBarItem: NavBarItem { ) } } - diff --git a/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionView.swift b/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionView.swift index fe17c2d9ba..d798bdd5dc 100644 --- a/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionView.swift +++ b/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionView.swift @@ -66,7 +66,7 @@ class PageNavigationCollectionView: UIView, NibBased { assertionFailure("init(frame:) not supported") self.layout = PageNavigationCollectionView.getDefaultFlowLayout() - self.layoutType = .fullScreen + self.layoutType = .fullScreen super.init(frame: frame) } @@ -74,7 +74,7 @@ class PageNavigationCollectionView: UIView, NibBased { required init?(coder: NSCoder) { self.layout = PageNavigationCollectionView.getDefaultFlowLayout() - self.layoutType = .fullScreen + self.layoutType = .fullScreen super.init(coder: coder) @@ -655,8 +655,8 @@ extension PageNavigationCollectionView: UIScrollViewDelegate { func scrollViewDidScroll(_ scrollView: UIScrollView) { - //logMessage(message: "did scroll") - //logMessage(message: " contentOffset.x: \(scrollView.contentOffset.x)") + // logMessage(message: "did scroll") + // logMessage(message: " contentOffset.x: \(scrollView.contentOffset.x)") let currentPage: Int = getPageBasedOnContentOffset(contentOffset: scrollView.contentOffset) diff --git a/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionViewCenteredLayout.swift b/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionViewCenteredLayout.swift index c0175f8386..a8bb7d9a5a 100644 --- a/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionViewCenteredLayout.swift +++ b/godtools/App/Share/Views/PageNavigationCollectionView/PageNavigationCollectionViewCenteredLayout.swift @@ -12,8 +12,8 @@ class PageNavigationCollectionViewCenteredLayout: UICollectionViewFlowLayout { enum PanDirection { + case directionNotSet case left - case none case right } @@ -26,7 +26,7 @@ class PageNavigationCollectionViewCenteredLayout: UICollectionViewFlowLayout { private var beginningContentOffset: CGPoint? private var lastPanningPoint: CGPoint = .zero - private(set) var panDirection: PageNavigationCollectionViewCenteredLayout.PanDirection = .none + private(set) var panDirection: PageNavigationCollectionViewCenteredLayout.PanDirection = .directionNotSet private(set) var isPanning: Bool = false private weak var pageNavigationCollectionView: PageNavigationCollectionView? @@ -100,6 +100,9 @@ class PageNavigationCollectionViewCenteredLayout: UICollectionViewFlowLayout { switch panDirection { + case .directionNotSet: + targetPage = beginningPage + case .left: if lastPanningPoint.x < beginningPanPoint.x { @@ -109,9 +112,6 @@ class PageNavigationCollectionViewCenteredLayout: UICollectionViewFlowLayout { targetPage = beginningPage } - case .none: - targetPage = beginningPage - case .right: if lastPanningPoint.x > beginningPanPoint.x { diff --git a/godtools/App/Share/Views/TransparentModal/TransparentModalView.swift b/godtools/App/Share/Views/TransparentModal/TransparentModalView.swift index b93a7b593d..071fa1b0bf 100644 --- a/godtools/App/Share/Views/TransparentModal/TransparentModalView.swift +++ b/godtools/App/Share/Views/TransparentModal/TransparentModalView.swift @@ -80,14 +80,7 @@ class TransparentModalView: UIViewController { // overlayButton overlayButton.backgroundColor = .black overlayButton.alpha = 0.4 - - //customModalView.backgroundColor = .white - //customModalView.layer.cornerRadius = modalCornerRadius - //customModalView.layer.shadowOffset = CGSize(width: 1, height: 1) - //customModalView.layer.shadowColor = UIColor.black.cgColor - //customModalView.layer.shadowRadius = 5 - //customModalView.layer.shadowOpacity = 0.6 - + // modalView addModalView(modalView: modalView) }