Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ struct TabScreen: View {
case .profile:
ProfileView(
isSelected: isSelected,
settingsStore: store.scope(state: \.settings, action: \.settings),
windowEvent: windowEvent
settingsStore: store.scope(state: \.settings, action: \.settings)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ struct ActivityCard: View {
// 행 배치를 바꾸지 않고 선택한 행 배경만 바깥으로 넓힘
// 선택 표시는 다른 목록 행과 같은 회색
.background {
if usesPaneLayout && store.showsDetailInPane
&& store.detail?.todoId == activity.todoId && store.detail?.showEditButton == false {
if usesPaneLayout && store.showsDetailInPane && store.detail?.todoId == activity.todoId {
RoundedRectangle(cornerRadius: CornerRadius.control)
.fill(Color.fill)
.padding(.horizontal, -8)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct ProfileFeature {
@ObservableState
struct State: Equatable {
@Presents var alert: AlertState<Never>?
// 활동 기록이나 최근 Todo에서 연 Todo 상세, 활동 기록 Todo는 고칠 수 없어 편집 버튼 없이 표시
// 활동 기록이나 최근 Todo에서 연 Todo 상세, 프로필은 보기만 하는 요약이라 편집 버튼 없이 표시
// 좁은 창은 내비게이션에 쌓고 사이드바가 있는 창은 상세 판이나 오른쪽 칸에 표시
@Presents var detail: TodoDetailFeature.State?
var name = ""
Expand Down Expand Up @@ -68,7 +68,7 @@ struct ProfileFeature {
case detail(PresentationAction<TodoDetailFeature.Action>)
case binding(BindingAction<State>)
// 사이드바가 있는 창은 연 곳(상세 판이나 오른쪽 칸)의 내용을 바꿈
case selectTodo(String, isEditable: Bool)
case selectTodo(String)
case startObserving
case fetchData
case refresh
Expand Down Expand Up @@ -128,10 +128,10 @@ struct ProfileFeature {
state.showsDetailInPane = false
case .detail:
break
case .selectTodo(let todoId, let isEditable):
case .selectTodo(let todoId):
// 이미 연 Todo는 불러온 상세와 열어 둔 시트를 그대로 둠
if state.detail?.todoId != todoId || state.detail?.showEditButton != isEditable {
state.detail = TodoDetailFeature.State(todoId: todoId, showEditButton: isEditable)
if state.detail?.todoId != todoId {
state.detail = TodoDetailFeature.State(todoId: todoId, showEditButton: false)
}
case .binding(\.isCreatedActivitySelected):
return updateHeatmapActivityKindsEffectIfNeeded(.created, state: state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@ public struct ProfileView: View {
@State private var store: StoreOf<ProfileFeature>
@Bindable private var settingsStore: StoreOf<SettingsFeature>
private let isSelected: Bool
private let windowEvent: TodoEditorWindowEvent

public init(
isSelected: Bool,
settingsStore: StoreOf<SettingsFeature>,
windowEvent: TodoEditorWindowEvent
settingsStore: StoreOf<SettingsFeature>
) {
let store = Store(initialState: ProfileFeature.State()) {
ProfileFeature()
}
self._store = State(initialValue: store)
self.settingsStore = settingsStore
self.isSelected = isSelected
self.windowEvent = windowEvent
}

public var body: some View {
Expand All @@ -45,11 +42,11 @@ public struct ProfileView: View {
LazyVStack(alignment: .leading, spacing: 0) {
UserInfoCard(store: store, isSelected: isSelected)
ActivityCard(store: store) { todoId in
store.send(.selectTodo(todoId, isEditable: false))
store.send(.selectTodo(todoId))
}
ProfileGoalSummary(store: store)
RecentActivityCard(store: store) { todoId in
store.send(.selectTodo(todoId, isEditable: true))
store.send(.selectTodo(todoId))
}
}
.padding(.bottom, 24)
Expand All @@ -74,20 +71,20 @@ public struct ProfileView: View {
inPane: store.showsDetailInPane,
isActive: isSelected
) { detailStore, onClose in
// 활동 기록 Todo는 고칠 수 없어 편집 결과를 받을 창 이벤트 없이 표시
// 프로필에서 연 Todo는 고칠 수 없어 편집 결과를 받을 창 이벤트 없이 표시
TodoDetailView(
store: detailStore,
windowEvent: detailStore.showEditButton ? windowEvent : nil,
windowEvent: nil,
isPaneDetail: onClose != nil,
onClose: onClose
)
// 칸 안에서 다른 Todo로 바꾸거나 같은 Todo를 다른 목록에서 다시 고르면 그 Todo를 조회
.id([AnyHashable(detailStore.todoId), detailStore.showEditButton])
// 칸 안에서 다른 Todo로 바꾸면 그 Todo를 조회
.id(detailStore.todoId)
} panel: { detailStore in
TodoDetailPanel(
store: detailStore,
location: Text("nav_profile", bundle: PresentationResources.bundle),
windowEvent: detailStore.showEditButton ? windowEvent : nil,
windowEvent: nil,
onMoveToPane: {
store.send(.binding(.set(\.showsDetailInPane, true)))
}
Expand All @@ -98,11 +95,10 @@ public struct ProfileView: View {
if let detail = store.detail {
TodoDetailSideBarView(
todoId: detail.todoId,
isEditable: detail.showEditButton,
windowEvent: windowEvent
isEditable: false,
windowEvent: nil
)
// 같은 Todo도 편집할 수 있는지가 바뀌면 다시 만듦
.id([AnyHashable(detail.todoId), detail.showEditButton])
.id(detail.todoId)
}
}
// 좁은 창은 설정 목록과 고른 항목 화면을 프로필 위에 쌓고, 사이드바가 있는 창은 창 전체 설정 화면에 그려 쌓지 않음
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ struct RecentActivityCard: View {
} label: {
RecentTodoRow(
todo: todo,
isSelected: usesPaneLayout && store.showsDetailInPane
&& store.detail?.todoId == todo.id && store.detail?.showEditButton == true
isSelected: usesPaneLayout && store.showsDetailInPane && store.detail?.todoId == todo.id
)
.todoDetailPreview(todoId: todo.id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,16 @@ struct ProfileFeatureTests {
ProfileFeature()
}

await store.send(.selectTodo("activity", isEditable: false)) {
await store.send(.selectTodo("activity")) {
$0.detail = TodoDetailFeature.State(todoId: "activity", showEditButton: false)
}
await store.send(.binding(.set(\.showsDetailInPane, true))) {
$0.showsDetailInPane = true
}
// 같은 Todo도 최근 Todo에서 고르면 편집할 수 있는 상세로 바꿈
await store.send(.selectTodo("activity", isEditable: true)) {
$0.detail = TodoDetailFeature.State(todoId: "activity", showEditButton: true)
// 다른 목록에서 같은 Todo를 고르면 연 상세를 그대로 둠
await store.send(.selectTodo("activity"))
await store.send(.selectTodo("recent")) {
$0.detail = TodoDetailFeature.State(todoId: "recent", showEditButton: false)
}
await store.send(.detail(.dismiss)) {
$0.detail = nil
Expand Down