Modern Apps git

xtool.git

Public
git clone https://git.maproj.org/xtool.git
appstore-distribution ▾

xtool.git / macOS / XToolMac / XToolMacUI.swift

XToolMacUI.swift69 lines · 1.7 KiBRaw
1import SwiftUI
2
3struct XToolMacUI: App {
4 var body: some Scene {
5 WindowGroup {
6 ContentView()
7 }
8 .windowResizability(.contentSize)
9 }
10}
11
12private struct ContentView: View {
13 private static let command = """
14 sudo ln -fs /Applications/xtool.app/Contents/Resources/bin/xtool /usr/local/bin/xtool
15 """
16
17 var body: some View {
18 VStack(alignment: .leading, spacing: 16) {
19 StepView(1) {
20 Text("Move this app into your `/Applications` folder.")
21 }
22
23 StepView(2) {
24 VStack(alignment: .leading, spacing: 16) {
25 Text("Symlink xtool into a location on your `PATH`.")
26
27 Text(Self.command)
28 .font(.body.monospaced())
29 .textSelection(.enabled)
30
31 Button("Copy Command") {
32 NSPasteboard.general.clearContents()
33 NSPasteboard.general.setString(Self.command, forType: .string)
34 }
35 }
36 }
37 }
38 .padding()
39 .padding(.vertical)
40 .frame(width: 500)
41 .fixedSize()
42 .navigationTitle("xtool")
43 }
44}
45
46private struct StepView<Content: View>: View {
47 let number: Int
48 let content: Content
49
50 init(_ number: Int, @ViewBuilder content: () -> Content) {
51 self.number = number
52 self.content = content()
53 }
54
55 var body: some View {
56 HStack(alignment: .firstTextBaseline) {
57 Text("\(number)")
58 .foregroundStyle(.background)
59 .padding(8)
60 .background(.secondary, in: .circle)
61
62 content
63 }
64 }
65}
66
67#Preview {
68 ContentView()
69}