dashboard
This commit is contained in:
parent
7215cc263a
commit
477426652f
@ -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)
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 }
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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 }
|
||||||
|
|||||||
@ -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 &&
|
||||||
|
|||||||
@ -60,42 +60,43 @@ struct DashboardView: View {
|
|||||||
// MARK: - Top bar
|
// MARK: - Top bar
|
||||||
|
|
||||||
private var topBar: some View {
|
private var topBar: some View {
|
||||||
HStack {
|
VStack(spacing: 8) {
|
||||||
Image("timerIcon")
|
HStack {
|
||||||
.foregroundStyle(Color.appBackground)
|
Image("timerIcon")
|
||||||
.frame(width: 32, height: 32)
|
.foregroundStyle(Color.appBackground)
|
||||||
|
|
||||||
|
|
||||||
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)
|
.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 {
|
Spacer()
|
||||||
Text(logoutErrorMessage)
|
|
||||||
.font(.jakartaRegular12)
|
HStack(spacing: 6) {
|
||||||
.foregroundStyle(.red)
|
Image("bluetoothIcon")
|
||||||
.frame(maxWidth: .infinity)
|
.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())
|
.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)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user