Optimised Button's Layout

Onboarding footer was using the same settings for 3 buttons.
This commit is contained in:
Lukas Korba 2022-02-23 15:04:36 +01:00
parent 8931433f8e
commit 9df95ebc29
1 changed files with 50 additions and 43 deletions

View File

@ -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<OnboardingState, OnboardingAction>(