mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Demo app tweaks
This commit is contained in:
1 parent
1a1c0cd3d1
commit
e3e1feee2b
3 files changed
+21
-14
No files matched your search
@@ -10,7 +10,7 @@
|
||||
<scene sceneID="Juk-Ad-tZ2">
|
||||
<objects>
|
||||
<tableViewController id="iNr-Oe-muq" customClass="PlayerEditionViewController" customModule="GRDBDemoiOS" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" dataMode="static" style="insetGrouped" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="vlV-lc-eQA">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" dataMode="static" style="insetGrouped" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="-1" estimatedSectionHeaderHeight="-1" sectionFooterHeight="-1" estimatedSectionFooterHeight="-1" id="vlV-lc-eQA">
|
||||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<sections>
|
||||
@@ -44,7 +44,7 @@
|
||||
<tableViewSection headerTitle="Score" id="Urb-uF-sj1">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="vp3-Ft-Gth">
|
||||
<rect key="frame" x="20" y="155.5" width="374" height="44"/>
|
||||
<rect key="frame" x="20" y="155" width="374" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vp3-Ft-Gth" id="ccO-0O-u72">
|
||||
<rect key="frame" x="0.0" y="0.0" width="374" height="44"/>
|
||||
|
||||
@@ -22,7 +22,7 @@ class PlayerEditionViewController: UITableViewController {
|
||||
configureNavigationItem()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@IBOutlet private weak var cancelBarButtonItem: UIBarButtonItem!
|
||||
@IBOutlet private weak var commitBarButtonItem: UIBarButtonItem!
|
||||
@IBOutlet private weak var nameCell: UITableViewCell!
|
||||
@@ -64,13 +64,15 @@ extension PlayerEditionViewController {
|
||||
private func configureNavigationItem() {
|
||||
guard isViewLoaded else { return }
|
||||
|
||||
switch presentation! {
|
||||
case .modal:
|
||||
navigationItem.leftBarButtonItem = cancelBarButtonItem
|
||||
navigationItem.rightBarButtonItem = commitBarButtonItem
|
||||
case .push:
|
||||
navigationItem.leftBarButtonItem = nil
|
||||
navigationItem.rightBarButtonItem = nil
|
||||
if let presentation = presentation {
|
||||
switch presentation {
|
||||
case .modal:
|
||||
navigationItem.leftBarButtonItem = cancelBarButtonItem
|
||||
navigationItem.rightBarButtonItem = commitBarButtonItem
|
||||
case .push:
|
||||
navigationItem.leftBarButtonItem = nil
|
||||
navigationItem.rightBarButtonItem = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,16 +147,21 @@ extension PlayerListViewController {
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
if segue.identifier == "Edit" {
|
||||
let player = players[tableView.indexPathForSelectedRow!.row]
|
||||
let controller = segue.destination as! PlayerEditionViewController
|
||||
guard
|
||||
let controller = segue.destination as? PlayerEditionViewController,
|
||||
let indexPath = tableView.indexPathForSelectedRow
|
||||
else { return }
|
||||
let player = players[indexPath.row]
|
||||
controller.title = player.name
|
||||
controller.player = player
|
||||
controller.presentation = .push
|
||||
}
|
||||
else if segue.identifier == "New" {
|
||||
guard
|
||||
let navigationController = segue.destination as? UINavigationController,
|
||||
let controller = navigationController.viewControllers.first as? PlayerEditionViewController
|
||||
else { return }
|
||||
setEditing(false, animated: true)
|
||||
let navigationController = segue.destination as! UINavigationController
|
||||
let controller = navigationController.viewControllers.first as! PlayerEditionViewController
|
||||
controller.title = "New Player"
|
||||
controller.player = Player(id: nil, name: "", score: 0)
|
||||
controller.presentation = .modal
|
||||
|
||||
Reference in new issue
Block a user