the manager lands in manager/, next to ios/ and web/. it is a fork of this repo's own app, not of feather, so scripts/apply-rebrand.sh excludes it the same way it excludes web/ — the generic feather-to- ftstore rule would rewrite its app.ftstore.manager identity and mangle the lineage notes in its docs. zsign and idevicekitten were vendored copies in the old repo. they are registered as submodules here instead, pinned to the same commits ios/ uses and verified byte-identical to what was vendored. that keeps 71 MB of duplicated source out of the tree and leaves the xcode project's relative paths intact, so project.pbxproj needed no edits. the server moves to ftstore.app in both apps: managerrepoclient, the seeded default source and managerconfig's fallback. downloadmanager keeps the old admin host in its user-agent allowlist — that check is permissive, not identifying, and dropping it would stop sending the header to installs whose stored override still names the old host. the rest of the admin rename lands too: the client id, the base-url environment variable, the info.plist key, and user-facing errors. the userdefaults override key is renamed with a one-time migration read, so an existing install keeps the address its owner configured instead of falling back to the default. tags gain a third namespace: manager-v* for releases, manager-dev for the rolling prerelease. both repos published to a tag called `dev` before; sharing it here would make each build overwrite the other's release assets.
140 lines
3.4 KiB
Swift
140 lines
3.4 KiB
Swift
//
|
|
// UIAlertController+Alerts.swift
|
|
// NimbleKit
|
|
//
|
|
// Created by samara on 28.04.2025.
|
|
//
|
|
|
|
import UIKit.UIAlertController
|
|
|
|
extension UIAlertController {
|
|
/// Presents an alert
|
|
/// - Parameters:
|
|
/// - presenter: View where its presenting
|
|
/// - title: Alert title
|
|
/// - message: Alert message
|
|
/// - actions: Alert actions
|
|
static public func showAlertWithCancel(
|
|
_ presenter: UIViewController = UIApplication.topViewController()!,
|
|
_ popoverFromView: UIView? = nil,
|
|
title: String?,
|
|
message: String?,
|
|
style: UIAlertController.Style = .alert,
|
|
actions: [UIAlertAction]
|
|
) {
|
|
var actions = actions
|
|
actions.append(
|
|
UIAlertAction(title: .localized("Cancel"), style: .cancel, handler: nil)
|
|
)
|
|
|
|
showAlert(
|
|
presenter,
|
|
popoverFromView,
|
|
title: title,
|
|
message: message,
|
|
style: style,
|
|
actions: actions
|
|
)
|
|
}
|
|
/// Presents an alert with an OK button
|
|
/// - Parameters:
|
|
/// - presenter: View where it is presenting
|
|
/// - title: Alert title
|
|
/// - message: Alert message
|
|
/// - style: Alert controller style
|
|
/// - isCancel: If true, sets action style to cancel and no handler
|
|
/// - action: Closure to run when OK is tapped (ignored if isCancel is true)
|
|
static public func showAlertWithOk(
|
|
_ presenter: UIViewController = UIApplication.topViewController()!,
|
|
_ popoverFromView: UIView? = nil,
|
|
title: String?,
|
|
message: String?,
|
|
style: UIAlertController.Style = .alert,
|
|
isCancel: Bool = false,
|
|
action: (() -> Void)? = nil
|
|
) {
|
|
var actions: [UIAlertAction] = []
|
|
|
|
let alertAction = UIAlertAction(
|
|
title: "OK",
|
|
style: isCancel ? .cancel : .default,
|
|
handler: { _ in
|
|
if !isCancel {
|
|
action?()
|
|
}
|
|
}
|
|
)
|
|
|
|
actions.append(alertAction)
|
|
|
|
showAlert(
|
|
presenter,
|
|
popoverFromView,
|
|
title: title,
|
|
message: message,
|
|
style: style,
|
|
actions: actions
|
|
)
|
|
}
|
|
/// Presents an alert
|
|
/// - Parameters:
|
|
/// - presenter: View where its presenting
|
|
/// - title: Alert title
|
|
/// - message: Alert message
|
|
static public func showAlertWithRestart(
|
|
_ presenter: UIViewController = UIApplication.topViewController()!,
|
|
_ popoverFromView: UIView? = nil,
|
|
title: String?,
|
|
message: String?,
|
|
style: UIAlertController.Style = .alert
|
|
) {
|
|
var actions: [UIAlertAction] = []
|
|
actions.append(
|
|
UIAlertAction(title: "Suspend", style: .default) { _ in
|
|
UIApplication.shared.suspend()
|
|
}
|
|
)
|
|
actions.append(
|
|
UIAlertAction(title: "Later", style: .cancel, handler: nil)
|
|
)
|
|
|
|
showAlert(
|
|
presenter,
|
|
popoverFromView,
|
|
title: title,
|
|
message: message,
|
|
style: style,
|
|
actions: actions
|
|
)
|
|
}
|
|
/// Presents an alert
|
|
/// - Parameters:
|
|
/// - presenter: View where its presenting
|
|
/// - title: Alert title
|
|
/// - message: Alert message
|
|
/// - actions: Alert actions
|
|
static public func showAlert(
|
|
_ presenter: UIViewController = UIApplication.topViewController()!,
|
|
_ popoverFromView: UIView? = nil,
|
|
title: String?,
|
|
message: String?,
|
|
style: UIAlertController.Style = .alert,
|
|
actions: [UIAlertAction]
|
|
) {
|
|
let alert = Self(title: title, message: message, preferredStyle: style)
|
|
actions.forEach { alert.addAction($0) }
|
|
|
|
if
|
|
style == .actionSheet,
|
|
let popover = alert.popoverPresentationController,
|
|
let view = popoverFromView
|
|
{
|
|
popover.sourceView = view
|
|
popover.sourceRect = view.bounds
|
|
popover.permittedArrowDirections = .any
|
|
}
|
|
|
|
presenter.present(alert, animated: true)
|
|
}
|
|
}
|