From 31e4ad7b74ae618ed5261b659342cf81ec9fc314 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 14:55:35 -0600 Subject: [PATCH 01/46] Initial Catalyst support (builds\!), Switch to Alamofire 5 --- Podfile | 10 +- Podfile.lock | 6 +- Slide Widgets/Slide Widgets.entitlements | 4 + Slide for Reddit.xcodeproj/project.pbxproj | 176 +++++++++++------- .../xcschemes/Slide for Apple Watch.xcscheme | 25 ++- .../xcshareddata/swiftpm/Package.resolved | 9 + .../NavigationHomeViewController.swift | 2 +- Slide for Reddit/ReplyViewController.swift | 4 +- Slide for Reddit/SettingValues.swift | 5 +- .../Slide for Reddit.entitlements | 8 + .../SplitMainViewController.swift | 2 +- Slide for Reddit/SubredditHeaderView.swift | 2 +- Slide for Reddit/ToolbarTextView.swift | 35 ++-- Slide for Reddit/TrendingViewController.swift | 4 +- Slide for Reddit/VideoMediaDownloader.swift | 14 +- .../VideoMediaViewController.swift | 14 +- Slide for Reddit/WebsiteViewController.swift | 4 +- .../WidgetConfigIntent.entitlements | 8 +- 18 files changed, 206 insertions(+), 126 deletions(-) diff --git a/Podfile b/Podfile index d7de4440a..cd5180336 100644 --- a/Podfile +++ b/Podfile @@ -19,7 +19,6 @@ target 'Slide for Reddit' do pod 'SwiftLinkPreview', '~> 3.0.1' pod 'DTCoreText', :git => 'https://github.com/Cocoanetics/DTCoreText' pod 'RLBAlertsPickers', :git => 'https://github.com/ccrama/Alerts-Pickers' - pod 'Alamofire', '~> 4.3' pod 'SwiftyJSON', :git => 'https://github.com/ccrama/SwiftyJSON.git', :branch => 'hotfix-xcode12' pod "YoutubePlayer-in-WKWebView", "~> 0.3.0" pod 'TGPControls' @@ -35,6 +34,15 @@ target 'Slide for Reddit' do end post_install do |installer| + installer.pods_project.targets.each do |target| + # Fix bundle targets' 'Signing Certificate' to 'Sign to Run Locally' + if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle" + target.build_configurations.each do |config| + config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = '-' + end + end + end + installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11' diff --git a/Podfile.lock b/Podfile.lock index e3fff770f..89ff77f76 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,4 @@ PODS: - - Alamofire (4.9.1) - DTCoreText (1.6.26): - DTCoreText/Core (= 1.6.26) - DTFoundation/Core (~> 1.7.5) @@ -55,7 +54,6 @@ PODS: - YoutubePlayer-in-WKWebView (0.3.5) DEPENDENCIES: - - Alamofire (~> 4.3) - DTCoreText (from `https://github.com/Cocoanetics/DTCoreText`) - LicensesViewController (~> 0.7.0) - MaterialComponents/ActivityIndicator @@ -76,7 +74,6 @@ DEPENDENCIES: SPEC REPOS: trunk: - - Alamofire - DTFoundation - HTMLSpecialCharacters - LicensesViewController @@ -135,7 +132,6 @@ CHECKOUT OPTIONS: :git: https://github.com/ccrama/SwiftyJSON.git SPEC CHECKSUMS: - Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 DTCoreText: ec749e013f2e1f76de5e7c7634642e600a7467ce DTFoundation: e7781d9fd2f202bfd451fbbf8cab71ce83b46498 HTMLSpecialCharacters: edc707cc4bcdc92eb3b9551de8cff94c1e6f9a19 @@ -160,6 +156,6 @@ SPEC CHECKSUMS: TGPControls: 52c0770bee9c9aee364f1559cc627fc01ea5e8b2 YoutubePlayer-in-WKWebView: cfbf46da51d7370662a695a8f351e5fa1d3e1008 -PODFILE CHECKSUM: 921cd225b4120efa1cb2e0c32101c3932f6ceb0c +PODFILE CHECKSUM: 11d5327e7fce051cd3b3ec699136a01fb7ad5b71 COCOAPODS: 1.10.0 diff --git a/Slide Widgets/Slide Widgets.entitlements b/Slide Widgets/Slide Widgets.entitlements index 23b6b4cc6..41aeeed9d 100644 --- a/Slide Widgets/Slide Widgets.entitlements +++ b/Slide Widgets/Slide Widgets.entitlements @@ -2,9 +2,13 @@ + com.apple.security.app-sandbox + com.apple.security.application-groups group.$(USR_DOMAIN).redditslide.prefs + com.apple.security.network.client + diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index c22090cb3..6e8197d75 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -50,13 +50,13 @@ B49EFE382511A18F002D6AEE /* HotPostsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49EFE372511A18F002D6AEE /* HotPostsWidget.swift */; }; B49EFE482511A1D1002D6AEE /* FavoriteSubredditsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49EFE472511A1D1002D6AEE /* FavoriteSubredditsWidget.swift */; }; B49EFE522511A221002D6AEE /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49EFE512511A221002D6AEE /* UIImage+Extensions.swift */; }; - B4F333E1251273AF0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333E0251273AF0032BB64 /* SwiftPackageProductDependency */; }; - B4F333EB251274050032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333EA251274050032BB64 /* SwiftPackageProductDependency */; }; - B4F333F52512742E0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333F42512742E0032BB64 /* SwiftPackageProductDependency */; }; - B4F3348B2512770F0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3348A2512770F0032BB64 /* SwiftPackageProductDependency */; }; - B4F3349F251277B80032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3349E251277B80032BB64 /* SwiftPackageProductDependency */; }; - B4F3354C25127BAB0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3354B25127BAB0032BB64 /* SwiftPackageProductDependency */; }; - B4F3355625127BD20032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3355525127BD20032BB64 /* SwiftPackageProductDependency */; }; + B4F333E1251273AF0032BB64 /* SDWebImage in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333E0251273AF0032BB64 /* SDWebImage */; }; + B4F333EB251274050032BB64 /* BadgeSwift in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333EA251274050032BB64 /* BadgeSwift */; }; + B4F333F52512742E0032BB64 /* BiometricAuthentication in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333F42512742E0032BB64 /* BiometricAuthentication */; }; + B4F3348B2512770F0032BB64 /* Embassy in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3348A2512770F0032BB64 /* Embassy */; }; + B4F3349F251277B80032BB64 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3349E251277B80032BB64 /* Starscream */; }; + B4F3354C25127BAB0032BB64 /* Anchorage in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3354B25127BAB0032BB64 /* Anchorage */; }; + B4F3355625127BD20032BB64 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3355525127BD20032BB64 /* Then */; }; B776B17D5CA92860424F37C0 /* ModQueueContributionLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B776BA7C2B7217C3875F3BEC /* ModQueueContributionLoader.swift */; }; B776B1DF80711B443ED76B61 /* SettingsPro.swift in Sources */ = {isa = PBXBuildFile; fileRef = B776B2AEE4A2438F5803329C /* SettingsPro.swift */; }; B776B1E23F4DEC18069F1579 /* MediaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B776BC65995FE8D1EE75E2AB /* MediaViewController.swift */; }; @@ -169,7 +169,7 @@ BE20852521588F3B00D8F33C /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE20852421588F3B00D8F33C /* ExtensionDelegate.swift */; }; BE20852721588F3B00D8F33C /* NotificationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE20852621588F3B00D8F33C /* NotificationController.swift */; }; BE20852921588F3B00D8F33C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BE20852821588F3B00D8F33C /* Assets.xcassets */; }; - BE20852E21588F3B00D8F33C /* Slide for Apple Watch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = BE20851121588F3900D8F33C /* Slide for Apple Watch.app */; }; + BE20852E21588F3B00D8F33C /* Slide for Apple Watch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = BE20851121588F3900D8F33C /* Slide for Apple Watch.app */; platformFilter = ios; }; BE20853A21589FD600D8F33C /* SubmissionRowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE20853921589FD600D8F33C /* SubmissionRowController.swift */; }; BE232695222DE429005CA83A /* ic_ghost@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BE232693222DE428005CA83A /* ic_ghost@2x.png */; }; BE232696222DE429005CA83A /* ic_ghost@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = BE232694222DE428005CA83A /* ic_ghost@3x.png */; }; @@ -202,7 +202,7 @@ BE2F3F5D1EF96877003C1B28 /* SettingsContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE2F3F5C1EF96877003C1B28 /* SettingsContent.swift */; }; BE3144FF25663674004A908C /* AsyncTextAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3144FE25663674004A908C /* AsyncTextAttachment.swift */; }; BE314509256738FF004A908C /* TitleUITextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE314508256738FF004A908C /* TitleUITextView.swift */; }; - BE31454625674E03004A908C /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = BE31454525674E03004A908C /* SwiftPackageProductDependency */; }; + BE31454625674E03004A908C /* Proton in Frameworks */ = {isa = PBXBuildFile; productRef = BE31454525674E03004A908C /* Proton */; }; BE325C66257EF04600BD2468 /* RedditObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE325C65257EF04600BD2468 /* RedditObject.swift */; }; BE325C70257EF06A00BD2468 /* SubmissionObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE325C6F257EF06A00BD2468 /* SubmissionObject.swift */; }; BE325C7C257EF33900BD2468 /* CommentObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE325C7B257EF33900BD2468 /* CommentObject.swift */; }; @@ -310,6 +310,7 @@ BE8AE94321F9225000E1C0D1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BE8AE94221F9225000E1C0D1 /* Main.storyboard */; }; BE8AE94721F922F400E1C0D1 /* ColorPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8AE94621F922F400E1C0D1 /* ColorPickerViewController.swift */; }; BE8C29211EDE8001004D7514 /* MarginedTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8C29201EDE8001004D7514 /* MarginedTableViewCell.swift */; }; + BE8CDDCD25C261D1002BBFF4 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = BE8CDDCC25C261D1002BBFF4 /* Alamofire */; }; BE8EA67325A80F4B0094718E /* SubredditToolbarSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8EA67225A80F4B0094718E /* SubredditToolbarSearchViewController.swift */; }; BE8FCA081E0C46090063B8EF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8FCA071E0C46090063B8EF /* AppDelegate.swift */; }; BE8FCA0A1E0C46090063B8EF /* SingleSubredditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8FCA091E0C46090063B8EF /* SingleSubredditViewController.swift */; }; @@ -821,6 +822,7 @@ BE8AE94221F9225000E1C0D1 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; BE8AE94621F922F400E1C0D1 /* ColorPickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorPickerViewController.swift; sourceTree = ""; }; BE8C29201EDE8001004D7514 /* MarginedTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginedTableViewCell.swift; sourceTree = ""; }; + BE8CDBB325C259EF002BBFF4 /* Open in Slide.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Open in Slide.entitlements"; sourceTree = ""; }; BE8EA67225A80F4B0094718E /* SubredditToolbarSearchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubredditToolbarSearchViewController.swift; sourceTree = ""; }; BE8FCA041E0C46090063B8EF /* Slide for Reddit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Slide for Reddit.app"; sourceTree = BUILT_PRODUCTS_DIR; }; BE8FCA071E0C46090063B8EF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -960,18 +962,19 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B4F333F52512742E0032BB64 /* BuildFile in Frameworks */, + B4F333F52512742E0032BB64 /* BiometricAuthentication in Frameworks */, + BE8CDDCD25C261D1002BBFF4 /* Alamofire in Frameworks */, BEC2AB3A250D8D2C00AD5BEA /* WidgetKit.framework in Frameworks */, - B4F3355625127BD20032BB64 /* BuildFile in Frameworks */, - B4F333E1251273AF0032BB64 /* BuildFile in Frameworks */, - B4F333EB251274050032BB64 /* BuildFile in Frameworks */, + B4F3355625127BD20032BB64 /* Then in Frameworks */, + B4F333E1251273AF0032BB64 /* SDWebImage in Frameworks */, + B4F333EB251274050032BB64 /* BadgeSwift in Frameworks */, BE51BE6520C7386A00DFFD8B /* StoreKit.framework in Frameworks */, - B4F3354C25127BAB0032BB64 /* BuildFile in Frameworks */, - B4F3348B2512770F0032BB64 /* BuildFile in Frameworks */, - BE31454625674E03004A908C /* BuildFile in Frameworks */, + B4F3354C25127BAB0032BB64 /* Anchorage in Frameworks */, + B4F3348B2512770F0032BB64 /* Embassy in Frameworks */, + BE31454625674E03004A908C /* Proton in Frameworks */, BE2E9F0823492B4300FE07B4 /* CloudKit.framework in Frameworks */, BE7BFB481F1997BA009CA2E1 /* MapKit.framework in Frameworks */, - B4F3349F251277B80032BB64 /* BuildFile in Frameworks */, + B4F3349F251277B80032BB64 /* Starscream in Frameworks */, 01BBE6AB1AC863FE2E897632 /* Pods_Slide_for_Reddit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1217,6 +1220,7 @@ BE257A6C21F64AA30082A47E /* Open in Slide */ = { isa = PBXGroup; children = ( + BE8CDBB325C259EF002BBFF4 /* Open in Slide.entitlements */, BE257A6D21F64AA30082A47E /* Media.xcassets */, BE257A6F21F64AA30082A47E /* ActionViewController.swift */, BE257A7121F64AA30082A47E /* MainInterface.storyboard */, @@ -1823,14 +1827,15 @@ ); name = "Slide for Reddit"; packageProductDependencies = ( - B4F333E0251273AF0032BB64 /* SwiftPackageProductDependency */, - B4F333EA251274050032BB64 /* SwiftPackageProductDependency */, - B4F333F42512742E0032BB64 /* SwiftPackageProductDependency */, - B4F3348A2512770F0032BB64 /* SwiftPackageProductDependency */, - B4F3349E251277B80032BB64 /* SwiftPackageProductDependency */, - B4F3354B25127BAB0032BB64 /* SwiftPackageProductDependency */, - B4F3355525127BD20032BB64 /* SwiftPackageProductDependency */, - BE31454525674E03004A908C /* SwiftPackageProductDependency */, + B4F333E0251273AF0032BB64 /* SDWebImage */, + B4F333EA251274050032BB64 /* BadgeSwift */, + B4F333F42512742E0032BB64 /* BiometricAuthentication */, + B4F3348A2512770F0032BB64 /* Embassy */, + B4F3349E251277B80032BB64 /* Starscream */, + B4F3354B25127BAB0032BB64 /* Anchorage */, + B4F3355525127BD20032BB64 /* Then */, + BE31454525674E03004A908C /* Proton */, + BE8CDDCC25C261D1002BBFF4 /* Alamofire */, ); productName = "Slide for Reddit"; productReference = BE8FCA041E0C46090063B8EF /* Slide for Reddit.app */; @@ -1994,14 +1999,15 @@ ); mainGroup = BE8FC9FB1E0C46090063B8EF; packageReferences = ( - B4F333DF251273AF0032BB64 /* RemoteSwiftPackageReference */, - B4F333E9251274050032BB64 /* RemoteSwiftPackageReference */, - B4F333F32512742E0032BB64 /* RemoteSwiftPackageReference */, - B4F334892512770F0032BB64 /* RemoteSwiftPackageReference */, - B4F3349D251277B80032BB64 /* RemoteSwiftPackageReference */, - B4F3354A25127BAB0032BB64 /* RemoteSwiftPackageReference */, - B4F3355425127BD20032BB64 /* RemoteSwiftPackageReference */, - BE31454425674E03004A908C /* RemoteSwiftPackageReference */, + B4F333DF251273AF0032BB64 /* XCRemoteSwiftPackageReference "SDWebImage" */, + B4F333E9251274050032BB64 /* XCRemoteSwiftPackageReference "swift-badge" */, + B4F333F32512742E0032BB64 /* XCRemoteSwiftPackageReference "BiometricAuthentication" */, + B4F334892512770F0032BB64 /* XCRemoteSwiftPackageReference "Embassy" */, + B4F3349D251277B80032BB64 /* XCRemoteSwiftPackageReference "Starscream" */, + B4F3354A25127BAB0032BB64 /* XCRemoteSwiftPackageReference "Anchorage" */, + B4F3355425127BD20032BB64 /* XCRemoteSwiftPackageReference "Then" */, + BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */, + BE8CDDCB25C261D1002BBFF4 /* XCRemoteSwiftPackageReference "Alamofire" */, ); productRefGroup = BE8FCA051E0C46090063B8EF /* Products */; projectDirPath = ""; @@ -2268,7 +2274,6 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Slide for Reddit/Pods-Slide for Reddit-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", "${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework", "${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework", "${BUILT_PRODUCTS_DIR}/HTMLSpecialCharacters/HTMLSpecialCharacters.framework", @@ -2294,7 +2299,6 @@ ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTCoreText.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTFoundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HTMLSpecialCharacters.framework", @@ -2707,6 +2711,7 @@ }; BE20852D21588F3B00D8F33C /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BE20851021588F3900D8F33C /* Slide for Apple Watch */; targetProxy = BE20852C21588F3B00D8F33C /* PBXContainerItemProxy */; }; @@ -2777,7 +2782,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2793,6 +2798,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).WidgetConfigIntent"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2810,7 +2816,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2826,6 +2832,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgetconfigintent"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2845,7 +2852,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2886,7 +2893,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2920,7 +2927,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2953,7 +2960,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2984,10 +2991,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "Open in Slide/Open in Slide.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3003,6 +3011,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).Open-in-Slide"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3016,10 +3025,11 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "Open in Slide/Open in Slide.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3035,6 +3045,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledOpen-in-Slide"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3174,11 +3185,12 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3193,11 +3205,14 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SUPPORTS_MACCATALYST = YES; + SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; "SWIFT_OPTIMIZATION_LEVEL[arch=*]" = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; @@ -3212,12 +3227,13 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3232,9 +3248,12 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide"; + SUPPORTS_MACCATALYST = YES; + SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; @@ -3389,7 +3408,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3405,6 +3424,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).widgets"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3424,7 +3444,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 219; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3440,6 +3460,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgets 1599951103"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3541,7 +3562,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - B4F333DF251273AF0032BB64 /* RemoteSwiftPackageReference */ = { + B4F333DF251273AF0032BB64 /* XCRemoteSwiftPackageReference "SDWebImage" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SDWebImage/SDWebImage"; requirement = { @@ -3549,7 +3570,7 @@ minimumVersion = 5.9.1; }; }; - B4F333E9251274050032BB64 /* RemoteSwiftPackageReference */ = { + B4F333E9251274050032BB64 /* XCRemoteSwiftPackageReference "swift-badge" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/evgenyneu/swift-badge"; requirement = { @@ -3557,7 +3578,7 @@ minimumVersion = 8.0.2; }; }; - B4F333F32512742E0032BB64 /* RemoteSwiftPackageReference */ = { + B4F333F32512742E0032BB64 /* XCRemoteSwiftPackageReference "BiometricAuthentication" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/rushisangani/BiometricAuthentication"; requirement = { @@ -3565,7 +3586,7 @@ minimumVersion = 3.1.2; }; }; - B4F334892512770F0032BB64 /* RemoteSwiftPackageReference */ = { + B4F334892512770F0032BB64 /* XCRemoteSwiftPackageReference "Embassy" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/envoy/Embassy"; requirement = { @@ -3573,7 +3594,7 @@ minimumVersion = 4.1.1; }; }; - B4F3349D251277B80032BB64 /* RemoteSwiftPackageReference */ = { + B4F3349D251277B80032BB64 /* XCRemoteSwiftPackageReference "Starscream" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/daltoniam/Starscream"; requirement = { @@ -3581,7 +3602,7 @@ version = 3.1.1; }; }; - B4F3354A25127BAB0032BB64 /* RemoteSwiftPackageReference */ = { + B4F3354A25127BAB0032BB64 /* XCRemoteSwiftPackageReference "Anchorage" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Rightpoint/Anchorage"; requirement = { @@ -3589,7 +3610,7 @@ minimumVersion = 4.5.0; }; }; - B4F3355425127BD20032BB64 /* RemoteSwiftPackageReference */ = { + B4F3355425127BD20032BB64 /* XCRemoteSwiftPackageReference "Then" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/devxoul/Then"; requirement = { @@ -3597,7 +3618,7 @@ minimumVersion = 2.7.0; }; }; - BE31454425674E03004A908C /* RemoteSwiftPackageReference */ = { + BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/rajdeep/proton"; requirement = { @@ -3605,49 +3626,62 @@ minimumVersion = 0.5.0; }; }; + BE8CDDCB25C261D1002BBFF4 /* XCRemoteSwiftPackageReference "Alamofire" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Alamofire/Alamofire.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.4.1; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - B4F333E0251273AF0032BB64 /* SwiftPackageProductDependency */ = { + B4F333E0251273AF0032BB64 /* SDWebImage */ = { isa = XCSwiftPackageProductDependency; - package = B4F333DF251273AF0032BB64 /* RemoteSwiftPackageReference */; + package = B4F333DF251273AF0032BB64 /* XCRemoteSwiftPackageReference "SDWebImage" */; productName = SDWebImage; }; - B4F333EA251274050032BB64 /* SwiftPackageProductDependency */ = { + B4F333EA251274050032BB64 /* BadgeSwift */ = { isa = XCSwiftPackageProductDependency; - package = B4F333E9251274050032BB64 /* RemoteSwiftPackageReference */; + package = B4F333E9251274050032BB64 /* XCRemoteSwiftPackageReference "swift-badge" */; productName = BadgeSwift; }; - B4F333F42512742E0032BB64 /* SwiftPackageProductDependency */ = { + B4F333F42512742E0032BB64 /* BiometricAuthentication */ = { isa = XCSwiftPackageProductDependency; - package = B4F333F32512742E0032BB64 /* RemoteSwiftPackageReference */; + package = B4F333F32512742E0032BB64 /* XCRemoteSwiftPackageReference "BiometricAuthentication" */; productName = BiometricAuthentication; }; - B4F3348A2512770F0032BB64 /* SwiftPackageProductDependency */ = { + B4F3348A2512770F0032BB64 /* Embassy */ = { isa = XCSwiftPackageProductDependency; - package = B4F334892512770F0032BB64 /* RemoteSwiftPackageReference */; + package = B4F334892512770F0032BB64 /* XCRemoteSwiftPackageReference "Embassy" */; productName = Embassy; }; - B4F3349E251277B80032BB64 /* SwiftPackageProductDependency */ = { + B4F3349E251277B80032BB64 /* Starscream */ = { isa = XCSwiftPackageProductDependency; - package = B4F3349D251277B80032BB64 /* RemoteSwiftPackageReference */; + package = B4F3349D251277B80032BB64 /* XCRemoteSwiftPackageReference "Starscream" */; productName = Starscream; }; - B4F3354B25127BAB0032BB64 /* SwiftPackageProductDependency */ = { + B4F3354B25127BAB0032BB64 /* Anchorage */ = { isa = XCSwiftPackageProductDependency; - package = B4F3354A25127BAB0032BB64 /* RemoteSwiftPackageReference */; + package = B4F3354A25127BAB0032BB64 /* XCRemoteSwiftPackageReference "Anchorage" */; productName = Anchorage; }; - B4F3355525127BD20032BB64 /* SwiftPackageProductDependency */ = { + B4F3355525127BD20032BB64 /* Then */ = { isa = XCSwiftPackageProductDependency; - package = B4F3355425127BD20032BB64 /* RemoteSwiftPackageReference */; + package = B4F3355425127BD20032BB64 /* XCRemoteSwiftPackageReference "Then" */; productName = Then; }; - BE31454525674E03004A908C /* SwiftPackageProductDependency */ = { + BE31454525674E03004A908C /* Proton */ = { isa = XCSwiftPackageProductDependency; - package = BE31454425674E03004A908C /* RemoteSwiftPackageReference */; + package = BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */; productName = Proton; }; + BE8CDDCC25C261D1002BBFF4 /* Alamofire */ = { + isa = XCSwiftPackageProductDependency; + package = BE8CDDCB25C261D1002BBFF4 /* XCRemoteSwiftPackageReference "Alamofire" */; + productName = Alamofire; + }; /* End XCSwiftPackageProductDependency section */ /* Begin XCVersionGroup section */ diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0530f2df2..0d084ded0 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,8 +65,10 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - + + + + + diff --git a/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved index e0557b5f9..990c26537 100644 --- a/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,6 +1,15 @@ { "object": { "pins": [ + { + "package": "Alamofire", + "repositoryURL": "https://github.com/Alamofire/Alamofire.git", + "state": { + "branch": null, + "revision": "eaf6e622dd41b07b251d8f01752eab31bc811493", + "version": "5.4.1" + } + }, { "package": "Anchorage", "repositoryURL": "https://github.com/Rightpoint/Anchorage", diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index f64c5b6b7..19dd4c117 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -642,7 +642,7 @@ extension NavigationHomeViewController: UISearchBarDelegate { do { let requestString = "https://www.reddit.com/api/subreddit_autocomplete_v2.json?always_show_media=1&api_type=json&expand_srs=1&feature=link_preview&from_detail=1&include_users=true&obey_over18=1&raw_json=1&rtj=debug&sr_detail=1&query=\(searchTerm)&include_over_18=\((AccountController.isLoggedIn && SettingValues.nsfwEnabled) ? "true" : "false")" print("Requesting \(requestString)") - task = Alamofire.request(requestString, method: .get).responseString { response in + task = AF.request(requestString, method: .get).responseString { response in do { guard let data = response.data else { return diff --git a/Slide for Reddit/ReplyViewController.swift b/Slide for Reddit/ReplyViewController.swift index c0ef39920..b122bb358 100644 --- a/Slide for Reddit/ReplyViewController.swift +++ b/Slide for Reddit/ReplyViewController.swift @@ -551,7 +551,7 @@ class ReplyViewController: MediaViewController, UITextViewDelegate { }) let requestString = "https://oauth.reddit.com/r/\(subreddit)/api/link_flair_v2.json" - Alamofire.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in + AF.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in guard let self = self else { return } do { guard let data = response.data else { @@ -1238,7 +1238,7 @@ class ReplyViewController: MediaViewController, UITextViewDelegate { } var alertController: UIAlertController? - var session: Session? + var session: reddift.Session? func getSubmissionEdited(_ name: String) { DispatchQueue.main.async { diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 32d908dbf..3dbc4f576 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -498,7 +498,10 @@ class SettingValues { SettingValues.reduceColor = settings.object(forKey: SettingValues.pref_reduceColor) == nil ? true : settings.bool(forKey: SettingValues.pref_reduceColor) SettingValues.saveHistory = settings.object(forKey: SettingValues.pref_saveHistory) == nil ? true : settings.bool(forKey: SettingValues.pref_saveHistory) - let columns = 2 // TODO - Maybe calculate per device? + var columns = 2 // TODO - Maybe calculate per device? + if UIApplication.shared.isMac() { + columns = 3 + } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIDevice.current.userInterfaceIdiom == .pad ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) SettingValues.galleryCount = settings.object(forKey: SettingValues.pref_galleryCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_galleryCount) diff --git a/Slide for Reddit/Slide for Reddit.entitlements b/Slide for Reddit/Slide for Reddit.entitlements index 6eb5143f8..1515e5779 100644 --- a/Slide for Reddit/Slide for Reddit.entitlements +++ b/Slide for Reddit/Slide for Reddit.entitlements @@ -19,9 +19,17 @@ app-usage + com.apple.security.app-sandbox + com.apple.security.application-groups group.$(USR_DOMAIN).redditslide.prefs + com.apple.security.device.camera + + com.apple.security.network.client + + com.apple.security.personal-information.photos-library + diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 707f7ae1d..8f5b8f167 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -901,7 +901,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } func random(_ vc: NavigationHomeViewController) { - Alamofire.request("https://www.reddit.com/r/random/about.json", method: .get).responseString { response in + AF.request("https://www.reddit.com/r/random/about.json", method: .get).responseString { response in do { guard let data = response.data else { BannerUtil.makeBanner(text: "Random subreddit not found", color: GMColor.red500Color(), seconds: 2, context: self.parent, top: true, callback: nil) diff --git a/Slide for Reddit/SubredditHeaderView.swift b/Slide for Reddit/SubredditHeaderView.swift index 512435017..863fa1994 100644 --- a/Slide for Reddit/SubredditHeaderView.swift +++ b/Slide for Reddit/SubredditHeaderView.swift @@ -165,7 +165,7 @@ class SubredditHeaderView: UIView { @objc func flair(_ selector: UITableViewCell) { if let subName = subreddit?.displayName, let token = (UIApplication.shared.delegate as? AppDelegate)?.session?.token { let requestString = "https://www.reddit.com/r/\(subName)/api/user_flair_v2.json" - Alamofire.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in + AF.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in guard let self = self else { return } do { guard let data = response.data else { diff --git a/Slide for Reddit/ToolbarTextView.swift b/Slide for Reddit/ToolbarTextView.swift index f2daaba7c..852d73279 100644 --- a/Slide for Reddit/ToolbarTextView.swift +++ b/Slide for Reddit/ToolbarTextView.swift @@ -229,7 +229,7 @@ public class ToolbarTextView: NSObject { }) if assets.count > 1 { - Alamofire.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + AF.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) .responseJSON { response in print(response) if let status = response.response?.statusCode { @@ -396,8 +396,9 @@ public class ToolbarTextView: NSObject { } } } + - Alamofire.upload(multipartFormData: { (multipartFormData) in + AF.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(data!, withName: "image", fileName: name, mimeType: mime! as String) for (key, value) in parameters { multipartFormData.append((value.data(using: .utf8))!, withName: key) @@ -405,29 +406,29 @@ public class ToolbarTextView: NSObject { if !album.isEmpty { multipartFormData.append(album.data(using: .utf8)!, withName: "album") } - }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"], encodingCompletion: { (encodingResult) in - switch encodingResult { - case .success(let upload, _, _): - print("Success") - upload.uploadProgress { progress in - DispatchQueue.main.async { - print(progress.fractionCompleted) - self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) - } - } - upload.responseJSON { response in - debugPrint(response) - let link = JSON(response.value!)["data"]["link"].stringValue + }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + .uploadProgress(closure: { (progress) in + DispatchQueue.main.async { + print(progress.fractionCompleted) + self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) + } + }) + .responseJSON { (response) in + switch response.result { + case .success(let result): + debugPrint(result) + if let json = result as? NSDictionary, let link = (json["data"] as? NSDictionary)?["link"] as? String { print("Link is \(link)") if count == assets.count { completion(link) } + } else { + completion("Failure") } - case .failure: completion("Failure") } - }) + } }) } diff --git a/Slide for Reddit/TrendingViewController.swift b/Slide for Reddit/TrendingViewController.swift index 23a6ca64b..de85ebe29 100644 --- a/Slide for Reddit/TrendingViewController.swift +++ b/Slide for Reddit/TrendingViewController.swift @@ -31,7 +31,7 @@ class TrendingViewController: UITableViewController { do { let requestString = "https://www.reddit.com/api/trending_searches_v1.json?always_show_media=1&api_type=json&expand_srs=1&feature=link_preview&from_detail=1&obey_over18=1&raw_json=1&sr_detail=1" - taskSearches = Alamofire.request(requestString, method: .get).responseString { response in + taskSearches = AF.request(requestString, method: .get).responseString { response in do { guard let data = response.data else { return @@ -66,7 +66,7 @@ class TrendingViewController: UITableViewController { } do { let requestString = "https://www.reddit.com/api/trending_subreddits.json" - taskSubs = Alamofire.request(requestString, method: .get).responseString { response in + taskSubs = AF.request(requestString, method: .get).responseString { response in do { guard let data = response.data else { return diff --git a/Slide for Reddit/VideoMediaDownloader.swift b/Slide for Reddit/VideoMediaDownloader.swift index 7047a2f37..37888530e 100644 --- a/Slide for Reddit/VideoMediaDownloader.swift +++ b/Slide for Reddit/VideoMediaDownloader.swift @@ -51,11 +51,11 @@ class VideoMediaDownloader { } func testQuality(urlToLoad: String, quality: String, completion: @escaping(_ success: Bool, _ url: String) -> Void) { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in if response.response?.statusCode == 200 { completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)")) } else { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4")) } } @@ -93,7 +93,7 @@ class VideoMediaDownloader { self.completion(URL(fileURLWithPath: self.getKeyFromURL())) }) } else { - request = Alamofire.download(URL(string: baseURL)!, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + request = AF.download(URL(string: baseURL)!, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (URL(fileURLWithPath: self.videoType == .REDDIT ? self.getKeyFromURL().replacingOccurrences(of: ".mp4", with: "video.mp4") : self.getKeyFromURL()), [.createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { @@ -161,7 +161,7 @@ class VideoMediaDownloader { let localUrlV = URL.init(fileURLWithPath: key.replacingOccurrences(of: ".mp4", with: "video.mp4")) let localUrlAudio = URL.init(fileURLWithPath: key.replacingOccurrences(of: ".mp4", with: "audio.mp4")) - Alamofire.request(toLoadAudio).responseString { (response) in + AF.request(toLoadAudio).responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it if let url = URL(string: toLoadAudio) { self.requestWithProgress(url: url, localUrlAudio: localUrlAudio) { (response) in @@ -184,7 +184,7 @@ class VideoMediaDownloader { self.doCopy(localUrlV, to: finalUrl) } } else if response.response?.statusCode ?? 0 > 400 { // Might exist elsewhere - Alamofire.request("\(toLoadAudioBase)/audio").responseString { (response) in + AF.request("\(toLoadAudioBase)/audio").responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it if let url = URL(string: "\(toLoadAudioBase)/audio") { self.requestWithProgress(url: url, localUrlAudio: localUrlAudio) { (response) in @@ -216,8 +216,8 @@ class VideoMediaDownloader { } } - func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (DownloadResponse) -> Void) { - self.request = Alamofire.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (AFDownloadResponse) -> Void) { + self.request = AF.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (localUrlAudio, [.removePreviousFile, .createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 0db75f8bd..4a45ddf43 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -581,11 +581,11 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz } func testQuality(urlToLoad: String, quality: String, completion: @escaping(_ success: Bool, _ url: String) -> Void) { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in if response.response?.statusCode == 200 { completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)")) } else { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4")) } } @@ -620,7 +620,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz print("Downloading " + toLoad) let fileURLPath = self.videoType == .REDDIT ? self.getKeyFromURL().replacingOccurrences(of: ".mp4", with: "video.mp4") : self.getKeyFromURL() - request = Alamofire.download(toLoad, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + request = AF.download(toLoad, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (URL(fileURLWithPath: fileURLPath), [.createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { @@ -658,7 +658,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz let localUrlV = URL.init(fileURLWithPath: videoLocation) let localUrlAudio = URL.init(fileURLWithPath: key.replacingOccurrences(of: ".mp4", with: "audio.mp4")) - Alamofire.request(toLoadAudio).responseString { (response) in + AF.request(toLoadAudio).responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it self.requestWithProgress(url: finalUrl, localUrlAudio: localUrlAudio) { (response) in if (response.error as NSError?)?.code == NSURLErrorCancelled { // Cancelled, exit @@ -676,7 +676,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz } } else if response.response?.statusCode ?? 0 > 400 { // Might exist elsewhere - Alamofire.request("\(toLoadAudioBase)/audio").responseString { (response) in + AF.request("\(toLoadAudioBase)/audio").responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it self.requestWithProgress(url: finalUrl, localUrlAudio: localUrlAudio) { (response) in if (response.error as NSError?)?.code == NSURLErrorCancelled { // Cancelled, exit @@ -715,8 +715,8 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz } } - func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (DownloadResponse) -> Void) { - self.request = Alamofire.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (DownloadResponse) -> Void) { + self.request = AF.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (localUrlAudio, [.removePreviousFile, .createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { diff --git a/Slide for Reddit/WebsiteViewController.swift b/Slide for Reddit/WebsiteViewController.swift index 23fc2c3bf..135095ab3 100644 --- a/Slide for Reddit/WebsiteViewController.swift +++ b/Slide for Reddit/WebsiteViewController.swift @@ -373,7 +373,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { if #available(iOS 13.0, *) { // Let Reddit create new reddit_session Cookie from data returned from Apple Login let jsonData = try JSONSerialization.data(withJSONObject: params, options: .withoutEscapingSlashes) - Alamofire.request("https://www.reddit.com/account/identity_provider_login", method: .post, parameters: [:], encoding: String(data: jsonData, encoding: .utf8)!, headers: nil).responseJSON { (response) in + AF.request("https://www.reddit.com/account/identity_provider_login", method: .post, parameters: [:], encoding: String(data: jsonData, encoding: .utf8)!, headers: nil).responseJSON { (response) in switch response.result { case .success(let JSON): let token = (JSON as? [String: Any])?["token"] as? String ?? "" @@ -450,7 +450,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { // Get user csrf token for Alamofire, which will be used to authorize next @objc func loginWithApple() { - Alamofire.request("https://www.reddit.com/account/login/?mobile_ui=on&experiment_mweb_sso_login_link=enabled&experiment_mweb_google_onetap=onetap_auto&experiment_mweb_am_refactoring=enabled", method: .get, parameters: [:], encoding: URLEncoding.default, headers: nil).response { (response) in + AF.request("https://www.reddit.com/account/login/?mobile_ui=on&experiment_mweb_sso_login_link=enabled&experiment_mweb_google_onetap=onetap_auto&experiment_mweb_am_refactoring=enabled", method: .get, parameters: [:], encoding: URLEncoding.default, headers: nil).response { (response) in if let data = response.data, let stringBody = String(data: data, encoding: .utf8) { // Get token out of body HTML diff --git a/WidgetConfigIntent/WidgetConfigIntent.entitlements b/WidgetConfigIntent/WidgetConfigIntent.entitlements index 86d745ebf..41aeeed9d 100644 --- a/WidgetConfigIntent/WidgetConfigIntent.entitlements +++ b/WidgetConfigIntent/WidgetConfigIntent.entitlements @@ -2,9 +2,13 @@ + com.apple.security.app-sandbox + com.apple.security.application-groups - group.$(USR_DOMAIN).redditslide.prefs - + group.$(USR_DOMAIN).redditslide.prefs + + com.apple.security.network.client + From 932c2e802e5dd9265f7a004679d5516428f20131 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 15:51:32 -0600 Subject: [PATCH 02/46] Fix Mac layout, Force iPad code for Mac installs --- Slide for Reddit/AppDelegate.swift | 44 ++++++++++++++++--- .../AsyncAlertImagePickerViewController.swift | 4 +- .../BottomMenuPresentationController.swift | 4 +- Slide for Reddit/CommentDepthCell.swift | 4 +- Slide for Reddit/CommentViewController.swift | 22 +++++----- .../ContentListingViewController.swift | 34 +++++++------- Slide for Reddit/LinkCellView.swift | 2 +- .../NavigationHomeViewController.swift | 6 +-- Slide for Reddit/SettingValues.swift | 6 +-- Slide for Reddit/SettingsGeneral.swift | 2 +- Slide for Reddit/SettingsTheme.swift | 4 +- Slide for Reddit/SettingsViewMode.swift | 4 +- .../SingleSubredditViewController.swift | 19 ++++---- .../SplitMainViewController.swift | 18 ++++---- ...SubredditToolbarSearchViewController.swift | 2 +- .../TapBehindModalViewController.swift | 2 +- Slide for Reddit/UIAlert+Extensions.swift | 2 +- .../UIApplication+Extensions.swift | 4 ++ Slide for Reddit/VCPresenter.swift | 10 ++--- Slide for Reddit/WebsiteViewController.swift | 2 +- Slide for Reddit/WrappingFlowLayout.swift | 6 +-- 21 files changed, 122 insertions(+), 79 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 9e7225604..95cfb3b71 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -423,8 +423,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let main: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) - switch UIDevice.current.userInterfaceIdiom { - case .pad: + if UIApplication.shared.isMac() { switch SettingValues.appMode { case .SINGLE, .MULTI_COLUMN: splitViewController.setViewController( @@ -454,10 +453,43 @@ class AppDelegate: UIResponder, UIApplicationDelegate { PlaceholderViewController(), for: .secondary) } - default: - splitViewController = NoHomebarSplitViewController() - let navHome = NavigationHomeViewController(controller: main) - splitViewController.viewControllers = [SwipeForwardNavigationController(rootViewController: navHome), SwipeForwardNavigationController(rootViewController: main)] + } else { + switch UIDevice.current.userInterfaceIdiom { + case .pad: + switch SettingValues.appMode { + case .SINGLE, .MULTI_COLUMN: + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), + for: .primary) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .secondary) + + let main2: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) + let compact = SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main2)) + + compact.pushViewController(main2, animated: false) + splitViewController.setViewController(compact, for: .compact) + + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .secondary) + case .SPLIT: + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), + for: .primary) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .supplementary) + splitViewController.setViewController( + PlaceholderViewController(), + for: .secondary) + } + default: + splitViewController = NoHomebarSplitViewController() + let navHome = NavigationHomeViewController(controller: main) + splitViewController.viewControllers = [SwipeForwardNavigationController(rootViewController: navHome), SwipeForwardNavigationController(rootViewController: main)] + } } window.rootViewController = splitViewController diff --git a/Slide for Reddit/AsyncAlertImagePickerViewController.swift b/Slide for Reddit/AsyncAlertImagePickerViewController.swift index f220f1bb5..29d48b83c 100644 --- a/Slide for Reddit/AsyncAlertImagePickerViewController.swift +++ b/Slide for Reddit/AsyncAlertImagePickerViewController.swift @@ -25,7 +25,7 @@ extension AlertController { func addAsyncImagePicker(flow: UICollectionView.ScrollDirection, paging: Bool, images: [URL], selection: AsyncImagePickerViewController.SelectionType? = nil) { let vc = AsyncImagePickerViewController(flow: flow, paging: paging, images: images, selection: selection) - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { vc.preferredContentSize.height = vc.preferredSize.height * 0.9 vc.preferredContentSize.width = vc.preferredSize.width * 0.9 } else { @@ -82,7 +82,7 @@ final class AsyncImagePickerViewController: UIViewController { } var columns: CGFloat { - return UIDevice.current.userInterfaceIdiom == .pad ? 3 : 2 + return UIApplication.shared.respectIpadLayout() ? 3 : 2 } var itemSize: CGSize { diff --git a/Slide for Reddit/BottomMenuPresentationController.swift b/Slide for Reddit/BottomMenuPresentationController.swift index cd2ac2f67..def2422f4 100644 --- a/Slide for Reddit/BottomMenuPresentationController.swift +++ b/Slide for Reddit/BottomMenuPresentationController.swift @@ -97,7 +97,7 @@ extension BottomMenuPresentationController { let horizontalCoveragePercent: CGFloat = 0.95 // Make smaller on iPad - var width = containerView.bounds.size.width * (UIDevice.current.userInterfaceIdiom == .pad ? 0.75 : horizontalCoveragePercent) + var width = containerView.bounds.size.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : horizontalCoveragePercent) if width < 250 { width = containerView.bounds.size.width * horizontalCoveragePercent } @@ -147,7 +147,7 @@ class SlideInTransition: NSObject, UIViewControllerAnimatedTransitioning { guard let viewToAnimate = viewControllerToAnimate.view else { return } var offsetFrame = viewToAnimate.bounds - var width = UIScreen.main.bounds.width * (UIDevice.current.userInterfaceIdiom == .pad ? 0.75 : 0.95) + var width = UIScreen.main.bounds.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : 0.95) if width < 250 { width = UIScreen.main.bounds.width * 0.95 } diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index e98eb54d6..19468c74c 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -741,7 +741,7 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat removedSubviews.forEach({ $0.removeFromSuperview() }) - if UIDevice.current.userInterfaceIdiom == .pad && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { + if UIApplication.shared.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { menu.addArrangedSubviews(flexSpace(), flexSpace(), flexSpace(), editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) } else { menu.addArrangedSubviews(editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) @@ -2495,7 +2495,7 @@ extension CommentDepthCell: UIContextMenuInteractionDelegate { } } - if UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac() { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { if self.parent?.menuCell == self { if let parent = self.parent { let menu = self.getMoreMenu(parent) diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index 58ee8110f..2a565442b 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -92,7 +92,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi var didDisappearCompletely = false var live = false var liveTimer = Timer() - var refreshControl: UIRefreshControl! + var refreshControl: UIRefreshControl? var tableView: UITableView! var sortButton = UIButton() @@ -881,7 +881,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi } @objc func refresh(_ sender: AnyObject) { - self.tableView.setContentOffset(CGPoint(x: 0, y: self.tableView.contentOffset.y - (self.refreshControl!.frame.size.height)), animated: true) + self.tableView.setContentOffset(CGPoint(x: 0, y: self.tableView.contentOffset.y - (self.refreshControl?.frame.size.height ?? 0)), animated: true) session = (UIApplication.shared.delegate as! AppDelegate).session approved.removeAll() removed.removeAll() @@ -1341,17 +1341,19 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi self.view.backgroundColor = UIColor.backgroundColor self.tableView.backgroundColor = UIColor.backgroundColor self.navigationController?.view.backgroundColor = UIColor.foregroundColor - refreshControl = UIRefreshControl() - refreshControl?.tintColor = UIColor.fontColor - refreshControl?.attributedTitle = NSAttributedString(string: "") - refreshControl?.addTarget(self, action: #selector(CommentViewController.refresh(_:)), for: UIControl.Event.valueChanged) + if !UIApplication.shared.isMac() { + refreshControl = UIRefreshControl() + refreshControl?.tintColor = UIColor.fontColor + refreshControl?.attributedTitle = NSAttributedString(string: "") + refreshControl?.addTarget(self, action: #selector(CommentViewController.refresh(_:)), for: UIControl.Event.valueChanged) + } var top = CGFloat(64) let bottom = CGFloat(45) if #available(iOS 11.0, *) { top = 0 } tableView.contentInset = UIEdgeInsets(top: top, left: 0, bottom: bottom, right: 0) - tableView.addSubview(refreshControl!) + //tableView.addSubview(refreshControl!) self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItem.Style.plain, target: nil, action: nil) @@ -1691,7 +1693,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi fullWidthBackGestureRecognizer?.isEnabled = true cellGestureRecognizer?.isEnabled = true - refreshControl.setValue(100, forKey: "_snappingHeight") + refreshControl?.setValue(100, forKey: "_snappingHeight") if UIScreen.main.traitCollection.userInterfaceIdiom == .pad && Int(round(self.view.bounds.width / CGFloat(320))) > 1 && false { self.navigationController!.view.backgroundColor = .clear @@ -3257,7 +3259,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { cellGestureRecognizer.delegate = self cellGestureRecognizer.maximumNumberOfTouches = 1 tableView.addGestureRecognizer(cellGestureRecognizer) - if UIDevice.current.userInterfaceIdiom != .pad { + if !UIApplication.shared.respectIpadLayout() { // cellGestureRecognizer.require(toFail: tableView.panGestureRecognizer) } if let parent = parent as? ColorMuxPagingViewController { @@ -3278,7 +3280,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { return } - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.appMode != .SINGLE { + if UIApplication.shared.respectIpadLayout() && SettingValues.appMode != .SINGLE { if #available(iOS 14, *) { return } diff --git a/Slide for Reddit/ContentListingViewController.swift b/Slide for Reddit/ContentListingViewController.swift index 6ef916c54..781e1f847 100644 --- a/Slide for Reddit/ContentListingViewController.swift +++ b/Slide for Reddit/ContentListingViewController.swift @@ -193,13 +193,15 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat self.tableView.delegate = self self.tableView.dataSource = self - refreshControl = UIRefreshControl() - refreshControl.tintColor = UIColor.fontColor - - refreshControl.attributedTitle = NSAttributedString(string: "") - refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) - refreshControl.centerAnchors /==/ tableView.centerAnchors + if !UIApplication.shared.isMac() { + refreshControl = UIRefreshControl() + refreshControl.tintColor = UIColor.fontColor + + refreshControl.attributedTitle = NSAttributedString(string: "") + refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + tableView.addSubview(refreshControl) + refreshControl.centerAnchors /==/ tableView.centerAnchors + } tableView.alwaysBounceVertical = true @@ -527,14 +529,16 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat } func endAndResetRefresh() { - self.refreshControl.endRefreshing() - self.refreshControl.removeFromSuperview() - self.refreshControl = UIRefreshControl() - self.refreshControl.tintColor = UIColor.fontColor - - self.refreshControl.attributedTitle = NSAttributedString(string: "") - self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - self.tableView.addSubview(self.refreshControl) + if !UIApplication.shared.isMac() { + self.refreshControl.endRefreshing() + self.refreshControl.removeFromSuperview() + self.refreshControl = UIRefreshControl() + self.refreshControl.tintColor = UIColor.fontColor + + self.refreshControl.attributedTitle = NSAttributedString(string: "") + self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + self.tableView.addSubview(self.refreshControl) + } } var loading: Bool = false diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index 570122b99..715050ff1 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -3358,7 +3358,7 @@ extension LinkCellView: UIContextMenuInteractionDelegate { }) } - if UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac() { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { _ in return self.del?.getMoreMenu(self) }) diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 19dd4c117..f0e8b1296 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -895,7 +895,7 @@ class CurrentAccountHeaderView: UIView { } var forwardButton = UIButton(type: .custom).then { - $0.setImage(UIImage(sfString: UIDevice.current.userInterfaceIdiom == .pad ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) + $0.setImage(UIImage(sfString: UIApplication.shared.respectIpadLayout() ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) $0.contentEdgeInsets = UIEdgeInsets(top: 7, left: 8, bottom: 7, right: 8) $0.accessibilityLabel = "Go home" } @@ -1228,7 +1228,7 @@ extension CurrentAccountHeaderView { nav.pushNextViewControllerFromRight(nil) } else { var is14Column = false - if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIDevice.current.userInterfaceIdiom == .pad { + if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIApplication.shared.respectIpadLayout() { is14Column = true } if #available(iOS 14, *), self.parent?.splitViewController?.style == .doubleColumn { @@ -1243,7 +1243,7 @@ extension CurrentAccountHeaderView { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.userInterfaceIdiom == .pad { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.parent?.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 3dbc4f576..6e966a21b 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -492,7 +492,7 @@ class SettingValues { } public static func initialize() { - let pad = UIDevice.current.userInterfaceIdiom == .pad + let pad = UIApplication.shared.respectIpadLayout() let settings = UserDefaults.standard SettingValues.saveNSFWHistory = settings.bool(forKey: SettingValues.pref_saveNSFWHistory) SettingValues.reduceColor = settings.object(forKey: SettingValues.pref_reduceColor) == nil ? true : settings.bool(forKey: SettingValues.pref_reduceColor) @@ -503,7 +503,7 @@ class SettingValues { columns = 3 } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) - SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIDevice.current.userInterfaceIdiom == .pad ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) + SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIApplication.shared.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) SettingValues.galleryCount = settings.object(forKey: SettingValues.pref_galleryCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_galleryCount) SettingValues.highlightOp = settings.object(forKey: SettingValues.pref_highlightOp) == nil ? true : settings.bool(forKey: SettingValues.pref_highlightOp) @@ -536,7 +536,7 @@ class SettingValues { } SettingValues.desktopMode = settings.object(forKey: SettingValues.pref_desktopMode) == nil ? UIApplication.shared.isMac() : settings.bool(forKey: SettingValues.pref_desktopMode) - SettingValues.desktopMode = SettingValues.desktopMode && (UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac()) // Only enable this on Mac or iPad + SettingValues.desktopMode = SettingValues.desktopMode && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) // Only enable this on Mac or iPad SettingValues.scrollSidebar = settings.object(forKey: SettingValues.pref_scrollSidebar) == nil ? true : settings.bool(forKey: SettingValues.pref_scrollSidebar) diff --git a/Slide for Reddit/SettingsGeneral.swift b/Slide for Reddit/SettingsGeneral.swift index e4a5f64e9..13b934e74 100644 --- a/Slide for Reddit/SettingsGeneral.swift +++ b/Slide for Reddit/SettingsGeneral.swift @@ -541,7 +541,7 @@ class SettingsGeneral: BubbleSettingTableViewController { } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - let pad = UIDevice.current.userInterfaceIdiom == .pad + let pad = UIApplication.shared.respectIpadLayout() switch section { case 0: return 4 + (!pad ? 1 : 0) case 1: return 3 diff --git a/Slide for Reddit/SettingsTheme.swift b/Slide for Reddit/SettingsTheme.swift index 3453c078f..08caf88aa 100644 --- a/Slide for Reddit/SettingsTheme.swift +++ b/Slide for Reddit/SettingsTheme.swift @@ -118,7 +118,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } @@ -215,7 +215,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) alertController.modalPresentationStyle = .popover - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } if let presenter = alertController.popoverPresentationController { diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index 2611af17c..a3e55a252 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -188,7 +188,7 @@ class SettingsViewMode: BubbleSettingTableViewController { multicolumnPortraitCount.contentView.alpha = 0.8 } - if UIDevice.current.userInterfaceIdiom != .pad { + if !UIApplication.shared.respectIpadLayout() { self.splitMode.isUserInteractionEnabled = false self.splitMode.textLabel!.isEnabled = false self.splitMode.detailTextLabel!.isEnabled = false @@ -393,7 +393,7 @@ class SettingsViewMode: BubbleSettingTableViewController { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { var ipadOffset = 0 var isIpad = false - if UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac() { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { isIpad = true ipadOffset = 3 } diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 6d0ad1678..fbaf9eec1 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -140,6 +140,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele var searchText: String? + var refreshControl: UIRefreshControl! var hasHeader = false @@ -203,7 +204,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele super.viewDidLoad() CachedTitle.titles.removeAll() - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { + if UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { splitViewController?.showDetailViewController(SwipeForwardNavigationController(rootViewController: PlaceholderViewController()), sender: self) } @@ -904,7 +905,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele if self.dataSource.loaded && !self.dataSource.loading { self.flowLayout.reset(modal: self.presentingViewController != nil, vc: self, isGallery: self.isGallery) self.tableView.reloadData() - if UIDevice.current.userInterfaceIdiom != .pad { + if !UIApplication.shared.respectIpadLayout() { var newOffset = self.tableView.contentOffset newOffset.y -= self.headerHeight(false) self.tableView.setContentOffset(newOffset, animated: false) @@ -971,7 +972,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele refreshControl.attributedTitle = NSAttributedString(string: "") refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) // not required when using UITableViewController + // tableView.addSubview(refreshControl) // not required when using UITableViewController tableView.alwaysBounceVertical = true self.automaticallyAdjustsScrollViewInsets = false @@ -2081,7 +2082,7 @@ extension SingleSubredditViewController: SubmissionDataSouceDelegate { if self.navigationController?.modalPresentationStyle == .pageSheet && self.navigationController?.viewControllers.count == 1 && !(self.navigationController?.viewControllers[0] is MainViewController) { topOffset = 0 } - let headerHeight = (UIDevice.current.userInterfaceIdiom == .pad && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) + let headerHeight = (UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) let paddingOffset = CGFloat(headerHeight == 0 ? -4 : 0) setOffset = paddingOffset + navOffset + topOffset + headerHeight @@ -2699,7 +2700,7 @@ extension SingleSubredditViewController: LinkCellViewDelegate { } return }) - VCPresenter.showVC(viewController: comment, popupIfPossible: (UIDevice.current.userInterfaceIdiom == .pad && SettingValues.disablePopupIpad || UIDevice.current.userInterfaceIdiom != .pad) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) + VCPresenter.showVC(viewController: comment, popupIfPossible: (UIApplication.shared.respectIpadLayout() && SettingValues.disablePopupIpad || !UIApplication.shared.respectIpadLayout()) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) } } @@ -3009,7 +3010,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { full.view?.removeGestureRecognizer(full) } - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { fullWidthBackGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(showParentMenu(_:))) guard let swipe = fullWidthBackGestureRecognizer as? UISwipeGestureRecognizer else { return } swipe.direction = .right @@ -3059,7 +3060,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { return false } if translation.x < 0 { - if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIDevice.current.userInterfaceIdiom == .pad) { + if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIApplication.shared.respectIpadLayout()) { return true } } else if !SettingValues.submissionGestureMode.shouldPage() && abs(translation.x) > abs(translation.y) { @@ -3453,7 +3454,7 @@ public class LinksHeaderCellView: UICollectionViewCell { header.addSubview(imageView) imageView.clipsToBounds = true - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { imageView.verticalAnchors /==/ header.verticalAnchors imageView.horizontalAnchors /==/ header.horizontalAnchors + 4 imageView.layer.cornerRadius = 15 @@ -3492,7 +3493,7 @@ public class SubLinkItem { extension SingleSubredditViewController: TapBehindModalViewControllerDelegate { func shouldDismiss() -> Bool { - return UIDevice.current.userInterfaceIdiom == .pad + return UIApplication.shared.respectIpadLayout() } } diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 8f5b8f167..44da5634b 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -115,7 +115,7 @@ class SplitMainViewController: MainViewController { splitViewController?.navigationItem.hidesBackButton = true if #available(iOS 14.0, *) { - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { splitViewController?.showsSecondaryOnlyButton = false splitViewController?.navigationItem.hidesBackButton = true splitViewController?.navigationItem.backBarButtonItem = UIBarButtonItem() @@ -199,7 +199,7 @@ class SplitMainViewController: MainViewController { if self.navigationController?.viewControllers[0] is NavigationHomeViewController { self.navigationController?.popViewController(animated: true) } else if #available(iOS 14, *) { - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { self.splitViewController?.show(UISplitViewController.Column.primary) } else { self.navigationController?.popViewController(animated: true) @@ -317,7 +317,7 @@ class SplitMainViewController: MainViewController { vc.setupSwipeGesture() } else if SettingValues.submissionGestureMode == .HALF_FULL { // Always allow swipe back with paging disabled and not full vc.setupSwipeGesture() - } else if UIDevice.current.userInterfaceIdiom == .pad && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { + } else if UIApplication.shared.respectIpadLayout() && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { vc.setupSwipeGesture() } @@ -532,7 +532,7 @@ class SplitMainViewController: MainViewController { if self.finalSubs.contains(subreddit) && !override { let index = self.finalSubs.firstIndex(of: subreddit) if index == nil { - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.disableSubredditPopupIpad { + if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { if self.navigationController?.topViewController != self && !(self.navigationController?.topViewController is NavigationHomeViewController) { self.navigationController?.popToRootViewController(animated: false) } @@ -578,7 +578,7 @@ class SplitMainViewController: MainViewController { self.navigationController?.popToRootViewController(animated: false) } - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.disableSubredditPopupIpad { + if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { VCPresenter.showVC(viewController: SingleSubredditViewController(subName: subreddit.replacingOccurrences(of: " ", with: ""), single: true), popupIfPossible: false, parentNavigationController: self.navigationController, parentViewController: self) } else { VCPresenter.openRedditLink("/r/" + subreddit.replacingOccurrences(of: " ", with: ""), self.navigationController, self) @@ -1068,7 +1068,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIDevice.current.userInterfaceIdiom == .pad { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { is14Column = true } @@ -1081,7 +1081,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.userInterfaceIdiom == .pad { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in @@ -1108,7 +1108,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIDevice.current.userInterfaceIdiom == .pad { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { is14Column = true } @@ -1116,7 +1116,7 @@ extension SplitMainViewController: NavigationHomeDelegate { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.userInterfaceIdiom == .pad && !SettingValues.desktopMode { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() && !SettingValues.desktopMode { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/SubredditToolbarSearchViewController.swift b/Slide for Reddit/SubredditToolbarSearchViewController.swift index 1f0bc6e94..a5647e4e2 100644 --- a/Slide for Reddit/SubredditToolbarSearchViewController.swift +++ b/Slide for Reddit/SubredditToolbarSearchViewController.swift @@ -104,7 +104,7 @@ class SubredditToolbarSearchViewController: UIViewController, UIGestureRecognize } if controller.navigationController?.viewControllers.count ?? 0 == 1 && controller.navigationController?.modalPresentationStyle ?? controller.modalPresentationStyle == .pageSheet { bottomOffset += 64 - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { bottomOffset += 24 } } diff --git a/Slide for Reddit/TapBehindModalViewController.swift b/Slide for Reddit/TapBehindModalViewController.swift index d8c391722..51d6582fa 100644 --- a/Slide for Reddit/TapBehindModalViewController.swift +++ b/Slide for Reddit/TapBehindModalViewController.swift @@ -23,7 +23,7 @@ class TapBehindModalViewController: SwipeForwardNavigationController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIDevice.current.userInterfaceIdiom == .pad) { + if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIApplication.shared.respectIpadLayout()) { self.tapOutsideRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTapBehind)) self.tapOutsideRecognizer.numberOfTapsRequired = 1 self.tapOutsideRecognizer.cancelsTouchesInView = false diff --git a/Slide for Reddit/UIAlert+Extensions.swift b/Slide for Reddit/UIAlert+Extensions.swift index bbc2df40f..f0b8384c4 100644 --- a/Slide for Reddit/UIAlert+Extensions.swift +++ b/Slide for Reddit/UIAlert+Extensions.swift @@ -92,7 +92,7 @@ extension UIAlertController { } } visualEffectView?.effect = UIBlurEffect(style: UIColor.isLightTheme ? UIBlurEffect.Style.light : UIBlurEffect.Style.dark) - if self.preferredStyle == .actionSheet && UIDevice.current.userInterfaceIdiom != .pad { + if self.preferredStyle == .actionSheet && !UIApplication.shared.respectIpadLayout() { cancelActionView?.backgroundColor = UIColor.foregroundColor } } diff --git a/Slide for Reddit/UIApplication+Extensions.swift b/Slide for Reddit/UIApplication+Extensions.swift index 62ecf1d26..7b9f1a195 100644 --- a/Slide for Reddit/UIApplication+Extensions.swift +++ b/Slide for Reddit/UIApplication+Extensions.swift @@ -24,6 +24,10 @@ extension UIApplication { } } + public func respectIpadLayout() -> Bool { + return UIDevice.current.userInterfaceIdiom == .pad || isMac() + } + } extension UIApplication { public var isSplitOrSlideOver: Bool { diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index 677bca260..d0352b59e 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -39,7 +39,7 @@ public class VCPresenter { } } } - if (UIDevice.current.userInterfaceIdiom != .pad && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { + if (!UIApplication.shared.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { override13 = false } @@ -48,7 +48,7 @@ public class VCPresenter { let respectedOverride13 = override13 var shouldPopup = popupIfPossible - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { if viewController is SingleSubredditViewController && SettingValues.disableSubredditPopupIpad { shouldPopup = false } else if (viewController is CommentViewController || viewController is PagingCommentViewController) && SettingValues.disablePopupIpad { @@ -56,12 +56,12 @@ public class VCPresenter { } } - override13 = override13 && (UIDevice.current.userInterfaceIdiom == .pad || (viewController is UIPageViewController || viewController is SettingsViewController)) + override13 = override13 && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() || (viewController is UIPageViewController || viewController is SettingsViewController)) - if (viewController is PagingCommentViewController || viewController is CommentViewController || viewController is WebsiteViewController) && (parentViewController?.splitViewController != nil && UIDevice.current.userInterfaceIdiom == .pad && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { + if (viewController is PagingCommentViewController || viewController is CommentViewController || viewController is WebsiteViewController) && (parentViewController?.splitViewController != nil && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { (parentViewController!.splitViewController)?.showDetailViewController(SwipeForwardNavigationController(rootViewController: viewController), sender: nil) return - } else if ((!SettingValues.disablePopupIpad) && UIDevice.current.userInterfaceIdiom == .pad && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { + } else if ((!SettingValues.disablePopupIpad) && UIApplication.shared.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { if viewController is SingleSubredditViewController { (viewController as! SingleSubredditViewController).isModal = true diff --git a/Slide for Reddit/WebsiteViewController.swift b/Slide for Reddit/WebsiteViewController.swift index 135095ab3..2ecd6f402 100644 --- a/Slide for Reddit/WebsiteViewController.swift +++ b/Slide for Reddit/WebsiteViewController.swift @@ -294,7 +294,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { } func loadUrl() { - if url?.host == "twitter.com" && UIDevice.current.userInterfaceIdiom == .pad { + if url?.host == "twitter.com" && UIApplication.shared.respectIpadLayout() { webView.customUserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)" } let myURLRequest: URLRequest = URLRequest(url: url!) diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 3c7cda5ec..5a6db089f 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -48,11 +48,11 @@ class WrappingFlowLayout: UICollectionViewLayout { cache = [] contentHeight = 0 var portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad || UIApplication.shared.isMac() if SettingValues.appMode == .MULTI_COLUMN { - if UIApplication.shared.statusBarOrientation.isPortrait || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { - if UIScreen.main.traitCollection.userInterfaceIdiom != .pad { + if (UIApplication.shared.statusBarOrientation.isPortrait && !UIApplication.shared.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { + if !pad { numberOfColumns = SettingValues.portraitMultiColumnCount } else { if SettingValues.disableMulticolumnCollections { From 9764f7191e03a8e316d4c4562a41d4b61290b93f Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 20:02:31 -0600 Subject: [PATCH 03/46] Improved Catalyst layouts --- Slide for Reddit/AppDelegate.swift | 105 +++++++++--------- .../ContentListingViewController.swift | 34 +++--- Slide for Reddit/SettingValues.swift | 6 + Slide for Reddit/SettingsViewMode.swift | 72 +++++++----- .../SplitMainViewController.swift | 2 +- Slide for Reddit/VideoScrubberView.swift | 8 +- Slide for Reddit/WrappingFlowLayout.swift | 4 +- 7 files changed, 128 insertions(+), 103 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 95cfb3b71..43ccae045 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -418,41 +418,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate { @available(iOS 14.0, *) func doHard14(_ window: UIWindow) -> MainViewController { - let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT ? .tripleColumn : .doubleColumn + let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT || UIApplication.shared.isMac() ? .tripleColumn : .doubleColumn var splitViewController: NoHomebarSplitViewController = NoHomebarSplitViewController(style: style) let main: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) if UIApplication.shared.isMac() { - switch SettingValues.appMode { - case .SINGLE, .MULTI_COLUMN: - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), - for: .primary) - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: main), - for: .secondary) - - let main2: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) - let compact = SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main2)) - - compact.pushViewController(main2, animated: false) - splitViewController.setViewController(compact, for: .compact) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), + for: .primary) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .supplementary) + splitViewController.setViewController( + PlaceholderViewController(), + for: .secondary) - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: main), - for: .secondary) - case .SPLIT: - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), - for: .primary) - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: main), - for: .supplementary) - splitViewController.setViewController( - PlaceholderViewController(), - for: .secondary) - } } else { switch UIDevice.current.userInterfaceIdiom { case .pad: @@ -504,11 +485,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func setupSplitLayout(_ splitViewController: UISplitViewController) { // Set column widths if #available(iOS 14.0, *) { - splitViewController.preferredPrimaryColumnWidthFraction = 0.33 - splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 - if splitViewController.style == .tripleColumn { - splitViewController.preferredSupplementaryColumnWidthFraction = 0.33 - splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.33 + if UIApplication.shared.isMac() { + splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 + splitViewController.preferredPrimaryColumnWidthFraction = 0.15 + splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 + + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 + splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 + splitViewController.preferredSupplementaryColumnWidthFraction = 0.40 + } else { + splitViewController.preferredPrimaryColumnWidthFraction = 0.33 + splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 + if splitViewController.style == .tripleColumn { + splitViewController.preferredSupplementaryColumnWidthFraction = 0.33 + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.33 + } } } else { splitViewController.preferredPrimaryColumnWidthFraction = 0.4 @@ -517,35 +508,39 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.presentsWithGesture = true - // Set display mode and split behavior - switch UIDevice.current.userInterfaceIdiom { - case .pad: - switch SettingValues.appMode { - case .SINGLE, .MULTI_COLUMN: - if UIApplication.shared.isSplitOrSlideOver { - setupSplitPaneLayout(splitViewController) - } else if SettingValues.desktopMode { - splitViewController.preferredDisplayMode = .oneBesideSecondary - if #available(iOS 14.0, *) { - splitViewController.preferredSplitBehavior = .displace - } - } else { - splitViewController.preferredDisplayMode = .secondaryOnly - if #available(iOS 14.0, *) { - splitViewController.preferredSplitBehavior = .overlay + if UIApplication.shared.isMac() { + setupSplitPaneLayout(splitViewController) + } else { + // Set display mode and split behavior + switch UIDevice.current.userInterfaceIdiom { + case .pad: + switch SettingValues.appMode { + case .SINGLE, .MULTI_COLUMN: + if UIApplication.shared.isSplitOrSlideOver { + setupSplitPaneLayout(splitViewController) + } else if SettingValues.desktopMode { + splitViewController.preferredDisplayMode = .oneBesideSecondary + if #available(iOS 14.0, *) { + splitViewController.preferredSplitBehavior = .displace + } + } else { + splitViewController.preferredDisplayMode = .secondaryOnly + if #available(iOS 14.0, *) { + splitViewController.preferredSplitBehavior = .overlay + } } + case .SPLIT: + setupSplitPaneLayout(splitViewController) } - case .SPLIT: - setupSplitPaneLayout(splitViewController) + default: + splitViewController.preferredDisplayMode = .oneOverSecondary } - default: - splitViewController.preferredDisplayMode = .oneOverSecondary } } func setupSplitPaneLayout(_ splitViewController: UISplitViewController) { if #available(iOS 14.0, *) { - if SettingValues.desktopMode { + if SettingValues.desktopMode || UIApplication.shared.isMac() { splitViewController.preferredDisplayMode = .twoBesideSecondary splitViewController.preferredSplitBehavior = .tile } else { diff --git a/Slide for Reddit/ContentListingViewController.swift b/Slide for Reddit/ContentListingViewController.swift index 781e1f847..56d10a3fa 100644 --- a/Slide for Reddit/ContentListingViewController.swift +++ b/Slide for Reddit/ContentListingViewController.swift @@ -156,8 +156,8 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat self.navigationController?.delegate = self if !loaded && !loading { - self.tableView.contentOffset = CGPoint(x: 0, y: -self.refreshControl.frame.size.height) - refreshControl.beginRefreshing() + self.tableView.contentOffset = CGPoint(x: 0, y: -(self.refreshControl?.frame.size.height ?? 0)) + refreshControl?.beginRefreshing() } else { self.tableView.reloadData() } @@ -195,12 +195,14 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat if !UIApplication.shared.isMac() { refreshControl = UIRefreshControl() - refreshControl.tintColor = UIColor.fontColor + refreshControl?.tintColor = UIColor.fontColor - refreshControl.attributedTitle = NSAttributedString(string: "") - refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) - refreshControl.centerAnchors /==/ tableView.centerAnchors + refreshControl?.attributedTitle = NSAttributedString(string: "") + refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + if let control = self.refreshControl { + self.tableView.addSubview(control) + control.centerAnchors /==/ self.tableView.centerAnchors + } } tableView.alwaysBounceVertical = true @@ -491,13 +493,13 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat } } - var refreshControl: UIRefreshControl! + var refreshControl: UIRefreshControl? func refresh() { loading = true emptyStateView.isHidden = true baseData.reset() - refreshControl.beginRefreshing() + refreshControl?.beginRefreshing() flowLayout.reset(modal: presentingViewController != nil, vc: self, isGallery: false) flowLayout.invalidateLayout() tableView.reloadData() @@ -530,14 +532,16 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat func endAndResetRefresh() { if !UIApplication.shared.isMac() { - self.refreshControl.endRefreshing() - self.refreshControl.removeFromSuperview() + self.refreshControl?.endRefreshing() + self.refreshControl?.removeFromSuperview() self.refreshControl = UIRefreshControl() - self.refreshControl.tintColor = UIColor.fontColor + self.refreshControl?.tintColor = UIColor.fontColor - self.refreshControl.attributedTitle = NSAttributedString(string: "") - self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - self.tableView.addSubview(self.refreshControl) + self.refreshControl?.attributedTitle = NSAttributedString(string: "") + self.refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + if let control = self.refreshControl { + self.tableView.addSubview(control) + } } } diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 6e966a21b..1f6ffcb02 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -589,6 +589,9 @@ class SettingValues { SettingValues.disable13Popup = false // REMOVE this setting settings.bool(forKey: SettingValues.pref_disable13Popup) SettingValues.streamVideos = settings.object(forKey: SettingValues.pref_streamVideos) == nil ? true : settings.bool(forKey: SettingValues.pref_streamVideos) SettingValues.fullWidthHeaderCells = settings.bool(forKey: SettingValues.pref_fullWidthHeaderCells) + if UIApplication.shared.isMac() { + SettingValues.fullWidthHeaderCells = true + } SettingValues.gfycatAPI = settings.object(forKey: SettingValues.pref_gfycatAPI) == nil ? true : settings.bool(forKey: SettingValues.pref_gfycatAPI) SettingValues.imageFlairs = settings.object(forKey: SettingValues.pref_imageFlairs) == nil ? true : settings.bool(forKey: SettingValues.pref_imageFlairs) SettingValues.coloredFlairs = settings.object(forKey: SettingValues.pref_coloredFlairs) == nil ? true : settings.bool(forKey: SettingValues.pref_coloredFlairs) @@ -662,6 +665,9 @@ class SettingValues { SettingValues.scoreInTitle = settings.bool(forKey: SettingValues.pref_scoreInTitle) SettingValues.commentsInTitle = settings.bool(forKey: SettingValues.pref_commentsInTitle) SettingValues.appMode = AppMode.init(rawValue: settings.string(forKey: SettingValues.pref_appMode) ?? (pad ? "multi" : "single")) ?? (pad ? .SPLIT : .SINGLE) + if UIApplication.shared.isMac() { + SettingValues.appMode = .SPLIT + } SettingValues.hideSeen = settings.bool(forKey: SettingValues.pref_hideSeen) SettingValues.postViewMode = PostViewType.init(rawValue: settings.string(forKey: SettingValues.pref_postViewMode) ?? "card") ?? .CARD diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index a3e55a252..f9507b1ce 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -173,7 +173,7 @@ class SettingsViewMode: BubbleSettingTableViewController { self.galleryCount.textLabel!.isEnabled = true self.galleryCount.detailTextLabel!.isEnabled = true - if !SettingValues.isPro { + if !SettingValues.isPro && !UIApplication.shared.isMac() { multicolumnCount.isUserInteractionEnabled = false multicolumnCount.textLabel!.isEnabled = false multicolumnCount.detailTextLabel!.isEnabled = false @@ -194,7 +194,7 @@ class SettingsViewMode: BubbleSettingTableViewController { self.splitMode.detailTextLabel!.isEnabled = false } - if SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro { + if (SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro) && !UIApplication.shared.respectIpadLayout(){ self.multicolumnCount.isUserInteractionEnabled = false self.multicolumnCount.textLabel!.isEnabled = false self.multicolumnCount.detailTextLabel!.isEnabled = false @@ -292,36 +292,52 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showMultiColumn() { - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad - let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) + if UIApplication.shared.isMac() { + let popup = DragDownAlertMenu(title: "Column Count", subtitle: "", icon: nil) + + for value in 1...5 { + popup.addAction(title: "\(value)", icon: nil) { + SettingValues.multiColumnCount = value + UserDefaults.standard.set(value, forKey: SettingValues.pref_multiColumnCount) + UserDefaults.standard.synchronize() + SubredditReorderViewController.changed = true + self.setSelected() + } + } + + popup.show(self) + } else { + let pad = UIApplication.shared.respectIpadLayout() + let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) - actionSheetController.addCloseButton() + actionSheetController.addCloseButton() - let values = pad ? [["1", "2", "3", "4", "5"]] : [["1", "2", "3"]] - let pickerView = PickerViewViewControllerColored(values: values, initialSelection: [(0, SettingValues.multiColumnCount - 1)], action: { (_, _, chosen, _) in - SettingValues.multiColumnCount = chosen.row + 1 - UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_multiColumnCount) - UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true - self.setSelected() - }) + let values = pad ? [["1", "2", "3", "4", "5"]] : [["1", "2", "3"]] + let pickerView = PickerViewViewControllerColored(values: values, initialSelection: [(0, SettingValues.multiColumnCount - 1)], action: { (_, _, chosen, _) in + SettingValues.multiColumnCount = chosen.row + 1 + UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_multiColumnCount) + UserDefaults.standard.synchronize() + SubredditReorderViewController.changed = true + self.setSelected() + }) - actionSheetController.setupTheme() - - actionSheetController.attributedTitle = NSAttributedString(string: "Landscape column count", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.fontColor]) - - actionSheetController.addChild(pickerView) - - let pv = pickerView.view! - actionSheetController.contentView.addSubview(pv) - - pv.edgeAnchors /==/ actionSheetController.contentView.edgeAnchors - 14 - pv.heightAnchor /==/ CGFloat(216) - pickerView.didMove(toParent: actionSheetController) - - actionSheetController.addBlurView() + actionSheetController.setupTheme() + + actionSheetController.attributedTitle = NSAttributedString(string: "Landscape column count", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.fontColor]) + + actionSheetController.addChild(pickerView) + + let pv = pickerView.view! + actionSheetController.contentView.addSubview(pv) + + pv.edgeAnchors /==/ actionSheetController.contentView.edgeAnchors - 14 + pv.heightAnchor /==/ CGFloat(216) + pickerView.didMove(toParent: actionSheetController) + + actionSheetController.addBlurView() - self.present(actionSheetController, animated: true, completion: nil) + self.present(actionSheetController, animated: true, completion: nil) + } } func showPortraitMultiColumn() { diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 44da5634b..79b5ec301 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -274,7 +274,7 @@ class SplitMainViewController: MainViewController { NotificationCenter.default.addObserver(self, selector: #selector(autoCacheFinished(_:)), name: .autoCacheFinished, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(autoCacheProgress(_:)), name: .autoCacheProgress, object: nil) - if let splitViewController = splitViewController, (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { + if let splitViewController = splitViewController, (!UIApplication.shared.isSplitOrSlideOver) { (UIApplication.shared.delegate as? AppDelegate)?.setupSplitLayout(splitViewController) } } diff --git a/Slide for Reddit/VideoScrubberView.swift b/Slide for Reddit/VideoScrubberView.swift index d37de2a7d..eabfb40b7 100644 --- a/Slide for Reddit/VideoScrubberView.swift +++ b/Slide for Reddit/VideoScrubberView.swift @@ -172,7 +172,9 @@ extension VideoScrubberView { @objc func sliderDidBeginDragging(_ sender: ThickSlider) { delegate?.sliderDidBeginDragging() - slider.setThumbImage(largeThumbImage, for: .normal) + if !UIApplication.shared.isMac() { + slider.setThumbImage(largeThumbImage, for: .normal) + } UIView.animate(withDuration: 0.3) { self.playButton.isHidden = true } @@ -180,7 +182,9 @@ extension VideoScrubberView { @objc func sliderDidEndDragging(_ sender: ThickSlider) { delegate?.sliderDidEndDragging() - slider.setThumbImage(smallThumbImage, for: .normal) + if !UIApplication.shared.isMac() { + slider.setThumbImage(smallThumbImage, for: .normal) + } UIView.animate(withDuration: 0.3) { self.playButton.isHidden = false } diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 5a6db089f..2322a131c 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -48,9 +48,9 @@ class WrappingFlowLayout: UICollectionViewLayout { cache = [] contentHeight = 0 var portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad || UIApplication.shared.isMac() + let pad = UIApplication.shared.respectIpadLayout() - if SettingValues.appMode == .MULTI_COLUMN { + if SettingValues.appMode == .MULTI_COLUMN || UIApplication.shared.isMac() { if (UIApplication.shared.statusBarOrientation.isPortrait && !UIApplication.shared.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { if !pad { numberOfColumns = SettingValues.portraitMultiColumnCount From 2c84ef34a4098b956880d5bfee1952745e9efca0 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 20:44:01 -0600 Subject: [PATCH 04/46] Removed toolbar for Mac, Fixed video crashes --- Slide for Reddit/AnyModalViewController.swift | 21 +++++--- Slide for Reddit/AppDelegate.swift | 50 +++++++++++++++++-- .../VideoMediaViewController.swift | 37 ++++++++------ Slide for Reddit/VideoScrubberView.swift | 24 +++------ 4 files changed, 89 insertions(+), 43 deletions(-) diff --git a/Slide for Reddit/AnyModalViewController.swift b/Slide for Reddit/AnyModalViewController.swift index 95173de86..68504de85 100644 --- a/Slide for Reddit/AnyModalViewController.swift +++ b/Slide for Reddit/AnyModalViewController.swift @@ -13,7 +13,7 @@ import Then import UIKit class AnyModalViewController: UIViewController { - let volume = SubtleVolume(style: SubtleVolumeStyle.rounded) + var volume: SubtleVolume? let volumeHeight: CGFloat = 3 static var linkID = "" @@ -171,9 +171,6 @@ class AnyModalViewController: UIViewController { connectActions() handleHideUI() - volume.barTintColor = .white - volume.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) - volume.animation = .slideDown var is13 = false if #available(iOS 13, *) { @@ -181,8 +178,14 @@ class AnyModalViewController: UIViewController { } if !is13 { - view.addSubview(volume) - NotificationCenter.default.addObserver(volume, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) + volume = SubtleVolume(style: .rounded) + + volume!.barTintColor = .white + volume!.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) + volume!.animation = .slideDown + + view.addSubview(volume!) + NotificationCenter.default.addObserver(volume!, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) } if urlToLoad != nil && self.embeddedPlayer == nil { @@ -255,8 +258,10 @@ class AnyModalViewController: UIViewController { func layoutVolume() { let volumeYPadding: CGFloat = 10 let volumeXPadding = UIScreen.main.bounds.width * 0.4 / 2 - volume.superview?.bringSubviewToFront(volume) - volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + if let volume = volume { + volume.superview?.bringSubviewToFront(volume) + volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + } } func stopDisplayLink() { diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 43ccae045..4d728dc89 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -490,9 +490,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.preferredPrimaryColumnWidthFraction = 0.15 splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 - splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 - splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 - splitViewController.preferredSupplementaryColumnWidthFraction = 0.40 + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 + splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 + splitViewController.preferredSupplementaryColumnWidthFraction = 0.60 } else { splitViewController.preferredPrimaryColumnWidthFraction = 0.33 splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 @@ -1270,6 +1270,15 @@ extension AppDelegate: UIWindowSceneDelegate { } } + + #if targetEnvironment(macCatalyst) + guard let windowScene = scene as? UIWindowScene else { return } + + if let titlebar = windowScene.titlebar { + titlebar.titleVisibility = .hidden + titlebar.toolbar = nil + } + #endif } } @@ -1321,3 +1330,38 @@ class NoHomebarSplitViewController: UISplitViewController { return SettingValues.hideStatusBar } } + +#if targetEnvironment(macCatalyst) +extension AppDelegate: NSToolbarDelegate { + + func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { + let identifiers: [NSToolbarItem.Identifier] = [ + + ] + return identifiers + } + + func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { + return toolbarDefaultItemIdentifiers(toolbar) + } + + func toolbar(_ toolbar: NSToolbar, + itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, + willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { + + var toolbarItem: NSToolbarItem? + + switch itemIdentifier { + case .toggleSidebar: + toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier) + + default: + toolbarItem = nil + } + + return toolbarItem + } + +} +#endif + diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 4a45ddf43..8c77d6541 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -32,7 +32,9 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz }, completion: nil) } } - let volume = SubtleVolume(style: SubtleVolumeStyle.rounded) + + + var volume: SubtleVolume? let volumeHeight: CGFloat = 3 var setOnce = false @@ -106,30 +108,35 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz strongSelf.handleHideUI(hideTitle: true) }) - volume.barTintColor = .white - volume.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) - volume.animation = .slideDown - - var is13 = false if #available(iOS 13, *) { - is13 = true - } - if !((parent?.parent) is ShadowboxLinkViewController) && !is13 { - view.addSubview(volume) - volume.delegate = self - NotificationCenter.default.addObserver(volume, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) + + } else { + if !((parent?.parent) is ShadowboxLinkViewController) { + volume = SubtleVolume(style: SubtleVolumeStyle.rounded) + volume!.barTintColor = .white + volume!.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) + volume!.animation = .slideDown + view.addSubview(volume!) + volume!.delegate = self + NotificationCenter.default.addObserver(volume!, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) + } } } override func viewDidLayoutSubviews() { - layoutVolume() + if #available(iOS 13, *) { + } else { + layoutVolume() + } } func layoutVolume() { let volumeYPadding: CGFloat = 10 let volumeXPadding = UIScreen.main.bounds.width * 0.4 / 2 - volume.superview?.bringSubviewToFront(volume) - volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + if let volume = volume { + volume.superview?.bringSubviewToFront(volume) + volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + } } func stopDisplayLink() { diff --git a/Slide for Reddit/VideoScrubberView.swift b/Slide for Reddit/VideoScrubberView.swift index eabfb40b7..31ecd5870 100644 --- a/Slide for Reddit/VideoScrubberView.swift +++ b/Slide for Reddit/VideoScrubberView.swift @@ -69,17 +69,16 @@ class VideoScrubberView: UIView { super.init(frame: frame) slider.tintColor = ColorUtil.accentColorForSub(sub: "") -// slider.setThumbImage(UIImage(named: "circle")?.getCopy(withSize: .square(size: 72), withColor: slider.tintColor), for: .normal) slider.minimumValue = 0 slider.maximumValue = 1 slider.isContinuous = true -// slider.setThumbImage(UIImage(), for: .normal) -// slider.setMinimumTrackImage(UIImage.image(with: slider.tintColor).getCopy(withSize: .square(size: 72)), for: .normal) -// slider.setMaximumTrackImage(UIImage.image(with: slider.tintColor.withAlphaComponent(0.4)).getCopy(withSize: .square(size: 72)), for: .normal) -// slider.thumbTintColor = ColorUtil.accentColorForSub(sub: "") - slider.minimumTrackTintColor = ColorUtil.accentColorForSub(sub: "") - slider.maximumTrackTintColor = ColorUtil.accentColorForSub(sub: "").withAlphaComponent(0.4) - slider.setThumbImage(UIImage(named: "circle")?.getCopy(withSize: CGSize.square(size: 20), withColor: .white), for: .normal) + + if !UIApplication.shared.isMac() { + slider.minimumTrackTintColor = ColorUtil.accentColorForSub(sub: "") + slider.maximumTrackTintColor = ColorUtil.accentColorForSub(sub: "").withAlphaComponent(0.4) + + slider.setThumbImage(UIImage(named: "circle")?.getCopy(withSize: CGSize.square(size: 20), withColor: .white), for: .normal) + } self.addSubview(slider) self.addSubview(playButton) @@ -88,15 +87,6 @@ class VideoScrubberView: UIView { slider.heightAnchor /==/ 24 slider.bottomAnchor /==/ self.bottomAnchor - 4 slider.leftAnchor /==/ timeTotalLabel.rightAnchor + 8 - - // timeElapsedLabel.font = UIFont.boldSystemFont(ofSize: 12) - // timeElapsedLabel.textAlignment = .center - // timeElapsedLabel.textColor = UIColor.white - // self.addSubview(timeElapsedLabel) - // timeElapsedLabel.centerYAnchor /==/ slider.centerYAnchor - // timeElapsedLabel.leftAnchor />=/ slider.leftAnchor ~ .high -// timeElapsedRightConstraint = timeElapsedLabel.rightAnchor /==/ CGFloat(slider.thumbCenterX - 16) ~ .low -// slider timeTotalLabel.font = UIFont.monospacedDigitSystemFont(ofSize: 12, weight: UIFont.Weight(rawValue: 10)) timeTotalLabel.textAlignment = .center From 62e7be83f0e4e902d7e1e85d68bc9edfb052504f Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 31 Jan 2021 15:30:33 -0600 Subject: [PATCH 05/46] Use new windows for more ViewControllers --- Slide for Reddit/AppDelegate.swift | 65 ++++++++++++++-- Slide for Reddit/SettingValues.swift | 2 +- Slide for Reddit/VCPresenter.swift | 95 ++++++++++++++++------- Slide for Reddit/WrappingFlowLayout.swift | 2 + 4 files changed, 127 insertions(+), 37 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 4d728dc89..93c5552b6 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -490,9 +490,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.preferredPrimaryColumnWidthFraction = 0.15 splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 - splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 - splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 - splitViewController.preferredSupplementaryColumnWidthFraction = 0.60 + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.25 + splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.25 + splitViewController.preferredSupplementaryColumnWidthFraction = 0.25 } else { splitViewController.preferredPrimaryColumnWidthFraction = 0.33 splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 @@ -1187,7 +1187,25 @@ extension AppDelegate: UIWindowSceneDelegate { willResignActive() SlideCoreData.sharedInstance.saveContext() } - + + func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) { + if UIApplication.shared.isMac() { + let size = windowScene.coordinateSpace.bounds.size + + for window in windowScene.windows { + if let split = window.rootViewController as? UISplitViewController, split.style == .tripleColumn { + split.minimumPrimaryColumnWidth = size.width * 0.15 + split.preferredPrimaryColumnWidthFraction = 0.15 + split.maximumPrimaryColumnWidth = size.width * 0.15 + + split.minimumSupplementaryColumnWidth = size.width * 0.25 + split.maximumSupplementaryColumnWidth = size.width * 0.25 + split.preferredSupplementaryColumnWidthFraction = 0.25 + } + } + } + } + func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { if let url = shortcutItem.userInfo?["sub"] { VCPresenter.openRedditLink("/r/\(url)", window?.rootViewController as? UINavigationController, window?.rootViewController) @@ -1261,14 +1279,49 @@ extension AppDelegate: UIWindowSceneDelegate { } if let userActivity = connectionOptions.userActivities.first { - if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "SUBREDDIT" { + if connectionOptions.userActivities.first?.activityType == "settings" { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: SettingsViewController()) + } else if connectionOptions.userActivities.first?.activityType == "website", let url = userActivity.userInfo?["url"] as? URL { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: WebsiteViewController(url: url, subreddit: "")) + } else if connectionOptions.userActivities.first?.activityType == "subreddit", let subreddit = userActivity.userInfo?["subreddit"] as? String { + let subVC = SingleSubredditViewController(subName: subreddit, single: true) + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + + window?.rootViewController = split + } else if connectionOptions.userActivities.first?.activityType == "profile", let profile = userActivity.userInfo?["profile"] as? String { + let subVC = SwipeForwardNavigationController(rootViewController: ProfileViewController(name: profile)) + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + + window?.rootViewController = split + } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "SUBREDDIT" { VCPresenter.openRedditLink("/r/\(userActivity.title ?? "")", window?.rootViewController as? UINavigationController, window?.rootViewController) } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "INBOX" { VCPresenter.showVC(viewController: InboxViewController(), popupIfPossible: false, parentNavigationController: window?.rootViewController as? UINavigationController, parentViewController: window?.rootViewController) } else if let url = userActivity.webpageURL { _ = handleURL(url) } - } #if targetEnvironment(macCatalyst) diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 1f6ffcb02..79f22c5d8 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -500,7 +500,7 @@ class SettingValues { var columns = 2 // TODO - Maybe calculate per device? if UIApplication.shared.isMac() { - columns = 3 + columns = 1 } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIApplication.shared.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index d0352b59e..f30c40289 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -39,11 +39,15 @@ public class VCPresenter { } } } + + if UIApplication.shared.isMac() { + parentIs13 = false + } + if (!UIApplication.shared.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { override13 = false } - // Yes, this logic is a mess. I need to redo it sometime... let respectedOverride13 = override13 var shouldPopup = popupIfPossible @@ -56,50 +60,81 @@ public class VCPresenter { } } - override13 = override13 && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() || (viewController is UIPageViewController || viewController is SettingsViewController)) + override13 = override13 && (UIApplication.shared.respectIpadLayout() || (viewController is UIPageViewController || viewController is SettingsViewController)) - if (viewController is PagingCommentViewController || viewController is CommentViewController || viewController is WebsiteViewController) && (parentViewController?.splitViewController != nil && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { + if (viewController is PagingCommentViewController || viewController is CommentViewController || (viewController is WebsiteViewController && !((viewController as! WebsiteViewController).url?.absoluteString.contains("login.compact") ?? false))) && (parentViewController?.splitViewController != nil && UIApplication.shared.respectIpadLayout() && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { (parentViewController!.splitViewController)?.showDetailViewController(SwipeForwardNavigationController(rootViewController: viewController), sender: nil) return } else if ((!SettingValues.disablePopupIpad) && UIApplication.shared.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { - if viewController is SingleSubredditViewController { - (viewController as! SingleSubredditViewController).isModal = true - } + if UIApplication.shared.isMac() && viewController is SettingsViewController { + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: NSUserActivity(activityType: "settings"), + options: nil, + errorHandler: nil) + + } else if UIApplication.shared.isMac() && viewController is SingleSubredditViewController { + let activity = NSUserActivity(activityType: "subreddit") + activity.userInfo = ["subreddit": (viewController as! SingleSubredditViewController).sub] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + + } else if UIApplication.shared.isMac() && viewController is ProfileViewController { + let activity = NSUserActivity(activityType: "profile") + activity.userInfo = ["profile": (viewController as! ProfileViewController).name] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + } else if UIApplication.shared.isMac() && viewController is WebsiteViewController { + let activity = NSUserActivity(activityType: "website") + activity.userInfo = ["url": (viewController as! WebsiteViewController).url] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) - let newParent = TapBehindModalViewController.init(rootViewController: viewController) + } else { + if viewController is SingleSubredditViewController { + (viewController as! SingleSubredditViewController).isModal = true + } - newParent.navigationBar.shadowImage = UIImage() - newParent.navigationBar.isTranslucent = false + let newParent = TapBehindModalViewController.init(rootViewController: viewController) - let button = UIButtonWithContext(buttonImage: UIImage(sfString: SFSymbol.xmark, overrideString: "close")) - button.parentController = newParent - button.imageView?.contentMode = UIView.ContentMode.scaleAspectFit - button.addTarget(self, action: #selector(VCPresenter.handleCloseNav(controller:)), for: .touchUpInside) + newParent.navigationBar.shadowImage = UIImage() + newParent.navigationBar.isTranslucent = false - let barButton = UIBarButtonItem.init(customView: button) + let button = UIButtonWithContext(buttonImage: UIImage(sfString: SFSymbol.xmark, overrideString: "close")) + button.parentController = newParent + button.imageView?.contentMode = UIView.ContentMode.scaleAspectFit + button.addTarget(self, action: #selector(VCPresenter.handleCloseNav(controller:)), for: .touchUpInside) + + let barButton = UIBarButtonItem.init(customView: button) - // Let's figure out how to present it - let small: Bool = shouldPopup && UIScreen.main.traitCollection.userInterfaceIdiom == .pad && UIApplication.shared.statusBarOrientation != .portrait + // Let's figure out how to present it + let small: Bool = shouldPopup && UIScreen.main.traitCollection.userInterfaceIdiom == .pad && UIApplication.shared.statusBarOrientation != .portrait - if small || override13 || respectedOverride13 { - newParent.modalPresentationStyle = .pageSheet - if !override13 && !respectedOverride13 { + if small || override13 || respectedOverride13 { + newParent.modalPresentationStyle = .pageSheet + if !override13 && !respectedOverride13 { + newParent.modalTransitionStyle = .crossDissolve + } + } else { + newParent.modalPresentationStyle = .fullScreen newParent.modalTransitionStyle = .crossDissolve } - } else { - newParent.modalPresentationStyle = .fullScreen - newParent.modalTransitionStyle = .crossDissolve - } - viewController.navigationItem.leftBarButtonItems = [barButton] + viewController.navigationItem.leftBarButtonItems = [barButton] - parentViewController!.present(newParent, animated: true, completion: nil) - if viewController is SFHideSafariViewController { - newParent.setNavigationBarHidden(true, animated: false) - } - if !(viewController is SingleSubredditViewController) { - viewController.setupBaseBarColors() + parentViewController!.present(newParent, animated: true, completion: nil) + if viewController is SFHideSafariViewController { + newParent.setNavigationBarHidden(true, animated: false) + } + if !(viewController is SingleSubredditViewController) { + viewController.setupBaseBarColors() + } } } else { let button = UIButtonWithContext(buttonImage: UIImage(sfString: SFSymbol.chevronLeft, overrideString: "close")) diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 2322a131c..a1787f614 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -81,6 +81,8 @@ class WrappingFlowLayout: UICollectionViewLayout { if isGallery { numberOfColumns = SettingValues.galleryCount } + + numberOfColumns = 1 cellPadding = (numberOfColumns > 1 && (SettingValues.postViewMode != .LIST) && (SettingValues.postViewMode != .COMPACT)) ? CGFloat(3) : ((SettingValues.postViewMode == .LIST) ? CGFloat(1) : CGFloat(0)) prepare() } From a7a388243af83e446e2ec9e7bd86d359a64d7040 Mon Sep 17 00:00:00 2001 From: ccrama Date: Thu, 4 Feb 2021 23:18:48 -0600 Subject: [PATCH 06/46] Fixed some sidebar bugs --- Slide for Reddit/AppDelegate.swift | 16 ++++++++++++++++ Slide for Reddit/CustomAlbum.swift | 2 +- .../NavigationHomeViewController.swift | 4 ++++ Slide for Reddit/VCPresenter.swift | 7 +++++++ slide_ios_rounded.png | Bin 19729 -> 0 bytes 5 files changed, 28 insertions(+), 1 deletion(-) delete mode 100644 slide_ios_rounded.png diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 93c5552b6..55f871301 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -1298,6 +1298,22 @@ extension AppDelegate: UIWindowSceneDelegate { split.preferredDisplayMode = .oneBesideSecondary split.preferredSplitBehavior = .tile + window?.rootViewController = split + } else if connectionOptions.userActivities.first?.activityType == "inbox" { + let subVC = InboxViewController() + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + window?.rootViewController = split } else if connectionOptions.userActivities.first?.activityType == "profile", let profile = userActivity.userInfo?["profile"] as? String { let subVC = SwipeForwardNavigationController(rootViewController: ProfileViewController(name: profile)) diff --git a/Slide for Reddit/CustomAlbum.swift b/Slide for Reddit/CustomAlbum.swift index 8406151ad..9e4ab869f 100644 --- a/Slide for Reddit/CustomAlbum.swift +++ b/Slide for Reddit/CustomAlbum.swift @@ -94,6 +94,6 @@ class CustomAlbum: NSObject { } func saveMovieToLibrary(movieURL: URL, parent: UIViewController?) { - UISaveVideoAtPathToSavedPhotosAlbum(movieURL.absoluteString, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil) + UISaveVideoAtPathToSavedPhotosAlbum(movieURL.absoluteString, self, #selector(video(_:didFinishSavingWithError:contextInfo:)), nil) } } diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index f0e8b1296..0ed6e09fb 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -670,6 +670,8 @@ extension NavigationHomeViewController: UISearchBarDelegate { DispatchQueue.main.async { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() + self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.searchBar.becomeFirstResponder() } } } catch { @@ -694,6 +696,8 @@ extension NavigationHomeViewController: UISearchBarDelegate { DispatchQueue.main.async { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() + self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.searchBar.becomeFirstResponder() } case .failure(let error): print(error) diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index f30c40289..43fc88e5d 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -80,6 +80,13 @@ public class VCPresenter { userActivity: activity, options: nil, errorHandler: nil) + + } else if UIApplication.shared.isMac() && viewController is InboxViewController { + let activity = NSUserActivity(activityType: "inbox") + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) } else if UIApplication.shared.isMac() && viewController is ProfileViewController { let activity = NSUserActivity(activityType: "profile") diff --git a/slide_ios_rounded.png b/slide_ios_rounded.png deleted file mode 100644 index 5951d2c838b5dbb83197cfa1313b2abf212ff35f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19729 zcmV)HK)t_-P)}+wP4%jZs$wot85I=~N*Q9K0#1OoX;2i=v;ksbqM)Jz4oQC&f=Rw^6M@(< zgSLhGIizDzO7c(8FxZ{M?kELdhdN7 z)O+`yv(FxW>$iSu?cr4PB>AbYT(fF+Z0zJ-U9aj;Z;h)~UDMH2)kjkuE7_}ws@i?G zs;PEO>3jE!zc$`b^Ns47bhG=u@(&94;P3GwF2ns>scWehE=rGq=lRd8_@%CoRY!PU z73&+T6zZqygAb1NuiNUM9?9*9b;r+r8{G$~o!cs^H#YqrF0QM36H&FPs_IQuui7+Q z&u*Ul%HB;+1}ORJKi)snSD)rUc@}kgYpAZ)P)%z*DiDl3U;?06(+I*e))r_01PBTQ zyaTC!c0y15T?2^AM+66}6R6hp@t0fo7C>4%ps^vuXJrPH&<%ao7-Zd8xav~}Q~+}7 zbIZV>&S+qw>}UYZ7&-87tUL9_4t4Gv|I)6Fk2kg+H$YE)@R!c7sCNO?bT(0abfkg^ zrUGLzV|eTW02)dJEJcIxSg^pNK-*AW17>`lV0mEgR6ek8W>f{xw;5Feva3HcKek!- z0fSv$iWGzbb$wPB0=S!=ySOK@a@KV<}G_6F_?) z6MdBG`qHFLGfANb3Yf`~8)7UidBFpq*obv+i5-!t(=&AWC>emAECA{<(lxHDds6R< z?|@k?$&d^~$&o|`(OGdj+0f9y%sxQ2RUScfK%nq73(l%w;k(x;xgnj27+g4ZWAfNi$Z98&AQZa;X_`k+Cf)q;zuv zm)A~8BP*6fw=eoAUMCn3Jz1!ez^v7;8q{si(_W&jJ_v5CqrM0G(gSg2}>(3F@E?W@-5`kNty+AhQtQMz>jNmT~C^k0^eg)TjSb=mlTpP5r;WKMvd{>Y0jrMmiL$P07sG`iF@5QBEC20}}IIb#_x5}lHB9oEW@ zdO+hK>Wl|prn4NH`O(Gt?-&d?n(A{Qi@R>#~ zd7PGZV0$fsfLojNXhA-CmFhvgZeQ7Yp8-Anp))>5Ro!T1Y)m%DhAYz6s@c{ok3nDP zcx17@k|U0Oa4WI@I8TcKoRPaV<%+?I+K^f$3xWm*Tp3(IvK((!Zort~r7YQ%t^=?O z1JikN!)svxnp<6y3(ttf@_>G9*Nu0(@2fV@wqb!iG@$FXXRn%_n)+PrQ*jXE2p7j0 z3uGtgB{MK74N?pHqRZ7xkwAwj!jfTG&j8?vvMqoC0JSv0wze92$w*5cF2)8ZNg|NV ziIuE>3V_#=g9q8$z0rTdczgzgZ;|oVV@?_+BiPjd-<@S9tzM7%rjHdwK zpfTkIpxtndjpgZ%jZEcTKFgSfK;=wVOE$q87;8}Zv&?lWCNzUeOBNaTWvN30Ou}6= z+ZT){bzYw8OZr(<1D@CDksNrXIzUnh=J}18-I8Zf?GcRL+RsCSdSE~YFi+i1RE243 zZafZ_m`2u~(Hg`7S)$0k%EC>}+M)~lq`*Qm!N5|=%>Z1cN0oLqy;5=`O@Ai0r=Fd# z4Q=*SlSWlzAEe?-{frqFZj%C-204yJ7H231Pv2XHiC)nHb^3necz1B79vILwAO3f@ z)Ks|{KOk4_f>fYlM%Bo+(21JmGb_eM>&yu=1J3Nl=dgDu0Rr{2pZF*QaYaD+v{NCo z!*xclV+EZ}m&&yvI7t*WuFfV1?^jU(H1w6FrL$bPnvCN6TfG(nvJYU>SjK+fxF!7w zDMBQW#vnG1ck6-V$3TD%0U*U$KPD}s6MSh_=fHpoi;n?Ea{Jmq`sqsOpse!&WLYp) z(1UG3T=rd0O&lqP>uW%0aKO}>0aKO)GZX-(Bq73QjpT^IY?eWR=UN_0rvkJ3uyLYy zFgyTPCJ~hmu95sOzOsnR*LmH<*Ls&JBxQg01$0c!eJ(G^U`Yh4710(g-*pJEn79s~ z3>~KjqZoW?);1;#tQj?($ISq$B6KS~m$4-dmSOx_-}2}<4K>;Z2VUH#Q1HT_*(tK5=$2W zJ@t_@)>d`xR?OJ}Pcbc~-D-htg^@&*8Wx!ap~(xBbe9G+vZIkV7wxlH4LdlEI!y8F z@0H;u?}D*~s*?ae2c@8ylM!n`HUsSd9l8cAUi7CB(|O9xj57?wM>)voNnTdRCLn40 zwITbSaRbuIe8Y7@|L9rN8`p%DyX*q;+gfCr@oSQ%SjSqkXF`ZXIC+>mBP zE<wJqT7eV>Yl2`3Mx(D0%w`0HictfQl_#>iPl>^OU#dRQ zbwK0fZCa+xgnIOiZSYz}hT6#B?_Q6NncP6xwl5RV(;s@Vn@hh$1ZtdP)*wPNDFq(l z9>vDlJuTDP0yqWG_Zvhpa0a6!paRqB`uj2HXB;hTFN^^RVnDBxv3^)K8tz6=*M13h zWFQ==+{5TPwSk-a5H&Qiv<|41@rg_r8$_lAfbdZMd1c_g+c2@7UN0Nf?1M_5$2H9l zqz^2>rO6Z?X>?}-;q4nwMMJfvV%ePDYhhL2Aqr%olX+a#fa}i2j?M0mEZCQE)eNR! zwt{x_%^hazm0~mhNF4+NC^XOo&RdL6GpqnH-=`Nn8Eh|z1ny%)!haJfsWu9kO4RGn z%P0TRZSiV;GKRL%?!+-y~uJFbKx_@_ja9|fDi_~RsR}ZLb!arM#b2D zB>EQXRT$TyVkCn&OgT%WwX^{A^aoG7fvDp)wHg5ix|KL0Vv7|3T#I?D@p_){;{LcFFs)Z<1E>ZTFnK>9q<&GXWiGsDgA4IQ_^XZO@jL6< z0X>B9TnJ#0E*@E&`UGtFdkd0-y|d;*D@EFH;LQ`axLNG*BLRKQ>5iR`PQbxm_)61t zKu2iyu^0v=L<$O;8kPetW7aR-1};+&D|euEh>T^p%Jm8WT9QMtT_!zB&p`JFslHTq z1c$NvJoX#2bJNX6j@i_~26)*ZGQu!Cm2PLYe-w?{=!0xhMPFm(z|B}~+r)Z0Faz|| zHK$)tRdh>elVTLPr^>*)m8dUFo}{}`cNt*gdT<*s8cwzdgDz^Nr{!aNvdG=o!I7@f zrzBajMNby#^&Q6Y00aU8$chs(W>O3Y(kLC$l%)`@qZ70ds=0;~#~9jHdw|p)%Rqso zM7v89JB5iHac>Ulis-WO_2hTCB!-^8=Jc4VL-$}=79z)*9prm7h~j;k;gb&4x=y>t zXlOzF6 zSe;GanL*W0Z2=fpRc9@dL2w1M{kvK+|>ElH$_6Z((uD+GnHR!MevK>M@i zDst;K)DLtz0!r&8|6L0}xU&S_!P+&mWL^b8ZyE!#nr12-?1J@MteXZ%yIsrkv;i8f z&*Bh6lAvS|2E+A`?X%Z#U?*WtJbrE&jR0gRk3NW(#IdsKtTQM^4jaKQh|JW`0ewC4 ziZ(hRsG~W-qMC7hnTmE3u#-pXo-{FFVDbf_BxKS&yR?d+2HKk|Aoc;Bgy7 zI`&H#$j15g9Rbi+owklTZmQb?8xF2zA;v;-)T82-Hq8yd&KMIHlUo5~DagPwg?lKR z2pZdp1IPh#ar38QAu$LArbJ^!5Vp!5?FHg!wWUa{v?YQyb&2~$XpzE!mzo^7Fl)^@ z6Oqbcm(sKS+HM&J0y<8zM9Fb#SSIQlmHeV&YdtuzF{V6-WfZj>bcB_cMC)~BSay_k zfWbz%+k>Ceqyy|-%%T`e5@@4`flIcpJro-XlEVP$HQ}Z3hy^D!EFW*I1-u z1(=EO(71p!1R+}2v=C3p3lu$_ay~?xCf3t25zwc=(M7s~tebdI2o8!g5pfuysk4y* z4b3fd95X*yf69m$pWy%`w`OQK&1h)(+9u4&9j>x;1lIh5)KeP0aRZI2)}NaJ(TCIsG>slB7|x8_fgn=U;+19JLcVm(!r zJ2`)5Y-DSG8Gu0tNZG|uGb;_30fku(78G%3`=SaRo@~iltYjGo$P+P`1=lG~+_&nG zd~~y(xabNskdP=^*fmQ7vImev}KQG7PV4XllB2GxpiKf;uoKZKl6E=mUt3Cw(*mILr` zEmMS%^%*2=zb{8kuvlejR@Qx(0l~=8iu9ubf5yJy0ZsMPz?&c{Y*NjF($vv~L*@&B zwSv5?9!k0*L(;Wd;IwgB3#zN@CMe$k~=liUQ0ovZbgSO?rvy3k;l)l)}H0qL3U zOn?eI8-CZ-K*m6~#wgIUau(pywZ?PwK=I$Hu6job16VVkWn9LZ67?>Zu(}R+c*i=T zmy_(I&cU;uq0?#Ftt!I7Tyq9y0AcD|+tb)@X3$167^vNhVKsHti(IPXqcZSU?V~NoY62dW6eGif;jW=B8O+<3LzxzZPRDF)0s726oMuqStLX#z4=E z6ned=RSl0*Do3?NY`IF+jQ!L1dAe@>*c1D`)Zcn+v=JiFSPZUaVFj$Tw3lzQd8_+GdMNz)*&yr3qSnQIcR51k2Mwn-L^sGQ}7W zEn70Mwx!vO_IcY5{U11`AOrMsg?AYc%&CkPsgWuIV71bM>5&TLx(|mjL<7?`(VYR% zbp&*ZtB{%SPGyA%{w#GvP-oHojSLIF^^qE)Ul5oBWJoM<;dtr5JJkoJq9wCbE*#5A0XKUZ?vTDL z%TJGhb_|^wz^GR9_V95cT=`4W^<2pWs_d8WfyHv-b1 zpkSDEGsqvj7rr-LqbtmKtChv588G`XYwY9Hm$DDDBMY*?Of3)4UIqI;u_6GcANT~I zV?Skmg#Bx!>+pLmYmiI}_%SdYBnJYT2V6*j65U&$8_~L@r$q;&jzw2%eXd$zb-dQ+ zf_1D;ZYxu>h`K);SR7n5h*(aNblR)vJ$qb^0p#?`3C+F*BPhlep$<5OUPVtMcENas zfb}R4hL%5>_q8%l+(!jTS@PgELAy`4IY4jqXV=NyScUY4yGH|AcPx&Y0ea0AX>0+^ znYUreo$7#PrZLoq#o(PAnt%Xb57LF2U!mNA$aj$F>9V6ZgcEYJL{meU|j|~Rw83@c#_aj$Ucgq zG<#sDrNP2FVM~pCc&4-UU}`<)zE`?ivp#|*xo2xFNy~tzdc{7<$|-oZRF}~1{Oo7+ z0$@NDyst2If$}!VprUj#jXLyKT8Ut+IAm65zRzDucqPRdyN0GYq8rr&?E z98m_Dwn(vZ%^+$sRcC2m!&*~iOYTeo!D^fse0{wzc@>PdWj_kuM`&BidlWJoIJ+hW z6&lp4n`6K0*EqA$iKc`UnP0lZeUtjg!BFRk0q}8%5?I;WL`;Z3{S&aCELP=b;n?GK zMo?`MT7OhWK!XV9=O8hf#}%l;88bLg&9O~+O%Q+zZ;h$}8KV0My#;n?QWD0pQw#Ko zsT7k44`f8zrhYFCCbFl>9_eX#!>xx$DdU3Yhp*Y&FuVdtnp@#-ONON4(LiIF!9Vyh z^m>{dt)Z`jsZ{>@=vVA)Rx-i?&;00*w2a(1qO==EpMQui=|r`)PkiMpe_wia$#6sE5A8Nv~66I3fqU`;f+lE%)wm^w$jfJRSytqI)0;SsK^ zcWM<;-n4jW005_JW6H|XwrC_pBLG(AnreL;)mjD+q^(qb0hFmp&>iRZ->G6n{~apSd%!g?}T zGX{s=u>wSk`2|yGR#)jK{XP~nlvH2a2sszv&xVedFo2WoMF8{5uso12yoN@fcg8*r z`~2TFd;eWD{gvw*U{?Xyp0(re0mVG?*y!sdOA=`r9&o@aSJUr(epK)+ck~nK2=K%+ zYS2^hSXlsysdXW+w6}f>f(z4j$$z|_Mo)dsfW!OvUpDi%U!bY4UQhLwO@Xni0O|nR25KB225HhF z1BYxvU}ymX0Ai6%^;0za@X!?GN->2e&=)aMu+|K?kaDzGu>^E|Z3aNpzi6cW-X6<< zmq2fdmq6yUnh*TEybSGetnA=0cJ6P`#D!NsVbWqqT+!aITu;+qxsIw%WNOyZI1!WB zI;3?PojtsE=K2MO9_WYtfx6fNmc`O0Q*wSv`TXR1H0#CdvMdKPxw@ViJL{kLfb76V zOuH7|RF!h?4ry30vNM2{=Z(cnb1_FAv@-*pwX#kIDlVML__30;Epc4*IZoU1VrnJflY+9>;lKO~8DK#f%x5BPh{G z0L5q|T%Drq(ZOHA2vR+)JhGwfvpOibV$wj2-1%8eUQOuZ;ANx40O`RR*|Ty@H1@JL z)5P1Zr)uenA&2$Jb@`spet>4aaT9eqp$?x!L%TlmN~(5mPhfUz?K2;~ zzrrje|L|1CFb%7w-}Ah9$b%kTivjzHb;0gd#z9#HOBfCOWGj|m=PZNTm62MlwQX#N zg(w7K0&K~H#0xSbHD(*5Anx`Y+e&ZYnW@8pU$EC8HEODttfZyCa|?|e_55MR@F{hz z)785^{7RyqZ}M#IGa$^=ZagAH7|g@6bpUi@6H;cBy2_FtBK6XCBRs-lHg~JuIgDVl zY$|E{Qbq#ll>^9j-8?%>)U9iB|2n|U%+_8CxZk_oAPXE=8L#0p+CnTKUo^Z+>~c-9Yz8_s~u!KlW@T7b}Jdn5e5Gn)e0N z0nj)&mPxc_7|g9(2GCk_+E%7Q0Xh|_w0oxgn~aTP(Wx1tsp*<#yA{oLYnq-3z{Nb7 zEYS)m74wVW6;g)L;{;qcM%yrRG(wkOjx(H&)t`R(b#&;3@0f4QJn74u{^rfJ`-aPC z#HIA&q_fX}u=I$O6&5@V_7ee(uN8&?8mtUNUR*r~fM#9I?8X0P0EeK?BTTQ&MxBGR zb>a8ft^+R7o+$@jqG`vtv)~#MzGOfreT89ICDs=ik>)uKHw4CEW)4y#7*YUp$Z8z^ zs~@1%m+U{;jA0?O_e&q6yc*Eb@btg&@=_{~ z0h$0^kn2Tn&^U5r-n|~g5PX?ET9{geb;H>j6OYW69CsnbCl4YI`vAjUz|db_YQ*&1 zlH;CF&-t@&4U2*O?)shAy@6)Gvq6H|%`htIF$hyfKr8l3`ZT)Eetge^%d=vF4SD$~ z1Ef!;#F*E20Cu3=0CYWb+MobykT%YE;oyuzX@eGm*tH6dHL zKYSIMl?6dJyLZ&rGedRj1bAL&s|UvYdGowN&umAFo?8Ec~Jq*pSn49`A)Cw-lN7(@KhOh@e(Vj@b<$(R4iX2^(-F`X(`r_Xpx4vk3^cuM z%Tg9eKL?OI39);x19Hqfh)f2cPM2lsY{{C!K)u_Kb_-x@44Lm$z(otnSUg;7NsT6} z5y2dv8MJdnCw%FDFG>x=l)DdYrX5$j(C4Q)^I@@cTW-2xXz>8l)W(xJ$YCbVE>W7? z?~@CY5mPfY?c7bYa}U2pufUF&T#}%WG-GNe`d$AR5tGj~3a{09uR@yHq0+ zk;#bC*fd~qOzZ&cL7dXWg4@_n$HKHh4Unf!dCblzT(-< zcq1Y8Til=0#&FU;Xz4xE746^zubVwQFgw4?_E*^(aB^ySYk`S1c; z^1$XI*|G2TT||%Wj+(f*SQ{AF%vMAYl>i&WFR(gF2d=gPvX#lmBvV2D0B}<=z6lVp z!a**4c`tehUITLCB0CR+Xu;B*z|tv|=f;dBhao*Apm9>9q`VCPI!UqhQ5WO|2CgbT zSkOqfSxrLsj+n~4gkF3ER2g%=qWCN~EvQxQM@#@kxf9o2#FtwJGqb%$lhtV0n$OX2 zyH5^0_u@tEJP@42MLYlWeKh@z8$Fnrr3cZ{)%3fbCG%k{P&j@^W&=iZGGf~E{)yXOt!}KD8D`pbdHbPb5-jdM>d83}ij({Bi8;DL*@{t1x@L|Ee z-xKI3QYw1(C)d;RHBX*h+CyOL3AuFo-aBc>2VX&>o!SS7{y#^~agU;3`(cRa2T3F3#}$J@7t91%5z}n}mFln<$V;m?oY zW4o2h;kurfCANhjE-LL3aG}iNtfO71KO#1!5B={rmtz@Jn{lP!l;4uY zvH|~(+F_fBRcn`m7V@dz=?cdA*(6Xv>9%(3ofFIxQ`Azgs%G z`r&^#rWrAl3N2ZH6DgYAOERTE@#*6b*d<05k1gG6fDMy)*eu}1 znM&Aa>xy>A8pKC9(hk$z6`gw5Lkk9ck5xk-e*GcT*}K)AWQpvYG;{#8rclgBt7?jz zbNr53H!b$pX$wfnCHyNp(f~%SYcB0{H|U8SRiCt17$rrN2tg>s4G0?S@$byQ6`*6W z?jJr}F@d^AGwl{DO5kOkw!pAr?nkQM^``m<)hV`T?}_EBnMQl zsH>$W6?@P@B8b~9{ce_D()F0xP&bO|;H)12ncJ8o5dglhBPS#~+)IAk5>Y$_DWvU| zo%|Ad&P}(>bvzgR{oB@FNVEUocCv)n%IRpHHT29Jr@{TN3DCaV^cl;51d$!EWQfu4 zalw!~v8?&Q*Ne3*WRk+RFsK^b29Q-&1nvlBY7MR@VdONVs0U{>LNQ^6(8~> zGP251Wl73bOGLF1;l0)bN@zz0V3rzU9ZGC-_Iyjigvigaa#*(!uJIce;-+!;yZij0 z^WH+oeB`FNj^~2Ef9rq#HJbgF4QO7ZTZ9`4a^mCAH?+#Z%4r5o3Y1Pe6k3}@4Y<8XsfIb8Gl=Y!9^ zn2!1FKU(mBoNEU-K+i-#m)3Q7FgsBH@O4L-8alouy7-bG9OAUjo!O6rHIFF>2;KJ> zZ*n18KexDfA&VGm!ieMsoCHS;m>A%uURU~GEm7s{hp%E>v*GHLrn*^n^a4X4``e2Q zJ$FFAoo2qZ&adV0GlqIOsnpO%dcyTO7qSV7Gg($!yQi{14ku@T*sO*6g7_dJ6YHI| z%eUBFdzL5zglxANHlMMhS+%n zbcaIfE=_^g;Z+xqx~qQhx+BGCYt@_)YV!WJI!%?&a=03tRx@K&@NKG^In7L6xUZ>^ zLly%PUL2Y+zY!x?vyNs?8dueYX9qxs{IioFD_`Ld>X>ATi|&jPn~d~Z{wbn;TX%-cgWATKp|r;69mL2~qZ9XkE*w#;=r z7ySJXo_{EH_Wr^EbbPP431|jQ+Cl}cmV>&Y>}V6rpi=?+@_aaWmMN{njpq4BC0(2V z?Fz)#*0rSr^+ZckVY$X6*2iZ#B2x7FT zX9!2!LjS_LXdfK@;I+@NsWDq|7lCO7O=9{2(sb6mOvc1kPPzF^*Z{8H0M-`l?(3%w z44TNlhCm_jXQkQ2nRs}$*y$aoz5Rqr05~sBde-lLfet!*;k;^MUx8b?Z_nL#(IZ#A zlEz1SK3$h(Is8kQ;-pF$&=!nL>I9#xB#OS=Gz424^WozGZb3%y^toKC%#tNu*P0%T z;MLa%CT{>9)@1YfA_B?HPPEu2e~d%ip&|g?BRcd=@1$eifBk%q^MWaF+h2T&cKzv< zG&Wi{dFXURSjb7^R;=m=uYEd?w9>IkQ>rm-7P2Au8Cac=zY^eSD^D_Iny~gogDw`t z3jt+GvkS5=v9Xdn5Ln_J?sdNSHy=2|Qrb_hAVWKVcPm=H=4Eukrx(|A?5hPn{5x;- z3zOWAmC?4f9Gr{xfc7H=6A2kX>qSc${T2@PFtoM7h(ZN0hQpi8n?=XCz^Rx?F{DLP zNGuP|;zO?iWy)lUUMB*2K0Xd#Y3wIi(t2p3&azdsX8lJ0+P1}?;d|gGuRD}Rr+z`B zPCqL^yJ_&W(k=n|HO$cJVM$|ZP+9??p;^UgO4;;Gz5?6Ng~SOF0cO5S(d=W2W^~{e;9A5a5t{ z6AG!A_G^OPbeM!L(&+$w_(kucW8Qz=u;aPluitXxRW$XD8)3wWM>H$m+mu8iO5+rxXdZfx9&f2?ij9cF$qvuTh{U!dciVJuW&!fC zhCzs9z4&U>8#)uB48}9G)6H@3tj|Zsr5|Am+`WyqqR!G)bo#e`wBP|cYzO@KqG!{{ zFCGZ{2{C1tP9%+a=;)+F+RgzworV-y%?~7N>gFw0X$4;6b+b)Q0RwnubYNirT5>ds zQtQkaJWGqm0`N%N%pkP^03yv;)6(tyS#C^R)s&0og-QO9b3P8tZI-R*d7r+OR-W>b zVaIgAUhm|_miNDs#z%TVJL{EpC^vXfr=R+El7ls6miCgn4Ra1`WJ7?Q1Wfkszaog? z1f(QiP#Z@>OT}kYX-H{{&0*s!D+g0rfLuZ5=8scKzA=C>TNtKr{O^AHJFdLzRkZx% zv*^S>Tg-M0YM~EZ{~I)Y`#KtPfcA1j?p6^2Ap-jT^H$gHgdnC`fo-+KB8(@bKsZ>aMg)QZx-g4xwXjDh=RqNUkU;!3o_*?f1mJf=YD7E#qCSt6KO za(H0-$(07s-EN0|>GlT}vmFB?{x*@OEeW&eYsGt1bo#iW>zEL<`qife6pd{ zSwAOMHkdjs_z&+K3^FPnEW^nk7-ONW&FY_Fnc{Q8IK$lttXfFWJjm;C&**VC>q zUhB29KQW1C2=!_HFhiIq^!{^K+q=F8?o-8k$iV$(2Q@%5mB13gcn0#VMZK84i1gf4 z$1+NIxHb^}N(YG?FT~=)Z9!__F7S|-u85W%M5o@mn3HaUmSg9Cd+)1ha2bz9mTqUt zpMU0h+WEz6Y1}dMAaWxE^f?aDalp*gbU=URT8a23S*xBp1%_B@O9N*1Q2>-y9`Q`P z#KZ#!dfp=)0<-}8%7zzPmeEV0FAC94Y8m~J_r~K7MT5`nV3Oo%Nubtm? zJWY7*941ckeS~qB3I>7@M^*Qqb9hYKx%C$e?Dpl!O+^L+nplj7DMG`AXJwbjF&^TW zf?38M>h-j{MinARzE7Jo?;`_E&Y|bChVcY{m%j5m!2_WE`i>W!MJN6F*9R7L3+2KG zuX_hged}{xJG-4JJl$QvA&vS>J6@R7XlMp>>NTcL^{<50I zj`)?|Tqs!W+sDqJxnq*}=P6 z;y%N$zJsV*dN954t9LC*4yRu9QU!hZgguLMC>uB6d4L8LdCQ`zC zzU6yWJcy0gP+;NJ{jWZBz{svJnI}?mdI}pJC6}_PWuFm{u_hr7i#tZt%%ogAQi>RP zLI&2Ppu9+vHD!5`sr1}6C=C)F9k;>bJV=iKYMwoeQ{z5Bbc>fp>Dkx*F|9uTEej6R z+yD9t^w7tDoyNy|VgY~3Y{1MQ%MD)tj9g~`8UrEKul_4w=t6Kd&}cvgLL?(%?L?ML zus5@y6|fc7E1Mo6SHjI@07!N~XjB5wpf|F>Fg(KtCNaa|F2PLzeDgc4PI5Jmx&@f<3x%fISy^|P?(9(tJpG? z(IPvPefZ&xlQZU$O`&eA+%M8A+oqC9ttmj<`BKzHYE~bn&SPNfXRE5p55Rbg!rf>7 zWj1ks$)%jU;sAzru5`9r(`+|Nj&7Ju?Di^}nIW3#R`j#6!|3UM{MYo{=RS9Tz-wz8 z9GEx1>s%V2c3=*>xp^iqoc)Y1+6>DT{8{?ZuMZAr*O|>=6j6q93UsgiN;2VCdPu6n{W&g*AZw&Pk%?I4sr>O z27`r5oZ(=Go^`ih{$T;sjdVbk!ZwEQB=q8Fkjuq17`N3aUElw zn#L1wYnq&>e3UKLO8N3F!!qgx*9CTtz>W)-d@kBAD{WTb&AJp`m*|^Q2hxo@o<`kn zm&V4%=;I&%IKApsuiEdJde?WqO+WqMMKn77h~HMluW55TW@d)o`qsD7yWjn8 zI^ci3m zIHBZ?OoWNam=qZ{K_cqun&@Y<6ZH12FGyf!Kr^_frlx51>ecl5&wrkt{`99mWW zPd<7qeRJ=@ab;d$X#UUL;xx6BAP(40g1qNF?-{h0p3v(YEC2k<|CN6J+3RRxtQ(HN zMV-u|r#Jd#6^? zhju(KftdjumYoJ*^Jfm&PJ$eM_~BkxUwGk#{l@hP`+nzlzfJ%8v3F4Y@Q=dwDZk?c z-qXz|@B>S87Q+ex2ay@rSP5vc&eK9!ih_&|Q#zF=-I)Oscnavv0=(ur2ja8GFWf&JnazxW9Qu70os^22|AJ?;M9T{JNfR?IPw{X0>7;Mb%--I7rL zJY_UoV!=~$v*KY;sgZ=leXlq$_I#f}sR)etg}}N30!Nfcmg#zaJQh&-2zSM@z{Zmk z{n*p0oCQWpgA_n3w7e=m83Qy3i$PB&^6x=*d~@nh`sB{z6AQC;W&op>M#kpf8Q9Nx z&U5IRxBn`g`TC2VFkm|%Z~61TCo5X9G_tW^N#zB6Yg-PcN!9EF z8#Nm z-cDv`-Riv&8eM%9Ej#69wBoE^rpf1=MB`68au__A*Sa9jgZO)Q(T+QACAU?|1$kp* z4#+$i5@5u^odd34j}gyr=A9-I$iU2)$rvC#S87xMbm-mwxe<+#6c>Ud=$q$lu63QU zYPr+KP0q2Io`!%gt35NIKH~!ct8dbE6zDfRNqoM*ZP+u|EY`v`A{d~?;`G8LBD(As zft}OSBaji`3}mgPk-3lV?500F;Qz)+n|Q!_Tnsfk+oA5PqY0w1ryWI0jz5`}9RC6u zf7($re#BAUrpJ%Sf!^J@ou>co$JBjv8@ZI*%!5Csz5jfV2e1R;=xEmiIRMwKuV~m9 zfr>2b0Uy_5_@IxcuXz?w%ZwpXbQY+q`_5h&(8233{J2M?GOeI8FUbZ?-uO2fOC7Qk ztCrVv-~l{i2c(%Wsn5`Z7bd1avjkw%Ex^oRrlDZxy7o@-T0PU$K(guABwehouIZb5 z52rtf?92e>L)Dpe`E$+AT9SNbEE|zhu?zK=1g4P+=Qb zSmhHWP&}t3jy<=$(+Shko@G5~ga7wui~F-M8aCF_K?ZvEb^hth!g>o;BFTMoEY*E4 zcYtntyC#6G*uDIok&;9EVNd4udtUbL)gr zNun5?Q37-{hRe2|PCx4gb`FcS!fB;?1tK!B#oVtL+d}VMx(TM#!yZPz?mAY>C;igw zWV2XmkfGu%Lt;};c+J6xnrS`o{Zw@Tyk~DL zzjet^=&h4Kjk{oiY(P-+)-Mn4bO;cy&u%(GKVEqH_y@~^Fysw@HTycCN^LA(SF9yQ zqMtbgevb+Z^j)lJB6{7zXEl=IN+61sHTX<`hljSd!LGnn1YhjsSSx)uKj8wjFi_Dma> zrv~haYxr;WrofYC)(4q6$q&@LDY!F09?=@cy-A=k4<0gVDq__#qL%a z24>wfbLT!k2OSe<}w3xCQ1mJu5T@Q~)b)$Q~_IxGvfVvY=IWtKP66Xq+zHdOAJS zTOtC%tOT9ni+?k)c(^el000cYNklZD|3t5zc&L#RXngLZCel;L0SM6Ki2ZXpp`qT z@1GeNT6DA!zHpzU=~V|*bjXT0Dbmk;1QW;Jv=~x6qI8&z@vx$_P#{P95eAF0A^x5j zV!U}^fY)@*j+5x#nN`K!Y17htlVj&kulz18t7awVuvP|eC%K^rY7n`Bl|(tgpG%M{ z5JwD$zQy*{6F;M?mi?2t zYz3=rgSOGr1N3UDYXWa#+(v?=j}&_G&oqq2K8k+8+}H0tpud0S^0idcM@1n@dWI>b z0JK#H)O5&7w;B$8p0;5nBXXsZbfC~VgMv9Ap-;OtV5N6y97c;5K*Pk`c4{tXRw7hX zoo<_6O@HucShtaSt53Zx#{T?)|3IrdQ@#k%vx*zi1@^+%@O81<@;Jl_=zJlC37-+W)d* zBb_|9eV`%E?5}W_=9!@wHC{Z_JphE4xMZ>5Lga z$e?pkEHSeWQnw5vJedz?d1%(+XESSi4-)5on+n=bPxaPJ2nJ$NRw_-w0GZzKGPmtr zO@9!x8*Mq}wytu);1>@3&LF)huCWvzUyxWEND1G|Btn|UQU4CzNaKcHhhARYefFwV zqurUUV%#dXON40kfpy$`swg>WOXdGF8D?}Xg4AE1Yd5oTN!~Dsaox4jvZ(-kGgn)e zMX;J)-;yHMg_6~s+_*<&H#8$-;AhqD^-F$A?_BmT^D)*7qKv9XFZ77~{!5pN5pwG< z4m;3&(*m{<4WyFdFP1#95gR`>G^)N{RLj<$jfO6K&)!6Qt>sLqZ2nxyq-fu}dLwk< z)|Z;PxTKY>F8Ta{-=Wo=y$b@2^U=tO^>N|z_g^x(k*exsFEI|RY5CGPGNy}1dDKdtbJ6-Pj0S^2|fy`4%j+l15d7ttTAJ_^O4% zGySYK7%+SKe=Su95<#e*7Aa6<q&MW%F&g1E}snsbUWFYsG7+Cyo zE&YG=hRJ_jC}5m>J1hG7#MkHo4~Na?PF{J~O8TTf?@cR>e#Di)hwSNxP$o@Fsx0K?BLF|sl;Gk45oD9wvH-6}rC5IQC>m^&KW-%Po5-E-#z=*8^D(16}Pv7Y=4 z765w5IwHEHI5~n^HEC*o@21!EJ>$SEh7+2Y)$lu zozEpVYu2n^>vGak*Bk7L zXG*iy>AQ1fz^zvz*krGwPGAHebFJUG{S^9_+2wP>&)*z;=bY|eXg60xmyNF{N5~?D zKvQp?+(uNdlnbK^=Q0a&#c5yA)@JGryW8~hQmXjB${B@x5w{vnUr$RiD8!=8`mfYI znZwaH)U>M}rPu%BC3C{lNu%576D#kTQyB~F<|H>VKu^DU;)c4W_ck3O1g*rsNEBG^ zyI*=l%MDG5@&0~N0_AbvI%!FS*@_&XBEU^SsYTtPT(`6PsvT?Qgr~PnZlbp>-8`o< z7Szo(-8^v%UCM11sfs-pFFCr?>pc*@)RCScJD5HF<<{ZlR^X?C#T+$YPu8`@8cJNZ z$ib*7YoZaElN*IVujplRgI&Mp>GUVNpEV~uE$Zjty3b8_k8hxjCZOGiQx}bg;INHg z2iCv!=wsi~btpY>flsm+8@#2Wbx^|76#3w0`e1h8q!e_42t>@_rw z1rU1xwdgk3JK;LAX_ijY&VxaVC;5Ta<;zVFs{l|)ZOc&lWo6nsdpE32Ar9KVIGw3=T8w7YofO`|S)Jh{nW^vis}BT#nZqN0?MP|Gn}@dN-Y$%&G2 z2$nCW+~$f6w`6qfqbJU(m_J$hk96$lt~r&l0B+tq-lH|u2HG|>pr_w7wx*`~?)->K zWo?IfA?8| zp!VynrR;s<*p*dPe=>nOtuO-#f@!?gGdbL&tPBIZ#VTQ01(O1QmLAp{Y+573{yjJ3 z6?0A5?d$%*A*=aRzuYeoZEHlU#jM z=|08iqFVFI#HALmef0VCchiULGhh~{y!&(=EI^twpz8~0)$~~B4yvn@MPWEA=f40+ zU}Y#WmKBNWxUxiPYoRjmeS{J415fhoGu8&WajrS&#gtuZH{Ubfqq9r8c__(|xX*!l zq;rScdnj^wW?By>SF(B*n736%w`u2sejW&h^LNqPwuW6Q`}(uE2D;dD1B027Fz^_7 zrgorqnGbCiSthJ4hpZlnc*R{HiS-Ar;uCh^Tqji)bI|6{4F%?*0qsSF2X&Q$TCPNu zdkTGBnYC5sAx(%3`M#AW47&D%&v`_h89!wGu3Gkg=$s`F4SCmoefiK}-X}mepzhp2 z6sN~a{hIR6{;uYfzj>Z=eliT}BB1AS6e{}qc$Y36L^JEB4wU66Rdw$h=*o(!PbLCp z+-7p5pZs`yG7D#}rnUPbG3Hfr=)(3~Ku32*=mx6k{JAypsde`vp!aRO+!D~bN0(Zw=Ju^bwMlkg z3(0`}MmoFd`BQA>7W&Uug&yN_76Cn62YVoQXzg6(h4s{VlN?szp0O)hOBG!}MDBgE z`{mCfpa&Y(?Nrl-s-_!o58yy|4sp?A3TUjy^c(2Xx~8-DM{q9!x`?>#RM8z(O&i8~ zv|&CpazAW8Zh#ixcA1e5T|gDBp_<&j|D*a<^vV4FBB0agY^I7fQcW9s9lGPOkQDuJ z@Pq)`s+3Frbw_Dcu_Ef|2$bW`F;-Q?KL&W1h}!NYT85(qYO#lD@07*qoM6N<$f=>1|>Hq)$ From 4a0ba2bbaa5c58bcf0ef12e9b314e61c35a6b543 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 14 Feb 2021 12:54:35 -0600 Subject: [PATCH 07/46] Fixed build issues --- Slide for Reddit.xcodeproj/project.pbxproj | 23 ++++---- Slide for Reddit/AnyModalViewController.swift | 6 ++- Slide for Reddit/ToolbarTextView.swift | 53 +++++++++---------- .../VideoMediaViewController.swift | 4 +- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index 8d2dfa067..0ef1444a3 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -78,7 +78,7 @@ BE02B253240C9F5400C457BC /* CommentsRowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE02B252240C9F5400C457BC /* CommentsRowController.swift */; }; BE02B255240CAC5D00C457BC /* CommentRepliesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE02B254240CAC5D00C457BC /* CommentRepliesController.swift */; }; BE0334AF25294B8400B8C6B6 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0334AE25294B8400B8C6B6 /* IntentHandler.swift */; }; - BE0334B325294B8400B8C6B6 /* WidgetConfigIntent.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE0334AC25294B8400B8C6B6 /* WidgetConfigIntent.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + BE0334B325294B8400B8C6B6 /* WidgetConfigIntent.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE0334AC25294B8400B8C6B6 /* WidgetConfigIntent.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BE0334CF25294C0700B8C6B6 /* TimelineSubreddit.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = BED90FF4250C1FB300090DF5 /* TimelineSubreddit.intentdefinition */; }; BE03351225294CEE00B8C6B6 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0334AE25294B8400B8C6B6 /* IntentHandler.swift */; }; BE03356725295AB500B8C6B6 /* SettingsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE03356625295AB500B8C6B6 /* SettingsWidget.swift */; }; @@ -178,7 +178,7 @@ BE257A6E21F64AA30082A47E /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BE257A6D21F64AA30082A47E /* Media.xcassets */; }; BE257A7021F64AA30082A47E /* ActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE257A6F21F64AA30082A47E /* ActionViewController.swift */; }; BE257A7321F64AA30082A47E /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BE257A7121F64AA30082A47E /* MainInterface.storyboard */; }; - BE257A7721F64AA30082A47E /* Open in Slide.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE257A6B21F64AA30082A47E /* Open in Slide.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + BE257A7721F64AA30082A47E /* Open in Slide.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE257A6B21F64AA30082A47E /* Open in Slide.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BE257A7D21F8D9710082A47E /* SettingsThemeChooser.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE257A7C21F8D9710082A47E /* SettingsThemeChooser.swift */; }; BE25CAD424C3A28300736CA5 /* SwipeForwardNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE25CAD324C3A28300736CA5 /* SwipeForwardNavigationController.swift */; }; BE25CAD624C3A65400736CA5 /* SwipeForwardAnimatedTransitioning.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE25CAD524C3A65400736CA5 /* SwipeForwardAnimatedTransitioning.swift */; }; @@ -365,7 +365,7 @@ BEBF45DB1E23383D00764BB8 /* seen.plist in Resources */ = {isa = PBXBuildFile; fileRef = BEBF45DA1E23383D00764BB8 /* seen.plist */; }; BEBF45DD1E23384500764BB8 /* comments.plist in Resources */ = {isa = PBXBuildFile; fileRef = BEBF45DC1E23384500764BB8 /* comments.plist */; }; BEBF45E11E23EED800764BB8 /* SettingValues.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEBF45E01E23EED800764BB8 /* SettingValues.swift */; }; - BEC2AB3A250D8D2C00AD5BEA /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED90FE0250BF71600090DF5 /* WidgetKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + BEC2AB3A250D8D2C00AD5BEA /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED90FE0250BF71600090DF5 /* WidgetKit.framework */; platformFilter = ios; settings = {ATTRIBUTES = (Weak, ); }; }; BEC2FE19235BA2B100374013 /* adaway.json in Resources */ = {isa = PBXBuildFile; fileRef = BEC2FE18235BA2B100374013 /* adaway.json */; }; BEC494281E307D57006618F3 /* GalleryTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEC494271E307D57006618F3 /* GalleryTableViewController.swift */; }; BEC4942A1E307DDA006618F3 /* GalleryCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEC494291E307DDA006618F3 /* GalleryCellView.swift */; }; @@ -393,7 +393,7 @@ BED90FE3250BF71600090DF5 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED90FE2250BF71600090DF5 /* SwiftUI.framework */; }; BED90FE6250BF71600090DF5 /* SlideWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = BED90FE5250BF71600090DF5 /* SlideWidgets.swift */; }; BED90FE8250BF71800090DF5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BED90FE7250BF71800090DF5 /* Assets.xcassets */; }; - BED90FEC250BF71800090DF5 /* Slide Widgets.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BED90FDF250BF71600090DF5 /* Slide Widgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + BED90FEC250BF71800090DF5 /* Slide Widgets.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BED90FDF250BF71600090DF5 /* Slide Widgets.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BED90FF5250C1FB300090DF5 /* TimelineSubreddit.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = BED90FF4250C1FB300090DF5 /* TimelineSubreddit.intentdefinition */; }; BED90FF6250C1FB300090DF5 /* TimelineSubreddit.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = BED90FF4250C1FB300090DF5 /* TimelineSubreddit.intentdefinition */; }; BEDDA9911E19AB5D003CD6C3 /* WebsiteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEDDA9901E19AB5D003CD6C3 /* WebsiteViewController.swift */; }; @@ -2725,6 +2725,7 @@ /* Begin PBXTargetDependency section */ BE0334B225294B8400B8C6B6 /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BE0334AB25294B8400B8C6B6 /* WidgetConfigIntent */; targetProxy = BE0334B125294B8400B8C6B6 /* PBXContainerItemProxy */; }; @@ -2741,6 +2742,7 @@ }; BE257A7621F64AA30082A47E /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BE257A6A21F64AA30082A47E /* Open in Slide */; targetProxy = BE257A7521F64AA30082A47E /* PBXContainerItemProxy */; }; @@ -2761,6 +2763,7 @@ }; BED90FEB250BF71800090DF5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BED90FDE250BF71600090DF5 /* Slide Widgets */; targetProxy = BED90FEA250BF71800090DF5 /* PBXContainerItemProxy */; }; @@ -2822,7 +2825,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).WidgetConfigIntent"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2856,7 +2859,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgetconfigintent"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3035,7 +3038,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).Open-in-Slide"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3069,7 +3072,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledOpen-in-Slide"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3448,7 +3451,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).widgets"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3484,7 +3487,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgets 1599951103"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/Slide for Reddit/AnyModalViewController.swift b/Slide for Reddit/AnyModalViewController.swift index 68504de85..4004eada5 100644 --- a/Slide for Reddit/AnyModalViewController.swift +++ b/Slide for Reddit/AnyModalViewController.swift @@ -8,7 +8,11 @@ import Anchorage import AVKit -import SubtleVolume + +#if os(iOS) + import SubtleVolume +#endif + import Then import UIKit diff --git a/Slide for Reddit/ToolbarTextView.swift b/Slide for Reddit/ToolbarTextView.swift index 28a58a289..af272dbf1 100644 --- a/Slide for Reddit/ToolbarTextView.swift +++ b/Slide for Reddit/ToolbarTextView.swift @@ -470,7 +470,7 @@ public class ToolbarTextView: NSObject { }) if results.count > 1 { - Alamofire.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + AF.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) .responseJSON { response in print(response) if let status = response.response?.statusCode { @@ -639,42 +639,41 @@ public class ToolbarTextView: NSObject { return } - Alamofire.upload(multipartFormData: { (multipartFormData) in + AF.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(data, withName: "image", fileName: UUID().uuidString + ".jpeg", mimeType: "image/jpg") + if !album.isEmpty { multipartFormData.append(album.data(using: .utf8)!, withName: "album") } - }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"], encodingCompletion: { (encodingResult) in - switch encodingResult { - case .success(let upload, _, _): - print("Success") - upload.uploadProgress { progress in - DispatchQueue.main.async { - print(progress.fractionCompleted) - self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) - } - } - upload.responseJSON { response in - if let val = response.value { - let json = JSON(val) - debugPrint(response) - let link = json["data"]["link"].stringValue - if link.isEmpty { - if json["data"]["error"].stringValue != "" { - tryUploadWithSize(size: size - 0.1) - return - } - } - print("Link is \(link)") - if count == results.count { - completion(link, true) + }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + .uploadProgress(closure: { (progress) in + DispatchQueue.main.async { + print(progress.fractionCompleted) + self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) + } + }) + .responseJSON { (response) in + switch response.result { + case .success(let result): + if let val = response.value { + let json = JSON(val) + debugPrint(response) + let link = json["data"]["link"].stringValue + if link.isEmpty { + if json["data"]["error"].stringValue != "" { + tryUploadWithSize(size: size - 0.1) + return } } + print("Link is \(link)") + if count == results.count { + completion(link, true) + } } case .failure: completion("Failure", false) } - }) + } } tryUploadWithSize(size: 1) diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 8c77d6541..8966ea01b 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -11,7 +11,9 @@ import Anchorage import AVFoundation import SDCAlertView import SDWebImage -import SubtleVolume +#if os(iOS) + import SubtleVolume +#endif import Then import UIKit From 7d1098663a7cc0b8fec2ec248e74aeff44807e86 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 14 Feb 2021 13:27:11 -0600 Subject: [PATCH 08/46] Fixed multi-column mode --- Slide for Reddit/AppDelegate.swift | 8 ++++---- Slide for Reddit/WrappingFlowLayout.swift | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index f176f4bb3..a608a0528 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -347,7 +347,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } #if DEBUG - SettingValues.isPro = false + SettingValues.isPro = true UserDefaults.standard.set(true, forKey: SettingValues.pref_pro) UserDefaults.standard.synchronize() UIApplication.shared.isIdleTimerDisabled = true @@ -1198,9 +1198,9 @@ extension AppDelegate: UIWindowSceneDelegate { split.preferredPrimaryColumnWidthFraction = 0.15 split.maximumPrimaryColumnWidth = size.width * 0.15 - split.minimumSupplementaryColumnWidth = size.width * 0.25 - split.maximumSupplementaryColumnWidth = size.width * 0.25 - split.preferredSupplementaryColumnWidthFraction = 0.25 + split.minimumSupplementaryColumnWidth = size.width * 0.6 + split.maximumSupplementaryColumnWidth = size.width * 0.6 + split.preferredSupplementaryColumnWidthFraction = 0.6 } } } diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index a1787f614..c61d96005 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -82,7 +82,6 @@ class WrappingFlowLayout: UICollectionViewLayout { numberOfColumns = SettingValues.galleryCount } - numberOfColumns = 1 cellPadding = (numberOfColumns > 1 && (SettingValues.postViewMode != .LIST) && (SettingValues.postViewMode != .COMPACT)) ? CGFloat(3) : ((SettingValues.postViewMode == .LIST) ? CGFloat(1) : CGFloat(0)) prepare() } From 5962059b64a3e87a044d7946446c35fdd9869f7e Mon Sep 17 00:00:00 2001 From: ccrama Date: Mon, 15 Feb 2021 19:47:25 -0600 Subject: [PATCH 09/46] Use event system for Settings changes --- Slide for Reddit/AccountController.swift | 2 - Slide for Reddit/AppDelegate.swift | 1 + Slide for Reddit/CacheSettings.swift | 2 - Slide for Reddit/MainViewController.swift | 2 - .../NavigationHomeViewController.swift | 11 +++- Slide for Reddit/SettingsBackup.swift | 3 - Slide for Reddit/SettingsCustomTheme.swift | 10 +-- Slide for Reddit/SettingsDonate.swift | 3 - Slide for Reddit/SettingsFont.swift | 6 +- Slide for Reddit/SettingsGeneral.swift | 7 +- Slide for Reddit/SettingsGestures.swift | 33 ++++++---- Slide for Reddit/SettingsLayout.swift | 45 ++++++++----- Slide for Reddit/SettingsTheme.swift | 66 +++++++++++++------ Slide for Reddit/SettingsViewController.swift | 4 +- Slide for Reddit/SettingsViewMode.swift | 16 +++-- .../SingleSubredditViewController.swift | 22 ++++++- .../SplitMainViewController.swift | 57 ++++++++-------- .../SubredditReorderViewController.swift | 13 +++- .../SubredditThemeViewController.swift | 2 - Slide for Reddit/Subscriptions.swift | 8 ++- Slide for Reddit/ThreadViewController.swift | 39 ++++++----- 21 files changed, 220 insertions(+), 132 deletions(-) diff --git a/Slide for Reddit/AccountController.swift b/Slide for Reddit/AccountController.swift index e2866adeb..a80324b3c 100644 --- a/Slide for Reddit/AccountController.swift +++ b/Slide for Reddit/AccountController.swift @@ -22,7 +22,6 @@ class AccountController { } static func switchAccount(name: String) { - changed = true ActionStates.upVotedFullnames.removeAll() ActionStates.downVotedFullnames.removeAll() ActionStates.savedFullnames.removeAll() @@ -36,7 +35,6 @@ class AccountController { static var isLoggedIn = false static var isGold = false - static var changed = false static var modSubs: [String] = [] static var current: Account? diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index a608a0528..20f26915e 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -509,6 +509,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.presentsWithGesture = true if UIApplication.shared.isMac() { + splitViewController.presentsWithGesture = false setupSplitPaneLayout(splitViewController) } else { // Set display mode and split behavior diff --git a/Slide for Reddit/CacheSettings.swift b/Slide for Reddit/CacheSettings.swift index a8071b55f..fc4e5cee4 100644 --- a/Slide for Reddit/CacheSettings.swift +++ b/Slide for Reddit/CacheSettings.swift @@ -79,8 +79,6 @@ class CacheSettings: BubbleSettingTableViewController { var delete = UIButton() - public static var changed = false - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return indexPath.section == 0 ? 80 : 60 } diff --git a/Slide for Reddit/MainViewController.swift b/Slide for Reddit/MainViewController.swift index 04f874bd7..1cf81c131 100644 --- a/Slide for Reddit/MainViewController.swift +++ b/Slide for Reddit/MainViewController.swift @@ -32,8 +32,6 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe var isReload = false var readLaterBadge: BadgeSwift? public static var current: String = "" - public static var needsRestart = false - public static var needsReTheme = false public var toolbar: UIView? var tabBar: SubredditPagingTitleCollectionView! var subs: UIView? diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 21d25b439..a99464ad5 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -112,7 +112,8 @@ class NavigationHomeViewController: UIViewController { updateAccessibility() searchBar.isUserInteractionEnabled = true NotificationCenter.default.addObserver(self, selector: #selector(onThemeChanged), name: .onThemeChanged, object: nil) - + NotificationCenter.default.addObserver(self, selector: #selector(onSubredditOrderChanged), name: .subredditOrderChanged, object: nil) + /*if let sectionIndex = tableView.sectionIndexView, let nav = (navigationController as? SwipeForwardNavigationController) { //DISABLE for now NavigationHomeViewController.edgeGesture = UIScreenEdgePanGestureRecognizer(target: nav, action: #selector(nav.handleRightSwipe(_:))) NavigationHomeViewController.edgeGesture!.edges = UIRectEdge.right @@ -125,6 +126,11 @@ class NavigationHomeViewController: UIViewController { doViews() } + @objc func onSubredditOrderChanged() { + subsSource.reload() + self.tableView.reloadData() + } + func doViews() { tableView = UITableView(frame: CGRect.zero, style: .grouped) tableView.backgroundColor = UIColor.foregroundColor @@ -671,6 +677,7 @@ extension NavigationHomeViewController: UISearchBarDelegate { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.tableView.resignFirstResponder() self.searchBar.becomeFirstResponder() } } @@ -697,6 +704,7 @@ extension NavigationHomeViewController: UISearchBarDelegate { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.tableView.resignFirstResponder() self.searchBar.becomeFirstResponder() } case .failure(let error): @@ -704,7 +712,6 @@ extension NavigationHomeViewController: UISearchBarDelegate { } }) } - } func searchTableList() { diff --git a/Slide for Reddit/SettingsBackup.swift b/Slide for Reddit/SettingsBackup.swift index 98b95c5b5..5f55ed578 100644 --- a/Slide for Reddit/SettingsBackup.swift +++ b/Slide for Reddit/SettingsBackup.swift @@ -14,9 +14,6 @@ import SDWebImage import UIKit class SettingsBackup: BubbleSettingTableViewController { - - static var changed = false - var restore: UITableViewCell = InsetCell(style: .subtitle, reuseIdentifier: nil) var backup: UITableViewCell = InsetCell(style: .subtitle, reuseIdentifier: nil) diff --git a/Slide for Reddit/SettingsCustomTheme.swift b/Slide for Reddit/SettingsCustomTheme.swift index 11aa7c4cd..fce15d7c9 100644 --- a/Slide for Reddit/SettingsCustomTheme.swift +++ b/Slide for Reddit/SettingsCustomTheme.swift @@ -147,7 +147,8 @@ class SettingsCustomTheme: UITableViewController { colorString += (self.foregroundColor.toHexString() + self.backgroundColor.toHexString() + self.fontColor.toHexString() + self.navIconColor.toHexString() + ColorUtil.baseColor.toHexString() + ColorUtil.baseAccent.toHexString() + "#" + String(self.statusbarEnabled)).addPercentEncoding UserDefaults.standard.set(colorString, forKey: "Theme+" + (self.themeText ?? today_string)) UserDefaults.standard.synchronize() - SettingsTheme.needsRestart = true + + NotificationCenter.default.post(name: .settingsThemeNeedsRestart, object: nil) ColorUtil.initializeThemes() self.dismiss(animated: true, completion: nil) @@ -171,10 +172,11 @@ class SettingsCustomTheme: UITableViewController { UserDefaults.standard.synchronize() if isCurrentTheme { _ = ColorUtil.doInit() - MainViewController.needsReTheme = true } ColorUtil.initializeThemes() - SettingsTheme.needsRestart = true + + NotificationCenter.default.post(name: .settingsThemeNeedsRestart, object: nil) + self.delegate?.themeSaved() self.dismiss(animated: true, completion: nil) } @@ -301,7 +303,7 @@ class SettingsCustomTheme: UITableViewController { } override func viewWillDisappear(_ animated: Bool) { - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { diff --git a/Slide for Reddit/SettingsDonate.swift b/Slide for Reddit/SettingsDonate.swift index 800c09325..4f187728c 100644 --- a/Slide for Reddit/SettingsDonate.swift +++ b/Slide for Reddit/SettingsDonate.swift @@ -16,9 +16,6 @@ import SDWebImage import UIKit class SettingsDonate: UIViewController, MFMailComposeViewControllerDelegate { - - static var changed = false - override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) } diff --git a/Slide for Reddit/SettingsFont.swift b/Slide for Reddit/SettingsFont.swift index 3f2083f0b..daf416fb9 100644 --- a/Slide for Reddit/SettingsFont.swift +++ b/Slide for Reddit/SettingsFont.swift @@ -77,7 +77,9 @@ class SettingsFont: BubbleSettingTableViewController { SettingValues.postFontOffset = size UserDefaults.standard.set(size, forKey: SettingValues.pref_postFontSize) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) + CachedTitle.titleFont = FontGenerator.fontOfSize(size: CachedTitle.baseFontSize, submission: true) FontGenerator.initialize() refresh() @@ -500,7 +502,7 @@ extension SettingsFont { CachedTitle.titleFont = FontGenerator.fontOfSize(size: 18, submission: true) CachedTitle.titleFontSmall = FontGenerator.fontOfSize(size: 14, submission: true) SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) if let nav = self.navigationController as? SwipeForwardNavigationController { nav.fullWidthBackGestureRecognizer.isEnabled = true } diff --git a/Slide for Reddit/SettingsGeneral.swift b/Slide for Reddit/SettingsGeneral.swift index 13b934e74..976d4959c 100644 --- a/Slide for Reddit/SettingsGeneral.swift +++ b/Slide for Reddit/SettingsGeneral.swift @@ -79,7 +79,7 @@ class SettingsGeneral: BubbleSettingTableViewController { @objc func switchIsChanged(_ changed: UISwitch) { if changed == showPagesSwitch { - MainViewController.needsRestart = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) SettingValues.showPages = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_showPages) } else if changed == autoKeyboardSwitch { @@ -100,7 +100,8 @@ class SettingsGeneral: BubbleSettingTableViewController { } else if changed == hideFABSwitch { SettingValues.hiddenFAB = !changed.isOn UserDefaults.standard.set(!changed.isOn, forKey: SettingValues.pref_hiddenFAB) - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) doDisables() } else if changed == hapticFeedback { SettingValues.hapticFeedback = !changed.isOn @@ -136,7 +137,7 @@ class SettingsGeneral: BubbleSettingTableViewController { } else if changed == pinToolbarSwitch { SettingValues.dontHideTopBar = !changed.isOn UserDefaults.standard.set(!changed.isOn, forKey: SettingValues.pref_pinToolbar) - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .tabBarsChanged, object: nil) if SettingValues.dontHideTopBar { self.totallyCollapse.contentView.alpha = 0.5 self.totallyCollapse.isUserInteractionEnabled = false diff --git a/Slide for Reddit/SettingsGestures.swift b/Slide for Reddit/SettingsGestures.swift index 9542aa80e..c2c9dd4b4 100644 --- a/Slide for Reddit/SettingsGestures.swift +++ b/Slide for Reddit/SettingsGestures.swift @@ -42,7 +42,8 @@ class SettingsGestures: BubbleSettingTableViewController { if changed == disableBanner { SettingValues.disableBanner = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_disableBanner) - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } UserDefaults.standard.synchronize() @@ -61,8 +62,8 @@ class SettingsGestures: BubbleSettingTableViewController { UserDefaults.standard.synchronize() self.commentGesturesCell.detailTextLabel?.text = SettingValues.commentGesturesMode.description() self.updateCells() - SplitMainViewController.needsReTheme = true - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } } alertController.show(self) @@ -80,8 +81,8 @@ class SettingsGestures: BubbleSettingTableViewController { UserDefaults.standard.synchronize() self.submissionGesturesCell.detailTextLabel?.text = SettingValues.submissionGestureMode.description() self.updateCells() - SplitMainViewController.needsReTheme = true - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } } alertController.show(self) @@ -168,7 +169,7 @@ class SettingsGestures: BubbleSettingTableViewController { UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_submissionActionForceTouch) } - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) UserDefaults.standard.synchronize() self.updateCells() } @@ -408,7 +409,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionLeftRight = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionLeftRight) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -418,7 +420,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionLeftLeft = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionLeftLeft) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -428,7 +431,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionRightLeft = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionRightLeft) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -437,7 +441,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionRightRight = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionRightRight) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -446,9 +451,9 @@ public class GesturePreviewCell: InsetCell { self.showActionSub { (action) in SettingValues.submissionActionLeft = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_submissionActionLeft) - SubredditReorderViewController.changed = true UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -457,9 +462,9 @@ public class GesturePreviewCell: InsetCell { self.showActionSub { (action) in SettingValues.submissionActionRight = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_submissionActionRight) - SubredditReorderViewController.changed = true UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) diff --git a/Slide for Reddit/SettingsLayout.swift b/Slide for Reddit/SettingsLayout.swift index 5a91bfe24..e6e1be9e9 100644 --- a/Slide for Reddit/SettingsLayout.swift +++ b/Slide for Reddit/SettingsLayout.swift @@ -222,7 +222,9 @@ class SettingsLayout: BubbleSettingTableViewController { UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_reduceElevation) } SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) + UserDefaults.standard.synchronize() doDisables() doLink() @@ -341,7 +343,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Large card view", icon: UIImage(named: "card")!.menuIcon()) { @@ -353,7 +356,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Centered Image large card view", icon: UIImage(named: "centeredimage")!.menuIcon()) { @@ -365,7 +369,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Compact list view", icon: UIImage(named: "compact")!.menuIcon()) { @@ -377,7 +382,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.show(self) @@ -392,7 +398,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Cropped image", icon: UIImage(named: "crop")!.menuIcon()) { @@ -403,7 +410,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Shortened image", icon: UIImage(named: "crop")!.menuIcon()) { @@ -414,7 +422,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Thumbnail only", icon: UIImage(named: "thumb")!.menuIcon()) { @@ -425,7 +434,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "No image", icon: UIImage(named: "hide")!.menuIcon()) { @@ -436,7 +446,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.show(self) @@ -452,7 +463,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Left aligned button bar", icon: UIImage(sfString: SFSymbol.handPointLeftFill, overrideString: "code")!.menuIcon()) { @@ -464,7 +476,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Vote buttons on left side", icon: UIImage(sfString: SFSymbol.chevronUp, overrideString: "up")!.menuIcon()) { @@ -476,7 +489,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Vote buttons on right side", icon: UIImage(sfString: SFSymbol.chevronDown, overrideString: "down")!.menuIcon()) { @@ -488,8 +502,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Disable buttons", icon: UIImage(sfString: SFSymbol.xmark, overrideString: "hide")!.menuIcon()) { @@ -501,7 +515,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.show(self) diff --git a/Slide for Reddit/SettingsTheme.swift b/Slide for Reddit/SettingsTheme.swift index 08caf88aa..8f7e9228a 100644 --- a/Slide for Reddit/SettingsTheme.swift +++ b/Slide for Reddit/SettingsTheme.swift @@ -157,6 +157,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { super.viewDidLoad() redoThemes() self.tableView.register(ThemeCellView.classForCoder(), forCellReuseIdentifier: "theme") + NotificationCenter.default.addObserver(self, selector: #selector(onSettingsThemeNeedsRestart), name: .settingsThemeNeedsRestart, object: nil) } func pickAccent() { @@ -242,17 +243,20 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { } var doneOnce = false - static var needsRestart = false + + @objc func onSettingsThemeNeedsRestart() { + self.setupViews() + self.redoThemes() + self.tochange!.doCells() + self.tochange!.tableView.reloadData() + self.tableView.reloadData() + } + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) setupBaseBarColors() - if doneOnce || SettingsTheme.needsRestart { - SettingsTheme.needsRestart = false - self.setupViews() - self.redoThemes() - self.tochange!.doCells() - self.tochange!.tableView.reloadData() - self.tableView.reloadData() + if doneOnce { + onSettingsThemeNeedsRestart() } else { doneOnce = true } @@ -380,15 +384,10 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { var themeText: String? @objc func switchIsChanged(_ changed: UISwitch) { - if changed == reduceColor { - MainViewController.needsReTheme = true - SettingValues.reduceColor = changed.isOn - UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_reduceColor) - } else if changed == tintOutsideSwitch { + if changed == tintOutsideSwitch { SettingValues.onlyTintOutside = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_onlyTintOutside) } else if changed == reduceColor { - MainViewController.needsReTheme = true SettingValues.reduceColor = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_reduceColor) setupBaseBarColors() @@ -401,12 +400,18 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { let barButton = UIBarButtonItem.init(customView: button) navigationItem.leftBarButtonItem = barButton + + NotificationCenter.default.post(name: .reduceColorChanged, object: nil) } else if changed == nightEnabled { SettingValues.nightModeEnabled = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_nightMode) _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.tochange!.doCells() self.tochange!.tableView.reloadData() } @@ -511,7 +516,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { UserDefaults.standard.synchronize() _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tableView.reloadData() self.tochange!.doCells() @@ -553,7 +562,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -601,7 +614,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -628,7 +645,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { _ = ColorUtil.doInit() self.setupViews() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.tableView.reloadData() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -770,11 +791,14 @@ final public class PickerViewViewControllerColored: UIViewController { extension SettingsTheme: SettingsCustomThemeDelegate { func themeSaved() { - SettingsTheme.needsRestart = false _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() diff --git a/Slide for Reddit/SettingsViewController.swift b/Slide for Reddit/SettingsViewController.swift index 4d560201a..8b90a5fc9 100644 --- a/Slide for Reddit/SettingsViewController.swift +++ b/Slide for Reddit/SettingsViewController.swift @@ -482,7 +482,7 @@ class SettingsViewController: MediaTableViewController, MFMailComposeViewControl } } else if changed == subIcons { SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) SettingValues.subredditIcons = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_subredditIcons) @@ -712,7 +712,7 @@ class SettingsViewController: MediaTableViewController, MFMailComposeViewControl UserDefaults.standard.synchronize() self.autoPlayCell.detailTextLabel?.text = SettingValues.autoPlayMode.description() + "\nAutoPlaying videos can lead to more data use" SingleSubredditViewController.cellVersion += 1 - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } } alertController.show(self) diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index f9507b1ce..a880267d3 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -51,7 +51,7 @@ class SettingsViewMode: BubbleSettingTableViewController { @objc func switchIsChanged(_ changed: UISwitch) { if changed == subredditBarSwitch { - MainViewController.needsRestart = true + NotificationCenter.default.post(name: .tabBarsChanged, object: nil) SettingValues.fullWidthHeaderCells = !changed.isOn UserDefaults.standard.set(!changed.isOn, forKey: SettingValues.pref_fullWidthHeaderCells) } else if changed == thireenPopupSwitch { @@ -286,7 +286,7 @@ class SettingsViewMode: BubbleSettingTableViewController { showPortraitMultiColumn() } - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) UserDefaults.standard.synchronize() setSelected() } @@ -300,7 +300,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.multiColumnCount = value UserDefaults.standard.set(value, forKey: SettingValues.pref_multiColumnCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() } } @@ -317,7 +318,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.multiColumnCount = chosen.row + 1 UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_multiColumnCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() }) @@ -351,7 +353,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.portraitMultiColumnCount = chosen.row + 1 UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_portraitMultiColumnCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() }) @@ -384,7 +387,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.galleryCount = chosen.row + 1 UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_galleryCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() }) diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 9e5037946..92a08a896 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -192,6 +192,18 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele } } + @objc func cellsNeedReDraw() { + reloadDataReset() + } + + @objc func subNeedsReload() { + swipeBackAdded = false + + reloadDataReset() + setupSwipeGesture() + setupGestures() + } + deinit { NotificationCenter.default.removeObserver(self) } @@ -205,6 +217,9 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele } NotificationCenter.default.addObserver(self, selector: #selector(youTubePlaying), name: .onYouTubeWillStart, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(cellsNeedReDraw), name: .cellsNeedReDraw, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(subNeedsReload), name: .subNeedsReload, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(reduceColorChanged), name: .reduceColorChanged, object: nil) flowLayout.delegate = self self.tableView = UICollectionView(frame: CGRect.zero, collectionViewLayout: flowLayout) @@ -965,6 +980,10 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele } } + @objc func reduceColorChanged() { + reloadNeedingColor() + } + func reloadNeedingColor() { tableView.backgroundColor = UIColor.backgroundColor inHeadView?.backgroundColor = ColorUtil.getColorForSub(sub: sub, true) @@ -2988,7 +3007,8 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { func setupGestures() { if cellGestureRecognizer != nil { - return + cellGestureRecognizer.view?.removeGestureRecognizer(cellGestureRecognizer) + cellGestureRecognizer = nil } cellGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(panCell(_:))) cellGestureRecognizer.delegate = self diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 620b1688a..10d14da36 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -59,6 +59,7 @@ class SplitMainViewController: MainViewController { inHeadView.backgroundColor = .clear } } + override func doProfileIcon() { let account = ExpandedHitButton(type: .custom) let accountImage = UIImage(sfString: SFSymbol.personCropCircle, overrideString: "profile")?.navIcon() @@ -109,7 +110,7 @@ class SplitMainViewController: MainViewController { } override func doButtons() { - if menu.superview != nil && !MainViewController.needsReTheme { + if menu.superview != nil { // What was this for... && !MainViewController.needsReTheme { return } @@ -273,6 +274,10 @@ class SplitMainViewController: MainViewController { NotificationCenter.default.addObserver(self, selector: #selector(autoCacheFinished(_:)), name: .autoCacheFinished, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(autoCacheProgress(_:)), name: .autoCacheProgress, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(subredditOrderDidChange), name: .subredditOrderChanged, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(resetTabBars), name: .tabBarsChanged, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(onThemeChanged), name: .reduceColorChanged, object: nil) + if let splitViewController = splitViewController, (!UIApplication.shared.isSplitOrSlideOver) { (UIApplication.shared.delegate as? AppDelegate)?.setupSplitLayout(splitViewController) } @@ -282,7 +287,7 @@ class SplitMainViewController: MainViewController { @objc func onThemeChanged() { SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + navigationController?.toolbar.barTintColor = UIColor.backgroundColor navigationController?.toolbar.tintColor = UIColor.fontColor self.parent?.navigationController?.toolbar.barTintColor = UIColor.foregroundColor @@ -370,7 +375,6 @@ class SplitMainViewController: MainViewController { setupBaseBarColors(ColorUtil.getColorForSub(sub: getSubredditVC()?.sub ?? "", true)) toolbar?.backgroundColor = UIColor.foregroundColor.add(overlay: UIColor.isLightTheme ? UIColor.black.withAlphaComponent(0.05) : UIColor.white.withAlphaComponent(0.05)) self.doButtons() - MainViewController.needsReTheme = false } var isReappear = false @@ -395,11 +399,8 @@ class SplitMainViewController: MainViewController { } } - if subChanged || SubredditReorderViewController.changed { - finalSubs = [] - finalSubs.append(contentsOf: Subscriptions.pinned) - finalSubs.append(contentsOf: Subscriptions.subreddits.sorted(by: { $0.caseInsensitiveCompare($1) == .orderedAscending }).filter({ return !Subscriptions.pinned.contains($0) })) - redoSubs() + if subChanged { + subredditOrderDidChange() } self.parent?.navigationController?.navigationBar.shadowImage = UIImage() @@ -410,6 +411,13 @@ class SplitMainViewController: MainViewController { setNeedsStatusBarAppearanceUpdate() } + @objc func subredditOrderDidChange() { + finalSubs = [] + finalSubs.append(contentsOf: Subscriptions.pinned) + finalSubs.append(contentsOf: Subscriptions.subreddits.sorted(by: { $0.caseInsensitiveCompare($1) == .orderedAscending }).filter({ return !Subscriptions.pinned.contains($0) })) + redoSubs() + } + override func viewWillAppear(_ animated: Bool) { if navToMux == nil { self.navToMux = self.navigationController?.navigationBar @@ -428,27 +436,25 @@ class SplitMainViewController: MainViewController { */ } - if MainViewController.needsRestart { - MainViewController.needsRestart = false - tabBar?.removeFromSuperview() - self.navigationItem.leftBarButtonItems = [] - self.navigationItem.rightBarButtonItems = [] - if SettingValues.subredditBar { - setupTabBar(finalSubs) - if SettingValues.submissionGestureMode.shouldPage() { - self.dataSource = self - } - } else { - self.navigationItem.titleView = nil - self.dataSource = nil - } - } else if MainViewController.needsReTheme { - doRetheme() - } didUpdate() setupBaseBarColors( ColorUtil.getColorForSub(sub: getSubredditVC()?.sub ?? "", true)) } + + @objc func resetTabBars() { + tabBar?.removeFromSuperview() + self.navigationItem.leftBarButtonItems = [] + self.navigationItem.rightBarButtonItems = [] + if SettingValues.subredditBar { + setupTabBar(finalSubs) + if SettingValues.submissionGestureMode.shouldPage() { + self.dataSource = self + } + } else { + self.navigationItem.titleView = nil + self.dataSource = nil + } + } override func hardReset(soft: Bool = false) { var keyWindow = UIApplication.shared.keyWindow @@ -614,7 +620,6 @@ class SplitMainViewController: MainViewController { CachedTitle.titles.removeAll() view.backgroundColor = UIColor.backgroundColor splitViewController?.view.backgroundColor = UIColor.foregroundColor - SubredditReorderViewController.changed = false finalSubs = [] LinkCellView.cachedInternet = nil diff --git a/Slide for Reddit/SubredditReorderViewController.swift b/Slide for Reddit/SubredditReorderViewController.swift index 1d9bba6d5..f292db9d2 100644 --- a/Slide for Reddit/SubredditReorderViewController.swift +++ b/Slide for Reddit/SubredditReorderViewController.swift @@ -107,8 +107,6 @@ class SubredditReorderViewController: UITableViewController { var delete = UIButton() - public static var changed = false - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return UITableView.automaticDimension } @@ -130,11 +128,11 @@ class SubredditReorderViewController: UITableViewController { } func save(_ selector: AnyObject?) { - SubredditReorderViewController.changed = true Subscriptions.setPinned(name: AccountController.currentName, subs: pinned, completion: { Subscriptions.set(name: AccountController.currentName, subs: self.subs, completion: { }) }) + NotificationCenter.default.post(name: .subredditOrderChanged, object: nil) } override func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) { @@ -398,3 +396,12 @@ class SubredditReorderViewController: UITableViewController { } } } + +extension Notification.Name { + static let subredditOrderChanged = Notification.Name("subreddit-order-changed") + static let cellsNeedReDraw = Notification.Name("cells-need-re-draw") + static let subNeedsReload = Notification.Name("sub-needs-reload") + static let tabBarsChanged = Notification.Name("tab-bars-changed") + static let settingsThemeNeedsRestart = Notification.Name("settings-theme-needs-restart") + static let reduceColorChanged = Notification.Name("reduce-color-changed") +} diff --git a/Slide for Reddit/SubredditThemeViewController.swift b/Slide for Reddit/SubredditThemeViewController.swift index e36879f32..f5ac6053c 100644 --- a/Slide for Reddit/SubredditThemeViewController.swift +++ b/Slide for Reddit/SubredditThemeViewController.swift @@ -119,8 +119,6 @@ class SubredditThemeViewController: UITableViewController, ColorPickerViewDelega } } - public static var changed = false - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return UITableView.automaticDimension } diff --git a/Slide for Reddit/Subscriptions.swift b/Slide for Reddit/Subscriptions.swift index bf1284fc0..7be951d00 100644 --- a/Slide for Reddit/Subscriptions.swift +++ b/Slide for Reddit/Subscriptions.swift @@ -135,9 +135,11 @@ class Subscriptions { public static func subscribe(_ name: String, _ subscribe: Bool, session: Session?) { var sub = Subscriptions.subreddits - SubredditReorderViewController.changed = true + sub.append(name) set(name: AccountController.currentName, subs: sub) { () in } + + NotificationCenter.default.post(name: .subredditOrderChanged, object: nil) if #available(iOS 10.0, *) { HapticUtility.hapticActionStrong() } else if SettingValues.hapticFeedback { @@ -158,8 +160,10 @@ class Subscriptions { var subs = Subscriptions.subreddits subs = subs.filter { $0 != name } setPinned(name: AccountController.currentName, subs: pinned.filter { $0 != name }, completion: {}) - SubredditReorderViewController.changed = true + set(name: AccountController.currentName, subs: subs) { () in } + + NotificationCenter.default.post(name: .subredditOrderChanged, object: nil) if #available(iOS 10.0, *) { HapticUtility.hapticActionStrong() } else if SettingValues.hapticFeedback { diff --git a/Slide for Reddit/ThreadViewController.swift b/Slide for Reddit/ThreadViewController.swift index 60132d874..8a78012e2 100644 --- a/Slide for Reddit/ThreadViewController.swift +++ b/Slide for Reddit/ThreadViewController.swift @@ -79,8 +79,8 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi self.navigationController?.delegate = self if !loaded && !loading { - self.tableView.contentOffset = CGPoint(x: 0, y: -self.refreshControl.frame.size.height) - refreshControl.beginRefreshing() + self.tableView.contentOffset = CGPoint(x: 0, y: -(self.refreshControl?.frame.size.height ?? 0)) + refreshControl?.beginRefreshing() } else { self.tableView.reloadData() } @@ -149,13 +149,15 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi self.tableView.delegate = self self.tableView.dataSource = self - refreshControl = UIRefreshControl() - refreshControl.tintColor = UIColor.fontColor - - refreshControl.attributedTitle = NSAttributedString(string: "") - refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) - refreshControl.centerAnchors /==/ tableView.centerAnchors + if !UIApplication.shared.isMac() { + refreshControl = UIRefreshControl() + refreshControl?.tintColor = UIColor.fontColor + + refreshControl?.attributedTitle = NSAttributedString(string: "") + refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + tableView.addSubview(refreshControl!) + refreshControl!.centerAnchors /==/ tableView.centerAnchors + } tableView.alwaysBounceVertical = true @@ -268,13 +270,13 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi // TODO: - maybe add this later } - var refreshControl: UIRefreshControl! + var refreshControl: UIRefreshControl? func refresh() { loading = true emptyStateView.isHidden = true baseData.reset() - refreshControl.beginRefreshing() + refreshControl?.beginRefreshing() flowLayout.reset(modal: presentingViewController != nil, vc: self, isGallery: false) flowLayout.invalidateLayout() tableView.reloadData() @@ -293,14 +295,17 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi } func endAndResetRefresh() { - self.refreshControl.endRefreshing() - self.refreshControl.removeFromSuperview() + if UIApplication.shared.isMac() { + return + } + self.refreshControl?.endRefreshing() + self.refreshControl?.removeFromSuperview() self.refreshControl = UIRefreshControl() - self.refreshControl.tintColor = UIColor.fontColor + self.refreshControl?.tintColor = UIColor.fontColor - self.refreshControl.attributedTitle = NSAttributedString(string: "") - self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - self.tableView.addSubview(self.refreshControl) + self.refreshControl?.attributedTitle = NSAttributedString(string: "") + self.refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + self.tableView.addSubview(self.refreshControl!) } var loading: Bool = false From 5865bebca5bdac4c8096cb4bca1052209b6bc474 Mon Sep 17 00:00:00 2001 From: ccrama Date: Fri, 19 Feb 2021 16:41:22 -0600 Subject: [PATCH 10/46] Moved search bar out of table header --- 7.0.0 | 0 Slide for Reddit/ModalMediaViewController.swift | 8 +++++++- Slide for Reddit/NavigationHomeViewController.swift | 10 ++++++---- Slide for Reddit/SwipeDownModalVC.swift | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 7.0.0 diff --git a/7.0.0 b/7.0.0 new file mode 100644 index 000000000..e69de29bb diff --git a/Slide for Reddit/ModalMediaViewController.swift b/Slide for Reddit/ModalMediaViewController.swift index fd9597bc0..b547f5957 100644 --- a/Slide for Reddit/ModalMediaViewController.swift +++ b/Slide for Reddit/ModalMediaViewController.swift @@ -285,7 +285,11 @@ class ModalMediaViewController: UIViewController { panGestureRecognizer!.allowedScrollTypesMask = .continuous } panGestureRecognizer!.cancelsTouchesInView = false - + if UIApplication.shared.isMac() { + panGestureRecognizer!.allowedScrollTypesMask = .discrete + panGestureRecognizer!.maximumNumberOfTouches = 0 + } + view.addGestureRecognizer(panGestureRecognizer!) background = UIView() @@ -525,6 +529,8 @@ extension ModalMediaViewController: UIGestureRecognizerDelegate { } else if panGesture.state == .ended { let velocity = panGesture.velocity(in: view) + print(velocity) + let down = panGesture.velocity(in: view).y > 0 if abs(velocity.y) >= 1000 || abs(self.view.frame.origin.y) > self.view.frame.size.height / 2 { diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index a99464ad5..4d8f8274a 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -284,7 +284,7 @@ class NavigationHomeViewController: UIViewController { tableView.register(SubredditCellView.classForCoder(), forCellReuseIdentifier: "search") tableView.register(SubredditCellView.classForCoder(), forCellReuseIdentifier: "profile") - view.addSubview(tableView) + view.addSubviews(headerView, tableView) setColors(MainViewController.current) } @@ -310,7 +310,9 @@ class NavigationHomeViewController: UIViewController { searchBar.heightAnchor /==/ 50 searchBar.bottomAnchor /==/ headerView.bottomAnchor - tableView.topAnchor /==/ view.safeTopAnchor + headerView.topAnchor /==/ view.safeTopAnchor + headerView.horizontalAnchors /==/ view.horizontalAnchors + tableView.topAnchor /==/ headerView.bottomAnchor tableView.contentInset = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) tableView.horizontalAnchors /==/ view.horizontalAnchors tableView.bottomAnchor /==/ view.bottomAnchor @@ -401,7 +403,7 @@ extension NavigationHomeViewController: UITableViewDelegate, UITableViewDataSour func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { if section == 0 { - return 50 + 4 + accountHeader!.estimateHeight() + return 0 } if isSearching && section == 0 { return 0 @@ -488,7 +490,7 @@ extension NavigationHomeViewController: UITableViewDelegate, UITableViewDataSour toReturn.backgroundColor = UIColor.foregroundColor if section == 0 { - return headerView + return UIView() } if isSearching { switch section { diff --git a/Slide for Reddit/SwipeDownModalVC.swift b/Slide for Reddit/SwipeDownModalVC.swift index b29db6172..ccaaa2133 100644 --- a/Slide for Reddit/SwipeDownModalVC.swift +++ b/Slide for Reddit/SwipeDownModalVC.swift @@ -40,7 +40,7 @@ class SwipeDownModalVC: ColorMuxPagingViewController { if #available(iOS 13.4, *) { panGestureRecognizer!.allowedScrollTypesMask = .continuous } - + panGestureRecognizer2!.direction = .horizontal panGestureRecognizer!.cancelsTouchesInView = false From 62b35ec0593bdc5e52fbd871a0a075b4fa3fd77b Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 21 Feb 2021 17:22:49 -0600 Subject: [PATCH 11/46] Moved isMac from UIApplication to UIDevice --- .../xcschemes/Slide for Apple Watch.xcscheme | 25 ++- Slide for Reddit/AppDelegate.swift | 21 +-- .../AsyncAlertImagePickerViewController.swift | 4 +- .../BottomMenuPresentationController.swift | 4 +- Slide for Reddit/CommentDepthCell.swift | 4 +- Slide for Reddit/CommentViewController.swift | 162 +++++++++++------- .../ContentListingViewController.swift | 4 +- Slide for Reddit/LinkCellView.swift | 2 +- .../ModalMediaViewController.swift | 10 +- .../NavigationHomeViewController.swift | 6 +- Slide for Reddit/ProfileViewController.swift | 2 +- Slide for Reddit/SettingValues.swift | 28 +-- Slide for Reddit/SettingsComments.swift | 2 +- Slide for Reddit/SettingsGeneral.swift | 2 +- Slide for Reddit/SettingsTheme.swift | 8 +- Slide for Reddit/SettingsViewMode.swift | 41 +++-- .../SingleSubredditViewController.swift | 22 +-- .../SplitMainViewController.swift | 18 +- .../SubredditThemeViewController.swift | 4 +- ...SubredditToolbarSearchViewController.swift | 2 +- .../SwipeForwardNavigationController.swift | 2 +- .../TapBehindModalViewController.swift | 2 +- Slide for Reddit/ThreadViewController.swift | 4 +- Slide for Reddit/UIAlert+Extensions.swift | 2 +- .../UIApplication+Extensions.swift | 5 +- Slide for Reddit/VCPresenter.swift | 24 +-- Slide for Reddit/VideoScrubberView.swift | 6 +- Slide for Reddit/WebsiteViewController.swift | 8 +- Slide for Reddit/WrappingFlowLayout.swift | 8 +- 29 files changed, 254 insertions(+), 178 deletions(-) diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0530f2df2..0d084ded0 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,8 +65,10 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - + + + + + diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 20f26915e..088c85c88 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -395,7 +395,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { SwipeForwardNavigationController( rootViewController: main), ] - case .SPLIT: + default: let swipeNav = SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)) swipeNav.pushViewController(main, animated: false) splitViewController.viewControllers = [ @@ -418,12 +418,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { @available(iOS 14.0, *) func doHard14(_ window: UIWindow) -> MainViewController { - let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT || UIApplication.shared.isMac() ? .tripleColumn : .doubleColumn + let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT || SettingValues.appMode == .TRIPLE_MULTI_COLUMN + ? .tripleColumn : .doubleColumn var splitViewController: NoHomebarSplitViewController = NoHomebarSplitViewController(style: style) let main: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) - if UIApplication.shared.isMac() { + if SettingValues.appMode == .TRIPLE_MULTI_COLUMN { splitViewController.setViewController( SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), for: .primary) @@ -436,7 +437,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } else { switch UIDevice.current.userInterfaceIdiom { - case .pad: + case .pad, .mac: switch SettingValues.appMode { case .SINGLE, .MULTI_COLUMN: splitViewController.setViewController( @@ -455,7 +456,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.setViewController( SwipeForwardNavigationController(rootViewController: main), for: .secondary) - case .SPLIT: + default: splitViewController.setViewController( SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), for: .primary) @@ -485,7 +486,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func setupSplitLayout(_ splitViewController: UISplitViewController) { // Set column widths if #available(iOS 14.0, *) { - if UIApplication.shared.isMac() { + if SettingValues.appMode == .TRIPLE_MULTI_COLUMN { splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 splitViewController.preferredPrimaryColumnWidthFraction = 0.15 splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 @@ -508,7 +509,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.presentsWithGesture = true - if UIApplication.shared.isMac() { + if SettingValues.appMode == .TRIPLE_MULTI_COLUMN { splitViewController.presentsWithGesture = false setupSplitPaneLayout(splitViewController) } else { @@ -530,7 +531,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.preferredSplitBehavior = .overlay } } - case .SPLIT: + default: setupSplitPaneLayout(splitViewController) } default: @@ -541,7 +542,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func setupSplitPaneLayout(_ splitViewController: UISplitViewController) { if #available(iOS 14.0, *) { - if SettingValues.desktopMode || UIApplication.shared.isMac() { + if SettingValues.desktopMode || UIDevice.current.isMac() { splitViewController.preferredDisplayMode = .twoBesideSecondary splitViewController.preferredSplitBehavior = .tile } else { @@ -1190,7 +1191,7 @@ extension AppDelegate: UIWindowSceneDelegate { } func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) { - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { let size = windowScene.coordinateSpace.bounds.size for window in windowScene.windows { diff --git a/Slide for Reddit/AsyncAlertImagePickerViewController.swift b/Slide for Reddit/AsyncAlertImagePickerViewController.swift index 29d48b83c..f2bc075a6 100644 --- a/Slide for Reddit/AsyncAlertImagePickerViewController.swift +++ b/Slide for Reddit/AsyncAlertImagePickerViewController.swift @@ -25,7 +25,7 @@ extension AlertController { func addAsyncImagePicker(flow: UICollectionView.ScrollDirection, paging: Bool, images: [URL], selection: AsyncImagePickerViewController.SelectionType? = nil) { let vc = AsyncImagePickerViewController(flow: flow, paging: paging, images: images, selection: selection) - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { vc.preferredContentSize.height = vc.preferredSize.height * 0.9 vc.preferredContentSize.width = vc.preferredSize.width * 0.9 } else { @@ -82,7 +82,7 @@ final class AsyncImagePickerViewController: UIViewController { } var columns: CGFloat { - return UIApplication.shared.respectIpadLayout() ? 3 : 2 + return UIDevice.current.respectIpadLayout() ? 3 : 2 } var itemSize: CGSize { diff --git a/Slide for Reddit/BottomMenuPresentationController.swift b/Slide for Reddit/BottomMenuPresentationController.swift index def2422f4..3239fd4b2 100644 --- a/Slide for Reddit/BottomMenuPresentationController.swift +++ b/Slide for Reddit/BottomMenuPresentationController.swift @@ -97,7 +97,7 @@ extension BottomMenuPresentationController { let horizontalCoveragePercent: CGFloat = 0.95 // Make smaller on iPad - var width = containerView.bounds.size.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : horizontalCoveragePercent) + var width = containerView.bounds.size.width * (UIDevice.current.respectIpadLayout() ? 0.75 : horizontalCoveragePercent) if width < 250 { width = containerView.bounds.size.width * horizontalCoveragePercent } @@ -147,7 +147,7 @@ class SlideInTransition: NSObject, UIViewControllerAnimatedTransitioning { guard let viewToAnimate = viewControllerToAnimate.view else { return } var offsetFrame = viewToAnimate.bounds - var width = UIScreen.main.bounds.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : 0.95) + var width = UIScreen.main.bounds.width * (UIDevice.current.respectIpadLayout() ? 0.75 : 0.95) if width < 250 { width = UIScreen.main.bounds.width * 0.95 } diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index 8f1e1c4ec..9eccd0317 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -747,7 +747,7 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat removedSubviews.forEach({ $0.removeFromSuperview() }) - if UIApplication.shared.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { + if UIDevice.current.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMac()) { menu.addArrangedSubviews(flexSpace(), flexSpace(), flexSpace(), editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) } else { menu.addArrangedSubviews(editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) @@ -2503,7 +2503,7 @@ extension CommentDepthCell: UIContextMenuInteractionDelegate { } } - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { if self.parent?.menuCell == self { if let parent = self.parent { let menu = self.getMoreMenu(parent) diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index 566d6c842..c132f9f83 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -1341,7 +1341,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi self.view.backgroundColor = UIColor.backgroundColor self.tableView.backgroundColor = UIColor.backgroundColor self.navigationController?.view.backgroundColor = UIColor.foregroundColor - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { refreshControl = UIRefreshControl() refreshControl?.tintColor = UIColor.fontColor refreshControl?.attributedTitle = NSAttributedString(string: "") @@ -1695,7 +1695,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi refreshControl?.setValue(100, forKey: "_snappingHeight") - if UIScreen.main.traitCollection.userInterfaceIdiom == .pad && Int(round(self.view.bounds.width / CGFloat(320))) > 1 && false { + if UIDevice.current.respectIpadLayout() && Int(round(self.view.bounds.width / CGFloat(320))) > 1 && false { self.navigationController!.view.backgroundColor = .clear } self.isHiding = false @@ -2143,66 +2143,108 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi } func updateToolbar() { - navigationController?.setToolbarHidden(false, animated: false) - self.isToolbarHidden = false let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) - var items: [UIBarButtonItem] = [] - if !context.isEmpty() { - items.append(space) - let loadFullThreadButton = UIBarButtonItem.init(title: "Load full thread", style: .plain, target: self, action: #selector(CommentViewController.loadAll(_:))) - loadFullThreadButton.accessibilityLabel = "Load full thread" - items.append(loadFullThreadButton) - items.append(space) - } else { - let up = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactUp, overrideString: "up"), toolbar: true) - up.accessibilityLabel = "Navigate up one comment thread" - up.addTarget(self, action: #selector(CommentViewController.goUp(_:)), for: UIControl.Event.touchUpInside) - let upB = UIBarButtonItem(customView: up) - - let nav = UIButton(buttonImage: UIImage(sfString: SFSymbol.safariFill, overrideString: "nav"), toolbar: true) - nav.accessibilityLabel = "Change criteria for comment thread navigation" - nav.addTarget(self, action: #selector(CommentViewController.showNavTypes(_:)), for: UIControl.Event.touchUpInside) - let navB = UIBarButtonItem(customView: nav) - - let down = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactDown, overrideString: "down"), toolbar: true) - down.accessibilityLabel = "Navigate down one comment thread" - down.addTarget(self, action: #selector(CommentViewController.goDown(_:)), for: UIControl.Event.touchUpInside) - let downB = UIBarButtonItem(customView: down) + if UIDevice.current.isMac() { + navigationController?.setToolbarHidden(false, animated: false) + var items = [UIBarButtonItem]() - let more = UIButton(buttonImage: UIImage.init(sfString: SFSymbol.ellipsis, overrideString: "moreh"), toolbar: true) - more.accessibilityLabel = "Post options" - more.addTarget(self, action: #selector(self.showMenu(_:)), for: UIControl.Event.touchUpInside) - moreB = UIBarButtonItem(customView: more) - - let mod = UIButton(buttonImage: UIImage(sfString: SFSymbol.shieldLefthalfFill, overrideString: "mod"), toolbar: true) - mod.accessibilityLabel = "Moderator options" - mod.addTarget(self, action: #selector(self.showMod(_:)), for: UIControl.Event.touchUpInside) - modB = UIBarButtonItem(customView: mod) - if modLink.isEmpty() && modB.customView != nil { - modB.customView? = UIView(frame: modB.customView!.frame) + if !context.isEmpty() { + items.append(space) + let loadFullThreadButton = UIBarButtonItem.init(title: "Load full thread", style: .plain, target: self, action: #selector(CommentViewController.loadAll(_:))) + loadFullThreadButton.accessibilityLabel = "Load full thread" + items.append(loadFullThreadButton) + items.append(space) + if parent != nil && parent is PagingCommentViewController { + + parent?.toolbarItems = items + parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor + parent?.navigationController?.toolbar.tintColor = UIColor.fontColor + } else { + toolbarItems = items + navigationController?.toolbar.barTintColor = UIColor.backgroundColor + navigationController?.toolbar.tintColor = UIColor.fontColor + } + } else { + navigationController?.setToolbarHidden(true, animated: false) + + let more = UIButton(buttonImage: UIImage.init(sfString: SFSymbol.ellipsis, overrideString: "moreh"), toolbar: true) + more.accessibilityLabel = "Post options" + more.addTarget(self, action: #selector(self.showMenu(_:)), for: UIControl.Event.touchUpInside) + moreB = UIBarButtonItem(customView: more) + + if parent != nil && parent is PagingCommentViewController { + parent?.navigationItem.leftBarButtonItems = items + parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor + parent?.navigationController?.toolbar.tintColor = UIColor.fontColor + } else { + navigationItem.leftBarButtonItems = items + navigationController?.toolbar.barTintColor = UIColor.backgroundColor + navigationController?.toolbar.tintColor = UIColor.fontColor + } } - - items.append(modB) - items.append(space) - items.append(upB) - items.append(space) - items.append(navB) - items.append(space) - items.append(downB) - items.append(space) - items.append(moreB) - } - self.navigationController?.navigationBar.shadowImage = UIImage() - navigationController?.navigationBar.isTranslucent = false - - if parent != nil && parent is PagingCommentViewController { - parent?.toolbarItems = items - parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor - parent?.navigationController?.toolbar.tintColor = UIColor.fontColor } else { - toolbarItems = items - navigationController?.toolbar.barTintColor = UIColor.backgroundColor - navigationController?.toolbar.tintColor = UIColor.fontColor + navigationController?.setToolbarHidden(false, animated: false) + self.isToolbarHidden = false + var items: [UIBarButtonItem] = [] + if !context.isEmpty() { + items.append(space) + let loadFullThreadButton = UIBarButtonItem.init(title: "Load full thread", style: .plain, target: self, action: #selector(CommentViewController.loadAll(_:))) + loadFullThreadButton.accessibilityLabel = "Load full thread" + items.append(loadFullThreadButton) + items.append(space) + } else { + let up = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactUp, overrideString: "up"), toolbar: true) + up.accessibilityLabel = "Navigate up one comment thread" + up.addTarget(self, action: #selector(CommentViewController.goUp(_:)), for: UIControl.Event.touchUpInside) + let upB = UIBarButtonItem(customView: up) + + let nav = UIButton(buttonImage: UIImage(sfString: SFSymbol.safariFill, overrideString: "nav"), toolbar: true) + nav.accessibilityLabel = "Change criteria for comment thread navigation" + nav.addTarget(self, action: #selector(CommentViewController.showNavTypes(_:)), for: UIControl.Event.touchUpInside) + let navB = UIBarButtonItem(customView: nav) + + let down = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactDown, overrideString: "down"), toolbar: true) + down.accessibilityLabel = "Navigate down one comment thread" + down.addTarget(self, action: #selector(CommentViewController.goDown(_:)), for: UIControl.Event.touchUpInside) + let downB = UIBarButtonItem(customView: down) + + let more = UIButton(buttonImage: UIImage.init(sfString: SFSymbol.ellipsis, overrideString: "moreh"), toolbar: true) + more.accessibilityLabel = "Post options" + more.addTarget(self, action: #selector(self.showMenu(_:)), for: UIControl.Event.touchUpInside) + moreB = UIBarButtonItem(customView: more) + + let mod = UIButton(buttonImage: UIImage(sfString: SFSymbol.shieldLefthalfFill, overrideString: "mod"), toolbar: true) + mod.accessibilityLabel = "Moderator options" + mod.addTarget(self, action: #selector(self.showMod(_:)), for: UIControl.Event.touchUpInside) + modB = UIBarButtonItem(customView: mod) + if modLink.isEmpty() && modB.customView != nil { + modB.customView? = UIView(frame: modB.customView!.frame) + } + + items.append(modB) + items.append(space) + items.append(upB) + items.append(space) + items.append(navB) + items.append(space) + items.append(downB) + items.append(space) + items.append(moreB) + } + self.navigationController?.navigationBar.shadowImage = UIImage() + navigationController?.navigationBar.isTranslucent = false + + if parent != nil && parent is PagingCommentViewController { + + parent?.toolbarItems = items + parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor + parent?.navigationController?.toolbar.tintColor = UIColor.fontColor + } else { + toolbarItems = items + navigationController?.toolbar.barTintColor = UIColor.backgroundColor + navigationController?.toolbar.tintColor = UIColor.fontColor + } + } } @@ -3267,7 +3309,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { cellGestureRecognizer.delegate = self cellGestureRecognizer.maximumNumberOfTouches = 1 tableView.addGestureRecognizer(cellGestureRecognizer) - if !UIApplication.shared.respectIpadLayout() { + if !UIDevice.current.respectIpadLayout() { // cellGestureRecognizer.require(toFail: tableView.panGestureRecognizer) } @@ -3292,7 +3334,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { return } - if UIApplication.shared.respectIpadLayout() && SettingValues.appMode != .SINGLE { + if UIDevice.current.respectIpadLayout() && SettingValues.appMode != .SINGLE { if #available(iOS 14, *) { return } diff --git a/Slide for Reddit/ContentListingViewController.swift b/Slide for Reddit/ContentListingViewController.swift index 64a67e109..c63f003e5 100644 --- a/Slide for Reddit/ContentListingViewController.swift +++ b/Slide for Reddit/ContentListingViewController.swift @@ -193,7 +193,7 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat self.tableView.delegate = self self.tableView.dataSource = self - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { refreshControl = UIRefreshControl() refreshControl?.tintColor = UIColor.fontColor @@ -535,7 +535,7 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat } func endAndResetRefresh() { - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { self.refreshControl?.endRefreshing() self.refreshControl?.removeFromSuperview() self.refreshControl = UIRefreshControl() diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index 3f3049a4f..7f9fad229 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -3362,7 +3362,7 @@ extension LinkCellView: UIContextMenuInteractionDelegate { }) } - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { _ in return self.del?.getMoreMenu(self) }) diff --git a/Slide for Reddit/ModalMediaViewController.swift b/Slide for Reddit/ModalMediaViewController.swift index b547f5957..fa9bf47f0 100644 --- a/Slide for Reddit/ModalMediaViewController.swift +++ b/Slide for Reddit/ModalMediaViewController.swift @@ -285,7 +285,7 @@ class ModalMediaViewController: UIViewController { panGestureRecognizer!.allowedScrollTypesMask = .continuous } panGestureRecognizer!.cancelsTouchesInView = false - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { panGestureRecognizer!.allowedScrollTypesMask = .discrete panGestureRecognizer!.maximumNumberOfTouches = 0 } @@ -528,11 +528,9 @@ extension ModalMediaViewController: UIGestureRecognizerDelegate { } else if panGesture.state == .ended { let velocity = panGesture.velocity(in: view) - - print(velocity) - - let down = panGesture.velocity(in: view).y > 0 - if abs(velocity.y) >= 1000 || abs(self.view.frame.origin.y) > self.view.frame.size.height / 2 { + + let down = panGesture.velocity(in: view).y > 0 || viewToMove.frame.origin.y > 0 + if abs(velocity.y) >= 1000 || abs(viewToMove.frame.origin.y) > self.view.frame.size.height / (UIDevice.current.isMac() ? 4 : 2) { UIView.animate(withDuration: 0.2, animations: { viewToMove.frame.origin = CGPoint( diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 8d6c3896c..d7deac2d2 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -908,7 +908,7 @@ class CurrentAccountHeaderView: UIView { } var forwardButton = UIButton(type: .custom).then { - $0.setImage(UIImage(sfString: UIApplication.shared.respectIpadLayout() ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) + $0.setImage(UIImage(sfString: UIDevice.current.respectIpadLayout() ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) $0.contentEdgeInsets = UIEdgeInsets(top: 7, left: 8, bottom: 7, right: 8) $0.accessibilityLabel = "Go home" } @@ -1240,7 +1240,7 @@ extension CurrentAccountHeaderView { nav.pushNextViewControllerFromRight(nil) } else { var is14Column = false - if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIApplication.shared.respectIpadLayout() { + if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIDevice.current.respectIpadLayout() { is14Column = true } if #available(iOS 14, *), self.parent?.splitViewController?.style == .doubleColumn { @@ -1255,7 +1255,7 @@ extension CurrentAccountHeaderView { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.parent?.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/ProfileViewController.swift b/Slide for Reddit/ProfileViewController.swift index 25e4d9bf9..3f9de7812 100644 --- a/Slide for Reddit/ProfileViewController.swift +++ b/Slide for Reddit/ProfileViewController.swift @@ -156,7 +156,7 @@ extension ProfileViewController: ColorPickerViewDelegate { } else { let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 3640b7b5c..d78068d0a 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -492,18 +492,18 @@ class SettingValues { } public static func initialize() { - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() let settings = UserDefaults.standard SettingValues.saveNSFWHistory = settings.bool(forKey: SettingValues.pref_saveNSFWHistory) SettingValues.reduceColor = settings.object(forKey: SettingValues.pref_reduceColor) == nil ? true : settings.bool(forKey: SettingValues.pref_reduceColor) SettingValues.saveHistory = settings.object(forKey: SettingValues.pref_saveHistory) == nil ? true : settings.bool(forKey: SettingValues.pref_saveHistory) var columns = 2 // TODO - Maybe calculate per device? - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { columns = 1 } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) - SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIApplication.shared.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) + SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIDevice.current.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) SettingValues.galleryCount = settings.object(forKey: SettingValues.pref_galleryCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_galleryCount) SettingValues.highlightOp = settings.object(forKey: SettingValues.pref_highlightOp) == nil ? true : settings.bool(forKey: SettingValues.pref_highlightOp) @@ -535,8 +535,8 @@ class SettingValues { } } - SettingValues.desktopMode = settings.object(forKey: SettingValues.pref_desktopMode) == nil ? UIApplication.shared.isMac() : settings.bool(forKey: SettingValues.pref_desktopMode) - SettingValues.desktopMode = SettingValues.desktopMode && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) // Only enable this on Mac or iPad + SettingValues.desktopMode = settings.object(forKey: SettingValues.pref_desktopMode) == nil ? UIDevice.current.isMac() : settings.bool(forKey: SettingValues.pref_desktopMode) + SettingValues.desktopMode = SettingValues.desktopMode && (UIDevice.current.respectIpadLayout() || UIDevice.current.isMac()) // Only enable this on Mac or iPad SettingValues.scrollSidebar = settings.object(forKey: SettingValues.pref_scrollSidebar) == nil ? true : settings.bool(forKey: SettingValues.pref_scrollSidebar) @@ -589,7 +589,7 @@ class SettingValues { SettingValues.disable13Popup = false // REMOVE this setting settings.bool(forKey: SettingValues.pref_disable13Popup) SettingValues.streamVideos = settings.object(forKey: SettingValues.pref_streamVideos) == nil ? true : settings.bool(forKey: SettingValues.pref_streamVideos) SettingValues.fullWidthHeaderCells = settings.bool(forKey: SettingValues.pref_fullWidthHeaderCells) - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { SettingValues.fullWidthHeaderCells = true } SettingValues.gfycatAPI = settings.object(forKey: SettingValues.pref_gfycatAPI) == nil ? true : settings.bool(forKey: SettingValues.pref_gfycatAPI) @@ -664,10 +664,7 @@ class SettingValues { SettingValues.abbreviateScores = settings.object(forKey: SettingValues.pref_abbreviateScores) == nil ? true : settings.bool(forKey: SettingValues.pref_abbreviateScores) SettingValues.scoreInTitle = settings.bool(forKey: SettingValues.pref_scoreInTitle) SettingValues.commentsInTitle = settings.bool(forKey: SettingValues.pref_commentsInTitle) - SettingValues.appMode = AppMode.init(rawValue: settings.string(forKey: SettingValues.pref_appMode) ?? (pad ? "multi" : "single")) ?? (pad ? .SPLIT : .SINGLE) - if UIApplication.shared.isMac() { - SettingValues.appMode = .SPLIT - } + SettingValues.appMode = AppMode.init(rawValue: settings.string(forKey: SettingValues.pref_appMode) ?? (UIDevice.current.isMac() ? "triple" : (pad ? "multi" : "single"))) ?? (UIDevice.current.isMac() ? .TRIPLE_MULTI_COLUMN : (pad ? .SPLIT : .SINGLE)) SettingValues.hideSeen = settings.bool(forKey: SettingValues.pref_hideSeen) SettingValues.postViewMode = PostViewType.init(rawValue: settings.string(forKey: SettingValues.pref_postViewMode) ?? "card") ?? .CARD @@ -1283,12 +1280,13 @@ class SettingValues { } public enum AppMode: String { - public static let cases: [AppMode] = [.SPLIT, .SINGLE, .MULTI_COLUMN] + public static let cases: [AppMode] = UIDevice.current.isMac() ? [.SPLIT, .SINGLE, .MULTI_COLUMN, .TRIPLE_MULTI_COLUMN] : [.SPLIT, .SINGLE, .MULTI_COLUMN] case SPLIT = "split" case SINGLE = "single" case MULTI_COLUMN = "multi" - + case TRIPLE_MULTI_COLUMN = "triple" + func getTitle() -> String { switch self { case .SPLIT: @@ -1297,17 +1295,21 @@ class SettingValues { return "Single list" case .MULTI_COLUMN: return "Multi-column mode" + case .TRIPLE_MULTI_COLUMN: + return "Multi-column with comments" } } func getDescription() -> String { switch self { case .SPLIT: - return "Displays submissions on the left and comments on the right (requires an iPad)" + return "Displays submissions on the left and comments on the right" case .SINGLE: return "Single column display of submissions" case .MULTI_COLUMN: return "Multiple column display of submissions" + case .TRIPLE_MULTI_COLUMN: + return "Multiple column display of submissions with comments on the right" } } } diff --git a/Slide for Reddit/SettingsComments.swift b/Slide for Reddit/SettingsComments.swift index 4b922b3aa..bb22c5eac 100644 --- a/Slide for Reddit/SettingsComments.swift +++ b/Slide for Reddit/SettingsComments.swift @@ -226,7 +226,7 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() diff --git a/Slide for Reddit/SettingsGeneral.swift b/Slide for Reddit/SettingsGeneral.swift index 976d4959c..3c5f83814 100644 --- a/Slide for Reddit/SettingsGeneral.swift +++ b/Slide for Reddit/SettingsGeneral.swift @@ -542,7 +542,7 @@ class SettingsGeneral: BubbleSettingTableViewController { } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() switch section { case 0: return 4 + (!pad ? 1 : 0) case 1: return 3 diff --git a/Slide for Reddit/SettingsTheme.swift b/Slide for Reddit/SettingsTheme.swift index 8f7e9228a..795cba090 100644 --- a/Slide for Reddit/SettingsTheme.swift +++ b/Slide for Reddit/SettingsTheme.swift @@ -82,7 +82,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { } else { let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: UIScreen.main.bounds.size.width - margin * 4.0, height: 200) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: UIScreen.main.bounds.size.width - margin * 4.0, height: 200) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() @@ -118,7 +118,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } @@ -173,7 +173,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 200) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 200) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColorAccent() @@ -216,7 +216,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) alertController.modalPresentationStyle = .popover - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } if let presenter = alertController.popoverPresentationController { diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index a880267d3..8fbab3926 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -16,6 +16,7 @@ class SettingsViewMode: BubbleSettingTableViewController { var singleMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "single") var desktopMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "desktop") var splitMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "split") + var tripleMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "triple") var multicolumnMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "multi") var multicolumnCount: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "multicount") var multicolumnPortraitCount: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "portrait") @@ -100,9 +101,10 @@ class SettingsViewMode: BubbleSettingTableViewController { createCell(disablePopupSubreddit, disablePopupSubredditSwitch, isOn: SettingValues.disableSubredditPopupIpad, text: "Show subreddits full screen") createCell(disablePopup, disablePopupSwitch, isOn: SettingValues.disablePopupIpad, text: "Show comments full screen") createCell(disableMulticolumn, disableMulticolumnSwitch, isOn: !SettingValues.disableMulticolumnCollections, text: "Multi-column in profile and inbox") - createCell(singleMode, isOn: false, text: "Single-column posts") - createCell(multicolumnMode, isOn: false, text: "Multi-column posts") - createCell(splitMode, isOn: false, text: "Split-content") + createCell(singleMode, isOn: false, text: "Single-column posts\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") + createCell(multicolumnMode, isOn: false, text: "Multi-column posts\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") + createCell(splitMode, isOn: false, text: "Split-content\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") + createCell(tripleMode, isOn: false, text: "Triple-pane Multi-column\(UIDevice.current.isMac() ? "(designed for MacOS)" : "")") createCell(multicolumnCount, isOn: false, text: "Multi-column count (Pro)") createCell(multicolumnPortraitCount, isOn: false, text: "Portrait Multi-column count (Pro)") createCell(galleryCount, isOn: false, text: "Gallery-mode column count (Pro)") @@ -113,7 +115,13 @@ class SettingsViewMode: BubbleSettingTableViewController { self.singleMode.backgroundColor = UIColor.foregroundColor self.singleMode.textLabel?.textColor = UIColor.fontColor self.singleMode.detailTextLabel?.numberOfLines = 0 - + + self.tripleMode.detailTextLabel?.text = SettingValues.AppMode.TRIPLE_MULTI_COLUMN.getDescription() + self.tripleMode.detailTextLabel?.textColor = UIColor.fontColor + self.tripleMode.backgroundColor = UIColor.foregroundColor + self.tripleMode.textLabel?.textColor = UIColor.fontColor + self.tripleMode.detailTextLabel?.numberOfLines = 0 + self.splitMode.detailTextLabel?.text = SettingValues.AppMode.SPLIT.getDescription() self.splitMode.detailTextLabel?.textColor = UIColor.fontColor self.splitMode.backgroundColor = UIColor.foregroundColor @@ -167,13 +175,15 @@ class SettingsViewMode: BubbleSettingTableViewController { self.splitMode.accessoryType = .checkmark case .MULTI_COLUMN: self.multicolumnMode.accessoryType = .checkmark + case .TRIPLE_MULTI_COLUMN: + self.tripleMode.accessoryType = .checkmark } self.galleryCount.isUserInteractionEnabled = true self.galleryCount.textLabel!.isEnabled = true self.galleryCount.detailTextLabel!.isEnabled = true - if !SettingValues.isPro && !UIApplication.shared.isMac() { + if !SettingValues.isPro && !UIDevice.current.isMac() { multicolumnCount.isUserInteractionEnabled = false multicolumnCount.textLabel!.isEnabled = false multicolumnCount.detailTextLabel!.isEnabled = false @@ -188,13 +198,13 @@ class SettingsViewMode: BubbleSettingTableViewController { multicolumnPortraitCount.contentView.alpha = 0.8 } - if !UIApplication.shared.respectIpadLayout() { + if !UIDevice.current.respectIpadLayout() { self.splitMode.isUserInteractionEnabled = false self.splitMode.textLabel!.isEnabled = false self.splitMode.detailTextLabel!.isEnabled = false } - if (SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro) && !UIApplication.shared.respectIpadLayout(){ + if (SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro) && !UIDevice.current.respectIpadLayout(){ self.multicolumnCount.isUserInteractionEnabled = false self.multicolumnCount.textLabel!.isEnabled = false self.multicolumnCount.detailTextLabel!.isEnabled = false @@ -226,7 +236,7 @@ class SettingsViewMode: BubbleSettingTableViewController { case 0: return self.singleMode case 1: return self.splitMode case 2: return self.multicolumnMode - case 3: return self.desktopMode + case 3: return UIDevice.current.isMac() ? self.tripleMode : self.desktopMode default: fatalError("Unknown row in section 0") } case 1: @@ -259,6 +269,11 @@ class SettingsViewMode: BubbleSettingTableViewController { case 2: SettingValues.appMode = .MULTI_COLUMN UserDefaults.standard.set(SettingValues.AppMode.MULTI_COLUMN.rawValue, forKey: SettingValues.pref_appMode) + case 3: + if UIDevice.current.isMac() { + SettingValues.appMode = .TRIPLE_MULTI_COLUMN + UserDefaults.standard.set(SettingValues.AppMode.TRIPLE_MULTI_COLUMN.rawValue, forKey: SettingValues.pref_appMode) + } default: break } @@ -292,7 +307,7 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showMultiColumn() { - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { let popup = DragDownAlertMenu(title: "Column Count", subtitle: "", icon: nil) for value in 1...5 { @@ -308,7 +323,7 @@ class SettingsViewMode: BubbleSettingTableViewController { popup.show(self) } else { - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) actionSheetController.addCloseButton() @@ -343,7 +358,7 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showPortraitMultiColumn() { - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIDevice.current.respectIpadLayout() let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) actionSheetController.addCloseButton() @@ -377,7 +392,7 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showGalleryColumn() { - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIDevice.current.respectIpadLayout() let actionSheetController = AlertController(title: "Gallery column count", message: nil, preferredStyle: .alert) actionSheetController.addCloseButton() @@ -413,7 +428,7 @@ class SettingsViewMode: BubbleSettingTableViewController { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { var ipadOffset = 0 var isIpad = false - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { isIpad = true ipadOffset = 3 } diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 92a08a896..c9cebbfd5 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -212,7 +212,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele super.viewDidLoad() CachedTitle.titles.removeAll() - if UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { + if UIDevice.current.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { splitViewController?.showDetailViewController(SwipeForwardNavigationController(rootViewController: PlaceholderViewController()), sender: self) } @@ -924,7 +924,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele if self.dataSource.loaded && !self.dataSource.loading { self.flowLayout.reset(modal: self.presentingViewController != nil, vc: self, isGallery: self.isGallery) self.tableView.reloadData() - if !UIApplication.shared.respectIpadLayout() { + if !UIDevice.current.respectIpadLayout() { var newOffset = self.tableView.contentOffset newOffset.y -= self.headerHeight(false) self.tableView.setContentOffset(newOffset, animated: false) @@ -2119,7 +2119,7 @@ extension SingleSubredditViewController: SubmissionDataSouceDelegate { if self.navigationController?.modalPresentationStyle == .pageSheet && self.navigationController?.viewControllers.count == 1 && !(self.navigationController?.viewControllers[0] is MainViewController) { topOffset = 0 } - let headerHeight = (UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) + let headerHeight = (UIDevice.current.respectIpadLayout() && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) let paddingOffset = CGFloat(headerHeight == 0 ? -4 : 0) setOffset = paddingOffset + navOffset + topOffset + headerHeight @@ -2262,7 +2262,7 @@ extension SingleSubredditViewController { isAccent = false let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.scrollToPreselectedIndex = true MKColorPicker.delegate = self @@ -2342,7 +2342,7 @@ extension SingleSubredditViewController { isAccent = true let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.scrollToPreselectedIndex = true MKColorPicker.delegate = self @@ -2646,7 +2646,7 @@ extension SingleSubredditViewController: UICollectionViewDataSource { var numberOfColumns = CGFloat.zero let portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIDevice.current.respectIpadLayout() if SettingValues.appMode == .MULTI_COLUMN { if UIApplication.shared.statusBarOrientation.isPortrait { @@ -2737,7 +2737,7 @@ extension SingleSubredditViewController: LinkCellViewDelegate { } return }) - VCPresenter.showVC(viewController: comment, popupIfPossible: (UIApplication.shared.respectIpadLayout() && SettingValues.disablePopupIpad || !UIApplication.shared.respectIpadLayout()) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) + VCPresenter.showVC(viewController: comment, popupIfPossible: (UIDevice.current.respectIpadLayout() && SettingValues.disablePopupIpad || !UIDevice.current.respectIpadLayout()) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) } } @@ -3049,7 +3049,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { full.view?.removeGestureRecognizer(full) } - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { fullWidthBackGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(showParentMenu(_:))) guard let swipe = fullWidthBackGestureRecognizer as? UISwipeGestureRecognizer else { return } swipe.direction = .right @@ -3099,7 +3099,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { return false } if translation.x < 0 { - if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIApplication.shared.respectIpadLayout()) { + if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIDevice.current.respectIpadLayout()) { return true } } else if !SettingValues.submissionGestureMode.shouldPage() && abs(translation.x) > abs(translation.y) { @@ -3493,7 +3493,7 @@ public class LinksHeaderCellView: UICollectionViewCell { header.addSubview(imageView) imageView.clipsToBounds = true - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { imageView.verticalAnchors /==/ header.verticalAnchors imageView.horizontalAnchors /==/ header.horizontalAnchors + 4 imageView.layer.cornerRadius = 15 @@ -3532,7 +3532,7 @@ public class SubLinkItem { extension SingleSubredditViewController: TapBehindModalViewControllerDelegate { func shouldDismiss() -> Bool { - return UIApplication.shared.respectIpadLayout() + return UIDevice.current.respectIpadLayout() } } diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 10d14da36..8725cfa4d 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -116,7 +116,7 @@ class SplitMainViewController: MainViewController { splitViewController?.navigationItem.hidesBackButton = true if #available(iOS 14.0, *) { - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { splitViewController?.showsSecondaryOnlyButton = false splitViewController?.navigationItem.hidesBackButton = true splitViewController?.navigationItem.backBarButtonItem = UIBarButtonItem() @@ -199,7 +199,7 @@ class SplitMainViewController: MainViewController { if self.navigationController?.viewControllers[0] is NavigationHomeViewController { self.navigationController?.popViewController(animated: true) } else if #available(iOS 14, *) { - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { self.splitViewController?.show(UISplitViewController.Column.primary) } else { self.navigationController?.popViewController(animated: true) @@ -321,7 +321,7 @@ class SplitMainViewController: MainViewController { vc.setupSwipeGesture() } else if SettingValues.submissionGestureMode == .HALF_FULL { // Always allow swipe back with paging disabled and not full vc.setupSwipeGesture() - } else if UIApplication.shared.respectIpadLayout() && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { + } else if UIDevice.current.respectIpadLayout() && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { vc.setupSwipeGesture() } @@ -537,7 +537,7 @@ class SplitMainViewController: MainViewController { if self.finalSubs.contains(subreddit) && !override { let index = self.finalSubs.firstIndex(of: subreddit) if index == nil { - if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { + if UIDevice.current.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { if self.navigationController?.topViewController != self && !(self.navigationController?.topViewController is NavigationHomeViewController) { self.navigationController?.popToRootViewController(animated: false) } @@ -583,7 +583,7 @@ class SplitMainViewController: MainViewController { self.navigationController?.popToRootViewController(animated: false) } - if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { + if UIDevice.current.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { VCPresenter.showVC(viewController: SingleSubredditViewController(subName: subreddit.replacingOccurrences(of: " ", with: ""), single: true), popupIfPossible: false, parentNavigationController: self.navigationController, parentViewController: self) } else { VCPresenter.openRedditLink("/r/" + subreddit.replacingOccurrences(of: " ", with: ""), self.navigationController, self) @@ -1072,7 +1072,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac())) && UIDevice.current.respectIpadLayout() { is14Column = true } @@ -1085,7 +1085,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in @@ -1112,7 +1112,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac())) && UIDevice.current.respectIpadLayout() { is14Column = true } @@ -1120,7 +1120,7 @@ extension SplitMainViewController: NavigationHomeDelegate { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() && !SettingValues.desktopMode { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.respectIpadLayout() && !SettingValues.desktopMode { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/SubredditThemeViewController.swift b/Slide for Reddit/SubredditThemeViewController.swift index f5ac6053c..acfb03304 100644 --- a/Slide for Reddit/SubredditThemeViewController.swift +++ b/Slide for Reddit/SubredditThemeViewController.swift @@ -298,7 +298,7 @@ class SubredditThemeViewController: UITableViewController, ColorPickerViewDelega isAccent = false let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() @@ -345,7 +345,7 @@ class SubredditThemeViewController: UITableViewController, ColorPickerViewDelega let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColorAccent() diff --git a/Slide for Reddit/SubredditToolbarSearchViewController.swift b/Slide for Reddit/SubredditToolbarSearchViewController.swift index a5647e4e2..e9170333c 100644 --- a/Slide for Reddit/SubredditToolbarSearchViewController.swift +++ b/Slide for Reddit/SubredditToolbarSearchViewController.swift @@ -104,7 +104,7 @@ class SubredditToolbarSearchViewController: UIViewController, UIGestureRecognize } if controller.navigationController?.viewControllers.count ?? 0 == 1 && controller.navigationController?.modalPresentationStyle ?? controller.modalPresentationStyle == .pageSheet { bottomOffset += 64 - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { bottomOffset += 24 } } diff --git a/Slide for Reddit/SwipeForwardNavigationController.swift b/Slide for Reddit/SwipeForwardNavigationController.swift index 7bb2497b9..9fd0febf9 100644 --- a/Slide for Reddit/SwipeForwardNavigationController.swift +++ b/Slide for Reddit/SwipeForwardNavigationController.swift @@ -264,7 +264,7 @@ extension SwipeForwardNavigationController { let pushedViewController = pushableViewControllers.last if pushedViewController != nil && visibleViewController != nil && visibleViewController?.isBeingPresented == false && visibleViewController?.isBeingDismissed == false { - push(pushedViewController, animated: (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac()) ? false : true) { + push(pushedViewController, animated: (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac()) ? false : true) { if !self.pushableViewControllers.isEmpty { self.pushableViewControllers.removeLast() callback?() diff --git a/Slide for Reddit/TapBehindModalViewController.swift b/Slide for Reddit/TapBehindModalViewController.swift index 51d6582fa..85bb73307 100644 --- a/Slide for Reddit/TapBehindModalViewController.swift +++ b/Slide for Reddit/TapBehindModalViewController.swift @@ -23,7 +23,7 @@ class TapBehindModalViewController: SwipeForwardNavigationController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIApplication.shared.respectIpadLayout()) { + if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIDevice.current.respectIpadLayout()) { self.tapOutsideRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTapBehind)) self.tapOutsideRecognizer.numberOfTapsRequired = 1 self.tapOutsideRecognizer.cancelsTouchesInView = false diff --git a/Slide for Reddit/ThreadViewController.swift b/Slide for Reddit/ThreadViewController.swift index 059f7a8c6..1b4f0ecd5 100644 --- a/Slide for Reddit/ThreadViewController.swift +++ b/Slide for Reddit/ThreadViewController.swift @@ -149,7 +149,7 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi self.tableView.delegate = self self.tableView.dataSource = self - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { refreshControl = UIRefreshControl() refreshControl?.tintColor = UIColor.fontColor @@ -294,7 +294,7 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi } func endAndResetRefresh() { - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { return } self.refreshControl?.endRefreshing() diff --git a/Slide for Reddit/UIAlert+Extensions.swift b/Slide for Reddit/UIAlert+Extensions.swift index f0b8384c4..dd262d0d4 100644 --- a/Slide for Reddit/UIAlert+Extensions.swift +++ b/Slide for Reddit/UIAlert+Extensions.swift @@ -92,7 +92,7 @@ extension UIAlertController { } } visualEffectView?.effect = UIBlurEffect(style: UIColor.isLightTheme ? UIBlurEffect.Style.light : UIBlurEffect.Style.dark) - if self.preferredStyle == .actionSheet && !UIApplication.shared.respectIpadLayout() { + if self.preferredStyle == .actionSheet && !UIDevice.current.respectIpadLayout() { cancelActionView?.backgroundColor = UIColor.foregroundColor } } diff --git a/Slide for Reddit/UIApplication+Extensions.swift b/Slide for Reddit/UIApplication+Extensions.swift index 7b9f1a195..b8ef7bab5 100644 --- a/Slide for Reddit/UIApplication+Extensions.swift +++ b/Slide for Reddit/UIApplication+Extensions.swift @@ -13,7 +13,9 @@ extension UIApplication { var statusBarView: UIView? { return statusBarUIView } - +} + +extension UIDevice { public func isMac() -> Bool { if #available(iOS 14.0, *) { return ProcessInfo.processInfo.isiOSAppOnMac || ProcessInfo.processInfo.isMacCatalystApp @@ -27,7 +29,6 @@ extension UIApplication { public func respectIpadLayout() -> Bool { return UIDevice.current.userInterfaceIdiom == .pad || isMac() } - } extension UIApplication { public var isSplitOrSlideOver: Bool { diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index 43fc88e5d..a3b9e2cf2 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -40,11 +40,11 @@ public class VCPresenter { } } - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { parentIs13 = false } - if (!UIApplication.shared.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { + if (!UIDevice.current.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { override13 = false } @@ -52,7 +52,7 @@ public class VCPresenter { let respectedOverride13 = override13 var shouldPopup = popupIfPossible - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { if viewController is SingleSubredditViewController && SettingValues.disableSubredditPopupIpad { shouldPopup = false } else if (viewController is CommentViewController || viewController is PagingCommentViewController) && SettingValues.disablePopupIpad { @@ -60,20 +60,20 @@ public class VCPresenter { } } - override13 = override13 && (UIApplication.shared.respectIpadLayout() || (viewController is UIPageViewController || viewController is SettingsViewController)) + override13 = override13 && (UIDevice.current.respectIpadLayout() || (viewController is UIPageViewController || viewController is SettingsViewController)) - if (viewController is PagingCommentViewController || viewController is CommentViewController || (viewController is WebsiteViewController && !((viewController as! WebsiteViewController).url?.absoluteString.contains("login.compact") ?? false))) && (parentViewController?.splitViewController != nil && UIApplication.shared.respectIpadLayout() && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { + if (viewController is PagingCommentViewController || viewController is CommentViewController || (viewController is WebsiteViewController && !((viewController as! WebsiteViewController).url?.absoluteString.contains("login.compact") ?? false))) && (parentViewController?.splitViewController != nil && UIDevice.current.respectIpadLayout() && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { (parentViewController!.splitViewController)?.showDetailViewController(SwipeForwardNavigationController(rootViewController: viewController), sender: nil) return - } else if ((!SettingValues.disablePopupIpad) && UIApplication.shared.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { + } else if ((!SettingValues.disablePopupIpad) && UIDevice.current.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { - if UIApplication.shared.isMac() && viewController is SettingsViewController { + if UIDevice.current.isMac() && viewController is SettingsViewController { UIApplication.shared.requestSceneSessionActivation(nil, userActivity: NSUserActivity(activityType: "settings"), options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is SingleSubredditViewController { + } else if UIDevice.current.isMac() && viewController is SingleSubredditViewController { let activity = NSUserActivity(activityType: "subreddit") activity.userInfo = ["subreddit": (viewController as! SingleSubredditViewController).sub] UIApplication.shared.requestSceneSessionActivation(nil, @@ -81,21 +81,21 @@ public class VCPresenter { options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is InboxViewController { + } else if UIDevice.current.isMac() && viewController is InboxViewController { let activity = NSUserActivity(activityType: "inbox") UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is ProfileViewController { + } else if UIDevice.current.isMac() && viewController is ProfileViewController { let activity = NSUserActivity(activityType: "profile") activity.userInfo = ["profile": (viewController as! ProfileViewController).name] UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is WebsiteViewController { + } else if UIDevice.current.isMac() && viewController is WebsiteViewController { let activity = NSUserActivity(activityType: "website") activity.userInfo = ["url": (viewController as! WebsiteViewController).url] UIApplication.shared.requestSceneSessionActivation(nil, @@ -121,7 +121,7 @@ public class VCPresenter { let barButton = UIBarButtonItem.init(customView: button) // Let's figure out how to present it - let small: Bool = shouldPopup && UIScreen.main.traitCollection.userInterfaceIdiom == .pad && UIApplication.shared.statusBarOrientation != .portrait + let small: Bool = shouldPopup && UIDevice.current.respectIpadLayout() && UIApplication.shared.statusBarOrientation != .portrait if small || override13 || respectedOverride13 { newParent.modalPresentationStyle = .pageSheet diff --git a/Slide for Reddit/VideoScrubberView.swift b/Slide for Reddit/VideoScrubberView.swift index 31ecd5870..6f48f95e5 100644 --- a/Slide for Reddit/VideoScrubberView.swift +++ b/Slide for Reddit/VideoScrubberView.swift @@ -73,7 +73,7 @@ class VideoScrubberView: UIView { slider.maximumValue = 1 slider.isContinuous = true - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { slider.minimumTrackTintColor = ColorUtil.accentColorForSub(sub: "") slider.maximumTrackTintColor = ColorUtil.accentColorForSub(sub: "").withAlphaComponent(0.4) @@ -162,7 +162,7 @@ extension VideoScrubberView { @objc func sliderDidBeginDragging(_ sender: ThickSlider) { delegate?.sliderDidBeginDragging() - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { slider.setThumbImage(largeThumbImage, for: .normal) } UIView.animate(withDuration: 0.3) { @@ -172,7 +172,7 @@ extension VideoScrubberView { @objc func sliderDidEndDragging(_ sender: ThickSlider) { delegate?.sliderDidEndDragging() - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { slider.setThumbImage(smallThumbImage, for: .normal) } UIView.animate(withDuration: 0.3) { diff --git a/Slide for Reddit/WebsiteViewController.swift b/Slide for Reddit/WebsiteViewController.swift index 2ecd6f402..a87f13693 100644 --- a/Slide for Reddit/WebsiteViewController.swift +++ b/Slide for Reddit/WebsiteViewController.swift @@ -89,7 +89,11 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { items.append(forwardB) items.append(space) - toolbarItems = items + if UIDevice.current.isMac() { + navigationItem.rightBarButtonItems = items + } else { + toolbarItems = items + } } @objc func goBack() { @@ -294,7 +298,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { } func loadUrl() { - if url?.host == "twitter.com" && UIApplication.shared.respectIpadLayout() { + if url?.host == "twitter.com" && UIDevice.current.respectIpadLayout() { webView.customUserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)" } let myURLRequest: URLRequest = URLRequest(url: url!) diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 804754145..da82fc8be 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -48,10 +48,10 @@ class WrappingFlowLayout: UICollectionViewLayout { cache = [] contentHeight = 0 var portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() - if SettingValues.appMode == .MULTI_COLUMN || UIApplication.shared.isMac() { - if (UIApplication.shared.statusBarOrientation.isPortrait && !UIApplication.shared.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { + if SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .TRIPLE_MULTI_COLUMN { + if (UIApplication.shared.statusBarOrientation.isPortrait && !UIDevice.current.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { if !pad { numberOfColumns = SettingValues.portraitMultiColumnCount } else { @@ -68,7 +68,7 @@ class WrappingFlowLayout: UICollectionViewLayout { numberOfColumns = 1 } - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { if pad && UIApplication.shared.keyWindow?.frame != UIScreen.main.bounds || UIApplication.shared.isSplitOrSlideOver { numberOfColumns = 1 } From 69e6c76d7f6b9017fabd93cb4864898fc6ace0cf Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 6 Mar 2021 13:08:09 -0600 Subject: [PATCH 12/46] Update build number for production 7.0.2 --- Slide for Reddit.xcodeproj/project.pbxproj | 160 ++++++++++---------- Slide for Reddit/TextDisplayStackView.swift | 3 +- 2 files changed, 82 insertions(+), 81 deletions(-) diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index 05ab1690c..efb85d745 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -50,13 +50,13 @@ B49EFE382511A18F002D6AEE /* HotPostsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49EFE372511A18F002D6AEE /* HotPostsWidget.swift */; }; B49EFE482511A1D1002D6AEE /* FavoriteSubredditsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49EFE472511A1D1002D6AEE /* FavoriteSubredditsWidget.swift */; }; B49EFE522511A221002D6AEE /* UIImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = B49EFE512511A221002D6AEE /* UIImage+Extensions.swift */; }; - B4F333E1251273AF0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333E0251273AF0032BB64 /* SwiftPackageProductDependency */; }; - B4F333EB251274050032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333EA251274050032BB64 /* SwiftPackageProductDependency */; }; - B4F333F52512742E0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333F42512742E0032BB64 /* SwiftPackageProductDependency */; }; - B4F3348B2512770F0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3348A2512770F0032BB64 /* SwiftPackageProductDependency */; }; - B4F3349F251277B80032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3349E251277B80032BB64 /* SwiftPackageProductDependency */; }; - B4F3354C25127BAB0032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3354B25127BAB0032BB64 /* SwiftPackageProductDependency */; }; - B4F3355625127BD20032BB64 /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3355525127BD20032BB64 /* SwiftPackageProductDependency */; }; + B4F333E1251273AF0032BB64 /* SDWebImage in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333E0251273AF0032BB64 /* SDWebImage */; }; + B4F333EB251274050032BB64 /* BadgeSwift in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333EA251274050032BB64 /* BadgeSwift */; }; + B4F333F52512742E0032BB64 /* BiometricAuthentication in Frameworks */ = {isa = PBXBuildFile; productRef = B4F333F42512742E0032BB64 /* BiometricAuthentication */; }; + B4F3348B2512770F0032BB64 /* Embassy in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3348A2512770F0032BB64 /* Embassy */; }; + B4F3349F251277B80032BB64 /* Starscream in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3349E251277B80032BB64 /* Starscream */; }; + B4F3354C25127BAB0032BB64 /* Anchorage in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3354B25127BAB0032BB64 /* Anchorage */; }; + B4F3355625127BD20032BB64 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = B4F3355525127BD20032BB64 /* Then */; }; B776B17D5CA92860424F37C0 /* ModQueueContributionLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = B776BA7C2B7217C3875F3BEC /* ModQueueContributionLoader.swift */; }; B776B1DF80711B443ED76B61 /* SettingsPro.swift in Sources */ = {isa = PBXBuildFile; fileRef = B776B2AEE4A2438F5803329C /* SettingsPro.swift */; }; B776B1E23F4DEC18069F1579 /* MediaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B776BC65995FE8D1EE75E2AB /* MediaViewController.swift */; }; @@ -202,7 +202,7 @@ BE2F3F5D1EF96877003C1B28 /* SettingsContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE2F3F5C1EF96877003C1B28 /* SettingsContent.swift */; }; BE3144FF25663674004A908C /* AsyncTextAttachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3144FE25663674004A908C /* AsyncTextAttachment.swift */; }; BE314509256738FF004A908C /* TitleUITextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE314508256738FF004A908C /* TitleUITextView.swift */; }; - BE31454625674E03004A908C /* BuildFile in Frameworks */ = {isa = PBXBuildFile; productRef = BE31454525674E03004A908C /* SwiftPackageProductDependency */; }; + BE31454625674E03004A908C /* Proton in Frameworks */ = {isa = PBXBuildFile; productRef = BE31454525674E03004A908C /* Proton */; }; BE325C66257EF04600BD2468 /* RedditObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE325C65257EF04600BD2468 /* RedditObject.swift */; }; BE325C70257EF06A00BD2468 /* SubmissionObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE325C6F257EF06A00BD2468 /* SubmissionObject.swift */; }; BE325C7C257EF33900BD2468 /* CommentObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE325C7B257EF33900BD2468 /* CommentObject.swift */; }; @@ -972,18 +972,18 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - B4F333F52512742E0032BB64 /* BuildFile in Frameworks */, + B4F333F52512742E0032BB64 /* BiometricAuthentication in Frameworks */, BEC2AB3A250D8D2C00AD5BEA /* WidgetKit.framework in Frameworks */, - B4F3355625127BD20032BB64 /* BuildFile in Frameworks */, - B4F333E1251273AF0032BB64 /* BuildFile in Frameworks */, - B4F333EB251274050032BB64 /* BuildFile in Frameworks */, + B4F3355625127BD20032BB64 /* Then in Frameworks */, + B4F333E1251273AF0032BB64 /* SDWebImage in Frameworks */, + B4F333EB251274050032BB64 /* BadgeSwift in Frameworks */, BE51BE6520C7386A00DFFD8B /* StoreKit.framework in Frameworks */, - B4F3354C25127BAB0032BB64 /* BuildFile in Frameworks */, - B4F3348B2512770F0032BB64 /* BuildFile in Frameworks */, - BE31454625674E03004A908C /* BuildFile in Frameworks */, + B4F3354C25127BAB0032BB64 /* Anchorage in Frameworks */, + B4F3348B2512770F0032BB64 /* Embassy in Frameworks */, + BE31454625674E03004A908C /* Proton in Frameworks */, BE2E9F0823492B4300FE07B4 /* CloudKit.framework in Frameworks */, BE7BFB481F1997BA009CA2E1 /* MapKit.framework in Frameworks */, - B4F3349F251277B80032BB64 /* BuildFile in Frameworks */, + B4F3349F251277B80032BB64 /* Starscream in Frameworks */, 01BBE6AB1AC863FE2E897632 /* Pods_Slide_for_Reddit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1841,14 +1841,14 @@ ); name = "Slide for Reddit"; packageProductDependencies = ( - B4F333E0251273AF0032BB64 /* SwiftPackageProductDependency */, - B4F333EA251274050032BB64 /* SwiftPackageProductDependency */, - B4F333F42512742E0032BB64 /* SwiftPackageProductDependency */, - B4F3348A2512770F0032BB64 /* SwiftPackageProductDependency */, - B4F3349E251277B80032BB64 /* SwiftPackageProductDependency */, - B4F3354B25127BAB0032BB64 /* SwiftPackageProductDependency */, - B4F3355525127BD20032BB64 /* SwiftPackageProductDependency */, - BE31454525674E03004A908C /* SwiftPackageProductDependency */, + B4F333E0251273AF0032BB64 /* SDWebImage */, + B4F333EA251274050032BB64 /* BadgeSwift */, + B4F333F42512742E0032BB64 /* BiometricAuthentication */, + B4F3348A2512770F0032BB64 /* Embassy */, + B4F3349E251277B80032BB64 /* Starscream */, + B4F3354B25127BAB0032BB64 /* Anchorage */, + B4F3355525127BD20032BB64 /* Then */, + BE31454525674E03004A908C /* Proton */, ); productName = "Slide for Reddit"; productReference = BE8FCA041E0C46090063B8EF /* Slide for Reddit.app */; @@ -2012,14 +2012,14 @@ ); mainGroup = BE8FC9FB1E0C46090063B8EF; packageReferences = ( - B4F333DF251273AF0032BB64 /* RemoteSwiftPackageReference */, - B4F333E9251274050032BB64 /* RemoteSwiftPackageReference */, - B4F333F32512742E0032BB64 /* RemoteSwiftPackageReference */, - B4F334892512770F0032BB64 /* RemoteSwiftPackageReference */, - B4F3349D251277B80032BB64 /* RemoteSwiftPackageReference */, - B4F3354A25127BAB0032BB64 /* RemoteSwiftPackageReference */, - B4F3355425127BD20032BB64 /* RemoteSwiftPackageReference */, - BE31454425674E03004A908C /* RemoteSwiftPackageReference */, + B4F333DF251273AF0032BB64 /* XCRemoteSwiftPackageReference "SDWebImage" */, + B4F333E9251274050032BB64 /* XCRemoteSwiftPackageReference "swift-badge" */, + B4F333F32512742E0032BB64 /* XCRemoteSwiftPackageReference "BiometricAuthentication" */, + B4F334892512770F0032BB64 /* XCRemoteSwiftPackageReference "Embassy" */, + B4F3349D251277B80032BB64 /* XCRemoteSwiftPackageReference "Starscream" */, + B4F3354A25127BAB0032BB64 /* XCRemoteSwiftPackageReference "Anchorage" */, + B4F3355425127BD20032BB64 /* XCRemoteSwiftPackageReference "Then" */, + BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */, ); productRefGroup = BE8FCA051E0C46090063B8EF /* Products */; projectDirPath = ""; @@ -2801,7 +2801,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2811,7 +2811,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).WidgetConfigIntent"; @@ -2834,7 +2834,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2844,7 +2844,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.bundledwidgetconfigintent; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2869,7 +2869,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2879,7 +2879,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).watchkitapp"; @@ -2910,7 +2910,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2920,7 +2920,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2944,7 +2944,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2953,7 +2953,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).watchkitapp.watchkitextension"; @@ -2977,7 +2977,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2986,7 +2986,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.watchkitapp.watchkitextension; PRODUCT_NAME = "${TARGET_NAME}"; @@ -3011,7 +3011,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3021,7 +3021,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).Open-in-Slide"; @@ -3043,7 +3043,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3053,7 +3053,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "ccrama.me.redditslide.bundledOpen-in-Slide"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3198,7 +3198,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; @@ -3207,7 +3207,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; OTHER_LDFLAGS = ( "$(inherited)", "-framework", @@ -3236,7 +3236,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; @@ -3246,7 +3246,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; OTHER_LDFLAGS = ( "$(inherited)", "-framework", @@ -3413,7 +3413,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3423,7 +3423,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).widgets"; @@ -3448,7 +3448,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 224; + CURRENT_PROJECT_VERSION = 225; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3458,7 +3458,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.1; + MARKETING_VERSION = 7.0.2; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.bundledwidgets; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3565,7 +3565,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - B4F333DF251273AF0032BB64 /* RemoteSwiftPackageReference */ = { + B4F333DF251273AF0032BB64 /* XCRemoteSwiftPackageReference "SDWebImage" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/SDWebImage/SDWebImage"; requirement = { @@ -3573,7 +3573,7 @@ minimumVersion = 5.9.1; }; }; - B4F333E9251274050032BB64 /* RemoteSwiftPackageReference */ = { + B4F333E9251274050032BB64 /* XCRemoteSwiftPackageReference "swift-badge" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/evgenyneu/swift-badge"; requirement = { @@ -3581,7 +3581,7 @@ minimumVersion = 8.0.2; }; }; - B4F333F32512742E0032BB64 /* RemoteSwiftPackageReference */ = { + B4F333F32512742E0032BB64 /* XCRemoteSwiftPackageReference "BiometricAuthentication" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/rushisangani/BiometricAuthentication"; requirement = { @@ -3589,7 +3589,7 @@ minimumVersion = 3.1.2; }; }; - B4F334892512770F0032BB64 /* RemoteSwiftPackageReference */ = { + B4F334892512770F0032BB64 /* XCRemoteSwiftPackageReference "Embassy" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/envoy/Embassy"; requirement = { @@ -3597,7 +3597,7 @@ minimumVersion = 4.1.1; }; }; - B4F3349D251277B80032BB64 /* RemoteSwiftPackageReference */ = { + B4F3349D251277B80032BB64 /* XCRemoteSwiftPackageReference "Starscream" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/daltoniam/Starscream"; requirement = { @@ -3605,7 +3605,7 @@ version = 3.1.1; }; }; - B4F3354A25127BAB0032BB64 /* RemoteSwiftPackageReference */ = { + B4F3354A25127BAB0032BB64 /* XCRemoteSwiftPackageReference "Anchorage" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Rightpoint/Anchorage"; requirement = { @@ -3613,7 +3613,7 @@ minimumVersion = 4.5.0; }; }; - B4F3355425127BD20032BB64 /* RemoteSwiftPackageReference */ = { + B4F3355425127BD20032BB64 /* XCRemoteSwiftPackageReference "Then" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/devxoul/Then"; requirement = { @@ -3621,7 +3621,7 @@ minimumVersion = 2.7.0; }; }; - BE31454425674E03004A908C /* RemoteSwiftPackageReference */ = { + BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/rajdeep/proton"; requirement = { @@ -3632,44 +3632,44 @@ /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ - B4F333E0251273AF0032BB64 /* SwiftPackageProductDependency */ = { + B4F333E0251273AF0032BB64 /* SDWebImage */ = { isa = XCSwiftPackageProductDependency; - package = B4F333DF251273AF0032BB64 /* RemoteSwiftPackageReference */; + package = B4F333DF251273AF0032BB64 /* XCRemoteSwiftPackageReference "SDWebImage" */; productName = SDWebImage; }; - B4F333EA251274050032BB64 /* SwiftPackageProductDependency */ = { + B4F333EA251274050032BB64 /* BadgeSwift */ = { isa = XCSwiftPackageProductDependency; - package = B4F333E9251274050032BB64 /* RemoteSwiftPackageReference */; + package = B4F333E9251274050032BB64 /* XCRemoteSwiftPackageReference "swift-badge" */; productName = BadgeSwift; }; - B4F333F42512742E0032BB64 /* SwiftPackageProductDependency */ = { + B4F333F42512742E0032BB64 /* BiometricAuthentication */ = { isa = XCSwiftPackageProductDependency; - package = B4F333F32512742E0032BB64 /* RemoteSwiftPackageReference */; + package = B4F333F32512742E0032BB64 /* XCRemoteSwiftPackageReference "BiometricAuthentication" */; productName = BiometricAuthentication; }; - B4F3348A2512770F0032BB64 /* SwiftPackageProductDependency */ = { + B4F3348A2512770F0032BB64 /* Embassy */ = { isa = XCSwiftPackageProductDependency; - package = B4F334892512770F0032BB64 /* RemoteSwiftPackageReference */; + package = B4F334892512770F0032BB64 /* XCRemoteSwiftPackageReference "Embassy" */; productName = Embassy; }; - B4F3349E251277B80032BB64 /* SwiftPackageProductDependency */ = { + B4F3349E251277B80032BB64 /* Starscream */ = { isa = XCSwiftPackageProductDependency; - package = B4F3349D251277B80032BB64 /* RemoteSwiftPackageReference */; + package = B4F3349D251277B80032BB64 /* XCRemoteSwiftPackageReference "Starscream" */; productName = Starscream; }; - B4F3354B25127BAB0032BB64 /* SwiftPackageProductDependency */ = { + B4F3354B25127BAB0032BB64 /* Anchorage */ = { isa = XCSwiftPackageProductDependency; - package = B4F3354A25127BAB0032BB64 /* RemoteSwiftPackageReference */; + package = B4F3354A25127BAB0032BB64 /* XCRemoteSwiftPackageReference "Anchorage" */; productName = Anchorage; }; - B4F3355525127BD20032BB64 /* SwiftPackageProductDependency */ = { + B4F3355525127BD20032BB64 /* Then */ = { isa = XCSwiftPackageProductDependency; - package = B4F3355425127BD20032BB64 /* RemoteSwiftPackageReference */; + package = B4F3355425127BD20032BB64 /* XCRemoteSwiftPackageReference "Then" */; productName = Then; }; - BE31454525674E03004A908C /* SwiftPackageProductDependency */ = { + BE31454525674E03004A908C /* Proton */ = { isa = XCSwiftPackageProductDependency; - package = BE31454425674E03004A908C /* RemoteSwiftPackageReference */; + package = BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */; productName = Proton; }; /* End XCSwiftPackageProductDependency section */ diff --git a/Slide for Reddit/TextDisplayStackView.swift b/Slide for Reddit/TextDisplayStackView.swift index 20d75cbcc..af18ec9e1 100644 --- a/Slide for Reddit/TextDisplayStackView.swift +++ b/Slide for Reddit/TextDisplayStackView.swift @@ -689,12 +689,13 @@ public class TextDisplayStackView: UIStackView { let imgPattern = "\\" if let regex = try? NSRegularExpression(pattern: imgPattern, options: .caseInsensitive) { - let modString = regex.stringByReplacingMatches(in: html, options: .withTransparentBounds, range: NSMakeRange(0, html.length), withTemplate: "Image") + let modString = regex.stringByReplacingMatches(in: html, options: .withTransparentBounds, range: NSRange(location: 0, length: html.length), withTemplate: "Image") preSeperated.append(modString) } else { preSeperated.append(html) } } + return preSeperated } From 559db920075d332839eb4f36e687a20ecbbf65af Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 14:55:35 -0600 Subject: [PATCH 13/46] Initial Catalyst support (builds\!), Switch to Alamofire 5 --- Podfile | 10 +++- Podfile.lock | 6 +-- Slide Widgets/Slide Widgets.entitlements | 4 ++ Slide for Reddit.xcodeproj/project.pbxproj | 52 +++++++++++++++++-- .../xcschemes/Slide for Apple Watch.xcscheme | 25 ++++++--- .../xcshareddata/swiftpm/Package.resolved | 9 ++++ .../NavigationHomeViewController.swift | 2 +- Slide for Reddit/ReplyViewController.swift | 4 +- Slide for Reddit/SettingValues.swift | 5 +- .../Slide for Reddit.entitlements | 8 +++ .../SplitMainViewController.swift | 2 +- Slide for Reddit/SubredditHeaderView.swift | 2 +- Slide for Reddit/ToolbarTextView.swift | 35 +++++++------ Slide for Reddit/TrendingViewController.swift | 4 +- Slide for Reddit/VideoMediaDownloader.swift | 14 ++--- .../VideoMediaViewController.swift | 14 ++--- Slide for Reddit/WebsiteViewController.swift | 4 +- .../WidgetConfigIntent.entitlements | 8 ++- 18 files changed, 150 insertions(+), 58 deletions(-) diff --git a/Podfile b/Podfile index d7de4440a..cd5180336 100644 --- a/Podfile +++ b/Podfile @@ -19,7 +19,6 @@ target 'Slide for Reddit' do pod 'SwiftLinkPreview', '~> 3.0.1' pod 'DTCoreText', :git => 'https://github.com/Cocoanetics/DTCoreText' pod 'RLBAlertsPickers', :git => 'https://github.com/ccrama/Alerts-Pickers' - pod 'Alamofire', '~> 4.3' pod 'SwiftyJSON', :git => 'https://github.com/ccrama/SwiftyJSON.git', :branch => 'hotfix-xcode12' pod "YoutubePlayer-in-WKWebView", "~> 0.3.0" pod 'TGPControls' @@ -35,6 +34,15 @@ target 'Slide for Reddit' do end post_install do |installer| + installer.pods_project.targets.each do |target| + # Fix bundle targets' 'Signing Certificate' to 'Sign to Run Locally' + if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle" + target.build_configurations.each do |config| + config.build_settings['CODE_SIGN_IDENTITY[sdk=macosx*]'] = '-' + end + end + end + installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11' diff --git a/Podfile.lock b/Podfile.lock index b69f9fba7..7286f302d 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,4 @@ PODS: - - Alamofire (4.9.1) - DTCoreText (1.6.26): - DTCoreText/Core (= 1.6.26) - DTFoundation/Core (~> 1.7.5) @@ -55,7 +54,6 @@ PODS: - YoutubePlayer-in-WKWebView (0.3.5) DEPENDENCIES: - - Alamofire (~> 4.3) - DTCoreText (from `https://github.com/Cocoanetics/DTCoreText`) - LicensesViewController (~> 0.7.0) - MaterialComponents/ActivityIndicator @@ -76,7 +74,6 @@ DEPENDENCIES: SPEC REPOS: trunk: - - Alamofire - DTFoundation - HTMLSpecialCharacters - LicensesViewController @@ -135,7 +132,6 @@ CHECKOUT OPTIONS: :git: https://github.com/ccrama/SwiftyJSON.git SPEC CHECKSUMS: - Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18 DTCoreText: ec749e013f2e1f76de5e7c7634642e600a7467ce DTFoundation: e7781d9fd2f202bfd451fbbf8cab71ce83b46498 HTMLSpecialCharacters: edc707cc4bcdc92eb3b9551de8cff94c1e6f9a19 @@ -160,6 +156,6 @@ SPEC CHECKSUMS: TGPControls: 52c0770bee9c9aee364f1559cc627fc01ea5e8b2 YoutubePlayer-in-WKWebView: cfbf46da51d7370662a695a8f351e5fa1d3e1008 -PODFILE CHECKSUM: 921cd225b4120efa1cb2e0c32101c3932f6ceb0c +PODFILE CHECKSUM: 11d5327e7fce051cd3b3ec699136a01fb7ad5b71 COCOAPODS: 1.10.0 diff --git a/Slide Widgets/Slide Widgets.entitlements b/Slide Widgets/Slide Widgets.entitlements index 23b6b4cc6..41aeeed9d 100644 --- a/Slide Widgets/Slide Widgets.entitlements +++ b/Slide Widgets/Slide Widgets.entitlements @@ -2,9 +2,13 @@ + com.apple.security.app-sandbox + com.apple.security.application-groups group.$(USR_DOMAIN).redditslide.prefs + com.apple.security.network.client + diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index efb85d745..c9974b8b4 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -169,7 +169,7 @@ BE20852521588F3B00D8F33C /* ExtensionDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE20852421588F3B00D8F33C /* ExtensionDelegate.swift */; }; BE20852721588F3B00D8F33C /* NotificationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE20852621588F3B00D8F33C /* NotificationController.swift */; }; BE20852921588F3B00D8F33C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BE20852821588F3B00D8F33C /* Assets.xcassets */; }; - BE20852E21588F3B00D8F33C /* Slide for Apple Watch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = BE20851121588F3900D8F33C /* Slide for Apple Watch.app */; }; + BE20852E21588F3B00D8F33C /* Slide for Apple Watch.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = BE20851121588F3900D8F33C /* Slide for Apple Watch.app */; platformFilter = ios; }; BE20853A21589FD600D8F33C /* SubmissionRowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE20853921589FD600D8F33C /* SubmissionRowController.swift */; }; BE232695222DE429005CA83A /* ic_ghost@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = BE232693222DE428005CA83A /* ic_ghost@2x.png */; }; BE232696222DE429005CA83A /* ic_ghost@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = BE232694222DE428005CA83A /* ic_ghost@3x.png */; }; @@ -314,6 +314,7 @@ BE8AE94321F9225000E1C0D1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BE8AE94221F9225000E1C0D1 /* Main.storyboard */; }; BE8AE94721F922F400E1C0D1 /* ColorPickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8AE94621F922F400E1C0D1 /* ColorPickerViewController.swift */; }; BE8C29211EDE8001004D7514 /* MarginedTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8C29201EDE8001004D7514 /* MarginedTableViewCell.swift */; }; + BE8CDDCD25C261D1002BBFF4 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = BE8CDDCC25C261D1002BBFF4 /* Alamofire */; }; BE8EA67325A80F4B0094718E /* SubredditToolbarSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8EA67225A80F4B0094718E /* SubredditToolbarSearchViewController.swift */; }; BE8FCA081E0C46090063B8EF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8FCA071E0C46090063B8EF /* AppDelegate.swift */; }; BE8FCA0A1E0C46090063B8EF /* SingleSubredditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE8FCA091E0C46090063B8EF /* SingleSubredditViewController.swift */; }; @@ -831,6 +832,7 @@ BE8AE94221F9225000E1C0D1 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; BE8AE94621F922F400E1C0D1 /* ColorPickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ColorPickerViewController.swift; sourceTree = ""; }; BE8C29201EDE8001004D7514 /* MarginedTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarginedTableViewCell.swift; sourceTree = ""; }; + BE8CDBB325C259EF002BBFF4 /* Open in Slide.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Open in Slide.entitlements"; sourceTree = ""; }; BE8EA67225A80F4B0094718E /* SubredditToolbarSearchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubredditToolbarSearchViewController.swift; sourceTree = ""; }; BE8FCA041E0C46090063B8EF /* Slide for Reddit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Slide for Reddit.app"; sourceTree = BUILT_PRODUCTS_DIR; }; BE8FCA071E0C46090063B8EF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -973,6 +975,7 @@ buildActionMask = 2147483647; files = ( B4F333F52512742E0032BB64 /* BiometricAuthentication in Frameworks */, + BE8CDDCD25C261D1002BBFF4 /* Alamofire in Frameworks */, BEC2AB3A250D8D2C00AD5BEA /* WidgetKit.framework in Frameworks */, B4F3355625127BD20032BB64 /* Then in Frameworks */, B4F333E1251273AF0032BB64 /* SDWebImage in Frameworks */, @@ -1230,6 +1233,7 @@ BE257A6C21F64AA30082A47E /* Open in Slide */ = { isa = PBXGroup; children = ( + BE8CDBB325C259EF002BBFF4 /* Open in Slide.entitlements */, BE257A6D21F64AA30082A47E /* Media.xcassets */, BE257A6F21F64AA30082A47E /* ActionViewController.swift */, BE257A7121F64AA30082A47E /* MainInterface.storyboard */, @@ -1849,6 +1853,7 @@ B4F3354B25127BAB0032BB64 /* Anchorage */, B4F3355525127BD20032BB64 /* Then */, BE31454525674E03004A908C /* Proton */, + BE8CDDCC25C261D1002BBFF4 /* Alamofire */, ); productName = "Slide for Reddit"; productReference = BE8FCA041E0C46090063B8EF /* Slide for Reddit.app */; @@ -2020,6 +2025,7 @@ B4F3354A25127BAB0032BB64 /* XCRemoteSwiftPackageReference "Anchorage" */, B4F3355425127BD20032BB64 /* XCRemoteSwiftPackageReference "Then" */, BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */, + BE8CDDCB25C261D1002BBFF4 /* XCRemoteSwiftPackageReference "Alamofire" */, ); productRefGroup = BE8FCA051E0C46090063B8EF /* Products */; projectDirPath = ""; @@ -2289,7 +2295,6 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Slide for Reddit/Pods-Slide for Reddit-frameworks.sh", - "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", "${BUILT_PRODUCTS_DIR}/DTCoreText/DTCoreText.framework", "${BUILT_PRODUCTS_DIR}/DTFoundation/DTFoundation.framework", "${BUILT_PRODUCTS_DIR}/HTMLSpecialCharacters/HTMLSpecialCharacters.framework", @@ -2315,7 +2320,6 @@ ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTCoreText.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/DTFoundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/HTMLSpecialCharacters.framework", @@ -2731,6 +2735,7 @@ }; BE20852D21588F3B00D8F33C /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BE20851021588F3900D8F33C /* Slide for Apple Watch */; targetProxy = BE20852C21588F3B00D8F33C /* PBXContainerItemProxy */; }; @@ -2802,6 +2807,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2817,6 +2823,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).WidgetConfigIntent"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2835,6 +2842,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2850,6 +2858,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgetconfigintent"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2870,6 +2879,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2911,6 +2921,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2945,6 +2956,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2978,6 +2990,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -3008,10 +3021,12 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "Open in Slide/Open in Slide.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3027,6 +3042,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).Open-in-Slide"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3040,10 +3056,12 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "Open in Slide/Open in Slide.entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3059,6 +3077,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledOpen-in-Slide"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3199,10 +3218,12 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3217,11 +3238,14 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SUPPORTS_MACCATALYST = YES; + SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; "SWIFT_OPTIMIZATION_LEVEL[arch=*]" = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; @@ -3237,11 +3261,13 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; + "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -3256,9 +3282,12 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide"; + SUPPORTS_MACCATALYST = YES; + SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; @@ -3414,6 +3443,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3429,6 +3459,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).widgets"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3449,6 +3480,7 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 225; + CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3464,6 +3496,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgets 1599951103"; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3629,6 +3662,14 @@ minimumVersion = 0.5.0; }; }; + BE8CDDCB25C261D1002BBFF4 /* XCRemoteSwiftPackageReference "Alamofire" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/Alamofire/Alamofire.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 5.4.1; + }; + }; /* End XCRemoteSwiftPackageReference section */ /* Begin XCSwiftPackageProductDependency section */ @@ -3672,6 +3713,11 @@ package = BE31454425674E03004A908C /* XCRemoteSwiftPackageReference "proton" */; productName = Proton; }; + BE8CDDCC25C261D1002BBFF4 /* Alamofire */ = { + isa = XCSwiftPackageProductDependency; + package = BE8CDDCB25C261D1002BBFF4 /* XCRemoteSwiftPackageReference "Alamofire" */; + productName = Alamofire; + }; /* End XCSwiftPackageProductDependency section */ /* Begin XCVersionGroup section */ diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0530f2df2..0d084ded0 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,8 +65,10 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - + + + + + diff --git a/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved index e0557b5f9..990c26537 100644 --- a/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Slide for Reddit.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,6 +1,15 @@ { "object": { "pins": [ + { + "package": "Alamofire", + "repositoryURL": "https://github.com/Alamofire/Alamofire.git", + "state": { + "branch": null, + "revision": "eaf6e622dd41b07b251d8f01752eab31bc811493", + "version": "5.4.1" + } + }, { "package": "Anchorage", "repositoryURL": "https://github.com/Rightpoint/Anchorage", diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index bb2600951..b412e63c8 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -642,7 +642,7 @@ extension NavigationHomeViewController: UISearchBarDelegate { do { let requestString = "https://www.reddit.com/api/subreddit_autocomplete_v2.json?always_show_media=1&api_type=json&expand_srs=1&feature=link_preview&from_detail=1&include_users=true&obey_over18=1&raw_json=1&rtj=debug&sr_detail=1&query=\(searchTerm)&include_over_18=\((AccountController.isLoggedIn && SettingValues.nsfwEnabled) ? "true" : "false")" print("Requesting \(requestString)") - task = Alamofire.request(requestString, method: .get).responseString { response in + task = AF.request(requestString, method: .get).responseString { response in do { guard let data = response.data else { return diff --git a/Slide for Reddit/ReplyViewController.swift b/Slide for Reddit/ReplyViewController.swift index 236ef501d..7004c829f 100644 --- a/Slide for Reddit/ReplyViewController.swift +++ b/Slide for Reddit/ReplyViewController.swift @@ -576,7 +576,7 @@ class ReplyViewController: MediaViewController, UITextViewDelegate { }) let requestString = "https://oauth.reddit.com/r/\(subreddit)/api/link_flair_v2.json" - Alamofire.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in + AF.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in guard let self = self else { return } do { guard let data = response.data else { @@ -1292,7 +1292,7 @@ class ReplyViewController: MediaViewController, UITextViewDelegate { } var alertController: UIAlertController? - var session: Session? + var session: reddift.Session? func getSubmissionEdited(_ name: String) { DispatchQueue.main.async { diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 733d84ea9..54d2f571b 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -498,7 +498,10 @@ class SettingValues { SettingValues.reduceColor = settings.object(forKey: SettingValues.pref_reduceColor) == nil ? true : settings.bool(forKey: SettingValues.pref_reduceColor) SettingValues.saveHistory = settings.object(forKey: SettingValues.pref_saveHistory) == nil ? true : settings.bool(forKey: SettingValues.pref_saveHistory) - let columns = 2 // TODO - Maybe calculate per device? + var columns = 2 // TODO - Maybe calculate per device? + if UIApplication.shared.isMac() { + columns = 3 + } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIDevice.current.userInterfaceIdiom == .pad ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) SettingValues.galleryCount = settings.object(forKey: SettingValues.pref_galleryCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_galleryCount) diff --git a/Slide for Reddit/Slide for Reddit.entitlements b/Slide for Reddit/Slide for Reddit.entitlements index 6eb5143f8..1515e5779 100644 --- a/Slide for Reddit/Slide for Reddit.entitlements +++ b/Slide for Reddit/Slide for Reddit.entitlements @@ -19,9 +19,17 @@ app-usage + com.apple.security.app-sandbox + com.apple.security.application-groups group.$(USR_DOMAIN).redditslide.prefs + com.apple.security.device.camera + + com.apple.security.network.client + + com.apple.security.personal-information.photos-library + diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 3cfd63ff9..6f40e2fef 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -902,7 +902,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } func random(_ vc: NavigationHomeViewController) { - Alamofire.request("https://www.reddit.com/r/random/about.json", method: .get).responseString { response in + AF.request("https://www.reddit.com/r/random/about.json", method: .get).responseString { response in do { guard let data = response.data else { BannerUtil.makeBanner(text: "Random subreddit not found", color: GMColor.red500Color(), seconds: 2, context: self.parent, top: true, callback: nil) diff --git a/Slide for Reddit/SubredditHeaderView.swift b/Slide for Reddit/SubredditHeaderView.swift index 675df46e4..212c4b923 100644 --- a/Slide for Reddit/SubredditHeaderView.swift +++ b/Slide for Reddit/SubredditHeaderView.swift @@ -165,7 +165,7 @@ class SubredditHeaderView: UIView { @objc func flair(_ selector: UITableViewCell) { if let subName = subreddit?.displayName, let token = (UIApplication.shared.delegate as? AppDelegate)?.session?.token { let requestString = "https://www.reddit.com/r/\(subName)/api/user_flair_v2.json" - Alamofire.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in + AF.request(requestString, method: .get, headers: ["Authorization": "bearer \(token.accessToken)"]).responseString { [weak self] response in guard let self = self else { return } do { guard let data = response.data else { diff --git a/Slide for Reddit/ToolbarTextView.swift b/Slide for Reddit/ToolbarTextView.swift index 518d91fab..28a58a289 100644 --- a/Slide for Reddit/ToolbarTextView.swift +++ b/Slide for Reddit/ToolbarTextView.swift @@ -248,7 +248,7 @@ public class ToolbarTextView: NSObject { }) if assets.count > 1 { - Alamofire.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + AF.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) .responseJSON { response in print(response) if let status = response.response?.statusCode { @@ -415,8 +415,9 @@ public class ToolbarTextView: NSObject { } } } + - Alamofire.upload(multipartFormData: { (multipartFormData) in + AF.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(data!, withName: "image", fileName: name, mimeType: mime! as String) for (key, value) in parameters { multipartFormData.append((value.data(using: .utf8))!, withName: key) @@ -424,29 +425,29 @@ public class ToolbarTextView: NSObject { if !album.isEmpty { multipartFormData.append(album.data(using: .utf8)!, withName: "album") } - }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"], encodingCompletion: { (encodingResult) in - switch encodingResult { - case .success(let upload, _, _): - print("Success") - upload.uploadProgress { progress in - DispatchQueue.main.async { - print(progress.fractionCompleted) - self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) - } - } - upload.responseJSON { response in - debugPrint(response) - let link = JSON(response.value!)["data"]["link"].stringValue + }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + .uploadProgress(closure: { (progress) in + DispatchQueue.main.async { + print(progress.fractionCompleted) + self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) + } + }) + .responseJSON { (response) in + switch response.result { + case .success(let result): + debugPrint(result) + if let json = result as? NSDictionary, let link = (json["data"] as? NSDictionary)?["link"] as? String { print("Link is \(link)") if count == assets.count { completion(link) } + } else { + completion("Failure") } - case .failure: completion("Failure") } - }) + } }) } } diff --git a/Slide for Reddit/TrendingViewController.swift b/Slide for Reddit/TrendingViewController.swift index 23a6ca64b..de85ebe29 100644 --- a/Slide for Reddit/TrendingViewController.swift +++ b/Slide for Reddit/TrendingViewController.swift @@ -31,7 +31,7 @@ class TrendingViewController: UITableViewController { do { let requestString = "https://www.reddit.com/api/trending_searches_v1.json?always_show_media=1&api_type=json&expand_srs=1&feature=link_preview&from_detail=1&obey_over18=1&raw_json=1&sr_detail=1" - taskSearches = Alamofire.request(requestString, method: .get).responseString { response in + taskSearches = AF.request(requestString, method: .get).responseString { response in do { guard let data = response.data else { return @@ -66,7 +66,7 @@ class TrendingViewController: UITableViewController { } do { let requestString = "https://www.reddit.com/api/trending_subreddits.json" - taskSubs = Alamofire.request(requestString, method: .get).responseString { response in + taskSubs = AF.request(requestString, method: .get).responseString { response in do { guard let data = response.data else { return diff --git a/Slide for Reddit/VideoMediaDownloader.swift b/Slide for Reddit/VideoMediaDownloader.swift index 7047a2f37..37888530e 100644 --- a/Slide for Reddit/VideoMediaDownloader.swift +++ b/Slide for Reddit/VideoMediaDownloader.swift @@ -51,11 +51,11 @@ class VideoMediaDownloader { } func testQuality(urlToLoad: String, quality: String, completion: @escaping(_ success: Bool, _ url: String) -> Void) { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in if response.response?.statusCode == 200 { completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)")) } else { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4")) } } @@ -93,7 +93,7 @@ class VideoMediaDownloader { self.completion(URL(fileURLWithPath: self.getKeyFromURL())) }) } else { - request = Alamofire.download(URL(string: baseURL)!, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + request = AF.download(URL(string: baseURL)!, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (URL(fileURLWithPath: self.videoType == .REDDIT ? self.getKeyFromURL().replacingOccurrences(of: ".mp4", with: "video.mp4") : self.getKeyFromURL()), [.createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { @@ -161,7 +161,7 @@ class VideoMediaDownloader { let localUrlV = URL.init(fileURLWithPath: key.replacingOccurrences(of: ".mp4", with: "video.mp4")) let localUrlAudio = URL.init(fileURLWithPath: key.replacingOccurrences(of: ".mp4", with: "audio.mp4")) - Alamofire.request(toLoadAudio).responseString { (response) in + AF.request(toLoadAudio).responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it if let url = URL(string: toLoadAudio) { self.requestWithProgress(url: url, localUrlAudio: localUrlAudio) { (response) in @@ -184,7 +184,7 @@ class VideoMediaDownloader { self.doCopy(localUrlV, to: finalUrl) } } else if response.response?.statusCode ?? 0 > 400 { // Might exist elsewhere - Alamofire.request("\(toLoadAudioBase)/audio").responseString { (response) in + AF.request("\(toLoadAudioBase)/audio").responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it if let url = URL(string: "\(toLoadAudioBase)/audio") { self.requestWithProgress(url: url, localUrlAudio: localUrlAudio) { (response) in @@ -216,8 +216,8 @@ class VideoMediaDownloader { } } - func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (DownloadResponse) -> Void) { - self.request = Alamofire.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (AFDownloadResponse) -> Void) { + self.request = AF.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (localUrlAudio, [.removePreviousFile, .createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 0db75f8bd..4a45ddf43 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -581,11 +581,11 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz } func testQuality(urlToLoad: String, quality: String, completion: @escaping(_ success: Bool, _ url: String) -> Void) { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)"), method: .get).responseString { response in if response.response?.statusCode == 200 { completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality)")) } else { - Alamofire.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in + AF.request(urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4"), method: .get).responseString { response in completion(response.response?.statusCode ?? 0 == 200, urlToLoad.replacingOccurrences(of: "HLSPlaylist.m3u8", with: "DASH_\(quality).mp4")) } } @@ -620,7 +620,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz print("Downloading " + toLoad) let fileURLPath = self.videoType == .REDDIT ? self.getKeyFromURL().replacingOccurrences(of: ".mp4", with: "video.mp4") : self.getKeyFromURL() - request = Alamofire.download(toLoad, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + request = AF.download(toLoad, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (URL(fileURLWithPath: fileURLPath), [.createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { @@ -658,7 +658,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz let localUrlV = URL.init(fileURLWithPath: videoLocation) let localUrlAudio = URL.init(fileURLWithPath: key.replacingOccurrences(of: ".mp4", with: "audio.mp4")) - Alamofire.request(toLoadAudio).responseString { (response) in + AF.request(toLoadAudio).responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it self.requestWithProgress(url: finalUrl, localUrlAudio: localUrlAudio) { (response) in if (response.error as NSError?)?.code == NSURLErrorCancelled { // Cancelled, exit @@ -676,7 +676,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz } } else if response.response?.statusCode ?? 0 > 400 { // Might exist elsewhere - Alamofire.request("\(toLoadAudioBase)/audio").responseString { (response) in + AF.request("\(toLoadAudioBase)/audio").responseString { (response) in if response.response?.statusCode == 200 { // Audio exists, let's get it self.requestWithProgress(url: finalUrl, localUrlAudio: localUrlAudio) { (response) in if (response.error as NSError?)?.code == NSURLErrorCancelled { // Cancelled, exit @@ -715,8 +715,8 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz } } - func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (DownloadResponse) -> Void) { - self.request = Alamofire.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.DownloadOptions) in + func requestWithProgress(url: URL, localUrlAudio: URL, callback: @escaping (DownloadResponse) -> Void) { + self.request = AF.download(url, method: .get, to: { (_, _) -> (destinationURL: URL, options: DownloadRequest.Options) in return (localUrlAudio, [.removePreviousFile, .createIntermediateDirectories]) }).downloadProgress() { progress in DispatchQueue.main.async { diff --git a/Slide for Reddit/WebsiteViewController.swift b/Slide for Reddit/WebsiteViewController.swift index 23fc2c3bf..135095ab3 100644 --- a/Slide for Reddit/WebsiteViewController.swift +++ b/Slide for Reddit/WebsiteViewController.swift @@ -373,7 +373,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { if #available(iOS 13.0, *) { // Let Reddit create new reddit_session Cookie from data returned from Apple Login let jsonData = try JSONSerialization.data(withJSONObject: params, options: .withoutEscapingSlashes) - Alamofire.request("https://www.reddit.com/account/identity_provider_login", method: .post, parameters: [:], encoding: String(data: jsonData, encoding: .utf8)!, headers: nil).responseJSON { (response) in + AF.request("https://www.reddit.com/account/identity_provider_login", method: .post, parameters: [:], encoding: String(data: jsonData, encoding: .utf8)!, headers: nil).responseJSON { (response) in switch response.result { case .success(let JSON): let token = (JSON as? [String: Any])?["token"] as? String ?? "" @@ -450,7 +450,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { // Get user csrf token for Alamofire, which will be used to authorize next @objc func loginWithApple() { - Alamofire.request("https://www.reddit.com/account/login/?mobile_ui=on&experiment_mweb_sso_login_link=enabled&experiment_mweb_google_onetap=onetap_auto&experiment_mweb_am_refactoring=enabled", method: .get, parameters: [:], encoding: URLEncoding.default, headers: nil).response { (response) in + AF.request("https://www.reddit.com/account/login/?mobile_ui=on&experiment_mweb_sso_login_link=enabled&experiment_mweb_google_onetap=onetap_auto&experiment_mweb_am_refactoring=enabled", method: .get, parameters: [:], encoding: URLEncoding.default, headers: nil).response { (response) in if let data = response.data, let stringBody = String(data: data, encoding: .utf8) { // Get token out of body HTML diff --git a/WidgetConfigIntent/WidgetConfigIntent.entitlements b/WidgetConfigIntent/WidgetConfigIntent.entitlements index 86d745ebf..41aeeed9d 100644 --- a/WidgetConfigIntent/WidgetConfigIntent.entitlements +++ b/WidgetConfigIntent/WidgetConfigIntent.entitlements @@ -2,9 +2,13 @@ + com.apple.security.app-sandbox + com.apple.security.application-groups - group.$(USR_DOMAIN).redditslide.prefs - + group.$(USR_DOMAIN).redditslide.prefs + + com.apple.security.network.client + From f46d2579803176257340330b6f48cafc090ae540 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 15:51:32 -0600 Subject: [PATCH 14/46] Fix Mac layout, Force iPad code for Mac installs --- Slide for Reddit/AppDelegate.swift | 44 ++++++++++++++++--- .../AsyncAlertImagePickerViewController.swift | 4 +- .../BottomMenuPresentationController.swift | 4 +- Slide for Reddit/CommentDepthCell.swift | 4 +- Slide for Reddit/CommentViewController.swift | 22 +++++----- .../ContentListingViewController.swift | 34 +++++++------- Slide for Reddit/LinkCellView.swift | 2 +- .../NavigationHomeViewController.swift | 6 +-- Slide for Reddit/SettingValues.swift | 6 +-- Slide for Reddit/SettingsGeneral.swift | 2 +- Slide for Reddit/SettingsTheme.swift | 4 +- Slide for Reddit/SettingsViewMode.swift | 4 +- .../SingleSubredditViewController.swift | 19 ++++---- .../SplitMainViewController.swift | 18 ++++---- ...SubredditToolbarSearchViewController.swift | 2 +- .../TapBehindModalViewController.swift | 2 +- Slide for Reddit/UIAlert+Extensions.swift | 2 +- .../UIApplication+Extensions.swift | 4 ++ Slide for Reddit/VCPresenter.swift | 10 ++--- Slide for Reddit/WebsiteViewController.swift | 2 +- Slide for Reddit/WrappingFlowLayout.swift | 6 +-- 21 files changed, 122 insertions(+), 79 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index bc0e4a671..15f25eacb 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -423,8 +423,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let main: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) - switch UIDevice.current.userInterfaceIdiom { - case .pad: + if UIApplication.shared.isMac() { switch SettingValues.appMode { case .SINGLE, .MULTI_COLUMN: splitViewController.setViewController( @@ -454,10 +453,43 @@ class AppDelegate: UIResponder, UIApplicationDelegate { PlaceholderViewController(), for: .secondary) } - default: - splitViewController = NoHomebarSplitViewController() - let navHome = NavigationHomeViewController(controller: main) - splitViewController.viewControllers = [SwipeForwardNavigationController(rootViewController: navHome), SwipeForwardNavigationController(rootViewController: main)] + } else { + switch UIDevice.current.userInterfaceIdiom { + case .pad: + switch SettingValues.appMode { + case .SINGLE, .MULTI_COLUMN: + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), + for: .primary) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .secondary) + + let main2: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) + let compact = SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main2)) + + compact.pushViewController(main2, animated: false) + splitViewController.setViewController(compact, for: .compact) + + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .secondary) + case .SPLIT: + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), + for: .primary) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .supplementary) + splitViewController.setViewController( + PlaceholderViewController(), + for: .secondary) + } + default: + splitViewController = NoHomebarSplitViewController() + let navHome = NavigationHomeViewController(controller: main) + splitViewController.viewControllers = [SwipeForwardNavigationController(rootViewController: navHome), SwipeForwardNavigationController(rootViewController: main)] + } } window.rootViewController = splitViewController diff --git a/Slide for Reddit/AsyncAlertImagePickerViewController.swift b/Slide for Reddit/AsyncAlertImagePickerViewController.swift index f220f1bb5..29d48b83c 100644 --- a/Slide for Reddit/AsyncAlertImagePickerViewController.swift +++ b/Slide for Reddit/AsyncAlertImagePickerViewController.swift @@ -25,7 +25,7 @@ extension AlertController { func addAsyncImagePicker(flow: UICollectionView.ScrollDirection, paging: Bool, images: [URL], selection: AsyncImagePickerViewController.SelectionType? = nil) { let vc = AsyncImagePickerViewController(flow: flow, paging: paging, images: images, selection: selection) - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { vc.preferredContentSize.height = vc.preferredSize.height * 0.9 vc.preferredContentSize.width = vc.preferredSize.width * 0.9 } else { @@ -82,7 +82,7 @@ final class AsyncImagePickerViewController: UIViewController { } var columns: CGFloat { - return UIDevice.current.userInterfaceIdiom == .pad ? 3 : 2 + return UIApplication.shared.respectIpadLayout() ? 3 : 2 } var itemSize: CGSize { diff --git a/Slide for Reddit/BottomMenuPresentationController.swift b/Slide for Reddit/BottomMenuPresentationController.swift index cd2ac2f67..def2422f4 100644 --- a/Slide for Reddit/BottomMenuPresentationController.swift +++ b/Slide for Reddit/BottomMenuPresentationController.swift @@ -97,7 +97,7 @@ extension BottomMenuPresentationController { let horizontalCoveragePercent: CGFloat = 0.95 // Make smaller on iPad - var width = containerView.bounds.size.width * (UIDevice.current.userInterfaceIdiom == .pad ? 0.75 : horizontalCoveragePercent) + var width = containerView.bounds.size.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : horizontalCoveragePercent) if width < 250 { width = containerView.bounds.size.width * horizontalCoveragePercent } @@ -147,7 +147,7 @@ class SlideInTransition: NSObject, UIViewControllerAnimatedTransitioning { guard let viewToAnimate = viewControllerToAnimate.view else { return } var offsetFrame = viewToAnimate.bounds - var width = UIScreen.main.bounds.width * (UIDevice.current.userInterfaceIdiom == .pad ? 0.75 : 0.95) + var width = UIScreen.main.bounds.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : 0.95) if width < 250 { width = UIScreen.main.bounds.width * 0.95 } diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index 8ef19b072..8f1e1c4ec 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -747,7 +747,7 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat removedSubviews.forEach({ $0.removeFromSuperview() }) - if UIDevice.current.userInterfaceIdiom == .pad && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { + if UIApplication.shared.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { menu.addArrangedSubviews(flexSpace(), flexSpace(), flexSpace(), editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) } else { menu.addArrangedSubviews(editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) @@ -2503,7 +2503,7 @@ extension CommentDepthCell: UIContextMenuInteractionDelegate { } } - if UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac() { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { if self.parent?.menuCell == self { if let parent = self.parent { let menu = self.getMoreMenu(parent) diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index 592a0e4b9..566d6c842 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -92,7 +92,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi var didDisappearCompletely = false var live = false var liveTimer = Timer() - var refreshControl: UIRefreshControl! + var refreshControl: UIRefreshControl? var tableView: UITableView! var sortButton = UIButton() @@ -881,7 +881,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi } @objc func refresh(_ sender: AnyObject) { - self.tableView.setContentOffset(CGPoint(x: 0, y: self.tableView.contentOffset.y - (self.refreshControl!.frame.size.height)), animated: true) + self.tableView.setContentOffset(CGPoint(x: 0, y: self.tableView.contentOffset.y - (self.refreshControl?.frame.size.height ?? 0)), animated: true) session = (UIApplication.shared.delegate as! AppDelegate).session approved.removeAll() removed.removeAll() @@ -1341,17 +1341,19 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi self.view.backgroundColor = UIColor.backgroundColor self.tableView.backgroundColor = UIColor.backgroundColor self.navigationController?.view.backgroundColor = UIColor.foregroundColor - refreshControl = UIRefreshControl() - refreshControl?.tintColor = UIColor.fontColor - refreshControl?.attributedTitle = NSAttributedString(string: "") - refreshControl?.addTarget(self, action: #selector(CommentViewController.refresh(_:)), for: UIControl.Event.valueChanged) + if !UIApplication.shared.isMac() { + refreshControl = UIRefreshControl() + refreshControl?.tintColor = UIColor.fontColor + refreshControl?.attributedTitle = NSAttributedString(string: "") + refreshControl?.addTarget(self, action: #selector(CommentViewController.refresh(_:)), for: UIControl.Event.valueChanged) + } var top = CGFloat(64) let bottom = CGFloat(45) if #available(iOS 11.0, *) { top = 0 } tableView.contentInset = UIEdgeInsets(top: top, left: 0, bottom: bottom, right: 0) - tableView.addSubview(refreshControl!) + //tableView.addSubview(refreshControl!) self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItem.Style.plain, target: nil, action: nil) @@ -1691,7 +1693,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi fullWidthBackGestureRecognizer?.isEnabled = true cellGestureRecognizer?.isEnabled = true - refreshControl.setValue(100, forKey: "_snappingHeight") + refreshControl?.setValue(100, forKey: "_snappingHeight") if UIScreen.main.traitCollection.userInterfaceIdiom == .pad && Int(round(self.view.bounds.width / CGFloat(320))) > 1 && false { self.navigationController!.view.backgroundColor = .clear @@ -3265,7 +3267,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { cellGestureRecognizer.delegate = self cellGestureRecognizer.maximumNumberOfTouches = 1 tableView.addGestureRecognizer(cellGestureRecognizer) - if UIDevice.current.userInterfaceIdiom != .pad { + if !UIApplication.shared.respectIpadLayout() { // cellGestureRecognizer.require(toFail: tableView.panGestureRecognizer) } @@ -3290,7 +3292,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { return } - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.appMode != .SINGLE { + if UIApplication.shared.respectIpadLayout() && SettingValues.appMode != .SINGLE { if #available(iOS 14, *) { return } diff --git a/Slide for Reddit/ContentListingViewController.swift b/Slide for Reddit/ContentListingViewController.swift index 4fbd20c5d..1340538bc 100644 --- a/Slide for Reddit/ContentListingViewController.swift +++ b/Slide for Reddit/ContentListingViewController.swift @@ -193,13 +193,15 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat self.tableView.delegate = self self.tableView.dataSource = self - refreshControl = UIRefreshControl() - refreshControl.tintColor = UIColor.fontColor - - refreshControl.attributedTitle = NSAttributedString(string: "") - refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) - refreshControl.centerAnchors /==/ tableView.centerAnchors + if !UIApplication.shared.isMac() { + refreshControl = UIRefreshControl() + refreshControl.tintColor = UIColor.fontColor + + refreshControl.attributedTitle = NSAttributedString(string: "") + refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + tableView.addSubview(refreshControl) + refreshControl.centerAnchors /==/ tableView.centerAnchors + } tableView.alwaysBounceVertical = true @@ -531,14 +533,16 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat } func endAndResetRefresh() { - self.refreshControl.endRefreshing() - self.refreshControl.removeFromSuperview() - self.refreshControl = UIRefreshControl() - self.refreshControl.tintColor = UIColor.fontColor - - self.refreshControl.attributedTitle = NSAttributedString(string: "") - self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - self.tableView.addSubview(self.refreshControl) + if !UIApplication.shared.isMac() { + self.refreshControl.endRefreshing() + self.refreshControl.removeFromSuperview() + self.refreshControl = UIRefreshControl() + self.refreshControl.tintColor = UIColor.fontColor + + self.refreshControl.attributedTitle = NSAttributedString(string: "") + self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + self.tableView.addSubview(self.refreshControl) + } } var loading: Bool = false diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index 7acc2a69e..3f3049a4f 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -3362,7 +3362,7 @@ extension LinkCellView: UIContextMenuInteractionDelegate { }) } - if UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac() { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { _ in return self.del?.getMoreMenu(self) }) diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index b412e63c8..7eb58a7fb 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -895,7 +895,7 @@ class CurrentAccountHeaderView: UIView { } var forwardButton = UIButton(type: .custom).then { - $0.setImage(UIImage(sfString: UIDevice.current.userInterfaceIdiom == .pad ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) + $0.setImage(UIImage(sfString: UIApplication.shared.respectIpadLayout() ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) $0.contentEdgeInsets = UIEdgeInsets(top: 7, left: 8, bottom: 7, right: 8) $0.accessibilityLabel = "Go home" } @@ -1227,7 +1227,7 @@ extension CurrentAccountHeaderView { nav.pushNextViewControllerFromRight(nil) } else { var is14Column = false - if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIDevice.current.userInterfaceIdiom == .pad { + if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIApplication.shared.respectIpadLayout() { is14Column = true } if #available(iOS 14, *), self.parent?.splitViewController?.style == .doubleColumn { @@ -1242,7 +1242,7 @@ extension CurrentAccountHeaderView { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.userInterfaceIdiom == .pad { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.parent?.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 54d2f571b..c3943a994 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -492,7 +492,7 @@ class SettingValues { } public static func initialize() { - let pad = UIDevice.current.userInterfaceIdiom == .pad + let pad = UIApplication.shared.respectIpadLayout() let settings = UserDefaults.standard SettingValues.saveNSFWHistory = settings.bool(forKey: SettingValues.pref_saveNSFWHistory) SettingValues.reduceColor = settings.object(forKey: SettingValues.pref_reduceColor) == nil ? true : settings.bool(forKey: SettingValues.pref_reduceColor) @@ -503,7 +503,7 @@ class SettingValues { columns = 3 } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) - SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIDevice.current.userInterfaceIdiom == .pad ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) + SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIApplication.shared.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) SettingValues.galleryCount = settings.object(forKey: SettingValues.pref_galleryCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_galleryCount) SettingValues.highlightOp = settings.object(forKey: SettingValues.pref_highlightOp) == nil ? true : settings.bool(forKey: SettingValues.pref_highlightOp) @@ -536,7 +536,7 @@ class SettingValues { } SettingValues.desktopMode = settings.object(forKey: SettingValues.pref_desktopMode) == nil ? UIApplication.shared.isMac() : settings.bool(forKey: SettingValues.pref_desktopMode) - SettingValues.desktopMode = SettingValues.desktopMode && (UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac()) // Only enable this on Mac or iPad + SettingValues.desktopMode = SettingValues.desktopMode && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) // Only enable this on Mac or iPad SettingValues.scrollSidebar = settings.object(forKey: SettingValues.pref_scrollSidebar) == nil ? true : settings.bool(forKey: SettingValues.pref_scrollSidebar) diff --git a/Slide for Reddit/SettingsGeneral.swift b/Slide for Reddit/SettingsGeneral.swift index e4a5f64e9..13b934e74 100644 --- a/Slide for Reddit/SettingsGeneral.swift +++ b/Slide for Reddit/SettingsGeneral.swift @@ -541,7 +541,7 @@ class SettingsGeneral: BubbleSettingTableViewController { } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - let pad = UIDevice.current.userInterfaceIdiom == .pad + let pad = UIApplication.shared.respectIpadLayout() switch section { case 0: return 4 + (!pad ? 1 : 0) case 1: return 3 diff --git a/Slide for Reddit/SettingsTheme.swift b/Slide for Reddit/SettingsTheme.swift index 7c1fd3fb3..8c41eb3ae 100644 --- a/Slide for Reddit/SettingsTheme.swift +++ b/Slide for Reddit/SettingsTheme.swift @@ -118,7 +118,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } @@ -215,7 +215,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) alertController.modalPresentationStyle = .popover - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } if let presenter = alertController.popoverPresentationController { diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index 2611af17c..a3e55a252 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -188,7 +188,7 @@ class SettingsViewMode: BubbleSettingTableViewController { multicolumnPortraitCount.contentView.alpha = 0.8 } - if UIDevice.current.userInterfaceIdiom != .pad { + if !UIApplication.shared.respectIpadLayout() { self.splitMode.isUserInteractionEnabled = false self.splitMode.textLabel!.isEnabled = false self.splitMode.detailTextLabel!.isEnabled = false @@ -393,7 +393,7 @@ class SettingsViewMode: BubbleSettingTableViewController { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { var ipadOffset = 0 var isIpad = false - if UIDevice.current.userInterfaceIdiom == .pad || UIApplication.shared.isMac() { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { isIpad = true ipadOffset = 3 } diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index a47d32012..9e5037946 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -136,6 +136,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele var searchText: String? + var refreshControl: UIRefreshControl! var hasHeader = false @@ -199,7 +200,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele super.viewDidLoad() CachedTitle.titles.removeAll() - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { + if UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { splitViewController?.showDetailViewController(SwipeForwardNavigationController(rootViewController: PlaceholderViewController()), sender: self) } @@ -908,7 +909,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele if self.dataSource.loaded && !self.dataSource.loading { self.flowLayout.reset(modal: self.presentingViewController != nil, vc: self, isGallery: self.isGallery) self.tableView.reloadData() - if UIDevice.current.userInterfaceIdiom != .pad { + if !UIApplication.shared.respectIpadLayout() { var newOffset = self.tableView.contentOffset newOffset.y -= self.headerHeight(false) self.tableView.setContentOffset(newOffset, animated: false) @@ -975,7 +976,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele refreshControl.attributedTitle = NSAttributedString(string: "") refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) // not required when using UITableViewController + // tableView.addSubview(refreshControl) // not required when using UITableViewController tableView.alwaysBounceVertical = true self.automaticallyAdjustsScrollViewInsets = false @@ -2099,7 +2100,7 @@ extension SingleSubredditViewController: SubmissionDataSouceDelegate { if self.navigationController?.modalPresentationStyle == .pageSheet && self.navigationController?.viewControllers.count == 1 && !(self.navigationController?.viewControllers[0] is MainViewController) { topOffset = 0 } - let headerHeight = (UIDevice.current.userInterfaceIdiom == .pad && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) + let headerHeight = (UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) let paddingOffset = CGFloat(headerHeight == 0 ? -4 : 0) setOffset = paddingOffset + navOffset + topOffset + headerHeight @@ -2717,7 +2718,7 @@ extension SingleSubredditViewController: LinkCellViewDelegate { } return }) - VCPresenter.showVC(viewController: comment, popupIfPossible: (UIDevice.current.userInterfaceIdiom == .pad && SettingValues.disablePopupIpad || UIDevice.current.userInterfaceIdiom != .pad) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) + VCPresenter.showVC(viewController: comment, popupIfPossible: (UIApplication.shared.respectIpadLayout() && SettingValues.disablePopupIpad || !UIApplication.shared.respectIpadLayout()) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) } } @@ -3028,7 +3029,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { full.view?.removeGestureRecognizer(full) } - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { fullWidthBackGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(showParentMenu(_:))) guard let swipe = fullWidthBackGestureRecognizer as? UISwipeGestureRecognizer else { return } swipe.direction = .right @@ -3078,7 +3079,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { return false } if translation.x < 0 { - if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIDevice.current.userInterfaceIdiom == .pad) { + if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIApplication.shared.respectIpadLayout()) { return true } } else if !SettingValues.submissionGestureMode.shouldPage() && abs(translation.x) > abs(translation.y) { @@ -3472,7 +3473,7 @@ public class LinksHeaderCellView: UICollectionViewCell { header.addSubview(imageView) imageView.clipsToBounds = true - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { imageView.verticalAnchors /==/ header.verticalAnchors imageView.horizontalAnchors /==/ header.horizontalAnchors + 4 imageView.layer.cornerRadius = 15 @@ -3511,7 +3512,7 @@ public class SubLinkItem { extension SingleSubredditViewController: TapBehindModalViewControllerDelegate { func shouldDismiss() -> Bool { - return UIDevice.current.userInterfaceIdiom == .pad + return UIApplication.shared.respectIpadLayout() } } diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 6f40e2fef..0c29faf5a 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -115,7 +115,7 @@ class SplitMainViewController: MainViewController { splitViewController?.navigationItem.hidesBackButton = true if #available(iOS 14.0, *) { - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { splitViewController?.showsSecondaryOnlyButton = false splitViewController?.navigationItem.hidesBackButton = true splitViewController?.navigationItem.backBarButtonItem = UIBarButtonItem() @@ -198,7 +198,7 @@ class SplitMainViewController: MainViewController { if self.navigationController?.viewControllers[0] is NavigationHomeViewController { self.navigationController?.popViewController(animated: true) } else if #available(iOS 14, *) { - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { self.splitViewController?.show(UISplitViewController.Column.primary) } else { self.navigationController?.popViewController(animated: true) @@ -316,7 +316,7 @@ class SplitMainViewController: MainViewController { vc.setupSwipeGesture() } else if SettingValues.submissionGestureMode == .HALF_FULL { // Always allow swipe back with paging disabled and not full vc.setupSwipeGesture() - } else if UIDevice.current.userInterfaceIdiom == .pad && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { + } else if UIApplication.shared.respectIpadLayout() && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { vc.setupSwipeGesture() } @@ -531,7 +531,7 @@ class SplitMainViewController: MainViewController { if self.finalSubs.contains(subreddit) && !override { let index = self.finalSubs.firstIndex(of: subreddit) if index == nil { - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.disableSubredditPopupIpad { + if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { if self.navigationController?.topViewController != self && !(self.navigationController?.topViewController is NavigationHomeViewController) { self.navigationController?.popToRootViewController(animated: false) } @@ -577,7 +577,7 @@ class SplitMainViewController: MainViewController { self.navigationController?.popToRootViewController(animated: false) } - if UIDevice.current.userInterfaceIdiom == .pad && SettingValues.disableSubredditPopupIpad { + if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { VCPresenter.showVC(viewController: SingleSubredditViewController(subName: subreddit.replacingOccurrences(of: " ", with: ""), single: true), popupIfPossible: false, parentNavigationController: self.navigationController, parentViewController: self) } else { VCPresenter.openRedditLink("/r/" + subreddit.replacingOccurrences(of: " ", with: ""), self.navigationController, self) @@ -1069,7 +1069,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIDevice.current.userInterfaceIdiom == .pad { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { is14Column = true } @@ -1082,7 +1082,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.userInterfaceIdiom == .pad { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in @@ -1109,7 +1109,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIDevice.current.userInterfaceIdiom == .pad { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { is14Column = true } @@ -1117,7 +1117,7 @@ extension SplitMainViewController: NavigationHomeDelegate { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.userInterfaceIdiom == .pad && !SettingValues.desktopMode { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() && !SettingValues.desktopMode { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/SubredditToolbarSearchViewController.swift b/Slide for Reddit/SubredditToolbarSearchViewController.swift index 1f0bc6e94..a5647e4e2 100644 --- a/Slide for Reddit/SubredditToolbarSearchViewController.swift +++ b/Slide for Reddit/SubredditToolbarSearchViewController.swift @@ -104,7 +104,7 @@ class SubredditToolbarSearchViewController: UIViewController, UIGestureRecognize } if controller.navigationController?.viewControllers.count ?? 0 == 1 && controller.navigationController?.modalPresentationStyle ?? controller.modalPresentationStyle == .pageSheet { bottomOffset += 64 - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() { bottomOffset += 24 } } diff --git a/Slide for Reddit/TapBehindModalViewController.swift b/Slide for Reddit/TapBehindModalViewController.swift index d8c391722..51d6582fa 100644 --- a/Slide for Reddit/TapBehindModalViewController.swift +++ b/Slide for Reddit/TapBehindModalViewController.swift @@ -23,7 +23,7 @@ class TapBehindModalViewController: SwipeForwardNavigationController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIDevice.current.userInterfaceIdiom == .pad) { + if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIApplication.shared.respectIpadLayout()) { self.tapOutsideRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTapBehind)) self.tapOutsideRecognizer.numberOfTapsRequired = 1 self.tapOutsideRecognizer.cancelsTouchesInView = false diff --git a/Slide for Reddit/UIAlert+Extensions.swift b/Slide for Reddit/UIAlert+Extensions.swift index bbc2df40f..f0b8384c4 100644 --- a/Slide for Reddit/UIAlert+Extensions.swift +++ b/Slide for Reddit/UIAlert+Extensions.swift @@ -92,7 +92,7 @@ extension UIAlertController { } } visualEffectView?.effect = UIBlurEffect(style: UIColor.isLightTheme ? UIBlurEffect.Style.light : UIBlurEffect.Style.dark) - if self.preferredStyle == .actionSheet && UIDevice.current.userInterfaceIdiom != .pad { + if self.preferredStyle == .actionSheet && !UIApplication.shared.respectIpadLayout() { cancelActionView?.backgroundColor = UIColor.foregroundColor } } diff --git a/Slide for Reddit/UIApplication+Extensions.swift b/Slide for Reddit/UIApplication+Extensions.swift index 62ecf1d26..7b9f1a195 100644 --- a/Slide for Reddit/UIApplication+Extensions.swift +++ b/Slide for Reddit/UIApplication+Extensions.swift @@ -24,6 +24,10 @@ extension UIApplication { } } + public func respectIpadLayout() -> Bool { + return UIDevice.current.userInterfaceIdiom == .pad || isMac() + } + } extension UIApplication { public var isSplitOrSlideOver: Bool { diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index 677bca260..d0352b59e 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -39,7 +39,7 @@ public class VCPresenter { } } } - if (UIDevice.current.userInterfaceIdiom != .pad && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { + if (!UIApplication.shared.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { override13 = false } @@ -48,7 +48,7 @@ public class VCPresenter { let respectedOverride13 = override13 var shouldPopup = popupIfPossible - if UIDevice.current.userInterfaceIdiom == .pad { + if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { if viewController is SingleSubredditViewController && SettingValues.disableSubredditPopupIpad { shouldPopup = false } else if (viewController is CommentViewController || viewController is PagingCommentViewController) && SettingValues.disablePopupIpad { @@ -56,12 +56,12 @@ public class VCPresenter { } } - override13 = override13 && (UIDevice.current.userInterfaceIdiom == .pad || (viewController is UIPageViewController || viewController is SettingsViewController)) + override13 = override13 && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() || (viewController is UIPageViewController || viewController is SettingsViewController)) - if (viewController is PagingCommentViewController || viewController is CommentViewController || viewController is WebsiteViewController) && (parentViewController?.splitViewController != nil && UIDevice.current.userInterfaceIdiom == .pad && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { + if (viewController is PagingCommentViewController || viewController is CommentViewController || viewController is WebsiteViewController) && (parentViewController?.splitViewController != nil && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { (parentViewController!.splitViewController)?.showDetailViewController(SwipeForwardNavigationController(rootViewController: viewController), sender: nil) return - } else if ((!SettingValues.disablePopupIpad) && UIDevice.current.userInterfaceIdiom == .pad && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { + } else if ((!SettingValues.disablePopupIpad) && UIApplication.shared.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { if viewController is SingleSubredditViewController { (viewController as! SingleSubredditViewController).isModal = true diff --git a/Slide for Reddit/WebsiteViewController.swift b/Slide for Reddit/WebsiteViewController.swift index 135095ab3..2ecd6f402 100644 --- a/Slide for Reddit/WebsiteViewController.swift +++ b/Slide for Reddit/WebsiteViewController.swift @@ -294,7 +294,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { } func loadUrl() { - if url?.host == "twitter.com" && UIDevice.current.userInterfaceIdiom == .pad { + if url?.host == "twitter.com" && UIApplication.shared.respectIpadLayout() { webView.customUserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)" } let myURLRequest: URLRequest = URLRequest(url: url!) diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 91aedf8a9..8b14fc846 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -48,11 +48,11 @@ class WrappingFlowLayout: UICollectionViewLayout { cache = [] contentHeight = 0 var portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad || UIApplication.shared.isMac() if SettingValues.appMode == .MULTI_COLUMN { - if UIApplication.shared.statusBarOrientation.isPortrait || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { - if UIScreen.main.traitCollection.userInterfaceIdiom != .pad { + if (UIApplication.shared.statusBarOrientation.isPortrait && !UIApplication.shared.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { + if !pad { numberOfColumns = SettingValues.portraitMultiColumnCount } else { if SettingValues.disableMulticolumnCollections && vc is ContentListingViewController { From 8edfcd5b7724ec07a706489b159e4f0e1f8d81c2 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 20:02:31 -0600 Subject: [PATCH 15/46] Improved Catalyst layouts --- Slide for Reddit/AppDelegate.swift | 105 +++++++++--------- .../ContentListingViewController.swift | 34 +++--- Slide for Reddit/SettingValues.swift | 6 + Slide for Reddit/SettingsViewMode.swift | 72 +++++++----- .../SplitMainViewController.swift | 2 +- Slide for Reddit/VideoScrubberView.swift | 8 +- Slide for Reddit/WrappingFlowLayout.swift | 4 +- 7 files changed, 128 insertions(+), 103 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 15f25eacb..18f970480 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -418,41 +418,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate { @available(iOS 14.0, *) func doHard14(_ window: UIWindow) -> MainViewController { - let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT ? .tripleColumn : .doubleColumn + let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT || UIApplication.shared.isMac() ? .tripleColumn : .doubleColumn var splitViewController: NoHomebarSplitViewController = NoHomebarSplitViewController(style: style) let main: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) if UIApplication.shared.isMac() { - switch SettingValues.appMode { - case .SINGLE, .MULTI_COLUMN: - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), - for: .primary) - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: main), - for: .secondary) - - let main2: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) - let compact = SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main2)) - - compact.pushViewController(main2, animated: false) - splitViewController.setViewController(compact, for: .compact) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), + for: .primary) + splitViewController.setViewController( + SwipeForwardNavigationController(rootViewController: main), + for: .supplementary) + splitViewController.setViewController( + PlaceholderViewController(), + for: .secondary) - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: main), - for: .secondary) - case .SPLIT: - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), - for: .primary) - splitViewController.setViewController( - SwipeForwardNavigationController(rootViewController: main), - for: .supplementary) - splitViewController.setViewController( - PlaceholderViewController(), - for: .secondary) - } } else { switch UIDevice.current.userInterfaceIdiom { case .pad: @@ -504,11 +485,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func setupSplitLayout(_ splitViewController: UISplitViewController) { // Set column widths if #available(iOS 14.0, *) { - splitViewController.preferredPrimaryColumnWidthFraction = 0.33 - splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 - if splitViewController.style == .tripleColumn { - splitViewController.preferredSupplementaryColumnWidthFraction = 0.33 - splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.33 + if UIApplication.shared.isMac() { + splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 + splitViewController.preferredPrimaryColumnWidthFraction = 0.15 + splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 + + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 + splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 + splitViewController.preferredSupplementaryColumnWidthFraction = 0.40 + } else { + splitViewController.preferredPrimaryColumnWidthFraction = 0.33 + splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 + if splitViewController.style == .tripleColumn { + splitViewController.preferredSupplementaryColumnWidthFraction = 0.33 + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.33 + } } } else { splitViewController.preferredPrimaryColumnWidthFraction = 0.4 @@ -517,35 +508,39 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.presentsWithGesture = true - // Set display mode and split behavior - switch UIDevice.current.userInterfaceIdiom { - case .pad: - switch SettingValues.appMode { - case .SINGLE, .MULTI_COLUMN: - if UIApplication.shared.isSplitOrSlideOver { - setupSplitPaneLayout(splitViewController) - } else if SettingValues.desktopMode { - splitViewController.preferredDisplayMode = .oneBesideSecondary - if #available(iOS 14.0, *) { - splitViewController.preferredSplitBehavior = .displace - } - } else { - splitViewController.preferredDisplayMode = .secondaryOnly - if #available(iOS 14.0, *) { - splitViewController.preferredSplitBehavior = .overlay + if UIApplication.shared.isMac() { + setupSplitPaneLayout(splitViewController) + } else { + // Set display mode and split behavior + switch UIDevice.current.userInterfaceIdiom { + case .pad: + switch SettingValues.appMode { + case .SINGLE, .MULTI_COLUMN: + if UIApplication.shared.isSplitOrSlideOver { + setupSplitPaneLayout(splitViewController) + } else if SettingValues.desktopMode { + splitViewController.preferredDisplayMode = .oneBesideSecondary + if #available(iOS 14.0, *) { + splitViewController.preferredSplitBehavior = .displace + } + } else { + splitViewController.preferredDisplayMode = .secondaryOnly + if #available(iOS 14.0, *) { + splitViewController.preferredSplitBehavior = .overlay + } } + case .SPLIT: + setupSplitPaneLayout(splitViewController) } - case .SPLIT: - setupSplitPaneLayout(splitViewController) + default: + splitViewController.preferredDisplayMode = .oneOverSecondary } - default: - splitViewController.preferredDisplayMode = .oneOverSecondary } } func setupSplitPaneLayout(_ splitViewController: UISplitViewController) { if #available(iOS 14.0, *) { - if SettingValues.desktopMode { + if SettingValues.desktopMode || UIApplication.shared.isMac() { splitViewController.preferredDisplayMode = .twoBesideSecondary splitViewController.preferredSplitBehavior = .tile } else { diff --git a/Slide for Reddit/ContentListingViewController.swift b/Slide for Reddit/ContentListingViewController.swift index 1340538bc..64a67e109 100644 --- a/Slide for Reddit/ContentListingViewController.swift +++ b/Slide for Reddit/ContentListingViewController.swift @@ -156,8 +156,8 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat self.navigationController?.delegate = self if !loaded && !loading { - self.tableView.contentOffset = CGPoint(x: 0, y: -self.refreshControl.frame.size.height) - refreshControl.beginRefreshing() + self.tableView.contentOffset = CGPoint(x: 0, y: -(self.refreshControl?.frame.size.height ?? 0)) + refreshControl?.beginRefreshing() } else { self.tableView.reloadData() } @@ -195,12 +195,14 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat if !UIApplication.shared.isMac() { refreshControl = UIRefreshControl() - refreshControl.tintColor = UIColor.fontColor + refreshControl?.tintColor = UIColor.fontColor - refreshControl.attributedTitle = NSAttributedString(string: "") - refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) - refreshControl.centerAnchors /==/ tableView.centerAnchors + refreshControl?.attributedTitle = NSAttributedString(string: "") + refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + if let control = self.refreshControl { + self.tableView.addSubview(control) + control.centerAnchors /==/ self.tableView.centerAnchors + } } tableView.alwaysBounceVertical = true @@ -495,13 +497,13 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat } } - var refreshControl: UIRefreshControl! + var refreshControl: UIRefreshControl? func refresh() { loading = true emptyStateView.isHidden = true baseData.reset() - refreshControl.beginRefreshing() + refreshControl?.beginRefreshing() flowLayout.reset(modal: presentingViewController != nil, vc: self, isGallery: false) flowLayout.invalidateLayout() tableView.reloadData() @@ -534,14 +536,16 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat func endAndResetRefresh() { if !UIApplication.shared.isMac() { - self.refreshControl.endRefreshing() - self.refreshControl.removeFromSuperview() + self.refreshControl?.endRefreshing() + self.refreshControl?.removeFromSuperview() self.refreshControl = UIRefreshControl() - self.refreshControl.tintColor = UIColor.fontColor + self.refreshControl?.tintColor = UIColor.fontColor - self.refreshControl.attributedTitle = NSAttributedString(string: "") - self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - self.tableView.addSubview(self.refreshControl) + self.refreshControl?.attributedTitle = NSAttributedString(string: "") + self.refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + if let control = self.refreshControl { + self.tableView.addSubview(control) + } } } diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index c3943a994..fd577aa38 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -589,6 +589,9 @@ class SettingValues { SettingValues.disable13Popup = false // REMOVE this setting settings.bool(forKey: SettingValues.pref_disable13Popup) SettingValues.streamVideos = settings.object(forKey: SettingValues.pref_streamVideos) == nil ? true : settings.bool(forKey: SettingValues.pref_streamVideos) SettingValues.fullWidthHeaderCells = settings.bool(forKey: SettingValues.pref_fullWidthHeaderCells) + if UIApplication.shared.isMac() { + SettingValues.fullWidthHeaderCells = true + } SettingValues.gfycatAPI = settings.object(forKey: SettingValues.pref_gfycatAPI) == nil ? true : settings.bool(forKey: SettingValues.pref_gfycatAPI) SettingValues.imageFlairs = settings.object(forKey: SettingValues.pref_imageFlairs) == nil ? true : settings.bool(forKey: SettingValues.pref_imageFlairs) SettingValues.coloredFlairs = settings.object(forKey: SettingValues.pref_coloredFlairs) == nil ? true : settings.bool(forKey: SettingValues.pref_coloredFlairs) @@ -662,6 +665,9 @@ class SettingValues { SettingValues.scoreInTitle = settings.bool(forKey: SettingValues.pref_scoreInTitle) SettingValues.commentsInTitle = settings.bool(forKey: SettingValues.pref_commentsInTitle) SettingValues.appMode = AppMode.init(rawValue: settings.string(forKey: SettingValues.pref_appMode) ?? (pad ? "multi" : "single")) ?? (pad ? .SPLIT : .SINGLE) + if UIApplication.shared.isMac() { + SettingValues.appMode = .SPLIT + } SettingValues.hideSeen = settings.bool(forKey: SettingValues.pref_hideSeen) SettingValues.postViewMode = PostViewType.init(rawValue: settings.string(forKey: SettingValues.pref_postViewMode) ?? "card") ?? .CARD diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index a3e55a252..f9507b1ce 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -173,7 +173,7 @@ class SettingsViewMode: BubbleSettingTableViewController { self.galleryCount.textLabel!.isEnabled = true self.galleryCount.detailTextLabel!.isEnabled = true - if !SettingValues.isPro { + if !SettingValues.isPro && !UIApplication.shared.isMac() { multicolumnCount.isUserInteractionEnabled = false multicolumnCount.textLabel!.isEnabled = false multicolumnCount.detailTextLabel!.isEnabled = false @@ -194,7 +194,7 @@ class SettingsViewMode: BubbleSettingTableViewController { self.splitMode.detailTextLabel!.isEnabled = false } - if SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro { + if (SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro) && !UIApplication.shared.respectIpadLayout(){ self.multicolumnCount.isUserInteractionEnabled = false self.multicolumnCount.textLabel!.isEnabled = false self.multicolumnCount.detailTextLabel!.isEnabled = false @@ -292,36 +292,52 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showMultiColumn() { - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad - let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) + if UIApplication.shared.isMac() { + let popup = DragDownAlertMenu(title: "Column Count", subtitle: "", icon: nil) + + for value in 1...5 { + popup.addAction(title: "\(value)", icon: nil) { + SettingValues.multiColumnCount = value + UserDefaults.standard.set(value, forKey: SettingValues.pref_multiColumnCount) + UserDefaults.standard.synchronize() + SubredditReorderViewController.changed = true + self.setSelected() + } + } + + popup.show(self) + } else { + let pad = UIApplication.shared.respectIpadLayout() + let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) - actionSheetController.addCloseButton() + actionSheetController.addCloseButton() - let values = pad ? [["1", "2", "3", "4", "5"]] : [["1", "2", "3"]] - let pickerView = PickerViewViewControllerColored(values: values, initialSelection: [(0, SettingValues.multiColumnCount - 1)], action: { (_, _, chosen, _) in - SettingValues.multiColumnCount = chosen.row + 1 - UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_multiColumnCount) - UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true - self.setSelected() - }) + let values = pad ? [["1", "2", "3", "4", "5"]] : [["1", "2", "3"]] + let pickerView = PickerViewViewControllerColored(values: values, initialSelection: [(0, SettingValues.multiColumnCount - 1)], action: { (_, _, chosen, _) in + SettingValues.multiColumnCount = chosen.row + 1 + UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_multiColumnCount) + UserDefaults.standard.synchronize() + SubredditReorderViewController.changed = true + self.setSelected() + }) - actionSheetController.setupTheme() - - actionSheetController.attributedTitle = NSAttributedString(string: "Landscape column count", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.fontColor]) - - actionSheetController.addChild(pickerView) - - let pv = pickerView.view! - actionSheetController.contentView.addSubview(pv) - - pv.edgeAnchors /==/ actionSheetController.contentView.edgeAnchors - 14 - pv.heightAnchor /==/ CGFloat(216) - pickerView.didMove(toParent: actionSheetController) - - actionSheetController.addBlurView() + actionSheetController.setupTheme() + + actionSheetController.attributedTitle = NSAttributedString(string: "Landscape column count", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.fontColor]) + + actionSheetController.addChild(pickerView) + + let pv = pickerView.view! + actionSheetController.contentView.addSubview(pv) + + pv.edgeAnchors /==/ actionSheetController.contentView.edgeAnchors - 14 + pv.heightAnchor /==/ CGFloat(216) + pickerView.didMove(toParent: actionSheetController) + + actionSheetController.addBlurView() - self.present(actionSheetController, animated: true, completion: nil) + self.present(actionSheetController, animated: true, completion: nil) + } } func showPortraitMultiColumn() { diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 0c29faf5a..5807ef401 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -273,7 +273,7 @@ class SplitMainViewController: MainViewController { NotificationCenter.default.addObserver(self, selector: #selector(autoCacheFinished(_:)), name: .autoCacheFinished, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(autoCacheProgress(_:)), name: .autoCacheProgress, object: nil) - if let splitViewController = splitViewController, (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { + if let splitViewController = splitViewController, (!UIApplication.shared.isSplitOrSlideOver) { (UIApplication.shared.delegate as? AppDelegate)?.setupSplitLayout(splitViewController) } } diff --git a/Slide for Reddit/VideoScrubberView.swift b/Slide for Reddit/VideoScrubberView.swift index d37de2a7d..eabfb40b7 100644 --- a/Slide for Reddit/VideoScrubberView.swift +++ b/Slide for Reddit/VideoScrubberView.swift @@ -172,7 +172,9 @@ extension VideoScrubberView { @objc func sliderDidBeginDragging(_ sender: ThickSlider) { delegate?.sliderDidBeginDragging() - slider.setThumbImage(largeThumbImage, for: .normal) + if !UIApplication.shared.isMac() { + slider.setThumbImage(largeThumbImage, for: .normal) + } UIView.animate(withDuration: 0.3) { self.playButton.isHidden = true } @@ -180,7 +182,9 @@ extension VideoScrubberView { @objc func sliderDidEndDragging(_ sender: ThickSlider) { delegate?.sliderDidEndDragging() - slider.setThumbImage(smallThumbImage, for: .normal) + if !UIApplication.shared.isMac() { + slider.setThumbImage(smallThumbImage, for: .normal) + } UIView.animate(withDuration: 0.3) { self.playButton.isHidden = false } diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 8b14fc846..1edbfd330 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -48,9 +48,9 @@ class WrappingFlowLayout: UICollectionViewLayout { cache = [] contentHeight = 0 var portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad || UIApplication.shared.isMac() + let pad = UIApplication.shared.respectIpadLayout() - if SettingValues.appMode == .MULTI_COLUMN { + if SettingValues.appMode == .MULTI_COLUMN || UIApplication.shared.isMac() { if (UIApplication.shared.statusBarOrientation.isPortrait && !UIApplication.shared.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { if !pad { numberOfColumns = SettingValues.portraitMultiColumnCount From bf27ad20d8b3287e0e0a748bdfd286b02392712b Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 30 Jan 2021 20:44:01 -0600 Subject: [PATCH 16/46] Removed toolbar for Mac, Fixed video crashes --- Slide for Reddit/AnyModalViewController.swift | 21 +++++--- Slide for Reddit/AppDelegate.swift | 50 +++++++++++++++++-- .../VideoMediaViewController.swift | 37 ++++++++------ Slide for Reddit/VideoScrubberView.swift | 24 +++------ 4 files changed, 89 insertions(+), 43 deletions(-) diff --git a/Slide for Reddit/AnyModalViewController.swift b/Slide for Reddit/AnyModalViewController.swift index 95173de86..68504de85 100644 --- a/Slide for Reddit/AnyModalViewController.swift +++ b/Slide for Reddit/AnyModalViewController.swift @@ -13,7 +13,7 @@ import Then import UIKit class AnyModalViewController: UIViewController { - let volume = SubtleVolume(style: SubtleVolumeStyle.rounded) + var volume: SubtleVolume? let volumeHeight: CGFloat = 3 static var linkID = "" @@ -171,9 +171,6 @@ class AnyModalViewController: UIViewController { connectActions() handleHideUI() - volume.barTintColor = .white - volume.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) - volume.animation = .slideDown var is13 = false if #available(iOS 13, *) { @@ -181,8 +178,14 @@ class AnyModalViewController: UIViewController { } if !is13 { - view.addSubview(volume) - NotificationCenter.default.addObserver(volume, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) + volume = SubtleVolume(style: .rounded) + + volume!.barTintColor = .white + volume!.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) + volume!.animation = .slideDown + + view.addSubview(volume!) + NotificationCenter.default.addObserver(volume!, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) } if urlToLoad != nil && self.embeddedPlayer == nil { @@ -255,8 +258,10 @@ class AnyModalViewController: UIViewController { func layoutVolume() { let volumeYPadding: CGFloat = 10 let volumeXPadding = UIScreen.main.bounds.width * 0.4 / 2 - volume.superview?.bringSubviewToFront(volume) - volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + if let volume = volume { + volume.superview?.bringSubviewToFront(volume) + volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + } } func stopDisplayLink() { diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 18f970480..e53e760c4 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -490,9 +490,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.preferredPrimaryColumnWidthFraction = 0.15 splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 - splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 - splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.40 - splitViewController.preferredSupplementaryColumnWidthFraction = 0.40 + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 + splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 + splitViewController.preferredSupplementaryColumnWidthFraction = 0.60 } else { splitViewController.preferredPrimaryColumnWidthFraction = 0.33 splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 @@ -1267,6 +1267,15 @@ extension AppDelegate: UIWindowSceneDelegate { } } + + #if targetEnvironment(macCatalyst) + guard let windowScene = scene as? UIWindowScene else { return } + + if let titlebar = windowScene.titlebar { + titlebar.titleVisibility = .hidden + titlebar.toolbar = nil + } + #endif } } @@ -1314,3 +1323,38 @@ class NoHomebarSplitViewController: UISplitViewController { } } } + +#if targetEnvironment(macCatalyst) +extension AppDelegate: NSToolbarDelegate { + + func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { + let identifiers: [NSToolbarItem.Identifier] = [ + + ] + return identifiers + } + + func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { + return toolbarDefaultItemIdentifiers(toolbar) + } + + func toolbar(_ toolbar: NSToolbar, + itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, + willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { + + var toolbarItem: NSToolbarItem? + + switch itemIdentifier { + case .toggleSidebar: + toolbarItem = NSToolbarItem(itemIdentifier: itemIdentifier) + + default: + toolbarItem = nil + } + + return toolbarItem + } + +} +#endif + diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 4a45ddf43..8c77d6541 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -32,7 +32,9 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz }, completion: nil) } } - let volume = SubtleVolume(style: SubtleVolumeStyle.rounded) + + + var volume: SubtleVolume? let volumeHeight: CGFloat = 3 var setOnce = false @@ -106,30 +108,35 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz strongSelf.handleHideUI(hideTitle: true) }) - volume.barTintColor = .white - volume.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) - volume.animation = .slideDown - - var is13 = false if #available(iOS 13, *) { - is13 = true - } - if !((parent?.parent) is ShadowboxLinkViewController) && !is13 { - view.addSubview(volume) - volume.delegate = self - NotificationCenter.default.addObserver(volume, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) + + } else { + if !((parent?.parent) is ShadowboxLinkViewController) { + volume = SubtleVolume(style: SubtleVolumeStyle.rounded) + volume!.barTintColor = .white + volume!.barBackgroundColor = UIColor.white.withAlphaComponent(0.3) + volume!.animation = .slideDown + view.addSubview(volume!) + volume!.delegate = self + NotificationCenter.default.addObserver(volume!, selector: #selector(SubtleVolume.resume), name: UIApplication.didBecomeActiveNotification, object: nil) + } } } override func viewDidLayoutSubviews() { - layoutVolume() + if #available(iOS 13, *) { + } else { + layoutVolume() + } } func layoutVolume() { let volumeYPadding: CGFloat = 10 let volumeXPadding = UIScreen.main.bounds.width * 0.4 / 2 - volume.superview?.bringSubviewToFront(volume) - volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + if let volume = volume { + volume.superview?.bringSubviewToFront(volume) + volume.frame = CGRect(x: safeAreaInsets.left + volumeXPadding, y: safeAreaInsets.top + volumeYPadding, width: UIScreen.main.bounds.width - (volumeXPadding * 2) - safeAreaInsets.left - safeAreaInsets.right, height: volumeHeight) + } } func stopDisplayLink() { diff --git a/Slide for Reddit/VideoScrubberView.swift b/Slide for Reddit/VideoScrubberView.swift index eabfb40b7..31ecd5870 100644 --- a/Slide for Reddit/VideoScrubberView.swift +++ b/Slide for Reddit/VideoScrubberView.swift @@ -69,17 +69,16 @@ class VideoScrubberView: UIView { super.init(frame: frame) slider.tintColor = ColorUtil.accentColorForSub(sub: "") -// slider.setThumbImage(UIImage(named: "circle")?.getCopy(withSize: .square(size: 72), withColor: slider.tintColor), for: .normal) slider.minimumValue = 0 slider.maximumValue = 1 slider.isContinuous = true -// slider.setThumbImage(UIImage(), for: .normal) -// slider.setMinimumTrackImage(UIImage.image(with: slider.tintColor).getCopy(withSize: .square(size: 72)), for: .normal) -// slider.setMaximumTrackImage(UIImage.image(with: slider.tintColor.withAlphaComponent(0.4)).getCopy(withSize: .square(size: 72)), for: .normal) -// slider.thumbTintColor = ColorUtil.accentColorForSub(sub: "") - slider.minimumTrackTintColor = ColorUtil.accentColorForSub(sub: "") - slider.maximumTrackTintColor = ColorUtil.accentColorForSub(sub: "").withAlphaComponent(0.4) - slider.setThumbImage(UIImage(named: "circle")?.getCopy(withSize: CGSize.square(size: 20), withColor: .white), for: .normal) + + if !UIApplication.shared.isMac() { + slider.minimumTrackTintColor = ColorUtil.accentColorForSub(sub: "") + slider.maximumTrackTintColor = ColorUtil.accentColorForSub(sub: "").withAlphaComponent(0.4) + + slider.setThumbImage(UIImage(named: "circle")?.getCopy(withSize: CGSize.square(size: 20), withColor: .white), for: .normal) + } self.addSubview(slider) self.addSubview(playButton) @@ -88,15 +87,6 @@ class VideoScrubberView: UIView { slider.heightAnchor /==/ 24 slider.bottomAnchor /==/ self.bottomAnchor - 4 slider.leftAnchor /==/ timeTotalLabel.rightAnchor + 8 - - // timeElapsedLabel.font = UIFont.boldSystemFont(ofSize: 12) - // timeElapsedLabel.textAlignment = .center - // timeElapsedLabel.textColor = UIColor.white - // self.addSubview(timeElapsedLabel) - // timeElapsedLabel.centerYAnchor /==/ slider.centerYAnchor - // timeElapsedLabel.leftAnchor />=/ slider.leftAnchor ~ .high -// timeElapsedRightConstraint = timeElapsedLabel.rightAnchor /==/ CGFloat(slider.thumbCenterX - 16) ~ .low -// slider timeTotalLabel.font = UIFont.monospacedDigitSystemFont(ofSize: 12, weight: UIFont.Weight(rawValue: 10)) timeTotalLabel.textAlignment = .center From ff6a495a6834f738594dd39dd428db36cc4c1ce5 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 31 Jan 2021 15:30:33 -0600 Subject: [PATCH 17/46] Use new windows for more ViewControllers --- Slide for Reddit/AppDelegate.swift | 65 ++++++++++++++-- Slide for Reddit/SettingValues.swift | 2 +- Slide for Reddit/VCPresenter.swift | 95 ++++++++++++++++------- Slide for Reddit/WrappingFlowLayout.swift | 2 + 4 files changed, 127 insertions(+), 37 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index e53e760c4..ea112ff47 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -490,9 +490,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.preferredPrimaryColumnWidthFraction = 0.15 splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 - splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 - splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.60 - splitViewController.preferredSupplementaryColumnWidthFraction = 0.60 + splitViewController.minimumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.25 + splitViewController.maximumSupplementaryColumnWidth = UIScreen.main.bounds.width * 0.25 + splitViewController.preferredSupplementaryColumnWidthFraction = 0.25 } else { splitViewController.preferredPrimaryColumnWidthFraction = 0.33 splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.33 @@ -1184,7 +1184,25 @@ extension AppDelegate: UIWindowSceneDelegate { willResignActive() SlideCoreData.sharedInstance.saveContext() } - + + func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) { + if UIApplication.shared.isMac() { + let size = windowScene.coordinateSpace.bounds.size + + for window in windowScene.windows { + if let split = window.rootViewController as? UISplitViewController, split.style == .tripleColumn { + split.minimumPrimaryColumnWidth = size.width * 0.15 + split.preferredPrimaryColumnWidthFraction = 0.15 + split.maximumPrimaryColumnWidth = size.width * 0.15 + + split.minimumSupplementaryColumnWidth = size.width * 0.25 + split.maximumSupplementaryColumnWidth = size.width * 0.25 + split.preferredSupplementaryColumnWidthFraction = 0.25 + } + } + } + } + func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { if let url = shortcutItem.userInfo?["sub"] { VCPresenter.openRedditLink("/r/\(url)", window?.rootViewController as? UINavigationController, window?.rootViewController) @@ -1258,14 +1276,49 @@ extension AppDelegate: UIWindowSceneDelegate { } if let userActivity = connectionOptions.userActivities.first { - if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "SUBREDDIT" { + if connectionOptions.userActivities.first?.activityType == "settings" { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: SettingsViewController()) + } else if connectionOptions.userActivities.first?.activityType == "website", let url = userActivity.userInfo?["url"] as? URL { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: WebsiteViewController(url: url, subreddit: "")) + } else if connectionOptions.userActivities.first?.activityType == "subreddit", let subreddit = userActivity.userInfo?["subreddit"] as? String { + let subVC = SingleSubredditViewController(subName: subreddit, single: true) + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + + window?.rootViewController = split + } else if connectionOptions.userActivities.first?.activityType == "profile", let profile = userActivity.userInfo?["profile"] as? String { + let subVC = SwipeForwardNavigationController(rootViewController: ProfileViewController(name: profile)) + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + + window?.rootViewController = split + } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "SUBREDDIT" { VCPresenter.openRedditLink("/r/\(userActivity.title ?? "")", window?.rootViewController as? UINavigationController, window?.rootViewController) } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "INBOX" { VCPresenter.showVC(viewController: InboxViewController(), popupIfPossible: false, parentNavigationController: window?.rootViewController as? UINavigationController, parentViewController: window?.rootViewController) } else if let url = userActivity.webpageURL { _ = handleURL(url) } - } #if targetEnvironment(macCatalyst) diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index fd577aa38..15fc9772f 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -500,7 +500,7 @@ class SettingValues { var columns = 2 // TODO - Maybe calculate per device? if UIApplication.shared.isMac() { - columns = 3 + columns = 1 } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIApplication.shared.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index d0352b59e..f30c40289 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -39,11 +39,15 @@ public class VCPresenter { } } } + + if UIApplication.shared.isMac() { + parentIs13 = false + } + if (!UIApplication.shared.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { override13 = false } - // Yes, this logic is a mess. I need to redo it sometime... let respectedOverride13 = override13 var shouldPopup = popupIfPossible @@ -56,50 +60,81 @@ public class VCPresenter { } } - override13 = override13 && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() || (viewController is UIPageViewController || viewController is SettingsViewController)) + override13 = override13 && (UIApplication.shared.respectIpadLayout() || (viewController is UIPageViewController || viewController is SettingsViewController)) - if (viewController is PagingCommentViewController || viewController is CommentViewController || viewController is WebsiteViewController) && (parentViewController?.splitViewController != nil && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { + if (viewController is PagingCommentViewController || viewController is CommentViewController || (viewController is WebsiteViewController && !((viewController as! WebsiteViewController).url?.absoluteString.contains("login.compact") ?? false))) && (parentViewController?.splitViewController != nil && UIApplication.shared.respectIpadLayout() && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { (parentViewController!.splitViewController)?.showDetailViewController(SwipeForwardNavigationController(rootViewController: viewController), sender: nil) return } else if ((!SettingValues.disablePopupIpad) && UIApplication.shared.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { - if viewController is SingleSubredditViewController { - (viewController as! SingleSubredditViewController).isModal = true - } + if UIApplication.shared.isMac() && viewController is SettingsViewController { + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: NSUserActivity(activityType: "settings"), + options: nil, + errorHandler: nil) + + } else if UIApplication.shared.isMac() && viewController is SingleSubredditViewController { + let activity = NSUserActivity(activityType: "subreddit") + activity.userInfo = ["subreddit": (viewController as! SingleSubredditViewController).sub] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + + } else if UIApplication.shared.isMac() && viewController is ProfileViewController { + let activity = NSUserActivity(activityType: "profile") + activity.userInfo = ["profile": (viewController as! ProfileViewController).name] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + } else if UIApplication.shared.isMac() && viewController is WebsiteViewController { + let activity = NSUserActivity(activityType: "website") + activity.userInfo = ["url": (viewController as! WebsiteViewController).url] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) - let newParent = TapBehindModalViewController.init(rootViewController: viewController) + } else { + if viewController is SingleSubredditViewController { + (viewController as! SingleSubredditViewController).isModal = true + } - newParent.navigationBar.shadowImage = UIImage() - newParent.navigationBar.isTranslucent = false + let newParent = TapBehindModalViewController.init(rootViewController: viewController) - let button = UIButtonWithContext(buttonImage: UIImage(sfString: SFSymbol.xmark, overrideString: "close")) - button.parentController = newParent - button.imageView?.contentMode = UIView.ContentMode.scaleAspectFit - button.addTarget(self, action: #selector(VCPresenter.handleCloseNav(controller:)), for: .touchUpInside) + newParent.navigationBar.shadowImage = UIImage() + newParent.navigationBar.isTranslucent = false - let barButton = UIBarButtonItem.init(customView: button) + let button = UIButtonWithContext(buttonImage: UIImage(sfString: SFSymbol.xmark, overrideString: "close")) + button.parentController = newParent + button.imageView?.contentMode = UIView.ContentMode.scaleAspectFit + button.addTarget(self, action: #selector(VCPresenter.handleCloseNav(controller:)), for: .touchUpInside) + + let barButton = UIBarButtonItem.init(customView: button) - // Let's figure out how to present it - let small: Bool = shouldPopup && UIScreen.main.traitCollection.userInterfaceIdiom == .pad && UIApplication.shared.statusBarOrientation != .portrait + // Let's figure out how to present it + let small: Bool = shouldPopup && UIScreen.main.traitCollection.userInterfaceIdiom == .pad && UIApplication.shared.statusBarOrientation != .portrait - if small || override13 || respectedOverride13 { - newParent.modalPresentationStyle = .pageSheet - if !override13 && !respectedOverride13 { + if small || override13 || respectedOverride13 { + newParent.modalPresentationStyle = .pageSheet + if !override13 && !respectedOverride13 { + newParent.modalTransitionStyle = .crossDissolve + } + } else { + newParent.modalPresentationStyle = .fullScreen newParent.modalTransitionStyle = .crossDissolve } - } else { - newParent.modalPresentationStyle = .fullScreen - newParent.modalTransitionStyle = .crossDissolve - } - viewController.navigationItem.leftBarButtonItems = [barButton] + viewController.navigationItem.leftBarButtonItems = [barButton] - parentViewController!.present(newParent, animated: true, completion: nil) - if viewController is SFHideSafariViewController { - newParent.setNavigationBarHidden(true, animated: false) - } - if !(viewController is SingleSubredditViewController) { - viewController.setupBaseBarColors() + parentViewController!.present(newParent, animated: true, completion: nil) + if viewController is SFHideSafariViewController { + newParent.setNavigationBarHidden(true, animated: false) + } + if !(viewController is SingleSubredditViewController) { + viewController.setupBaseBarColors() + } } } else { let button = UIButtonWithContext(buttonImage: UIImage(sfString: SFSymbol.chevronLeft, overrideString: "close")) diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 1edbfd330..a9b870869 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -92,6 +92,8 @@ class WrappingFlowLayout: UICollectionViewLayout { if isGallery { numberOfColumns = SettingValues.galleryCount } + + numberOfColumns = 1 cellPadding = (numberOfColumns > 1 && (SettingValues.postViewMode != .LIST) && (SettingValues.postViewMode != .COMPACT)) ? CGFloat(3) : ((SettingValues.postViewMode == .LIST) ? CGFloat(1) : CGFloat(0)) prepare() } From f6a64cd7dc8ceb5037e41be968a907c9fa1efaf6 Mon Sep 17 00:00:00 2001 From: ccrama Date: Thu, 4 Feb 2021 23:18:48 -0600 Subject: [PATCH 18/46] Fixed some sidebar bugs --- .../xcschemes/Slide for Apple Watch.xcscheme | 25 +++++------------- Slide for Reddit/AppDelegate.swift | 16 +++++++++++ .../NavigationHomeViewController.swift | 4 +++ Slide for Reddit/VCPresenter.swift | 7 +++++ slide_ios_rounded.png | Bin 19729 -> 0 bytes 5 files changed, 33 insertions(+), 19 deletions(-) delete mode 100644 slide_ios_rounded.png diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0d084ded0..0530f2df2 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,10 +65,8 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - - - - - + diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index ea112ff47..240b16135 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -1295,6 +1295,22 @@ extension AppDelegate: UIWindowSceneDelegate { split.preferredDisplayMode = .oneBesideSecondary split.preferredSplitBehavior = .tile + window?.rootViewController = split + } else if connectionOptions.userActivities.first?.activityType == "inbox" { + let subVC = InboxViewController() + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + window?.rootViewController = split } else if connectionOptions.userActivities.first?.activityType == "profile", let profile = userActivity.userInfo?["profile"] as? String { let subVC = SwipeForwardNavigationController(rootViewController: ProfileViewController(name: profile)) diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 7eb58a7fb..9e65efb36 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -670,6 +670,8 @@ extension NavigationHomeViewController: UISearchBarDelegate { DispatchQueue.main.async { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() + self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.searchBar.becomeFirstResponder() } } } catch { @@ -694,6 +696,8 @@ extension NavigationHomeViewController: UISearchBarDelegate { DispatchQueue.main.async { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() + self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.searchBar.becomeFirstResponder() } case .failure(let error): print(error) diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index f30c40289..43fc88e5d 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -80,6 +80,13 @@ public class VCPresenter { userActivity: activity, options: nil, errorHandler: nil) + + } else if UIApplication.shared.isMac() && viewController is InboxViewController { + let activity = NSUserActivity(activityType: "inbox") + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) } else if UIApplication.shared.isMac() && viewController is ProfileViewController { let activity = NSUserActivity(activityType: "profile") diff --git a/slide_ios_rounded.png b/slide_ios_rounded.png deleted file mode 100644 index 5951d2c838b5dbb83197cfa1313b2abf212ff35f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 19729 zcmV)HK)t_-P)}+wP4%jZs$wot85I=~N*Q9K0#1OoX;2i=v;ksbqM)Jz4oQC&f=Rw^6M@(< zgSLhGIizDzO7c(8FxZ{M?kELdhdN7 z)O+`yv(FxW>$iSu?cr4PB>AbYT(fF+Z0zJ-U9aj;Z;h)~UDMH2)kjkuE7_}ws@i?G zs;PEO>3jE!zc$`b^Ns47bhG=u@(&94;P3GwF2ns>scWehE=rGq=lRd8_@%CoRY!PU z73&+T6zZqygAb1NuiNUM9?9*9b;r+r8{G$~o!cs^H#YqrF0QM36H&FPs_IQuui7+Q z&u*Ul%HB;+1}ORJKi)snSD)rUc@}kgYpAZ)P)%z*DiDl3U;?06(+I*e))r_01PBTQ zyaTC!c0y15T?2^AM+66}6R6hp@t0fo7C>4%ps^vuXJrPH&<%ao7-Zd8xav~}Q~+}7 zbIZV>&S+qw>}UYZ7&-87tUL9_4t4Gv|I)6Fk2kg+H$YE)@R!c7sCNO?bT(0abfkg^ zrUGLzV|eTW02)dJEJcIxSg^pNK-*AW17>`lV0mEgR6ek8W>f{xw;5Feva3HcKek!- z0fSv$iWGzbb$wPB0=S!=ySOK@a@KV<}G_6F_?) z6MdBG`qHFLGfANb3Yf`~8)7UidBFpq*obv+i5-!t(=&AWC>emAECA{<(lxHDds6R< z?|@k?$&d^~$&o|`(OGdj+0f9y%sxQ2RUScfK%nq73(l%w;k(x;xgnj27+g4ZWAfNi$Z98&AQZa;X_`k+Cf)q;zuv zm)A~8BP*6fw=eoAUMCn3Jz1!ez^v7;8q{si(_W&jJ_v5CqrM0G(gSg2}>(3F@E?W@-5`kNty+AhQtQMz>jNmT~C^k0^eg)TjSb=mlTpP5r;WKMvd{>Y0jrMmiL$P07sG`iF@5QBEC20}}IIb#_x5}lHB9oEW@ zdO+hK>Wl|prn4NH`O(Gt?-&d?n(A{Qi@R>#~ zd7PGZV0$fsfLojNXhA-CmFhvgZeQ7Yp8-Anp))>5Ro!T1Y)m%DhAYz6s@c{ok3nDP zcx17@k|U0Oa4WI@I8TcKoRPaV<%+?I+K^f$3xWm*Tp3(IvK((!Zort~r7YQ%t^=?O z1JikN!)svxnp<6y3(ttf@_>G9*Nu0(@2fV@wqb!iG@$FXXRn%_n)+PrQ*jXE2p7j0 z3uGtgB{MK74N?pHqRZ7xkwAwj!jfTG&j8?vvMqoC0JSv0wze92$w*5cF2)8ZNg|NV ziIuE>3V_#=g9q8$z0rTdczgzgZ;|oVV@?_+BiPjd-<@S9tzM7%rjHdwK zpfTkIpxtndjpgZ%jZEcTKFgSfK;=wVOE$q87;8}Zv&?lWCNzUeOBNaTWvN30Ou}6= z+ZT){bzYw8OZr(<1D@CDksNrXIzUnh=J}18-I8Zf?GcRL+RsCSdSE~YFi+i1RE243 zZafZ_m`2u~(Hg`7S)$0k%EC>}+M)~lq`*Qm!N5|=%>Z1cN0oLqy;5=`O@Ai0r=Fd# z4Q=*SlSWlzAEe?-{frqFZj%C-204yJ7H231Pv2XHiC)nHb^3necz1B79vILwAO3f@ z)Ks|{KOk4_f>fYlM%Bo+(21JmGb_eM>&yu=1J3Nl=dgDu0Rr{2pZF*QaYaD+v{NCo z!*xclV+EZ}m&&yvI7t*WuFfV1?^jU(H1w6FrL$bPnvCN6TfG(nvJYU>SjK+fxF!7w zDMBQW#vnG1ck6-V$3TD%0U*U$KPD}s6MSh_=fHpoi;n?Ea{Jmq`sqsOpse!&WLYp) z(1UG3T=rd0O&lqP>uW%0aKO}>0aKO)GZX-(Bq73QjpT^IY?eWR=UN_0rvkJ3uyLYy zFgyTPCJ~hmu95sOzOsnR*LmH<*Ls&JBxQg01$0c!eJ(G^U`Yh4710(g-*pJEn79s~ z3>~KjqZoW?);1;#tQj?($ISq$B6KS~m$4-dmSOx_-}2}<4K>;Z2VUH#Q1HT_*(tK5=$2W zJ@t_@)>d`xR?OJ}Pcbc~-D-htg^@&*8Wx!ap~(xBbe9G+vZIkV7wxlH4LdlEI!y8F z@0H;u?}D*~s*?ae2c@8ylM!n`HUsSd9l8cAUi7CB(|O9xj57?wM>)voNnTdRCLn40 zwITbSaRbuIe8Y7@|L9rN8`p%DyX*q;+gfCr@oSQ%SjSqkXF`ZXIC+>mBP zE<wJqT7eV>Yl2`3Mx(D0%w`0HictfQl_#>iPl>^OU#dRQ zbwK0fZCa+xgnIOiZSYz}hT6#B?_Q6NncP6xwl5RV(;s@Vn@hh$1ZtdP)*wPNDFq(l z9>vDlJuTDP0yqWG_Zvhpa0a6!paRqB`uj2HXB;hTFN^^RVnDBxv3^)K8tz6=*M13h zWFQ==+{5TPwSk-a5H&Qiv<|41@rg_r8$_lAfbdZMd1c_g+c2@7UN0Nf?1M_5$2H9l zqz^2>rO6Z?X>?}-;q4nwMMJfvV%ePDYhhL2Aqr%olX+a#fa}i2j?M0mEZCQE)eNR! zwt{x_%^hazm0~mhNF4+NC^XOo&RdL6GpqnH-=`Nn8Eh|z1ny%)!haJfsWu9kO4RGn z%P0TRZSiV;GKRL%?!+-y~uJFbKx_@_ja9|fDi_~RsR}ZLb!arM#b2D zB>EQXRT$TyVkCn&OgT%WwX^{A^aoG7fvDp)wHg5ix|KL0Vv7|3T#I?D@p_){;{LcFFs)Z<1E>ZTFnK>9q<&GXWiGsDgA4IQ_^XZO@jL6< z0X>B9TnJ#0E*@E&`UGtFdkd0-y|d;*D@EFH;LQ`axLNG*BLRKQ>5iR`PQbxm_)61t zKu2iyu^0v=L<$O;8kPetW7aR-1};+&D|euEh>T^p%Jm8WT9QMtT_!zB&p`JFslHTq z1c$NvJoX#2bJNX6j@i_~26)*ZGQu!Cm2PLYe-w?{=!0xhMPFm(z|B}~+r)Z0Faz|| zHK$)tRdh>elVTLPr^>*)m8dUFo}{}`cNt*gdT<*s8cwzdgDz^Nr{!aNvdG=o!I7@f zrzBajMNby#^&Q6Y00aU8$chs(W>O3Y(kLC$l%)`@qZ70ds=0;~#~9jHdw|p)%Rqso zM7v89JB5iHac>Ulis-WO_2hTCB!-^8=Jc4VL-$}=79z)*9prm7h~j;k;gb&4x=y>t zXlOzF6 zSe;GanL*W0Z2=fpRc9@dL2w1M{kvK+|>ElH$_6Z((uD+GnHR!MevK>M@i zDst;K)DLtz0!r&8|6L0}xU&S_!P+&mWL^b8ZyE!#nr12-?1J@MteXZ%yIsrkv;i8f z&*Bh6lAvS|2E+A`?X%Z#U?*WtJbrE&jR0gRk3NW(#IdsKtTQM^4jaKQh|JW`0ewC4 ziZ(hRsG~W-qMC7hnTmE3u#-pXo-{FFVDbf_BxKS&yR?d+2HKk|Aoc;Bgy7 zI`&H#$j15g9Rbi+owklTZmQb?8xF2zA;v;-)T82-Hq8yd&KMIHlUo5~DagPwg?lKR z2pZdp1IPh#ar38QAu$LArbJ^!5Vp!5?FHg!wWUa{v?YQyb&2~$XpzE!mzo^7Fl)^@ z6Oqbcm(sKS+HM&J0y<8zM9Fb#SSIQlmHeV&YdtuzF{V6-WfZj>bcB_cMC)~BSay_k zfWbz%+k>Ceqyy|-%%T`e5@@4`flIcpJro-XlEVP$HQ}Z3hy^D!EFW*I1-u z1(=EO(71p!1R+}2v=C3p3lu$_ay~?xCf3t25zwc=(M7s~tebdI2o8!g5pfuysk4y* z4b3fd95X*yf69m$pWy%`w`OQK&1h)(+9u4&9j>x;1lIh5)KeP0aRZI2)}NaJ(TCIsG>slB7|x8_fgn=U;+19JLcVm(!r zJ2`)5Y-DSG8Gu0tNZG|uGb;_30fku(78G%3`=SaRo@~iltYjGo$P+P`1=lG~+_&nG zd~~y(xabNskdP=^*fmQ7vImev}KQG7PV4XllB2GxpiKf;uoKZKl6E=mUt3Cw(*mILr` zEmMS%^%*2=zb{8kuvlejR@Qx(0l~=8iu9ubf5yJy0ZsMPz?&c{Y*NjF($vv~L*@&B zwSv5?9!k0*L(;Wd;IwgB3#zN@CMe$k~=liUQ0ovZbgSO?rvy3k;l)l)}H0qL3U zOn?eI8-CZ-K*m6~#wgIUau(pywZ?PwK=I$Hu6job16VVkWn9LZ67?>Zu(}R+c*i=T zmy_(I&cU;uq0?#Ftt!I7Tyq9y0AcD|+tb)@X3$167^vNhVKsHti(IPXqcZSU?V~NoY62dW6eGif;jW=B8O+<3LzxzZPRDF)0s726oMuqStLX#z4=E z6ned=RSl0*Do3?NY`IF+jQ!L1dAe@>*c1D`)Zcn+v=JiFSPZUaVFj$Tw3lzQd8_+GdMNz)*&yr3qSnQIcR51k2Mwn-L^sGQ}7W zEn70Mwx!vO_IcY5{U11`AOrMsg?AYc%&CkPsgWuIV71bM>5&TLx(|mjL<7?`(VYR% zbp&*ZtB{%SPGyA%{w#GvP-oHojSLIF^^qE)Ul5oBWJoM<;dtr5JJkoJq9wCbE*#5A0XKUZ?vTDL z%TJGhb_|^wz^GR9_V95cT=`4W^<2pWs_d8WfyHv-b1 zpkSDEGsqvj7rr-LqbtmKtChv588G`XYwY9Hm$DDDBMY*?Of3)4UIqI;u_6GcANT~I zV?Skmg#Bx!>+pLmYmiI}_%SdYBnJYT2V6*j65U&$8_~L@r$q;&jzw2%eXd$zb-dQ+ zf_1D;ZYxu>h`K);SR7n5h*(aNblR)vJ$qb^0p#?`3C+F*BPhlep$<5OUPVtMcENas zfb}R4hL%5>_q8%l+(!jTS@PgELAy`4IY4jqXV=NyScUY4yGH|AcPx&Y0ea0AX>0+^ znYUreo$7#PrZLoq#o(PAnt%Xb57LF2U!mNA$aj$F>9V6ZgcEYJL{meU|j|~Rw83@c#_aj$Ucgq zG<#sDrNP2FVM~pCc&4-UU}`<)zE`?ivp#|*xo2xFNy~tzdc{7<$|-oZRF}~1{Oo7+ z0$@NDyst2If$}!VprUj#jXLyKT8Ut+IAm65zRzDucqPRdyN0GYq8rr&?E z98m_Dwn(vZ%^+$sRcC2m!&*~iOYTeo!D^fse0{wzc@>PdWj_kuM`&BidlWJoIJ+hW z6&lp4n`6K0*EqA$iKc`UnP0lZeUtjg!BFRk0q}8%5?I;WL`;Z3{S&aCELP=b;n?GK zMo?`MT7OhWK!XV9=O8hf#}%l;88bLg&9O~+O%Q+zZ;h$}8KV0My#;n?QWD0pQw#Ko zsT7k44`f8zrhYFCCbFl>9_eX#!>xx$DdU3Yhp*Y&FuVdtnp@#-ONON4(LiIF!9Vyh z^m>{dt)Z`jsZ{>@=vVA)Rx-i?&;00*w2a(1qO==EpMQui=|r`)PkiMpe_wia$#6sE5A8Nv~66I3fqU`;f+lE%)wm^w$jfJRSytqI)0;SsK^ zcWM<;-n4jW005_JW6H|XwrC_pBLG(AnreL;)mjD+q^(qb0hFmp&>iRZ->G6n{~apSd%!g?}T zGX{s=u>wSk`2|yGR#)jK{XP~nlvH2a2sszv&xVedFo2WoMF8{5uso12yoN@fcg8*r z`~2TFd;eWD{gvw*U{?Xyp0(re0mVG?*y!sdOA=`r9&o@aSJUr(epK)+ck~nK2=K%+ zYS2^hSXlsysdXW+w6}f>f(z4j$$z|_Mo)dsfW!OvUpDi%U!bY4UQhLwO@Xni0O|nR25KB225HhF z1BYxvU}ymX0Ai6%^;0za@X!?GN->2e&=)aMu+|K?kaDzGu>^E|Z3aNpzi6cW-X6<< zmq2fdmq6yUnh*TEybSGetnA=0cJ6P`#D!NsVbWqqT+!aITu;+qxsIw%WNOyZI1!WB zI;3?PojtsE=K2MO9_WYtfx6fNmc`O0Q*wSv`TXR1H0#CdvMdKPxw@ViJL{kLfb76V zOuH7|RF!h?4ry30vNM2{=Z(cnb1_FAv@-*pwX#kIDlVML__30;Epc4*IZoU1VrnJflY+9>;lKO~8DK#f%x5BPh{G z0L5q|T%Drq(ZOHA2vR+)JhGwfvpOibV$wj2-1%8eUQOuZ;ANx40O`RR*|Ty@H1@JL z)5P1Zr)uenA&2$Jb@`spet>4aaT9eqp$?x!L%TlmN~(5mPhfUz?K2;~ zzrrje|L|1CFb%7w-}Ah9$b%kTivjzHb;0gd#z9#HOBfCOWGj|m=PZNTm62MlwQX#N zg(w7K0&K~H#0xSbHD(*5Anx`Y+e&ZYnW@8pU$EC8HEODttfZyCa|?|e_55MR@F{hz z)785^{7RyqZ}M#IGa$^=ZagAH7|g@6bpUi@6H;cBy2_FtBK6XCBRs-lHg~JuIgDVl zY$|E{Qbq#ll>^9j-8?%>)U9iB|2n|U%+_8CxZk_oAPXE=8L#0p+CnTKUo^Z+>~c-9Yz8_s~u!KlW@T7b}Jdn5e5Gn)e0N z0nj)&mPxc_7|g9(2GCk_+E%7Q0Xh|_w0oxgn~aTP(Wx1tsp*<#yA{oLYnq-3z{Nb7 zEYS)m74wVW6;g)L;{;qcM%yrRG(wkOjx(H&)t`R(b#&;3@0f4QJn74u{^rfJ`-aPC z#HIA&q_fX}u=I$O6&5@V_7ee(uN8&?8mtUNUR*r~fM#9I?8X0P0EeK?BTTQ&MxBGR zb>a8ft^+R7o+$@jqG`vtv)~#MzGOfreT89ICDs=ik>)uKHw4CEW)4y#7*YUp$Z8z^ zs~@1%m+U{;jA0?O_e&q6yc*Eb@btg&@=_{~ z0h$0^kn2Tn&^U5r-n|~g5PX?ET9{geb;H>j6OYW69CsnbCl4YI`vAjUz|db_YQ*&1 zlH;CF&-t@&4U2*O?)shAy@6)Gvq6H|%`htIF$hyfKr8l3`ZT)Eetge^%d=vF4SD$~ z1Ef!;#F*E20Cu3=0CYWb+MobykT%YE;oyuzX@eGm*tH6dHL zKYSIMl?6dJyLZ&rGedRj1bAL&s|UvYdGowN&umAFo?8Ec~Jq*pSn49`A)Cw-lN7(@KhOh@e(Vj@b<$(R4iX2^(-F`X(`r_Xpx4vk3^cuM z%Tg9eKL?OI39);x19Hqfh)f2cPM2lsY{{C!K)u_Kb_-x@44Lm$z(otnSUg;7NsT6} z5y2dv8MJdnCw%FDFG>x=l)DdYrX5$j(C4Q)^I@@cTW-2xXz>8l)W(xJ$YCbVE>W7? z?~@CY5mPfY?c7bYa}U2pufUF&T#}%WG-GNe`d$AR5tGj~3a{09uR@yHq0+ zk;#bC*fd~qOzZ&cL7dXWg4@_n$HKHh4Unf!dCblzT(-< zcq1Y8Til=0#&FU;Xz4xE746^zubVwQFgw4?_E*^(aB^ySYk`S1c; z^1$XI*|G2TT||%Wj+(f*SQ{AF%vMAYl>i&WFR(gF2d=gPvX#lmBvV2D0B}<=z6lVp z!a**4c`tehUITLCB0CR+Xu;B*z|tv|=f;dBhao*Apm9>9q`VCPI!UqhQ5WO|2CgbT zSkOqfSxrLsj+n~4gkF3ER2g%=qWCN~EvQxQM@#@kxf9o2#FtwJGqb%$lhtV0n$OX2 zyH5^0_u@tEJP@42MLYlWeKh@z8$Fnrr3cZ{)%3fbCG%k{P&j@^W&=iZGGf~E{)yXOt!}KD8D`pbdHbPb5-jdM>d83}ij({Bi8;DL*@{t1x@L|Ee z-xKI3QYw1(C)d;RHBX*h+CyOL3AuFo-aBc>2VX&>o!SS7{y#^~agU;3`(cRa2T3F3#}$J@7t91%5z}n}mFln<$V;m?oY zW4o2h;kurfCANhjE-LL3aG}iNtfO71KO#1!5B={rmtz@Jn{lP!l;4uY zvH|~(+F_fBRcn`m7V@dz=?cdA*(6Xv>9%(3ofFIxQ`Azgs%G z`r&^#rWrAl3N2ZH6DgYAOERTE@#*6b*d<05k1gG6fDMy)*eu}1 znM&Aa>xy>A8pKC9(hk$z6`gw5Lkk9ck5xk-e*GcT*}K)AWQpvYG;{#8rclgBt7?jz zbNr53H!b$pX$wfnCHyNp(f~%SYcB0{H|U8SRiCt17$rrN2tg>s4G0?S@$byQ6`*6W z?jJr}F@d^AGwl{DO5kOkw!pAr?nkQM^``m<)hV`T?}_EBnMQl zsH>$W6?@P@B8b~9{ce_D()F0xP&bO|;H)12ncJ8o5dglhBPS#~+)IAk5>Y$_DWvU| zo%|Ad&P}(>bvzgR{oB@FNVEUocCv)n%IRpHHT29Jr@{TN3DCaV^cl;51d$!EWQfu4 zalw!~v8?&Q*Ne3*WRk+RFsK^b29Q-&1nvlBY7MR@VdONVs0U{>LNQ^6(8~> zGP251Wl73bOGLF1;l0)bN@zz0V3rzU9ZGC-_Iyjigvigaa#*(!uJIce;-+!;yZij0 z^WH+oeB`FNj^~2Ef9rq#HJbgF4QO7ZTZ9`4a^mCAH?+#Z%4r5o3Y1Pe6k3}@4Y<8XsfIb8Gl=Y!9^ zn2!1FKU(mBoNEU-K+i-#m)3Q7FgsBH@O4L-8alouy7-bG9OAUjo!O6rHIFF>2;KJ> zZ*n18KexDfA&VGm!ieMsoCHS;m>A%uURU~GEm7s{hp%E>v*GHLrn*^n^a4X4``e2Q zJ$FFAoo2qZ&adV0GlqIOsnpO%dcyTO7qSV7Gg($!yQi{14ku@T*sO*6g7_dJ6YHI| z%eUBFdzL5zglxANHlMMhS+%n zbcaIfE=_^g;Z+xqx~qQhx+BGCYt@_)YV!WJI!%?&a=03tRx@K&@NKG^In7L6xUZ>^ zLly%PUL2Y+zY!x?vyNs?8dueYX9qxs{IioFD_`Ld>X>ATi|&jPn~d~Z{wbn;TX%-cgWATKp|r;69mL2~qZ9XkE*w#;=r z7ySJXo_{EH_Wr^EbbPP431|jQ+Cl}cmV>&Y>}V6rpi=?+@_aaWmMN{njpq4BC0(2V z?Fz)#*0rSr^+ZckVY$X6*2iZ#B2x7FT zX9!2!LjS_LXdfK@;I+@NsWDq|7lCO7O=9{2(sb6mOvc1kPPzF^*Z{8H0M-`l?(3%w z44TNlhCm_jXQkQ2nRs}$*y$aoz5Rqr05~sBde-lLfet!*;k;^MUx8b?Z_nL#(IZ#A zlEz1SK3$h(Is8kQ;-pF$&=!nL>I9#xB#OS=Gz424^WozGZb3%y^toKC%#tNu*P0%T z;MLa%CT{>9)@1YfA_B?HPPEu2e~d%ip&|g?BRcd=@1$eifBk%q^MWaF+h2T&cKzv< zG&Wi{dFXURSjb7^R;=m=uYEd?w9>IkQ>rm-7P2Au8Cac=zY^eSD^D_Iny~gogDw`t z3jt+GvkS5=v9Xdn5Ln_J?sdNSHy=2|Qrb_hAVWKVcPm=H=4Eukrx(|A?5hPn{5x;- z3zOWAmC?4f9Gr{xfc7H=6A2kX>qSc${T2@PFtoM7h(ZN0hQpi8n?=XCz^Rx?F{DLP zNGuP|;zO?iWy)lUUMB*2K0Xd#Y3wIi(t2p3&azdsX8lJ0+P1}?;d|gGuRD}Rr+z`B zPCqL^yJ_&W(k=n|HO$cJVM$|ZP+9??p;^UgO4;;Gz5?6Ng~SOF0cO5S(d=W2W^~{e;9A5a5t{ z6AG!A_G^OPbeM!L(&+$w_(kucW8Qz=u;aPluitXxRW$XD8)3wWM>H$m+mu8iO5+rxXdZfx9&f2?ij9cF$qvuTh{U!dciVJuW&!fC zhCzs9z4&U>8#)uB48}9G)6H@3tj|Zsr5|Am+`WyqqR!G)bo#e`wBP|cYzO@KqG!{{ zFCGZ{2{C1tP9%+a=;)+F+RgzworV-y%?~7N>gFw0X$4;6b+b)Q0RwnubYNirT5>ds zQtQkaJWGqm0`N%N%pkP^03yv;)6(tyS#C^R)s&0og-QO9b3P8tZI-R*d7r+OR-W>b zVaIgAUhm|_miNDs#z%TVJL{EpC^vXfr=R+El7ls6miCgn4Ra1`WJ7?Q1Wfkszaog? z1f(QiP#Z@>OT}kYX-H{{&0*s!D+g0rfLuZ5=8scKzA=C>TNtKr{O^AHJFdLzRkZx% zv*^S>Tg-M0YM~EZ{~I)Y`#KtPfcA1j?p6^2Ap-jT^H$gHgdnC`fo-+KB8(@bKsZ>aMg)QZx-g4xwXjDh=RqNUkU;!3o_*?f1mJf=YD7E#qCSt6KO za(H0-$(07s-EN0|>GlT}vmFB?{x*@OEeW&eYsGt1bo#iW>zEL<`qife6pd{ zSwAOMHkdjs_z&+K3^FPnEW^nk7-ONW&FY_Fnc{Q8IK$lttXfFWJjm;C&**VC>q zUhB29KQW1C2=!_HFhiIq^!{^K+q=F8?o-8k$iV$(2Q@%5mB13gcn0#VMZK84i1gf4 z$1+NIxHb^}N(YG?FT~=)Z9!__F7S|-u85W%M5o@mn3HaUmSg9Cd+)1ha2bz9mTqUt zpMU0h+WEz6Y1}dMAaWxE^f?aDalp*gbU=URT8a23S*xBp1%_B@O9N*1Q2>-y9`Q`P z#KZ#!dfp=)0<-}8%7zzPmeEV0FAC94Y8m~J_r~K7MT5`nV3Oo%Nubtm? zJWY7*941ckeS~qB3I>7@M^*Qqb9hYKx%C$e?Dpl!O+^L+nplj7DMG`AXJwbjF&^TW zf?38M>h-j{MinARzE7Jo?;`_E&Y|bChVcY{m%j5m!2_WE`i>W!MJN6F*9R7L3+2KG zuX_hged}{xJG-4JJl$QvA&vS>J6@R7XlMp>>NTcL^{<50I zj`)?|Tqs!W+sDqJxnq*}=P6 z;y%N$zJsV*dN954t9LC*4yRu9QU!hZgguLMC>uB6d4L8LdCQ`zC zzU6yWJcy0gP+;NJ{jWZBz{svJnI}?mdI}pJC6}_PWuFm{u_hr7i#tZt%%ogAQi>RP zLI&2Ppu9+vHD!5`sr1}6C=C)F9k;>bJV=iKYMwoeQ{z5Bbc>fp>Dkx*F|9uTEej6R z+yD9t^w7tDoyNy|VgY~3Y{1MQ%MD)tj9g~`8UrEKul_4w=t6Kd&}cvgLL?(%?L?ML zus5@y6|fc7E1Mo6SHjI@07!N~XjB5wpf|F>Fg(KtCNaa|F2PLzeDgc4PI5Jmx&@f<3x%fISy^|P?(9(tJpG? z(IPvPefZ&xlQZU$O`&eA+%M8A+oqC9ttmj<`BKzHYE~bn&SPNfXRE5p55Rbg!rf>7 zWj1ks$)%jU;sAzru5`9r(`+|Nj&7Ju?Di^}nIW3#R`j#6!|3UM{MYo{=RS9Tz-wz8 z9GEx1>s%V2c3=*>xp^iqoc)Y1+6>DT{8{?ZuMZAr*O|>=6j6q93UsgiN;2VCdPu6n{W&g*AZw&Pk%?I4sr>O z27`r5oZ(=Go^`ih{$T;sjdVbk!ZwEQB=q8Fkjuq17`N3aUElw zn#L1wYnq&>e3UKLO8N3F!!qgx*9CTtz>W)-d@kBAD{WTb&AJp`m*|^Q2hxo@o<`kn zm&V4%=;I&%IKApsuiEdJde?WqO+WqMMKn77h~HMluW55TW@d)o`qsD7yWjn8 zI^ci3m zIHBZ?OoWNam=qZ{K_cqun&@Y<6ZH12FGyf!Kr^_frlx51>ecl5&wrkt{`99mWW zPd<7qeRJ=@ab;d$X#UUL;xx6BAP(40g1qNF?-{h0p3v(YEC2k<|CN6J+3RRxtQ(HN zMV-u|r#Jd#6^? zhju(KftdjumYoJ*^Jfm&PJ$eM_~BkxUwGk#{l@hP`+nzlzfJ%8v3F4Y@Q=dwDZk?c z-qXz|@B>S87Q+ex2ay@rSP5vc&eK9!ih_&|Q#zF=-I)Oscnavv0=(ur2ja8GFWf&JnazxW9Qu70os^22|AJ?;M9T{JNfR?IPw{X0>7;Mb%--I7rL zJY_UoV!=~$v*KY;sgZ=leXlq$_I#f}sR)etg}}N30!Nfcmg#zaJQh&-2zSM@z{Zmk z{n*p0oCQWpgA_n3w7e=m83Qy3i$PB&^6x=*d~@nh`sB{z6AQC;W&op>M#kpf8Q9Nx z&U5IRxBn`g`TC2VFkm|%Z~61TCo5X9G_tW^N#zB6Yg-PcN!9EF z8#Nm z-cDv`-Riv&8eM%9Ej#69wBoE^rpf1=MB`68au__A*Sa9jgZO)Q(T+QACAU?|1$kp* z4#+$i5@5u^odd34j}gyr=A9-I$iU2)$rvC#S87xMbm-mwxe<+#6c>Ud=$q$lu63QU zYPr+KP0q2Io`!%gt35NIKH~!ct8dbE6zDfRNqoM*ZP+u|EY`v`A{d~?;`G8LBD(As zft}OSBaji`3}mgPk-3lV?500F;Qz)+n|Q!_Tnsfk+oA5PqY0w1ryWI0jz5`}9RC6u zf7($re#BAUrpJ%Sf!^J@ou>co$JBjv8@ZI*%!5Csz5jfV2e1R;=xEmiIRMwKuV~m9 zfr>2b0Uy_5_@IxcuXz?w%ZwpXbQY+q`_5h&(8233{J2M?GOeI8FUbZ?-uO2fOC7Qk ztCrVv-~l{i2c(%Wsn5`Z7bd1avjkw%Ex^oRrlDZxy7o@-T0PU$K(guABwehouIZb5 z52rtf?92e>L)Dpe`E$+AT9SNbEE|zhu?zK=1g4P+=Qb zSmhHWP&}t3jy<=$(+Shko@G5~ga7wui~F-M8aCF_K?ZvEb^hth!g>o;BFTMoEY*E4 zcYtntyC#6G*uDIok&;9EVNd4udtUbL)gr zNun5?Q37-{hRe2|PCx4gb`FcS!fB;?1tK!B#oVtL+d}VMx(TM#!yZPz?mAY>C;igw zWV2XmkfGu%Lt;};c+J6xnrS`o{Zw@Tyk~DL zzjet^=&h4Kjk{oiY(P-+)-Mn4bO;cy&u%(GKVEqH_y@~^Fysw@HTycCN^LA(SF9yQ zqMtbgevb+Z^j)lJB6{7zXEl=IN+61sHTX<`hljSd!LGnn1YhjsSSx)uKj8wjFi_Dma> zrv~haYxr;WrofYC)(4q6$q&@LDY!F09?=@cy-A=k4<0gVDq__#qL%a z24>wfbLT!k2OSe<}w3xCQ1mJu5T@Q~)b)$Q~_IxGvfVvY=IWtKP66Xq+zHdOAJS zTOtC%tOT9ni+?k)c(^el000cYNklZD|3t5zc&L#RXngLZCel;L0SM6Ki2ZXpp`qT z@1GeNT6DA!zHpzU=~V|*bjXT0Dbmk;1QW;Jv=~x6qI8&z@vx$_P#{P95eAF0A^x5j zV!U}^fY)@*j+5x#nN`K!Y17htlVj&kulz18t7awVuvP|eC%K^rY7n`Bl|(tgpG%M{ z5JwD$zQy*{6F;M?mi?2t zYz3=rgSOGr1N3UDYXWa#+(v?=j}&_G&oqq2K8k+8+}H0tpud0S^0idcM@1n@dWI>b z0JK#H)O5&7w;B$8p0;5nBXXsZbfC~VgMv9Ap-;OtV5N6y97c;5K*Pk`c4{tXRw7hX zoo<_6O@HucShtaSt53Zx#{T?)|3IrdQ@#k%vx*zi1@^+%@O81<@;Jl_=zJlC37-+W)d* zBb_|9eV`%E?5}W_=9!@wHC{Z_JphE4xMZ>5Lga z$e?pkEHSeWQnw5vJedz?d1%(+XESSi4-)5on+n=bPxaPJ2nJ$NRw_-w0GZzKGPmtr zO@9!x8*Mq}wytu);1>@3&LF)huCWvzUyxWEND1G|Btn|UQU4CzNaKcHhhARYefFwV zqurUUV%#dXON40kfpy$`swg>WOXdGF8D?}Xg4AE1Yd5oTN!~Dsaox4jvZ(-kGgn)e zMX;J)-;yHMg_6~s+_*<&H#8$-;AhqD^-F$A?_BmT^D)*7qKv9XFZ77~{!5pN5pwG< z4m;3&(*m{<4WyFdFP1#95gR`>G^)N{RLj<$jfO6K&)!6Qt>sLqZ2nxyq-fu}dLwk< z)|Z;PxTKY>F8Ta{-=Wo=y$b@2^U=tO^>N|z_g^x(k*exsFEI|RY5CGPGNy}1dDKdtbJ6-Pj0S^2|fy`4%j+l15d7ttTAJ_^O4% zGySYK7%+SKe=Su95<#e*7Aa6<q&MW%F&g1E}snsbUWFYsG7+Cyo zE&YG=hRJ_jC}5m>J1hG7#MkHo4~Na?PF{J~O8TTf?@cR>e#Di)hwSNxP$o@Fsx0K?BLF|sl;Gk45oD9wvH-6}rC5IQC>m^&KW-%Po5-E-#z=*8^D(16}Pv7Y=4 z765w5IwHEHI5~n^HEC*o@21!EJ>$SEh7+2Y)$lu zozEpVYu2n^>vGak*Bk7L zXG*iy>AQ1fz^zvz*krGwPGAHebFJUG{S^9_+2wP>&)*z;=bY|eXg60xmyNF{N5~?D zKvQp?+(uNdlnbK^=Q0a&#c5yA)@JGryW8~hQmXjB${B@x5w{vnUr$RiD8!=8`mfYI znZwaH)U>M}rPu%BC3C{lNu%576D#kTQyB~F<|H>VKu^DU;)c4W_ck3O1g*rsNEBG^ zyI*=l%MDG5@&0~N0_AbvI%!FS*@_&XBEU^SsYTtPT(`6PsvT?Qgr~PnZlbp>-8`o< z7Szo(-8^v%UCM11sfs-pFFCr?>pc*@)RCScJD5HF<<{ZlR^X?C#T+$YPu8`@8cJNZ z$ib*7YoZaElN*IVujplRgI&Mp>GUVNpEV~uE$Zjty3b8_k8hxjCZOGiQx}bg;INHg z2iCv!=wsi~btpY>flsm+8@#2Wbx^|76#3w0`e1h8q!e_42t>@_rw z1rU1xwdgk3JK;LAX_ijY&VxaVC;5Ta<;zVFs{l|)ZOc&lWo6nsdpE32Ar9KVIGw3=T8w7YofO`|S)Jh{nW^vis}BT#nZqN0?MP|Gn}@dN-Y$%&G2 z2$nCW+~$f6w`6qfqbJU(m_J$hk96$lt~r&l0B+tq-lH|u2HG|>pr_w7wx*`~?)->K zWo?IfA?8| zp!VynrR;s<*p*dPe=>nOtuO-#f@!?gGdbL&tPBIZ#VTQ01(O1QmLAp{Y+573{yjJ3 z6?0A5?d$%*A*=aRzuYeoZEHlU#jM z=|08iqFVFI#HALmef0VCchiULGhh~{y!&(=EI^twpz8~0)$~~B4yvn@MPWEA=f40+ zU}Y#WmKBNWxUxiPYoRjmeS{J415fhoGu8&WajrS&#gtuZH{Ubfqq9r8c__(|xX*!l zq;rScdnj^wW?By>SF(B*n736%w`u2sejW&h^LNqPwuW6Q`}(uE2D;dD1B027Fz^_7 zrgorqnGbCiSthJ4hpZlnc*R{HiS-Ar;uCh^Tqji)bI|6{4F%?*0qsSF2X&Q$TCPNu zdkTGBnYC5sAx(%3`M#AW47&D%&v`_h89!wGu3Gkg=$s`F4SCmoefiK}-X}mepzhp2 z6sN~a{hIR6{;uYfzj>Z=eliT}BB1AS6e{}qc$Y36L^JEB4wU66Rdw$h=*o(!PbLCp z+-7p5pZs`yG7D#}rnUPbG3Hfr=)(3~Ku32*=mx6k{JAypsde`vp!aRO+!D~bN0(Zw=Ju^bwMlkg z3(0`}MmoFd`BQA>7W&Uug&yN_76Cn62YVoQXzg6(h4s{VlN?szp0O)hOBG!}MDBgE z`{mCfpa&Y(?Nrl-s-_!o58yy|4sp?A3TUjy^c(2Xx~8-DM{q9!x`?>#RM8z(O&i8~ zv|&CpazAW8Zh#ixcA1e5T|gDBp_<&j|D*a<^vV4FBB0agY^I7fQcW9s9lGPOkQDuJ z@Pq)`s+3Frbw_Dcu_Ef|2$bW`F;-Q?KL&W1h}!NYT85(qYO#lD@07*qoM6N<$f=>1|>Hq)$ From 651112471fe6193624455a78e8f4e900f457892c Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 14 Feb 2021 12:54:35 -0600 Subject: [PATCH 19/46] Fixed build issues --- Slide for Reddit.xcodeproj/project.pbxproj | 23 ++++---- Slide for Reddit/AnyModalViewController.swift | 6 ++- Slide for Reddit/ToolbarTextView.swift | 53 +++++++++---------- .../VideoMediaViewController.swift | 4 +- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index c9974b8b4..30d44b86a 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -78,7 +78,7 @@ BE02B253240C9F5400C457BC /* CommentsRowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE02B252240C9F5400C457BC /* CommentsRowController.swift */; }; BE02B255240CAC5D00C457BC /* CommentRepliesController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE02B254240CAC5D00C457BC /* CommentRepliesController.swift */; }; BE0334AF25294B8400B8C6B6 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0334AE25294B8400B8C6B6 /* IntentHandler.swift */; }; - BE0334B325294B8400B8C6B6 /* WidgetConfigIntent.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE0334AC25294B8400B8C6B6 /* WidgetConfigIntent.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + BE0334B325294B8400B8C6B6 /* WidgetConfigIntent.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE0334AC25294B8400B8C6B6 /* WidgetConfigIntent.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BE0334CF25294C0700B8C6B6 /* TimelineSubreddit.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = BED90FF4250C1FB300090DF5 /* TimelineSubreddit.intentdefinition */; }; BE03351225294CEE00B8C6B6 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE0334AE25294B8400B8C6B6 /* IntentHandler.swift */; }; BE03356725295AB500B8C6B6 /* SettingsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE03356625295AB500B8C6B6 /* SettingsWidget.swift */; }; @@ -178,7 +178,7 @@ BE257A6E21F64AA30082A47E /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BE257A6D21F64AA30082A47E /* Media.xcassets */; }; BE257A7021F64AA30082A47E /* ActionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE257A6F21F64AA30082A47E /* ActionViewController.swift */; }; BE257A7321F64AA30082A47E /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BE257A7121F64AA30082A47E /* MainInterface.storyboard */; }; - BE257A7721F64AA30082A47E /* Open in Slide.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE257A6B21F64AA30082A47E /* Open in Slide.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + BE257A7721F64AA30082A47E /* Open in Slide.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BE257A6B21F64AA30082A47E /* Open in Slide.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BE257A7D21F8D9710082A47E /* SettingsThemeChooser.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE257A7C21F8D9710082A47E /* SettingsThemeChooser.swift */; }; BE25CAD424C3A28300736CA5 /* SwipeForwardNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE25CAD324C3A28300736CA5 /* SwipeForwardNavigationController.swift */; }; BE25CAD624C3A65400736CA5 /* SwipeForwardAnimatedTransitioning.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE25CAD524C3A65400736CA5 /* SwipeForwardAnimatedTransitioning.swift */; }; @@ -365,7 +365,7 @@ BEBF45DB1E23383D00764BB8 /* seen.plist in Resources */ = {isa = PBXBuildFile; fileRef = BEBF45DA1E23383D00764BB8 /* seen.plist */; }; BEBF45DD1E23384500764BB8 /* comments.plist in Resources */ = {isa = PBXBuildFile; fileRef = BEBF45DC1E23384500764BB8 /* comments.plist */; }; BEBF45E11E23EED800764BB8 /* SettingValues.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEBF45E01E23EED800764BB8 /* SettingValues.swift */; }; - BEC2AB3A250D8D2C00AD5BEA /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED90FE0250BF71600090DF5 /* WidgetKit.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; + BEC2AB3A250D8D2C00AD5BEA /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED90FE0250BF71600090DF5 /* WidgetKit.framework */; platformFilter = ios; settings = {ATTRIBUTES = (Weak, ); }; }; BEC2FE19235BA2B100374013 /* adaway.json in Resources */ = {isa = PBXBuildFile; fileRef = BEC2FE18235BA2B100374013 /* adaway.json */; }; BEC494281E307D57006618F3 /* GalleryTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEC494271E307D57006618F3 /* GalleryTableViewController.swift */; }; BEC4942A1E307DDA006618F3 /* GalleryCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEC494291E307DDA006618F3 /* GalleryCellView.swift */; }; @@ -393,7 +393,7 @@ BED90FE3250BF71600090DF5 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BED90FE2250BF71600090DF5 /* SwiftUI.framework */; }; BED90FE6250BF71600090DF5 /* SlideWidgets.swift in Sources */ = {isa = PBXBuildFile; fileRef = BED90FE5250BF71600090DF5 /* SlideWidgets.swift */; }; BED90FE8250BF71800090DF5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BED90FE7250BF71800090DF5 /* Assets.xcassets */; }; - BED90FEC250BF71800090DF5 /* Slide Widgets.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BED90FDF250BF71600090DF5 /* Slide Widgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + BED90FEC250BF71800090DF5 /* Slide Widgets.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BED90FDF250BF71600090DF5 /* Slide Widgets.appex */; platformFilter = ios; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BED90FF5250C1FB300090DF5 /* TimelineSubreddit.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = BED90FF4250C1FB300090DF5 /* TimelineSubreddit.intentdefinition */; }; BED90FF6250C1FB300090DF5 /* TimelineSubreddit.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = BED90FF4250C1FB300090DF5 /* TimelineSubreddit.intentdefinition */; }; BEDDA9911E19AB5D003CD6C3 /* WebsiteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEDDA9901E19AB5D003CD6C3 /* WebsiteViewController.swift */; }; @@ -2725,6 +2725,7 @@ /* Begin PBXTargetDependency section */ BE0334B225294B8400B8C6B6 /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BE0334AB25294B8400B8C6B6 /* WidgetConfigIntent */; targetProxy = BE0334B125294B8400B8C6B6 /* PBXContainerItemProxy */; }; @@ -2741,6 +2742,7 @@ }; BE257A7621F64AA30082A47E /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BE257A6A21F64AA30082A47E /* Open in Slide */; targetProxy = BE257A7521F64AA30082A47E /* PBXContainerItemProxy */; }; @@ -2761,6 +2763,7 @@ }; BED90FEB250BF71800090DF5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; + platformFilter = ios; target = BED90FDE250BF71600090DF5 /* Slide Widgets */; targetProxy = BED90FEA250BF71800090DF5 /* PBXContainerItemProxy */; }; @@ -2823,7 +2826,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).WidgetConfigIntent"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -2858,7 +2861,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgetconfigintent"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3042,7 +3045,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).Open-in-Slide"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3077,7 +3080,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledOpen-in-Slide"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3459,7 +3462,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).widgets"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -3496,7 +3499,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide.bundledwidgets 1599951103"; SKIP_INSTALL = YES; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/Slide for Reddit/AnyModalViewController.swift b/Slide for Reddit/AnyModalViewController.swift index 68504de85..4004eada5 100644 --- a/Slide for Reddit/AnyModalViewController.swift +++ b/Slide for Reddit/AnyModalViewController.swift @@ -8,7 +8,11 @@ import Anchorage import AVKit -import SubtleVolume + +#if os(iOS) + import SubtleVolume +#endif + import Then import UIKit diff --git a/Slide for Reddit/ToolbarTextView.swift b/Slide for Reddit/ToolbarTextView.swift index 28a58a289..af272dbf1 100644 --- a/Slide for Reddit/ToolbarTextView.swift +++ b/Slide for Reddit/ToolbarTextView.swift @@ -470,7 +470,7 @@ public class ToolbarTextView: NSObject { }) if results.count > 1 { - Alamofire.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + AF.request("https://api.imgur.com/3/album", method: .post, parameters: nil, encoding: JSONEncoding.default, headers: ["Authorization": "Client-ID bef87913eb202e9"]) .responseJSON { response in print(response) if let status = response.response?.statusCode { @@ -639,42 +639,41 @@ public class ToolbarTextView: NSObject { return } - Alamofire.upload(multipartFormData: { (multipartFormData) in + AF.upload(multipartFormData: { (multipartFormData) in multipartFormData.append(data, withName: "image", fileName: UUID().uuidString + ".jpeg", mimeType: "image/jpg") + if !album.isEmpty { multipartFormData.append(album.data(using: .utf8)!, withName: "album") } - }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"], encodingCompletion: { (encodingResult) in - switch encodingResult { - case .success(let upload, _, _): - print("Success") - upload.uploadProgress { progress in - DispatchQueue.main.async { - print(progress.fractionCompleted) - self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) - } - } - upload.responseJSON { response in - if let val = response.value { - let json = JSON(val) - debugPrint(response) - let link = json["data"]["link"].stringValue - if link.isEmpty { - if json["data"]["error"].stringValue != "" { - tryUploadWithSize(size: size - 0.1) - return - } - } - print("Link is \(link)") - if count == results.count { - completion(link, true) + }, to: "https://api.imgur.com/3/image", method: .post, headers: ["Authorization": "Client-ID bef87913eb202e9"]) + .uploadProgress(closure: { (progress) in + DispatchQueue.main.async { + print(progress.fractionCompleted) + self.progressBar.setProgress(Float(progress.fractionCompleted), animated: true) + } + }) + .responseJSON { (response) in + switch response.result { + case .success(let result): + if let val = response.value { + let json = JSON(val) + debugPrint(response) + let link = json["data"]["link"].stringValue + if link.isEmpty { + if json["data"]["error"].stringValue != "" { + tryUploadWithSize(size: size - 0.1) + return } } + print("Link is \(link)") + if count == results.count { + completion(link, true) + } } case .failure: completion("Failure", false) } - }) + } } tryUploadWithSize(size: 1) diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 8c77d6541..8966ea01b 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -11,7 +11,9 @@ import Anchorage import AVFoundation import SDCAlertView import SDWebImage -import SubtleVolume +#if os(iOS) + import SubtleVolume +#endif import Then import UIKit From 88bfcf22587a7e2254da44eefa913f4c8d94cb9e Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 14 Feb 2021 13:27:11 -0600 Subject: [PATCH 20/46] Fixed multi-column mode --- Slide for Reddit/AppDelegate.swift | 6 +++--- Slide for Reddit/WrappingFlowLayout.swift | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 240b16135..09790555c 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -1195,9 +1195,9 @@ extension AppDelegate: UIWindowSceneDelegate { split.preferredPrimaryColumnWidthFraction = 0.15 split.maximumPrimaryColumnWidth = size.width * 0.15 - split.minimumSupplementaryColumnWidth = size.width * 0.25 - split.maximumSupplementaryColumnWidth = size.width * 0.25 - split.preferredSupplementaryColumnWidthFraction = 0.25 + split.minimumSupplementaryColumnWidth = size.width * 0.6 + split.maximumSupplementaryColumnWidth = size.width * 0.6 + split.preferredSupplementaryColumnWidthFraction = 0.6 } } } diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index a9b870869..31643dba4 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -93,7 +93,6 @@ class WrappingFlowLayout: UICollectionViewLayout { numberOfColumns = SettingValues.galleryCount } - numberOfColumns = 1 cellPadding = (numberOfColumns > 1 && (SettingValues.postViewMode != .LIST) && (SettingValues.postViewMode != .COMPACT)) ? CGFloat(3) : ((SettingValues.postViewMode == .LIST) ? CGFloat(1) : CGFloat(0)) prepare() } From 4c39ef8fb268cb0d48be3b9da89094c04ec198f0 Mon Sep 17 00:00:00 2001 From: ccrama Date: Mon, 15 Feb 2021 19:47:25 -0600 Subject: [PATCH 21/46] Use event system for Settings changes --- Slide for Reddit/AccountController.swift | 2 - Slide for Reddit/AppDelegate.swift | 1 + Slide for Reddit/CacheSettings.swift | 2 - Slide for Reddit/MainViewController.swift | 2 - .../NavigationHomeViewController.swift | 11 +++- Slide for Reddit/SettingsBackup.swift | 3 - Slide for Reddit/SettingsCustomTheme.swift | 10 +-- Slide for Reddit/SettingsDonate.swift | 3 - Slide for Reddit/SettingsFont.swift | 6 +- Slide for Reddit/SettingsGeneral.swift | 7 +- Slide for Reddit/SettingsGestures.swift | 33 ++++++---- Slide for Reddit/SettingsLayout.swift | 45 ++++++++----- Slide for Reddit/SettingsTheme.swift | 66 +++++++++++++------ Slide for Reddit/SettingsViewController.swift | 4 +- Slide for Reddit/SettingsViewMode.swift | 16 +++-- .../SingleSubredditViewController.swift | 22 ++++++- .../SplitMainViewController.swift | 57 ++++++++-------- .../SubredditReorderViewController.swift | 13 +++- .../SubredditThemeViewController.swift | 2 - Slide for Reddit/Subscriptions.swift | 8 ++- Slide for Reddit/ThreadViewController.swift | 39 ++++++----- 21 files changed, 220 insertions(+), 132 deletions(-) diff --git a/Slide for Reddit/AccountController.swift b/Slide for Reddit/AccountController.swift index e2866adeb..a80324b3c 100644 --- a/Slide for Reddit/AccountController.swift +++ b/Slide for Reddit/AccountController.swift @@ -22,7 +22,6 @@ class AccountController { } static func switchAccount(name: String) { - changed = true ActionStates.upVotedFullnames.removeAll() ActionStates.downVotedFullnames.removeAll() ActionStates.savedFullnames.removeAll() @@ -36,7 +35,6 @@ class AccountController { static var isLoggedIn = false static var isGold = false - static var changed = false static var modSubs: [String] = [] static var current: Account? diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 09790555c..ccf121273 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -509,6 +509,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.presentsWithGesture = true if UIApplication.shared.isMac() { + splitViewController.presentsWithGesture = false setupSplitPaneLayout(splitViewController) } else { // Set display mode and split behavior diff --git a/Slide for Reddit/CacheSettings.swift b/Slide for Reddit/CacheSettings.swift index a8071b55f..fc4e5cee4 100644 --- a/Slide for Reddit/CacheSettings.swift +++ b/Slide for Reddit/CacheSettings.swift @@ -79,8 +79,6 @@ class CacheSettings: BubbleSettingTableViewController { var delete = UIButton() - public static var changed = false - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return indexPath.section == 0 ? 80 : 60 } diff --git a/Slide for Reddit/MainViewController.swift b/Slide for Reddit/MainViewController.swift index e971897b1..122571706 100644 --- a/Slide for Reddit/MainViewController.swift +++ b/Slide for Reddit/MainViewController.swift @@ -32,8 +32,6 @@ class MainViewController: ColorMuxPagingViewController, UINavigationControllerDe var isReload = false var readLaterBadge: BadgeSwift? public static var current: String = "" - public static var needsRestart = false - public static var needsReTheme = false public var toolbar: UIView? var tabBar: SubredditPagingTitleCollectionView! var subs: UIView? diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 9e65efb36..42ff4331b 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -112,7 +112,8 @@ class NavigationHomeViewController: UIViewController { updateAccessibility() searchBar.isUserInteractionEnabled = true NotificationCenter.default.addObserver(self, selector: #selector(onThemeChanged), name: .onThemeChanged, object: nil) - + NotificationCenter.default.addObserver(self, selector: #selector(onSubredditOrderChanged), name: .subredditOrderChanged, object: nil) + /*if let sectionIndex = tableView.sectionIndexView, let nav = (navigationController as? SwipeForwardNavigationController) { //DISABLE for now NavigationHomeViewController.edgeGesture = UIScreenEdgePanGestureRecognizer(target: nav, action: #selector(nav.handleRightSwipe(_:))) NavigationHomeViewController.edgeGesture!.edges = UIRectEdge.right @@ -125,6 +126,11 @@ class NavigationHomeViewController: UIViewController { doViews() } + @objc func onSubredditOrderChanged() { + subsSource.reload() + self.tableView.reloadData() + } + func doViews() { tableView = UITableView(frame: CGRect.zero, style: .grouped) tableView.backgroundColor = UIColor.foregroundColor @@ -671,6 +677,7 @@ extension NavigationHomeViewController: UISearchBarDelegate { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.tableView.resignFirstResponder() self.searchBar.becomeFirstResponder() } } @@ -697,6 +704,7 @@ extension NavigationHomeViewController: UISearchBarDelegate { self.suggestions = self.suggestions.sorted { ($0.hasPrefix(searchTerm) ? 0 : 1) < ($1.hasPrefix(searchTerm) ? 0 : 1) } self.tableView.reloadData() self.tableView.deselectRow(at: IndexPath(row: 0, section: 0), animated: false) + self.tableView.resignFirstResponder() self.searchBar.becomeFirstResponder() } case .failure(let error): @@ -704,7 +712,6 @@ extension NavigationHomeViewController: UISearchBarDelegate { } }) } - } func searchTableList() { diff --git a/Slide for Reddit/SettingsBackup.swift b/Slide for Reddit/SettingsBackup.swift index 98b95c5b5..5f55ed578 100644 --- a/Slide for Reddit/SettingsBackup.swift +++ b/Slide for Reddit/SettingsBackup.swift @@ -14,9 +14,6 @@ import SDWebImage import UIKit class SettingsBackup: BubbleSettingTableViewController { - - static var changed = false - var restore: UITableViewCell = InsetCell(style: .subtitle, reuseIdentifier: nil) var backup: UITableViewCell = InsetCell(style: .subtitle, reuseIdentifier: nil) diff --git a/Slide for Reddit/SettingsCustomTheme.swift b/Slide for Reddit/SettingsCustomTheme.swift index 11aa7c4cd..fce15d7c9 100644 --- a/Slide for Reddit/SettingsCustomTheme.swift +++ b/Slide for Reddit/SettingsCustomTheme.swift @@ -147,7 +147,8 @@ class SettingsCustomTheme: UITableViewController { colorString += (self.foregroundColor.toHexString() + self.backgroundColor.toHexString() + self.fontColor.toHexString() + self.navIconColor.toHexString() + ColorUtil.baseColor.toHexString() + ColorUtil.baseAccent.toHexString() + "#" + String(self.statusbarEnabled)).addPercentEncoding UserDefaults.standard.set(colorString, forKey: "Theme+" + (self.themeText ?? today_string)) UserDefaults.standard.synchronize() - SettingsTheme.needsRestart = true + + NotificationCenter.default.post(name: .settingsThemeNeedsRestart, object: nil) ColorUtil.initializeThemes() self.dismiss(animated: true, completion: nil) @@ -171,10 +172,11 @@ class SettingsCustomTheme: UITableViewController { UserDefaults.standard.synchronize() if isCurrentTheme { _ = ColorUtil.doInit() - MainViewController.needsReTheme = true } ColorUtil.initializeThemes() - SettingsTheme.needsRestart = true + + NotificationCenter.default.post(name: .settingsThemeNeedsRestart, object: nil) + self.delegate?.themeSaved() self.dismiss(animated: true, completion: nil) } @@ -301,7 +303,7 @@ class SettingsCustomTheme: UITableViewController { } override func viewWillDisappear(_ animated: Bool) { - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { diff --git a/Slide for Reddit/SettingsDonate.swift b/Slide for Reddit/SettingsDonate.swift index 800c09325..4f187728c 100644 --- a/Slide for Reddit/SettingsDonate.swift +++ b/Slide for Reddit/SettingsDonate.swift @@ -16,9 +16,6 @@ import SDWebImage import UIKit class SettingsDonate: UIViewController, MFMailComposeViewControllerDelegate { - - static var changed = false - override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) } diff --git a/Slide for Reddit/SettingsFont.swift b/Slide for Reddit/SettingsFont.swift index 3f2083f0b..daf416fb9 100644 --- a/Slide for Reddit/SettingsFont.swift +++ b/Slide for Reddit/SettingsFont.swift @@ -77,7 +77,9 @@ class SettingsFont: BubbleSettingTableViewController { SettingValues.postFontOffset = size UserDefaults.standard.set(size, forKey: SettingValues.pref_postFontSize) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) + CachedTitle.titleFont = FontGenerator.fontOfSize(size: CachedTitle.baseFontSize, submission: true) FontGenerator.initialize() refresh() @@ -500,7 +502,7 @@ extension SettingsFont { CachedTitle.titleFont = FontGenerator.fontOfSize(size: 18, submission: true) CachedTitle.titleFontSmall = FontGenerator.fontOfSize(size: 14, submission: true) SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) if let nav = self.navigationController as? SwipeForwardNavigationController { nav.fullWidthBackGestureRecognizer.isEnabled = true } diff --git a/Slide for Reddit/SettingsGeneral.swift b/Slide for Reddit/SettingsGeneral.swift index 13b934e74..976d4959c 100644 --- a/Slide for Reddit/SettingsGeneral.swift +++ b/Slide for Reddit/SettingsGeneral.swift @@ -79,7 +79,7 @@ class SettingsGeneral: BubbleSettingTableViewController { @objc func switchIsChanged(_ changed: UISwitch) { if changed == showPagesSwitch { - MainViewController.needsRestart = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) SettingValues.showPages = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_showPages) } else if changed == autoKeyboardSwitch { @@ -100,7 +100,8 @@ class SettingsGeneral: BubbleSettingTableViewController { } else if changed == hideFABSwitch { SettingValues.hiddenFAB = !changed.isOn UserDefaults.standard.set(!changed.isOn, forKey: SettingValues.pref_hiddenFAB) - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) doDisables() } else if changed == hapticFeedback { SettingValues.hapticFeedback = !changed.isOn @@ -136,7 +137,7 @@ class SettingsGeneral: BubbleSettingTableViewController { } else if changed == pinToolbarSwitch { SettingValues.dontHideTopBar = !changed.isOn UserDefaults.standard.set(!changed.isOn, forKey: SettingValues.pref_pinToolbar) - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .tabBarsChanged, object: nil) if SettingValues.dontHideTopBar { self.totallyCollapse.contentView.alpha = 0.5 self.totallyCollapse.isUserInteractionEnabled = false diff --git a/Slide for Reddit/SettingsGestures.swift b/Slide for Reddit/SettingsGestures.swift index 9542aa80e..c2c9dd4b4 100644 --- a/Slide for Reddit/SettingsGestures.swift +++ b/Slide for Reddit/SettingsGestures.swift @@ -42,7 +42,8 @@ class SettingsGestures: BubbleSettingTableViewController { if changed == disableBanner { SettingValues.disableBanner = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_disableBanner) - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } UserDefaults.standard.synchronize() @@ -61,8 +62,8 @@ class SettingsGestures: BubbleSettingTableViewController { UserDefaults.standard.synchronize() self.commentGesturesCell.detailTextLabel?.text = SettingValues.commentGesturesMode.description() self.updateCells() - SplitMainViewController.needsReTheme = true - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } } alertController.show(self) @@ -80,8 +81,8 @@ class SettingsGestures: BubbleSettingTableViewController { UserDefaults.standard.synchronize() self.submissionGesturesCell.detailTextLabel?.text = SettingValues.submissionGestureMode.description() self.updateCells() - SplitMainViewController.needsReTheme = true - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) } } alertController.show(self) @@ -168,7 +169,7 @@ class SettingsGestures: BubbleSettingTableViewController { UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_submissionActionForceTouch) } - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) UserDefaults.standard.synchronize() self.updateCells() } @@ -408,7 +409,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionLeftRight = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionLeftRight) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -418,7 +420,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionLeftLeft = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionLeftLeft) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -428,7 +431,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionRightLeft = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionRightLeft) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -437,7 +441,8 @@ public class GesturePreviewCell: InsetCell { SettingValues.commentActionRightRight = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_commentActionRightRight) UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -446,9 +451,9 @@ public class GesturePreviewCell: InsetCell { self.showActionSub { (action) in SettingValues.submissionActionLeft = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_submissionActionLeft) - SubredditReorderViewController.changed = true UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) @@ -457,9 +462,9 @@ public class GesturePreviewCell: InsetCell { self.showActionSub { (action) in SettingValues.submissionActionRight = action UserDefaults.standard.set(action.rawValue, forKey: SettingValues.pref_submissionActionRight) - SubredditReorderViewController.changed = true UserDefaults.standard.synchronize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.parentController?.updateCells() } })) diff --git a/Slide for Reddit/SettingsLayout.swift b/Slide for Reddit/SettingsLayout.swift index 5a91bfe24..e6e1be9e9 100644 --- a/Slide for Reddit/SettingsLayout.swift +++ b/Slide for Reddit/SettingsLayout.swift @@ -222,7 +222,9 @@ class SettingsLayout: BubbleSettingTableViewController { UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_reduceElevation) } SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) + UserDefaults.standard.synchronize() doDisables() doLink() @@ -341,7 +343,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Large card view", icon: UIImage(named: "card")!.menuIcon()) { @@ -353,7 +356,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Centered Image large card view", icon: UIImage(named: "centeredimage")!.menuIcon()) { @@ -365,7 +369,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Compact list view", icon: UIImage(named: "compact")!.menuIcon()) { @@ -377,7 +382,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.cardModeCell.detailTextLabel?.text = SettingValues.postViewMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.show(self) @@ -392,7 +398,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Cropped image", icon: UIImage(named: "crop")!.menuIcon()) { @@ -403,7 +410,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Shortened image", icon: UIImage(named: "crop")!.menuIcon()) { @@ -414,7 +422,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Thumbnail only", icon: UIImage(named: "thumb")!.menuIcon()) { @@ -425,7 +434,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "No image", icon: UIImage(named: "hide")!.menuIcon()) { @@ -436,7 +446,8 @@ class SettingsLayout: BubbleSettingTableViewController { self.doLink() tableView.reloadData() self.imageCell.detailTextLabel?.text = SettingValues.postImageMode.rawValue.capitalize() - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.show(self) @@ -452,7 +463,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Left aligned button bar", icon: UIImage(sfString: SFSymbol.handPointLeftFill, overrideString: "code")!.menuIcon()) { @@ -464,7 +476,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Vote buttons on left side", icon: UIImage(sfString: SFSymbol.chevronUp, overrideString: "up")!.menuIcon()) { @@ -476,7 +489,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Vote buttons on right side", icon: UIImage(sfString: SFSymbol.chevronDown, overrideString: "down")!.menuIcon()) { @@ -488,8 +502,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.addAction(title: "Disable buttons", icon: UIImage(sfString: SFSymbol.xmark, overrideString: "hide")!.menuIcon()) { @@ -501,7 +515,8 @@ class SettingsLayout: BubbleSettingTableViewController { tableView.reloadData() self.actionBarCell.detailTextLabel?.text = SettingValues.actionBarMode.rawValue.capitalize() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } alertController.show(self) diff --git a/Slide for Reddit/SettingsTheme.swift b/Slide for Reddit/SettingsTheme.swift index 8c41eb3ae..ab2d65a5f 100644 --- a/Slide for Reddit/SettingsTheme.swift +++ b/Slide for Reddit/SettingsTheme.swift @@ -157,6 +157,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { super.viewDidLoad() redoThemes() self.tableView.register(ThemeCellView.classForCoder(), forCellReuseIdentifier: "theme") + NotificationCenter.default.addObserver(self, selector: #selector(onSettingsThemeNeedsRestart), name: .settingsThemeNeedsRestart, object: nil) } func pickAccent() { @@ -242,17 +243,20 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { } var doneOnce = false - static var needsRestart = false + + @objc func onSettingsThemeNeedsRestart() { + self.setupViews() + self.redoThemes() + self.tochange!.doCells() + self.tochange!.tableView.reloadData() + self.tableView.reloadData() + } + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) setupBaseBarColors() - if doneOnce || SettingsTheme.needsRestart { - SettingsTheme.needsRestart = false - self.setupViews() - self.redoThemes() - self.tochange!.doCells() - self.tochange!.tableView.reloadData() - self.tableView.reloadData() + if doneOnce { + onSettingsThemeNeedsRestart() } else { doneOnce = true } @@ -380,15 +384,10 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { var themeText: String? @objc func switchIsChanged(_ changed: UISwitch) { - if changed == reduceColor { - MainViewController.needsReTheme = true - SettingValues.reduceColor = changed.isOn - UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_reduceColor) - } else if changed == tintOutsideSwitch { + if changed == tintOutsideSwitch { SettingValues.onlyTintOutside = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_onlyTintOutside) } else if changed == reduceColor { - MainViewController.needsReTheme = true SettingValues.reduceColor = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_reduceColor) setupBaseBarColors() @@ -401,12 +400,18 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { let barButton = UIBarButtonItem.init(customView: button) navigationItem.leftBarButtonItem = barButton + + NotificationCenter.default.post(name: .reduceColorChanged, object: nil) } else if changed == nightEnabled { SettingValues.nightModeEnabled = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_nightMode) _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.tochange!.doCells() self.tochange!.tableView.reloadData() } @@ -511,7 +516,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { UserDefaults.standard.synchronize() _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tableView.reloadData() self.tochange!.doCells() @@ -559,7 +568,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -614,7 +627,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -641,7 +658,11 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { _ = ColorUtil.doInit() self.setupViews() SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.tableView.reloadData() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -783,11 +804,14 @@ final public class PickerViewViewControllerColored: UIViewController { extension SettingsTheme: SettingsCustomThemeDelegate { func themeSaved() { - SettingsTheme.needsRestart = false _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - MainViewController.needsReTheme = true + + if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 + NotificationCenter.default.post(name: .onThemeChanged, object: nil) + } + self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() diff --git a/Slide for Reddit/SettingsViewController.swift b/Slide for Reddit/SettingsViewController.swift index 4d560201a..8b90a5fc9 100644 --- a/Slide for Reddit/SettingsViewController.swift +++ b/Slide for Reddit/SettingsViewController.swift @@ -482,7 +482,7 @@ class SettingsViewController: MediaTableViewController, MFMailComposeViewControl } } else if changed == subIcons { SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) SettingValues.subredditIcons = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_subredditIcons) @@ -712,7 +712,7 @@ class SettingsViewController: MediaTableViewController, MFMailComposeViewControl UserDefaults.standard.synchronize() self.autoPlayCell.detailTextLabel?.text = SettingValues.autoPlayMode.description() + "\nAutoPlaying videos can lead to more data use" SingleSubredditViewController.cellVersion += 1 - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .cellsNeedReDraw, object: nil) } } alertController.show(self) diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index f9507b1ce..a880267d3 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -51,7 +51,7 @@ class SettingsViewMode: BubbleSettingTableViewController { @objc func switchIsChanged(_ changed: UISwitch) { if changed == subredditBarSwitch { - MainViewController.needsRestart = true + NotificationCenter.default.post(name: .tabBarsChanged, object: nil) SettingValues.fullWidthHeaderCells = !changed.isOn UserDefaults.standard.set(!changed.isOn, forKey: SettingValues.pref_fullWidthHeaderCells) } else if changed == thireenPopupSwitch { @@ -286,7 +286,7 @@ class SettingsViewMode: BubbleSettingTableViewController { showPortraitMultiColumn() } - SubredditReorderViewController.changed = true + NotificationCenter.default.post(name: .subNeedsReload, object: nil) UserDefaults.standard.synchronize() setSelected() } @@ -300,7 +300,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.multiColumnCount = value UserDefaults.standard.set(value, forKey: SettingValues.pref_multiColumnCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() } } @@ -317,7 +318,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.multiColumnCount = chosen.row + 1 UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_multiColumnCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() }) @@ -351,7 +353,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.portraitMultiColumnCount = chosen.row + 1 UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_portraitMultiColumnCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() }) @@ -384,7 +387,8 @@ class SettingsViewMode: BubbleSettingTableViewController { SettingValues.galleryCount = chosen.row + 1 UserDefaults.standard.set(chosen.row + 1, forKey: SettingValues.pref_galleryCount) UserDefaults.standard.synchronize() - SubredditReorderViewController.changed = true + + NotificationCenter.default.post(name: .subNeedsReload, object: nil) self.setSelected() }) diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 9e5037946..92a08a896 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -192,6 +192,18 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele } } + @objc func cellsNeedReDraw() { + reloadDataReset() + } + + @objc func subNeedsReload() { + swipeBackAdded = false + + reloadDataReset() + setupSwipeGesture() + setupGestures() + } + deinit { NotificationCenter.default.removeObserver(self) } @@ -205,6 +217,9 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele } NotificationCenter.default.addObserver(self, selector: #selector(youTubePlaying), name: .onYouTubeWillStart, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(cellsNeedReDraw), name: .cellsNeedReDraw, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(subNeedsReload), name: .subNeedsReload, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(reduceColorChanged), name: .reduceColorChanged, object: nil) flowLayout.delegate = self self.tableView = UICollectionView(frame: CGRect.zero, collectionViewLayout: flowLayout) @@ -965,6 +980,10 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele } } + @objc func reduceColorChanged() { + reloadNeedingColor() + } + func reloadNeedingColor() { tableView.backgroundColor = UIColor.backgroundColor inHeadView?.backgroundColor = ColorUtil.getColorForSub(sub: sub, true) @@ -2988,7 +3007,8 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { func setupGestures() { if cellGestureRecognizer != nil { - return + cellGestureRecognizer.view?.removeGestureRecognizer(cellGestureRecognizer) + cellGestureRecognizer = nil } cellGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(panCell(_:))) cellGestureRecognizer.delegate = self diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index 5807ef401..de4b4c672 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -59,6 +59,7 @@ class SplitMainViewController: MainViewController { inHeadView.backgroundColor = .clear } } + override func doProfileIcon() { let account = ExpandedHitButton(type: .custom) let accountImage = UIImage(sfString: SFSymbol.personCropCircle, overrideString: "profile")?.navIcon() @@ -109,7 +110,7 @@ class SplitMainViewController: MainViewController { } override func doButtons() { - if menu.superview != nil && !MainViewController.needsReTheme { + if menu.superview != nil { // What was this for... && !MainViewController.needsReTheme { return } @@ -273,6 +274,10 @@ class SplitMainViewController: MainViewController { NotificationCenter.default.addObserver(self, selector: #selector(autoCacheFinished(_:)), name: .autoCacheFinished, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(autoCacheProgress(_:)), name: .autoCacheProgress, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(subredditOrderDidChange), name: .subredditOrderChanged, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(resetTabBars), name: .tabBarsChanged, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(onThemeChanged), name: .reduceColorChanged, object: nil) + if let splitViewController = splitViewController, (!UIApplication.shared.isSplitOrSlideOver) { (UIApplication.shared.delegate as? AppDelegate)?.setupSplitLayout(splitViewController) } @@ -282,7 +287,7 @@ class SplitMainViewController: MainViewController { @objc func onThemeChanged() { SingleSubredditViewController.cellVersion += 1 - MainViewController.needsReTheme = true + navigationController?.toolbar.barTintColor = UIColor.backgroundColor navigationController?.toolbar.tintColor = UIColor.fontColor self.parent?.navigationController?.toolbar.barTintColor = UIColor.foregroundColor @@ -370,7 +375,6 @@ class SplitMainViewController: MainViewController { setupBaseBarColors(ColorUtil.getColorForSub(sub: getSubredditVC()?.sub ?? "", true)) toolbar?.backgroundColor = UIColor.foregroundColor.add(overlay: UIColor.isLightTheme ? UIColor.black.withAlphaComponent(0.05) : UIColor.white.withAlphaComponent(0.05)) self.doButtons() - MainViewController.needsReTheme = false } var isReappear = false @@ -395,11 +399,8 @@ class SplitMainViewController: MainViewController { } } - if subChanged || SubredditReorderViewController.changed { - finalSubs = [] - finalSubs.append(contentsOf: Subscriptions.pinned) - finalSubs.append(contentsOf: Subscriptions.subreddits.sorted(by: { $0.caseInsensitiveCompare($1) == .orderedAscending }).filter({ return !Subscriptions.pinned.contains($0) })) - redoSubs() + if subChanged { + subredditOrderDidChange() } self.parent?.navigationController?.navigationBar.shadowImage = UIImage() @@ -410,6 +411,13 @@ class SplitMainViewController: MainViewController { setNeedsStatusBarAppearanceUpdate() } + @objc func subredditOrderDidChange() { + finalSubs = [] + finalSubs.append(contentsOf: Subscriptions.pinned) + finalSubs.append(contentsOf: Subscriptions.subreddits.sorted(by: { $0.caseInsensitiveCompare($1) == .orderedAscending }).filter({ return !Subscriptions.pinned.contains($0) })) + redoSubs() + } + override func viewWillAppear(_ animated: Bool) { if navToMux == nil { self.navToMux = self.navigationController?.navigationBar @@ -428,27 +436,25 @@ class SplitMainViewController: MainViewController { */ } - if MainViewController.needsRestart { - MainViewController.needsRestart = false - tabBar?.removeFromSuperview() - self.navigationItem.leftBarButtonItems = [] - self.navigationItem.rightBarButtonItems = [] - if SettingValues.subredditBar { - setupTabBar(finalSubs) - if SettingValues.submissionGestureMode.shouldPage() { - self.dataSource = self - } - } else { - self.navigationItem.titleView = nil - self.dataSource = nil - } - } else if MainViewController.needsReTheme { - doRetheme() - } didUpdate() setupBaseBarColors( ColorUtil.getColorForSub(sub: getSubredditVC()?.sub ?? "", true)) } + + @objc func resetTabBars() { + tabBar?.removeFromSuperview() + self.navigationItem.leftBarButtonItems = [] + self.navigationItem.rightBarButtonItems = [] + if SettingValues.subredditBar { + setupTabBar(finalSubs) + if SettingValues.submissionGestureMode.shouldPage() { + self.dataSource = self + } + } else { + self.navigationItem.titleView = nil + self.dataSource = nil + } + } override func hardReset(soft: Bool = false) { var keyWindow = UIApplication.shared.keyWindow @@ -614,7 +620,6 @@ class SplitMainViewController: MainViewController { CachedTitle.titles.removeAll() view.backgroundColor = UIColor.backgroundColor splitViewController?.view.backgroundColor = UIColor.foregroundColor - SubredditReorderViewController.changed = false finalSubs = [] LinkCellView.cachedInternet = nil diff --git a/Slide for Reddit/SubredditReorderViewController.swift b/Slide for Reddit/SubredditReorderViewController.swift index 1d9bba6d5..f292db9d2 100644 --- a/Slide for Reddit/SubredditReorderViewController.swift +++ b/Slide for Reddit/SubredditReorderViewController.swift @@ -107,8 +107,6 @@ class SubredditReorderViewController: UITableViewController { var delete = UIButton() - public static var changed = false - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return UITableView.automaticDimension } @@ -130,11 +128,11 @@ class SubredditReorderViewController: UITableViewController { } func save(_ selector: AnyObject?) { - SubredditReorderViewController.changed = true Subscriptions.setPinned(name: AccountController.currentName, subs: pinned, completion: { Subscriptions.set(name: AccountController.currentName, subs: self.subs, completion: { }) }) + NotificationCenter.default.post(name: .subredditOrderChanged, object: nil) } override func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath) { @@ -398,3 +396,12 @@ class SubredditReorderViewController: UITableViewController { } } } + +extension Notification.Name { + static let subredditOrderChanged = Notification.Name("subreddit-order-changed") + static let cellsNeedReDraw = Notification.Name("cells-need-re-draw") + static let subNeedsReload = Notification.Name("sub-needs-reload") + static let tabBarsChanged = Notification.Name("tab-bars-changed") + static let settingsThemeNeedsRestart = Notification.Name("settings-theme-needs-restart") + static let reduceColorChanged = Notification.Name("reduce-color-changed") +} diff --git a/Slide for Reddit/SubredditThemeViewController.swift b/Slide for Reddit/SubredditThemeViewController.swift index e36879f32..f5ac6053c 100644 --- a/Slide for Reddit/SubredditThemeViewController.swift +++ b/Slide for Reddit/SubredditThemeViewController.swift @@ -119,8 +119,6 @@ class SubredditThemeViewController: UITableViewController, ColorPickerViewDelega } } - public static var changed = false - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return UITableView.automaticDimension } diff --git a/Slide for Reddit/Subscriptions.swift b/Slide for Reddit/Subscriptions.swift index bf1284fc0..7be951d00 100644 --- a/Slide for Reddit/Subscriptions.swift +++ b/Slide for Reddit/Subscriptions.swift @@ -135,9 +135,11 @@ class Subscriptions { public static func subscribe(_ name: String, _ subscribe: Bool, session: Session?) { var sub = Subscriptions.subreddits - SubredditReorderViewController.changed = true + sub.append(name) set(name: AccountController.currentName, subs: sub) { () in } + + NotificationCenter.default.post(name: .subredditOrderChanged, object: nil) if #available(iOS 10.0, *) { HapticUtility.hapticActionStrong() } else if SettingValues.hapticFeedback { @@ -158,8 +160,10 @@ class Subscriptions { var subs = Subscriptions.subreddits subs = subs.filter { $0 != name } setPinned(name: AccountController.currentName, subs: pinned.filter { $0 != name }, completion: {}) - SubredditReorderViewController.changed = true + set(name: AccountController.currentName, subs: subs) { () in } + + NotificationCenter.default.post(name: .subredditOrderChanged, object: nil) if #available(iOS 10.0, *) { HapticUtility.hapticActionStrong() } else if SettingValues.hapticFeedback { diff --git a/Slide for Reddit/ThreadViewController.swift b/Slide for Reddit/ThreadViewController.swift index 8fb95ee8b..059f7a8c6 100644 --- a/Slide for Reddit/ThreadViewController.swift +++ b/Slide for Reddit/ThreadViewController.swift @@ -79,8 +79,8 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi self.navigationController?.delegate = self if !loaded && !loading { - self.tableView.contentOffset = CGPoint(x: 0, y: -self.refreshControl.frame.size.height) - refreshControl.beginRefreshing() + self.tableView.contentOffset = CGPoint(x: 0, y: -(self.refreshControl?.frame.size.height ?? 0)) + refreshControl?.beginRefreshing() } else { self.tableView.reloadData() } @@ -149,13 +149,15 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi self.tableView.delegate = self self.tableView.dataSource = self - refreshControl = UIRefreshControl() - refreshControl.tintColor = UIColor.fontColor - - refreshControl.attributedTitle = NSAttributedString(string: "") - refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl) - refreshControl.centerAnchors /==/ tableView.centerAnchors + if !UIApplication.shared.isMac() { + refreshControl = UIRefreshControl() + refreshControl?.tintColor = UIColor.fontColor + + refreshControl?.attributedTitle = NSAttributedString(string: "") + refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + tableView.addSubview(refreshControl!) + refreshControl!.centerAnchors /==/ tableView.centerAnchors + } tableView.alwaysBounceVertical = true @@ -267,13 +269,13 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi // TODO: - maybe add this later } - var refreshControl: UIRefreshControl! + var refreshControl: UIRefreshControl? func refresh() { loading = true emptyStateView.isHidden = true baseData.reset() - refreshControl.beginRefreshing() + refreshControl?.beginRefreshing() flowLayout.reset(modal: presentingViewController != nil, vc: self, isGallery: false) flowLayout.invalidateLayout() tableView.reloadData() @@ -292,14 +294,17 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi } func endAndResetRefresh() { - self.refreshControl.endRefreshing() - self.refreshControl.removeFromSuperview() + if UIApplication.shared.isMac() { + return + } + self.refreshControl?.endRefreshing() + self.refreshControl?.removeFromSuperview() self.refreshControl = UIRefreshControl() - self.refreshControl.tintColor = UIColor.fontColor + self.refreshControl?.tintColor = UIColor.fontColor - self.refreshControl.attributedTitle = NSAttributedString(string: "") - self.refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - self.tableView.addSubview(self.refreshControl) + self.refreshControl?.attributedTitle = NSAttributedString(string: "") + self.refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) + self.tableView.addSubview(self.refreshControl!) } var loading: Bool = false From 72312865e6af10f37e035f08fe72446cb294c761 Mon Sep 17 00:00:00 2001 From: ccrama Date: Fri, 19 Feb 2021 16:41:22 -0600 Subject: [PATCH 22/46] Moved search bar out of table header --- 7.0.0 | 0 Slide for Reddit/ModalMediaViewController.swift | 8 +++++++- Slide for Reddit/NavigationHomeViewController.swift | 10 ++++++---- Slide for Reddit/SwipeDownModalVC.swift | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 7.0.0 diff --git a/7.0.0 b/7.0.0 new file mode 100644 index 000000000..e69de29bb diff --git a/Slide for Reddit/ModalMediaViewController.swift b/Slide for Reddit/ModalMediaViewController.swift index fd9597bc0..b547f5957 100644 --- a/Slide for Reddit/ModalMediaViewController.swift +++ b/Slide for Reddit/ModalMediaViewController.swift @@ -285,7 +285,11 @@ class ModalMediaViewController: UIViewController { panGestureRecognizer!.allowedScrollTypesMask = .continuous } panGestureRecognizer!.cancelsTouchesInView = false - + if UIApplication.shared.isMac() { + panGestureRecognizer!.allowedScrollTypesMask = .discrete + panGestureRecognizer!.maximumNumberOfTouches = 0 + } + view.addGestureRecognizer(panGestureRecognizer!) background = UIView() @@ -525,6 +529,8 @@ extension ModalMediaViewController: UIGestureRecognizerDelegate { } else if panGesture.state == .ended { let velocity = panGesture.velocity(in: view) + print(velocity) + let down = panGesture.velocity(in: view).y > 0 if abs(velocity.y) >= 1000 || abs(self.view.frame.origin.y) > self.view.frame.size.height / 2 { diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 42ff4331b..8d6c3896c 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -284,7 +284,7 @@ class NavigationHomeViewController: UIViewController { tableView.register(SubredditCellView.classForCoder(), forCellReuseIdentifier: "search") tableView.register(SubredditCellView.classForCoder(), forCellReuseIdentifier: "profile") - view.addSubview(tableView) + view.addSubviews(headerView, tableView) setColors(MainViewController.current) } @@ -310,7 +310,9 @@ class NavigationHomeViewController: UIViewController { searchBar.heightAnchor /==/ 50 searchBar.bottomAnchor /==/ headerView.bottomAnchor - tableView.topAnchor /==/ view.safeTopAnchor + headerView.topAnchor /==/ view.safeTopAnchor + headerView.horizontalAnchors /==/ view.horizontalAnchors + tableView.topAnchor /==/ headerView.bottomAnchor tableView.contentInset = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) tableView.horizontalAnchors /==/ view.horizontalAnchors tableView.bottomAnchor /==/ view.bottomAnchor @@ -401,7 +403,7 @@ extension NavigationHomeViewController: UITableViewDelegate, UITableViewDataSour func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { if section == 0 { - return 50 + 4 + accountHeader!.estimateHeight() + return 0 } if isSearching && section == 0 { return 0 @@ -488,7 +490,7 @@ extension NavigationHomeViewController: UITableViewDelegate, UITableViewDataSour toReturn.backgroundColor = UIColor.foregroundColor if section == 0 { - return headerView + return UIView() } if isSearching { switch section { diff --git a/Slide for Reddit/SwipeDownModalVC.swift b/Slide for Reddit/SwipeDownModalVC.swift index b29db6172..ccaaa2133 100644 --- a/Slide for Reddit/SwipeDownModalVC.swift +++ b/Slide for Reddit/SwipeDownModalVC.swift @@ -40,7 +40,7 @@ class SwipeDownModalVC: ColorMuxPagingViewController { if #available(iOS 13.4, *) { panGestureRecognizer!.allowedScrollTypesMask = .continuous } - + panGestureRecognizer2!.direction = .horizontal panGestureRecognizer!.cancelsTouchesInView = false From a90bae0e06243e5750372c53c5568f37522f13bb Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 21 Feb 2021 17:22:49 -0600 Subject: [PATCH 23/46] Moved isMac from UIApplication to UIDevice --- .../xcschemes/Slide for Apple Watch.xcscheme | 25 ++- Slide for Reddit/AppDelegate.swift | 21 +-- .../AsyncAlertImagePickerViewController.swift | 4 +- .../BottomMenuPresentationController.swift | 4 +- Slide for Reddit/CommentDepthCell.swift | 4 +- Slide for Reddit/CommentViewController.swift | 162 +++++++++++------- .../ContentListingViewController.swift | 4 +- Slide for Reddit/LinkCellView.swift | 2 +- .../ModalMediaViewController.swift | 10 +- .../NavigationHomeViewController.swift | 6 +- Slide for Reddit/ProfileViewController.swift | 2 +- Slide for Reddit/SettingValues.swift | 28 +-- Slide for Reddit/SettingsComments.swift | 2 +- Slide for Reddit/SettingsGeneral.swift | 2 +- Slide for Reddit/SettingsTheme.swift | 8 +- Slide for Reddit/SettingsViewMode.swift | 41 +++-- .../SingleSubredditViewController.swift | 22 +-- .../SplitMainViewController.swift | 18 +- .../SubredditThemeViewController.swift | 4 +- ...SubredditToolbarSearchViewController.swift | 2 +- .../SwipeForwardNavigationController.swift | 2 +- .../TapBehindModalViewController.swift | 2 +- Slide for Reddit/ThreadViewController.swift | 4 +- Slide for Reddit/UIAlert+Extensions.swift | 2 +- .../UIApplication+Extensions.swift | 5 +- Slide for Reddit/VCPresenter.swift | 24 +-- Slide for Reddit/VideoScrubberView.swift | 6 +- Slide for Reddit/WebsiteViewController.swift | 8 +- Slide for Reddit/WrappingFlowLayout.swift | 8 +- 29 files changed, 254 insertions(+), 178 deletions(-) diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0530f2df2..0d084ded0 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,8 +65,10 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - + + + + + diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index ccf121273..a60dd673e 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -395,7 +395,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { SwipeForwardNavigationController( rootViewController: main), ] - case .SPLIT: + default: let swipeNav = SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)) swipeNav.pushViewController(main, animated: false) splitViewController.viewControllers = [ @@ -418,12 +418,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { @available(iOS 14.0, *) func doHard14(_ window: UIWindow) -> MainViewController { - let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT || UIApplication.shared.isMac() ? .tripleColumn : .doubleColumn + let style: UISplitViewController.Style = SettingValues.appMode == .SPLIT || SettingValues.appMode == .TRIPLE_MULTI_COLUMN + ? .tripleColumn : .doubleColumn var splitViewController: NoHomebarSplitViewController = NoHomebarSplitViewController(style: style) let main: SplitMainViewController = SplitMainViewController(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil) - if UIApplication.shared.isMac() { + if SettingValues.appMode == .TRIPLE_MULTI_COLUMN { splitViewController.setViewController( SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), for: .primary) @@ -436,7 +437,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } else { switch UIDevice.current.userInterfaceIdiom { - case .pad: + case .pad, .mac: switch SettingValues.appMode { case .SINGLE, .MULTI_COLUMN: splitViewController.setViewController( @@ -455,7 +456,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.setViewController( SwipeForwardNavigationController(rootViewController: main), for: .secondary) - case .SPLIT: + default: splitViewController.setViewController( SwipeForwardNavigationController(rootViewController: NavigationHomeViewController(controller: main)), for: .primary) @@ -485,7 +486,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func setupSplitLayout(_ splitViewController: UISplitViewController) { // Set column widths if #available(iOS 14.0, *) { - if UIApplication.shared.isMac() { + if SettingValues.appMode == .TRIPLE_MULTI_COLUMN { splitViewController.minimumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 splitViewController.preferredPrimaryColumnWidthFraction = 0.15 splitViewController.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.15 @@ -508,7 +509,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.presentsWithGesture = true - if UIApplication.shared.isMac() { + if SettingValues.appMode == .TRIPLE_MULTI_COLUMN { splitViewController.presentsWithGesture = false setupSplitPaneLayout(splitViewController) } else { @@ -530,7 +531,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { splitViewController.preferredSplitBehavior = .overlay } } - case .SPLIT: + default: setupSplitPaneLayout(splitViewController) } default: @@ -541,7 +542,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func setupSplitPaneLayout(_ splitViewController: UISplitViewController) { if #available(iOS 14.0, *) { - if SettingValues.desktopMode || UIApplication.shared.isMac() { + if SettingValues.desktopMode || UIDevice.current.isMac() { splitViewController.preferredDisplayMode = .twoBesideSecondary splitViewController.preferredSplitBehavior = .tile } else { @@ -1187,7 +1188,7 @@ extension AppDelegate: UIWindowSceneDelegate { } func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) { - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { let size = windowScene.coordinateSpace.bounds.size for window in windowScene.windows { diff --git a/Slide for Reddit/AsyncAlertImagePickerViewController.swift b/Slide for Reddit/AsyncAlertImagePickerViewController.swift index 29d48b83c..f2bc075a6 100644 --- a/Slide for Reddit/AsyncAlertImagePickerViewController.swift +++ b/Slide for Reddit/AsyncAlertImagePickerViewController.swift @@ -25,7 +25,7 @@ extension AlertController { func addAsyncImagePicker(flow: UICollectionView.ScrollDirection, paging: Bool, images: [URL], selection: AsyncImagePickerViewController.SelectionType? = nil) { let vc = AsyncImagePickerViewController(flow: flow, paging: paging, images: images, selection: selection) - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { vc.preferredContentSize.height = vc.preferredSize.height * 0.9 vc.preferredContentSize.width = vc.preferredSize.width * 0.9 } else { @@ -82,7 +82,7 @@ final class AsyncImagePickerViewController: UIViewController { } var columns: CGFloat { - return UIApplication.shared.respectIpadLayout() ? 3 : 2 + return UIDevice.current.respectIpadLayout() ? 3 : 2 } var itemSize: CGSize { diff --git a/Slide for Reddit/BottomMenuPresentationController.swift b/Slide for Reddit/BottomMenuPresentationController.swift index def2422f4..3239fd4b2 100644 --- a/Slide for Reddit/BottomMenuPresentationController.swift +++ b/Slide for Reddit/BottomMenuPresentationController.swift @@ -97,7 +97,7 @@ extension BottomMenuPresentationController { let horizontalCoveragePercent: CGFloat = 0.95 // Make smaller on iPad - var width = containerView.bounds.size.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : horizontalCoveragePercent) + var width = containerView.bounds.size.width * (UIDevice.current.respectIpadLayout() ? 0.75 : horizontalCoveragePercent) if width < 250 { width = containerView.bounds.size.width * horizontalCoveragePercent } @@ -147,7 +147,7 @@ class SlideInTransition: NSObject, UIViewControllerAnimatedTransitioning { guard let viewToAnimate = viewControllerToAnimate.view else { return } var offsetFrame = viewToAnimate.bounds - var width = UIScreen.main.bounds.width * (UIApplication.shared.respectIpadLayout() ? 0.75 : 0.95) + var width = UIScreen.main.bounds.width * (UIDevice.current.respectIpadLayout() ? 0.75 : 0.95) if width < 250 { width = UIScreen.main.bounds.width * 0.95 } diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index 8f1e1c4ec..9eccd0317 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -747,7 +747,7 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat removedSubviews.forEach({ $0.removeFromSuperview() }) - if UIApplication.shared.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) { + if UIDevice.current.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMac()) { menu.addArrangedSubviews(flexSpace(), flexSpace(), flexSpace(), editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) } else { menu.addArrangedSubviews(editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) @@ -2503,7 +2503,7 @@ extension CommentDepthCell: UIContextMenuInteractionDelegate { } } - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { if self.parent?.menuCell == self { if let parent = self.parent { let menu = self.getMoreMenu(parent) diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index 566d6c842..c132f9f83 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -1341,7 +1341,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi self.view.backgroundColor = UIColor.backgroundColor self.tableView.backgroundColor = UIColor.backgroundColor self.navigationController?.view.backgroundColor = UIColor.foregroundColor - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { refreshControl = UIRefreshControl() refreshControl?.tintColor = UIColor.fontColor refreshControl?.attributedTitle = NSAttributedString(string: "") @@ -1695,7 +1695,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi refreshControl?.setValue(100, forKey: "_snappingHeight") - if UIScreen.main.traitCollection.userInterfaceIdiom == .pad && Int(round(self.view.bounds.width / CGFloat(320))) > 1 && false { + if UIDevice.current.respectIpadLayout() && Int(round(self.view.bounds.width / CGFloat(320))) > 1 && false { self.navigationController!.view.backgroundColor = .clear } self.isHiding = false @@ -2143,66 +2143,108 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi } func updateToolbar() { - navigationController?.setToolbarHidden(false, animated: false) - self.isToolbarHidden = false let space = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) - var items: [UIBarButtonItem] = [] - if !context.isEmpty() { - items.append(space) - let loadFullThreadButton = UIBarButtonItem.init(title: "Load full thread", style: .plain, target: self, action: #selector(CommentViewController.loadAll(_:))) - loadFullThreadButton.accessibilityLabel = "Load full thread" - items.append(loadFullThreadButton) - items.append(space) - } else { - let up = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactUp, overrideString: "up"), toolbar: true) - up.accessibilityLabel = "Navigate up one comment thread" - up.addTarget(self, action: #selector(CommentViewController.goUp(_:)), for: UIControl.Event.touchUpInside) - let upB = UIBarButtonItem(customView: up) - - let nav = UIButton(buttonImage: UIImage(sfString: SFSymbol.safariFill, overrideString: "nav"), toolbar: true) - nav.accessibilityLabel = "Change criteria for comment thread navigation" - nav.addTarget(self, action: #selector(CommentViewController.showNavTypes(_:)), for: UIControl.Event.touchUpInside) - let navB = UIBarButtonItem(customView: nav) - - let down = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactDown, overrideString: "down"), toolbar: true) - down.accessibilityLabel = "Navigate down one comment thread" - down.addTarget(self, action: #selector(CommentViewController.goDown(_:)), for: UIControl.Event.touchUpInside) - let downB = UIBarButtonItem(customView: down) + if UIDevice.current.isMac() { + navigationController?.setToolbarHidden(false, animated: false) + var items = [UIBarButtonItem]() - let more = UIButton(buttonImage: UIImage.init(sfString: SFSymbol.ellipsis, overrideString: "moreh"), toolbar: true) - more.accessibilityLabel = "Post options" - more.addTarget(self, action: #selector(self.showMenu(_:)), for: UIControl.Event.touchUpInside) - moreB = UIBarButtonItem(customView: more) - - let mod = UIButton(buttonImage: UIImage(sfString: SFSymbol.shieldLefthalfFill, overrideString: "mod"), toolbar: true) - mod.accessibilityLabel = "Moderator options" - mod.addTarget(self, action: #selector(self.showMod(_:)), for: UIControl.Event.touchUpInside) - modB = UIBarButtonItem(customView: mod) - if modLink.isEmpty() && modB.customView != nil { - modB.customView? = UIView(frame: modB.customView!.frame) + if !context.isEmpty() { + items.append(space) + let loadFullThreadButton = UIBarButtonItem.init(title: "Load full thread", style: .plain, target: self, action: #selector(CommentViewController.loadAll(_:))) + loadFullThreadButton.accessibilityLabel = "Load full thread" + items.append(loadFullThreadButton) + items.append(space) + if parent != nil && parent is PagingCommentViewController { + + parent?.toolbarItems = items + parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor + parent?.navigationController?.toolbar.tintColor = UIColor.fontColor + } else { + toolbarItems = items + navigationController?.toolbar.barTintColor = UIColor.backgroundColor + navigationController?.toolbar.tintColor = UIColor.fontColor + } + } else { + navigationController?.setToolbarHidden(true, animated: false) + + let more = UIButton(buttonImage: UIImage.init(sfString: SFSymbol.ellipsis, overrideString: "moreh"), toolbar: true) + more.accessibilityLabel = "Post options" + more.addTarget(self, action: #selector(self.showMenu(_:)), for: UIControl.Event.touchUpInside) + moreB = UIBarButtonItem(customView: more) + + if parent != nil && parent is PagingCommentViewController { + parent?.navigationItem.leftBarButtonItems = items + parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor + parent?.navigationController?.toolbar.tintColor = UIColor.fontColor + } else { + navigationItem.leftBarButtonItems = items + navigationController?.toolbar.barTintColor = UIColor.backgroundColor + navigationController?.toolbar.tintColor = UIColor.fontColor + } } - - items.append(modB) - items.append(space) - items.append(upB) - items.append(space) - items.append(navB) - items.append(space) - items.append(downB) - items.append(space) - items.append(moreB) - } - self.navigationController?.navigationBar.shadowImage = UIImage() - navigationController?.navigationBar.isTranslucent = false - - if parent != nil && parent is PagingCommentViewController { - parent?.toolbarItems = items - parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor - parent?.navigationController?.toolbar.tintColor = UIColor.fontColor } else { - toolbarItems = items - navigationController?.toolbar.barTintColor = UIColor.backgroundColor - navigationController?.toolbar.tintColor = UIColor.fontColor + navigationController?.setToolbarHidden(false, animated: false) + self.isToolbarHidden = false + var items: [UIBarButtonItem] = [] + if !context.isEmpty() { + items.append(space) + let loadFullThreadButton = UIBarButtonItem.init(title: "Load full thread", style: .plain, target: self, action: #selector(CommentViewController.loadAll(_:))) + loadFullThreadButton.accessibilityLabel = "Load full thread" + items.append(loadFullThreadButton) + items.append(space) + } else { + let up = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactUp, overrideString: "up"), toolbar: true) + up.accessibilityLabel = "Navigate up one comment thread" + up.addTarget(self, action: #selector(CommentViewController.goUp(_:)), for: UIControl.Event.touchUpInside) + let upB = UIBarButtonItem(customView: up) + + let nav = UIButton(buttonImage: UIImage(sfString: SFSymbol.safariFill, overrideString: "nav"), toolbar: true) + nav.accessibilityLabel = "Change criteria for comment thread navigation" + nav.addTarget(self, action: #selector(CommentViewController.showNavTypes(_:)), for: UIControl.Event.touchUpInside) + let navB = UIBarButtonItem(customView: nav) + + let down = UIButton(buttonImage: UIImage(sfString: SFSymbol.chevronCompactDown, overrideString: "down"), toolbar: true) + down.accessibilityLabel = "Navigate down one comment thread" + down.addTarget(self, action: #selector(CommentViewController.goDown(_:)), for: UIControl.Event.touchUpInside) + let downB = UIBarButtonItem(customView: down) + + let more = UIButton(buttonImage: UIImage.init(sfString: SFSymbol.ellipsis, overrideString: "moreh"), toolbar: true) + more.accessibilityLabel = "Post options" + more.addTarget(self, action: #selector(self.showMenu(_:)), for: UIControl.Event.touchUpInside) + moreB = UIBarButtonItem(customView: more) + + let mod = UIButton(buttonImage: UIImage(sfString: SFSymbol.shieldLefthalfFill, overrideString: "mod"), toolbar: true) + mod.accessibilityLabel = "Moderator options" + mod.addTarget(self, action: #selector(self.showMod(_:)), for: UIControl.Event.touchUpInside) + modB = UIBarButtonItem(customView: mod) + if modLink.isEmpty() && modB.customView != nil { + modB.customView? = UIView(frame: modB.customView!.frame) + } + + items.append(modB) + items.append(space) + items.append(upB) + items.append(space) + items.append(navB) + items.append(space) + items.append(downB) + items.append(space) + items.append(moreB) + } + self.navigationController?.navigationBar.shadowImage = UIImage() + navigationController?.navigationBar.isTranslucent = false + + if parent != nil && parent is PagingCommentViewController { + + parent?.toolbarItems = items + parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor + parent?.navigationController?.toolbar.tintColor = UIColor.fontColor + } else { + toolbarItems = items + navigationController?.toolbar.barTintColor = UIColor.backgroundColor + navigationController?.toolbar.tintColor = UIColor.fontColor + } + } } @@ -3267,7 +3309,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { cellGestureRecognizer.delegate = self cellGestureRecognizer.maximumNumberOfTouches = 1 tableView.addGestureRecognizer(cellGestureRecognizer) - if !UIApplication.shared.respectIpadLayout() { + if !UIDevice.current.respectIpadLayout() { // cellGestureRecognizer.require(toFail: tableView.panGestureRecognizer) } @@ -3292,7 +3334,7 @@ extension CommentViewController: UIGestureRecognizerDelegate { return } - if UIApplication.shared.respectIpadLayout() && SettingValues.appMode != .SINGLE { + if UIDevice.current.respectIpadLayout() && SettingValues.appMode != .SINGLE { if #available(iOS 14, *) { return } diff --git a/Slide for Reddit/ContentListingViewController.swift b/Slide for Reddit/ContentListingViewController.swift index 64a67e109..c63f003e5 100644 --- a/Slide for Reddit/ContentListingViewController.swift +++ b/Slide for Reddit/ContentListingViewController.swift @@ -193,7 +193,7 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat self.tableView.delegate = self self.tableView.dataSource = self - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { refreshControl = UIRefreshControl() refreshControl?.tintColor = UIColor.fontColor @@ -535,7 +535,7 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat } func endAndResetRefresh() { - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { self.refreshControl?.endRefreshing() self.refreshControl?.removeFromSuperview() self.refreshControl = UIRefreshControl() diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index 3f3049a4f..7f9fad229 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -3362,7 +3362,7 @@ extension LinkCellView: UIContextMenuInteractionDelegate { }) } - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { _ in return self.del?.getMoreMenu(self) }) diff --git a/Slide for Reddit/ModalMediaViewController.swift b/Slide for Reddit/ModalMediaViewController.swift index b547f5957..fa9bf47f0 100644 --- a/Slide for Reddit/ModalMediaViewController.swift +++ b/Slide for Reddit/ModalMediaViewController.swift @@ -285,7 +285,7 @@ class ModalMediaViewController: UIViewController { panGestureRecognizer!.allowedScrollTypesMask = .continuous } panGestureRecognizer!.cancelsTouchesInView = false - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { panGestureRecognizer!.allowedScrollTypesMask = .discrete panGestureRecognizer!.maximumNumberOfTouches = 0 } @@ -528,11 +528,9 @@ extension ModalMediaViewController: UIGestureRecognizerDelegate { } else if panGesture.state == .ended { let velocity = panGesture.velocity(in: view) - - print(velocity) - - let down = panGesture.velocity(in: view).y > 0 - if abs(velocity.y) >= 1000 || abs(self.view.frame.origin.y) > self.view.frame.size.height / 2 { + + let down = panGesture.velocity(in: view).y > 0 || viewToMove.frame.origin.y > 0 + if abs(velocity.y) >= 1000 || abs(viewToMove.frame.origin.y) > self.view.frame.size.height / (UIDevice.current.isMac() ? 4 : 2) { UIView.animate(withDuration: 0.2, animations: { viewToMove.frame.origin = CGPoint( diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 8d6c3896c..d7deac2d2 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -908,7 +908,7 @@ class CurrentAccountHeaderView: UIView { } var forwardButton = UIButton(type: .custom).then { - $0.setImage(UIImage(sfString: UIApplication.shared.respectIpadLayout() ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) + $0.setImage(UIImage(sfString: UIDevice.current.respectIpadLayout() ? .xmark : .chevronRight, overrideString: "next")!.getCopy(withSize: .square(size: 20), withColor: UIColor.fontColor), for: UIControl.State.normal) $0.contentEdgeInsets = UIEdgeInsets(top: 7, left: 8, bottom: 7, right: 8) $0.accessibilityLabel = "Go home" } @@ -1240,7 +1240,7 @@ extension CurrentAccountHeaderView { nav.pushNextViewControllerFromRight(nil) } else { var is14Column = false - if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIApplication.shared.respectIpadLayout() { + if #available(iOS 14, *), SettingValues.appMode == .SPLIT && UIDevice.current.respectIpadLayout() { is14Column = true } if #available(iOS 14, *), self.parent?.splitViewController?.style == .doubleColumn { @@ -1255,7 +1255,7 @@ extension CurrentAccountHeaderView { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.parent?.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/ProfileViewController.swift b/Slide for Reddit/ProfileViewController.swift index 25e4d9bf9..3f9de7812 100644 --- a/Slide for Reddit/ProfileViewController.swift +++ b/Slide for Reddit/ProfileViewController.swift @@ -156,7 +156,7 @@ extension ProfileViewController: ColorPickerViewDelegate { } else { let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 15fc9772f..d8590c972 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -492,18 +492,18 @@ class SettingValues { } public static func initialize() { - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() let settings = UserDefaults.standard SettingValues.saveNSFWHistory = settings.bool(forKey: SettingValues.pref_saveNSFWHistory) SettingValues.reduceColor = settings.object(forKey: SettingValues.pref_reduceColor) == nil ? true : settings.bool(forKey: SettingValues.pref_reduceColor) SettingValues.saveHistory = settings.object(forKey: SettingValues.pref_saveHistory) == nil ? true : settings.bool(forKey: SettingValues.pref_saveHistory) var columns = 2 // TODO - Maybe calculate per device? - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { columns = 1 } SettingValues.multiColumnCount = settings.object(forKey: SettingValues.pref_multiColumnCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_multiColumnCount) - SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIApplication.shared.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) + SettingValues.portraitMultiColumnCount = settings.object(forKey: SettingValues.pref_portraitMultiColumnCount) == nil ? (UIDevice.current.respectIpadLayout() ? 2 : 1) : settings.integer(forKey: SettingValues.pref_portraitMultiColumnCount) SettingValues.galleryCount = settings.object(forKey: SettingValues.pref_galleryCount) == nil ? columns : settings.integer(forKey: SettingValues.pref_galleryCount) SettingValues.highlightOp = settings.object(forKey: SettingValues.pref_highlightOp) == nil ? true : settings.bool(forKey: SettingValues.pref_highlightOp) @@ -535,8 +535,8 @@ class SettingValues { } } - SettingValues.desktopMode = settings.object(forKey: SettingValues.pref_desktopMode) == nil ? UIApplication.shared.isMac() : settings.bool(forKey: SettingValues.pref_desktopMode) - SettingValues.desktopMode = SettingValues.desktopMode && (UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac()) // Only enable this on Mac or iPad + SettingValues.desktopMode = settings.object(forKey: SettingValues.pref_desktopMode) == nil ? UIDevice.current.isMac() : settings.bool(forKey: SettingValues.pref_desktopMode) + SettingValues.desktopMode = SettingValues.desktopMode && (UIDevice.current.respectIpadLayout() || UIDevice.current.isMac()) // Only enable this on Mac or iPad SettingValues.scrollSidebar = settings.object(forKey: SettingValues.pref_scrollSidebar) == nil ? true : settings.bool(forKey: SettingValues.pref_scrollSidebar) @@ -589,7 +589,7 @@ class SettingValues { SettingValues.disable13Popup = false // REMOVE this setting settings.bool(forKey: SettingValues.pref_disable13Popup) SettingValues.streamVideos = settings.object(forKey: SettingValues.pref_streamVideos) == nil ? true : settings.bool(forKey: SettingValues.pref_streamVideos) SettingValues.fullWidthHeaderCells = settings.bool(forKey: SettingValues.pref_fullWidthHeaderCells) - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { SettingValues.fullWidthHeaderCells = true } SettingValues.gfycatAPI = settings.object(forKey: SettingValues.pref_gfycatAPI) == nil ? true : settings.bool(forKey: SettingValues.pref_gfycatAPI) @@ -664,10 +664,7 @@ class SettingValues { SettingValues.abbreviateScores = settings.object(forKey: SettingValues.pref_abbreviateScores) == nil ? true : settings.bool(forKey: SettingValues.pref_abbreviateScores) SettingValues.scoreInTitle = settings.bool(forKey: SettingValues.pref_scoreInTitle) SettingValues.commentsInTitle = settings.bool(forKey: SettingValues.pref_commentsInTitle) - SettingValues.appMode = AppMode.init(rawValue: settings.string(forKey: SettingValues.pref_appMode) ?? (pad ? "multi" : "single")) ?? (pad ? .SPLIT : .SINGLE) - if UIApplication.shared.isMac() { - SettingValues.appMode = .SPLIT - } + SettingValues.appMode = AppMode.init(rawValue: settings.string(forKey: SettingValues.pref_appMode) ?? (UIDevice.current.isMac() ? "triple" : (pad ? "multi" : "single"))) ?? (UIDevice.current.isMac() ? .TRIPLE_MULTI_COLUMN : (pad ? .SPLIT : .SINGLE)) SettingValues.hideSeen = settings.bool(forKey: SettingValues.pref_hideSeen) SettingValues.postViewMode = PostViewType.init(rawValue: settings.string(forKey: SettingValues.pref_postViewMode) ?? "card") ?? .CARD @@ -1288,12 +1285,13 @@ class SettingValues { } public enum AppMode: String { - public static let cases: [AppMode] = [.SPLIT, .SINGLE, .MULTI_COLUMN] + public static let cases: [AppMode] = UIDevice.current.isMac() ? [.SPLIT, .SINGLE, .MULTI_COLUMN, .TRIPLE_MULTI_COLUMN] : [.SPLIT, .SINGLE, .MULTI_COLUMN] case SPLIT = "split" case SINGLE = "single" case MULTI_COLUMN = "multi" - + case TRIPLE_MULTI_COLUMN = "triple" + func getTitle() -> String { switch self { case .SPLIT: @@ -1302,17 +1300,21 @@ class SettingValues { return "Single list" case .MULTI_COLUMN: return "Multi-column mode" + case .TRIPLE_MULTI_COLUMN: + return "Multi-column with comments" } } func getDescription() -> String { switch self { case .SPLIT: - return "Displays submissions on the left and comments on the right (requires an iPad)" + return "Displays submissions on the left and comments on the right" case .SINGLE: return "Single column display of submissions" case .MULTI_COLUMN: return "Multiple column display of submissions" + case .TRIPLE_MULTI_COLUMN: + return "Multiple column display of submissions with comments on the right" } } } diff --git a/Slide for Reddit/SettingsComments.swift b/Slide for Reddit/SettingsComments.swift index 4b922b3aa..bb22c5eac 100644 --- a/Slide for Reddit/SettingsComments.swift +++ b/Slide for Reddit/SettingsComments.swift @@ -226,7 +226,7 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() diff --git a/Slide for Reddit/SettingsGeneral.swift b/Slide for Reddit/SettingsGeneral.swift index 976d4959c..3c5f83814 100644 --- a/Slide for Reddit/SettingsGeneral.swift +++ b/Slide for Reddit/SettingsGeneral.swift @@ -542,7 +542,7 @@ class SettingsGeneral: BubbleSettingTableViewController { } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() switch section { case 0: return 4 + (!pad ? 1 : 0) case 1: return 3 diff --git a/Slide for Reddit/SettingsTheme.swift b/Slide for Reddit/SettingsTheme.swift index ab2d65a5f..09bef12b7 100644 --- a/Slide for Reddit/SettingsTheme.swift +++ b/Slide for Reddit/SettingsTheme.swift @@ -82,7 +82,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { } else { let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: UIScreen.main.bounds.size.width - margin * 4.0, height: 200) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: UIScreen.main.bounds.size.width - margin * 4.0, height: 200) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() @@ -118,7 +118,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } @@ -173,7 +173,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 200) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 200) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColorAccent() @@ -216,7 +216,7 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { alertController.addAction(somethingAction) alertController.addAction(cancelAction) alertController.modalPresentationStyle = .popover - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { alertController.preferredContentSize = CGSize(width: MKColorPicker.bounds.size.width + (margin * 2), height: MKColorPicker.bounds.size.height + 100) } if let presenter = alertController.popoverPresentationController { diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index a880267d3..8fbab3926 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -16,6 +16,7 @@ class SettingsViewMode: BubbleSettingTableViewController { var singleMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "single") var desktopMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "desktop") var splitMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "split") + var tripleMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "triple") var multicolumnMode: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "multi") var multicolumnCount: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "multicount") var multicolumnPortraitCount: UITableViewCell = InsetCell.init(style: .subtitle, reuseIdentifier: "portrait") @@ -100,9 +101,10 @@ class SettingsViewMode: BubbleSettingTableViewController { createCell(disablePopupSubreddit, disablePopupSubredditSwitch, isOn: SettingValues.disableSubredditPopupIpad, text: "Show subreddits full screen") createCell(disablePopup, disablePopupSwitch, isOn: SettingValues.disablePopupIpad, text: "Show comments full screen") createCell(disableMulticolumn, disableMulticolumnSwitch, isOn: !SettingValues.disableMulticolumnCollections, text: "Multi-column in profile and inbox") - createCell(singleMode, isOn: false, text: "Single-column posts") - createCell(multicolumnMode, isOn: false, text: "Multi-column posts") - createCell(splitMode, isOn: false, text: "Split-content") + createCell(singleMode, isOn: false, text: "Single-column posts\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") + createCell(multicolumnMode, isOn: false, text: "Multi-column posts\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") + createCell(splitMode, isOn: false, text: "Split-content\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") + createCell(tripleMode, isOn: false, text: "Triple-pane Multi-column\(UIDevice.current.isMac() ? "(designed for MacOS)" : "")") createCell(multicolumnCount, isOn: false, text: "Multi-column count (Pro)") createCell(multicolumnPortraitCount, isOn: false, text: "Portrait Multi-column count (Pro)") createCell(galleryCount, isOn: false, text: "Gallery-mode column count (Pro)") @@ -113,7 +115,13 @@ class SettingsViewMode: BubbleSettingTableViewController { self.singleMode.backgroundColor = UIColor.foregroundColor self.singleMode.textLabel?.textColor = UIColor.fontColor self.singleMode.detailTextLabel?.numberOfLines = 0 - + + self.tripleMode.detailTextLabel?.text = SettingValues.AppMode.TRIPLE_MULTI_COLUMN.getDescription() + self.tripleMode.detailTextLabel?.textColor = UIColor.fontColor + self.tripleMode.backgroundColor = UIColor.foregroundColor + self.tripleMode.textLabel?.textColor = UIColor.fontColor + self.tripleMode.detailTextLabel?.numberOfLines = 0 + self.splitMode.detailTextLabel?.text = SettingValues.AppMode.SPLIT.getDescription() self.splitMode.detailTextLabel?.textColor = UIColor.fontColor self.splitMode.backgroundColor = UIColor.foregroundColor @@ -167,13 +175,15 @@ class SettingsViewMode: BubbleSettingTableViewController { self.splitMode.accessoryType = .checkmark case .MULTI_COLUMN: self.multicolumnMode.accessoryType = .checkmark + case .TRIPLE_MULTI_COLUMN: + self.tripleMode.accessoryType = .checkmark } self.galleryCount.isUserInteractionEnabled = true self.galleryCount.textLabel!.isEnabled = true self.galleryCount.detailTextLabel!.isEnabled = true - if !SettingValues.isPro && !UIApplication.shared.isMac() { + if !SettingValues.isPro && !UIDevice.current.isMac() { multicolumnCount.isUserInteractionEnabled = false multicolumnCount.textLabel!.isEnabled = false multicolumnCount.detailTextLabel!.isEnabled = false @@ -188,13 +198,13 @@ class SettingsViewMode: BubbleSettingTableViewController { multicolumnPortraitCount.contentView.alpha = 0.8 } - if !UIApplication.shared.respectIpadLayout() { + if !UIDevice.current.respectIpadLayout() { self.splitMode.isUserInteractionEnabled = false self.splitMode.textLabel!.isEnabled = false self.splitMode.detailTextLabel!.isEnabled = false } - if (SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro) && !UIApplication.shared.respectIpadLayout(){ + if (SettingValues.appMode != .MULTI_COLUMN || !SettingValues.isPro) && !UIDevice.current.respectIpadLayout(){ self.multicolumnCount.isUserInteractionEnabled = false self.multicolumnCount.textLabel!.isEnabled = false self.multicolumnCount.detailTextLabel!.isEnabled = false @@ -226,7 +236,7 @@ class SettingsViewMode: BubbleSettingTableViewController { case 0: return self.singleMode case 1: return self.splitMode case 2: return self.multicolumnMode - case 3: return self.desktopMode + case 3: return UIDevice.current.isMac() ? self.tripleMode : self.desktopMode default: fatalError("Unknown row in section 0") } case 1: @@ -259,6 +269,11 @@ class SettingsViewMode: BubbleSettingTableViewController { case 2: SettingValues.appMode = .MULTI_COLUMN UserDefaults.standard.set(SettingValues.AppMode.MULTI_COLUMN.rawValue, forKey: SettingValues.pref_appMode) + case 3: + if UIDevice.current.isMac() { + SettingValues.appMode = .TRIPLE_MULTI_COLUMN + UserDefaults.standard.set(SettingValues.AppMode.TRIPLE_MULTI_COLUMN.rawValue, forKey: SettingValues.pref_appMode) + } default: break } @@ -292,7 +307,7 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showMultiColumn() { - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { let popup = DragDownAlertMenu(title: "Column Count", subtitle: "", icon: nil) for value in 1...5 { @@ -308,7 +323,7 @@ class SettingsViewMode: BubbleSettingTableViewController { popup.show(self) } else { - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) actionSheetController.addCloseButton() @@ -343,7 +358,7 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showPortraitMultiColumn() { - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIDevice.current.respectIpadLayout() let actionSheetController = AlertController(title: "Column count", message: nil, preferredStyle: .alert) actionSheetController.addCloseButton() @@ -377,7 +392,7 @@ class SettingsViewMode: BubbleSettingTableViewController { } func showGalleryColumn() { - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIDevice.current.respectIpadLayout() let actionSheetController = AlertController(title: "Gallery column count", message: nil, preferredStyle: .alert) actionSheetController.addCloseButton() @@ -413,7 +428,7 @@ class SettingsViewMode: BubbleSettingTableViewController { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { var ipadOffset = 0 var isIpad = false - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { isIpad = true ipadOffset = 3 } diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 92a08a896..c9cebbfd5 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -212,7 +212,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele super.viewDidLoad() CachedTitle.titles.removeAll() - if UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIApplication.shared.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { + if UIDevice.current.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { splitViewController?.showDetailViewController(SwipeForwardNavigationController(rootViewController: PlaceholderViewController()), sender: self) } @@ -924,7 +924,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele if self.dataSource.loaded && !self.dataSource.loading { self.flowLayout.reset(modal: self.presentingViewController != nil, vc: self, isGallery: self.isGallery) self.tableView.reloadData() - if !UIApplication.shared.respectIpadLayout() { + if !UIDevice.current.respectIpadLayout() { var newOffset = self.tableView.contentOffset newOffset.y -= self.headerHeight(false) self.tableView.setContentOffset(newOffset, animated: false) @@ -2119,7 +2119,7 @@ extension SingleSubredditViewController: SubmissionDataSouceDelegate { if self.navigationController?.modalPresentationStyle == .pageSheet && self.navigationController?.viewControllers.count == 1 && !(self.navigationController?.viewControllers[0] is MainViewController) { topOffset = 0 } - let headerHeight = (UIApplication.shared.respectIpadLayout() && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) + let headerHeight = (UIDevice.current.respectIpadLayout() && SettingValues.appMode == .MULTI_COLUMN ? 0 : self.headerHeight(false)) let paddingOffset = CGFloat(headerHeight == 0 ? -4 : 0) setOffset = paddingOffset + navOffset + topOffset + headerHeight @@ -2262,7 +2262,7 @@ extension SingleSubredditViewController { isAccent = false let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.scrollToPreselectedIndex = true MKColorPicker.delegate = self @@ -2342,7 +2342,7 @@ extension SingleSubredditViewController { isAccent = true let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.scrollToPreselectedIndex = true MKColorPicker.delegate = self @@ -2646,7 +2646,7 @@ extension SingleSubredditViewController: UICollectionViewDataSource { var numberOfColumns = CGFloat.zero let portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIScreen.main.traitCollection.userInterfaceIdiom == .pad + let pad = UIDevice.current.respectIpadLayout() if SettingValues.appMode == .MULTI_COLUMN { if UIApplication.shared.statusBarOrientation.isPortrait { @@ -2737,7 +2737,7 @@ extension SingleSubredditViewController: LinkCellViewDelegate { } return }) - VCPresenter.showVC(viewController: comment, popupIfPossible: (UIApplication.shared.respectIpadLayout() && SettingValues.disablePopupIpad || !UIApplication.shared.respectIpadLayout()) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) + VCPresenter.showVC(viewController: comment, popupIfPossible: (UIDevice.current.respectIpadLayout() && SettingValues.disablePopupIpad || !UIDevice.current.respectIpadLayout()) ? false : true, parentNavigationController: self.navigationController, parentViewController: self) } } @@ -3049,7 +3049,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { full.view?.removeGestureRecognizer(full) } - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { fullWidthBackGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(showParentMenu(_:))) guard let swipe = fullWidthBackGestureRecognizer as? UISwipeGestureRecognizer else { return } swipe.direction = .right @@ -3099,7 +3099,7 @@ extension SingleSubredditViewController: UIGestureRecognizerDelegate { return false } if translation.x < 0 { - if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIApplication.shared.respectIpadLayout()) { + if gestureRecognizer.location(in: tableView).x > tableView.frame.width * 0.5 || !SettingValues.submissionGestureMode.shouldPage() || (SettingValues.appMode == .MULTI_COLUMN && UIDevice.current.respectIpadLayout()) { return true } } else if !SettingValues.submissionGestureMode.shouldPage() && abs(translation.x) > abs(translation.y) { @@ -3493,7 +3493,7 @@ public class LinksHeaderCellView: UICollectionViewCell { header.addSubview(imageView) imageView.clipsToBounds = true - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { imageView.verticalAnchors /==/ header.verticalAnchors imageView.horizontalAnchors /==/ header.horizontalAnchors + 4 imageView.layer.cornerRadius = 15 @@ -3532,7 +3532,7 @@ public class SubLinkItem { extension SingleSubredditViewController: TapBehindModalViewControllerDelegate { func shouldDismiss() -> Bool { - return UIApplication.shared.respectIpadLayout() + return UIDevice.current.respectIpadLayout() } } diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index de4b4c672..ba7593bdb 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -116,7 +116,7 @@ class SplitMainViewController: MainViewController { splitViewController?.navigationItem.hidesBackButton = true if #available(iOS 14.0, *) { - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { splitViewController?.showsSecondaryOnlyButton = false splitViewController?.navigationItem.hidesBackButton = true splitViewController?.navigationItem.backBarButtonItem = UIBarButtonItem() @@ -199,7 +199,7 @@ class SplitMainViewController: MainViewController { if self.navigationController?.viewControllers[0] is NavigationHomeViewController { self.navigationController?.popViewController(animated: true) } else if #available(iOS 14, *) { - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { self.splitViewController?.show(UISplitViewController.Column.primary) } else { self.navigationController?.popViewController(animated: true) @@ -321,7 +321,7 @@ class SplitMainViewController: MainViewController { vc.setupSwipeGesture() } else if SettingValues.submissionGestureMode == .HALF_FULL { // Always allow swipe back with paging disabled and not full vc.setupSwipeGesture() - } else if UIApplication.shared.respectIpadLayout() && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { + } else if UIDevice.current.respectIpadLayout() && !SettingValues.subredditBar && SettingValues.submissionGestureMode != .FULL { vc.setupSwipeGesture() } @@ -537,7 +537,7 @@ class SplitMainViewController: MainViewController { if self.finalSubs.contains(subreddit) && !override { let index = self.finalSubs.firstIndex(of: subreddit) if index == nil { - if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { + if UIDevice.current.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { if self.navigationController?.topViewController != self && !(self.navigationController?.topViewController is NavigationHomeViewController) { self.navigationController?.popToRootViewController(animated: false) } @@ -583,7 +583,7 @@ class SplitMainViewController: MainViewController { self.navigationController?.popToRootViewController(animated: false) } - if UIApplication.shared.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { + if UIDevice.current.respectIpadLayout() && SettingValues.disableSubredditPopupIpad { VCPresenter.showVC(viewController: SingleSubredditViewController(subName: subreddit.replacingOccurrences(of: " ", with: ""), single: true), popupIfPossible: false, parentNavigationController: self.navigationController, parentViewController: self) } else { VCPresenter.openRedditLink("/r/" + subreddit.replacingOccurrences(of: " ", with: ""), self.navigationController, self) @@ -1074,7 +1074,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac())) && UIDevice.current.respectIpadLayout() { is14Column = true } @@ -1087,7 +1087,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.respectIpadLayout() { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in @@ -1114,7 +1114,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac())) && UIApplication.shared.respectIpadLayout() { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac())) && UIDevice.current.respectIpadLayout() { is14Column = true } @@ -1122,7 +1122,7 @@ extension SplitMainViewController: NavigationHomeDelegate { UIApplication.shared.sendAction(action, to: target, from: nil, for: nil) } else { UIView.animate(withDuration: 0.3, animations: { - if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIApplication.shared.respectIpadLayout() && !SettingValues.desktopMode { + if (SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .SINGLE) && UIDevice.current.respectIpadLayout() && !SettingValues.desktopMode { UIView.animate(withDuration: 0.5, animations: { () -> Void in self.splitViewController?.preferredDisplayMode = .primaryHidden }, completion: { (_) in diff --git a/Slide for Reddit/SubredditThemeViewController.swift b/Slide for Reddit/SubredditThemeViewController.swift index f5ac6053c..acfb03304 100644 --- a/Slide for Reddit/SubredditThemeViewController.swift +++ b/Slide for Reddit/SubredditThemeViewController.swift @@ -298,7 +298,7 @@ class SubredditThemeViewController: UITableViewController, ColorPickerViewDelega isAccent = false let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColor() @@ -345,7 +345,7 @@ class SubredditThemeViewController: UITableViewController, ColorPickerViewDelega let alertController = UIAlertController(title: "\n\n\n\n\n\n\n\n", message: nil, preferredStyle: UIAlertController.Style.actionSheet) let margin: CGFloat = 10.0 - let rect = CGRect(x: margin, y: margin, width: UIScreen.main.traitCollection.userInterfaceIdiom == .pad ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) + let rect = CGRect(x: margin, y: margin, width: UIDevice.current.respectIpadLayout() ? 314 - margin * 4.0: alertController.view.bounds.size.width - margin * 4.0, height: 150) let MKColorPicker = ColorPickerView.init(frame: rect) MKColorPicker.delegate = self MKColorPicker.colors = GMPalette.allColorAccent() diff --git a/Slide for Reddit/SubredditToolbarSearchViewController.swift b/Slide for Reddit/SubredditToolbarSearchViewController.swift index a5647e4e2..e9170333c 100644 --- a/Slide for Reddit/SubredditToolbarSearchViewController.swift +++ b/Slide for Reddit/SubredditToolbarSearchViewController.swift @@ -104,7 +104,7 @@ class SubredditToolbarSearchViewController: UIViewController, UIGestureRecognize } if controller.navigationController?.viewControllers.count ?? 0 == 1 && controller.navigationController?.modalPresentationStyle ?? controller.modalPresentationStyle == .pageSheet { bottomOffset += 64 - if UIApplication.shared.respectIpadLayout() { + if UIDevice.current.respectIpadLayout() { bottomOffset += 24 } } diff --git a/Slide for Reddit/SwipeForwardNavigationController.swift b/Slide for Reddit/SwipeForwardNavigationController.swift index 7bb2497b9..9fd0febf9 100644 --- a/Slide for Reddit/SwipeForwardNavigationController.swift +++ b/Slide for Reddit/SwipeForwardNavigationController.swift @@ -264,7 +264,7 @@ extension SwipeForwardNavigationController { let pushedViewController = pushableViewControllers.last if pushedViewController != nil && visibleViewController != nil && visibleViewController?.isBeingPresented == false && visibleViewController?.isBeingDismissed == false { - push(pushedViewController, animated: (UIApplication.shared.isSplitOrSlideOver && !UIApplication.shared.isMac()) ? false : true) { + push(pushedViewController, animated: (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac()) ? false : true) { if !self.pushableViewControllers.isEmpty { self.pushableViewControllers.removeLast() callback?() diff --git a/Slide for Reddit/TapBehindModalViewController.swift b/Slide for Reddit/TapBehindModalViewController.swift index 51d6582fa..85bb73307 100644 --- a/Slide for Reddit/TapBehindModalViewController.swift +++ b/Slide for Reddit/TapBehindModalViewController.swift @@ -23,7 +23,7 @@ class TapBehindModalViewController: SwipeForwardNavigationController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIApplication.shared.respectIpadLayout()) { + if self.tapOutsideRecognizer == nil && ((modalPresentationStyle == .pageSheet || modalPresentationStyle == .popover) || UIDevice.current.respectIpadLayout()) { self.tapOutsideRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.handleTapBehind)) self.tapOutsideRecognizer.numberOfTapsRequired = 1 self.tapOutsideRecognizer.cancelsTouchesInView = false diff --git a/Slide for Reddit/ThreadViewController.swift b/Slide for Reddit/ThreadViewController.swift index 059f7a8c6..1b4f0ecd5 100644 --- a/Slide for Reddit/ThreadViewController.swift +++ b/Slide for Reddit/ThreadViewController.swift @@ -149,7 +149,7 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi self.tableView.delegate = self self.tableView.dataSource = self - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { refreshControl = UIRefreshControl() refreshControl?.tintColor = UIColor.fontColor @@ -294,7 +294,7 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi } func endAndResetRefresh() { - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { return } self.refreshControl?.endRefreshing() diff --git a/Slide for Reddit/UIAlert+Extensions.swift b/Slide for Reddit/UIAlert+Extensions.swift index f0b8384c4..dd262d0d4 100644 --- a/Slide for Reddit/UIAlert+Extensions.swift +++ b/Slide for Reddit/UIAlert+Extensions.swift @@ -92,7 +92,7 @@ extension UIAlertController { } } visualEffectView?.effect = UIBlurEffect(style: UIColor.isLightTheme ? UIBlurEffect.Style.light : UIBlurEffect.Style.dark) - if self.preferredStyle == .actionSheet && !UIApplication.shared.respectIpadLayout() { + if self.preferredStyle == .actionSheet && !UIDevice.current.respectIpadLayout() { cancelActionView?.backgroundColor = UIColor.foregroundColor } } diff --git a/Slide for Reddit/UIApplication+Extensions.swift b/Slide for Reddit/UIApplication+Extensions.swift index 7b9f1a195..b8ef7bab5 100644 --- a/Slide for Reddit/UIApplication+Extensions.swift +++ b/Slide for Reddit/UIApplication+Extensions.swift @@ -13,7 +13,9 @@ extension UIApplication { var statusBarView: UIView? { return statusBarUIView } - +} + +extension UIDevice { public func isMac() -> Bool { if #available(iOS 14.0, *) { return ProcessInfo.processInfo.isiOSAppOnMac || ProcessInfo.processInfo.isMacCatalystApp @@ -27,7 +29,6 @@ extension UIApplication { public func respectIpadLayout() -> Bool { return UIDevice.current.userInterfaceIdiom == .pad || isMac() } - } extension UIApplication { public var isSplitOrSlideOver: Bool { diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index 43fc88e5d..a3b9e2cf2 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -40,11 +40,11 @@ public class VCPresenter { } } - if UIApplication.shared.isMac() { + if UIDevice.current.isMac() { parentIs13 = false } - if (!UIApplication.shared.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { + if (!UIDevice.current.respectIpadLayout() && viewController is PagingCommentViewController && !parentIs13) || (viewController is WebsiteViewController && parentNavigationController != nil) || viewController is SFHideSafariViewController || SettingValues.disable13Popup { override13 = false } @@ -52,7 +52,7 @@ public class VCPresenter { let respectedOverride13 = override13 var shouldPopup = popupIfPossible - if UIApplication.shared.respectIpadLayout() || UIApplication.shared.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { if viewController is SingleSubredditViewController && SettingValues.disableSubredditPopupIpad { shouldPopup = false } else if (viewController is CommentViewController || viewController is PagingCommentViewController) && SettingValues.disablePopupIpad { @@ -60,20 +60,20 @@ public class VCPresenter { } } - override13 = override13 && (UIApplication.shared.respectIpadLayout() || (viewController is UIPageViewController || viewController is SettingsViewController)) + override13 = override13 && (UIDevice.current.respectIpadLayout() || (viewController is UIPageViewController || viewController is SettingsViewController)) - if (viewController is PagingCommentViewController || viewController is CommentViewController || (viewController is WebsiteViewController && !((viewController as! WebsiteViewController).url?.absoluteString.contains("login.compact") ?? false))) && (parentViewController?.splitViewController != nil && UIApplication.shared.respectIpadLayout() && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { + if (viewController is PagingCommentViewController || viewController is CommentViewController || (viewController is WebsiteViewController && !((viewController as! WebsiteViewController).url?.absoluteString.contains("login.compact") ?? false))) && (parentViewController?.splitViewController != nil && UIDevice.current.respectIpadLayout() && (SettingValues.appMode != .MULTI_COLUMN && SettingValues.appMode != .SINGLE)) && !(parentViewController is CommentViewController) && (!override13 || !parentIs13) { (parentViewController!.splitViewController)?.showDetailViewController(SwipeForwardNavigationController(rootViewController: viewController), sender: nil) return - } else if ((!SettingValues.disablePopupIpad) && UIApplication.shared.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { + } else if ((!SettingValues.disablePopupIpad) && UIDevice.current.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { - if UIApplication.shared.isMac() && viewController is SettingsViewController { + if UIDevice.current.isMac() && viewController is SettingsViewController { UIApplication.shared.requestSceneSessionActivation(nil, userActivity: NSUserActivity(activityType: "settings"), options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is SingleSubredditViewController { + } else if UIDevice.current.isMac() && viewController is SingleSubredditViewController { let activity = NSUserActivity(activityType: "subreddit") activity.userInfo = ["subreddit": (viewController as! SingleSubredditViewController).sub] UIApplication.shared.requestSceneSessionActivation(nil, @@ -81,21 +81,21 @@ public class VCPresenter { options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is InboxViewController { + } else if UIDevice.current.isMac() && viewController is InboxViewController { let activity = NSUserActivity(activityType: "inbox") UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is ProfileViewController { + } else if UIDevice.current.isMac() && viewController is ProfileViewController { let activity = NSUserActivity(activityType: "profile") activity.userInfo = ["profile": (viewController as! ProfileViewController).name] UIApplication.shared.requestSceneSessionActivation(nil, userActivity: activity, options: nil, errorHandler: nil) - } else if UIApplication.shared.isMac() && viewController is WebsiteViewController { + } else if UIDevice.current.isMac() && viewController is WebsiteViewController { let activity = NSUserActivity(activityType: "website") activity.userInfo = ["url": (viewController as! WebsiteViewController).url] UIApplication.shared.requestSceneSessionActivation(nil, @@ -121,7 +121,7 @@ public class VCPresenter { let barButton = UIBarButtonItem.init(customView: button) // Let's figure out how to present it - let small: Bool = shouldPopup && UIScreen.main.traitCollection.userInterfaceIdiom == .pad && UIApplication.shared.statusBarOrientation != .portrait + let small: Bool = shouldPopup && UIDevice.current.respectIpadLayout() && UIApplication.shared.statusBarOrientation != .portrait if small || override13 || respectedOverride13 { newParent.modalPresentationStyle = .pageSheet diff --git a/Slide for Reddit/VideoScrubberView.swift b/Slide for Reddit/VideoScrubberView.swift index 31ecd5870..6f48f95e5 100644 --- a/Slide for Reddit/VideoScrubberView.swift +++ b/Slide for Reddit/VideoScrubberView.swift @@ -73,7 +73,7 @@ class VideoScrubberView: UIView { slider.maximumValue = 1 slider.isContinuous = true - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { slider.minimumTrackTintColor = ColorUtil.accentColorForSub(sub: "") slider.maximumTrackTintColor = ColorUtil.accentColorForSub(sub: "").withAlphaComponent(0.4) @@ -162,7 +162,7 @@ extension VideoScrubberView { @objc func sliderDidBeginDragging(_ sender: ThickSlider) { delegate?.sliderDidBeginDragging() - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { slider.setThumbImage(largeThumbImage, for: .normal) } UIView.animate(withDuration: 0.3) { @@ -172,7 +172,7 @@ extension VideoScrubberView { @objc func sliderDidEndDragging(_ sender: ThickSlider) { delegate?.sliderDidEndDragging() - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { slider.setThumbImage(smallThumbImage, for: .normal) } UIView.animate(withDuration: 0.3) { diff --git a/Slide for Reddit/WebsiteViewController.swift b/Slide for Reddit/WebsiteViewController.swift index 2ecd6f402..a87f13693 100644 --- a/Slide for Reddit/WebsiteViewController.swift +++ b/Slide for Reddit/WebsiteViewController.swift @@ -89,7 +89,11 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { items.append(forwardB) items.append(space) - toolbarItems = items + if UIDevice.current.isMac() { + navigationItem.rightBarButtonItems = items + } else { + toolbarItems = items + } } @objc func goBack() { @@ -294,7 +298,7 @@ class WebsiteViewController: MediaViewController, WKNavigationDelegate { } func loadUrl() { - if url?.host == "twitter.com" && UIApplication.shared.respectIpadLayout() { + if url?.host == "twitter.com" && UIDevice.current.respectIpadLayout() { webView.customUserAgent = "Googlebot/2.1 (+http://www.google.com/bot.html)" } let myURLRequest: URLRequest = URLRequest(url: url!) diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 31643dba4..37c3fdc75 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -48,10 +48,10 @@ class WrappingFlowLayout: UICollectionViewLayout { cache = [] contentHeight = 0 var portraitCount = SettingValues.portraitMultiColumnCount - let pad = UIApplication.shared.respectIpadLayout() + let pad = UIDevice.current.respectIpadLayout() - if SettingValues.appMode == .MULTI_COLUMN || UIApplication.shared.isMac() { - if (UIApplication.shared.statusBarOrientation.isPortrait && !UIApplication.shared.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { + if SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .TRIPLE_MULTI_COLUMN { + if (UIApplication.shared.statusBarOrientation.isPortrait && !UIDevice.current.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { if !pad { numberOfColumns = SettingValues.portraitMultiColumnCount } else { @@ -68,7 +68,7 @@ class WrappingFlowLayout: UICollectionViewLayout { numberOfColumns = 1 } - if !UIApplication.shared.isMac() { + if !UIDevice.current.isMac() { if pad && UIApplication.shared.keyWindow?.frame != UIScreen.main.bounds || UIApplication.shared.isSplitOrSlideOver { numberOfColumns = 1 } From f474d33ccb4f6da86ae4124a8a44f1e0474e4780 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 7 Mar 2021 17:14:50 -0600 Subject: [PATCH 24/46] Fixed issues on iOS from Catalyst conversion --- .../xcschemes/Slide for Apple Watch.xcscheme | 25 +-- Slide for Reddit/AppDelegate.swift | 161 ++++++++++-------- Slide for Reddit/CommentViewController.swift | 4 +- .../ModalMediaViewController.swift | 4 +- .../NavigationHomeViewController.swift | 25 ++- .../SingleSubredditViewController.swift | 4 +- .../TabsContentPagingViewController.swift | 2 +- Slide for Reddit/ThreadViewController.swift | 4 +- Slide for Reddit/VCPresenter.swift | 73 ++++---- 9 files changed, 168 insertions(+), 134 deletions(-) diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0d084ded0..0530f2df2 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,10 +65,8 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - - - - - + diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index a60dd673e..00623f579 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -1192,14 +1192,16 @@ extension AppDelegate: UIWindowSceneDelegate { let size = windowScene.coordinateSpace.bounds.size for window in windowScene.windows { - if let split = window.rootViewController as? UISplitViewController, split.style == .tripleColumn { - split.minimumPrimaryColumnWidth = size.width * 0.15 - split.preferredPrimaryColumnWidthFraction = 0.15 - split.maximumPrimaryColumnWidth = size.width * 0.15 - - split.minimumSupplementaryColumnWidth = size.width * 0.6 - split.maximumSupplementaryColumnWidth = size.width * 0.6 - split.preferredSupplementaryColumnWidthFraction = 0.6 + if #available(iOS 14.0, *) { + if let split = window.rootViewController as? UISplitViewController, split.style == .tripleColumn { + split.minimumPrimaryColumnWidth = size.width * 0.15 + split.preferredPrimaryColumnWidthFraction = 0.15 + split.maximumPrimaryColumnWidth = size.width * 0.15 + + split.minimumSupplementaryColumnWidth = size.width * 0.6 + split.maximumSupplementaryColumnWidth = size.width * 0.6 + split.preferredSupplementaryColumnWidthFraction = 0.6 + } } } } @@ -1277,68 +1279,91 @@ extension AppDelegate: UIWindowSceneDelegate { }*/ } - if let userActivity = connectionOptions.userActivities.first { - if connectionOptions.userActivities.first?.activityType == "settings" { - window?.rootViewController = SwipeForwardNavigationController(rootViewController: SettingsViewController()) - } else if connectionOptions.userActivities.first?.activityType == "website", let url = userActivity.userInfo?["url"] as? URL { - window?.rootViewController = SwipeForwardNavigationController(rootViewController: WebsiteViewController(url: url, subreddit: "")) - } else if connectionOptions.userActivities.first?.activityType == "subreddit", let subreddit = userActivity.userInfo?["subreddit"] as? String { - let subVC = SingleSubredditViewController(subName: subreddit, single: true) - let split = UISplitViewController(style: .doubleColumn) - split.setViewController(subVC, for: .primary) - split.setViewController(PlaceholderViewController(), for: .secondary) - let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) - - split.preferredContentSize = size - split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 - split.preferredPrimaryColumnWidthFraction = 0.60 - split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 - - split.preferredDisplayMode = .oneBesideSecondary - split.preferredSplitBehavior = .tile - - window?.rootViewController = split - } else if connectionOptions.userActivities.first?.activityType == "inbox" { - let subVC = InboxViewController() - let split = UISplitViewController(style: .doubleColumn) - split.setViewController(subVC, for: .primary) - split.setViewController(PlaceholderViewController(), for: .secondary) - let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) - - split.preferredContentSize = size - split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 - split.preferredPrimaryColumnWidthFraction = 0.60 - split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 - - split.preferredDisplayMode = .oneBesideSecondary - split.preferredSplitBehavior = .tile - - window?.rootViewController = split - } else if connectionOptions.userActivities.first?.activityType == "profile", let profile = userActivity.userInfo?["profile"] as? String { - let subVC = SwipeForwardNavigationController(rootViewController: ProfileViewController(name: profile)) - let split = UISplitViewController(style: .doubleColumn) - split.setViewController(subVC, for: .primary) - split.setViewController(PlaceholderViewController(), for: .secondary) - let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) - - split.preferredContentSize = size - split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 - split.preferredPrimaryColumnWidthFraction = 0.60 - split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 - - split.preferredDisplayMode = .oneBesideSecondary - split.preferredSplitBehavior = .tile - - window?.rootViewController = split - } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "SUBREDDIT" { - VCPresenter.openRedditLink("/r/\(userActivity.title ?? "")", window?.rootViewController as? UINavigationController, window?.rootViewController) - } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "INBOX" { - VCPresenter.showVC(viewController: InboxViewController(), popupIfPossible: false, parentNavigationController: window?.rootViewController as? UINavigationController, parentViewController: window?.rootViewController) - } else if let url = userActivity.webpageURL { - _ = handleURL(url) + if #available(iOS 14, *) { + if let userActivity = connectionOptions.userActivities.first { + if connectionOptions.userActivities.first?.activityType == "settings" { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: SettingsViewController()) + } else if connectionOptions.userActivities.first?.activityType == "website", let url = userActivity.userInfo?["url"] as? URL { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: WebsiteViewController(url: url, subreddit: "")) + } else if connectionOptions.userActivities.first?.activityType == "subreddit", let subreddit = userActivity.userInfo?["subreddit"] as? String { + let subVC = SingleSubredditViewController(subName: subreddit, single: true) + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + split.presentsWithGesture = false + split.showsSecondaryOnlyButton = false + + window?.rootViewController = split + } else if connectionOptions.userActivities.first?.activityType == "inbox" { + let subVC = InboxViewController() + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + split.presentsWithGesture = false + split.showsSecondaryOnlyButton = false + + window?.rootViewController = split + } else if connectionOptions.userActivities.first?.activityType == "profile", let profile = userActivity.userInfo?["profile"] as? String { + let subVC = SwipeForwardNavigationController(rootViewController: ProfileViewController(name: profile)) + let split = UISplitViewController(style: .doubleColumn) + split.setViewController(subVC, for: .primary) + split.setViewController(PlaceholderViewController(), for: .secondary) + let size = window?.frame.size ?? CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + + split.preferredContentSize = size + split.minimumPrimaryColumnWidth = split.preferredContentSize.width * 0.60 + split.preferredPrimaryColumnWidthFraction = 0.60 + split.maximumPrimaryColumnWidth = UIScreen.main.bounds.width * 0.60 + + split.preferredDisplayMode = .oneBesideSecondary + split.preferredSplitBehavior = .tile + split.presentsWithGesture = false + split.showsSecondaryOnlyButton = false + + window?.rootViewController = split + } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "SUBREDDIT" { + VCPresenter.openRedditLink("/r/\(userActivity.title ?? "")", window?.rootViewController as? UINavigationController, window?.rootViewController) + } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "INBOX" { + VCPresenter.showVC(viewController: InboxViewController(), popupIfPossible: false, parentNavigationController: window?.rootViewController as? UINavigationController, parentViewController: window?.rootViewController) + } else if let url = userActivity.webpageURL { + _ = handleURL(url) + } } + } else { + if let userActivity = connectionOptions.userActivities.first { + if connectionOptions.userActivities.first?.activityType == "settings" { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: SettingsViewController()) + } else if connectionOptions.userActivities.first?.activityType == "website", let url = userActivity.userInfo?["url"] as? URL { + window?.rootViewController = SwipeForwardNavigationController(rootViewController: WebsiteViewController(url: url, subreddit: "")) + } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "SUBREDDIT" { + VCPresenter.openRedditLink("/r/\(userActivity.title ?? "")", window?.rootViewController as? UINavigationController, window?.rootViewController) + } else if (userActivity.userInfo?["TYPE"] as? NSString) ?? "" == "INBOX" { + VCPresenter.showVC(viewController: InboxViewController(), popupIfPossible: false, parentNavigationController: window?.rootViewController as? UINavigationController, parentViewController: window?.rootViewController) + } else if let url = userActivity.webpageURL { + _ = handleURL(url) + } + } + } - + #if targetEnvironment(macCatalyst) guard let windowScene = scene as? UIWindowScene else { return } diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index c132f9f83..03637c146 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -1353,7 +1353,9 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi top = 0 } tableView.contentInset = UIEdgeInsets(top: top, left: 0, bottom: bottom, right: 0) - //tableView.addSubview(refreshControl!) + if let refresh = refreshControl, !UIDevice.current.isMac() { + tableView.addSubview(refresh) + } self.navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: UIBarButtonItem.Style.plain, target: nil, action: nil) diff --git a/Slide for Reddit/ModalMediaViewController.swift b/Slide for Reddit/ModalMediaViewController.swift index fa9bf47f0..bd5bb6dbe 100644 --- a/Slide for Reddit/ModalMediaViewController.swift +++ b/Slide for Reddit/ModalMediaViewController.swift @@ -286,7 +286,9 @@ class ModalMediaViewController: UIViewController { } panGestureRecognizer!.cancelsTouchesInView = false if UIDevice.current.isMac() { - panGestureRecognizer!.allowedScrollTypesMask = .discrete + if #available(iOS 13.4, *) { + panGestureRecognizer!.allowedScrollTypesMask = .discrete + } panGestureRecognizer!.maximumNumberOfTouches = 0 } diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index d7deac2d2..076fb5cce 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -284,7 +284,11 @@ class NavigationHomeViewController: UIViewController { tableView.register(SubredditCellView.classForCoder(), forCellReuseIdentifier: "search") tableView.register(SubredditCellView.classForCoder(), forCellReuseIdentifier: "profile") - view.addSubviews(headerView, tableView) + if UIDevice.current.isMac() { + view.addSubviews(headerView, tableView) + } else { + view.addSubview(tableView) + } setColors(MainViewController.current) } @@ -310,9 +314,14 @@ class NavigationHomeViewController: UIViewController { searchBar.heightAnchor /==/ 50 searchBar.bottomAnchor /==/ headerView.bottomAnchor - headerView.topAnchor /==/ view.safeTopAnchor - headerView.horizontalAnchors /==/ view.horizontalAnchors - tableView.topAnchor /==/ headerView.bottomAnchor + if UIDevice.current.isMac() { + headerView.topAnchor /==/ view.safeTopAnchor + headerView.horizontalAnchors /==/ view.horizontalAnchors + tableView.topAnchor /==/ headerView.bottomAnchor + } else { + tableView.topAnchor /==/ view.safeTopAnchor + } + tableView.contentInset = UIEdgeInsets(top: 8, left: 0, bottom: 0, right: 0) tableView.horizontalAnchors /==/ view.horizontalAnchors tableView.bottomAnchor /==/ view.bottomAnchor @@ -403,7 +412,7 @@ extension NavigationHomeViewController: UITableViewDelegate, UITableViewDataSour func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { if section == 0 { - return 0 + return UIDevice.current.isMac() ? 0 : 50 + 4 + (accountHeader?.estimateHeight() ?? 0) } if isSearching && section == 0 { return 0 @@ -490,7 +499,11 @@ extension NavigationHomeViewController: UITableViewDelegate, UITableViewDataSour toReturn.backgroundColor = UIColor.foregroundColor if section == 0 { - return UIView() + if UIDevice.current.isMac() { + return UIView() + } else { + return headerView + } } if isSearching { switch section { diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index c9cebbfd5..b2eb1e343 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -995,7 +995,9 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele refreshControl.attributedTitle = NSAttributedString(string: "") refreshControl.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - // tableView.addSubview(refreshControl) // not required when using UITableViewController + if let refresh = refreshControl, !UIDevice.current.isMac() { + tableView.addSubview(refresh) + } tableView.alwaysBounceVertical = true self.automaticallyAdjustsScrollViewInsets = false diff --git a/Slide for Reddit/TabsContentPagingViewController.swift b/Slide for Reddit/TabsContentPagingViewController.swift index 6d12e9fb8..59e58a68b 100644 --- a/Slide for Reddit/TabsContentPagingViewController.swift +++ b/Slide for Reddit/TabsContentPagingViewController.swift @@ -123,7 +123,7 @@ class TabsContentPagingViewController: ColorMuxPagingViewController, UIPageViewC } let topAnchorOffset = (self.navigationController?.navigationBar.frame.size.height ?? 64) + (isModal13 ? 0 : UIApplication.shared.statusBarFrame.height) if #available(iOS 13, *) { - tabBar.topAnchor /==/ self.view.topAnchor + topAnchorOffset + tabBar.topAnchor /==/ self.view.safeTopAnchor } else { tabBar.topAnchor /==/ self.view.topAnchor } diff --git a/Slide for Reddit/ThreadViewController.swift b/Slide for Reddit/ThreadViewController.swift index 1b4f0ecd5..9eb44e1b5 100644 --- a/Slide for Reddit/ThreadViewController.swift +++ b/Slide for Reddit/ThreadViewController.swift @@ -155,7 +155,9 @@ class ThreadViewControler: MediaViewController, UICollectionViewDelegate, Wrappi refreshControl?.attributedTitle = NSAttributedString(string: "") refreshControl?.addTarget(self, action: #selector(self.drefresh(_:)), for: UIControl.Event.valueChanged) - tableView.addSubview(refreshControl!) + if let refresh = refreshControl, !UIDevice.current.isMac() { + tableView.addSubview(refresh) + } refreshControl!.centerAnchors /==/ tableView.centerAnchors } diff --git a/Slide for Reddit/VCPresenter.swift b/Slide for Reddit/VCPresenter.swift index a3b9e2cf2..4268780a7 100644 --- a/Slide for Reddit/VCPresenter.swift +++ b/Slide for Reddit/VCPresenter.swift @@ -67,42 +67,43 @@ public class VCPresenter { return } else if ((!SettingValues.disablePopupIpad) && UIDevice.current.respectIpadLayout() && shouldPopup) || ((parentNavigationController != nil && (override13 || parentNavigationController!.modalPresentationStyle != .pageSheet)) && shouldPopup && override13) || parentNavigationController == nil { - if UIDevice.current.isMac() && viewController is SettingsViewController { - UIApplication.shared.requestSceneSessionActivation(nil, - userActivity: NSUserActivity(activityType: "settings"), - options: nil, - errorHandler: nil) - - } else if UIDevice.current.isMac() && viewController is SingleSubredditViewController { - let activity = NSUserActivity(activityType: "subreddit") - activity.userInfo = ["subreddit": (viewController as! SingleSubredditViewController).sub] - UIApplication.shared.requestSceneSessionActivation(nil, - userActivity: activity, - options: nil, - errorHandler: nil) - - } else if UIDevice.current.isMac() && viewController is InboxViewController { - let activity = NSUserActivity(activityType: "inbox") - UIApplication.shared.requestSceneSessionActivation(nil, - userActivity: activity, - options: nil, - errorHandler: nil) - - } else if UIDevice.current.isMac() && viewController is ProfileViewController { - let activity = NSUserActivity(activityType: "profile") - activity.userInfo = ["profile": (viewController as! ProfileViewController).name] - UIApplication.shared.requestSceneSessionActivation(nil, - userActivity: activity, - options: nil, - errorHandler: nil) - } else if UIDevice.current.isMac() && viewController is WebsiteViewController { - let activity = NSUserActivity(activityType: "website") - activity.userInfo = ["url": (viewController as! WebsiteViewController).url] - UIApplication.shared.requestSceneSessionActivation(nil, - userActivity: activity, - options: nil, - errorHandler: nil) - + if UIDevice.current.isMac(), #available(iOS 13, *) { + if viewController is SettingsViewController { + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: NSUserActivity(activityType: "settings"), + options: nil, + errorHandler: nil) + + } else if viewController is SingleSubredditViewController { + let activity = NSUserActivity(activityType: "subreddit") + activity.userInfo = ["subreddit": (viewController as! SingleSubredditViewController).sub] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + + } else if viewController is InboxViewController { + let activity = NSUserActivity(activityType: "inbox") + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + + } else if viewController is ProfileViewController { + let activity = NSUserActivity(activityType: "profile") + activity.userInfo = ["profile": (viewController as! ProfileViewController).name] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + } else if viewController is WebsiteViewController { + let activity = NSUserActivity(activityType: "website") + activity.userInfo = ["url": (viewController as! WebsiteViewController).url] + UIApplication.shared.requestSceneSessionActivation(nil, + userActivity: activity, + options: nil, + errorHandler: nil) + } } else { if viewController is SingleSubredditViewController { (viewController as! SingleSubredditViewController).isModal = true From b0e78a915af722898e9f388d26ac560b73bdf670 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 13:03:37 -0500 Subject: [PATCH 25/46] Theme switching improvements, Fastlane updates --- Slide for Reddit.xcodeproj/project.pbxproj | 19 +- Slide for Reddit/AppDelegate.swift | 4 + .../AppIcon.appiconset/Contents.json | 206 +++++++++++------- Slide for Reddit/ColorUtil.swift | 5 +- Slide for Reddit/CommentViewController.swift | 40 ++-- Slide for Reddit/Fonts/LinkParser.swift | 4 +- .../ImageMediaViewController.swift | 6 + .../ModalMediaViewController.swift | 6 - .../NavigationHomeViewController.swift | 22 +- Slide for Reddit/SettingValues.swift | 1 + Slide for Reddit/SettingsTheme.swift | 51 ++--- .../SingleSubredditViewController.swift | 17 +- fastlane/Fastfile | 2 +- fastlane/Matchfile | 1 + fastlane/report.xml | 18 +- 15 files changed, 225 insertions(+), 177 deletions(-) diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index 30d44b86a..3978313fb 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -1399,6 +1399,7 @@ BE0C4F7D21BCBE82006C54FF /* ic_tronblue@3x.png */, BE0C4F7821BCBE82006C54FF /* ic_tronteal@2x.png */, BE0C4F7221BCBE81006C54FF /* ic_tronteal@3x.png */, + BEC912AA258B31FF00E65F34 /* ContentViews */, BE0C4F7421BCBE81006C54FF /* ic_yellow@2x.png */, BE0C4F7E21BCBE82006C54FF /* ic_yellow@3x.png */, ); @@ -1534,7 +1535,6 @@ BE3E5C0F1E16BA1300749C0C /* Album */, BE4AB49C21BC4DAE001092C4 /* App Icons */, BE84B1B0257C5DAF00A90C5D /* CoreData */, - BEC912AA258B31FF00E65F34 /* ContentViews */, BE780B671E35276600DAA1EB /* ContentUtilities */, BE1DA3991E26D52500EC0A04 /* ContentViewControllers */, 0965260320E1688400EA53BE /* Extensions */, @@ -1731,6 +1731,7 @@ BEAE6A4A2564CCC100EF0806 /* ModLogCellView.swift */, ); name = ContentViews; + path = ..; sourceTree = ""; }; BED90FE4250BF71600090DF5 /* Slide Widgets */ = { @@ -2809,7 +2810,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -2844,7 +2844,6 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -2881,7 +2880,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -2923,7 +2921,6 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -2958,7 +2955,6 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -2992,7 +2988,6 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -3028,7 +3023,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -3063,7 +3057,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -3220,7 +3213,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_WARN_UNUSED_PARAMETER = YES; @@ -3242,6 +3234,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SUPPORTS_MACCATALYST = YES; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -3260,10 +3253,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "Slide for Reddit/Slide for Reddit.entitlements"; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_OPTIMIZATION_LEVEL = fast; @@ -3286,6 +3278,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide"; SUPPORTS_MACCATALYST = YES; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; @@ -3445,7 +3438,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; @@ -3482,7 +3474,6 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 225; CURRENT_PROJECT_VERSION = 220; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 00623f579..c3b594fcc 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -1265,6 +1265,10 @@ extension AppDelegate: UIWindowSceneDelegate { if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) self.window = window + + if UIDevice.current.isMac() && (connectionOptions.userActivities.first?.activityType != "settings") { + windowScene.sizeRestrictions?.minimumSize = CGSize(width: UIScreen.main.bounds.width * 0.75, height: UIScreen.main.bounds.height * 0.75) + } didFinishLaunching(window: window) /* TODO This launchedURL = launchOptions?[UIApplication.LaunchOptionsKey.url] as? URL diff --git a/Slide for Reddit/Assets.xcassets/AppIcon.appiconset/Contents.json b/Slide for Reddit/Assets.xcassets/AppIcon.appiconset/Contents.json index 93a583906..f0400e87c 100644 --- a/Slide for Reddit/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Slide for Reddit/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -1,158 +1,208 @@ { "images" : [ { - "size" : "20x20", - "idiom" : "iphone", "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" }, { - "size" : "20x20", - "idiom" : "iphone", "filename" : "Icon-App-20x20@3x.png", - "scale" : "3x" + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" }, { - "size" : "29x29", - "idiom" : "iphone", "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" + "idiom" : "iphone", + "scale" : "1x", + "size" : "29x29" }, { - "size" : "29x29", - "idiom" : "iphone", "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" }, { - "size" : "29x29", - "idiom" : "iphone", "filename" : "Icon-App-29x29@3x.png", - "scale" : "3x" + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" }, { - "size" : "40x40", - "idiom" : "iphone", "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" }, { - "size" : "40x40", - "idiom" : "iphone", "filename" : "Icon-App-40x40@3x.png", - "scale" : "3x" + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" }, { - "size" : "57x57", - "idiom" : "iphone", "filename" : "Icon-App-57x57@1x.png", - "scale" : "1x" + "idiom" : "iphone", + "scale" : "1x", + "size" : "57x57" }, { - "size" : "57x57", - "idiom" : "iphone", "filename" : "Icon-App-57x57@2x.png", - "scale" : "2x" + "idiom" : "iphone", + "scale" : "2x", + "size" : "57x57" }, { - "size" : "60x60", - "idiom" : "iphone", "filename" : "Icon-App-60x60@2x.png", - "scale" : "2x" + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" }, { - "size" : "60x60", - "idiom" : "iphone", "filename" : "Icon-App-60x60@3x.png", - "scale" : "3x" + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" }, { - "size" : "20x20", - "idiom" : "ipad", "filename" : "Icon-App-20x20@1x.png", - "scale" : "1x" + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" }, { - "size" : "20x20", - "idiom" : "ipad", "filename" : "Icon-App-20x20@2x.png", - "scale" : "2x" + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" }, { - "size" : "29x29", - "idiom" : "ipad", "filename" : "Icon-App-29x29@1x.png", - "scale" : "1x" + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" }, { - "size" : "29x29", - "idiom" : "ipad", "filename" : "Icon-App-29x29@2x.png", - "scale" : "2x" + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" }, { - "size" : "40x40", - "idiom" : "ipad", "filename" : "Icon-App-40x40@1x.png", - "scale" : "1x" + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" }, { - "size" : "40x40", - "idiom" : "ipad", "filename" : "Icon-App-40x40@2x.png", - "scale" : "2x" + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" }, { - "size" : "50x50", - "idiom" : "ipad", "filename" : "Icon-Small-50x50@1x.png", - "scale" : "1x" + "idiom" : "ipad", + "scale" : "1x", + "size" : "50x50" }, { - "size" : "50x50", - "idiom" : "ipad", "filename" : "Icon-Small-50x50@2x.png", - "scale" : "2x" + "idiom" : "ipad", + "scale" : "2x", + "size" : "50x50" }, { - "size" : "72x72", - "idiom" : "ipad", "filename" : "Icon-App-72x72@1x.png", - "scale" : "1x" + "idiom" : "ipad", + "scale" : "1x", + "size" : "72x72" }, { - "size" : "72x72", - "idiom" : "ipad", "filename" : "Icon-App-72x72@2x.png", - "scale" : "2x" + "idiom" : "ipad", + "scale" : "2x", + "size" : "72x72" }, { - "size" : "76x76", - "idiom" : "ipad", "filename" : "Icon-App-76x76@1x.png", - "scale" : "1x" + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" }, { - "size" : "76x76", - "idiom" : "ipad", "filename" : "Icon-App-76x76@2x.png", - "scale" : "2x" + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" }, { - "size" : "83.5x83.5", - "idiom" : "ipad", "filename" : "Icon-App-83.5x83.5@2x.png", - "scale" : "2x" + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" }, { - "size" : "1024x1024", - "idiom" : "ios-marketing", "filename" : "slide_ios_1024.png", - "scale" : "1x" + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Slide for Reddit/ColorUtil.swift b/Slide for Reddit/ColorUtil.swift index 6e0b66ede..d6a05fcc7 100644 --- a/Slide for Reddit/ColorUtil.swift +++ b/Slide for Reddit/ColorUtil.swift @@ -105,9 +105,8 @@ public class ColorUtil { if accent != nil { baseAccent = accent! } - if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 - NotificationCenter.default.post(name: .onThemeChanged, object: nil) - } + + NotificationCenter.default.post(name: .onThemeChanged, object: nil) return true } diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index 03637c146..16e3a96de 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -2173,16 +2173,12 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi more.accessibilityLabel = "Post options" more.addTarget(self, action: #selector(self.showMenu(_:)), for: UIControl.Event.touchUpInside) moreB = UIBarButtonItem(customView: more) - - if parent != nil && parent is PagingCommentViewController { - parent?.navigationItem.leftBarButtonItems = items - parent?.navigationController?.toolbar.barTintColor = UIColor.backgroundColor - parent?.navigationController?.toolbar.tintColor = UIColor.fontColor - } else { - navigationItem.leftBarButtonItems = items - navigationController?.toolbar.barTintColor = UIColor.backgroundColor - navigationController?.toolbar.tintColor = UIColor.fontColor - } + + items.append(moreB) + + navigationItem.leftBarButtonItems = items + navigationController?.toolbar.barTintColor = UIColor.backgroundColor + navigationController?.toolbar.tintColor = UIColor.fontColor } } else { navigationController?.setToolbarHidden(false, animated: false) @@ -2710,6 +2706,16 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi } func hideUI(inHeader: Bool) { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak self] in + guard let strongSelf = self else { return } + strongSelf.createJumpButton() + strongSelf.isHiding = false + } + + if UIDevice.current.isMac() { + return + } + isHiding = true // self.tableView.endEditing(true) if inHeadView.superview == nil { @@ -2724,13 +2730,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi } } self.isToolbarHidden = true - - DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) { [weak self] in - guard let strongSelf = self else { return } - strongSelf.createJumpButton() - strongSelf.isHiding = false - } - + if SettingValues.hideStatusBar { self.setNeedsStatusBarAppearanceUpdate() } @@ -2738,7 +2738,11 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi func showUI() { (navigationController)?.setNavigationBarHidden(false, animated: true) - (navigationController)?.setToolbarHidden(false, animated: true) + + if UIDevice.current.isMac() { + return + } + if live { progressDot.layer.removeAllAnimations() let pulseAnimation = CABasicAnimation(keyPath: "transform.scale") diff --git a/Slide for Reddit/Fonts/LinkParser.swift b/Slide for Reddit/Fonts/LinkParser.swift index be02dfb71..bf0309c47 100644 --- a/Slide for Reddit/Fonts/LinkParser.swift +++ b/Slide for Reddit/Fonts/LinkParser.swift @@ -122,7 +122,9 @@ class LinkParser { } if isItalic { - let descriptor = newFont.fontDescriptor.withSymbolicTraits(UIFontDescriptor.SymbolicTraits.traitItalic) ?? newFont.fontDescriptor + var symbolicTraits = newFont.fontDescriptor.symbolicTraits + symbolicTraits.insert(UIFontDescriptor.SymbolicTraits.traitItalic) + let descriptor = newFont.fontDescriptor.withSymbolicTraits(symbolicTraits) ?? newFont.fontDescriptor newFont = UIFont(descriptor: descriptor, size: f.pointSize) } diff --git a/Slide for Reddit/ImageMediaViewController.swift b/Slide for Reddit/ImageMediaViewController.swift index fd5e5f12d..526b45f5f 100644 --- a/Slide for Reddit/ImageMediaViewController.swift +++ b/Slide for Reddit/ImageMediaViewController.swift @@ -162,6 +162,12 @@ class ImageMediaViewController: EmbeddableMediaViewController { } @objc func fullscreen(_ sender: AnyObject) { + if SettingValues.tapExitMedia { + if let parent = parent as? ModalMediaViewController { + parent.exit() + return + } + } if let strongParent = parent as? ModalMediaViewController, strongParent.fullscreen { strongParent.unFullscreen(self) } else if let strongParent = parent as? ModalMediaViewController { diff --git a/Slide for Reddit/ModalMediaViewController.swift b/Slide for Reddit/ModalMediaViewController.swift index bd5bb6dbe..cdeede08d 100644 --- a/Slide for Reddit/ModalMediaViewController.swift +++ b/Slide for Reddit/ModalMediaViewController.swift @@ -285,12 +285,6 @@ class ModalMediaViewController: UIViewController { panGestureRecognizer!.allowedScrollTypesMask = .continuous } panGestureRecognizer!.cancelsTouchesInView = false - if UIDevice.current.isMac() { - if #available(iOS 13.4, *) { - panGestureRecognizer!.allowedScrollTypesMask = .discrete - } - panGestureRecognizer!.maximumNumberOfTouches = 0 - } view.addGestureRecognizer(panGestureRecognizer!) diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 076fb5cce..97a5aad83 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -75,9 +75,29 @@ class NavigationHomeViewController: UIViewController { $0.searchBarStyle = UISearchBar.Style.minimal $0.placeholder = " Search subs, posts, or profiles" $0.isTranslucent = true - $0.barStyle = .blackTranslucent + $0.barStyle = .black + if #available(iOS 13.0, *) { + $0.searchTextField.tintColor = UIColor.fontColor + $0.searchTextField.textColor = UIColor.fontColor + } else { + // Fallback on earlier versions + } $0.accessibilityLabel = "Search" $0.accessibilityHint = "Search subreddits, posts, or profiles" + + if UIDevice.current.isMac() { + if #available(iOS 13.0, *) { + $0.searchTextField.attributedPlaceholder = NSAttributedString(string: " Search subs, posts, or profiles", attributes: [.foregroundColor: UIColor.fontColor]) + $0.searchTextField.leftView?.tintColor = UIColor.fontColor + $0.searchTextField.rightView?.tintColor = UIColor.fontColor + $0.searchTextField.backgroundColor = UIColor.backgroundColor + if let clearButton = $0.searchTextField.value(forKey: "_clearButton") as? UIButton { + let templateImage = clearButton.imageView?.image?.withRenderingMode(.alwaysTemplate) + clearButton.setImage(templateImage, for: .normal) + clearButton.tintColor = UIColor.fontColor + } + } + } } var accountHeader: CurrentAccountHeaderView? diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index d8590c972..72e6357c2 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -293,6 +293,7 @@ class SettingValues { public static var coloredFlairs = false public static var showFlairs = true public static var desktopMode = false + public static var tapExitMedia = true public static var commentLimit = 95 public static var submissionLimit = 13 diff --git a/Slide for Reddit/SettingsTheme.swift b/Slide for Reddit/SettingsTheme.swift index 09bef12b7..ec1214eda 100644 --- a/Slide for Reddit/SettingsTheme.swift +++ b/Slide for Reddit/SettingsTheme.swift @@ -408,10 +408,6 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { _ = ColorUtil.doInit() SingleSubredditViewController.cellVersion += 1 - if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 - NotificationCenter.default.post(name: .onThemeChanged, object: nil) - } - self.tochange!.doCells() self.tochange!.tableView.reloadData() } @@ -515,11 +511,6 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { UserDefaults.standard.set(theme.title, forKey: SettingValues.pref_nightTheme) UserDefaults.standard.synchronize() _ = ColorUtil.doInit() - SingleSubredditViewController.cellVersion += 1 - - if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 - NotificationCenter.default.post(name: .onThemeChanged, object: nil) - } self.setupViews() self.tableView.reloadData() @@ -561,25 +552,23 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { let cv = themeView.contentView let alert = DragDownAlertMenu(title: theme.title, subtitle: "", icon: nil, extraView: cv, themeColor: nil, full: false) - alert.addAction(title: "Apply Theme", icon: UIImage(sfString: .checkmark, overrideString: "add")?.navIcon()) { - UserDefaults.standard.set(theme.title, forKey: "theme") - UserDefaults.standard.synchronize() - - _ = ColorUtil.doInit() - SingleSubredditViewController.cellVersion += 1 - self.tableView.reloadData() + if ColorUtil.getCurrentTheme() != theme { + alert.addAction(title: "Apply Theme", icon: UIImage(sfString: .checkmark, overrideString: "add")?.navIcon()) { + UserDefaults.standard.set(theme.title, forKey: "theme") + UserDefaults.standard.synchronize() + + _ = ColorUtil.doInit() + SingleSubredditViewController.cellVersion += 1 + self.tableView.reloadData() - if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 - NotificationCenter.default.post(name: .onThemeChanged, object: nil) + self.setupViews() + self.tochange!.doCells() + self.tochange!.tableView.reloadData() + self.tableView.reloadData() + self.setupBaseBarColors() } - - self.setupViews() - self.tochange!.doCells() - self.tochange!.tableView.reloadData() - self.tableView.reloadData() - self.setupBaseBarColors() } - + alert.extraViewHeight = 60 alert.addAction(title: "Edit Theme", icon: UIImage(sfString: .pencil, overrideString: "edit")?.navIcon()) { @@ -628,10 +617,6 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 - NotificationCenter.default.post(name: .onThemeChanged, object: nil) - } - self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -659,10 +644,6 @@ class SettingsTheme: BubbleSettingTableViewController, ColorPickerViewDelegate { self.setupViews() SingleSubredditViewController.cellVersion += 1 - if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 - NotificationCenter.default.post(name: .onThemeChanged, object: nil) - } - self.tableView.reloadData() self.tochange!.doCells() self.tochange!.tableView.reloadData() @@ -808,10 +789,6 @@ extension SettingsTheme: SettingsCustomThemeDelegate { SingleSubredditViewController.cellVersion += 1 self.tableView.reloadData() - if #available(iOS 13.0, *) { } else { // Re-draw views on iOS 11 and 12 - NotificationCenter.default.post(name: .onThemeChanged, object: nil) - } - self.setupViews() self.tochange!.doCells() self.tochange!.tableView.reloadData() diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index b2eb1e343..c599dfd2b 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -493,6 +493,9 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) + if tableView == nil { + return + } inHeadView?.removeFromSuperview() fab?.removeFromSuperview() @@ -973,10 +976,18 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele let flexButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil) - if parent is SplitMainViewController { - parent!.toolbarItems = [searchB, flexButton, moreB] + if UIDevice.current.isMac() { + if parent is SplitMainViewController { + parent!.navigationItem.leftBarButtonItems = [searchB, moreB] + } else { + navigationItem.leftBarButtonItems = [searchB, moreB] + } } else { - toolbarItems = [searchB, flexButton, moreB] + if parent is SplitMainViewController { + parent!.toolbarItems = [searchB, flexButton, moreB] + } else { + toolbarItems = [searchB, flexButton, moreB] + } } } diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 276a7c583..ee92d3711 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -11,7 +11,7 @@ # # Uncomment the line if you want fastlane to automatically update itself -# update_fastlane +update_fastlane default_platform(:ios) diff --git a/fastlane/Matchfile b/fastlane/Matchfile index f05510f02..7fd0b6d0d 100644 --- a/fastlane/Matchfile +++ b/fastlane/Matchfile @@ -4,6 +4,7 @@ storage_mode("git") type("development") # The default type, can be: appstore, adhoc, enterprise or development +platform( "ios", "macos") # app_identifier(["tools.fastlane.app", "tools.fastlane.app2"]) # username("user@fastlane.tools") # Your Apple Developer Portal username diff --git a/fastlane/report.xml b/fastlane/report.xml index f00d9cc7a..a8e789231 100644 --- a/fastlane/report.xml +++ b/fastlane/report.xml @@ -5,29 +5,17 @@ - + - + - - - - - - - - - - - - - + From a66ceed398b4fe5ee3dc7b71926de3f1ff4feb0e Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 13:50:13 -0500 Subject: [PATCH 26/46] Improvements to video muting, Added option to disable tapping on usernames and subreddits Fixes #1174 --- Slide for Reddit/CachedTitle.swift | 17 ++++++++++--- Slide for Reddit/SettingValues.swift | 4 +++ Slide for Reddit/SettingsAudio.swift | 6 ++--- Slide for Reddit/SettingsLayout.swift | 15 +++++++++-- .../VideoMediaViewController.swift | 25 +++++++++++-------- Slide for Reddit/VideoSource.swift | 4 +++ 6 files changed, 52 insertions(+), 19 deletions(-) diff --git a/Slide for Reddit/CachedTitle.swift b/Slide for Reddit/CachedTitle.swift index 493129a6e..0292cc3ab 100644 --- a/Slide for Reddit/CachedTitle.swift +++ b/Slide for Reddit/CachedTitle.swift @@ -204,7 +204,9 @@ class CachedTitle { authorAttributes[.foregroundColor] = UIColor.white } - authorAttributes[.textHighlight] = TextHighlight(["url": URL(string: "/u/\(submission.author)")]) + if SettingValues.tapProfilesAndSubs || full, let authorUrl = URL(string: "https://www.reddit.com/u/\(submission.author)") { + authorAttributes[.urlAction] = authorUrl + } let authorString = NSMutableAttributedString(string: "\u{00A0}\(AccountController.formatUsername(input: submission.author, small: false) + (submission.isCakeday ? " 🎂" : ""))\u{00A0}", attributes: authorAttributes) endString.append(authorString) @@ -502,7 +504,9 @@ class CachedTitle { attrs[.baselineOffset] = (((24 - fontSize) / 2) - (titleFont.descender / 2)) } let tapString = NSMutableAttributedString(string: " r/\(link.subreddit)", attributes: attrs) - tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) + if SettingValues.tapProfilesAndSubs || full { + tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) + } iconString.append(tapString) } else { @@ -510,11 +514,16 @@ class CachedTitle { let preString = NSMutableAttributedString(string: "⬤ ", attributes: [NSAttributedString.Key.font: titleFont, NSAttributedString.Key.foregroundColor: color]) iconString = preString let tapString = NSMutableAttributedString(string: "r/\(link.subreddit)", attributes: attrs) - tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) + if SettingValues.tapProfilesAndSubs || full { + tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) + } + iconString.append(tapString) } else { let tapString = NSMutableAttributedString(string: "r/\(link.subreddit)", attributes: attrs) - tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) + if SettingValues.tapProfilesAndSubs || full { + tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) + } iconString = tapString } } diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 72e6357c2..eeae1a569 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -148,6 +148,7 @@ class SettingValues { public static let pref_coloredFlairs = "COLORED_FLAIRS" public static let pref_showFlairs = "SHOW_FLAIRS" public static let pref_desktopMode = "DESKTOP_MODE" + public static let pref_tapProfilesAndSubs = "TAP_PROFILES_AND_SUBS" public static let BROWSER_INTERNAL = "internal" public static let BROWSER_SAFARI_INTERNAL_READABILITY = "readability" @@ -294,6 +295,7 @@ class SettingValues { public static var showFlairs = true public static var desktopMode = false public static var tapExitMedia = true + public static var tapProfilesAndSubs = false public static var commentLimit = 95 public static var submissionLimit = 13 @@ -597,6 +599,8 @@ class SettingValues { SettingValues.imageFlairs = settings.object(forKey: SettingValues.pref_imageFlairs) == nil ? true : settings.bool(forKey: SettingValues.pref_imageFlairs) SettingValues.coloredFlairs = settings.object(forKey: SettingValues.pref_coloredFlairs) == nil ? true : settings.bool(forKey: SettingValues.pref_coloredFlairs) SettingValues.showFlairs = settings.object(forKey: SettingValues.pref_showFlairs) == nil ? true : settings.bool(forKey: SettingValues.pref_showFlairs) + + SettingValues.tapProfilesAndSubs = settings.object(forKey: SettingValues.pref_tapProfilesAndSubs) == nil ? true : settings.bool(forKey: SettingValues.pref_tapProfilesAndSubs) SettingValues.subredditIcons = settings.object(forKey: SettingValues.pref_subredditIcons) == nil ? true : settings.bool(forKey: SettingValues.pref_subredditIcons) SettingValues.disablePopupIpad = settings.bool(forKey: SettingValues.pref_disablePopupIpad) diff --git a/Slide for Reddit/SettingsAudio.swift b/Slide for Reddit/SettingsAudio.swift index aa936e523..7da49b806 100644 --- a/Slide for Reddit/SettingsAudio.swift +++ b/Slide for Reddit/SettingsAudio.swift @@ -64,7 +64,7 @@ class SettingsAudio: BubbleSettingTableViewController { $0.isOn = SettingValues.muteVideosInModal } muteModalVideoSwitch.addTarget(self, action: #selector(SettingsAudio.switchIsChanged(_:)), for: UIControl.Event.valueChanged) - muteModalVideoCell.textLabel?.text = "Always start videos muted" + muteModalVideoCell.textLabel?.text = "Mute full-screen videos by default" muteModalVideoCell.accessoryView = muteModalVideoSwitch muteModalVideoCell.textLabel?.numberOfLines = 0 muteModalVideoCell.selectionStyle = UITableViewCell.SelectionStyle.none @@ -74,7 +74,7 @@ class SettingsAudio: BubbleSettingTableViewController { $0.isOn = SettingValues.modalVideosRespectHardwareMuteSwitch } modalVideoFollowsMuteSwitchSwitch.addTarget(self, action: #selector(SettingsAudio.switchIsChanged(_:)), for: UIControl.Event.valueChanged) - modalVideoFollowsMuteSwitchCell.textLabel?.text = "Start videos muted if your device is muted" + modalVideoFollowsMuteSwitchCell.textLabel?.text = "Mute full-screen videos when iOS is muted" modalVideoFollowsMuteSwitchCell.accessoryView = modalVideoFollowsMuteSwitchSwitch modalVideoFollowsMuteSwitchCell.textLabel?.numberOfLines = 0 modalVideoFollowsMuteSwitchCell.selectionStyle = UITableViewCell.SelectionStyle.none @@ -84,7 +84,7 @@ class SettingsAudio: BubbleSettingTableViewController { $0.isOn = SettingValues.muteYouTube } muteYTSwitch.addTarget(self, action: #selector(SettingsAudio.switchIsChanged(_:)), for: UIControl.Event.valueChanged) - muteYTCell.textLabel?.text = "Always start YouTube videos muted" + muteYTCell.textLabel?.text = "Mute YouTube videos by default" muteYTCell.accessoryView = muteYTSwitch muteYTCell.textLabel?.numberOfLines = 0 muteYTCell.selectionStyle = UITableViewCell.SelectionStyle.none diff --git a/Slide for Reddit/SettingsLayout.swift b/Slide for Reddit/SettingsLayout.swift index e6e1be9e9..2344c9061 100644 --- a/Slide for Reddit/SettingsLayout.swift +++ b/Slide for Reddit/SettingsLayout.swift @@ -112,6 +112,11 @@ class SettingsLayout: BubbleSettingTableViewController { var more = UISwitch().then { $0.onTintColor = ColorUtil.baseAccent } + + var tapCell: UITableViewCell = InsetCell() + var tap = UISwitch().then { + $0.onTintColor = ColorUtil.baseAccent + } var shareCell: UITableViewCell = InsetCell() var share = UISwitch().then { @@ -165,6 +170,10 @@ class SettingsLayout: BubbleSettingTableViewController { } else if changed == more { SettingValues.menuButton = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_moreButton) + } else if changed == tap { + SettingValues.tapProfilesAndSubs = changed.isOn + UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_tapProfilesAndSubs) + CachedTitle.titles.removeAll() } else if changed == infoBelowTitle { SettingValues.infoBelowTitle = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_infoBelowTitle) @@ -582,7 +591,8 @@ class SettingsLayout: BubbleSettingTableViewController { createCell(imageFlairsCell, imageFlairs, isOn: SettingValues.imageFlairs, text: "Show flair images") createCell(typeTitleCell, typeTitle, isOn: SettingValues.typeInTitle, text: "Content type in title") - createCell(hideAwardCell, hideAward, isOn: SettingValues.hideAwards, text: "Hide Reddit awards line") + createCell(hideAwardCell, hideAward, isOn: SettingValues.hideAwards, text: "Hide Reddit awards") + createCell(tapCell, tap, isOn: SettingValues.tapProfilesAndSubs, text: "Enable tappable author name and subreddit") createCell(smalltagCell, smalltag, isOn: SettingValues.smallerTag, text: "Smaller content tag") createCell(largerThumbnailCell, largerThumbnail, isOn: SettingValues.largerThumbnail, text: "Larger thumbnail") createCell(commentTitleCell, commentTitle, isOn: SettingValues.commentsInTitle, text: "Comment count in title") @@ -725,6 +735,7 @@ class SettingsLayout: BubbleSettingTableViewController { case 5: return self.domainInfoCell case 6: return self.hideImageSelftextCell case 7: return self.hideAwardCell + case 8: return self.tapCell default: fatalError("Unknown row in section 2") } case 3: @@ -763,7 +774,7 @@ class SettingsLayout: BubbleSettingTableViewController { switch section { case 0: return 1 case 1: return 5 - case 2: return 8 + case 2: return 9 case 3: return 3 case 4: return 4 case 5: return 7 diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 8966ea01b..270bcbcc2 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -35,7 +35,6 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz } } - var volume: SubtleVolume? let volumeHeight: CGFloat = 3 var setOnce = false @@ -93,6 +92,8 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz var fastForwardImageView = UIImageView() var rewindImageView = UIImageView() + private var volumeObserver: NSKeyValueObservation! + override func viewDidLoad() { super.viewDidLoad() @@ -161,6 +162,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) + volumeObserver?.invalidate() VideoMediaViewController.soundLocked = false } @@ -742,7 +744,7 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz DispatchQueue.global(qos: .background).async { do { try AVAudioSession.sharedInstance().setCategory(.ambient, options: [.mixWithOthers]) - try AVAudioSession.sharedInstance().setActive(true) + try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation) } catch let error as NSError { print(error) } @@ -1069,9 +1071,6 @@ extension VideoMediaViewController { extension VideoMediaViewController { @objc func displayLinkDidUpdate(displaylink: CADisplayLink) { if isYoutubeView { - if youtubeMute && muteButton.isHidden && SettingValues.muteYouTube { - muteButton.isHidden = false - } if !sliderBeingUsed { youtubeView.getCurrentTime { [weak self] (currentTime: Float, error: Error?) in if error == nil { @@ -1083,10 +1082,8 @@ extension VideoMediaViewController { let hasAudioTracks = isYoutubeView || (videoView.player?.currentItem?.tracks.count ?? 1) > 1 - if hasAudioTracks { - if (videoView.player?.isMuted ?? youtubeMute) && muteButton.isHidden && (isYoutubeView ? SettingValues.muteYouTube : SettingValues.muteVideosInModal) { - muteButton.isHidden = false - } + if hasAudioTracks && muteButton.isHidden { + muteButton.isHidden = false } if !setOnce || lastTracks != hasAudioTracks { @@ -1115,6 +1112,14 @@ extension VideoMediaViewController { NSLog(error.localizedDescription) } } + + volumeObserver = AVAudioSession.sharedInstance().observe(\.outputVolume) { [weak self] (_, _) in + guard let self = self else { return } + + if self.videoView.player?.isMuted ?? false || self.youtubeMute { + self.unmute() + } + } } guard let player = videoView.player else { @@ -1155,7 +1160,7 @@ extension VideoMediaViewController: WKYTPlayerViewDelegate { } } - try AVAudioSession.sharedInstance().setActive(true) + try AVAudioSession.sharedInstance().setActive(true, options: .notifyOthersOnDeactivation) } catch let error as NSError { print(error) } diff --git a/Slide for Reddit/VideoSource.swift b/Slide for Reddit/VideoSource.swift index 58acb8494..37edcdae0 100644 --- a/Slide for Reddit/VideoSource.swift +++ b/Slide for Reddit/VideoSource.swift @@ -117,6 +117,7 @@ class StreamableVideoSource: VideoSource { let hash = url.substring(url.lastIndexOf("/")! + 1, length: url.length - (url.lastIndexOf("/")! + 1)) let finalURL = URL(string: "https://api.streamable.com/videos/" + hash) + if finalURL == nil { failure?() return nil @@ -158,6 +159,9 @@ class StreamableVideoSource: VideoSource { } } catch let error as NSError { print(error) + DispatchQueue.main.async { + failure?() + } } } } From 888e891fb110730841d520c52227079ba4bca782 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 14:00:58 -0500 Subject: [PATCH 27/46] Load more comments now respects sorting mode, Fixes #1177 --- Slide for Reddit/CommentViewController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index 16e3a96de..38fe5a519 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -2992,7 +2992,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi for c in children { strings.append(c) } - try session?.getMoreChildren(strings, name: link.getId(), sort: .top, id: more.getId(), completion: { (result) -> Void in + try session?.getMoreChildren(strings, name: link.getId(), sort: sort, id: more.getId(), completion: { (result) -> Void in switch result { case .failure(let error): print(error) @@ -3222,7 +3222,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi strings.append(c) } cell.animateMore() - try session?.getMoreChildren(strings, name: link.getId(), sort: .top, id: more.getId(), completion: { (result) -> Void in + try session?.getMoreChildren(strings, name: link.getId(), sort: sort, id: more.getId(), completion: { (result) -> Void in switch result { case .failure(let error): print(error) @@ -3232,7 +3232,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi var queue: [RedditObject] = [] for i in self.extendForMore(parentID: more.parentID, comments: list, current: startDepth) { - if let item = i.0 is Comment ? CommentObject.commentToCommentObject(comment: i.0 as! Comment, depth: i.1) : MoreObject.moreToMoreObject(more: i.0 as! More) as? RedditObject { + if let item = i.0 is Comment ? CommentObject.commentToCommentObject(comment: i.0 as! Comment, depth: i.1) : MoreObject.moreToMoreObject(more: i.0 as! More) { queue.append(item) self.cDepth[item.getId()] = i.1 self.updateStrings([i]) From b7f0f2abec4c7158e4ad98cc2b959670a437a3d9 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 14:01:22 -0500 Subject: [PATCH 28/46] Fixed build issue --- Slide for Reddit/CommentViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index 38fe5a519..e907f8ef1 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -3232,7 +3232,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi var queue: [RedditObject] = [] for i in self.extendForMore(parentID: more.parentID, comments: list, current: startDepth) { - if let item = i.0 is Comment ? CommentObject.commentToCommentObject(comment: i.0 as! Comment, depth: i.1) : MoreObject.moreToMoreObject(more: i.0 as! More) { + if let item = i.0 is Comment ? CommentObject.commentToCommentObject(comment: i.0 as! Comment, depth: i.1) : MoreObject.moreToMoreObject(more: i.0 as! More) as? RedditObject { queue.append(item) self.cDepth[item.getId()] = i.1 self.updateStrings([i]) From 721c17738c1f86a36790eb11648aa7d0ccdd56d3 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 14:10:33 -0500 Subject: [PATCH 29/46] Fixed theme share crashing --- Slide for Reddit/AppDelegate.swift | 5 +++-- Slide for Reddit/NavigationHomeViewController.swift | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Slide for Reddit/AppDelegate.swift b/Slide for Reddit/AppDelegate.swift index 4f9b8b501..cd35279e0 100644 --- a/Slide for Reddit/AppDelegate.swift +++ b/Slide for Reddit/AppDelegate.swift @@ -806,12 +806,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let themeName = url.absoluteString.removingPercentEncoding!.split("#")[1] let themeView = ThemeCellView().then { - $0.setTheme(string: url.absoluteString.removingPercentEncoding ?? url.absoluteString) + $0.setTheme(colors: url.absoluteString.removingPercentEncoding ?? url.absoluteString) } let cv = themeView.contentView let alert = DragDownAlertMenu(title: themeName, subtitle: "", icon: nil, extraView: cv, themeColor: nil, full: false) - + alert.extraViewHeight = 60 + alert.addAction(title: "Save Theme", icon: UIImage(sfString: .squareAndArrowDownFill, overrideString: "save-1")) { let colorString = url.absoluteString.removingPercentEncoding ?? url.absoluteString diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 97a5aad83..0d4db67a7 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -144,6 +144,9 @@ class NavigationHomeViewController: UIViewController { @objc func onThemeChanged() { doViews() + + self.navigationController?.setToolbarHidden(true, animated: false) + self.navigationController?.setToolbarHidden(false, animated: false) } @objc func onSubredditOrderChanged() { From 7816ec19f9edb3dbdfe409a80065acd0b48adc10 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 14:16:48 -0500 Subject: [PATCH 30/46] Slightly modified light theme --- Slide for Reddit/ColorUtil.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Slide for Reddit/ColorUtil.swift b/Slide for Reddit/ColorUtil.swift index d6a05fcc7..7b2c55ad9 100644 --- a/Slide for Reddit/ColorUtil.swift +++ b/Slide for Reddit/ColorUtil.swift @@ -300,16 +300,16 @@ public class ColorUtil { static func initializeThemes() { ColorUtil.themes.removeAll() - ColorUtil.themes.append(Theme(title: "light", displayName: "Light", foregroundColor: UIColor.white, backgroundColor: UIColor(hexString: "#e5e5e5"), navIconColor: UIColor(hexString: "#000000").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#000000").withAlphaComponent(0.87), isLight: true, isCustom: false)) + ColorUtil.themes.append(Theme(title: "light", displayName: "Light", foregroundColor: UIColor.white, backgroundColor: UIColor(hexString: "#f2f2f7"), navIconColor: UIColor(hexString: "#000000").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#000000").withAlphaComponent(0.87), isLight: true, isCustom: false)) ColorUtil.themes.append(Theme(title: "dark", displayName: "Dark Gray", foregroundColor: UIColor(hexString: "#303030"), backgroundColor: UIColor(hexString: "#212121"), navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) - ColorUtil.themes.append(Theme(title: "black", displayName: "AMOLED Black", foregroundColor: UIColor.black, backgroundColor: UIColor.black, navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) + ColorUtil.themes.append(Theme(title: "black", displayName: "Black", foregroundColor: UIColor.black, backgroundColor: UIColor.black, navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "blue", displayName: "Blue", foregroundColor: UIColor(hexString: "#37474F"), backgroundColor: UIColor(hexString: "#2F3D44"), navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "sepia", displayName: "Sepia", foregroundColor: UIColor(hexString: "#e2dfd7"), backgroundColor: UIColor(hexString: "#cac5ad"), navIconColor: UIColor(hexString: "#3e3d36").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#3e3d36").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "red", displayName: "Dark Red", foregroundColor: UIColor(hexString: "#402c2c"), backgroundColor: UIColor(hexString: "#312322"), navIconColor: UIColor(hexString: "#fff7ed").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#fff7ed").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "deep", displayName: "Deep Purple", foregroundColor: UIColor(hexString: "#1f1e26"), backgroundColor: UIColor(hexString: "#16161C"), navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "mint", displayName: "Mint Green", foregroundColor: UIColor(hexString: "#ffffff"), backgroundColor: UIColor(hexString: "#eef6e8"), navIconColor: UIColor(hexString: "#9fc675"), fontColor: UIColor(hexString: "#09360f").withAlphaComponent(0.87), isLight: true, isCustom: false)) ColorUtil.themes.append(Theme(title: "cream", displayName: "Crème", foregroundColor: UIColor(hexString: "#DCD8C2"), backgroundColor: UIColor(hexString: "#D1CDB9"), navIconColor: UIColor(hexString: "#444139").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#444139").withAlphaComponent(0.87), isLight: true, isCustom: false)) - ColorUtil.themes.append(Theme(title: "acontrast", displayName: "AMOLED Black with Contrast", foregroundColor: UIColor.black, backgroundColor: UIColor(hexString: "#111010"), navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) + ColorUtil.themes.append(Theme(title: "acontrast", displayName: "Black with Contrast", foregroundColor: UIColor.black, backgroundColor: UIColor(hexString: "#111010"), navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "pink", displayName: "Pink", foregroundColor: UIColor(hexString: "#FFFFFC"), backgroundColor: UIColor(hexString: "#fff5e8"), navIconColor: UIColor(hexString: "#ea8ab4"), fontColor: UIColor(hexString: "#262844").withAlphaComponent(0.87), isLight: true, isCustom: false)) ColorUtil.themes.append(Theme(title: "solarize", displayName: "Solarized", foregroundColor: UIColor(hexString: "#0C3641"), backgroundColor: UIColor(hexString: "#032B35"), navIconColor: UIColor(hexString: "#6E73C1"), fontColor: UIColor(hexString: "#839496"), isLight: false, isCustom: false)) From bf7ba0d6fa9908b3d72f6cf298610e82ab63ee2e Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 14:27:41 -0500 Subject: [PATCH 31/46] Added partial completion to AutoCache, Fixes #1168 --- Slide for Reddit/AutoCache.swift | 10 +++++++--- Slide for Reddit/ColorUtil.swift | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Slide for Reddit/AutoCache.swift b/Slide for Reddit/AutoCache.swift index e4c0d686e..22cb92e00 100644 --- a/Slide for Reddit/AutoCache.swift +++ b/Slide for Reddit/AutoCache.swift @@ -39,7 +39,8 @@ public class AutoCache: NSObject { AutoCache.current = self self.subs = subs if !self.subs.isEmpty { - doCache(subs: subs, progress: { sub, post, total, _ in + let startIndex = UserDefaults.standard.integer(forKey: "CACHE_LAST_INDEX") + doCache(subs: subs, startIndex: startIndex, progress: { sub, post, total, _ in DispatchQueue.main.async { NotificationCenter.default.post(name: .autoCacheProgress, object: nil, userInfo: ["subreddit": sub, "progress": Float(post) / Float(total)]) self.cacheProgress = Float(post) / Float(total) @@ -47,6 +48,7 @@ public class AutoCache: NSObject { }, completion: { (total, failed) in DispatchQueue.main.async { AutoCache.current = nil + UserDefaults.standard.setValue(0, forKey: "CACHE_LAST_INDEX") NotificationCenter.default.post(name: .autoCacheFinished, object: nil, userInfo: ["total": total, "failed": failed]) } }) @@ -62,8 +64,8 @@ public class AutoCache: NSObject { AutoCache.current = nil } - func doCache(subs: [String], progress: @escaping (String, Int, Int, Int) -> Void, completion: @escaping (Int, Int) -> Void) { - cacheSub(0, progress: progress, completion: completion, total: 0, failed: 0) + func doCache(subs: [String], startIndex: Int, progress: @escaping (String, Int, Int, Int) -> Void, completion: @escaping (Int, Int) -> Void) { + cacheSub(startIndex, progress: progress, completion: completion, total: 0, failed: 0) } func cacheComments(_ index: Int, commentIndex: Int, currentLinks: [SubmissionObject], done: Int, failed: Int, progress: @escaping (String, Int, Int, Int) -> Void, completion: @escaping (Int, Int) -> Void) { @@ -132,6 +134,8 @@ public class AutoCache: NSObject { self.cacheSub(index + 1, progress: progress, completion: completion, total: total, failed: failed) return } + + UserDefaults.standard.setValue(index, forKey: "CACHE_LAST_INDEX") NotificationCenter.default.post(name: .autoCacheStarted, object: nil, userInfo: ["subreddit": self.subs[index]]) self.currentSubreddit = self.subs[index] diff --git a/Slide for Reddit/ColorUtil.swift b/Slide for Reddit/ColorUtil.swift index 7b2c55ad9..c9840caad 100644 --- a/Slide for Reddit/ColorUtil.swift +++ b/Slide for Reddit/ColorUtil.swift @@ -300,7 +300,7 @@ public class ColorUtil { static func initializeThemes() { ColorUtil.themes.removeAll() - ColorUtil.themes.append(Theme(title: "light", displayName: "Light", foregroundColor: UIColor.white, backgroundColor: UIColor(hexString: "#f2f2f7"), navIconColor: UIColor(hexString: "#000000").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#000000").withAlphaComponent(0.87), isLight: true, isCustom: false)) + ColorUtil.themes.append(Theme(title: "light", displayName: "Light", foregroundColor: UIColor.white, backgroundColor: UIColor(hexString: "#f2f2f7"), navIconColor: UIColor(hexString: "#3c3c43").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#000000").withAlphaComponent(0.87), isLight: true, isCustom: false)) ColorUtil.themes.append(Theme(title: "dark", displayName: "Dark Gray", foregroundColor: UIColor(hexString: "#303030"), backgroundColor: UIColor(hexString: "#212121"), navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "black", displayName: "Black", foregroundColor: UIColor.black, backgroundColor: UIColor.black, navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) ColorUtil.themes.append(Theme(title: "blue", displayName: "Blue", foregroundColor: UIColor(hexString: "#37474F"), backgroundColor: UIColor(hexString: "#2F3D44"), navIconColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), fontColor: UIColor(hexString: "#FFFFFF").withAlphaComponent(0.87), isLight: false, isCustom: false)) From 54696633c73a58dcad66cb53f400e260d6f4b51a Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 15:32:48 -0500 Subject: [PATCH 32/46] Added ability to follow and subscribe to user profiles --- .../xcschemes/Slide for Apple Watch.xcscheme | 25 +++-------- Slide for Reddit/CachedTitle.swift | 4 +- Slide for Reddit/CommentDepthCell.swift | 11 +++++ Slide for Reddit/LinkCellView.swift | 13 +++++- .../NavigationHomeViewController.swift | 2 +- .../PagingTitleCollectionView.swift | 2 +- .../ProfileInfoViewController.swift | 44 ++++++++++++++++++- Slide for Reddit/ProfileViewController.swift | 1 + Slide for Reddit/SubredditCellView.swift | 2 +- 9 files changed, 77 insertions(+), 27 deletions(-) diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0d084ded0..0530f2df2 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,10 +65,8 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - - - - - + diff --git a/Slide for Reddit/CachedTitle.swift b/Slide for Reddit/CachedTitle.swift index 0292cc3ab..918f76754 100644 --- a/Slide for Reddit/CachedTitle.swift +++ b/Slide for Reddit/CachedTitle.swift @@ -204,8 +204,8 @@ class CachedTitle { authorAttributes[.foregroundColor] = UIColor.white } - if SettingValues.tapProfilesAndSubs || full, let authorUrl = URL(string: "https://www.reddit.com/u/\(submission.author)") { - authorAttributes[.urlAction] = authorUrl + if SettingValues.tapProfilesAndSubs || full, let authorUrl = URL(string: "/u/\(submission.author)") { + authorAttributes[.textHighlight] = TextHighlight(["url": authorUrl]) } let authorString = NSMutableAttributedString(string: "\u{00A0}\(AccountController.formatUsername(input: submission.author, small: false) + (submission.isCakeday ? " 🎂" : ""))\u{00A0}", attributes: authorAttributes) diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index 9eccd0317..b99997c08 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -2619,6 +2619,17 @@ extension CommentDepthCell: UIContextMenuInteractionDelegate { VCPresenter.openRedditLink("https://www.reddit.com/message/compose?to=\(username)", self.parent?.navigationController, self.parent) }) + if !Subscriptions.isSubscriber("u_\(username)") { + children.append(UIAction(title: "Follow user", image: UIImage(sfString: SFSymbol.plusCircleFill, overrideString: "add")!.menuIcon()) { _ in + if let session = (UIApplication.shared.delegate as? AppDelegate)?.session { + Subscriptions.subscribe("u_\(username)", true, session: session) + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Followed \(username)", seconds: 3, context: self.parent) + } + } + }) + } + children.append(UIAction(title: "Block user", image: UIImage(sfString: SFSymbol.personCropCircleBadgeXmark, overrideString: "copy")!.menuIcon(), attributes: UIMenuElement.Attributes.destructive, handler: { [weak self] (_) in guard let self = self else { return } if let parent = self.parent { diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index 7f9fad229..baa2142f2 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -1551,7 +1551,7 @@ class LinkCellView: UICollectionViewCell, UIViewControllerPreviewingDelegate, UI setVisibility(downvote, actions.isVotingPossible) setVisibility(hide, actions.isHideEnabled && !full) setVisibility(readLater, actions.isReadLaterEnabled) - setVisibility(save, actions.isSaveEnabled && actions.isSavePossible) + setVisibility(save, (actions.isSaveEnabled && actions.isSavePossible) || (self.parentViewController is ContentListingViewController && (self.parentViewController as? ContentListingViewController)?.baseData is CollectionsContributionLoader)) setVisibility(reply, actions.isReplyPossible && full) setVisibility(menu, actions.isMenuEnabled) setVisibility(share, actions.isShareEnabled) @@ -3472,6 +3472,17 @@ extension LinkCellView: UIContextMenuInteractionDelegate { VCPresenter.openRedditLink("https://www.reddit.com/message/compose?to=\(username)", self.parentViewController?.navigationController, self.parentViewController) }) + if !Subscriptions.isSubscriber("u_\(username)") { + children.append(UIAction(title: "Follow user", image: UIImage(sfString: SFSymbol.plusCircleFill, overrideString: "add")!.menuIcon()) { _ in + if let session = (UIApplication.shared.delegate as? AppDelegate)?.session { + Subscriptions.subscribe("u_\(username)", true, session: session) + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Followed \(username)", seconds: 3, context: self.parentViewController) + } + } + }) + } + children.append(UIAction(title: "Block user", image: UIImage(sfString: SFSymbol.personCropCircleBadgeXmark, overrideString: "copy")!.menuIcon(), attributes: UIMenuElement.Attributes.destructive, handler: { [weak self] (_) in guard let self = self else { return } if let parent = self.parentViewController { diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index 0d4db67a7..d0df9e5cd 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -92,7 +92,7 @@ class NavigationHomeViewController: UIViewController { $0.searchTextField.rightView?.tintColor = UIColor.fontColor $0.searchTextField.backgroundColor = UIColor.backgroundColor if let clearButton = $0.searchTextField.value(forKey: "_clearButton") as? UIButton { - let templateImage = clearButton.imageView?.image?.withRenderingMode(.alwaysTemplate) + let templateImage = clearButton.imageView?.image?.withRenderingMode(.alwaysTemplate) clearButton.setImage(templateImage, for: .normal) clearButton.tintColor = UIColor.fontColor } diff --git a/Slide for Reddit/PagingTitleCollectionView.swift b/Slide for Reddit/PagingTitleCollectionView.swift index 1c0f1b20b..dc9cbe1cd 100644 --- a/Slide for Reddit/PagingTitleCollectionView.swift +++ b/Slide for Reddit/PagingTitleCollectionView.swift @@ -256,7 +256,7 @@ class SubredditTitleCollectionViewCell: UICollectionViewCell { title.adjustsFontSizeToFitWidth = true title.translatesAutoresizingMaskIntoConstraints = false - title.text = subreddit + title.text = subreddit.contains("u_") ? subreddit.replacingOccurrences(of: "u_", with: "u/") : subreddit title.numberOfLines = 1 title.sizeToFit() sideView.backgroundColor = ColorUtil.getColorForSub(sub: subreddit) diff --git a/Slide for Reddit/ProfileInfoViewController.swift b/Slide for Reddit/ProfileInfoViewController.swift index 53b2223de..d68694be4 100644 --- a/Slide for Reddit/ProfileInfoViewController.swift +++ b/Slide for Reddit/ProfileInfoViewController.swift @@ -237,7 +237,7 @@ extension ProfileInfoViewController { b.addTapGestureRecognizer(action: { _ in if trophy.url != nil { var trophyURL = trophy.url!.absoluteString - if !trophyURL.contains("reddit.com") { + if !trophyURL.contains("http") { trophyURL = "https://www.reddit.com" + trophyURL } VCPresenter.presentModally(viewController: WebsiteViewController(url: URL(string: trophyURL) ?? trophy.url!, subreddit: ""), self, nil) @@ -346,6 +346,24 @@ extension ProfileInfoViewController { } extension ProfileInfoViewController: ProfileHeaderViewDelegate { + func didRequestUnFollow() { + if let session = (UIApplication.shared.delegate as? AppDelegate)?.session, let username = self.user?.name { + Subscriptions.unsubscribe("u_\(username)", session: session) + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Un-followed \(username)", seconds: 3, context: self) + } + } + } + + func didRequestFollow() { + if let session = (UIApplication.shared.delegate as? AppDelegate)?.session, let username = self.user?.name { + Subscriptions.subscribe("u_\(username)", true, session: session) + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Followed \(username)", seconds: 3, context: self) + } + } + } + func didRequestPrivateMessage() { if user == nil { return @@ -458,6 +476,8 @@ protocol ProfileHeaderViewDelegate: AnyObject { func didRequestPrivateMessage() func didRequestRemoveFriend() func didRequestAddFriend() + func didRequestUnFollow() + func didRequestFollow() func didRequestSetColor() func didRequestEditTag() } @@ -493,6 +513,7 @@ class ProfileHeaderView: UIView { var user: Account? var friendCell = UITableViewCell() + var followCell = UITableViewCell() var colorCell = UITableViewCell().then { $0.configure(text: "Set user color", imageName: "add", sfSymbolName: .eyedropperFull, imageColor: GMColor.yellow500Color()) @@ -520,7 +541,7 @@ class ProfileHeaderView: UIView { addSubviews(infoStack, trophyArea, cellStack) infoStack.addArrangedSubviews(commentKarmaLabel, postKarmaLabel) - cellStack.addArrangedSubviews(messageCell, friendCell, colorCell, tagCell) + cellStack.addArrangedSubviews(messageCell, friendCell, followCell, colorCell, tagCell) self.clipsToBounds = true @@ -549,6 +570,9 @@ class ProfileHeaderView: UIView { self.friendCell.configure(text: account?.isFriend ?? false ? "Remove friend" : "Add friend", imageName: "profile", sfSymbolName: account?.isFriend ?? false ? SFSymbol.personBadgeMinusFill : SFSymbol.personBadgePlusFill, imageColor: GMColor.yellow500Color()) + let isFollower = Subscriptions.isSubscriber("u_\(account?.name ?? "")") + self.followCell.configure(text: isFollower ? "Stop following and unsubscribe" : "Follow and Subscribe", imageName: "add", sfSymbolName: isFollower ? SFSymbol.minusCircleFill : SFSymbol.plusCircleFill, imageColor: GMColor.yellow500Color()) + postKarmaLabel.attributedText = { let attrs = [NSAttributedString.Key.font: FontGenerator.boldFontOfSize(size: 16, submission: true)] let attributedString = NSMutableAttributedString(string: "\(account?.linkKarma.delimiter ?? "0")", attributes: attrs) @@ -570,6 +594,7 @@ class ProfileHeaderView: UIView { cellStack.horizontalAnchors /==/ horizontalAnchors messageCell.heightAnchor /==/ 50 + followCell.heightAnchor /==/ 50 friendCell.heightAnchor /==/ 50 tagCell.heightAnchor /==/ 50 colorCell.heightAnchor /==/ 50 @@ -581,11 +606,26 @@ class ProfileHeaderView: UIView { friendCell.addTapGestureRecognizer { [weak self] (_) in guard let strongSelf = self else { return } if strongSelf.user?.isFriend ?? false { + strongSelf.friendCell.configure(text: "Add friend", imageName: "profile", sfSymbolName: SFSymbol.personBadgePlusFill, imageColor: GMColor.yellow500Color()) strongSelf.delegate?.didRequestRemoveFriend() } else { + strongSelf.friendCell.configure(text: "Remove friend", imageName: "profile", sfSymbolName: SFSymbol.personBadgeMinusFill, imageColor: GMColor.yellow500Color()) strongSelf.delegate?.didRequestAddFriend() } } + + followCell.addTapGestureRecognizer { [weak self] (_) in + guard let strongSelf = self else { return } + let isFollower = Subscriptions.isSubscriber("u_\(strongSelf.user?.name ?? "")") + + if !isFollower { + strongSelf.delegate?.didRequestFollow() + } else { + strongSelf.delegate?.didRequestUnFollow() + } + + strongSelf.followCell.configure(text: !isFollower ? "Stop following and unsubscribe" : "Follow and Subscribe", imageName: "add", sfSymbolName: !isFollower ? SFSymbol.minusCircleFill : SFSymbol.plusCircleFill, imageColor: GMColor.yellow500Color()) + } messageCell.addTapGestureRecognizer { [weak self] (_) in guard let strongSelf = self else { return } strongSelf.delegate?.didRequestPrivateMessage() diff --git a/Slide for Reddit/ProfileViewController.swift b/Slide for Reddit/ProfileViewController.swift index 3f9de7812..6856f023e 100644 --- a/Slide for Reddit/ProfileViewController.swift +++ b/Slide for Reddit/ProfileViewController.swift @@ -97,6 +97,7 @@ class ProfileViewController: TabsContentPagingViewController { let vc = ProfileInfoViewController(accountNamed: user) vc.modalPresentationStyle = .custom vc.transitioningDelegate = currentAccountTransitioningManager + vc.profile = self present(vc, animated: true) } diff --git a/Slide for Reddit/SubredditCellView.swift b/Slide for Reddit/SubredditCellView.swift index 554046090..982c3e304 100644 --- a/Slide for Reddit/SubredditCellView.swift +++ b/Slide for Reddit/SubredditCellView.swift @@ -139,7 +139,7 @@ class SubredditCellView: UITableViewCell { if !exists { title.text = "Go to r/\(subreddit)" } else { - title.text = subreddit + title.text = subreddit.starts(with: "u_") ? subreddit.replacingOccurrences(of: "u_", with: "u/") : subreddit } failedLabel?.removeFromSuperview() From 5a4f0cba2051996b3e729de5933beac924d547df Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 15:38:53 -0500 Subject: [PATCH 33/46] Fixed subreddit top link bubble colors --- Slide for Reddit/SingleSubredditViewController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 8916d804a..2a019e302 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -878,7 +878,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele func loadBubbles() { self.subLinks.removeAll() - if self.sub == ("all") || self.sub == ("frontpage") || self.sub == ("popular") || self.sub == ("friends") || self.sub.lowercased() == ("myrandom") || self.sub.lowercased() == ("random") || self.sub.lowercased() == ("randnsfw") || self.sub.hasPrefix("/m/") || self.sub.contains("+") { + if self.sub == ("all") || self.sub == ("frontpage") || self.sub == ("popular") || self.sub == ("friends") || self.sub.lowercased() == ("myrandom") || self.sub.lowercased() == ("random") || self.sub.lowercased() == ("randnsfw") || self.sub.hasPrefix("/m/") || self.sub.hasPrefix("m/") || self.sub.hasPrefix("u_") || self.sub.contains("+") { return } do { @@ -3463,7 +3463,7 @@ public class LinksHeaderCellView: UICollectionViewCell { $0.setTitleColor(.white, for: .selected) $0.titleLabel?.textAlignment = .center $0.titleLabel?.font = UIFont.systemFont(ofSize: 12) - $0.backgroundColor = ColorUtil.getNavColorForSub(sub: sub) ?? UIColor.navIconColor + $0.backgroundColor = ColorUtil.getNavColorForSub(sub: sub) ?? ColorUtil.accentColorForSub(sub: sub) $0.addTapGestureRecognizer { (_) in self.del?.doShow(url: link.link!, heroView: nil, finalSize: nil, heroVC: nil, link: SubmissionObject()) } From 55d4d8998cd9aad88f640fbac0bb9ff5cffd525b Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 15:54:37 -0500 Subject: [PATCH 34/46] Refactored method for formatting users, multireddits, and subreddits for display, Bug fixes --- .../SubmissionRowController.swift | 24 +++++++++++++++++- .../xcschemes/Slide for Apple Watch.xcscheme | 25 ++++++++++++++----- Slide for Reddit/CachedTitle.swift | 10 ++++---- Slide for Reddit/CommentCellView.swift | 6 ++--- Slide for Reddit/CommentViewController.swift | 10 ++++---- .../ContentListingViewController.swift | 8 +++--- Slide for Reddit/LinkCellView.swift | 4 +-- Slide for Reddit/MessageCellView.swift | 6 ++--- Slide for Reddit/ModLogCellView.swift | 2 +- .../ModerationViewController.swift | 2 +- .../PagingTitleCollectionView.swift | 2 +- Slide for Reddit/SearchViewController.swift | 2 +- Slide for Reddit/SettingValues.swift | 4 +-- Slide for Reddit/Sidebar.swift | 4 +-- .../SingleSubredditViewController.swift | 16 ++++++------ Slide for Reddit/SiriShortcuts.swift | 2 +- Slide for Reddit/String+Extensions.swift | 22 ++++++++++++++++ .../SubSidebarViewController.swift | 10 ++++---- Slide for Reddit/SubmissionsDataSource.swift | 4 +-- Slide for Reddit/SubredditCellView.swift | 8 +++--- .../SubredditFindReturnViewController.swift | 4 +-- Slide for Reddit/SubredditHeaderView.swift | 10 ++++---- ...SubredditToolbarSearchViewController.swift | 4 +-- 23 files changed, 123 insertions(+), 66 deletions(-) diff --git a/Slide for Apple Watch Extension/SubmissionRowController.swift b/Slide for Apple Watch Extension/SubmissionRowController.swift index 498725c33..52d01aaed 100644 --- a/Slide for Apple Watch Extension/SubmissionRowController.swift +++ b/Slide for Apple Watch Extension/SubmissionRowController.swift @@ -100,7 +100,7 @@ public class SubmissionRowController: NSObject { // endString.append(tagString) // } // - let boldString = NSMutableAttributedString(string: "r/\(dictionary["subreddit"] ?? "")", attributes: attrs) + let boldString = NSMutableAttributedString(string: (dictionary["subreddit"] as? String ?? "").getSubredditFormatted(), attributes: attrs) boldString.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: NSRange.init(location: 0, length: boldString.length)) @@ -240,3 +240,25 @@ public class SubmissionRowController: NSObject { self.imageGroup.setCornerRadius(10) } } + +extension String { + func getSubredditFormatted() -> String { + if self.hasPrefix("/m/") { + return self.replacingOccurrences(of: "/m/", with: "m/") + } + + if self.hasPrefix("u_") { + return self.replacingOccurrences(of: "u_", with: "u/") + } + + if self.hasPrefix("/r/") { + return self.replacingOccurrences(of: "/r/", with: "r/") + } + + if self.hasPrefix("r/") { + return self + } else { + return "r/\(self)" + } + } +} diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0530f2df2..0d084ded0 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,8 +65,10 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - + + + + + diff --git a/Slide for Reddit/CachedTitle.swift b/Slide for Reddit/CachedTitle.swift index 918f76754..80e88bc20 100644 --- a/Slide for Reddit/CachedTitle.swift +++ b/Slide for Reddit/CachedTitle.swift @@ -334,7 +334,7 @@ class CachedTitle { let attrs = [NSAttributedString.Key.font: FontGenerator.fontOfSize(size: 12, submission: true), NSAttributedString.Key.foregroundColor: colorF] as [NSAttributedString.Key: Any] - let boldString = NSMutableAttributedString(string: "r/\(submission.crosspostSubreddit ?? "")", attributes: attrs) + let boldString = NSMutableAttributedString(string: "\((submission.crosspostSubreddit ?? "").getSubredditFormatted())", attributes: attrs) let color = ColorUtil.getColorForSub(sub: submission.crosspostSubreddit ?? "") if color != ColorUtil.baseColor { @@ -422,7 +422,7 @@ class CachedTitle { attributedTitle.append(oc) } - let endString = NSMutableAttributedString(string: "r/\(submission.subreddit) • \(DateFormatter().timeSince(from: submission.created as NSDate, numericDates: true))\((submission.isEdited ? ("(edit \(DateFormatter().timeSince(from: submission.edited! as NSDate, numericDates: true)))") : "")) • ", attributes: [NSAttributedString.Key.font: FontGenerator.fontOfSize(size: 12, submission: true), NSAttributedString.Key.foregroundColor: colorF]) + let endString = NSMutableAttributedString(string: "\(submission.subreddit.getSubredditFormatted()) • \(DateFormatter().timeSince(from: submission.created as NSDate, numericDates: true))\((submission.isEdited ? ("(edit \(DateFormatter().timeSince(from: submission.edited! as NSDate, numericDates: true)))") : "")) • ", attributes: [NSAttributedString.Key.font: FontGenerator.fontOfSize(size: 12, submission: true), NSAttributedString.Key.foregroundColor: colorF]) var authorAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.font: FontGenerator.fontOfSize(size: 12, submission: true), NSAttributedString.Key.foregroundColor: colorF] let userColor = ColorUtil.getColorForUser(name: submission.author) @@ -503,7 +503,7 @@ class CachedTitle { iconString.append(NSAttributedString(attachment: attachment)) attrs[.baselineOffset] = (((24 - fontSize) / 2) - (titleFont.descender / 2)) } - let tapString = NSMutableAttributedString(string: " r/\(link.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: " \(link.subreddit.getSubredditFormatted())", attributes: attrs) if SettingValues.tapProfilesAndSubs || full { tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) } @@ -513,14 +513,14 @@ class CachedTitle { if color != ColorUtil.baseColor { let preString = NSMutableAttributedString(string: "⬤ ", attributes: [NSAttributedString.Key.font: titleFont, NSAttributedString.Key.foregroundColor: color]) iconString = preString - let tapString = NSMutableAttributedString(string: "r/\(link.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: "\(link.subreddit.getSubredditFormatted())", attributes: attrs) if SettingValues.tapProfilesAndSubs || full { tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) } iconString.append(tapString) } else { - let tapString = NSMutableAttributedString(string: "r/\(link.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: "\(link.subreddit.getSubredditFormatted())", attributes: attrs) if SettingValues.tapProfilesAndSubs || full { tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(link.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) } diff --git a/Slide for Reddit/CommentCellView.swift b/Slide for Reddit/CommentCellView.swift index 9e7133f74..c70070bbe 100644 --- a/Slide for Reddit/CommentCellView.swift +++ b/Slide for Reddit/CommentCellView.swift @@ -108,7 +108,7 @@ class CommentCellView: UICollectionViewCell, UIGestureRecognizerDelegate { iconString.append(NSAttributedString(attachment: attachment)) attrs[.baselineOffset] = (((24 - fontSize) / 2) - (titleFont.descender / 2)) } - let tapString = NSMutableAttributedString(string: " r/\(comment.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: " \(comment.subreddit.getSubredditFormatted())", attributes: attrs) tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(comment.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) iconString.append(tapString) @@ -116,11 +116,11 @@ class CommentCellView: UICollectionViewCell, UIGestureRecognizerDelegate { if color != ColorUtil.baseColor { let preString = NSMutableAttributedString(string: "⬤ ", attributes: [NSAttributedString.Key.font: titleFont, NSAttributedString.Key.foregroundColor: color]) iconString = preString - let tapString = NSMutableAttributedString(string: "r/\(comment.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: "\(comment.subreddit.getSubredditFormatted())", attributes: attrs) tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(comment.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) iconString.append(tapString) } else { - let tapString = NSMutableAttributedString(string: "r/\(comment.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: "\(comment.subreddit.getSubredditFormatted())", attributes: attrs) tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(comment.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) iconString = tapString } diff --git a/Slide for Reddit/CommentViewController.swift b/Slide for Reddit/CommentViewController.swift index e907f8ef1..3bb14c213 100644 --- a/Slide for Reddit/CommentViewController.swift +++ b/Slide for Reddit/CommentViewController.swift @@ -34,20 +34,20 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi func subscribe(link: SubmissionObject) { let sub = link.subreddit - let alrController = UIAlertController.init(title: "Follow r/\(sub)", message: nil, preferredStyle: .alert) + let alrController = UIAlertController.init(title: "Subscribe to \(sub.getSubredditFormatted())", message: nil, preferredStyle: .alert) if AccountController.isLoggedIn { let somethingAction = UIAlertAction(title: "Subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(sub, true, session: self.session!) self.subChanged = true - BannerUtil.makeBanner(text: "Subscribed to r/\(sub)", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "Subscribed to \(sub.getSubredditFormatted())", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) }) alrController.addAction(somethingAction) } - let somethingAction = UIAlertAction(title: "Casually subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in + let somethingAction = UIAlertAction(title: "Follow without Subscribing", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(sub, false, session: self.session!) self.subChanged = true - BannerUtil.makeBanner(text: "r/\(sub) added to your subreddit list", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "\(sub.getSubredditFormatted()) added to your subreddit list", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) }) alrController.addAction(somethingAction) @@ -1781,7 +1781,7 @@ class CommentViewController: MediaViewController, UITableViewDelegate, UITableVi VCPresenter.showVC(viewController: related, popupIfPossible: false, parentNavigationController: self.navigationController, parentViewController: self) } - alertController.addAction(title: "View r/\(link.subreddit)'s sidebar", icon: UIImage(sfString: SFSymbol.infoCircle, overrideString: "info")!.menuIcon()) { + alertController.addAction(title: "View \(link.subreddit.getSubredditFormatted())'s sidebar", icon: UIImage(sfString: SFSymbol.infoCircle, overrideString: "info")!.menuIcon()) { Sidebar.init(parent: self, subname: self.submission!.subreddit).displaySidebar() } diff --git a/Slide for Reddit/ContentListingViewController.swift b/Slide for Reddit/ContentListingViewController.swift index c63f003e5..d4603fc58 100644 --- a/Slide for Reddit/ContentListingViewController.swift +++ b/Slide for Reddit/ContentListingViewController.swift @@ -35,20 +35,20 @@ class ContentListingViewController: MediaViewController, UICollectionViewDelegat func subscribe(link: SubmissionObject) { let sub = link.subreddit - let alrController = UIAlertController.init(title: "Follow r/\(sub)", message: nil, preferredStyle: .alert) + let alrController = UIAlertController.init(title: "Subscribe to \(sub.getSubredditFormatted())", message: nil, preferredStyle: .alert) if AccountController.isLoggedIn { let somethingAction = UIAlertAction(title: "Subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(sub, true, session: self.session!) self.subChanged = true - BannerUtil.makeBanner(text: "Subscribed\nr/\(sub)", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "Subscribed\n\(sub.getSubredditFormatted())", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) }) alrController.addAction(somethingAction) } - let somethingAction = UIAlertAction(title: "Casually subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in + let somethingAction = UIAlertAction(title: "Follow without subscribing", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(sub, false, session: self.session!) self.subChanged = true - BannerUtil.makeBanner(text: "Added\nr/\(sub) ", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "Casually subscribed\n\(sub.getSubredditFormatted()) ", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) }) alrController.addAction(somethingAction) diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index baa2142f2..02bb68b4a 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -2018,7 +2018,7 @@ class LinkCellView: UICollectionViewCell, UIViewControllerPreviewingDelegate, UI let attrs = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: colorF] as [NSAttributedString.Key: Any] - let boldString = NSMutableAttributedString(string: "r/\(submission.crosspostSubreddit ?? "")", attributes: attrs) + let boldString = NSMutableAttributedString(string: "\((submission.crosspostSubreddit ?? "").getSubredditFormatted())", attributes: attrs) let color = ColorUtil.getColorForSub(sub: submission.crosspostSubreddit ?? "") if color != ColorUtil.baseColor { boldString.addAttribute(NSAttributedString.Key.foregroundColor, value: color, range: NSRange.init(location: 0, length: boldString.length)) @@ -2469,7 +2469,7 @@ class LinkCellView: UICollectionViewCell, UIViewControllerPreviewingDelegate, UI case .success(let flairs): list.append(contentsOf: flairs) DispatchQueue.main.async { - let sheet = DragDownAlertMenu(title: "r/\(self.link!.subreddit) flairs", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: self.link!.subreddit), full: true) + let sheet = DragDownAlertMenu(title: "\((self.link?.subreddit ?? "").getSubredditFormatted()) flairs", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: self.link!.subreddit), full: true) for flair in flairs { sheet.addAction(title: (flair.text.isEmpty) ? flair.name : flair.text, icon: nil, action: { diff --git a/Slide for Reddit/MessageCellView.swift b/Slide for Reddit/MessageCellView.swift index 504c7f078..bab2d90e7 100644 --- a/Slide for Reddit/MessageCellView.swift +++ b/Slide for Reddit/MessageCellView.swift @@ -130,7 +130,7 @@ class MessageCellView: UICollectionViewCell { iconString.append(NSAttributedString(attachment: attachment)) attrs[.baselineOffset] = (((24 - fontSize) / 2) - (titleFont.descender / 2)) } - let tapString = NSMutableAttributedString(string: " r/\(message.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: " \(message.subreddit.getSubredditFormatted())", attributes: attrs) tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(message.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) iconString.append(tapString) @@ -138,11 +138,11 @@ class MessageCellView: UICollectionViewCell { if color != ColorUtil.baseColor { let preString = NSMutableAttributedString(string: "⬤ ", attributes: [NSAttributedString.Key.font: titleFont, NSAttributedString.Key.foregroundColor: color]) iconString = preString - let tapString = NSMutableAttributedString(string: "r/\(message.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: "\(message.subreddit.getSubredditFormatted())", attributes: attrs) tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(message.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) iconString.append(tapString) } else { - let tapString = NSMutableAttributedString(string: "r/\(message.subreddit)", attributes: attrs) + let tapString = NSMutableAttributedString(string: "\(message.subreddit.getSubredditFormatted())", attributes: attrs) tapString.addAttributes([.urlAction: URL(string: "https://www.reddit.com/r/\(message.subreddit)")!], range: NSRange(location: 0, length: tapString.length)) iconString = tapString } diff --git a/Slide for Reddit/ModLogCellView.swift b/Slide for Reddit/ModLogCellView.swift index bbe2e7464..cbb2ba918 100644 --- a/Slide for Reddit/ModLogCellView.swift +++ b/Slide for Reddit/ModLogCellView.swift @@ -91,7 +91,7 @@ class ModlogCellView: UICollectionViewCell { color = UIColor.fontColor } - let subString = NSMutableAttributedString(string: "r/\(item.subreddit)", attributes: [NSAttributedString.Key.font: FontGenerator.fontOfSize(size: 16, submission: false), NSAttributedString.Key.foregroundColor: color]) + let subString = NSMutableAttributedString(string: "\(item.subreddit.getSubredditFormatted())", attributes: [NSAttributedString.Key.font: FontGenerator.fontOfSize(size: 16, submission: false), NSAttributedString.Key.foregroundColor: color]) let infoString = NSMutableAttributedString() infoString.append(endString) diff --git a/Slide for Reddit/ModerationViewController.swift b/Slide for Reddit/ModerationViewController.swift index 48bdea7b9..e939a5d11 100644 --- a/Slide for Reddit/ModerationViewController.swift +++ b/Slide for Reddit/ModerationViewController.swift @@ -34,7 +34,7 @@ class ModerationViewController: TabsContentPagingViewController { } override func appearOthers() { - self.title = "r/\(subreddit)" + self.title = "\(subreddit.getSubredditFormatted())" } @objc func new(_ sender: AnyObject) { diff --git a/Slide for Reddit/PagingTitleCollectionView.swift b/Slide for Reddit/PagingTitleCollectionView.swift index dc9cbe1cd..1d803c4d0 100644 --- a/Slide for Reddit/PagingTitleCollectionView.swift +++ b/Slide for Reddit/PagingTitleCollectionView.swift @@ -256,7 +256,7 @@ class SubredditTitleCollectionViewCell: UICollectionViewCell { title.adjustsFontSizeToFitWidth = true title.translatesAutoresizingMaskIntoConstraints = false - title.text = subreddit.contains("u_") ? subreddit.replacingOccurrences(of: "u_", with: "u/") : subreddit + title.text = subreddit.getSubredditFormatted() title.numberOfLines = 1 title.sizeToFit() sideView.backgroundColor = ColorUtil.getColorForSub(sub: subreddit) diff --git a/Slide for Reddit/SearchViewController.swift b/Slide for Reddit/SearchViewController.swift index 22665dc80..d86fa198d 100644 --- a/Slide for Reddit/SearchViewController.swift +++ b/Slide for Reddit/SearchViewController.swift @@ -95,7 +95,7 @@ class SearchViewController: ContentListingViewController { self.refreshControl?.beginRefreshing() }) base.getData(reload: true) - self.navigationItem.titleView = self.setTitle(title: self.search, subtitle: "r/\(self.sub)") + self.navigationItem.titleView = self.setTitle(title: self.search, subtitle: "\(self.sub.getSubredditFormatted())") } } }, inputPlaceholder: "Edit your search...", inputValue: self.search, inputIcon: UIImage(sfString: SFSymbol.pencil, overrideString: "edit")!.menuIcon(), textRequired: true, exitOnAction: true) diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index eeae1a569..5b0b7273b 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -834,12 +834,12 @@ class SettingValues { if link == nil { return "Subreddit" } - return "r/\(link!.subreddit)" + return "\(link!.subreddit.getSubredditFormatted())" case .SUBSCRIBE: if link == nil { return "Subscribe" } - return "Subscribe to r/\(link!.subreddit)" + return "Subscribe to \(link!.subreddit.getSubredditFormatted())" case .REPORT: return "Report content" case .BLOCK: diff --git a/Slide for Reddit/Sidebar.swift b/Slide for Reddit/Sidebar.swift index 28c58b2be..6594bcc75 100644 --- a/Slide for Reddit/Sidebar.swift +++ b/Slide for Reddit/Sidebar.swift @@ -62,7 +62,7 @@ class Sidebar: NSObject { parent!.subChanged = false BannerUtil.makeBanner(text: "Unsubscribed", seconds: 5, context: self.parent, top: true) } else { - let alrController = DragDownAlertMenu(title: "Follow r/\(sub.displayName)", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: sub.displayName), full: true) + let alrController = DragDownAlertMenu(title: "Subscribe to \(sub.displayName.getSubredditFormatted())", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: sub.displayName), full: true) if AccountController.isLoggedIn { alrController.addAction(title: "Subscribe", icon: nil) { Subscriptions.subscribe(sub.displayName, true, session: (UIApplication.shared.delegate as! AppDelegate).session!) @@ -71,7 +71,7 @@ class Sidebar: NSObject { } } - alrController.addAction(title: "Casually subscribe", icon: nil) { + alrController.addAction(title: "Follow without Subscribing", icon: nil) { Subscriptions.subscribe(sub.displayName, false, session: (UIApplication.shared.delegate as! AppDelegate).session!) self.parent!.subChanged = true BannerUtil.makeBanner(text: "Added to subscription list", seconds: 5, context: self.parent, top: true) diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 2a019e302..025bda30b 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -1135,7 +1135,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele } if self.subInfo!.over18 && !SettingValues.nsfwEnabled { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 2) { - let alert = UIAlertController.init(title: "r/\(self.sub) is NSFW", message: "You must log into Reddit and enable NSFW content at Reddit.com to view this subreddit", preferredStyle: .alert) + let alert = UIAlertController.init(title: "\(self.sub.getSubredditFormatted()) is NSFW", message: "You must log into Reddit and enable NSFW content at Reddit.com to view this subreddit", preferredStyle: .alert) alert.addAction(UIAlertAction.init(title: "Close", style: .default, handler: { (_) in self.navigationController?.popViewController(animated: true) self.dismiss(animated: true, completion: nil) @@ -1222,7 +1222,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele BannerUtil.makeBanner(text: "Unsubscribed", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) subb.setImage(UIImage(sfString: SFSymbol.plusCircleFill, overrideString: "addcircle")?.navIcon(), for: UIControl.State.normal) } else { - let alrController = UIAlertController.init(title: "Follow r/\(sub)", message: nil, preferredStyle: .alert) + let alrController = UIAlertController.init(title: "Subscribe to \(sub.getSubredditFormatted())", message: nil, preferredStyle: .alert) if AccountController.isLoggedIn { let somethingAction = UIAlertAction(title: "Subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(self.sub, true, session: self.session!) @@ -1233,7 +1233,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele alrController.addAction(somethingAction) } - let somethingAction = UIAlertAction(title: "Casually subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in + let somethingAction = UIAlertAction(title: "Follow without Subscribing", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(self.sub, false, session: self.session!) self.subChanged = true BannerUtil.makeBanner(text: "r/\(self.sub) added to your subreddit list", color: ColorUtil.accentColorForSub(sub: self.sub), seconds: 3, context: self, top: true) @@ -1404,7 +1404,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele alert.setupTheme() alert.attributedTitle = NSAttributedString(string: "Content to hide on", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedString.Key.foregroundColor: UIColor.fontColor]) - alert.attributedMessage = NSAttributedString(string: "r/\(sub)", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.fontColor]) + alert.attributedMessage = NSAttributedString(string: "\(sub.getSubredditFormatted())", attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14), NSAttributedString.Key.foregroundColor: UIColor.fontColor]) alert.contentView.addSubview(filterView) settings.didMove(toParent: alert) @@ -2834,7 +2834,7 @@ extension SingleSubredditViewController: SubmissionMoreDelegate { func subscribe(link: SubmissionObject) { let sub = link.subreddit - let alrController = UIAlertController.init(title: "Follow r/\(sub)", message: nil, preferredStyle: .alert) + let alrController = UIAlertController.init(title: "Subscribe to \(sub.getSubredditFormatted())", message: nil, preferredStyle: .alert) if AccountController.isLoggedIn { let somethingAction = UIAlertAction(title: "Subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(sub, true, session: self.session!) @@ -2844,10 +2844,10 @@ extension SingleSubredditViewController: SubmissionMoreDelegate { alrController.addAction(somethingAction) } - let somethingAction = UIAlertAction(title: "Casually subscribe", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in + let somethingAction = UIAlertAction(title: "Follow without Subscribing", style: UIAlertAction.Style.default, handler: { (_: UIAlertAction!) in Subscriptions.subscribe(sub, false, session: self.session!) self.subChanged = true - BannerUtil.makeBanner(text: "r/\(sub) added to your subreddit list", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "\(sub.getSubredditFormatted()) added to your subreddit list", color: ColorUtil.accentColorForSub(sub: sub), seconds: 3, context: self, top: true) }) alrController.addAction(somethingAction) @@ -2996,7 +2996,7 @@ extension SingleSubredditViewController: SubmissionMoreDelegate { } actionSheetController.addAction(cancelActionButton) - cancelActionButton = UIAlertAction(title: "Posts from r/\(link.subreddit)", style: .default) { _ -> Void in + cancelActionButton = UIAlertAction(title: "Posts from \(link.subreddit.getSubredditFormatted())", style: .default) { _ -> Void in PostFilter.subreddits.append(link.subreddit as NSString) PostFilter.saveAndUpdate() self.dataSource.content = PostFilter.filter(self.dataSource.content, previous: nil, baseSubreddit: self.sub).map { $0 as! SubmissionObject } diff --git a/Slide for Reddit/SiriShortcuts.swift b/Slide for Reddit/SiriShortcuts.swift index c0e22d402..1f5c3a9cc 100644 --- a/Slide for Reddit/SiriShortcuts.swift +++ b/Slide for Reddit/SiriShortcuts.swift @@ -21,7 +21,7 @@ extension SingleSubredditViewController { let attributes = CSSearchableItemAttributeSet(itemContentType: kUTTypeItem as String) activity.title = subreddit activity.userInfo = ["TYPE": "SUBREDDIT"] - attributes.contentDescription = "Open r/\(subreddit) in Slide" + attributes.contentDescription = "Open \(subreddit.getSubredditFormatted()) in Slide" activity.contentAttributeSet = attributes return activity diff --git a/Slide for Reddit/String+Extensions.swift b/Slide for Reddit/String+Extensions.swift index c7f69b6d9..ff5dc5882 100644 --- a/Slide for Reddit/String+Extensions.swift +++ b/Slide for Reddit/String+Extensions.swift @@ -67,3 +67,25 @@ extension String { return str } } + +extension String { + func getSubredditFormatted() -> String { + if self.hasPrefix("/m/") { + return self.replacingOccurrences(of: "/m/", with: "m/") + } + + if self.hasPrefix("u_") { + return self.replacingOccurrences(of: "u_", with: "u/") + } + + if self.hasPrefix("/r/") { + return self.replacingOccurrences(of: "/r/", with: "r/") + } + + if self.hasPrefix("r/") { + return self + } else { + return "r/\(self)" + } + } +} diff --git a/Slide for Reddit/SubSidebarViewController.swift b/Slide for Reddit/SubSidebarViewController.swift index ccbfe0bd4..61ce0cca6 100644 --- a/Slide for Reddit/SubSidebarViewController.swift +++ b/Slide for Reddit/SubSidebarViewController.swift @@ -83,21 +83,21 @@ class SubSidebarViewController: MediaViewController, UIGestureRecognizerDelegate @objc func doSub(_ changed: UISwitch) { if !changed.isOn { Subscriptions.unsubscribe(subreddit!.displayName, session: (UIApplication.shared.delegate as! AppDelegate).session!) - BannerUtil.makeBanner(text: "Unsubscribed from r/\(subreddit!.displayName)", color: ColorUtil.accentColorForSub(sub: subreddit!.displayName), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "Unsubscribed from \(subreddit!.displayName.getSubredditFormatted())", color: ColorUtil.accentColorForSub(sub: subreddit!.displayName), seconds: 3, context: self, top: true) } else { - let alrController = DragDownAlertMenu(title: "Follow \(subreddit!.displayName)", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: subreddit!.displayName), full: true) + let alrController = DragDownAlertMenu(title: "Subscribe to \(subreddit!.displayNamegetSubredditFormatted())", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: subreddit!.displayName), full: true) if AccountController.isLoggedIn { alrController.addAction(title: "Subscribe", icon: nil) { Subscriptions.subscribe(self.subreddit!.displayName, true, session: (UIApplication.shared.delegate as! AppDelegate).session!) - BannerUtil.makeBanner(text: "Subscribed to r/\(self.subreddit!.displayName)", color: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "Subscribed to \(self.subreddit!.displayName.getSubredditFormatted())", color: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), seconds: 3, context: self, top: true) } } - alrController.addAction(title: "Casually subscribe", icon: nil) { + alrController.addAction(title: "Follow without Subscribing", icon: nil) { Subscriptions.subscribe(self.subreddit!.displayName, false, session: (UIApplication.shared.delegate as! AppDelegate).session!) - BannerUtil.makeBanner(text: "r/\(self.subreddit!.displayName) added to your subreddit list", color: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), seconds: 3, context: self, top: true) + BannerUtil.makeBanner(text: "\(self.subreddit!.displayName.getSubredditFormatted()) added to your subreddit list", color: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), seconds: 3, context: self, top: true) } alrController.show(self) diff --git a/Slide for Reddit/SubmissionsDataSource.swift b/Slide for Reddit/SubmissionsDataSource.swift index 832296b63..3c8ad8867 100644 --- a/Slide for Reddit/SubmissionsDataSource.swift +++ b/Slide for Reddit/SubmissionsDataSource.swift @@ -147,12 +147,12 @@ class SubmissionsDataSource { } if subreddit.lowercased() == "randnsfw" && !SettingValues.nsfwEnabled { if let delegate = delegate { - delegate.generalError(title: "r/\(self.subreddit) is NSFW", message: "You must log into Reddit and enable NSFW content at Reddit.com to view this subreddit") + delegate.generalError(title: "\(self.subreddit.getSubredditFormatted()) is NSFW", message: "You must log into Reddit and enable NSFW content at Reddit.com to view this subreddit") } return } else if subreddit.lowercased() == "myrandom" && !AccountController.isGold { if let delegate = delegate { - delegate.generalError(title: "r/\(self.subreddit) requires gold", message: "See reddit.com/gold/about for more details") + delegate.generalError(title: "\(self.subreddit.getSubredditFormatted()) requires a Reddit Premium subscription", message: "See reddit.com/gold/about for more details") } return } diff --git a/Slide for Reddit/SubredditCellView.swift b/Slide for Reddit/SubredditCellView.swift index 982c3e304..e50d9cdb2 100644 --- a/Slide for Reddit/SubredditCellView.swift +++ b/Slide for Reddit/SubredditCellView.swift @@ -137,9 +137,9 @@ class SubredditCellView: UITableViewCell { self.sideView.isHidden = false self.icon.isHidden = false if !exists { - title.text = "Go to r/\(subreddit)" + title.text = "Go to \(subreddit.getSubredditFormatted())" } else { - title.text = subreddit.starts(with: "u_") ? subreddit.replacingOccurrences(of: "u_", with: "u/") : subreddit + title.text = subreddit.getSubredditFormatted() } failedLabel?.removeFromSuperview() @@ -203,7 +203,7 @@ class SubredditCellView: UITableViewCell { self.icon.isHidden = false self.sideView.isHidden = true self.navController = nav - title.text = "Search " + (sub == nil ? "Reddit" : "r/\(self.subreddit)") + title.text = "Search " + (sub == nil ? "Reddit" : "\(self.subreddit.getSubredditFormatted())") self.icon.contentMode = .center self.icon.image = UIImage.init(sfString: SFSymbol.magnifyingglass, overrideString: "search")!.menuIcon() sideView.backgroundColor = ColorUtil.getColorForSub(sub: subreddit) @@ -284,7 +284,7 @@ class SubredditCellView: UITableViewCell { if let icon = Subscriptions.icon(for: submission.subreddit) { subDot.sd_setImage(with: URL(string: icon.unescapeHTML), completed: nil) } - subName.text = "r/\(submission.subreddit)" + subName.text = "\(submission.subreddit.getSubredditFormatted())" thumbView.contentMode = .scaleAspectFill if submission.hasBanner { diff --git a/Slide for Reddit/SubredditFindReturnViewController.swift b/Slide for Reddit/SubredditFindReturnViewController.swift index cb57be705..78dd254fe 100644 --- a/Slide for Reddit/SubredditFindReturnViewController.swift +++ b/Slide for Reddit/SubredditFindReturnViewController.swift @@ -118,7 +118,7 @@ class SubredditFindReturnViewController: UITableViewController, UISearchBarDeleg return } - let alrController = DragDownAlertMenu(title: "Follow r/\(sub)", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: sub), full: true) + let alrController = DragDownAlertMenu(title: "Subscribe to \(sub.getSubredditFormatted())", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: sub), full: true) if AccountController.isLoggedIn { alrController.addAction(title: "Subscribe", icon: nil) { @@ -133,7 +133,7 @@ class SubredditFindReturnViewController: UITableViewController, UISearchBarDeleg return } - alrController.addAction(title: "Casually subscribe", icon: nil) { + alrController.addAction(title: "Follow without Subscribing", icon: nil) { Subscriptions.subscribe(sub, false, session: (UIApplication.shared.delegate as! AppDelegate).session!) self.navigationController?.popViewController(animated: true) self.callback(sub) diff --git a/Slide for Reddit/SubredditHeaderView.swift b/Slide for Reddit/SubredditHeaderView.swift index 212c4b923..68c55226a 100644 --- a/Slide for Reddit/SubredditHeaderView.swift +++ b/Slide for Reddit/SubredditHeaderView.swift @@ -38,9 +38,9 @@ class SubredditHeaderView: UIView { case .success(let users): list.append(contentsOf: users) DispatchQueue.main.async { - let sheet = DragDownAlertMenu(title: "Moderators", subtitle: "r/\(self.subreddit!.displayName)", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), full: false) + let sheet = DragDownAlertMenu(title: "Moderators", subtitle: "\(self.subreddit!.displayName.getSubredditFormatted())", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), full: false) - sheet.addAction(title: "Message r/\(self.subreddit!.displayName) moderators", icon: UIImage(sfString: SFSymbol.shieldLefthalfFill, overrideString: "mod")?.menuIcon(), action: { + sheet.addAction(title: "Message \(self.subreddit!.displayName.getSubredditFormatted()) moderators", icon: UIImage(sfString: SFSymbol.shieldLefthalfFill, overrideString: "mod")?.menuIcon(), action: { VCPresenter.openRedditLink("https://www.reddit.com/message/compose?to=/r/\(self.subreddit!.displayName)", self.parentController?.navigationController, self.parentController) }) @@ -173,7 +173,7 @@ class SubredditHeaderView: UIView { } let json = try JSON(data: data) if let flairs = json.array { - let alert = DragDownAlertMenu(title: "Available flairs", subtitle: "r/\(self.subreddit!.displayName)", icon: nil) + let alert = DragDownAlertMenu(title: "Available flairs", subtitle: "\(self.subreddit!.displayName.getSubredditFormatted())", icon: nil) for item in flairs { if let richtext = item["richtext"].array?[0] { @@ -254,7 +254,7 @@ class SubredditHeaderView: UIView { } @objc func sort(_ selector: UITableViewCell) { - let actionSheetController = DragDownAlertMenu(title: "Default sorting for r/\(self.subreddit!.displayName)", subtitle: "Overrides the default in Settings > General", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), full: true) + let actionSheetController = DragDownAlertMenu(title: "Default sorting for \(self.subreddit!.displayName.getSubredditFormatted())", subtitle: "Overrides the default in Settings > General", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: self.subreddit!.displayName), full: true) let selected = UIImage(sfString: SFSymbol.checkmarkCircle, overrideString: "selected")!.menuIcon() @@ -348,7 +348,7 @@ class SubredditHeaderView: UIView { descHeight = info.estimatedHeight } - self.flair.textLabel?.text = "Your flair on r/\(subreddit.displayName)" + self.flair.textLabel?.text = "Your flair on \(subreddit.displayName.getSubredditFormatted())" } var subreddit: Subreddit? diff --git a/Slide for Reddit/SubredditToolbarSearchViewController.swift b/Slide for Reddit/SubredditToolbarSearchViewController.swift index e9170333c..b6878473d 100644 --- a/Slide for Reddit/SubredditToolbarSearchViewController.swift +++ b/Slide for Reddit/SubredditToolbarSearchViewController.swift @@ -693,7 +693,7 @@ class SubredditToolbarSearchViewController: UIViewController, UIGestureRecognize } func setupHeader(_ subreddit: String) { - let titleString = NSMutableAttributedString(string: "r/\(subreddit)", attributes: [NSAttributedString.Key.foregroundColor: UIColor.fontColor, NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 18)]) + let titleString = NSMutableAttributedString(string: "\(subreddit.getSubredditFormatted())", attributes: [NSAttributedString.Key.foregroundColor: UIColor.fontColor, NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 18)]) subTitleView.attributedText = titleString subTitleView.numberOfLines = 0 @@ -722,7 +722,7 @@ class SubredditToolbarSearchViewController: UIViewController, UIGestureRecognize } func setDescriptionLabel(_ subreddit: Subreddit) { - let titleString = NSMutableAttributedString(string: "r/\(subreddit.displayName)", attributes: [NSAttributedString.Key.foregroundColor: UIColor.fontColor, NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 18)]) + let titleString = NSMutableAttributedString(string: "\(subreddit.displayName.getSubredditFormatted())", attributes: [NSAttributedString.Key.foregroundColor: UIColor.fontColor, NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 18)]) titleString.appendString("\n") titleString.append(NSMutableAttributedString(string: "\(subreddit.accountsActive) HERE • \(subreddit.subscribers) SUBSCRIBERS", attributes: [NSAttributedString.Key.foregroundColor: UIColor.fontColor, NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)])) From fb3cd94de1a97a9563dea984dd76c4707b03558d Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 16:08:25 -0500 Subject: [PATCH 35/46] Made Dark Mode enabled by default, Bug fixes --- .../xcschemes/Slide for Apple Watch.xcscheme | 25 +++++-------------- Slide for Reddit/ColorUtil.swift | 2 +- .../PagingTitleCollectionView.swift | 2 +- Slide for Reddit/SettingValues.swift | 3 ++- Slide for Reddit/String+Extensions.swift | 16 ++++++++++++ .../SubSidebarViewController.swift | 2 +- Slide for Reddit/SubredditCellView.swift | 4 +-- .../SubredditThemeViewController.swift | 3 +-- 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0d084ded0..0530f2df2 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,10 +65,8 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - - - - - + diff --git a/Slide for Reddit/ColorUtil.swift b/Slide for Reddit/ColorUtil.swift index c9840caad..24358051b 100644 --- a/Slide for Reddit/ColorUtil.swift +++ b/Slide for Reddit/ColorUtil.swift @@ -446,7 +446,7 @@ extension UIColor { static var isLightTheme: Bool { if #available(iOS 13.0, *) { - return UITraitCollection.current.userInterfaceStyle != .dark && SettingValues.nightModeEnabled ? ColorUtil.theme.isLight : ColorUtil.nightTheme.isLight + return UITraitCollection.current.userInterfaceStyle == .dark && SettingValues.nightModeEnabled ? ColorUtil.nightTheme.isLight : ColorUtil.theme.isLight } else { return ColorUtil.swappedTheme.isLight } diff --git a/Slide for Reddit/PagingTitleCollectionView.swift b/Slide for Reddit/PagingTitleCollectionView.swift index 1d803c4d0..e7fdf143e 100644 --- a/Slide for Reddit/PagingTitleCollectionView.swift +++ b/Slide for Reddit/PagingTitleCollectionView.swift @@ -256,7 +256,7 @@ class SubredditTitleCollectionViewCell: UICollectionViewCell { title.adjustsFontSizeToFitWidth = true title.translatesAutoresizingMaskIntoConstraints = false - title.text = subreddit.getSubredditFormatted() + title.text = subreddit.getSubredditFormattedShort() title.numberOfLines = 1 title.sizeToFit() sideView.backgroundColor = ColorUtil.getColorForSub(sub: subreddit) diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 5b0b7273b..ec24618e0 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -653,7 +653,8 @@ class SettingValues { SettingValues.saveButton = settings.object(forKey: SettingValues.pref_saveButton) == nil ? true : settings.bool(forKey: SettingValues.pref_saveButton) SettingValues.readLaterButton = settings.object(forKey: SettingValues.pref_readLaterButton) == nil ? true : settings.bool(forKey: SettingValues.pref_readLaterButton) SettingValues.hideButton = settings.bool(forKey: SettingValues.pref_hideButton) - SettingValues.nightModeEnabled = settings.bool(forKey: SettingValues.pref_nightMode) + SettingValues.nightModeEnabled = settings.object(forKey: SettingValues.pref_nightMode) == nil ? true : settings.bool(forKey: SettingValues.pref_nightMode) + SettingValues.nightStart = settings.object(forKey: SettingValues.pref_nightStartH) == nil ? 9 : settings.integer(forKey: SettingValues.pref_nightStartH) SettingValues.nightStartMin = settings.object(forKey: SettingValues.pref_nightStartH) == nil ? 0 : settings.integer(forKey: SettingValues.pref_nightStartM) SettingValues.nightEnd = settings.object(forKey: SettingValues.pref_nightStartH) == nil ? 5 : settings.integer(forKey: SettingValues.pref_nightEndH) diff --git a/Slide for Reddit/String+Extensions.swift b/Slide for Reddit/String+Extensions.swift index ff5dc5882..dafa0b019 100644 --- a/Slide for Reddit/String+Extensions.swift +++ b/Slide for Reddit/String+Extensions.swift @@ -88,4 +88,20 @@ extension String { return "r/\(self)" } } + + func getSubredditFormattedShort() -> String { + if self.hasPrefix("/m/") { + return self.replacingOccurrences(of: "/m/", with: "m/") + } + + if self.hasPrefix("u_") { + return self.replacingOccurrences(of: "u_", with: "u/") + } + + if self.hasPrefix("/r/") { + return self.replacingOccurrences(of: "/r/", with: "") + } + + return self + } } diff --git a/Slide for Reddit/SubSidebarViewController.swift b/Slide for Reddit/SubSidebarViewController.swift index 61ce0cca6..30325d4c4 100644 --- a/Slide for Reddit/SubSidebarViewController.swift +++ b/Slide for Reddit/SubSidebarViewController.swift @@ -86,7 +86,7 @@ class SubSidebarViewController: MediaViewController, UIGestureRecognizerDelegate BannerUtil.makeBanner(text: "Unsubscribed from \(subreddit!.displayName.getSubredditFormatted())", color: ColorUtil.accentColorForSub(sub: subreddit!.displayName), seconds: 3, context: self, top: true) } else { - let alrController = DragDownAlertMenu(title: "Subscribe to \(subreddit!.displayNamegetSubredditFormatted())", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: subreddit!.displayName), full: true) + let alrController = DragDownAlertMenu(title: "Subscribe to \(subreddit!.displayName.getSubredditFormatted())", subtitle: "", icon: nil, themeColor: ColorUtil.accentColorForSub(sub: subreddit!.displayName), full: true) if AccountController.isLoggedIn { alrController.addAction(title: "Subscribe", icon: nil) { diff --git a/Slide for Reddit/SubredditCellView.swift b/Slide for Reddit/SubredditCellView.swift index e50d9cdb2..888135b1d 100644 --- a/Slide for Reddit/SubredditCellView.swift +++ b/Slide for Reddit/SubredditCellView.swift @@ -137,9 +137,9 @@ class SubredditCellView: UITableViewCell { self.sideView.isHidden = false self.icon.isHidden = false if !exists { - title.text = "Go to \(subreddit.getSubredditFormatted())" + title.text = "Go to \(subreddit.getSubredditFormattedShort())" } else { - title.text = subreddit.getSubredditFormatted() + title.text = subreddit.getSubredditFormattedShort() } failedLabel?.removeFromSuperview() diff --git a/Slide for Reddit/SubredditThemeViewController.swift b/Slide for Reddit/SubredditThemeViewController.swift index acfb03304..719bca1d0 100644 --- a/Slide for Reddit/SubredditThemeViewController.swift +++ b/Slide for Reddit/SubredditThemeViewController.swift @@ -20,12 +20,11 @@ class SubredditThemeViewController: UITableViewController, ColorPickerViewDelega override var preferredStatusBarStyle: UIStatusBarStyle { if UIColor.isLightTheme && SettingValues.reduceColor { - if #available(iOS 13, *) { + if #available(iOS 13, *) { return .darkContent } else { return .default } - } else { return .lightContent } From 063044fd964c9d4aa1574f4e23c9a4533cfd4128 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 16:29:05 -0500 Subject: [PATCH 36/46] Added iCloud debugging menu --- Slide for Reddit/SettingsGeneral.swift | 78 +++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 8 deletions(-) diff --git a/Slide for Reddit/SettingsGeneral.swift b/Slide for Reddit/SettingsGeneral.swift index 3c5f83814..0282ffc2d 100644 --- a/Slide for Reddit/SettingsGeneral.swift +++ b/Slide for Reddit/SettingsGeneral.swift @@ -7,6 +7,7 @@ // import Anchorage +import CloudKit import reddift import RLBAlertsPickers import SDCAlertView @@ -14,6 +15,13 @@ import UIKit import UserNotifications class SettingsGeneral: BubbleSettingTableViewController { + /** + Corresponds to USR_DOMAIN in info.plist, which derives its value + from USR_DOMAIN in the pbxproj build settings. Default is `ccrama.me`. + */ + lazy var USR_DOMAIN: String = { + return Bundle.main.object(forInfoDictionaryKey: "USR_DOMAIN") as! String + }() var hideFAB: InsetCell = InsetCell(style: .subtitle, reuseIdentifier: "hidefab") var scrubUsername: InsetCell = InsetCell.init(style: .subtitle, reuseIdentifier: "scrub") @@ -34,6 +42,7 @@ class SettingsGeneral: BubbleSettingTableViewController { var commentSorting: InsetCell = InsetCell.init(style: .subtitle, reuseIdentifier: "comment") var searchSorting: InsetCell = InsetCell.init(style: .subtitle, reuseIdentifier: "search") var notifications: InsetCell = InsetCell.init(style: .subtitle, reuseIdentifier: "notif") + var debugiCloud: InsetCell = InsetCell.init(style: .subtitle, reuseIdentifier: "debugicloud") var hideFABSwitch = UISwitch().then { $0.onTintColor = ColorUtil.baseAccent } @@ -179,7 +188,7 @@ class SettingsGeneral: BubbleSettingTableViewController { override func loadView() { super.loadView() - headers = ["Subreddits", "Auto-Hide", "Interaction", "Notifications", "Sorting", "Loading limits"] + headers = ["Subreddits", "Auto-Hide", "Interaction", "Notifications", "Sorting", "Loading limits", "Debug"] // set the title self.title = "General" @@ -199,6 +208,11 @@ class SettingsGeneral: BubbleSettingTableViewController { createCell(alwaysShowHeader, alwaysShowHeaderSwitch, isOn: SettingValues.alwaysShowHeader, text: "Show subreddit header") createCell(scrollSidebar, scrollSidebarSwitch, isOn: SettingValues.scrollSidebar, text: "Reset sidebar automatically") + createCell(debugiCloud, nil, isOn: false, text: "Tap to test Slide's iCloud connection") + self.debugiCloud.detailTextLabel?.text = "Any errors will be copied to your clipboard" + self.debugiCloud.detailTextLabel?.textColor = UIColor.fontColor + self.debugiCloud.detailTextLabel?.numberOfLines = 0 + self.alwaysShowHeader.detailTextLabel?.text = "When off, scrolling up past the first post will display the header" self.alwaysShowHeader.detailTextLabel?.textColor = UIColor.fontColor self.alwaysShowHeader.detailTextLabel?.numberOfLines = 0 @@ -364,7 +378,7 @@ class SettingsGeneral: BubbleSettingTableViewController { } override func numberOfSections(in tableView: UITableView) -> Int { - return 6 + return 7 } func doDisables() { @@ -402,32 +416,37 @@ class SettingsGeneral: BubbleSettingTableViewController { case 0: cell = self.pinToolbar case 1: cell = self.totallyCollapse case 2: cell = self.fullyHideNavbar - default: fatalError("Unknown row in section 0") + default: fatalError("Unknown row in section 1") } case 2: switch indexPath.row { case 0: cell = self.hapticFeedback case 1: cell = self.scrollSidebar // case 1: return self.matchSilence - default: fatalError("Unknown row in section 0") + default: fatalError("Unknown row in section 2") } case 3: switch indexPath.row { case 0: cell = self.notifications - default: fatalError("Unknown row in section 1") + default: fatalError("Unknown row in section 3") } case 4: switch indexPath.row { case 0: cell = self.postSorting case 1: cell = self.commentSorting case 2: cell = self.searchSorting - default: fatalError("Unknown row in section 2") + default: fatalError("Unknown row in section 4") } case 5: switch indexPath.row { case 0: cell = self.postLimit case 1: cell = self.commentLimit - default: fatalError("Unknown row in section 2") + default: fatalError("Unknown row in section 5") + } + case 6: + switch indexPath.row { + case 0: cell = debugiCloud + default: fatalError("Unknown row in section 6") } default: fatalError("Unknown section") } @@ -537,8 +556,50 @@ class SettingsGeneral: BubbleSettingTableViewController { showMenuComments(tableView.cellForRow(at: indexPath)) } else if indexPath.section == 4 && indexPath.row == 2 { showMenuSearch(tableView.cellForRow(at: indexPath)) + } else if indexPath.section == 6 && indexPath.row == 0 { + doDebugiCloud() + } + } + + func doDebugiCloud() { + let privateDatabase = CKContainer(identifier: "iCloud.\(USR_DOMAIN).redditslide").privateCloudDatabase + + let query = CKQuery(recordType: CKRecord.RecordType(stringLiteral: "collections"), predicate: NSPredicate(value: true)) + privateDatabase.perform(query, inZoneWith: nil) { (records, error) in + if error != nil { + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Slide can't connect to iCloud. The error has been copied to your clipboard", color: GMColor.red500Color(), seconds: 4, context: self) + } + let pasteboard = UIPasteboard.general + pasteboard.string = error?.localizedDescription ?? error.debugDescription + } else { + if let unwrappedRecord = records?[0] { + if let object = unwrappedRecord.object(forKey: "data_xml") as? String { + if let data = object.data(using: String.Encoding.utf8) { + do { + let dict = try PropertyListSerialization.propertyList(from: data, options: PropertyListSerialization.ReadOptions.mutableContainersAndLeaves, format: nil) as? NSMutableDictionary + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Slide successfully connected to iCloud", color: GMColor.green500Color(), seconds: 4, context: self) + } + return + } catch { + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Slide can't connect to iCloud. The error has been copied to your clipboard", color: GMColor.red500Color(), seconds: 4, context: self) + } + let pasteboard = UIPasteboard.general + pasteboard.string = "Error: Could not deserialize list" + } + } + } + } else { + DispatchQueue.main.async { + BannerUtil.makeBanner(text: "Slide can't connect to iCloud. The error has been copied to your clipboard", color: GMColor.red500Color(), seconds: 4, context: self) + } + let pasteboard = UIPasteboard.general + pasteboard.string = "Error: No records found" + } + } } - } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { @@ -550,6 +611,7 @@ class SettingsGeneral: BubbleSettingTableViewController { case 3: return 1 case 4: return 3 case 5: return 2 + case 6: return 1 default: fatalError("Unknown number of sections") } } From 2e38f4d45cbc477c2f55dc95c2730a2dade89f02 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 17:01:33 -0500 Subject: [PATCH 37/46] Added support for regex filters, Fixes #1175 --- Slide for Reddit/CommentDepthCell.swift | 11 ++++++++++- Slide for Reddit/PostActions.swift | 10 ++++++++++ Slide for Reddit/PostFilter.swift | 13 +++++++++---- Slide for Reddit/ProfileViewController.swift | 8 ++++++-- Slide for Reddit/SFSymbolsEnum.swift | 3 +++ Slide for Reddit/SettingValues.swift | 7 ++++++- Slide for Reddit/SettingsContentFilters.swift | 3 ++- Slide for Reddit/SettingsViewController.swift | 2 +- 8 files changed, 47 insertions(+), 10 deletions(-) diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index b99997c08..d38f29dc7 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -1342,7 +1342,7 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat } par.present(activityViewController, animated: true, completion: {}) })) - + if AccountController.isLoggedIn { actions.append(AlertMenuAction(title: ActionStates.isSaved(s: comment!) ? "Unsave" : "Save", icon: UIImage(sfString: SFSymbol.starFill, overrideString: "save")!.menuIcon(), action: { par.saveComment(self.comment!) @@ -1361,6 +1361,15 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat par.blockUser(name: self.comment!.author) })) + actions.append(AlertMenuAction(title: "Share u/\(comment!.author)'s profile", icon: UIImage(sfString: SFSymbol.xmark, overrideString: "hide")!.menuIcon(), action: { + let activityViewController = UIActivityViewController(activityItems: [URL(string: "https://www.reddit.com/u/\(self.comment!.author)") ?? URL(string: "about://blank")], applicationActivities: nil) + if let presenter = activityViewController.popoverPresentationController { + presenter.sourceView = self.moreButton + presenter.sourceRect = self.moreButton.bounds + } + par.present(activityViewController, animated: true, completion: {}) + })) + actions.append(AlertMenuAction(title: "Copy text", icon: UIImage(sfString: SFSymbol.docOnDocFill, overrideString: "copy")!.menuIcon(), action: { let alert = AlertController.init(title: "Copy text", message: nil, preferredStyle: .alert) diff --git a/Slide for Reddit/PostActions.swift b/Slide for Reddit/PostActions.swift index c083a2110..9fb16ddf5 100644 --- a/Slide for Reddit/PostActions.swift +++ b/Slide for Reddit/PostActions.swift @@ -143,6 +143,16 @@ class PostActions: NSObject { cell.downvote() case .MODERATE: PostActions.showModMenu(cell, parent: parent) + case .SHARE_AUTHOR: + if let authorUrl = URL(string: "https://reddit.com/u/" + link.subreddit) { + let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [SubjectItemSource(subject: link.title.decodeHTML(), url: authorUrl)], applicationActivities: nil) + if let presenter = activityViewController.popoverPresentationController { + presenter.sourceView = cell.contentView + presenter.sourceRect = cell.contentView.bounds + } + + parent.present(activityViewController, animated: true, completion: nil) + } } } diff --git a/Slide for Reddit/PostFilter.swift b/Slide for Reddit/PostFilter.swift index 94a570a27..ed67ab1bd 100644 --- a/Slide for Reddit/PostFilter.swift +++ b/Slide for Reddit/PostFilter.swift @@ -57,18 +57,23 @@ class PostFilter { public static func containedIn(_ array: [NSString], value: String) -> Bool { for text in array { - if value.localizedCaseInsensitiveContains(String(text)) { + if regexMatch(text as String, against: value) { return true } } return false } + + public static func regexMatch(_ regex: String, against: String) -> Bool { + let pattern = try? NSRegularExpression(pattern: regex, options: .caseInsensitive) + return ((pattern?.firstMatch(in: against, options: [], range: NSRange(location: 0, length: against.length))) != nil) + } public static func matches(_ link: SubmissionObject, baseSubreddit: String, gallery: Bool) -> Bool { - let mainMatch = (PostFilter.domains.contains(where: { $0.containedIn(base: link.domain) })) || - PostFilter.profiles.contains(where: { $0.caseInsensitiveCompare(link.author) == .orderedSame }) || - PostFilter.subreddits.contains(where: { $0.caseInsensitiveCompare(link.subreddit) == .orderedSame }) || + let mainMatch = (PostFilter.domains.contains(where: { $0.containedIn(base: link.domain) || regexMatch($0 as String, against: link.domain) })) || contains(PostFilter.flairs, value: link.flair) || + containedIn(PostFilter.subreddits, value: link.subreddit) || + containedIn(PostFilter.profiles, value: link.author) || containedIn(PostFilter.selftext, value: link.htmlBody ?? "") || containedIn(PostFilter.titles, value: link.title) || (link.isNSFW && !SettingValues.nsfwEnabled) || (link.isNSFW && gallery && !(SettingValues.nsfwPreviews || SettingValues.hideNSFWCollection && Subscriptions.isCollection(baseSubreddit))) || link.hidden || History.getSeen(s: link) && SettingValues.hideSeen diff --git a/Slide for Reddit/ProfileViewController.swift b/Slide for Reddit/ProfileViewController.swift index 6856f023e..5a3bb2754 100644 --- a/Slide for Reddit/ProfileViewController.swift +++ b/Slide for Reddit/ProfileViewController.swift @@ -127,8 +127,12 @@ class ProfileViewController: TabsContentPagingViewController { extension ProfileViewController: TabsContentPagingViewControllerDelegate { func shouldUpdateButtons() { - if currentIndex >= 1 { - let current = content[currentIndex - 1] + var offset = 1 + if name != AccountController.currentName { + offset = 0 + } + if currentIndex >= offset { + let current = content[currentIndex - offset] if current == .comments || current == .submitted || current == .overview { navigationItem.rightBarButtonItems = [ moreB!, sortB!] } else { diff --git a/Slide for Reddit/SFSymbolsEnum.swift b/Slide for Reddit/SFSymbolsEnum.swift index ba549003b..48c74a704 100644 --- a/Slide for Reddit/SFSymbolsEnum.swift +++ b/Slide for Reddit/SFSymbolsEnum.swift @@ -1598,6 +1598,9 @@ public enum SFSymbol: String { /// 􀘲 case bubbleLeftAndBubbleRightFill = "bubble.left.and.bubble.right.fill" + + /// 􀪨 + case arrowUpAndPersonRectanglePortrait = "arrow.up.and.person.rectangle.portrait" /// 􀌫 case bubbleLeftFill = "bubble.left.fill" diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index ec24618e0..7225195ed 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -779,6 +779,7 @@ class SettingValues { case READ_LATER = "readlater" case SHARE_CONTENT = "sharecontent" case SHARE_REDDIT = "sharereddit" + case SHARE_AUTHOR = "shareauthor" case CHROME = "openchrome" case SAFARI = "opensafari" case FILTER = "filter" @@ -816,7 +817,7 @@ class SettingValues { } public static func getMenuNone() -> [PostOverflowAction] { - let menu = UserDefaults.standard.stringArray(forKey: "postMenu") ?? ["profile", "sub", "moderate", "report", "block", "save", "crosspost", "readlater", "sharecontent", "sharereddit", "openchrome", "opensafari", "filter", "copy", "hide"] + let menu = UserDefaults.standard.stringArray(forKey: "postMenu") ?? ["profile", "sub", "moderate", "report", "block", "save", "crosspost", "readlater", "sharecontent", "sharereddit", "shareauthor", "openchrome", "opensafari", "filter", "copy", "hide"] var toReturn = [PostOverflowAction]() for item in menu { toReturn.append(PostOverflowAction(rawValue: item)!) @@ -858,6 +859,8 @@ class SettingValues { return "Share content link" case .SHARE_REDDIT: return "Share reddit link" + case .SHARE_AUTHOR: + return "Share author profile" case .CHROME: return "Open in Chrome" case .SAFARI: @@ -902,6 +905,8 @@ class SettingValues { return UIImage(sfString: SFSymbol.squareAndArrowUp, overrideString: "share")!.menuIcon() case .SHARE_REDDIT: return UIImage(sfString: SFSymbol.bubbleLeftAndBubbleRightFill, overrideString: "comments")!.menuIcon() + case .SHARE_AUTHOR: + return UIImage(sfString: SFSymbol.arrowUpAndPersonRectanglePortrait, overrideString: "share")!.menuIcon() case .CHROME: return UIImage(sfString: SFSymbol.link, overrideString: "link")!.menuIcon() case .SAFARI: diff --git a/Slide for Reddit/SettingsContentFilters.swift b/Slide for Reddit/SettingsContentFilters.swift index 6cbaa2398..47a73271d 100644 --- a/Slide for Reddit/SettingsContentFilters.swift +++ b/Slide for Reddit/SettingsContentFilters.swift @@ -140,7 +140,8 @@ class SettingsContentFilters: BubbleSettingTableViewController, UISearchBarDeleg self.view.backgroundColor = UIColor.backgroundColor // set the title - self.title = "Filters" + self.navigationItem.titleView = setTitle(title: "Content Filters", subtitle: "Tip: you can use Regex in filter fields") + self.headers = ["Submission domain filters", "Submission body text filters", "Submission title filters", "Submission author filters", "Subreddit filters", "Submission flair filters"] setupSearchBar(domainEnter, "Add new domain filter") diff --git a/Slide for Reddit/SettingsViewController.swift b/Slide for Reddit/SettingsViewController.swift index 8b90a5fc9..c473629fd 100644 --- a/Slide for Reddit/SettingsViewController.swift +++ b/Slide for Reddit/SettingsViewController.swift @@ -374,7 +374,7 @@ class SettingsViewController: MediaTableViewController, MFMailComposeViewControl self.subCell.imageView?.image = UIImage(sfString: .rCircleFill, overrideString: "subs")?.toolbarIcon() self.subCell.imageView?.tintColor = UIColor.fontColor - self.filters.textLabel?.text = "Filters" + self.filters.textLabel?.text = "Content Filters" self.filters.accessoryType = .disclosureIndicator self.filters.backgroundColor = UIColor.foregroundColor self.filters.textLabel?.textColor = UIColor.fontColor From 2cd9166defff52b5ddc44302c9e754fb6dd46a27 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 18:24:23 -0500 Subject: [PATCH 38/46] Update pods, Add options to show awards in comments and show profile images in comments --- .../CommentModel+CoreDataProperties.swift | 1 + .../Reddit.xcdatamodel/contents | 5 +- Podfile.lock | 32 ++--- Slide for Reddit/CommentDepthCell.swift | 133 +++++++++++++++++- .../RedditObjects/CommentObject.swift | 4 + Slide for Reddit/SettingValues.swift | 6 + Slide for Reddit/SettingsComments.swift | 41 ++++-- 7 files changed, 188 insertions(+), 34 deletions(-) diff --git a/CoreData_Models/CommentModel+CoreDataProperties.swift b/CoreData_Models/CommentModel+CoreDataProperties.swift index 4a7f6e717..bb59d53aa 100644 --- a/CoreData_Models/CommentModel+CoreDataProperties.swift +++ b/CoreData_Models/CommentModel+CoreDataProperties.swift @@ -18,6 +18,7 @@ extension CommentModel { @NSManaged public var approvedBy: String? @NSManaged public var author: String + @NSManaged public var authorProfileImage: String? @NSManaged public var awardsJSON: String? @NSManaged public var controversality: Int64 @NSManaged public var created: Date diff --git a/CoreData_Models/Reddit.xcdatamodeld/Reddit.xcdatamodel/contents b/CoreData_Models/Reddit.xcdatamodeld/Reddit.xcdatamodel/contents index 9dc813230..d00fb1330 100644 --- a/CoreData_Models/Reddit.xcdatamodeld/Reddit.xcdatamodel/contents +++ b/CoreData_Models/Reddit.xcdatamodeld/Reddit.xcdatamodel/contents @@ -1,8 +1,9 @@ - + + @@ -150,7 +151,7 @@ - + diff --git a/Podfile.lock b/Podfile.lock index 7286f302d..be601ea76 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -18,24 +18,24 @@ PODS: - DTFoundation/Core - HTMLSpecialCharacters (1.3.6) - LicensesViewController (0.7.0) - - MaterialComponents/ActivityIndicator (119.5.0): + - MaterialComponents/ActivityIndicator (124.1.1): - MaterialComponents/Palettes - MaterialComponents/private/Application - MDFInternationalization - - MotionAnimator (~> 2.0) - - MaterialComponents/Palettes (119.5.0) - - MaterialComponents/private/Application (119.5.0) - - MaterialComponents/private/Math (119.5.0) - - MaterialComponents/ProgressView (119.5.0): + - MotionAnimator (~> 4.0) + - MaterialComponents/Palettes (124.1.1) + - MaterialComponents/private/Application (124.1.1) + - MaterialComponents/private/Math (124.1.1) + - MaterialComponents/ProgressView (124.1.1): - MaterialComponents/Palettes - MaterialComponents/private/Math - MDFInternationalization - MDFInternationalization (2.0.0) - MiniKeychain (1.0.8) - MKColorPicker (1.2) - - MotionAnimator (2.8.1): - - MotionInterchange (~> 1.6) - - MotionInterchange (1.6.0) + - MotionAnimator (4.0.1): + - MotionInterchange (~> 3.0) + - MotionInterchange (3.0.0) - MTColorDistance (0.0.3) - OpalImagePicker (3.0.0) - QuickLayout (3.0.0) @@ -48,7 +48,7 @@ PODS: - SwiftEntryKit (1.2.1): - QuickLayout (= 3.0.0) - SwiftLinkPreview (3.0.1) - - SwiftLint (0.42.0) + - SwiftLint (0.43.1) - SwiftyJSON (5.0.0) - TGPControls (5.1.0) - YoutubePlayer-in-WKWebView (0.3.5) @@ -110,13 +110,13 @@ EXTERNAL SOURCES: CHECKOUT OPTIONS: DTCoreText: - :commit: 24823e50ec7496b80bd9dd346459136511cfa9d5 + :commit: c4cb9c9aa8bf245bcbf270335f02ac440a3f72a3 :git: https://github.com/Cocoanetics/DTCoreText MKColorPicker: :commit: e76cd225ff60f12f8ec0052e39e5e307a32c0762 :git: https://github.com/ccrama/MKColorPicker reddift: - :commit: 79d54d0d00a3b888f766d413ef4a191c4e4c99f7 + :commit: bb77a789b94731d0291f1a673f343cbcab13e02c :git: https://github.com/ccrama/reddift RLBAlertsPickers: :commit: a22003f93a803c2e14b193f636669c21358fb1d7 @@ -136,12 +136,12 @@ SPEC CHECKSUMS: DTFoundation: e7781d9fd2f202bfd451fbbf8cab71ce83b46498 HTMLSpecialCharacters: edc707cc4bcdc92eb3b9551de8cff94c1e6f9a19 LicensesViewController: 2f7bba13b3cec7516d4990e41df297720fdbaaab - MaterialComponents: 2cdc12c16528ed7e6f1d5bd6d6927c47f9f4e90f + MaterialComponents: b9f58f24bf74588a83b2dce05802a11aaed5257d MDFInternationalization: 010097556d6b09d2c4ea38e0820ea6d37be6a314 MiniKeychain: 5d424fcd50fb8ab4cc946db2c3415dc391ffffdc MKColorPicker: 8998b2ab977e4f240fdf254db27a18b810da3cfc - MotionAnimator: ee16aa30567c5bae0fb2750c132915829cfaaf8a - MotionInterchange: ead0e3ae1f3a5fb539e289debbc7ae036160a10d + MotionAnimator: 5f99d7c9592928c0f28a66283eda9c3b657dc480 + MotionInterchange: 13adae439b377e31d1674cc165539d50e1d1566a MTColorDistance: 5ab8708eb88bc22d4d88e309d09eb912f3a6e27b OpalImagePicker: 38e772dd93a54431fc516b33e1f337c50f745834 QuickLayout: 07b45a72b10083fee3f095990cfed1c1e7b27f0a @@ -151,7 +151,7 @@ SPEC CHECKSUMS: SubtleVolume: 101038d203018736bcd1df3ac95bcc0f6b8640ce SwiftEntryKit: 1661b766dd22b07679e6ebb326ccfbd81ceb0a20 SwiftLinkPreview: 7524438c43bf63a5041615713777c3d8f19a9a31 - SwiftLint: 4fa9579c63416865179bc416f0a92d55f009600d + SwiftLint: 99f82d07b837b942dd563c668de129a03fc3fb52 SwiftyJSON: f0574c07d8ca1644050db687067209e3033a89a0 TGPControls: 52c0770bee9c9aee364f1559cc627fc01ea5e8b2 YoutubePlayer-in-WKWebView: cfbf46da51d7370662a695a8f351e5fa1d3e1008 diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index d38f29dc7..c3e641c77 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -1883,6 +1883,64 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat flairString = flairTitle } } + + var awardString: NSMutableAttributedString? + if !SettingValues.hideAwards { + let to = 3 + if !comment.awardsDictionary.keys.isEmpty { + var awardCount = 0 + let awardDict = comment.awardsDictionary + + let values = awardDict.values + let sortedValues = values.sorted { (a, b) -> Bool in + let amountA = Int((a as? [String])?[4] ?? "0") ?? 0 + let amountB = Int((b as? [String])?[4] ?? "0") ?? 0 + + return amountA > amountB + } + for raw in sortedValues { + if let award = raw as? [String] { + awardCount += Int(award[2]) ?? 0 + } + } + + var totalAwards = 0 + var attachments = [NSTextAttachment]() + + for raw in sortedValues { + if let award = raw as? [String] { + if totalAwards == to { + break + } + + totalAwards += 1 + + let url = award[1] + if let urlAsURL = URL(string: url) { + let attachment = AsyncTextAttachmentNoLoad(imageURL: urlAsURL, delegate: nil, rounded: false, backgroundColor: UIColor.foregroundColor) + attachment.bounds = CGRect(x: 0, y: -2 + (15 * -0.5) / 2, width: 15, height: 15) + attachments.append(attachment) + } + } + } + + let awardLine = NSMutableAttributedString(string: "\n", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 10), NSAttributedString.Key.foregroundColor: UIColor.foregroundColor]) + + for award in attachments { + awardLine.append(NSAttributedString(attachment: award)) + awardLine.appendString(" ") + } + + if totalAwards == to { + awardLine.append(NSMutableAttributedString(string: "\(awardCount) Awards", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 10), NSAttributedString.Key.foregroundColor: UIColor.fontColor, .baselineOffset: -2])) + } + + awardLine.addAttributes([.urlAction: URL(string: CachedTitle.AWARD_KEY)!], range: NSRange(location: 2, length: awardLine.length - 2)) // We will catch this URL later on, start it after the newline + + awardString = awardLine + awardString?.append(NSAttributedString(string: "\u{00A0}")) // Stop tap from going to the end of the view width + } + } let pinned = NSMutableAttributedString.init(string: "\u{00A0}PINNED\u{00A0}", attributes: [NSAttributedString.Key.font: FontGenerator.boldFontOfSize(size: 12, submission: false), .badgeColor: GMColor.green500Color(), NSAttributedString.Key.foregroundColor: UIColor.white]) @@ -1933,13 +1991,6 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat infoString.append(spacer) infoString.append(pinned) } - - // TODO flairs and awards - /*if comment.isCakeday { - infoString.append(spacer) - let gild = NSMutableAttributedString.yy_attachmentString(withEmojiImage: UIImage(named: "cakeday")!, fontSize: boldFont.pointSize)! - infoString.append(gild) - }*/ if parent!.removed.contains(comment.id) || (!(comment.removedBy ?? "").isEmpty() && !parent!.approved.contains(comment.id)) { let attrs = [NSAttributedString.Key.font: FontGenerator.boldFontOfSize(size: 12, submission: false), NSAttributedString.Key.foregroundColor: GMColor.red500Color()] @@ -1955,9 +2006,22 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat infoString.append(NSMutableAttributedString.init(string: "Approved\(!(comment.approvedBy ?? "").isEmpty() ? " by \(comment.approvedBy!)":"")", attributes: attrs)) } + if let awards = awardString { + infoString.append(awards) + } + paragraphStyle.lineSpacing = 1.5 // infoString.setAttributes([NSAttributedString.Key.paragraphStyle: paragraphStyle], range: NSRange(location: 0, length: infoString.length)) + if SettingValues.showProfileImagesComments && comment.authorProfileImage != nil { + if let urlAsURL = URL(string: comment.authorProfileImage?.unescapeHTML ?? "") { + let attachment = AsyncTextAttachmentNoLoad(imageURL: urlAsURL, delegate: nil, rounded: true, backgroundColor: color) + attachment.bounds = CGRect(x: -2, y: -2, width: boldFont.pointSize + 4, height: boldFont.pointSize + 4) + infoString.insert(NSAttributedString(string: " "), at: 0) + infoString.insert(NSAttributedString(attachment: attachment), at: 0) + } + } + commentBody.tColor = ColorUtil.accentColorForSub(sub: comment.subreddit) if !isCollapsed || !SettingValues.collapseFully { title.linkTextAttributes = [NSAttributedString.Key.foregroundColor: ColorUtil.accentColorForSub(sub: comment.subreddit)] @@ -2094,8 +2158,58 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat } extension CommentDepthCell: TextDisplayStackViewDelegate { + func showAwardMenu() { + guard let comment = comment else { return } + let awardDict = comment.awardsDictionary + + let alertController = DragDownAlertMenu(title: "Comment awards", subtitle: "", icon: nil) + var coinTotal = 0 + + let sortedValues = awardDict.values.sorted { (a, b) -> Bool in + let amountA = Int((a as? [String])?[4] ?? "0") ?? 0 + let amountB = Int((b as? [String])?[4] ?? "0") ?? 0 + + return amountA > amountB + } + + for raw in sortedValues { + if let award = raw as? [String] { + coinTotal += Int(award[4]) ?? 0 + alertController.addView(title: "\(award[0]) x\(award[2])", icon_url: award[5], action: {() in + let alertController = DragDownAlertMenu(title: award[0], subtitle: award[3], icon: award[5]) + alertController.modalPresentationStyle = .overCurrentContext + if let window = UIApplication.shared.keyWindow, let modalVC = window.rootViewController?.presentedViewController { + if let presented = modalVC.presentedViewController { + alertController.show(presented) + } else { + alertController.show(modalVC) + } + } else if let window = UIApplication.shared.keyWindow, let root = window.rootViewController { + alertController.show(root) + } + }) + } + } + + alertController.subtitle = "\(coinTotal) coins spent" + + if #available(iOS 10.0, *) { + HapticUtility.hapticActionStrong() + } else if SettingValues.hapticFeedback { + AudioServicesPlaySystemSound(1519) + } + if let parent = parent { + alertController.show(parent) + } + } + func linkTapped(url: URL, text: String) { islink = true + if url.absoluteString == CachedTitle.AWARD_KEY { + showAwardMenu() + return + } + if !text.isEmpty { self.parent?.showSpoiler(text) } else { @@ -2106,6 +2220,11 @@ extension CommentDepthCell: TextDisplayStackViewDelegate { func linkLongTapped(url: URL) { longBlocking = true + if url.absoluteString == CachedTitle.AWARD_KEY { + showAwardMenu() + return + } + let alertController = DragDownAlertMenu(title: "Link options", subtitle: url.absoluteString, icon: url.absoluteString) alertController.addAction(title: "Share URL", icon: UIImage(sfString: SFSymbol.squareAndArrowUp, overrideString: "share")!.menuIcon()) { diff --git a/Slide for Reddit/RedditObjects/CommentObject.swift b/Slide for Reddit/RedditObjects/CommentObject.swift index cb0b0f508..52f9880e7 100644 --- a/Slide for Reddit/RedditObjects/CommentObject.swift +++ b/Slide for Reddit/RedditObjects/CommentObject.swift @@ -46,6 +46,7 @@ class CommentObject: RedditObject { public var scoreHidden: Bool = false public var submissionTitle: String = "" public var subreddit: String = "" + public var authorProfileImage: String? public var voteDirection: Bool = false static func thingToCommentOrMore(thing: Thing, depth: Int) -> RedditObject? { @@ -97,6 +98,7 @@ class CommentObject: RedditObject { self.parentID = model.parentID self.permalink = model.permalink self.removalNote = model.removalNote + self.authorProfileImage = model.authorProfileImage self.removalReason = model.removalReason self.removedBy = model.removedBy @@ -120,6 +122,7 @@ class CommentObject: RedditObject { self.isSaved = comment.saved self.markdownBody = comment.body self.removalReason = comment.baseJson["ban_note"] as? String ?? "" + self.authorProfileImage = comment.baseJson["profile_img"] as? String self.removalNote = comment.baseJson["mod_note"] as? String ?? "" self.removedBy = comment.baseJson["banned_by"] as? String ?? "" self.isRemoved = !(self.removedBy ?? "").isEmpty() @@ -257,6 +260,7 @@ extension CommentObject: Cacheable { commentModel.approvedBy = self.approvedBy commentModel.author = self.author + commentModel.authorProfileImage = self.authorProfileImage commentModel.awardsJSON = self.awardsJSON commentModel.controversality = Int64(self.controversality) commentModel.created = self.created diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 7225195ed..92ad69680 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -135,6 +135,8 @@ class SettingValues { public static let pref_commentLimit = "COMMENT_LIMIT" public static let pref_submissionLimit = "SUBMISSION_LIMIT" public static let pref_hideAwards = "HIDE_AWARDS_v2" + public static let pref_hideAwardsComments = "HIDE_AWARDS_COMMENTS_V2" + public static let pref_showProfileImagesComments = "SHOW_PROFILE_IMAGES_COMMENTS" public static let pref_subredditIcons = "SUBREDDIT_ICONS" public static let pref_streamVideos = "STREAM_VIDEOS" public static let pref_fullWidthHeaderCells = "FULL_WIDTH_HEADER_CELLS" @@ -284,6 +286,7 @@ class SettingValues { public static var disable13Popup = true public static var thumbTag = true public static var hideAwards = false + public static var hideAwardsComments = false public static var streamVideos = true public static var fullWidthHeaderCells = false public static var disablePopupIpad = false @@ -296,6 +299,7 @@ class SettingValues { public static var desktopMode = false public static var tapExitMedia = true public static var tapProfilesAndSubs = false + public static var showProfileImagesComments = false public static var commentLimit = 95 public static var submissionLimit = 13 @@ -644,6 +648,8 @@ class SettingValues { SettingValues.disableBanner = settings.bool(forKey: SettingValues.pref_disableBanner) SettingValues.newIndicator = settings.bool(forKey: SettingValues.pref_newIndicator) SettingValues.hideAwards = settings.bool(forKey: SettingValues.pref_hideAwards) + SettingValues.hideAwardsComments = settings.object(forKey: SettingValues.pref_hideAwardsComments) == nil ? true : settings.bool(forKey: SettingValues.pref_hideAwardsComments) + SettingValues.showProfileImagesComments = settings.bool(forKey: SettingValues.pref_showProfileImagesComments) SettingValues.dataSavingEnabled = settings.bool(forKey: SettingValues.pref_dataSavingEnabled) SettingValues.dataSavingDisableWiFi = settings.bool(forKey: SettingValues.pref_dataSavingDisableWifi) diff --git a/Slide for Reddit/SettingsComments.swift b/Slide for Reddit/SettingsComments.swift index bb22c5eac..421a9d05f 100644 --- a/Slide for Reddit/SettingsComments.swift +++ b/Slide for Reddit/SettingsComments.swift @@ -24,6 +24,16 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat var wideIndicator = UISwitch().then { $0.onTintColor = ColorUtil.baseAccent } + + var showAwardsCell: UITableViewCell = InsetCell() + var showAwards = UISwitch().then { + $0.onTintColor = ColorUtil.baseAccent + } + + var showProfilesCell: UITableViewCell = InsetCell(style: .subtitle, reuseIdentifier: "profile") + var showProfiles = UISwitch().then { + $0.onTintColor = ColorUtil.baseAccent + } var floatingJumpCell: UITableViewCell = InsetCell(style: .subtitle, reuseIdentifier: "jump") @@ -279,7 +289,13 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat self.view.backgroundColor = UIColor.backgroundColor // set the title self.title = "Comments settings" - self.headers = ["Comments page", "Comment display", "Comment interaction"] + self.headers = ["Profiles and Awards", "Comments page", "Comment display", "Comment interaction"] + + createCell(showAwardsCell, showAwards, isOn: !SettingValues.hideAwardsComments, text: "Show comment awards line") + createCell(showProfilesCell, showProfiles, isOn: SettingValues.showProfileImagesComments, text: "Show profile images") + showProfilesCell.detailTextLabel?.textColor = UIColor.fontColor + showProfilesCell.detailTextLabel?.numberOfLines = 0 + showProfilesCell.detailTextLabel?.text = "Experimental" createCell(disableNavigationBarCell, disableNavigationBar, isOn: SettingValues.disableNavigationBar, text: "Disable comment navigation toolbar") createCell(fullscreenImageCell, fullscreenImage, isOn: !SettingValues.commentFullScreen, text: "Crop the lead banner image") @@ -348,26 +364,32 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { switch indexPath.section { case 0: + switch indexPath.row { + case 0: return self.showAwardsCell + case 1: return self.showProfilesCell + default: fatalError("Unkown row in section 0") + } + case 1: switch indexPath.row { case 0: return self.fullscreenImageCell case 1: return self.hideAutomodCell case 2: return self.floatingJumpCell - default: fatalError("Unkown row in section 0") + default: fatalError("Unkown row in section 1") } - case 1: + case 2: switch indexPath.row { case 0: return self.authorThemeCell case 1: return self.themeColorCell case 2: return self.wideIndicatorCell case 3: return self.highlightOpCell - default: fatalError("Unknown row in section 1") + default: fatalError("Unknown row in section 2") } - case 2: + case 3: switch indexPath.row { case 0: return self.collapseDefaultCell case 1: return self.collapseFullyCell case 2: return self.swapLongPressCell - default: fatalError("Unknown row in section 2") + default: fatalError("Unknown row in section 3") } default: fatalError("Unknown section") } @@ -376,9 +398,10 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { switch section { - case 0: return 3 - case 1: return 4 - case 2: return 3 + case 0: return 2 + case 1: return 3 + case 2: return 4 + case 3: return 3 default: fatalError("Unknown number of sections") } } From eabf7b1cfd4af0cef1c533cf006e38218ad34ac6 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 18:37:58 -0500 Subject: [PATCH 39/46] Bug fixes --- Slide for Reddit/CommentDepthCell.swift | 2 +- Slide for Reddit/SettingsComments.swift | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index c3e641c77..e89ad5e47 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -1885,7 +1885,7 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat } var awardString: NSMutableAttributedString? - if !SettingValues.hideAwards { + if !SettingValues.hideAwardsComments { let to = 3 if !comment.awardsDictionary.keys.isEmpty { var awardCount = 0 diff --git a/Slide for Reddit/SettingsComments.swift b/Slide for Reddit/SettingsComments.swift index 421a9d05f..922f9a408 100644 --- a/Slide for Reddit/SettingsComments.swift +++ b/Slide for Reddit/SettingsComments.swift @@ -25,8 +25,8 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat $0.onTintColor = ColorUtil.baseAccent } - var showAwardsCell: UITableViewCell = InsetCell() - var showAwards = UISwitch().then { + var hideAwardsCell: UITableViewCell = InsetCell() + var hideAwards = UISwitch().then { $0.onTintColor = ColorUtil.baseAccent } @@ -74,6 +74,12 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat } else if changed == wideIndicator { SettingValues.wideIndicators = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_widerIndicators) + } else if changed == hideAwards { + SettingValues.hideAwards = changed.isOn + UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_hideAwardsComments) + } else if changed == showProfiles { + SettingValues.showProfileImagesComments = changed.isOn + UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_showProfileImagesComments) } else if changed == hideAutomod { SettingValues.hideAutomod = changed.isOn UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_hideAutomod) @@ -103,11 +109,11 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) - if indexPath.section == 1 && indexPath.row == 0 { + if indexPath.section == 2 && indexPath.row == 0 { showAuthorChooser() - } else if indexPath.section == 1 && indexPath.row == 1 { + } else if indexPath.section == 2 && indexPath.row == 1 { showDepthChooser() - } else if indexPath.section == 0 && indexPath.row == 2 { + } else if indexPath.section == 1 && indexPath.row == 2 { showJumpChooser() } } @@ -291,7 +297,7 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat self.title = "Comments settings" self.headers = ["Profiles and Awards", "Comments page", "Comment display", "Comment interaction"] - createCell(showAwardsCell, showAwards, isOn: !SettingValues.hideAwardsComments, text: "Show comment awards line") + createCell(hideAwardsCell, hideAwards, isOn: SettingValues.hideAwardsComments, text: "Hide Reddit awards") createCell(showProfilesCell, showProfiles, isOn: SettingValues.showProfileImagesComments, text: "Show profile images") showProfilesCell.detailTextLabel?.textColor = UIColor.fontColor showProfilesCell.detailTextLabel?.numberOfLines = 0 @@ -365,7 +371,7 @@ class SettingsComments: BubbleSettingTableViewController, ColorPickerViewDelegat switch indexPath.section { case 0: switch indexPath.row { - case 0: return self.showAwardsCell + case 0: return self.hideAwardsCell case 1: return self.showProfilesCell default: fatalError("Unkown row in section 0") } From ae6d595adc8f1f0c440ab3b71c2d8ea2c2217063 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 18:39:19 -0500 Subject: [PATCH 40/46] Update build number for 7.1, Disable Mac Catalyst build until further testing can be done --- Slide for Reddit.xcodeproj/project.pbxproj | 58 +++++++++++----------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index 3978313fb..0d7ba0f08 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -2810,7 +2810,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2820,7 +2820,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).WidgetConfigIntent"; @@ -2844,7 +2844,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2854,7 +2854,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.bundledwidgetconfigintent; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2880,7 +2880,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2890,7 +2890,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).watchkitapp"; @@ -2921,7 +2921,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2931,7 +2931,7 @@ "@executable_path/../Frameworks", "@loader_path/../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.watchkitapp; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2955,7 +2955,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2964,7 +2964,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).watchkitapp.watchkitextension"; @@ -2988,7 +2988,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2997,7 +2997,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.watchkitapp.watchkitextension; PRODUCT_NAME = "${TARGET_NAME}"; @@ -3023,7 +3023,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3033,7 +3033,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).Open-in-Slide"; @@ -3057,7 +3057,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3067,7 +3067,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "ccrama.me.redditslide.bundledOpen-in-Slide"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -3213,17 +3213,16 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; OTHER_LDFLAGS = ( "$(inherited)", "-framework", @@ -3233,7 +3232,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; @@ -3241,7 +3240,7 @@ "SWIFT_OPTIMIZATION_LEVEL[arch=*]" = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2,6"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -3256,18 +3255,17 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.2; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; OTHER_LDFLAGS = ( "$(inherited)", "-framework", @@ -3277,13 +3275,13 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER)"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "match Development ccrama.me.redditslide"; - SUPPORTS_MACCATALYST = YES; + SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES; SWIFT_ENABLE_BATCH_MODE = NO; SWIFT_OBJC_BRIDGING_HEADER = "Slide for Reddit/Slide for Reddit-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2,6"; + TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; @@ -3438,7 +3436,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3448,7 +3446,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = "$(USR_BASE_IDENTIFIER).widgets"; @@ -3474,7 +3472,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 220; + CURRENT_PROJECT_VERSION = 221; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3484,7 +3482,7 @@ "@executable_path/Frameworks", "@executable_path/../../Frameworks", ); - MARKETING_VERSION = 7.0.2; + MARKETING_VERSION = 7.1; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = ccrama.me.redditslide.bundledwidgets; PRODUCT_NAME = "$(TARGET_NAME)"; From 962f7decc82435398aecf84e834a778c1edab95a Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 19:06:58 -0500 Subject: [PATCH 41/46] Disable new MacOS features until next update --- .../xcschemes/Slide for Apple Watch.xcscheme | 25 ++++++++++++++----- Slide for Reddit/CommentDepthCell.swift | 4 +-- Slide for Reddit/LinkCellView.swift | 2 +- Slide for Reddit/SettingValues.swift | 2 +- Slide for Reddit/SettingsViewMode.swift | 6 ++--- .../SingleSubredditViewController.swift | 2 +- .../SplitMainViewController.swift | 4 +-- .../SwipeForwardNavigationController.swift | 2 +- .../UIApplication+Extensions.swift | 13 +++++++++- Slide for Reddit/WrappingFlowLayout.swift | 4 +-- 10 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme index 0530f2df2..0d084ded0 100644 --- a/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme +++ b/Slide for Reddit.xcodeproj/xcshareddata/xcschemes/Slide for Apple Watch.xcscheme @@ -65,8 +65,10 @@ debugServiceExtension = "internal" allowLocationSimulation = "YES" notificationPayloadFile = "Slide for Apple Watch Extension/PushNotificationPayload.apns"> - + - + - + - + + + + + diff --git a/Slide for Reddit/CommentDepthCell.swift b/Slide for Reddit/CommentDepthCell.swift index e89ad5e47..e3d53629d 100644 --- a/Slide for Reddit/CommentDepthCell.swift +++ b/Slide for Reddit/CommentDepthCell.swift @@ -747,7 +747,7 @@ class CommentDepthCell: MarginedTableViewCell, UIViewControllerPreviewingDelegat removedSubviews.forEach({ $0.removeFromSuperview() }) - if UIDevice.current.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMac()) { + if UIDevice.current.respectIpadLayout() && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMacReal()) { menu.addArrangedSubviews(flexSpace(), flexSpace(), flexSpace(), editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) } else { menu.addArrangedSubviews(editButton, deleteButton, upvoteButton, downvoteButton, replyButton, moreButton, modButton) @@ -2631,7 +2631,7 @@ extension CommentDepthCell: UIContextMenuInteractionDelegate { } } - if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMacReal() { if self.parent?.menuCell == self { if let parent = self.parent { let menu = self.getMoreMenu(parent) diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index 02bb68b4a..18ec66803 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -3362,7 +3362,7 @@ extension LinkCellView: UIContextMenuInteractionDelegate { }) } - if UIDevice.current.respectIpadLayout() || UIDevice.current.isMac() { + if UIDevice.current.respectIpadLayout() || UIDevice.current.isMacReal() { return UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: { _ in return self.del?.getMoreMenu(self) }) diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 92ad69680..814539959 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -543,7 +543,7 @@ class SettingValues { } SettingValues.desktopMode = settings.object(forKey: SettingValues.pref_desktopMode) == nil ? UIDevice.current.isMac() : settings.bool(forKey: SettingValues.pref_desktopMode) - SettingValues.desktopMode = SettingValues.desktopMode && (UIDevice.current.respectIpadLayout() || UIDevice.current.isMac()) // Only enable this on Mac or iPad + SettingValues.desktopMode = SettingValues.desktopMode && (UIDevice.current.respectIpadLayout() || UIDevice.current.isMacReal()) // Only enable this on Mac or iPad SettingValues.scrollSidebar = settings.object(forKey: SettingValues.pref_scrollSidebar) == nil ? true : settings.bool(forKey: SettingValues.pref_scrollSidebar) diff --git a/Slide for Reddit/SettingsViewMode.swift b/Slide for Reddit/SettingsViewMode.swift index 8fbab3926..e4165a202 100644 --- a/Slide for Reddit/SettingsViewMode.swift +++ b/Slide for Reddit/SettingsViewMode.swift @@ -101,9 +101,9 @@ class SettingsViewMode: BubbleSettingTableViewController { createCell(disablePopupSubreddit, disablePopupSubredditSwitch, isOn: SettingValues.disableSubredditPopupIpad, text: "Show subreddits full screen") createCell(disablePopup, disablePopupSwitch, isOn: SettingValues.disablePopupIpad, text: "Show comments full screen") createCell(disableMulticolumn, disableMulticolumnSwitch, isOn: !SettingValues.disableMulticolumnCollections, text: "Multi-column in profile and inbox") - createCell(singleMode, isOn: false, text: "Single-column posts\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") - createCell(multicolumnMode, isOn: false, text: "Multi-column posts\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") - createCell(splitMode, isOn: false, text: "Split-content\(UIDevice.current.isMac() ? "(designed for iPad)" : "")") + createCell(singleMode, isOn: false, text: "Single-column posts\(UIDevice.current.isMacReal() ? "(designed for iPad)" : "")") + createCell(multicolumnMode, isOn: false, text: "Multi-column posts\(UIDevice.current.isMacReal() ? "(designed for iPad)" : "")") + createCell(splitMode, isOn: false, text: "Split-content\(UIDevice.current.isMacReal() ? "(designed for iPad)" : "")") createCell(tripleMode, isOn: false, text: "Triple-pane Multi-column\(UIDevice.current.isMac() ? "(designed for MacOS)" : "")") createCell(multicolumnCount, isOn: false, text: "Multi-column count (Pro)") createCell(multicolumnPortraitCount, isOn: false, text: "Portrait Multi-column count (Pro)") diff --git a/Slide for Reddit/SingleSubredditViewController.swift b/Slide for Reddit/SingleSubredditViewController.swift index 025bda30b..a758a2b93 100644 --- a/Slide for Reddit/SingleSubredditViewController.swift +++ b/Slide for Reddit/SingleSubredditViewController.swift @@ -212,7 +212,7 @@ class SingleSubredditViewController: MediaViewController, AutoplayScrollViewDele super.viewDidLoad() CachedTitle.titles.removeAll() - if UIDevice.current.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMac()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { + if UIDevice.current.respectIpadLayout() && SettingValues.appMode == .SPLIT && (!UIApplication.shared.isSplitOrSlideOver || UIDevice.current.isMacReal()) && !(splitViewController?.viewControllers[(splitViewController?.viewControllers.count ?? 1) - 1] is PlaceholderViewController) { splitViewController?.showDetailViewController(SwipeForwardNavigationController(rootViewController: PlaceholderViewController()), sender: self) } diff --git a/Slide for Reddit/SplitMainViewController.swift b/Slide for Reddit/SplitMainViewController.swift index ba7593bdb..d18597acc 100644 --- a/Slide for Reddit/SplitMainViewController.swift +++ b/Slide for Reddit/SplitMainViewController.swift @@ -1074,7 +1074,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac())) && UIDevice.current.respectIpadLayout() { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMacReal())) && UIDevice.current.respectIpadLayout() { is14Column = true } @@ -1114,7 +1114,7 @@ extension SplitMainViewController: NavigationHomeDelegate { } } else { var is14Column = false - if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac())) && UIDevice.current.respectIpadLayout() { + if #available(iOS 14, *), (SettingValues.appMode == .SPLIT || (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMacReal())) && UIDevice.current.respectIpadLayout() { is14Column = true } diff --git a/Slide for Reddit/SwipeForwardNavigationController.swift b/Slide for Reddit/SwipeForwardNavigationController.swift index 9fd0febf9..00693a54e 100644 --- a/Slide for Reddit/SwipeForwardNavigationController.swift +++ b/Slide for Reddit/SwipeForwardNavigationController.swift @@ -264,7 +264,7 @@ extension SwipeForwardNavigationController { let pushedViewController = pushableViewControllers.last if pushedViewController != nil && visibleViewController != nil && visibleViewController?.isBeingPresented == false && visibleViewController?.isBeingDismissed == false { - push(pushedViewController, animated: (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMac()) ? false : true) { + push(pushedViewController, animated: (UIApplication.shared.isSplitOrSlideOver && !UIDevice.current.isMacReal()) ? false : true) { if !self.pushableViewControllers.isEmpty { self.pushableViewControllers.removeLast() callback?() diff --git a/Slide for Reddit/UIApplication+Extensions.swift b/Slide for Reddit/UIApplication+Extensions.swift index b8ef7bab5..b2cdada0f 100644 --- a/Slide for Reddit/UIApplication+Extensions.swift +++ b/Slide for Reddit/UIApplication+Extensions.swift @@ -17,6 +17,7 @@ extension UIApplication { extension UIDevice { public func isMac() -> Bool { + return false //Disable new Mac features for now if #available(iOS 14.0, *) { return ProcessInfo.processInfo.isiOSAppOnMac || ProcessInfo.processInfo.isMacCatalystApp } else if #available(iOS 13.0, *) { @@ -26,8 +27,18 @@ extension UIDevice { } } + public func isMacReal() -> Bool { + if #available(iOS 14.0, *) { + return ProcessInfo.processInfo.isiOSAppOnMac || ProcessInfo.processInfo.isMacCatalystApp + } else if #available(iOS 13.0, *) { + return ProcessInfo.processInfo.isMacCatalystApp + } else { + return false + } + } + public func respectIpadLayout() -> Bool { - return UIDevice.current.userInterfaceIdiom == .pad || isMac() + return UIDevice.current.userInterfaceIdiom == .pad || isMacReal() } } extension UIApplication { diff --git a/Slide for Reddit/WrappingFlowLayout.swift b/Slide for Reddit/WrappingFlowLayout.swift index 37c3fdc75..ad7b7a8f4 100644 --- a/Slide for Reddit/WrappingFlowLayout.swift +++ b/Slide for Reddit/WrappingFlowLayout.swift @@ -51,7 +51,7 @@ class WrappingFlowLayout: UICollectionViewLayout { let pad = UIDevice.current.respectIpadLayout() if SettingValues.appMode == .MULTI_COLUMN || SettingValues.appMode == .TRIPLE_MULTI_COLUMN { - if (UIApplication.shared.statusBarOrientation.isPortrait && !UIDevice.current.isMac()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { + if (UIApplication.shared.statusBarOrientation.isPortrait && !UIDevice.current.isMacReal()) || (vc.presentingViewController != nil && (vc.modalPresentationStyle == .pageSheet || vc.modalPresentationStyle == .fullScreen)) { if !pad { numberOfColumns = SettingValues.portraitMultiColumnCount } else { @@ -68,7 +68,7 @@ class WrappingFlowLayout: UICollectionViewLayout { numberOfColumns = 1 } - if !UIDevice.current.isMac() { + if !UIDevice.current.isMacReal() { if pad && UIApplication.shared.keyWindow?.frame != UIScreen.main.bounds || UIApplication.shared.isSplitOrSlideOver { numberOfColumns = 1 } From f9ea1dd7280a814e6dd684454f99226c16ee92d7 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sat, 27 Mar 2021 19:18:58 -0500 Subject: [PATCH 42/46] Fixed build number --- Slide for Reddit.xcodeproj/project.pbxproj | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index 0d7ba0f08..550fa3571 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -2810,7 +2810,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2844,7 +2844,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2880,7 +2880,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2921,7 +2921,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2955,7 +2955,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2988,7 +2988,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -3023,7 +3023,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3057,7 +3057,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3213,7 +3213,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; @@ -3255,7 +3255,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; @@ -3436,7 +3436,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3472,7 +3472,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 221; + CURRENT_PROJECT_VERSION = 226; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; From f3d944317121abea4d77feffc5f12970075f5d11 Mon Sep 17 00:00:00 2001 From: ccrama Date: Sun, 28 Mar 2021 10:30:00 -0500 Subject: [PATCH 43/46] A few bug fixes, Settings improvements --- Slide for Reddit.xcodeproj/project.pbxproj | 24 +++++++++---------- Slide for Reddit/AnyModalViewController.swift | 23 ++++++++++++++++++ Slide for Reddit/Info.plist | 1 - Slide for Reddit/LinkCellView.swift | 2 ++ .../NavigationHomeViewController.swift | 2 ++ Slide for Reddit/SettingValues.swift | 2 ++ Slide for Reddit/SettingsAudio.swift | 12 +++++----- Slide for Reddit/SettingsGestures.swift | 19 +++++++++++++-- Slide for Reddit/TitleUITextView.swift | 3 +++ .../VideoMediaViewController.swift | 7 ++++++ 10 files changed, 74 insertions(+), 21 deletions(-) diff --git a/Slide for Reddit.xcodeproj/project.pbxproj b/Slide for Reddit.xcodeproj/project.pbxproj index 550fa3571..29cbf9323 100644 --- a/Slide for Reddit.xcodeproj/project.pbxproj +++ b/Slide for Reddit.xcodeproj/project.pbxproj @@ -2810,7 +2810,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2844,7 +2844,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = WidgetConfigIntent/Info.plist; @@ -2880,7 +2880,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2921,7 +2921,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; IBSC_MODULE = Slide_for_Apple_Watch_Extension; @@ -2955,7 +2955,7 @@ CLANG_ENABLE_OBJC_WEAK = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -2988,7 +2988,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = ""; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide for Apple Watch Extension/Info.plist"; @@ -3023,7 +3023,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3057,7 +3057,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Open in Slide/Info.plist"; @@ -3213,7 +3213,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_WARN_UNUSED_PARAMETER = YES; INFOPLIST_FILE = "Slide for Reddit/Info.plist"; @@ -3255,7 +3255,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_OPTIMIZATION_LEVEL = fast; GCC_WARN_UNUSED_PARAMETER = YES; @@ -3436,7 +3436,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; @@ -3472,7 +3472,7 @@ CODE_SIGN_IDENTITY = "iPhone Distribution"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CODE_SIGN_STYLE = Manual; - CURRENT_PROJECT_VERSION = 226; + CURRENT_PROJECT_VERSION = 227; DEVELOPMENT_TEAM = FTT89576VQ; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Slide Widgets/Info.plist"; diff --git a/Slide for Reddit/AnyModalViewController.swift b/Slide for Reddit/AnyModalViewController.swift index 4004eada5..1348f74b9 100644 --- a/Slide for Reddit/AnyModalViewController.swift +++ b/Slide for Reddit/AnyModalViewController.swift @@ -60,6 +60,7 @@ class AnyModalViewController: UIViewController { var bottomButtons = UIStackView() var goToCommentsButton = UIButton() var upvoteButton = UIButton() + private var volumeObserver: NSKeyValueObservation! var closeButton = UIButton().then { $0.accessibilityIdentifier = "Close Button" @@ -597,6 +598,7 @@ class AnyModalViewController: UIViewController { muteButton = UIButton().then { $0.accessibilityIdentifier = "Toggle Mute" + $0.isHidden = true $0.accessibilityLabel = "Toggle Mute" $0.contentEdgeInsets = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8) } @@ -712,6 +714,13 @@ class AnyModalViewController: UIViewController { if !self.scrubber.isHidden { self.fullscreen(self) + if SettingValues.tapExitMedia { + if let parent = parent as? ModalMediaViewController { + parent.exit() + return + } + } + UIView.animate(withDuration: 0.2, animations: { self.scrubber.alpha = 0 }, completion: { (_) in @@ -905,6 +914,11 @@ extension AnyModalViewController { until a bit of time has passed. We react to that here, setting the audio session and the mute button state accordingly. */ + + if hasAudioTracks && muteButton.isHidden { + muteButton.isHidden = false + } + if !setOnce || lastTracks != hasAudioTracks { setOnce = true lastTracks = hasAudioTracks @@ -920,6 +934,15 @@ extension AnyModalViewController { // from silencing background audio mute() } + + volumeObserver = AVAudioSession.sharedInstance().observe(\.outputVolume) { [weak self] (_, _) in + guard let self = self else { return } + + if self.videoView.player?.isMuted ?? false { + self.unmute() + } + } + } if !sliderBeingUsed { diff --git a/Slide for Reddit/Info.plist b/Slide for Reddit/Info.plist index 80c68a9f4..aa1feec12 100644 --- a/Slide for Reddit/Info.plist +++ b/Slide for Reddit/Info.plist @@ -504,7 +504,6 @@ UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight UISupportedInterfaceOrientations~ipad diff --git a/Slide for Reddit/LinkCellView.swift b/Slide for Reddit/LinkCellView.swift index 18ec66803..de2204f22 100644 --- a/Slide for Reddit/LinkCellView.swift +++ b/Slide for Reddit/LinkCellView.swift @@ -1281,11 +1281,13 @@ class LinkCellView: UICollectionViewCell, UIViewControllerPreviewingDelegate, UI videoView?.isHidden = false topVideoView?.isHidden = false sound.isHidden = true + self.updateProgress(-1, "", buffering: false) self.innerView.bringSubviewToFront(topVideoView!) self.progressDot.isHidden = true self.timeView.isHidden = true if wasPlayingAudio { + sound.setImage(UIImage(sfString: SFSymbol.speakerSlashFill, overrideString: "mute")?.getCopy(withSize: CGSize.square(size: 20), withColor: GMColor.red400Color()), for: .normal) DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { if (self.videoView?.player?.currentItem?.tracks.count ?? 1) > 1 && !VideoMediaViewController.soundLocked { do { diff --git a/Slide for Reddit/NavigationHomeViewController.swift b/Slide for Reddit/NavigationHomeViewController.swift index d0df9e5cd..2b60dee6b 100644 --- a/Slide for Reddit/NavigationHomeViewController.swift +++ b/Slide for Reddit/NavigationHomeViewController.swift @@ -255,6 +255,8 @@ class NavigationHomeViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) + accountHeader?.initCurrentAccount(self) + if SettingValues.autoKeyboard { // TODO enable this? searchBar.becomeFirstResponder() } diff --git a/Slide for Reddit/SettingValues.swift b/Slide for Reddit/SettingValues.swift index 814539959..0e2456be7 100644 --- a/Slide for Reddit/SettingValues.swift +++ b/Slide for Reddit/SettingValues.swift @@ -151,6 +151,7 @@ class SettingValues { public static let pref_showFlairs = "SHOW_FLAIRS" public static let pref_desktopMode = "DESKTOP_MODE" public static let pref_tapProfilesAndSubs = "TAP_PROFILES_AND_SUBS" + public static let pref_tapExitMedia = "TAP_EXIT_MEDIA" public static let BROWSER_INTERNAL = "internal" public static let BROWSER_SAFARI_INTERNAL_READABILITY = "readability" @@ -650,6 +651,7 @@ class SettingValues { SettingValues.hideAwards = settings.bool(forKey: SettingValues.pref_hideAwards) SettingValues.hideAwardsComments = settings.object(forKey: SettingValues.pref_hideAwardsComments) == nil ? true : settings.bool(forKey: SettingValues.pref_hideAwardsComments) SettingValues.showProfileImagesComments = settings.bool(forKey: SettingValues.pref_showProfileImagesComments) + SettingValues.tapExitMedia = settings.bool(forKey: SettingValues.pref_tapExitMedia) SettingValues.dataSavingEnabled = settings.bool(forKey: SettingValues.pref_dataSavingEnabled) SettingValues.dataSavingDisableWiFi = settings.bool(forKey: SettingValues.pref_dataSavingDisableWifi) diff --git a/Slide for Reddit/SettingsAudio.swift b/Slide for Reddit/SettingsAudio.swift index 7da49b806..569e31ef4 100644 --- a/Slide for Reddit/SettingsAudio.swift +++ b/Slide for Reddit/SettingsAudio.swift @@ -61,10 +61,10 @@ class SettingsAudio: BubbleSettingTableViewController { muteModalVideoSwitch = UISwitch().then { $0.onTintColor = ColorUtil.baseAccent - $0.isOn = SettingValues.muteVideosInModal + $0.isOn = !SettingValues.muteVideosInModal } muteModalVideoSwitch.addTarget(self, action: #selector(SettingsAudio.switchIsChanged(_:)), for: UIControl.Event.valueChanged) - muteModalVideoCell.textLabel?.text = "Mute full-screen videos by default" + muteModalVideoCell.textLabel?.text = "Play video sound when opening full-screen" muteModalVideoCell.accessoryView = muteModalVideoSwitch muteModalVideoCell.textLabel?.numberOfLines = 0 muteModalVideoCell.selectionStyle = UITableViewCell.SelectionStyle.none @@ -74,7 +74,7 @@ class SettingsAudio: BubbleSettingTableViewController { $0.isOn = SettingValues.modalVideosRespectHardwareMuteSwitch } modalVideoFollowsMuteSwitchSwitch.addTarget(self, action: #selector(SettingsAudio.switchIsChanged(_:)), for: UIControl.Event.valueChanged) - modalVideoFollowsMuteSwitchCell.textLabel?.text = "Mute full-screen videos when iOS is muted" + modalVideoFollowsMuteSwitchCell.textLabel?.text = "Respect device mute switch" modalVideoFollowsMuteSwitchCell.accessoryView = modalVideoFollowsMuteSwitchSwitch modalVideoFollowsMuteSwitchCell.textLabel?.numberOfLines = 0 modalVideoFollowsMuteSwitchCell.selectionStyle = UITableViewCell.SelectionStyle.none @@ -84,7 +84,7 @@ class SettingsAudio: BubbleSettingTableViewController { $0.isOn = SettingValues.muteYouTube } muteYTSwitch.addTarget(self, action: #selector(SettingsAudio.switchIsChanged(_:)), for: UIControl.Event.valueChanged) - muteYTCell.textLabel?.text = "Mute YouTube videos by default" + muteYTCell.textLabel?.text = "Mute YouTube videos" muteYTCell.accessoryView = muteYTSwitch muteYTCell.textLabel?.numberOfLines = 0 muteYTCell.selectionStyle = UITableViewCell.SelectionStyle.none @@ -116,7 +116,7 @@ class SettingsAudio: BubbleSettingTableViewController { func refresh() { muteInlineVideoSwitch.isOn = SettingValues.muteInlineVideos - muteModalVideoSwitch.isOn = SettingValues.muteVideosInModal + muteModalVideoSwitch.isOn = !SettingValues.muteVideosInModal modalVideoFollowsMuteSwitchSwitch.isOn = SettingValues.modalVideosRespectHardwareMuteSwitch self.tableView.reloadData() @@ -148,7 +148,7 @@ private extension SettingsAudio { case muteInlineVideoSwitch: SettingValues.muteInlineVideos = changed.isOn case muteModalVideoSwitch: - SettingValues.muteVideosInModal = changed.isOn + SettingValues.muteVideosInModal = !changed.isOn case modalVideoFollowsMuteSwitchSwitch: SettingValues.modalVideosRespectHardwareMuteSwitch = changed.isOn case muteYTSwitch: diff --git a/Slide for Reddit/SettingsGestures.swift b/Slide for Reddit/SettingsGestures.swift index c2c9dd4b4..65fb5e1c2 100644 --- a/Slide for Reddit/SettingsGestures.swift +++ b/Slide for Reddit/SettingsGestures.swift @@ -14,6 +14,11 @@ class SettingsGestures: BubbleSettingTableViewController { var disableBanner = UISwitch().then { $0.onTintColor = ColorUtil.baseAccent } + + var tapExitMediaCell: UITableViewCell = InsetCell.init(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: "tapmedia") + var tapExitMedia = UISwitch().then { + $0.onTintColor = ColorUtil.baseAccent + } var forceTouchSubmissionCell: UITableViewCell = InsetCell.init(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: "3dsubmission") @@ -44,6 +49,9 @@ class SettingsGestures: BubbleSettingTableViewController { UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_disableBanner) NotificationCenter.default.post(name: .subNeedsReload, object: nil) + } else if changed == tapExitMedia { + SettingValues.tapExitMedia = changed.isOn + UserDefaults.standard.set(changed.isOn, forKey: SettingValues.pref_tapExitMedia) } UserDefaults.standard.synchronize() @@ -197,7 +205,7 @@ class SettingsGestures: BubbleSettingTableViewController { self.view.backgroundColor = UIColor.backgroundColor // set the title self.title = "Gestures" - self.headers = ["Submissions", "Comments", "Main view edge shortcut"] + self.headers = ["Submissions", "Comments", "Media"] createCell(submissionGesturesCell, nil, isOn: false, text: "Submission gestures mode") self.submissionGesturesCell.detailTextLabel?.textColor = UIColor.fontColor self.submissionGesturesCell.detailTextLabel?.lineBreakMode = .byWordWrapping @@ -212,6 +220,13 @@ class SettingsGestures: BubbleSettingTableViewController { self.disableBannerCell.detailTextLabel?.numberOfLines = 0 self.disableBannerCell.detailTextLabel?.text = "Enabling this will open comments when clicking on the submission banner image" self.disableBannerCell.contentView.backgroundColor = UIColor.foregroundColor + + createCell(tapExitMediaCell, tapExitMedia, isOn: SettingValues.tapExitMedia, text: "Close media views by clicking or tapping") + self.tapExitMediaCell.detailTextLabel?.textColor = UIColor.fontColor + self.tapExitMediaCell.detailTextLabel?.lineBreakMode = .byWordWrapping + self.tapExitMediaCell.detailTextLabel?.numberOfLines = 0 + self.tapExitMediaCell.detailTextLabel?.text = "Disables tap for 'fullscreen' mode, allows for exiting media while using a mouse" + self.tapExitMediaCell.contentView.backgroundColor = UIColor.foregroundColor createCell(commentGesturesCell, nil, isOn: false, text: "Comment gestures mode") self.commentGesturesCell.detailTextLabel?.textColor = UIColor.fontColor @@ -363,7 +378,7 @@ class SettingsGestures: BubbleSettingTableViewController { default: fatalError("Unknown row in section 0") } case 2: - return self.sideShortcutActionCell + return self.tapExitMediaCell default: fatalError("Unknown section") } diff --git a/Slide for Reddit/TitleUITextView.swift b/Slide for Reddit/TitleUITextView.swift index b336f6e3f..8a081b5b0 100644 --- a/Slide for Reddit/TitleUITextView.swift +++ b/Slide for Reddit/TitleUITextView.swift @@ -97,6 +97,9 @@ class TitleUITextView: UITextView { delegate?.previewProfile(profile: profile) return } else if let url = highlight.userInfo["url"] as? URL { + if url.absoluteString.contains("ccrama.me") { + return + } delegate?.linkLongTapped(url: url) return } diff --git a/Slide for Reddit/VideoMediaViewController.swift b/Slide for Reddit/VideoMediaViewController.swift index 270bcbcc2..b2e709119 100644 --- a/Slide for Reddit/VideoMediaViewController.swift +++ b/Slide for Reddit/VideoMediaViewController.swift @@ -464,6 +464,13 @@ class VideoMediaViewController: EmbeddableMediaViewController, UIGestureRecogniz @objc func handleHideUI(hideTitle: Bool) { if !self.scrubber.isHidden || hideTitle { + if SettingValues.tapExitMedia { + if let parent = parent as? ModalMediaViewController { + parent.exit() + return + } + } + if let parent = parent as? ModalMediaViewController { parent.fullscreen(self, hideTitle) } From d328ad76eb1af4a0c3c2862d4d6187ebad1b2635 Mon Sep 17 00:00:00 2001 From: Carlos Crane Date: Sun, 28 Mar 2021 10:46:30 -0500 Subject: [PATCH 44/46] Force Fastlane update on bundle install --- .github/workflows/core_data_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/core_data_tests.yml b/.github/workflows/core_data_tests.yml index a27ab670d..9721dbeac 100644 --- a/.github/workflows/core_data_tests.yml +++ b/.github/workflows/core_data_tests.yml @@ -42,6 +42,7 @@ jobs: run: | sh ./bootstrap.sh pod install + bundle exec fastlane install_plugins - name: Run code validation uses: actions/checkout@v1 with: From 40a1192226bff9c1eab0cfd7c846ced1cc581bb6 Mon Sep 17 00:00:00 2001 From: Carlos Crane Date: Sun, 28 Mar 2021 10:59:34 -0500 Subject: [PATCH 45/46] Update core_data_tests.yml --- .github/workflows/core_data_tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/core_data_tests.yml b/.github/workflows/core_data_tests.yml index 9721dbeac..fdcc6e6ef 100644 --- a/.github/workflows/core_data_tests.yml +++ b/.github/workflows/core_data_tests.yml @@ -42,6 +42,7 @@ jobs: run: | sh ./bootstrap.sh pod install + bundle update fastlane bundle exec fastlane install_plugins - name: Run code validation uses: actions/checkout@v1 From 5d37b46a73465d053b0b1efcc4657666c3b5634e Mon Sep 17 00:00:00 2001 From: Carlos Crane Date: Sun, 28 Mar 2021 11:08:41 -0500 Subject: [PATCH 46/46] Update core_data_tests.yml --- .github/workflows/core_data_tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/core_data_tests.yml b/.github/workflows/core_data_tests.yml index fdcc6e6ef..59d87b3ff 100644 --- a/.github/workflows/core_data_tests.yml +++ b/.github/workflows/core_data_tests.yml @@ -43,7 +43,6 @@ jobs: sh ./bootstrap.sh pod install bundle update fastlane - bundle exec fastlane install_plugins - name: Run code validation uses: actions/checkout@v1 with: