Minor fixes

This commit is contained in:
Selim Mustafaev 2024-12-24 22:19:55 +03:00
parent 08a5c01990
commit deb3dae992
6 changed files with 43 additions and 15 deletions

View File

@ -1693,7 +1693,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 143; CURRENT_PROJECT_VERSION = 144;
DEVELOPMENT_TEAM = 46DTTB8X4S; DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_FILE = AutoCat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = AutoCat; INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
@ -1720,7 +1720,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 143; CURRENT_PROJECT_VERSION = 144;
DEVELOPMENT_TEAM = 46DTTB8X4S; DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_FILE = AutoCat/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = AutoCat; INFOPLIST_KEY_CFBundleDisplayName = AutoCat;

View File

@ -73,12 +73,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
HUD.allowsInteraction = false HUD.allowsInteraction = false
registerServices() registerServices()
setupAppearance()
//Logging.URLRequests = { _ in false }; //Logging.URLRequests = { _ in false };
return true return true
} }
func setupAppearance() {
let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithDefaultBackground()
UITabBar.appearance().standardAppearance = tabBarAppearance
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
let navigationBarAppearance = UINavigationBarAppearance()
navigationBarAppearance.configureWithDefaultBackground()
UINavigationBar.appearance().standardAppearance = navigationBarAppearance
UINavigationBar.appearance().scrollEdgeAppearance = navigationBarAppearance
}
func registerServices() { func registerServices() {
let container = ServiceContainer.shared let container = ServiceContainer.shared

View File

@ -105,11 +105,6 @@ struct EventsScreen: View {
@ViewBuilder @ViewBuilder
func makeActions(for event: EventModel, useLabels: Bool = false) -> some View { func makeActions(for event: EventModel, useLabels: Bool = false) -> some View {
Button(role: .destructive) {
Task { await viewModel.deleteEvent(event) }
} label: {
Label(useLabels ? "Delete" : "", systemImage: "trash")
}
Button() { Button() {
Task { await viewModel.editEvent(event) } Task { await viewModel.editEvent(event) }
@ -134,6 +129,12 @@ struct EventsScreen: View {
ShareLink(item: link) ShareLink(item: link)
} }
} }
Button(role: .destructive) {
Task { await viewModel.deleteEvent(event) }
} label: {
Label(useLabels ? "Delete" : "", systemImage: "trash")
}
} }
} }

View File

@ -63,11 +63,6 @@ struct NotesScreen: View {
@ViewBuilder @ViewBuilder
func makeActions(for note: VehicleNoteDto, useLabels: Bool = false) -> some View { func makeActions(for note: VehicleNoteDto, useLabels: Bool = false) -> some View {
Button(role: .destructive) {
Task { await viewModel.deleteNote(id: note.id) }
} label: {
Label(useLabels ? "Delete" : "", systemImage: "trash")
}
Button() { Button() {
selectedNoteId = note.id selectedNoteId = note.id
@ -82,6 +77,12 @@ struct NotesScreen: View {
} label: { } label: {
Label(useLabels ? "Copy" : "", systemImage: "doc.on.doc") Label(useLabels ? "Copy" : "", systemImage: "doc.on.doc")
} }
Button(role: .destructive) {
Task { await viewModel.deleteNote(id: note.id) }
} label: {
Label(useLabels ? "Delete" : "", systemImage: "trash")
}
} }
} }

View File

@ -37,6 +37,14 @@ struct EventsTests {
given(settingsServiceMock) given(settingsServiceMock)
.user.willReturn(User()) .user.willReturn(User())
} }
func makeViewModel(vehicle: VehicleDto) -> EventsViewModel {
EventsViewModel(apiService: apiServiceMock,
storageService: storageServiceMock,
settingsService: settingsServiceMock,
vehicle: vehicle)
}
@Test("Add event", arguments: [true, false]) @Test("Add event", arguments: [true, false])
mutating func addEvent(isUnrecognized: Bool) async throws { mutating func addEvent(isUnrecognized: Bool) async throws {
@ -55,7 +63,7 @@ struct EventsTests {
.add(event: .value(.valid), to: .value(VehicleDto.validNumber)) .add(event: .value(.valid), to: .value(VehicleDto.validNumber))
.willReturn(unrecognizedVehicleWithEvent) .willReturn(unrecognizedVehicleWithEvent)
viewModel.vehicle = isUnrecognized ? .unrecognized : .normal viewModel = makeViewModel(vehicle: isUnrecognized ? .unrecognized : .normal)
await viewModel.addEvent(.valid) await viewModel.addEvent(.valid)
verify(apiServiceMock) verify(apiServiceMock)
@ -95,7 +103,7 @@ struct EventsTests {
.remove(event: .value(VehicleEventDto.validId), from: .value(VehicleDto.validNumber)) .remove(event: .value(VehicleEventDto.validId), from: .value(VehicleDto.validNumber))
.willReturn(.unrecognized) .willReturn(.unrecognized)
viewModel.vehicle = vehicleWithEvent viewModel = makeViewModel(vehicle: vehicleWithEvent)
await viewModel.deleteEvent(VehicleEventDto.valid.viewModel) await viewModel.deleteEvent(VehicleEventDto.valid.viewModel)
verify(apiServiceMock) verify(apiServiceMock)

View File

@ -18,6 +18,9 @@ extension VehicleEventDto {
static let validLatitude: Double = 42 static let validLatitude: Double = 42
static let validLongitude: Double = 24 static let validLongitude: Double = 24
static let testAddress = "testAddress"
static let testAddressModified = "testAddressModified"
static var valid: VehicleEventDto { static var valid: VehicleEventDto {
var event = VehicleEventDto( var event = VehicleEventDto(
@ -28,6 +31,7 @@ extension VehicleEventDto {
event.id = validId event.id = validId
event.date = 0 event.date = 0
event.address = testAddress
return event return event
} }
@ -37,7 +41,7 @@ extension VehicleEventDto {
id: id, id: id,
date: "", date: "",
coordinate: CLLocationCoordinate2DMake(latitude, longitude), coordinate: CLLocationCoordinate2DMake(latitude, longitude),
address: "", address: address ?? "",
isMe: true isMe: true
) )
} }