animation for the valid button

fix/answer-animation
Lucas DELANIER 1 year ago
parent 98270138fc
commit 12709c8e00

@ -14,6 +14,7 @@ struct ChoiceFinalAnswerCell: View {
var selected = false var selected = false
var answer: AnswerDetail var answer: AnswerDetail
var rawColor = AllInColors.blueAccentColor var rawColor = AllInColors.blueAccentColor
var body: some View { var body: some View {
ZStack{ ZStack{
@ -27,6 +28,9 @@ struct ChoiceFinalAnswerCell: View {
Spacer() Spacer()
OddCapsule(backgroundColor: selected ? .white : AllInColors.purpleAccentColor, foregroundColor: selected ? AllInColors.purpleAccentColor : .white ,odd: answer.odds ).padding(.trailing,20).scaleEffect(0.9) OddCapsule(backgroundColor: selected ? .white : AllInColors.purpleAccentColor, foregroundColor: selected ? AllInColors.purpleAccentColor : .white ,odd: answer.odds ).padding(.trailing,20).scaleEffect(0.9)
} }
}.background(selected ? AllInColors.purpleAccentColor : .white).cornerRadius(17) }.background(selected ? AllInColors.purpleAccentColor : .white).cornerRadius(17).scaleEffect(selected ? 1.02 : 1).animation(
.easeInOut(duration: 0.3),
value: selected
)
} }
} }

@ -70,7 +70,7 @@ struct BetEndingValidation: View {
} }
} }
Spacer() Spacer()
selectedAnswer != nil ? Button { Button {
dismiss() dismiss()
} label: { } label: {
Text("Valider") Text("Valider")
@ -80,9 +80,10 @@ struct BetEndingValidation: View {
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.padding(.vertical, 3) .padding(.vertical, 3)
} }
.opacity(selectedAnswer != nil ? 1 : 0)
.animation(.easeInOut(duration: 0.3), value: selectedAnswer != nil)
.buttonStyle(.borderedProminent) .buttonStyle(.borderedProminent)
.tint(AllInColors.purpleAccentColor) .tint(AllInColors.purpleAccentColor)
: nil
} }
.padding([.all],20) .padding([.all],20)
} }

Loading…
Cancel
Save