-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…tton-UI [FEAT/#8] �프레임과 스티커를 담당하는 커스텀 버튼을 구현하였습니다.
- Loading branch information
Showing
22 changed files
with
194 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import UIKit | ||
import SnapKit | ||
|
||
public final class PTGGrayButton: UIButton { | ||
private let type: PTGGrayButtonType | ||
private let stackView = UIStackView() | ||
private let grayButtonImage = UIImageView() | ||
private let grayButtonLabel = UILabel() | ||
|
||
public init(type: PTGGrayButtonType) { | ||
self.type = type | ||
super.init(frame: .zero) | ||
|
||
addViews() | ||
setupConstraints() | ||
configureUI() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private func addViews() { | ||
addSubview(stackView) | ||
[grayButtonImage, grayButtonLabel].forEach { | ||
stackView.addArrangedSubview($0) | ||
} | ||
} | ||
|
||
private func setupConstraints() { | ||
stackView.snp.makeConstraints { | ||
$0.center.equalToSuperview() | ||
} | ||
|
||
grayButtonImage.snp.makeConstraints { | ||
$0.width.height.equalTo(24) | ||
} | ||
} | ||
|
||
private func configureUI() { | ||
backgroundColor = .gray85 | ||
layer.cornerRadius = 12 | ||
|
||
stackView.axis = .horizontal | ||
stackView.distribution = .equalSpacing | ||
stackView.spacing = 8 | ||
|
||
grayButtonImage.image = UIImage.load(name: type.image) | ||
grayButtonImage.contentMode = .scaleAspectFit | ||
grayButtonImage.tintColor = .white | ||
|
||
grayButtonLabel.text = type.text | ||
grayButtonLabel.textColor = .white | ||
grayButtonLabel.font = .systemFont(ofSize: 16, weight: .semibold) | ||
} | ||
} | ||
|
||
public extension PTGGrayButton { | ||
enum PTGGrayButtonType { | ||
case frame | ||
case sticker | ||
|
||
var text: String { | ||
switch self { | ||
case .frame: | ||
return "프레임" | ||
case .sticker: | ||
return "스티커" | ||
} | ||
} | ||
|
||
var image: String { | ||
switch self { | ||
case .frame: | ||
return "frameIcon" | ||
case .sticker: | ||
return "stickerIcon" | ||
} | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
PhotoGether/DesignSystem/DesignSystem/Resource/DesignSystem.xcassets/PTGColor/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
PhotoGether/DesignSystem/DesignSystem/Resource/DesignSystem.xcassets/PTGIcon/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...stem/DesignSystem/Resource/DesignSystem.xcassets/PTGIcon/frameIcon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "frameIcon.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...nSystem/Resource/DesignSystem.xcassets/PTGIcon/frameIcon.imageset/frameIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
...em/DesignSystem/Resource/DesignSystem.xcassets/PTGIcon/stickerIcon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "stickerIcon.svg", | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...tem/Resource/DesignSystem.xcassets/PTGIcon/stickerIcon.imageset/stickerIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import UIKit | ||
|
||
public extension UIImage { | ||
static func load(name: String) -> UIImage? { | ||
let image = UIImage( | ||
named: name, | ||
in: Bundle.init(identifier: "kr.codesquad.boostcamp9.DesignSystem"), | ||
compatibleWith: nil | ||
) | ||
return image | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters