Skip to content

Instantly share code, notes, and snippets.

struct CardFront : View {
let width : CGFloat
let height : CGFloat
@Binding var degree : Double
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 20)
.fill(.white)
.frame(width: width, height: height)
struct likesPile : View {
@State var likes :[LikeView] = []
let timer = Timer.publish(every: 0.3, on: .main, in: .common).autoconnect()
var body: some View {
ZStack {
ForEach(likes) { like in
like.image
.resizable()
struct CustomButton : View {
var body: some View {
ZStack {
Color(Colors.mainColor)
Button("Click") {
}
.buttonStyle(NeumorphicButtonStyle(width: 200, cornerRadius : 20))
}
struct NeumorphicButtonStyle: ButtonStyle {
@State var opacity : CGFloat = 1
@State var opacityOp : CGFloat = 0
@State var shadowRadiusXY : CGFloat = 3
@State var scale : CGFloat = 1
let width : CGFloat
let cornerRadius : CGFloat
func makeBody(configuration: Self.Configuration) -> some View {
configuration.label
struct NeuButtonBackgroundView : View {
let cornerRadius : CGFloat
@Binding var opacity : CGFloat
@Binding var opacityOp : CGFloat
@Binding var shadowRadiusXY : CGFloat
var body: some View {
ZStack {
//Button shape and color
RoundedRectangle(cornerRadius: cornerRadius)
struct ContentView: View {
var body: some View {
ZStack {
Color(Colors.mainColor).ignoresSafeArea()
CustomToggle(width: 150, height: 60, toggleWidthOffset: 20, cornerRadius: 30, padding: 0)
}
}
}
struct ContentView: View {
var body: some View {
ZStack {
Color(Colors.mainColor).ignoresSafeArea()
CustomToggle(width: 200, height: 80, toggleWidthOffset: 20, cornerRadius: 10, padding: 10)
}
}
}
struct Colors {
public static let mainColor = "mainColor"
public static let lightShadow = "lightShadow"
public static let darkShadow = "darkShadow"
}
struct ContentView: View {
var body: some View {
ZStack {
Color(Colors.mainColor)
CustomToggle(width: 170, height: 60, toggleWidthOffset: 20, cornerRadius: 30, padding: 10)
}
}
}
struct CustomToggle : View {
let width : CGFloat
let height : CGFloat
let toggleWidthOffset : CGFloat
let cornerRadius : CGFloat
let padding : CGFloat
@State var isToggled = false
@State var switchWidth : CGFloat = 0.0