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()
}
.inObjectScope(.container)
container.register(APIClient.self) { _ in
return APIClient()
}
@ -26,57 +28,12 @@ final class ManagerAssembly: Assembly {
return EventsManager()
}
/*
container.register(MedMapAPI.self) { _ in
return MedMapAPI()
}
.inObjectScope(.container)
container.register(ComicsBooksManager.self) { _ in
return ComicsBooksManager()
}
.inObjectScope(.container)
container.register(EventsManager.self) { _ in
return EventsManager()
}
.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 logoutErrorMessage: String?
private let api: MedMapAPI
init(api: MedMapAPI = MedMapAPI()) {
self.api = api
super.init()
}
private let api: MedMapAPI = DIContainer.shared.resolve()
var patientAge: Int? {
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 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 {
!email.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty && !password.isEmpty && !isLoading

View File

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

View File

@ -14,12 +14,9 @@ final class SignupViewModel: ViewModel {
@Published var confirmationPassword = ""
@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 {
!email.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty &&

View File

@ -60,42 +60,43 @@ struct DashboardView: View {
// MARK: - Top bar
private var topBar: some View {
HStack {
Image("timerIcon")
.foregroundStyle(Color.appBackground)
.frame(width: 32, height: 32)
Spacer()
HStack(spacing: 6) {
Image("bluetoothIcon")
.foregroundStyle(Color.appTextPrimary.opacity(0.55))
Circle()
.fill(.green)
.frame(width: 16, height: 16)
}
Button {
isShowingLogoutConfirmation = true
} label: {
Image(systemName: "power")
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(Color.appTextPrimary.opacity(0.52))
VStack(spacing: 8) {
HStack {
Image("timerIcon")
.foregroundStyle(Color.appBackground)
.frame(width: 32, height: 32)
.background(.white.opacity(0.45))
.clipShape(Circle())
}
.buttonStyle(.plain)
.accessibilityLabel("Terminar sessao")
}
.padding(.horizontal, 32)
if let logoutErrorMessage = viewModel.logoutErrorMessage {
Text(logoutErrorMessage)
.font(.jakartaRegular12)
.foregroundStyle(.red)
.frame(maxWidth: .infinity)
Spacer()
HStack(spacing: 6) {
Image("bluetoothIcon")
.foregroundStyle(Color.appTextPrimary.opacity(0.55))
Circle()
.fill(.green)
.frame(width: 16, height: 16)
}
Button {
isShowingLogoutConfirmation = true
} label: {
Image(systemName: "power")
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(Color.appTextPrimary.opacity(0.52))
.frame(width: 32, height: 32)
.background(.white.opacity(0.45))
.clipShape(Circle())
}
.buttonStyle(.plain)
.accessibilityLabel("Terminar sessao")
}
.padding(.horizontal, 32)
if let logoutErrorMessage = viewModel.logoutErrorMessage {
Text(logoutErrorMessage)
.font(.jakartaRegular12)
.foregroundStyle(.red)
.frame(maxWidth: .infinity)
}
}
}
@ -253,10 +254,13 @@ private struct MedicationCardView: View {
.clipShape(Capsule())
if let nextDoseTime = card.nextDoseTime {
Group {
Text("Próxima toma às ") +
Text("\(nextDoseTime)h").fontWeight(.bold)
}
Text({
var attributed = AttributedString("Próxima toma às ")
var timePart = AttributedString("\(nextDoseTime)h")
timePart.inlinePresentationIntent = .stronglyEmphasized
attributed.append(timePart)
return attributed
}())
.font(.jakartaRegular14)
.foregroundStyle(Color.appBackground)
}