refactor: add color assets and update UI components

This commit is contained in:
2026-03-16 16:36:21 +07:00
parent 37b87ececd
commit d991d06f17
25 changed files with 532 additions and 160 deletions
@@ -1,6 +1,33 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.188",
"green" : "0.231",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.227",
"green" : "0.271",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.188",
"green" : "0.231",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.227",
"green" : "0.271",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "0.478",
"red" : "0.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "1.000",
"green" : "0.518",
"red" : "0.039"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.349",
"green" : "0.780",
"red" : "0.204"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.345",
"green" : "0.820",
"red" : "0.188"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.000",
"green" : "0.584",
"red" : "1.000"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.039",
"green" : "0.624",
"red" : "1.000"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
+6 -1
View File
@@ -1,7 +1,7 @@
import SwiftUI
struct ContentView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@Environment(AuthViewModel.self) private var authViewModel
var body: some View {
Group {
@@ -19,3 +19,8 @@ struct ContentView: View {
}
}
}
#Preview {
ContentView()
.environment(AuthViewModel())
}
+54 -40
View File
@@ -2,10 +2,23 @@
"sourceLanguage" : "ru",
"strings" : {
"(%lld)" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "(%lld)"
}
}
}
},
"%@ alert: %@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "%1$@ alert: %2$@"
}
},
"ru" : {
"stringUnit" : {
"state" : "new",
@@ -31,7 +44,14 @@
}
},
"Active" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Active"
}
}
}
},
"active_sessions" : {
"localizations" : {
@@ -65,40 +85,6 @@
}
}
},
"alert_status_active" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "active"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "активен"
}
}
}
},
"alert_status_resolved" : {
"extractionState" : "stale",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "resolved"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "завершён"
}
}
}
},
"cancel" : {
"localizations" : {
"en" : {
@@ -292,7 +278,14 @@
}
},
"Email" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Email"
}
}
}
},
"error_invalid_credentials" : {
"localizations" : {
@@ -503,7 +496,14 @@
}
},
"Mayday" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Mayday"
}
}
}
},
"new_password" : {
"localizations" : {
@@ -618,7 +618,14 @@
}
},
"OK" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "OK"
}
}
}
},
"open_button" : {
"localizations" : {
@@ -797,7 +804,14 @@
}
},
"Resolved" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Resolved"
}
}
}
},
"save_button" : {
"localizations" : {
+2 -2
View File
@@ -2,13 +2,13 @@ import SwiftUI
@main
struct MaydayApp: App {
@StateObject private var authViewModel = AuthViewModel()
@State private var authViewModel = AuthViewModel()
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(authViewModel)
.environment(authViewModel)
}
}
}
+7 -6
View File
@@ -1,13 +1,14 @@
import Foundation
import SwiftUI
@Observable
@MainActor
class AuthViewModel: ObservableObject {
@Published var isAuthenticated = false
@Published var isCheckingAuth = true
@Published var currentUser: UserResponse?
@Published var isLoading = false
@Published var error: String?
final class AuthViewModel {
var isAuthenticated = false
var isCheckingAuth = true
var currentUser: UserResponse?
var isLoading = false
var error: String?
private let auth = AuthService.shared
private let keychain = KeychainService.shared
+16 -7
View File
@@ -2,16 +2,25 @@ import Foundation
import SwiftUI
import UIKit
@Observable
@MainActor
class NotificationsViewModel: ObservableObject {
@Published var notifications: [AppNotification] = []
@Published var unreadCount = 0
@Published var isLoading = false
@Published var isLoadingMore = false
@Published var error: String?
@Published var hasMore = true
final class NotificationsViewModel {
var notifications: [AppNotification] = []
var unreadCount = 0
var isLoading = false
var isLoadingMore = false
var error: String?
var hasMore = true
private var hasLoadedOnce = false
var unreadNotifications: [AppNotification] {
notifications.filter { !$0.isRead }
}
var readNotifications: [AppNotification] {
notifications.filter { $0.isRead }
}
private let service = NotificationsAPIService.shared
private let limit = 50
private var currentOffset = 0
+6 -5
View File
@@ -1,12 +1,13 @@
import Foundation
import SwiftUI
@Observable
@MainActor
class SettingsViewModel: ObservableObject {
@Published var sessions: [SessionResponse] = []
@Published var isLoading = false
@Published var error: String?
@Published var successMessage: String?
final class SettingsViewModel {
var sessions: [SessionResponse] = []
var isLoading = false
var error: String?
var successMessage: String?
private let service = NotificationsAPIService.shared
+9 -4
View File
@@ -1,7 +1,7 @@
import SwiftUI
struct LoginView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@Environment(AuthViewModel.self) private var authViewModel
@State private var email = ""
@State private var password = ""
@State private var showRegister = false
@@ -23,7 +23,7 @@ struct LoginView: View {
.scaledToFit()
.frame(width: 84, height: 84)
.clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
.shadow(color: .red.opacity(0.25), radius: 12, y: 6)
.shadow(color: .brand.opacity(0.25), radius: 12, y: 6)
Text("Mayday")
.font(.largeTitle.bold())
@@ -56,7 +56,7 @@ struct LoginView: View {
if let error = authViewModel.error {
Text(error)
.foregroundStyle(.red)
.foregroundStyle(.brand)
.font(.footnote)
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity, alignment: .leading)
@@ -69,7 +69,7 @@ struct LoginView: View {
RoundedRectangle(cornerRadius: 14, style: .continuous)
.fill(
LinearGradient(
colors: [Color.red, Color.red.opacity(0.82)],
colors: [Color.brand, Color.brand.opacity(0.82)],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
@@ -107,3 +107,8 @@ struct LoginView: View {
}
}
}
#Preview {
LoginView()
.environment(AuthViewModel())
}
+14 -7
View File
@@ -1,8 +1,8 @@
import SwiftUI
struct RegisterView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@Environment(\.dismiss) var dismiss
@Environment(AuthViewModel.self) private var authViewModel
@Environment(\.dismiss) private var dismiss
@State private var email = ""
@State private var password = ""
@@ -26,7 +26,7 @@ struct RegisterView: View {
.scaledToFit()
.frame(width: 76, height: 76)
.clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
.shadow(color: .red.opacity(0.22), radius: 12, y: 6)
.shadow(color: .brand.opacity(0.22), radius: 12, y: 6)
Text("register_title")
.font(.largeTitle.bold())
@@ -48,21 +48,21 @@ struct RegisterView: View {
if password.count > 0 && password.count < 8 {
Text("password_min_length")
.foregroundStyle(.red)
.foregroundStyle(.brand)
.font(.footnote)
.frame(maxWidth: .infinity, alignment: .leading)
}
if confirmPassword.count > 0 && password != confirmPassword {
Text("passwords_mismatch")
.foregroundStyle(.red)
.foregroundStyle(.brand)
.font(.footnote)
.frame(maxWidth: .infinity, alignment: .leading)
}
if let error = authViewModel.error {
Text(error)
.foregroundStyle(.red)
.foregroundStyle(.brand)
.font(.footnote)
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
@@ -81,7 +81,7 @@ struct RegisterView: View {
RoundedRectangle(cornerRadius: 14, style: .continuous)
.fill(
LinearGradient(
colors: [Color.red, Color.red.opacity(0.82)],
colors: [Color.brand, Color.brand.opacity(0.82)],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
@@ -122,3 +122,10 @@ struct RegisterView: View {
!email.isEmpty && password.count >= 8 && password == confirmPassword
}
}
#Preview {
NavigationStack {
RegisterView()
}
.environment(AuthViewModel())
}
+12 -5
View File
@@ -4,7 +4,7 @@ struct VerifyEmailView: View {
let email: String
let password: String
@EnvironmentObject var authViewModel: AuthViewModel
@Environment(AuthViewModel.self) private var authViewModel
@State private var codeDigits: [String] = Array(repeating: "", count: 6)
@State private var resendCooldown = 0
@State private var focusedIndex: Int?
@@ -40,7 +40,7 @@ struct VerifyEmailView: View {
if let error = authViewModel.error {
Text(error)
.foregroundStyle(.red)
.foregroundStyle(.brand)
.font(.footnote)
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
@@ -65,7 +65,7 @@ struct VerifyEmailView: View {
.scaledToFit()
.frame(width: 72, height: 72)
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
.shadow(color: .red.opacity(0.22), radius: 12, y: 6)
.shadow(color: .brand.opacity(0.22), radius: 12, y: 6)
Text("verify_email_title")
.font(.largeTitle.bold())
@@ -102,7 +102,7 @@ struct VerifyEmailView: View {
}
}
.font(.footnote.weight(.semibold))
.foregroundStyle(resendCooldown > 0 ? Color.secondary : Color.red)
.foregroundStyle(resendCooldown > 0 ? Color.secondary : Color.brand)
.padding(.horizontal, 14)
.padding(.vertical, 8)
.background(Color(.tertiarySystemFill))
@@ -136,7 +136,7 @@ struct VerifyEmailView: View {
RoundedRectangle(cornerRadius: 12, style: .continuous)
.stroke(
focusedIndex == index
? Color.red.opacity(0.9)
? Color.brand.opacity(0.9)
: Color.primary.opacity(0.10),
lineWidth: focusedIndex == index ? 2 : 1
)
@@ -188,3 +188,10 @@ struct VerifyEmailView: View {
}
}
}
#Preview {
NavigationStack {
VerifyEmailView(email: "user@example.com", password: "password123")
}
.environment(AuthViewModel())
}
@@ -2,7 +2,7 @@ import SwiftUI
struct NotificationDetailView: View {
let notificationId: UUID
@ObservedObject var viewModel: NotificationsViewModel
var viewModel: NotificationsViewModel
private var notification: AppNotification? {
viewModel.notifications.first { $0.id == notificationId }
@@ -56,12 +56,12 @@ struct NotificationDetailView: View {
} label: {
Text("mark_as_read")
.font(.headline)
.foregroundStyle(.red)
.foregroundStyle(.brand)
.frame(maxWidth: .infinity)
.padding(.vertical, 14)
.background(
RoundedRectangle(cornerRadius: 16)
.fill(Color.red.opacity(0.1))
.fill(Color.brand.opacity(0.1))
)
}
.padding(.horizontal, 16)
@@ -109,8 +109,8 @@ struct NotificationDetailView: View {
private func statusBadge(for notification: AppNotification) -> some View {
let (text, color): (String, Color) = notification.isRead
? (String(localized: "status_read"), .green)
: (String(localized: "status_new"), .red)
? (String(localized: "status_read"), .success)
: (String(localized: "status_new"), .brand)
return Text(text)
.font(.caption.bold())
.foregroundStyle(color)
@@ -239,3 +239,18 @@ struct NotificationDetailView: View {
}
}
}
#Preview {
let notification = AppNotification(
id: UUID(), userId: UUID(), scopeId: nil, channel: .inApp,
contentType: .plain, templateId: nil, subject: "CPU Usage Critical",
body: "Server load has exceeded 95% for the last 5 minutes. Immediate action is required to prevent service degradation.",
source: "monitoring", metadata: ["severity": "critical", "host": "prod-01", "region": "eu-west-1"],
status: .sent, error: nil, attempts: 1, maxAttempts: 3,
nextRetryAt: nil, sentAt: Date(), readAt: nil, createdAt: Date()
)
let vm = NotificationsViewModel()
NavigationStack {
NotificationDetailView(notification: notification, viewModel: vm)
}
}
@@ -1,18 +1,10 @@
import SwiftUI
struct NotificationsView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@StateObject private var viewModel = NotificationsViewModel()
@Environment(AuthViewModel.self) private var authViewModel
@State private var viewModel = NotificationsViewModel()
@State private var showSettings = false
private var unreadNotifications: [AppNotification] {
viewModel.notifications.filter { !$0.isRead }
}
private var readNotifications: [AppNotification] {
viewModel.notifications.filter { $0.isRead }
}
var body: some View {
NavigationStack {
Group {
@@ -49,7 +41,7 @@ struct NotificationsView: View {
}
.sheet(isPresented: $showSettings) {
SettingsView()
.environmentObject(authViewModel)
.environment(authViewModel)
}
.task {
await viewModel.load()
@@ -64,12 +56,12 @@ struct NotificationsView: View {
}
}
var notificationsList: some View {
private var notificationsList: some View {
ScrollView {
LazyVStack(spacing: 0) {
if !unreadNotifications.isEmpty {
if !viewModel.unreadNotifications.isEmpty {
sectionHeader(String(localized: "notifications_active"))
ForEach(unreadNotifications) { notification in
ForEach(viewModel.unreadNotifications) { notification in
NavigationLink(destination: NotificationDetailView(notification: notification, viewModel: viewModel)) {
ActiveNotificationCard(notification: notification)
}
@@ -85,9 +77,9 @@ struct NotificationsView: View {
}
}
if !readNotifications.isEmpty {
if !viewModel.readNotifications.isEmpty {
sectionHeader(String(localized: "notifications_completed"))
ForEach(readNotifications) { notification in
ForEach(viewModel.readNotifications) { notification in
NavigationLink(destination: NotificationDetailView(notification: notification, viewModel: viewModel)) {
ResolvedNotificationCard(notification: notification)
}
@@ -112,7 +104,7 @@ struct NotificationsView: View {
}
}
func sectionHeader(_ title: String) -> some View {
private func sectionHeader(_ title: String) -> some View {
HStack {
Text(title)
.font(.subheadline)
@@ -127,6 +119,43 @@ struct NotificationsView: View {
}
}
// MARK: - Previews
private extension AppNotification {
static let previewUnread = AppNotification(
id: UUID(), userId: UUID(), scopeId: nil, channel: .inApp,
contentType: .plain, templateId: nil, subject: "CPU Usage Critical",
body: "Server load has exceeded 95% for the last 5 minutes.",
source: "monitoring", metadata: ["severity": "critical"],
status: .sent, error: nil, attempts: 1, maxAttempts: 3,
nextRetryAt: nil, sentAt: Date(), readAt: nil, createdAt: Date()
)
static let previewRead = AppNotification(
id: UUID(), userId: UUID(), scopeId: nil, channel: .inApp,
contentType: .plain, templateId: nil, subject: "Deployment Successful",
body: "Version 2.1.0 has been deployed to production.",
source: "ci/cd", metadata: ["severity": "success"],
status: .read, error: nil, attempts: 1, maxAttempts: 3,
nextRetryAt: nil, sentAt: Date(), readAt: Date(), createdAt: Date().addingTimeInterval(-3600)
)
}
#Preview("Active Card") {
ActiveNotificationCard(notification: .previewUnread)
.padding()
}
#Preview("Resolved Card") {
ResolvedNotificationCard(notification: .previewRead)
.padding()
}
#Preview("Notifications List") {
NotificationsView()
.environment(AuthViewModel())
}
// MARK: - Active (Unread) Card
struct ActiveNotificationCard: View {
@@ -166,7 +195,7 @@ struct ActiveNotificationCard: View {
Spacer()
Text("open_button")
.font(.subheadline.bold())
.foregroundStyle(Color.red)
.foregroundStyle(Color.brand)
.padding(.horizontal, 32)
.padding(.vertical, 10)
.background(Color(.systemBackground))
@@ -177,13 +206,13 @@ struct ActiveNotificationCard: View {
.padding(16)
.background(
LinearGradient(
colors: [Color.red, Color.red.opacity(0.85)],
colors: [Color.brand, Color.brand.opacity(0.85)],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
)
.clipShape(RoundedRectangle(cornerRadius: 20))
.shadow(color: .red.opacity(0.3), radius: 8, y: 4)
.shadow(color: .brand.opacity(0.3), radius: 8, y: 4)
}
}
@@ -231,7 +260,7 @@ struct ResolvedNotificationCard: View {
HStack(spacing: 4) {
Image(systemName: "checkmark")
.font(.caption2)
.foregroundStyle(.green)
.foregroundStyle(.success)
Text("notification_read_at \(readAt.formatted(date: .abbreviated, time: .shortened))")
.font(.caption)
.foregroundStyle(.secondary)
+66 -14
View File
@@ -1,46 +1,98 @@
import SwiftUI
struct ChangePasswordView: View {
@StateObject private var viewModel = SettingsViewModel()
@Environment(\.dismiss) var dismiss
var viewModel: SettingsViewModel
@Environment(\.dismiss) private var dismiss
@State private var currentPassword = ""
@State private var newPassword = ""
@State private var confirmPassword = ""
private var isFormInvalid: Bool {
!isFormValid || viewModel.isLoading
}
private var isFormValid: Bool {
!currentPassword.isEmpty && newPassword.count >= 8 && newPassword == confirmPassword
}
var body: some View {
NavigationStack {
Form {
Section {
SecureField("current_password", text: $currentPassword)
VStack(spacing: 12) {
AppSecureField(
title: "current_password",
icon: "lock.fill",
text: $currentPassword
)
.textContentType(.password)
SecureField("new_password", text: $newPassword)
AppSecureField(
title: "new_password",
icon: "key.fill",
text: $newPassword
)
.textContentType(.newPassword)
SecureField("confirm_new_password", text: $confirmPassword)
AppSecureField(
title: "confirm_new_password",
icon: "lock.rotation",
text: $confirmPassword
)
.textContentType(.newPassword)
}
.padding(.vertical, 4)
}
if newPassword.count > 0 && newPassword.count < 8 {
Section {
Text("password_min_length")
.foregroundStyle(.brand)
.font(.footnote)
}
}
if confirmPassword.count > 0 && newPassword != confirmPassword {
Section {
Text("passwords_mismatch")
.foregroundStyle(.brand)
.font(.footnote)
}
}
if let error = viewModel.error {
Section {
Text(error).foregroundStyle(.red)
Text(error)
.foregroundStyle(.brand)
.font(.footnote)
}
}
if let success = viewModel.successMessage {
Section {
Text(success).foregroundStyle(.green)
Text(success)
.foregroundStyle(.success)
.font(.footnote)
}
}
Section {
Button("save_button") {
Button {
Task {
let success = await viewModel.changePassword(current: currentPassword, new: newPassword)
if success { dismiss() }
}
} label: {
if viewModel.isLoading {
ProgressView()
.frame(maxWidth: .infinity)
} else {
Text("save_button")
.frame(maxWidth: .infinity)
}
}
.disabled(!isFormValid || viewModel.isLoading)
.frame(maxWidth: .infinity)
.disabled(isFormInvalid)
}
}
.navigationTitle("change_password_title")
@@ -52,8 +104,8 @@ struct ChangePasswordView: View {
}
}
}
var isFormValid: Bool {
!currentPassword.isEmpty && newPassword.count >= 8 && newPassword == confirmPassword
}
}
#Preview {
ChangePasswordView(viewModel: SettingsViewModel())
}
+8 -4
View File
@@ -1,8 +1,8 @@
import SwiftUI
struct SessionsView: View {
@EnvironmentObject var viewModel: SettingsViewModel
@Environment(\.dismiss) var dismiss
var viewModel: SettingsViewModel
@Environment(\.dismiss) private var dismiss
var body: some View {
NavigationStack {
@@ -18,8 +18,8 @@ struct SessionsView: View {
.font(.caption)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(Color.green.opacity(0.2))
.foregroundStyle(.green)
.background(Color.success.opacity(0.2))
.foregroundStyle(.success)
.cornerRadius(4)
}
}
@@ -51,3 +51,7 @@ struct SessionsView: View {
}
}
}
#Preview {
SessionsView(viewModel: SettingsViewModel())
}
+19 -16
View File
@@ -1,13 +1,14 @@
import SwiftUI
struct SettingsView: View {
@EnvironmentObject var authViewModel: AuthViewModel
@StateObject private var viewModel = SettingsViewModel()
@Environment(\.dismiss) var dismiss
@Environment(AuthViewModel.self) private var authViewModel
@State private var viewModel = SettingsViewModel()
@Environment(\.dismiss) private var dismiss
@State private var showChangePassword = false
@State private var showSessions = false
@State private var showLogoutAllConfirm = false
@State private var logoutAllError: String?
@State private var showLogoutAllError = false
var body: some View {
NavigationStack {
@@ -19,9 +20,12 @@ struct SettingsView: View {
}
Section {
Button("change_password") {
Button {
showChangePassword = true
} label: {
Text("change_password")
}
.tint(.primary)
Button {
if let url = URL(string: UIApplication.openNotificationSettingsURLString) {
@@ -29,8 +33,8 @@ struct SettingsView: View {
}
} label: {
Label("push_notifications", systemImage: "bell.badge")
.foregroundStyle(.primary)
}
.tint(.primary)
}
Section {
@@ -48,7 +52,7 @@ struct SettingsView: View {
.foregroundStyle(.secondary)
}
}
.foregroundStyle(.primary)
.tint(.primary)
}
Section {
@@ -71,6 +75,7 @@ struct SettingsView: View {
await authViewModel.logout()
} catch {
logoutAllError = error.localizedDescription
showLogoutAllError = true
}
}
}
@@ -86,19 +91,12 @@ struct SettingsView: View {
}
}
.sheet(isPresented: $showChangePassword) {
ChangePasswordView()
ChangePasswordView(viewModel: viewModel)
}
.sheet(isPresented: $showSessions) {
SessionsView()
.environmentObject(viewModel)
SessionsView(viewModel: viewModel)
}
.alert(
"error_title",
isPresented: Binding(
get: { logoutAllError != nil },
set: { if !$0 { logoutAllError = nil } }
)
) {
.alert("error_title", isPresented: $showLogoutAllError) {
Button("OK") { logoutAllError = nil }
} message: {
Text(logoutAllError ?? "")
@@ -109,3 +107,8 @@ struct SettingsView: View {
}
}
}
#Preview {
SettingsView()
.environment(AuthViewModel())
}
+1 -1
View File
@@ -4,7 +4,7 @@ struct AppBackgroundModifier: ViewModifier {
func body(content: Content) -> some View {
content.background(
LinearGradient(
colors: [Color(.systemGroupedBackground), Color.red.opacity(0.08)],
colors: [Color(.systemGroupedBackground), Color.brand.opacity(0.08)],
startPoint: .top,
endPoint: .bottom
)
+15
View File
@@ -0,0 +1,15 @@
import SwiftUI
extension Color {
static let brand = Color("Brand")
static let success = Color("Success")
static let warning = Color("Warning")
static let info = Color("Info")
}
extension ShapeStyle where Self == Color {
static var brand: Color { .brand }
static var success: Color { .success }
static var warning: Color { .warning }
static var info: Color { .info }
}
+5
View File
@@ -23,3 +23,8 @@ struct AppSecureField: View {
)
}
}
#Preview {
AppSecureField(title: "Password", icon: "lock.fill", text: .constant(""))
.padding()
}
+5
View File
@@ -23,3 +23,8 @@ struct AppTextField: View {
)
}
}
#Preview {
AppTextField(title: "Email", icon: "envelope.fill", text: .constant("user@example.com"))
.padding()
}
+14 -4
View File
@@ -17,10 +17,10 @@ enum NotificationSeverity: String {
var color: Color {
switch self {
case .critical: return .red
case .warning: return .orange
case .info: return .blue
case .success: return .green
case .critical: return .brand
case .warning: return .warning
case .info: return .info
case .success: return .success
}
}
@@ -45,3 +45,13 @@ struct NotificationIconView: View {
}
}
}
#Preview {
HStack(spacing: 16) {
NotificationIconView(severity: .critical, isActive: true)
NotificationIconView(severity: .warning, isActive: false)
NotificationIconView(severity: .info, isActive: false)
NotificationIconView(severity: .success, isActive: false)
}
.padding()
}