2021-12-27 22:33:27 +08:00
|
|
|
//
|
|
|
|
// BaseNavigationView.swift
|
|
|
|
// PushDeer
|
|
|
|
//
|
|
|
|
// Created by HEXT on 2021/12/26.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
/// 具有导航栏结构的基础容器View, APP内的页面基本上都可以使用它包装
|
|
|
|
struct BaseNavigationView<Content : View> : View {
|
|
|
|
/// 导航栏标题
|
2022-01-15 22:13:23 +08:00
|
|
|
let title: LocalizedStringKey
|
2021-12-27 22:33:27 +08:00
|
|
|
/// 页面主体View
|
|
|
|
@ViewBuilder let contentView: Content
|
|
|
|
|
2022-01-16 00:10:47 +08:00
|
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
|
2021-12-27 22:33:27 +08:00
|
|
|
var body: some View {
|
|
|
|
NavigationView {
|
|
|
|
ZStack {
|
2022-01-15 22:13:23 +08:00
|
|
|
// VStack HStack Spacer 组合起来撑到最大
|
|
|
|
VStack {
|
|
|
|
HStack {
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
Spacer()
|
|
|
|
}
|
2021-12-27 22:33:27 +08:00
|
|
|
contentView
|
|
|
|
}
|
|
|
|
.background(
|
2022-01-16 00:10:47 +08:00
|
|
|
Image("deer.gray")
|
|
|
|
.offset(x: -150, y: -10)
|
|
|
|
.opacity(colorScheme == .dark ? 0.4 : 1),
|
2021-12-27 22:33:27 +08:00
|
|
|
alignment: .bottom
|
|
|
|
)
|
|
|
|
.navigationBarTitle(title)
|
|
|
|
}
|
|
|
|
.navigationViewStyle(.stack)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BaseNavigationView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
BaseNavigationView(title: "标题") {
|
|
|
|
Text("内容")
|
|
|
|
}
|
2022-01-16 00:10:47 +08:00
|
|
|
.environment(\.colorScheme, .dark)
|
2021-12-27 22:33:27 +08:00
|
|
|
}
|
|
|
|
}
|