Sheet for adding new number
This commit is contained in:
parent
51899baeee
commit
7d1811171e
@ -21,6 +21,8 @@
|
||||
7A0391D6285933EF000EE522 /* AutoCatCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A49F4D727D4064500AEAAE0 /* AutoCatCore.framework */; };
|
||||
7A0391D7285933EF000EE522 /* AutoCatCore.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 7A49F4D727D4064500AEAAE0 /* AutoCatCore.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
7A0391DD28593DBC000EE522 /* SidebarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A0391DC28593DBC000EE522 /* SidebarController.swift */; };
|
||||
7A163BF128BBE9ED0005A0A4 /* VehiclesListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A163BF028BBE9ED0005A0A4 /* VehiclesListView.swift */; };
|
||||
7A163BF328BBEAFC0005A0A4 /* PlateNumberView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A163BF228BBEAFC0005A0A4 /* PlateNumberView.swift */; };
|
||||
7A1D80E027F1F275007BD64F /* DifferenceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7A1D80DF27F1F275007BD64F /* DifferenceKit */; };
|
||||
7A1D80E627F20FCB007BD64F /* DifferenceKit in Frameworks */ = {isa = PBXBuildFile; productRef = 7A1D80E527F20FCB007BD64F /* DifferenceKit */; };
|
||||
7A1D80E827F30399007BD64F /* VModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1D80E727F30399007BD64F /* VModel.swift */; };
|
||||
@ -79,7 +81,7 @@
|
||||
7A49F50D27D406CB00AEAAE0 /* Vehicle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F50627D406CB00AEAAE0 /* Vehicle.swift */; };
|
||||
7A49F50E27D406CB00AEAAE0 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F50727D406CB00AEAAE0 /* User.swift */; };
|
||||
7A49F50F27D406CB00AEAAE0 /* Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F50827D406CB00AEAAE0 /* Response.swift */; };
|
||||
7A49F51027D406CB00AEAAE0 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F50927D406CB00AEAAE0 /* Settings.swift */; };
|
||||
7A49F51027D406CB00AEAAE0 /* MainSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F50927D406CB00AEAAE0 /* MainSettings.swift */; };
|
||||
7A49F51127D406CB00AEAAE0 /* PlateNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F50A27D406CB00AEAAE0 /* PlateNumber.swift */; };
|
||||
7A49F51227D406CB00AEAAE0 /* VName.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F50B27D406CB00AEAAE0 /* VName.swift */; };
|
||||
7A49F51527D40C6100AEAAE0 /* AutoCat2.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 7A49F51327D40C6100AEAAE0 /* AutoCat2.xcdatamodeld */; };
|
||||
@ -98,6 +100,8 @@
|
||||
7AE32D6927F06536004EF6E0 /* CoreDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE32D6827F06536004EF6E0 /* CoreDataSource.swift */; };
|
||||
7AE32D6E27F06D2D004EF6E0 /* SwiftDate in Frameworks */ = {isa = PBXBuildFile; productRef = 7AE32D6D27F06D2D004EF6E0 /* SwiftDate */; };
|
||||
7AE32D7127F06DA4004EF6E0 /* DateSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE32D7027F06DA4004EF6E0 /* DateSection.swift */; };
|
||||
7AF1D0D828BB577E004E19F7 /* CheckNumber.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF1D0D728BB577E004E19F7 /* CheckNumber.swift */; };
|
||||
7AF1D0DA28BB5BF5004E19F7 /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF1D0D928BB5BF5004E19F7 /* View.swift */; };
|
||||
7AFD7AE02871823E00BCCD37 /* SidebarSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AFD7ADF2871823E00BCCD37 /* SidebarSection.swift */; };
|
||||
7AFD7AE22871826D00BCCD37 /* SidebarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AFD7AE12871826D00BCCD37 /* SidebarItem.swift */; };
|
||||
7AFD7AE4287182CD00BCCD37 /* SidebarFilterItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AFD7AE3287182CD00BCCD37 /* SidebarFilterItem.swift */; };
|
||||
@ -217,6 +221,8 @@
|
||||
6841AFB465BF16E122875D9A /* ACButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ACButton.swift; sourceTree = "<group>"; };
|
||||
6841AFE790F6FC06838B1E2C /* UIControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIControl.swift; sourceTree = "<group>"; };
|
||||
7A0391DC28593DBC000EE522 /* SidebarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarController.swift; sourceTree = "<group>"; };
|
||||
7A163BF028BBE9ED0005A0A4 /* VehiclesListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VehiclesListView.swift; sourceTree = "<group>"; };
|
||||
7A163BF228BBEAFC0005A0A4 /* PlateNumberView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlateNumberView.swift; sourceTree = "<group>"; };
|
||||
7A1D80E727F30399007BD64F /* VModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VModel.swift; sourceTree = "<group>"; };
|
||||
7A24C19527EE212E00049E7F /* RoadNumbers.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = RoadNumbers.otf; sourceTree = "<group>"; };
|
||||
7A24C19627EE212E00049E7F /* RoadNumbers2.0.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = RoadNumbers2.0.otf; sourceTree = "<group>"; };
|
||||
@ -269,7 +275,7 @@
|
||||
7A49F50627D406CB00AEAAE0 /* Vehicle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Vehicle.swift; sourceTree = "<group>"; };
|
||||
7A49F50727D406CB00AEAAE0 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
|
||||
7A49F50827D406CB00AEAAE0 /* Response.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Response.swift; sourceTree = "<group>"; };
|
||||
7A49F50927D406CB00AEAAE0 /* Settings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
|
||||
7A49F50927D406CB00AEAAE0 /* MainSettings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainSettings.swift; sourceTree = "<group>"; };
|
||||
7A49F50A27D406CB00AEAAE0 /* PlateNumber.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlateNumber.swift; sourceTree = "<group>"; };
|
||||
7A49F50B27D406CB00AEAAE0 /* VName.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VName.swift; sourceTree = "<group>"; };
|
||||
7A49F51427D40C6100AEAAE0 /* Shared.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Shared.xcdatamodel; sourceTree = "<group>"; };
|
||||
@ -293,6 +299,8 @@
|
||||
7AE32D6527F063A1004EF6E0 /* UIEdgeInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIEdgeInsets.swift; sourceTree = "<group>"; };
|
||||
7AE32D6827F06536004EF6E0 /* CoreDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataSource.swift; sourceTree = "<group>"; };
|
||||
7AE32D7027F06DA4004EF6E0 /* DateSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateSection.swift; sourceTree = "<group>"; };
|
||||
7AF1D0D728BB577E004E19F7 /* CheckNumber.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckNumber.swift; sourceTree = "<group>"; };
|
||||
7AF1D0D928BB5BF5004E19F7 /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = "<group>"; };
|
||||
7AFD7ADF2871823E00BCCD37 /* SidebarSection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarSection.swift; sourceTree = "<group>"; };
|
||||
7AFD7AE12871826D00BCCD37 /* SidebarItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarItem.swift; sourceTree = "<group>"; };
|
||||
7AFD7AE3287182CD00BCCD37 /* SidebarFilterItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarFilterItem.swift; sourceTree = "<group>"; };
|
||||
@ -433,6 +441,14 @@
|
||||
path = Controllers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A163BEF28BBE9DA0005A0A4 /* VehiclesList */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A163BF028BBE9ED0005A0A4 /* VehiclesListView.swift */,
|
||||
);
|
||||
path = VehiclesList;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7A24C19427EE212E00049E7F /* Fonts */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -504,6 +520,8 @@
|
||||
7A4951C3288D3AF000C644B6 /* Screens */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A163BEF28BBE9DA0005A0A4 /* VehiclesList */,
|
||||
7AF1D0D628BB5768004E19F7 /* CheckNumber */,
|
||||
7A4951CE288D5C1300C644B6 /* Main */,
|
||||
7A4951CD288D5C0800C644B6 /* Auth */,
|
||||
);
|
||||
@ -532,6 +550,7 @@
|
||||
children = (
|
||||
7A4951B8288D3A6100C644B6 /* RootView.swift */,
|
||||
7A4951D0288D5C4300C644B6 /* ACProgressView.swift */,
|
||||
7A163BF228BBEAFC0005A0A4 /* PlateNumberView.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
@ -540,6 +559,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7A4951D4288D5ED000C644B6 /* Alert.swift */,
|
||||
7AF1D0D928BB5BF5004E19F7 /* View.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
@ -668,7 +688,7 @@
|
||||
7A49F50627D406CB00AEAAE0 /* Vehicle.swift */,
|
||||
7A49F50727D406CB00AEAAE0 /* User.swift */,
|
||||
7A49F50827D406CB00AEAAE0 /* Response.swift */,
|
||||
7A49F50927D406CB00AEAAE0 /* Settings.swift */,
|
||||
7A49F50927D406CB00AEAAE0 /* MainSettings.swift */,
|
||||
7A49F50A27D406CB00AEAAE0 /* PlateNumber.swift */,
|
||||
7AFD7AE528718BF000BCCD37 /* Filter.swift */,
|
||||
);
|
||||
@ -758,6 +778,14 @@
|
||||
path = DataSource;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7AF1D0D628BB5768004E19F7 /* CheckNumber */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7AF1D0D728BB577E004E19F7 /* CheckNumber.swift */,
|
||||
);
|
||||
path = CheckNumber;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7AFD7ADE2871822000BCCD37 /* Sidebar */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -1088,9 +1116,13 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7A4951D3288D5E2800C644B6 /* AuthVM.swift in Sources */,
|
||||
7A163BF128BBE9ED0005A0A4 /* VehiclesListView.swift in Sources */,
|
||||
7A4951B9288D3A6100C644B6 /* RootView.swift in Sources */,
|
||||
7A4951C7288D3BDD00C644B6 /* MainView.swift in Sources */,
|
||||
7AF1D0D828BB577E004E19F7 /* CheckNumber.swift in Sources */,
|
||||
7A4951B7288D3A6100C644B6 /* AutoCat2SUIApp.swift in Sources */,
|
||||
7AF1D0DA28BB5BF5004E19F7 /* View.swift in Sources */,
|
||||
7A163BF328BBEAFC0005A0A4 /* PlateNumberView.swift in Sources */,
|
||||
7A4951D1288D5C4300C644B6 /* ACProgressView.swift in Sources */,
|
||||
7A4951C5288D3BCF00C644B6 /* AuthView.swift in Sources */,
|
||||
7A4951D5288D5ED000C644B6 /* Alert.swift in Sources */,
|
||||
@ -1167,7 +1199,7 @@
|
||||
7A36E55E27FB5A260025AACB /* LoginMethodMock.swift in Sources */,
|
||||
7A49F50C27D406CB00AEAAE0 /* VBrand.swift in Sources */,
|
||||
7A36E55C27FB55570025AACB /* Testing.swift in Sources */,
|
||||
7A49F51027D406CB00AEAAE0 /* Settings.swift in Sources */,
|
||||
7A49F51027D406CB00AEAAE0 /* MainSettings.swift in Sources */,
|
||||
929EDE9027F8F76300E55F65 /* DebugInfo.swift in Sources */,
|
||||
7A36E55D27FB5A220025AACB /* ApiMethodMock.swift in Sources */,
|
||||
929EDE8927F8E65500E55F65 /* VAd.swift in Sources */,
|
||||
@ -1309,7 +1341,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = pro.aliencat.AutoCat2SUI;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@ -1348,7 +1380,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
||||
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 12.4;
|
||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = pro.aliencat.AutoCat2SUI;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
||||
@ -17,12 +17,12 @@
|
||||
<key>AutoCat2Mac.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</dict>
|
||||
<key>AutoCat2SUI.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>2</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>AutoCat2UITests.testExample.xcscheme</key>
|
||||
<dict>
|
||||
|
||||
@ -76,7 +76,7 @@ class AuthController: UIViewController {
|
||||
|
||||
do {
|
||||
HUD.show(.progress)
|
||||
Settings.shared.user = try await Api.shared.login(email: email, password: password)
|
||||
MainSettings.shared.user = try await Api.shared.login(email: email, password: password)
|
||||
view.window?.rootViewController = MainTabController()
|
||||
HUD.hide()
|
||||
} catch {
|
||||
@ -92,7 +92,7 @@ class AuthController: UIViewController {
|
||||
|
||||
do {
|
||||
HUD.show(.progress)
|
||||
Settings.shared.user = try await Api.shared.signup(email: email, password: password)
|
||||
MainSettings.shared.user = try await Api.shared.signup(email: email, password: password)
|
||||
view.window?.rootViewController = MainTabController()
|
||||
HUD.hide()
|
||||
} catch {
|
||||
|
||||
@ -21,7 +21,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
|
||||
self.window = UIWindow(windowScene: scene)
|
||||
|
||||
if Settings.shared.user.token.isEmpty {
|
||||
if MainSettings.shared.user.token.isEmpty {
|
||||
self.window?.rootViewController = AuthController()
|
||||
} else {
|
||||
self.window?.rootViewController = MainTabController()
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<true/>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
<key>com.apple.security.files.user-selected.read-only</key>
|
||||
<true/>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@ -26,15 +26,15 @@ struct AutoCat2SUIApp: App {
|
||||
}
|
||||
|
||||
func getTestSettings() -> TestSettings {
|
||||
guard let settings = Settings.shared as? TestSettings else {
|
||||
guard let settings = MainSettings.shared as? TestSettings else {
|
||||
fatalError("Error getting settings")
|
||||
}
|
||||
|
||||
return settings
|
||||
}
|
||||
|
||||
func getSettings() -> Settings {
|
||||
guard let settings = Settings.shared as? Settings else {
|
||||
func getSettings() -> MainSettings {
|
||||
guard let settings = MainSettings.shared as? MainSettings else {
|
||||
fatalError("Error getting settings")
|
||||
}
|
||||
|
||||
|
||||
14
AutoCat2SUI/Extensions/View.swift
Normal file
14
AutoCat2SUI/Extensions/View.swift
Normal file
@ -0,0 +1,14 @@
|
||||
//
|
||||
// View.swift
|
||||
// AutoCat2SUI
|
||||
//
|
||||
// Created by Selim Mustafaev on 28.08.2022.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
extension View {
|
||||
func hidden(_ shouldHide: Bool) -> some View {
|
||||
opacity(shouldHide ? 0 : 1)
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ public class AuthVM: ObservableObject {
|
||||
private let api: ApiProtocol
|
||||
private var settings: any SettingsProtocol
|
||||
|
||||
init(api: ApiProtocol = Api.shared, settings: any SettingsProtocol = Settings.shared) {
|
||||
init(api: ApiProtocol = Api.shared, settings: any SettingsProtocol = MainSettings.shared) {
|
||||
|
||||
self.api = api
|
||||
self.settings = settings
|
||||
|
||||
56
AutoCat2SUI/Screens/CheckNumber/CheckNumber.swift
Normal file
56
AutoCat2SUI/Screens/CheckNumber/CheckNumber.swift
Normal file
@ -0,0 +1,56 @@
|
||||
//
|
||||
// CheckNumber.swift
|
||||
// AutoCat2SUI
|
||||
//
|
||||
// Created by Selim Mustafaev on 28.08.2022.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AutoCatCore
|
||||
|
||||
struct CheckNumber: View {
|
||||
|
||||
@Environment(\.presentationMode) var presentation
|
||||
@State var plateNumber: String = ""
|
||||
@State var showProgress = false
|
||||
@State private var alert: AlertMessage? = nil
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .center, spacing: 8) {
|
||||
Text("Check new plate number")
|
||||
TextField("qwe", text: $plateNumber, prompt: Text("Plate number"))
|
||||
.disabled(showProgress)
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle())
|
||||
.hidden(!showProgress)
|
||||
HStack {
|
||||
Button("Cancel") {
|
||||
self.presentation.wrappedValue.dismiss()
|
||||
}
|
||||
.disabled(showProgress)
|
||||
Button("Check") {
|
||||
Task.init {
|
||||
showProgress = true
|
||||
do {
|
||||
try await VehicleService.shared.check(plateNumber: plateNumber.uppercased(), force: false)
|
||||
self.presentation.wrappedValue.dismiss()
|
||||
} catch {
|
||||
alert = .error(error: error)
|
||||
}
|
||||
showProgress = false
|
||||
}
|
||||
}
|
||||
.alert(item: $alert, content: Alert.init)
|
||||
.disabled(showProgress)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.frame(minWidth: 300)
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckNumber_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CheckNumber()
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,7 @@ struct MainView: View {
|
||||
@FetchRequest(entity: CDVehicle.entity(), sortDescriptors: []) var vehicles: FetchedResults<CDVehicle>
|
||||
|
||||
@State private var selectedFilter: Filter?
|
||||
@State private var checkSheetPresented = false
|
||||
|
||||
private var historyFilters: [Filter] = [
|
||||
.allLocal,
|
||||
@ -30,7 +31,8 @@ struct MainView: View {
|
||||
Section("History") {
|
||||
ForEach(historyFilters) { filter in
|
||||
NavigationLink(value: filter) {
|
||||
Label(filter.name, image: filter.iconName)
|
||||
Label(filter.name, systemImage: filter.iconName)
|
||||
.badge(vehicles.count)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,11 +40,28 @@ struct MainView: View {
|
||||
Section("Remote") {
|
||||
ForEach(remoteFilters) { filter in
|
||||
NavigationLink(value: filter) {
|
||||
Label(filter.name, image: filter.iconName)
|
||||
Label(filter.name, systemImage: filter.iconName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .primaryAction) {
|
||||
Spacer()
|
||||
Button {
|
||||
checkSheetPresented = true
|
||||
} label: {
|
||||
Image(systemName: "plus")
|
||||
}
|
||||
.sheet(isPresented: $checkSheetPresented) {
|
||||
CheckNumber()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
.navigationDestination(for: Filter.self) { filter in
|
||||
VehiclesListView(vehicles: [], selection: nil)
|
||||
}
|
||||
} content: {
|
||||
Text("Content")
|
||||
} detail: {
|
||||
|
||||
30
AutoCat2SUI/Screens/VehiclesList/VehiclesListView.swift
Normal file
30
AutoCat2SUI/Screens/VehiclesList/VehiclesListView.swift
Normal file
@ -0,0 +1,30 @@
|
||||
//
|
||||
// VehiclesListView.swift
|
||||
// AutoCat2SUI
|
||||
//
|
||||
// Created by Selim Mustafaev on 28.08.2022.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AutoCatCore
|
||||
|
||||
struct VehiclesListView: View {
|
||||
|
||||
var vehicles: [CDVehicle]
|
||||
@State var selection: CDVehicle?
|
||||
|
||||
var body: some View {
|
||||
List(selection: $selection) {
|
||||
ForEach(vehicles, id: \.self) { vehicle in
|
||||
let number = PlateNumber(vehicle.number ?? "")
|
||||
PlateNumberView(number: number, unrecognized: vehicle.unrecognized, outdated: vehicle.outdated)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct VehiclesListView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
VehiclesListView(vehicles: [])
|
||||
}
|
||||
}
|
||||
68
AutoCat2SUI/Views/PlateNumberView.swift
Normal file
68
AutoCat2SUI/Views/PlateNumberView.swift
Normal file
@ -0,0 +1,68 @@
|
||||
//
|
||||
// PlateNumberView.swift
|
||||
// AutoCat2SUI
|
||||
//
|
||||
// Created by Selim Mustafaev on 28.08.2022.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
import AutoCatCore
|
||||
|
||||
struct PlateNumberView: View {
|
||||
|
||||
let number: PlateNumber
|
||||
let unrecognized: Bool
|
||||
let outdated: Bool
|
||||
|
||||
private var fgColor: Color {
|
||||
if unrecognized {
|
||||
return Color("PlateBackgroundError")
|
||||
} else {
|
||||
return Color("PlateForeground")
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.fill(fgColor)
|
||||
GeometryReader { geometry in
|
||||
HStack(alignment: .center, spacing: 2) {
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.fill(Color("PlateBackground"))
|
||||
Text(number.mainPart())
|
||||
.font(Font.custom("RoadNumbers", size: geometry.size.height*0.9))
|
||||
}
|
||||
.frame(width: geometry.size.width*0.73 - 1)
|
||||
ZStack {
|
||||
RoundedRectangle(cornerRadius: 4)
|
||||
.fill(Color("PlateBackground"))
|
||||
VStack(spacing: 0) {
|
||||
Text(number.region())
|
||||
.frame(height: geometry.size.height*0.65, alignment: .center)
|
||||
HStack {
|
||||
|
||||
}
|
||||
.frame(height: geometry.size.height*0.35, alignment: .center)
|
||||
}
|
||||
}
|
||||
.frame(width: geometry.size.width*0.27 - 1)
|
||||
}
|
||||
}
|
||||
.padding(2)
|
||||
}
|
||||
.aspectRatio(520.0/112.0, contentMode: .fit)
|
||||
}
|
||||
}
|
||||
|
||||
struct PlateNumberView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Group {
|
||||
PlateNumberView(number: PlateNumber("Е201АМ761"), unrecognized: false, outdated: false)
|
||||
PlateNumberView(number: PlateNumber("Е201АМ761"), unrecognized: true, outdated: false)
|
||||
PlateNumberView(number: PlateNumber("Е201АМ761"), unrecognized: false, outdated: true)
|
||||
}
|
||||
.previewLayout(.fixed(width: 200, height: 50))
|
||||
}
|
||||
}
|
||||
@ -27,6 +27,6 @@ struct RootView<T>: View where T: SettingsProtocol {
|
||||
|
||||
struct RootView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
RootView(settings: Settings())
|
||||
RootView(settings: MainSettings())
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,9 +7,9 @@ public protocol SettingsProtocol: ObservableObject {
|
||||
|
||||
}
|
||||
|
||||
public class Settings: SettingsProtocol {
|
||||
public class MainSettings: SettingsProtocol {
|
||||
private let defaults: UserDefaults
|
||||
public static var shared: any SettingsProtocol = Testing.isUITesting ? TestSettings() : Settings()
|
||||
public static var shared: any SettingsProtocol = Testing.isUITesting ? TestSettings() : MainSettings()
|
||||
|
||||
@Published
|
||||
public var user: User {
|
||||
@ -31,6 +31,10 @@ public class Settings: SettingsProtocol {
|
||||
public init(defaults: UserDefaults = .standard) {
|
||||
self.defaults = defaults
|
||||
|
||||
// if let bundleID = Bundle.main.bundleIdentifier {
|
||||
// UserDefaults.standard.removePersistentDomain(forName: bundleID)
|
||||
// }
|
||||
|
||||
self.defaults.register(defaults: [
|
||||
"showDebugInfo": false
|
||||
])
|
||||
@ -14,7 +14,7 @@ public class Api: ApiProtocol {
|
||||
|
||||
public static let shared = Api()
|
||||
|
||||
public init(session: URLSession? = nil, settings: any SettingsProtocol = Settings.shared) {
|
||||
public init(session: URLSession? = nil, settings: any SettingsProtocol = MainSettings.shared) {
|
||||
|
||||
self.settings = settings
|
||||
|
||||
|
||||
@ -3,8 +3,8 @@ import Foundation
|
||||
public struct Constants {
|
||||
public static var baseUrl: String {
|
||||
#if DEBUG
|
||||
return "http://127.0.0.1:3000/"
|
||||
//return "http://192.168.1.67:3000/"
|
||||
//return "http://127.0.0.1:3000/"
|
||||
return "http://192.168.1.1:3000/"
|
||||
//return "https://vps.aliencat.pro:8443/"
|
||||
#else
|
||||
return "https://vps.aliencat.pro:8443/"
|
||||
|
||||
@ -22,7 +22,7 @@ class SettingsTests: XCTestCase {
|
||||
throw TestError.createDefaultsFailed
|
||||
}
|
||||
userDefaults.removePersistentDomain(forName: #file)
|
||||
self.settings = Settings(defaults: userDefaults)
|
||||
self.settings = MainSettings(defaults: userDefaults)
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user