Files
mayday/Mayday/Views/Settings/SessionsView.swift
T
copilot-swe-agent[bot] 1eb21c71ce 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>
2026-03-13 23:04:35 +00:00

54 lines
2.1 KiB
Swift

import SwiftUI
struct SessionsView: View {
@EnvironmentObject var viewModel: SettingsViewModel
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
List {
ForEach(viewModel.sessions) { session in
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(session.userAgent)
.font(.body)
.lineLimit(1)
if session.isCurrent {
Text("Текущая")
.font(.caption)
.padding(.horizontal, 6)
.padding(.vertical, 2)
.background(Color.green.opacity(0.2))
.foregroundStyle(.green)
.cornerRadius(4)
}
}
Text(session.ipAddress)
.font(.caption)
.foregroundStyle(.secondary)
Text("Создана: \(session.createdAt.formatted(date: .abbreviated, time: .shortened))")
.font(.caption2)
.foregroundStyle(.secondary)
}
.swipeActions(edge: .trailing) {
if !session.isCurrent {
Button(role: .destructive) {
Task { await viewModel.deleteSession(session) }
} label: {
Label("Удалить", systemImage: "trash")
}
}
}
}
}
.navigationTitle("Активные сессии")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Готово") { dismiss() }
}
}
}
}
}