Skip to content

Commit

Permalink
BURN :: [#326] 중단
Browse files Browse the repository at this point in the history
  • Loading branch information
cyj513 committed May 16, 2024
1 parent a39e64a commit 7291954
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

window = UIWindow(windowScene: windowScene)
let useCase = DefaultSelfCareUseCase(repository: SelfCareRepository(networkService: SelfCareService()))
let viewModel = SelfCareMyRoutineViewModel(useCase: useCase)
let viewController = SelfCareMyRoutineViewController(viewModel)
let viewModel = SelfCareHomeViewModel()
let viewController = SelfCareHomeViewController(viewModel)
// let viewModel = SelfCareMyRoutineViewModel(useCase: useCase)
// let viewController = SelfCareMyRoutineViewController(viewModel)
window?.configure(withRootViewController: viewController)
window?.makeKeyAndVisible()
}
Expand Down
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.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ public class SelfCareMyRoutineViewController: BaseViewController<SelfCareMyRouti
.bind(onNext: { [weak self] in
let useCase = DefaultSelfCareUseCase(repository: SelfCareRepository(networkService: SelfCareService()))

let viewModel = SelfCareMyRoutineEditViewModel(useCase: useCase)
let vc = SelfCareMyRoutineEditViewController(viewModel)
let viewModel = SelfCareMyRoutineAddViewModel(useCase: useCase)
let vc = SelfCareMyRoutineAddViewController(viewModel)
self?.navigationController?.pushViewController(vc, animated: true)
}).disposed(by: disposeBag)
}
Expand Down Expand Up @@ -178,22 +178,7 @@ extension SelfCareMyRoutineViewController: UITableViewDataSource {
cell?.selectionStyle = .none
cell?.dotsButtonTap
.bind(onNext: { [weak self] in
let modal = TestViewController()

if #available(iOS 16.0, *) {
let customDetent = UISheetPresentationController.Detent.custom(identifier: .init("custom")) { _ in
return 257
}
if let sheet = modal.sheetPresentationController {
sheet.detents = [customDetent]
sheet.prefersGrabberVisible = true
}
} else {
if let sheet = modal.sheetPresentationController {
sheet.detents = [.medium()]
sheet.prefersGrabberVisible = true
}
}
let modal = MGBottomSheetViewController(type: .plain)
self?.present(modal, animated: true)
}).disposed(by: disposeBag)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
//
// TestViewController.swift
// SelfCarePostureAddViewController.swift
// SelfCareFeatureInterface
//
// Created by 조영준 on 5/13/24.
// Created by 조영준 on 5/16/24.
// Copyright © 2024 MaeumGaGym-iOS. All rights reserved.
//

import UIKit

public class TestViewController: UIViewController {
class SelfCarePostureAddViewController: UIViewController {

public override func viewDidLoad() {
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = .blue

// Do any additional setup after loading the view.
}

Expand Down
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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SelfCareButton: BaseButton {
private var buttonImage = UIImageView()

private var buttonLabel = MGLabel(font: UIFont.Pretendard.labelLarge,
isCenter: false,
isCenter: true,
numberOfLineCount: 1
)

Expand Down

0 comments on commit 7291954

Please sign in to comment.