From 815091a2ff937efe7e5d644f595a627ca243dd55 Mon Sep 17 00:00:00 2001 From: edwinQQQ Date: Fri, 25 Jul 2025 14:43:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=8A=9F=E8=83=BD=E4=BB=A5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在AppSettingFeature中新增dismissTapped事件,处理返回操作。 - 更新MainFeature以监听dismissTapped事件,支持导航栈的pop操作。 - 在AppSettingView中实现返回按钮,提升用户体验与界面交互性。 - 隐藏导航栏以优化设置页面的视觉效果。 --- yana/Features/AppSettingFeature.swift | 5 +++++ yana/Features/MainFeature.swift | 6 ++++++ yana/Views/AppSettingView.swift | 25 +++++++++---------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/yana/Features/AppSettingFeature.swift b/yana/Features/AppSettingFeature.swift index 28a458f..3362432 100644 --- a/yana/Features/AppSettingFeature.swift +++ b/yana/Features/AppSettingFeature.swift @@ -35,6 +35,7 @@ struct AppSettingFeature { case onAppear case editNicknameTapped case logoutTapped + case dismissTapped // 用户信息相关 case loadUserInfo @@ -80,6 +81,10 @@ struct AppSettingFeature { // 向上层Feature传递登出事件(需在MainFeature处理) // 这里直接返回.none,由MainFeature监听AppSettingFeature.Action.logoutTapped后处理 } + + case .dismissTapped: + // 返回上一页,由 MainFeature 处理 navigationPath 的 pop 操作 + return .none case .loadUserInfo: state.isLoadingUserInfo = true diff --git a/yana/Features/MainFeature.swift b/yana/Features/MainFeature.swift index c02f4fd..64c17ab 100644 --- a/yana/Features/MainFeature.swift +++ b/yana/Features/MainFeature.swift @@ -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)) diff --git a/yana/Views/AppSettingView.swift b/yana/Views/AppSettingView.swift index 7436241..f3662a6 100644 --- a/yana/Views/AppSettingView.swift +++ b/yana/Views/AppSettingView.swift @@ -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()