-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
271 additions
and
26 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
202 changes: 202 additions & 0 deletions
202
...Features/SelfCareFeature/Sources/RoutineScene/VC/SelfCareMyRoutineAddViewController.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,202 @@ | ||
import UIKit | ||
|
||
import RxFlow | ||
import RxCocoa | ||
import RxSwift | ||
|
||
import SnapKit | ||
import Then | ||
|
||
import Core | ||
import Data | ||
import DSKit | ||
|
||
import Domain | ||
import MGLogger | ||
import MGNetworks | ||
|
||
import SelfCareFeatureInterface | ||
|
||
public class SelfCareMyRoutineAddViewController: BaseViewController<SelfCareMyRoutineAddViewModel>, Stepper, UIGestureRecognizerDelegate { | ||
|
||
private var myRoutineEditData: SelfCareMyRoutineEditModel = | ||
SelfCareMyRoutineEditModel( | ||
textFieldData: | ||
MyRoutineEditTextFieldModel( | ||
textFieldTitle: "", | ||
textFieldText: "", | ||
textFieldPlaceholder: "" | ||
), date: [], | ||
exerciseData: [] | ||
) | ||
|
||
private var naviBar = RoutineNavigationBarBar() | ||
|
||
private var headerView = UIView() | ||
|
||
private var titleTextView = MGTitleTextFieldView(titleText: "제목", textLimit: 3, placeholder: "제목을 입력해주세요") | ||
|
||
private var textFieldData: MyRoutineEditTextFieldModel = MyRoutineEditTextFieldModel( | ||
textFieldTitle: "", | ||
textFieldText: "", | ||
textFieldPlaceholder: "" | ||
) | ||
private var myRoutineDetailTableView = UITableView().then { | ||
$0.showsVerticalScrollIndicator = false | ||
$0.showsHorizontalScrollIndicator = false | ||
$0.backgroundColor = .white | ||
$0.separatorStyle = .none | ||
$0.register( | ||
MyRoutineEditTableViewCell.self, | ||
forCellReuseIdentifier: MyRoutineEditTableViewCell.identifier | ||
) | ||
$0.register( | ||
MyRoutineDateTableViewCell.self, | ||
forCellReuseIdentifier: MyRoutineDateTableViewCell.identifier | ||
) | ||
} | ||
|
||
private let underLine = MGLine(lineHeight: 1.0) | ||
private let underBackView = UIView() | ||
private let buttonSpaceView = UIView() | ||
|
||
private var plusPostureButton = SelfCareButton(type: .posturePlus) | ||
private var editButton = SelfCareButton(type: .complete) | ||
|
||
override public func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
view.backgroundColor = .white | ||
} | ||
|
||
public override func configureNavigationBar() { | ||
super.configureNavigationBar() | ||
navigationController?.isNavigationBarHidden = true | ||
self.view.frame = self.view.frame.inset(by: UIEdgeInsets(top: .zero, left: 0, bottom: .zero, right: 0)) | ||
} | ||
|
||
public override func attribute() { | ||
super.attribute() | ||
|
||
naviBar.setLeftText(text: "루틴 추가") | ||
|
||
myRoutineDetailTableView.delegate = self | ||
myRoutineDetailTableView.dataSource = self | ||
navigationController?.interactivePopGestureRecognizer?.delegate = self | ||
} | ||
|
||
public override func layout() { | ||
super.layout() | ||
|
||
headerView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 132.0)) | ||
view.addSubviews([naviBar, myRoutineDetailTableView, underBackView]) | ||
|
||
headerView.addSubview(titleTextView) | ||
|
||
naviBar.snp.makeConstraints { | ||
$0.leading.top.trailing.equalTo(view.safeAreaLayoutGuide) | ||
} | ||
|
||
titleTextView.snp.makeConstraints { | ||
$0.top.equalToSuperview().offset(24.0) | ||
$0.leading.trailing.equalToSuperview().inset(20.0) | ||
$0.bottom.equalToSuperview().inset(32.0) | ||
} | ||
|
||
myRoutineDetailTableView.tableHeaderView = headerView | ||
myRoutineDetailTableView.snp.makeConstraints { | ||
$0.top.equalToSuperview().offset(105.0) | ||
$0.leading.trailing.equalToSuperview() | ||
$0.height.equalTo(695.0) | ||
} | ||
|
||
underBackView.snp.makeConstraints { | ||
$0.bottom.equalTo(view.safeAreaLayoutGuide) | ||
$0.leading.trailing.equalToSuperview() | ||
$0.top.equalTo(myRoutineDetailTableView.snp.bottom) | ||
} | ||
|
||
underBackView.addSubviews([underLine, buttonSpaceView, plusPostureButton, editButton]) | ||
|
||
underLine.snp.makeConstraints { | ||
$0.trailing.leading.equalToSuperview() | ||
$0.top.equalToSuperview() | ||
} | ||
|
||
buttonSpaceView.snp.makeConstraints { | ||
$0.top.bottom.equalToSuperview() | ||
$0.width.equalTo(8.0) | ||
$0.centerX.equalToSuperview() | ||
} | ||
|
||
plusPostureButton.snp.makeConstraints { | ||
$0.top.bottom.equalToSuperview().inset(20.0) | ||
$0.leading.equalToSuperview().offset(20.0) | ||
$0.trailing.equalTo(buttonSpaceView.snp.leading) | ||
} | ||
|
||
editButton.snp.makeConstraints { | ||
$0.top.bottom.equalToSuperview().inset(20.0) | ||
$0.trailing.equalToSuperview().offset(-20.0) | ||
$0.leading.equalTo(buttonSpaceView.snp.trailing) | ||
} | ||
} | ||
|
||
public override func bindActions() { | ||
self.naviBar.leftButtonTap | ||
.bind(onNext: { [weak self] in | ||
self?.navigationController?.popViewController(animated: true) | ||
}).disposed(by: disposeBag) | ||
} | ||
// public override func bindViewModel() { | ||
// let useCase = DefaultSelfCareUseCase(repository: SelfCareRepository(networkService: SelfCareService())) | ||
// | ||
// viewModel = SelfCareMyRoutineEditViewModel(useCase: useCase) | ||
// | ||
// let input = SelfCareMyRoutineEditViewModel.Input( | ||
// getMyRoutineEditData: Observable.just(()).asDriver(onErrorDriveWith: .never())) | ||
// | ||
// let output = viewModel.transform(input, action: { output in | ||
// output.myRoutineEditData | ||
// .subscribe(onNext: { myRoutineEditData in | ||
// MGLogger.debug("myRoutineEditData: \(myRoutineEditData)") | ||
// self.myRoutineEditData = myRoutineEditData | ||
// self.textFieldData = myRoutineEditData.textFieldData | ||
// }).disposed(by: disposeBag) | ||
// }) | ||
// } | ||
} | ||
|
||
extension SelfCareMyRoutineAddViewController: UITableViewDelegate { | ||
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | ||
switch indexPath.row { | ||
case 0: | ||
return 104 | ||
default: | ||
return 216 | ||
} | ||
} | ||
} | ||
|
||
extension SelfCareMyRoutineAddViewController: UITableViewDataSource { | ||
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
myRoutineEditData.exerciseData.count + 1 | ||
} | ||
|
||
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
switch indexPath.row { | ||
case 0: | ||
let cell = tableView.dequeueReusableCell(withIdentifier: MyRoutineDateTableViewCell.identifier, for: indexPath) as? MyRoutineDateTableViewCell | ||
cell?.selectionStyle = .none | ||
return cell ?? UITableViewCell() | ||
default: | ||
let cell = tableView.dequeueReusableCell( | ||
withIdentifier: MyRoutineEditTableViewCell.identifier, | ||
for: indexPath) as? MyRoutineEditTableViewCell | ||
let editData = myRoutineEditData.exerciseData[indexPath.row - 1] | ||
cell?.setup(with: editData) | ||
cell?.selectionStyle = .none | ||
return cell ?? UITableViewCell() | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
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
10 changes: 5 additions & 5 deletions
10
...outineScene/Test/TestViewController.swift → ...VC/SelfCarePostureAddViewController.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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions
56
...atures/SelfCareFeature/Sources/RoutineScene/ViewModel/SelfCareMyRoutineAddViewModel.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,56 @@ | ||
import Foundation | ||
|
||
import RxFlow | ||
import RxCocoa | ||
import RxSwift | ||
|
||
import Core | ||
import Domain | ||
import MGLogger | ||
|
||
public class SelfCareMyRoutineAddViewModel: BaseViewModel { | ||
|
||
public typealias ViewModel = SelfCareMyRoutineAddViewModel | ||
|
||
private let disposeBag = DisposeBag() | ||
|
||
private let useCase: SelfCareUseCase | ||
|
||
public struct Input { | ||
let getMyRoutineEditData: Driver<Void> | ||
} | ||
|
||
public struct Output { | ||
let myRoutineEditData: Observable<SelfCareMyRoutineEditModel> | ||
} | ||
|
||
private let myRoutineEditDataSubject = PublishSubject<SelfCareMyRoutineEditModel>() | ||
|
||
public init(useCase: SelfCareUseCase) { | ||
self.useCase = useCase | ||
} | ||
|
||
public func transform(_ input: Input, action: (Output) -> Void) -> Output { | ||
let output = Output( | ||
myRoutineEditData: myRoutineEditDataSubject.asObservable() | ||
) | ||
|
||
action(output) | ||
|
||
self.bindOutput(output: output) | ||
|
||
input.getMyRoutineEditData | ||
.drive(onNext: { [weak self] _ in | ||
self?.useCase.getMyRoutineEditData() | ||
}).disposed(by: disposeBag) | ||
|
||
return output | ||
} | ||
|
||
private func bindOutput(output: Output) { | ||
useCase.myRoutineEditData | ||
.subscribe(onNext: { myRoutineEditData in | ||
self.myRoutineEditDataSubject.onNext(myRoutineEditData) | ||
}).disposed(by: disposeBag) | ||
} | ||
} |
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