| 1 | import SwiftUI |
| 2 | |
| 3 | @main |
| 4 | struct ControlKitRunnerApp: App { |
| 5 | // MARK: - Internal |
| 6 | |
| 7 | var body: some Scene { |
| 8 | WindowGroup { |
| 9 | ControlKitShowcaseView() |
| 10 | } |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | private struct ControlKitShowcaseView: View { |
| 15 | // MARK: - Internal |
| 16 | |
| 17 | var body: some View { |
| 18 | ZStack { |
| 19 | LinearGradient( |
| 20 | colors: [Color.controlKitGreen, Color(red: 0.04, green: 0.12, blue: 0.09)], |
| 21 | startPoint: .topLeading, |
| 22 | endPoint: .bottomTrailing |
| 23 | ) |
| 24 | .ignoresSafeArea() |
| 25 | |
| 26 | ScrollView { |
| 27 | VStack(alignment: .leading, spacing: 28) { |
| 28 | HStack(spacing: 18) { |
| 29 | logo |
| 30 | VStack(alignment: .leading, spacing: 4) { |
| 31 | Text("ControlKit") |
| 32 | .font(.system(size: 40, weight: .bold, design: .rounded)) |
| 33 | Text("Apple platform automation") |
| 34 | .font(.title3) |
| 35 | .foregroundStyle(Color.controlKitCream.opacity(0.78)) |
| 36 | } |
| 37 | } |
| 38 | .padding(.top, 32) |
| 39 | |
| 40 | statusCard |
| 41 | informationCard |
| 42 | |
| 43 | Link(destination: repositoryURL) { |
| 44 | Label("View project on GitHub", systemImage: "arrow.up.right") |
| 45 | .font(.headline) |
| 46 | .frame(maxWidth: .infinity) |
| 47 | } |
| 48 | .buttonStyle(.borderedProminent) |
| 49 | .tint(Color.controlKitCream) |
| 50 | .foregroundStyle(Color.controlKitGreen) |
| 51 | } |
| 52 | .foregroundStyle(Color.controlKitCream) |
| 53 | .padding(32) |
| 54 | .frame(maxWidth: 820) |
| 55 | } |
| 56 | .frame(maxWidth: .infinity, maxHeight: .infinity) |
| 57 | } |
| 58 | .frame(maxWidth: .infinity, maxHeight: .infinity) |
| 59 | .frame(minWidth: UIScreen.main.bounds.width, minHeight: UIScreen.main.bounds.height) |
| 60 | .ignoresSafeArea(.all) |
| 61 | .statusBarHidden(true) |
| 62 | } |
| 63 | |
| 64 | // MARK: - Private |
| 65 | |
| 66 | private let repositoryURL = URL(string: "https://github.com/ondeinference/xcrs-controlkit")! |
| 67 | |
| 68 | private var logo: some View { |
| 69 | Text("XC\nRS") |
| 70 | .font(.system(size: 30, weight: .black, design: .rounded)) |
| 71 | .multilineTextAlignment(.center) |
| 72 | .lineSpacing(-8) |
| 73 | .foregroundStyle(Color.controlKitGreen) |
| 74 | .frame(width: 96, height: 96) |
| 75 | .background(Color.controlKitCream, in: RoundedRectangle(cornerRadius: 24)) |
| 76 | } |
| 77 | |
| 78 | private var statusCard: some View { |
| 79 | VStack(alignment: .leading, spacing: 14) { |
| 80 | Label("Runner online", systemImage: "checkmark.circle.fill") |
| 81 | .font(.headline) |
| 82 | .foregroundStyle(.green) |
| 83 | Text("The XCTest host is ready to receive ControlKit automation requests.") |
| 84 | .foregroundStyle(Color.controlKitCream.opacity(0.78)) |
| 85 | } |
| 86 | .padding(22) |
| 87 | .frame(maxWidth: .infinity, alignment: .leading) |
| 88 | .background(.white.opacity(0.1), in: RoundedRectangle(cornerRadius: 20)) |
| 89 | } |
| 90 | |
| 91 | private var informationCard: some View { |
| 92 | VStack(alignment: .leading, spacing: 16) { |
| 93 | infoRow(title: "Project", value: "XCRSControlKit") |
| 94 | infoRow(title: "Creator", value: "smbCloud") |
| 95 | infoRow(title: "Platform", value: "iOS and iPadOS") |
| 96 | infoRow(title: "Purpose", value: "Native UI automation runner") |
| 97 | } |
| 98 | .padding(22) |
| 99 | .frame(maxWidth: .infinity, alignment: .leading) |
| 100 | .background(.white.opacity(0.08), in: RoundedRectangle(cornerRadius: 20)) |
| 101 | } |
| 102 | |
| 103 | private func infoRow(title: String, value: String) -> some View { |
| 104 | HStack { |
| 105 | Text(title) |
| 106 | .foregroundStyle(Color.controlKitCream.opacity(0.62)) |
| 107 | Spacer() |
| 108 | Text(value) |
| 109 | .fontWeight(.semibold) |
| 110 | .multilineTextAlignment(.trailing) |
| 111 | } |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | private extension Color { |
| 116 | static let controlKitGreen = Color(red: 0.106, green: 0.263, blue: 0.196) |
| 117 | static let controlKitCream = Color(red: 0.961, green: 0.953, blue: 0.925) |
| 118 | } |