diff --git a/KkuMulKum/Source/AddMeeting/CheckInviteCode/ViewController/CheckInviteCodeViewController.swift b/KkuMulKum/Source/AddMeeting/CheckInviteCode/ViewController/CheckInviteCodeViewController.swift index 2f26a5b3..42361659 100644 --- a/KkuMulKum/Source/AddMeeting/CheckInviteCode/ViewController/CheckInviteCodeViewController.swift +++ b/KkuMulKum/Source/AddMeeting/CheckInviteCode/ViewController/CheckInviteCodeViewController.swift @@ -12,13 +12,13 @@ class CheckInviteCodeViewController: BaseViewController { // MARK: Property - private let checkInviteCodeView: CheckInviteCodeView = CheckInviteCodeView() + private let rootView: CheckInviteCodeView = CheckInviteCodeView() // MARK: LifeCycle override func loadView() { - view = checkInviteCodeView + view = rootView } override func viewWillAppear(_ animated: Bool) { @@ -44,11 +44,11 @@ class CheckInviteCodeViewController: BaseViewController { } override func setupAction() { - checkInviteCodeView.enterInviteCodeView.addGestureRecognizer(UITapGestureRecognizer( + rootView.enterInviteCodeView.addGestureRecognizer(UITapGestureRecognizer( target: self, action: #selector(inviteCodeViewDidTap) )) - checkInviteCodeView.createMeetingView.addGestureRecognizer(UITapGestureRecognizer( + rootView.createMeetingView.addGestureRecognizer(UITapGestureRecognizer( target: self, action: #selector(createMeetingViewDidTap) )) diff --git a/KkuMulKum/Source/AddMeeting/CreateMeeting/View/CreateMeetingView.swift b/KkuMulKum/Source/AddMeeting/CreateMeeting/View/CreateMeetingView.swift index 53655331..ab434160 100644 --- a/KkuMulKum/Source/AddMeeting/CreateMeeting/View/CreateMeetingView.swift +++ b/KkuMulKum/Source/AddMeeting/CreateMeeting/View/CreateMeetingView.swift @@ -11,10 +11,6 @@ class CreateMeetingView: BaseView { // MARK: Property - - private let mainTitleLabel: UILabel = UILabel().then { - $0.setText("모임 이름을\n입력해 주세요", style: .head01) - } let nameTextField: CustomTextField = CustomTextField( placeHolder: "모임 이름을 입력해 주세요" @@ -29,6 +25,10 @@ class CreateMeetingView: BaseView { isEnabled: false ) + private let mainTitleLabel: UILabel = UILabel().then { + $0.setText("모임 이름을\n입력해 주세요", style: .head01) + } + // MARK: - Setup diff --git a/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewController/CreateMeetingViewController.swift b/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewController/CreateMeetingViewController.swift index ad19c327..344bd1e3 100644 --- a/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewController/CreateMeetingViewController.swift +++ b/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewController/CreateMeetingViewController.swift @@ -12,14 +12,14 @@ class CreateMeetingViewController: BaseViewController { // MARK: Property - private let createMeetingViewModel: CreateMeetingViewModel - private let createMeetingView: CreateMeetingView = CreateMeetingView() + private let viewModel: CreateMeetingViewModel + private let rootView: CreateMeetingView = CreateMeetingView() // MARK: - LifeCycle init(viewModel: CreateMeetingViewModel) { - self.createMeetingViewModel = viewModel + self.viewModel = viewModel super.init(nibName: nil, bundle: nil) } @@ -29,7 +29,7 @@ class CreateMeetingViewController: BaseViewController { } override func loadView() { - view = createMeetingView + view = rootView } override func viewDidLoad() { @@ -60,12 +60,12 @@ class CreateMeetingViewController: BaseViewController { } override func setupAction() { - createMeetingView.nameTextField.addTarget( + rootView.nameTextField.addTarget( self, action: #selector(textFieldDidChange(_:)), for: .editingChanged ) - createMeetingView.presentButton.addTarget( + rootView.presentButton.addTarget( self, action: #selector(presentButtonDidTap), for: .touchUpInside @@ -84,45 +84,45 @@ class CreateMeetingViewController: BaseViewController { private extension CreateMeetingViewController { func setupBinding() { - createMeetingViewModel.inviteCodeState.bind(with: self) { owner, state in + viewModel.inviteCodeState.bind(with: self) { owner, state in switch state { case .empty, .invalid: - owner.createMeetingView.presentButton.isEnabled = false + owner.rootView.presentButton.isEnabled = false case .valid: - owner.createMeetingView.presentButton.isEnabled = true + owner.rootView.presentButton.isEnabled = true } - owner.createMeetingViewModel.characterCount.bind(with: self) { owner, count in - owner.createMeetingView.characterLabel.text = count + owner.viewModel.characterCount.bind(with: self) { owner, count in + owner.rootView.characterLabel.text = count } } } @objc func textFieldDidChange(_ textField: UITextField) { - createMeetingViewModel.validateName(textField.text ?? "") + viewModel.validateName(textField.text ?? "") } @objc func dismissKeyboard() { view.endEditing(true) - createMeetingView.nameTextField.layer.borderColor = UIColor.gray3.cgColor + rootView.nameTextField.layer.borderColor = UIColor.gray3.cgColor } @objc func presentButtonDidTap() { let inviteCodePopUpViewController = InvitationCodePopUpViewController( - invitationCode: createMeetingViewModel.inviteCode.value + invitationCode: viewModel.inviteCode.value ) setupPopUpViewController(viewController: inviteCodePopUpViewController) setupPopUpAction(view: inviteCodePopUpViewController.rootView) removeDismissGesture(view: inviteCodePopUpViewController.rootView) - createMeetingViewModel.createMeeting(name: createMeetingViewModel.meetingName.value) + viewModel.createMeeting(name: viewModel.meetingName.value) DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { inviteCodePopUpViewController.rootView.setInvitationCodeText( - self.createMeetingViewModel.inviteCode.value + self.viewModel.inviteCode.value ) self.present(inviteCodePopUpViewController, animated: true) @@ -131,9 +131,9 @@ private extension CreateMeetingViewController { @objc private func copyButtonDidTap() { - UIPasteboard.general.string = createMeetingViewModel.inviteCode.value + UIPasteboard.general.string = viewModel.inviteCode.value - let finishCreateViewController = FinishCreateViewController(meetingID: createMeetingViewModel.meetingID) + let finishCreateViewController = FinishCreateViewController(meetingID: viewModel.meetingID) navigationController?.pushViewController(finishCreateViewController, animated: true) } @@ -141,7 +141,7 @@ private extension CreateMeetingViewController { @objc private func inviteLaterButtonDidTap() { DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { - let finishCreateViewController = FinishCreateViewController(meetingID: self.createMeetingViewModel.meetingID) + let finishCreateViewController = FinishCreateViewController(meetingID: self.viewModel.meetingID) self.navigationController?.pushViewController(finishCreateViewController, animated: true) } diff --git a/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewModel/CreateMeetingViewModel.swift b/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewModel/CreateMeetingViewModel.swift index ad950708..2f96ff7e 100644 --- a/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewModel/CreateMeetingViewModel.swift +++ b/KkuMulKum/Source/AddMeeting/CreateMeeting/ViewModel/CreateMeetingViewModel.swift @@ -18,7 +18,6 @@ class CreateMeetingViewModel { // MARK: Property - var createMeetingResponse = ObservablePattern(nil) let isNextButtonEnabled = ObservablePattern(false) let meetingName = ObservablePattern("") let inviteCode = ObservablePattern("") @@ -26,6 +25,8 @@ class CreateMeetingViewModel { let inviteCodeState = ObservablePattern(.empty) let createMeetingService: CreateMeetingServiceProtocol + var createMeetingResponse = ObservablePattern(nil) + private (set) var meetingID: Int = 0 diff --git a/KkuMulKum/Source/AddMeeting/InviteCode/View/InviteCodeView.swift b/KkuMulKum/Source/AddMeeting/InviteCode/View/InviteCodeView.swift index 1366af5d..61ef5fe3 100644 --- a/KkuMulKum/Source/AddMeeting/InviteCode/View/InviteCodeView.swift +++ b/KkuMulKum/Source/AddMeeting/InviteCode/View/InviteCodeView.swift @@ -11,10 +11,6 @@ class InviteCodeView: BaseView { // MARK: Property - - private let mainTitleLabel: UILabel = UILabel().then { - $0.setText("모임 초대 코드를\n입력해 주세요", style: .head01) - } let inviteCodeTextField: CustomTextField = CustomTextField( placeHolder: "모임 초대 코드를 입력해 주세요" @@ -33,6 +29,9 @@ class InviteCodeView: BaseView { let presentButton: CustomButton = CustomButton(title: "모임 가입하기", isEnabled: false) + private let mainTitleLabel: UILabel = UILabel().then { + $0.setText("모임 초대 코드를\n입력해 주세요", style: .head01) + } // MARK: - Setup diff --git a/KkuMulKum/Source/AddMeeting/InviteCode/ViewController/InviteCodeViewController.swift b/KkuMulKum/Source/AddMeeting/InviteCode/ViewController/InviteCodeViewController.swift index c9464d6a..f167360b 100644 --- a/KkuMulKum/Source/AddMeeting/InviteCode/ViewController/InviteCodeViewController.swift +++ b/KkuMulKum/Source/AddMeeting/InviteCode/ViewController/InviteCodeViewController.swift @@ -12,15 +12,14 @@ class InviteCodeViewController: BaseViewController { // MARK: Property - private let inviteCodeViewModel: InviteCodeViewModel - - private let inviteCodeView: InviteCodeView = InviteCodeView() + private let viewModel: InviteCodeViewModel + private let rootView: InviteCodeView = InviteCodeView() // MARK: - LifeCycle init(viewModel: InviteCodeViewModel) { - self.inviteCodeViewModel = viewModel + self.viewModel = viewModel super.init(nibName: nil, bundle: nil) } @@ -29,7 +28,7 @@ class InviteCodeViewController: BaseViewController { } override func loadView() { - view = inviteCodeView + view = rootView } override func viewDidLoad() { @@ -60,12 +59,12 @@ class InviteCodeViewController: BaseViewController { } override func setupAction() { - inviteCodeView.inviteCodeTextField.addTarget( + rootView.inviteCodeTextField.addTarget( self, action: #selector(textFieldDidChange(_:)), for: .editingChanged ) - inviteCodeView.presentButton.addTarget( + rootView.presentButton.addTarget( self, action: #selector(nextButtonTapped), for: .touchUpInside @@ -73,8 +72,8 @@ class InviteCodeViewController: BaseViewController { } override func setupDelegate() { - inviteCodeView.inviteCodeTextField.delegate = self - inviteCodeView.inviteCodeTextField.returnKeyType = .done + rootView.inviteCodeTextField.delegate = self + rootView.inviteCodeTextField.returnKeyType = .done } } @@ -83,36 +82,36 @@ class InviteCodeViewController: BaseViewController { extension InviteCodeViewController { private func setupBinding() { - inviteCodeViewModel.inviteCodeState.bind(with: self) { owner, state in + viewModel.inviteCodeState.bind(with: self) { owner, state in switch state { case .empty: - owner.inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.gray3.cgColor - owner.inviteCodeView.errorLabel.isHidden = true - owner.inviteCodeView.checkImageView.isHidden = true - owner.inviteCodeView.presentButton.isEnabled = false + owner.rootView.inviteCodeTextField.layer.borderColor = UIColor.gray3.cgColor + owner.rootView.errorLabel.isHidden = true + owner.rootView.checkImageView.isHidden = true + owner.rootView.presentButton.isEnabled = false case .invalid: - owner.inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.mainred.cgColor - owner.inviteCodeView.errorLabel.isHidden = false - owner.inviteCodeView.checkImageView.isHidden = true - owner.inviteCodeView.presentButton.isEnabled = false + owner.rootView.inviteCodeTextField.layer.borderColor = UIColor.mainred.cgColor + owner.rootView.errorLabel.isHidden = false + owner.rootView.checkImageView.isHidden = true + owner.rootView.presentButton.isEnabled = false case .valid: - owner.inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor - owner.inviteCodeView.errorLabel.isHidden = true - owner.inviteCodeView.checkImageView.isHidden = true - owner.inviteCodeView.presentButton.isEnabled = true + owner.rootView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor + owner.rootView.errorLabel.isHidden = true + owner.rootView.checkImageView.isHidden = true + owner.rootView.presentButton.isEnabled = true case .success: - owner.inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor - owner.inviteCodeView.errorLabel.isHidden = true - owner.inviteCodeView.checkImageView.isHidden = false - owner.inviteCodeView.presentButton.isEnabled = true + owner.rootView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor + owner.rootView.errorLabel.isHidden = true + owner.rootView.checkImageView.isHidden = false + owner.rootView.presentButton.isEnabled = true } } - inviteCodeViewModel.meetingID.bind { [weak self] id in + viewModel.meetingID.bind { [weak self] id in guard let id else { return } DispatchQueue.main.async { - self?.inviteCodeViewModel.inviteCodeState.value = .success + self?.viewModel.inviteCodeState.value = .success } DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { @@ -139,10 +138,10 @@ extension InviteCodeViewController { } } - inviteCodeViewModel.errorDescription.bind(with: self) { owner, error in + viewModel.errorDescription.bind(with: self) { owner, error in DispatchQueue.main.async { - owner.inviteCodeView.errorLabel.setText(error, style: .caption02, color: .mainred) - owner.inviteCodeViewModel.inviteCodeState.value = .invalid + owner.rootView.errorLabel.setText(error, style: .caption02, color: .mainred) + owner.viewModel.inviteCodeState.value = .invalid } } } @@ -155,16 +154,16 @@ extension InviteCodeViewController { } @objc private func nextButtonTapped() { - inviteCodeViewModel.joinMeeting(inviteCode: inviteCodeViewModel.inviteCode.value) + viewModel.joinMeeting(inviteCode: viewModel.inviteCode.value) } @objc private func textFieldDidChange(_ textField: UITextField) { - inviteCodeViewModel.validateCode(textField.text ?? "") + viewModel.validateCode(textField.text ?? "") } @objc private func dismissKeyboard() { view.endEditing(true) - inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.gray3.cgColor + rootView.inviteCodeTextField.layer.borderColor = UIColor.gray3.cgColor } } @@ -173,19 +172,19 @@ extension InviteCodeViewController { extension InviteCodeViewController: UITextFieldDelegate { func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { - inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor + rootView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor return true } func textFieldShouldEndEditing(_ textField: UITextField) -> Bool { - switch inviteCodeViewModel.inviteCodeState.value { + switch viewModel.inviteCodeState.value { case .empty: - inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.gray3.cgColor + rootView.inviteCodeTextField.layer.borderColor = UIColor.gray3.cgColor case .valid, .success: - inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor + rootView.inviteCodeTextField.layer.borderColor = UIColor.maincolor.cgColor case .invalid: - inviteCodeView.inviteCodeTextField.layer.borderColor = UIColor.mainred.cgColor + rootView.inviteCodeTextField.layer.borderColor = UIColor.mainred.cgColor } return true diff --git a/KkuMulKum/Source/Promise/PagePromise/View/PagePromiseSegmentedControl.swift b/KkuMulKum/Source/Promise/PagePromise/View/PagePromiseSegmentedControl.swift index 155a2b8b..0a0a91e3 100644 --- a/KkuMulKum/Source/Promise/PagePromise/View/PagePromiseSegmentedControl.swift +++ b/KkuMulKum/Source/Promise/PagePromise/View/PagePromiseSegmentedControl.swift @@ -13,13 +13,13 @@ class PagePromiseSegmentedControl: UISegmentedControl { // MARK: Property - - private let backgroundLineView: UIView = UIView(backgroundColor: .gray2) let selectedUnderLineView: UIView = UIView(backgroundColor: .black).then { $0.layer.cornerRadius = 1 } + private let backgroundLineView: UIView = UIView(backgroundColor: .gray2) + // MARK: Initialize diff --git a/KkuMulKum/Source/Promise/PagePromise/ViewController/PromiseViewController.swift b/KkuMulKum/Source/Promise/PagePromise/ViewController/PromiseViewController.swift index fc81e712..191edd63 100644 --- a/KkuMulKum/Source/Promise/PagePromise/ViewController/PromiseViewController.swift +++ b/KkuMulKum/Source/Promise/PagePromise/ViewController/PromiseViewController.swift @@ -13,24 +13,20 @@ class PromiseViewController: BaseViewController { // MARK: Property private let viewModel: PromiseViewModel - - private var promiseViewControllerList: [BaseViewController] = [] - private let promiseInfoViewController: PromiseInfoViewController - private let readyStatusViewController: ReadyStatusViewController - private let tardyViewController: TardyViewController - - private lazy var promiseSegmentedControl = PagePromiseSegmentedControl( - items: ["약속 정보", "준비 현황", "지각 꾸물이"] - ) - private let promisePageViewController = UIPageViewController( transitionStyle: .scroll, navigationOrientation: .vertical ) + private var promiseViewControllerList: [BaseViewController] = [] + + private lazy var promiseSegmentedControl = PagePromiseSegmentedControl( + items: ["약속 정보", "준비 현황", "지각 꾸물이"] + ) + // MARK: - LifeCycle @@ -86,7 +82,6 @@ class PromiseViewController: BaseViewController { addChild(promisePageViewController) - view.addSubviews( promiseSegmentedControl, promisePageViewController.view @@ -138,7 +133,16 @@ class PromiseViewController: BaseViewController { // MARK: - Extension -extension PromiseViewController { +private extension PromiseViewController { + func setupBindings() { + viewModel.promiseInfo.bind { [weak self] model in + guard let model else { return } + DispatchQueue.main.async { + self?.setupNavigationBarTitle(with: model.promiseName) + } + } + } + @objc private func didSegmentedControlIndexUpdated() { let condition = viewModel.currentPage.value <= promiseSegmentedControl.selectedSegmentIndex let direction: UIPageViewController.NavigationDirection = condition ? .forward : .reverse @@ -187,14 +191,3 @@ extension PromiseViewController: UIPageViewControllerDataSource { return nil } } - -private extension PromiseViewController { - func setupBindings() { - viewModel.promiseInfo.bind { [weak self] model in - guard let model else { return } - DispatchQueue.main.async { - self?.setupNavigationBarTitle(with: model.promiseName) - } - } - } -} diff --git a/KkuMulKum/Source/Promise/PromiseInfo/View/PromiseInfoView.swift b/KkuMulKum/Source/Promise/PromiseInfo/View/PromiseInfoView.swift index da566063..6a564027 100644 --- a/KkuMulKum/Source/Promise/PromiseInfo/View/PromiseInfoView.swift +++ b/KkuMulKum/Source/Promise/PromiseInfo/View/PromiseInfoView.swift @@ -17,11 +17,6 @@ class PromiseInfoView: BaseView { $0.setHighlightText("n명", style: .body01, color: .maincolor) } - private let chevronButton: UIButton = UIButton().then { - $0.setImage(.iconRight.withTintColor(.gray4), for: .normal) - $0.contentMode = .scaleAspectFill - } - let participantCollectionView: UICollectionView = UICollectionView( frame: .zero, collectionViewLayout: UICollectionViewFlowLayout().then { @@ -37,6 +32,27 @@ class PromiseInfoView: BaseView { ) } + let locationContentLabel: UILabel = UILabel().then { + $0.setText("sss역 s번 출구", style: .body04, color: .gray7) + } + + let timeContentLabel: UILabel = UILabel().then { + $0.setText("mm월 dd일 hh:mm", style: .body04, color: .gray7) + } + + let readyLevelContentLabel: UILabel = UILabel().then { + $0.setText("LV n. sss", style: .body04, color: .gray7) + } + + let penaltyLevelContentLabel: UILabel = UILabel().then { + $0.setText("ssss하기", style: .body04, color: .gray7) + } + + private let chevronButton: UIButton = UIButton().then { + $0.setImage(.iconRight.withTintColor(.gray4), for: .normal) + $0.contentMode = .scaleAspectFill + } + private let backgroundView: UIView = UIView().then { $0.backgroundColor = .gray0 $0.layer.cornerRadius = Screen.height(18) @@ -57,10 +73,6 @@ class PromiseInfoView: BaseView { $0.setText("위치", style: .caption01, color: .maincolor) } - let locationContentLabel: UILabel = UILabel().then { - $0.setText("sss역 s번 출구", style: .body04, color: .gray7) - } - private let locationDivideView: UIView = UIView().then { $0.backgroundColor = .gray2 } @@ -69,10 +81,6 @@ class PromiseInfoView: BaseView { $0.setText("약속시간", style: .caption01, color: .maincolor) } - let timeContentLabel: UILabel = UILabel().then { - $0.setText("mm월 dd일 hh:mm", style: .body04, color: .gray7) - } - private let timeDivideView: UIView = UIView().then { $0.backgroundColor = .gray2 } @@ -81,10 +89,6 @@ class PromiseInfoView: BaseView { $0.setText("준비레벨", style: .caption01, color: .maincolor) } - let readyLevelContentLabel: UILabel = UILabel().then { - $0.setText("LV n. sss", style: .body04, color: .gray7) - } - private let readyLevelDivideView: UIView = UIView().then { $0.backgroundColor = .gray2 } @@ -93,10 +97,6 @@ class PromiseInfoView: BaseView { $0.setText("벌칙", style: .caption01, color: .maincolor) } - let penaltyLevelContentLabel: UILabel = UILabel().then { - $0.setText("ssss하기", style: .body04, color: .gray7) - } - // MARK: - Setup diff --git a/KkuMulKum/Source/Promise/PromiseInfo/ViewController/PromiseInfoViewController.swift b/KkuMulKum/Source/Promise/PromiseInfo/ViewController/PromiseInfoViewController.swift index 579a7096..5536311b 100644 --- a/KkuMulKum/Source/Promise/PromiseInfo/ViewController/PromiseInfoViewController.swift +++ b/KkuMulKum/Source/Promise/PromiseInfo/ViewController/PromiseInfoViewController.swift @@ -15,7 +15,7 @@ class PromiseInfoViewController: BaseViewController { // MARK: Property private let viewModel: PromiseViewModel - private let promiseInfoView: PromiseInfoView = PromiseInfoView() + private let rootView: PromiseInfoView = PromiseInfoView() // MARK: - LifeCycle @@ -31,7 +31,7 @@ class PromiseInfoViewController: BaseViewController { } override func loadView() { - view = promiseInfoView + view = rootView } override func viewWillAppear(_ animated: Bool) { @@ -45,8 +45,8 @@ class PromiseInfoViewController: BaseViewController { // MARK: - Setup override func setupDelegate() { - promiseInfoView.participantCollectionView.delegate = self - promiseInfoView.participantCollectionView.dataSource = self + rootView.participantCollectionView.delegate = self + rootView.participantCollectionView.dataSource = self } } @@ -56,26 +56,26 @@ class PromiseInfoViewController: BaseViewController { extension PromiseInfoViewController { func setupBinding() { viewModel.promiseInfo.bind(with: self) { owner, info in - owner.promiseInfoView.timeContentLabel.setText( + owner.rootView.timeContentLabel.setText( info?.time ?? "설정되지 않음", style: .body04, color: .gray7 ) - owner.promiseInfoView.readyLevelContentLabel.setText( + owner.rootView.readyLevelContentLabel.setText( info?.dressUpLevel ?? "설정되지 않음", style: .body04, color: .gray7 ) - owner.promiseInfoView.locationContentLabel.setText( + owner.rootView.locationContentLabel.setText( info?.address ?? "설정되지 않음", style: .body04, color: .gray7, isSingleLine: true ) - owner.promiseInfoView.penaltyLevelContentLabel.setText( + owner.rootView.penaltyLevelContentLabel.setText( info?.penalty ?? "설정되지 않음", style: .body04, color: .gray7 @@ -86,17 +86,17 @@ extension PromiseInfoViewController { owner, participantsInfo in DispatchQueue.main.async { - owner.promiseInfoView.participantNumberLabel.setText( + owner.rootView.participantNumberLabel.setText( "약속 참여 인원 \(participantsInfo?.count ?? 0)명", style: .body01 ) - owner.promiseInfoView.participantNumberLabel.setHighlightText( + owner.rootView.participantNumberLabel.setHighlightText( "\(participantsInfo?.count ?? 0)명", style: .body01, color: .maincolor ) - owner.promiseInfoView.participantCollectionView.reloadData() + owner.rootView.participantCollectionView.reloadData() } } } diff --git a/KkuMulKum/Source/Promise/ReadyStatus/View/EnterReadyInfoButtonView.swift b/KkuMulKum/Source/Promise/ReadyStatus/View/EnterReadyInfoButtonView.swift index 1c40e8bd..1ecd31ab 100644 --- a/KkuMulKum/Source/Promise/ReadyStatus/View/EnterReadyInfoButtonView.swift +++ b/KkuMulKum/Source/Promise/ReadyStatus/View/EnterReadyInfoButtonView.swift @@ -21,6 +21,9 @@ class EnterReadyInfoButtonView: BaseView { $0.contentMode = .scaleAspectFill } + + // MARK: - Setup + override func setupView() { backgroundColor = .white addSubviews(descriptionLabel, chevronButton) diff --git a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyPlanInfoView.swift b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyPlanInfoView.swift index 879277fe..62faef46 100644 --- a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyPlanInfoView.swift +++ b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyPlanInfoView.swift @@ -34,6 +34,9 @@ class ReadyPlanInfoView: BaseView { $0.clipsToBounds = true } + + // MARK: - Setup + override func setupView() { backgroundColor = .white diff --git a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusButton.swift b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusButton.swift index f56c9041..28cbf2c1 100644 --- a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusButton.swift +++ b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusButton.swift @@ -15,6 +15,10 @@ enum ReadyProgressStatus { } class ReadyStatusButton: UIButton { + + + // MARK: - LifeCycle + init(title: String, readyStatus: ReadyProgressStatus) { super.init(frame: .zero) diff --git a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusProgressView.swift b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusProgressView.swift index e6cd6e21..10376934 100644 --- a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusProgressView.swift +++ b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusProgressView.swift @@ -8,6 +8,10 @@ import UIKit class ReadyStatusProgressView: BaseView { + + + // MARK: Property + let statusProgressView: UIProgressView = UIProgressView().then { $0.trackTintColor = .gray2 $0.progressTintColor = .maincolor @@ -63,7 +67,7 @@ class ReadyStatusProgressView: BaseView { $0.isHidden = true } - let arrivalCheckImageView: UIImageView = UIImageView(backgroundColor: .gray2).then { + let arrivalCheckImageView: UIImageView = UIImageView(backgroundColor: .gray2).then { $0.layer.cornerRadius = Screen.height(16 / 2) $0.clipsToBounds = true } @@ -81,6 +85,9 @@ class ReadyStatusProgressView: BaseView { $0.isHidden = true } + + // MARK: - Setup + override func setupView() { backgroundColor = .white diff --git a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift index c93c56ed..fdd795f2 100644 --- a/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift +++ b/KkuMulKum/Source/Promise/ReadyStatus/View/ReadyStatusView.swift @@ -6,22 +6,13 @@ // import UIKit -import SnapKit +import SnapKit class ReadyStatusView: BaseView { - private let scrollView: UIScrollView = UIScrollView().then { - $0.showsVerticalScrollIndicator = false - } - private let contentView: UIView = UIView() - - private var collectionViewHeightConstraint: Constraint? - private let baseStackView: UIStackView = UIStackView(axis: .vertical).then { - $0.spacing = 24 - $0.backgroundColor = .gray0 - } + // MARK: Property let enterReadyButtonView: EnterReadyInfoButtonView = EnterReadyInfoButtonView().then { $0.layer.cornerRadius = 8 @@ -33,14 +24,6 @@ class ReadyStatusView: BaseView { $0.clipsToBounds = true } - private let myReadyStatusTitleLabel: UILabel = UILabel().then { - $0.setText("나의 준비 현황", style: .body01, color: .gray8) - } - - private let readyBaseView: UIStackView = UIStackView(axis: .vertical).then { - $0.spacing = 4 - } - let myReadyStatusProgressView: ReadyStatusProgressView = ReadyStatusProgressView().then { $0.layer.cornerRadius = 8 $0.clipsToBounds = true @@ -51,14 +34,6 @@ class ReadyStatusView: BaseView { $0.isHidden = true } - private let ourReadyStatusLabel: UILabel = UILabel().then { - $0.setText( - "우리들의 준비 현황", - style: .body01, - color: .gray8 - ) - } - let ourReadyStatusCollectionView: UICollectionView = UICollectionView( frame: .zero, collectionViewLayout: UICollectionViewFlowLayout().then { @@ -74,6 +49,38 @@ class ReadyStatusView: BaseView { ) } + private let scrollView: UIScrollView = UIScrollView().then { + $0.showsVerticalScrollIndicator = false + } + + private let contentView: UIView = UIView() + + private let baseStackView: UIStackView = UIStackView(axis: .vertical).then { + $0.spacing = 24 + $0.backgroundColor = .gray0 + } + + private let myReadyStatusTitleLabel: UILabel = UILabel().then { + $0.setText("나의 준비 현황", style: .body01, color: .gray8) + } + + private let readyBaseView: UIStackView = UIStackView(axis: .vertical).then { + $0.spacing = 4 + } + + private let ourReadyStatusLabel: UILabel = UILabel().then { + $0.setText( + "우리들의 준비 현황", + style: .body01, + color: .gray8 + ) + } + + private var collectionViewHeightConstraint: Constraint? + + + // MARK: - Setup + override func setupView() { readyBaseView.addArrangedSubviews( myReadyStatusProgressView, @@ -99,13 +106,6 @@ class ReadyStatusView: BaseView { } - func updateCollectionViewHeight() { - ourReadyStatusCollectionView.layoutIfNeeded() - let contentHeight = ourReadyStatusCollectionView.collectionViewLayout.collectionViewContentSize.height - collectionViewHeightConstraint?.update(offset: contentHeight) - layoutIfNeeded() - } - override func setupAutoLayout() { scrollView.snp.makeConstraints { $0.edges.equalToSuperview() @@ -131,6 +131,16 @@ class ReadyStatusView: BaseView { $0.bottom.equalTo(ourReadyStatusCollectionView.snp.bottom).offset(20) } } - - +} + + +// MARK: - Extension + +extension ReadyStatusView { + func updateCollectionViewHeight() { + ourReadyStatusCollectionView.layoutIfNeeded() + let contentHeight = ourReadyStatusCollectionView.collectionViewLayout.collectionViewContentSize.height + collectionViewHeightConstraint?.update(offset: contentHeight) + layoutIfNeeded() + } } diff --git a/KkuMulKum/Source/Promise/Tardy/View/ArriveView.swift b/KkuMulKum/Source/Promise/Tardy/View/ArriveView.swift index 8888ba49..2a1230d0 100644 --- a/KkuMulKum/Source/Promise/Tardy/View/ArriveView.swift +++ b/KkuMulKum/Source/Promise/Tardy/View/ArriveView.swift @@ -11,6 +11,13 @@ class ArriveView: BaseView { // MARK: Property + + let finishMeetingButton: CustomButton = CustomButton( + title: "약속 마치기", + isEnabled: true + ).then { + $0.backgroundColor = .maincolor + } private let giftImageView: UIImageView = UIImageView().then { $0.image = .imgGift @@ -25,13 +32,6 @@ class ArriveView: BaseView { $0.setText("약속 시간까지 아무도 꾸물거리지 않았네요!", style: .body06, color: .gray6) } - let finishMeetingButton: CustomButton = CustomButton( - title: "약속 마치기", - isEnabled: true - ).then { - $0.backgroundColor = .maincolor - } - // MARK: - Setup diff --git a/KkuMulKum/Source/Promise/Tardy/View/TardyPenaltyView.swift b/KkuMulKum/Source/Promise/Tardy/View/TardyPenaltyView.swift index 1eabdf48..36d4b502 100644 --- a/KkuMulKum/Source/Promise/Tardy/View/TardyPenaltyView.swift +++ b/KkuMulKum/Source/Promise/Tardy/View/TardyPenaltyView.swift @@ -11,6 +11,10 @@ class TardyPenaltyView: BaseView { // MARK: Property + + let contentLabel: UILabel = UILabel().then { + $0.setText("탕후루 릴스 찍기", style: .body03, color: .gray8) + } private let penaltyImageView: UIImageView = UIImageView().then { $0.image = .iconPenalty @@ -21,10 +25,6 @@ class TardyPenaltyView: BaseView { $0.setText("벌칙", style: .caption02, color: .gray8) } - let contentLabel: UILabel = UILabel().then { - $0.setText("탕후루 릴스 찍기", style: .body03, color: .gray8) - } - // MARK: - Setup diff --git a/KkuMulKum/Source/Promise/Tardy/View/TardyView.swift b/KkuMulKum/Source/Promise/Tardy/View/TardyView.swift index eb2f9210..9d369054 100644 --- a/KkuMulKum/Source/Promise/Tardy/View/TardyView.swift +++ b/KkuMulKum/Source/Promise/Tardy/View/TardyView.swift @@ -16,10 +16,6 @@ class TardyView: BaseView { $0.layer.cornerRadius = 8 } - private let titleLabel: UILabel = UILabel().then { - $0.setText("이번 약속의 지각 꾸물이는?", style: .head01, color: .gray8) - } - let tardyEmptyView: TardyEmptyView = TardyEmptyView() let tardyCollectionView: UICollectionView = UICollectionView( @@ -44,6 +40,10 @@ class TardyView: BaseView { $0.backgroundColor = .maincolor } + private let titleLabel: UILabel = UILabel().then { + $0.setText("이번 약속의 지각 꾸물이는?", style: .head01, color: .gray8) + } + // MARK: - Setup diff --git a/KkuMulKum/Source/Promise/ViewModel/PromiseViewModel.swift b/KkuMulKum/Source/Promise/ViewModel/PromiseViewModel.swift index 46c0ce3f..a541be04 100644 --- a/KkuMulKum/Source/Promise/ViewModel/PromiseViewModel.swift +++ b/KkuMulKum/Source/Promise/ViewModel/PromiseViewModel.swift @@ -28,6 +28,9 @@ class PromiseViewModel { /// 설령 데이터가 없다하더라도 약속 시간은 담겨있음. let myReadyStatus = ObservablePattern(nil) + /// 현재 준비 상태에 대한 버튼 처리 + let myReadyProgressStatus = ObservablePattern(.none) + /// 준비 시작 시간 var readyStartTime = ObservablePattern("") @@ -40,9 +43,6 @@ class PromiseViewModel { /// 이동 소요 시간 var moveTime = ObservablePattern("") - /// 현재 준비 상태에 대한 버튼 처리 - let myReadyProgressStatus = ObservablePattern(.none) - /// 꾸물거림 여부 var isLate = ObservablePattern(false)