Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
18 changes: 16 additions & 2 deletions Projects/Feature/GoalDetail/Sources/Detail/GoalDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,22 @@ private extension GoalDetailView {
cardOffset = repeatedCardOffset(for: width)
isCrossingDuringDrag = shouldCrossCards(for: width)
}
.onEnded { _ in
.onEnded { value in
guard !store.isEditing else { return }

let translation = value.translation
let width = resistedDragWidth(
for: translation.width,
velocity: value.velocity.width
)

guard abs(width) >= abs(translation.height) else {
withAnimation(.spring(response: 0.2, dampingFraction: 0.94)) {
resetDragState()
}
return
}

withAnimation(.spring(response: 0.2, dampingFraction: 0.94)) {
resetDragState()
store.send(.view(.cardSwiped))
Expand Down Expand Up @@ -431,7 +445,7 @@ private extension GoalDetailView {
.padding(.bottom, 26)
.frame(width: rectFrame.width, height: rectFrame.height, alignment: .bottom)
.rotationEffect(frontCardRotation)
.offset(x: posX, y: posY - keyboardInset)
.offset(x: posX + cardOffset, y: posY - keyboardInset)
.animation(.easeOut(duration: 0.25), value: keyboardInset)
}
}
Expand Down
19 changes: 14 additions & 5 deletions Projects/Feature/MakeGoal/Sources/MakeGoalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ private extension MakeGoalView {
Spacer()

if store.showPeriodCount {
dropDownButton { store.send(.view(.periodSelected)) }
dropDownButton(text: store.periodCountText) {
store.send(.view(.periodSelected))
}
}
}
}
Expand All @@ -190,7 +192,9 @@ private extension MakeGoalView {

Spacer()

dropDownButton { store.send(.view(.startDateTapped)) }
dropDownButton(text: store.startDateText) {
store.send(.view(.startDateTapped))
}
}
.frame(height: 32)
.padding(.vertical, 16)
Expand All @@ -214,7 +218,9 @@ private extension MakeGoalView {

Spacer()

dropDownButton { store.send(.view(.endDateTapped)) }
dropDownButton(text: store.endDateText) {
store.send(.view(.endDateTapped))
}
}
.padding(.vertical, 21.5)
}
Expand All @@ -236,9 +242,12 @@ private extension MakeGoalView {
.padding(.vertical, -1)
}

func dropDownButton(_ action: @escaping () -> Void) -> some View {
func dropDownButton(
text: String,
action: @escaping () -> Void
) -> some View {
HStack(spacing: 0) {
Text(store.startDateText)
Text(text)
.typography(.b2_14r)
.foregroundStyle(Color.Gray.gray500)
Image.Icon.Symbol.arrow2Down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ import SwiftUI

struct TXRoundButton: View {
let shape: TXButtonShape
let allowsActionWhenDisabled: Bool
let onTap: () -> Void

public var body: some View {
if case let .round(style, size, state) = shape {
Button {
onTap()
switch state {
case .disabled:
if allowsActionWhenDisabled {
onTap()
}
case .standard:
onTap()
}
} label: {
ZStack {
Capsule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import SwiftUI
/// ```
public struct TXButton: View {
let shape: TXButtonShape
let allowsActionWhenDisabled: Bool
let onTap: () -> Void

/// 버튼을 생성합니다.
Expand All @@ -41,9 +42,11 @@ public struct TXButton: View {
/// ```
public init(
shape: TXButtonShape,
allowsActionWhenDisabled: Bool = false,
onTap: @escaping () -> Void
) {
self.shape = shape
self.allowsActionWhenDisabled = allowsActionWhenDisabled
self.onTap = onTap
}

Expand All @@ -65,6 +68,7 @@ public struct TXButton: View {
case .round:
TXRoundButton(
shape: shape,
allowsActionWhenDisabled: allowsActionWhenDisabled,
onTap: onTap
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private extension GoalCardView {
size: .s,
state: isButtonDisabled ? .disabled : .standard
),
allowsActionWhenDisabled: true,
onTap: { buttonAction?() }
)
.padding(.bottom, 14)
Expand Down
Loading