@@ -450,10 +450,10 @@ public struct BezierButton: View, Themeable {
450
450
size: ButtonSize ,
451
451
type: ButtonType ,
452
452
resizing: ButtonResizing ,
453
- action: @escaping ( ) -> Void ,
454
453
title: String ? = nil ,
455
454
leftContent: Image ? = nil ,
456
- rightContent: Image ? = nil
455
+ rightContent: Image ? = nil ,
456
+ action: @escaping ( ) -> Void
457
457
) {
458
458
self . size = size
459
459
self . type = type
@@ -468,71 +468,71 @@ public struct BezierButton: View, Themeable {
468
468
size: ButtonSize ,
469
469
type: ButtonType ,
470
470
resizing: ButtonResizing ,
471
- action : @escaping ( ) -> Void ,
472
- title : @escaping ( ) -> String ,
473
- leftImage : @escaping ( ) -> Image ,
474
- rightImage : @escaping ( ) -> Image
471
+ title : String ,
472
+ leftImage : Image ,
473
+ rightImage : Image ,
474
+ action : @escaping ( ) -> Void
475
475
) {
476
476
self . init (
477
477
size: size,
478
478
type: type,
479
479
resizing: resizing,
480
- action : action ,
481
- title : title ( ) ,
482
- leftContent : leftImage ( ) ,
483
- rightContent : rightImage ( )
480
+ title : title ,
481
+ leftContent : leftImage ,
482
+ rightContent : rightImage ,
483
+ action : action
484
484
)
485
485
}
486
486
487
487
public init (
488
488
size: ButtonSize ,
489
489
type: ButtonType ,
490
490
resizing: ButtonResizing ,
491
- action : @escaping ( ) -> Void ,
492
- title : @escaping ( ) -> String ,
493
- leftImage : @escaping ( ) -> Image
491
+ title : String ,
492
+ leftImage : Image ,
493
+ action : @escaping ( ) -> Void
494
494
) {
495
495
self . init (
496
496
size: size,
497
497
type: type,
498
498
resizing: resizing,
499
- action : action ,
500
- title : title ( ) ,
501
- leftContent : leftImage ( )
499
+ title : title ,
500
+ leftContent : leftImage ,
501
+ action : action
502
502
)
503
503
}
504
504
505
505
public init (
506
506
size: ButtonSize ,
507
507
type: ButtonType ,
508
508
resizing: ButtonResizing ,
509
- action : @escaping ( ) -> Void ,
510
- title : @escaping ( ) -> String ,
511
- rightImage : @escaping ( ) -> Image
509
+ title : String ,
510
+ rightImage : Image ,
511
+ action : @escaping ( ) -> Void
512
512
) {
513
513
self . init (
514
514
size: size,
515
515
type: type,
516
516
resizing: resizing,
517
- action : action ,
518
- title : title ( ) ,
519
- rightContent : rightImage ( )
517
+ title : title ,
518
+ rightContent : rightImage ,
519
+ action : action
520
520
)
521
521
}
522
522
523
523
public init (
524
524
size: ButtonSize ,
525
525
type: ButtonType ,
526
526
resizing: ButtonResizing ,
527
- action : @escaping ( ) -> Void ,
528
- leftImage : @escaping ( ) -> Image
527
+ centerImage : Image ,
528
+ action : @escaping ( ) -> Void
529
529
) {
530
530
self . init (
531
531
size: size,
532
532
type: type,
533
533
resizing: resizing,
534
- action : action ,
535
- leftContent : leftImage ( )
534
+ leftContent : centerImage ,
535
+ action : action
536
536
)
537
537
}
538
538
@@ -548,7 +548,7 @@ public struct BezierButton: View, Themeable {
548
548
type: type,
549
549
resizing: resizing,
550
550
action: action,
551
- title: title ( )
551
+ title: title
552
552
)
553
553
}
554
554
@@ -592,7 +592,6 @@ public struct BezierButton: View, Themeable {
592
592
}
593
593
. buttonStyle (
594
594
BezierButtonStyle (
595
- self ,
596
595
size: size,
597
596
type: type,
598
597
resizing: resizing
@@ -622,21 +621,20 @@ private extension Image {
622
621
}
623
622
}
624
623
625
- struct BezierButtonStyle : ButtonStyle {
626
- private let themeable : Themeable
624
+ private struct BezierButtonStyle : ButtonStyle , Themeable {
625
+ @Environment ( \. colorScheme) var colorScheme
626
+
627
627
private let size : ButtonSize
628
628
private let type : ButtonType
629
629
private let resizing : ButtonResizing
630
630
631
631
@Environment ( \. isEnabled) var isEnabled : Bool
632
632
633
633
init (
634
- _ themeable: Themeable ,
635
634
size: ButtonSize ,
636
635
type: ButtonType ,
637
636
resizing: ButtonResizing
638
637
) {
639
- self . themeable = themeable
640
638
self . size = size
641
639
self . type = type
642
640
self . resizing = resizing
@@ -647,7 +645,7 @@ struct BezierButtonStyle: ButtonStyle {
647
645
configuration. label
648
646
. frame ( height: self . size. height)
649
647
. disabled ( !self . isEnabled)
650
- . background ( themeable . palette ( self . type. backgroundColor ( state: buttonState) ) )
648
+ . background ( self . palette ( self . type. backgroundColor ( state: buttonState) ) )
651
649
. applyBezierCornerRadius ( type: self . size. cornerRadius ( type: self . type) )
652
650
. opacity ( self . isEnabled ? 1 : Constant . disalbedOpacity)
653
651
}
@@ -660,71 +658,35 @@ struct BezierButtonStyle: ButtonStyle {
660
658
struct BezierButton_Previews : PreviewProvider {
661
659
static var previews : some View {
662
660
VStack {
663
- BezierButton ( size: . large, type: . primary( . green) , resizing: . fill) {
661
+ BezierButton ( size: . large, type: . primary( . green) , resizing: . fill, title : " Get started " , leftImage : Image ( systemName : " trash " ) ) {
664
662
print ( " " )
665
- } title: {
666
- " Get started "
667
- } leftImage: {
668
- Image ( systemName: " trash " )
669
- } rightImage: {
670
- Image ( systemName: " trash " )
671
663
}
672
664
673
- BezierButton ( size: . large, type: . primary( . blue) , resizing: . hug) {
665
+
666
+ BezierButton ( size: . large, type: . primary( . blue) , resizing: . hug, title: " Get started " , leftImage: Image ( systemName: " trash " ) , rightImage: Image ( systemName: " trash " ) ) {
674
667
print ( " " )
675
- } title: {
676
- " Get started "
677
- } leftImage: {
678
- Image ( systemName: " trash " )
679
- } rightImage: {
680
- Image ( systemName: " trash " )
681
668
}
682
669
683
- BezierButton ( size: . large, type: . primary( . red) , resizing: . hug) {
670
+ BezierButton ( size: . large, type: . primary( . red) , resizing: . hug, title : " Get started " , leftImage : Image ( systemName : " trash " ) , rightImage : Image ( systemName : " trash " ) ) {
684
671
print ( " " )
685
- } title: {
686
- " Get started "
687
- } leftImage: {
688
- Image ( systemName: " trash " )
689
- } rightImage: {
690
- Image ( systemName: " trash " )
691
672
}
692
673
693
- BezierButton ( size: . large, type: . secondary( . red) , resizing: . hug) {
674
+ BezierButton ( size: . large, type: . secondary( . red) , resizing: . hug, title : " Get started " , leftImage : Image ( systemName : " trash " ) , rightImage : Image ( systemName : " trash " ) ) {
694
675
print ( " " )
695
- } title: {
696
- " Get started "
697
- } leftImage: {
698
- Image ( systemName: " trash " )
699
- } rightImage: {
700
- Image ( systemName: " trash " )
701
676
}
702
677
703
- BezierButton ( size: . large, type: . tertiary( . red) , resizing: . hug) {
678
+ BezierButton ( size: . large, type: . tertiary( . red) , resizing: . hug, title : " Get started " , leftImage : Image ( systemName : " trash " ) , rightImage : Image ( systemName : " trash " ) ) {
704
679
print ( " " )
705
- } title: {
706
- " Get started "
707
- } leftImage: {
708
- Image ( systemName: " trash " )
709
- } rightImage: {
710
- Image ( systemName: " trash " )
711
680
}
712
681
713
- BezierButton ( size: . large, type: . floating( . red ) , resizing: . hug) {
682
+ BezierButton ( size: . large, type: . floating( . cobalt ) , resizing: . hug, title : " Get started " , leftImage : Image ( systemName : " trash " ) , rightImage : Image ( systemName : " trash " ) ) {
714
683
print ( " " )
715
- } title: {
716
- " Get started "
717
- } leftImage: {
718
- Image ( systemName: " trash " )
719
- } rightImage: {
720
- Image ( systemName: " trash " )
721
684
}
722
685
723
- BezierButton ( size: . large, type: . primary( . yellow) , resizing: . hug) {
686
+ BezierButton ( size: . large, type: . primary( . yellow) , resizing: . hug, centerImage : Image ( systemName : " trash " ) ) {
724
687
print ( " " )
725
- } leftImage: {
726
- Image ( systemName: " trash " )
727
688
}
689
+
728
690
} . padding ( )
729
691
}
730
692
}
0 commit comments