Skip to content

Commit

Permalink
✨[feat]: 프로필 취향설정
Browse files Browse the repository at this point in the history
  • Loading branch information
Byeonjinha committed Nov 22, 2023
1 parent 225a173 commit db879a1
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ public class CommonViewViewModel: ObservableObject {
@Published public var goToMainView: Bool = false
@Published public var customTabs: [CustomTab] = []

@Published var selectedFavorite: [Favorite] = []
@Published var selectedCharacter: [String] = []
@Published public var selectedSource: [Source] = [] {
didSet {
print(selectedSource)
}
}
@Published public var selectedCharacter: [Flavor] = [] {
didSet {
print(selectedCharacter)
}
}

//MARK: 모달 관련
@Published public var offsetY: CGFloat = 30
Expand Down Expand Up @@ -357,18 +365,19 @@ public class CommonViewViewModel: ObservableObject {
}
}

func appendAndPopFavorite(favorite: Favorite) {
guard self.selectedFavorite.count < 2 || self.selectedFavorite.contains(favorite) else { return }
public func appendAndPopFavorite(favorite: Source) {
if selectedSource.count > 2 { selectedSource = [] }
guard self.selectedSource.count < 2 || self.selectedSource.contains(favorite) else { return }

if self.selectedFavorite.contains(favorite) {
guard let index = self.selectedFavorite.firstIndex(of: favorite) else { return }
self.selectedFavorite.remove(at: index)
if self.selectedSource.contains(favorite) {
guard let index = self.selectedSource.firstIndex(of: favorite) else { return }
self.selectedSource.remove(at: index)
} else {
self.selectedFavorite.append(favorite)
self.selectedSource.append(favorite)
}
}

func appendAndPopCharacter(character: String, index: Int) {
public func appendAndPopCharacter(character: Flavor, index: Int) {
guard self.selectedCharacter.count < 2 || self.selectedCharacter.contains(character) else { return }

if self.selectedCharacter.contains(character) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,3 @@
// Created by 서원지 on 2023/09/03.
// Copyright © 2023 Wonji Suh. All rights reserved.
//

import Foundation

public enum Favorite: String {
case anime
case book
case celeb
case film
case greatman
case OTHER
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Profile
struct ProfileApp: App {
var body: some Scene {
WindowGroup {
ProfileView(backProfileViewAction: {})
// ProfileView(backProfileViewAction: {})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public struct ModalView: View {

let didClose: () -> Void

let height:CGFloat = UIScreen.screenHeight * 0.7
let height:CGFloat = UIScreen.screenHeight == 667 ? UIScreen.screenHeight * 0.8 : UIScreen.screenHeight * 0.7


public init(viewModel: CommonViewViewModel, config: SheetManager.Config, isPopup: Bool, defaultYoffset: CGFloat, didClose: @escaping () -> Void) {
self._viewModel = StateObject(wrappedValue: viewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public struct SelectCategoryView: View {

ForEach(sortedCommCds, id: \.self) { item in
VStack {
let favoirte = Favorite(rawValue: item.commCD)
let favoirte = Source(rawValue: item.commCD)

if viewModel.selectedFavorite.contains(Favorite(rawValue: (favoirte ?? .anime).rawValue) ?? .anime){
if viewModel.selectedFavorite.contains(Source(rawValue: (favoirte ?? .anime).rawValue) ?? .anime){
Circle()
.frame(width: 96, height: 96)
.foregroundColor(.basicGray3)
Expand All @@ -143,8 +143,8 @@ public struct SelectCategoryView: View {
}
.onTapGesture {

let favoirte = Favorite(rawValue: item.commCD)
if let favorite = favoirte {
let source = Source(rawValue: item.commCD)
if let favorite = source {
self.viewModel.appendAndPopFavorite(favorite: favorite)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ public struct SelectCharacterView: View {
}
)
.onTapGesture {
self.viewModel.appendAndPopCharacter(character: viewModel.flavorArray.options[flavorIndex].korean, index: flavorIndex)
guard let flavor = Flavor(rawValue: viewModel.flavorArray.options[flavorIndex].korean) else { return }
self.viewModel.appendAndPopCharacter(character: flavor, index: flavorIndex)
self.viewModel.selectedFavoriteFlavor = commCDItem.commCD
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ public class OnBoardingViewModel: ObservableObject {
@Published var selectJobCode: Int = .zero
@Published var selectedFavoriteCategory: String = ""
@Published var selectedFavoriteFlavor: String = ""
@Published var selectedFavorite: [Favorite] = []
@Published var selectedCharacter: [String] = []
@Published var selectedFavorite: [Source] = []
@Published var selectedCharacter: [Flavor] = []
@Published public var isSignUP: Bool = false
@AppStorage("completdSignUP") public var completdSignUP: Bool = false
@Published public var alreadySignUP: Bool = false
@AppStorage("isFirstUserPOPUP") public var isFirstUserPOPUP: Bool = false

let unicodeArray: [Character] = CheckRegister.generateUnicodeArray()

@Published var flavorArray: SearchViewButtonInfo = SearchViewButtonInfo(title: .flavor, options: [
@Published var flavorArray: SearchViewButtonInfo = SearchViewButtonInfo(title: .flavor, options: [
SearchOption(korean: "달콤한 맛", english: "sweet", iconImageName: "🍰", detail: "지친 삶의 위로, 기쁨을 주는 명언"),
SearchOption(korean: "짭잘한 맛", english: "salty", iconImageName: "😭", detail: "울컥하게 만드는 감동적인 명언"),
SearchOption(korean: "매콤한 맛", english: "spicy", iconImageName: "🔥", detail: "따끔한 조언의 자극적인 명언"),
Expand Down Expand Up @@ -198,7 +197,7 @@ public class OnBoardingViewModel: ObservableObject {


//MARK: favorite 관련
func appendAndPopFavorite(favorite: Favorite) {
func appendAndPopFavorite(favorite: Source) {
guard self.selectedFavorite.count < 2 || self.selectedFavorite.contains(favorite) else { return }

if self.selectedFavorite.contains(favorite) {
Expand Down Expand Up @@ -230,7 +229,7 @@ public class OnBoardingViewModel: ObservableObject {
}

//MARK: favorite character 관련
func appendAndPopCharacter(character: String, index: Int) {
func appendAndPopCharacter(character: Flavor, index: Int) {
guard self.selectedCharacter.count < 2 || self.selectedCharacter.contains(character) else { return }

if self.selectedCharacter.contains(character) {
Expand Down
Loading

0 comments on commit db879a1

Please sign in to comment.