Skip to content

Commit

Permalink
[CAT-290] 마이페이지 내고양이 Rive 적용 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jihyun247 authored Aug 20, 2024
1 parent 1f2f11b commit acf5b86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 9 additions & 0 deletions Projects/Feature/MyPageFeature/Sources/MyCat/MyCatCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@

import CatFeature
import CatServiceInterface
import DesignSystem

import ComposableArchitecture
import RiveRuntime

@Reducer
public struct MyCatCore {
@ObservableState
public struct State: Equatable {
var cat: AnyCat
var tooltip: MyCatTooltip? = .init()
var catRiv: RiveViewModel = Rive.catSelectRiv(stateMachineName: "State Machine_selectCat")
@Presents var selectCat: SelectCatCore.State?
@Presents var namingCat: NamingCatCore.State?
}

public enum Action {
case onAppear
case setTooltip(MyCatTooltip?)
case changeCatButtonTapped
case changeCatNameButtonTapped
Expand All @@ -46,6 +50,11 @@ public struct MyCatCore {

private func core(state: inout State, action: Action) -> EffectOf<Self> {
switch action {
case .onAppear:
state.catRiv.stop()
state.catRiv.triggerInput(state.cat.rivTriggerName)
return .none

case .setTooltip:
return .none

Expand Down
12 changes: 5 additions & 7 deletions Projects/Feature/MyPageFeature/Sources/MyCat/MyCatView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ public struct MyCatView: View {
VStack {
Spacer()
VStack(spacing: Alias.Spacing.medium) {
ZStack {
Rectangle()
.foregroundStyle(Alias.Color.Background.secondary)
.frame(maxHeight: .infinity)
store.cat.catImage
.setTooltipTarget(tooltip: MyCatTooltip.self)
}
store.catRiv.view()
.setTooltipTarget(tooltip: MyCatTooltip.self)
.frame(maxHeight: 240)

HStack(spacing: Alias.Spacing.xSmall) {
Expand Down Expand Up @@ -69,5 +64,8 @@ public struct MyCatView: View {
) { store in
NamingCatView(store: store)
}
.onAppear {
store.send(.onAppear)
}
}
}

0 comments on commit acf5b86

Please sign in to comment.