-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30f54a1
commit 141e2db
Showing
5 changed files
with
193 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// ClearModifier.swift | ||
// | ||
// SPDX-FileCopyrightText: 2022 Istituto Nazionale Previdenza Sociale | ||
// | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
|
||
|
||
import SwiftUI | ||
import UIKit | ||
|
||
public struct ClearModifier<FullScreenContent: View>: ViewModifier { | ||
|
||
@Binding var isPresented: Bool | ||
let fullScreenContent: () -> (FullScreenContent) | ||
|
||
public func body(content: Content) -> some View { | ||
content | ||
.onChange(of: isPresented) { _ in | ||
UIView.setAnimationsEnabled(false) | ||
} | ||
.fullScreenCover(isPresented: $isPresented, | ||
content: { | ||
ZStack { | ||
fullScreenContent() | ||
} | ||
.edgesIgnoringSafeArea(.all) | ||
.background(ClearBackgroundView()) | ||
.onAppear { | ||
if !UIView.areAnimationsEnabled { | ||
UIView.setAnimationsEnabled(true) | ||
} | ||
} | ||
.onDisappear { | ||
if !UIView.areAnimationsEnabled { | ||
UIView.setAnimationsEnabled(true) | ||
} | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
|
||
private struct ClearBackgroundView: UIViewRepresentable { | ||
|
||
private class ClearView: UIView { | ||
|
||
override func didMoveToWindow() { | ||
super.didMoveToWindow() | ||
superview?.superview?.backgroundColor = .clear | ||
} | ||
} | ||
|
||
func makeUIView(context: Context) -> UIView { | ||
return ClearView() | ||
} | ||
|
||
func updateUIView(_ uiView: UIView, context: Context) {} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters