-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ :: [#478] BaseReactorViewController, BaseStoryboardReactorViewContr…
…oller
- Loading branch information
Showing
3 changed files
with
108 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -19,4 +19,3 @@ let project = Project.module( | |
) | ||
] | ||
) | ||
|
61 changes: 61 additions & 0 deletions
61
Projects/Features/BaseFeature/Sources/BaseReactorViewController.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,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) {} | ||
} |
47 changes: 47 additions & 0 deletions
47
Projects/Features/BaseFeature/Sources/BaseStoryboardReactorViewController.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,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) {} | ||
} |