@@ -9,64 +9,65 @@ import SwiftUI
99
1010public struct SecondaryGradientButton : View {
1111 private var color : Color
12- private var title : String
12+ private var title : LocalizedStringKey
1313 private var action : ( ) -> ( )
1414 private var disabled : Bool
15-
16- @Environment ( \. colorScheme) var scheme
17-
18- var gradient : [ Color ] {
19- if disabled {
20- return [ . gray, . gray. opacity ( 0.8 ) ]
21- } else {
22- return [ color. prominence ( scheme: scheme) , color. prominence ( scheme: scheme) . opacity ( 0.8 ) ]
23- }
24- }
25-
26- public init ( title: String , color: Color , disabled: Bool , _ action: @escaping ( ) -> Void ) {
15+
16+ public init ( title: LocalizedStringKey , color: Color , disabled: Bool = false , _ action: @escaping ( ) -> Void ) {
2717 self . title = title
2818 self . color = color
2919 self . action = action
3020 self . disabled = disabled
3121 }
32-
22+
3323 public var body : some View {
3424 Button ( action: action) {
3525 Text ( title)
36- . foregroundColor ( color. prominence ( scheme: scheme, reverse: true ) )
37- . buttonText ( )
26+ . font ( . callout)
27+ . bold ( )
28+ . fontWidth ( . expanded)
29+ . foregroundStyle ( Color . primary)
30+ . frame ( maxWidth: . infinity)
3831 }
39- . buttonStyle ( SecondaryButtonStyle {
40- RoundedRectangle ( cornerRadius: Constants . cornerRadius)
41- . stroke ( LinearGradient ( gradient: Gradient ( colors: gradient) , startPoint: . top, endPoint: . bottom) , lineWidth: 1.5 )
42- } )
32+ . controlSize ( . large)
33+ . buttonStyle ( . glass)
34+ . buttonBorderShape ( . roundedRectangle( radius: 16 ) )
35+ . tint ( disabled ? . gray : color)
36+ . accessibilityLabel ( title)
37+ . accessibilityAddTraits ( . isButton)
4338 }
4439}
4540
4641public struct SecondaryButton : View {
47- private var title : String
42+ private var title : LocalizedStringKey
4843 private var action : ( ) -> ( )
49-
50- public init ( _ title: String , _ action: @escaping ( ) -> Void ) {
44+
45+ public init ( _ title: LocalizedStringKey , _ action: @escaping ( ) -> Void ) {
5146 self . title = title
5247 self . action = action
5348 }
54-
49+
5550 public var body : some View {
5651 Button ( action: action) {
5752 Text ( title)
58- . foregroundColor ( . primary)
59- . buttonText ( )
53+ . font ( . callout)
54+ . bold ( )
55+ . fontWidth ( . expanded)
56+ . foregroundStyle ( Color . primary)
57+ . frame ( maxWidth: . infinity)
6058 }
61- . buttonStyle ( SecondaryButtonStyle {
62- RoundedRectangle ( cornerRadius: Constants . cornerRadius)
63- . stroke ( Color . accentColor, lineWidth: 1 )
64- } )
59+ . controlSize ( . large)
60+ . buttonStyle ( . glass)
61+ . buttonBorderShape ( . roundedRectangle( radius: 16 ) )
62+ . accessibilityLabel ( title)
63+ . accessibilityAddTraits ( . isButton)
6564 }
6665}
6766
68- struct SecondaryButton_Previews : PreviewProvider {
69- static var previews : some View {
70- SecondaryButton ( " Try again " , { } )
67+ #Preview {
68+ VStack {
69+ SecondaryButton ( " Try Again " , { } )
70+ SecondaryGradientButton ( title: " Show Score " , color: . blue, disabled: false , { } )
7171 }
72+ . padding ( )
7273}
0 commit comments