Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
WhiteHyun committed Oct 25, 2022
2 parents e14f386 + 480a7a6 commit 0e66467
Show file tree
Hide file tree
Showing 34 changed files with 1,533 additions and 78 deletions.
62 changes: 62 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh
# written by Noah
LINT=$(which swiftlint)

if [[ -e "${LINT}" ]]; then
echo "🚀 SwiftLint 시작..."
echo "🔍 lint 적용 경로: $(pwd)"
else
echo "SwiftLint가 존재하지 않습니다, 공식문서를 확인해주세요. 🌐 https://github.com/realm/SwiftLint"
exit 1
fi

normalfiles=$(git diff --stat --cached)
targets=$(git diff --stat --cached --diff-filter=d --name-only $(git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)) | grep -F ".swift")

if [ -n "$normalfiles" -a -z "$targets" ]; then
printf "✨ 고생하셨습니다👏 👏 👏\n"
exit 0

elif [ -z "${normalfiles}" ]; then
printf "🏷️ Staging Area 파일이 없습니다"
printf "\n ✔ git add를 먼저 진행해주세요:)"
exit 1

elif [ -z "$targets" ]; then
printf "🏷️ Staging Area swift 파일이 없습니다"
printf "\n ✔ git add를 먼저 진행해주세요:)"
exit 1
fi

# lint rule 정의 파일
#RESULT=$($LINT lint --quiet --config .precommit.yml)
RESULT=$($LINT lint --quiet)

if [ "$RESULT" == '' ]; then
printf "✨ SwiftLint 적용을 완료했습니다!! 고생하셨습니다:)\n"
else
echo ""
printf "✔ SwiftLint Failed 아래 내용을 확인해주세요:\n"
while read -r line; do
FILEPATH=$(echo $line | cut -d : -f 1)
L=$(echo $line | cut -d : -f 2)
C=$(echo $line | cut -d : -f 3)
TYPE=$(echo $line | cut -d : -f 4 | cut -c 2-)
MESSAGE=$(echo $line | cut -d : -f 5 | cut -c 2-)
DESCRIPTION=$(echo $line | cut -d : -f 6 | cut -c 2-)
if [ $TYPE == 'warning' ]; then
printf "\n 🚧 $TYPE\n"
# warning 타입은 오류메시지만 표시하고 커밋을 허용하고 싶다면 line 40~42 주석 해제.
# printf " $FILEPATH:$L:$C\n"
# printf " 📌 $MESSAGE: - $DESCRIPTION\n"
# exit 0
elif [ $TYPE == 'error' ]; then
printf "\n 🚨 $TYPE\n"
fi
printf "$FILEPATH:$L:$C\n"
printf " 📌 $MESSAGE: - $DESCRIPTION\n"
done <<< "$RESULT"

printf "\n 🚑 커밋실패!! Swiftlint rule에 맞게 코드를 변경해주세요:)\n"
exit 1
fi
170 changes: 160 additions & 10 deletions FlipClock.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"pins" : [
{
"identity" : "rxswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ReactiveX/RxSwift",
"state" : {
"branch" : "main",
"revision" : "e0ab8c4e18baf6679a65b325155923276b832687"
}
},
{
"identity" : "snapkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SnapKit/SnapKit.git",
"state" : {
"branch" : "develop",
"revision" : "07c5d1f6044701d97e94dc11157259e8811977be"
}
},
{
"identity" : "then",
"kind" : "remoteSourceControl",
"location" : "https://github.com/devxoul/Then.git",
"state" : {
"branch" : "master",
"revision" : "d41ef523faef0f911369f79c0b96815d9dbb6d7a"
}
}
],
"version" : 2
}
25 changes: 9 additions & 16 deletions FlipClock/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,20 @@ import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

23 changes: 23 additions & 0 deletions FlipClock/Assets.xcassets/theme1.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "theme2-modified.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "theme2-modified@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "theme2-modified@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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.
23 changes: 23 additions & 0 deletions FlipClock/Assets.xcassets/theme2.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "theme1-modified.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "theme1-modified@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "theme1-modified@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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.
8 changes: 3 additions & 5 deletions FlipClock/Coordinators/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

import UIKit



protocol Coordinator: AnyObject {

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

func start()

}
42 changes: 16 additions & 26 deletions FlipClock/Coordinators/MainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,42 @@
// Created by 홍승현 on 2022/07/06.
//

import Foundation
import UIKit

final class MainCoordinator: NSObject, Coordinator {

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)

let homeVC = ViewController()
homeVC.coordinator = self
navigationController.pushViewController(homeVC, 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
}
for (index, coordinator) in childCoordinators.enumerated() where coordinator === child {
childCoordinators.remove(at: index)
break
}
}
}


// MARK: - UINavigationControllerDelegate

extension MainCoordinator: UINavigationControllerDelegate {
Expand All @@ -56,19 +49,16 @@ extension MainCoordinator: UINavigationControllerDelegate {
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)
}


}
}
20 changes: 12 additions & 8 deletions FlipClock/Coordinators/SettingCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@

import UIKit

class SettingCoordinator: Coordinator {
final class SettingCoordinator: Coordinator {

var childCoordinators: [Coordinator] = []
weak var parentCoordinator: MainCoordinator?
var navigationController: UINavigationController



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

func start() {
let vc = SettingsViewController()
vc.coordinator = self
navigationController.pushViewController(vc, animated: true)
let settingVC = SettingsViewController()
settingVC.coordinator = self
navigationController.pushViewController(settingVC, animated: true)
}

func moveToThemeVC() {
let child = ThemeCoordinator(navigationController: navigationController)
child.start()
}
}
24 changes: 24 additions & 0 deletions FlipClock/Coordinators/ThemeCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ThemeCoordinator.swift
// FlipClock
//
// Created by 홍승현 on 2022/08/03.
//

import UIKit

final class ThemeCoordinator: Coordinator {

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

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

func start() {
let themeVC = ThemeViewController()
themeVC.coordinator = self
navigationController.pushViewController(themeVC, animated: true)
}
}
36 changes: 36 additions & 0 deletions FlipClock/Extensions/Theme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// Theme.swift
// FlipClock
//
// Created by 홍승현 on 2022/09/23.
//

import Foundation

import RxCocoa

enum Theme: Int {
case dark
case light

static let currentTheme = BehaviorRelay<Theme>(value: Theme(rawValue: UserDefaults.standard.theme) ?? .dark)

var colors: HexColor {
switch self {
case .dark:
return HexColor(background: 0xAAAAAA, text: 0xFFFFFF, clockBackground: 0x000000)
case .light:
return HexColor(background: 0xF0F2F7, text: 0x000000, clockBackground: 0xFFFFFF)
}
}
}

// MARK: - Color(Hex Value)

extension Theme {
struct HexColor {
let background: Int
let text: Int
let clockBackground: Int
}
}
Loading

0 comments on commit 0e66467

Please sign in to comment.