feat: add complete Mayday iOS Xcode project
- Swift 6, SwiftUI, MVVM + async/await architecture - iOS 17.0 minimum deployment target - Two targets: Mayday app + MaydayLiveActivity widget extension - Models: UserResponse, TokenPair, AppNotification, SessionResponse, AlertAttributes - Services: HTTPClient (actor), AuthService, KeychainService, NotificationsAPIService, PushNotificationService - ViewModels: AuthViewModel, NotificationsViewModel, SettingsViewModel - Views: Login/Register/VerifyEmail, NotificationsList/Detail, Settings/ChangePassword/Sessions - APNs push notifications with UIApplicationDelegate - ActivityKit Live Activities for Dynamic Island + Lock Screen - Keychain (Security framework) token storage - 30-second polling with pagination for notifications - Xcode project file (project.pbxproj) with correct build phases for both targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import ActivityKit
|
||||
import Foundation
|
||||
|
||||
struct AlertAttributes: ActivityAttributes {
|
||||
let topic: String
|
||||
let alertId: String
|
||||
let severity: Severity
|
||||
|
||||
struct ContentState: Codable, Hashable {
|
||||
let title: String
|
||||
let value: String?
|
||||
let status: AlertStatus
|
||||
let startedAt: Date
|
||||
let updatedAt: Date
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case title, value, status
|
||||
case startedAt = "startedAt"
|
||||
case updatedAt = "updatedAt"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum Severity: String, Codable, Hashable {
|
||||
case critical
|
||||
case warning
|
||||
case info
|
||||
|
||||
var color: String {
|
||||
switch self {
|
||||
case .critical: return "red"
|
||||
case .warning: return "yellow"
|
||||
case .info: return "blue"
|
||||
}
|
||||
}
|
||||
|
||||
var emoji: String {
|
||||
switch self {
|
||||
case .critical: return "🔴"
|
||||
case .warning: return "🟡"
|
||||
case .info: return "🔵"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum AlertStatus: String, Codable, Hashable {
|
||||
case active
|
||||
case resolved
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import Foundation
|
||||
|
||||
struct AppNotification: Codable, Identifiable {
|
||||
let id: UUID
|
||||
let topic: String
|
||||
let subject: String
|
||||
let body: String
|
||||
let metadata: [String: String]?
|
||||
let status: NotificationStatus
|
||||
let channel: NotificationChannel
|
||||
let readAt: Date?
|
||||
let createdAt: Date
|
||||
let updatedAt: Date
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, topic, subject, body, metadata, status, channel
|
||||
case readAt = "read_at"
|
||||
case createdAt = "created_at"
|
||||
case updatedAt = "updated_at"
|
||||
}
|
||||
|
||||
var isRead: Bool { readAt != nil }
|
||||
}
|
||||
|
||||
enum NotificationStatus: String, Codable {
|
||||
case sent
|
||||
case delivered
|
||||
case read
|
||||
}
|
||||
|
||||
enum NotificationChannel: String, Codable {
|
||||
case inApp = "in_app"
|
||||
case push
|
||||
case email
|
||||
}
|
||||
|
||||
struct NotificationsPage: Codable {
|
||||
let items: [AppNotification]
|
||||
let total: Int
|
||||
let page: Int
|
||||
let perPage: Int
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case items, total, page
|
||||
case perPage = "per_page"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import Foundation
|
||||
|
||||
struct SessionResponse: Codable, Identifiable {
|
||||
let id: UUID
|
||||
let userAgent: String
|
||||
let ipAddress: String
|
||||
let isCurrent: Bool
|
||||
let createdAt: Date
|
||||
let expiresAt: Date
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case userAgent = "user_agent"
|
||||
case ipAddress = "ip_address"
|
||||
case isCurrent = "is_current"
|
||||
case createdAt = "created_at"
|
||||
case expiresAt = "expires_at"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import Foundation
|
||||
|
||||
struct TokenPair: Codable {
|
||||
let accessToken: String
|
||||
let refreshToken: String
|
||||
let expiresAt: Date
|
||||
let tokenType: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case accessToken = "access_token"
|
||||
case refreshToken = "refresh_token"
|
||||
case expiresAt = "expires_at"
|
||||
case tokenType = "token_type"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import Foundation
|
||||
|
||||
struct UserResponse: Codable, Identifiable {
|
||||
let id: UUID
|
||||
let email: String
|
||||
let status: UserStatus
|
||||
let metadata: [String: AnyCodable]?
|
||||
let emailVerifiedAt: Date?
|
||||
let roles: [String]
|
||||
let createdAt: Date
|
||||
let updatedAt: Date
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, email, status, metadata, roles
|
||||
case emailVerifiedAt = "email_verified_at"
|
||||
case createdAt = "created_at"
|
||||
case updatedAt = "updated_at"
|
||||
}
|
||||
}
|
||||
|
||||
enum UserStatus: String, Codable {
|
||||
case pending
|
||||
case active
|
||||
case suspended
|
||||
case deleted
|
||||
}
|
||||
|
||||
// Helper for Any JSON values
|
||||
struct AnyCodable: Codable {
|
||||
let value: Any
|
||||
|
||||
init(_ value: Any) {
|
||||
self.value = value
|
||||
}
|
||||
|
||||
init(from decoder: Decoder) throws {
|
||||
let container = try decoder.singleValueContainer()
|
||||
if let int = try? container.decode(Int.self) {
|
||||
value = int
|
||||
} else if let double = try? container.decode(Double.self) {
|
||||
value = double
|
||||
} else if let bool = try? container.decode(Bool.self) {
|
||||
value = bool
|
||||
} else if let string = try? container.decode(String.self) {
|
||||
value = string
|
||||
} else {
|
||||
value = ""
|
||||
}
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
switch value {
|
||||
case let int as Int: try container.encode(int)
|
||||
case let double as Double: try container.encode(double)
|
||||
case let bool as Bool: try container.encode(bool)
|
||||
case let string as String: try container.encode(string)
|
||||
default: try container.encode("")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user