56 lines
2.0 KiB
Swift
56 lines
2.0 KiB
Swift
import UIKit
|
|
import SwiftEntryKit
|
|
import AutoCatCore
|
|
import RxSwift
|
|
|
|
class MainTabController: UITabBarController, UITabBarControllerDelegate {
|
|
|
|
private let bag = DisposeBag()
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
self.delegate = self
|
|
}
|
|
|
|
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
|
|
if viewController is DummyNewController {
|
|
showCheckPuller()
|
|
return false
|
|
} else {
|
|
return true
|
|
}
|
|
}
|
|
|
|
func showCheckPuller() {
|
|
guard let checkNav = viewControllers?.first as? UINavigationController,
|
|
let checkController = checkNav.viewControllers.first as? CheckController
|
|
else {
|
|
return
|
|
}
|
|
|
|
var attributes = EKAttributes.bottomToast
|
|
attributes.displayDuration = .infinity
|
|
attributes.entryBackground = .color(color: .init(.secondarySystemBackground))
|
|
attributes.screenBackground = .color(color: EKColor(UIColor(white: 0, alpha: 0.7)))
|
|
attributes.roundCorners = .top(radius: 24)
|
|
attributes.screenInteraction = .dismiss
|
|
attributes.entryInteraction = .forward
|
|
attributes.entranceAnimation = .init(translate: .init(duration: 0.2))
|
|
attributes.exitAnimation = .init(translate: .init(duration: 0.2))
|
|
|
|
let newNumberController = NewNumberController()
|
|
newNumberController.onCheck = { number in
|
|
SwiftEntryKit.dismiss {
|
|
self.selectedIndex = 0
|
|
checkController.checkTapped(number: number)
|
|
}
|
|
}
|
|
|
|
SwiftEntryKit.display(entry: newNumberController, using: attributes)
|
|
|
|
// User probably just saw a vehicle and is about to start entering plate number
|
|
// Requesting current location ASAP while we still close to initial location
|
|
RxLocationManager.requestCurrentLocation().subscribe().disposed(by: self.bag)
|
|
}
|
|
}
|