Skip to content

Commit

Permalink
v0.1.0 (#4)
Browse files Browse the repository at this point in the history
* Test: 테스트 버전

* Chore: SnapKit 추가

* Chore: Then 프레임워크 추가

* Feat: FlipLabel SnapKit Constraint 적용

* Feat: Then 적용

* Test: 테스트 코드 추가

* Feat: 코드 구조화

* Style: 메소드명 변경

* Style: 주석 추가

* Feat: configure 메서드 추가

- 초기화 과정에 필수적으로 적용할 코드를 메서드로 구조화함.

* Style: 메서드명 변경

createSnapshotViews -> createLabelImages

* Style: 클래스명 변경

FlippableLabel -> Flipitem

* Feat: 가운데 구분선 추가

* Feat: FlipView 파일 추가

* Feat: 시간, 분, 초에 따른 Enum타입 생성

* Feat: 중간 구분선 FlipView 클래스로 이동

* Feat: time 프로퍼티 추가

* Feat: FlipClockView 클래스 추가

* Feat: 시간, 분, 초 단위의 FlipClock 생성

* Feat: Constraint 적용

* Feat: Timer 추가

* Feat: 같은 값인 경우 단순반환

* Feat: FlipView에 적용

* Test: 테스트코드 작성

* Feat: 화면 회전할 때 스택뷰 축 변경

* Fix: stackview의 축이 바뀔 때 cliptobounds값이 바뀌는 현상 수정

* Refactor: 코드 역할에 맞게 addSubviews 코드 이동

* Feat: Coordinator로 실행 구성

* Feat: SettingsViewController 추가

* Feat: SettingCoordinator 추가

* Feat: child와 parent process 구현

* Fix: 화면 회전할 때 background 문제 생기는 버그 수정

* Fix: 백그라운드 진입시 생기는 Flip 버그 수정

- 사라져야되는 텍스트가 사라지지 않는 버그

* Feat: 우측 navbar button 추가

- gear 아이콘으로 설정
- 설정페이지로 넘어가는 objc func 선언

* Feat: 시계 왼 오른쪽 간격 40으로 설정

* Feat: "준비중" 문구 표시

* Feat: 기본 테이블뷰 설정

* Style: 앱 아이콘 추가
  • Loading branch information
WhiteHyun authored Jul 8, 2022
1 parent 1c132e9 commit 1b65e2b
Show file tree
Hide file tree
Showing 31 changed files with 895 additions and 120 deletions.
92 changes: 91 additions & 1 deletion FlipClock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,71 @@
objects = {

/* Begin PBXBuildFile section */
BA7ECC1E287473F000511694 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = BA7ECC1D287473F000511694 /* SnapKit */; };
BA7ECC2128747BBD00511694 /* Then in Frameworks */ = {isa = PBXBuildFile; productRef = BA7ECC2028747BBD00511694 /* Then */; };
BA7ECC232875293100511694 /* FlipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7ECC222875293100511694 /* FlipView.swift */; };
BA7ECC2528754CA600511694 /* FlipClockView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7ECC2428754CA600511694 /* FlipClockView.swift */; };
BA7ECC2928757D4200511694 /* Coordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7ECC2828757D4200511694 /* Coordinator.swift */; };
BA7ECC2B28757D8A00511694 /* MainCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7ECC2A28757D8A00511694 /* MainCoordinator.swift */; };
BA7ECC2E28759CB200511694 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7ECC2D28759CB200511694 /* SettingsViewController.swift */; };
BA7ECC312875A04D00511694 /* SettingCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA7ECC302875A04D00511694 /* SettingCoordinator.swift */; };
BA95DE0B28671BDD00041A30 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA95DE0A28671BDD00041A30 /* AppDelegate.swift */; };
BA95DE0D28671BDD00041A30 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA95DE0C28671BDD00041A30 /* SceneDelegate.swift */; };
BA95DE0F28671BDD00041A30 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA95DE0E28671BDD00041A30 /* ViewController.swift */; };
BA95DE1428671BDE00041A30 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BA95DE1328671BDE00041A30 /* Assets.xcassets */; };
BA95DE1728671BDE00041A30 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BA95DE1528671BDE00041A30 /* LaunchScreen.storyboard */; };
BA95DE1F28671EFA00041A30 /* FlipItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA95DE1E28671EFA00041A30 /* FlipItem.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
BA7ECC222875293100511694 /* FlipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlipView.swift; sourceTree = "<group>"; };
BA7ECC2428754CA600511694 /* FlipClockView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlipClockView.swift; sourceTree = "<group>"; };
BA7ECC2828757D4200511694 /* Coordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coordinator.swift; sourceTree = "<group>"; };
BA7ECC2A28757D8A00511694 /* MainCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainCoordinator.swift; sourceTree = "<group>"; };
BA7ECC2D28759CB200511694 /* SettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
BA7ECC302875A04D00511694 /* SettingCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingCoordinator.swift; sourceTree = "<group>"; };
BA95DE0728671BDD00041A30 /* FlipClock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FlipClock.app; sourceTree = BUILT_PRODUCTS_DIR; };
BA95DE0A28671BDD00041A30 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
BA95DE0C28671BDD00041A30 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
BA95DE0E28671BDD00041A30 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
BA95DE1328671BDE00041A30 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
BA95DE1628671BDE00041A30 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
BA95DE1828671BDE00041A30 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BA95DE1E28671EFA00041A30 /* FlipItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlipItem.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
BA95DE0428671BDD00041A30 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
BA7ECC1E287473F000511694 /* SnapKit in Frameworks */,
BA7ECC2128747BBD00511694 /* Then in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
BA7ECC2C28757F1500511694 /* Coordinators */ = {
isa = PBXGroup;
children = (
BA7ECC2828757D4200511694 /* Coordinator.swift */,
BA7ECC2A28757D8A00511694 /* MainCoordinator.swift */,
BA7ECC302875A04D00511694 /* SettingCoordinator.swift */,
);
path = Coordinators;
sourceTree = "<group>";
};
BA7ECC2F28759CB600511694 /* ViewControllers */ = {
isa = PBXGroup;
children = (
BA95DE0E28671BDD00041A30 /* ViewController.swift */,
BA7ECC2D28759CB200511694 /* SettingsViewController.swift */,
);
path = ViewControllers;
sourceTree = "<group>";
};
BA95DDFE28671BDD00041A30 = {
isa = PBXGroup;
children = (
Expand All @@ -56,10 +93,14 @@
children = (
BA95DE0A28671BDD00041A30 /* AppDelegate.swift */,
BA95DE0C28671BDD00041A30 /* SceneDelegate.swift */,
BA95DE0E28671BDD00041A30 /* ViewController.swift */,
BA7ECC2C28757F1500511694 /* Coordinators */,
BA7ECC2F28759CB600511694 /* ViewControllers */,
BA95DE1328671BDE00041A30 /* Assets.xcassets */,
BA95DE1528671BDE00041A30 /* LaunchScreen.storyboard */,
BA95DE1828671BDE00041A30 /* Info.plist */,
BA95DE1E28671EFA00041A30 /* FlipItem.swift */,
BA7ECC222875293100511694 /* FlipView.swift */,
BA7ECC2428754CA600511694 /* FlipClockView.swift */,
);
path = FlipClock;
sourceTree = "<group>";
Expand All @@ -80,6 +121,10 @@
dependencies = (
);
name = FlipClock;
packageProductDependencies = (
BA7ECC1D287473F000511694 /* SnapKit */,
BA7ECC2028747BBD00511694 /* Then */,
);
productName = FlipClock;
productReference = BA95DE0728671BDD00041A30 /* FlipClock.app */;
productType = "com.apple.product-type.application";
Expand Down Expand Up @@ -108,6 +153,10 @@
Base,
);
mainGroup = BA95DDFE28671BDD00041A30;
packageReferences = (
BA7ECC1C287473F000511694 /* XCRemoteSwiftPackageReference "SnapKit" */,
BA7ECC1F28747BBD00511694 /* XCRemoteSwiftPackageReference "Then" */,
);
productRefGroup = BA95DE0828671BDD00041A30 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand All @@ -134,9 +183,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BA7ECC232875293100511694 /* FlipView.swift in Sources */,
BA7ECC2B28757D8A00511694 /* MainCoordinator.swift in Sources */,
BA95DE0F28671BDD00041A30 /* ViewController.swift in Sources */,
BA7ECC2528754CA600511694 /* FlipClockView.swift in Sources */,
BA95DE1F28671EFA00041A30 /* FlipItem.swift in Sources */,
BA95DE0B28671BDD00041A30 /* AppDelegate.swift in Sources */,
BA95DE0D28671BDD00041A30 /* SceneDelegate.swift in Sources */,
BA7ECC312875A04D00511694 /* SettingCoordinator.swift in Sources */,
BA7ECC2928757D4200511694 /* Coordinator.swift in Sources */,
BA7ECC2E28759CB200511694 /* SettingsViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -280,6 +336,7 @@
INFOPLIST_FILE = FlipClock/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -307,6 +364,7 @@
INFOPLIST_FILE = FlipClock/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations = "";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -344,6 +402,38 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
BA7ECC1C287473F000511694 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SnapKit/SnapKit.git";
requirement = {
branch = develop;
kind = branch;
};
};
BA7ECC1F28747BBD00511694 /* XCRemoteSwiftPackageReference "Then" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/devxoul/Then.git";
requirement = {
branch = master;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
BA7ECC1D287473F000511694 /* SnapKit */ = {
isa = XCSwiftPackageProductDependency;
package = BA7ECC1C287473F000511694 /* XCRemoteSwiftPackageReference "SnapKit" */;
productName = SnapKit;
};
BA7ECC2028747BBD00511694 /* Then */ = {
isa = XCSwiftPackageProductDependency;
package = BA7ECC1F28747BBD00511694 /* XCRemoteSwiftPackageReference "Then" */;
productName = Then;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = BA95DDFF28671BDD00041A30 /* Project object */;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FlipClock/Assets.xcassets/AppIcon.appiconset/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 1 addition & 98 deletions FlipClock/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,98 +1 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"72x72","expected-size":"72","filename":"72.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"76x76","expected-size":"152","filename":"152.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"50x50","expected-size":"100","filename":"100.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"76x76","expected-size":"76","filename":"76.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"50x50","expected-size":"50","filename":"50.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"72x72","expected-size":"144","filename":"144.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"40x40","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"83.5x83.5","expected-size":"167","filename":"167.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"20x20","expected-size":"20","filename":"20.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"}]}
19 changes: 19 additions & 0 deletions FlipClock/Coordinators/Coordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Coordinator.swift
// FlipClock
//
// Created by 홍승현 on 2022/07/06.
//

import UIKit



protocol Coordinator: AnyObject {

var childCoordinators: [Coordinator] { get set }
var navigationController: UINavigationController { get set }

func start()

}
74 changes: 74 additions & 0 deletions FlipClock/Coordinators/MainCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// MainCoordinator.swift
// FlipClock
//
// Created by 홍승현 on 2022/07/06.
//

import Foundation
import UIKit


class MainCoordinator: NSObject, Coordinator {

var childCoordinators: [Coordinator] = []
var navigationController: UINavigationController

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

func start() {

navigationController.delegate = self

let vc = ViewController()
vc.coordinator = self
navigationController.pushViewController(vc, animated: false)
}


func moveToSetting() {
let child = SettingCoordinator(navigationController: navigationController)

child.parentCoordinator = self
childCoordinators.append(child)
child.start()
}


func childDidFinish(_ child: Coordinator?) {
for (index, coordinator) in childCoordinators.enumerated() {
if coordinator === child {
childCoordinators.remove(at: index)
break
}
}
}
}


// MARK: - UINavigationControllerDelegate

extension MainCoordinator: UINavigationControllerDelegate {
func navigationController(
_ navigationController: UINavigationController,
didShow viewController: UIViewController,
animated: Bool
) {

guard let fromVC = navigationController.transitionCoordinator?.viewController(forKey: .from) else {
return
}

if navigationController.viewControllers.contains(fromVC) {
return
}

if let settingVC = fromVC as? SettingsViewController {
childDidFinish(settingVC.coordinator)
}


}
}
Loading

0 comments on commit 1b65e2b

Please sign in to comment.