|
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) |
|
.fill(Color(Colors.mainColor)) |
|
//Button's dark edge (top left) |
|
RoundedRectangle(cornerRadius: cornerRadius) |
|
.stroke(Color(Colors.darkShadow).opacity(opacityOp), lineWidth: 2) |
|
.mask(RoundedRectangle(cornerRadius: cornerRadius).fill(LinearGradient(colors:[Color(Colors.darkShadow).opacity(opacityOp), Color.clear], startPoint: .top, endPoint: .bottom))) |
|
//Button's inner dark shadow (top left) |
|
RoundedRectangle(cornerRadius: cornerRadius) |
|
.stroke(Color(Colors.darkShadow), lineWidth: 2) |
|
.blur(radius: 3) |
|
.offset(x: 1, y: 1) |
|
.mask(RoundedRectangle(cornerRadius: cornerRadius).fill(LinearGradient(colors: [Color(Colors.darkShadow).opacity(opacityOp), Color.clear], startPoint: .top, endPoint: .bottom))) |
|
//Button's inner light edge (bottom right) |
|
RoundedRectangle(cornerRadius: cornerRadius) |
|
.stroke(Color(Colors.lightShadow).opacity(opacityOp), lineWidth: 2) |
|
.mask(RoundedRectangle(cornerRadius: cornerRadius).fill(LinearGradient(colors: [Color.clear, Color(Colors.lightShadow).opacity(opacityOp)], startPoint: .top, endPoint: .bottom))) |
|
} |
|
//Button's outer light shadow (top left) |
|
.shadow(color: Color(Colors.lightShadow).opacity(opacity), radius: shadowRadiusXY, x: -shadowRadiusXY, y: -shadowRadiusXY) |
|
//Button's outer dark shadow (bottom right) |
|
.shadow(color: Color(Colors.darkShadow).opacity(opacity), radius: shadowRadiusXY, x: shadowRadiusXY, y: shadowRadiusXY) |
|
} |
|
|
|
} |