Skip to content

Commit

Permalink
Update ViewController.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanPodymov committed Nov 25, 2019
1 parent 4a763f9 commit d8117fa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Example iOS/Controllers/ViewController.swift
Expand Up @@ -25,17 +25,22 @@ class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "Choose Style"
#if os(iOS)
let segmentedControl = UISegmentedControl(items: ["List", "Dialog", "Native"])
#else
let segmentedControl = UISegmentedControl(items: ["Native"])
#endif
navigationItem.titleView = segmentedControl
segmentedControl.selectedSegmentIndex = 0
navigationItem.rightBarButtonItem = UIBarButtonItem.init(barButtonSystemItem: .play, target: self, action: #selector(self.requestPermissions))
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .play, target: self, action: #selector(self.requestPermissions))
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
}

@objc func requestPermissions() {
if selectedPermissions.isEmpty { return }
guard let segmentControl = navigationItem.titleView as? UISegmentedControl else { return }
switch segmentControl.selectedSegmentIndex {
#if os(iOS)
case 0:
let controller = SPPermissions.list(selectedPermissions)
controller.dataSource = self
Expand All @@ -44,8 +49,11 @@ class ViewController: UITableViewController {
let controller = SPPermissions.dialog(selectedPermissions)
controller.dataSource = self
controller.present(on: self)
#endif
case 2:
break
let controller = SPPermissions.native(selectedPermissions)
controller.dataSource = self
controller.present(on: self)
default:
break
}
Expand Down

0 comments on commit d8117fa

Please sign in to comment.