diff --git a/.DS_Store b/.DS_Store index fdfa471846ee393ed5670fdeb85cf3ee7956eb1e..af7c5950eb1216049b34e074baedcb84f6dda4dd 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/TraccarClient.xcodeproj/project.pbxproj b/TraccarClient.xcodeproj/project.pbxproj index a3796814281821d3bed9e0908b4e69fe1b5aebfd..d996ba8c30062a9dd3d420a5d9928fdd8a052a5f 100644 --- a/TraccarClient.xcodeproj/project.pbxproj +++ b/TraccarClient.xcodeproj/project.pbxproj @@ -100,6 +100,13 @@ 53D62E3F2AEFA31200C80BAC /* InitialViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53D62E3D2AEFA31200C80BAC /* InitialViewController.swift */; }; 53D62E402AEFA31200C80BAC /* InitialViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53D62E3E2AEFA31200C80BAC /* InitialViewController.xib */; }; 53D62E432AEFA4DC00C80BAC /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 53D62E422AEFA4DC00C80BAC /* Lottie */; }; + 53EBC5FE2AF199FF00601AA7 /* SettingsTextTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EBC5FC2AF199FF00601AA7 /* SettingsTextTableViewCell.swift */; }; + 53EBC5FF2AF199FF00601AA7 /* SettingsTextTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53EBC5FD2AF199FF00601AA7 /* SettingsTextTableViewCell.xib */; }; + 53EBC6012AF1A1DB00601AA7 /* DefaultsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EBC6002AF1A1DB00601AA7 /* DefaultsModel.swift */; }; + 53EBC6062AF1A43900601AA7 /* SettingsSwitchTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EBC6042AF1A43900601AA7 /* SettingsSwitchTableViewCell.swift */; }; + 53EBC6072AF1A43900601AA7 /* SettingsSwitchTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53EBC6052AF1A43900601AA7 /* SettingsSwitchTableViewCell.xib */; }; + 53EBC60B2AF1A5C200601AA7 /* SettingsSegmentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53EBC6092AF1A5C200601AA7 /* SettingsSegmentTableViewCell.swift */; }; + 53EBC60C2AF1A5C200601AA7 /* SettingsSegmentTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 53EBC60A2AF1A5C200601AA7 /* SettingsSegmentTableViewCell.xib */; }; 53F10AE22AF05C57004D0529 /* KNNavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53F10AE12AF05C57004D0529 /* KNNavigationController.swift */; }; 53F10AE42AF05E68004D0529 /* AuthenticationStep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53F10AE32AF05E68004D0529 /* AuthenticationStep.swift */; }; 53F10AE62AF05E97004D0529 /* AuthenticationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53F10AE52AF05E97004D0529 /* AuthenticationCoordinator.swift */; }; @@ -128,7 +135,6 @@ CB7ED0801F6602CD00A33FCF /* Position.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB7ED07F1F6602CD00A33FCF /* Position.swift */; }; CB7ED0821F661B4F00A33FCF /* PositionProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB7ED0811F661B4F00A33FCF /* PositionProvider.swift */; }; CB7ED0841F662BAF00A33FCF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB7ED0831F662BAF00A33FCF /* AppDelegate.swift */; }; - CBAA0F7D1F68E14C008BBBBE /* StatusViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAA0F7C1F68E14C008BBBBE /* StatusViewController.swift */; }; CBAA0F7F1F68E807008BBBBE /* MainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAA0F7E1F68E807008BBBBE /* MainViewController.swift */; }; CBAA0F811F68EB62008BBBBE /* TrackingController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBAA0F801F68EB62008BBBBE /* TrackingController.swift */; }; CBCE82EF1B8D253600A7318B /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBCE82EE1B8D253600A7318B /* CoreData.framework */; }; @@ -259,6 +265,13 @@ 5370B46F2AEFB8A900AE08CC /* splash.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = splash.json; sourceTree = "<group>"; }; 53D62E3D2AEFA31200C80BAC /* InitialViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InitialViewController.swift; sourceTree = "<group>"; }; 53D62E3E2AEFA31200C80BAC /* InitialViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InitialViewController.xib; sourceTree = "<group>"; }; + 53EBC5FC2AF199FF00601AA7 /* SettingsTextTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsTextTableViewCell.swift; sourceTree = "<group>"; }; + 53EBC5FD2AF199FF00601AA7 /* SettingsTextTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingsTextTableViewCell.xib; sourceTree = "<group>"; }; + 53EBC6002AF1A1DB00601AA7 /* DefaultsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultsModel.swift; sourceTree = "<group>"; }; + 53EBC6042AF1A43900601AA7 /* SettingsSwitchTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSwitchTableViewCell.swift; sourceTree = "<group>"; }; + 53EBC6052AF1A43900601AA7 /* SettingsSwitchTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingsSwitchTableViewCell.xib; sourceTree = "<group>"; }; + 53EBC6092AF1A5C200601AA7 /* SettingsSegmentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSegmentTableViewCell.swift; sourceTree = "<group>"; }; + 53EBC60A2AF1A5C200601AA7 /* SettingsSegmentTableViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SettingsSegmentTableViewCell.xib; sourceTree = "<group>"; }; 53F10AE12AF05C57004D0529 /* KNNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KNNavigationController.swift; sourceTree = "<group>"; }; 53F10AE32AF05E68004D0529 /* AuthenticationStep.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationStep.swift; sourceTree = "<group>"; }; 53F10AE52AF05E97004D0529 /* AuthenticationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationCoordinator.swift; sourceTree = "<group>"; }; @@ -284,7 +297,6 @@ CB7ED07F1F6602CD00A33FCF /* Position.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Position.swift; sourceTree = "<group>"; }; CB7ED0811F661B4F00A33FCF /* PositionProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PositionProvider.swift; sourceTree = "<group>"; }; CB7ED0831F662BAF00A33FCF /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; - CBAA0F7C1F68E14C008BBBBE /* StatusViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusViewController.swift; sourceTree = "<group>"; }; CBAA0F7E1F68E807008BBBBE /* MainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainViewController.swift; sourceTree = "<group>"; }; CBAA0F801F68EB62008BBBBE /* TrackingController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrackingController.swift; sourceTree = "<group>"; }; CBCE82EE1B8D253600A7318B /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; @@ -367,8 +379,10 @@ 5300802B2AF149C500A05E04 /* SettingsViewController */ = { isa = PBXGroup; children = ( + 53EBC5FB2AF199E200601AA7 /* Cells */, 5300802C2AF149D400A05E04 /* SettingsViewController.swift */, 5300802D2AF149D400A05E04 /* SettingsViewController.xib */, + 53EBC6002AF1A1DB00601AA7 /* DefaultsModel.swift */, ); path = SettingsViewController; sourceTree = "<group>"; @@ -643,6 +657,43 @@ path = InitialViewController; sourceTree = "<group>"; }; + 53EBC5FB2AF199E200601AA7 /* Cells */ = { + isa = PBXGroup; + children = ( + 53EBC6082AF1A5A800601AA7 /* SettingsSegmentTableViewCell */, + 53EBC6032AF1A41C00601AA7 /* SettingsSwitchTableViewCell */, + 53EBC6022AF1A41000601AA7 /* SettingsTextTableViewCell */, + ); + path = Cells; + sourceTree = "<group>"; + }; + 53EBC6022AF1A41000601AA7 /* SettingsTextTableViewCell */ = { + isa = PBXGroup; + children = ( + 53EBC5FC2AF199FF00601AA7 /* SettingsTextTableViewCell.swift */, + 53EBC5FD2AF199FF00601AA7 /* SettingsTextTableViewCell.xib */, + ); + path = SettingsTextTableViewCell; + sourceTree = "<group>"; + }; + 53EBC6032AF1A41C00601AA7 /* SettingsSwitchTableViewCell */ = { + isa = PBXGroup; + children = ( + 53EBC6042AF1A43900601AA7 /* SettingsSwitchTableViewCell.swift */, + 53EBC6052AF1A43900601AA7 /* SettingsSwitchTableViewCell.xib */, + ); + path = SettingsSwitchTableViewCell; + sourceTree = "<group>"; + }; + 53EBC6082AF1A5A800601AA7 /* SettingsSegmentTableViewCell */ = { + isa = PBXGroup; + children = ( + 53EBC6092AF1A5C200601AA7 /* SettingsSegmentTableViewCell.swift */, + 53EBC60A2AF1A5C200601AA7 /* SettingsSegmentTableViewCell.xib */, + ); + path = SettingsSegmentTableViewCell; + sourceTree = "<group>"; + }; 53F10AF12AF0F267004D0529 /* MainViewController */ = { isa = PBXGroup; children = ( @@ -706,7 +757,6 @@ CB7ED0811F661B4F00A33FCF /* PositionProvider.swift */, 5E716A2A1F63A60800A2DBC3 /* ProtocolFormatter.swift */, 5E716A281F63A45A00A2DBC3 /* RequestManager.swift */, - CBAA0F7C1F68E14C008BBBBE /* StatusViewController.swift */, CBAA0F801F68EB62008BBBBE /* TrackingController.swift */, ); path = TraccarClient; @@ -868,11 +918,14 @@ 5326833D2AE9175900A364C0 /* LoginViewController.xib in Resources */, CE5899C81B115C9100ED70D2 /* Images.xcassets in Resources */, 5326835F2AE91A6F00A364C0 /* Montserrat-Black.ttf in Resources */, + 53EBC5FF2AF199FF00601AA7 /* SettingsTextTableViewCell.xib in Resources */, 532683742AE923A500A364C0 /* KNTextFieldView.xib in Resources */, 532683622AE91A6F00A364C0 /* Montserrat-ExtraBoldItalic.ttf in Resources */, 5326835E2AE91A6F00A364C0 /* Montserrat-Regular.ttf in Resources */, 532683522AE91A6F00A364C0 /* Montserrat-Light.ttf in Resources */, + 53EBC60C2AF1A5C200601AA7 /* SettingsSegmentTableViewCell.xib in Resources */, CEF643271B919FFA00195CEA /* LaunchScreen.xib in Resources */, + 53EBC6072AF1A43900601AA7 /* SettingsSwitchTableViewCell.xib in Resources */, 532683592AE91A6F00A364C0 /* Montserrat-SemiBold.ttf in Resources */, CED4879B17DB1E61007FCF57 /* InAppSettings.bundle in Resources */, 532683532AE91A6F00A364C0 /* Montserrat-ExtraBold.ttf in Resources */, @@ -938,10 +991,12 @@ 532683BB2AEA50B800A364C0 /* LoginDataSource.swift in Sources */, 53157ED82AEE5751003C9B6A /* KNAlertViewController.swift in Sources */, 5326837A2AE923A500A364C0 /* KNFieldDropDownAddressObjectProtocol.swift in Sources */, + 53EBC5FE2AF199FF00601AA7 /* SettingsTextTableViewCell.swift in Sources */, CBAA0F7F1F68E807008BBBBE /* MainViewController.swift in Sources */, 532683B52AE98FB600A364C0 /* UIString.swift in Sources */, 5326839C2AE9482300A364C0 /* Network+Error.swift in Sources */, 532683AF2AE94C2F00A364C0 /* NSLayoutConstraints.swift in Sources */, + 53EBC6062AF1A43900601AA7 /* SettingsSwitchTableViewCell.swift in Sources */, CB7ED0821F661B4F00A33FCF /* PositionProvider.swift in Sources */, 5300803D2AF1803100A05E04 /* TransactionTableViewCell.swift in Sources */, 53554AE52AED1BF10018BAEE /* UIButton.swift in Sources */, @@ -980,7 +1035,6 @@ 532683652AE91D0800A364C0 /* UIFont.swift in Sources */, CBCE82F21B8D265800A7318B /* TraccarClient.xcdatamodeld in Sources */, 532683762AE923A500A364C0 /* KNTextFieldViewHelper.swift in Sources */, - CBAA0F7D1F68E14C008BBBBE /* StatusViewController.swift in Sources */, 53F10AEC2AF06556004D0529 /* UIImage.swift in Sources */, 532683A72AE94ADC00A364C0 /* KNObject.swift in Sources */, 532683A12AE948FF00A364C0 /* AppManager.swift in Sources */, @@ -997,6 +1051,7 @@ 532683792AE923A500A364C0 /* FieldTableViewCell.swift in Sources */, 5326838B2AE92CA500A364C0 /* JSONField.swift in Sources */, 532683BF2AEA50EF00A364C0 /* LoginDataProvider.swift in Sources */, + 53EBC60B2AF1A5C200601AA7 /* SettingsSegmentTableViewCell.swift in Sources */, 5300802E2AF149D400A05E04 /* SettingsViewController.swift in Sources */, 53F10AEE2AF06785004D0529 /* UITextField.swift in Sources */, 532683892AE92B6800A364C0 /* Observable.swift in Sources */, @@ -1004,6 +1059,7 @@ 53F10AE22AF05C57004D0529 /* KNNavigationController.swift in Sources */, 532683BD2AEA50C600A364C0 /* LoginModelController.swift in Sources */, 5326837B2AE923A500A364C0 /* KNFieldType.swift in Sources */, + 53EBC6012AF1A1DB00601AA7 /* DefaultsModel.swift in Sources */, 532683B12AE94C9400A364C0 /* Dictionary.swift in Sources */, 5E716A291F63A45A00A2DBC3 /* RequestManager.swift in Sources */, 532683C32AEA537F00A364C0 /* UITableView.swift in Sources */, diff --git a/TraccarClient.xcodeproj/project.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate b/TraccarClient.xcodeproj/project.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate index 9a0325a4f13560960b785151b6ec2f8aadb4d29d..c6bc58bbd229e30140ad471222a14cdc49a5d103 100644 Binary files a/TraccarClient.xcodeproj/project.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate and b/TraccarClient.xcodeproj/project.xcworkspace/xcuserdata/g.makhoul.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/TraccarClient/.DS_Store b/TraccarClient/.DS_Store index 135acbc6c8039c0b8e0c571828429ae70828cb24..82c956209b9b8bcbcaaf3b693b8ba7e8316d06ee 100644 Binary files a/TraccarClient/.DS_Store and b/TraccarClient/.DS_Store differ diff --git a/TraccarClient/AppDelegate.swift b/TraccarClient/AppDelegate.swift index f79098350a4470a0f99175dc712f85c06609f921..af26439fcba58b7889408db9a1405e5556e05579 100644 --- a/TraccarClient/AppDelegate.swift +++ b/TraccarClient/AppDelegate.swift @@ -66,18 +66,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, PositionProviderDelegate managedObjectContext = NSManagedObjectContext.init(concurrencyType: .mainQueueConcurrencyType) managedObjectContext?.persistentStoreCoordinator = persistentStoreCoordinator - // - // if userDefaults.bool(forKey: "service_status_preference") { - // StatusViewController.addMessage(NSLocalizedString("Service created", comment: "")) - // trackingController = TrackingController() - // trackingController?.start() - // } - - // } initialViewController() - return true } diff --git a/TraccarClient/MainViewController/ConnectViewController.swift b/TraccarClient/MainViewController/ConnectViewController.swift index 54edd3a180a2a3a66bca319666d292bb3c1b475c..d352d659af3100d36399a436f5e24c5c09f6e8df 100644 --- a/TraccarClient/MainViewController/ConnectViewController.swift +++ b/TraccarClient/MainViewController/ConnectViewController.swift @@ -7,7 +7,7 @@ // import UIKit -import InAppSettingsKit +//import InAppSettingsKit final class ConnectViewController: KNViewController { // MARK: - Outlets diff --git a/TraccarClient/SettingsViewController/Cells/SettingsSegmentTableViewCell/SettingsSegmentTableViewCell.swift b/TraccarClient/SettingsViewController/Cells/SettingsSegmentTableViewCell/SettingsSegmentTableViewCell.swift new file mode 100644 index 0000000000000000000000000000000000000000..fca552174c45849af85be96a74c9c78a104b0c1d --- /dev/null +++ b/TraccarClient/SettingsViewController/Cells/SettingsSegmentTableViewCell/SettingsSegmentTableViewCell.swift @@ -0,0 +1,46 @@ +// +// SettingsSegmentTableViewCell.swift +// TraccarClient +// +// Created by George Makhoul on 01/11/2023. +// Copyright © 2023 Traccar. All rights reserved. +// + +import UIKit + +class SettingsSegmentTableViewCell: KNTableViewCell { + // MARK: - Outlets + @IBOutlet weak var segments: UISegmentedControl! + @IBOutlet weak var titleLabel: UILabel! + + // MARK: - Properties + let defaults = UserDefaults.standard + + // MARK: - LifeCycle + override func awakeFromNib() { + super.awakeFromNib() + setupUI() + } + + private func setupUI() { + titleLabel.set(text: "", color: .main, font: .semibold(16)) + let selectedAttributes: [NSAttributedString.Key: Any] = [ + .foregroundColor: UIColor.white + ] + segments.setTitleTextAttributes(selectedAttributes, for: .selected) + } + + func set(defaultValue: DefaultsModel) { + titleLabel.set(text: defaultValue.title) + let selected = defaults.string(forKey: defaultValue.value) + if selected == "high" { + segments.selectedSegmentIndex = 2 + + } else if selected == "medium" { + segments.selectedSegmentIndex = 1 + + } else { + segments.selectedSegmentIndex = 0 + } + } +} diff --git a/TraccarClient/SettingsViewController/Cells/SettingsSegmentTableViewCell/SettingsSegmentTableViewCell.xib b/TraccarClient/SettingsViewController/Cells/SettingsSegmentTableViewCell/SettingsSegmentTableViewCell.xib new file mode 100644 index 0000000000000000000000000000000000000000..e04c03f2bfa7489c154fde3d379180173ca6ff9c --- /dev/null +++ b/TraccarClient/SettingsViewController/Cells/SettingsSegmentTableViewCell/SettingsSegmentTableViewCell.xib @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> + <device id="retina6_12" orientation="portrait" appearance="light"/> + <dependencies> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/> + <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <objects> + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> + <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="71" id="KGk-i7-Jjw" customClass="SettingsSegmentTableViewCell" customModule="TraccarClient" customModuleProvider="target"> + <rect key="frame" x="0.0" y="0.0" width="420" height="71"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> + <rect key="frame" x="0.0" y="0.0" width="420" height="71"/> + <autoresizingMask key="autoresizingMask"/> + <subviews> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vpd-o1-C8h"> + <rect key="frame" x="16" y="25" width="42" height="21"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <nil key="textColor"/> + <nil key="highlightedColor"/> + </label> + <segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="l4F-di-BbK"> + <rect key="frame" x="198" y="20" width="206" height="32"/> + <segments> + <segment title="Low"/> + <segment title="Medium"/> + <segment title="High"/> + </segments> + <color key="selectedSegmentTintColor" red="0.38431372549999998" green="0.21960784310000001" blue="0.62352941179999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + </segmentedControl> + </subviews> + <constraints> + <constraint firstAttribute="trailing" secondItem="l4F-di-BbK" secondAttribute="trailing" constant="16" id="Psw-cA-syd"/> + <constraint firstItem="vpd-o1-C8h" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="SFA-fK-sPc"/> + <constraint firstItem="l4F-di-BbK" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="Sxa-4p-MjX"/> + <constraint firstItem="vpd-o1-C8h" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="fak-0Z-DbV"/> + </constraints> + </tableViewCellContentView> + <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> + <connections> + <outlet property="segments" destination="l4F-di-BbK" id="HqC-RK-JAR"/> + <outlet property="titleLabel" destination="vpd-o1-C8h" id="e2M-PY-4Ug"/> + </connections> + <point key="canvasLocation" x="215.26717557251908" y="29.225352112676056"/> + </tableViewCell> + </objects> +</document> diff --git a/TraccarClient/SettingsViewController/Cells/SettingsSwitchTableViewCell/SettingsSwitchTableViewCell.swift b/TraccarClient/SettingsViewController/Cells/SettingsSwitchTableViewCell/SettingsSwitchTableViewCell.swift new file mode 100644 index 0000000000000000000000000000000000000000..ea20f09c4c734be1d92d1dfe6e9a8efac1dfc52a --- /dev/null +++ b/TraccarClient/SettingsViewController/Cells/SettingsSwitchTableViewCell/SettingsSwitchTableViewCell.swift @@ -0,0 +1,33 @@ +// +// SettingsSwitchTableViewCell.swift +// TraccarClient +// +// Created by George Makhoul on 01/11/2023. +// Copyright © 2023 Traccar. All rights reserved. +// + +import UIKit + +class SettingsSwitchTableViewCell: KNTableViewCell { + // MARK: - Outlets + @IBOutlet private weak var titleLabel: UILabel! + @IBOutlet private weak var switchView: UISwitch! + + // MARK: - Properties + let defaults = UserDefaults.standard + + // MARK: - LifeCycle + override func awakeFromNib() { + super.awakeFromNib() + setupUI() + } + + private func setupUI() { + titleLabel.set(text: "", color: .main, font: .semibold(16)) + } + + func set(defaultValue: DefaultsModel) { + titleLabel.set(text: defaultValue.title) + switchView.isOn = defaults.bool(forKey: defaultValue.value) + } +} diff --git a/TraccarClient/SettingsViewController/Cells/SettingsSwitchTableViewCell/SettingsSwitchTableViewCell.xib b/TraccarClient/SettingsViewController/Cells/SettingsSwitchTableViewCell/SettingsSwitchTableViewCell.xib new file mode 100644 index 0000000000000000000000000000000000000000..cb14315f1cefd51b187244bb79b745a661bff3e0 --- /dev/null +++ b/TraccarClient/SettingsViewController/Cells/SettingsSwitchTableViewCell/SettingsSwitchTableViewCell.xib @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> + <device id="retina6_12" orientation="portrait" appearance="light"/> + <dependencies> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/> + <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <objects> + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> + <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="53" id="KGk-i7-Jjw" customClass="SettingsSwitchTableViewCell" customModule="TraccarClient" customModuleProvider="target"> + <rect key="frame" x="0.0" y="0.0" width="320" height="53"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> + <rect key="frame" x="0.0" y="0.0" width="320" height="53"/> + <autoresizingMask key="autoresizingMask"/> + <subviews> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XrY-mn-MKb"> + <rect key="frame" x="16" y="16" width="42" height="21"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <nil key="textColor"/> + <nil key="highlightedColor"/> + </label> + <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="oUi-My-KAn"> + <rect key="frame" x="255" y="11" width="51" height="31"/> + <color key="onTintColor" red="0.38431372549999998" green="0.21960784310000001" blue="0.62352941179999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + </switch> + </subviews> + <constraints> + <constraint firstItem="XrY-mn-MKb" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="5QD-5z-iin"/> + <constraint firstItem="XrY-mn-MKb" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="BQV-lh-phJ"/> + <constraint firstAttribute="trailing" secondItem="oUi-My-KAn" secondAttribute="trailing" constant="16" id="Ewj-Re-zhD"/> + <constraint firstItem="oUi-My-KAn" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="vvl-XO-zi7"/> + </constraints> + </tableViewCellContentView> + <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> + <connections> + <outlet property="switchView" destination="oUi-My-KAn" id="Pgh-Kh-O5l"/> + <outlet property="titleLabel" destination="XrY-mn-MKb" id="Gsx-4q-WOw"/> + </connections> + <point key="canvasLocation" x="138.93129770992365" y="22.887323943661972"/> + </tableViewCell> + </objects> +</document> diff --git a/TraccarClient/SettingsViewController/Cells/SettingsTextTableViewCell/SettingsTextTableViewCell.swift b/TraccarClient/SettingsViewController/Cells/SettingsTextTableViewCell/SettingsTextTableViewCell.swift new file mode 100644 index 0000000000000000000000000000000000000000..af6fe31aebaf68866891f88b472d04b5c4ec4ba7 --- /dev/null +++ b/TraccarClient/SettingsViewController/Cells/SettingsTextTableViewCell/SettingsTextTableViewCell.swift @@ -0,0 +1,39 @@ +// +// SettingsTextTableViewCell.swift +// TraccarClient +// +// Created by George Makhoul on 31/10/2023. +// Copyright © 2023 Traccar. All rights reserved. +// + +import UIKit + +class SettingsTextTableViewCell: KNTableViewCell { + // MARK: - Outlets + @IBOutlet private weak var titleLabel: UILabel! + @IBOutlet private weak var valueField: UITextField! + + // MARK: - Properties + let defaults = UserDefaults.standard + + // MARK: - LifeCycle + override func awakeFromNib() { + super.awakeFromNib() + setupUI() + } + + private func setupUI() { + titleLabel.set(text: "", color: .main, font: .semibold(16)) + valueField.textAlignment = .center + valueField.textColor = .black + valueField.font = .semibold(16) + } + + func set(defaultValue: DefaultsModel) { + + titleLabel.set(text: defaultValue.title) + + valueField.text = defaults.string(forKey: defaultValue.value) + valueField.keyboardType = defaultValue.keyboardType + } +} diff --git a/TraccarClient/SettingsViewController/Cells/SettingsTextTableViewCell/SettingsTextTableViewCell.xib b/TraccarClient/SettingsViewController/Cells/SettingsTextTableViewCell/SettingsTextTableViewCell.xib new file mode 100644 index 0000000000000000000000000000000000000000..c86d7763611d48c03cc2ab564050b2b6b08a62ce --- /dev/null +++ b/TraccarClient/SettingsViewController/Cells/SettingsTextTableViewCell/SettingsTextTableViewCell.xib @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> + <device id="retina6_12" orientation="portrait" appearance="light"/> + <dependencies> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/> + <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <objects> + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> + <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="58" id="KGk-i7-Jjw" customClass="SettingsTextTableViewCell" customModule="TraccarClient" customModuleProvider="target"> + <rect key="frame" x="0.0" y="0.0" width="320" height="58"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> + <rect key="frame" x="0.0" y="0.0" width="320" height="58"/> + <autoresizingMask key="autoresizingMask"/> + <subviews> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DnJ-PY-l78"> + <rect key="frame" x="16" y="19" width="36" height="20.333333333333329"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <nil key="textColor"/> + <nil key="highlightedColor"/> + </label> + <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="qqj-8U-yI6"> + <rect key="frame" x="64" y="12" width="244" height="34"/> + <fontDescription key="fontDescription" type="system" pointSize="14"/> + <textInputTraits key="textInputTraits"/> + </textField> + </subviews> + <constraints> + <constraint firstAttribute="trailing" secondItem="qqj-8U-yI6" secondAttribute="trailing" constant="12" id="1gN-Jc-sKE"/> + <constraint firstItem="DnJ-PY-l78" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="4zA-tP-PPD"/> + <constraint firstItem="qqj-8U-yI6" firstAttribute="leading" secondItem="DnJ-PY-l78" secondAttribute="trailing" constant="12" id="PPd-DE-WVJ"/> + <constraint firstAttribute="bottom" secondItem="qqj-8U-yI6" secondAttribute="bottom" constant="12" id="Ubl-Nq-wzE"/> + <constraint firstItem="DnJ-PY-l78" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="V3G-3m-OjL"/> + <constraint firstItem="qqj-8U-yI6" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="12" id="ufb-uV-mZD"/> + </constraints> + </tableViewCellContentView> + <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> + <connections> + <outlet property="titleLabel" destination="DnJ-PY-l78" id="p1R-tB-eUN"/> + <outlet property="valueField" destination="qqj-8U-yI6" id="9DE-dK-p0D"/> + </connections> + <point key="canvasLocation" x="138.93129770992365" y="24.647887323943664"/> + </tableViewCell> + </objects> +</document> diff --git a/TraccarClient/SettingsViewController/DefaultsModel.swift b/TraccarClient/SettingsViewController/DefaultsModel.swift new file mode 100644 index 0000000000000000000000000000000000000000..7fafc6aa6b7f3bf8ae0dfd41c1279edeb40a1057 --- /dev/null +++ b/TraccarClient/SettingsViewController/DefaultsModel.swift @@ -0,0 +1,23 @@ +// +// DefaultsModel.swift +// TraccarClient +// +// Created by George Makhoul on 31/10/2023. +// Copyright © 2023 Traccar. All rights reserved. +// + +import Foundation +import UIKit + +struct DefaultsModel { + var title: String = "" + var value: String = "" + var keyboardType: UIKeyboardType = .default + + init(title: String, value: String, keyboardType: UIKeyboardType) { + self.title = title + self.value = value + self.keyboardType = keyboardType + + } +} diff --git a/TraccarClient/SettingsViewController/SettingsViewController.swift b/TraccarClient/SettingsViewController/SettingsViewController.swift index f0127c16e8a65dbb4845e1ec6bfc01793493da6e..89b75e06622d9015c486572322c504379c9cc4fe 100644 --- a/TraccarClient/SettingsViewController/SettingsViewController.swift +++ b/TraccarClient/SettingsViewController/SettingsViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import InAppSettingsKit final class SettingsViewController: KNViewController { // MARK: - Outlets @@ -14,17 +15,28 @@ final class SettingsViewController: KNViewController { @IBOutlet weak var tableView: UITableView! // MARK: - Properties + private var textDefaults: [DefaultsModel] = [DefaultsModel(title: "Frequency", value: "frequency_preference", keyboardType: .numberPad), + DefaultsModel(title: "Distance", value: "distance_preference", keyboardType: .numberPad), + DefaultsModel(title: "Angle", value: "angle_preference", keyboardType: .numberPad)] + private var switchDefaults: [DefaultsModel] = [DefaultsModel(title: "Offline buffering", value: "buffer_preference", keyboardType: .default)] + private var multiChoicesDefaults: [DefaultsModel] = [DefaultsModel(title: "Accuracy", value: "accuracy_preference", keyboardType: .default)] // MARK: - LifeCycle override func viewDidLoad() { super.viewDidLoad() - customHeaderView.set(type: .settings, delegate: self) - + setupUI() } private func setupUI() { + customHeaderView.set(type: .settings, delegate: self) + tableView.delegate = self tableView.dataSource = self + + tableView.register(cells: [SettingsTextTableViewCell.self, + SettingsSwitchTableViewCell.self, + SettingsSegmentTableViewCell.self]) + tableView.allowsSelection = false tableView.separatorStyle = .none } @@ -41,14 +53,44 @@ extension SettingsViewController: CustomHeaderViewDelegate { // MARK: - UITableViewDelegate extension SettingsViewController: UITableViewDelegate, UITableViewDataSource { + + func numberOfSections(in tableView: UITableView) -> Int { + 3 + } + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - 7 + switch section { + case 0: + return textDefaults.count + case 1: + return multiChoicesDefaults.count + case 2: + return switchDefaults.count + default: + return 0 + } } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - <#code#> + if indexPath.section == 0 { + let cell = tableView.dequeue(withCell: SettingsTextTableViewCell.self) + cell.set(defaultValue: textDefaults[indexPath.row]) + return cell + } + if indexPath.section == 1 { + let cell = tableView.dequeue(withCell: SettingsSegmentTableViewCell.self) + cell.set(defaultValue: multiChoicesDefaults[indexPath.row]) + return cell + } + if indexPath.section == 2 { + let cell = tableView.dequeue(withCell: SettingsSwitchTableViewCell.self) + cell.set(defaultValue: switchDefaults[indexPath.row]) + return cell + } + return UITableViewCell() } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { - 40 + 70 } } diff --git a/TraccarClient/StatusViewController.swift b/TraccarClient/StatusViewController.swift deleted file mode 100644 index 95cdd8972728d092d74f6a7648eb53df39ffd109..0000000000000000000000000000000000000000 --- a/TraccarClient/StatusViewController.swift +++ /dev/null @@ -1,81 +0,0 @@ -// -// Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import UIKit - -class StatusViewController: UITableViewController { - - static let LIMIT = 20 - static var statusViewController: StatusViewController? - - static var messages = [String]() - - class func addMessage(_ message: String) { - let formatter = DateFormatter() - formatter.dateFormat = "HH:mm - " - - messages.append(formatter.string(from: Date()) + (message)) - - if messages.count > LIMIT { - messages.remove(at: 0) - } - - statusViewController?.tableView.reloadData() - } - - class func clearMessages() { - messages.removeAll() - - statusViewController?.tableView.reloadData() - } - - @IBAction func clear(_ sender: UIBarButtonItem) { - StatusViewController.clearMessages() - } - - override func viewDidLoad() { - tableView.tableFooterView = UIView() - } - - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - StatusViewController.statusViewController = self - } - - override func viewWillDisappear(_ animated: Bool) { - super.viewWillDisappear(animated) - StatusViewController.statusViewController = nil - } - - override func numberOfSections(in tableView: UITableView) -> Int { - return 1 - } - - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return StatusViewController.messages.count - } - - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cellIdentifier: String = "status" - var cell: UITableViewCell? = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) - if cell == nil { - cell = UITableViewCell(style: .default, reuseIdentifier: cellIdentifier) - } - cell?.textLabel?.text = StatusViewController.messages[indexPath.row] - return cell! - } - -}