jsdw_ios/QuickLocation/Section/Home/SOS/SOSViewController.swift

60 lines
1.9 KiB
Swift

//
// SOSViewController.swift
// QuickLocation
//
// Created by on 2026/6/18.
//
import UIKit
import RxSwift
import Lottie
class SOSViewController: BaseViewController {
fileprivate var rootView: SOSView!
override func loadView() {
rootView = SOSView(frame: UIScreen.main.bounds)
view = rootView
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
fd_interactivePopDisabled = true
// requestUserInfo()
rootView.didSendSOS = { status in
self.requestSOS(status)
}
}
private func requestUserInfo(completion: (() -> Void)? = nil) {
UserService.userInfo().subscribe { response in
guard let model = response.model else { return }
AppContextManager.shared.saveAccount(model)
guard model.status == 1 else { return }
self.rootView.countDownView.alpha = 1
self.rootView.countDownFinish = true
if let path = Bundle.main.path(forResource: "red-exclamation", ofType: "json") {
self.rootView.countDownLottieView.animation = LottieAnimation.filepath(path)
self.rootView.countDownLottieView.loopMode = .loop
self.rootView.countDownLottieView.play()
self.rootView.countDownTipsLab.text = "已将你的SOS和位置发送到你的圈子和紧急联系人。\n\n您的 SOS 将发送给5个人"
}
}.disposed(by: disposeBag)
}
private func requestSOS(_ enable: Bool) {
dl.showLoading()
SystemService.sos(enable: enable).subscribe(onNext: { response in
self.dl.show(text: enable ? "发送成功" : "取消成功") {
AppRouter.shared.popOrDismiss()
}
}, onError: { (error) in }).disposed(by: disposeBag)
}
}