Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CAT-192] 홈 기본 UI 구성 #26

Merged
merged 16 commits into from
Aug 16, 2024
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
devMinseok marked this conversation as resolved.
Show resolved Hide resolved
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))
}
}

Comment on lines +11 to +16
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요것은 어떤 역할을 하는거야 ?? onAppear과 다르게 onLoad를 둔 이유 ? ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 코드 보면 알겠지만 viewDidLoad와 같은 역할을 하려고 만든거야

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core에서 didLoad 플래그를 둬도 되긴 하는데 매번 해주는게 불편해서

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.

Loading