Adding stub for SwiftUI report screen

This commit is contained in:
Selim Mustafaev 2024-11-17 13:20:50 +03:00
parent 3b6eebcd27
commit 3875259244
9 changed files with 198 additions and 5 deletions

View File

@ -42,6 +42,10 @@
7A1CF80529A41C66007962DA /* RealmSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 7A1CF80429A41C66007962DA /* RealmSwift */; };
7A1CF81629A42117007962DA /* Realm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1CF81529A42117007962DA /* Realm.swift */; };
7A1DC38E2517ED98002E9C99 /* BlockBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1DC38D2517ED98002E9C99 /* BlockBarButtonItem.swift */; };
7A1E78F62CE900330004B740 /* ReportScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E78F52CE900330004B740 /* ReportScreen.swift */; };
7A1E78F82CE900440004B740 /* ReportViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E78F72CE900440004B740 /* ReportViewModel.swift */; };
7A1E78FA2CE9005C0004B740 /* ReportCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E78F92CE9005C0004B740 /* ReportCoordinator.swift */; };
7A1E78FF2CE91A740004B740 /* Vehicle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1E78FE2CE91A740004B740 /* Vehicle.swift */; };
7A22B6ED2C67FDEA00E60173 /* SwiftLocationMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A22B6EB2C67FDEA00E60173 /* SwiftLocationMock.swift */; };
7A22B6EE2C67FDEA00E60173 /* GeocoderMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A22B6EA2C67FDEA00E60173 /* GeocoderMock.swift */; };
7A27ADC7249D43210035F39E /* RegionsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A27ADC6249D43210035F39E /* RegionsController.swift */; };
@ -300,6 +304,10 @@
7A17CE4B2A2E850200626A6E /* UISegmentedControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UISegmentedControl.swift; sourceTree = "<group>"; };
7A1CF81529A42117007962DA /* Realm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Realm.swift; sourceTree = "<group>"; };
7A1DC38D2517ED98002E9C99 /* BlockBarButtonItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlockBarButtonItem.swift; sourceTree = "<group>"; };
7A1E78F52CE900330004B740 /* ReportScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportScreen.swift; sourceTree = "<group>"; };
7A1E78F72CE900440004B740 /* ReportViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportViewModel.swift; sourceTree = "<group>"; };
7A1E78F92CE9005C0004B740 /* ReportCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReportCoordinator.swift; sourceTree = "<group>"; };
7A1E78FE2CE91A740004B740 /* Vehicle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Vehicle.swift; sourceTree = "<group>"; };
7A22B6EA2C67FDEA00E60173 /* GeocoderMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeocoderMock.swift; sourceTree = "<group>"; };
7A22B6EB2C67FDEA00E60173 /* SwiftLocationMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftLocationMock.swift; sourceTree = "<group>"; };
7A27ADC6249D43210035F39E /* RegionsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegionsController.swift; sourceTree = "<group>"; };
@ -682,6 +690,7 @@
7A1441632C297E9800E79018 /* Screens */ = {
isa = PBXGroup;
children = (
7A1E78F42CE9001A0004B740 /* ReportScreen */,
7A43228F2CB2CC5D00085CF6 /* FiltersScreen */,
7A06E0AA2C706550005731AC /* SettingsScreen */,
7A1022752C557E3F00B84627 /* LocationPickerScreen */,
@ -705,6 +714,24 @@
path = NotesScreen;
sourceTree = "<group>";
};
7A1E78F42CE9001A0004B740 /* ReportScreen */ = {
isa = PBXGroup;
children = (
7A1E78F52CE900330004B740 /* ReportScreen.swift */,
7A1E78F72CE900440004B740 /* ReportViewModel.swift */,
7A1E78F92CE9005C0004B740 /* ReportCoordinator.swift */,
);
path = ReportScreen;
sourceTree = "<group>";
};
7A1E78FB2CE91A590004B740 /* Data */ = {
isa = PBXGroup;
children = (
7A1E78FE2CE91A740004B740 /* Vehicle.swift */,
);
path = Data;
sourceTree = "<group>";
};
7A22B6EC2C67FDEA00E60173 /* Mocks */ = {
isa = PBXGroup;
children = (
@ -949,6 +976,7 @@
7AB587352C42E3BF00FA7B66 /* Preview */ = {
isa = PBXGroup;
children = (
7A1E78FB2CE91A590004B740 /* Data */,
7AB587362C42E3EC00FA7B66 /* StorageServiceStub.swift */,
7A176DB12C43071A00999D6B /* ApiServiceStub.swift */,
7AB0EF882C5D307600291EE6 /* LocationServiceStub.swift */,
@ -1288,6 +1316,7 @@
7A7158092C44087E00852088 /* OsagoCoordinator.swift in Sources */,
7A1441662C297EDE00E79018 /* NotesScreen.swift in Sources */,
7A11470123FDE7E500B424AF /* AppDelegate.swift in Sources */,
7A1E78FF2CE91A740004B740 /* Vehicle.swift in Sources */,
7A3399AB299063370087DF98 /* SearchControllerExt.swift in Sources */,
7A14416E2C297F7C00E79018 /* Coordinator.swift in Sources */,
7A6DD90824329144009DE740 /* CenterTextLayer.swift in Sources */,
@ -1321,10 +1350,12 @@
7ADF6CA12512244400F237B2 /* MapExt.swift in Sources */,
7AC3554E29696C4500889457 /* DummyNewController.swift in Sources */,
7A7158122C444A6400852088 /* AdsViewModel.swift in Sources */,
7A1E78FA2CE9005C0004B740 /* ReportCoordinator.swift in Sources */,
7A659B5B24A3768A0043A0F2 /* Substrings.swift in Sources */,
7A71580E2C4445A200852088 /* AdsCoordinator.swift in Sources */,
7AFBE8CA2C3081C7003C491D /* ACProgressHud+Modifiers.swift in Sources */,
7A27ADF7249FEF690035F39E /* Recorder.swift in Sources */,
7A1E78F62CE900330004B740 /* ReportScreen.swift in Sources */,
7A10226C2C551EC500B84627 /* LocationEditScreen.swift in Sources */,
7A7158072C44085600852088 /* OsagoScreen.swift in Sources */,
7AAAFAD32C4D0FD00050410D /* ACImageSliderView.swift in Sources */,
@ -1351,6 +1382,7 @@
7A1022792C557ED600B84627 /* LocationPickerViewModel.swift in Sources */,
7A11470323FDE7E500B424AF /* SceneDelegate.swift in Sources */,
7A530B7E24017FEE00CBFE6E /* VehicleCell.swift in Sources */,
7A1E78F82CE900440004B740 /* ReportViewModel.swift in Sources */,
7A10226E2C551EE000B84627 /* LocationEditViewModel.swift in Sources */,
7AFBE8CE2C308B53003C491D /* ACMessageView.swift in Sources */,
7A14416C2C297F2100E79018 /* NotesCoordinator.swift in Sources */,

View File

@ -265,8 +265,12 @@ class CheckController: UIViewController, UITableViewDelegate, UISearchResultsUpd
let report = detail.viewControllers.first as? ReportController
report?.number = vehicle.getNumber()
splitViewController.showDetailViewController(detail, sender: self)
//self.performSegue(withIdentifier: "OpenDetailSegue", sender: self)
}
// Task {
// let coordinator = ReportCoordinator(splitController: splitViewController, vehicle: vehicle)
// try? await coordinator.start()
// }
}
}

View File

@ -0,0 +1,42 @@
//
// Vehicle.swift
// AutoCat
//
// Created by Selim Mustafaev on 16.11.2024.
// Copyright © 2024 Selim Mustafaev. All rights reserved.
//
import AutoCatCore
extension VehicleDto {
static var preview: Self {
var vehicle = Self()
vehicle.brand?.name?.normalized = "Audi"
vehicle.brand?.name?.original = "Audi TT"
vehicle.brand?.logo = "https://vl.imgix.net/img/audi-logo.png"
vehicle.model?.name?.normalized = "TT"
vehicle.color = "ЧЕРНЫЙ"
vehicle.year = 2008
vehicle.category = "B"
vehicle.engine?.number = "51156"
vehicle.engine?.volume = 3189
vehicle.engine?.powerHp = 250.03
vehicle.engine?.powerKw = 183.9
vehicle.engine?.fuelType = "Бензиновый"
vehicle.number = "А123АА761"
vehicle.currentNumber = "А123АА761"
vehicle.vin1 = "TRUZZZ1234567890"
vehicle.sts = "1234567890"
vehicle.pts = "123QWERTY456"
vehicle.isRightWheel = false
vehicle.isJapanese = false
vehicle.addedDate = 1609435770213
vehicle.updatedDate = 1609435770213
vehicle.addedBy = "selim@fastmail.fm"
return vehicle
}
}

View File

@ -0,0 +1,44 @@
//
// ReportCoordinator.swift
// AutoCat
//
// Created by Selim Mustafaev on 16.11.2024.
// Copyright © 2024 Selim Mustafaev. All rights reserved.
//
import UIKit
import SwiftUI
import AutoCatCore
@MainActor
class ReportCoordinator: Coordinator {
let viewController: UISplitViewController?
let vehicle: VehicleDto
var navController: UINavigationController?
init(splitController: UISplitViewController?, vehicle: VehicleDto) {
self.viewController = splitController
self.vehicle = vehicle
}
func start() async throws {
if viewController?.viewControllers.count == 2 {
navController = viewController?.viewControllers.last as? UINavigationController
} else {
let viewModel = ReportViewModel(vehicle: vehicle)
let controller = UIHostingController(rootView: ReportScreen(viewModel: viewModel))
navController = UINavigationController(rootViewController: controller)
}
if let navController {
navController.popToRootViewController(animated: true)
let report = navController.viewControllers.first as? ReportController
report?.number = vehicle.getNumber()
viewController?.showDetailViewController(navController, sender: self)
}
}
}

View File

@ -0,0 +1,46 @@
//
// ReportScreen.swift
// AutoCat
//
// Created by Selim Mustafaev on 16.11.2024.
// Copyright © 2024 Selim Mustafaev. All rights reserved.
//
import SwiftUI
import AutoCatCore
struct ReportScreen: View {
@State var viewModel: ReportViewModel
var body: some View {
Form {
Section {
LabeledContent {
Text(viewModel.vehicle.brand?.name?.original ?? "")
} label: {
AsyncImage(url: URL(string: viewModel.vehicle.brand?.logo ?? "")) { phase in
phase.image?
.resizable()
.aspectRatio(contentMode: .fit)
.frame(height: 32)
}
}
}
Section("General") {
LabeledContent("Year", value: String(viewModel.vehicle.year))
LabeledContent("Color", value: viewModel.vehicle.color ?? "")
LabeledContent("Category", value: viewModel.vehicle.category ?? "")
LabeledContent("Steering wheel position",
value: viewModel.vehicle.isRightWheel == true ? "Right" : "Left")
LabeledContent("Japanese",
value: viewModel.vehicle.isJapanese == true ? "Yes" : "No")
}
}
}
}
#Preview {
ReportScreen(viewModel: .init(vehicle: .preview))
}

View File

@ -0,0 +1,25 @@
//
// ReportViewModel.swift
// AutoCat
//
// Created by Selim Mustafaev on 16.11.2024.
// Copyright © 2024 Selim Mustafaev. All rights reserved.
//
import AutoCatCore
import SwiftUI
@MainActor
@Observable
class ReportViewModel {
@ObservationIgnored @Service var api: ApiServiceProtocol
@ObservationIgnored @Service var storageService: StorageServiceProtocol
var vehicle: VehicleDto
var hud: ACHud?
init(vehicle: VehicleDto) {
self.vehicle = vehicle
}
}

View File

@ -42,7 +42,7 @@ class SettingsCoordinator: Coordinator {
}
func openGoogleOauthPage() {
print("===== openGoogleOauthPage")
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let vc = storyboard.instantiateViewController(identifier: "GoogleSignInController") as? GoogleSignInController {
settingsController?.present(vc, animated: true)

View File

@ -10,5 +10,5 @@ import Foundation
public struct VehicleModelDto: Decodable, Sendable {
let name: VehicleNameDto?
public var name: VehicleNameDto?
}

View File

@ -5,7 +5,7 @@ public enum Constants {
public enum Backend: String, CaseIterable {
case de = "https://vps.aliencat.pro:8443/"
case ru = "https://vps2.aliencat.pro:8443/"
case ru = "https://charon.aliencat.pro:8443/"
case debug = "http://192.168.1.2:3000/"
public var name: String {