Skip to content

Commit

Permalink
✨ :: [#478] BaseReactorViewController, BaseStoryboardReactorViewContr…
Browse files Browse the repository at this point in the history
…oller
  • Loading branch information
baekteun committed Apr 1, 2024
1 parent ccd31f5 commit db0e5c2
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
1 change: 0 additions & 1 deletion Projects/Features/BaseFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ let project = Project.module(
)
]
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import NVActivityIndicatorView
import ReactorKit
import RxSwift
import SnapKit
import Then
import UIKit

open class BaseReactorViewController<R: Reactor>: UIViewController, View {
public var disposeBag = DisposeBag()
open lazy var indicator = NVActivityIndicatorView(frame: .zero).then {
view.addSubview($0)
$0.snp.makeConstraints {
$0.center.equalToSuperview()
$0.size.equalTo(30)
}
}

public init(reactor: R) {
super.init(nibName: nil, bundle: nil)
self.reactor = reactor
}

@available(*, unavailable)
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override open func viewDidLoad() {
super.viewDidLoad()
addView()
setLayout()
configureUI()
configureNavigation()
}

public func bind(reactor: R) {
bindState(reactor: reactor)
bindAction(reactor: reactor)
}

open func addView() {}
open func setLayout() {}
open func configureUI() {
// 내용 유지?
if #available(iOS 15.0, *) {
let tableViews = self.view.subviews
.compactMap { $0 as? UITableView }
.forEach {
$0.sectionHeaderTopPadding = 0
}
}
}

open func configureNavigation() {
// 내용 유지?
self.navigationController?.setNavigationBarHidden(true, animated: false)
}

open func bindState(reactor: R) {}
open func bindAction(reactor: R) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import NVActivityIndicatorView
import ReactorKit
import RxSwift
import SnapKit
import Then
import UIKit
import Utility

open class BaseStoryboardReactorViewController<R: Reactor>: UIViewController, StoryboardView,
ViewControllerFromStoryBoard {
public var disposeBag = DisposeBag()

@available(*, unavailable)
public required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override open func viewDidLoad() {
super.viewDidLoad()
configureUI()
configureNavigation()
}

public func bind(reactor: R) {
bindState(reactor: reactor)
bindAction(reactor: reactor)
}

open func configureUI() {
// 내용 유지?
if #available(iOS 15.0, *) {
let tableViews = self.view.subviews
.compactMap { $0 as? UITableView }
.forEach {
$0.sectionHeaderTopPadding = 0
}
}
}

open func configureNavigation() {
// 내용 유지?
self.navigationController?.setNavigationBarHidden(true, animated: false)
}

open func bindState(reactor: R) {}
open func bindAction(reactor: R) {}
}

0 comments on commit db0e5c2

Please sign in to comment.