Skip to content

Instantly share code, notes, and snippets.

@h4yder
Last active August 12, 2020 15:09
Show Gist options
  • Save h4yder/d71edd4ad00f0115002b25a8075ad493 to your computer and use it in GitHub Desktop.
Save h4yder/d71edd4ad00f0115002b25a8075ad493 to your computer and use it in GitHub Desktop.
@State private var rotation: Angle = .zero
@State private var backgroundOpacity: Double = 0.0
@State private var durationLabelOpacity: Double = 1.0
@State private var xOffset: CGFloat = 0.0
@State private var accumulationLabelOpacity: Double = 0.0
@State private var numberOfAnimations: Int = 0
@State private var accumulationString: String = ""
var body: some View {
ZStack {
Group {
RoundArrowBackground()
.fill()
.opacity(backgroundOpacity)
RoundArrow()
.stroke(lineWidth: 3)
RoundArrowHead()
.fill()
}
.rotationEffect(rotation)
// Duration label
ScalableText(string: "\(interval)")
.opacity(durationLabelOpacity)
ScalableText(string: accumulationString, fontWeight: .bold, xOffset: xOffset)
.opacity(accumulationLabelOpacity)
}
.contentShape(Rectangle())
.onTapGesture {
if self.numberOfAnimations == 0 {
self.accumulationString = "+\(self.interval)"
} else {
self.accumulationString = self.incrementSeekValue()
}
self.numberOfAnimations += 1
self.animateArrowAndBackground()
self.animateDurationLabel()
self.animateAccumulationLabel()
self.popAnimation()
self.action(interval)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment