build: remove PKHUD
With Xcode 14.3 IPHONEOS_DEPLOYMENT_TARGET is 9, when
PKHUD has 8 and it was not updated from 2020.
Change-Id: Ia5f245735e2affd8edeb52adf23ca4d361727238
diff --git a/Ring/Cartfile b/Ring/Cartfile
index b8b06ed..3b44744 100644
--- a/Ring/Cartfile
+++ b/Ring/Cartfile
@@ -1,6 +1,5 @@
github "RxSwiftCommunity/RxRealm"
github "RxSwiftCommunity/RxDataSources"
-github "pkluz/PKHUD"
github "AliSoftware/Reusable"
github "SwiftyBeaver/SwiftyBeaver"
github "andreamazz/AMPopTip"
diff --git a/Ring/Cartfile.resolved b/Ring/Cartfile.resolved
index 3ea49da..213f506 100644
--- a/Ring/Cartfile.resolved
+++ b/Ring/Cartfile.resolved
@@ -2,10 +2,9 @@
github "ReactiveX/RxSwift" "6.5.0"
github "RxSwiftCommunity/RxDataSources" "5.0.2"
github "RxSwiftCommunity/RxRealm" "v5.0.5"
-github "SwiftyBeaver/SwiftyBeaver" "1.9.6"
-github "andreamazz/AMPopTip" "4.9.0"
+github "SwiftyBeaver/SwiftyBeaver" "2.0.0"
+github "andreamazz/AMPopTip" "4.11.0"
github "ashleymills/Reachability.swift" "v5.1.0"
github "gskbyte/GSKStretchyHeaderView" "1.0.4"
-github "pkluz/PKHUD" "5.4.0"
-github "realm/realm-cocoa" "v10.28.5"
-github "stephencelis/SQLite.swift" "0.13.3"
+github "realm/realm-cocoa" "v10.38.0"
+github "stephencelis/SQLite.swift" "0.14.1"
diff --git a/Ring/Ring.xcodeproj/project.pbxproj b/Ring/Ring.xcodeproj/project.pbxproj
index 2634ee5..dc4c94b 100644
--- a/Ring/Ring.xcodeproj/project.pbxproj
+++ b/Ring/Ring.xcodeproj/project.pbxproj
@@ -216,6 +216,7 @@
260AE64529C8FD2500D66D5E /* VCardUtilsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260AE64429C8FD2500D66D5E /* VCardUtilsTests.swift */; };
260C73F129196B66005C513F /* MessageHistoryVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260C73F029196B66005C513F /* MessageHistoryVM.swift */; };
260C73F329196C6C005C513F /* MessageStackVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260C73F229196C6C005C513F /* MessageStackVM.swift */; };
+ 261E4EF229F8191300ABB37C /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 261E4EF129F8191300ABB37C /* LoadingView.swift */; };
263B7158246D9390007044C4 /* SmartListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 263B7157246D9390007044C4 /* SmartListCell.swift */; };
263B715A246D9556007044C4 /* IncognitoSmartListCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 263B7159246D9556007044C4 /* IncognitoSmartListCell.swift */; };
263B715C246D96E5007044C4 /* IncognitoSmartListCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 263B715B246D96E5007044C4 /* IncognitoSmartListCell.xib */; };
@@ -388,8 +389,6 @@
446FAF1D2373427100519C4F /* SendFileViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 446FAF1C2373427100519C4F /* SendFileViewModel.swift */; };
449E736428D9F69E00CBF564 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1ABE07DA1F0D915100D36361 /* Localizable.strings */; };
449E736728D9F86A00CBF564 /* Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ABE07E11F0D924700D36361 /* Strings.swift */; };
- 44DFB39A2887048E0023878C /* PKHUD.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 44DFB38A2887044A0023878C /* PKHUD.xcframework */; };
- 44DFB39B2887048E0023878C /* PKHUD.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 44DFB38A2887044A0023878C /* PKHUD.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
44DFB39C2887048F0023878C /* RxSwift.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 44DFB38B2887044E0023878C /* RxSwift.xcframework */; };
44DFB39D2887048F0023878C /* RxSwift.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 44DFB38B2887044E0023878C /* RxSwift.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
44DFB39E2887048F0023878C /* SwiftyBeaver.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 44DFB38C288704530023878C /* SwiftyBeaver.xcframework */; };
@@ -541,7 +540,6 @@
44DFB3A9288704900023878C /* Differentiator.xcframework in Embed Frameworks */,
44DFB3A12887048F0023878C /* RxRealm.xcframework in Embed Frameworks */,
44DFB3B9288704920023878C /* RealmSwift.xcframework in Embed Frameworks */,
- 44DFB39B2887048E0023878C /* PKHUD.xcframework in Embed Frameworks */,
44DFB3B3288704910023878C /* RxCocoa.xcframework in Embed Frameworks */,
44DFB39F2887048F0023878C /* SwiftyBeaver.xcframework in Embed Frameworks */,
44DFB3B1288704910023878C /* Reusable.xcframework in Embed Frameworks */,
@@ -828,6 +826,7 @@
260AE64429C8FD2500D66D5E /* VCardUtilsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VCardUtilsTests.swift; sourceTree = "<group>"; };
260C73F029196B66005C513F /* MessageHistoryVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageHistoryVM.swift; sourceTree = "<group>"; };
260C73F229196C6C005C513F /* MessageStackVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageStackVM.swift; sourceTree = "<group>"; };
+ 261E4EF129F8191300ABB37C /* LoadingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingView.swift; sourceTree = "<group>"; };
262AA981262C724700DC34AD /* libfmt.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfmt.a; path = ../DEPS/arm64/lib/libfmt.a; sourceTree = "<group>"; };
26376721245315E600CDC51F /* Debug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Debug.entitlements; sourceTree = "<group>"; };
263B7157246D9390007044C4 /* SmartListCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartListCell.swift; sourceTree = "<group>"; };
@@ -1169,7 +1168,6 @@
44DFB39E2887048F0023878C /* SwiftyBeaver.xcframework in Frameworks */,
269DA06928D0D366007D51D6 /* libpjmedia-videodev.a in Frameworks */,
44DFB3B6288704910023878C /* SQLite.xcframework in Frameworks */,
- 44DFB39A2887048E0023878C /* PKHUD.xcframework in Frameworks */,
269DA07E28D0D367007D51D6 /* libyuv.a in Frameworks */,
269DA06628D0D366007D51D6 /* libpjlib-util.a in Frameworks */,
269DA06E28D0D366007D51D6 /* libpjsip.a in Frameworks */,
@@ -1755,6 +1753,7 @@
0E99F19F22417A0400CF8BD6 /* JamiURI.swift */,
260AE62429B65A4B00D66D5E /* ContactsUtils.swift */,
260AE63F29C23AEC00D66D5E /* CallsHelper.swift */,
+ 261E4EF129F8191300ABB37C /* LoadingView.swift */,
);
path = Helpers;
sourceTree = "<group>";
@@ -2808,6 +2807,7 @@
264FB66229775B1C00BEFBBF /* SystemService.swift in Sources */,
0E99F1A022417A0400CF8BD6 /* JamiURI.swift in Sources */,
1A5DC02E1F3565640075E8EF /* ConversationViewModel.swift in Sources */,
+ 261E4EF229F8191300ABB37C /* LoadingView.swift in Sources */,
0EBB72A92034F44200D88F46 /* ProfilesService.swift in Sources */,
0E13A91C22B844B100A12A54 /* NSUserActivity+Call.swift in Sources */,
1A2D189C1F264AD900B2C785 /* UIViewController+Ring.swift in Sources */,
@@ -3250,6 +3250,7 @@
);
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../fat/lib";
MARKETING_VERSION = 3.46;
+ OTHER_CFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.savoirfairelinux.ring;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
@@ -3288,6 +3289,7 @@
);
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../fat/lib";
MARKETING_VERSION = 3.46;
+ OTHER_CFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.savoirfairelinux.ring;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
@@ -3628,6 +3630,7 @@
);
LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../fat/lib";
MARKETING_VERSION = 3.46;
+ OTHER_CFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.savoirfairelinux.ring;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
diff --git a/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift b/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift
index c0fa6c2..a9b293e 100644
--- a/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift
+++ b/Ring/Ring/Features/Conversations/SmartList/IncognitoSmartListViewController.swift
@@ -23,7 +23,6 @@
import RxDataSources
import RxCocoa
import Reusable
-import PKHUD
class IncognitoSmartListViewController: UIViewController, StoryboardBased, ViewModelBased {
@@ -36,6 +35,7 @@
@IBOutlet weak var networkAlertLabel: UILabel!
@IBOutlet weak var networkAlertView: UIView!
@IBOutlet weak var searchBarShadow: UIView!
+ var loadingViewPresenter = LoadingViewPresenter()
var viewModel: IncognitoSmartListViewModel!
private let disposeBag = DisposeBag()
@@ -181,10 +181,10 @@
}
internal func stopLoadingView() {
- HUD.hide(animated: false)
+ loadingViewPresenter.hide(animated: false)
}
internal func showLoadingViewWithoutText() {
- HUD.show(.labeledProgress(title: "", subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: "", presentingVC: self, animated: true)
}
}
diff --git a/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift b/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift
index 8d8d69f..00f486d 100644
--- a/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift
+++ b/Ring/Ring/Features/Me/LinkNewDeviceViewController.swift
@@ -21,12 +21,12 @@
import Foundation
import Reusable
import RxSwift
-import PKHUD
class LinkNewDeviceViewController: UIViewController, StoryboardBased, ViewModelBased {
var viewModel: LinkNewDeviceViewModel!
let disposeBag = DisposeBag()
+ var loadingViewPresenter = LoadingViewPresenter()
override func viewDidLoad() {
@@ -58,10 +58,10 @@
}
private func showProgress() {
- HUD.show(.labeledProgress(title: L10n.LinkDevice.hudMessage, subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: L10n.LinkDevice.hudMessage, presentingVC: self, animated: true)
}
private func hideHud() {
- HUD.hide(animated: false)
+ loadingViewPresenter.hide(animated: false)
}
func showSuccessAlert(pin: String) {
diff --git a/Ring/Ring/Features/Me/Me/MeViewController.swift b/Ring/Ring/Features/Me/Me/MeViewController.swift
index 6d04597..a9ccdf3 100644
--- a/Ring/Ring/Features/Me/Me/MeViewController.swift
+++ b/Ring/Ring/Features/Me/Me/MeViewController.swift
@@ -25,7 +25,6 @@
import RxSwift
import RxCocoa
import RxDataSources
-import PKHUD
// swiftlint:disable type_body_length
// swiftlint:disable file_length
@@ -46,6 +45,7 @@
private let jamiIDCell = "jamiIDCell"
private let jamiUserNameCell = "jamiUserNameCell"
private let accountStateCell = "accountStateCell"
+ var loadingViewPresenter = LoadingViewPresenter()
// MARK: - functions
override func viewDidLoad() {
@@ -174,15 +174,16 @@
}
private func showLoadingView() {
- HUD.show(.labeledProgress(title: L10n.AccountPage.deviceRevocationProgress, subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: L10n.AccountPage.deviceRevocationProgress, presentingVC: self, animated: true)
}
private func showNameRegistration() {
- HUD.show(.labeledProgress(title: L10n.AccountPage.usernameRegistering, subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: L10n.AccountPage.usernameRegistering, presentingVC: self, animated: true)
}
private func showDeviceRevocationError(deviceId: String, errorMessage: String) {
- HUD.hide(animated: true) { _ in
+ loadingViewPresenter.hide(animated: true) { [weak self] in
+ guard let self = self else { return }
let alert = UIAlertController(title: errorMessage,
message: nil,
preferredStyle: .alert)
@@ -199,7 +200,8 @@
}
private func showDeviceRevokedAlert(deviceId: String) {
- HUD.hide(animated: true) { _ in
+ loadingViewPresenter.hide(animated: true) { [weak self] in
+ guard let self = self else { return }
let alert = UIAlertController(title: L10n.AccountPage.deviceRevocationSuccess,
message: nil,
preferredStyle: .alert)
@@ -211,7 +213,8 @@
}
private func showNameRegisterationFailed(error: String) {
- HUD.hide(animated: true) { _ in
+ loadingViewPresenter.hide(animated: true) { [weak self] in
+ guard let self = self else { return }
let alert = UIAlertController(title: error,
message: nil,
preferredStyle: .alert)
@@ -1278,10 +1281,10 @@
}
internal func stopLoadingView() {
- HUD.hide(animated: false)
+ loadingViewPresenter.hide(animated: false)
}
internal func showLoadingViewWithoutText() {
- HUD.show(.labeledProgress(title: "", subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: "", presentingVC: self, animated: true)
}
}
diff --git a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
index 33cc532..5c3bccf 100644
--- a/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateAccount/CreateAccountViewController.swift
@@ -22,7 +22,6 @@
import UIKit
import Reusable
import RxSwift
-import PKHUD
class CreateAccountViewController: UIViewController, StoryboardBased, ViewModelBased {
@@ -58,6 +57,7 @@
@IBOutlet weak var containerViewBottomConstraint: NSLayoutConstraint!
var keyboardDismissTapRecognizer: UITapGestureRecognizer!
var isKeyboardOpened: Bool = false
+ var loadingViewPresenter = LoadingViewPresenter()
// MARK: functions
override func viewDidLoad() {
@@ -329,9 +329,6 @@
self.createAccountButton.rx.tap
.subscribe(onNext: { [weak self] in
guard let self = self else { return }
- DispatchQueue.main.async {
- self.showAccountCreationInProgress()
- }
DispatchQueue.global(qos: .background).async {
self.viewModel.createAccount()
}
@@ -340,15 +337,11 @@
}
private func showAccountCreationInProgress() {
- HUD.show(.labeledProgress(title: L10n.CreateAccount.loading, subtitle: nil))
- }
-
- private func showAccountCreationSuccess() {
- HUD.flash(.labeledSuccess(title: L10n.Alerts.accountAddedTitle, subtitle: nil), delay: Durations.alertFlashDuration.value)
+ loadingViewPresenter.presentWithMessage(message: L10n.CreateAccount.loading, presentingVC: self, animated: true)
}
private func hideAccountCreationHud() {
- HUD.hide()
+ loadingViewPresenter.hide(animated: false)
}
private func showAccountCreationError(error: AccountCreationError) {
diff --git a/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift b/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift
index f69c3e8..61eedd3 100644
--- a/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/CreateSipAccount/CreateSipAccountViewController.swift
@@ -21,7 +21,6 @@
import UIKit
import Reusable
import RxSwift
-import PKHUD
class CreateSipAccountViewController: UIViewController, StoryboardBased, ViewModelBased {
var viewModel: CreateSipAccountViewModel!
diff --git a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift
index 0a6ae33..f19728e 100644
--- a/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/LinkDevice/LinkDeviceViewController.swift
@@ -22,7 +22,6 @@
import UIKit
import Reusable
import RxSwift
-import PKHUD
import AMPopTip
import SwiftyBeaver
@@ -45,6 +44,7 @@
var keyboardDismissTapRecognizer: UITapGestureRecognizer!
var isKeyboardOpened: Bool = false
let popTip = PopTip()
+ var loadingViewPresenter = LoadingViewPresenter()
let log = SwiftyBeaver.self
@@ -193,15 +193,15 @@
}
private func showCreationHUD() {
- HUD.show(.labeledProgress(title: L10n.LinkToAccount.waitLinkToAccountTitle, subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: L10n.LinkToAccount.waitLinkToAccountTitle, presentingVC: self, animated: true)
}
private func showLinkedSuccess() {
- HUD.flash(.labeledSuccess(title: L10n.Alerts.accountLinkedTitle, subtitle: nil), delay: Durations.alertFlashDuration.value)
+ loadingViewPresenter.showSuccessAllert(message: L10n.Alerts.accountLinkedTitle, presentingVC: self, animated: true)
}
private func hideHud() {
- HUD.hide()
+ loadingViewPresenter.hide(animated: false)
}
private func showAccountCreationError(error: AccountCreationError) {
diff --git a/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift b/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift
index 4f183e2..474331d 100644
--- a/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift
+++ b/Ring/Ring/Features/Walkthrough/LinkToAccountManager/LinkToAccountManagerViewController.swift
@@ -21,7 +21,6 @@
import UIKit
import Reusable
import RxSwift
-import PKHUD
class LinkToAccountManagerViewController: UIViewController, StoryboardBased, ViewModelBased {
var viewModel: LinkToAccountManagerViewModel!
@@ -39,6 +38,7 @@
var keyboardDismissTapRecognizer: UITapGestureRecognizer!
var isKeyboardOpened: Bool = false
var disposeBag = DisposeBag()
+ var loadingViewPresenter = LoadingViewPresenter()
override func viewDidLoad() {
super.viewDidLoad()
@@ -132,11 +132,11 @@
}
private func showLinkHUD() {
- HUD.show(.labeledProgress(title: L10n.LinkToAccountManager.signIn, subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: L10n.LinkToAccountManager.signIn, presentingVC: self, animated: true)
}
private func hideHud() {
- HUD.hide()
+ loadingViewPresenter.hide(animated: false)
}
private func showAccountCreationError(error: AccountCreationError) {
diff --git a/Ring/Ring/Helpers/LoadingView.swift b/Ring/Ring/Helpers/LoadingView.swift
new file mode 100644
index 0000000..08c9fee
--- /dev/null
+++ b/Ring/Ring/Helpers/LoadingView.swift
@@ -0,0 +1,193 @@
+/*
+ * Copyright (C) 2023 Savoir-faire Linux Inc.
+ *
+ * Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import Foundation
+
+class LoadingViewPresenter {
+
+ private weak var timer: Timer?
+ private let timeout = 2.0
+
+ var loadingView: LoadingView! = {
+ let loadingView = LoadingView()
+ loadingView.modalPresentationStyle = .overCurrentContext
+ loadingView.modalTransitionStyle = .crossDissolve
+ return loadingView
+ }()
+
+ func presentWithMessage(message: String, presentingVC: UIViewController, animated flag: Bool) {
+ loadingView.message = message
+ loadingView.showLoadingView()
+ presentingVC.present(loadingView, animated: flag)
+ }
+
+ func showSuccessAllert(message: String, presentingVC: UIViewController, animated flag: Bool) {
+ loadingView.message = message
+ loadingView.showSuccessView()
+ presentingVC.present(loadingView, animated: flag)
+ startTimer()
+ }
+
+ func hide(animated flag: Bool, completion: (() -> Void)? = nil) {
+ loadingView.dismiss(animated: flag, completion: completion)
+ }
+
+ // MARK: - Timer
+ @objc
+ func timerHandler(_ timer: Timer) {
+ defer {
+ stopTimer()
+ }
+ loadingView.dismiss(animated: true)
+ }
+
+ func startTimer() {
+ stopTimer()
+ timer = Timer.scheduledTimer(timeInterval: timeout, target: self, selector: #selector(timerHandler(_:)), userInfo: nil, repeats: false)
+ }
+
+ func stopTimer() {
+ timer?.invalidate()
+ }
+}
+
+class LoadingView: UIViewController {
+ let horizontalMargin: CGFloat = 10
+ let verticalMargin: CGFloat = 10
+ let defaultSize: CGFloat = 156
+ var message: String = ""
+
+ var containerView: UIVisualEffectView = {
+ let blurEffect = UIBlurEffect(style: .systemChromeMaterialLight)
+ let blurEffectView = UIVisualEffectView(effect: blurEffect)
+ blurEffectView.layer.cornerRadius = 9.0
+ blurEffectView.layer.masksToBounds = true
+ blurEffectView.autoresizingMask = [
+ .flexibleWidth, .flexibleHeight
+ ]
+ return blurEffectView
+ }()
+
+ override func viewDidLoad() {
+ super.viewDidLoad()
+ view.backgroundColor = UIColor.black.withAlphaComponent(0.3)
+ view.addSubview(containerView)
+ }
+
+ func showLoadingView() {
+ self.containerView.contentView.removeSubviews(recursive: true)
+ let indicator = UIActivityIndicatorView()
+ indicator.style = .large
+ indicator.color = .black
+ indicator.startAnimating()
+ indicator.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: 60, height: 60))
+ self.addToContainerMessageAndView(viewToAdd: indicator)
+ }
+
+ func showSuccessView() {
+ self.containerView.contentView.removeSubviews(recursive: true)
+ let imageView = UIImageView()
+ imageView.image = UIImage(systemName: "checkmark")
+ imageView.contentMode = .scaleAspectFit
+ imageView.tintColor = .jamiSuccess
+ imageView.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: 60, height: 60))
+ self.addToContainerMessageAndView(viewToAdd: imageView)
+ }
+
+ func addVibrancy() {
+ let blurEffect = UIBlurEffect(style: .systemChromeMaterialLight)
+ let vibrancyEffect = UIVibrancyEffect(blurEffect: blurEffect)
+ let vibrancyView = UIVisualEffectView(effect: vibrancyEffect)
+ vibrancyView.translatesAutoresizingMaskIntoConstraints = false
+ containerView.contentView.addSubview(vibrancyView)
+ NSLayoutConstraint.activate([
+ vibrancyView
+ .heightAnchor
+ .constraint(equalTo: containerView.contentView.heightAnchor),
+ vibrancyView
+ .widthAnchor
+ .constraint(equalTo: containerView.contentView.widthAnchor),
+ vibrancyView
+ .centerXAnchor
+ .constraint(equalTo: containerView.contentView.centerXAnchor),
+ vibrancyView
+ .centerYAnchor
+ .constraint(equalTo: containerView.contentView.centerYAnchor)
+ ])
+ }
+
+ func addView(viewToAdd: UIView) {
+ containerView.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: defaultSize, height: defaultSize))
+ containerView.center = view.center
+ self.addVibrancy()
+ containerView.contentView.addSubview(viewToAdd)
+ viewToAdd.center = containerView.contentView.center
+ }
+
+ func createMessageView() -> UILabel {
+ let messageLabel = UILabel()
+ messageLabel.lineBreakMode = .byWordWrapping
+ messageLabel.numberOfLines = 0
+ messageLabel.textAlignment = .center
+ messageLabel.font = UIFont.boldSystemFont(ofSize: 18.0)
+ messageLabel.textColor = UIColor.black.withAlphaComponent(0.85)
+ messageLabel.adjustsFontSizeToFitWidth = true
+ messageLabel.minimumScaleFactor = 0.25
+ messageLabel.text = message
+ messageLabel.frame.size.width = defaultSize
+ messageLabel.sizeToFit()
+ return messageLabel
+ }
+
+ func addToContainerMessageAndView(viewToAdd: UIView) {
+ if message.isEmpty {
+ self.addView(viewToAdd: viewToAdd)
+ return
+ }
+ let messageLabel = createMessageView()
+
+ // sizes
+ let viewHeight = viewToAdd.frame.height
+ let textHeight = messageLabel.frame.height
+ let width = horizontalMargin * 2 + defaultSize
+ let conteinerHeight = viewHeight + textHeight + verticalMargin * 3
+ let height = max(defaultSize, conteinerHeight)
+ let updatedVerticalMargin = (height - textHeight - viewHeight) / 3
+
+ containerView.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: width, height: height))
+ containerView.center = view.center
+
+ self.addVibrancy()
+ containerView.contentView.addSubview(messageLabel)
+
+ let centerX = containerView.contentView.center.x
+ let indicatorCenterY = containerView.contentView.frame.height - (viewHeight * 0.5) - updatedVerticalMargin
+ let textCenterY = (textHeight * 0.5) + updatedVerticalMargin
+ messageLabel.center = CGPoint(
+ x: centerX,
+ y: textCenterY
+ )
+ containerView.contentView.addSubview(viewToAdd)
+ viewToAdd.center = CGPoint(
+ x: centerX,
+ y: indicatorCenterY
+ )
+ }
+}
diff --git a/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift b/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift
index ab3c018..fc7a15b 100644
--- a/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift
+++ b/Ring/Ring/MigrateAccount/MigrateAccountViewController.swift
@@ -22,7 +22,6 @@
import UIKit
import RxSwift
import RxCocoa
-import PKHUD
class MigrateAccountViewController: UIViewController, StoryboardBased, ViewModelBased {
var viewModel: MigrateAccountViewModel!
@@ -42,6 +41,7 @@
@IBOutlet weak var passwordContainer: UIStackView!
@IBOutlet weak var passwordField: DesignableTextField!
@IBOutlet weak var passwordExplanationLabel: UILabel!
+ var loadingViewPresenter = LoadingViewPresenter()
var keyboardDismissTapRecognizer: UITapGestureRecognizer!
var isKeyboardOpened: Bool = false
@@ -227,15 +227,15 @@
// MARK: - alerts
private func stopLoadingView() {
- HUD.hide(animated: false)
+ loadingViewPresenter.hide(animated: false)
}
private func showLoadingView() {
- HUD.show(.labeledProgress(title: L10n.MigrateAccount.migrating,
- subtitle: nil))
+ loadingViewPresenter.presentWithMessage(message: L10n.MigrateAccount.migrating, presentingVC: self, animated: true)
}
private func showMigrationError() {
- HUD.hide(animated: true) { _ in
+ loadingViewPresenter.hide(animated: true) { [weak self] in
+ guard let self = self else { return }
let alert = UIAlertController(title: L10n.MigrateAccount.error,
message: nil,
preferredStyle: .alert)