Quick action for fast checking new plate number
This commit is contained in:
parent
6bf0ad8d12
commit
754c7e5063
@ -547,7 +547,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
@ -571,7 +571,7 @@
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 4;
|
||||
CURRENT_PROJECT_VERSION = 5;
|
||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
||||
@ -1,11 +1,21 @@
|
||||
import UIKit
|
||||
import SVProgressHUD
|
||||
import RealmSwift
|
||||
import os.log
|
||||
|
||||
extension OSLog {
|
||||
static let startup = OSLog(subsystem: "pro.aliencat.autocat.startup", category: "startup")
|
||||
}
|
||||
|
||||
enum QuickAction {
|
||||
case none
|
||||
case check
|
||||
}
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
|
||||
var quickAction: QuickAction = .none
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
|
||||
@ -27,6 +37,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||||
// Called when a new scene session is being created.
|
||||
// Use this method to select a configuration to create the new scene with.
|
||||
|
||||
if let shortcutItem = options.shortcutItem {
|
||||
if shortcutItem.type == "CheckNumberAction" {
|
||||
self.quickAction = .check
|
||||
}
|
||||
}
|
||||
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
|
||||
@ -62,6 +62,20 @@ class CheckController: UIViewController, MaskedTextFieldDelegateListener {
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
self.handleQuickActions()
|
||||
}
|
||||
|
||||
func handleQuickActions() {
|
||||
guard let ad = UIApplication.shared.delegate as? AppDelegate else { return }
|
||||
|
||||
if ad.quickAction == .check {
|
||||
ad.quickAction = .none
|
||||
self.number.becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func checkTapped(_ sender: UIButton) {
|
||||
guard let number = self.number.text else { return }
|
||||
|
||||
|
||||
@ -93,7 +93,17 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
guard let ad = UIApplication.shared.delegate as? AppDelegate else { return }
|
||||
|
||||
self.navigationController?.setNavigationBarHidden(self.traitCollection.horizontalSizeClass != .compact, animated: false)
|
||||
|
||||
if ad.quickAction == .check {
|
||||
self.dismiss(animated: false, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
|
||||
@ -63,6 +63,17 @@
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>UIApplicationShortcutItems</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UIApplicationShortcutItemIconType</key>
|
||||
<string>UIApplicationShortcutIconTypeCompose</string>
|
||||
<key>UIApplicationShortcutItemTitle</key>
|
||||
<string>Check plate number</string>
|
||||
<key>UIApplicationShortcutItemType</key>
|
||||
<string>CheckNumberAction</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
|
||||
@ -50,6 +50,26 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
// to restore the scene back to its current state.
|
||||
}
|
||||
|
||||
|
||||
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
|
||||
guard let ad = UIApplication.shared.delegate as? AppDelegate else { return }
|
||||
|
||||
if shortcutItem.type == "CheckNumberAction" {
|
||||
ad.quickAction = .check
|
||||
|
||||
if let split = self.window?.rootViewController as? MainSplitController, let tabvc = split.viewControllers.first as? UITabBarController {
|
||||
if tabvc.selectedIndex == 0 {
|
||||
if let nav = tabvc.selectedViewController as? UINavigationController, let child = nav.topViewController {
|
||||
if let check = child as? CheckController {
|
||||
check.handleQuickActions()
|
||||
} else {
|
||||
nav.popToRootViewController(animated: false)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tabvc.selectedIndex = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user