Skip to content

Commit

Permalink
FEAT: 홈, 온보딩 모듈 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok committed Jul 22, 2024
1 parent b7eb8cf commit 91af532
Show file tree
Hide file tree
Showing 66 changed files with 785 additions and 79 deletions.
Binary file modified DependencyGraph/mohanyang_dev_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified DependencyGraph/mohanyang_prod_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dev:

.PHONY: prod
prod:
make generate config=prod
make generate config=prod target=Mohanyang


### Script ###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import Foundation
@_spi(Domain)
public enum Domain: String, Modulable {
case AppService
case PushService
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ import Foundation

@_spi(Feature)
public enum Feature: String, Modulable {
case AppFeature
case HomeFeature
case OnboardingFeature
}
100 changes: 50 additions & 50 deletions Projects/App/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,56 @@
import SwiftUI
import UserNotifications

import AppFeature
import Feature
import DesignSystem

//import FirebaseMessaging
import ComposableArchitecture

//final class AppDelegate: UIResponder, UIApplicationDelegate {
// let store = Store(
// initialState: AppCore.State()
// ) {
// AppCore()
// }
//
// func application(
// _ application: UIApplication,
// didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
// ) -> Bool {
// self.store.send(.appDelegate(.didFinishLaunching))
// return true
// }
//
// func application(
// _ application: UIApplication,
// didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
// ) {
// self.store.send(.appDelegate(.didRegisterForRemoteNotifications(.success(deviceToken))))
// }
//
// func application(
// _ application: UIApplication,
// didFailToRegisterForRemoteNotificationsWithError error: Error
// ) {
// self.store.send(.appDelegate(.didRegisterForRemoteNotifications(.failure(error))))
// }
//}
//
//@main
//struct KimcaddieOwnerApp: App {
// @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
// @Environment(\.scenePhase) private var scenePhase
//
// init() {
// DesignSystemFontFamily.registerAllCustomFonts()
// }
//
// var body: some Scene {
// WindowGroup {
// AppView(store: self.appDelegate.store)
// }
// .onChange(of: self.scenePhase) { value in
// self.appDelegate.store.send(.didChangeScenePhase(value))
// }
// }
//}
final class AppDelegate: UIResponder, UIApplicationDelegate {
let store = Store(
initialState: AppCore.State()
) {
AppCore()
}

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
self.store.send(.appDelegate(.didFinishLaunching))
return true
}

func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
self.store.send(.appDelegate(.didRegisterForRemoteNotifications(.success(deviceToken))))
}

func application(
_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error
) {
self.store.send(.appDelegate(.didRegisterForRemoteNotifications(.failure(error))))
}
}

@main
struct MohanyangApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
@Environment(\.scenePhase) private var scenePhase

init() {
DesignSystemFontFamily.registerAllCustomFonts()
}

var body: some Scene {
WindowGroup {
AppView(store: self.appDelegate.store)
}
.onChange(of: self.scenePhase) { oldValue, newValue in

Check warning on line 60 in Projects/App/Sources/AppDelegate.swift

View workflow job for this annotation

GitHub Actions / Run Swiftlint

Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
self.appDelegate.store.send(.didChangeScenePhase(newValue))
}
}
}
2 changes: 1 addition & 1 deletion Projects/Core/Core/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import DependencyPlugin
let project: Project = .makeRootProject(
rootModule: Core.self,
scripts: [],
product: .framework
product: .staticLibrary
)
2 changes: 1 addition & 1 deletion Projects/Domain/Domain/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import DependencyPlugin
let project: Project = .makeRootProject(
rootModule: Domain.self,
scripts: [],
product: .framework
product: .staticLibrary
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "ICON_DEMO.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21679"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="PushService Example" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zuX-Xj-POK">
<rect key="frame" x="148" y="339" width="118" height="38.5"/>
<fontDescription key="fontDescription" type="system" pointSize="32"/>
<color key="textColor" name="white"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" name="green60"/>
<constraints>
<constraint firstItem="zuX-Xj-POK" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="Dci-bf-BmU"/>
<constraint firstItem="zuX-Xj-POK" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" multiplier="0.8" id="qjt-zk-rv9"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="52.173913043478265" y="375"/>
</scene>
</scenes>
<resources>
<namedColor name="green60">
<color red="0.24699999392032623" green="0.76499998569488525" blue="0.68999999761581421" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="white">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
11 changes: 11 additions & 0 deletions Projects/Domain/PushService/Example/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import UIKit

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
return true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// PushNotificationContent.swift
// PushService
//
// Created by devMinseok on 7/22/24.
// Copyright © 2024 PomoNyang. All rights reserved.
//

import Foundation

public enum PushNotificationContent: Decodable {
case test
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

public struct AppFeatureInterface {
public struct PushServiceInterface {
public init() {}
}
23 changes: 23 additions & 0 deletions Projects/Domain/PushService/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ProjectDescription
import ProjectDescriptionHelpers

@_spi(Domain)
@_spi(Core)
import DependencyPlugin

let project: Project = .makeTMABasedProject(
module: Domain.PushService,
scripts: [],
targets: [
.sources,
.interface,
.tests,
.testing,
.example
],
dependencies: [
.interface: [
.dependency(rootModule: Core.self)
]
]
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

public struct AppFeature {
public struct PushService {
public init() {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

public struct AppFeatureTesting {
public struct PushServiceTesting {
public init() {}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation

public struct AppFeatureTests {
public struct PushServiceTests {
public init() {}
}
2 changes: 1 addition & 1 deletion Projects/Feature/Feature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import DependencyPlugin
let project: Project = .makeRootProject(
rootModule: Feature.self,
scripts: [],
product: .framework
product: .staticLibrary
)
93 changes: 93 additions & 0 deletions Projects/Feature/Feature/Sources/AppCore.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// AppCore.swift
// AppServiceInterface
//
// Created by devMinseok on 7/22/24.
// Copyright © 2024 PomoNyang. All rights reserved.
//

import SwiftUI

import HomeFeature
import HomeFeatureInterface
import OnboardingFeature
import OnboardingFeatureInterface
import PushServiceInterface

import ComposableArchitecture

@Reducer
public struct AppCore {
@ObservableState
public struct State: Equatable {
public var appDelegate: AppDelegateCore.State = .init()
var home: HomeCore.State?
var onboarding: OnboardingCore.State?

public init() {}
}

public enum Action {
case onAppear
case appDelegate(AppDelegateCore.Action)
case didChangeScenePhase(ScenePhase)
case home(HomeCore.Action)
case onboarding(OnboardingCore.Action)
}

public init() {}

public var body: some ReducerOf<Self> {
Scope(state: \.appDelegate, action: \.appDelegate) {
AppDelegateCore()
}
Reduce(self.core)
.ifLet(\.home, action: \.home) {
HomeCore()
}
.ifLet(\.onboarding, action: \.onboarding) {
OnboardingCore()
}
}

private func core(_ state: inout State, _ action: Action) -> EffectOf<Self> {
switch action {
case .onAppear:
let isLoggedIn = false
if isLoggedIn { // 로그인 판단
state.home = HomeCore.State()
} else {
state.onboarding = OnboardingCore.State()
}
return .none

case let .appDelegate(.userNotifications(.didReceiveResponse(response, completionHandler))):
let userInfo = response.notification.request.content.userInfo
guard let data = try? JSONSerialization.data(withJSONObject: userInfo),
let pushNotiContent = try? JSONDecoder().decode(PushNotificationContent.self, from: data)
else {
completionHandler()
return .none
}
return .run { send in

Check warning on line 72 in Projects/Feature/Feature/Sources/AppCore.swift

View workflow job for this annotation

GitHub Actions / Run Swiftlint

Unused parameter in a closure should be replaced with _ (unused_closure_parameter)
switch pushNotiContent {
case .test:
break
}
completionHandler()
}

case .appDelegate:
return .none

case .didChangeScenePhase:
return .none

case .home:
return .none

case .onboarding:
return .none
}
}
}
Loading

0 comments on commit 91af532

Please sign in to comment.