Skip to content

Commit

Permalink
🪛[chore] : 모듈 분리 작업
Browse files Browse the repository at this point in the history
  • Loading branch information
lainyzine committed Oct 4, 2023
1 parent 1bc4c82 commit 5a328ab
Show file tree
Hide file tree
Showing 13 changed files with 535 additions and 520 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,3 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import SwiftUI
import Model

public class SheetManager: ObservableObject {
public init() { }
public typealias Config = Action.Info
@Published public var isPopup: Bool = false
public enum Action {
public struct Info {
var idx: Int
}
case na
case present(info: Info)
case dismiss
}

@Published public private(set) var action: Action = .na

public func present(with config: Config) {
guard !action.isPresented else { return }
if !self.isPopup {
self.action = .present(info: config)
}
}

public func dismiss() {
self.action = .dismiss
}
}

extension SheetManager.Action {
var isPresented: Bool {
guard case .present(_) = self else { return false }
return true
}
}
20 changes: 20 additions & 0 deletions PingPong/Projects/Core/Common/Sources/AppState/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,23 @@
//

import Foundation
import SwiftUI

public class AppState: ObservableObject {
@Published public var goToProfileSettingView: Bool = false
@Published public var goToBackingView: Bool = false
@Published public var goToMainView: Bool = false

// MARK: 오늘의 명언굽기 State
@Published public var isStartBake: Bool = false
@Published public var isTodayBake: Bool = false
@Published public var isChoicedBread: Bool = false
@Published public var isChoicedIngredent: Bool = false
@Published public var isChoicedTopping: Bool = false
@Published public var isCompleteBake: Bool = false

public init() {
// 초기화 로직을 여기에 추가할 수 있습니다.
}
}

37 changes: 36 additions & 1 deletion PingPong/Projects/Core/Common/Sources/SheetManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,39 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import Foundation
import SwiftUI
import Model

public class SheetManager: ObservableObject {
public init() { }
public typealias Config = Action.Info
@Published public var isPopup: Bool = false
public enum Action {
public struct Info {
var idx: Int
}
case na
case present(info: Info)
case dismiss
}

@Published public private(set) var action: Action = .na

public func present(with config: Config) {
guard !action.isPresented else { return }
if !self.isPopup {
self.action = .present(info: config)
}
}

public func dismiss() {
self.action = .dismiss
}
}

extension SheetManager.Action {
var isPresented: Bool {
guard case .present(_) = self else { return false }
return true
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import Common
import DesignSystem
import Model
import SwiftUI
import Home
import Authorization

public struct ArchiveView: View {
@StateObject private var viewModel: HomeViewViewModel
@StateObject var appState: HomeAppState = HomeAppState()

public init(viewModel: HomeViewViewModel) {
@StateObject var viewModel: CommonViewViewModel
@StateObject var archiveViewViewModel: ArchiveViewViewModel = ArchiveViewViewModel()
@StateObject var appState: AppState = AppState()

public init(viewModel: CommonViewViewModel) {
self._viewModel = StateObject(wrappedValue: viewModel)
}

Expand Down Expand Up @@ -52,7 +56,7 @@ public struct ArchiveView: View {
ScrollView(.vertical) {
LazyVGrid(columns: columns) {
ForEach(group) { item in
let colorSet = searchCharacterColor(flavor: Flavor(rawValue: item.hashtags.flavor.rawValue) ?? .light)
let colorSet = viewModel.searchCharacterColor(flavor: Flavor(rawValue: item.hashtags.flavor.rawValue) ?? .light)
VStack {
HStack {
let imageSet = viewModel.generateImageNameAndText(hashtags: item.hashtags)
Expand Down Expand Up @@ -154,12 +158,12 @@ public struct ArchiveView: View {
.foregroundColor(.primaryOrangeDark)
.pretendardFont(family: .Medium, size: 14)
.onTapGesture {
if viewModel.isAscendingOrder {
if archiveViewViewModel.isAscendingOrder {
viewModel.homePosts.sort { $0.title < $1.title }
} else {
viewModel.homePosts.sort { $0.title > $1.title }
}
viewModel.isAscendingOrder.toggle()
archiveViewViewModel.isAscendingOrder.toggle()
}
}
.frame(width: UIScreen.screenWidth - 40, height: 38)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ArchiveViewModel.swift
// ArchiveViewViewModel.swift
// Archive
//
// Created by Byeon jinha on 2023/10/04.
Expand All @@ -8,6 +8,9 @@

import Foundation

public class ArchiveViewModel: ObservableObject {
public class ArchiveViewViewModel: ObservableObject {

public init() { }

@Published var isAscendingOrder = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,4 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import Foundation
import SwiftUI


public class HomeAppState: ObservableObject {
@Published var goToProfileSettingView: Bool = false
@Published var goToBackingView: Bool = false
@Published var goToMainView: Bool = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import SwiftUI
import Common
import DesignSystem
import Model
import SwiftUI

public struct ChoiceIngredentView: View {
@StateObject private var viewModel: HomeViewViewModel
@StateObject private var viewModel: CommonViewViewModel

var backAction: () -> Void
var rebakeAction: () -> Void

public init(viewModel: HomeViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
public init(viewModel: CommonViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
self._viewModel = StateObject(wrappedValue: viewModel)
self.backAction = backAction
self.rebakeAction = rebakeAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import SwiftUI
import Common
import DesignSystem
import Model
import SwiftUI

public struct ChoiceToppingView: View {
@StateObject private var viewModel: HomeViewViewModel
@StateObject private var viewModel: CommonViewViewModel

var backAction: () -> Void
var rebakeAction: () -> Void

public init(viewModel: HomeViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
public init(viewModel: CommonViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
self._viewModel = StateObject(wrappedValue: viewModel)
self.backAction = backAction
self.rebakeAction = rebakeAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import Common
import SwiftUI

struct FamousSayingBakeCardView: View {

@StateObject private var viewModel: HomeViewViewModel
@StateObject private var viewModel: CommonViewViewModel
@Environment(\.presentationMode) var presentationMode
@StateObject var sheetManager: SheetManager = SheetManager()

var backAction: () -> Void
var rebakeAction: () -> Void

public init(viewModel: HomeViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
public init(viewModel: CommonViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
self._viewModel = StateObject(wrappedValue: viewModel)
self.backAction = backAction
self.rebakeAction = rebakeAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import Common
import SDWebImageSwiftUI
import SwiftUI

struct FamousSayingBakeView: View {

@StateObject private var viewModel: HomeViewViewModel
@StateObject private var viewModel: CommonViewViewModel
var backAction: () -> Void
var rebakeAction: () -> Void

public init(viewModel: HomeViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
public init(viewModel: CommonViewViewModel, backAction: @escaping () -> Void, rebakeAction: @escaping () -> Void) {
self._viewModel = StateObject(wrappedValue: viewModel)
self.backAction = backAction
self.rebakeAction = rebakeAction
Expand Down
Loading

0 comments on commit 5a328ab

Please sign in to comment.