aboutsummaryrefslogtreecommitdiff
path: root/Hotline/macOS
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2024-05-01 21:22:18 -0700
committerDustin Mierau <dustin@mierau.me>2024-05-01 21:32:15 -0700
commit60a3f2d29dfff945f59787f5a7786c6e78ba7bb9 (patch)
treee3d0aa6ae541790ea700353b0ac01fe8b4950f9f /Hotline/macOS
parentb9529a0d255ad41c62a4e3b93a47ebb5bb82a565 (diff)
New Hotline toolbar window for banner.
Diffstat (limited to 'Hotline/macOS')
-rw-r--r--Hotline/macOS/ChatView.swift17
-rw-r--r--Hotline/macOS/HotlinePanelView.swift116
-rw-r--r--Hotline/macOS/ServerView.swift8
3 files changed, 132 insertions, 9 deletions
diff --git a/Hotline/macOS/ChatView.swift b/Hotline/macOS/ChatView.swift
index 7f7d677..1b82e02 100644
--- a/Hotline/macOS/ChatView.swift
+++ b/Hotline/macOS/ChatView.swift
@@ -38,21 +38,22 @@ struct ChatView: View {
if msg.type == .agreement {
VStack(alignment: .center, spacing: 16) {
+ #if os(iOS)
if let bannerImage = self.model.bannerImage {
- #if os(macOS)
- Image(nsImage: bannerImage)
- .resizable()
- .scaledToFit()
- .frame(maxWidth: 468.0)
- .clipShape(RoundedRectangle(cornerRadius: 3))
- #elseif os(iOS)
+// #if os(macOS)
+// Image(nsImage: bannerImage)
+// .resizable()
+// .scaledToFit()
+// .frame(maxWidth: 468.0)
+// .clipShape(RoundedRectangle(cornerRadius: 3))
+// #elseif os(iOS)
Image(uiImage: bannerImage)
.resizable()
.scaledToFit()
.frame(maxWidth: 468.0)
.clipShape(RoundedRectangle(cornerRadius: 3))
- #endif
}
+ #endif
VStack(spacing: 0) {
ScrollView(.vertical) {
diff --git a/Hotline/macOS/HotlinePanelView.swift b/Hotline/macOS/HotlinePanelView.swift
new file mode 100644
index 0000000..36204a7
--- /dev/null
+++ b/Hotline/macOS/HotlinePanelView.swift
@@ -0,0 +1,116 @@
+import SwiftUI
+
+struct HotlinePanelView: View {
+ @Environment(\.openWindow) var openWindow
+ @Environment(\.colorScheme) var colorScheme
+
+ @FocusedValue(\.activeHotlineModel) private var activeHotline: Hotline?
+ @FocusedValue(\.activeServerState) private var activeServerState: ServerState?
+
+ var body: some View {
+ VStack {
+ Image(nsImage: ApplicationState.shared.activeServerBanner ?? NSImage(named: "Default Banner")!)
+ .interpolation(.high)
+ .resizable()
+ .scaledToFit()
+ .frame(width: 468, height: 60)
+ .clipShape(RoundedRectangle(cornerRadius: 6.0))
+ .padding([.top, .leading, .trailing], 4)
+
+ HStack(spacing: 16) {
+ Button {
+ openWindow(id: "servers")
+ }
+ label: {
+ Image(systemName: "globe.americas.fill")
+ .resizable()
+ .scaledToFit()
+ }
+ .buttonStyle(.plain)
+ .frame(width: 18, height: 18)
+ .help("Hotline Servers")
+
+ Button {
+ ApplicationState.shared.activeServerState?.selection = .chat
+ }
+ label: {
+ Image(systemName: "bubble.fill")
+ .resizable()
+ .scaledToFit()
+ }
+ .buttonStyle(.plain)
+ .frame(width: 18, height: 18)
+ .opacity(ApplicationState.shared.activeServerState == nil ? 0.5 : 1.0)
+ .disabled(ApplicationState.shared.activeServerState == nil)
+ .help("Public Chat")
+
+ Button {
+ ApplicationState.shared.activeServerState?.selection = .news
+ }
+ label: {
+ Image(systemName: "newspaper.fill")
+ .resizable()
+ .scaledToFit()
+ }
+ .buttonStyle(.plain)
+ .frame(width: 18, height: 18)
+ .opacity(ApplicationState.shared.activeServerState == nil ? 0.5 : 1.0)
+ .disabled(ApplicationState.shared.activeServerState == nil)
+ .help("News")
+
+ Button {
+ ApplicationState.shared.activeServerState?.selection = .board
+ }
+ label: {
+ Image(systemName: "pin.fill")
+ .resizable()
+ .scaledToFit()
+ }
+ .buttonStyle(.plain)
+ .frame(width: 18, height: 18)
+ .opacity(ApplicationState.shared.activeServerState == nil ? 0.5 : 1.0)
+ .disabled(ApplicationState.shared.activeServerState == nil)
+ .help("Message Board")
+
+ Button {
+ ApplicationState.shared.activeServerState?.selection = .files
+ }
+ label: {
+ Image(systemName: "folder.fill")
+ .resizable()
+ .scaledToFit()
+ }
+ .buttonStyle(.plain)
+ .frame(width: 18, height: 18)
+ .opacity(ApplicationState.shared.activeServerState == nil ? 0.5 : 1.0)
+ .disabled(ApplicationState.shared.activeServerState == nil)
+ .help("Files")
+
+ Spacer()
+
+ SettingsLink(label: {
+ Image(systemName: "gearshape.fill")
+ .resizable()
+ .scaledToFit()
+ })
+ .buttonStyle(.plain)
+ .frame(width: 18, height: 18)
+ .help("Settings")
+ }
+ .padding(.top, 8)
+ .padding(.bottom, 16)
+ .padding([.leading, .trailing], 16)
+ }
+// .frame(width: 468)
+// .background(colorScheme == .dark ? .black : .white)
+ .background(
+ VisualEffectView(material: .headerView, blendingMode: .behindWindow)
+ .cornerRadius(10.0)
+ )
+ }
+}
+
+#Preview {
+ HotlinePanelView()
+ .environment(Hotline(trackerClient: HotlineTrackerClient(), client: HotlineClient()))
+}
diff --git a/Hotline/macOS/ServerView.swift b/Hotline/macOS/ServerView.swift
index 8176704..1892177 100644
--- a/Hotline/macOS/ServerView.swift
+++ b/Hotline/macOS/ServerView.swift
@@ -2,12 +2,17 @@ import SwiftUI
import UniformTypeIdentifiers
@Observable
-class ServerState {
+class ServerState: Equatable {
+ var id: UUID = UUID()
var selection: ServerNavigationType
init(selection: ServerNavigationType) {
self.selection = selection
}
+
+ static func == (lhs: ServerState, rhs: ServerState) -> Bool {
+ return lhs.id == rhs.id
+ }
}
enum MenuItemType {
@@ -121,6 +126,7 @@ struct ServerView: View {
@Environment(\.dismiss) var dismiss
@Environment(\.colorScheme) private var colorScheme
@Environment(\.controlActiveState) private var controlActiveState
+ @Environment(\.scenePhase) private var scenePhase
@State private var model: Hotline = Hotline(trackerClient: HotlineTrackerClient(), client: HotlineClient())
@State private var state: ServerState = ServerState(selection: .chat)