From 9df95ebc2988e8a834ccba297245524e85460a1a Mon Sep 17 00:00:00 2001 From: Lukas Korba <62649321+lukaskorba-indiedev@users.noreply.github.com> Date: Wed, 23 Feb 2022 15:04:36 +0100 Subject: [PATCH] Optimised Button's Layout Onboarding footer was using the same settings for 3 buttons. --- .../Onboarding/OnboardingFooterView.swift | 93 ++++++++++--------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/secant/Screens/Onboarding/OnboardingFooterView.swift b/secant/Screens/Onboarding/OnboardingFooterView.swift index 3a34e49..e7c6794 100644 --- a/secant/Screens/Onboarding/OnboardingFooterView.swift +++ b/secant/Screens/Onboarding/OnboardingFooterView.swift @@ -13,57 +13,64 @@ struct OnboardingFooterView: View { let animationDuration: CGFloat = 0.8 var body: some View { - GeometryReader { proxy in - WithViewStore(self.store) { viewStore in - VStack(spacing: 5) { - Spacer() - - if viewStore.isFinalStep { - Button("Create New Wallet") { - withAnimation(.easeInOut(duration: animationDuration)) { - viewStore.send(.createNewWallet) - } + WithViewStore(self.store) { viewStore in + VStack(spacing: 5) { + Spacer() + + if viewStore.isFinalStep { + Button("Create New Wallet") { + withAnimation(.easeInOut(duration: animationDuration)) { + viewStore.send(.createNewWallet) } - .primaryButtonStyle - .frame(height: proxy.size.height / 12) - .padding(.horizontal, 15) - .transition(.opacity) - - Button("Import an Existing Wallet") { - withAnimation(.easeInOut(duration: animationDuration)) { - viewStore.send(.createNewWallet) - } - } - .secondaryButtonStyle - .frame(height: proxy.size.height / 12) - .padding(.horizontal, 15) - .transition(.opacity) - } else { - Button("Next") { - withAnimation(.easeInOut(duration: animationDuration)) { - viewStore.send(.next) - } - } - .primaryButtonStyle - .frame(height: 60) - .padding(.horizontal, 28) - .transition(.opacity) - - ProgressView( - "0\(viewStore.index + 1)", - value: Double(viewStore.index + 1), - total: Double(viewStore.steps.count) - ) - .onboardingProgressStyle - .padding(.horizontal, 30) - .padding(.vertical, 20) } + .createButtonStyle + .buttonLayout() + + Button("Import an Existing Wallet") { + withAnimation(.easeInOut(duration: animationDuration)) { + viewStore.send(.createNewWallet) + } + } + .secondaryButtonStyle + .buttonLayout() + } else { + Button("Next") { + withAnimation(.easeInOut(duration: animationDuration)) { + viewStore.send(.next) + } + } + .primaryButtonStyle + .buttonLayout() + + ProgressView( + "0\(viewStore.index + 1)", + value: Double(viewStore.index + 1), + total: Double(viewStore.steps.count) + ) + .onboardingProgressStyle + .padding(.horizontal, 30) + .padding(.vertical, 20) } } } } } +struct OnboardingFooterButtonLayout: ViewModifier { + func body(content: Content) -> some View { + content + .frame(height: 60) + .padding(.horizontal, 28) + .transition(.opacity) + } +} + +extension View { + func buttonLayout() -> some View { + modifier(OnboardingFooterButtonLayout()) + } +} + struct OnboardingFooterView_Previews: PreviewProvider { static var previews: some View { let store = Store(