mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 18:31:41 +01:00
update demo app
This commit is contained in:
@@ -682,6 +682,9 @@
|
|||||||
<nil key="simulatedBottomBarMetrics"/>
|
<nil key="simulatedBottomBarMetrics"/>
|
||||||
<connections>
|
<connections>
|
||||||
<outlet property="bottomContainerView" destination="6So-f3-4Gp" id="C7O-e2-k0l"/>
|
<outlet property="bottomContainerView" destination="6So-f3-4Gp" id="C7O-e2-k0l"/>
|
||||||
|
<outlet property="stackView" destination="cce-yT-4dn" id="r5B-BT-mUM"/>
|
||||||
|
<outlet property="toggleBottomBarButtonItem" destination="aPM-OC-EB8" id="kEV-gg-XOX"/>
|
||||||
|
<outlet property="toggleTopBarButtonItem" destination="6q3-Zk-A9p" id="usC-Zu-DQm"/>
|
||||||
<outlet property="topContainerView" destination="L5f-tW-lXf" id="DRV-mm-rBY"/>
|
<outlet property="topContainerView" destination="L5f-tW-lXf" id="DRV-mm-rBY"/>
|
||||||
</connections>
|
</connections>
|
||||||
</viewController>
|
</viewController>
|
||||||
@@ -900,7 +903,7 @@
|
|||||||
<objects>
|
<objects>
|
||||||
<collectionViewController id="EKY-1g-ALK" customClass="CollectionViewDemoViewController" customModule="CoreStoreDemo" customModuleProvider="target" sceneMemberID="viewController">
|
<collectionViewController id="EKY-1g-ALK" customClass="CollectionViewDemoViewController" customModule="CoreStoreDemo" customModuleProvider="target" sceneMemberID="viewController">
|
||||||
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="hx3-j3-Q80">
|
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="hx3-j3-Q80">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="375" height="311"/>
|
<rect key="frame" x="0.0" y="0.0" width="375" height="311.5"/>
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
|
||||||
<collectionViewFlowLayout key="collectionViewLayout" automaticEstimatedItemSize="YES" minimumLineSpacing="10" minimumInteritemSpacing="10" id="X6n-f9-yEl">
|
<collectionViewFlowLayout key="collectionViewLayout" automaticEstimatedItemSize="YES" minimumLineSpacing="10" minimumInteritemSpacing="10" id="X6n-f9-yEl">
|
||||||
@@ -961,6 +964,9 @@
|
|||||||
</connections>
|
</connections>
|
||||||
</collectionView>
|
</collectionView>
|
||||||
<navigationItem key="navigationItem" title="LiveList" id="goy-Zu-94A"/>
|
<navigationItem key="navigationItem" title="LiveList" id="goy-Zu-94A"/>
|
||||||
|
<connections>
|
||||||
|
<segue destination="dX3-kR-CYC" kind="show" identifier="ObjectObserverDemoViewController" id="k4E-dJ-1lz"/>
|
||||||
|
</connections>
|
||||||
</collectionViewController>
|
</collectionViewController>
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="Fmi-gN-RXz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
<placeholder placeholderIdentifier="IBFirstResponder" id="Fmi-gN-RXz" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
|
||||||
</objects>
|
</objects>
|
||||||
@@ -1170,4 +1176,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<image name="second" width="30" height="30"/>
|
<image name="second" width="30" height="30"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
<inferredMetricsTieBreakers>
|
||||||
|
<segue reference="k4E-dJ-1lz"/>
|
||||||
|
</inferredMetricsTieBreakers>
|
||||||
</document>
|
</document>
|
||||||
|
|||||||
@@ -12,7 +12,32 @@ import CoreStore
|
|||||||
|
|
||||||
// MARK: - ListObserverDemoViewController
|
// MARK: - ListObserverDemoViewController
|
||||||
|
|
||||||
class ListObserverDemoViewController: UITableViewController {
|
final class ListObserverDemoViewController: UITableViewController {
|
||||||
|
|
||||||
|
// MARK: - EditableDataSource
|
||||||
|
|
||||||
|
final class EditableDataSource: DiffableDataSource.TableView<Palette> {
|
||||||
|
|
||||||
|
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
|
||||||
|
|
||||||
|
switch editingStyle {
|
||||||
|
|
||||||
|
case .delete:
|
||||||
|
let palette = ColorsDemo.palettes[indexPath: indexPath]
|
||||||
|
ColorsDemo.stack.perform(
|
||||||
|
asynchronous: { (transaction) in
|
||||||
|
|
||||||
|
transaction.delete(palette)
|
||||||
|
},
|
||||||
|
completion: { _ in }
|
||||||
|
)
|
||||||
|
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: UIViewController
|
// MARK: UIViewController
|
||||||
|
|
||||||
@@ -51,7 +76,7 @@ class ListObserverDemoViewController: UITableViewController {
|
|||||||
]
|
]
|
||||||
self.filterBarButton = filterBarButton
|
self.filterBarButton = filterBarButton
|
||||||
|
|
||||||
self.dataSource = DiffableDataSource.TableView<Palette>(
|
self.dataSource = EditableDataSource(
|
||||||
tableView: self.tableView,
|
tableView: self.tableView,
|
||||||
dataStack: ColorsDemo.stack,
|
dataStack: ColorsDemo.stack,
|
||||||
cellProvider: { (tableView, indexPath, palette) in
|
cellProvider: { (tableView, indexPath, palette) in
|
||||||
@@ -101,25 +126,6 @@ class ListObserverDemoViewController: UITableViewController {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
|
|
||||||
|
|
||||||
switch editingStyle {
|
|
||||||
|
|
||||||
case .delete:
|
|
||||||
let palette = ColorsDemo.palettes[indexPath: indexPath]
|
|
||||||
ColorsDemo.stack.perform(
|
|
||||||
asynchronous: { (transaction) in
|
|
||||||
|
|
||||||
transaction.delete(palette)
|
|
||||||
},
|
|
||||||
completion: { _ in }
|
|
||||||
)
|
|
||||||
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
|
|||||||
@@ -31,16 +31,29 @@ class ObserversViewController: UIViewController {
|
|||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
|
@IBOutlet private dynamic weak var toggleTopBarButtonItem: UIBarButtonItem?
|
||||||
|
@IBOutlet private dynamic weak var toggleBottomBarButtonItem: UIBarButtonItem?
|
||||||
|
@IBOutlet private dynamic weak var stackView: UIStackView?
|
||||||
@IBOutlet private dynamic weak var topContainerView: UIView?
|
@IBOutlet private dynamic weak var topContainerView: UIView?
|
||||||
@IBOutlet private dynamic weak var bottomContainerView: UIView?
|
@IBOutlet private dynamic weak var bottomContainerView: UIView?
|
||||||
|
|
||||||
@IBAction private dynamic func toggleTopContainerView() {
|
@IBAction private dynamic func toggleTopContainerView() {
|
||||||
|
|
||||||
self.topContainerView?.isHidden.toggle()
|
UIView.animate(withDuration: 0.2) {
|
||||||
|
|
||||||
|
self.topContainerView!.isHidden.toggle()
|
||||||
|
}
|
||||||
|
self.toggleTopBarButtonItem!.isEnabled = !self.bottomContainerView!.isHidden
|
||||||
|
self.toggleBottomBarButtonItem!.isEnabled = !self.topContainerView!.isHidden
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction private dynamic func toggleBottomContainerView() {
|
@IBAction private dynamic func toggleBottomContainerView() {
|
||||||
|
|
||||||
self.bottomContainerView?.isHidden.toggle()
|
UIView.animate(withDuration: 0.2) {
|
||||||
|
|
||||||
|
self.bottomContainerView!.isHidden.toggle()
|
||||||
|
}
|
||||||
|
self.toggleTopBarButtonItem!.isEnabled = !self.bottomContainerView!.isHidden
|
||||||
|
self.toggleBottomBarButtonItem!.isEnabled = !self.topContainerView!.isHidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,6 +215,21 @@ extension DiffableDataSource {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
open dynamic func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
open dynamic func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle {
|
||||||
|
|
||||||
|
return .delete
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc
|
||||||
|
open dynamic func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {}
|
||||||
|
|
||||||
|
|
||||||
// MARK: Private
|
// MARK: Private
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user