feat: 实现DetailView头像点击功能并优化MeView
- 在DetailView中添加头像点击功能,支持展示非当前用户的主页。 - 更新OptimizedDynamicCardView以支持头像点击回调。 - 修改DetailFeature以管理用户主页显示状态。 - 在MeView中添加关闭按钮支持,优化用户体验。 - 确保其他页面的兼容性,未影响现有功能。
This commit is contained in:
@@ -6,6 +6,15 @@ struct MeView: View {
|
||||
// 新增:图片预览状态
|
||||
@State private var previewItem: PreviewItem? = nil
|
||||
@State private var previewCurrentIndex: Int = 0
|
||||
// 新增:是否显示关闭按钮
|
||||
let showCloseButton: Bool
|
||||
// 新增:dismiss环境变量
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
init(store: StoreOf<MeFeature>, showCloseButton: Bool = false) {
|
||||
self.store = store
|
||||
self.showCloseButton = showCloseButton
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
WithPerceptionTracking {
|
||||
@@ -22,16 +31,35 @@ struct MeView: View {
|
||||
// 顶部栏,右上角设置按钮
|
||||
VStack {
|
||||
HStack {
|
||||
Spacer()
|
||||
Button(action: {
|
||||
store.send(.settingButtonTapped)
|
||||
}) {
|
||||
Image(systemName: "gearshape")
|
||||
.font(.system(size: 33, weight: .medium))
|
||||
.foregroundColor(.white)
|
||||
// 新增:关闭按钮(仅在present时显示)
|
||||
if showCloseButton {
|
||||
Button(action: {
|
||||
dismiss()
|
||||
}) {
|
||||
Image(systemName: "xmark")
|
||||
.font(.system(size: 20, weight: .medium))
|
||||
.foregroundColor(.white)
|
||||
.frame(width: 44, height: 44)
|
||||
.background(Color.black.opacity(0.3))
|
||||
.clipShape(Circle())
|
||||
}
|
||||
.padding(.leading, 16)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if !store.isDisplayingOtherUser {
|
||||
Button(action: {
|
||||
store.send(.settingButtonTapped)
|
||||
}) {
|
||||
Image(systemName: "gearshape")
|
||||
.font(.system(size: 33, weight: .medium))
|
||||
.foregroundColor(.white)
|
||||
}
|
||||
.padding(.trailing, 16)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
.padding(.trailing, 16)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
@@ -111,7 +139,7 @@ struct MeView: View {
|
||||
.foregroundColor(.white)
|
||||
|
||||
// 用户ID
|
||||
UserIDDisplay(uid: store.userInfo?.uid ?? 0)
|
||||
UserIDDisplay(uid: store.userInfo?.uid ?? 0, isDisplayCopy: true)
|
||||
}
|
||||
.padding(.horizontal, 32)
|
||||
}
|
||||
@@ -184,7 +212,8 @@ struct MeView: View {
|
||||
},
|
||||
onCardTap: {
|
||||
store.send(.showDetail(moment))
|
||||
}
|
||||
},
|
||||
onAvatarTap: nil // MeView中不需要头像点击功能
|
||||
)
|
||||
.padding(.horizontal, 12)
|
||||
}
|
||||
|
Reference in New Issue
Block a user