Skip to content

Commit

Permalink
[#24] Snackbar Error 타입 제작
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJoEun-01 committed Nov 8, 2024
1 parent 149ce32 commit efc482f
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 21 deletions.
20 changes: 10 additions & 10 deletions Handy/Handy-Storybook/Atom/SnackbarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ final class SnackbarViewController: BaseViewController {

override func setViewHierarchies() {
self.view.addSubview(snackbar1)
self.view.addSubview(snackbar2)
self.view.addSubview(snackbar3)
// self.view.addSubview(snackbar2)
// self.view.addSubview(snackbar3)
self.view.addSubview(snackbar4)
}

Expand All @@ -51,14 +51,14 @@ final class SnackbarViewController: BaseViewController {
$0.bottom.equalToSuperview().inset(56)
$0.centerX.equalToSuperview()
}
snackbar2.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(156)
$0.centerX.equalToSuperview()
}
snackbar3.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(256)
$0.centerX.equalToSuperview()
}
// snackbar2.snp.makeConstraints {
// $0.bottom.equalToSuperview().inset(156)
// $0.centerX.equalToSuperview()
// }
// snackbar3.snp.makeConstraints {
// $0.bottom.equalToSuperview().inset(256)
// $0.centerX.equalToSuperview()
// }
snackbar4.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(356)
$0.centerX.equalToSuperview()
Expand Down
62 changes: 51 additions & 11 deletions Handy/Handy/Source/Atom/HandySnackbar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,18 @@ final public class HandySnackbar: UIView {

private let errorIcon: UIImageView = {
let imageView = UIImageView()
imageView.image = UIImage(systemName: "exclamationmark.circle.fill")
imageView.image = HandyIcon.alertTriangleFilled.withRenderingMode(.alwaysTemplate)
imageView.tintColor = HandySemantic.bgStatusNegative
return imageView
}()

private let cancelButton: UIButton = {
let button = UIButton()
button.setImage(HandyIcon.closeLine, for: .normal)
button.setTitleColor(HandySemantic.iconBasicTertiary, for: .normal)
return button
}()


public init() {
super.init(frame: .zero)
Expand All @@ -96,13 +103,28 @@ final public class HandySnackbar: UIView {

private func setViewHierarchy() {
self.addSubview(label)
self.addSubview(errorIcon)
self.addSubview(cancelButton)
}

private func setAutoLayout() {
self.snp.makeConstraints {
$0.width.equalTo(343)
}
label.snp.makeConstraints {
$0.edges.equalToSuperview().inset(16)
$0.width.equalTo(311)
}
errorIcon.snp.makeConstraints {
$0.size.equalTo(20)
$0.leading.equalToSuperview().inset(16)
$0.centerY.equalToSuperview()
}
cancelButton.snp.makeConstraints {
$0.size.equalTo(20)
$0.trailing.equalToSuperview().inset(16)
$0.centerY.equalToSuperview()
}
}

private func setLabel() {
Expand All @@ -113,6 +135,24 @@ final public class HandySnackbar: UIView {
if snackbarType == .error {
// 경고 아이콘
print(" === error === ")
errorIcon.isHidden = false
cancelButton.isHidden = false

// label.snp.makeConstraints {
// $0.width.equalTo(255)
// $0.leading.equalTo(errorIcon).offset(28)
// $0.trailing.equalToSuperview().inset(44)
// $0.bottom.top.equalToSuperview().inset(16)
// }

} else {
errorIcon.isHidden = true
cancelButton.isHidden = true

// label.snp.makeConstraints {
// $0.width.equalTo(311)
// $0.edges.equalToSuperview().inset(16)
// }
}
}

Expand All @@ -124,7 +164,7 @@ final public class HandySnackbar: UIView {
private func showSnackbar() {
print("== showSnackbar ==")
UIView.animate(
withDuration: 0.5,
withDuration: 1.5,
delay: 0.0,
options: .curveEaseInOut,
animations: {
Expand All @@ -135,15 +175,15 @@ final public class HandySnackbar: UIView {
}

private func hideSnackbar() {
UIView.animate(
withDuration: 2.0,
delay: 5.0,
options: .curveEaseOut,
animations: {
self.alpha = 0.0
}, completion: { _ in
self.removeFromSuperview()
})
// UIView.animate(
// withDuration: 2.0,
// delay: 5.0,
// options: .curveEaseOut,
// animations: {
// self.alpha = 0.0
// }, completion: { _ in
// self.removeFromSuperview()
// })
}

override public func setNeedsLayout() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "ic_close_filled.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "ic_close_line.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Handy/Handy/Source/Foundation/HandyIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public enum HandyIcon {
public static var volumeLine: UIImage { .load(name: "ic_volume_line") }
public static var wifiFilled: UIImage { .load(name: "ic_wifi_filled") }
public static var wifiLine: UIImage { .load(name: "ic_wifi_line") }
public static var closeFilled: UIImage { .load(name: "ic_close_filled") }
public static var closeLine: UIImage { .load(name: "ic_close_line") }

public static var checkBoxFilled: UIImage { .load(name: "checkBoxFilled") }
public static var checkBoxLine: UIImage { .load(name: "checkBoxLine") }
Expand Down
11 changes: 11 additions & 0 deletions Handy/Handy/Source/Foundation/HandySematic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,15 @@ public enum HandySemantic {
public static var paginationBasicUnSelected: UIColor {
return .gray500
}

// MARK: - Snackbar

public static var snackbarInfo: UIColor {
return .gray800
}

public static var snackbarError: UIColor {
return .redSub
}

}

0 comments on commit efc482f

Please sign in to comment.