iOS_app_test/tg_test/ExtraViews.swift
2026-09-24 14:06:21 +08:00

276 lines
10 KiB
Swift

//
// ExtraViews.swift
// tg_test
//
import SwiftUI
// MARK: - Analytics View
struct AnalyticsView: View {
private let metrics = [
("Daily Active Users", "12.4K", "+18%", Color.green),
("Avg. Session Time", "8m 42s", "+5%", Color.blue),
("Retention Rate", "68.2%", "+2.4%", Color.purple),
("Conversion Rate", "4.15%", "-0.8%", Color.orange)
]
var body: some View {
NavigationStack {
ScrollView {
VStack(alignment: .leading, spacing: 16) {
Text("Overview Highlights")
.font(.headline)
.padding(.horizontal)
LazyVGrid(columns: [GridItem(.flexible()), GridItem(.flexible())], spacing: 12) {
ForEach(metrics, id: \.0) { item in
VStack(alignment: .leading, spacing: 8) {
Text(item.0)
.font(.caption)
.foregroundStyle(.secondary)
Text(item.1)
.font(.title2)
.bold()
Text(item.2)
.font(.caption)
.bold()
.foregroundStyle(item.3)
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
.background(Color(.secondarySystemBackground))
.clipShape(RoundedRectangle(cornerRadius: 12))
}
}
.padding(.horizontal)
VStack(alignment: .leading, spacing: 12) {
Text("Performance Chart")
.font(.headline)
RoundedRectangle(cornerRadius: 12)
.fill(LinearGradient(colors: [.blue.opacity(0.6), .purple.opacity(0.6)], startPoint: .topLeading, endPoint: .bottomTrailing))
.frame(height: 180)
.overlay(
Image(systemName: "waveform.path.ecg")
.font(.system(size: 70))
.foregroundStyle(.white.opacity(0.8))
)
}
.padding(.horizontal)
}
.padding(.top)
}
.navigationTitle("Analytics")
}
}
}
// MARK: - Messages View
struct MessagesView: View {
struct Chat: Identifiable {
let id = UUID()
let name: String
let message: String
let time: String
let unread: Bool
}
private let chats = [
Chat(name: "Sarah Connor", message: "Hey, did you review the latest wheel UI?", time: "10:42 AM", unread: true),
Chat(name: "Tech Team", message: "Deployment complete for v1.0.4", time: "09:15 AM", unread: true),
Chat(name: "Alex Rivera", message: "See you at the meeting tomorrow!", time: "Yesterday", unread: false),
Chat(name: "Design Guild", message: "New Figma mockups are uploaded.", time: "Tuesday", unread: false)
]
var body: some View {
NavigationStack {
List(chats) { chat in
HStack(spacing: 12) {
Circle()
.fill(chat.unread ? Color.teal : Color.gray.opacity(0.3))
.frame(width: 44, height: 44)
.overlay(
Text(String(chat.name.prefix(1)))
.font(.headline)
.foregroundStyle(chat.unread ? .white : .primary)
)
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(chat.name)
.font(.headline)
Spacer()
Text(chat.time)
.font(.caption)
.foregroundStyle(.secondary)
}
Text(chat.message)
.font(.subheadline)
.foregroundStyle(chat.unread ? .primary : .secondary)
.lineLimit(1)
}
}
.padding(.vertical, 4)
}
.navigationTitle("Messages")
}
}
}
// MARK: - Favorites View
struct FavoritesView: View {
private let favoriteItems = [
("SwiftUI Wheel Navigation", "UI Component", "star.fill", Color.yellow),
("Async/Await Best Practices", "Article", "doc.text.fill", Color.blue),
("Color Schemes & Typography", "Guide", "paintpalette.fill", Color.purple),
("Custom Canvas Rendering", "Tutorial", "paintbrush.fill", Color.pink)
]
var body: some View {
NavigationStack {
List(favoriteItems, id: \.0) { item in
HStack(spacing: 14) {
Image(systemName: item.2)
.font(.title2)
.foregroundStyle(item.3)
.frame(width: 36)
VStack(alignment: .leading, spacing: 4) {
Text(item.0)
.font(.headline)
Text(item.1)
.font(.subheadline)
.foregroundStyle(.secondary)
}
Spacer()
Image(systemName: "heart.fill")
.foregroundStyle(.pink)
}
.padding(.vertical, 4)
}
.navigationTitle("Favorites")
}
}
}
// MARK: - Downloads View
struct DownloadsView: View {
var body: some View {
NavigationStack {
VStack(spacing: 20) {
Spacer()
Image(systemName: "arrow.down.circle.fill")
.font(.system(size: 70))
.foregroundStyle(.cyan)
Text("No Active Downloads")
.font(.title2)
.bold()
Text("Files you download will show up here for offline access.")
.font(.body)
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
.padding(.horizontal, 40)
Button(action: {}) {
Label("Explore Content", systemImage: "sparkles")
.font(.headline)
.padding()
.background(Color.cyan)
.foregroundStyle(.white)
.clipShape(Capsule())
}
Spacer()
}
.navigationTitle("Downloads")
}
}
}
// MARK: - Cloud View
struct CloudView: View {
var body: some View {
NavigationStack {
List {
Section("Storage Usage") {
VStack(alignment: .leading, spacing: 8) {
HStack {
Text("Cloud Storage")
.font(.headline)
Spacer()
Text("42.5 GB / 100 GB")
.font(.subheadline)
.foregroundStyle(.secondary)
}
ProgressView(value: 0.425)
.tint(.blue)
}
.padding(.vertical, 4)
}
Section("Synced Repositories") {
Label("iOS App Test Project", systemImage: "folder.fill")
Label("Design Assets 2026", systemImage: "photo.on.rectangle.angled")
Label("User Data Backups", systemImage: "internaldrive.fill")
}
}
.navigationTitle("Cloud")
}
}
}
// MARK: - Settings View
struct SettingsView: View {
@State private var autoSync = true
@State private var hapticFeedback = true
@State private var wheelSpeed = 1.0
var body: some View {
NavigationStack {
Form {
Section("Navigation Wheel Settings") {
Toggle("Haptic Feedback", isOn: $hapticFeedback)
Toggle("Auto Sync Selection", isOn: $autoSync)
}
Section("App Preferences") {
HStack {
Text("Theme Color")
Spacer()
Text("Dynamic")
.foregroundStyle(.secondary)
}
}
}
.navigationTitle("Settings")
}
}
}
// MARK: - Help View
struct HelpView: View {
var body: some View {
NavigationStack {
List {
Section("Frequent Questions") {
DisclosureGroup("How do I use the wheel nav bar?") {
Text("Swipe horizontally on the bottom dial or tap any icon to switch pages instantly. You can also tap the left/right arrows for step-by-step navigation.")
.font(.subheadline)
.foregroundStyle(.secondary)
.padding(.vertical, 4)
}
DisclosureGroup("How many pages can the wheel hold?") {
Text("The wheel supports virtually unlimited pages! Drag left or right to scroll smoothly through 10, 11, or more pages.")
.font(.subheadline)
.foregroundStyle(.secondary)
.padding(.vertical, 4)
}
}
}
.navigationTitle("Help & Support")
}
}
}