Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔀 :: [#146] 자기관리 - 내 루틴 View #151

Merged
merged 20 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ecad04c
⚓️ :: [#146] 자기관리 - tableViewCell 파일 추가
Eunho0922 Jan 29, 2024
aabb2e1
⚓️ :: [#146] 자기관리 - 내 루틴 이미지 추가
Eunho0922 Jan 29, 2024
3d8f3af
⚓️ :: [#146] 자기관리 - 내 루틴 ViewModel 파일 추가
Eunho0922 Jan 29, 2024
fc8eacc
⚓️ :: [#146] 자기관리 - 내 루틴 VC 파일 추가
Eunho0922 Jan 29, 2024
1a2128c
⚓️ :: [#146] 자기관리 - 내 루틴 이미지 추가
Eunho0922 Jan 29, 2024
666a9d3
⚓️ :: [#146] 자기관리 - 내 루틴 모델, 버튼 파일 추가
Eunho0922 Jan 29, 2024
c3b7463
⚓️ :: [#146] 마음가짐 공유 상태 View 추가
Eunho0922 Jan 29, 2024
121df5d
⚓️ :: [#146] 자기관리 - 내 루틴 tableViewCell 추가
Eunho0922 Jan 29, 2024
4b84933
⚓️ :: [#146] 자기관리 - 내 루틴 추가 버튼 추가
Eunho0922 Jan 29, 2024
6426b4a
⚓️ :: [#146] 자기관리 - 내 루틴 model 추가
Eunho0922 Jan 29, 2024
65c2871
⚓️ :: [#146] 자기관리 - 내 루틴 임시 ViewModel 추가
Eunho0922 Jan 29, 2024
59ddf3b
⚓️ :: [#146] 자기관리 - 내 루틴 ViewController 추가
Eunho0922 Jan 29, 2024
8b2e42c
⚓️ :: [#146] 자기관리 - 내 루틴 TableViewCell 추가
Eunho0922 Jan 29, 2024
55164e7
🍗 :: [#146] scenedelgate 변경
Eunho0922 Jan 29, 2024
a045089
⚓️ :: [#146] enum 파일 추가
Eunho0922 Jan 29, 2024
9eeb05e
⚓️ :: [#146] enum 추가
Eunho0922 Jan 29, 2024
946908f
🍗 :: [#146] 코드 스타일 리펙토링
Eunho0922 Jan 29, 2024
7efb0ca
🍗 :: [#146] BaseView 적용
Eunho0922 Jan 29, 2024
9dfa96e
⚓️ :: [#146] 레이아웃 추가
Eunho0922 Jan 29, 2024
50f0f2b
🍗 :: [#146] 코드 리펙토링
Eunho0922 Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
window?.rootViewController = UINavigationController(rootViewController: SelfCareViewController())
window?.rootViewController = UINavigationController(rootViewController: SelfCareMyRoutineViewController(SelfCareMyRoutineViewModel()))
window?.makeKeyAndVisible()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import UIKit
import SnapKit
import Then
import Core
import DSKit
public class SelfCareMyRoutineViewController: BaseViewController<SelfCareMyRoutineViewModel> {
private var myRoutineModel = SelfCareMyRoutineModel.myRoutine

private var containerView = UIView()
private var headerView = UIView()

private let myRoutineTitleLabel = UILabel().then {
$0.text = "내 루틴"
$0.textColor = .black
$0.contentMode = .left
$0.font = UIFont.Pretendard.titleLarge
}

private let myRoutineSubTitleLabel = UILabel().then {
$0.text = "나만의 루틴을 구성하여\n규칙적인 운동을 해보세요."
$0.numberOfLines = 2
$0.textColor = DSKitAsset.Colors.gray600.color
$0.font = UIFont.Pretendard.bodyMedium
}

private var myRoutineTableView = UITableView().then {
$0.showsVerticalScrollIndicator = false
$0.showsHorizontalScrollIndicator = false
$0.backgroundColor = .white
$0.separatorStyle = .none
$0.register(MyRoutineTableViewCell.self,
forCellReuseIdentifier: MyRoutineTableViewCell.identifier)
}

private var plusRoutineButton = MyRoutinePlusButton(text: "루틴 추가하기")

override public func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .white
}

public override func attribute() {

myRoutineTableView.delegate = self
myRoutineTableView.dataSource = self
}

public override func layout() {

headerView = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 144.0))
view.addSubview(headerView)

headerView.addSubview(containerView)

containerView.snp.makeConstraints {
$0.top.equalToSuperview().offset(24.0)
$0.leading.trailing.equalToSuperview().inset(20.0)
$0.bottom.equalToSuperview().inset(20.0)
}

containerView.addSubview(myRoutineTitleLabel)
containerView.addSubview(myRoutineSubTitleLabel)

myRoutineTitleLabel.snp.makeConstraints {
$0.top.leading.equalToSuperview()
$0.width.equalToSuperview()
$0.height.equalTo(48.0)
}

myRoutineSubTitleLabel.snp.makeConstraints {
$0.leading.bottom.equalToSuperview()
$0.width.equalToSuperview()
$0.height.equalTo(40.0)
}

view.addSubview(myRoutineTableView)
myRoutineTableView.tableHeaderView = headerView
myRoutineTableView.snp.makeConstraints {
$0.top.equalTo(view.safeAreaLayoutGuide)
$0.leading.trailing.equalToSuperview()
$0.bottom.equalToSuperview()
}

view.addSubview(plusRoutineButton)
plusRoutineButton.snp.makeConstraints {
$0.bottom.equalToSuperview().offset(-54.0)
$0.leading.trailing.equalToSuperview().inset(20.0)
$0.height.equalTo(58.0)
}

}
}
extension SelfCareMyRoutineViewController: UITableViewDelegate {
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.row == myRoutineModel.data.count + 1 {
return 100 // 마지막 셀의 높이를 100으로 설정
} else {
return 94
}
}
}
extension SelfCareMyRoutineViewController: UITableViewDataSource {
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
myRoutineModel.data.count + 1
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == myRoutineModel.data.count {
let cell = UITableViewCell()
cell.backgroundColor = .white
cell.selectionStyle = .none
return cell
} else {
let cell = tableView.dequeueReusableCell(
withIdentifier: MyRoutineTableViewCell.identifier,
for: indexPath) as? MyRoutineTableViewCell
let routine = myRoutineModel.data[indexPath.row]
cell?.setup(name: routine.name, state: routine.routineState, shared: routine.sharedState)
cell?.selectionStyle = .none
return cell ?? UITableViewCell()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Foundation

import RxFlow
import RxCocoa
import RxSwift

import Core

public class SelfCareMyRoutineViewModel: BaseViewModel {
public func transform(_ input: Input) -> Output {
return Output()
}

public struct Input {

}

public struct Output {

}

public init() {

}
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import UIKit

import DSKit

public struct SelfCareContent {
var name: String
var routineState: RoutineState
var sharedState: SharedState
}

public enum SelfCareMyRoutineModel {
case myRoutine

var data: [SelfCareContent] {
switch self {
case .myRoutine:
return [
SelfCareContent(name: "주말 루틴", routineState: .useRoutine, sharedState: .yesShared),
SelfCareContent(name: "매일 루틴", routineState: .keepRoutine, sharedState: .notShared),
SelfCareContent(name: "평일 루틴", routineState: .useRoutine, sharedState: .notShared),
SelfCareContent(name: "말왕 루틴", routineState: .keepRoutine, sharedState: .yesShared),
SelfCareContent(name: "루틴 루틴", routineState: .keepRoutine, sharedState: .yesShared),
SelfCareContent(name: "이은호 루틴", routineState: .keepRoutine, sharedState: .notShared),
SelfCareContent(name: "부현수 루틴", routineState: .useRoutine, sharedState: .notShared),
SelfCareContent(name: "이태영 루틴", routineState: .useRoutine, sharedState: .yesShared),
SelfCareContent(name: "플러터1 루틴", routineState: .keepRoutine, sharedState: .notShared),
SelfCareContent(name: "플러터2 루틴", routineState: .useRoutine, sharedState: .yesShared),
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import UIKit

import SnapKit
import Then

import DSKit
import Core

public class MyRoutinePlusButton: BaseButton {

private var plusImage = UIImageView().then {
$0.image = DSKitAsset.Assets.selfCareAdd.image
}

private var textLabel = UILabel().then {
$0.font = UIFont.Pretendard.labelLarge
$0.text = "루틴 추가하기"
$0.textColor = .white
$0.contentMode = .left
}

public init (
text: String? = "루틴 추가하기"
) {
super.init(frame: .zero)

textLabel.text = text
layer.cornerRadius = 8.0
layer.backgroundColor = DSKitAsset.Colors.blue500.color.cgColor

}
required public init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override public func layout() {
addSubviews([textLabel, plusImage])

textLabel.snp.makeConstraints {
$0.centerX.equalToSuperview().offset(16.5)
$0.top.bottom.equalToSuperview().inset(17.0)
$0.width.equalTo(109.0)
$0.height.equalTo(24.0)
}

plusImage.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(17.0)
$0.trailing.equalTo(textLabel.snp.leading).offset(-8.0)
$0.width.height.equalTo(24.0)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import UIKit

import SnapKit
import Then

import Core
import DSKit

public class MyRoutineTableViewCell: BaseTableViewCell {

static let identifier: String = "MyRoutineTableViewCell"

private var containerView = UIView().then {
$0.backgroundColor = DSKitAsset.Colors.blue50.color
$0.layer.cornerRadius = 16.0
}

private var routineNameLabel = UILabel().then {
$0.font = UIFont.Pretendard.labelLarge
$0.textColor = .black
$0.numberOfLines = 1
}

private var routineStateLabel = UILabel().then {
$0.font = UIFont.Pretendard.bodySmall
$0.numberOfLines = 1
$0.textColor = DSKitAsset.Colors.gray400.color
}

private var sharedView = MGShareStateView().then {
$0.isHidden = true
}

private let dotsButton = UIButton().then {
$0.setImage(DSKitAsset.Assets.selfCareDots.image, for: .normal)
}

public func setup(name: String, state: RoutineState, shared: SharedState) {
routineNameLabel.text = name

routineState(routineState: state)
SharedViewState(sharedState: shared)
addViews()
layout()

}

override public func addViews() {
super.addViews()

contentView.addSubview(containerView)
[
routineNameLabel,
routineStateLabel,
dotsButton,
sharedView
].forEach { containerView.addSubview($0) }
}

override public func layout() {
super.layout()

containerView.snp.makeConstraints {
$0.top.equalToSuperview().offset(12.0)
$0.leading.trailing.equalToSuperview().inset(20.0)
}

routineNameLabel.snp.makeConstraints {
$0.top.equalToSuperview().offset(18.0)
$0.leading.equalToSuperview().offset(20.0)
$0.width.equalToSuperview()
$0.height.equalTo(24.0)
}

routineStateLabel.snp.makeConstraints {
$0.top.equalTo(routineNameLabel.snp.bottom).offset(4.0)
$0.leading.equalToSuperview().offset(20.0)
$0.width.equalTo(37.0)
$0.height.equalTo(18.0)
}

dotsButton.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(29.0)
$0.trailing.equalToSuperview().offset(-20.0)
$0.width.height.equalTo(24.0)
}

sharedView.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(23.0)
$0.trailing.equalTo(dotsButton.snp.leading).offset(-12.0)
$0.width.equalTo(98.0)
$0.height.equalTo(36.0)
}
}

public func SharedViewState(sharedState: SharedState) {
switch sharedState {
case .yesShared:
sharedView.isHidden = false
case .notShared:
sharedView.isHidden = true
}
}

public func routineState(routineState: RoutineState) {
switch routineState {
case .useRoutine:
routineStateLabel.text = "사용중"
routineStateLabel.textColor = DSKitAsset.Colors.blue500.color
case .keepRoutine:
routineStateLabel.text = "보관중"
routineStateLabel.textColor = DSKitAsset.Colors.gray400.color
}
}

public func changeRoutineName(text: String) {
routineNameLabel.text = text
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public enum RoutineState {
case useRoutine
case keepRoutine
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Foundation

public enum SharedState {
case yesShared
case notShared
}
Loading