UnbindViewController.swift
1.77 KB
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
//
// UnbindViewController.swift
// Twear
//
// Created by yangbin on 2022/1/4.
//
import UIKit
class UnbindViewController: UIViewController {
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var macLabel: UILabel!
@IBOutlet weak var batteryLabel: UILabel!
var unbindClosure: (() -> ())?
let device = CurDevice
override func viewDidLoad() {
super.viewDidLoad()
title = LocString("解绑设备")
nameLabel.text = device.name
macLabel.text = "mac:\(device.mac)"
batteryLabel.text = "\(LocString("电量")):\(Battery)%"
// Do any additional setup after loading the view.
}
@IBAction func unbind(_ sender: Any) {
let alertVC = UIAlertController(title: "", message: LocString("是否解除绑定?"), preferredStyle: .alert)
let confirm = UIAlertAction(title: LocString("确定"), style: .destructive) { [weak self] (action) in
BluetoothManager.shared.disconnect()
BluetoothManager.shared.forgetPeripheral()
self?.unbindClosure?()
self?.navigationController?.popViewController(animated: true)
// self?.updateConnectView(false)
}
let cancel = UIAlertAction(title: LocString("取消"), style: .default, handler: nil)
alertVC.addAction(cancel)
alertVC.addAction(confirm)
present(alertVC, animated: true, completion: nil)
}
/*
// 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.
}
*/
}