diff --git a/App/client-ios/Resources/Info.plist b/App/client-ios/Resources/Info.plist index d8cb845b40392068f453251c9c0aa72cd00979db..ee4d813d2e0ccc94a932d66a36070d80705cab5b 100644 --- a/App/client-ios/Resources/Info.plist +++ b/App/client-ios/Resources/Info.plist @@ -105,6 +105,6 @@ <key>UIViewControllerBasedStatusBarAppearance</key> <true/> <key>isReportingOptional</key> - <false/> + <true/> </dict> </plist> diff --git a/Sources/BackupFeature/Service/BackupService.swift b/Sources/BackupFeature/Service/BackupService.swift index 8392f32865dfc4c3c586cc90a346295ec7ddb6aa..8b1b10f7b1779bb7cfb66de02c48c414b56b450b 100644 --- a/Sources/BackupFeature/Service/BackupService.swift +++ b/Sources/BackupFeature/Service/BackupService.swift @@ -120,9 +120,7 @@ public final class BackupService { try messenger.startBackup( password: passphrase, params: .init( - username: username!, - email: email, - phone: phone + username: username! ) ) } catch { diff --git a/Sources/LaunchFeature/LaunchViewModel.swift b/Sources/LaunchFeature/LaunchViewModel.swift index d1472aa558d1ebfe6b12ecb833a85a44a0d7ea34..92f46f14d1c534d100c40f8ec75f25d4ce984a8b 100644 --- a/Sources/LaunchFeature/LaunchViewModel.swift +++ b/Sources/LaunchFeature/LaunchViewModel.swift @@ -251,8 +251,7 @@ final class LaunchViewModel { private func versionFailed(error: Error) { hudController.show(.init( title: Localized.Launch.Version.failed, - content: error.localizedDescription, - isDismissable: false + content: error.localizedDescription )) } diff --git a/Sources/SettingsFeature/ViewModels/AccountDeleteViewModel.swift b/Sources/SettingsFeature/ViewModels/AccountDeleteViewModel.swift index 9065c744e6275cb46317db77e5f93a23e34301bd..d03db85ada994987d0f2d06515120fe24e7337d8 100644 --- a/Sources/SettingsFeature/ViewModels/AccountDeleteViewModel.swift +++ b/Sources/SettingsFeature/ViewModels/AccountDeleteViewModel.swift @@ -48,8 +48,7 @@ final class AccountDeleteViewModel { hudController.show(.init( title: "Account deleted", - content: "Now kill the app and re-open", - isDismissable: false + content: "Now kill the app and re-open" )) } catch { DispatchQueue.main.async { [weak self] in diff --git a/Sources/Shared/Controllers/HUDController.swift b/Sources/Shared/Controllers/HUDController.swift index 1d281a39ac906fc4f54a32076a99d41909e31ab0..fc48d6c7dd643aebcbf21aa24a8e6e71732a2ede 100644 --- a/Sources/Shared/Controllers/HUDController.swift +++ b/Sources/Shared/Controllers/HUDController.swift @@ -14,6 +14,11 @@ public final class HUDController { } public func show(_ model: HUDModel? = nil) { + guard let model else { + modelSubject.send(.init(hasDotAnimation: true)) + return + } + modelSubject.send(model) } } diff --git a/Sources/Shared/Controllers/RootViewController.swift b/Sources/Shared/Controllers/RootViewController.swift index 383ef01a2afb32dea0aebdf64fbfa1fe4b79d387..909af5d6a1193f15e81b92c5ff41d3c4293aaf62 100644 --- a/Sources/Shared/Controllers/RootViewController.swift +++ b/Sources/Shared/Controllers/RootViewController.swift @@ -7,6 +7,7 @@ public final class RootViewController: UIViewController { @Dependency var hudDispatcher: HUDController @Dependency var toastDispatcher: ToastController + var hud: HUDView? let content: UIViewController? var cancellables = Set<AnyCancellable>() @@ -60,11 +61,17 @@ public final class RootViewController: UIViewController { .modelPublisher .receive(on: DispatchQueue.main) .sink { [unowned self] model in - guard model != nil else { - // REMOVE FROM SUPERVIEW + guard let model else { + guard let hud else { return } + UIView.animate(withDuration: 0.2) { + hud.alpha = 0.0 + } completion: { _ in + hud.removeFromSuperview() + self.hud = nil + } return } - // ADD TO SUPERVIEW + add(hudView: HUDView().setup(model: model)) }.store(in: &cancellables) } } @@ -166,67 +173,32 @@ extension RootViewController { // MARK: - HUD extension RootViewController { - // private func showWindow() { - // if let animation = animation { - // window?.addSubview(animation) - // animation.setColor(.white) - // animation.snp.makeConstraints { $0.center.equalToSuperview() } - // } - // - // if let titleLabel = titleLabel { - // window?.addSubview(titleLabel) - // titleLabel.textAlignment = .center - // titleLabel.numberOfLines = 0 - // titleLabel.snp.makeConstraints { make in - // make.left.equalToSuperview().offset(18) - // make.center.equalToSuperview().offset(50) - // make.right.equalToSuperview().offset(-18) - // } - // } - // - // if let actionButton = actionButton { - // window?.addSubview(actionButton) - // actionButton.snp.makeConstraints { - // $0.left.equalToSuperview().offset(18) - // $0.right.equalToSuperview().offset(-18) - // $0.bottom.equalToSuperview().offset(-50) - // } - // } - // - // if let errorView = errorView { - // window?.addSubview(errorView) - // errorView.snp.makeConstraints { make in - // make.left.equalToSuperview().offset(18) - // make.center.equalToSuperview() - // make.right.equalToSuperview().offset(-18) - // } - // - // errorView.button - // .publisher(for: .touchUpInside) - // .receive(on: DispatchQueue.main) - // .sink { [unowned self] in hideWindow() } - // .store(in: &cancellables) - // } - // - // window?.alpha = 0.0 - // window?.makeKeyAndVisible() - // - // UIView.animate(withDuration: 0.3) { self.window?.alpha = 1.0 } - // } - // - // private func hideWindow() { - // UIView.animate(withDuration: 0.3) { - // self.window?.alpha = 0.0 - // } completion: { _ in - // self.cancellables.removeAll() - // self.errorView = nil - // self.animation = nil - // self.actionButton = nil - // self.titleLabel = nil - // self.window = nil - // } - // } + private func add(hudView: HUDView) { + if let hud { + hud.removeFromSuperview() + self.hud = nil + } + + hudView.alpha = 0.0 + hudView.translatesAutoresizingMaskIntoConstraints = false + view.addSubview(hudView) + NSLayoutConstraint.activate([ + hudView.topAnchor.constraint(equalTo: view.topAnchor), + hudView.leftAnchor.constraint(equalTo: view.leftAnchor), + hudView.rightAnchor.constraint(equalTo: view.rightAnchor), + hudView.bottomAnchor.constraint(equalTo: view.bottomAnchor) + ]) + + view.setNeedsLayout() + view.layoutIfNeeded() + + UIView.animate(withDuration: 0.2) { + hudView.alpha = 1.0 + } + + hud = hudView + } // if statusSubject.value.isPresented == true && status.isPresented == true { // self.errorView = nil diff --git a/Sources/Shared/Models/HUDModel.swift b/Sources/Shared/Models/HUDModel.swift index d9e58e4d2b1170fa20dd224ffca265f72264aa8b..a68d3bc389311ee80cc38c58aa0a3c347eb7c1ba 100644 --- a/Sources/Shared/Models/HUDModel.swift +++ b/Sources/Shared/Models/HUDModel.swift @@ -4,59 +4,32 @@ public struct HUDModel { var title: String? var content: String? var actionTitle: String? - var isDismissable: Bool - var animationColor: UIColor? + var hasDotAnimation: Bool var onTapClosure: (() -> Void)? public init( title: String? = nil, content: String? = nil, actionTitle: String? = nil, - isDismissable: Bool = true, - animationColor: UIColor? = nil, + hasDotAnimation: Bool = false, onTapClosure: (() -> Void)? = nil ) { self.title = title self.content = content self.actionTitle = actionTitle - self.isDismissable = isDismissable self.onTapClosure = onTapClosure - self.animationColor = animationColor + self.hasDotAnimation = hasDotAnimation } public init( error: Error, - isDismissable: Bool = true + actionTitle: String? = Localized.Hud.Error.action, + onTapClosure: (() -> Void)? = nil ) { - self.isDismissable = isDismissable + self.hasDotAnimation = false + self.actionTitle = actionTitle + self.onTapClosure = onTapClosure self.title = Localized.Hud.Error.title self.content = error.localizedDescription - self.actionTitle = Localized.Hud.Error.action } } - -//public struct HUDError: Equatable { -// var title: String -// var content: String -// var buttonTitle: String -// var dismissable: Bool -// -// public init( -// content: String, -// title: String = Localized.Hud.Error.title, -// buttonTitle: String = Localized.Hud.Error.action, -// dismissable: Bool = true -// ) { -// self.title = title -// self.content = content -// self.buttonTitle = buttonTitle -// self.dismissable = dismissable -// } -// -// public init(with error: Error) { -// self.title = Localized.Hud.Error.title -// self.buttonTitle = Localized.Hud.Error.action -// self.content = error.localizedDescription -// self.dismissable = true -// } -//} diff --git a/Sources/Shared/Views/HUDView.swift b/Sources/Shared/Views/HUDView.swift index df54b7d55b770ae39c727710e7deed05e038e5a7..328c0b9f92308877cd627995a7289bc7cbc314a1 100644 --- a/Sources/Shared/Views/HUDView.swift +++ b/Sources/Shared/Views/HUDView.swift @@ -3,20 +3,65 @@ import Combine final class HUDView: UIView { let titleLabel = UILabel() + let contentLabel = UILabel() + let stackView = UIStackView() + let backgroundView = UIView() let actionButton = CapsuleButton() let animationView = DotAnimation() var cancellables = Set<AnyCancellable>() - init(model: HUDModel) { + init() { super.init(frame: .zero) + stackView.spacing = 20 + stackView.axis = .vertical + titleLabel.numberOfLines = 0 + titleLabel.textAlignment = .center titleLabel.textColor = Asset.neutralWhite.color - backgroundColor = Asset.neutralDark.color.withAlphaComponent(0.8) + titleLabel.font = Fonts.Mulish.bold.font(size: 30.0) - if let color = model.animationColor { - animationView.setColor(color) + contentLabel.numberOfLines = 0 + contentLabel.textAlignment = .center + contentLabel.textColor = Asset.neutralWhite.color + contentLabel.font = Fonts.Mulish.regular.font(size: 15.0) + + animationView.setColor(Asset.neutralWhite.color) + backgroundColor = Asset.neutralDark.color.withAlphaComponent(0.9) + + addSubview(backgroundView) + backgroundView.addSubview(stackView) + + backgroundView.snp.makeConstraints { + $0.centerY.equalToSuperview() + $0.left.equalToSuperview().offset(30) + $0.right.equalToSuperview().offset(-30) } + stackView.snp.makeConstraints { + $0.top.equalToSuperview().offset(15) + $0.left.equalToSuperview().offset(15) + $0.right.equalToSuperview().offset(-15) + $0.bottom.equalToSuperview().offset(-20) + } + } + + required init?(coder: NSCoder) { nil } + + func setup(model: HUDModel) -> HUDView { + if let title = model.title { + titleLabel.text = title + stackView.addArrangedSubview(titleLabel) + } + if let content = model.content { + contentLabel.text = content + stackView.addArrangedSubview(contentLabel) + } + if model.hasDotAnimation { + animationView.snp.makeConstraints { + $0.height.equalTo(20) + } + stackView.addArrangedSubview(animationView) + } if let actionTitle = model.actionTitle { actionButton.set( style: .seeThroughWhite, @@ -26,8 +71,8 @@ final class HUDView: UIView { .publisher(for: .touchUpInside) .sink { model.onTapClosure?() } .store(in: &cancellables) + stackView.addArrangedSubview(actionButton) } + return self } - - required init?(coder: NSCoder) { nil } } diff --git a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved index 659e607ccb07a4ee550069a01dc5b919f4c25419..6006a39d34ebab1c7bbe76132c3f428df725ee71 100644 --- a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -320,8 +320,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/swift-custom-dump.git", "state" : { - "revision" : "c9b6b940d95c0a925c63f6858943415714d8a981", - "version" : "0.5.2" + "revision" : "819d9d370cd721c9d87671e29d947279292e4541", + "version" : "0.6.0" } }, { @@ -383,8 +383,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/pointfreeco/xctest-dynamic-overlay.git", "state" : { - "revision" : "30314f1ece684dd60679d598a9b89107557b67d9", - "version" : "0.4.1" + "revision" : "16e6409ee82e1b81390bdffbf217b9c08ab32784", + "version" : "0.5.0" } } ],