|
| 1 | +import SwiftUI |
| 2 | + |
| 3 | +struct WelcomeView: View { |
| 4 | + let onOpen: () -> Void |
| 5 | + let onClone: () -> Void |
| 6 | + |
| 7 | + var body: some View { |
| 8 | + VStack(spacing: DesignTokens.Spacing.xxl) { |
| 9 | + Spacer() |
| 10 | + |
| 11 | + // App Icon |
| 12 | + Image(systemName: "arrow.triangle.branch") |
| 13 | + .font(.system(size: 80, weight: .light)) |
| 14 | + .foregroundColor(AppTheme.accent) |
| 15 | + |
| 16 | + // Welcome text |
| 17 | + VStack(spacing: DesignTokens.Spacing.sm) { |
| 18 | + Text("Welcome to GitMac") |
| 19 | + .font(.largeTitle) |
| 20 | + .fontWeight(.bold) |
| 21 | + .foregroundColor(AppTheme.textPrimary) |
| 22 | + |
| 23 | + Text("A modern Git client for macOS") |
| 24 | + .font(.title3) |
| 25 | + .foregroundColor(AppTheme.textSecondary) |
| 26 | + } |
| 27 | + |
| 28 | + // Action buttons |
| 29 | + HStack(spacing: DesignTokens.Spacing.lg) { |
| 30 | + WelcomeButton( |
| 31 | + title: "Open Repository", |
| 32 | + icon: "folder", |
| 33 | + action: onOpen |
| 34 | + ) |
| 35 | + |
| 36 | + WelcomeButton( |
| 37 | + title: "Clone Repository", |
| 38 | + icon: "arrow.down.circle", |
| 39 | + action: onClone |
| 40 | + ) |
| 41 | + } |
| 42 | + |
| 43 | + Spacer() |
| 44 | + |
| 45 | + // Recent repositories |
| 46 | + RecentRepositoriesSection() |
| 47 | + } |
| 48 | + .frame(maxWidth: .infinity, maxHeight: .infinity) |
| 49 | + .background(AppTheme.background) |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +struct WelcomeButton: View { |
| 54 | + let title: String |
| 55 | + let icon: String |
| 56 | + let action: () -> Void |
| 57 | + |
| 58 | + var body: some View { |
| 59 | + Button(action: action) { |
| 60 | + VStack(spacing: DesignTokens.Spacing.sm) { |
| 61 | + Image(systemName: icon) |
| 62 | + .font(.system(size: 32)) |
| 63 | + .foregroundColor(AppTheme.accent) |
| 64 | + |
| 65 | + Text(title) |
| 66 | + .font(.headline) |
| 67 | + .foregroundColor(AppTheme.textPrimary) |
| 68 | + } |
| 69 | + .frame(width: 160, height: 100) |
| 70 | + .background(AppTheme.backgroundSecondary) |
| 71 | + .cornerRadius(DesignTokens.CornerRadius.lg) |
| 72 | + } |
| 73 | + .buttonStyle(.plain) |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +struct RecentRepositoriesSection: View { |
| 78 | + @EnvironmentObject var recentReposManager: RecentRepositoriesManager |
| 79 | + @EnvironmentObject var appState: AppState |
| 80 | + |
| 81 | + var body: some View { |
| 82 | + VStack(alignment: .leading, spacing: DesignTokens.Spacing.md) { |
| 83 | + Text("Recent Repositories") |
| 84 | + .font(.headline) |
| 85 | + .foregroundColor(AppTheme.textSecondary) |
| 86 | + |
| 87 | + if recentReposManager.recentRepos.isEmpty { |
| 88 | + Text("No recent repositories") |
| 89 | + .font(.subheadline) |
| 90 | + .foregroundColor(AppTheme.textMuted) |
| 91 | + .padding(.vertical, DesignTokens.Spacing.lg) |
| 92 | + } else { |
| 93 | + ForEach(recentReposManager.recentRepos.prefix(5), id: \.path) { repo in |
| 94 | + RecentRepoRow(repo: repo) |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | + .padding(DesignTokens.Spacing.lg) |
| 99 | + .frame(width: 400) |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +struct RecentRepoRow: View { |
| 104 | + let repo: RecentRepository |
| 105 | + @EnvironmentObject var appState: AppState |
| 106 | + @State private var isHovered = false |
| 107 | + |
| 108 | + var body: some View { |
| 109 | + Button { |
| 110 | + Task { |
| 111 | + await appState.openRepository(at: repo.path) |
| 112 | + } |
| 113 | + } label: { |
| 114 | + HStack(spacing: DesignTokens.Spacing.md) { |
| 115 | + Image(systemName: "folder.fill") |
| 116 | + .font(.system(size: 20)) |
| 117 | + .foregroundColor(AppTheme.accent) |
| 118 | + |
| 119 | + VStack(alignment: .leading, spacing: 2) { |
| 120 | + Text(repo.name) |
| 121 | + .font(.system(size: 13, weight: .medium)) |
| 122 | + .foregroundColor(AppTheme.textPrimary) |
| 123 | + .lineLimit(1) |
| 124 | + |
| 125 | + Text(repo.path) |
| 126 | + .font(.caption) |
| 127 | + .foregroundColor(AppTheme.textMuted) |
| 128 | + .lineLimit(1) |
| 129 | + } |
| 130 | + |
| 131 | + Spacer() |
| 132 | + |
| 133 | + Text(repo.lastOpened, style: .relative) |
| 134 | + .font(.caption2) |
| 135 | + .foregroundColor(AppTheme.textMuted) |
| 136 | + } |
| 137 | + .padding(.horizontal, DesignTokens.Spacing.md) |
| 138 | + .padding(.vertical, DesignTokens.Spacing.sm) |
| 139 | + .background(isHovered ? AppTheme.hover : Color.clear) |
| 140 | + .cornerRadius(DesignTokens.CornerRadius.md) |
| 141 | + } |
| 142 | + .buttonStyle(.plain) |
| 143 | + .onHover { isHovered = $0 } |
| 144 | + } |
| 145 | +} |
0 commit comments