dashboard

This commit is contained in:
RSA 2026-09-16 14:43:57 +01:00
parent 7215cc263a
commit 477426652f
6 changed files with 61 additions and 112 deletions

View File

@ -17,6 +17,8 @@ final class ManagerAssembly: Assembly {
return GRDBDatabaseManager() return GRDBDatabaseManager()
} }
.inObjectScope(.container) .inObjectScope(.container)
container.register(APIClient.self) { _ in container.register(APIClient.self) { _ in
return APIClient() return APIClient()
} }
@ -26,57 +28,12 @@ final class ManagerAssembly: Assembly {
return EventsManager() return EventsManager()
} }
/*
container.register(MedMapAPI.self) { _ in
return MedMapAPI()
container.register(ComicsBooksManager.self) { _ in
return ComicsBooksManager()
}
.inObjectScope(.container)
container.register(EventsManager.self) { _ in
return EventsManager()
} }
.inObjectScope(.container) .inObjectScope(.container)
// API Client
container.register(AuthorizationInterceptor.self) { _ in
return AuthorizationInterceptor()
}
.inObjectScope(.container)
container.register(APIClient.self) { _ in
return APIClient()
}
.inObjectScope(.container)
container.register(EventsManager.self) { _ in
return EventsManager()
}
.inObjectScope(.container)
container.register(EntityDetector.self) { _ in
return EntityDetector()
}
.inObjectScope(.container)
container.register(FileSystemManager.self) { _ in
return FileSystemManager()
}
.inObjectScope(.container)
container.register(FluxReaderAPI.self) { _ in
return FluxReaderAPI()
}
.inObjectScope(.container)
container.register(PreferencesManager.self) { _ in
return PreferencesManager()
}
.inObjectScope(.container)
container.register(NetworkMonitor.self) { _ in
return NetworkMonitor()
}
.inObjectScope(.container)
*/
} }
} }

View File

@ -11,12 +11,7 @@ final class DashboardViewModel: ViewModel {
@Published private(set) var errorMessage: String? @Published private(set) var errorMessage: String?
@Published private(set) var logoutErrorMessage: String? @Published private(set) var logoutErrorMessage: String?
private let api: MedMapAPI private let api: MedMapAPI = DIContainer.shared.resolve()
init(api: MedMapAPI = MedMapAPI()) {
self.api = api
super.init()
}
var patientAge: Int? { var patientAge: Int? {
guard let dateOfBirth = patient?.dateOfBirth else { return nil } guard let dateOfBirth = patient?.dateOfBirth else { return nil }

View File

@ -14,12 +14,10 @@ final class LoginViewModel: ViewModel {
@Published private(set) var errorMessage: String? @Published private(set) var errorMessage: String?
@Published private(set) var authenticatedPatient: LoginResponse? @Published private(set) var authenticatedPatient: LoginResponse?
private let api: MedMapAPI private let api: MedMapAPI = DIContainer.shared.resolve()
init(api: MedMapAPI = MedMapAPI()) {
self.api = api
super.init()
}
var canSubmit: Bool { var canSubmit: Bool {
!email.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && !password.isEmpty && !isLoading !email.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && !password.isEmpty && !isLoading

View File

@ -4,21 +4,19 @@
// //
import Foundation import Foundation
import Combine
import SwiftUI
@MainActor @MainActor
final class PatientMonthlyHistoryViewModel: ViewModel { final class PatientMonthlyHistoryViewModel: ViewModel {
@Published private(set) var history: PatientMonthlyHistoryResponse? @Published private(set) var history: PatientMonthlyHistoryResponse?
@Published private(set) var errorMessage: String? @Published private(set) var errorMessage: String?
private let api: MedMapAPI private let api: MedMapAPI = DIContainer.shared.resolve()
private let calendar = Calendar(identifier: .gregorian) private let calendar = Calendar(identifier: .gregorian)
private var selectedMonth = Date.now private var selectedMonth = Date.now
init(api: MedMapAPI = MedMapAPI()) {
self.api = api
super.init()
}
func loadHistory() async { func loadHistory() async {
guard !isLoading else { return } guard !isLoading else { return }

View File

@ -14,12 +14,9 @@ final class SignupViewModel: ViewModel {
@Published var confirmationPassword = "" @Published var confirmationPassword = ""
@Published private(set) var errorMessage: String? @Published private(set) var errorMessage: String?
private let api: MedMapAPI private let api: MedMapAPI = DIContainer.shared.resolve()
init(api: MedMapAPI = MedMapAPI()) {
self.api = api
super.init()
}
var canSubmit: Bool { var canSubmit: Bool {
!email.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && !email.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty &&

View File

@ -60,12 +60,12 @@ struct DashboardView: View {
// MARK: - Top bar // MARK: - Top bar
private var topBar: some View { private var topBar: some View {
VStack(spacing: 8) {
HStack { HStack {
Image("timerIcon") Image("timerIcon")
.foregroundStyle(Color.appBackground) .foregroundStyle(Color.appBackground)
.frame(width: 32, height: 32) .frame(width: 32, height: 32)
Spacer() Spacer()
HStack(spacing: 6) { HStack(spacing: 6) {
@ -98,6 +98,7 @@ struct DashboardView: View {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
} }
} }
}
// MARK: - Patient header // MARK: - Patient header
@ -253,10 +254,13 @@ private struct MedicationCardView: View {
.clipShape(Capsule()) .clipShape(Capsule())
if let nextDoseTime = card.nextDoseTime { if let nextDoseTime = card.nextDoseTime {
Group { Text({
Text("Próxima toma às ") + var attributed = AttributedString("Próxima toma às ")
Text("\(nextDoseTime)h").fontWeight(.bold) var timePart = AttributedString("\(nextDoseTime)h")
} timePart.inlinePresentationIntent = .stronglyEmphasized
attributed.append(timePart)
return attributed
}())
.font(.jakartaRegular14) .font(.jakartaRegular14)
.foregroundStyle(Color.appBackground) .foregroundStyle(Color.appBackground)
} }