feat: 新增返回按钮功能以优化设置页面导航
- 在AppSettingFeature中新增dismissTapped事件,处理返回操作。 - 更新MainFeature以监听dismissTapped事件,支持导航栈的pop操作。 - 在AppSettingView中实现返回按钮,提升用户体验与界面交互性。 - 隐藏导航栏以优化设置页面的视觉效果。
This commit is contained in:
@@ -35,6 +35,7 @@ struct AppSettingFeature {
|
||||
case onAppear
|
||||
case editNicknameTapped
|
||||
case logoutTapped
|
||||
case dismissTapped
|
||||
|
||||
// 用户信息相关
|
||||
case loadUserInfo
|
||||
@@ -81,6 +82,10 @@ struct AppSettingFeature {
|
||||
// 这里直接返回.none,由MainFeature监听AppSettingFeature.Action.logoutTapped后处理
|
||||
}
|
||||
|
||||
case .dismissTapped:
|
||||
// 返回上一页,由 MainFeature 处理 navigationPath 的 pop 操作
|
||||
return .none
|
||||
|
||||
case .loadUserInfo:
|
||||
state.isLoadingUserInfo = true
|
||||
state.userInfoError = nil
|
||||
|
@@ -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))
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user