From 3ff9e0b9e74b24172655cf4f5379c46b5193e6f6 Mon Sep 17 00:00:00 2001 From: "hsj._.06" Date: Wed, 3 Apr 2024 15:15:25 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=A9=20::=20Tap=20=EB=B2=94=EC=9C=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/Flow/Sources/Home/HomeFlow.swift | 2 +- .../Sources/EasterEgg/EasterEggView.swift | 68 ++++++++----------- .../EasterEgg/RxFlowViewController.swift | 2 +- 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/Projects/Flow/Sources/Home/HomeFlow.swift b/Projects/Flow/Sources/Home/HomeFlow.swift index d7327980..42175aff 100644 --- a/Projects/Flow/Sources/Home/HomeFlow.swift +++ b/Projects/Flow/Sources/Home/HomeFlow.swift @@ -74,7 +74,7 @@ private extension HomeFlow { let easterEggFlow = EasterEggFlow(container: container) Flows.use(easterEggFlow, when: .created) { root in - self.rootViewController.present( + self.rootViewController.pushViewController( root, animated: true ) } diff --git a/Projects/Presentation/Sources/EasterEgg/EasterEggView.swift b/Projects/Presentation/Sources/EasterEgg/EasterEggView.swift index c2fde643..bf414e4d 100644 --- a/Projects/Presentation/Sources/EasterEgg/EasterEggView.swift +++ b/Projects/Presentation/Sources/EasterEgg/EasterEggView.swift @@ -3,8 +3,25 @@ import DesignSystem struct EasterEggView: View { @State private var count = 0 + var body: some View { + ZStack(alignment: .bottom) { + Button("") {} + .buttonStyle(CatButtonStyle(count: $count)) + + Text("\(count)") + .padding(.top, 50) + } + } +} + +struct CatButtonStyle: ButtonStyle { + @Binding var count: Int @State private var angle = 0 @State private var index = 0 + + init(count: Binding) { + _count = count + } private var colors: [Color] = [ .yellow, .red, @@ -15,46 +32,19 @@ struct EasterEggView: View { .mint, .white ] - var body: some View { - VStack { - Button("", action: addAction) - .buttonStyle(CatButtonStyle()) - .rotationEffect(.degrees(Double(angle))) - - Text("\(count)") - .padding(.top, 50) - } + func makeBody(configuration: Configuration) -> some View { + (configuration.isPressed ? DesignSystemAsset.Images.EasterEgg.open.swiftUIImage: + DesignSystemAsset.Images.EasterEgg.close.swiftUIImage) + .rotationEffect(.degrees(Double(angle))) .frame(maxWidth: .infinity, maxHeight: .infinity) - .padding() .background(colors[index]) - } - - private func addAction() { - count += 1 - angle = (angle + 45) % 360 - index = Int.random(in: 0.. some View { - configuration.isPressed ? DesignSystemAsset.Images.EasterEgg.open.swiftUIImage: - DesignSystemAsset.Images.EasterEgg.close.swiftUIImage - } -} - -final private class HapticManager { - static let instance = HapticManager() - - func notification(type: UINotificationFeedbackGenerator.FeedbackType) { - - let generator = UINotificationFeedbackGenerator() - generator.notificationOccurred(type) - } - - func impact(style: UIImpactFeedbackGenerator.FeedbackStyle) { - let generator = UIImpactFeedbackGenerator(style: style) - generator.impactOccurred() + .onChange(of: configuration.isPressed) { + if $0 { + angle = (angle + 45) % 360 + index = Int.random(in: 0..