mirror of
https://github.com/yattee/yattee.git
synced 2026-10-27 23:17:18 +00:00
Use a scheme-adaptive background for tvOS full screen covers
tvOS full screen covers are transparent, so each one filled itself with a hardcoded black — invisible black-on-black text under the light color scheme (e.g. the View All Comments page). A shared tvFullScreenCoverBackground() modifier now picks black or light gray from the color scheme; applied to the comments cover, subscription destination picker, instance login, edit source, iCloud progress, and legacy accounts import covers.
This commit is contained in:
@@ -367,8 +367,6 @@ struct SubscriptionDestinationPicker: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color.black.ignoresSafeArea()
|
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 24) {
|
VStack(alignment: .leading, spacing: 24) {
|
||||||
Text(String(localized: "channel.menu.subscribeOn"))
|
Text(String(localized: "channel.menu.subscribeOn"))
|
||||||
.font(.title2.bold())
|
.font(.title2.bold())
|
||||||
@@ -395,6 +393,8 @@ struct SubscriptionDestinationPicker: View {
|
|||||||
.padding(.horizontal, 80)
|
.padding(.horizontal, 80)
|
||||||
.padding(.vertical, 60)
|
.padding(.vertical, 60)
|
||||||
}
|
}
|
||||||
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
.tvFullScreenCoverBackground()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
39
Yattee/Views/Components/TVFullScreenCoverBackground.swift
Normal file
39
Yattee/Views/Components/TVFullScreenCoverBackground.swift
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
//
|
||||||
|
// TVFullScreenCoverBackground.swift
|
||||||
|
// Yattee
|
||||||
|
//
|
||||||
|
// Scheme-adaptive opaque background for tvOS full screen covers.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
#if os(tvOS)
|
||||||
|
/// tvOS full screen covers have a transparent background, letting the view
|
||||||
|
/// below leak through, so they need an explicit opaque fill. A hardcoded
|
||||||
|
/// black makes primary (black) text invisible under the light color scheme,
|
||||||
|
/// so the fill follows the scheme instead.
|
||||||
|
struct TVFullScreenCoverBackgroundModifier: ViewModifier {
|
||||||
|
@Environment(\.colorScheme) private var colorScheme
|
||||||
|
|
||||||
|
func body(content: Content) -> some View {
|
||||||
|
content
|
||||||
|
.background(
|
||||||
|
(colorScheme == .dark ? Color.black : Color(white: 0.92))
|
||||||
|
.ignoresSafeArea()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extension View {
|
||||||
|
/// Gives a tvOS full screen cover an opaque, color-scheme-appropriate
|
||||||
|
/// background. No-op on other platforms.
|
||||||
|
@ViewBuilder
|
||||||
|
func tvFullScreenCoverBackground() -> some View {
|
||||||
|
#if os(tvOS)
|
||||||
|
modifier(TVFullScreenCoverBackgroundModifier())
|
||||||
|
#else
|
||||||
|
self
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -552,7 +552,7 @@ struct InstanceBrowseView: View {
|
|||||||
TVSidebarDetailContainer(systemImage: "pencil.circle", title: String(localized: "sources.editSource")) {
|
TVSidebarDetailContainer(systemImage: "pencil.circle", title: String(localized: "sources.editSource")) {
|
||||||
EditSourceView(source: .remoteServer(instance))
|
EditSourceView(source: .remoteServer(instance))
|
||||||
}
|
}
|
||||||
.background(Color.black.ignoresSafeArea())
|
.tvFullScreenCoverBackground()
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
.sheet(isPresented: $showEditInstance) {
|
.sheet(isPresented: $showEditInstance) {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct InstanceLoginView: View {
|
|||||||
formContent
|
formContent
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.background(Color.black.ignoresSafeArea())
|
.tvFullScreenCoverBackground()
|
||||||
.accessibilityIdentifier("instance.login.view")
|
.accessibilityIdentifier("instance.login.view")
|
||||||
#else
|
#else
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
|
|||||||
@@ -1989,9 +1989,7 @@ struct VideoInfoView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if os(tvOS)
|
.tvFullScreenCoverBackground()
|
||||||
.background(Color.black.ignoresSafeArea())
|
|
||||||
#endif
|
|
||||||
.navigationTitle(String(localized: "videoInfo.section.comments"))
|
.navigationTitle(String(localized: "videoInfo.section.comments"))
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
|||||||
@@ -182,11 +182,9 @@ struct YatteeApp: App {
|
|||||||
.fullScreenCover(isPresented: $showingICloudProgress) {
|
.fullScreenCover(isPresented: $showingICloudProgress) {
|
||||||
ICloudSyncProgressView()
|
ICloudSyncProgressView()
|
||||||
.appEnvironment(appEnvironment)
|
.appEnvironment(appEnvironment)
|
||||||
#if os(tvOS)
|
|
||||||
// tvOS full screen covers have a transparent background,
|
// tvOS full screen covers have a transparent background,
|
||||||
// letting the view below leak through.
|
// letting the view below leak through.
|
||||||
.background(Color.black.ignoresSafeArea())
|
.tvFullScreenCoverBackground()
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
@@ -202,7 +200,7 @@ struct YatteeApp: App {
|
|||||||
}
|
}
|
||||||
.appEnvironment(appEnvironment)
|
.appEnvironment(appEnvironment)
|
||||||
}
|
}
|
||||||
.background(Color.black.ignoresSafeArea())
|
.tvFullScreenCoverBackground()
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
.sheet(isPresented: $showingLegacyAccountsImport) {
|
.sheet(isPresented: $showingLegacyAccountsImport) {
|
||||||
|
|||||||
Reference in New Issue
Block a user