From 1d377b8faad130490092fece813c83e9f7f2d5f3 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Sun, 8 Jan 2023 16:22:07 +0300 Subject: [PATCH] Adding number with puller instead of old textfield --- AutoCat.xcodeproj/project.pbxproj | 73 +++++++++++++- .../xcshareddata/swiftpm/Package.resolved | 9 ++ .../xcdebugger/Breakpoints_v2.xcbkptlist | 95 +----------------- AutoCat/ACUIKit/Extensions/UIControl.swift | 35 +++++++ AutoCat/ACUIKit/Extensions/UIEdgeInsets.swift | 15 +++ .../ACUIKit/Extensions/UIView+layout.swift | 13 +++ AutoCat/ACUIKit/Views/ACButton.swift | 80 +++++++++++++++ AutoCat/Base.lproj/Main.storyboard | 97 ++++++++----------- AutoCat/Cells/VehicleCell.swift | 2 + AutoCat/Controllers/CheckController.swift | 73 ++++++-------- AutoCat/Controllers/DummyNewController.swift | 6 ++ AutoCat/Controllers/MainTabController.swift | 55 +++++++++++ AutoCat/Controllers/NewNumberController.swift | 83 ++++++++++++++++ AutoCat/Controllers/ReportController.swift | 14 +-- AutoCat/Controllers/SearchController.swift | 1 + AutoCat/Utils/RxRealmDataSource.swift | 14 ++- AutoCat/Utils/RxSectionedDataSource.swift | 6 +- AutoCat/Views/PNKeyboard.swift | 13 ++- AutoCat/Views/PlateView.swift | 81 +++++++++++++--- AutoCat/ru.lproj/Localizable.strings | 3 + AutoCat/ru.lproj/Main.strings | 11 +-- AutoCatCore/Models/DateSection.swift | 20 ++-- AutoCatCore/Models/PlateNumber.swift | 63 ++++++++++-- AutoCatCore/Models/Vehicle.swift | 14 ++- 24 files changed, 624 insertions(+), 252 deletions(-) create mode 100644 AutoCat/ACUIKit/Extensions/UIControl.swift create mode 100644 AutoCat/ACUIKit/Extensions/UIEdgeInsets.swift create mode 100644 AutoCat/ACUIKit/Extensions/UIView+layout.swift create mode 100644 AutoCat/ACUIKit/Views/ACButton.swift create mode 100644 AutoCat/Controllers/DummyNewController.swift create mode 100644 AutoCat/Controllers/MainTabController.swift create mode 100644 AutoCat/Controllers/NewNumberController.swift diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index 0f1d185..4d2fa39 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -84,6 +84,14 @@ 7AABDE26253350C30041AFC6 /* RxSectionedDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AABDE25253350C30041AFC6 /* RxSectionedDataSource.swift */; }; 7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8B2435C38700258F61 /* CustomTextField.swift */; }; 7AB67E8E2435D1A000258F61 /* CustomButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AB67E8D2435D1A000258F61 /* CustomButton.swift */; }; + 7AC3554A2969652F00889457 /* SwiftEntryKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7AC355492969652F00889457 /* SwiftEntryKit */; }; + 7AC3554C29696A1C00889457 /* MainTabController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC3554B29696A1C00889457 /* MainTabController.swift */; }; + 7AC3554E29696C4500889457 /* DummyNewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC3554D29696C4500889457 /* DummyNewController.swift */; }; + 7AC3555029696D5A00889457 /* NewNumberController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC3554F29696D5A00889457 /* NewNumberController.swift */; }; + 7AC3555229696E3F00889457 /* UIView+layout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC3555129696E3F00889457 /* UIView+layout.swift */; }; + 7AC35554296973E100889457 /* ACButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC35553296973E100889457 /* ACButton.swift */; }; + 7AC355592969746600889457 /* UIControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC355582969746600889457 /* UIControl.swift */; }; + 7AC3555B296995B200889457 /* UIEdgeInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC3555A296995B200889457 /* UIEdgeInsets.swift */; }; 7AC76D7B270083AE0084DB27 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AC76D7A270083AE0084DB27 /* TextView.swift */; }; 7ADF6C93250B954900F237B2 /* Navigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADF6C92250B954900F237B2 /* Navigation.swift */; }; 7ADF6C95250D037700F237B2 /* ShowEventController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADF6C94250D037700F237B2 /* ShowEventController.swift */; }; @@ -251,6 +259,13 @@ 7AB562B9249C9E9B00473D53 /* VehicleRegion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehicleRegion.swift; sourceTree = ""; }; 7AB67E8B2435C38700258F61 /* CustomTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTextField.swift; sourceTree = ""; }; 7AB67E8D2435D1A000258F61 /* CustomButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomButton.swift; sourceTree = ""; }; + 7AC3554B29696A1C00889457 /* MainTabController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainTabController.swift; sourceTree = ""; }; + 7AC3554D29696C4500889457 /* DummyNewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DummyNewController.swift; sourceTree = ""; }; + 7AC3554F29696D5A00889457 /* NewNumberController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewNumberController.swift; sourceTree = ""; }; + 7AC3555129696E3F00889457 /* UIView+layout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+layout.swift"; sourceTree = ""; }; + 7AC35553296973E100889457 /* ACButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ACButton.swift; sourceTree = ""; }; + 7AC355582969746600889457 /* UIControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIControl.swift; sourceTree = ""; }; + 7AC3555A296995B200889457 /* UIEdgeInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIEdgeInsets.swift; sourceTree = ""; }; 7AC76D7A270083AE0084DB27 /* TextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextView.swift; sourceTree = ""; }; 7ADF6C92250B954900F237B2 /* Navigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Navigation.swift; sourceTree = ""; }; 7ADF6C94250D037700F237B2 /* ShowEventController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShowEventController.swift; sourceTree = ""; }; @@ -285,6 +300,7 @@ 7AA7BC3325A5DFB80053A5D5 /* Kingfisher in Frameworks */, 7A813DBE2506A57100CC93B9 /* AuthenticationServices.framework in Frameworks */, 7AA7BC3625A5DFB80053A5D5 /* PKHUD in Frameworks */, + 7AC3554A2969652F00889457 /* SwiftEntryKit in Frameworks */, 7AF6D2042677C03B0086EA64 /* AutoCatCore.framework in Frameworks */, 7A35177B27E23F8800DC538C /* Eureka in Frameworks */, 7A96AE2F246B2BCD00297C33 /* WebKit.framework in Frameworks */, @@ -368,6 +384,7 @@ 7A1146FF23FDE7E500B424AF /* AutoCat */ = { isa = PBXGroup; children = ( + 7AC355552969742800889457 /* ACUIKit */, 7A530B7C24017FBE00CBFE6E /* Cells */, 7A11471423FDEAF800B424AF /* Controllers */, 7A3F07A924360D9100E59687 /* Extensions */, @@ -408,6 +425,9 @@ 7A3F07AC2436350B00E59687 /* SearchController.swift */, 7AEFE727240455E200910EB7 /* SettingsController.swift */, 7A6F095D26DB9F85003A965D /* NotesController.swift */, + 7AC3554B29696A1C00889457 /* MainTabController.swift */, + 7AC3554D29696C4500889457 /* DummyNewController.swift */, + 7AC3554F29696D5A00889457 /* NewNumberController.swift */, ); path = Controllers; sourceTree = ""; @@ -558,6 +578,33 @@ path = Location; sourceTree = ""; }; + 7AC355552969742800889457 /* ACUIKit */ = { + isa = PBXGroup; + children = ( + 7AC355562969743800889457 /* Views */, + 7AC355572969744100889457 /* Extensions */, + ); + path = ACUIKit; + sourceTree = ""; + }; + 7AC355562969743800889457 /* Views */ = { + isa = PBXGroup; + children = ( + 7AC35553296973E100889457 /* ACButton.swift */, + ); + path = Views; + sourceTree = ""; + }; + 7AC355572969744100889457 /* Extensions */ = { + isa = PBXGroup; + children = ( + 7AC3555129696E3F00889457 /* UIView+layout.swift */, + 7AC355582969746600889457 /* UIControl.swift */, + 7AC3555A296995B200889457 /* UIEdgeInsets.swift */, + ); + path = Extensions; + sourceTree = ""; + }; 7AF6D1DE2677A7E00086EA64 /* AutoCatTests */ = { isa = PBXGroup; children = ( @@ -642,6 +689,7 @@ 7A813DC02508C4D900CC93B9 /* ExceptionCatcher */, 7AABDE1C2532F3EB0041AFC6 /* PKHUD */, 7A35177A27E23F8800DC538C /* Eureka */, + 7AC355492969652F00889457 /* SwiftEntryKit */, ); productName = AutoCat; productReference = 7A1146FD23FDE7E500B424AF /* AutoCat.app */; @@ -734,6 +782,7 @@ 7AABDE1B2532F3EB0041AFC6 /* XCRemoteSwiftPackageReference "PKHUD" */, 7AABDE21253327F10041AFC6 /* XCRemoteSwiftPackageReference "DifferenceKit" */, 7A35177927E23F8800DC538C /* XCRemoteSwiftPackageReference "Eureka" */, + 7AC355482969652F00889457 /* XCRemoteSwiftPackageReference "SwiftEntryKit" */, ); productRefGroup = 7A1146FE23FDE7E500B424AF /* Products */; projectDirPath = ""; @@ -792,12 +841,14 @@ 7A6DD90824329144009DE740 /* CenterTextLayer.swift in Sources */, 7A99406426E4BFAE002E9CB6 /* VehicleNoteCell.swift in Sources */, 7A8AB76B25A1D95500ECF2C1 /* SourceStatusRow.swift in Sources */, + 7AC3554C29696A1C00889457 /* MainTabController.swift in Sources */, 7A813DC32508EE4F00CC93B9 /* EventCell.swift in Sources */, 7A3F07AD2436350B00E59687 /* SearchController.swift in Sources */, 7AABDE26253350C30041AFC6 /* RxSectionedDataSource.swift in Sources */, 7A0B96A0257D6D4B000B39AD /* MultilineLabelRow.swift in Sources */, 7A6DD90C24335A6D009DE740 /* FlagLayer.swift in Sources */, 7A761C0B267E8FF90005F28F /* Error.swift in Sources */, + 7AC3555029696D5A00889457 /* NewNumberController.swift in Sources */, 7AE26A3524F31B0700625033 /* EventsController.swift in Sources */, 7A2DE69E2589606A00A113FC /* ImageGridRow.swift in Sources */, 7AB67E8C2435C38700258F61 /* CustomTextField.swift in Sources */, @@ -808,6 +859,7 @@ 7A27ADF3249F8B650035F39E /* RecordsController.swift in Sources */, 7A8A2209248D10EC0073DFD9 /* ResizeImage.swift in Sources */, 7ADF6CA12512244400F237B2 /* MapExt.swift in Sources */, + 7AC3554E29696C4500889457 /* DummyNewController.swift in Sources */, 7A659B5B24A3768A0043A0F2 /* Substrings.swift in Sources */, 7AEFE728240455E200910EB7 /* SettingsController.swift in Sources */, 7A27ADF7249FEF690035F39E /* Recorder.swift in Sources */, @@ -836,10 +888,14 @@ 7A813DCB250B5DC900CC93B9 /* LocationPickerController.swift in Sources */, 7A9FEEC82529AB23001CA50E /* RxRealmDataSource.swift in Sources */, 7A8AB76525A0DB8F00ECF2C1 /* BundleVersion.swift in Sources */, + 7AC3555229696E3F00889457 /* UIView+layout.swift in Sources */, 7A0420AD2561A0B100034941 /* OsagoController.swift in Sources */, + 7AC355592969746600889457 /* UIControl.swift in Sources */, 7AB67E8E2435D1A000258F61 /* CustomButton.swift in Sources */, 7A21112A24FC3D7E003BBF6F /* AudioEngine.swift in Sources */, + 7AC35554296973E100889457 /* ACButton.swift in Sources */, 7A8A220B248D67B60073DFD9 /* VehicleReportImage.swift in Sources */, + 7AC3555B296995B200889457 /* UIEdgeInsets.swift in Sources */, 7ADF6C95250D037700F237B2 /* ShowEventController.swift in Sources */, 7A27ADC7249D43210035F39E /* RegionsController.swift in Sources */, 7AE492A1259232F000322D2E /* MultilineLinkRow.swift in Sources */, @@ -1080,7 +1136,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 100; + CURRENT_PROJECT_VERSION = 101; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -1105,7 +1161,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 100; + CURRENT_PROJECT_VERSION = 101; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -1329,6 +1385,14 @@ minimumVersion = 1.1.5; }; }; + 7AC355482969652F00889457 /* XCRemoteSwiftPackageReference "SwiftEntryKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/huri000/SwiftEntryKit"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.0.0; + }; + }; 7AF58D322402A91C00CE01A0 /* XCRemoteSwiftPackageReference "Kingfisher" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/onevcat/Kingfisher"; @@ -1380,6 +1444,11 @@ package = 7AABDE1B2532F3EB0041AFC6 /* XCRemoteSwiftPackageReference "PKHUD" */; productName = PKHUD; }; + 7AC355492969652F00889457 /* SwiftEntryKit */ = { + isa = XCSwiftPackageProductDependency; + package = 7AC355482969652F00889457 /* XCRemoteSwiftPackageReference "SwiftEntryKit" */; + productName = SwiftEntryKit; + }; 7AF58D332402A91C00CE01A0 /* Kingfisher */ = { isa = XCSwiftPackageProductDependency; package = 7AF58D322402A91C00CE01A0 /* XCRemoteSwiftPackageReference "Kingfisher" */; diff --git a/AutoCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AutoCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 1bdda73..8bd90e4 100644 --- a/AutoCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AutoCat.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -89,6 +89,15 @@ "revision" : "6190d0cefff3013e77ed567e6b074f324e5c5bf5", "version" : "6.3.1" } + }, + { + "identity" : "swiftentrykit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/huri000/SwiftEntryKit", + "state" : { + "revision" : "5ad36cccf0c4b9fea32f4e9b17a8e38f07563ef0", + "version" : "2.0.0" + } } ], "version" : 2 diff --git a/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 705989c..1359d48 100644 --- a/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -4,38 +4,18 @@ type = "1" version = "2.0"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/AutoCat/ACUIKit/Extensions/UIControl.swift b/AutoCat/ACUIKit/Extensions/UIControl.swift new file mode 100644 index 0000000..5af9cb3 --- /dev/null +++ b/AutoCat/ACUIKit/Extensions/UIControl.swift @@ -0,0 +1,35 @@ +import UIKit + +extension UIControl { + + func addAction(for controlEvent: UIControl.Event = .touchUpInside, _ closure: @escaping () -> Void) { + + addActionImpl(for: controlEvent, closure: closure) + } + + func addActionAsync(for controlEvent: UIControl.Event = .touchUpInside, _ closure: @escaping () async -> Void) { + + addActionImpl(for: controlEvent) { + Task { + await closure() + } + } + } + + func addActionImpl(for controlEvents: UIControl.Event, closure: @escaping () -> Void) { + + if #available(iOS 14.0, *) { + addAction(UIAction { _ in closure() }, for: controlEvents) + } else { + @objc class ClosureSleeve: NSObject { + let closure:()->() + init(_ closure: @escaping()->()) { self.closure = closure } + @objc func invoke() { closure() } + } + let sleeve = ClosureSleeve(closure) + addTarget(sleeve, action: #selector(ClosureSleeve.invoke), for: controlEvents) + objc_setAssociatedObject(self, "\(UUID())", sleeve, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN) + } + } + +} diff --git a/AutoCat/ACUIKit/Extensions/UIEdgeInsets.swift b/AutoCat/ACUIKit/Extensions/UIEdgeInsets.swift new file mode 100644 index 0000000..aa8a553 --- /dev/null +++ b/AutoCat/ACUIKit/Extensions/UIEdgeInsets.swift @@ -0,0 +1,15 @@ +import UIKit + +extension UIEdgeInsets { + + init(all: CGFloat) { + self.init(top: all, left: all, bottom: all, right: all) + } +} + +extension UIEdgeInsets { + + static func all(_ value: CGFloat) -> UIEdgeInsets { + .init(all: value) + } +} diff --git a/AutoCat/ACUIKit/Extensions/UIView+layout.swift b/AutoCat/ACUIKit/Extensions/UIView+layout.swift new file mode 100644 index 0000000..bf59502 --- /dev/null +++ b/AutoCat/ACUIKit/Extensions/UIView+layout.swift @@ -0,0 +1,13 @@ +import UIKit + +extension UIView { + + func pin(to view: UIView, insets: UIEdgeInsets = .zero) { + NSLayoutConstraint.activate([ + leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: insets.left), + trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -insets.right), + topAnchor.constraint(equalTo: view.topAnchor, constant: insets.top), + bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -insets.bottom) + ]) + } +} diff --git a/AutoCat/ACUIKit/Views/ACButton.swift b/AutoCat/ACUIKit/Views/ACButton.swift new file mode 100644 index 0000000..fd07940 --- /dev/null +++ b/AutoCat/ACUIKit/Views/ACButton.swift @@ -0,0 +1,80 @@ +import UIKit + +enum ACButtonStyle { + case generic + case roundedBlue +} + +class ACButton: UIButton { + + private var style: ACButtonStyle = .generic + + convenience init(style: ACButtonStyle = .roundedBlue, title: String, onTap: @escaping () -> Void) { + self.init() + self.style(style) + self.onTap(onTap) + self.title(title) + translatesAutoresizingMaskIntoConstraints = false + } + + convenience init(style: ACButtonStyle = .roundedBlue, title: String, onTapAsync: @escaping () async -> Void) { + self.init() + self.style(style) + self.onTapAsync(onTapAsync) + self.title(title) + translatesAutoresizingMaskIntoConstraints = false + } + + override func layoutSubviews() { + super.layoutSubviews() + + if style == .roundedBlue { + self.layer.opacity = self.isEnabled ? 1 : 0.5 + } else { + self.layer.opacity = 1 + } + } + + @discardableResult + func style(_ style: ACButtonStyle) -> ACButton { + + self.style = style + + switch style { + case .generic: + break + case .roundedBlue: + backgroundColor = .systemBlue + layer.cornerRadius = 6 + } + + return self + } + + @discardableResult + func title(_ title: String) -> ACButton { + + setTitle(title, for: .normal) + return self + } + + @discardableResult + func enable(_ enabled: Bool) -> ACButton { + isEnabled = enabled + return self + } + + @discardableResult + func onTap(_ handler: @escaping () -> Void) -> ACButton { + + addAction(for: .touchUpInside, handler) + return self + } + + @discardableResult + func onTapAsync(_ handler: @escaping () async -> Void) -> ACButton { + + addActionAsync(for: .touchUpInside, handler) + return self + } +} diff --git a/AutoCat/Base.lproj/Main.storyboard b/AutoCat/Base.lproj/Main.storyboard index 847483e..4af2004 100644 --- a/AutoCat/Base.lproj/Main.storyboard +++ b/AutoCat/Base.lproj/Main.storyboard @@ -173,17 +173,17 @@ - + - + - + - + - + @@ -597,50 +597,19 @@ - - - - - - - - - - - - - - - - - - - + - + - + - + @@ -675,18 +644,15 @@ - + - + - - - - +