mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-14 19:05:27 +00:00
old method
This commit is contained in:
@@ -13,20 +13,36 @@ class AppSheetState: ObservableObject {
|
||||
@Published var scenePhaseActive: Bool = false
|
||||
}
|
||||
|
||||
private struct PrivacySensitive: ViewModifier {
|
||||
// The code works but needs to be tested on different versions of iOS
|
||||
//struct PrivacySensitive: ViewModifier {
|
||||
// @AppStorage(DEFAULT_PRIVACY_PROTECT_SCREEN) private var protectScreen = false
|
||||
// @Environment(\.scenePhase) var scenePhase
|
||||
// @ObservedObject var appSheetState: AppSheetState = AppSheetState.shared
|
||||
//
|
||||
// func body(content: Content) -> some View {
|
||||
// if !protectScreen {
|
||||
// content
|
||||
// } else {
|
||||
// content.privacySensitive(!appSheetState.scenePhaseActive).redacted(reason: .privacy)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
struct PrivacySensitive: ViewModifier {
|
||||
@AppStorage(DEFAULT_PRIVACY_PROTECT_SCREEN) private var protectScreen = false
|
||||
@Environment(\.scenePhase) var scenePhase
|
||||
@ObservedObject var appSheetState: AppSheetState = AppSheetState.shared
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
if !protectScreen {
|
||||
if !protectScreen || appSheetState.scenePhaseActive {
|
||||
content
|
||||
} else {
|
||||
content.privacySensitive(!appSheetState.scenePhaseActive).redacted(reason: .privacy)
|
||||
content.privacySensitive(true).redacted(reason: .privacy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension View {
|
||||
func appSheet<Content>(
|
||||
isPresented: Binding<Bool>,
|
||||
|
||||
@@ -27,7 +27,7 @@ struct NewChatMenuButton: View {
|
||||
.scaledToFit()
|
||||
.frame(width: 24, height: 24)
|
||||
}
|
||||
.appSheet(isPresented: $showNewChatSheet) {
|
||||
.sheet(isPresented: $showNewChatSheet) {
|
||||
NewChatSheet(alert: $alert)
|
||||
.environment(\EnvironmentValues.refresh as! WritableKeyPath<EnvironmentValues, RefreshAction?>, nil)
|
||||
.alert(item: $alert) { a in
|
||||
@@ -83,6 +83,7 @@ struct NewChatSheet: View {
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink
|
||||
)
|
||||
.frame(maxWidth: .infinity)
|
||||
.modifier(PrivacySensitive())
|
||||
}
|
||||
.listRowSeparator(.hidden)
|
||||
.listRowBackground(Color.clear)
|
||||
@@ -137,6 +138,7 @@ struct NewChatSheet: View {
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink,
|
||||
showDeletedChatIcon: true
|
||||
)
|
||||
.modifier(PrivacySensitive())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +442,8 @@ struct DeletedChats: View {
|
||||
.listRowBackground(Color.clear)
|
||||
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
|
||||
.frame(maxWidth: .infinity)
|
||||
|
||||
.modifier(PrivacySensitive())
|
||||
|
||||
ContactsList(
|
||||
baseContactTypes: $baseContactTypes,
|
||||
searchMode: $searchMode,
|
||||
@@ -450,6 +453,7 @@ struct DeletedChats: View {
|
||||
searchChatFilteredBySimplexLink: $searchChatFilteredBySimplexLink,
|
||||
showDeletedChatIcon: false
|
||||
)
|
||||
.modifier(PrivacySensitive())
|
||||
}
|
||||
.navigationTitle("Archived contacts")
|
||||
.navigationBarTitleDisplayMode(.large)
|
||||
|
||||
Reference in New Issue
Block a user