From f4b5b7d32834925e4f333ea7d10069d663c790e6 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Tue, 10 Jan 2023 23:23:40 +0300 Subject: [PATCH] Fix for puller --- AutoCat.xcodeproj/project.pbxproj | 4 +-- AutoCat/Controllers/MainTabController.swift | 3 ++- AutoCat/Controllers/NotesController.swift | 27 +++++++++++++++++++++ AutoCat/Utils/RxRealmDataSource.swift | 7 +++++- AutoCatCore/Models/Vehicle.swift | 10 +++++--- 5 files changed, 44 insertions(+), 7 deletions(-) diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index 8ea48ab..f8143cd 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -1136,7 +1136,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -1161,7 +1161,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 102; + CURRENT_PROJECT_VERSION = 103; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; diff --git a/AutoCat/Controllers/MainTabController.swift b/AutoCat/Controllers/MainTabController.swift index e308591..bc8787b 100644 --- a/AutoCat/Controllers/MainTabController.swift +++ b/AutoCat/Controllers/MainTabController.swift @@ -34,7 +34,8 @@ class MainTabController: UITabBarController, UITabBarControllerDelegate { attributes.screenBackground = .color(color: EKColor(UIColor(white: 0, alpha: 0.7))) attributes.roundCorners = .top(radius: 24) attributes.screenInteraction = .dismiss - attributes.entryInteraction = .forward + attributes.scroll = .disabled + attributes.entryInteraction = .absorbTouches attributes.entranceAnimation = .init(translate: .init(duration: 0.2)) attributes.exitAnimation = .init(translate: .init(duration: 0.2)) diff --git a/AutoCat/Controllers/NotesController.swift b/AutoCat/Controllers/NotesController.swift index 0a7d43a..4625f5a 100644 --- a/AutoCat/Controllers/NotesController.swift +++ b/AutoCat/Controllers/NotesController.swift @@ -233,6 +233,14 @@ class NotesController: UIViewController, UITableViewDataSource, UITableViewDeleg // MARK: - Utils func showAddNoteAlert(text: String?, completion: @escaping (String) -> Void) { + #if targetEnvironment(macCatalyst) + showAddNoteAlertCatalyst(text: text, completion: completion) + #else + showAddNoteAlertIos(text: text, completion: completion) + #endif + } + + func showAddNoteAlertIos(text: String?, completion: @escaping (String) -> Void) { let alertController = UIAlertController(title: NSLocalizedString("New note", comment: ""), message: nil, preferredStyle: .alert) let cancelAction = UIAlertAction.init(title: NSLocalizedString("Cancel", comment: ""), style: .default) @@ -265,4 +273,23 @@ class NotesController: UIViewController, UITableViewDataSource, UITableViewDeleg @objc func tapDone(sender: Any) { self.textView.endEditing(true) } + + func showAddNoteAlertCatalyst(text: String?, completion: @escaping (String) -> Void) { + let alertController = UIAlertController(title: NSLocalizedString("New note", comment: ""), message: nil, preferredStyle: .alert) + + let cancelAction = UIAlertAction.init(title: NSLocalizedString("Cancel", comment: ""), style: .default) + alertController.addAction(cancelAction) + + let saveAction = UIAlertAction(title: NSLocalizedString("Done", comment: ""), style: .default) { (action) in + let enteredText = alertController.textFields?.first?.text ?? "" + completion(enteredText) + } + alertController.addAction(saveAction) + + alertController.addTextField { textField in + textField.text = text + } + + self.present(alertController, animated: true) + } } diff --git a/AutoCat/Utils/RxRealmDataSource.swift b/AutoCat/Utils/RxRealmDataSource.swift index d7b7a82..f93d895 100644 --- a/AutoCat/Utils/RxRealmDataSource.swift +++ b/AutoCat/Utils/RxRealmDataSource.swift @@ -163,12 +163,17 @@ class RealmSectionedDataSource: NSObject, UITableViewDataSource throw CocoaError.error("Type \(Item.self) is not exportable") } + var items = self.data.toArray().map { $0.clone() } + if let predicate = self.filterPredicate { + items = items.filter(predicate) + } + var result = "" let newLine: Character = "\r\n" //"\u{000B}" result.append(type.csvHeader) result.append(newLine) - for item in self.data { + for item in items { if let exportableItem = item as? Exportable { result.append(exportableItem.csvLine) result.append(newLine) diff --git a/AutoCatCore/Models/Vehicle.swift b/AutoCatCore/Models/Vehicle.swift index b87f569..eb97629 100644 --- a/AutoCatCore/Models/Vehicle.swift +++ b/AutoCatCore/Models/Vehicle.swift @@ -364,7 +364,7 @@ public class Vehicle: Object, Decodable, Identifiable, Differentiable, Cloneable // MARK: - Exportable public static var csvHeader: String { - return "Plate Number, Model, Color, Year, Owners, VIN, STS, PTS, Added Date, Updated date, Locations, Notes" + return "Plate Number, Model, Color, Year, Power (HP), Events, Owners, VIN, STS, PTS, Added Date, Updated date, Locations, Notes" } public var csvLine: String { @@ -383,11 +383,15 @@ public class Vehicle: Object, Decodable, Identifiable, Differentiable, Cloneable partialResult + note.text + "\r\n" } - return String(format: "%@, \"%@\", %@, %d, %d, %@, %@, %@, \"%@\", \"%@\", \"%@\", \"%@\"", - self.number, + let number = self.currentNumber == nil ? self.number : "\(self.number) (\(self.currentNumber ?? ""))" + + return String(format: "%@, \"%@\", %@, %d, %f, %d, %d, %@, %@, %@, \"%@\", \"%@\", \"%@\", \"%@\"", + number, model, self.color ?? "", self.year, + self.engine?.powerHp ?? 0.0, + self.events.count, self.ownershipPeriods.count, self.vin1 ?? "", self.sts ?? "",