Adds ability to view previous sync results from SyncStatusViewController
This commit is contained in:
parent
86beaaaaa4
commit
878506e34f
@ -227,11 +227,11 @@
|
||||
<rect key="frame" x="0.0" y="611" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="bwW-PG-BcV" id="RNA-99-evH">
|
||||
<rect key="frame" x="0.0" y="0.0" width="349" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Service" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="4U1-fe-PIb">
|
||||
<rect key="frame" x="15" y="12" width="54" height="19.5"/>
|
||||
<rect key="frame" x="16" y="12" width="54" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -254,11 +254,11 @@
|
||||
<rect key="frame" x="0.0" y="655" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="JPg-6O-DRe" id="zcZ-QR-Nno">
|
||||
<rect key="frame" x="0.0" y="0.0" width="349" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Status" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="1u0-gh-zP7">
|
||||
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
|
||||
<rect key="frame" x="16" y="0.0" width="324" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -278,11 +278,11 @@
|
||||
<rect key="frame" x="0.0" y="755" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="SSL-t4-QZj" id="hQB-Iy-bzy">
|
||||
<rect key="frame" x="0.0" y="0.0" width="349" height="43.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="App Icon Shortcuts" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="c5i-qG-ir9">
|
||||
<rect key="frame" x="15" y="0.0" width="325" height="43.5"/>
|
||||
<rect key="frame" x="16" y="0.0" width="324" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
@ -827,6 +827,26 @@
|
||||
<segue destination="OnX-sX-bHK" kind="show" identifier="showGame" id="vUN-0T-oaK"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="gray" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="PreviousSyncCell" textLabel="Piz-MQ-rK5" style="IBUITableViewCellStyleDefault" id="tdO-nZ-AtU">
|
||||
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="tdO-nZ-AtU" id="Ecj-ul-03q">
|
||||
<rect key="frame" x="0.0" y="0.0" width="341" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Previous Sync" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Piz-MQ-rK5">
|
||||
<rect key="frame" x="16" y="0.0" width="324" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<color key="textColor" name="Purple"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<segue destination="NCG-b5-gRT" kind="show" identifier="showPreviousSyncResults" id="e0p-do-4bJ"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="vVg-ci-JRa" id="Ch3-KN-Vuq"/>
|
||||
@ -838,6 +858,14 @@
|
||||
</objects>
|
||||
<point key="canvasLocation" x="3351" y="1872"/>
|
||||
</scene>
|
||||
<!--syncResultViewController-->
|
||||
<scene sceneID="p0H-JM-YTw">
|
||||
<objects>
|
||||
<viewControllerPlaceholder storyboardName="SyncResultsViewController" referencedIdentifier="syncResultViewController" id="NCG-b5-gRT" sceneMemberID="viewController"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="X4J-BU-m3d" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="3350" y="2281"/>
|
||||
</scene>
|
||||
<!--Game Sync Status View Controller-->
|
||||
<scene sceneID="iQk-cq-qsQ">
|
||||
<objects>
|
||||
|
||||
@ -33,20 +33,30 @@ class SyncStatusViewController: UITableViewController
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
|
||||
{
|
||||
guard segue.identifier == "showGame" else { return }
|
||||
guard let identifier = segue.identifier else { return }
|
||||
|
||||
switch identifier
|
||||
{
|
||||
case "showGame":
|
||||
guard let cell = sender as? UITableViewCell, let indexPath = self.tableView.indexPath(for: cell) else { return }
|
||||
|
||||
let game = self.dataSource.item(at: indexPath)
|
||||
|
||||
let gameSyncStatusViewController = segue.destination as! GameSyncStatusViewController
|
||||
gameSyncStatusViewController.game = game
|
||||
|
||||
case "showPreviousSyncResults":
|
||||
let syncResultViewController = segue.destination as! SyncResultViewController
|
||||
syncResultViewController.result = SyncManager.shared.previousSyncResult
|
||||
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension SyncStatusViewController
|
||||
{
|
||||
func makeDataSource() -> RSTFetchedResultsTableViewDataSource<Game>
|
||||
func makeDataSource() -> RSTCompositeTableViewDataSource<Game>
|
||||
{
|
||||
let fetchRequest = Game.fetchRequest() as NSFetchRequest<Game>
|
||||
fetchRequest.returnsObjectsAsFaults = false
|
||||
@ -54,10 +64,9 @@ private extension SyncStatusViewController
|
||||
|
||||
let fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext, sectionNameKeyPath: #keyPath(Game.gameCollection.name), cacheName: nil)
|
||||
|
||||
let dataSource = RSTFetchedResultsTableViewDataSource(fetchedResultsController: fetchedResultsController)
|
||||
dataSource.proxy = self
|
||||
dataSource.searchController.searchableKeyPaths = [#keyPath(Game.name)]
|
||||
dataSource.cellConfigurationHandler = { (cell, game, indexPath) in
|
||||
let fetchedDataSource = RSTFetchedResultsTableViewDataSource(fetchedResultsController: fetchedResultsController)
|
||||
fetchedDataSource.searchController.searchableKeyPaths = [#keyPath(Game.name)]
|
||||
fetchedDataSource.cellConfigurationHandler = { (cell, game, indexPath) in
|
||||
let cell = cell as! BadgedTableViewCell
|
||||
cell.textLabel?.text = game.name
|
||||
cell.textLabel?.numberOfLines = 0
|
||||
@ -89,6 +98,14 @@ private extension SyncStatusViewController
|
||||
}
|
||||
}
|
||||
|
||||
let dynamicDataSource = RSTDynamicTableViewDataSource<Game>()
|
||||
dynamicDataSource.numberOfSectionsHandler = { (SyncManager.shared.previousSyncResult != nil) ? 1 : 0 }
|
||||
dynamicDataSource.numberOfItemsHandler = { _ in 1 }
|
||||
dynamicDataSource.cellIdentifierHandler = { _ in "PreviousSyncCell" }
|
||||
dynamicDataSource.cellConfigurationHandler = { (cell, _, indexPath) in }
|
||||
|
||||
let dataSource = RSTCompositeTableViewDataSource(dataSources: [dynamicDataSource, fetchedDataSource])
|
||||
dataSource.proxy = self
|
||||
return dataSource
|
||||
}
|
||||
|
||||
@ -149,7 +166,18 @@ extension SyncStatusViewController
|
||||
{
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?
|
||||
{
|
||||
let section = self.dataSource.fetchedResultsController.sections?[section]
|
||||
return section?.name
|
||||
var section = section
|
||||
|
||||
if SyncManager.shared.previousSyncResult != nil
|
||||
{
|
||||
guard section > 0 else { return nil }
|
||||
|
||||
section -= 1
|
||||
}
|
||||
|
||||
let dataSource = self.dataSource.dataSources[1] as! RSTFetchedResultsTableViewDataSource
|
||||
|
||||
let sectionInfo = dataSource.fetchedResultsController.sections?[section]
|
||||
return sectionInfo?.name
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ extension SyncResultViewController
|
||||
|
||||
class SyncResultViewController: UITableViewController
|
||||
{
|
||||
private(set) var result: Result<[Record<NSManagedObject>: Result<Void, RecordError>], SyncError>!
|
||||
var result: Result<[Record<NSManagedObject>: Result<Void, RecordError>], SyncError>!
|
||||
|
||||
private lazy var dataSource = self.makeDataSource()
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<!--Results-->
|
||||
<scene sceneID="bU4-NU-gHn">
|
||||
<objects>
|
||||
<tableViewController id="Vv7-67-y3h" customClass="SyncResultViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableViewController storyboardIdentifier="syncResultViewController" id="Vv7-67-y3h" customClass="SyncResultViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="Mge-4Z-RnG">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
|
||||
2
External/Harmony
vendored
2
External/Harmony
vendored
@ -1 +1 @@
|
||||
Subproject commit 3ac5af8d95bc9c9be04ddcc0da471b532366f4e4
|
||||
Subproject commit c5e7c42f6af20791e65097c7ce2f69774bee8b14
|
||||
Loading…
Reference in New Issue
Block a user