Files
zeekayandHanzo Dev c8bfbebc15 Keep ZAMA's copyright notices
This app is ZAMA's BSD 3-Clause Clear demo. The license requires its notices to
survive redistribution, and a rebrand had replaced every one of them with ours:
the LICENSE text, 66 source headers and the app's copyright string. They are
back, each with our line beside it for our changes.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-23 01:55:03 -07:00

30 lines
913 B
Swift

// Copyright © 2025 Zama. All rights reserved.
// Copyright © 2025 Lux Industries Inc.
import SwiftUI
struct OnAppearAgainModifier: ViewModifier {
@Environment(\.scenePhase) private var scenePhase
let action: () -> Void
func body(content: Content) -> some View {
content
.onChange(of: scenePhase) { _, newPhase in
if newPhase == .active {
action() // When coming back from background (or inactive state)
}
}
.onAppear()
.task {
action() // On app launch
}
}
}
extension View {
/// Adds an action to perform before this view appears _the first time_, **or anytime this view comes back from background**
func onAppearAgain(perform action: @escaping () -> Void) -> some View {
self.modifier(OnAppearAgainModifier(action: action))
}
}