2020-03-28 23:51:14 +01:00
//
// C l o u d K i t A c c o u n t V i e w C o n t r o l l e r . s w i f t
// N e t N e w s W i r e - i O S
//
// C r e a t e d b y M a u r i c e P a r k e r o n 3 / 2 8 / 2 0 .
// C o p y r i g h t © 2 0 2 0 R a n c h e r o S o f t w a r e . A l l r i g h t s r e s e r v e d .
//
import UIKit
import Account
class CloudKitAccountViewController : UITableViewController {
weak var delegate : AddAccountDismissDelegate ?
2020-11-09 14:41:05 +01:00
@IBOutlet weak var footerLabel : UILabel !
2020-03-28 23:51:14 +01:00
override func viewDidLoad ( ) {
super . viewDidLoad ( )
2020-11-09 14:41:05 +01:00
setupFooter ( )
2020-03-28 23:51:14 +01:00
tableView . register ( ImageHeaderView . self , forHeaderFooterViewReuseIdentifier : " SectionHeader " )
}
2020-11-09 14:41:05 +01:00
private func setupFooter ( ) {
2020-12-08 08:04:25 +01:00
footerLabel . text = NSLocalizedString ( " NetNewsWire will use your iCloud account to sync your subscriptions across your Mac and iOS devices. " , comment : " iCloud " )
2020-11-09 14:41:05 +01:00
}
2020-03-28 23:51:14 +01:00
@IBAction func cancel ( _ sender : Any ) {
dismiss ( animated : true , completion : nil )
delegate ? . dismiss ( )
}
@IBAction func add ( _ sender : Any ) {
2020-04-01 23:45:29 +02:00
let _ = AccountManager . shared . createAccount ( type : . cloudKit )
2020-03-28 23:51:14 +01:00
dismiss ( animated : true , completion : nil )
delegate ? . dismiss ( )
}
override func tableView ( _ tableView : UITableView , heightForHeaderInSection section : Int ) -> CGFloat {
return section = = 0 ? ImageHeaderView . rowHeight : super . tableView ( tableView , heightForHeaderInSection : section )
}
override func tableView ( _ tableView : UITableView , viewForHeaderInSection section : Int ) -> UIView ? {
if section = = 0 {
let headerView = tableView . dequeueReusableHeaderFooterView ( withIdentifier : " SectionHeader " ) as ! ImageHeaderView
headerView . imageView . image = AppAssets . image ( for : . cloudKit )
return headerView
} else {
return super . tableView ( tableView , viewForHeaderInSection : section )
}
}
}