mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
Moved more logic into session view controller
This commit is contained in:
1 parent
7777d50a46
commit
eda65aa32f
6 files changed
+206
-225
No files matched your search
@@ -318,7 +318,7 @@
|
||||
<scene sceneID="e3W-CJ-soQ">
|
||||
<objects>
|
||||
<navigationController storyboardIdentifier="rootViewController" id="pqQ-jd-OwW" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="x3H-m5-yJB">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="x3H-m5-yJB">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
@@ -456,7 +456,7 @@
|
||||
<scene sceneID="6Ty-cK-spl">
|
||||
<objects>
|
||||
<navigationController id="Pn3-0n-ZdQ" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="McN-2f-sK6">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="McN-2f-sK6">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
@@ -647,12 +647,18 @@
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" id="d7b-oZ-rAj">
|
||||
<barButtonItem key="rightBarButtonItem" image="settings" id="eom-UN-CnO"/>
|
||||
<barButtonItem key="rightBarButtonItem" image="settings" id="eom-UN-CnO">
|
||||
<connections>
|
||||
<action selector="optionButtonTapped:" destination="smT-3p-ZYf" id="L22-oj-dPG"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<connections>
|
||||
<outlet property="startTrackingButton" destination="e6j-2H-QrX" id="nhE-ml-oLW"/>
|
||||
<outlet property="trainingNameLabel" destination="68H-E2-rnx" id="1p1-q8-8mJ"/>
|
||||
<segue destination="I54-NN-JAf" kind="presentation" identifier="Tracking" id="gEw-ml-Ejg"/>
|
||||
<segue destination="4Fb-v3-mkB" kind="presentation" identifier="Settings" id="yTp-8r-iQQ"/>
|
||||
<segue destination="dfN-Ch-vpm" kind="presentation" identifier="About" id="aVN-ja-G16"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="b6N-3i-Dul" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
@@ -868,7 +874,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mark Name Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumFontSize="12" adjustsLetterSpacingToFitWidth="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="BQe-Id-ec3">
|
||||
<rect key="frame" x="101" y="290.5" width="173" height="22"/>
|
||||
<rect key="frame" x="101.5" y="290.5" width="173" height="22"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="22" id="g3A-7J-yFy"/>
|
||||
</constraints>
|
||||
@@ -1074,7 +1080,7 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6rV-hv-c3D" userLabel="Countdown View">
|
||||
<rect key="frame" x="6.5" y="38" width="363" height="50"/>
|
||||
<rect key="frame" x="6" y="38" width="363" height="50"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pjH-rV-MGI" userLabel="Days View">
|
||||
<rect key="frame" x="0.0" y="0.0" width="121" height="50"/>
|
||||
@@ -1389,7 +1395,7 @@
|
||||
<scene sceneID="s4S-5p-4o1">
|
||||
<objects>
|
||||
<navigationController id="I54-NN-JAf" sceneMemberID="viewController">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="Qb2-vc-6Pl">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="Qb2-vc-6Pl">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
@@ -1489,13 +1495,13 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Status Title Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="r6d-OU-cRI">
|
||||
<rect key="frame" x="20" y="14.5" width="134.5" height="23.5"/>
|
||||
<rect key="frame" x="20" y="14" width="134.5" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Status Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="5Xu-6g-tqP">
|
||||
<rect key="frame" x="259" y="14.5" width="96" height="23.5"/>
|
||||
<rect key="frame" x="259" y="14" width="96" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
@@ -1521,13 +1527,13 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mode Title Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="Xww-rc-pOA">
|
||||
<rect key="frame" x="20" y="14.5" width="130.5" height="23.5"/>
|
||||
<rect key="frame" x="20" y="14" width="130.5" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Mode Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="tJY-RR-vpe">
|
||||
<rect key="frame" x="262" y="14.5" width="93" height="23.5"/>
|
||||
<rect key="frame" x="262" y="14" width="93" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
@@ -1553,13 +1559,13 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GPS Fixes Title Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="Ujw-jg-ilY">
|
||||
<rect key="frame" x="20" y="14.5" width="161" height="23.5"/>
|
||||
<rect key="frame" x="20" y="14" width="161" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GPS Fixes Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="dz3-w7-CCh">
|
||||
<rect key="frame" x="232" y="14.5" width="123" height="23.5"/>
|
||||
<rect key="frame" x="232" y="14" width="123" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
@@ -1585,13 +1591,13 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GPS Accuracy Title Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="Z1d-5I-pbj">
|
||||
<rect key="frame" x="20" y="14.5" width="191.5" height="23.5"/>
|
||||
<rect key="frame" x="20" y="14" width="191.5" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="GPS Accuracy Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DiM-MR-SGV">
|
||||
<rect key="frame" x="181.5" y="14.5" width="153.5" height="23.5"/>
|
||||
<rect key="frame" x="181.5" y="14" width="153.5" height="23.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="17"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -1703,7 +1709,7 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Value Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="48" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="mUm-EE-6Is" userLabel="Time Label">
|
||||
<rect key="frame" x="3" y="243.5" width="369" height="98.5"/>
|
||||
<rect key="frame" x="3" y="244" width="369" height="98.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Light" family="Open Sans" pointSize="72"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -1745,7 +1751,7 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Value Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l5u-i3-029">
|
||||
<rect key="frame" x="3" y="243.5" width="369" height="98.5"/>
|
||||
<rect key="frame" x="3" y="244" width="369" height="98.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Light" family="Open Sans" pointSize="72"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -1786,7 +1792,7 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Value Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sGK-xV-9a0">
|
||||
<rect key="frame" x="3" y="243.5" width="369" height="98.5"/>
|
||||
<rect key="frame" x="3" y="244" width="369" height="98.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Light" family="Open Sans" pointSize="72"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -2151,7 +2157,7 @@
|
||||
<objects>
|
||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="4Fb-v3-mkB" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="opw-zV-Qak">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="opw-zV-Qak">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
@@ -2169,7 +2175,7 @@
|
||||
<objects>
|
||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="dfN-Ch-vpm" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" translucent="NO" id="IvG-lp-FEV">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" translucent="NO" id="IvG-lp-FEV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
@@ -2237,7 +2243,7 @@
|
||||
<objects>
|
||||
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="Njg-ZD-Ycd" sceneMemberID="viewController">
|
||||
<toolbarItems/>
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" id="bNh-Bg-ROM">
|
||||
<navigationBar key="navigationBar" contentMode="scaleToFill" misplaced="YES" id="bNh-Bg-ROM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
@@ -2338,11 +2344,17 @@
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" id="QkD-gi-54l">
|
||||
<barButtonItem key="rightBarButtonItem" image="settings" id="MF0-Id-Lx7"/>
|
||||
<barButtonItem key="rightBarButtonItem" image="settings" id="MF0-Id-Lx7">
|
||||
<connections>
|
||||
<action selector="optionButtonTapped:" destination="IkV-3c-dLR" id="L5U-xZ-PpN"/>
|
||||
</connections>
|
||||
</barButtonItem>
|
||||
</navigationItem>
|
||||
<connections>
|
||||
<outlet property="startTrackingButton" destination="1px-gI-O3d" id="OWA-Ao-RGV"/>
|
||||
<outlet property="trainingNameLabel" destination="GU1-ro-ifJ" id="9wI-5l-XLF"/>
|
||||
<segue destination="dfN-Ch-vpm" kind="presentation" identifier="About" id="rvK-Na-br8"/>
|
||||
<segue destination="4Fb-v3-mkB" kind="presentation" identifier="Settings" id="Gdf-Oz-N6Y"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="7zr-QD-wnW" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
@@ -2361,9 +2373,9 @@
|
||||
<image name="settings" width="22" height="22"/>
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="rvK-Na-br8"/>
|
||||
<segue reference="gEw-ml-Ejg"/>
|
||||
<segue reference="DI8-aY-hHi"/>
|
||||
<segue reference="dH2-8c-PlZ"/>
|
||||
<segue reference="yTp-8r-iQQ"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
<color key="tintColor" red="0.0" green="0.61568627450980395" blue="0.8784313725490196" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</document>
|
||||
@@ -101,52 +101,6 @@ class RegattaCompetitorViewController : SessionViewController, UINavigationContr
|
||||
navigationController?.navigationBar.setNeedsLayout()
|
||||
}
|
||||
|
||||
// MARK: - Update
|
||||
|
||||
fileprivate func update() {
|
||||
competitorSessionController.update { [weak self] in
|
||||
self?.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
fileprivate func refresh() {
|
||||
refreshCompetitor()
|
||||
refreshTeamImage()
|
||||
}
|
||||
|
||||
fileprivate func refreshCompetitor() {
|
||||
competitorNameLabel.text = competitorCheckIn.name
|
||||
competitorFlagImageView.image = UIImage(named: competitorCheckIn.countryCode)
|
||||
competitorSailLabel.text = competitorCheckIn.sailID
|
||||
}
|
||||
|
||||
fileprivate func refreshTeamImage() {
|
||||
if let imageData = competitorCheckIn.teamImageData {
|
||||
teamImageView.image = UIImage(data: imageData as Data)
|
||||
if competitorCheckIn.teamImageRetry {
|
||||
refreshTeamImageButtons(showAddButton: false, showEditButton: true, showRetryButton: true)
|
||||
} else {
|
||||
refreshTeamImageButtons(showAddButton: false, showEditButton: true, showRetryButton: false)
|
||||
setTeamImageWithURLRequest(urlString: competitorCheckIn.teamImageURL, completion: { (withSuccess) in
|
||||
self.refreshTeamImageButtons(showAddButton: false, showEditButton: true, showRetryButton: false)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
self.refreshTeamImageButtons(showAddButton: true, showEditButton: false, showRetryButton: false)
|
||||
setTeamImageWithURLRequest(urlString: competitorCheckIn.teamImageURL, completion: { (withSuccess) in
|
||||
self.refreshTeamImageButtons(showAddButton: !withSuccess, showEditButton: withSuccess, showRetryButton: false)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func refreshTeamImageButtons(showAddButton: Bool, showEditButton: Bool, showRetryButton: Bool) {
|
||||
teamImageAddButton.isHidden = !showAddButton
|
||||
teamImageEditButton.isHidden = !showEditButton
|
||||
teamImageRetryButton.isHidden = !showRetryButton
|
||||
}
|
||||
|
||||
// MARK: - TeamImage
|
||||
|
||||
fileprivate func setTeamImageWithURLRequest(urlString: String?, completion: @escaping (_ withSuccess: Bool) -> Void) {
|
||||
@@ -225,36 +179,6 @@ class RegattaCompetitorViewController : SessionViewController, UINavigationContr
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func optionButtonTapped(_ sender: AnyObject) {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
if let popoverController = alertController.popoverPresentationController {
|
||||
popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
}
|
||||
let settingsAction = UIAlertAction(title: Translation.SettingsView.Title.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.Settings, sender: self)
|
||||
}
|
||||
let checkOutAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.CheckOutAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.checkOut()
|
||||
}
|
||||
let replaceImageAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.ReplaceImageAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.showSelectImageAlert()
|
||||
}
|
||||
let updateAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.UpdateAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.update()
|
||||
}
|
||||
let aboutAction = UIAlertAction(title: Translation.Common.Info.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.About, sender: alertController)
|
||||
}
|
||||
let cancelAction = UIAlertAction(title: Translation.Common.Cancel.String, style: .cancel, handler: nil)
|
||||
alertController.addAction(settingsAction)
|
||||
alertController.addAction(checkOutAction)
|
||||
alertController.addAction(replaceImageAction)
|
||||
alertController.addAction(updateAction)
|
||||
alertController.addAction(aboutAction)
|
||||
alertController.addAction(cancelAction)
|
||||
present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - Alerts
|
||||
|
||||
fileprivate func showSelectImageAlert() {
|
||||
@@ -298,10 +222,30 @@ class RegattaCompetitorViewController : SessionViewController, UINavigationContr
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
fileprivate lazy var actionReplaceImage: UIAlertAction = {
|
||||
return UIAlertAction(title: Translation.CompetitorView.OptionSheet.ReplaceImageAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.showSelectImageAlert()
|
||||
}
|
||||
}()
|
||||
|
||||
fileprivate lazy var competitorSessionController: CompetitorSessionController = {
|
||||
return CompetitorSessionController(checkIn: self.competitorCheckIn, coreDataManager: self.regattaCoreDataManager)
|
||||
}()
|
||||
|
||||
lazy var regattaCompetitorOptionSheet: UIAlertController = {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
// if let popoverController = alertController.popoverPresentationController {
|
||||
// popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
// }
|
||||
alertController.addAction(self.actionSettings)
|
||||
alertController.addAction(self.actionCheckOut)
|
||||
alertController.addAction(self.actionReplaceImage)
|
||||
alertController.addAction(self.actionUpdate)
|
||||
alertController.addAction(self.actionInfo)
|
||||
alertController.addAction(self.actionCancel)
|
||||
return alertController
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UIImagePickerControllerDelegate
|
||||
@@ -384,6 +328,46 @@ extension RegattaCompetitorViewController: SessionViewControllerDelegate {
|
||||
|
||||
var coreDataManager: CoreDataManager { get { return regattaCoreDataManager } }
|
||||
|
||||
var optionSheet: UIAlertController { get { return regattaCompetitorOptionSheet } }
|
||||
|
||||
var sessionController: SessionController { get { return competitorSessionController } }
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
func refresh() {
|
||||
refreshCompetitor()
|
||||
refreshTeamImage()
|
||||
}
|
||||
|
||||
fileprivate func refreshCompetitor() {
|
||||
competitorNameLabel.text = competitorCheckIn.name
|
||||
competitorFlagImageView.image = UIImage(named: competitorCheckIn.countryCode)
|
||||
competitorSailLabel.text = competitorCheckIn.sailID
|
||||
}
|
||||
|
||||
fileprivate func refreshTeamImage() {
|
||||
if let imageData = competitorCheckIn.teamImageData {
|
||||
teamImageView.image = UIImage(data: imageData as Data)
|
||||
if competitorCheckIn.teamImageRetry {
|
||||
refreshTeamImageButtons(showAddButton: false, showEditButton: true, showRetryButton: true)
|
||||
} else {
|
||||
refreshTeamImageButtons(showAddButton: false, showEditButton: true, showRetryButton: false)
|
||||
setTeamImageWithURLRequest(urlString: competitorCheckIn.teamImageURL, completion: { (withSuccess) in
|
||||
self.refreshTeamImageButtons(showAddButton: false, showEditButton: true, showRetryButton: false)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
self.refreshTeamImageButtons(showAddButton: true, showEditButton: false, showRetryButton: false)
|
||||
setTeamImageWithURLRequest(urlString: competitorCheckIn.teamImageURL, completion: { (withSuccess) in
|
||||
self.refreshTeamImageButtons(showAddButton: !withSuccess, showEditButton: withSuccess, showRetryButton: false)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func refreshTeamImageButtons(showAddButton: Bool, showEditButton: Bool, showRetryButton: Bool) {
|
||||
teamImageAddButton.isHidden = !showAddButton
|
||||
teamImageEditButton.isHidden = !showEditButton
|
||||
teamImageRetryButton.isHidden = !showRetryButton
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,48 +48,6 @@ class RegattaMarkViewController: SessionViewController {
|
||||
navigationController?.navigationBar.setNeedsLayout()
|
||||
}
|
||||
|
||||
// MARK: - Update
|
||||
|
||||
fileprivate func update() {
|
||||
markSessionController.update { [weak self] in
|
||||
self?.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
fileprivate func refresh() {
|
||||
markNameLabel.text = markCheckIn.name
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func optionButtonTapped(_ sender: AnyObject) {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
if let popoverController = alertController.popoverPresentationController {
|
||||
popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
}
|
||||
let settingsAction = UIAlertAction(title: Translation.SettingsView.Title.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.Settings, sender: self)
|
||||
}
|
||||
let checkOutAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.CheckOutAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.checkOut()
|
||||
}
|
||||
let updateAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.UpdateAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.update()
|
||||
}
|
||||
let aboutAction = UIAlertAction(title: Translation.Common.Info.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.About, sender: alertController)
|
||||
}
|
||||
let cancelAction = UIAlertAction(title: Translation.Common.Cancel.String, style: .cancel, handler: nil)
|
||||
alertController.addAction(settingsAction)
|
||||
alertController.addAction(checkOutAction)
|
||||
alertController.addAction(updateAction)
|
||||
alertController.addAction(aboutAction)
|
||||
alertController.addAction(cancelAction)
|
||||
present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - Segues
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
@@ -107,6 +65,19 @@ class RegattaMarkViewController: SessionViewController {
|
||||
return MarkSessionController(checkIn: self.markCheckIn, coreDataManager: self.regattaCoreDataManager)
|
||||
}()
|
||||
|
||||
fileprivate lazy var regattaMarkOptionSheet: UIAlertController = {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
// if let popoverController = alertController.popoverPresentationController {
|
||||
// popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
// }
|
||||
alertController.addAction(self.actionSettings)
|
||||
alertController.addAction(self.actionCheckOut)
|
||||
alertController.addAction(self.actionUpdate)
|
||||
alertController.addAction(self.actionInfo)
|
||||
alertController.addAction(self.actionCancel)
|
||||
return alertController
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// MARK: SessionViewControllerDelegate
|
||||
@@ -117,6 +88,14 @@ extension RegattaMarkViewController: SessionViewControllerDelegate {
|
||||
|
||||
var coreDataManager: CoreDataManager { get { return regattaCoreDataManager } }
|
||||
|
||||
var optionSheet: UIAlertController { get { return regattaMarkOptionSheet } }
|
||||
|
||||
var sessionController: SessionController { get { return markSessionController } }
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
func refresh() {
|
||||
markNameLabel.text = markCheckIn.name
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,8 +14,12 @@ protocol SessionViewControllerDelegate: class {
|
||||
|
||||
var coreDataManager: CoreDataManager { get }
|
||||
|
||||
var optionSheet: UIAlertController { get }
|
||||
|
||||
var sessionController: SessionController { get }
|
||||
|
||||
func refresh()
|
||||
|
||||
}
|
||||
|
||||
class SessionViewController: UIViewController {
|
||||
@@ -55,12 +59,26 @@ class SessionViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Update
|
||||
|
||||
func update() {
|
||||
delegate.sessionController.update { [weak self] in
|
||||
self?.delegate.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CheckOut
|
||||
|
||||
func checkOut() {
|
||||
showCheckOutAlert()
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func optionButtonTapped(_ sender: AnyObject) {
|
||||
present(delegate.optionSheet, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - Alerts
|
||||
|
||||
fileprivate func showCheckOutAlert() {
|
||||
@@ -128,4 +146,34 @@ class SessionViewController: UIViewController {
|
||||
present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
lazy var actionCancel: UIAlertAction = {
|
||||
return UIAlertAction(title: Translation.Common.Cancel.String, style: .cancel, handler: nil)
|
||||
}()
|
||||
|
||||
lazy var actionCheckOut: UIAlertAction = {
|
||||
return UIAlertAction(title: Translation.CompetitorView.OptionSheet.CheckOutAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.checkOut()
|
||||
}
|
||||
}()
|
||||
|
||||
lazy var actionInfo: UIAlertAction = {
|
||||
return UIAlertAction(title: Translation.Common.Info.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.About, sender: action)
|
||||
}
|
||||
}()
|
||||
|
||||
lazy var actionSettings: UIAlertAction = {
|
||||
return UIAlertAction(title: Translation.SettingsView.Title.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.Settings, sender: self)
|
||||
}
|
||||
}()
|
||||
|
||||
lazy var actionUpdate: UIAlertAction = {
|
||||
return UIAlertAction(title: Translation.CompetitorView.OptionSheet.UpdateAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.update()
|
||||
}
|
||||
}()
|
||||
|
||||
}
|
||||
@@ -46,48 +46,6 @@ class TrainingCompetitorViewController: SessionViewController {
|
||||
navigationController?.navigationBar.setNeedsLayout()
|
||||
}
|
||||
|
||||
// MARK: - Update
|
||||
|
||||
fileprivate func update() {
|
||||
competitorSessionController.update { [weak self] in
|
||||
self?.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
fileprivate func refresh() {
|
||||
trainingNameLabel.text = competitorCheckIn.event.name
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func optionButtonTapped(_ sender: AnyObject) {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
if let popoverController = alertController.popoverPresentationController {
|
||||
popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
}
|
||||
let settingsAction = UIAlertAction(title: Translation.SettingsView.Title.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.Settings, sender: self)
|
||||
}
|
||||
let checkOutAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.CheckOutAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.checkOut()
|
||||
}
|
||||
let updateAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.UpdateAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.update()
|
||||
}
|
||||
let aboutAction = UIAlertAction(title: Translation.Common.Info.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.About, sender: alertController)
|
||||
}
|
||||
let cancelAction = UIAlertAction(title: Translation.Common.Cancel.String, style: .cancel, handler: nil)
|
||||
alertController.addAction(settingsAction)
|
||||
alertController.addAction(checkOutAction)
|
||||
alertController.addAction(updateAction)
|
||||
alertController.addAction(aboutAction)
|
||||
alertController.addAction(cancelAction)
|
||||
present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - Segues
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
@@ -105,6 +63,19 @@ class TrainingCompetitorViewController: SessionViewController {
|
||||
return CompetitorSessionController(checkIn: self.competitorCheckIn, coreDataManager: self.trainingCoreDataManager)
|
||||
}()
|
||||
|
||||
fileprivate lazy var trainingCompetitorOptionSheet: UIAlertController = {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
// if let popoverController = alertController.popoverPresentationController {
|
||||
// popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
// }
|
||||
alertController.addAction(self.actionSettings)
|
||||
alertController.addAction(self.actionCheckOut)
|
||||
alertController.addAction(self.actionUpdate)
|
||||
alertController.addAction(self.actionInfo)
|
||||
alertController.addAction(self.actionCancel)
|
||||
return alertController
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// MARK: - SessionViewControllerDelegate
|
||||
@@ -115,6 +86,14 @@ extension TrainingCompetitorViewController: SessionViewControllerDelegate {
|
||||
|
||||
var coreDataManager: CoreDataManager { get { return trainingCoreDataManager } }
|
||||
|
||||
var optionSheet: UIAlertController { get { return trainingCompetitorOptionSheet } }
|
||||
|
||||
var sessionController: SessionController { get { return competitorSessionController } }
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
func refresh() {
|
||||
trainingNameLabel.text = competitorCheckIn.event.name
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,48 +46,6 @@ class TrainingMarkViewController: SessionViewController {
|
||||
navigationController?.navigationBar.setNeedsLayout()
|
||||
}
|
||||
|
||||
// MARK: - Update
|
||||
|
||||
fileprivate func update() {
|
||||
markSessionController.update { [weak self] in
|
||||
self?.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
fileprivate func refresh() {
|
||||
trainingNameLabel.text = markCheckIn.event.name
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func optionButtonTapped(_ sender: AnyObject) {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
if let popoverController = alertController.popoverPresentationController {
|
||||
popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
}
|
||||
let settingsAction = UIAlertAction(title: Translation.SettingsView.Title.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.Settings, sender: self)
|
||||
}
|
||||
let checkOutAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.CheckOutAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.checkOut()
|
||||
}
|
||||
let updateAction = UIAlertAction(title: Translation.CompetitorView.OptionSheet.UpdateAction.Title.String, style: .default) { [weak self] action in
|
||||
self?.update()
|
||||
}
|
||||
let aboutAction = UIAlertAction(title: Translation.Common.Info.String, style: .default) { [weak self] action in
|
||||
self?.performSegue(withIdentifier: Segue.About, sender: alertController)
|
||||
}
|
||||
let cancelAction = UIAlertAction(title: Translation.Common.Cancel.String, style: .cancel, handler: nil)
|
||||
alertController.addAction(settingsAction)
|
||||
alertController.addAction(checkOutAction)
|
||||
alertController.addAction(updateAction)
|
||||
alertController.addAction(aboutAction)
|
||||
alertController.addAction(cancelAction)
|
||||
present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - Segues
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
@@ -105,6 +63,19 @@ class TrainingMarkViewController: SessionViewController {
|
||||
return MarkSessionController(checkIn: self.markCheckIn, coreDataManager: self.trainingCoreDataManager)
|
||||
}()
|
||||
|
||||
fileprivate lazy var trainingMarkOptionSheet: UIAlertController = {
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
// if let popoverController = alertController.popoverPresentationController {
|
||||
// popoverController.barButtonItem = sender as? UIBarButtonItem
|
||||
// }
|
||||
alertController.addAction(self.actionSettings)
|
||||
alertController.addAction(self.actionCheckOut)
|
||||
alertController.addAction(self.actionUpdate)
|
||||
alertController.addAction(self.actionInfo)
|
||||
alertController.addAction(self.actionCancel)
|
||||
return alertController
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// MARK: - SessionViewControllerDelegate
|
||||
@@ -115,6 +86,14 @@ extension TrainingMarkViewController: SessionViewControllerDelegate {
|
||||
|
||||
var coreDataManager: CoreDataManager { get { return trainingCoreDataManager } }
|
||||
|
||||
var optionSheet: UIAlertController { get { return trainingMarkOptionSheet } }
|
||||
|
||||
var sessionController: SessionController { get { return markSessionController } }
|
||||
|
||||
// MARK: - Refresh
|
||||
|
||||
func refresh() {
|
||||
trainingNameLabel.text = markCheckIn.event.name
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user