From 9093380d4f18e8d9a465fe991d13845f2707eb1e Mon Sep 17 00:00:00 2001 From: Bruno Muniz Azevedo Filho <bruno@elixxir.io> Date: Sat, 12 Nov 2022 17:12:24 -0300 Subject: [PATCH] using xxm-navigation --- Package.swift | 35 +- Sources/App/AppDelegate.swift | 2 +- Sources/App/DependencyRegistrator.swift | 2 +- .../Controllers/BackupConfigController.swift | 2 +- .../ViewModels/BackupConfigViewModel.swift | 2 +- .../Controllers/GroupChatController.swift | 2 +- .../Controllers/SingleChatController.swift | 7 +- .../ViewModels/SingleChatViewModel.swift | 3 +- .../Controller/ChatListController.swift | 2 +- .../ChatListSearchTableController.swift | 2 +- .../Controller/ChatListTableController.swift | 2 +- .../Controllers/ContactController.swift | 2 +- .../Controllers/ContactListController.swift | 2 +- .../Controllers/CreateGroupController.swift | 2 +- Sources/Countries/CountryListController.swift | 2 +- Sources/DrawerFeature/DrawerController.swift | 32 +- Sources/DrawerFeature/DrawerView.swift | 30 +- Sources/LaunchFeature/LaunchController.swift | 2 +- .../LaunchViewModel+Messenger.swift | 8 +- .../Controllers/MenuController.swift | 21 +- Sources/MenuFeature/Views/MenuView.swift | 141 ++++---- .../OnboardingCodeController.swift | 2 +- .../OnboardingEmailController.swift | 2 +- .../OnboardingPhoneController.swift | 4 +- .../OnboardingStartController.swift | 2 +- .../OnboardingUsernameController.swift | 2 +- .../OnboardingWelcomeController.swift | 2 +- .../RequestPermissionController.swift | 4 +- .../Controllers/ProfileCodeController.swift | 2 +- .../Controllers/ProfileController.swift | 2 +- .../Controllers/ProfileEmailController.swift | 4 +- .../Controllers/ProfilePhoneController.swift | 6 +- .../RequestsContainerController.swift | 2 +- .../RequestsReceivedController.swift | 2 +- .../Controllers/RestoreController.swift | 2 +- .../Controllers/RestoreListController.swift | 2 +- .../RestoreSuccessController.swift | 2 +- .../Controllers/ScanContainerController.swift | 2 +- .../Controllers/ScanController.swift | 2 +- .../SearchContainerController.swift | 2 +- .../Controllers/SearchLeftController.swift | 4 +- .../Controllers/SearchRightController.swift | 2 +- .../Controllers/AccountDeleteController.swift | 2 +- .../SettingsAdvancedController.swift | 2 +- .../Controllers/SettingsController.swift | 2 +- Sources/Shared/Models/MenuItem.swift | 11 - Sources/Shared/Models/PermissionType.swift | 5 - .../TermsConditionsController.swift | 4 +- Sources/XXNavigation/Chat/PresentCamera.swift | 9 - Sources/XXNavigation/Chat/PresentChat.swift | 36 -- .../XXNavigation/Chat/PresentChatList.swift | 30 -- .../XXNavigation/Chat/PresentGroupChat.swift | 36 -- .../XXNavigation/Chat/PresentMemberList.swift | 15 - .../XXNavigation/Chat/PresentNewGroup.swift | 30 -- .../XXNavigation/Chat/PresentWebsite.swift | 15 - .../XXNavigation/Contact/PresentContact.swift | 36 -- .../Contact/PresentContactList.swift | 30 -- .../Contact/PresentNickname.swift | 17 - .../XXNavigation/CustomActions/OpenLeft.swift | 310 ------------------ .../XXNavigation/CustomActions/OpenUp.swift | 201 ------------ Sources/XXNavigation/Export.swift | 1 - .../Onboarding/PresentOnboardingCode.swift | 42 --- .../Onboarding/PresentOnboardingEmail.swift | 30 -- .../Onboarding/PresentOnboardingPhone.swift | 30 -- .../Onboarding/PresentOnboardingStart.swift | 30 -- .../PresentOnboardingUsername.swift | 30 -- .../Onboarding/PresentOnboardingWelcome.swift | 30 -- .../PresentTermsAndConditions.swift | 40 --- .../XXNavigation/PresentActivitySheet.swift | 42 --- Sources/XXNavigation/PresentCountryList.swift | 38 --- Sources/XXNavigation/PresentDrawer.swift | 46 --- Sources/XXNavigation/PresentMenu.swift | 42 --- .../PresentPermissionRequest.swift | 38 --- .../XXNavigation/PresentPhotoLibrary.swift | 34 -- Sources/XXNavigation/PresentScan.swift | 30 -- Sources/XXNavigation/PresentSearch.swift | 43 --- .../XXNavigation/Profile/PresentProfile.swift | 30 -- .../Profile/PresentProfileCode.swift | 42 --- .../Profile/PresentProfileEmail.swift | 30 -- .../Profile/PresentProfilePhone.swift | 30 -- .../RestoreAndBackup/PresentPassphrase.swift | 17 - .../RestoreAndBackup/PresentRequests.swift | 30 -- .../RestoreAndBackup/PresentRestoreList.swift | 30 -- .../RestoreAndBackup/PresentSFTP.swift | 14 - .../Settings/PresentSettings.swift | 30 -- .../PresentSettingsAccountDelete.swift | 30 -- .../Settings/PresentSettingsAdvanced.swift | 30 -- .../Settings/PresentSettingsBackup.swift | 30 -- Tests/DefaultsTests/KeyObjectTests.swift | 116 +++---- Tests/ThemeTests/ThemeTests.swift | 68 ++-- .../xcshareddata/swiftpm/Package.resolved | 9 - 91 files changed, 270 insertions(+), 1960 deletions(-) delete mode 100644 Sources/Shared/Models/MenuItem.swift delete mode 100644 Sources/Shared/Models/PermissionType.swift delete mode 100644 Sources/XXNavigation/Chat/PresentCamera.swift delete mode 100644 Sources/XXNavigation/Chat/PresentChat.swift delete mode 100644 Sources/XXNavigation/Chat/PresentChatList.swift delete mode 100644 Sources/XXNavigation/Chat/PresentGroupChat.swift delete mode 100644 Sources/XXNavigation/Chat/PresentMemberList.swift delete mode 100644 Sources/XXNavigation/Chat/PresentNewGroup.swift delete mode 100644 Sources/XXNavigation/Chat/PresentWebsite.swift delete mode 100644 Sources/XXNavigation/Contact/PresentContact.swift delete mode 100644 Sources/XXNavigation/Contact/PresentContactList.swift delete mode 100644 Sources/XXNavigation/Contact/PresentNickname.swift delete mode 100644 Sources/XXNavigation/CustomActions/OpenLeft.swift delete mode 100644 Sources/XXNavigation/CustomActions/OpenUp.swift delete mode 100644 Sources/XXNavigation/Export.swift delete mode 100644 Sources/XXNavigation/Onboarding/PresentOnboardingCode.swift delete mode 100644 Sources/XXNavigation/Onboarding/PresentOnboardingEmail.swift delete mode 100644 Sources/XXNavigation/Onboarding/PresentOnboardingPhone.swift delete mode 100644 Sources/XXNavigation/Onboarding/PresentOnboardingStart.swift delete mode 100644 Sources/XXNavigation/Onboarding/PresentOnboardingUsername.swift delete mode 100644 Sources/XXNavigation/Onboarding/PresentOnboardingWelcome.swift delete mode 100644 Sources/XXNavigation/Onboarding/PresentTermsAndConditions.swift delete mode 100644 Sources/XXNavigation/PresentActivitySheet.swift delete mode 100644 Sources/XXNavigation/PresentCountryList.swift delete mode 100644 Sources/XXNavigation/PresentDrawer.swift delete mode 100644 Sources/XXNavigation/PresentMenu.swift delete mode 100644 Sources/XXNavigation/PresentPermissionRequest.swift delete mode 100644 Sources/XXNavigation/PresentPhotoLibrary.swift delete mode 100644 Sources/XXNavigation/PresentScan.swift delete mode 100644 Sources/XXNavigation/PresentSearch.swift delete mode 100644 Sources/XXNavigation/Profile/PresentProfile.swift delete mode 100644 Sources/XXNavigation/Profile/PresentProfileCode.swift delete mode 100644 Sources/XXNavigation/Profile/PresentProfileEmail.swift delete mode 100644 Sources/XXNavigation/Profile/PresentProfilePhone.swift delete mode 100644 Sources/XXNavigation/RestoreAndBackup/PresentPassphrase.swift delete mode 100644 Sources/XXNavigation/RestoreAndBackup/PresentRequests.swift delete mode 100644 Sources/XXNavigation/RestoreAndBackup/PresentRestoreList.swift delete mode 100644 Sources/XXNavigation/RestoreAndBackup/PresentSFTP.swift delete mode 100644 Sources/XXNavigation/Settings/PresentSettings.swift delete mode 100644 Sources/XXNavigation/Settings/PresentSettingsAccountDelete.swift delete mode 100644 Sources/XXNavigation/Settings/PresentSettingsAdvanced.swift delete mode 100644 Sources/XXNavigation/Settings/PresentSettingsBackup.swift diff --git a/Package.swift b/Package.swift index e9456bac..2162bd75 100644 --- a/Package.swift +++ b/Package.swift @@ -23,7 +23,6 @@ let package = Package( .library(name: "PushFeature", targets: ["PushFeature"]), .library(name: "CrashService", targets: ["CrashService"]), .library(name: "TermsFeature", targets: ["TermsFeature"]), - .library(name: "XXNavigation", targets: ["XXNavigation"]), .library(name: "Presentation", targets: ["Presentation"]), .library(name: "BackupFeature", targets: ["BackupFeature"]), .library(name: "LaunchFeature", targets: ["LaunchFeature"]), @@ -97,9 +96,6 @@ let package = Package( .package( path: "../xxm-cloud-providers" ), - .package( - path: "../Router-PoC/Navigation" - ), .package( url: "https://git.xx.network/elixxir/client-ios-db.git", .upToNextMajor(from: "1.1.0") @@ -127,6 +123,9 @@ let package = Package( .package( url: "https://git.xx.network/elixxir/xxm-di.git", .upToNextMajor(from: "1.0.0") + ), + .package( + path: "../xxm-navigation" ) ], targets: [ @@ -140,7 +139,6 @@ let package = Package( .target(name: "ChatFeature"), .target(name: "MenuFeature"), .target(name: "PushFeature"), - .target(name: "XXNavigation"), .target(name: "TermsFeature"), .target(name: "CrashService"), .target(name: "BackupFeature"), @@ -156,6 +154,7 @@ let package = Package( .target(name: "ReportingFeature"), .target(name: "OnboardingFeature"), .target(name: "ContactListFeature"), + .product(name: "DependencyInjection", package: "xxm-di"), ] ), .testTarget( @@ -186,19 +185,10 @@ let package = Package( name: "Permissions", dependencies: [ .target(name: "Shared"), - .target(name: "XXNavigation"), + .product(name: "Navigation", package: "xxm-navigation"), .product(name: "DependencyInjection", package: "xxm-di"), ] ), - .target( - name: "XXNavigation", - dependencies: [ - .target(name: "DrawerFeature"), - .product(name: "DependencyInjection", package: "xxm-di"), - .product(name: "Navigation", package: "Navigation"), - .product(name: "XXModels", package: "client-ios-db"), - ] - ), .target( name: "PushFeature", dependencies: [ @@ -239,7 +229,6 @@ let package = Package( name: "Countries", dependencies: [ .target(name: "Shared"), - .target(name: "XXNavigation"), .product(name: "DependencyInjection", package: "xxm-di"), ] ), @@ -299,9 +288,9 @@ let package = Package( dependencies: [ .target(name: "Shared"), .target(name: "Presentation"), - .target(name: "XXNavigation"), - .product(name: "DependencyInjection", package: "xxm-di"), .product(name: "XXDatabase", package: "client-ios-db"), + .product(name: "Navigation", package: "xxm-navigation"), + .product(name: "DependencyInjection", package: "xxm-di"), .product(name: "XXClient", package: "elixxir-dapps-sdk-swift"), .product(name: "CloudFilesDrive", package: "xxm-cloud-providers"), .product(name: "CloudFilesDropbox", package: "xxm-cloud-providers"), @@ -329,7 +318,6 @@ let package = Package( .target(name: "Voxophone"), .target(name: "Permissions"), .target(name: "Presentation"), - .target(name: "XXNavigation"), .target(name: "DrawerFeature"), .target(name: "ChatInputFeature"), .target(name: "ReportingFeature"), @@ -350,9 +338,9 @@ let package = Package( .target(name: "Presentation"), .target(name: "ContactFeature"), .target(name: "NetworkMonitor"), - .product(name: "DependencyInjection", package: "xxm-di"), .product(name: "Retry", package: "Retry"), .product(name: "XXDatabase", package: "client-ios-db"), + .product(name: "DependencyInjection", package: "xxm-di"), ] ), .target( @@ -380,7 +368,7 @@ let package = Package( .target(name: "Shared"), .target(name: "Defaults"), .target(name: "Presentation"), - .target(name: "XXNavigation"), + .product(name: "Navigation", package: "xxm-navigation"), ] ), .target( @@ -405,6 +393,7 @@ let package = Package( .target(name: "Presentation"), .target(name: "DrawerFeature"), .target(name: "BackupFeature"), + .product(name: "Navigation", package: "xxm-navigation"), .product(name: "DependencyInjection", package: "xxm-di"), .product(name: "CombineSchedulers", package: "combine-schedulers"), .product(name: "ScrollViewController", package: "ScrollViewController"), @@ -419,7 +408,6 @@ let package = Package( .target(name: "Defaults"), .target(name: "MenuFeature"), .target(name: "ChatFeature"), - .target(name: "XXNavigation"), .target(name: "ProfileFeature"), .target(name: "SettingsFeature"), .target(name: "ContactListFeature"), @@ -451,9 +439,9 @@ let package = Package( .target(name: "Shared"), .target(name: "Defaults"), .target(name: "Presentation"), - .target(name: "XXNavigation"), .target(name: "DrawerFeature"), .target(name: "ReportingFeature"), + .product(name: "Navigation", package: "xxm-navigation"), .product(name: "DependencyInjection", package: "xxm-di"), .product(name: "XXClient", package: "elixxir-dapps-sdk-swift"), ] @@ -466,6 +454,7 @@ let package = Package( .target(name: "Presentation"), .target(name: "DrawerFeature"), .target(name: "NetworkMonitor"), + .product(name: "Navigation", package: "xxm-navigation"), .product(name: "DependencyInjection", package: "xxm-di"), .product(name: "XXClient", package: "elixxir-dapps-sdk-swift"), .product(name: "CloudFilesSFTP", package: "xxm-cloud-providers"), diff --git a/Sources/App/AppDelegate.swift b/Sources/App/AppDelegate.swift index 2b3b6e9a..fd23e19c 100644 --- a/Sources/App/AppDelegate.swift +++ b/Sources/App/AppDelegate.swift @@ -11,7 +11,7 @@ import DI import XXModels import XXLogger import XXClient -import XXNavigation +import Navigation import XXMessengerClient import CloudFiles diff --git a/Sources/App/DependencyRegistrator.swift b/Sources/App/DependencyRegistrator.swift index 787aa378..f562bd38 100644 --- a/Sources/App/DependencyRegistrator.swift +++ b/Sources/App/DependencyRegistrator.swift @@ -43,7 +43,7 @@ import ContactListFeature import Shared import XXClient -import XXNavigation +import Navigation import KeychainAccess import XXMessengerClient diff --git a/Sources/BackupFeature/Controllers/BackupConfigController.swift b/Sources/BackupFeature/Controllers/BackupConfigController.swift index 3a8cdb14..5c75751e 100644 --- a/Sources/BackupFeature/Controllers/BackupConfigController.swift +++ b/Sources/BackupFeature/Controllers/BackupConfigController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import CloudFiles -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift b/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift index d8e916d4..4ae6414e 100644 --- a/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift +++ b/Sources/BackupFeature/ViewModels/BackupConfigViewModel.swift @@ -8,7 +8,7 @@ import Foundation import DI import CloudFiles -import XXNavigation +import Navigation enum BackupActionState { case backupFinished diff --git a/Sources/ChatFeature/Controllers/GroupChatController.swift b/Sources/ChatFeature/Controllers/GroupChatController.swift index c780effb..97a65ca8 100644 --- a/Sources/ChatFeature/Controllers/GroupChatController.swift +++ b/Sources/ChatFeature/Controllers/GroupChatController.swift @@ -5,7 +5,7 @@ import Combine import XXModels import Voxophone import ChatLayout -import XXNavigation +import Navigation import DrawerFeature import DifferenceKit import ReportingFeature diff --git a/Sources/ChatFeature/Controllers/SingleChatController.swift b/Sources/ChatFeature/Controllers/SingleChatController.swift index c320ad1d..c4a89089 100644 --- a/Sources/ChatFeature/Controllers/SingleChatController.swift +++ b/Sources/ChatFeature/Controllers/SingleChatController.swift @@ -1,17 +1,18 @@ +import DI import UIKit import Shared import Combine import XXLogger -import QuickLook import XXModels +import QuickLook import Voxophone +import Navigation import ChatLayout -import XXNavigation +import Navigation import DrawerFeature import DifferenceKit import ChatInputFeature import ReportingFeature -import DI import ScrollViewController extension FlexibleSpace: CollectionCellContent { diff --git a/Sources/ChatFeature/ViewModels/SingleChatViewModel.swift b/Sources/ChatFeature/ViewModels/SingleChatViewModel.swift index 8dde807b..6f0b3f96 100644 --- a/Sources/ChatFeature/ViewModels/SingleChatViewModel.swift +++ b/Sources/ChatFeature/ViewModels/SingleChatViewModel.swift @@ -1,3 +1,4 @@ +import DI import UIKit import Shared import Combine @@ -5,11 +6,11 @@ import XXLogger import XXModels import XXClient import Defaults +import Navigation import Foundation import Permissions import DifferenceKit import ReportingFeature -import DI import XXMessengerClient import struct XXModels.Message diff --git a/Sources/ChatListFeature/Controller/ChatListController.swift b/Sources/ChatListFeature/Controller/ChatListController.swift index 071e61e2..dfa484b0 100644 --- a/Sources/ChatListFeature/Controller/ChatListController.swift +++ b/Sources/ChatListFeature/Controller/ChatListController.swift @@ -3,7 +3,7 @@ import Shared import Combine import XXModels import MenuFeature -import XXNavigation +import Navigation import DI public final class ChatListController: UIViewController { diff --git a/Sources/ChatListFeature/Controller/ChatListSearchTableController.swift b/Sources/ChatListFeature/Controller/ChatListSearchTableController.swift index 999049ff..d2949c9c 100644 --- a/Sources/ChatListFeature/Controller/ChatListSearchTableController.swift +++ b/Sources/ChatListFeature/Controller/ChatListSearchTableController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DI class ChatSearchListTableViewDiffableDataSource: UITableViewDiffableDataSource<SearchSection, SearchItem> { diff --git a/Sources/ChatListFeature/Controller/ChatListTableController.swift b/Sources/ChatListFeature/Controller/ChatListTableController.swift index 74e58324..7129b97c 100644 --- a/Sources/ChatListFeature/Controller/ChatListTableController.swift +++ b/Sources/ChatListFeature/Controller/ChatListTableController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import XXModels -import XXNavigation +import Navigation import DifferenceKit import DrawerFeature import DI diff --git a/Sources/ContactFeature/Controllers/ContactController.swift b/Sources/ContactFeature/Controllers/ContactController.swift index 06147dd9..14531814 100644 --- a/Sources/ContactFeature/Controllers/ContactController.swift +++ b/Sources/ContactFeature/Controllers/ContactController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import XXModels -import XXNavigation +import Navigation import DrawerFeature import DI import ScrollViewController diff --git a/Sources/ContactListFeature/Controllers/ContactListController.swift b/Sources/ContactListFeature/Controllers/ContactListController.swift index 12fe939a..2c45e7d9 100644 --- a/Sources/ContactListFeature/Controllers/ContactListController.swift +++ b/Sources/ContactListFeature/Controllers/ContactListController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DI public final class ContactListController: UIViewController { diff --git a/Sources/ContactListFeature/Controllers/CreateGroupController.swift b/Sources/ContactListFeature/Controllers/CreateGroupController.swift index 2e848091..4397c8cd 100644 --- a/Sources/ContactListFeature/Controllers/CreateGroupController.swift +++ b/Sources/ContactListFeature/Controllers/CreateGroupController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import XXModels -import XXNavigation +import Navigation import DI public final class CreateGroupController: UIViewController { diff --git a/Sources/Countries/CountryListController.swift b/Sources/Countries/CountryListController.swift index c49f954b..5a618131 100644 --- a/Sources/Countries/CountryListController.swift +++ b/Sources/Countries/CountryListController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DI public final class CountryListController: UIViewController, UITableViewDelegate { diff --git a/Sources/DrawerFeature/DrawerController.swift b/Sources/DrawerFeature/DrawerController.swift index a51fe87a..c7503f8c 100644 --- a/Sources/DrawerFeature/DrawerController.swift +++ b/Sources/DrawerFeature/DrawerController.swift @@ -2,26 +2,26 @@ import UIKit import Combine public final class DrawerController: UIViewController { - private lazy var screenView = DrawerView() - private let content: [DrawerItem] - public var cancellables = Set<AnyCancellable>() + private lazy var screenView = DrawerView() + private let content: [DrawerItem] + public var cancellables = Set<AnyCancellable>() - public init(_ items: [DrawerItem]) { - self.content = items - super.init(nibName: nil, bundle: nil) + public init(_ items: [Any]) { + self.content = items as! [DrawerItem] + super.init(nibName: nil, bundle: nil) - let views = content.map { $0.makeView() } - views.forEach { screenView.stackView.addArrangedSubview($0) } + let views = content.map { $0.makeView() } + views.forEach { screenView.stackView.addArrangedSubview($0) } - content.enumerated().forEach { item in - guard let spacing = item.element.spacingAfter else { return } - screenView.stackView.setCustomSpacing(spacing, after: views[item.offset]) - } + content.enumerated().forEach { item in + guard let spacing = item.element.spacingAfter else { return } + screenView.stackView.setCustomSpacing(spacing, after: views[item.offset]) } + } - required init?(coder: NSCoder) { nil } + required init?(coder: NSCoder) { nil } - public override func loadView() { - view = screenView - } + public override func loadView() { + view = screenView + } } diff --git a/Sources/DrawerFeature/DrawerView.swift b/Sources/DrawerFeature/DrawerView.swift index e03282d5..4c157e0d 100644 --- a/Sources/DrawerFeature/DrawerView.swift +++ b/Sources/DrawerFeature/DrawerView.swift @@ -2,25 +2,25 @@ import UIKit import Shared final class DrawerView: UIView { - let stackView = UIStackView() + let stackView = UIStackView() - init() { - super.init(frame: .zero) + init() { + super.init(frame: .zero) - layer.cornerRadius = 40 - backgroundColor = Asset.neutralWhite.color - layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] + layer.cornerRadius = 40 + backgroundColor = Asset.neutralWhite.color + layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner] - stackView.axis = .vertical - addSubview(stackView) + stackView.axis = .vertical + addSubview(stackView) - stackView.snp.makeConstraints { - $0.top.equalToSuperview().offset(40) - $0.left.equalToSuperview().offset(50) - $0.right.equalToSuperview().offset(-50) - $0.bottom.equalToSuperview().offset(-50) - } + stackView.snp.makeConstraints { + $0.top.equalToSuperview().offset(40) + $0.left.equalToSuperview().offset(50) + $0.right.equalToSuperview().offset(-50) + $0.bottom.equalToSuperview().offset(-50) } + } - required init?(coder: NSCoder) { nil } + required init?(coder: NSCoder) { nil } } diff --git a/Sources/LaunchFeature/LaunchController.swift b/Sources/LaunchFeature/LaunchController.swift index 092facf9..48a8e1fe 100644 --- a/Sources/LaunchFeature/LaunchController.swift +++ b/Sources/LaunchFeature/LaunchController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import PushFeature -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/LaunchFeature/LaunchViewModel+Messenger.swift b/Sources/LaunchFeature/LaunchViewModel+Messenger.swift index cd52d720..9871a24d 100644 --- a/Sources/LaunchFeature/LaunchViewModel+Messenger.swift +++ b/Sources/LaunchFeature/LaunchViewModel+Messenger.swift @@ -1,10 +1,10 @@ +import DI import Shared import XXClient import XXModels import XXLogger import Foundation import XXMessengerClient -import DI extension LaunchViewModel { func setupBackupCallback() { @@ -118,7 +118,7 @@ extension LaunchViewModel { // fileTransferId: model.id // )) // - // if let manager: XXClient.FileTransfer = try? DependencyInjection.Container.shared.resolve() { + // if let manager: XXClient.FileTransfer = try? DI.Container.shared.resolve() { // print(">>> registerReceivedProgressCallback") // // try! manager.registerReceivedProgressCallback( @@ -143,7 +143,7 @@ extension LaunchViewModel { // }) // ) // } else { - // //print(DependencyInjection.Container.shared.dependencies) + // //print(DI.Container.shared.dependencies) // } // } } @@ -385,7 +385,7 @@ extension LaunchViewModel { // }) // ) // - // DependencyInjection.Container.shared.register(manager) + // DI.Container.shared.register(manager) } func generateTrafficManager() throws { diff --git a/Sources/MenuFeature/Controllers/MenuController.swift b/Sources/MenuFeature/Controllers/MenuController.swift index 12415b6a..6b2cd52c 100644 --- a/Sources/MenuFeature/Controllers/MenuController.swift +++ b/Sources/MenuFeature/Controllers/MenuController.swift @@ -1,9 +1,9 @@ +import DI import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature -import DI public final class MenuController: UIViewController { @Dependency var navigator: Navigator @@ -33,7 +33,22 @@ public final class MenuController: UIViewController { username: viewModel.username, image: viewModel.avatar ) - screenView.select(item: currentItem) + + switch currentItem { + case .scan: + screenView.scanButton.set(color: Asset.brandPrimary.color) + case .chats: + screenView.chatsButton.set(color: Asset.brandPrimary.color) + case .contacts: + screenView.contactsButton.set(color: Asset.brandPrimary.color) + case .requests: + screenView.requestsButton.set(color: Asset.brandPrimary.color) + case .settings: + screenView.settingsButton.set(color: Asset.brandPrimary.color) + default: + break + } + screenView.xxdkVersionLabel.text = "XXDK \(viewModel.xxdk)" screenView.buildLabel.text = Localized.Menu.build(viewModel.build) screenView.versionLabel.text = Localized.Menu.version(viewModel.version) diff --git a/Sources/MenuFeature/Views/MenuView.swift b/Sources/MenuFeature/Views/MenuView.swift index e256782e..8e83eacb 100644 --- a/Sources/MenuFeature/Views/MenuView.swift +++ b/Sources/MenuFeature/Views/MenuView.swift @@ -2,96 +2,79 @@ import UIKit import Shared final class MenuView: UIView { - let buildLabel = UILabel() - let versionLabel = UILabel() - let stackView = UIStackView() - let xxdkVersionLabel = UILabel() - let infoStackView = UIStackView() - let headerView = MenuHeaderView() - let joinButton = MenuSectionButton() - let scanButton = MenuSectionButton() - let shareButton = MenuSectionButton() - let chatsButton = MenuSectionButton() - let contactsButton = MenuSectionButton() - let requestsButton = MenuSectionButton() - let settingsButton = MenuSectionButton() - let dashboardButton = MenuSectionButton() + let buildLabel = UILabel() + let versionLabel = UILabel() + let stackView = UIStackView() + let xxdkVersionLabel = UILabel() + let infoStackView = UIStackView() + let headerView = MenuHeaderView() + let joinButton = MenuSectionButton() + let scanButton = MenuSectionButton() + let shareButton = MenuSectionButton() + let chatsButton = MenuSectionButton() + let contactsButton = MenuSectionButton() + let requestsButton = MenuSectionButton() + let settingsButton = MenuSectionButton() + let dashboardButton = MenuSectionButton() - init() { - super.init(frame: .zero) - backgroundColor = Asset.neutralDark.color + init() { + super.init(frame: .zero) + backgroundColor = Asset.neutralDark.color - scanButton.set(title: Localized.Menu.scan, image: Asset.menuScan.image) - shareButton.set(title: Localized.Menu.share, image: Asset.menuShare.image) - chatsButton.set(title: Localized.Menu.chats, image: Asset.menuChats.image) - joinButton.set(title: Localized.Menu.join, image: Asset.permissionLogo.image) - requestsButton.set(title: Localized.Menu.requests, image: Asset.menuRequests.image) - contactsButton.set(title: Localized.Menu.contacts, image: Asset.menuContacts.image) - settingsButton.set(title: Localized.Menu.settings, image: Asset.menuSettings.image) - dashboardButton.set(title: Localized.Menu.dashboard, image: Asset.menuDashboard.image) + scanButton.set(title: Localized.Menu.scan, image: Asset.menuScan.image) + shareButton.set(title: Localized.Menu.share, image: Asset.menuShare.image) + chatsButton.set(title: Localized.Menu.chats, image: Asset.menuChats.image) + joinButton.set(title: Localized.Menu.join, image: Asset.permissionLogo.image) + requestsButton.set(title: Localized.Menu.requests, image: Asset.menuRequests.image) + contactsButton.set(title: Localized.Menu.contacts, image: Asset.menuContacts.image) + settingsButton.set(title: Localized.Menu.settings, image: Asset.menuSettings.image) + dashboardButton.set(title: Localized.Menu.dashboard, image: Asset.menuDashboard.image) - stackView.addArrangedSubview(chatsButton) - stackView.addArrangedSubview(contactsButton) - stackView.addArrangedSubview(requestsButton) - stackView.addArrangedSubview(scanButton) - stackView.addArrangedSubview(settingsButton) - stackView.addArrangedSubview(dashboardButton) - stackView.addArrangedSubview(joinButton) - stackView.addArrangedSubview(shareButton) + stackView.addArrangedSubview(chatsButton) + stackView.addArrangedSubview(contactsButton) + stackView.addArrangedSubview(requestsButton) + stackView.addArrangedSubview(scanButton) + stackView.addArrangedSubview(settingsButton) + stackView.addArrangedSubview(dashboardButton) + stackView.addArrangedSubview(joinButton) + stackView.addArrangedSubview(shareButton) - infoStackView.spacing = 10 - infoStackView.axis = .vertical - [buildLabel, versionLabel, xxdkVersionLabel].forEach { - $0.textColor = Asset.neutralWeak.color - $0.font = Fonts.Mulish.regular.font(size: 12.0) - infoStackView.addArrangedSubview($0) - } + infoStackView.spacing = 10 + infoStackView.axis = .vertical + [buildLabel, versionLabel, xxdkVersionLabel].forEach { + $0.textColor = Asset.neutralWeak.color + $0.font = Fonts.Mulish.regular.font(size: 12.0) + infoStackView.addArrangedSubview($0) + } - stackView.spacing = 28 - stackView.axis = .vertical - stackView.distribution = .equalSpacing + stackView.spacing = 28 + stackView.axis = .vertical + stackView.distribution = .equalSpacing - addSubview(headerView) - addSubview(stackView) - addSubview(infoStackView) + addSubview(headerView) + addSubview(stackView) + addSubview(infoStackView) - setupConstraints() - } + setupConstraints() + } - required init?(coder: NSCoder) { nil } + required init?(coder: NSCoder) { nil } - func select(item: MenuItem) { - switch item { - case .scan: - scanButton.set(color: Asset.brandPrimary.color) - case .chats: - chatsButton.set(color: Asset.brandPrimary.color) - case .contacts: - contactsButton.set(color: Asset.brandPrimary.color) - case .requests: - requestsButton.set(color: Asset.brandPrimary.color) - case .settings: - settingsButton.set(color: Asset.brandPrimary.color) - case .share, .join, .profile, .dashboard: - break - } + private func setupConstraints() { + headerView.snp.makeConstraints { + $0.top.equalTo(safeAreaLayoutGuide).offset(20) + $0.left.equalToSuperview().offset(30) + $0.right.equalToSuperview().offset(-24) } - private func setupConstraints() { - headerView.snp.makeConstraints { - $0.top.equalTo(safeAreaLayoutGuide).offset(20) - $0.left.equalToSuperview().offset(30) - $0.right.equalToSuperview().offset(-24) - } - - stackView.snp.makeConstraints { - $0.left.equalToSuperview().offset(26) - $0.top.equalTo(headerView.snp.bottom).offset(75) - } + stackView.snp.makeConstraints { + $0.left.equalToSuperview().offset(26) + $0.top.equalTo(headerView.snp.bottom).offset(75) + } - infoStackView.snp.makeConstraints { - $0.bottom.equalTo(safeAreaLayoutGuide).offset(-20) - $0.left.equalToSuperview().offset(20) - } + infoStackView.snp.makeConstraints { + $0.bottom.equalTo(safeAreaLayoutGuide).offset(-20) + $0.left.equalToSuperview().offset(20) } + } } diff --git a/Sources/OnboardingFeature/Controllers/OnboardingCodeController.swift b/Sources/OnboardingFeature/Controllers/OnboardingCodeController.swift index a2e1e353..c9b91738 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingCodeController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingCodeController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI import ScrollViewController diff --git a/Sources/OnboardingFeature/Controllers/OnboardingEmailController.swift b/Sources/OnboardingFeature/Controllers/OnboardingEmailController.swift index 1804e216..ab9a453e 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingEmailController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingEmailController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI import ScrollViewController diff --git a/Sources/OnboardingFeature/Controllers/OnboardingPhoneController.swift b/Sources/OnboardingFeature/Controllers/OnboardingPhoneController.swift index aa696246..c2d4aeba 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingPhoneController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingPhoneController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI import ScrollViewController @@ -95,7 +95,7 @@ public final class OnboardingPhoneController: UIViewController { navigator.perform(PresentCountryList(completion: { [weak self] in guard let self else { return } self.navigator.perform(DismissModal(from: self)) - self.viewModel.didChooseCountry($0) + self.viewModel.didChooseCountry($0 as! Country) })) }.store(in: &cancellables) diff --git a/Sources/OnboardingFeature/Controllers/OnboardingStartController.swift b/Sources/OnboardingFeature/Controllers/OnboardingStartController.swift index f0251cd3..7cb3faf0 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingStartController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingStartController.swift @@ -1,6 +1,6 @@ import UIKit import Combine -import XXNavigation +import Navigation import DI public final class OnboardingStartController: UIViewController { diff --git a/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift b/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift index 0959b1d1..0f192fbb 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingUsernameController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI import ScrollViewController diff --git a/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift b/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift index 72a1347a..93752425 100644 --- a/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift +++ b/Sources/OnboardingFeature/Controllers/OnboardingWelcomeController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import Defaults -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/Permissions/RequestPermissionController.swift b/Sources/Permissions/RequestPermissionController.swift index 0cdc65b0..24b09405 100644 --- a/Sources/Permissions/RequestPermissionController.swift +++ b/Sources/Permissions/RequestPermissionController.swift @@ -1,8 +1,8 @@ +import DI import UIKit import Shared import Combine -import XXNavigation -import DI +import Navigation public final class RequestPermissionController: UIViewController { @Dependency var navigator: Navigator diff --git a/Sources/ProfileFeature/Controllers/ProfileCodeController.swift b/Sources/ProfileFeature/Controllers/ProfileCodeController.swift index d55d52f3..8f6ff16f 100644 --- a/Sources/ProfileFeature/Controllers/ProfileCodeController.swift +++ b/Sources/ProfileFeature/Controllers/ProfileCodeController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DI import ScrollViewController diff --git a/Sources/ProfileFeature/Controllers/ProfileController.swift b/Sources/ProfileFeature/Controllers/ProfileController.swift index ca2abe5a..d80d7a9c 100644 --- a/Sources/ProfileFeature/Controllers/ProfileController.swift +++ b/Sources/ProfileFeature/Controllers/ProfileController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/ProfileFeature/Controllers/ProfileEmailController.swift b/Sources/ProfileFeature/Controllers/ProfileEmailController.swift index 0a4599c0..4fb0b42f 100644 --- a/Sources/ProfileFeature/Controllers/ProfileEmailController.swift +++ b/Sources/ProfileFeature/Controllers/ProfileEmailController.swift @@ -1,8 +1,8 @@ +import DI import UIKit import Shared import Combine -import XXNavigation -import DI +import Navigation import ScrollViewController public final class ProfileEmailController: UIViewController { diff --git a/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift b/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift index 061521d5..a1e42168 100644 --- a/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift +++ b/Sources/ProfileFeature/Controllers/ProfilePhoneController.swift @@ -1,8 +1,8 @@ +import DI import UIKit import Shared import Combine -import XXNavigation -import DI +import Navigation import ScrollViewController public final class ProfilePhoneController: UIViewController { @@ -62,7 +62,7 @@ public final class ProfilePhoneController: UIViewController { .sink { [unowned self] in navigator.perform(PresentCountryList(completion: { [weak self] in guard let self else { return } - self.viewModel.didChooseCountry($0) + self.viewModel.didChooseCountry($0 as! Country) })) }.store(in: &cancellables) diff --git a/Sources/RequestsFeature/Controllers/RequestsContainerController.swift b/Sources/RequestsFeature/Controllers/RequestsContainerController.swift index 03cf57c1..3a1c2488 100644 --- a/Sources/RequestsFeature/Controllers/RequestsContainerController.swift +++ b/Sources/RequestsFeature/Controllers/RequestsContainerController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import ContactFeature import DI diff --git a/Sources/RequestsFeature/Controllers/RequestsReceivedController.swift b/Sources/RequestsFeature/Controllers/RequestsReceivedController.swift index 1ab20d49..fe07a5bd 100644 --- a/Sources/RequestsFeature/Controllers/RequestsReceivedController.swift +++ b/Sources/RequestsFeature/Controllers/RequestsReceivedController.swift @@ -3,7 +3,7 @@ import Shared import Combine import XXModels import Countries -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/RestoreFeature/Controllers/RestoreController.swift b/Sources/RestoreFeature/Controllers/RestoreController.swift index 50d9f0e7..5e4c555b 100644 --- a/Sources/RestoreFeature/Controllers/RestoreController.swift +++ b/Sources/RestoreFeature/Controllers/RestoreController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/RestoreFeature/Controllers/RestoreListController.swift b/Sources/RestoreFeature/Controllers/RestoreListController.swift index 7cf56651..4d138ba3 100644 --- a/Sources/RestoreFeature/Controllers/RestoreListController.swift +++ b/Sources/RestoreFeature/Controllers/RestoreListController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift b/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift index f2c0aa2c..a1eec1bb 100644 --- a/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift +++ b/Sources/RestoreFeature/Controllers/RestoreSuccessController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DI public final class RestoreSuccessController: UIViewController { diff --git a/Sources/ScanFeature/Controllers/ScanContainerController.swift b/Sources/ScanFeature/Controllers/ScanContainerController.swift index b669014e..806d852e 100644 --- a/Sources/ScanFeature/Controllers/ScanContainerController.swift +++ b/Sources/ScanFeature/Controllers/ScanContainerController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/ScanFeature/Controllers/ScanController.swift b/Sources/ScanFeature/Controllers/ScanController.swift index af705b25..52369e75 100644 --- a/Sources/ScanFeature/Controllers/ScanController.swift +++ b/Sources/ScanFeature/Controllers/ScanController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import Permissions -import XXNavigation +import Navigation import CombineSchedulers import DI diff --git a/Sources/SearchFeature/Controllers/SearchContainerController.swift b/Sources/SearchFeature/Controllers/SearchContainerController.swift index db43b620..70f063ba 100644 --- a/Sources/SearchFeature/Controllers/SearchContainerController.swift +++ b/Sources/SearchFeature/Controllers/SearchContainerController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import XXModels -import XXNavigation +import Navigation import DrawerFeature import DI diff --git a/Sources/SearchFeature/Controllers/SearchLeftController.swift b/Sources/SearchFeature/Controllers/SearchLeftController.swift index 106c328f..a1a2b3c8 100644 --- a/Sources/SearchFeature/Controllers/SearchLeftController.swift +++ b/Sources/SearchFeature/Controllers/SearchLeftController.swift @@ -4,7 +4,7 @@ import Combine import XXModels import Defaults import Countries -import XXNavigation +import Navigation import DrawerFeature import DI @@ -160,7 +160,7 @@ final class SearchLeftController: UIViewController { .sink { [unowned self] in navigator.perform(PresentCountryList(completion: { [weak self] in guard let self else { return } - self.viewModel.didPick(country: $0) + self.viewModel.didPick(country: $0 as! Country) })) }.store(in: &cancellables) diff --git a/Sources/SearchFeature/Controllers/SearchRightController.swift b/Sources/SearchFeature/Controllers/SearchRightController.swift index fb7283c5..d8cc22ec 100644 --- a/Sources/SearchFeature/Controllers/SearchRightController.swift +++ b/Sources/SearchFeature/Controllers/SearchRightController.swift @@ -1,6 +1,6 @@ import UIKit import Combine -import XXNavigation +import Navigation import DI final class SearchRightController: UIViewController { diff --git a/Sources/SettingsFeature/Controllers/AccountDeleteController.swift b/Sources/SettingsFeature/Controllers/AccountDeleteController.swift index b695ec08..f3bde0ba 100644 --- a/Sources/SettingsFeature/Controllers/AccountDeleteController.swift +++ b/Sources/SettingsFeature/Controllers/AccountDeleteController.swift @@ -2,7 +2,7 @@ import UIKit import Shared import Combine import Defaults -import XXNavigation +import Navigation import DrawerFeature import ScrollViewController import DI diff --git a/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift b/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift index 5399ca6a..0ca63236 100644 --- a/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift +++ b/Sources/SettingsFeature/Controllers/SettingsAdvancedController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DI public final class SettingsAdvancedController: UIViewController { diff --git a/Sources/SettingsFeature/Controllers/SettingsController.swift b/Sources/SettingsFeature/Controllers/SettingsController.swift index 6dd584cf..c2d74e69 100644 --- a/Sources/SettingsFeature/Controllers/SettingsController.swift +++ b/Sources/SettingsFeature/Controllers/SettingsController.swift @@ -1,7 +1,7 @@ import UIKit import Shared import Combine -import XXNavigation +import Navigation import DrawerFeature import DI import ScrollViewController diff --git a/Sources/Shared/Models/MenuItem.swift b/Sources/Shared/Models/MenuItem.swift deleted file mode 100644 index 072b5033..00000000 --- a/Sources/Shared/Models/MenuItem.swift +++ /dev/null @@ -1,11 +0,0 @@ -public enum MenuItem { - case join - case scan - case chats - case share - case profile - case contacts - case requests - case settings - case dashboard -} diff --git a/Sources/Shared/Models/PermissionType.swift b/Sources/Shared/Models/PermissionType.swift deleted file mode 100644 index 43d28fbd..00000000 --- a/Sources/Shared/Models/PermissionType.swift +++ /dev/null @@ -1,5 +0,0 @@ -public enum PermissionType { - case camera - case library - case microphone -} diff --git a/Sources/TermsFeature/TermsConditionsController.swift b/Sources/TermsFeature/TermsConditionsController.swift index 95c43432..9485704f 100644 --- a/Sources/TermsFeature/TermsConditionsController.swift +++ b/Sources/TermsFeature/TermsConditionsController.swift @@ -1,10 +1,10 @@ +import DI import UIKit import WebKit import Shared import Combine import Defaults -import XXNavigation -import DI +import Navigation public final class TermsConditionsController: UIViewController { @Dependency var navigator: Navigator diff --git a/Sources/XXNavigation/Chat/PresentCamera.swift b/Sources/XXNavigation/Chat/PresentCamera.swift deleted file mode 100644 index ad8bd440..00000000 --- a/Sources/XXNavigation/Chat/PresentCamera.swift +++ /dev/null @@ -1,9 +0,0 @@ -import Navigation - -public struct PresentCamera: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} diff --git a/Sources/XXNavigation/Chat/PresentChat.swift b/Sources/XXNavigation/Chat/PresentChat.swift deleted file mode 100644 index 06fa031d..00000000 --- a/Sources/XXNavigation/Chat/PresentChat.swift +++ /dev/null @@ -1,36 +0,0 @@ -import UIKit -import XXModels -import Navigation -import DI - -public struct PresentChat: Navigation.Action { - public var contact: Contact - public var animated: Bool - - public init( - contact: Contact, - animated: Bool = true - ) { - self.contact = contact - self.animated = animated - } -} - -public struct PresentChatNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (Contact) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentChat, completion: @escaping () -> Void) { - let pushAction = Push(screen(action.contact), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping (Contact) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Chat/PresentChatList.swift b/Sources/XXNavigation/Chat/PresentChatList.swift deleted file mode 100644 index 14059d98..00000000 --- a/Sources/XXNavigation/Chat/PresentChatList.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentChatList: Navigation.Action { - public var animated: Bool = true - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentChatListNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentChatList, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Chat/PresentGroupChat.swift b/Sources/XXNavigation/Chat/PresentGroupChat.swift deleted file mode 100644 index a4e74db1..00000000 --- a/Sources/XXNavigation/Chat/PresentGroupChat.swift +++ /dev/null @@ -1,36 +0,0 @@ -import UIKit -import XXModels -import Navigation -import DI - -public struct PresentGroupChat: Navigation.Action { - public var model: GroupInfo - public var animated: Bool - - public init( - model: GroupInfo, - animated: Bool = true - ) { - self.model = model - self.animated = animated - } -} - -public struct PresentGroupChatNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (GroupInfo) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentGroupChat, completion: @escaping () -> Void) { - let pushAction = Push(screen(action.model), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping (GroupInfo) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Chat/PresentMemberList.swift b/Sources/XXNavigation/Chat/PresentMemberList.swift deleted file mode 100644 index 628c0613..00000000 --- a/Sources/XXNavigation/Chat/PresentMemberList.swift +++ /dev/null @@ -1,15 +0,0 @@ -import XXModels -import Navigation - -public struct PresentMemberList: Navigation.Action { - public var members: [Contact] - public var animated: Bool - - public init( - members: [Contact], - animated: Bool = true - ) { - self.members = members - self.animated = animated - } -} diff --git a/Sources/XXNavigation/Chat/PresentNewGroup.swift b/Sources/XXNavigation/Chat/PresentNewGroup.swift deleted file mode 100644 index d827f553..00000000 --- a/Sources/XXNavigation/Chat/PresentNewGroup.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentNewGroup: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentNewGroupNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentNewGroup, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Chat/PresentWebsite.swift b/Sources/XXNavigation/Chat/PresentWebsite.swift deleted file mode 100644 index cb46909b..00000000 --- a/Sources/XXNavigation/Chat/PresentWebsite.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Navigation -import Foundation - -public struct PresentWebsite: Navigation.Action { - public var url: URL - public var animated: Bool - - public init( - url: URL, - animated: Bool = true - ) { - self.url = url - self.animated = animated - } -} diff --git a/Sources/XXNavigation/Contact/PresentContact.swift b/Sources/XXNavigation/Contact/PresentContact.swift deleted file mode 100644 index b662609b..00000000 --- a/Sources/XXNavigation/Contact/PresentContact.swift +++ /dev/null @@ -1,36 +0,0 @@ -import UIKit -import XXModels -import Navigation -import DI - -public struct PresentContact: Navigation.Action { - public var contact: Contact - public var animated: Bool - - public init( - contact: Contact, - animated: Bool = true - ) { - self.contact = contact - self.animated = animated - } -} - -public struct PresentContactNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (Contact) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentContact, completion: @escaping () -> Void) { - let pushAction = Push(screen(action.contact), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping (Contact) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Contact/PresentContactList.swift b/Sources/XXNavigation/Contact/PresentContactList.swift deleted file mode 100644 index 4758d801..00000000 --- a/Sources/XXNavigation/Contact/PresentContactList.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentContactList: Navigation.Action { - public var animated: Bool = true - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentContactListNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentContactList, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Contact/PresentNickname.swift b/Sources/XXNavigation/Contact/PresentNickname.swift deleted file mode 100644 index 11d691e2..00000000 --- a/Sources/XXNavigation/Contact/PresentNickname.swift +++ /dev/null @@ -1,17 +0,0 @@ -import Navigation - -public struct PresentNickname: Navigation.Action { - public var prefilled: String? - public var completion: (String) -> Void - public var animated: Bool - - public init( - prefilled: String?, - completion: @escaping (String) -> Void, - animated: Bool = true - ) { - self.prefilled = prefilled - self.completion = completion - self.animated = animated - } -} diff --git a/Sources/XXNavigation/CustomActions/OpenLeft.swift b/Sources/XXNavigation/CustomActions/OpenLeft.swift deleted file mode 100644 index 4296f39e..00000000 --- a/Sources/XXNavigation/CustomActions/OpenLeft.swift +++ /dev/null @@ -1,310 +0,0 @@ -import UIKit -import Navigation - -/// Open left view controller on provided parent view controller -public struct OpenLeft: Action { - /// - Parameters: - /// - viewController: View controller to present - /// - parent: Parent view controller from which presentation should happen - /// - animated: Animate the transition - public init( - _ viewController: UIViewController, - from parent: UIViewController, - animated: Bool = true - ) { - self.viewController = viewController - self.parent = parent - self.animated = animated - } - - /// View controller to present - public var viewController: UIViewController - - /// Parent view controller from which presentation should happen - public var parent: UIViewController - - /// Animate the transition - public var animated: Bool -} - -/// Performs `OpenLeft` action -public struct OpenLeftNavigator: TypedNavigator { - let transitioningDelegate = SidePresenter() - - public init() {} - - public func perform(_ action: OpenLeft, completion: @escaping () -> Void) { - action.viewController.transitioningDelegate = transitioningDelegate - action.viewController.modalPresentationStyle = .overFullScreen - - action.parent.present( - action.viewController, - animated: action.animated, - completion: completion - ) - } -} - -final class SidePresenter: NSObject, UIViewControllerTransitioningDelegate { - public init(dismissInteractor: SideMenuDismissInteracting = SideMenuDismissInteractor(), - menuAnimator: SideMenuAnimating = SideMenuAnimator(), - viewAnimator: UIViewAnimating.Type = UIView.self) { - self.dismissInteractor = dismissInteractor - self.menuAnimator = menuAnimator - self.viewAnimator = viewAnimator - super.init() - } - - let dismissInteractor: SideMenuDismissInteracting - let menuAnimator: SideMenuAnimating - let viewAnimator: UIViewAnimating.Type - - // MARK: Presenting - - public func present(_ viewControllers: UIViewController..., from parent: UIViewController) { - guard let screen = viewControllers.first else { - fatalError("Tried to present empty list of view controllers") - } - - screen.modalPresentationStyle = .overFullScreen - screen.transitioningDelegate = self - parent.present(screen, animated: true) - } - - // MARK: UIViewControllerTransitioningDelegate - - public func animationController( - forPresented presented: UIViewController, - presenting: UIViewController, - source: UIViewController - ) -> UIViewControllerAnimatedTransitioning? { - SideMenuPresentTransition(dismissInteractor: dismissInteractor, - menuAnimator: menuAnimator, - viewAnimator: viewAnimator) - } - - public func animationController( - forDismissed dismissed: UIViewController - ) -> UIViewControllerAnimatedTransitioning? { - SideMenuDismissTransition(menuAnimator: menuAnimator, - viewAnimator: viewAnimator) - } - - public func interactionControllerForDismissal( - using animator: UIViewControllerAnimatedTransitioning - ) -> UIViewControllerInteractiveTransitioning? { - dismissInteractor.interactionInProgress ? dismissInteractor : nil - } -} - -public protocol SideMenuAnimating { - func animate(in containerView: UIView, to progress: CGFloat) -} - -public struct SideMenuAnimator: SideMenuAnimating { - public init() {} - - public func animate(in containerView: UIView, to progress: CGFloat) { - guard let fromView = containerView.viewWithTag(SideMenuPresentTransition.fromViewTag) - else { return } - - let cornerRadius = progress * 24 - let shadowOpacity = Float(progress) - let offsetX = containerView.bounds.size.width * 0.5 * progress - let offsetY = containerView.bounds.size.height * 0.08 * progress - let scale = 1 - (0.25 * progress) - - fromView.subviews.first?.layer.cornerRadius = cornerRadius - fromView.layer.shadowOpacity = shadowOpacity - fromView.transform = CGAffineTransform.identity - .translatedBy(x: offsetX, y: offsetY) - .scaledBy(x: scale, y: scale) - } -} - -import UIKit -import Shared - -public protocol SideMenuDismissInteracting: UIViewControllerInteractiveTransitioning { - var interactionInProgress: Bool { get } - - func setup(view: UIView, action: @escaping EmptyClosure) -} - -public final class SideMenuDismissInteractor: UIPercentDrivenInteractiveTransition, SideMenuDismissInteracting { - private var action: EmptyClosure? - private var shouldFinishTransition = false - - // MARK: SideMenuDismissInteracting - - public var interactionInProgress = false - - public func setup(view: UIView, action: @escaping EmptyClosure) { - let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePanGesture(_:))) - view.addGestureRecognizer(panRecognizer) - - let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTapGesture(_:))) - view.addGestureRecognizer(tapRecognizer) - - self.action = action - } - - // MARK: Gesture handling - - @objc - private func handleTapGesture(_ recognizer: UITapGestureRecognizer) { - action?() - } - - @objc - private func handlePanGesture(_ recognizer: UIPanGestureRecognizer) { - guard let view = recognizer.view, - let containerView = view.superview - else { return } - - let viewWidth = containerView.bounds.size.width - guard viewWidth > 0 else { return } - - let translation = recognizer.translation(in: view) - let progress = min(1, max(0, -translation.x / (viewWidth * 0.8))) - - switch recognizer.state { - case .possible, .failed: - interactionInProgress = false - - case .began: - interactionInProgress = true - shouldFinishTransition = false - action?() - - case .changed: - shouldFinishTransition = progress >= 0.5 - update(progress) - - case .cancelled: - interactionInProgress = false - cancel() - - case .ended: - interactionInProgress = false - shouldFinishTransition ? finish() : cancel() - - @unknown default: - interactionInProgress = false - cancel() - } - } -} - -import UIKit - -final class SideMenuDismissTransition: NSObject, UIViewControllerAnimatedTransitioning { - - init(menuAnimator: SideMenuAnimating, - viewAnimator: UIViewAnimating.Type) { - self.menuAnimator = menuAnimator - self.viewAnimator = viewAnimator - super.init() - } - - let menuAnimator: SideMenuAnimating - let viewAnimator: UIViewAnimating.Type - - // MARK: UIViewControllerAnimatedTransitioning - - func transitionDuration(using context: UIViewControllerContextTransitioning?) -> TimeInterval { 0.25 } - - func animateTransition(using context: UIViewControllerContextTransitioning) { - viewAnimator.animate( - withDuration: transitionDuration(using: context), - animations: { - self.menuAnimator.animate(in: context.containerView, to: 0) - }, - completion: { _ in - let isCancelled = context.transitionWasCancelled - context.completeTransition(isCancelled == false) - } - ) - } -} - -import UIKit -import Shared - -final class SideMenuPresentTransition: NSObject, UIViewControllerAnimatedTransitioning { - static let fromViewTag = UUID().hashValue - - init( - dismissInteractor: SideMenuDismissInteracting, - menuAnimator: SideMenuAnimating, - viewAnimator: UIViewAnimating.Type - ) { - self.dismissInteractor = dismissInteractor - self.menuAnimator = menuAnimator - self.viewAnimator = viewAnimator - super.init() - } - - let dismissInteractor: SideMenuDismissInteracting - let menuAnimator: SideMenuAnimating - let viewAnimator: UIViewAnimating.Type - - // MARK: UIViewControllerAnimatedTransitioning - - func transitionDuration(using context: UIViewControllerContextTransitioning?) -> TimeInterval { 0.25 } - - func animateTransition(using context: UIViewControllerContextTransitioning) { - guard let fromVC = context.viewController(forKey: .from), - let fromSnapshot = fromVC.view.snapshotView(afterScreenUpdates: true), - let toVC = context.viewController(forKey: .to) - else { - context.completeTransition(false) - return - } - - context.containerView.addSubview(toVC.view) - toVC.view.frame = context.containerView.bounds - - let fromView = UIView() - fromView.tag = Self.fromViewTag - context.containerView.addSubview(fromView) - fromView.frame = context.containerView.bounds - fromView.layer.shadowColor = UIColor.black.cgColor - fromView.layer.shadowOpacity = 1 - fromView.layer.shadowOffset = .zero - fromView.layer.shadowRadius = 32 - fromView.addSubview(fromSnapshot) - fromSnapshot.frame = fromView.bounds - fromSnapshot.layer.cornerRadius = 0 - fromSnapshot.layer.masksToBounds = true - - dismissInteractor.setup( - view: fromView, - action: { fromVC.dismiss(animated: true) } - ) - - viewAnimator.animate( - withDuration: transitionDuration(using: context), - animations: { - self.menuAnimator.animate(in: context.containerView, to: 1) - }, - completion: { _ in - let isCancelled = context.transitionWasCancelled - context.completeTransition(isCancelled == false) - } - ) - } -} - -import UIKit -import Shared - -public protocol UIViewAnimating { - static func animate( - withDuration duration: TimeInterval, - animations: @escaping EmptyClosure, - completion: ((Bool) -> Void)? - ) -} - -extension UIView: UIViewAnimating {} diff --git a/Sources/XXNavigation/CustomActions/OpenUp.swift b/Sources/XXNavigation/CustomActions/OpenUp.swift deleted file mode 100644 index 6aea3325..00000000 --- a/Sources/XXNavigation/CustomActions/OpenUp.swift +++ /dev/null @@ -1,201 +0,0 @@ -import UIKit -import Navigation - -/// Open up view controller on provided parent view controller -public struct OpenUp: Action { - /// - Parameters: - /// - viewController: View controller to present - /// - parent: Parent view controller from which presentation should happen - /// - animated: Animate the transition - /// - dismissable: Dismissable upon background touch flag - public init( - _ viewController: UIViewController, - from parent: UIViewController, - animated: Bool = true, - dismissable: Bool = true - ) { - self.viewController = viewController - self.parent = parent - self.animated = animated - self.dismissable = dismissable - } - - /// View controller to present - public var viewController: UIViewController - - /// Parent view controller from which presentation should happen - public var parent: UIViewController - - /// Animate the transition - public var animated: Bool - - /// Dismissable upon background touch flag - public var dismissable: Bool -} - -/// Performs `OpenUp` action -public struct OpenUpNavigator: TypedNavigator { - let transitioningDelegate = BottomPresenter() - - public init() {} - - public func perform(_ action: OpenUp, completion: @escaping () -> Void) { - transitioningDelegate.isDismissableOnBackgroundTouch = action.dismissable - action.viewController.transitioningDelegate = transitioningDelegate - action.viewController.modalPresentationStyle = .overFullScreen - - action.parent.present( - action.viewController, - animated: action.animated, - completion: completion - ) - } -} - -final class BottomPresenter: NSObject, UIViewControllerTransitioningDelegate { - var isDismissableOnBackgroundTouch: Bool = true - private var transition: BottomTransition? - - public func animationController( - forPresented presented: UIViewController, - presenting: UIViewController, - source: UIViewController - ) -> UIViewControllerAnimatedTransitioning? { - transition = BottomTransition(isDismissableOnBackgroundTouch) { [weak self] in - self?.transition = nil - } - - return transition - } - - public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { - transition?.direction = .dismiss - return transition - } -} - -import Combine -import SnapKit -final class BottomTransition: NSObject, UIViewControllerAnimatedTransitioning { - enum Direction { - case present - case dismiss - } - - let isDismissableOnBackground: Bool - var direction: Direction = .present - private let onDismissal: (() -> Void)? - private weak var darkOverlayView: UIControl? - private weak var topConstraint: Constraint? - private weak var bottomConstraint: Constraint? - private var cancellables = Set<AnyCancellable>() - - private var presentedConstraints: [NSLayoutConstraint] = [] - private var dismissedConstraints: [NSLayoutConstraint] = [] - - init( - _ isDismissableOnBackground: Bool = true, - onDismissal: (() -> Void)? - ) { - self.onDismissal = onDismissal - self.isDismissableOnBackground = isDismissableOnBackground - super.init() - } - - func transitionDuration(using context: UIViewControllerContextTransitioning?) -> TimeInterval { 0.5 } - - func animateTransition(using context: UIViewControllerContextTransitioning) { - switch direction { - case .present: - present(using: context) - case .dismiss: - dismiss(using: context) - } - } - - private func present(using context: UIViewControllerContextTransitioning) { - guard let presentingController = context.viewController(forKey: .from), - let presentedView = context.view(forKey: .to) else { - context.completeTransition(false) - return - } - - let darkOverlayView = UIControl() - self.darkOverlayView = darkOverlayView - - darkOverlayView.alpha = 0.0 - darkOverlayView.backgroundColor = UIColor.black.withAlphaComponent(0.5) - context.containerView.addSubview(darkOverlayView) - darkOverlayView.frame = context.containerView.bounds - - darkOverlayView - .publisher(for: .touchUpInside) - .sink { [weak presentingController] _ in - guard self.isDismissableOnBackground else { return } - presentingController?.dismiss(animated: true) - }.store(in: &cancellables) - - context.containerView.addSubview(presentedView) - presentedView.translatesAutoresizingMaskIntoConstraints = false - - presentedConstraints = [ - presentedView.leftAnchor.constraint(equalTo: context.containerView.leftAnchor), - presentedView.rightAnchor.constraint(equalTo: context.containerView.rightAnchor), - presentedView.bottomAnchor.constraint(equalTo: context.containerView.bottomAnchor), - presentedView.topAnchor.constraint( - greaterThanOrEqualTo: context.containerView.safeAreaLayoutGuide.topAnchor, - constant: 60 - ) - ] - - dismissedConstraints = [ - presentedView.leftAnchor.constraint(equalTo: context.containerView.leftAnchor), - presentedView.rightAnchor.constraint(equalTo: context.containerView.rightAnchor), - presentedView.topAnchor.constraint(equalTo: context.containerView.bottomAnchor) - ] - - NSLayoutConstraint.activate(dismissedConstraints) - - context.containerView.setNeedsLayout() - context.containerView.layoutIfNeeded() - - NSLayoutConstraint.deactivate(dismissedConstraints) - NSLayoutConstraint.activate(presentedConstraints) - - UIView.animate( - withDuration: transitionDuration(using: context), - delay: 0, - usingSpringWithDamping: 1, - initialSpringVelocity: 0, - options: .curveEaseInOut, - animations: { - darkOverlayView.alpha = 1.0 - context.containerView.setNeedsLayout() - context.containerView.layoutIfNeeded() - }, - completion: { _ in - context.completeTransition(true) - }) - } - - private func dismiss(using context: UIViewControllerContextTransitioning) { - NSLayoutConstraint.deactivate(presentedConstraints) - NSLayoutConstraint.activate(dismissedConstraints) - - UIView.animate( - withDuration: transitionDuration(using: context), - delay: 0, - usingSpringWithDamping: 1, - initialSpringVelocity: 0, - options: .curveEaseInOut, - animations: { [weak darkOverlayView] in - darkOverlayView?.alpha = 0.0 - context.containerView.setNeedsLayout() - context.containerView.layoutIfNeeded() - }, - completion: { [weak self] _ in - context.completeTransition(true) - self?.onDismissal?() - }) - } -} diff --git a/Sources/XXNavigation/Export.swift b/Sources/XXNavigation/Export.swift deleted file mode 100644 index dfaf1c7d..00000000 --- a/Sources/XXNavigation/Export.swift +++ /dev/null @@ -1 +0,0 @@ -@_exported import Navigation diff --git a/Sources/XXNavigation/Onboarding/PresentOnboardingCode.swift b/Sources/XXNavigation/Onboarding/PresentOnboardingCode.swift deleted file mode 100644 index 1853c774..00000000 --- a/Sources/XXNavigation/Onboarding/PresentOnboardingCode.swift +++ /dev/null @@ -1,42 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentOnboardingCode: Navigation.Action { - public var isEmail: Bool - public var content: String - public var confirmationId: String - public var animated: Bool - - public init( - isEmail: Bool, - content: String, - confirmationId: String, - animated: Bool = true - ) { - self.isEmail = isEmail - self.content = content - self.confirmationId = confirmationId - self.animated = animated - } -} - -public struct PresentOnboardingCodeNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (Bool, String, String) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentOnboardingCode, completion: @escaping () -> Void) { - let controller = screen(action.isEmail, action.content, action.confirmationId) - let pushAction = Push(controller, on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping (Bool, String, String) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Onboarding/PresentOnboardingEmail.swift b/Sources/XXNavigation/Onboarding/PresentOnboardingEmail.swift deleted file mode 100644 index c1786594..00000000 --- a/Sources/XXNavigation/Onboarding/PresentOnboardingEmail.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentOnboardingEmail: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentOnboardingEmailNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentOnboardingEmail, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Onboarding/PresentOnboardingPhone.swift b/Sources/XXNavigation/Onboarding/PresentOnboardingPhone.swift deleted file mode 100644 index 95c6e958..00000000 --- a/Sources/XXNavigation/Onboarding/PresentOnboardingPhone.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentOnboardingPhone: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentOnboardingPhoneNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentOnboardingPhone, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Onboarding/PresentOnboardingStart.swift b/Sources/XXNavigation/Onboarding/PresentOnboardingStart.swift deleted file mode 100644 index 943b31d7..00000000 --- a/Sources/XXNavigation/Onboarding/PresentOnboardingStart.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentOnboardingStart: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentOnboardingStartNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentOnboardingStart, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Onboarding/PresentOnboardingUsername.swift b/Sources/XXNavigation/Onboarding/PresentOnboardingUsername.swift deleted file mode 100644 index 91817a3f..00000000 --- a/Sources/XXNavigation/Onboarding/PresentOnboardingUsername.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentOnboardingUsername: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentOnboardingUsernameNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentOnboardingUsername, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Onboarding/PresentOnboardingWelcome.swift b/Sources/XXNavigation/Onboarding/PresentOnboardingWelcome.swift deleted file mode 100644 index 64a0fdd7..00000000 --- a/Sources/XXNavigation/Onboarding/PresentOnboardingWelcome.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentOnboardingWelcome: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentOnboardingWelcomeNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentOnboardingWelcome, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Onboarding/PresentTermsAndConditions.swift b/Sources/XXNavigation/Onboarding/PresentTermsAndConditions.swift deleted file mode 100644 index 0ec1ae5c..00000000 --- a/Sources/XXNavigation/Onboarding/PresentTermsAndConditions.swift +++ /dev/null @@ -1,40 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentTermsAndConditions: Navigation.Action { - public var popAllowed: Bool - public var animated: Bool - - public init( - popAllowed: Bool = true, - animated: Bool = true - ) { - self.popAllowed = popAllowed - self.animated = animated - } -} - -public struct PresentTermsAndConditionsNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentTermsAndConditions, completion: @escaping () -> Void) { - let navAction: Action - if action.popAllowed { - navAction = Push(screen(), on: navigationController(), animated: action.animated) - } else { - navAction = SetStack([screen()], on: navigationController(), animated: action.animated) - } - navigator.perform(navAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentActivitySheet.swift b/Sources/XXNavigation/PresentActivitySheet.swift deleted file mode 100644 index ae08e595..00000000 --- a/Sources/XXNavigation/PresentActivitySheet.swift +++ /dev/null @@ -1,42 +0,0 @@ -import UIKit -import XXModels -import Navigation -import DI - -public struct PresentActivitySheet: Navigation.Action { - public var items: [Any] - public var animated: Bool - - public init( - items: [Any], - animated: Bool = true - ) { - self.items = items - self.animated = animated - } -} - -public struct PresentActivitySheetNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: ([Any]) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentActivitySheet, completion: @escaping () -> Void) { - if let topViewController = navigationController().topViewController { - let modalAction = PresentModal( - screen(action.items), - from: topViewController, - animated: action.animated - ) - navigator.perform(modalAction, completion: completion) - } - } - - public init( - screen: @escaping ([Any]) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentCountryList.swift b/Sources/XXNavigation/PresentCountryList.swift deleted file mode 100644 index bd162148..00000000 --- a/Sources/XXNavigation/PresentCountryList.swift +++ /dev/null @@ -1,38 +0,0 @@ -import UIKit -import Shared -import Navigation -import DI - -public struct PresentCountryList: Navigation.Action { - public var completion: ((Country) -> Void) - public var animated: Bool - - public init( - completion: @escaping (Country) -> Void, - animated: Bool = true - ) { - self.animated = animated - self.completion = completion - } -} - -public struct PresentCountryListNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (@escaping (Country) -> Void) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentCountryList, completion: @escaping () -> Void) { - if let topViewController = navigationController().topViewController { - let modalAction = PresentModal(screen(action.completion), from: topViewController) - navigator.perform(modalAction, completion: completion) - } - } - - public init( - screen: @escaping (@escaping (Country) -> Void) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentDrawer.swift b/Sources/XXNavigation/PresentDrawer.swift deleted file mode 100644 index 9d659610..00000000 --- a/Sources/XXNavigation/PresentDrawer.swift +++ /dev/null @@ -1,46 +0,0 @@ -import UIKit -import Navigation -import DrawerFeature -import DI - -public struct PresentDrawer: Navigation.Action { - public var items: [DrawerItem] - public var dismissable: Bool - public var animated: Bool - - public init( - items: [DrawerItem], - dismissable: Bool = true, - animated: Bool = true - ) { - self.items = items - self.dismissable = dismissable - self.animated = animated - } -} - -public struct PresentDrawerNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: ([DrawerItem]) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentDrawer, completion: @escaping () -> Void) { - if let topViewController = navigationController().topViewController { - let openUpAction = OpenUp( - screen(action.items), - from: topViewController, - animated: action.animated, - dismissable: action.dismissable - ) - navigator.perform(openUpAction, completion: completion) - } - } - - public init( - screen: @escaping ([DrawerItem]) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentMenu.swift b/Sources/XXNavigation/PresentMenu.swift deleted file mode 100644 index ab9a82ec..00000000 --- a/Sources/XXNavigation/PresentMenu.swift +++ /dev/null @@ -1,42 +0,0 @@ -import UIKit -import Shared -import Navigation -import DI - -public struct PresentMenu: Navigation.Action { - public var currentItem: MenuItem - public var animated: Bool - - public init( - currentItem: MenuItem, - animated: Bool = true - ) { - self.currentItem = currentItem - self.animated = animated - } -} - -public struct PresentMenuNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var navigationController: () -> UINavigationController - var screen: (MenuItem) -> UIViewController - - public func perform(_ action: PresentMenu, completion: @escaping () -> Void) { - if let topViewController = navigationController().topViewController { - let openLeftAction = OpenLeft( - screen(action.currentItem), - from: topViewController, - animated: action.animated - ) - navigator.perform(openLeftAction, completion: completion) - } - } - - public init( - screen: @escaping (MenuItem) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentPermissionRequest.swift b/Sources/XXNavigation/PresentPermissionRequest.swift deleted file mode 100644 index d126d596..00000000 --- a/Sources/XXNavigation/PresentPermissionRequest.swift +++ /dev/null @@ -1,38 +0,0 @@ -import UIKit -import Shared -import Navigation -import DI - -public struct PresentPermissionRequest: Navigation.Action { - public var type: PermissionType - public var animated: Bool - - public init( - type: PermissionType, - animated: Bool = true - ) { - self.type = type - self.animated = animated - } -} - -public struct PresentPermissionRequestNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (PermissionType) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentPermissionRequest, completion: @escaping () -> Void) { - if let topViewController = navigationController().topViewController { - let modalAction = PresentModal(screen(action.type), from: topViewController) - navigator.perform(modalAction, completion: completion) - } - } - - public init( - screen: @escaping (PermissionType) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentPhotoLibrary.swift b/Sources/XXNavigation/PresentPhotoLibrary.swift deleted file mode 100644 index 8174fe21..00000000 --- a/Sources/XXNavigation/PresentPhotoLibrary.swift +++ /dev/null @@ -1,34 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentPhotoLibrary: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentPhotoLibraryNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIImagePickerController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentPhotoLibrary, completion: @escaping () -> Void) { - if let topViewController = navigationController().topViewController { - let imagePicker = screen() - imagePicker.delegate = topViewController as? UIImagePickerControllerDelegate & UINavigationControllerDelegate - let modalAction = PresentModal(imagePicker, from: topViewController) - navigator.perform(modalAction, completion: completion) - } - } - - public init( - screen: @escaping () -> UIImagePickerController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentScan.swift b/Sources/XXNavigation/PresentScan.swift deleted file mode 100644 index 87cec305..00000000 --- a/Sources/XXNavigation/PresentScan.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentScan: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentScanNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentScan, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/PresentSearch.swift b/Sources/XXNavigation/PresentSearch.swift deleted file mode 100644 index 6f5d2aba..00000000 --- a/Sources/XXNavigation/PresentSearch.swift +++ /dev/null @@ -1,43 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentSearch: Navigation.Action { - public var searching: String? - public var replacing: Bool - public var animated: Bool - - public init( - searching: String? = nil, - replacing: Bool = true, - animated: Bool = true - ) { - self.searching = searching - self.replacing = replacing - self.animated = animated - } -} - -public struct PresentSearchNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (String?) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentSearch, completion: @escaping () -> Void) { - let navAction: Action - if action.replacing { - navAction = SetStack([screen(action.searching)], on: navigationController(), animated: action.animated) - } else { - navAction = Push(screen(action.searching), on: navigationController(), animated: action.animated) - } - navigator.perform(navAction, completion: completion) - } - - public init( - screen: @escaping (String?) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Profile/PresentProfile.swift b/Sources/XXNavigation/Profile/PresentProfile.swift deleted file mode 100644 index 6dfdd650..00000000 --- a/Sources/XXNavigation/Profile/PresentProfile.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentProfile: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentProfileNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentProfile, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Profile/PresentProfileCode.swift b/Sources/XXNavigation/Profile/PresentProfileCode.swift deleted file mode 100644 index 3c6a9134..00000000 --- a/Sources/XXNavigation/Profile/PresentProfileCode.swift +++ /dev/null @@ -1,42 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentProfileCode: Navigation.Action { - public var isEmail: Bool - public var content: String - public var confirmationId: String - public var animated: Bool - - public init( - isEmail: Bool, - content: String, - confirmationId: String, - animated: Bool = true - ) { - self.isEmail = isEmail - self.content = content - self.confirmationId = confirmationId - self.animated = animated - } -} - -public struct PresentProfileCodeNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: (Bool, String, String) -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentProfileCode, completion: @escaping () -> Void) { - let controller = screen(action.isEmail, action.content, action.confirmationId) - let pushAction = Push(controller, on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping (Bool, String, String) -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Profile/PresentProfileEmail.swift b/Sources/XXNavigation/Profile/PresentProfileEmail.swift deleted file mode 100644 index c4844038..00000000 --- a/Sources/XXNavigation/Profile/PresentProfileEmail.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentProfileEmail: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentProfileEmailNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentProfileEmail, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Profile/PresentProfilePhone.swift b/Sources/XXNavigation/Profile/PresentProfilePhone.swift deleted file mode 100644 index 37235bb9..00000000 --- a/Sources/XXNavigation/Profile/PresentProfilePhone.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentProfilePhone: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentProfilePhoneNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentProfilePhone, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/RestoreAndBackup/PresentPassphrase.swift b/Sources/XXNavigation/RestoreAndBackup/PresentPassphrase.swift deleted file mode 100644 index b566ea3c..00000000 --- a/Sources/XXNavigation/RestoreAndBackup/PresentPassphrase.swift +++ /dev/null @@ -1,17 +0,0 @@ -import Navigation - -public struct PresentPassphrase: Navigation.Action { - public var onCancel: () -> Void - public var onPasspharse: (String) -> Void - public var animated: Bool - - public init( - onCancel: @escaping () -> Void, - onPassphrase: @escaping (String) -> Void, - animated: Bool = true - ) { - self.onCancel = onCancel - self.onPasspharse = onPassphrase - self.animated = animated - } -} diff --git a/Sources/XXNavigation/RestoreAndBackup/PresentRequests.swift b/Sources/XXNavigation/RestoreAndBackup/PresentRequests.swift deleted file mode 100644 index a72fbe33..00000000 --- a/Sources/XXNavigation/RestoreAndBackup/PresentRequests.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentRequests: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentRequestsNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentRequests, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/RestoreAndBackup/PresentRestoreList.swift b/Sources/XXNavigation/RestoreAndBackup/PresentRestoreList.swift deleted file mode 100644 index e1121be7..00000000 --- a/Sources/XXNavigation/RestoreAndBackup/PresentRestoreList.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentRestoreList: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentRestoreListNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentRestoreList, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/RestoreAndBackup/PresentSFTP.swift b/Sources/XXNavigation/RestoreAndBackup/PresentSFTP.swift deleted file mode 100644 index d19e06c5..00000000 --- a/Sources/XXNavigation/RestoreAndBackup/PresentSFTP.swift +++ /dev/null @@ -1,14 +0,0 @@ -import Navigation - -public struct PresentSFTP: Navigation.Action { - public var completion: (String, String, String) -> Void - public var animated: Bool - - public init( - completion: @escaping (String, String, String) -> Void, - animated: Bool = true - ) { - self.completion = completion - self.animated = animated - } -} diff --git a/Sources/XXNavigation/Settings/PresentSettings.swift b/Sources/XXNavigation/Settings/PresentSettings.swift deleted file mode 100644 index 387bc789..00000000 --- a/Sources/XXNavigation/Settings/PresentSettings.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentSettings: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentSettingsNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentSettings, completion: @escaping () -> Void) { - let setStackAction = SetStack([screen()], on: navigationController(), animated: action.animated) - navigator.perform(setStackAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Settings/PresentSettingsAccountDelete.swift b/Sources/XXNavigation/Settings/PresentSettingsAccountDelete.swift deleted file mode 100644 index 76b73f1e..00000000 --- a/Sources/XXNavigation/Settings/PresentSettingsAccountDelete.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentSettingsAccountDelete: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentSettingsAccountDeleteNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentSettingsAccountDelete, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Settings/PresentSettingsAdvanced.swift b/Sources/XXNavigation/Settings/PresentSettingsAdvanced.swift deleted file mode 100644 index 0c008515..00000000 --- a/Sources/XXNavigation/Settings/PresentSettingsAdvanced.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentSettingsAdvanced: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentSettingsAdvancedNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentSettingsAdvanced, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Sources/XXNavigation/Settings/PresentSettingsBackup.swift b/Sources/XXNavigation/Settings/PresentSettingsBackup.swift deleted file mode 100644 index 85856658..00000000 --- a/Sources/XXNavigation/Settings/PresentSettingsBackup.swift +++ /dev/null @@ -1,30 +0,0 @@ -import UIKit -import Navigation -import DI - -public struct PresentSettingsBackup: Navigation.Action { - public var animated: Bool - - public init(animated: Bool = true) { - self.animated = animated - } -} - -public struct PresentSettingsBackupNavigator: TypedNavigator { - @Dependency var navigator: Navigator - var screen: () -> UIViewController - var navigationController: () -> UINavigationController - - public func perform(_ action: PresentSettingsBackup, completion: @escaping () -> Void) { - let pushAction = Push(screen(), on: navigationController(), animated: action.animated) - navigator.perform(pushAction, completion: completion) - } - - public init( - screen: @escaping () -> UIViewController, - navigationController: @escaping () -> UINavigationController - ) { - self.screen = screen - self.navigationController = navigationController - } -} diff --git a/Tests/DefaultsTests/KeyObjectTests.swift b/Tests/DefaultsTests/KeyObjectTests.swift index 1b3bf380..0cbf3b4f 100644 --- a/Tests/DefaultsTests/KeyObjectTests.swift +++ b/Tests/DefaultsTests/KeyObjectTests.swift @@ -1,84 +1,84 @@ -import XCTest import DI +import XCTest @testable import Defaults final class KeyObjectSpec: XCTestCase { - func testGetCachedValue() { - var didSetObject: Any? - var didSetObjectForKey: String? + func testGetCachedValue() { + var didSetObject: Any? + var didSetObjectForKey: String? - let sut = KeyObjectStore( - objectForKey: { _ in fatalError() }, - setObjectForKey: { object, key in - didSetObject = object - didSetObjectForKey = key - }, removeObjectForKey: { _ in fatalError() } - ) + let sut = KeyObjectStore( + objectForKey: { _ in fatalError() }, + setObjectForKey: { object, key in + didSetObject = object + didSetObjectForKey = key + }, removeObjectForKey: { _ in fatalError() } + ) - DependencyInjection.Container.shared.register(sut) + DI.Container.shared.register(sut) - @KeyObject(.email, defaultValue: "1234") var email: String + @KeyObject(.email, defaultValue: "1234") var email: String - email = "5678" - assert(didSetObject as! String == "5678") - assert(didSetObjectForKey == Key.email.rawValue) - } + email = "5678" + assert(didSetObject as! String == "5678") + assert(didSetObjectForKey == Key.email.rawValue) + } - func testGetDefaultValue() { - var didGetObjectForKey: String? + func testGetDefaultValue() { + var didGetObjectForKey: String? - let sut = KeyObjectStore( - objectForKey: { didGetObjectForKey = $0 }, - setObjectForKey: { _,_ in fatalError() }, - removeObjectForKey: { _ in fatalError() } - ) + let sut = KeyObjectStore( + objectForKey: { didGetObjectForKey = $0 }, + setObjectForKey: { _,_ in fatalError() }, + removeObjectForKey: { _ in fatalError() } + ) - DependencyInjection.Container.shared.register(sut) + DI.Container.shared.register(sut) - let defaultValue = "1234" - @KeyObject(.email, defaultValue: defaultValue) var email: String + let defaultValue = "1234" + @KeyObject(.email, defaultValue: defaultValue) var email: String - assert(email == defaultValue) - assert(didGetObjectForKey == Key.email.rawValue) - } + assert(email == defaultValue) + assert(didGetObjectForKey == Key.email.rawValue) + } - func testSetValue() { - var didSetObject: Any? - var didSetObjectForKey: String? + func testSetValue() { + var didSetObject: Any? + var didSetObjectForKey: String? - let sut = KeyObjectStore( - objectForKey: { _ in fatalError() }, - setObjectForKey: { object, key in - didSetObject = object - didSetObjectForKey = key - }, removeObjectForKey: { _ in fatalError() } - ) + let sut = KeyObjectStore( + objectForKey: { _ in fatalError() }, + setObjectForKey: { object, key in + didSetObject = object + didSetObjectForKey = key + }, removeObjectForKey: { _ in fatalError() } + ) - DependencyInjection.Container.shared.register(sut) + DI.Container.shared.register(sut) - @KeyObject(.phone, defaultValue: "1234") var phone: String - phone = "5678" + @KeyObject(.phone, defaultValue: "1234") var phone: String + phone = "5678" - assert(didSetObject as! String == "5678") - assert(didSetObjectForKey == Key.phone.rawValue) - } + assert(didSetObject as! String == "5678") + assert(didSetObjectForKey == Key.phone.rawValue) + } - func testRemovingValue() { - var didRemoveObjectForKey: String? + func testRemovingValue() { + var didRemoveObjectForKey: String? - let sut = KeyObjectStore( - objectForKey: { _ in fatalError() }, - setObjectForKey: { _,_ in fatalError() }, - removeObjectForKey: { didRemoveObjectForKey = $0 } - ) + let sut = KeyObjectStore( + objectForKey: { _ in fatalError() }, + setObjectForKey: { _,_ in fatalError() }, + removeObjectForKey: { didRemoveObjectForKey = $0 } + ) - DependencyInjection.Container.shared.register(sut) + DI.Container.shared.register(sut) - @KeyObject(.phone, defaultValue: "1234") var phone: String? - phone = nil + @KeyObject(.phone, defaultValue: "1234") var phone: String? + phone = nil - assert(didRemoveObjectForKey == Key.phone.rawValue) - } + assert(didRemoveObjectForKey == Key.phone.rawValue) + } } diff --git a/Tests/ThemeTests/ThemeTests.swift b/Tests/ThemeTests/ThemeTests.swift index 3cdf37a0..1cc6794c 100644 --- a/Tests/ThemeTests/ThemeTests.swift +++ b/Tests/ThemeTests/ThemeTests.swift @@ -1,45 +1,45 @@ +import DI import Quick import Nimble import Defaults import Foundation -import DI @testable import Theme final class ThemeTests: QuickSpec { - override func spec() { - context("init") { - var sut: ThemeController! - var dictionary: NSMutableDictionary! - - beforeEach { - dictionary = .init() - - DependencyInjection.Container.shared - .register(KeyObjectStore.mock(dictionary: dictionary)) - - sut = ThemeController() - } - - afterEach { - dictionary = nil - } - - it("should load .system a.k.a 0 from defaults") { - let theme = dictionary.value(forKey: Key.theme.rawValue) as? Int - expect(theme).to(equal(0)) - } - - context("when changing theme") { - beforeEach { - sut.theme.send(.dark) - } - - it("should save .dark") { - let theme = dictionary.value(forKey: Key.theme.rawValue) as? Int - expect(theme).to(equal(1)) - } - } + override func spec() { + context("init") { + var sut: ThemeController! + var dictionary: NSMutableDictionary! + + beforeEach { + dictionary = .init() + + DI.Container.shared + .register(KeyObjectStore.mock(dictionary: dictionary)) + + sut = ThemeController() + } + + afterEach { + dictionary = nil + } + + it("should load .system a.k.a 0 from defaults") { + let theme = dictionary.value(forKey: Key.theme.rawValue) as? Int + expect(theme).to(equal(0)) + } + + context("when changing theme") { + beforeEach { + sut.theme.send(.dark) + } + + it("should save .dark") { + let theme = dictionary.value(forKey: Key.theme.rawValue) as? Int + expect(theme).to(equal(1)) } + } } + } } diff --git a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved index b17678ed..6006a39d 100644 --- a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -386,15 +386,6 @@ "revision" : "16e6409ee82e1b81390bdffbf217b9c08ab32784", "version" : "0.5.0" } - }, - { - "identity" : "xxm-di", - "kind" : "remoteSourceControl", - "location" : "https://git.xx.network/elixxir/xxm-di.git", - "state" : { - "revision" : "43b1e12c32109f1753fcc62e5b0b21e479ee27e3", - "version" : "1.0.0" - } } ], "version" : 2 -- GitLab