Skip to content

Commit d482fe9

Browse files
committed
[BOOK-119] feat: add common component for PreviewApp
1 parent e837a6d commit d482fe9

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright © 2025 Booket. All rights reserved
2+
3+
import UIKit
4+
5+
class BaseView: UIView {
6+
// MARK: - Initialize
7+
override init(frame: CGRect = .zero) {
8+
super.init(frame: frame)
9+
self.setupView()
10+
self.setupLayout()
11+
self.configure()
12+
}
13+
14+
@available(*, unavailable)
15+
required init?(coder: NSCoder) {
16+
fatalError("init(coder:) has not been implemented")
17+
}
18+
19+
// MARK: - Common Methods
20+
func setupView() {}
21+
func setupLayout() {}
22+
func configure() {}
23+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright © 2025 Booket. All rights reserved
2+
3+
import UIKit
4+
5+
class BaseViewController<T: BaseView>: UIViewController {
6+
// MARK: - Properties
7+
let contentView: T
8+
9+
// MARK: - Initialize
10+
init() {
11+
self.contentView = T()
12+
super.init(nibName: nil, bundle: nil)
13+
}
14+
15+
@available(*, unavailable)
16+
required init?(coder: NSCoder) {
17+
fatalError("init(coder:) has not been implemented")
18+
}
19+
20+
// MARK: - Life Cycle
21+
override func loadView() {
22+
if contentView.backgroundColor == nil {
23+
contentView.backgroundColor = .white
24+
}
25+
view = contentView
26+
}
27+
28+
override func viewDidLoad() {
29+
super.viewDidLoad()
30+
31+
self.setupView()
32+
self.configure()
33+
self.setupLayout()
34+
self.bindAction()
35+
self.bindState()
36+
}
37+
38+
// MARK: - Common Methods
39+
func setupView() {}
40+
func configure() {}
41+
func setupLayout() {}
42+
func bindAction() {}
43+
func bindState() {}
44+
}

0 commit comments

Comments
 (0)