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 @@ -90,7 +90,10 @@ public struct GoalDetailReducer {
public var isCameraPermissionAlertPresented: Bool = false

public var selectedReactionEmoji: ReactionEmoji?
public var myHasEmoji: Bool { isFrontMyCard && selectedReactionEmoji != nil }
public var didPlayMyEmojiAppearAnimation: Bool = false
public var shouldShowMyEmojiAnimation: Bool {
isFrontMyCard && selectedReactionEmoji != nil && !didPlayMyEmojiAppearAnimation
}
public var isShowReactionBar: Bool { !isFrontMyCard && isCompleted }
public var isLoading: Bool { item == nil }
public var isFetchFailed: Bool = false
Expand Down Expand Up @@ -142,6 +145,7 @@ public struct GoalDetailReducer {
case navigationBarTapped(TXNavigationBar.Action)
case reactionEmojiTapped(ReactionEmoji)
case cardSwiped
case myEmojiAppearAnimationPlayed
case focusChanged(Bool)
case dimmedBackgroundTapped
case proofPhotoDismissed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ extension GoalDetailReducer {
state.createdAt = timeFormatter.displayText(from: state.currentCard?.createdAt)

return .none

case .view(.myEmojiAppearAnimationPlayed):
state.didPlayMyEmojiAppearAnimation = true
return .none

case let .view(.focusChanged(isFocused)):
state.isCommentFocused = isFocused
Expand Down
30 changes: 17 additions & 13 deletions Projects/Feature/GoalDetail/Sources/Detail/GoalDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public struct GoalDetailView: View {
@State private var rectFrame: CGRect = .zero
@State private var keyboardFrame: CGRect = .zero
@StateObject private var myEmojiFlyingReactionEmitter = FlyingReactionEmitter()
@State private var didPlayMyEmojiAppearAnimation = false
@State private var cardOffset: CGFloat = .zero
@State private var isCrossingDuringDrag: Bool = false

Expand Down Expand Up @@ -74,6 +73,10 @@ public struct GoalDetailView: View {
if shouldShowCommentOverlay {
floatingCommentOverlay
}

if store.isShowReactionBar {
reactionBar
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
Expand All @@ -85,7 +88,6 @@ public struct GoalDetailView: View {
store.send(.view(.onAppear))
}
.onDisappear {
didPlayMyEmojiAppearAnimation = false
myEmojiFlyingReactionEmitter.clear()
store.send(.view(.onDisappear))
}
Expand All @@ -107,7 +109,7 @@ public struct GoalDetailView: View {
myEmojiFlyingReactionOverlay
}
.txToast(item: $store.toast, customPadding: 54)
.txLoading(isPresented: store.isSavingPhotoLog)
.txLoading(isPresented: store.isLoading || store.isSavingPhotoLog)
}
}

Expand Down Expand Up @@ -260,12 +262,6 @@ private extension GoalDetailView {
.padding(.top, 14)
.padding(.trailing, 36)
}

if store.isShowReactionBar {
reactionBar
.padding(.top, Constants.emojiTopPadding)
.padding(.horizontal, 20)
}
}

var createdAtText: some View {
Expand All @@ -282,6 +278,13 @@ private extension GoalDetailView {
store.send(.view(.reactionEmojiTapped(emoji)))
}
)
.padding(.horizontal, Constants.reactionBarHorizontalPadding)
.position(
x: rectFrame.midX,
y: rectFrame.maxY
+ Constants.reactionBarTopPadding
+ Constants.reactionBarHeight / 2
)
}

var backgroundCard: some View {
Expand Down Expand Up @@ -538,17 +541,16 @@ private extension GoalDetailView {
containerWidth: CGFloat,
containerHeight: CGFloat
) {
guard store.myHasEmoji,
!didPlayMyEmojiAppearAnimation,
guard store.shouldShowMyEmojiAnimation,
let selectedEmoji = store.selectedReactionEmoji else { return }
didPlayMyEmojiAppearAnimation = true
myEmojiFlyingReactionEmitter.emit(
emoji: selectedEmoji,
config: .goalDetailBottom(
width: containerWidth,
height: containerHeight
)
)
store.send(.view(.myEmojiAppearAnimationPlayed))
}
}

Expand Down Expand Up @@ -615,7 +617,9 @@ private extension GoalDetailView {
static let minimumDragResistance: CGFloat = 0.35
static var cardTopPadding: CGFloat { isSEDevice ? 34 : 89 }
static var cardSize: CGFloat { isSEDevice ? 321 : 336 }
static var emojiTopPadding: CGFloat { isSEDevice ? 19 : 69 }
static let reactionBarHeight: CGFloat = 77
static let reactionBarHorizontalPadding: CGFloat = 20
static var reactionBarTopPadding: CGFloat { isSEDevice ? 19 : 69 }
}
}

Expand Down
25 changes: 16 additions & 9 deletions Projects/Feature/Home/Sources/Root/HomeCoordinator+Impl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ extension HomeCoordinator {
// swiftlint:disable:next closure_body_length
let reducer = Reduce<State, Action> { state, action in
switch action {
case let .home(.delegate(.goToGoalDetail(id, owner, verificationDate))):
state.routes.append(.detail)
state.goalDetail = .init(
currentUser: owner,
id: id,
verificationDate: verificationDate
case let .home(.delegate(.goToGoalDetail(id, owner, date))):
return .send(
.navigateToGoalDetail(
id: id,
owner: owner,
date: date
)
)
return .none

case let .home(.delegate(.goToMakeGoal(category))):
state.routes.append(.makeGoal)
Expand Down Expand Up @@ -185,13 +185,20 @@ extension HomeCoordinator {
return .none

case let .navigateToGoalDetail(id, owner, date):
state.routes.append(.detail)
let isAlreadyOnDetail = state.routes.last == .detail

if !isAlreadyOnDetail {
state.routes.append(.detail)
}

state.goalDetail = .init(
currentUser: owner,
id: id,
verificationDate: date
)
return .none
return isAlreadyOnDetail
? .send(.goalDetail(.view(.onAppear)))
: .none

case .delegate:
return .none
Expand Down
Loading