feat: 新增应用设置功能及相关视图
- 在MainFeature中集成AppSettingFeature,支持应用设置页面的导航与状态管理。 - 新增AppSettingView以展示用户头像和昵称编辑功能,提升用户体验。 - 更新MainView以支持应用设置页面的展示,增强导航功能。
This commit is contained in:
@@ -15,12 +15,14 @@ struct MainFeature: Reducer {
|
||||
// 新增:导航路径和设置页面 State
|
||||
var navigationPath: [Destination] = []
|
||||
var settingState: SettingFeature.State? = nil
|
||||
var appSettingState: AppSettingFeature.State? = nil
|
||||
}
|
||||
|
||||
// 新增:导航目标
|
||||
enum Destination: Hashable, Equatable {
|
||||
case setting
|
||||
case test
|
||||
case appSetting
|
||||
}
|
||||
|
||||
@CasePathable
|
||||
@@ -35,6 +37,8 @@ struct MainFeature: Reducer {
|
||||
case settingButtonTapped
|
||||
case settingAction(SettingFeature.Action)
|
||||
case testButtonTapped
|
||||
case appSettingButtonTapped
|
||||
case appSettingAction(AppSettingFeature.Action)
|
||||
}
|
||||
|
||||
var body: some ReducerOf<Self> {
|
||||
@@ -66,8 +70,8 @@ struct MainFeature: Reducer {
|
||||
return .none
|
||||
case .me(.settingButtonTapped):
|
||||
// 触发 push 到设置页
|
||||
state.settingState = SettingFeature.State()
|
||||
state.navigationPath.append(.setting)
|
||||
state.appSettingState = AppSettingFeature.State()
|
||||
state.navigationPath.append(.appSetting)
|
||||
return .none
|
||||
case .me:
|
||||
return .none
|
||||
@@ -76,6 +80,9 @@ struct MainFeature: Reducer {
|
||||
if !newPath.contains(.setting) {
|
||||
state.settingState = nil
|
||||
}
|
||||
if !newPath.contains(.appSetting) {
|
||||
state.appSettingState = nil
|
||||
}
|
||||
state.navigationPath = newPath
|
||||
return .none
|
||||
case .settingButtonTapped:
|
||||
@@ -87,11 +94,20 @@ struct MainFeature: Reducer {
|
||||
case .testButtonTapped:
|
||||
state.navigationPath.append(.test)
|
||||
return .none
|
||||
case .appSettingButtonTapped:
|
||||
state.appSettingState = AppSettingFeature.State()
|
||||
state.navigationPath.append(.appSetting)
|
||||
return .none
|
||||
case .appSettingAction:
|
||||
return .none
|
||||
}
|
||||
}
|
||||
// 设置页作用域
|
||||
.ifLet(\ .settingState, action: /Action.settingAction) {
|
||||
SettingFeature()
|
||||
}
|
||||
.ifLet(\ .appSettingState, action: /Action.appSettingAction) {
|
||||
AppSettingFeature()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user