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 editNicknameTapped
case logoutTapped
case dismissTapped
//
case loadUserInfo
@@ -80,6 +81,10 @@ struct AppSettingFeature {
// FeatureMainFeature
// .noneMainFeatureAppSettingFeature.Action.logoutTapped
}
case .dismissTapped:
// MainFeature navigationPath pop
return .none
case .loadUserInfo:
state.isLoadingUserInfo = true

View File

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

View File

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