-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathGlassButtonStyle.swift
More file actions
50 lines (47 loc) · 2.13 KB
/
Copy pathGlassButtonStyle.swift
File metadata and controls
50 lines (47 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
// GlassButtonStyle.swift
// NativeAppTemplate
//
import SwiftUI
struct PrimaryGlassButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(.uiButtonLabelLarge)
.foregroundStyle(.glassForeground)
.padding(.vertical, NativeAppTemplateConstants.Spacing.sm)
.padding(.horizontal, NativeAppTemplateConstants.Spacing.md)
.frame(maxWidth: .infinity)
.background(
LinearGradient(
colors: [Color.accent, Color.accent.opacity(0.8)],
startPoint: .topLeading,
endPoint: .bottomTrailing
)
)
.clipShape(RoundedRectangle(cornerRadius: NativeAppTemplateConstants.CornerRadius.sm))
.shadow(
color: Color.accent.opacity(NativeAppTemplateConstants.Glass.shadowOpacity),
radius: NativeAppTemplateConstants.Layout.shadowRadius
)
.scaleEffect(configuration.isPressed ? 0.97 : 1.0)
.animation(.easeInOut(duration: NativeAppTemplateConstants.Animation.fast), value: configuration.isPressed)
}
}
struct SecondaryGlassButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.font(.uiButtonLabelLarge)
.foregroundStyle(.accent)
.padding(.vertical, NativeAppTemplateConstants.Spacing.sm)
.padding(.horizontal, NativeAppTemplateConstants.Spacing.md)
.frame(maxWidth: .infinity)
.background(.ultraThinMaterial)
.clipShape(RoundedRectangle(cornerRadius: NativeAppTemplateConstants.CornerRadius.sm))
.overlay(
RoundedRectangle(cornerRadius: NativeAppTemplateConstants.CornerRadius.sm)
.stroke(Color.accent, lineWidth: NativeAppTemplateConstants.Layout.borderWidth)
)
.scaleEffect(configuration.isPressed ? 0.97 : 1.0)
.animation(.easeInOut(duration: NativeAppTemplateConstants.Animation.fast), value: configuration.isPressed)
}
}