mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-28 04:06:57 +02:00
fda0568d88
- Initial space creation flow
72 lines
2.2 KiB
Swift
72 lines
2.2 KiB
Swift
//
|
|
// Copyright 2021 New Vector Ltd
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
@available(iOS 13.0, *)
|
|
extension View {
|
|
func configureNavigationBar(configure: @escaping (UINavigationController) -> Void) -> some View {
|
|
modifier(NavigationConfigurationViewModifier(configure: configure))
|
|
}
|
|
}
|
|
|
|
@available(iOS 13.0.0, *)
|
|
struct NavigationConfigurationViewModifier: ViewModifier {
|
|
let configure: (UINavigationController) -> Void
|
|
|
|
func body(content: Content) -> some View {
|
|
content.background(NavigationConfigurator(configure: configure))
|
|
}
|
|
}
|
|
|
|
@available(iOS 13.0.0, *)
|
|
struct NavigationConfigurator: UIViewControllerRepresentable {
|
|
let configure: (UINavigationController) -> Void
|
|
|
|
func makeUIViewController(
|
|
context: UIViewControllerRepresentableContext<NavigationConfigurator>
|
|
) -> NavigationConfigurationViewController {
|
|
NavigationConfigurationViewController(configure: configure)
|
|
}
|
|
|
|
func updateUIViewController(
|
|
_ uiViewController: NavigationConfigurationViewController,
|
|
context: UIViewControllerRepresentableContext<NavigationConfigurator>
|
|
) { }
|
|
}
|
|
|
|
@available(iOS 13.0.0, *)
|
|
final class NavigationConfigurationViewController: UIViewController {
|
|
let configure: (UINavigationController) -> Void
|
|
|
|
init(configure: @escaping (UINavigationController) -> Void) {
|
|
self.configure = configure
|
|
super.init(nibName: nil, bundle: nil)
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
override func viewDidLayoutSubviews() {
|
|
super.viewDidLayoutSubviews()
|
|
|
|
if let navigationController = navigationController {
|
|
configure(navigationController)
|
|
}
|
|
}
|
|
}
|