@@ -58,30 +58,23 @@ class RootViewController: UIViewController {
5858 rebootButton. translatesAutoresizingMaskIntoConstraints = false
5959 // 添加点击事件
6060 rebootButton. addTarget ( self , action: #selector( onClickRebootButton) , for: . touchUpInside)
61-
61+ rebootButton. isEnabled = enable // 无权限的时候不允许点击
62+
63+ // Respring
64+ let respringButton = UIButton ( type: . system)
65+ respringButton. setTitle ( NSLocalizedString ( " Respring_text " , comment: " " ) , for: . normal)
66+ respringButton. translatesAutoresizingMaskIntoConstraints = false
67+ respringButton. addTarget ( self , action: #selector( onClickRespringButton) , for: . touchUpInside)
68+ respringButton. isEnabled = enable // 无权限的时候不允许点击
69+
6270 // 添加设置项
63- let showAlertSwitch = UISwitch ( )
64- showAlertSwitch. translatesAutoresizingMaskIntoConstraints = false
65-
66- let showAlertLabel = UILabel ( )
67- showAlertLabel. text = NSLocalizedString ( " Show_Alert_Before_Starting_text " , comment: " " )
68- showAlertLabel. textColor = UIColor . label
69- showAlertLabel. translatesAutoresizingMaskIntoConstraints = false
70-
71- // 添加子视图
72- let showAlertSubView = UIView ( )
73- showAlertSubView. translatesAutoresizingMaskIntoConstraints = false
74- // 将开关和标签添加到子视图中
75- showAlertSubView. addSubview ( showAlertLabel)
76- showAlertSubView. addSubview ( showAlertSwitch)
77- // TODO 暂时隐藏 后期直接整合到设置项里
78- showAlertSubView. isHidden = true
71+ let settingButton = UIButton ( type: . system)
7972
8073 // 向View中添加控件
8174 self . view. addSubview ( iconImageView)
8275 self . view. addSubview ( checkPermissionLabel)
8376 self . view. addSubview ( rebootButton)
84- self . view. addSubview ( showAlertSubView )
77+ self . view. addSubview ( respringButton )
8578
8679
8780 // AutoLayout
@@ -102,19 +95,11 @@ class RootViewController: UIViewController {
10295 rebootButton. leadingAnchor. constraint ( equalTo: self . view. leadingAnchor, constant: 50 ) , // 左侧边距
10396 rebootButton. trailingAnchor. constraint ( equalTo: self . view. trailingAnchor, constant: - 50 ) , // 右侧边距
10497
105- showAlertSubView. centerXAnchor. constraint ( equalTo: self . view. centerXAnchor) ,
106- showAlertSubView. topAnchor. constraint ( equalTo: rebootButton. bottomAnchor, constant: 30 ) ,
107- // 动态设置容器的宽度和高度
108- showAlertSubView. leadingAnchor. constraint ( equalTo: showAlertLabel. leadingAnchor) ,
109- showAlertSubView. trailingAnchor. constraint ( equalTo: showAlertSwitch. trailingAnchor) ,
110- showAlertSubView. heightAnchor. constraint ( equalTo: showAlertSwitch. heightAnchor) ,
111- // 标签和开关在容器中水平排列
112- showAlertLabel. leadingAnchor. constraint ( equalTo: showAlertSubView. leadingAnchor) ,
113- showAlertLabel. centerYAnchor. constraint ( equalTo: showAlertSubView. centerYAnchor) ,
114-
115- showAlertSwitch. leadingAnchor. constraint ( equalTo: showAlertLabel. trailingAnchor, constant: 10 ) ,
116- showAlertSwitch. centerYAnchor. constraint ( equalTo: showAlertSubView. centerYAnchor) ,
117- showAlertSwitch. trailingAnchor. constraint ( equalTo: showAlertSubView. trailingAnchor)
98+ respringButton. centerXAnchor. constraint ( equalTo: self . view. centerXAnchor) , // 水平居中
99+ respringButton. heightAnchor. constraint ( equalToConstant: 50 ) ,
100+ respringButton. topAnchor. constraint ( equalTo: rebootButton. bottomAnchor, constant: 20 ) ,
101+ respringButton. leadingAnchor. constraint ( equalTo: self . view. leadingAnchor, constant: 50 ) , // 左侧边距
102+ respringButton. trailingAnchor. constraint ( equalTo: self . view. trailingAnchor, constant: - 50 ) // 右侧边距
118103 ] )
119104 }
120105
@@ -128,6 +113,11 @@ class RootViewController: UIViewController {
128113 let deviceController = DeviceController ( )
129114 deviceController. rebootDevice ( )
130115 }
116+
117+ @objc func onClickRespringButton( ) {
118+ let deviceController = DeviceController ( )
119+ deviceController. respring ( )
120+ }
131121}
132122
133123extension UIColor {
0 commit comments