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,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>MaydayLiveActivity</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,9 @@
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct MaydayLiveActivityBundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
MaydayLiveActivityLiveActivity()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import ActivityKit
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
struct MaydayLiveActivityLiveActivity: Widget {
|
||||
var body: some WidgetConfiguration {
|
||||
ActivityConfiguration(for: AlertAttributes.self) { context in
|
||||
// Lock Screen / Notification Center
|
||||
lockScreenView(context: context)
|
||||
.activityBackgroundTint(severityColor(context.attributes.severity).opacity(0.15))
|
||||
.activitySystemActionForegroundColor(.primary)
|
||||
} dynamicIsland: { context in
|
||||
DynamicIsland {
|
||||
DynamicIslandExpandedRegion(.leading) {
|
||||
Label(context.attributes.topic, systemImage: "exclamationmark.triangle.fill")
|
||||
.font(.caption)
|
||||
.foregroundStyle(severityColor(context.attributes.severity))
|
||||
}
|
||||
DynamicIslandExpandedRegion(.trailing) {
|
||||
if let value = context.state.value {
|
||||
Text(value)
|
||||
.font(.caption.bold())
|
||||
.foregroundStyle(severityColor(context.attributes.severity))
|
||||
}
|
||||
}
|
||||
DynamicIslandExpandedRegion(.bottom) {
|
||||
HStack {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(context.state.title)
|
||||
.font(.subheadline.bold())
|
||||
Text("Начало: \(context.state.startedAt.formatted(date: .omitted, time: .shortened))")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
Spacer()
|
||||
VStack(alignment: .trailing, spacing: 2) {
|
||||
statusBadge(context.state.status)
|
||||
Text("Длит.: \(duration(from: context.state.startedAt))")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
} compactLeading: {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(severityColor(context.attributes.severity))
|
||||
} compactTrailing: {
|
||||
let shortTopic = context.attributes.topic.components(separatedBy: "/").last ?? context.attributes.topic
|
||||
let valueText = context.state.value.map { " · \($0)" } ?? ""
|
||||
Text("\(shortTopic)\(valueText)")
|
||||
.font(.caption2)
|
||||
.lineLimit(1)
|
||||
} minimal: {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.foregroundStyle(severityColor(context.attributes.severity))
|
||||
}
|
||||
.keylineTint(severityColor(context.attributes.severity))
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func lockScreenView(context: ActivityViewContext<AlertAttributes>) -> some View {
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: "exclamationmark.triangle.fill")
|
||||
.font(.title2)
|
||||
.foregroundStyle(severityColor(context.attributes.severity))
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
Text(context.attributes.topic)
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
Text(context.state.title)
|
||||
.font(.subheadline.bold())
|
||||
if let value = context.state.value {
|
||||
Text(value)
|
||||
.font(.caption)
|
||||
.foregroundStyle(severityColor(context.attributes.severity))
|
||||
}
|
||||
Text(context.state.startedAt.relativeFormatted)
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
statusBadge(context.state.status)
|
||||
}
|
||||
.padding()
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
func statusBadge(_ status: AlertStatus) -> some View {
|
||||
let (text, color): (String, Color) = status == .active
|
||||
? ("active", .red)
|
||||
: ("resolved", .green)
|
||||
Text(text)
|
||||
.font(.caption2.bold())
|
||||
.padding(.horizontal, 6)
|
||||
.padding(.vertical, 2)
|
||||
.background(color.opacity(0.2))
|
||||
.foregroundStyle(color)
|
||||
.cornerRadius(4)
|
||||
}
|
||||
|
||||
func severityColor(_ severity: Severity) -> Color {
|
||||
switch severity {
|
||||
case .critical: return .red
|
||||
case .warning: return .yellow
|
||||
case .info: return .blue
|
||||
}
|
||||
}
|
||||
|
||||
func duration(from startDate: Date) -> String {
|
||||
let interval = Date().timeIntervalSince(startDate)
|
||||
let minutes = Int(interval / 60)
|
||||
let hours = minutes / 60
|
||||
if hours > 0 {
|
||||
return "\(hours)ч \(minutes % 60)м"
|
||||
}
|
||||
return "\(minutes)м"
|
||||
}
|
||||
}
|
||||
|
||||
extension Date {
|
||||
var relativeFormatted: String {
|
||||
let formatter = RelativeDateTimeFormatter()
|
||||
formatter.locale = Locale(identifier: "ru_RU")
|
||||
return formatter.localizedString(for: self, relativeTo: Date())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user