summaryrefslogtreecommitdiff
path: root/octosentry/octosentryApp.swift
diff options
context:
space:
mode:
Diffstat (limited to 'octosentry/octosentryApp.swift')
-rw-r--r--octosentry/octosentryApp.swift33
1 files changed, 32 insertions, 1 deletions
diff --git a/octosentry/octosentryApp.swift b/octosentry/octosentryApp.swift
index cf7522d..e80c4a0 100644
--- a/octosentry/octosentryApp.swift
+++ b/octosentry/octosentryApp.swift
@@ -7,15 +7,46 @@
import SwiftUI
+enum SecurityEventWindow {
+ static let id = "security-events-window"
+}
+
@main
struct octosentryApp: App {
@State private var store = SecurityEventStore()
@State private var authStore = AuthStore()
var body: some Scene {
- MenuBarExtra("OctoSentry", systemImage: "shield.lefthalf.filled") {
+ MenuBarExtra {
SecurityEventListView(store: store, authStore: authStore)
+ .frame(width: 380, height: 420)
+ } label: {
+ MenuBarIconView(criticalCount: store.unseenCriticalCount)
}
.menuBarExtraStyle(.window)
+
+ Window("Security Events", id: SecurityEventWindow.id) {
+ SecurityEventListView(store: store, authStore: authStore, isStandaloneWindow: true)
+ .frame(minWidth: 420, minHeight: 480)
+ }
+ }
+}
+
+private struct MenuBarIconView: View {
+ let criticalCount: Int
+
+ var body: some View {
+ ZStack(alignment: .topTrailing) {
+ Image(systemName: criticalCount > 0 ? "exclamationmark.shield.fill" : "shield.lefthalf.filled")
+
+ if criticalCount > 0 {
+ Text(criticalCount > 9 ? "9+" : "\(criticalCount)")
+ .font(.system(size: 8, weight: .bold))
+ .foregroundStyle(.white)
+ .padding(2)
+ .background(Circle().fill(.red))
+ .offset(x: 8, y: -6)
+ }
+ }
}
}