Ariver
2026-06-28 755ca63e4d37c1a54db7fc6475152319a4e46ceb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import SwiftUI
 
enum ProStatusPillStyle {
    case locked
    case preview
    case unlocked
    case legacy
    case neutral
}
 
struct ProStatusPill: View {
    let text: String
    let style: ProStatusPillStyle
    var compact = false
 
    var body: some View {
        HStack(spacing: compact ? 4 : 5) {
            if showsCrown {
                Image(systemName: "crown.fill")
                    .font(.system(size: compact ? 9 : 10, weight: .bold))
            }
 
            Text(text)
        }
            .font(.system(size: compact ? 10 : 11, weight: .semibold))
            .foregroundStyle(foregroundColor)
            .lineLimit(1)
            .padding(.horizontal, compact ? 8 : 10)
            .padding(.vertical, compact ? 4 : 5)
            .background(
                Capsule(style: .continuous)
                    .fill(backgroundColor)
            )
            .overlay(
                Capsule(style: .continuous)
                    .stroke(strokeColor, lineWidth: 1)
            )
    }
 
    private var foregroundColor: Color {
        switch style {
        case .locked:
            return Color(red: 0.56, green: 0.35, blue: 0.03)
        case .preview:
            return Color(red: 0.30, green: 0.22, blue: 0.08)
        case .unlocked, .legacy:
            return Color(red: 0.56, green: 0.35, blue: 0.03)
        case .neutral:
            return .secondary
        }
    }
 
    private var backgroundColor: Color {
        switch style {
        case .locked:
            return Color(red: 1.0, green: 0.78, blue: 0.22).opacity(0.18)
        case .preview:
            return Color.orange.opacity(0.14)
        case .unlocked, .legacy:
            return Color(red: 1.0, green: 0.78, blue: 0.22).opacity(0.18)
        case .neutral:
            return Color.secondary.opacity(0.10)
        }
    }
 
    private var strokeColor: Color {
        switch style {
        case .locked:
            return Color(red: 0.93, green: 0.62, blue: 0.10).opacity(0.42)
        case .preview:
            return Color.orange.opacity(0.28)
        case .unlocked, .legacy:
            return Color(red: 0.93, green: 0.62, blue: 0.10).opacity(0.42)
        case .neutral:
            return Color.secondary.opacity(0.18)
        }
    }
 
    private var showsCrown: Bool {
        switch style {
        case .locked, .unlocked, .legacy:
            return text.localizedCaseInsensitiveContains("Pro")
        case .preview, .neutral:
            return false
        }
    }
}
 
extension ProFeature {
    var promptMessageKey: String {
        switch self {
        case .premiumThemes:
            return "pro.prompt.themes"
        case .layoutImport:
            return "pro.prompt.import"
        case .layoutExport:
            return "pro.prompt.export"
        case .unlimitedNotes:
            return "pro.prompt.notes"
        case .persistentAppSorting:
            return "pro.prompt.sorting"
        }
    }
}
 
extension ProOperationState {
    var statusMessageKey: String? {
        switch self {
        case .idle:
            return nil
        case .loading:
            return "pro.operation.loading"
        case .purchasing:
            return "pro.operation.purchasing"
        case .restoring:
            return "pro.operation.restoring"
        case .pending:
            return "pro.operation.pending"
        case .cancelled:
            return "pro.operation.cancelled"
        case .restoreNotFound:
            return "pro.operation.restoreNotFound"
        case .failed(let messageKey):
            return messageKey
        }
    }
}
 
struct ProUpgradePromptView: View {
    let title: String
    let message: String
    let benefitText: String
    let operationText: String?
    let unlockTitle: String
    let restoreTitle: String
    let isBusy: Bool
    let onClose: () -> Void
    let onUnlock: () -> Void
    let onRestore: () -> Void
 
    var body: some View {
        VStack(alignment: .leading, spacing: 0) {
            HStack(alignment: .top, spacing: 12) {
                VStack(alignment: .leading, spacing: 10) {
                    HStack(spacing: 8) {
                        Text(title)
                            .font(.system(size: 26, weight: .bold))
                            .foregroundStyle(.primary)
                        ProStatusPill(text: tr("pro.card.badge"), style: .locked)
                    }
 
                    Text(message)
                        .font(.system(size: 14, weight: .medium))
                        .foregroundStyle(Color.primary.opacity(0.78))
                        .lineSpacing(2)
                        .fixedSize(horizontal: false, vertical: true)
                }
 
                Spacer(minLength: 16)
 
                Button(action: onClose) {
                    Image(systemName: "xmark")
                        .font(.system(size: 12, weight: .bold))
                        .foregroundStyle(.secondary)
                        .frame(width: 28, height: 28)
                        .background(
                            Circle()
                                .fill(Color.primary.opacity(0.08))
                        )
                }
                .buttonStyle(.plain)
                .help(tr("settings.cancel"))
            }
 
            HStack(alignment: .top, spacing: 10) {
                Image(systemName: "sparkles")
                    .font(.system(size: 14, weight: .semibold))
                    .foregroundStyle(Color.accentColor)
                    .frame(width: 18, height: 18)
                Text(benefitText)
                    .font(.system(size: 13, weight: .medium))
                    .foregroundStyle(Color.primary.opacity(0.76))
                    .lineSpacing(2)
                    .fixedSize(horizontal: false, vertical: true)
            }
            .padding(.top, 18)
 
            if let operationText {
                Text(operationText)
                    .font(.system(size: 12, weight: .semibold))
                    .foregroundStyle(Color.secondary)
                    .padding(.top, 14)
            }
 
            HStack(spacing: 10) {
                Button(tr("settings.cancel"), action: onClose)
                    .buttonStyle(.bordered)
 
                Spacer(minLength: 0)
 
                Button(restoreTitle, action: onRestore)
                    .buttonStyle(.bordered)
                    .disabled(isBusy)
 
                Button(unlockTitle, action: onUnlock)
                    .buttonStyle(.borderedProminent)
                    .disabled(isBusy)
            }
            .padding(.top, 20)
        }
        .padding(22)
        .frame(width: 460)
        .background(
            RoundedRectangle(cornerRadius: 12, style: .continuous)
                .fill(Color(nsColor: .windowBackgroundColor))
        )
        .overlay(
            RoundedRectangle(cornerRadius: 12, style: .continuous)
                .stroke(Color.primary.opacity(0.14), lineWidth: 1)
        )
        .shadow(color: .black.opacity(0.24), radius: 24, x: 0, y: 12)
    }
}