Fixing some search screen errors
This commit is contained in:
parent
36fb2af641
commit
a46f90d2f4
@ -74,6 +74,7 @@
|
|||||||
7A64A2222C19E99E00284124 /* DebugInfoDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A64A2212C19E99E00284124 /* DebugInfoDto.swift */; };
|
7A64A2222C19E99E00284124 /* DebugInfoDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A64A2212C19E99E00284124 /* DebugInfoDto.swift */; };
|
||||||
7A64A2242C1A07EA00284124 /* Formatters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A64A2232C1A07EA00284124 /* Formatters.swift */; };
|
7A64A2242C1A07EA00284124 /* Formatters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A64A2232C1A07EA00284124 /* Formatters.swift */; };
|
||||||
7A64A2262C1A32C800284124 /* AudioRecordDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A64A2252C1A32C800284124 /* AudioRecordDto.swift */; };
|
7A64A2262C1A32C800284124 /* AudioRecordDto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A64A2252C1A32C800284124 /* AudioRecordDto.swift */; };
|
||||||
|
7A6974C72DCA5024008AA6A1 /* ListItemStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6974C62DCA5024008AA6A1 /* ListItemStyle.swift */; };
|
||||||
7A6B65B32CFB0DB500AABA6B /* NullifyDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6B65B22CFB0DB500AABA6B /* NullifyDate.swift */; };
|
7A6B65B32CFB0DB500AABA6B /* NullifyDate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6B65B22CFB0DB500AABA6B /* NullifyDate.swift */; };
|
||||||
7A6C4D9E2C56BCA600982597 /* SwiftLocation in Frameworks */ = {isa = PBXBuildFile; productRef = 7A6C4D9D2C56BCA600982597 /* SwiftLocation */; };
|
7A6C4D9E2C56BCA600982597 /* SwiftLocation in Frameworks */ = {isa = PBXBuildFile; productRef = 7A6C4D9D2C56BCA600982597 /* SwiftLocation */; };
|
||||||
7A6C65222D999325001240C2 /* AudioRecordViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6C65212D999325001240C2 /* AudioRecordViewModel.swift */; };
|
7A6C65222D999325001240C2 /* AudioRecordViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A6C65212D999325001240C2 /* AudioRecordViewModel.swift */; };
|
||||||
@ -328,6 +329,7 @@
|
|||||||
7A64A2252C1A32C800284124 /* AudioRecordDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecordDto.swift; sourceTree = "<group>"; };
|
7A64A2252C1A32C800284124 /* AudioRecordDto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecordDto.swift; sourceTree = "<group>"; };
|
||||||
7A64AE6B2469DC6900ABE48E /* AutoCat.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AutoCat.entitlements; sourceTree = "<group>"; };
|
7A64AE6B2469DC6900ABE48E /* AutoCat.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AutoCat.entitlements; sourceTree = "<group>"; };
|
||||||
7A659B5824A2B1BA0043A0F2 /* AudioRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecord.swift; sourceTree = "<group>"; };
|
7A659B5824A2B1BA0043A0F2 /* AudioRecord.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecord.swift; sourceTree = "<group>"; };
|
||||||
|
7A6974C62DCA5024008AA6A1 /* ListItemStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListItemStyle.swift; sourceTree = "<group>"; };
|
||||||
7A6B65B22CFB0DB500AABA6B /* NullifyDate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NullifyDate.swift; sourceTree = "<group>"; };
|
7A6B65B22CFB0DB500AABA6B /* NullifyDate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NullifyDate.swift; sourceTree = "<group>"; };
|
||||||
7A6C65212D999325001240C2 /* AudioRecordViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecordViewModel.swift; sourceTree = "<group>"; };
|
7A6C65212D999325001240C2 /* AudioRecordViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRecordViewModel.swift; sourceTree = "<group>"; };
|
||||||
7A6DD90924329541009DE740 /* RoadNumbers2.0.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = RoadNumbers2.0.otf; sourceTree = "<group>"; };
|
7A6DD90924329541009DE740 /* RoadNumbers2.0.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = RoadNumbers2.0.otf; sourceTree = "<group>"; };
|
||||||
@ -1077,6 +1079,7 @@
|
|||||||
7AB4E42B2D397D8E0006D052 /* VehicleCellView.swift */,
|
7AB4E42B2D397D8E0006D052 /* VehicleCellView.swift */,
|
||||||
7AC8B2752D6A01C700190706 /* UISearchTextField+Dumb.swift */,
|
7AC8B2752D6A01C700190706 /* UISearchTextField+Dumb.swift */,
|
||||||
7AF231982DA27C1B00AE5EB3 /* ACButtonView.swift */,
|
7AF231982DA27C1B00AE5EB3 /* ACButtonView.swift */,
|
||||||
|
7A6974C62DCA5024008AA6A1 /* ListItemStyle.swift */,
|
||||||
);
|
);
|
||||||
path = SwiftUI;
|
path = SwiftUI;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1337,6 +1340,7 @@
|
|||||||
7AF231952DA1C29300AE5EB3 /* AuthViewModel.swift in Sources */,
|
7AF231952DA1C29300AE5EB3 /* AuthViewModel.swift in Sources */,
|
||||||
7AB4E4662D58A16C0006D052 /* GenericError.swift in Sources */,
|
7AB4E4662D58A16C0006D052 /* GenericError.swift in Sources */,
|
||||||
7AFBE8CA2C3081C7003C491D /* ACProgressHud+Modifiers.swift in Sources */,
|
7AFBE8CA2C3081C7003C491D /* ACProgressHud+Modifiers.swift in Sources */,
|
||||||
|
7A6974C72DCA5024008AA6A1 /* ListItemStyle.swift in Sources */,
|
||||||
7A71EF572D0A26B200943129 /* EventModel.swift in Sources */,
|
7A71EF572D0A26B200943129 /* EventModel.swift in Sources */,
|
||||||
7AABBE3B2CF9F85600346588 /* Binding+Map.swift in Sources */,
|
7AABBE3B2CF9F85600346588 /* Binding+Map.swift in Sources */,
|
||||||
7A1E78F62CE900330004B740 /* ReportScreen.swift in Sources */,
|
7A1E78F62CE900330004B740 /* ReportScreen.swift in Sources */,
|
||||||
@ -1661,7 +1665,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 = 162;
|
CURRENT_PROJECT_VERSION = 163;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
@ -1690,7 +1694,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 = 162;
|
CURRENT_PROJECT_VERSION = 163;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
|
|||||||
@ -90,17 +90,23 @@ final class SearchViewModel: ACHudContainer {
|
|||||||
pageToken = nil
|
pageToken = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadSearchResults(filter: Filter) async throws {
|
func loadSearchResults(filter: Filter, needResetData: Bool = false) async throws {
|
||||||
|
|
||||||
let response = try await apiService.getVehicles(with: filter, pageToken: pageToken, pageSize: 20)
|
let response = try await apiService.getVehicles(with: filter, pageToken: pageToken, pageSize: 20)
|
||||||
|
|
||||||
|
if needResetData {
|
||||||
|
resetData()
|
||||||
|
}
|
||||||
|
|
||||||
if response.items.isEmpty {
|
if response.items.isEmpty {
|
||||||
hasMoreData = false
|
hasMoreData = false
|
||||||
} else {
|
} else {
|
||||||
hasMoreData = response.pageToken != nil
|
hasMoreData = response.pageToken != nil
|
||||||
vehicles += response.items
|
vehicles += response.items
|
||||||
pageToken = response.pageToken
|
pageToken = response.pageToken
|
||||||
vehiclesCount = response.count ?? 0
|
if let count = response.count {
|
||||||
|
vehiclesCount = count
|
||||||
|
}
|
||||||
vehicleSections = vehicles.groupedByDate(type: .updatedDate)
|
vehicleSections = vehicles.groupedByDate(type: .updatedDate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,9 +127,8 @@ final class SearchViewModel: ACHudContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func reloadData(with filter: Filter) async {
|
func reloadData(with filter: Filter) async {
|
||||||
resetData()
|
|
||||||
do {
|
do {
|
||||||
try await loadSearchResults(filter: filter)
|
try await loadSearchResults(filter: filter, needResetData: true)
|
||||||
} catch {
|
} catch {
|
||||||
if !error.isCanceled {
|
if !error.isCanceled {
|
||||||
hasMoreData = false
|
hasMoreData = false
|
||||||
@ -169,10 +174,9 @@ final class SearchViewModel: ACHudContainer {
|
|||||||
func updateWithFilter(_ filter: Filter) async {
|
func updateWithFilter(_ filter: Filter) async {
|
||||||
|
|
||||||
self.filter = filter
|
self.filter = filter
|
||||||
resetData()
|
|
||||||
await wrapWithToast { [weak self] in
|
await wrapWithToast { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
try await loadSearchResults(filter: filter)
|
try await loadSearchResults(filter: filter, needResetData: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
AutoCat/SwiftUI/ListItemStyle.swift
Normal file
18
AutoCat/SwiftUI/ListItemStyle.swift
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
//
|
||||||
|
// ListItemStyle.swift
|
||||||
|
// AutoCat
|
||||||
|
//
|
||||||
|
// Created by Selim Mustafaev on 06.05.2025.
|
||||||
|
// Copyright © 2025 Selim Mustafaev. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct ListItemStyle: ButtonStyle {
|
||||||
|
|
||||||
|
func makeBody(configuration: Configuration) -> some View {
|
||||||
|
|
||||||
|
configuration.label
|
||||||
|
.background(configuration.isPressed ? Color.blue : Color.clear)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user