Skip to content

Commit

Permalink
[CAT-303] 시간 조절 버튼 UI 수정 (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok authored Aug 23, 2024
1 parent d38a8b6 commit 77be5c0
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,28 @@ public struct RestPomodoroView: View {
HStack(spacing: Alias.Spacing.small) {
Button(
subtitle: "5분",
leftIcon: DesignSystemAsset.Image._16MinusPrimary.swiftUIImage
leftIcon: DesignSystemAsset.Image._16MinusTertiary.swiftUIImage
) {
store.send(.minus5MinuteButtonTapped)
}
.buttonStyle(.select(isSelected: store.changeRestTimeByMinute < 0))
.frame(width: 68, height: 38)
.buttonStyle(
.selectChip(
isSelected: store.changeRestTimeByMinute < 0,
isDisabled: store.minus5MinuteButtonDisabled
)
)
Button(
subtitle: "5분",
leftIcon: DesignSystemAsset.Image._16PlusPrimary.swiftUIImage
leftIcon: DesignSystemAsset.Image._16PlusTertiary.swiftUIImage
) {
store.send(.plus5MinuteButtonTapped)
}
.buttonStyle(.select(isSelected: store.changeRestTimeByMinute > 0))
.frame(width: 68, height: 38)
.buttonStyle(
.selectChip(
isSelected: store.changeRestTimeByMinute > 0,
isDisabled: store.plus5MinuteButtonDisabled
)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,28 @@ public struct RestWaitingView: View {
HStack(spacing: Alias.Spacing.small) {
Button(
subtitle: "5분",
leftIcon: DesignSystemAsset.Image._16MinusPrimary.swiftUIImage
leftIcon: DesignSystemAsset.Image._16MinusTertiary.swiftUIImage
) {
store.send(.minus5MinuteButtonTapped)
}
.buttonStyle(.select(isSelected: store.changeFocusTimeByMinute < 0))
.frame(width: 68, height: 38)

.buttonStyle(
.selectChip(
isSelected: store.changeFocusTimeByMinute < 0,
isDisabled: store.minus5MinuteButtonDisabled
)
)
Button(
subtitle: "5분",
leftIcon: DesignSystemAsset.Image._16PlusPrimary.swiftUIImage
leftIcon: DesignSystemAsset.Image._16PlusTertiary.swiftUIImage
) {
store.send(.plus5MinuteButtonTapped)
}
.buttonStyle(.select(isSelected: store.changeFocusTimeByMinute > 0))
.frame(width: 68, height: 38)
.buttonStyle(
.selectChip(
isSelected: store.changeFocusTimeByMinute > 0,
isDisabled: store.plus5MinuteButtonDisabled
)
)
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "16_minus_tertiary.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
"images" : [
{
"filename" : "16_null_primary.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
"idiom" : "universal"
}
],
"info" : {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "16_plus_tertiary.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// SelectChipButtonStyle.swift
// DesignSystem
//
// Created by devMinseok on 8/24/24.
// Copyright © 2024 PomoNyang. All rights reserved.
//

import SwiftUI

public struct SelectChipButtonStyle: ButtonStyle {
let isSelected: Bool
let isDisabled: Bool

public init(
isSelected: Bool,
isDisabled: Bool
) {
self.isSelected = isSelected
self.isDisabled = isDisabled
}

public func makeBody(configuration: Configuration) -> some View {
configuration.label
.selectButtonDetailStyle(
SelectChipButtonStyleImpl(
isSelected: isSelected,
isDisabled: isDisabled
)
)
}
}

extension ButtonStyle where Self == SelectChipButtonStyle {
public static func selectChip(
isSelected: Bool,
isDisabled: Bool
) -> Self {
return SelectChipButtonStyle(isSelected: isSelected, isDisabled: isDisabled)
}
}

struct SelectChipButtonStyleImpl: SelectButtonDetailStyle {
let isSelected: Bool
let isDisabled: Bool

func makeBody(configuration: Configuration) -> some View {
HStack(spacing: Alias.Spacing.xSmall) {
configuration.leftIcon
configuration.subtitle
.font(Typography.bodySB)
.foregroundStyle(getSubtitleForegourndColor())
configuration.rightIcon
}
.padding(.horizontal, Alias.Spacing.medium)
.padding(.vertical, Alias.Spacing.small)
.background(
RoundedRectangle(cornerRadius: Alias.BorderRadius.xSmall)
.fill(getBackgroundColor())
.strokeBorder(isSelected ? Alias.Color.Background.accent1 : .clear, lineWidth: 1)
)
}

func getSubtitleForegourndColor() -> Color {
if isDisabled {
return Alias.Color.Text.disabled
} else {
return Alias.Color.Text.tertiary
}
}

func getBackgroundColor() -> Color {
if isSelected {
return Alias.Color.Background.accent2
} else {
return Alias.Color.Background.secondary
}
}
}

0 comments on commit 77be5c0

Please sign in to comment.