Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
Last active January 26, 2021 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sturdysturge/e448b297a988dc9442ae1fa0baf8bd4e to your computer and use it in GitHub Desktop.
Save sturdysturge/e448b297a988dc9442ae1fa0baf8bd4e to your computer and use it in GitHub Desktop.
struct AquaHighAndLowlightView<T: Shape>: View {
let shape: T
let colors: [Color]
var linearGradient: LinearGradient {
LinearGradient(gradient: Gradient(colors: colors), startPoint: .top, endPoint: .bottom)
}
var body: some View {
shape
.stroke(linearGradient, lineWidth: 2.5)
}
}
struct AquaCircularButtonStyle: ButtonStyle {
func makeBody(configuration: Self.Configuration) -> some View {
AquaCircularButton()
}
}
struct AquaCircularButton: View {
var body: some View {
GeometryReader { geometry in
let topHighlightHeight = geometry.size.height * 0.3
let bottomHighlightOffset = geometry.size.height * 0.6
ZStack {
Circle() //Behind highlight
.foregroundColor(.aquaBehindCircularButtonHighlight)
.offset(x: -1, y: 1)
Group {
Circle() // Main colour
Circle() //Bottom highlight
.foregroundColor(.white)
.offset(y: bottomHighlightOffset)
.blur(radius: 3)
Group {
Capsule() //Top highlight
.frame(height: topHighlightHeight)
.foregroundColor(.white)
.blur(radius: 2)
.padding(.horizontal, 3)
}
.frame(maxHeight: .infinity, alignment: .top)
//Outline
AquaHighAndLowlightView(shape: Circle(), colors:
[.aquaCircularButtonHighlight,
.aquaCircularButtonLowlight])
}
.clipShape(Circle())
}
}
.aspectRatio(1, contentMode: .fit)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment