Skip to content

Commit 1131cbb

Browse files
authored
[Fix] 버튼 사용 스펙 변경 (#8)
1 parent 15afb1f commit 1131cbb

File tree

4 files changed

+62
-80
lines changed

4 files changed

+62
-80
lines changed

Sources/BezierSwift/Foundation/Boxing/BezierCornerRadius.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
enum BezierCornerRadius {
10+
public enum BezierCornerRadius {
1111
case round2
1212
case round3
1313
case round4

Sources/BezierSwift/Foundation/Boxing/BezierElevation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import SwiftUI
99

10-
enum BezierElevation {
10+
public enum BezierElevation {
1111
case mEv1
1212
case mEv2
1313
case mEv3

Sources/BezierSwift/Foundation/MasterComponent/BezierButton.swift renamed to Sources/BezierSwift/MasterComponent/BezierButton/BezierButton.swift

Lines changed: 40 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,10 @@ public struct BezierButton: View, Themeable {
450450
size: ButtonSize,
451451
type: ButtonType,
452452
resizing: ButtonResizing,
453-
action: @escaping () -> Void,
454453
title: String? = nil,
455454
leftContent: Image? = nil,
456-
rightContent: Image? = nil
455+
rightContent: Image? = nil,
456+
action: @escaping () -> Void
457457
) {
458458
self.size = size
459459
self.type = type
@@ -468,71 +468,71 @@ public struct BezierButton: View, Themeable {
468468
size: ButtonSize,
469469
type: ButtonType,
470470
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
475475
) {
476476
self.init(
477477
size: size,
478478
type: type,
479479
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
484484
)
485485
}
486486

487487
public init(
488488
size: ButtonSize,
489489
type: ButtonType,
490490
resizing: ButtonResizing,
491-
action: @escaping () -> Void,
492-
title: @escaping () -> String,
493-
leftImage: @escaping () -> Image
491+
title: String,
492+
leftImage: Image,
493+
action: @escaping () -> Void
494494
) {
495495
self.init(
496496
size: size,
497497
type: type,
498498
resizing: resizing,
499-
action: action,
500-
title: title(),
501-
leftContent: leftImage()
499+
title: title,
500+
leftContent: leftImage,
501+
action: action
502502
)
503503
}
504504

505505
public init(
506506
size: ButtonSize,
507507
type: ButtonType,
508508
resizing: ButtonResizing,
509-
action: @escaping () -> Void,
510-
title: @escaping () -> String,
511-
rightImage: @escaping () -> Image
509+
title: String,
510+
rightImage: Image,
511+
action: @escaping () -> Void
512512
) {
513513
self.init(
514514
size: size,
515515
type: type,
516516
resizing: resizing,
517-
action: action,
518-
title: title(),
519-
rightContent: rightImage()
517+
title: title,
518+
rightContent: rightImage,
519+
action: action
520520
)
521521
}
522522

523523
public init(
524524
size: ButtonSize,
525525
type: ButtonType,
526526
resizing: ButtonResizing,
527-
action: @escaping () -> Void,
528-
leftImage: @escaping () -> Image
527+
centerImage: Image,
528+
action: @escaping () -> Void
529529
) {
530530
self.init(
531531
size: size,
532532
type: type,
533533
resizing: resizing,
534-
action: action,
535-
leftContent: leftImage()
534+
leftContent: centerImage,
535+
action: action
536536
)
537537
}
538538

@@ -548,7 +548,7 @@ public struct BezierButton: View, Themeable {
548548
type: type,
549549
resizing: resizing,
550550
action: action,
551-
title: title()
551+
title: title
552552
)
553553
}
554554

@@ -592,7 +592,6 @@ public struct BezierButton: View, Themeable {
592592
}
593593
.buttonStyle(
594594
BezierButtonStyle(
595-
self,
596595
size: size,
597596
type: type,
598597
resizing: resizing
@@ -622,21 +621,20 @@ private extension Image {
622621
}
623622
}
624623

625-
struct BezierButtonStyle: ButtonStyle {
626-
private let themeable: Themeable
624+
private struct BezierButtonStyle: ButtonStyle, Themeable {
625+
@Environment(\.colorScheme) var colorScheme
626+
627627
private let size: ButtonSize
628628
private let type: ButtonType
629629
private let resizing: ButtonResizing
630630

631631
@Environment(\.isEnabled) var isEnabled: Bool
632632

633633
init(
634-
_ themeable: Themeable,
635634
size: ButtonSize,
636635
type: ButtonType,
637636
resizing: ButtonResizing
638637
) {
639-
self.themeable = themeable
640638
self.size = size
641639
self.type = type
642640
self.resizing = resizing
@@ -647,7 +645,7 @@ struct BezierButtonStyle: ButtonStyle {
647645
configuration.label
648646
.frame(height: self.size.height)
649647
.disabled(!self.isEnabled)
650-
.background(themeable.palette(self.type.backgroundColor(state: buttonState)))
648+
.background(self.palette(self.type.backgroundColor(state: buttonState)))
651649
.applyBezierCornerRadius(type: self.size.cornerRadius(type: self.type))
652650
.opacity(self.isEnabled ? 1 : Constant.disalbedOpacity)
653651
}
@@ -660,71 +658,35 @@ struct BezierButtonStyle: ButtonStyle {
660658
struct BezierButton_Previews: PreviewProvider {
661659
static var previews: some View {
662660
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")) {
664662
print("")
665-
} title: {
666-
"Get started"
667-
} leftImage: {
668-
Image(systemName: "trash")
669-
} rightImage: {
670-
Image(systemName: "trash")
671663
}
672664

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")) {
674667
print("")
675-
} title: {
676-
"Get started"
677-
} leftImage: {
678-
Image(systemName: "trash")
679-
} rightImage: {
680-
Image(systemName: "trash")
681668
}
682669

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")) {
684671
print("")
685-
} title: {
686-
"Get started"
687-
} leftImage: {
688-
Image(systemName: "trash")
689-
} rightImage: {
690-
Image(systemName: "trash")
691672
}
692673

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")) {
694675
print("")
695-
} title: {
696-
"Get started"
697-
} leftImage: {
698-
Image(systemName: "trash")
699-
} rightImage: {
700-
Image(systemName: "trash")
701676
}
702677

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")) {
704679
print("")
705-
} title: {
706-
"Get started"
707-
} leftImage: {
708-
Image(systemName: "trash")
709-
} rightImage: {
710-
Image(systemName: "trash")
711680
}
712681

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")) {
714683
print("")
715-
} title: {
716-
"Get started"
717-
} leftImage: {
718-
Image(systemName: "trash")
719-
} rightImage: {
720-
Image(systemName: "trash")
721684
}
722685

723-
BezierButton(size: .large, type: .primary(.yellow), resizing: .hug) {
686+
BezierButton(size: .large, type: .primary(.yellow), resizing: .hug, centerImage: Image(systemName: "trash")) {
724687
print("")
725-
} leftImage: {
726-
Image(systemName: "trash")
727688
}
689+
728690
}.padding()
729691
}
730692
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// BezierDialog.swift
3+
//
4+
//
5+
// Created by Jam on 2023/02/15.
6+
//
7+
8+
import SwiftUI
9+
10+
struct BezierDialog: View {
11+
var body: some View {
12+
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/)
13+
}
14+
}
15+
16+
struct BezierDialog_Previews: PreviewProvider {
17+
static var previews: some View {
18+
BezierDialog()
19+
}
20+
}

0 commit comments

Comments
 (0)