feat: 更新登出确认逻辑和弹窗实现

- 修改MainFeature以将登出操作的Action名称从.logoutTapped更新为.logoutConfirmed,增强逻辑清晰度。
- 在AppSettingView中新增登出确认弹窗的实现,替换原有的登出确认逻辑,提升用户体验和交互性。
- 确保弹窗内容本地化,增强多语言支持。
This commit is contained in:
edwinQQQ
2025-07-31 18:39:53 +08:00
parent 01779a95c8
commit dc8ba46f86
2 changed files with 33 additions and 33 deletions

View File

@@ -114,8 +114,8 @@ struct MainFeature {
state.appSettingState = AppSettingFeature.State(nickname: nickname, avatarURL: avatarURL, userInfo: userInfo)
state.navigationPath.append(.appSetting)
return .none
case .appSettingAction(.logoutTapped):
//
case .appSettingAction(.logoutConfirmed):
//
state.isLoggedOut = true
return .none
case .appSettingAction(.dismissTapped):

View File

@@ -24,6 +24,37 @@ struct AppSettingView: View {
.onAppear {
store.send(.onAppear)
}
//
.alert(LocalizedString("appSetting.logoutConfirmation.title", comment: "确认退出"), isPresented: Binding(
get: { store.showLogoutConfirmation },
set: { store.send(.showLogoutConfirmation($0)) }
)) {
Button(LocalizedString("common.cancel", comment: "取消"), role: .cancel) {
store.send(.showLogoutConfirmation(false))
}
Button(LocalizedString("appSetting.logoutConfirmation.confirm", comment: "确认退出"), role: .destructive) {
store.send(.logoutConfirmed)
store.send(.showLogoutConfirmation(false))
}
} message: {
Text(LocalizedString("appSetting.logoutConfirmation.message", comment: "确定要退出当前账户吗?"))
}
//
.alert(LocalizedString("appSetting.aboutUs.title", comment: "关于我们"), isPresented: Binding(
get: { store.showAboutUs },
set: { store.send(.showAboutUs($0)) }
)) {
Button(LocalizedString("common.ok", comment: "确定")) {
store.send(.showAboutUs(false))
}
} message: {
VStack(alignment: .leading, spacing: 8) {
Text(LocalizedString("feedList.title", comment: "享受您的生活时光"))
.font(.headline)
Text(LocalizedString("feedList.slogan", comment: "疾病如同残酷的统治者,\n而时间是我们最宝贵的财富。\n我们活着的每一刻,都是对不可避免命运的胜利。"))
.font(.body)
}
}
}
@ViewBuilder
@@ -199,37 +230,6 @@ struct AppSettingView: View {
)
viewWithDeactivateAccount
//
.alert(LocalizedString("appSetting.logoutConfirmation.title", comment: "确认退出"), isPresented: Binding(
get: { store.showLogoutConfirmation },
set: { store.send(.showLogoutConfirmation($0)) }
)) {
Button(LocalizedString("common.cancel", comment: "取消"), role: .cancel) {
store.send(.showLogoutConfirmation(false))
}
Button(LocalizedString("appSetting.logoutConfirmation.confirm", comment: "确认退出"), role: .destructive) {
store.send(.logoutConfirmed)
store.send(.showLogoutConfirmation(false))
}
} message: {
Text(LocalizedString("appSetting.logoutConfirmation.message", comment: "确定要退出当前账户吗?"))
}
//
.alert(LocalizedString("appSetting.aboutUs.title", comment: "关于我们"), isPresented: Binding(
get: { store.showAboutUs },
set: { store.send(.showAboutUs($0)) }
)) {
Button(LocalizedString("common.ok", comment: "确定")) {
store.send(.showAboutUs(false))
}
} message: {
VStack(alignment: .leading, spacing: 8) {
Text(LocalizedString("feedList.title", comment: "享受您的生活时光"))
.font(.headline)
Text(LocalizedString("feedList.slogan", comment: "疾病如同残酷的统治者,\n而时间是我们最宝贵的财富。\n我们活着的每一刻,都是对不可避免命运的胜利。"))
.font(.body)
}
}
}
}