Skip to content

Commit fe48210

Browse files
committed
[BOOK-119] feat: add new catalog view for components
1 parent d482fe9 commit fe48210

4 files changed

Lines changed: 257 additions & 6 deletions

File tree

src/Projects/BKDesign/PreviewApp/Sources/SceneDelegate.swift

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import UIKit
55

66
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
77
var window: UIWindow?
8+
let navigationController = UINavigationController()
89

910
func scene(
1011
_ scene: UIScene,
@@ -13,12 +14,43 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
1314
) {
1415
guard let windowScene = scene as? UIWindowScene else { return }
1516

16-
let window = UIWindow(windowScene: windowScene)
17-
let viewController = BKButtonTestViewController()
18-
// let viewController = BKButtonGroupDemoViewController()
19-
window.rootViewController = UINavigationController(rootViewController: viewController)
20-
window.makeKeyAndVisible()
17+
setupNavigationBar()
18+
window = UIWindow(windowScene: windowScene)
19+
window?.rootViewController = navigationController
20+
window?.makeKeyAndVisible()
2121

22-
self.window = window
22+
navigationController.pushViewController(CatalogViewController(), animated: true)
23+
}
24+
25+
func setupNavigationBar() {
26+
guard let font = BKTextStyle.headline2(weight: .semiBold).uiFont else { return }
27+
let appearance = UINavigationBarAppearance()
28+
appearance.configureWithDefaultBackground()
29+
appearance.titleTextAttributes = [
30+
.foregroundColor: UIColor.bkContentColor(.primary),
31+
.font: font
32+
]
33+
appearance.backgroundColor = .bkBaseColor(.primary)
34+
appearance.shadowColor = .clear
35+
36+
let barButtonAppearance = UIBarButtonItemAppearance()
37+
barButtonAppearance.normal.titleTextAttributes = [
38+
.foregroundColor: UIColor.clear
39+
]
40+
41+
let backButtonImage = BKImage.Icon.chevronLeft
42+
.withRenderingMode(.alwaysTemplate)
43+
.withAlignmentRectInsets(
44+
UIEdgeInsets(top: 0, left: -16, bottom: 0, right: 0)
45+
)
46+
47+
appearance.backButtonAppearance = barButtonAppearance
48+
appearance.setBackIndicatorImage(backButtonImage, transitionMaskImage: backButtonImage)
49+
50+
navigationController.navigationBar.tintColor = .bkContentColor(.primary)
51+
navigationController.navigationBar.standardAppearance = appearance
52+
navigationController.navigationBar.scrollEdgeAppearance = appearance
53+
navigationController.navigationBar.compactAppearance = appearance
54+
navigationController.navigationBar.isTranslucent = false
2355
}
2456
}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
// Copyright © 2025 Booket. All rights reserved
2+
3+
import BKDesign
4+
import SnapKit
5+
import UIKit
6+
7+
final class BKInputCatalogView: BaseView {
8+
private let contentView = UIView()
9+
private let scrollView: UIScrollView = {
10+
let scrollView = UIScrollView()
11+
scrollView.alwaysBounceVertical = true
12+
scrollView.alwaysBounceHorizontal = false
13+
scrollView.showsHorizontalScrollIndicator = false
14+
return scrollView
15+
}()
16+
17+
private let stackView: UIStackView = {
18+
let stackView = UIStackView()
19+
stackView.axis = .vertical
20+
stackView.spacing = BKSpacing.spacing5
21+
stackView.alignment = .fill
22+
return stackView
23+
}()
24+
25+
private let mediumLabel = BKLabel(
26+
text: "Medium Label",
27+
type: .medium
28+
)
29+
30+
private let smallLabel = BKLabel(
31+
text: "small label",
32+
type: .small
33+
)
34+
35+
private let labelDivider = BKDivider(type: .medium)
36+
private let checkBoxStackView: UIStackView = {
37+
let stackView = UIStackView()
38+
stackView.axis = .horizontal
39+
stackView.spacing = BKSpacing.spacing2
40+
stackView.alignment = .leading
41+
stackView.distribution = .equalCentering
42+
return stackView
43+
}()
44+
45+
private let rectangleCheckBox = BKCheckBox(type: .rectangle)
46+
private let roundCheckBox = BKCheckBox(type: .round)
47+
private let checkBoxSpacer = UIView()
48+
49+
private let checkBoxDivider = BKDivider(type: .medium)
50+
51+
private let normalBaseTextField = BKBaseTextField(
52+
placeholder: "여기에 텍스트가 들어갑니다.",
53+
type: .normal
54+
)
55+
56+
private let brandBaseTextField = BKBaseTextField(
57+
placeholder: "여기에 텍스트가 들어갑니다.",
58+
type: .brand
59+
)
60+
61+
private let errorBaseTextField = BKBaseTextField(
62+
placeholder: "여기에 텍스트가 들어갑니다.",
63+
type: .error
64+
)
65+
66+
private let searchTextFieldDivider = BKDivider(type: .small)
67+
68+
private let searchTextField = BKSearchTextField(
69+
placeholder: "여기에 텍스트가 들어갑니다.",
70+
type: .brand
71+
)
72+
73+
private let textFieldDivider = BKDivider(type: .small)
74+
75+
private let textField = BKTextView(
76+
labelText: "BKTextField",
77+
placeholder: "여기에 텍스트가 들어갑니다.",
78+
helpMessage: "Help message",
79+
isError: false
80+
)
81+
82+
private let textFieldWithError = BKTextView(
83+
labelText: "BKTextField",
84+
placeholder: "에러가 발생한 TextField.",
85+
helpMessage: "Help message",
86+
isError: true
87+
)
88+
89+
override func setupView() {
90+
addSubview(scrollView)
91+
92+
scrollView.addSubview(contentView)
93+
contentView.addSubview(stackView)
94+
95+
stackView.addArrangedSubview(mediumLabel)
96+
stackView.addArrangedSubview(smallLabel)
97+
stackView.addArrangedSubview(labelDivider)
98+
99+
checkBoxStackView.addArrangedSubview(rectangleCheckBox)
100+
checkBoxStackView.addArrangedSubview(roundCheckBox)
101+
checkBoxStackView.addArrangedSubview(checkBoxSpacer)
102+
stackView.addArrangedSubview(checkBoxStackView)
103+
104+
stackView.addArrangedSubview(checkBoxDivider)
105+
106+
stackView.addArrangedSubview(normalBaseTextField)
107+
stackView.addArrangedSubview(brandBaseTextField)
108+
stackView.addArrangedSubview(errorBaseTextField)
109+
110+
stackView.addArrangedSubview(searchTextFieldDivider)
111+
112+
stackView.addArrangedSubview(searchTextField)
113+
114+
stackView.addArrangedSubview(textFieldDivider)
115+
stackView.addArrangedSubview(textField)
116+
stackView.addArrangedSubview(textFieldWithError)
117+
}
118+
119+
override func configure() {
120+
backgroundColor = .white
121+
}
122+
123+
override func setupLayout() {
124+
scrollView.snp.makeConstraints {
125+
$0.edges.equalToSuperview()
126+
}
127+
128+
contentView.snp.makeConstraints {
129+
$0.edges.equalTo(scrollView.contentLayoutGuide)
130+
$0.width.equalTo(scrollView.frameLayoutGuide)
131+
}
132+
133+
stackView.snp.makeConstraints {
134+
$0.edges.equalToSuperview()
135+
.inset(BKInset.inset20)
136+
}
137+
}
138+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright © 2025 Booket. All rights reserved
2+
3+
import UIKit
4+
5+
final class BKInputCatalogViewController: BaseViewController<BKInputCatalogView> {
6+
override func viewWillAppear(_ animated: Bool) {
7+
super.viewWillAppear(animated)
8+
navigationItem.title = "Label, TextField"
9+
}
10+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright © 2025 Booket. All rights reserved
2+
3+
import SnapKit
4+
import UIKit
5+
6+
final class CatalogViewController: UIViewController {
7+
private let inputCatalogButton: UIButton = {
8+
let button = UIButton(type: .system)
9+
button.setTitle("BKInputCatalogViewController", for: .normal)
10+
return button
11+
}()
12+
13+
private let buttonTestButton: UIButton = {
14+
let button = UIButton(type: .system)
15+
button.setTitle("BKButtonTestViewController", for: .normal)
16+
return button
17+
}()
18+
19+
private let buttonGroupDemoButton: UIButton = {
20+
let button = UIButton(type: .system)
21+
button.setTitle("BKButtonGroupDemoViewController", for: .normal)
22+
return button
23+
}()
24+
25+
override func viewDidLoad() {
26+
super.viewDidLoad()
27+
title = "Test Menu"
28+
view.backgroundColor = .systemBackground
29+
configure()
30+
bindActions()
31+
}
32+
33+
private func configure() {
34+
let stack = UIStackView(arrangedSubviews: [
35+
inputCatalogButton,
36+
buttonTestButton,
37+
buttonGroupDemoButton
38+
])
39+
stack.axis = .vertical
40+
stack.spacing = 16
41+
stack.alignment = .center
42+
43+
view.addSubview(stack)
44+
45+
stack.snp.makeConstraints {
46+
$0.centerX.equalToSuperview()
47+
$0.centerY.equalToSuperview()
48+
}
49+
}
50+
51+
private func bindActions() {
52+
inputCatalogButton.addTarget(self, action: #selector(openInputCatalog), for: .touchUpInside)
53+
buttonTestButton.addTarget(self, action: #selector(openButtonTest), for: .touchUpInside)
54+
buttonGroupDemoButton.addTarget(self, action: #selector(openButtonGroupDemo), for: .touchUpInside)
55+
}
56+
57+
@objc private func openInputCatalog() {
58+
let vc = BKInputCatalogViewController()
59+
navigationController?.pushViewController(vc, animated: true)
60+
}
61+
62+
@objc private func openButtonTest() {
63+
let vc = BKButtonTestViewController()
64+
navigationController?.pushViewController(vc, animated: true)
65+
}
66+
67+
@objc private func openButtonGroupDemo() {
68+
let vc = BKButtonGroupDemoViewController()
69+
navigationController?.pushViewController(vc, animated: true)
70+
}
71+
}

0 commit comments

Comments
 (0)