Blame view

Twear/Setting/DailViewController.swift 4.33 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
40
41
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
69
70
71
72
73
74
75
76
77
78
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
  //
  //  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
          scrollBounds.origin.y += NAVBAR_HEIGHT + 50
          scrollBounds.size.height -= NAVBAR_HEIGHT + 50
          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
          }
      }
      
      
      
      override func viewDidLoad() {
          super.viewDidLoad()
          
          //        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.
       }
       */
      
  }