Convert About and Device Capabilities to macOS-native helpers

This commit is contained in:
Arkadiusz Fal
2026-04-21 00:55:53 +02:00
parent 48963a9e2e
commit a5f8bdacfb
2 changed files with 62 additions and 42 deletions

View File

@@ -12,17 +12,16 @@ struct AboutView: View {
@Environment(\.openURL) private var openURL @Environment(\.openURL) private var openURL
var body: some View { var body: some View {
Form { SettingsFormContainer {
#if !os(tvOS) #if !os(tvOS)
Section { SettingsFormSection("settings.about.community") {
communityLink("GitHub", icon: "github", url: "https://github.com/yattee/yattee") communityLink("GitHub", icon: "github", url: "https://github.com/yattee/yattee")
communityLink("Discord", icon: "discord", url: "https://yattee.stream/discord") communityLink("Discord", icon: "discord", url: "https://yattee.stream/discord")
} header: {
Text(String(localized: "settings.about.community"))
} }
#endif #endif
Section { SettingsFormSection {
#if os(tvOS)
NavigationLink { NavigationLink {
ContributorsView() ContributorsView()
} label: { } label: {
@@ -40,14 +39,34 @@ struct AboutView: View {
} label: { } label: {
Label(String(localized: "settings.acknowledgements.title"), systemImage: "heart.text.square") Label(String(localized: "settings.acknowledgements.title"), systemImage: "heart.text.square")
} }
#else
SettingsNavigationRow("settings.contributors.title", systemImage: "person.3") {
ContributorsView()
}
SettingsNavigationRow("settings.translators.title", systemImage: "globe") {
TranslationContributorsView()
}
SettingsNavigationRow("settings.acknowledgements.title", systemImage: "heart.text.square") {
AcknowledgementsView()
}
#endif
} }
#if os(macOS)
.labelStyle(FixedIconWidthLabelStyle())
#endif
Section { SettingsFormSection {
#if os(tvOS)
NavigationLink { NavigationLink {
DeviceCapabilitiesView() DeviceCapabilitiesView()
} label: { } label: {
Label(String(localized: "settings.advanced.deviceCapabilities"), systemImage: "cpu") Label(String(localized: "settings.advanced.deviceCapabilities"), systemImage: "cpu")
} }
#else
SettingsNavigationRow("settings.advanced.deviceCapabilities", systemImage: "cpu") {
DeviceCapabilitiesView()
}
#endif
} }
versionInfoSection versionInfoSection
@@ -65,26 +84,32 @@ struct AboutView: View {
@ViewBuilder @ViewBuilder
private var versionInfoSection: some View { private var versionInfoSection: some View {
Section { SettingsFormSection("settings.about.versionInfo") {
LabeledContent(String(localized: "settings.advanced.debug.appVersion")) { versionInfoRow(label: String(localized: "settings.advanced.debug.appVersion"), value: appVersion)
Text(appVersion) versionInfoRow(label: String(localized: "settings.advanced.debug.buildNumber"), value: buildNumber)
} versionInfoRow(label: String(localized: "settings.advanced.debug.osVersion"), value: osVersion)
LabeledContent(String(localized: "settings.advanced.debug.buildNumber")) {
Text(buildNumber)
}
LabeledContent(String(localized: "settings.advanced.debug.osVersion")) {
Text(osVersion)
}
} header: {
Text(String(localized: "settings.about.versionInfo"))
} }
} }
@ViewBuilder
private func versionInfoRow(label: String, value: String) -> some View {
#if os(macOS)
HStack {
Text(label)
Spacer()
Text(value)
.foregroundStyle(.secondary)
}
#else
LabeledContent(label) {
Text(value)
}
#endif
}
@ViewBuilder @ViewBuilder
private var mpvInfoSection: some View { private var mpvInfoSection: some View {
Section { SettingsFormSection("settings.about.mpvInfo") {
if let versionInfo = appEnvironment?.playerService.mpvVersionInfo { if let versionInfo = appEnvironment?.playerService.mpvVersionInfo {
LabeledContent(String(localized: "settings.advanced.debug.mpvVersion")) { LabeledContent(String(localized: "settings.advanced.debug.mpvVersion")) {
Text(versionInfo.mpvVersion ?? "Unknown") Text(versionInfo.mpvVersion ?? "Unknown")
@@ -124,8 +149,6 @@ struct AboutView: View {
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
.font(.footnote) .font(.footnote)
} }
} header: {
Text(String(localized: "settings.about.mpvInfo"))
} }
} }

View File

@@ -11,7 +11,7 @@ struct DeviceCapabilitiesView: View {
@Environment(\.appEnvironment) private var appEnvironment @Environment(\.appEnvironment) private var appEnvironment
var body: some View { var body: some View {
List { SettingsFormContainer {
hardwareDecodingSection hardwareDecodingSection
networkStatusSection networkStatusSection
effectiveSettingsSection effectiveSettingsSection
@@ -26,7 +26,7 @@ struct DeviceCapabilitiesView: View {
@ViewBuilder @ViewBuilder
private var hardwareDecodingSection: some View { private var hardwareDecodingSection: some View {
Section { SettingsFormSection("settings.deviceCapabilities.hardwareDecoding", footer: "settings.deviceCapabilities.hardwareDecoding.footer") {
ForEach(HardwareCapabilities.shared.allCapabilities, id: \.name) { capability in ForEach(HardwareCapabilities.shared.allCapabilities, id: \.name) { capability in
HStack { HStack {
Text(capability.name) Text(capability.name)
@@ -40,10 +40,6 @@ struct DeviceCapabilitiesView: View {
} }
} }
} }
} header: {
Text(String(localized: "settings.deviceCapabilities.hardwareDecoding"))
} footer: {
Text(String(localized: "settings.deviceCapabilities.hardwareDecoding.footer"))
} }
} }
@@ -52,9 +48,12 @@ struct DeviceCapabilitiesView: View {
@ViewBuilder @ViewBuilder
private var networkStatusSection: some View { private var networkStatusSection: some View {
if let connectivity = appEnvironment?.connectivityMonitor { if let connectivity = appEnvironment?.connectivityMonitor {
Section { SettingsFormSection("settings.deviceCapabilities.networkStatus", footer: "settings.deviceCapabilities.networkStatus.footer") {
LabeledContent(String(localized: "settings.deviceCapabilities.network.connection")) { HStack {
Text(String(localized: "settings.deviceCapabilities.network.connection"))
Spacer()
Text(connectionTypeString(connectivity)) Text(connectionTypeString(connectivity))
.foregroundStyle(.secondary)
} }
HStack { HStack {
@@ -74,10 +73,6 @@ struct DeviceCapabilitiesView: View {
Spacer() Spacer()
statusIndicator(connectivity.isConstrained) statusIndicator(connectivity.isConstrained)
} }
} header: {
Text(String(localized: "settings.deviceCapabilities.networkStatus"))
} footer: {
Text(String(localized: "settings.deviceCapabilities.networkStatus.footer"))
} }
} }
} }
@@ -88,18 +83,20 @@ struct DeviceCapabilitiesView: View {
private var effectiveSettingsSection: some View { private var effectiveSettingsSection: some View {
if let settings = appEnvironment?.settingsManager, if let settings = appEnvironment?.settingsManager,
let connectivity = appEnvironment?.connectivityMonitor { let connectivity = appEnvironment?.connectivityMonitor {
Section { SettingsFormSection("settings.deviceCapabilities.effectiveSettings", footer: "settings.deviceCapabilities.effectiveSettings.footer") {
LabeledContent(String(localized: "settings.deviceCapabilities.effective.qualityLimit")) { HStack {
Text(String(localized: "settings.deviceCapabilities.effective.qualityLimit"))
Spacer()
Text(effectiveQualityString(settings: settings, connectivity: connectivity)) Text(effectiveQualityString(settings: settings, connectivity: connectivity))
.foregroundStyle(.secondary)
} }
LabeledContent(String(localized: "settings.deviceCapabilities.effective.preferredCodecs")) { HStack {
Text(String(localized: "settings.deviceCapabilities.effective.preferredCodecs"))
Spacer()
Text(HardwareCapabilities.shared.preferredCodecOrder.joined(separator: ", ")) Text(HardwareCapabilities.shared.preferredCodecOrder.joined(separator: ", "))
.foregroundStyle(.secondary)
} }
} header: {
Text(String(localized: "settings.deviceCapabilities.effectiveSettings"))
} footer: {
Text(String(localized: "settings.deviceCapabilities.effectiveSettings.footer"))
} }
} }
} }