feat: 新增返回按钮功能以优化设置页面导航
- 在AppSettingFeature中新增dismissTapped事件,处理返回操作。 - 更新MainFeature以监听dismissTapped事件,支持导航栈的pop操作。 - 在AppSettingView中实现返回按钮,提升用户体验与界面交互性。 - 隐藏导航栏以优化设置页面的视觉效果。
This commit is contained in:
@@ -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 {
|
|||||||
// 这里直接返回.none,由MainFeature监听AppSettingFeature.Action.logoutTapped后处理
|
// 这里直接返回.none,由MainFeature监听AppSettingFeature.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
|
||||||
|
@@ -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))
|
||||||
|
@@ -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()
|
||||||
|
Reference in New Issue
Block a user