diff --git a/TimeUse+/Access/API.swift b/TimeUse+/Access/API.swift index dfafdadfdc210e3c9a7d64455289baf0469d4969..80cf13818d0439a18f20f50bd87b2704d1d38372 100755 --- a/TimeUse+/Access/API.swift +++ b/TimeUse+/Access/API.swift @@ -203,6 +203,15 @@ class API { } } + @discardableResult + static func mergeEvent(by id: String, callback: @escaping (Result<Void>) -> Void) -> TTCancellable? { + let path = "events/\(id)/merge" + + return request(.delete, path: path, encoding: .url).responseAPI { (reponse, result) in + callback(result) + } + } + // MARK: - Statistics @discardableResult diff --git a/TimeUse+/Model/Event.swift b/TimeUse+/Model/Event.swift index 8cd28d44a7ff6c2305d882a2d4f2d23ba7f10136..a3587db23504d7faed74c10c513590a4d09d1f36 100644 --- a/TimeUse+/Model/Event.swift +++ b/TimeUse+/Model/Event.swift @@ -61,9 +61,9 @@ enum EventStatus: String, Codable { enum EventConfig: String, Codable, CaseIterable { case other, home, work - case car, passenger, carSharing, taxiUber, motorcycle, walk, eScooter - case bicycle, bicycleSharing, eBicycle, eBicycleSharing - case bus, regionalTrain, subway, train, tram, airplane, boat, coach, cableCar, ski + case car, passenger, carSharing = "carsharing", taxiUber = "taxi_uber", motorcycle = "motorbike_scooter", walk, eScooter = "kick_scooter" + case bicycle, bicycleSharing = "bikesharing", eBicycle = "ebicycle", eBicycleSharing = "ebikesharing" + case bus, regionalTrain = "regional_train", subway, train, tram, airplane, boat, coach, cableCar = "cable_car", aerialWay = "aerial_way", gondola, ski case deleted, untracked var title: String { @@ -112,7 +112,7 @@ enum EventConfig: String, Codable, CaseIterable { return Texts.Event.eBicycle.text case .eBicycleSharing: return Texts.Event.eBicycleSharing.text - case .cableCar: + case .cableCar, .aerialWay, .gondola: return Texts.Event.cableCar.text case .regionalTrain: return Texts.Event.regionalTrain.text @@ -189,7 +189,7 @@ enum EventConfig: String, Codable, CaseIterable { return Constants.Colors.main.motorcycle.value case .eScooter: return Constants.Colors.main.eScooter.value - case .cableCar: + case .cableCar, .aerialWay, .gondola: return Constants.Colors.main.cableCar.value case .regionalTrain: return Constants.Colors.main.regionalTrain.value @@ -246,7 +246,7 @@ enum EventConfig: String, Codable, CaseIterable { return #imageLiteral(resourceName: "car_icon") case .eScooter: return #imageLiteral(resourceName: "car_icon") - case .cableCar: + case .cableCar, .aerialWay, .gondola: return #imageLiteral(resourceName: "car_icon") case .regionalTrain: return #imageLiteral(resourceName: "train_icon") diff --git a/TimeUse+/Model/EventActivity.swift b/TimeUse+/Model/EventActivity.swift index eca2b76bf3bb7b6f940b1c8b8909e175d4ee73a8..d7d52dfa4a5e69afa19bb8c0c99c775d36dcdfd8 100644 --- a/TimeUse+/Model/EventActivity.swift +++ b/TimeUse+/Model/EventActivity.swift @@ -42,6 +42,7 @@ class EventActivity: Codable, Equatable { class EventName: Codable { var eventConfig: EventConfig var isSelected: Bool + var emissions: Int var isLast: Bool = false var isFirst: Bool = false @@ -53,10 +54,11 @@ class EventName: Codable { init(eventConfig: EventConfig, isSelected: Bool = false) { self.eventConfig = eventConfig self.isSelected = isSelected + self.emissions = 0 } enum CodingKeys: String, CodingKey { - case isSelected = "selected", eventConfig = "name" + case isSelected = "selected", eventConfig = "name", emissions } } diff --git a/TimeUse+/Screens/Base.lproj/Home.storyboard b/TimeUse+/Screens/Base.lproj/Home.storyboard index 7a4027e343bd1ad1e0d76f1eea237b49f149f115..85f8c3c64a0f20beac8363d8a53759b3275f7874 100644 --- a/TimeUse+/Screens/Base.lproj/Home.storyboard +++ b/TimeUse+/Screens/Base.lproj/Home.storyboard @@ -39,7 +39,7 @@ <rect key="frame" x="0.0" y="44" width="375" height="55"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Events Calendar" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BId-kJ-tGt"> - <rect key="frame" x="125.66666666666666" y="16.333333333333336" width="123.66666666666666" height="22.666666666666664"/> + <rect key="frame" x="125" y="17.666666666666664" width="125" height="20"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" name="dark"/> <nil key="highlightedColor"/> @@ -197,7 +197,7 @@ </constraints> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="10" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="a2j-bU-hBr"> - <rect key="frame" x="17.666666666666668" y="12" width="15.000000000000004" height="20"/> + <rect key="frame" x="16.666666666666668" y="13.333333333333334" width="17.000000000000004" height="17.666666666666664"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="dark"/> <nil key="highlightedColor"/> @@ -233,7 +233,7 @@ <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="March 2020" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DOY-M5-L74"> - <rect key="frame" x="5" y="16" width="113.33333333333333" height="41"/> + <rect key="frame" x="5" y="16" width="112" height="41"/> <constraints> <constraint firstAttribute="height" constant="41" id="fDO-UP-RmW"/> </constraints> @@ -264,16 +264,16 @@ <rect key="frame" x="16" y="691" width="343" height="45"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YIa-Hh-fNW"> - <rect key="frame" x="42.333333333333343" y="12.666666666666629" width="258.33333333333326" height="20"/> + <rect key="frame" x="23" y="13.666666666666631" width="297" height="17.666666666666671"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="You have <count> of unvalidated events." lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VNz-lc-5La"> - <rect key="frame" x="23.999999999999986" y="0.0" width="234.33333333333331" height="20"/> + <rect key="frame" x="24" y="0.0" width="273" height="17.666666666666668"/> <fontDescription key="fontDescription" name="RobotoCondensed-Regular" family="Roboto Condensed" pointSize="15"/> <color key="textColor" red="1" green="0.99999000000000005" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="alert_small_icon" translatesAutoresizingMaskIntoConstraints="NO" id="952-5L-WqL"> - <rect key="frame" x="0.0" y="2" width="16" height="16"/> + <rect key="frame" x="0.0" y="1" width="16" height="16"/> <color key="backgroundColor" name="red"/> <color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <constraints> @@ -370,7 +370,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dH4-gd-d7y" customClass="ExtendedUIButton" customModule="TimeUse" customModuleProvider="target"> - <rect key="frame" x="123.66666666666669" y="0.0" width="128" height="50"/> + <rect key="frame" x="124" y="0.0" width="127" height="50"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <state key="normal" title="31 March 2020" image="down_arrow_icon"> <color key="titleColor" name="dark"/> @@ -444,13 +444,13 @@ <rect key="frame" x="0.0" y="44" width="375" height="55"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="749" text="Event Details" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="28O-GV-UHg"> - <rect key="frame" x="137.66666666666666" y="5" width="100" height="45"/> + <rect key="frame" x="138" y="5" width="99.333333333333314" height="45"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> </label> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hFD-zv-AWt"> - <rect key="frame" x="16" y="0.0" width="40" height="55"/> + <rect key="frame" x="16" y="0.0" width="47" height="55"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <state key="normal" title="Cancel"> <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -460,7 +460,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="656-MF-a8U"> - <rect key="frame" x="335" y="0.0" width="30" height="55"/> + <rect key="frame" x="331" y="0.0" width="34" height="55"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <state key="normal" title="Save"> <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -470,7 +470,7 @@ </connections> </button> <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="white" translatesAutoresizingMaskIntoConstraints="NO" id="jPY-X2-K0E"> - <rect key="frame" x="307" y="17.666666666666664" width="20" height="20"/> + <rect key="frame" x="303" y="17.666666666666664" width="20" height="20"/> </activityIndicatorView> </subviews> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -509,16 +509,16 @@ </constraints> </view> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bEo-q9-eYc"> - <rect key="frame" x="0.0" y="259" width="375" height="121.66666666666669"/> + <rect key="frame" x="0.0" y="259" width="375" height="114.66666666666669"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="I8Y-Zi-5HZ"> - <rect key="frame" x="0.0" y="0.0" width="64" height="81.666666666666671"/> + <rect key="frame" x="0.0" y="0.0" width="64" height="76.666666666666671"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="D8p-6M-nCf" customClass="ExtendedUIView" customModule="TimeUse" customModuleProvider="target"> - <rect key="frame" x="16" y="17" width="48" height="48"/> + <rect key="frame" x="16" y="14.333333333333314" width="48" height="48"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="working_icon" translatesAutoresizingMaskIntoConstraints="NO" id="Dw0-Ov-MmB"> - <rect key="frame" x="12" y="13.333333333333314" width="24" height="21"/> + <rect key="frame" x="12" y="13.666666666666686" width="24" height="21"/> <color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </imageView> </subviews> @@ -551,25 +551,25 @@ </constraints> </view> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CDR-7F-u4G"> - <rect key="frame" x="64" y="0.0" width="106" height="81.666666666666671"/> + <rect key="frame" x="63.999999999999993" y="0.0" width="115.33333333333331" height="76.666666666666671"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="749" text="Other other" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NId-cS-GHS"> - <rect key="frame" x="16" y="18" width="90" height="22.666666666666671"/> + <rect key="frame" x="15.999999999999993" y="18" width="99.333333333333314" height="20"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" name="dark"/> <nil key="highlightedColor"/> </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="eLh-eU-CdK"> - <rect key="frame" x="16" y="43.666666666666686" width="33" height="20"/> + <rect key="frame" x="15.999999999999996" y="41" width="37.666666666666657" height="17.666666666666671"/> <fontDescription key="fontDescription" name="RobotoCondensed-Regular" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="darkGrey"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="time_arrow_icon" translatesAutoresizingMaskIntoConstraints="NO" id="3J2-3U-Cet"> - <rect key="frame" x="55" y="51.333333333333314" width="12" height="5"/> + <rect key="frame" x="59.666666666666671" y="47.333333333333314" width="12" height="5"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalCompressionResistancePriority="749" text="07:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zIM-Qh-XdF"> - <rect key="frame" x="73" y="43.666666666666686" width="33" height="20"/> + <rect key="frame" x="77.666666666666657" y="41" width="37.666666666666657" height="17.666666666666671"/> <fontDescription key="fontDescription" name="RobotoCondensed-Regular" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="darkGrey"/> <nil key="highlightedColor"/> @@ -591,7 +591,7 @@ </constraints> </view> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gai-sR-iCX" customClass="ExtendedUIButton" customModule="TimeUse" customModuleProvider="target"> - <rect key="frame" x="329" y="23" width="30" height="36"/> + <rect key="frame" x="329" y="20.333333333333314" width="30" height="36"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <constraints> <constraint firstAttribute="height" constant="36" id="Xh2-hM-Lhe"/> @@ -616,7 +616,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="tailTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5KO-zy-6jN" customClass="ExtendedUIButton" customModule="TimeUse" customModuleProvider="target"> - <rect key="frame" x="16" y="81.666666666666686" width="343" height="32"/> + <rect key="frame" x="16" y="76.666666666666686" width="343" height="30"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <state key="normal" title="Event did not happen/belongs to previous event"> <color key="titleColor" name="darkGrey"/> @@ -654,7 +654,7 @@ </constraints> </view> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="2HA-nf-Z5X"> - <rect key="frame" x="0.0" y="380.66666666666674" width="375" height="431.33333333333326"/> + <rect key="frame" x="0.0" y="373.66666666666674" width="375" height="438.33333333333326"/> <color key="backgroundColor" name="ultraLightGrey"/> <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="QhI-NF-Our"> <size key="itemSize" width="128" height="128"/> @@ -664,8 +664,8 @@ </collectionViewFlowLayout> <cells/> </collectionView> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No information about activity needed." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dfT-p3-BNk"> - <rect key="frame" x="30" y="580.66666666666663" width="315" height="58.333333333333371"/> + <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="No information about activity needed." textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dfT-p3-BNk"> + <rect key="frame" x="30" y="573.66666666666663" width="315" height="51.333333333333371"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="22"/> <color key="textColor" name="darkGrey"/> <nil key="highlightedColor"/> @@ -733,10 +733,10 @@ <rect key="frame" x="0.0" y="44" width="375" height="55"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="O1g-Mk-DmH" customClass="UIControl"> - <rect key="frame" x="15" y="7.6666666666666643" width="41" height="40"/> + <rect key="frame" x="15.000000000000004" y="7.6666666666666643" width="46.333333333333343" height="40"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Back" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bN5-gO-ilW"> - <rect key="frame" x="12" y="0.0" width="29" height="40"/> + <rect key="frame" x="12" y="0.0" width="34.333333333333336" height="40"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> @@ -764,7 +764,7 @@ </connections> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="749" text="Event Type" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wPF-tv-JPB"> - <rect key="frame" x="146" y="16.333333333333336" width="83.333333333333314" height="22.666666666666664"/> + <rect key="frame" x="146" y="17.666666666666664" width="83.333333333333314" height="20"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> @@ -844,7 +844,7 @@ <nil key="highlightedColor"/> </label> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="O0w-Xn-fuc"> - <rect key="frame" x="16" y="0.0" width="40" height="55"/> + <rect key="frame" x="16" y="0.0" width="47" height="55"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <state key="normal" title="Cancel"> <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -854,7 +854,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="B1u-zY-Hgm"> - <rect key="frame" x="335" y="0.0" width="30" height="55"/> + <rect key="frame" x="331" y="0.0" width="34" height="55"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <state key="normal" title="Save"> <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -864,7 +864,7 @@ </connections> </button> <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="white" translatesAutoresizingMaskIntoConstraints="NO" id="i5K-Rp-Lau"> - <rect key="frame" x="307" y="17.666666666666664" width="20" height="20"/> + <rect key="frame" x="303" y="17.666666666666664" width="20" height="20"/> </activityIndicatorView> </subviews> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -945,13 +945,13 @@ <rect key="frame" x="0.0" y="44" width="375" height="55"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="749" text="title" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="50K-ct-xtk"> - <rect key="frame" x="172.66666666666666" y="5" width="29.666666666666657" height="45"/> + <rect key="frame" x="173.66666666666666" y="5" width="27.666666666666657" height="45"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" name="dark"/> <nil key="highlightedColor"/> </label> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NTj-x1-cEY"> - <rect key="frame" x="16" y="0.0" width="40" height="55"/> + <rect key="frame" x="16" y="0.0" width="47" height="55"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <state key="normal" title="Cancel"> <color key="titleColor" name="darkGrey"/> @@ -961,7 +961,7 @@ </connections> </button> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="119-Y3-95o"> - <rect key="frame" x="335" y="0.0" width="30" height="55"/> + <rect key="frame" x="331" y="0.0" width="34" height="55"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <state key="normal" title="Save"> <color key="titleColor" name="blue"/> @@ -1057,14 +1057,14 @@ <rect key="frame" x="0.0" y="44" width="375" height="55"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dAQ-YQ-1lM" customClass="UIControl"> - <rect key="frame" x="15" y="7.6666666666666643" width="41" height="40"/> + <rect key="frame" x="15.000000000000004" y="7.6666666666666643" width="46.333333333333343" height="40"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="back_icon" translatesAutoresizingMaskIntoConstraints="NO" id="T1l-5i-cN2"> <rect key="frame" x="0.0" y="0.0" width="7" height="40"/> <color key="tintColor" name="blue"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Back" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1kO-GE-cTx"> - <rect key="frame" x="12" y="0.0" width="29" height="40"/> + <rect key="frame" x="12" y="0.0" width="34.333333333333336" height="40"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="blue"/> <nil key="highlightedColor"/> @@ -1086,7 +1086,7 @@ </connections> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Settings" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xc9-ig-Ukw"> - <rect key="frame" x="155.33333333333334" y="16.333333333333336" width="64.333333333333343" height="22.666666666666664"/> + <rect key="frame" x="156.33333333333334" y="17.666666666666664" width="62.666666666666657" height="20"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" name="dark"/> <nil key="highlightedColor"/> @@ -1173,14 +1173,14 @@ <rect key="frame" x="0.0" y="44" width="375" height="55"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pLR-WV-h2m" customClass="UIControl"> - <rect key="frame" x="15" y="7.6666666666666643" width="41" height="40"/> + <rect key="frame" x="15.000000000000004" y="7.6666666666666643" width="46.333333333333343" height="40"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="back_icon" translatesAutoresizingMaskIntoConstraints="NO" id="8nj-JY-JS3"> <rect key="frame" x="0.0" y="0.0" width="7" height="40"/> <color key="tintColor" name="blue"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Back" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xkX-9D-U2G"> - <rect key="frame" x="12" y="0.0" width="29" height="40"/> + <rect key="frame" x="12" y="0.0" width="34.333333333333336" height="40"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="blue"/> <nil key="highlightedColor"/> @@ -1202,7 +1202,7 @@ </connections> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="FAQ" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Opp-6p-ZQz"> - <rect key="frame" x="171.66666666666666" y="16.333333333333336" width="32" height="22.666666666666664"/> + <rect key="frame" x="171" y="17.666666666666664" width="33" height="20"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" name="dark"/> <nil key="highlightedColor"/> @@ -1283,20 +1283,20 @@ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="1jF-hf-gVn"> - <rect key="frame" x="0.0" y="0.0" width="375" height="121.33333333333333"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="113.66666666666667"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ifn-pu-3cR"> - <rect key="frame" x="0.0" y="43.999999999999993" width="375" height="77.333333333333314"/> + <rect key="frame" x="0.0" y="44.000000000000007" width="375" height="69.666666666666686"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ND3-K7-pou" customClass="UIControl"> - <rect key="frame" x="15" y="0.0" width="41" height="77.333333333333329"/> + <rect key="frame" x="15.000000000000004" y="0.0" width="46.333333333333343" height="69.666666666666671"/> <subviews> <imageView userInteractionEnabled="NO" contentMode="center" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" image="back_icon" translatesAutoresizingMaskIntoConstraints="NO" id="P8q-L5-5KJ"> - <rect key="frame" x="0.0" y="0.0" width="7" height="77.333333333333329"/> + <rect key="frame" x="0.0" y="0.0" width="7" height="69.666666666666671"/> <color key="tintColor" name="blue"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="751" text="Back" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="agh-YH-Voj"> - <rect key="frame" x="12" y="0.0" width="29" height="77.333333333333329"/> + <rect key="frame" x="12" y="0.0" width="34.333333333333336" height="69.666666666666671"/> <fontDescription key="fontDescription" name="RobotoCondensed-Bold" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="blue"/> <nil key="highlightedColor"/> @@ -1317,7 +1317,7 @@ </connections> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Where do I see my deleted events that are deleted from the list?" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Y6s-Bd-eTb"> - <rect key="frame" x="77.666666666666671" y="5" width="219.66666666666663" height="67.333333333333329"/> + <rect key="frame" x="83.666666666666686" y="4.9999999999999964" width="208" height="59.666666666666657"/> <fontDescription key="fontDescription" name="Roboto-Medium" family="Roboto" pointSize="17"/> <color key="textColor" name="dark"/> <nil key="highlightedColor"/> @@ -1338,7 +1338,7 @@ </constraints> </view> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ant-BF-sXo"> - <rect key="frame" x="0.0" y="120.33333333333333" width="375" height="1"/> + <rect key="frame" x="0.0" y="112.66666666666667" width="375" height="1"/> <color key="backgroundColor" name="lightGrey"/> <constraints> <constraint firstAttribute="height" constant="1" id="mkl-2S-3Ia"/> @@ -1356,7 +1356,7 @@ </constraints> </view> <wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="MBJ-R4-WDB"> - <rect key="frame" x="0.0" y="121.33333333333331" width="375" height="690.66666666666674"/> + <rect key="frame" x="0.0" y="113.66666666666669" width="375" height="698.33333333333326"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <wkWebViewConfiguration key="configuration"> <audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/> @@ -1395,16 +1395,16 @@ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gCO-wJ-enL" userLabel="headerView"> - <rect key="frame" x="0.0" y="44" width="375" height="48"/> + <rect key="frame" x="0.0" y="44" width="375" height="44.666666666666657"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Change Password" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lh3-78-m1v"> - <rect key="frame" x="102.66666666666667" y="20" width="169.66666666666663" height="28"/> + <rect key="frame" x="101.66666666666669" y="20" width="172" height="24.666666666666671"/> <fontDescription key="fontDescription" name="Roboto-Bold" family="Roboto" pointSize="21"/> <color key="textColor" red="0.094119999999999995" green="0.094119999999999995" blue="0.094119999999999995" alpha="1" colorSpace="custom" customColorSpace="displayP3"/> <nil key="highlightedColor"/> </label> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VDK-mv-Vna"> - <rect key="frame" x="335" y="16.666666666666664" width="35" height="35"/> + <rect key="frame" x="335" y="15" width="35" height="35"/> <constraints> <constraint firstAttribute="width" constant="35" id="bNj-iF-T9Z"/> <constraint firstAttribute="height" constant="35" id="sgk-9o-iE8"/> @@ -1427,7 +1427,7 @@ </constraints> </view> <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7ec-BI-L60"> - <rect key="frame" x="0.0" y="124" width="375" height="567"/> + <rect key="frame" x="0.0" y="120.66666666666669" width="375" height="570.33333333333326"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="T0X-Un-hqz" userLabel="formView"> <rect key="frame" x="0.0" y="0.0" width="375" height="112"/> @@ -1471,13 +1471,13 @@ </connections> </textField> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Old Password" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yso-KF-uMO"> - <rect key="frame" x="16" y="16" width="79.666666666666671" height="20"/> + <rect key="frame" x="16" y="17.333333333333329" width="94.333333333333329" height="17.666666666666671"/> <fontDescription key="fontDescription" name="RobotoCondensed-Regular" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="darkGrey"/> <nil key="highlightedColor"/> </label> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ihi-z4-7gT"> - <rect key="frame" x="255" y="11" width="30" height="30"/> + <rect key="frame" x="255" y="10.999999999999986" width="30" height="30"/> <constraints> <constraint firstAttribute="height" constant="30" id="AXU-a3-NMV"/> <constraint firstAttribute="width" constant="30" id="Rl4-zZ-hsC"/> @@ -1514,7 +1514,7 @@ </userDefinedRuntimeAttributes> </view> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5MS-Oa-6sD" userLabel="newPasswordView" customClass="ExtendedUIView" customModule="TimeUse" customModuleProvider="target"> - <rect key="frame" x="40" y="60" width="295" height="52"/> + <rect key="frame" x="40" y="59.999999999999986" width="295" height="52"/> <subviews> <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="22g-61-Gzz" customClass="SkyFloatingLabelTextField" customModule="SkyFloatingLabelTextField"> <rect key="frame" x="16" y="6" width="263" height="46"/> @@ -1552,7 +1552,7 @@ </connections> </textField> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="New Password" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Jz5-LL-BUy"> - <rect key="frame" x="16" y="16" width="86" height="20"/> + <rect key="frame" x="16" y="17.333333333333343" width="101" height="17.666666666666671"/> <fontDescription key="fontDescription" name="RobotoCondensed-Regular" family="Roboto Condensed" pointSize="15"/> <color key="textColor" name="darkGrey"/> <nil key="highlightedColor"/> @@ -1707,10 +1707,10 @@ </scenes> <designables> <designable name="22g-61-Gzz"> - <size key="intrinsicContentSize" width="263" height="42.29638671875"/> + <size key="intrinsicContentSize" width="263" height="39.988671874999994"/> </designable> <designable name="7bw-tK-moj"> - <size key="intrinsicContentSize" width="263" height="42.29638671875"/> + <size key="intrinsicContentSize" width="263" height="39.988671874999994"/> </designable> </designables> <resources> diff --git a/TimeUse+/Screens/Home/EventDetailsViewController.swift b/TimeUse+/Screens/Home/EventDetailsViewController.swift index 8a8e625fc3a26d0e8ce0e3f85c65faffd84dd83b..e1a0a99f0fa7042bc8cc0565917288f3b6b5f9fc 100644 --- a/TimeUse+/Screens/Home/EventDetailsViewController.swift +++ b/TimeUse+/Screens/Home/EventDetailsViewController.swift @@ -245,7 +245,17 @@ class EventDetailsViewController: __CollectionFeedController, GoogleMapsProtocol let alert = UIAlertController(title: nil, message: Texts.Other.areYouSure.text, preferredStyle: .alert) let action = UIAlertAction(title: Texts.Other.yes.text, style: .default) { action in - + self.saveEventActivityIndicator.startAnimating() + API.mergeEvent(by: self.event.id, callback: { (result) in + self.saveEventActivityIndicator.stopAnimating() + switch result { + case .failure(let error): + self.checkAndShow(error: error) + case .success(_): + self.dismiss(animated: true, completion: nil) + self.completedEventsDelegate?.didDeleteEvent() + } + }) } alert.addAction(action) alert.addAction(UIAlertAction(title: Texts.Other.cancel.text, style: .cancel)) diff --git a/TimeUse+/Screens/Home/EventsViewController/EventsViewController.swift b/TimeUse+/Screens/Home/EventsViewController/EventsViewController.swift index 4990d9bba578bc9f6f0bdb168902e712f42d71ee..fe3811a12692cce14a5a8eb4c5f0228907221d8a 100644 --- a/TimeUse+/Screens/Home/EventsViewController/EventsViewController.swift +++ b/TimeUse+/Screens/Home/EventsViewController/EventsViewController.swift @@ -44,7 +44,7 @@ class EventsViewController: __CollectionFeedController, DateSelectionDelegate, C cellController.completedEventsDelegate = self cellController.delegate = delegate date = Date() - loadEvents(date: date.withFormat("YYYY-MM-dd")) + loadEventsWithFormmatedDate() } // MARK: - Data Loading @@ -145,22 +145,28 @@ class EventsViewController: __CollectionFeedController, DateSelectionDelegate, C func didSelectDate(_ date: Date) { self.date = date - loadEvents(date: date.withFormat("YYYY-MM-dd")) + loadEventsWithFormmatedDate() delegate?.didSelectDay(date) } + // MARK: - Helpers + + func loadEventsWithFormmatedDate() { + loadEvents(date: date.withFormat("YYYY-MM-dd")) + } + // MARK: - EventDetailsViewController func didSaveActivity() { - loadEvents(date: date.withFormat("YYYY-MM-dd")) + loadEventsWithFormmatedDate() } func didDeleteEvent() { - loadEvents(date: date.withFormat("YYYY-MM-dd")) + loadEventsWithFormmatedDate() } func didUpdateUntrackedEvent() { - loadEvents(date: date.withFormat("YYYY-MM-dd")) + loadEventsWithFormmatedDate() } }