From f524a84e9451f7f6ae2d9da4c88b8116398d496c Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Thu, 6 Feb 2025 20:29:52 -0700 Subject: [PATCH] wip --- Shared/ViewModels/SettingsViewModel.swift | 38 +++++++------- .../AppSettingsView/AppSettingsView.swift | 50 +++++++++---------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/Shared/ViewModels/SettingsViewModel.swift b/Shared/ViewModels/SettingsViewModel.swift index 820f07516..109267f4f 100644 --- a/Shared/ViewModels/SettingsViewModel.swift +++ b/Shared/ViewModels/SettingsViewModel.swift @@ -26,30 +26,28 @@ final class SettingsViewModel: ViewModel { override init() { - guard let iconName = UIApplication.shared.alternateIconName else { - currentAppIcon = PrimaryAppIcon.primary - super.init() - return - } - - if let appicon = PrimaryAppIcon.createCase(iconName: iconName) { - currentAppIcon = appicon - } + if let iconName = UIApplication.shared.alternateIconName { + if let appicon = PrimaryAppIcon.createCase(iconName: iconName) { + currentAppIcon = appicon + } - if let appicon = DarkAppIcon.createCase(iconName: iconName) { - currentAppIcon = appicon - } + if let appicon = DarkAppIcon.createCase(iconName: iconName) { + currentAppIcon = appicon + } - if let appicon = InvertedDarkAppIcon.createCase(iconName: iconName) { - currentAppIcon = appicon - } + if let appicon = InvertedDarkAppIcon.createCase(iconName: iconName) { + currentAppIcon = appicon + } - if let appicon = InvertedLightAppIcon.createCase(iconName: iconName) { - currentAppIcon = appicon - } + if let appicon = InvertedLightAppIcon.createCase(iconName: iconName) { + currentAppIcon = appicon + } - if let appicon = LightAppIcon.createCase(iconName: iconName) { - currentAppIcon = appicon + if let appicon = LightAppIcon.createCase(iconName: iconName) { + currentAppIcon = appicon + } + } else { + currentAppIcon = PrimaryAppIcon.primary } super.init() diff --git a/Swiftfin tvOS/Views/AppSettingsView/AppSettingsView.swift b/Swiftfin tvOS/Views/AppSettingsView/AppSettingsView.swift index 31656c6b6..582442adf 100644 --- a/Swiftfin tvOS/Views/AppSettingsView/AppSettingsView.swift +++ b/Swiftfin tvOS/Views/AppSettingsView/AppSettingsView.swift @@ -23,8 +23,8 @@ struct AppSettingsView: View { @EnvironmentObject private var router: AppSettingsCoordinator.Router - @ObservedObject - var viewModel = SettingsViewModel() + @StateObject + private var viewModel = SettingsViewModel() @State private var resetUserSettingsSelected: Bool = false @@ -46,40 +46,40 @@ struct AppSettingsView: View { trailing: "\(UIApplication.appVersion ?? .emptyDash) (\(UIApplication.bundleVersion ?? .emptyDash))" ) - Section(L10n.accessibility) { - - // TODO: supposedly supported but not working -// ChevronButton(L10n.appIcon) -// .onSelect { -// router.route(to: \.appIconSelector, viewModel) -// } - - // Disabled until tvOS can alter app appearance -// if !selectUserUseSplashscreen { -// CaseIterablePicker( -// L10n.appearance, -// selection: $appearance -// ) -// } - } - Section { Toggle(L10n.useSplashscreen, isOn: $selectUserUseSplashscreen) if selectUserUseSplashscreen { - Picker(L10n.servers, selection: $selectUserAllServersSplashscreen) { + Menu { + Picker(L10n.servers, selection: $selectUserAllServersSplashscreen) { - Section { Label(L10n.random, systemImage: "dice.fill") .tag(SelectUserServerSelection.all) - } - ForEach(viewModel.servers) { server in - Text(server.name) - .tag(SelectUserServerSelection.server(id: server.id)) + ForEach(viewModel.servers) { server in + Text(server.name) + .tag(SelectUserServerSelection.server(id: server.id)) + } + } + } label: { + HStack { + Text(L10n.servers) + .frame(maxWidth: .infinity, alignment: .leading) + + if selectUserAllServersSplashscreen == .all { + Label(L10n.random, systemImage: "dice.fill") + } else if let server = viewModel.servers.first( + where: { server in + selectUserAllServersSplashscreen == .server(id: server.id) + } + ) { + Text(server.name) + } } } + .listRowBackground(Color.clear) + .listRowInsets(.zero) } } header: { Text(L10n.splashscreen)