feat: 更新Info.plist和AppSettingView以支持相机和图片选择功能

- 在Info.plist中新增相机使用说明,确保应用能够访问相机功能。
- 在AppSettingFeature中新增showImagePicker状态和setShowImagePicker动作,支持图片选择弹窗的显示。
- 在AppSettingView中整合图片选择与预览功能,优化用户体验。
- 更新MainView以简化导航逻辑,提升代码可读性与维护性。
- 在ImagePickerWithPreview组件中实现相机和相册选择功能,增强交互性。
This commit is contained in:
edwinQQQ
2025-07-25 18:47:11 +08:00
parent 2f3ef22ce5
commit ac0d622c97
6 changed files with 178 additions and 71 deletions

View File

@@ -33,18 +33,7 @@ struct InternalMainView: View {
GeometryReader { geometry in
contentView(geometry: geometry, viewStore: viewStore)
.navigationDestination(for: MainFeature.Destination.self) { destination in
let view: AnyView
switch destination {
case .appSetting:
if let appSettingStore = store.scope(state: \.appSettingState, action: \.appSettingAction) {
view = AnyView(AppSettingView(store: appSettingStore))
} else {
view = AnyView(Text("appSettingState is nil"))
}
case .testView:
view = AnyView(TestView())
}
return view
DestinationView(destination: destination, store: self.store)
}
.onChange(of: path) { newPath in
viewStore.send(.navigationPathChanged(newPath))
@@ -63,6 +52,28 @@ struct InternalMainView: View {
}
}
struct DestinationView: View {
let destination: MainFeature.Destination
let store: StoreOf<MainFeature>
var body: some View {
switch destination {
case .appSetting:
IfLetStore(
store.scope(state: \.appSettingState, action: \.appSettingAction),
then: { store in
WithPerceptionTracking {
AppSettingView(store: store)
}
},
else: { Text("appSettingState is nil") }
)
case .testView:
TestView()
}
}
}
private func contentView(geometry: GeometryProxy, viewStore: ViewStoreOf<MainFeature>) -> some View {
WithPerceptionTracking {
ZStack {
@@ -74,31 +85,45 @@ struct InternalMainView: View {
.clipped()
.ignoresSafeArea(.all)
//
ZStack {
FeedListView(store: store.scope(
state: \.feedList,
action: \.feedList
))
.isHidden(viewStore.selectedTab != .feed)
MeView(
store: store.scope(
state: \.me,
action: \.me
)
)
.isHidden(viewStore.selectedTab != .other)
}
MainContentView(
store: store,
selectedTab: viewStore.selectedTab
)
.frame(maxWidth: .infinity, maxHeight: .infinity)
//
VStack {
Spacer()
BottomTabView(selectedTab: viewStore.binding(
get: { Tab(rawValue: $0.selectedTab.rawValue) ?? .feed },
send: { MainFeature.Action.selectTab(MainFeature.Tab(rawValue: $0.rawValue) ?? .feed) }
))
BottomTabView(selectedTab: viewStore.binding(
get: { Tab(rawValue: $0.selectedTab.rawValue) ?? .feed },
send: { MainFeature.Action.selectTab(MainFeature.Tab(rawValue: $0.rawValue) ?? .feed) }
))
}
.padding(.bottom, geometry.safeAreaInsets.bottom + 60)
}
}
}
}
struct MainContentView: View {
let store: StoreOf<MainFeature>
let selectedTab: MainFeature.Tab
var body: some View {
Group {
if selectedTab == .feed {
FeedListView(store: store.scope(
state: \.feedList,
action: \.feedList
))
} else if selectedTab == .other {
MeView(
store: store.scope(
state: \.me,
action: \.me
)
)
} else {
EmptyView()
}
}
}
}