-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
3b8a7e8
commit f03cd97
Showing
9 changed files
with
252 additions
and
9 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
iOS/Projects/Features/WriteBoard/Sources/Dombain/Entities/Record.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,53 @@ | ||
// | ||
// Record.swift | ||
// WriteBoardFeature | ||
// | ||
// Created by MaraMincho on 1/11/24. | ||
// Copyright © 2024 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// 기록 목록을 표시하기위해 사용하는 모델입니다. | ||
struct Record: Codable, Hashable { | ||
/// 현재 운동의 날짜를 나타냅니다. | ||
let dateString: String | ||
|
||
/// 현재 운동의 목록을 나타냅니다. | ||
let workoutID: Int | ||
|
||
/// 운동 시작 시간 | ||
/// | ||
/// HH:MM 으로 표시 | ||
let startTime: String | ||
|
||
/// 운동 끝 시간 | ||
/// | ||
/// HH:MM 으로 표시 | ||
let endTime: String | ||
|
||
/// 총 운동한 거리를 "미터"단위로 표시해줍니다. | ||
let distance: Int | ||
} | ||
|
||
extension Record { | ||
var durationTime: String { | ||
guard | ||
let endDate = DateFormatter.HHmmFormatter.date(from: endTime), | ||
let startDate = DateFormatter.HHmmFormatter.date(from: startTime) else { | ||
return "" | ||
} | ||
let timeInterval = endDate.timeIntervalSince(startDate) | ||
let hours = Int(timeInterval / 3600) | ||
let minutes = Int((timeInterval.truncatingRemainder(dividingBy: 3600)) / 60) | ||
return "\(hours):\(minutes)" | ||
} | ||
} | ||
|
||
private extension DateFormatter { | ||
static let HHmmFormatter: DateFormatter = { | ||
let formatter = DateFormatter() | ||
formatter.dateFormat = "HH:mm" | ||
return formatter | ||
}() | ||
} |
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.
73 changes: 73 additions & 0 deletions
73
...s/Features/WriteBoard/Sources/Presentation/WirteBoardScene/WriteBoardViewController.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,73 @@ | ||
// | ||
// WriteBoardViewController.swift | ||
// WriteBoardFeature | ||
// | ||
// Created by MaraMincho on 1/11/24. | ||
// Copyright © 2024 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Combine | ||
import DesignSystem | ||
import UIKit | ||
|
||
// MARK: - WriteBoardViewController | ||
|
||
final class WriteBoardViewController: UIViewController { | ||
// MARK: Properties | ||
|
||
private let viewModel: WriteBoardViewModelRepresentable | ||
|
||
private var subscriptions: Set<AnyCancellable> = [] | ||
|
||
// MARK: UI Components | ||
|
||
private let button: UIButton = .init(configuration: .mainEnabled(title: "test button")) | ||
|
||
// MARK: Initializations | ||
|
||
init(viewModel: WriteBoardViewModelRepresentable) { | ||
self.viewModel = viewModel | ||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder _: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: Life Cycles | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
setup() | ||
} | ||
} | ||
|
||
private extension WriteBoardViewController { | ||
func setup() { | ||
setupStyles() | ||
setupHierarchyAndConstraints() | ||
bind() | ||
} | ||
|
||
func setupHierarchyAndConstraints() { | ||
let safeArea = view.safeAreaLayoutGuide | ||
} | ||
|
||
func setupStyles() { | ||
view.backgroundColor = DesignSystemColor.primaryBackground | ||
} | ||
|
||
func bind() { | ||
let output = viewModel.transform(input: .init()) | ||
output.sink { state in | ||
switch state { | ||
case .idle: | ||
break | ||
} | ||
} | ||
.store(in: &subscriptions) | ||
} | ||
|
||
enum Metrics {} | ||
} |
48 changes: 48 additions & 0 deletions
48
...ojects/Features/WriteBoard/Sources/Presentation/WirteBoardScene/WriteBoardViewModel.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,48 @@ | ||
// | ||
// WriteBoardViewModel.swift | ||
// WriteBoardFeature | ||
// | ||
// Created by MaraMincho on 1/11/24. | ||
// Copyright © 2024 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Combine | ||
import Foundation | ||
|
||
// MARK: - WriteBoardViewModelInput | ||
|
||
public struct WriteBoardViewModelInput {} | ||
|
||
public typealias WriteBoardViewModelOutput = AnyPublisher<WriteBoardState, Never> | ||
|
||
// MARK: - WriteBoardState | ||
|
||
public enum WriteBoardState { | ||
case idle | ||
} | ||
|
||
// MARK: - WriteBoardViewModelRepresentable | ||
|
||
protocol WriteBoardViewModelRepresentable { | ||
func transform(input: WriteBoardViewModelInput) -> WriteBoardViewModelOutput | ||
} | ||
|
||
// MARK: - WriteBoardViewModel | ||
|
||
final class WriteBoardViewModel { | ||
// MARK: - Properties | ||
|
||
private var subscriptions: Set<AnyCancellable> = [] | ||
} | ||
|
||
// MARK: WriteBoardViewModelRepresentable | ||
|
||
extension WriteBoardViewModel: WriteBoardViewModelRepresentable { | ||
public func transform(input _: WriteBoardViewModelInput) -> WriteBoardViewModelOutput { | ||
subscriptions.removeAll() | ||
|
||
let initialState: WriteBoardViewModelOutput = Just(.idle).eraseToAnyPublisher() | ||
|
||
return initialState | ||
} | ||
} |
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
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
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