This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let vc = ViewController() | |
| PlaygroundPage.current.liveView = vc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func display(device: Device, orientation: Orientation, language: Language) { | |
| let vc = R.storyboard.twitter.instantiateInitialViewController()! | |
| let (parent, _) = playgroundControllers(device: device, orientation: .portrait, child: vc) | |
| AppEnvironment.language = language | |
| PlaygroundPage.current.liveView = parent | |
| vc.load(statuses) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 端末の大きさ, 向き, 言語を網羅的に指定して列挙していく | |
| display(device: .phone3_5inch, orientation: .portrait, language: .ja) | |
| //display(device: .phone3_5inch, orientation: .portrait, language: .en) | |
| //display(device: .phone4inch, orientation: .portrait, language: .ja) | |
| //display(device: .phone4inch, orientation: .portrait, language: .en) | |
| //display(device: .phone4_7inch, orientation: .portrait, language: .ja) | |
| //display(device: .phone4_7inch, orientation: .portrait, language: .en) | |
| //display(device: .phone5_5inch, orientation: .portrait, language: .ja) | |
| //display(device: .phone5_5inch, orientation: .portrait, language: .en) | |
| //display(device: .pad, orientation: .portrait, language: .ja) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SimpleDataSource: NSObject, UITableViewDataSource { | |
| private var tasks: [Task] = [] | |
| func load(with tasks: [Task]) { | |
| self.tasks = tasks | |
| } | |
| . | |
| . | |
| . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func numberOfSections(in tableView: UITableView) -> Int { | |
| return Category.allCases.count + 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| switch section { | |
| case 0: | |
| return 1 | |
| case 1: | |
| return tasks.filter { $0.category == .personal }.count | |
| case 2: | |
| return tasks.filter { $0.category == .shopping }.count | |
| case 3: | |
| return tasks.filter { $0.category == .work }.count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| switch indexPath.section { | |
| case 0: | |
| return tableView.dequeueReusableCell(withIdentifier: "ProfileTableViewCell") as! ProfileTableViewCell | |
| case 1: | |
| let cell = tableView.dequeueReusableCell(withIdentifier: "TaskTableViewCell") as! TaskTableViewCell | |
| let personalTask = tasks.filter { $0.category == .personal }[indexPath.row] | |
| cell.configure(with: personalTask) | |
| return cell | |
| case 2: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | |
| switch section { | |
| case 0: | |
| return nil | |
| case 1: | |
| return Category.personal.rawValue | |
| case 2: | |
| return Category.shopping.rawValue | |
| case 3: | |
| return Category.work.rawValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CommonizedDataSource: NSObject, UITableViewDataSource { | |
| private var values: [(headerTitle: String?, rows: [(value: Any, reusableId: String)])] = [] | |
| func load(_ tasks: [Task]) { | |
| self.values = [ | |
| ( | |
| headerTitle: nil, | |
| rows: [(value: (), reusableId: "ProfileTableViewCell")] | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func numberOfSections(in tableView: UITableView) -> Int { | |
| return values.count | |
| } |
OlderNewer