summaryrefslogtreecommitdiff
path: root/Sources/BubombUI/Settings/SettingsView.swift
blob: 02d2287d6ff5a17304a5798cbb72331d028c8021 (plain)
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
import SwiftUI
import BubombCore

/// Main Settings Window for Bubomb.
@MainActor
public struct SettingsView: View {
    @ObservedObject var settingsStore: SettingsStore
    @ObservedObject var executor: PayloadExecutor

    @State private var selectedTab: Int = 0

    public init(settingsStore: SettingsStore = .shared, executor: PayloadExecutor? = nil) {
        self.settingsStore = settingsStore
        self.executor = executor ?? PayloadExecutor.shared
    }

    public var body: some View {
        VStack(spacing: 0) {
            topTabBar

            Divider().background(BubombTheme.borderSubtle)

            Group {
                switch selectedTab {
                case 0:
                    PayloadEditorView(settingsStore: settingsStore, executor: executor)
                case 1:
                    ExecutionStatusView(settingsStore: settingsStore, executor: executor)
                case 2:
                    GeneralSettingsView(settingsStore: settingsStore)
                default:
                    EmptyView()
                }
            }
            .frame(maxWidth: .infinity, maxHeight: .infinity)
        }
        .frame(minWidth: 620, idealWidth: 680, minHeight: 520, idealHeight: 580)
        .background(BubombTheme.windowBackground)
    }

    // MARK: - Top Tab Bar

    private var topTabBar: some View {
        HStack(spacing: 16) {
            HStack(spacing: 8) {
                AnimatedBombView(size: 28, isDetonating: executor.currentState.isRunning)
                Text("Bubomb")
                    .font(.headline.bold())
                    .foregroundColor(BubombTheme.textPrimary)
            }
            .padding(.leading, 8)

            Spacer()

            Picker("", selection: $selectedTab) {
                Label("Payload", systemImage: "flame.fill").tag(0)
                Label("Execution", systemImage: "clock.arrow.circlepath").tag(1)
                Label("General", systemImage: "gearshape.fill").tag(2)
            }
            .pickerStyle(.segmented)
            .frame(width: 320)
            .labelsHidden()

            Spacer()

            // Armed Status Pill
            if settingsStore.settings.activePayload != nil {
                HStack(spacing: 5) {
                    Circle().fill(BubombTheme.successGreen).frame(width: 6, height: 6)
                    Text("Armed")
                        .font(.caption2.bold())
                        .foregroundColor(BubombTheme.successGreen)
                }
                .padding(.horizontal, 8)
                .padding(.vertical, 4)
                .background(BubombTheme.successGreen.opacity(0.12))
                .cornerRadius(12)
            } else {
                HStack(spacing: 5) {
                    Circle().fill(BubombTheme.accentAmber).frame(width: 6, height: 6)
                    Text("Unarmed")
                        .font(.caption2.bold())
                        .foregroundColor(BubombTheme.accentAmber)
                }
                .padding(.horizontal, 8)
                .padding(.vertical, 4)
                .background(BubombTheme.accentAmber.opacity(0.12))
                .cornerRadius(12)
            }
        }
        .padding(.horizontal, 16)
        .padding(.vertical, 12)
        .background(BubombTheme.surface)
    }
}