Skip to content

Commit

Permalink
feat(Extensions): Add button to dismiss force update sheet
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Perignon <[email protected]>
  • Loading branch information
valentinperignon committed Feb 16, 2024
1 parent e3b586e commit 0d3e1a2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Infomaniak/ios-version-checker",
"state" : {
"revision" : "7f8a2fe8dd13e7b5fe3272d1ee64233b3524339a",
"version" : "1.1.1"
"revision" : "867d65cd4fc23d2a58b35975742bb448fd686f2c",
"version" : "1.1.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let project = Project(name: "kDrive",
.package(url: "https://github.com/raspu/Highlightr", .upToNextMajor(from: "2.1.0")),
.package(url: "https://github.com/bmoliveira/MarkdownKit", .upToNextMajor(from: "1.7.0")),
.package(url: "https://github.com/matomo-org/matomo-sdk-ios", .upToNextMajor(from: "7.5.1")),
.package(url: "https://github.com/Infomaniak/ios-version-checker", .upToNextMajor(from: "1.1.1")),
.package(url: "https://github.com/Infomaniak/ios-version-checker", .upToNextMajor(from: "1.1.2")),
],
targets: [
Target(name: "kDrive",
Expand Down
9 changes: 8 additions & 1 deletion kDrive/UI/Controller/DriveUpdateRequiredViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import UIKit
import VersionChecker

class DriveUpdateRequiredViewController: UIViewController {
var dismissHandler: (() -> Void)?

private let sharedStyle: TemplateSharedStyle = {
let largeButtonStyle = IKLargeButton.Style.primaryButton
return TemplateSharedStyle(
Expand All @@ -45,7 +47,8 @@ class DriveUpdateRequiredViewController: UIViewController {
let hostingViewController = UIHostingController(rootView: UpdateRequiredView(
image: KDriveResourcesAsset.updateRequired.swiftUIImage,
sharedStyle: sharedStyle,
handler: updateApp
updateHandler: updateApp,
dismissHandler: dismissHandler
))
guard let hostingView = hostingViewController.view else { return }

Expand All @@ -63,6 +66,10 @@ class DriveUpdateRequiredViewController: UIViewController {
hostingViewController.didMove(toParent: self)
}

override func viewWillAppear(_ animated: Bool) {
navigationController?.setNavigationBarHidden(true, animated: animated)
}

private func updateApp() {
let storeURL: URLConstants = Bundle.main.isRunningInTestFlight ? .testFlight : .appStore
UIConstants.openUrl(storeURL.url, from: self)
Expand Down
6 changes: 5 additions & 1 deletion kDriveActionExtension/ActionNavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ final class ActionNavigationController: TitleSizeAdjustingNavigationController {
private func checkAppVersion() async throws {
guard try await VersionChecker.standard.checkAppVersionStatus() == .updateIsRequired else { return }
Task { @MainActor in
viewControllers = [DriveUpdateRequiredViewController()]
let updateRequiredViewController = DriveUpdateRequiredViewController()
updateRequiredViewController.dismissHandler = { [weak self] in
self?.dismiss(animated: true)
}
viewControllers = [updateRequiredViewController]
}
}
}
6 changes: 5 additions & 1 deletion kDriveShareExtension/ShareNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ final class ShareNavigationViewController: TitleSizeAdjustingNavigationControlle
private func checkAppVersion() async throws {
guard try await VersionChecker.standard.checkAppVersionStatus() == .updateIsRequired else { return }
Task { @MainActor in
viewControllers = [DriveUpdateRequiredViewController()]
let updateRequiredViewController = DriveUpdateRequiredViewController()
updateRequiredViewController.dismissHandler = { [weak self] in
self?.dismiss(animated: true)
}
viewControllers = [updateRequiredViewController]
}
}
}

0 comments on commit 0d3e1a2

Please sign in to comment.