aboutsummaryrefslogtreecommitdiff
path: root/Hotline/macOS/SettingsView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hotline/macOS/SettingsView.swift')
-rw-r--r--Hotline/macOS/SettingsView.swift47
1 files changed, 28 insertions, 19 deletions
diff --git a/Hotline/macOS/SettingsView.swift b/Hotline/macOS/SettingsView.swift
index 81a2f8d..c67ba85 100644
--- a/Hotline/macOS/SettingsView.swift
+++ b/Hotline/macOS/SettingsView.swift
@@ -3,12 +3,12 @@ import SwiftUI
struct GeneralSettingsView: View {
@State private var username: String = ""
@State private var usernameChanged: Bool = false
-
+
let saveTimer = Timer.publish(every: 5, on: .main, in: .common).autoconnect()
-
+
var body: some View {
@Bindable var preferences = Prefs.shared
-
+
Form {
TextField("Your Name", text: $username, prompt: Text("guest"))
Toggle("Show Join/Leave in Chat", isOn: $preferences.showJoinLeaveMessages)
@@ -49,22 +49,24 @@ struct GeneralSettingsView: View {
struct IconSettingsView: View {
@State private var hoveredUserIconID: Int = -1
-
+
var body: some View {
@Bindable var preferences = Prefs.shared
-
+
Form {
ScrollViewReader { scrollProxy in
ScrollView {
- LazyVGrid(columns: [
- GridItem(.fixed(4+32+4)),
- GridItem(.fixed(4+32+4)),
- GridItem(.fixed(4+32+4)),
- GridItem(.fixed(4+32+4)),
- GridItem(.fixed(4+32+4)),
- GridItem(.fixed(4+32+4)),
- GridItem(.fixed(4+32+4))
- ], spacing: 0) {
+ LazyVGrid(
+ columns: [
+ GridItem(.fixed(4 + 32 + 4)),
+ GridItem(.fixed(4 + 32 + 4)),
+ GridItem(.fixed(4 + 32 + 4)),
+ GridItem(.fixed(4 + 32 + 4)),
+ GridItem(.fixed(4 + 32 + 4)),
+ GridItem(.fixed(4 + 32 + 4)),
+ GridItem(.fixed(4 + 32 + 4)),
+ ], spacing: 0
+ ) {
ForEach(Hotline.classicIconSet, id: \.self) { iconID in
HStack {
Image("Classic/\(iconID)")
@@ -77,7 +79,12 @@ struct IconSettingsView: View {
.tag(iconID)
.frame(width: 32, height: 32)
.padding(4)
- .background(iconID == preferences.userIconID ? Color.accentColor : (iconID == hoveredUserIconID ? Color.accentColor.opacity(0.1) : Color(nsColor: .textBackgroundColor)))
+ .background(
+ iconID == preferences.userIconID
+ ? Color.accentColor
+ : (iconID == hoveredUserIconID
+ ? Color.accentColor.opacity(0.1) : Color(nsColor: .textBackgroundColor))
+ )
.clipShape(RoundedRectangle(cornerRadius: 5))
.onTapGesture {
preferences.userIconID = iconID
@@ -93,7 +100,9 @@ struct IconSettingsView: View {
}
.background(Color(nsColor: .textBackgroundColor))
.clipShape(RoundedRectangle(cornerRadius: 6))
- .overlay(RoundedRectangle(cornerRadius: 6).stroke(Color(nsColor: .separatorColor), lineWidth: 1))
+ .overlay(
+ RoundedRectangle(cornerRadius: 6).stroke(Color(nsColor: .separatorColor), lineWidth: 1)
+ )
.onAppear {
scrollProxy.scrollTo(preferences.userIconID, anchor: .center)
}
@@ -107,11 +116,11 @@ struct IconSettingsView: View {
struct SoundSettingsView: View {
var body: some View {
@Bindable var preferences = Prefs.shared
-
+
Form {
Toggle("Enable Sounds", isOn: $preferences.playSounds)
.controlSize(.large)
-
+
Section("Sounds") {
Toggle("Chat", isOn: $preferences.playChatSound)
.disabled(!preferences.playSounds)
@@ -147,7 +156,7 @@ struct SettingsView: View {
private enum Tabs: Hashable {
case general, icon
}
-
+
var body: some View {
TabView {
GeneralSettingsView()