PresentFullScreenItemNotify.swift (1520B)
1 // 2 // PresentFullScreenItemNotify.swift 3 // damus 4 // 5 // Created by Daniel D’Aquino on 2024-11-01. 6 // 7 8 struct PresentFullScreenItemNotify: Notify { 9 typealias Payload = FullScreenItem 10 var payload: Payload 11 } 12 13 extension NotifyHandler { 14 static var present_full_screen_item: NotifyHandler<PresentFullScreenItemNotify> { 15 .init() 16 } 17 } 18 19 extension Notifications { 20 static func present_full_screen_item(_ item: FullScreenItem) -> Notifications<PresentFullScreenItemNotify> { 21 .init(.init(payload: item)) 22 } 23 } 24 25 /// Tell the app to present an item in full screen. Use this when presenting items coming from a timeline or any lazy stack. 26 /// 27 /// ## Usage notes 28 /// 29 /// Use this instead of `.damus_full_screen_cover` when the source view is on a lazy stack or timeline. 30 /// 31 /// The reason is that when using a full screen modifier in those scenarios, the full screen view may abruptly disappear. 32 /// One example is when showing videos from the timeline in full screen, where changing the orientation of the device (landscape/portrait) 33 /// can cause the source view to be unloaded by the lazy stack, making your full screen overlay to simply disappear, causing a feeling of flakiness to the app 34 /// 35 /// ## Implementation notes 36 /// 37 /// The requests from this function will be received and handled at the top level app view (`ContentView`), which contains a `.damus_full_screen_cover`. 38 /// 39 func present(full_screen_item: FullScreenItem) { 40 notify(.present_full_screen_item(full_screen_item)) 41 } 42