aboutsummaryrefslogtreecommitdiff
path: root/Hotline
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-11-08 19:51:48 -0800
committerDustin Mierau <dustin@mierau.me>2025-11-08 19:51:48 -0800
commit2caf86e633c1a121c8e23d068ac817ed8e80f6a7 (patch)
tree4c3d9cb30d9df501a4befd15bb798f7964c8caad /Hotline
parent206e4bbdaba85062a38b32c16a9937ab42cddb47 (diff)
Moved SoundEffects to Managers. Updated connect form in ServerView. Changed some icons in context menus for bookmarks.
Diffstat (limited to 'Hotline')
-rw-r--r--Hotline/Managers/SoundEffects.swift (renamed from Hotline/Library/SoundEffects.swift)9
-rw-r--r--Hotline/macOS/ServerView.swift73
-rw-r--r--Hotline/macOS/Trackers/TrackerView.swift7
3 files changed, 48 insertions, 41 deletions
diff --git a/Hotline/Library/SoundEffects.swift b/Hotline/Managers/SoundEffects.swift
index 4964b94..85a1c0e 100644
--- a/Hotline/Library/SoundEffects.swift
+++ b/Hotline/Managers/SoundEffects.swift
@@ -14,10 +14,13 @@ enum SoundEffect: String {
static var all: [SoundEffect] = [.loggedIn, .chatMessage, .transferComplete, .userLogin, .userLogout, .newNews, .serverMessage, .error]
}
-@Observable
class SoundEffects {
static let shared = SoundEffects()
+ static func play(_ name: SoundEffect) {
+ Self.shared.play(name)
+ }
+
private var preloadedSounds: [SoundEffect: NSSound] = [:]
private init() {
@@ -31,10 +34,6 @@ class SoundEffects {
}
}
- static func play(_ name: SoundEffect) {
- Self.shared.play(name)
- }
-
func play(_ name: SoundEffect) {
self.preloadedSounds[name]?.play()
}
diff --git a/Hotline/macOS/ServerView.swift b/Hotline/macOS/ServerView.swift
index d2c503f..44274ea 100644
--- a/Hotline/macOS/ServerView.swift
+++ b/Hotline/macOS/ServerView.swift
@@ -121,8 +121,10 @@ struct ServerView: View {
self.connectForm
Spacer()
}
-// .frame(maxWidth: .infinity, maxHeight: .infinity)
.navigationTitle("Connect to Server")
+ .onAppear {
+ self.focusedField = .address
+ }
}
else if case .failed(let error) = model.status {
VStack {
@@ -250,40 +252,47 @@ struct ServerView: View {
}
var connectForm: some View {
- Form {
- HStack(alignment: .top, spacing: 10) {
- Image("Server Large")
- .resizable()
- .scaledToFit()
- .frame(width: 28, height: 28)
+ VStack(alignment: .center, spacing: 0) {
+ Form {
+ HStack(alignment: .top, spacing: 10) {
+ Image("Server Large")
+ .resizable()
+ .scaledToFit()
+ .frame(width: 28, height: 28)
+
+ VStack(alignment: .leading) {
+ Text("Connect to Server")
+ Text("Enter the address of a Hotline server to connect to.")
+ .foregroundStyle(.secondary)
+ .font(.subheadline)
+ }
+ }
- VStack(alignment: .leading) {
- Text("Connect to Server")
- Text("Enter the address of a Hotline server to connect to.")
- .foregroundStyle(.secondary)
- .font(.subheadline)
+ TextField(text: $connectAddress) {
+ Text("Address")
}
+ .focused($focusedField, equals: .address)
+
+ TextField(text: $connectLogin, prompt: Text("Optional")) {
+ Text("Login")
+ }
+ .focused($focusedField, equals: .login)
+
+ SecureField(text: $connectPassword, prompt: Text("Optional")) {
+ Text("Password")
+ }
+ .focused($focusedField, equals: .password)
}
-
- TextField(text: $connectAddress) {
- Text("Address:")
- }
- .focused($focusedField, equals: .address)
-
- TextField(text: $connectLogin, prompt: Text("Optional")) {
- Text("Login:")
- }
- .focused($focusedField, equals: .login)
- SecureField(text: $connectPassword, prompt: Text("Optional")) {
- Text("Password:")
- }
- .focused($focusedField, equals: .password)
+ .formStyle(.grouped)
+ .fixedSize(horizontal: false, vertical: true)
HStack {
- Button("Save...") {
+ Button {
if !connectAddress.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
connectNameSheetPresented = true
}
+ } label: {
+ Image(systemName: "bookmark.fill")
}
.disabled(connectAddress.isEmpty)
.controlSize(.regular)
@@ -302,15 +311,12 @@ struct ServerView: View {
Button("Connect") {
connectToServer()
}
-
.controlSize(.regular)
.buttonStyle(.automatic)
.keyboardShortcut(.defaultAction)
}
- .padding(.top, 8)
+ .padding(.horizontal, 20)
}
- .formStyle(.grouped)
- .fixedSize(horizontal: false, vertical: true)
.onChange(of: connectAddress) {
let (a, p) = Server.parseServerAddressAndPort(connectAddress)
server.address = a
@@ -322,14 +328,11 @@ struct ServerView: View {
.onChange(of: connectPassword) {
server.password = connectPassword
}
- .onAppear {
- focusedField = .address
- }
.frame(maxWidth: 380)
.padding()
.sheet(isPresented: $connectNameSheetPresented) {
VStack(alignment: .leading) {
- Text("Name this server bookmark:")
+ Text("Save Bookmark")
.foregroundStyle(.secondary)
.padding(.bottom, 4)
TextField("Bookmark Name", text: $connectName)
diff --git a/Hotline/macOS/Trackers/TrackerView.swift b/Hotline/macOS/Trackers/TrackerView.swift
index dbbacaa..e0ca87d 100644
--- a/Hotline/macOS/Trackers/TrackerView.swift
+++ b/Hotline/macOS/Trackers/TrackerView.swift
@@ -480,7 +480,12 @@ struct TrackerView: View {
Button {
Bookmark.delete(bookmark, context: modelContext)
} label: {
- Label(bookmark.type == .tracker ? "Delete Tracker" : "Delete Bookmark", systemImage: "trash")
+ if bookmark.type == .tracker {
+ Label("Delete Tracker", systemImage: "xmark")
+ }
+ else {
+ Label("Delete Bookmark", systemImage: "bookmark.slash")
+ }
}
}