-
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.
MMButton, SnackBar Components 구현 (#3)
* feat: MMSnackBar 구현 (without Font, Image) * merge: 사파리 Resources 작업 가져오기 commit 04c74ca Author: Safari <[email protected]> Date: Mon Apr 8 10:21:15 2024 +0900 fix: Bundle 통해 리소스 데이터 가져오도록 수정 commit 8d51203 Author: Safari <[email protected]> Date: Mon Apr 8 10:20:32 2024 +0900 chore: 오타 수정 commit 348a4e0 Author: Safari <[email protected]> Date: Mon Apr 8 10:20:02 2024 +0900 chore: plist SceneDelegate 설정 * feat: MMSnackBar에 Font, Image 추가 * feat: Color Components 구현 * feat: Fonts 미리보기 구현 * feat: MM버튼 개선 및 MMButton 디자인시스템 구현 * Create pull_request_template.md
- Loading branch information
Showing
17 changed files
with
642 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## 작업 내용 | ||
|
||
- [ ] TODO | ||
- [ ] TODO | ||
- [ ] TODO | ||
|
||
## 리뷰어에게 (필요시) | ||
|
||
- ~참고 해주세요 | ||
|
||
## 스크린샷 (필요시) |
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,65 @@ | ||
import UIKit | ||
|
||
import DesignSystem | ||
|
||
final class ButtonVC: UIViewController { | ||
|
||
private let button1 = MMButton(title: "dudu", type: .primary) | ||
private let button2 = MMButton(title: "dudu", type: .primary) | ||
private let button3 = MMButton(title: "dudu", type: .primary) | ||
private let segmentedControl: UISegmentedControl = { | ||
let v = UISegmentedControl(items: ["primary", "secondary", "disable", "negative"]) | ||
v.selectedSegmentIndex = 0 | ||
return v | ||
}() | ||
|
||
private let rootContainer = UIView() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setupView() | ||
setupConstraints() | ||
} | ||
|
||
private func setupView() { | ||
view.backgroundColor = .systemBackground | ||
title = "MMButton" | ||
|
||
let buttons = [button1, button2, button3] | ||
|
||
segmentedControl.setAction(UIAction(title: "Primary") { _ in | ||
buttons.forEach { $0.setState(.primary) } | ||
}, forSegmentAt: 0) | ||
|
||
segmentedControl.setAction(UIAction(title: "Secondary") { _ in | ||
buttons.forEach { $0.setState(.secondary) } | ||
}, forSegmentAt: 1) | ||
|
||
segmentedControl.setAction(UIAction(title: "Disable") { _ in | ||
buttons.forEach { $0.setState(.disable) } | ||
}, forSegmentAt: 2) | ||
|
||
segmentedControl.setAction(UIAction(title: "Negative") { _ in | ||
buttons.forEach { $0.setState(.negative) } | ||
}, forSegmentAt: 3) | ||
} | ||
|
||
private func setupConstraints() { | ||
view.addSubview(rootContainer) | ||
|
||
rootContainer.flex.justifyContent(.center).padding(20).define { flex in | ||
flex.addItem(button1).height(56).marginBottom(20) | ||
flex.addItem(button2).height(44).marginBottom(20) | ||
flex.addItem(button3).height(40).marginBottom(20) | ||
flex.addItem(segmentedControl).height(50) | ||
} | ||
} | ||
|
||
override func viewDidLayoutSubviews() { | ||
super.viewDidLayoutSubviews() | ||
|
||
rootContainer.pin.all() | ||
rootContainer.flex.layout() | ||
} | ||
} |
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,72 @@ | ||
import UIKit | ||
|
||
import DesignSystem | ||
|
||
final class ColorVC: UITableViewController { | ||
|
||
private var items = [ | ||
["White": [Colors.White._1]], | ||
["Black": [Colors.Black._1]], | ||
["Gray": [Colors.Gray._1, Colors.Gray._2, Colors.Gray._3, Colors.Gray._4, Colors.Gray._5, Colors.Gray._6, Colors.Gray._7, Colors.Gray._8, Colors.Gray._9, Colors.Gray._10]], | ||
["Blue": [Colors.Blue._1, Colors.Blue._2, Colors.Blue._3, Colors.Blue._4]], | ||
["SkyBlue": [Colors.SkyBlue._1]], | ||
["Mint": [Colors.Mint._1, Colors.Mint._2, Colors.Mint._3]], | ||
["Yellow": [Colors.Yellow._1]], | ||
["Red": [Colors.Red._1, Colors.Red._2, Colors.Red._3]], | ||
] | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setupView() | ||
} | ||
|
||
private func setupView() { | ||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: String(describing: UITableViewCell.self)) | ||
title = "Colors" | ||
} | ||
} | ||
|
||
extension ColorVC { | ||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return items[section].values.first!.count | ||
} | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return items.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | ||
return items[section].keys.first | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UITableViewCell.self), for: indexPath) | ||
|
||
let colorName = items[indexPath.section].keys.first! | ||
let color = items[indexPath.section].values.first![indexPath.row] | ||
|
||
cell.textLabel?.text = " \(colorName)_\(indexPath.row + 1)" | ||
cell.textLabel?.font = .systemFont(ofSize: 20) | ||
|
||
let image = UIGraphicsImageRenderer(size: .init(width: 40, height: 40)).image { rendererContext in | ||
color.setFill() | ||
rendererContext.fill(CGRect(origin: .zero, size: .init(width: 40, height: 40))) | ||
} | ||
|
||
cell.imageView?.image = image | ||
cell.imageView?.layer.cornerRadius = 20 | ||
cell.imageView?.layer.borderColor = UIColor.black.cgColor | ||
cell.imageView?.layer.borderWidth = 1 | ||
cell.imageView?.clipsToBounds = true | ||
return cell | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | ||
return 60 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { | ||
return nil | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Projects/Shared/DesignSystem/Demo/Sources/DesignSystemVC.swift
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,64 @@ | ||
import UIKit | ||
|
||
final class DesignSystemVC: UITableViewController { | ||
|
||
enum Screen: Int, CaseIterable { | ||
case color | ||
case font | ||
case button | ||
case snackbar | ||
|
||
var title: String { | ||
switch self { | ||
case .color: return "Colors" | ||
case .font: return "Fonts" | ||
case .button: return "Buttons" | ||
case .snackbar: return "SnackBar" | ||
} | ||
} | ||
|
||
func move(with navigationController: UINavigationController?) { | ||
let vc: UIViewController | ||
switch self { | ||
case .color: vc = ColorVC(style: .insetGrouped) | ||
case .font: vc = FontVC(style: .insetGrouped) | ||
case .button: vc = ButtonVC() | ||
case .snackbar: vc = SnackBarVC() | ||
} | ||
|
||
navigationController?.pushViewController(vc, animated: true) | ||
} | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setupView() | ||
} | ||
|
||
private func setupView() { | ||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: String(describing: UITableViewCell.self)) | ||
title = "Components" | ||
navigationController?.navigationBar.prefersLargeTitles = true | ||
} | ||
} | ||
|
||
extension DesignSystemVC { | ||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return Screen.allCases.count | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UITableViewCell.self), for: indexPath) | ||
cell.accessoryType = .disclosureIndicator | ||
cell.textLabel?.text = Screen(rawValue: indexPath.row)?.title | ||
cell.textLabel?.font = .systemFont(ofSize: 20) | ||
return cell | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | ||
tableView.deselectRow(at: indexPath, animated: true) | ||
|
||
Screen(rawValue: indexPath.row)?.move(with: navigationController) | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
Projects/Shared/DesignSystem/Demo/Sources/DesignSystemViewController.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import UIKit | ||
import DesignSystem | ||
|
||
final class FontVC: UITableViewController { | ||
|
||
private let items: [UIFont] = [ | ||
Fonts.heading._1, | ||
Fonts.heading._2, | ||
Fonts.heading._3, | ||
Fonts.heading._4, | ||
Fonts.heading._5, | ||
Fonts.body._1, | ||
Fonts.body._2, | ||
Fonts.body._3, | ||
Fonts.body._4, | ||
Fonts.body._5, | ||
] | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setupView() | ||
} | ||
|
||
private func setupView() { | ||
tableView.register(UITableViewCell.self, forCellReuseIdentifier: String(describing: UITableViewCell.self)) | ||
title = "Fonts" | ||
} | ||
} | ||
|
||
extension FontVC { | ||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return items.count / 2 | ||
} | ||
|
||
override func numberOfSections(in tableView: UITableView) -> Int { | ||
return 2 | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { | ||
return section == 0 ? "Heading" : "Body" | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UITableViewCell.self), for: indexPath) | ||
|
||
let style = indexPath.section == 0 ? "heading" : "body" | ||
|
||
cell.textLabel?.text = "\(style)_\(indexPath.row+1)" | ||
cell.textLabel?.font = items[indexPath.section * 5 + indexPath.row] | ||
return cell | ||
} | ||
|
||
override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? { | ||
return nil | ||
} | ||
} |
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
Oops, something went wrong.