Files
simplex-chat/apps/ios/Shared/Views/Helpers/NavStackCompat.swift
Stanislav Dmitrenko a393bc8163 ios: Testing workaround of a crash (#1789)
* ios: Testing workaround of a crash

* another try

* complete

* added file

* enable swipe to go back from ChatView

* Revert "enable swipe to go back from ChatView"

This reverts commit 22de79505c.

* refactor

Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com>
2023-01-23 18:17:33 +00:00

44 lines
1.1 KiB
Swift

//
// NavStackCompat.swift
// SimpleX (iOS)
//
// Created by Evgeny on 23/01/2023.
// Copyright © 2023 SimpleX Chat. All rights reserved.
//
import SwiftUI
struct NavStackCompat <C: View, D: View>: View {
let isActive: Binding<Bool>
let destination: () -> D
let content: () -> C
var body: some View {
if #available(iOS 16, *) {
NavigationStack(path: Binding(
get: { isActive.wrappedValue ? [true] : [] },
set: { _ in }
)) {
ZStack {
NavigationLink(value: true) { EmptyView() }
content()
}
.navigationDestination(for: Bool.self) { show in
if show { destination() }
}
}
} else {
NavigationView {
ZStack {
NavigationLink(
destination: destination(),
isActive: isActive
) { EmptyView() }
content()
}
}
.navigationViewStyle(.stack)
}
}
}