-
-
Notifications
You must be signed in to change notification settings - Fork 488
/
Copy pathiCloudStatusCell.swift
40 lines (37 loc) · 1.36 KB
/
iCloudStatusCell.swift
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
//
// iCloudStatusCell.swift
// Bark
//
// Created by huangfeng on 2020/5/29.
// Copyright © 2020 Fin. All rights reserved.
//
import CloudKit
import UIKit
class iCloudStatusCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: .value1, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.backgroundColor = BKColor.background.secondary
self.textLabel?.text = NSLocalizedString("iCloudSatatus")
self.detailTextLabel?.text = ""
self.detailTextLabel?.textColor = BKColor.grey.darken2
CKContainer.default().accountStatus { status, _ in
dispatch_sync_safely_main_queue {
switch status {
case .available:
self.detailTextLabel?.text = NSLocalizedString("available")
case .noAccount, .restricted, .temporarilyUnavailable:
self.detailTextLabel?.text = NSLocalizedString("restricted")
case .couldNotDetermine:
self.detailTextLabel?.text = NSLocalizedString("unknown")
@unknown default:
break
}
}
}
}
@available(*, unavailable)
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}