Skip to content

Commit 19e7bd0

Browse files
committed
Update
1 parent 0b3284d commit 19e7bd0

File tree

1 file changed

+70
-3
lines changed

1 file changed

+70
-3
lines changed

Core/Sources/HostApp/GeneralView.swift

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SwiftUI
66

77
struct GeneralView: View {
88
let store: StoreOf<General>
9-
9+
1010
var body: some View {
1111
ScrollView {
1212
VStack(alignment: .leading, spacing: 0) {
@@ -87,7 +87,7 @@ struct ExtensionServiceView: View {
8787
WithViewStore(store, observe: { $0.xpcServiceVersion }) { viewStore in
8888
Text("Extension Service Version: \(viewStore.state ?? "Loading..")")
8989
}
90-
90+
9191
WithViewStore(store, observe: { $0.isAccessibilityPermissionGranted }) { viewStore in
9292
let grantedStatus: String = {
9393
guard let granted = viewStore.state else { return "Loading.." }
@@ -285,17 +285,84 @@ struct GeneralSettingsView: View {
285285

286286
Text("pt")
287287
}
288-
288+
289289
Toggle(isOn: $settings.hideCircularWidget) {
290290
Text("Hide circular widget")
291291
}
292292
}.padding()
293293
}
294294
}
295295

296+
struct WidgetPositionIcon: View {
297+
var position: SuggestionWidgetPositionMode
298+
var isSelected: Bool
299+
300+
var body: some View {
301+
ZStack {
302+
Rectangle()
303+
.fill(Color(nsColor: .textBackgroundColor))
304+
Rectangle()
305+
.fill(Color.accentColor.opacity(0.2))
306+
.frame(width: 120, height: 20)
307+
}
308+
.frame(width: 120, height: 80)
309+
}
310+
}
311+
312+
struct LargeIconPicker<
313+
Data: RandomAccessCollection,
314+
ID: Hashable,
315+
Content: View,
316+
Label: View
317+
>: View {
318+
@Binding var selection: Data.Element
319+
var data: Data
320+
var id: KeyPath<Data.Element, ID>
321+
var builder: (Data.Element, _ isSelected: Bool) -> Content
322+
var label: () -> Label
323+
324+
@ViewBuilder
325+
var content: some View {
326+
HStack {
327+
ForEach(data, id: id) { item in
328+
let isSelected = selection[keyPath: id] == item[keyPath: id]
329+
Button(action: {
330+
selection = item
331+
}) {
332+
builder(item, isSelected)
333+
.clipShape(RoundedRectangle(cornerRadius: 8))
334+
.overlay {
335+
RoundedRectangle(cornerRadius: 8)
336+
.stroke(
337+
isSelected ? Color.accentColor : Color.primary.opacity(0.1),
338+
style: .init(lineWidth: 2)
339+
)
340+
}
341+
}.buttonStyle(.plain)
342+
}
343+
}
344+
}
345+
346+
var body: some View {
347+
if #available(macOS 13.0, *) {
348+
LabeledContent {
349+
content
350+
} label: {
351+
label()
352+
}
353+
} else {
354+
VStack {
355+
label()
356+
content
357+
}
358+
}
359+
}
360+
}
361+
296362
struct GeneralView_Previews: PreviewProvider {
297363
static var previews: some View {
298364
GeneralView(store: .init(initialState: .init(), reducer: General()))
365+
.frame(height: 800)
299366
}
300367
}
301368

0 commit comments

Comments
 (0)