Blame view

Twear/Setting/DailViewController.swift 4.5 KB
582f536d   yangbin   common:2022.1.28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  //
  //  DailViewController.swift
  //  Twear
  //
  //  Created by yangbin on 2022/1/20.
  //
  
  import UIKit
  import MBProgressHUD
  
  class DailViewController: UIViewController {
      
      @IBOutlet weak var customButton: UIButton!
      @IBOutlet weak var recommendButton: UIButton!
      @IBOutlet weak var underLine: UIImageView!
      
      var dialNum: Int = 9
      private lazy var customVC: CustomDialViewController = {
          return UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "CustomDialViewController") as! CustomDialViewController
      }()
      
      private lazy var recommendVC: DailSyncViewController = {
          let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "DailSyncViewController") as! DailSyncViewController
          vc.dialNum = dialNum
          return vc
      }()
      
      
      private lazy var layout: LTLayout = {
          let layout = LTLayout()
          layout.sliderHeight = 0
          layout.isAverage = true
          layout.sliderWidth = 20
          /* 更多属性设置请参考 LTLayout 中 public 属性说明 */
          return layout
      }()
      
      private lazy var advancedManager: LTAdvancedManager = {
          var scrollBounds = view.bounds
be19e595   yangbin   9
40
41
          scrollBounds.origin.y += 50
          scrollBounds.size.height -= 50
582f536d   yangbin   common:2022.1.28
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
          let advancedManager = LTAdvancedManager(frame: scrollBounds, viewControllers:  [recommendVC, customVC], titles: [LocString("推荐"), LocString("自定义")], currentViewController: self, layout: layout, headerViewHandle: {[weak self] in
              guard let strongSelf = self else { return UIView() }
              return UIView()
          })
          advancedManager.advancedDidSelectIndexHandle = {[weak self] index in
              if index == 0 {
                  self?.selectMode((self?.recommendButton)!)
              } else {
                  self?.selectMode((self?.customButton)!)
              }
              
          }
          //        advancedManager.isClickScrollAnimation = false
          //        advancedManager.advancedDidSelectIndexHandle = {[weak self] index in
          //            self?.titleView.refreshButton(index: index)
          //        }
          return advancedManager
      }()
      
      override func navigationShouldPop() -> Bool {
          if !IsDailSyncing {
              return true
          } else {
              MBProgressHUD.showh(LocString("正在推送表盘中,请稍后..."))
              return false
          }
      }
be19e595   yangbin   9
69
      
66e7e76d   yangbin   NFC
70
71
72
73
      override func viewDidDisappear(_ animated: Bool) {
          super.viewDidDisappear(animated)
          UIApplication.shared.isIdleTimerDisabled = false
      }
582f536d   yangbin   common:2022.1.28
74
75
76
77
      
      
      override func viewDidLoad() {
          super.viewDidLoad()
66e7e76d   yangbin   NFC
78
          UIApplication.shared.isIdleTimerDisabled = true
582f536d   yangbin   common:2022.1.28
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
          //        override func viewDidLoad() {
          //            super.viewDidLoad()
          title = LocString("表盘推送")
          view.backgroundColor = .white
          view.addSubview(advancedManager)
          //        recommendVC.view.backgroundColor = .red
          //            view.addSubview(titleView)
          // Do any additional setup after loading the view.
          
          // Do any additional setup after loading the view.
      }
      
      
      @IBAction func selectMode(_ sender: UIButton) {
          if IsDailSyncing {
              MBProgressHUD.showh(LocString("正在推送表盘中,请稍后..."))
              return
          }
          customButton.titleLabel?.font = RegularFont(16)
          recommendButton.titleLabel?.font = RegularFont(16)
          sender.titleLabel?.font = BoldFont(16)
          switch sender.tag {
          case 0:
              recommendButton.setTitleColor(UIColor.rgbColorFromHex(0x00993E), for: .normal)
              customButton.setTitleColor(.black, for: .normal)
          case 1:
              recommendButton.setTitleColor(.black, for: .normal)
              customButton.setTitleColor(UIColor.rgbColorFromHex(0x00993E), for: .normal)
          default:
              break
          }
          
          UIView.animate(withDuration: 0.2) {
              self.underLine.center.x = sender.center.x
          }
          advancedManager.scrollToIndex(index: sender.tag)
      }
      
      deinit {
          print("deinit\(NSStringFromClass(type(of: self)))!!!!!!!")
      }
      
      /*
       // MARK: - Navigation
       
       // In a storyboard-based application, you will often want to do a little preparation before navigation
       override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
       // Get the new view controller using segue.destination.
       // Pass the selected object to the new view controller.
       }
       */
      
  }