summaryrefslogtreecommitdiff
path: root/makima/ios/Sources/Makima/Design/Components/MastheadBar.swift
blob: a304f958ceacaec6c1aa43581b3a780b55786cda (plain) (blame)
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
import SwiftUI

enum WebSocketStatus {
    case idle, connecting, online, offline

    var label: String {
        switch self {
        case .idle:       return "WS//IDLE"
        case .connecting: return "WS//…"
        case .online:     return "WS//ONLINE"
        case .offline:    return "WS//OFFLINE"
        }
    }

    var color: Color {
        switch self {
        case .idle:       return Palette.foregroundMuted
        case .connecting: return Palette.warn
        case .online:     return Palette.ok
        case .offline:    return Palette.danger
        }
    }
}

/// Top chrome strip, replaces a traditional nav bar.
/// Composition: small logo + "MAKIMA" brand + spacer + ws-pill + server label + version.
struct MastheadBar: View {
    let serverLabel: String
    let wsStatus: WebSocketStatus
    let version: String

    var body: some View {
        HStack(spacing: 10) {
            Logo(size: 22)
            Text("MAKIMA")
                .font(.system(.caption, design: .monospaced).weight(.semibold))
                .tracking(2)
                .foregroundStyle(Palette.foreground)

            Spacer(minLength: 8)

            Text(wsStatus.label)
                .font(Typography.navLabel)
                .foregroundStyle(wsStatus.color)
            Text("·")
                .foregroundStyle(Palette.borderMuted)
            Text(serverLabel)
                .font(Typography.navLabel)
                .foregroundStyle(Palette.accent)
            Text("·")
                .foregroundStyle(Palette.borderMuted)
            Text("v\(version)")
                .font(Typography.navLabel)
                .foregroundStyle(Palette.foregroundMuted)
        }
        .padding(.horizontal, 14)
        .padding(.vertical, 10)
        .background(
            LinearGradient(
                colors: [Palette.backgroundDeep.opacity(0.95), Palette.panel.opacity(0.7)],
                startPoint: .top, endPoint: .bottom
            )
        )
        .overlay(alignment: .bottom) {
            Rectangle().fill(Palette.border).frame(height: 2)
        }
    }
}

struct NavStripPlaceholder: View {
    private let labels = ["LISTEN", "DIRECTIVES", "ORDERS", "CONTRACTS", "DAEMONS", "HISTORY"]

    var body: some View {
        HStack(spacing: 10) {
            Text("NAV//")
                .font(Typography.navLabel)
                .foregroundStyle(Palette.accent)
                .padding(.trailing, 4)
                .overlay(alignment: .trailing) {
                    Rectangle().fill(Palette.borderMuted).frame(width: 1, height: 14)
                        .offset(x: 4)
                }
            ForEach(labels, id: \.self) { l in
                Text(l)
                    .font(Typography.navLabel)
                    .foregroundStyle(Palette.accent.opacity(0.8))
            }
            Spacer()
        }
        .padding(.horizontal, 12)
        .padding(.vertical, 10)
        .background(Palette.panel)
        .overlay(alignment: .top) {
            Rectangle().fill(Palette.borderMuted).frame(height: 1)
        }
        .overlay(alignment: .bottom) {
            Rectangle().fill(Palette.borderMuted).frame(height: 1)
        }
    }
}