feat: 更新登出确认逻辑和弹窗实现
- 修改MainFeature以将登出操作的Action名称从.logoutTapped更新为.logoutConfirmed,增强逻辑清晰度。 - 在AppSettingView中新增登出确认弹窗的实现,替换原有的登出确认逻辑,提升用户体验和交互性。 - 确保弹窗内容本地化,增强多语言支持。
This commit is contained in:
@@ -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):
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user