Browse Source

Pause switch also

Thomas Chef 3 years ago
parent
commit
2dd1b815f9
2 changed files with 91 additions and 11 deletions
  1. 60 10
      JourneyGPSTracker/Base.lproj/Main.storyboard
  2. 31 1
      JourneyGPSTracker/ViewController.swift

+ 60 - 10
JourneyGPSTracker/Base.lproj/Main.storyboard

@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15705" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
-    <device id="retina6_1" orientation="portrait" appearance="light"/>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15706"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -12,16 +13,16 @@
             <objects>
                 <viewController id="BYZ-38-t0r" customClass="ViewController" customModule="JourneyGPSTracker" customModuleProvider="target" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
-                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Tracking" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bwr-8A-cIL">
-                                <rect key="frame" x="141" y="91" width="56" height="17"/>
+                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Tracking active" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bwr-8A-cIL">
+                                <rect key="frame" x="110" y="88" width="98" height="17"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                 <nil key="highlightedColor"/>
                             </label>
-                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ibO-RI-Xe4">
+                            <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ibO-RI-Xe4">
                                 <rect key="frame" x="78" y="433" width="241" height="30"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="43"/>
@@ -31,19 +32,63 @@
                                     <action selector="jhfgjf:" destination="BYZ-38-t0r" eventType="editingChanged" id="607-lr-uNy"/>
                                 </connections>
                             </button>
-                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="vwo-8o-W4T">
-                                <rect key="frame" x="227" y="84" width="49" height="31"/>
+                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" title="Tracking on" translatesAutoresizingMaskIntoConstraints="NO" id="vwo-8o-W4T">
+                                <rect key="frame" x="217" y="81" width="49" height="31"/>
                                 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                 <connections>
                                     <action selector="trackingEnabledChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="tMj-hT-aGR"/>
                                 </connections>
                             </switch>
+                            <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" title="Pause" translatesAutoresizingMaskIntoConstraints="NO" id="1zW-3R-nTk">
+                                <rect key="frame" x="217" y="124" width="49" height="31"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <connections>
+                                    <action selector="tackingPauseChanged:" destination="BYZ-38-t0r" eventType="valueChanged" id="JMi-s9-gih"/>
+                                </connections>
+                            </switch>
+                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Pause" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yma-by-HCw">
+                                <rect key="frame" x="110" y="131" width="40" height="17"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="0" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gjP-2D-NvA">
+                                <rect key="frame" x="330" y="208" width="11" height="21"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="0" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yVZ-Xq-Fgc">
+                                <rect key="frame" x="330" y="228" width="11" height="21"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="No of received GPS Pos:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mF0-kp-IPL">
+                                <rect key="frame" x="34" y="208" width="186" height="21"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
+                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="No of sent GPS Pos:" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="r1m-0H-6gF">
+                                <rect key="frame" x="34" y="228" width="154" height="21"/>
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                <nil key="textColor"/>
+                                <nil key="highlightedColor"/>
+                            </label>
                         </subviews>
-                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                         <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                     </view>
                     <connections>
                         <outlet property="clickButton" destination="ibO-RI-Xe4" id="qFc-vE-7Yy"/>
+                        <outlet property="noOfRxGPSPos" destination="gjP-2D-NvA" id="7hy-Mg-Vvj"/>
+                        <outlet property="noOfSentGPSToServer" destination="yVZ-Xq-Fgc" id="LkD-uQ-QI7"/>
+                        <outlet property="pauseSwitch" destination="1zW-3R-nTk" id="z9y-HB-zSj"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
@@ -51,4 +96,9 @@
             <point key="canvasLocation" x="131.8840579710145" y="104.46428571428571"/>
         </scene>
     </scenes>
+    <resources>
+        <systemColor name="systemBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+    </resources>
 </document>

+ 31 - 1
JourneyGPSTracker/ViewController.swift

@@ -11,8 +11,17 @@ import CoreLocation
 
 class ViewController: UIViewController {
     
+    
+    @IBOutlet weak var noOfRxGPSPos: UILabel!
+    @IBOutlet weak var noOfSentGPSToServer: UILabel!
+    @IBOutlet weak var pauseSwitch: UISwitch!
+    @IBOutlet weak var clickButton: UIButton!
+
     var locationManager: CLLocationManager?
     
+    var noOfSentPos: Int = 0
+    
+    
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -25,6 +34,9 @@ class ViewController: UIViewController {
         locationManager?.activityType = CLActivityType.otherNavigation
         locationManager?.distanceFilter = 100.0
         locationManager?.allowsBackgroundLocationUpdates = true
+        pauseSwitch.isEnabled = false
+        
+        //noOfReceivedGPSPos.text = "KALLE"
     }
     
     @IBAction func buttonClicked(_ sender: Any) {
@@ -33,15 +45,28 @@ class ViewController: UIViewController {
         
     }
     
+    @IBAction func tackingPauseChanged(_ sender: UISwitch) {
+        print("Pause-Switch Changed !")
+        switch sender.isOn {
+        case true:
+            print("Pause ON")
+        default:
+            print("Pause OFF")
+        }
+    }
+    
     @IBAction func trackingEnabledChanged(_ sender: UISwitch) {
         print("Switch Changed !")
         switch sender.isOn {
         case true:
             print("ON")
             locationManager?.startUpdatingLocation()
+            pauseSwitch.isEnabled = true
         default:
             print("OFF")
             locationManager?.stopUpdatingLocation()
+            pauseSwitch.isEnabled = false
+            pauseSwitch.isOn = false
         }
     }
     
@@ -53,7 +78,8 @@ class ViewController: UIViewController {
         print("viewDidBecomeINActive")
     }
     
-    @IBOutlet weak var clickButton: UIButton!
+
+
     
 }
 
@@ -82,6 +108,10 @@ extension ViewController: CLLocationManagerDelegate {
       let dateFormatter = DateFormatter()
       dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
         
+        
+        noOfSentPos += 1
+        noOfRxGPSPos.text = String(noOfSentPos)
+        
         placeOrder(didUpdateLocations: locations)
       
       locations.forEach { (location) in