89 lines
2.6 KiB
Swift
89 lines
2.6 KiB
Swift
//
|
|
// FeatureIntroVC.swift
|
|
// QuickLocation
|
|
//
|
|
|
|
import UIKit
|
|
import CoreLocation
|
|
import SwiftyUserDefaults
|
|
import SDCycleScrollView
|
|
|
|
final class FeatureIntroVC: BaseViewController {
|
|
|
|
override var isNavigationBarHidden: Bool { true }
|
|
|
|
private var rootView: FeatureIntroView!
|
|
|
|
private var bannerList: [BannerConfigModel] = []
|
|
|
|
override func loadView() {
|
|
rootView = FeatureIntroView(frame: UIScreen.main.bounds)
|
|
view = rootView
|
|
}
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
|
|
rootView.cycleScrollView.delegate = self
|
|
|
|
rootView.onTapItem = { [weak self] action in
|
|
self?.handle(action)
|
|
}
|
|
}
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
super.viewDidAppear(animated)
|
|
|
|
guard let config = AppContextManager.shared.systemConfig else { return }
|
|
bannerList = config.bannerList
|
|
rootView.cycleScrollView.isHidden = config.bannerList.filter { $0.enable == true }.count == 0
|
|
rootView.cycleScrollView.imageURLStringsGroup = config.bannerList.filter { $0.enable == true }.map { $0.img }
|
|
}
|
|
|
|
private func handle(_ action: FeatureIntroAction) {
|
|
switch action {
|
|
case .signIn:
|
|
let vc = SignInVC(lastLocation: savedLastLocation)
|
|
vc.isNeedLogin = true
|
|
AppRouter.push(vc)
|
|
case .createBubble:
|
|
AppRouter.push(Route.createBubble)
|
|
case .lockDistract:
|
|
AppRouter.push(Route.lockDistract)
|
|
case .pigeonMessage:
|
|
AppRouter.push(Route.pigeonMessage)
|
|
case .searchLocation:
|
|
AppRouter.push(Route.searchLocation)
|
|
case .sos:
|
|
let vc = SOSViewController()
|
|
vc.isNeedLogin = true
|
|
AppRouter.push(vc)
|
|
case .placeholder:
|
|
DLToast.show(text: "敬请期待")
|
|
}
|
|
}
|
|
|
|
private var savedLastLocation: CLLocation? {
|
|
guard let lat = Defaults[\.currentLatitude],
|
|
let lon = Defaults[\.currentLongitude] else { return nil }
|
|
return CLLocation(latitude: lat, longitude: lon)
|
|
}
|
|
}
|
|
|
|
extension FeatureIntroVC: SDCycleScrollViewDelegate {
|
|
func cycleScrollView(_ cycleScrollView: SDCycleScrollView!, didSelectItemAt index: Int) {
|
|
let model = bannerList[index]
|
|
|
|
switch model.type {
|
|
case "app":
|
|
if model.url == "member" {
|
|
AppRouter.push(Route.vipRecharge)
|
|
}
|
|
case "web":
|
|
AppRouter.push(Route.web, userInfo: ["url": model.url])
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
}
|