From 52833b1f9b646175098681ea78be6929ebf79c49 Mon Sep 17 00:00:00 2001 From: MaraMincho <103064352+MaraMincho@users.noreply.github.com> Date: Sat, 9 Dec 2023 22:07:14 +0900 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20Appcoordinator=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=20=EC=8B=9C=EC=9E=91=20=EC=A7=80=EC=A0=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift b/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift index e27e9289..8e970e38 100644 --- a/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift +++ b/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift @@ -28,7 +28,7 @@ final class AppCoordinator: AppCoordinating { } func start() { - showSplashFlow() + showTabBarFlow() } private func showSplashFlow() { From e881fdeb6ad792542feab7e16e203f432f633a2a Mon Sep 17 00:00:00 2001 From: MaraMincho <103064352+MaraMincho@users.noreply.github.com> Date: Sun, 10 Dec 2023 10:49:25 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20scrollView=EB=A5=BC=20=ED=99=9C?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EC=97=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...orkoutEnvironmentSetupViewController.swift | 115 ++++++++++++------ 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift index 72b92152..f08c2b4e 100644 --- a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift +++ b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift @@ -31,8 +31,8 @@ public final class WorkoutEnvironmentSetupViewController: UIViewController { requestWorkoutPeerTypes.send() } - var cancellables = Set() - var viewModel: WorkoutEnvironmentSetupViewModelRepresentable? + private var subscriptions = Set() + private var viewModel: WorkoutEnvironmentSetupViewModelRepresentable? // MARK: - WorkoutEnvironmentSetupViewModelInput @@ -53,22 +53,36 @@ public final class WorkoutEnvironmentSetupViewController: UIViewController { private let workoutSelectViewController = WorkoutSelectViewController() private let workoutPeerSelectViewController = WorkoutPeerSelectViewController() + private lazy var contentViewControllers = [workoutSelectViewController, workoutPeerSelectViewController] + private var pageScrollView: UIScrollView? = nil - private let pageControl: GWPageControl = { + private let gwPageControl: GWPageControl = { let pageControl = GWPageControl(count: Constant.countOfPage) pageControl.translatesAutoresizingMaskIntoConstraints = false return pageControl }() - lazy var contentNavigationController = UINavigationController(rootViewController: workoutSelectViewController) + lazy var pageViewController: UIPageViewController = { + let pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal) + pageViewController.dataSource = self + pageViewController.delegate = self + + let scrollView = pageViewController.view.subviews + .compactMap { $0 as? UIScrollView } + .first + pageScrollView = scrollView + pageScrollView?.delegate = self + + pageViewController.view.translatesAutoresizingMaskIntoConstraints = false + return pageViewController + }() } private extension WorkoutEnvironmentSetupViewController { func setup() { view.backgroundColor = DesignSystemColor.primaryBackground setupViewHierarchyAndConstraints() - addNavigationGesture() bind() configureDataSource() @@ -77,38 +91,33 @@ private extension WorkoutEnvironmentSetupViewController { func setupViewHierarchyAndConstraints() { let safeArea = view.safeAreaLayoutGuide - view.addSubview(pageControl) - pageControl.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 0).isActive = true - pageControl.leadingAnchor + view.addSubview(gwPageControl) + gwPageControl.topAnchor.constraint(equalTo: safeArea.topAnchor, constant: 0).isActive = true + gwPageControl.leadingAnchor .constraint(equalTo: safeArea.leadingAnchor, constant: ConstraintsGuideLine.value + 11).isActive = true - pageControl.trailingAnchor + gwPageControl.trailingAnchor .constraint(equalTo: safeArea.trailingAnchor, constant: -ConstraintsGuideLine.value).isActive = true - pageControl.heightAnchor.constraint(equalToConstant: 30).isActive = true - - view.addSubview(contentNavigationController.view) - contentNavigationController.view.translatesAutoresizingMaskIntoConstraints = false - contentNavigationController.view.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor).isActive = true - contentNavigationController.view.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor).isActive = true - contentNavigationController.view.topAnchor.constraint(equalTo: pageControl.bottomAnchor).isActive = true - contentNavigationController.view.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor).isActive = true - } + gwPageControl.heightAnchor.constraint(equalToConstant: 30).isActive = true - func addNavigationGesture() { - guard let recognizer = contentNavigationController.interactivePopGestureRecognizer else { return } - recognizer.delegate = self - recognizer.isEnabled = true - contentNavigationController.delegate = self + view.addSubview(pageViewController.view) + if let viewController = contentViewControllers.first { + pageViewController.setViewControllers([viewController], direction: .forward, animated: false) + } + pageViewController.view.leadingAnchor.constraint(equalTo: safeArea.leadingAnchor).isActive = true + pageViewController.view.trailingAnchor.constraint(equalTo: safeArea.trailingAnchor).isActive = true + pageViewController.view.topAnchor.constraint(equalTo: gwPageControl.bottomAnchor).isActive = true + pageViewController.view.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor).isActive = true } func bind() { + workoutSelectViewController.delegate = self + workoutTypesCollectionView = workoutSelectViewController.workoutTypesCollectionView workoutTypesCollectionView?.delegate = self workoutPeerTypesCollectionView = workoutPeerSelectViewController.pearTypeSelectCollectionView workoutPeerTypesCollectionView?.delegate = self - workoutSelectViewController.delegate = self - bindViewModel() bindStartButton() } @@ -117,12 +126,12 @@ private extension WorkoutEnvironmentSetupViewController { workoutPeerSelectViewController .startButtonDidTapPublisher() .bind(to: didTapStartButton) - .store(in: &cancellables) + .store(in: &subscriptions) } func bindViewModel() { guard let viewModel else { return } - cancellables.removeAll() + subscriptions.removeAll() let input = WorkoutEnvironmentSetupViewModelInput( requestWorkoutTypes: requestWorkoutTypes.eraseToAnyPublisher(), @@ -148,7 +157,7 @@ private extension WorkoutEnvironmentSetupViewController { case let .didSelectWorkoutPeerType(bool): workoutPeerSelectViewController.startButtonEnable(bool) } } - .store(in: &cancellables) + .store(in: &subscriptions) } func configureDataSource() { @@ -232,30 +241,58 @@ private extension WorkoutEnvironmentSetupViewController { } } -// MARK: UIGestureRecognizerDelegate +// MARK: UIPageViewControllerDelegate, UIPageViewControllerDataSource + +extension WorkoutEnvironmentSetupViewController: UIPageViewControllerDelegate, UIPageViewControllerDataSource { + public func pageViewController( + _ pageViewController: UIPageViewController, + didFinishAnimating _: Bool, + previousViewControllers _: [UIViewController], + transitionCompleted _: Bool + ) { + if + let currentViewController = pageViewController.viewControllers?.first, + let currentIndex = contentViewControllers.firstIndex(of: currentViewController) { + gwPageControl.select(at: currentIndex) + } + } -extension WorkoutEnvironmentSetupViewController: UIGestureRecognizerDelegate { - public func gestureRecognizerShouldBegin(_: UIGestureRecognizer) -> Bool { - return contentNavigationController.viewControllers.count > 1 + public func pageViewController(_: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { + guard + let viewControllerIndex = contentViewControllers.firstIndex(of: viewController), + viewControllerIndex - 1 >= 0 + else { + return nil + } + let previousIndex = viewControllerIndex - 1 + return contentViewControllers[previousIndex] + } + + public func pageViewController(_: UIPageViewController, viewControllerAfter _: UIViewController) -> UIViewController? { + return nil } } -// MARK: UINavigationControllerDelegate +// MARK: UIScrollViewDelegate -extension WorkoutEnvironmentSetupViewController: UINavigationControllerDelegate { - public func navigationController(_: UINavigationController, didShow viewController: UIViewController, animated _: Bool) { - if viewController == workoutSelectViewController { - pageControl.select(at: 0) +extension WorkoutEnvironmentSetupViewController: UIScrollViewDelegate { + public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { + if pageViewController.viewControllers?.first == contentViewControllers.first { + scrollView.isScrollEnabled = false } } + + public func scrollViewDidEndDragging(_: UIScrollView, willDecelerate _: Bool) {} } // MARK: WorkoutSelectViewDelegate extension WorkoutEnvironmentSetupViewController: WorkoutSelectViewDelegate { func nextButtonDidTap() { - pageControl.next() - contentNavigationController.pushViewController(workoutPeerSelectViewController, animated: true) + gwPageControl.next() + pageViewController.setViewControllers([workoutPeerSelectViewController], direction: .forward, animated: true) { [weak self] _ in + self?.pageScrollView?.isScrollEnabled = true + } } } From 9243251341a0e941e6652f468fbd9c91b3401832 Mon Sep 17 00:00:00 2001 From: MaraMincho <103064352+MaraMincho@users.noreply.github.com> Date: Sun, 10 Dec 2023 10:54:44 +0900 Subject: [PATCH 3/5] =?UTF-8?q?delete:=20TabBarCoordinator=20->=20Splash?= =?UTF-8?q?=20Flow=20=EC=8B=9C=EC=9E=91=20=ED=9D=90=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift b/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift index 8e970e38..e27e9289 100644 --- a/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift +++ b/iOS/Projects/App/WeTri/Sources/CommonScene/Coordinator/AppCoordinator.swift @@ -28,7 +28,7 @@ final class AppCoordinator: AppCoordinating { } func start() { - showTabBarFlow() + showSplashFlow() } private func showSplashFlow() { From 72007542b72714ffd4b7515853e36e2de32f36f2 Mon Sep 17 00:00:00 2001 From: MaraMincho <103064352+MaraMincho@users.noreply.github.com> Date: Sun, 10 Dec 2023 11:43:27 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20UIScroll=EB=B2=84=EA=B7=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WorkoutEnvironmentSetUpCoordinator.swift | 4 ++- .../WorkoutSessionCoordinator.swift | 2 +- ...orkoutEnvironmentSetupViewController.swift | 27 ++++++++++--------- .../WorkoutSelectViewController.swift | 3 +-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutEnvironmentSetUpCoordinator.swift b/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutEnvironmentSetUpCoordinator.swift index 85d688b2..64414dbe 100644 --- a/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutEnvironmentSetUpCoordinator.swift +++ b/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutEnvironmentSetUpCoordinator.swift @@ -37,6 +37,7 @@ final class WorkoutEnvironmentSetUpCoordinator: WorkoutEnvironmentSetUpCoordinat let repository = WorkoutEnvironmentSetupNetworkRepository(session: URLSession.shared) let useCase = WorkoutEnvironmentSetupUseCase(repository: repository) + let userInfoUseCase = UserInformationUseCase() let viewModel = WorkoutEnvironmentSetupViewModel( @@ -46,8 +47,9 @@ final class WorkoutEnvironmentSetUpCoordinator: WorkoutEnvironmentSetUpCoordinat ) let viewController = WorkoutEnvironmentSetupViewController(viewModel: viewModel) + viewController.hidesBottomBarWhenPushed = true - navigationController.pushViewController(viewController, animated: false) + navigationController.pushViewController(viewController, animated: true) } func pushPeerRandomMatchingViewController(workoutSetting: WorkoutSetting) { diff --git a/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutSessionCoordinator.swift b/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutSessionCoordinator.swift index 2b2be534..34c72732 100644 --- a/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutSessionCoordinator.swift +++ b/iOS/Projects/Features/Record/Sources/Presentation/Common/Coordinator/WorkoutSessionCoordinator.swift @@ -176,7 +176,7 @@ final class WorkoutSessionCoordinator: WorkoutSessionCoordinating { let viewModel = CountDownBeforeWorkoutViewModel(coordinator: self, useCase: useCase) let viewController = CountDownBeforeWorkoutViewController(viewModel: viewModel) - navigationController.pushViewController(viewController, animated: true) + navigationController.setViewControllers([viewController], animated: true) } func pushTapBarViewController() { diff --git a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift index f08c2b4e..e886237c 100644 --- a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift +++ b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift @@ -72,6 +72,7 @@ public final class WorkoutEnvironmentSetupViewController: UIViewController { .compactMap { $0 as? UIScrollView } .first pageScrollView = scrollView + pageScrollView?.isScrollEnabled = false pageScrollView?.delegate = self pageViewController.view.translatesAutoresizingMaskIntoConstraints = false @@ -81,13 +82,23 @@ public final class WorkoutEnvironmentSetupViewController: UIViewController { private extension WorkoutEnvironmentSetupViewController { func setup() { - view.backgroundColor = DesignSystemColor.primaryBackground + setupStyle() setupViewHierarchyAndConstraints() bind() configureDataSource() } + func setupStyle() { + navigationController?.isNavigationBarHidden = false + navigationController?.navigationBar.isHidden = false + navigationController?.navigationBar.tintColor = DesignSystemColor.main03 + + let titleBarButtonItemFont: UIFont = .preferredFont(forTextStyle: .title3, weight: .semibold) + navigationController?.tabBarItem.setTitleTextAttributes([.font: titleBarButtonItemFont], for: .normal) + view.backgroundColor = DesignSystemColor.primaryBackground + } + func setupViewHierarchyAndConstraints() { let safeArea = view.safeAreaLayoutGuide @@ -253,6 +264,7 @@ extension WorkoutEnvironmentSetupViewController: UIPageViewControllerDelegate, U if let currentViewController = pageViewController.viewControllers?.first, let currentIndex = contentViewControllers.firstIndex(of: currentViewController) { + pageScrollView?.isScrollEnabled = currentIndex == 0 ? false : true gwPageControl.select(at: currentIndex) } } @@ -273,22 +285,11 @@ extension WorkoutEnvironmentSetupViewController: UIPageViewControllerDelegate, U } } -// MARK: UIScrollViewDelegate - -extension WorkoutEnvironmentSetupViewController: UIScrollViewDelegate { - public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { - if pageViewController.viewControllers?.first == contentViewControllers.first { - scrollView.isScrollEnabled = false - } - } - - public func scrollViewDidEndDragging(_: UIScrollView, willDecelerate _: Bool) {} -} - // MARK: WorkoutSelectViewDelegate extension WorkoutEnvironmentSetupViewController: WorkoutSelectViewDelegate { func nextButtonDidTap() { + pageScrollView?.isScrollEnabled = false gwPageControl.next() pageViewController.setViewControllers([workoutPeerSelectViewController], direction: .forward, animated: true) { [weak self] _ in self?.pageScrollView?.isScrollEnabled = true diff --git a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutSelectViewController.swift b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutSelectViewController.swift index 006ecfe2..9443636e 100644 --- a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutSelectViewController.swift +++ b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutSelectViewController.swift @@ -22,7 +22,6 @@ protocol WorkoutSelectViewDelegate: AnyObject { final class WorkoutSelectViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - navigationController?.setNavigationBarHidden(true, animated: false) setupConstraints() bind() } @@ -32,7 +31,7 @@ final class WorkoutSelectViewController: UIViewController { private let workoutSelectDescriptionLabel: UILabel = { let label = UILabel() - label.font = .preferredFont(forTextStyle: .title1, with: .traitBold) + label.font = .preferredFont(forTextStyle: .title1, weight: .bold) label.textAlignment = .left label.text = "1. 운동을 선택하세요" From 5eabb2f5ac1230c412e2ab24633e952d75243a4b Mon Sep 17 00:00:00 2001 From: MaraMincho <103064352+MaraMincho@users.noreply.github.com> Date: Sun, 10 Dec 2023 11:48:29 +0900 Subject: [PATCH 5/5] =?UTF-8?q?style:=20=EC=A0=91=EA=B7=BC=20=EC=A0=9C?= =?UTF-8?q?=EC=96=B4=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...orkoutEnvironmentSetupViewController.swift | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift index e886237c..100c9fa4 100644 --- a/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift +++ b/iOS/Projects/Features/Record/Sources/Presentation/WorkoutEnvironmentScene/ViewController/WorkoutEnvironmentSetupViewController.swift @@ -32,24 +32,24 @@ public final class WorkoutEnvironmentSetupViewController: UIViewController { } private var subscriptions = Set() - private var viewModel: WorkoutEnvironmentSetupViewModelRepresentable? + private let viewModel: WorkoutEnvironmentSetupViewModelRepresentable? // MARK: - WorkoutEnvironmentSetupViewModelInput - let requestWorkoutTypes = PassthroughSubject() - let requestWorkoutPeerTypes = PassthroughSubject() - let selectWorkoutType = PassthroughSubject() - let selectPeerType = PassthroughSubject() - let endWorkoutEnvironment = PassthroughSubject() - let didTapStartButton = PassthroughSubject() + private let requestWorkoutTypes = PassthroughSubject() + private let requestWorkoutPeerTypes = PassthroughSubject() + private let selectWorkoutType = PassthroughSubject() + private let selectPeerType = PassthroughSubject() + private let endWorkoutEnvironment = PassthroughSubject() + private let didTapStartButton = PassthroughSubject() // MARK: - ConatinerViewController Control Property - var workoutTypesDataSource: UICollectionViewDiffableDataSource? - var workoutPeerTypesDataSource: UICollectionViewDiffableDataSource? + private var workoutTypesDataSource: UICollectionViewDiffableDataSource? + private var workoutPeerTypesDataSource: UICollectionViewDiffableDataSource? - var workoutTypesCollectionView: UICollectionView? - var workoutPeerTypesCollectionView: UICollectionView? + private var workoutTypesCollectionView: UICollectionView? + private var workoutPeerTypesCollectionView: UICollectionView? private let workoutSelectViewController = WorkoutSelectViewController() private let workoutPeerSelectViewController = WorkoutPeerSelectViewController() @@ -63,7 +63,7 @@ public final class WorkoutEnvironmentSetupViewController: UIViewController { return pageControl }() - lazy var pageViewController: UIPageViewController = { + private lazy var pageViewController: UIPageViewController = { let pageViewController = UIPageViewController(transitionStyle: .scroll, navigationOrientation: .horizontal) pageViewController.dataSource = self pageViewController.delegate = self