mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-19 20:25:31 +00:00
List all trainings in training table view controller
This commit is contained in:
@@ -367,6 +367,7 @@
|
||||
C8D5E81D1D479FA800DA0D61 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C8D5E81C1D479FA800DA0D61 /* Main.storyboard */; };
|
||||
C8E0BD0A1F39A08B002FCCA5 /* FormularViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E0BD091F39A08B002FCCA5 /* FormularViewController.swift */; };
|
||||
C8E0BD0D1F39ADAD002FCCA5 /* KeychainPasswordItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E0BD0C1F39ADAD002FCCA5 /* KeychainPasswordItem.swift */; };
|
||||
C8E0D3041F5808E3001EEF5C /* TrainingTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E0D3031F5808E3001EEF5C /* TrainingTableViewCell.swift */; };
|
||||
C8F1B1E11D488B6D004C3379 /* Translation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8F1B1E01D488B6D004C3379 /* Translation.swift */; };
|
||||
C8F71EDA1D8691F700826DE4 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = C8F71EA61D8691F700826DE4 /* AFHTTPRequestOperation.m */; };
|
||||
C8F71EDB1D8691F700826DE4 /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C8F71EA81D8691F700826DE4 /* AFHTTPRequestOperationManager.m */; };
|
||||
@@ -773,6 +774,7 @@
|
||||
C8D938B11EB9AFDB00B1B4BC /* CoreData 3.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "CoreData 3.xcdatamodel"; sourceTree = "<group>"; };
|
||||
C8E0BD091F39A08B002FCCA5 /* FormularViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormularViewController.swift; sourceTree = "<group>"; };
|
||||
C8E0BD0C1F39ADAD002FCCA5 /* KeychainPasswordItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainPasswordItem.swift; sourceTree = "<group>"; };
|
||||
C8E0D3031F5808E3001EEF5C /* TrainingTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrainingTableViewCell.swift; sourceTree = "<group>"; };
|
||||
C8F1B1E01D488B6D004C3379 /* Translation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Translation.swift; sourceTree = "<group>"; };
|
||||
C8F71EA51D8691F700826DE4 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = "<group>"; };
|
||||
C8F71EA61D8691F700826DE4 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = "<group>"; };
|
||||
@@ -1299,6 +1301,7 @@
|
||||
C867BD081F4B0274007E78E0 /* TrainingViewController.swift */,
|
||||
C867BD0A1F4B0290007E78E0 /* CreateTrainingViewController.swift */,
|
||||
C867BD101F4C44E5007E78E0 /* TrainingTableViewController.swift */,
|
||||
C8E0D3031F5808E3001EEF5C /* TrainingTableViewCell.swift */,
|
||||
);
|
||||
name = Training;
|
||||
sourceTree = "<group>";
|
||||
@@ -2014,6 +2017,7 @@
|
||||
C8B3B9BC1F39E64400B3B6BA /* Keychain.swift in Sources */,
|
||||
C867BD111F4C44E5007E78E0 /* TrainingTableViewController.swift in Sources */,
|
||||
C8739E141D2BF16300A89F3C /* LeaderboardData.swift in Sources */,
|
||||
C8E0D3041F5808E3001EEF5C /* TrainingTableViewCell.swift in Sources */,
|
||||
C89C5FC51D06A289002AAAD2 /* GradientView.swift in Sources */,
|
||||
C8F71EEF1D8691F700826DE4 /* UIRefreshControl+AFNetworking.m in Sources */,
|
||||
C8F71EE21D8691F700826DE4 /* AFURLSessionManager.m in Sources */,
|
||||
|
||||
@@ -11,6 +11,7 @@ import UIKit
|
||||
class CreateTrainingViewController: UIViewController {
|
||||
|
||||
weak var trainingController: TrainingController!
|
||||
weak var trainingCoreDataManager: TrainingCoreDataManager!
|
||||
|
||||
@IBOutlet weak var boatClassPickerView: UIPickerView!
|
||||
|
||||
@@ -70,7 +71,7 @@ class CreateTrainingViewController: UIViewController {
|
||||
// MARK: - Propeties
|
||||
|
||||
fileprivate lazy var checkInController: CheckInController = {
|
||||
let checkInController = CheckInController(coreDataManager: RegattaCoreDataManager.shared)
|
||||
let checkInController = CheckInController(coreDataManager: self.trainingCoreDataManager)
|
||||
return checkInController
|
||||
}()
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="603"/>
|
||||
</imageView>
|
||||
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="81" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="OXU-ft-TXZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="397.5"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="400.5"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<view key="tableHeaderView" contentMode="scaleToFill" id="mhw-sY-eah" userLabel="Header View">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="52"/>
|
||||
@@ -143,7 +143,7 @@
|
||||
</connections>
|
||||
</tableView>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kz1-Nl-j1h" userLabel="Button View" customClass="GradientView" customModule="SAPTracker" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="397.5" width="375" height="205.5"/>
|
||||
<rect key="frame" x="0.0" y="400.5" width="375" height="202.5"/>
|
||||
<subviews>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ieu-ch-jeI">
|
||||
<rect key="frame" x="20" y="20" width="335" height="82"/>
|
||||
@@ -198,7 +198,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Info Code Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="OqX-q3-43s">
|
||||
<rect key="frame" x="20" y="166" width="335" height="19.5"/>
|
||||
<rect key="frame" x="20" y="166" width="335" height="16.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="14"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
@@ -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>
|
||||
@@ -417,7 +417,7 @@
|
||||
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<segue destination="1ba-kX-Lnq" kind="show" identifier="Training" id="TgF-p5-r1E"/>
|
||||
<action selector="trainingButtonTapped:" destination="ulQ-cJ-h3D" eventType="touchUpInside" id="sIW-5N-i04"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
@@ -442,6 +442,11 @@
|
||||
</userDefinedRuntimeAttributes>
|
||||
</view>
|
||||
<navigationItem key="navigationItem" id="sxV-N8-xrA"/>
|
||||
<connections>
|
||||
<outlet property="regattaButton" destination="Pmf-c9-OVe" id="pqg-ry-OPE"/>
|
||||
<outlet property="trainingButton" destination="TBi-yV-KGH" id="dUU-B8-sSj"/>
|
||||
<segue destination="1ba-kX-Lnq" kind="show" identifier="Training" id="eP3-jF-cGa"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="QYW-k3-jSc" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
@@ -451,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>
|
||||
@@ -695,7 +700,7 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="gxc-tr-1W6" customClass="HomeViewCell" customModule="SAPTracker" customModuleProvider="target">
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="gxc-tr-1W6" customClass="TrainingTableViewCell" customModule="SAPTracker" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="80" width="375" height="92"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" horizontalCompressionResistancePriority="751" verticalCompressionResistancePriority="751" tableViewCell="gxc-tr-1W6" id="1aF-Hl-dlE">
|
||||
@@ -745,9 +750,9 @@
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" red="0.96470588239999999" green="0.98431372549999996" blue="0.98431372549999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<connections>
|
||||
<outlet property="competitorLabel" destination="QcU-P1-Vfl" id="XHH-zm-LNL"/>
|
||||
<outlet property="eventLabel" destination="DMx-2P-6dH" id="GJo-a8-6Rf"/>
|
||||
<outlet property="leaderboardLabel" destination="QC9-68-Yhb" id="hCh-Yn-5QD"/>
|
||||
<outlet property="competitorLabel" destination="QcU-P1-Vfl" id="WGR-X9-fbv"/>
|
||||
<outlet property="eventLabel" destination="DMx-2P-6dH" id="XX6-oD-vlM"/>
|
||||
<outlet property="leaderboardLabel" destination="QC9-68-Yhb" id="JiV-Nd-SNI"/>
|
||||
<segue destination="smT-3p-ZYf" kind="show" id="b1e-YE-7n4"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
@@ -798,6 +803,7 @@
|
||||
<outlet property="addButton" destination="Pwd-JR-SVL" id="oQ2-6e-NCD"/>
|
||||
<outlet property="footerTextView" destination="AW1-r0-JWj" id="BoM-tz-fRo"/>
|
||||
<outlet property="headerTitleLabel" destination="bx9-EY-ljk" id="91C-Q7-cME"/>
|
||||
<outlet property="headerView" destination="Ugq-RP-elj" id="W6j-cd-AzM"/>
|
||||
<outlet property="tableView" destination="bav-TA-AP5" id="MUP-iZ-LeY"/>
|
||||
<segue destination="dfN-Ch-vpm" kind="presentation" identifier="About" id="TEI-KO-T29"/>
|
||||
<segue destination="4Fb-v3-mkB" kind="presentation" identifier="Settings" id="Xy1-6R-10o"/>
|
||||
@@ -843,7 +849,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="104.5" y="290.5" width="166.5" height="22"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="22" id="g3A-7J-yFy"/>
|
||||
</constraints>
|
||||
@@ -911,19 +917,19 @@
|
||||
<rect key="frame" x="0.0" y="272" width="375" height="38"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sail ID Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="iIf-9z-7fe">
|
||||
<rect key="frame" x="258" y="8.5" width="97" height="22"/>
|
||||
<rect key="frame" x="265.5" y="10" width="89.5" height="19"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Bold" family="Open Sans" pointSize="16"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="DE.png" translatesAutoresizingMaskIntoConstraints="NO" id="szG-Mg-huO">
|
||||
<rect key="frame" x="226" y="7" width="24" height="24"/>
|
||||
<rect key="frame" x="233.5" y="7" width="24" height="24"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="24" id="Ina-uK-atY"/>
|
||||
<constraint firstAttribute="height" constant="24" id="TVX-WF-dOi"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Competitor Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="oJS-dM-2B6" userLabel="Name Label">
|
||||
<rect key="frame" x="20" y="8.5" width="139" height="22"/>
|
||||
<rect key="frame" x="20" y="10" width="124.5" height="19"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Bold" family="Open Sans" pointSize="16"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
@@ -982,7 +988,7 @@
|
||||
</connections>
|
||||
</button>
|
||||
<button hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="1" verticalHuggingPriority="1" horizontalCompressionResistancePriority="999" verticalCompressionResistancePriority="999" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="clip" translatesAutoresizingMaskIntoConstraints="NO" id="CDA-ep-bjo">
|
||||
<rect key="frame" x="66" y="115.5" width="243" height="41"/>
|
||||
<rect key="frame" x="70" y="116" width="235" height="40"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="0.5" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="18"/>
|
||||
<inset key="contentEdgeInsets" minX="8" minY="8" maxX="8" maxY="8"/>
|
||||
@@ -1049,24 +1055,24 @@
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6rV-hv-c3D" userLabel="Countdown View">
|
||||
<rect key="frame" x="6" y="38" width="363" height="50"/>
|
||||
<rect key="frame" x="13.5" y="38" width="349.5" 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"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="116.5" height="50"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="356" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sGD-0U-P4b">
|
||||
<rect key="frame" x="8" y="0.0" width="104" height="29"/>
|
||||
<rect key="frame" x="8" y="0.0" width="99.5" height="24.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="21"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Days Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l8F-Sg-cUb" userLabel="Days Description Label">
|
||||
<rect key="frame" x="8" y="28" width="104" height="22"/>
|
||||
<rect key="frame" x="8" y="31" width="99.5" height="19"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
|
||||
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="joW-cG-ai8" userLabel="Separator View">
|
||||
<rect key="frame" x="120" y="10" width="1" height="30"/>
|
||||
<rect key="frame" x="115.5" y="10" width="1" height="30"/>
|
||||
<color key="backgroundColor" red="0.77900850772857666" green="0.78811043500900269" blue="0.79274082183837891" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="30" id="Jj2-tX-SU9"/>
|
||||
@@ -1086,21 +1092,21 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5is-0I-Kv3" userLabel="Hours View">
|
||||
<rect key="frame" x="121" y="0.0" width="121" height="50"/>
|
||||
<rect key="frame" x="116.5" y="0.0" width="116.5" height="50"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="24" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gaG-Iv-Xyq">
|
||||
<rect key="frame" x="8" y="0.0" width="105" height="29"/>
|
||||
<rect key="frame" x="8" y="0.0" width="100.5" height="24.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="21"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hours Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c2J-Uj-KEg" userLabel="Hours Description Label">
|
||||
<rect key="frame" x="8" y="28" width="105" height="22"/>
|
||||
<rect key="frame" x="8" y="31" width="100.5" height="19"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
|
||||
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JBv-xm-KUq" userLabel="Separator View">
|
||||
<rect key="frame" x="120" y="10" width="1" height="30"/>
|
||||
<rect key="frame" x="115.5" y="10" width="1" height="30"/>
|
||||
<color key="backgroundColor" red="0.81960784313725488" green="0.82745098039215681" blue="0.83137254901960778" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="1" id="Gck-dw-et7"/>
|
||||
@@ -1120,15 +1126,15 @@
|
||||
</constraints>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tvc-eS-Us6" userLabel="Minutes View">
|
||||
<rect key="frame" x="242" y="0.0" width="121" height="50"/>
|
||||
<rect key="frame" x="233" y="0.0" width="116.5" height="50"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="59" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" adjustsLetterSpacingToFitWidth="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Txm-uf-MP4">
|
||||
<rect key="frame" x="8" y="0.0" width="105" height="29"/>
|
||||
<rect key="frame" x="8" y="0.0" width="100.5" height="24.5"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="21"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Minutes Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EES-a9-qxv" userLabel="Minutes Description Label">
|
||||
<rect key="frame" x="8" y="28" width="105" height="22"/>
|
||||
<rect key="frame" x="8" y="31" width="100.5" height="19"/>
|
||||
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="16"/>
|
||||
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
@@ -1364,7 +1370,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>
|
||||
@@ -1464,13 +1470,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>
|
||||
@@ -1496,13 +1502,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>
|
||||
@@ -1528,13 +1534,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>
|
||||
@@ -1560,13 +1566,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"/>
|
||||
@@ -2126,7 +2132,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>
|
||||
@@ -2144,7 +2150,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>
|
||||
@@ -2212,7 +2218,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>
|
||||
|
||||
@@ -23,9 +23,9 @@ extension SignUpControllerError: LocalizedError {
|
||||
|
||||
@objc protocol SignUpControllerDelegate: class {
|
||||
|
||||
func signUpControllerDidFinish(_ controller: SignUpController)
|
||||
func signUpController(_ controller: SignUpController, didFinishLoginWithUserName userName: String)
|
||||
|
||||
func signUpControllerDidCancel(_ controller: SignUpController)
|
||||
func signUpControllerDidCancelLogin(_ controller: SignUpController)
|
||||
|
||||
func signUpControllerDidLogout(_ controller: SignUpController)
|
||||
|
||||
@@ -42,21 +42,23 @@ class SignUpController: NSObject {
|
||||
super.init()
|
||||
}
|
||||
|
||||
// MARK: - Login
|
||||
|
||||
func loginWithViewController(_ controller: UIViewController) {
|
||||
requestManager.postHello(success: { (principal, authenticated, remembered) in
|
||||
// Login success
|
||||
self.didFinishLoginWithViewController(controller)
|
||||
}) { (error, message) in
|
||||
do {
|
||||
let userName = try Keychain.userName.readPassword()
|
||||
let password = try Keychain.userPassword.readPassword()
|
||||
self.requestManager.postAccessToken(userName: userName, password: password, success: { (userName, accessToken) in
|
||||
// Login success, save access token
|
||||
do {
|
||||
try Keychain.userName.savePassword(userName)
|
||||
try Keychain.userAccessToken.savePassword(accessToken)
|
||||
} catch {
|
||||
self.showAlert(forError: error, andMessage: message, withViewController: controller)
|
||||
}
|
||||
self.didFinishLoginWithViewController(controller)
|
||||
}, failure: { (error, message) in
|
||||
self.loginWithViewControllerFailure(controller)
|
||||
})
|
||||
@@ -74,22 +76,45 @@ class SignUpController: NSObject {
|
||||
controller.present(loginNC, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
// MARK: - Logout
|
||||
|
||||
func logoutWithViewController(_ controller: UIViewController) {
|
||||
do {
|
||||
try Keychain.userName.deleteItem()
|
||||
try Keychain.userPassword.deleteItem()
|
||||
try Keychain.userAccessToken.deleteItem()
|
||||
} catch {
|
||||
self.showAlert(forError: error, andMessage: nil, withViewController: controller)
|
||||
showAlert(forError: error, andMessage: nil, withViewController: controller)
|
||||
}
|
||||
requestManager.postLogout(success: {
|
||||
|
||||
}) { (error, message) in
|
||||
|
||||
requestManager.postLogout(success: { [weak self] in
|
||||
self?.didLogoutWithViewController(controller)
|
||||
}) { [weak self] (error, message) in
|
||||
self?.didLogoutWithViewController(controller)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: SignUpControllerDelegate
|
||||
|
||||
fileprivate func didFinishLoginWithViewController(_ controller: UIViewController) {
|
||||
do {
|
||||
let userName = try Keychain.userName.readPassword()
|
||||
delegate?.signUpController(self, didFinishLoginWithUserName: userName)
|
||||
} catch {
|
||||
showAlert(forError: error, andMessage: nil, withViewController: controller)
|
||||
didCancelLoginWithViewController(controller)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func didCancelLoginWithViewController(_ controller: UIViewController) {
|
||||
delegate?.signUpControllerDidCancelLogin(self)
|
||||
}
|
||||
|
||||
fileprivate func didLogoutWithViewController(_ controller: UIViewController) {
|
||||
delegate?.signUpControllerDidLogout(self)
|
||||
}
|
||||
|
||||
// MARK: - Helper
|
||||
|
||||
fileprivate func showAlert(forError error: Error, andMessage message: String?, withViewController controller: UIViewController) {
|
||||
let alertController = UIAlertController.init(title: error.localizedDescription, message: message, preferredStyle: .alert)
|
||||
let okAction = UIAlertAction.init(title: Translation.Common.OK.String, style: .cancel, handler: nil)
|
||||
@@ -113,7 +138,7 @@ extension SignUpController: LoginViewControllerDelegate {
|
||||
|
||||
func loginViewControllerWillCancel(_ controller: LoginViewController) {
|
||||
controller.presentingViewController?.dismiss(animated: true)
|
||||
self.delegate?.signUpControllerDidCancel(self)
|
||||
didCancelLoginWithViewController(controller)
|
||||
}
|
||||
|
||||
fileprivate func loginViewController(_ controller: LoginViewController, didFinishLoginWithUserName userName: String, password: String, accessToken: String) {
|
||||
@@ -122,14 +147,14 @@ extension SignUpController: LoginViewControllerDelegate {
|
||||
try Keychain.userPassword.savePassword(password)
|
||||
try Keychain.userAccessToken.savePassword(accessToken)
|
||||
} catch {
|
||||
self.showAlert(forError: error, andMessage: nil, withViewController: controller)
|
||||
showAlert(forError: error, andMessage: nil, withViewController: controller)
|
||||
}
|
||||
controller.presentingViewController?.dismiss(animated: true)
|
||||
self.delegate?.signUpControllerDidFinish(self)
|
||||
didFinishLoginWithViewController(controller)
|
||||
}
|
||||
|
||||
fileprivate func loginViewController(_ controller: LoginViewController, didFailLoginWithError error: Error, message: String?) {
|
||||
self.showAlert(forError: SignUpController.loginViewControllerError(forError: error), andMessage: message, withViewController: controller)
|
||||
showAlert(forError: SignUpController.loginViewControllerError(forError: error), andMessage: message, withViewController: controller)
|
||||
}
|
||||
|
||||
fileprivate static func loginViewControllerError(forError error: Error) -> Error {
|
||||
@@ -171,14 +196,14 @@ extension SignUpController: SignUpViewControllerDelegate {
|
||||
try Keychain.userPassword.savePassword(password)
|
||||
try Keychain.userAccessToken.savePassword(accessToken)
|
||||
} catch {
|
||||
self.showAlert(forError: error, andMessage: nil, withViewController: controller)
|
||||
showAlert(forError: error, andMessage: nil, withViewController: controller)
|
||||
}
|
||||
controller.presentingViewController?.dismiss(animated: true)
|
||||
self.delegate?.signUpControllerDidFinish(self)
|
||||
didFinishLoginWithViewController(controller)
|
||||
}
|
||||
|
||||
fileprivate func signUpViewController(_ controller: SignUpViewController, didFailSignUpWithError error: Error, message: String?) {
|
||||
self.showAlert(forError: error, andMessage: message, withViewController: controller)
|
||||
showAlert(forError: error, andMessage: message, withViewController: controller)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -208,7 +233,7 @@ extension SignUpController: ForgotPasswordViewControllerDelegate {
|
||||
}
|
||||
|
||||
fileprivate func forgotPasswordViewController(_ controller: ForgotPasswordViewController, didFailChangePasswordWithError error: Error, message: String?) {
|
||||
self.showAlert(forError: error, andMessage: message, withViewController: controller)
|
||||
showAlert(forError: error, andMessage: message, withViewController: controller)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,17 @@
|
||||
import UIKit
|
||||
|
||||
class StartViewController: UIViewController {
|
||||
|
||||
|
||||
fileprivate struct Segue {
|
||||
static let Regatta = "Regatta"
|
||||
static let Training = "Training"
|
||||
}
|
||||
|
||||
var userName: String?
|
||||
|
||||
@IBOutlet weak var regattaButton: UIButton!
|
||||
@IBOutlet weak var trainingButton: UIButton!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
setup()
|
||||
@@ -26,4 +36,51 @@ class StartViewController: UIViewController {
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: UIImageView(image: UIImage(named: "sap_logo")))
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func trainingButtonTapped(_ sender: Any) {
|
||||
if (userName == nil) {
|
||||
signUpController.loginWithViewController(self)
|
||||
} else {
|
||||
performSegue(withIdentifier: Segue.Training, sender: self)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Segues
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
||||
if (segue.identifier == Segue.Training) {
|
||||
guard let trainingTVC = segue.destination as? TrainingTableViewController else { return }
|
||||
trainingTVC.userName = userName
|
||||
trainingTVC.signUpController = signUpController
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
fileprivate lazy var signUpController: SignUpController = {
|
||||
let signUpController = SignUpController(baseURLString: "https://ubilabstest.sapsailing.com")
|
||||
signUpController.delegate = self
|
||||
return signUpController
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// MARK: - SignUpControllerDelegate
|
||||
|
||||
extension StartViewController: SignUpControllerDelegate {
|
||||
|
||||
func signUpController(_ controller: SignUpController, didFinishLoginWithUserName userName: String) {
|
||||
self.userName = userName
|
||||
performSegue(withIdentifier: Segue.Training, sender: self)
|
||||
}
|
||||
|
||||
func signUpControllerDidCancelLogin(_ controller: SignUpController) {
|
||||
userName = nil
|
||||
}
|
||||
|
||||
func signUpControllerDidLogout(_ controller: SignUpController) {
|
||||
userName = nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,4 @@ import UIKit
|
||||
|
||||
class TrainingCoreDataManager: CoreDataManager {
|
||||
|
||||
class var shared: CoreDataManager {
|
||||
struct Singleton {
|
||||
static let shared = RegattaCoreDataManager(name: "TrainingCoreData")
|
||||
}
|
||||
return Singleton.shared
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// TrainingTableViewCell.swift
|
||||
// SAPTracker
|
||||
//
|
||||
// Created by Raimund Wege on 31.08.17.
|
||||
// Copyright © 2017 com.sap.sailing. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class TrainingTableViewCell: UITableViewCell {
|
||||
|
||||
@IBOutlet weak var eventLabel: UILabel!
|
||||
@IBOutlet weak var competitorLabel: UILabel!
|
||||
@IBOutlet weak var leaderboardLabel: UILabel!
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import CoreData
|
||||
|
||||
class TrainingTableViewController: UIViewController {
|
||||
|
||||
@@ -16,7 +17,10 @@ class TrainingTableViewController: UIViewController {
|
||||
static let Settings = "Settings"
|
||||
}
|
||||
|
||||
var login = true
|
||||
var signUpController: SignUpController!
|
||||
var userName: String!
|
||||
|
||||
@IBOutlet var headerView: UIView!
|
||||
|
||||
@IBOutlet weak var headerTitleLabel: UILabel!
|
||||
@IBOutlet weak var tableView: UITableView!
|
||||
@@ -28,24 +32,40 @@ class TrainingTableViewController: UIViewController {
|
||||
setup()
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
if login {
|
||||
signUpController.loginWithViewController(self)
|
||||
login = false
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
fileprivate func setup() {
|
||||
setupAddButton()
|
||||
setupTableView()
|
||||
setupTableViewDataSource()
|
||||
setupTableViewHeader()
|
||||
}
|
||||
|
||||
fileprivate func setupAddButton() {
|
||||
makeViewRoundWithShadow(addButton)
|
||||
}
|
||||
|
||||
fileprivate func setupTableView() {
|
||||
tableView.rowHeight = UITableViewAutomaticDimension
|
||||
tableView.estimatedRowHeight = 140
|
||||
}
|
||||
|
||||
fileprivate func setupTableViewDataSource() {
|
||||
do {
|
||||
try fetchedResultsController.performFetch()
|
||||
} catch {
|
||||
logError(name: "\(#function)", error: error)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func setupTableViewHeader() {
|
||||
if fetchedResultsController.sections?[0].numberOfObjects ?? 0 == 0 {
|
||||
tableView.tableHeaderView = nil
|
||||
} else {
|
||||
tableView.tableHeaderView = headerView
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@IBAction func optionButtonTapped(_ sender: Any) {
|
||||
@@ -80,23 +100,29 @@ class TrainingTableViewController: UIViewController {
|
||||
if (segue.identifier == Segue.CreateTraining) {
|
||||
let createTrainingNC = segue.destination as! UINavigationController
|
||||
let createTrainingVC = createTrainingNC.viewControllers[0] as! CreateTrainingViewController
|
||||
createTrainingVC.trainingCoreDataManager = trainingCoreDataManager;
|
||||
createTrainingVC.trainingController = trainingController
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
fileprivate lazy var signUpController: SignUpController = {
|
||||
let signUpController = SignUpController(baseURLString: "https://ubilabstest.sapsailing.com")
|
||||
signUpController.delegate = self
|
||||
return signUpController
|
||||
}()
|
||||
|
||||
fileprivate lazy var trainingController: TrainingController = {
|
||||
let trainingController = TrainingController(baseURLString: "https://ubilabstest.sapsailing.com")
|
||||
return trainingController
|
||||
}()
|
||||
|
||||
fileprivate lazy var trainingCoreDataManager: TrainingCoreDataManager = {
|
||||
let trainingCoreDataManager = TrainingCoreDataManager(name: self.userName)
|
||||
return trainingCoreDataManager
|
||||
}()
|
||||
|
||||
fileprivate lazy var fetchedResultsController: NSFetchedResultsController<CheckIn> = {
|
||||
let fetchedResultsController = self.trainingCoreDataManager.checkInFetchedResultsController()
|
||||
fetchedResultsController.delegate = self
|
||||
return fetchedResultsController
|
||||
}()
|
||||
|
||||
}
|
||||
|
||||
// MARK: - UITableViewDataSource
|
||||
@@ -104,7 +130,7 @@ class TrainingTableViewController: UIViewController {
|
||||
extension TrainingTableViewController: UITableViewDataSource {
|
||||
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return 0
|
||||
return fetchedResultsController.sections?[section].numberOfObjects ?? 0
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
@@ -114,11 +140,11 @@ extension TrainingTableViewController: UITableViewDataSource {
|
||||
}
|
||||
|
||||
func configureCell(cell: UITableViewCell, atIndexPath indexPath: IndexPath) {
|
||||
// guard let homeViewCell = cell as? HomeViewCell else { return }
|
||||
// let checkIn = fetchedResultsController.object(at: indexPath)
|
||||
// homeViewCell.eventLabel.text = checkIn.event.name
|
||||
// homeViewCell.leaderboardLabel.text = checkIn.leaderboard.name
|
||||
// homeViewCell.competitorLabel.text = checkIn.name
|
||||
guard let trainingTableViewCell = cell as? TrainingTableViewCell else { return }
|
||||
let checkIn = fetchedResultsController.object(at: indexPath)
|
||||
trainingTableViewCell.eventLabel.text = checkIn.event.name
|
||||
trainingTableViewCell.leaderboardLabel.text = checkIn.leaderboard.name
|
||||
trainingTableViewCell.competitorLabel.text = checkIn.name
|
||||
}
|
||||
|
||||
}
|
||||
@@ -129,20 +155,42 @@ extension TrainingTableViewController: UITableViewDelegate {
|
||||
|
||||
}
|
||||
|
||||
// MARK: - SignUpControllerDelegate
|
||||
|
||||
extension TrainingTableViewController: SignUpControllerDelegate {
|
||||
// MARK: - NSFetchedResultsControllerDelegate
|
||||
|
||||
extension TrainingTableViewController: NSFetchedResultsControllerDelegate {
|
||||
|
||||
func signUpControllerDidFinish(_ controller: SignUpController) {
|
||||
|
||||
func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
|
||||
tableView.beginUpdates()
|
||||
}
|
||||
|
||||
func signUpControllerDidCancel(_ controller: SignUpController) {
|
||||
navigationController?.popViewController(animated: true)
|
||||
func controller(
|
||||
_ controller: NSFetchedResultsController<NSFetchRequestResult>,
|
||||
didChange object: Any,
|
||||
at indexPath: IndexPath?,
|
||||
for type: NSFetchedResultsChangeType,
|
||||
newIndexPath: IndexPath?)
|
||||
{
|
||||
switch type {
|
||||
case .insert:
|
||||
tableView.insertRows(at: [newIndexPath!], with: UITableViewRowAnimation.automatic)
|
||||
case .update:
|
||||
let cell = tableView.cellForRow(at: indexPath!)
|
||||
if cell != nil {
|
||||
configureCell(cell: cell!, atIndexPath: indexPath!)
|
||||
tableView.reloadRows(at: [indexPath!], with: UITableViewRowAnimation.automatic)
|
||||
}
|
||||
case .move:
|
||||
tableView.deleteRows(at: [indexPath!], with: UITableViewRowAnimation.automatic)
|
||||
tableView.insertRows(at: [newIndexPath!], with: .automatic)
|
||||
case .delete:
|
||||
tableView.deleteRows(at: [indexPath!], with: UITableViewRowAnimation.automatic)
|
||||
}
|
||||
}
|
||||
|
||||
func signUpControllerDidLogout(_ controller: SignUpController) {
|
||||
navigationController?.popToRootViewController(animated: true)
|
||||
func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
|
||||
tableView.endUpdates()
|
||||
setupTableViewHeader()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user