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 @@ -27,6 +27,7 @@ public struct DropdownMenuItem {
let systemImage: String?
let imageColor: Color?
let isChecked: Bool
let isDisabled: Bool
let role: ButtonRole?
let kind: Kind

Expand All @@ -35,13 +36,15 @@ public struct DropdownMenuItem {
systemImage: String? = nil,
imageColor: Color? = nil,
isChecked: Bool = false,
isDisabled: Bool = false,
role: ButtonRole? = nil,
action: @escaping () -> Void
) {
self.title = title
self.systemImage = systemImage
self.imageColor = imageColor
self.isChecked = isChecked
self.isDisabled = isDisabled
self.role = role
self.kind = .action(action)
}
Expand All @@ -56,6 +59,7 @@ public struct DropdownMenuItem {
self.systemImage = systemImage
self.imageColor = imageColor
self.isChecked = false
self.isDisabled = false
self.role = nil
self.kind = .submenu(submenu)
}
Expand Down Expand Up @@ -261,6 +265,7 @@ private struct DropdownMenuRow: View {
let systemImage: String?
let imageColor: Color?
let isChecked: Bool
let isDisabled: Bool
let isDestructive: Bool
let hasSubmenu: Bool
let action: () -> Void
Expand All @@ -275,6 +280,7 @@ private struct DropdownMenuRow: View {
self.systemImage = systemImage
self.imageColor = imageColor
self.isChecked = false
self.isDisabled = false
self.isDestructive = false
self.hasSubmenu = false
self.action = action
Expand All @@ -285,6 +291,7 @@ private struct DropdownMenuRow: View {
self.systemImage = item.systemImage
self.imageColor = item.imageColor
self.isChecked = item.isChecked
self.isDisabled = item.isDisabled
self.isDestructive = item.role == .destructive
if case .submenu = item.kind {
self.hasSubmenu = true
Expand All @@ -304,7 +311,7 @@ private struct DropdownMenuRow: View {
if let systemImage {
Image(systemName: systemImage)
.font(.system(size: iconSize * 0.8))
.foregroundStyle(isDestructive ? Color.danger : imageColor ?? .secondaryLabel)
.foregroundStyle(isDisabled ? Color.tertiaryLabel : isDestructive ? .danger : imageColor ?? .secondaryLabel)
.frame(width: iconSize, height: iconSize)
}

Expand All @@ -316,20 +323,22 @@ private struct DropdownMenuRow: View {
if isChecked {
Image(systemName: "checkmark")
.font(.system(size: iconSize * 0.8, weight: .semibold))
.foregroundStyle(Color.label)
.foregroundStyle(isDisabled ? Color.tertiaryLabel : .label)
} else if hasSubmenu {
Image(systemName: "chevron.right")
.font(.system(size: iconSize * 0.7, weight: .semibold))
.foregroundStyle(Color.secondaryLabel)
}
}
.font(.system(size: isiOSAppOnMac ? 13 * AdaptiveSize.boardScale : 15))
.foregroundStyle(isDestructive ? Color.danger : .primary)
// 고를 수 없는 항목은 흐린 글자
.foregroundStyle(isDisabled ? Color.tertiaryLabel : isDestructive ? .danger : .primary)
.frame(maxWidth: .infinity, minHeight: isiOSAppOnMac ? 28 * AdaptiveSize.boardScale : 44)
.padding(.horizontal, isiOSAppOnMac ? 10 * AdaptiveSize.boardScale : 14)
.contentShape(.rect)
}
.buttonStyle(DropdownMenuRowStyle(radius: CornerRadius.control))
.disabled(isDisabled)
}
}

Expand All @@ -341,14 +350,15 @@ private struct DropdownMenuRowStyle: ButtonStyle {
}

private struct Highlight: View {
@Environment(\.isEnabled) private var isEnabled
@State private var isHovered = false
let configuration: Configuration
let radius: CGFloat

var body: some View {
configuration.label
.background(
configuration.isPressed || isHovered ? Color.fill : .clear,
isEnabled && (configuration.isPressed || isHovered) ? Color.fill : .clear,
in: .rect(cornerRadius: radius)
)
.onHover { isHovered = $0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,42 @@ struct ActivityCard: View {
}
.buttonStyle(.plain)
}
Menu {
ForEach(ActivityKindItem.selectableItems) { activityKindItem in
if let activityKind = ActivityKind(rawValue: activityKindItem.rawValue) {
switch activityKind {
// 제목 줄 오른쪽 끝 버튼이라 메뉴 오른쪽 끝을 버튼 오른쪽 끝에 맞춤
DropdownMenu(
alignment: .trailing,
sections: [
DropdownMenuSection(items: ActivityKindItem.selectableItems.compactMap { activityKindItem in
switch ActivityKind(rawValue: activityKindItem.rawValue) {
case .created:
Toggle(activityKindItem.title, isOn: $store.isCreatedActivitySelected)
.disabled(store.isCreatedActivityToggleDisabled)
DropdownMenuItem(
activityKindItem.title,
isChecked: store.isCreatedActivitySelected,
isDisabled: store.isCreatedActivityToggleDisabled
) {
store.send(.binding(.set(\.isCreatedActivitySelected, !store.isCreatedActivitySelected)))
}
case .completed:
Toggle(activityKindItem.title, isOn: $store.isCompletedActivitySelected)
.disabled(store.isCompletedActivityToggleDisabled)
DropdownMenuItem(
activityKindItem.title,
isChecked: store.isCompletedActivitySelected,
isDisabled: store.isCompletedActivityToggleDisabled
) {
store.send(.binding(.set(\.isCompletedActivitySelected, !store.isCompletedActivitySelected)))
}
case .deleted:
Toggle(activityKindItem.title, isOn: $store.isDeletedActivitySelected)
.disabled(store.isDeletedActivityToggleDisabled)
DropdownMenuItem(
activityKindItem.title,
isChecked: store.isDeletedActivitySelected,
isDisabled: store.isDeletedActivityToggleDisabled
) {
store.send(.binding(.set(\.isDeletedActivitySelected, !store.isDeletedActivitySelected)))
}
case nil:
nil
}
}
}
} label: {
})
]
) {
Image(systemName: "line.3.horizontal.decrease")
.foregroundStyle(Color.label)
}
Expand Down Expand Up @@ -243,14 +262,17 @@ struct QuarterPickerSheet: View {
.frame(height: 1)
}

Menu {
Picker("", selection: $store.selectedQuarterPickerYear) {
ForEach(store.availableQuarterYears, id: \.self) { year in
Text(verbatim: String(year))
.tag(year)
}
}
} label: {
// 연도 값이 행 오른쪽 끝에 있어 메뉴 오른쪽 끝을 행 오른쪽 끝에 맞춤
DropdownMenu(
alignment: .trailing,
sections: [
DropdownMenuSection(items: store.availableQuarterYears.map { year in
DropdownMenuItem(String(year), isChecked: store.selectedQuarterPickerYear == year) {
store.send(.binding(.set(\.selectedQuarterPickerYear, year)))
}
})
]
) {
HStack(spacing: 10 * AdaptiveSize.boardScale) {
Text(String(localized: "profile_year", bundle: PresentationResources.bundle))
.foregroundStyle(Color.label)
Expand All @@ -265,7 +287,6 @@ struct QuarterPickerSheet: View {
.frame(minHeight: isiOSAppOnMac ? 38 * AdaptiveSize.boardScale : 50)
.contentShape(.rect)
}
.buttonStyle(.plain)
.padding(.horizontal, isiOSAppOnMac ? 14 * AdaptiveSize.boardScale : 16)
.padding(.vertical, isiOSAppOnMac ? 8 * AdaptiveSize.boardScale : 12)

Expand Down Expand Up @@ -319,17 +340,26 @@ struct QuarterPickerSheet: View {
.font(.adaptive(.subheadline))
.foregroundStyle(Color.secondaryLabel)
Spacer()
Picker(
"",
selection: $store.selectedQuarterPickerYear
DropdownMenu(
alignment: .trailing,
sections: [
DropdownMenuSection(items: store.availableQuarterYears.map { year in
DropdownMenuItem(String(year), isChecked: store.selectedQuarterPickerYear == year) {
store.send(.binding(.set(\.selectedQuarterPickerYear, year)))
}
})
]
) {
ForEach(store.availableQuarterYears, id: \.self) { year in
Text(verbatim: String(year))
.tag(year)
HStack(spacing: 4) {
Text(verbatim: String(store.selectedQuarterPickerYear))
.foregroundStyle(Color.label)
Image(systemName: "chevron.up.chevron.down")
.font(.adaptive(.caption2))
.foregroundStyle(Color.secondaryLabel)
}
.font(.adaptive(.subheadline))
.contentShape(.rect)
}
.pickerStyle(.menu)
.labelsHidden()
}

// 시트가 닫히며 사라지는 동안에도 버튼 줄을 그리도록 지연 그리기 없는 한 줄 배치
Expand Down