feat: 新增返回按钮功能以优化设置页面导航

- 在AppSettingFeature中新增dismissTapped事件,处理返回操作。
- 更新MainFeature以监听dismissTapped事件,支持导航栈的pop操作。
- 在AppSettingView中实现返回按钮,提升用户体验与界面交互性。
- 隐藏导航栏以优化设置页面的视觉效果。
This commit is contained in:
edwinQQQ
2025-07-25 14:43:27 +08:00
parent fb09ddb956
commit 815091a2ff
3 changed files with 20 additions and 16 deletions

View File

@@ -35,6 +35,7 @@ struct AppSettingFeature {
case onAppear case onAppear
case editNicknameTapped case editNicknameTapped
case logoutTapped case logoutTapped
case dismissTapped
// //
case loadUserInfo case loadUserInfo
@@ -81,6 +82,10 @@ struct AppSettingFeature {
// .noneMainFeatureAppSettingFeature.Action.logoutTapped // .noneMainFeatureAppSettingFeature.Action.logoutTapped
} }
case .dismissTapped:
// MainFeature navigationPath pop
return .none
case .loadUserInfo: case .loadUserInfo:
state.isLoadingUserInfo = true state.isLoadingUserInfo = true
state.userInfoError = nil state.userInfoError = nil

View File

@@ -103,6 +103,12 @@ struct MainFeature {
// //
state.isLoggedOut = true state.isLoggedOut = true
return .none return .none
case .appSettingAction(.dismissTapped):
// pop
if !state.navigationPath.isEmpty {
state.navigationPath.removeLast()
}
return .none
case .appSettingAction(.updateUser(.success)): case .appSettingAction(.updateUser(.success)):
// Me // Me
return .send(.me(.refresh)) return .send(.me(.refresh))

View File

@@ -21,6 +21,7 @@ struct AppSettingView: View {
WithViewStore(store, observe: { $0 }) { viewStore in WithViewStore(store, observe: { $0 }) { viewStore in
WithPerceptionTracking{ WithPerceptionTracking{
mainContent(viewStore: viewStore) mainContent(viewStore: viewStore)
.navigationBarHidden(true)
.photosPicker( .photosPicker(
isPresented: $showPhotoPicker, isPresented: $showPhotoPicker,
selection: $selectedPhotoItem, selection: $selectedPhotoItem,
@@ -53,19 +54,7 @@ struct AppSettingView: View {
ZStack { ZStack {
Color(red: 22/255, green: 17/255, blue: 44/255).ignoresSafeArea() Color(red: 22/255, green: 17/255, blue: 44/255).ignoresSafeArea()
VStack(spacing: 0) { VStack(spacing: 0) {
//
// Text("nickname: \(viewStore.nickname)\navatarURL: \(String(describing: viewStore.avatarURL))\nuserInfo: \(String(describing: viewStore.userInfo))\nuserInfoError: \(String(describing: viewStore.userInfoError))")
// .foregroundColor(.yellow)
// .font(.system(size: 12))
// .padding(8)
//
topBar topBar
//
Button("测试跳转TestPushView") {
viewStore.send(.testPushTapped)
}
.padding()
ScrollView { ScrollView {
VStack(spacing: 32) { VStack(spacing: 32) {
// //
@@ -117,10 +106,14 @@ struct AppSettingView: View {
// MARK: - // MARK: -
private var topBar: some View { private var topBar: some View {
HStack { HStack {
Button(action: {}) { WithViewStore(store, observe: { $0 }) { viewStore in
Image(systemName: "chevron.left") Button(action: {
.foregroundColor(.white) viewStore.send(.dismissTapped)
.font(.system(size: 20, weight: .medium)) }) {
Image(systemName: "chevron.left")
.foregroundColor(.white)
.font(.system(size: 20, weight: .medium))
}
} }
Spacer() Spacer()