Add loading-indicator

cause I'm lazy
This commit is contained in:
Nathan Mattes 2023-10-23 13:55:54 +02:00
parent 19d67d6dab
commit 0951e658a2
3 changed files with 49 additions and 3 deletions

View File

@ -145,6 +145,7 @@
D8318A882A4468D300C0FB73 /* NotificationSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8318A872A4468D300C0FB73 /* NotificationSettingsViewController.swift */; };
D8318A8A2A4468DC00C0FB73 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8318A892A4468DC00C0FB73 /* AboutViewController.swift */; };
D8363B1629469CE200A74079 /* OnboardingNextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8363B1529469CE200A74079 /* OnboardingNextView.swift */; };
D84FA0932AE6915800987F47 /* MBProgressHUD in Frameworks */ = {isa = PBXBuildFile; productRef = D84FA0922AE6915800987F47 /* MBProgressHUD */; };
D852C23C2AC5D02C00309232 /* AboutInstanceViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D852C23B2AC5D02C00309232 /* AboutInstanceViewController.swift */; };
D852C23E2AC5D03300309232 /* InstanceRulesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D852C23D2AC5D03300309232 /* InstanceRulesViewController.swift */; };
D87364F92AE28DB500C8F919 /* Kanna in Frameworks */ = {isa = PBXBuildFile; productRef = D87364F82AE28DB500C8F919 /* Kanna */; };
@ -1290,6 +1291,7 @@
files = (
357FEEAF29523D470021C9DC /* MastodonSDKDynamic in Frameworks */,
DBF96326262EC0A6001D8D25 /* AuthenticationServices.framework in Frameworks */,
D84FA0932AE6915800987F47 /* MBProgressHUD in Frameworks */,
D87364F92AE28DB500C8F919 /* Kanna in Frameworks */,
71458AF57697DB405CFEC37C /* Pods_Mastodon.framework in Frameworks */,
);
@ -3144,6 +3146,7 @@
packageProductDependencies = (
357FEEAE29523D470021C9DC /* MastodonSDKDynamic */,
D87364F82AE28DB500C8F919 /* Kanna */,
D84FA0922AE6915800987F47 /* MBProgressHUD */,
);
productName = Mastodon;
productReference = DB427DD225BAA00100D1B89D /* Mastodon.app */;
@ -3328,6 +3331,7 @@
packageReferences = (
2AB501192992322500346092 /* XCRemoteSwiftPackageReference "LightChart" */,
D87364F72AE28DB500C8F919 /* XCRemoteSwiftPackageReference "Kanna" */,
D84FA0912AE6915800987F47 /* XCRemoteSwiftPackageReference "MBProgressHUD" */,
);
productRefGroup = DB427DD325BAA00100D1B89D /* Products */;
projectDirPath = "";
@ -5431,6 +5435,14 @@
kind = branch;
};
};
D84FA0912AE6915800987F47 /* XCRemoteSwiftPackageReference "MBProgressHUD" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/jdg/MBProgressHUD.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.2.0;
};
};
D87364F72AE28DB500C8F919 /* XCRemoteSwiftPackageReference "Kanna" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/tid-kijyun/Kanna.git";
@ -5475,6 +5487,11 @@
isa = XCSwiftPackageProductDependency;
productName = MastodonSDKDynamic;
};
D84FA0922AE6915800987F47 /* MBProgressHUD */ = {
isa = XCSwiftPackageProductDependency;
package = D84FA0912AE6915800987F47 /* XCRemoteSwiftPackageReference "MBProgressHUD" */;
productName = MBProgressHUD;
};
D87364F82AE28DB500C8F919 /* Kanna */ = {
isa = XCSwiftPackageProductDependency;
package = D87364F72AE28DB500C8F919 /* XCRemoteSwiftPackageReference "Kanna" */;

View File

@ -82,6 +82,15 @@
"version": null
}
},
{
"package": "MBProgressHUD",
"repositoryURL": "https://github.com/jdg/MBProgressHUD.git",
"state": {
"branch": null,
"revision": "bca42b801100b2b3a4eda0ba8dd33d858c780b0d",
"version": "1.2.0"
}
},
{
"package": "MetaTextKit",
"repositoryURL": "https://github.com/TwidereProject/MetaTextKit.git",

View File

@ -13,6 +13,7 @@ import MastodonSDK
import MastodonCore
import MastodonAsset
import MastodonLocalization
import MBProgressHUD
final public class SceneCoordinator {
@ -28,7 +29,8 @@ final public class SceneCoordinator {
private(set) weak var tabBarController: MainTabBarController!
private(set) weak var splitViewController: RootSplitViewController?
private(set) weak var rootViewController: UIViewController?
private(set) var secondaryStackHashValues = Set<Int>()
var childCoordinator: Coordinator?
@ -198,7 +200,7 @@ extension SceneCoordinator {
case safari(url: URL)
case alertController(alertController: UIAlertController)
case activityViewController(activityViewController: UIActivityViewController, sourceView: UIView?, barButtonItem: UIBarButtonItem?)
var isOnboarding: Bool {
switch self {
case .welcome,
@ -239,6 +241,7 @@ extension SceneCoordinator {
rootViewController = splitViewController
}
sceneDelegate.window?.rootViewController = rootViewController // base: main
self.rootViewController = rootViewController
if _authContext == nil { // entry #1: welcome
DispatchQueue.main.async {
@ -559,13 +562,30 @@ private extension SceneCoordinator {
return viewController
}
private func setupDependency(for needs: NeedsDependency?) {
needs?.context = appContext
needs?.coordinator = self
}
}
//MARK: - Loading
public extension SceneCoordinator {
func showLoading() {
guard let rootViewController else { return }
MBProgressHUD.showAdded(to: rootViewController.view, animated: true)
}
@MainActor
func hideLoading() {
guard let rootViewController else { return }
MBProgressHUD.hide(for: rootViewController.view, animated: true)
}
}
//MARK: - MastodonLoginViewControllerDelegate
extension SceneCoordinator: MastodonLoginViewControllerDelegate {