Skip to content

Commit

Permalink
[CAT-191] 서비스 가이드 기능 (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok authored Aug 16, 2024
1 parent 3ffc552 commit d78b5f9
Show file tree
Hide file tree
Showing 23 changed files with 69 additions and 46 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.
26 changes: 17 additions & 9 deletions Projects/Feature/HomeFeature/Sources/Home/HomeCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UserNotifications

import PushService
import UserNotificationClientInterface
import UserDefaultsClientInterface

import ComposableArchitecture

Expand All @@ -28,7 +28,7 @@ public struct HomeCore {
}

public enum Action {
case onAppear
case onLoad
case setHomeCatTooltip(HomeCatDialogueTooltip?)
case setHomeCategoryGuideTooltip(HomeCategoryGuideTooltip?)
case setHomeTimeGuideTooltip(HomeTimeGuideTooltip?)
Expand All @@ -48,7 +48,8 @@ public struct HomeCore {
case guide
}

@Dependency(UserNotificationClient.self) var userNotificationClient
@Dependency(UserDefaultsClient.self) var userDefaultsClient
let isHomeGuideCompletedKey = "mohanyang_userdefaults_isHomeGuideCompleted"

public init() {}

Expand All @@ -64,17 +65,24 @@ public struct HomeCore {

private func core(_ state: inout State, _ action: Action) -> EffectOf<Self> {
switch action {
case .onAppear:
state.homeCatTooltip = .init(title: "오랜만이다냥")
state.homeCategoryGuideTooltip = .init()
return .none
case .onLoad:
return .run { send in
await send(.setHomeCatTooltip(nil))
if self.userDefaultsClient.boolForKey(isHomeGuideCompletedKey) == false {
await self.userDefaultsClient.setBool(true, key: isHomeGuideCompletedKey)
await send(.setHomeCategoryGuideTooltip(HomeCategoryGuideTooltip()))
}
}

case let .setHomeCatTooltip(tooltip):
case .setHomeCatTooltip:
state.homeCatTooltip = .init(title: "오랜만이다냥") // TODO: - 문구 랜덤변경하기
return .none

case let .setHomeCategoryGuideTooltip(tooltip):
state.homeCategoryGuideTooltip = tooltip
state.homeTimeGuideTooltip = .init()
if tooltip == nil {
state.homeTimeGuideTooltip = .init()
}
return .none

case let .setHomeTimeGuideTooltip(tooltip):
Expand Down
5 changes: 3 additions & 2 deletions Projects/Feature/HomeFeature/Sources/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import SwiftUI

import DesignSystem
import Utils

import ComposableArchitecture

Expand Down Expand Up @@ -122,8 +123,8 @@ public struct HomeView: View {
) { store in
TimeSelectView(store: store)
}
.onAppear {
store.send(.onAppear)
.onLoad {
store.send(.onLoad)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import SwiftUI

import DesignSystem
import Utils

struct WheelPicker<D: WheelPickerData>: View {
@Namespace var backgroundFrameID
Expand Down
6 changes: 5 additions & 1 deletion Projects/Shared/DesignSystem/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ let project: Project = .makeTMABasedProject(
.sources,
.example
],
dependencies: [:],
dependencies: [
.sources: [
.dependency(module: Shared.Utils)
]
],
resourceSynthesizers: [
.fonts(), // for font
.assets(), // for .xcassets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import SwiftUI

import Utils

struct TooltipTarget: View {
let identifier: AnyHashable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

import SwiftUI

public struct ExcludeRoundedRectMask: View {
struct ExcludeRoundedRectMask: View {
let excludedRect: CGRect
let cornerRadius: CGFloat

public init(
init(
excludedRect: CGRect,
cornerRadius: CGFloat
) {
self.excludedRect = excludedRect
self.cornerRadius = cornerRadius
}

public var body: some View {
var body: some View {
GeometryReader { geometry in
let fullRect = geometry.frame(in: .local)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import SwiftUI

public struct Triangle: View {
public enum Direction: Double {
struct Triangle: View {
enum Direction: Double {
case down = 180
case left = -90
case up = 0
Expand All @@ -19,12 +19,12 @@ public struct Triangle: View {
private let direction: Direction
private let color: Color

public init(direction: Direction, color: Color) {
init(direction: Direction, color: Color) {
self.direction = direction
self.color = color
}

public var body: some View {
var body: some View {
TriangleShape()
.fill(color)
.rotationEffect(Angle.degrees(direction.rawValue))
Expand Down
1 change: 0 additions & 1 deletion Projects/Shared/Shared/Sources/Exports.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@_exported import Logger
@_exported import DesignSystem
@_exported import Utils
@_exported import UtilsInterface

@_exported import ThirdParty_SPM
@_exported import ThirdParty_Firebase
Expand Down
5 changes: 0 additions & 5 deletions Projects/Shared/Utils/Interface/UtilsInterface.swift

This file was deleted.

1 change: 0 additions & 1 deletion Projects/Shared/Utils/Preview/Resources/dummy.txt

This file was deleted.

5 changes: 0 additions & 5 deletions Projects/Shared/Utils/Preview/Sources/Utils.swift

This file was deleted.

5 changes: 1 addition & 4 deletions Projects/Shared/Utils/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ let project: Project = .makeTMABasedProject(
module: Shared.Utils,
scripts: [],
targets: [
.sources,
.interface,
.tests,
.testing
.sources
],
dependencies: [:]
)
1 change: 0 additions & 1 deletion Projects/Shared/Utils/Resources/dummy.txt

This file was deleted.

33 changes: 33 additions & 0 deletions Projects/Shared/Utils/Sources/Extension/SwiftUI/View+Onload.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// View+Extension.swift
// Utils
//
// Created by devMinseok on 8/16/24.
// Copyright © 2024 PomoNyang. All rights reserved.
//

import SwiftUI

extension View {
public func onLoad(perform action: (() -> Void)? = nil) -> some View {
modifier(ViewDidLoadModifier(perform: action))
}
}

private struct ViewDidLoadModifier: ViewModifier {
@State private var didLoad = false
private let action: (() -> Void)?

init(perform action: (() -> Void)? = nil) {
self.action = action
}

func body(content: Content) -> some View {
content.onAppear {
if didLoad == false {
didLoad = true
action?()
}
}
}
}
5 changes: 0 additions & 5 deletions Projects/Shared/Utils/Testing/UtilsTesting.swift

This file was deleted.

5 changes: 0 additions & 5 deletions Projects/Shared/Utils/Tests/UtilsTests.swift

This file was deleted.

0 comments on commit d78b5f9

Please sign in to comment.