Fix crash on lock screen (#779)

Missing environment Theme in LogoView.

Probably broken in #775
This commit is contained in:
Davide 2024-10-30 10:18:39 +01:00 committed by GitHub
parent 00bd826096
commit 9d6dfe6a76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 7 deletions

View File

@ -42,7 +42,7 @@ extension PassepartoutApp {
.onOpenURL { url in .onOpenURL { url in
ImporterPipe.shared.send([url]) ImporterPipe.shared.send([url])
} }
.themeLockScreen() .themeLockScreen(theme)
} }
} }
} }

View File

@ -68,7 +68,7 @@ struct ThemeBooleanModalModifier<Modal>: ViewModifier where Modal: View {
modal() modal()
.frame(minWidth: modalSize?.width, minHeight: modalSize?.height) .frame(minWidth: modalSize?.width, minHeight: modalSize?.height)
.interactiveDismissDisabled(!isInteractive) .interactiveDismissDisabled(!isInteractive)
.themeLockScreen() .themeLockScreen(theme)
} }
} }
@ -97,7 +97,7 @@ struct ThemeItemModalModifier<Modal, T>: ViewModifier where Modal: View, T: Iden
modal($0) modal($0)
.frame(minWidth: modalSize?.width, minHeight: modalSize?.height) .frame(minWidth: modalSize?.width, minHeight: modalSize?.height)
.interactiveDismissDisabled(!isInteractive) .interactiveDismissDisabled(!isInteractive)
.themeLockScreen() .themeLockScreen(theme)
} }
} }
@ -129,13 +129,13 @@ struct ThemeBooleanPopoverModifier<Popover>: ViewModifier where Popover: View {
.popover(isPresented: $isPresented) { .popover(isPresented: $isPresented) {
popover popover
.frame(minWidth: theme.popoverSize?.width, minHeight: theme.popoverSize?.height) .frame(minWidth: theme.popoverSize?.width, minHeight: theme.popoverSize?.height)
.themeLockScreen() .themeLockScreen(theme)
} }
} else { } else {
content content
.sheet(isPresented: $isPresented) { .sheet(isPresented: $isPresented) {
popover popover
.themeLockScreen() .themeLockScreen(theme)
} }
} }
} }
@ -322,6 +322,9 @@ struct ThemeLockScreenModifier: ViewModifier {
@AppStorage(AppPreference.locksInBackground.key) @AppStorage(AppPreference.locksInBackground.key)
private var locksInBackground = false private var locksInBackground = false
@ObservedObject
var theme: Theme
func body(content: Content) -> some View { func body(content: Content) -> some View {
LockableView( LockableView(
locksInBackground: $locksInBackground, locksInBackground: $locksInBackground,
@ -331,6 +334,7 @@ struct ThemeLockScreenModifier: ViewModifier {
lockedContent: LogoView.init, lockedContent: LogoView.init,
unlockBlock: Self.unlockScreenBlock unlockBlock: Self.unlockScreenBlock
) )
.environmentObject(theme)
} }
private static func unlockScreenBlock() async -> Bool { private static func unlockScreenBlock() async -> Bool {

View File

@ -199,8 +199,8 @@ extension View {
modifier(ThemeHoverListRowModifier()) modifier(ThemeHoverListRowModifier())
} }
public func themeLockScreen() -> some View { public func themeLockScreen(_ theme: Theme) -> some View {
modifier(ThemeLockScreenModifier()) modifier(ThemeLockScreenModifier(theme: theme))
} }
public func themeTip(_ text: String, edge: Edge) -> some View { public func themeTip(_ text: String, edge: Edge) -> some View {