Skip to content

Commit

Permalink
✨[feat]: 1.0.2 배포전 수정
Browse files Browse the repository at this point in the history
* 명언  취향 수정시 명언  변경되게 수정
  • Loading branch information
Roy-wonji committed Dec 14, 2023
1 parent 70faa52 commit 279052e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public struct CoreView: View {
@Binding var isFistUserPOPUP: Bool
@StateObject var authViewModel: AuthorizationViewModel
@StateObject var viewModel: CommonViewViewModel

@StateObject var homeViewModel: HomeViewViewModel = HomeViewViewModel()

public init(
viewModel: CommonViewViewModel,
Expand Down Expand Up @@ -107,7 +107,29 @@ public struct CoreView: View {
backAction: {
appState.isGoToProfileView = false
},
authViewModel: authViewModel)
authViewModel: authViewModel, cardChange: {
viewModel.cards = []

DispatchQueue.main.async {
homeViewModel.randomQuoteRequest(userID: authViewModel.userid ) { model in
for quoteContent in model.data?.content ?? [] {
let hashTags = viewModel.getHashtags(post: quoteContent)
self.homeViewModel.selecteLikeYn = quoteContent.likeID != nil
let card = CardInfomation(qouteId: quoteContent.quoteID ?? .zero,
hashtags: hashTags, image: "",
title: quoteContent.content ?? "",
sources: quoteContent.author ?? "",
isBookrmark: quoteContent.likeID != nil,
likeId: quoteContent.likeID
)
if !viewModel.cards.contains(card) {
viewModel.cards.append(card)
}
}
}
}

})
.environmentObject(sheetManager)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class HomeViewViewModel: ObservableObject {
@State var isOn: [Bool] = []
@Published public var selecteLikeYn: Bool = false
@Published public var currentPage = 0
// @Published public var currentPage = 0
@Published public var homeUserPrefModel: UserPrefModel?
public var homeUserPrefCancellable: AnyCancellable?

Expand All @@ -48,7 +49,7 @@ public class HomeViewViewModel: ObservableObject {
}

let provider = MoyaProvider<HomeService>(plugins: [MoyaLoggingPlugin()])
homeRandomQuoteCancellable = provider.requestWithProgressPublisher(.homeRandomQuote(page: currentPage, sizePerPage: 100, userId: (((userID?.isEmpty) == nil) ? "" : userID) ?? ""))
homeRandomQuoteCancellable = provider.requestWithProgressPublisher(.homeRandomQuote(page: 0, sizePerPage: 200, userId: (((userID?.isEmpty) == nil) ? "" : userID) ?? ""))
.compactMap { $0.response?.data }
.receive(on: DispatchQueue.main)
.decode(type: HomeRandomQuoteModel.self, decoder: JSONDecoder())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ public struct ProfileView: View {
@EnvironmentObject var sheetManager: SheetManager

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

public init(
viewModel: CommonViewViewModel,
appState: AppState,
backAction: @escaping () -> Void,
authViewModel: AuthorizationViewModel
authViewModel: AuthorizationViewModel,
cardChange: @escaping() -> Void

) {
self._appState = StateObject(wrappedValue: appState)
self._viewModel = StateObject(wrappedValue: viewModel)
self.backAction = backAction
self._authViewModel = StateObject(wrappedValue: authViewModel)
self.cardChange = cardChange
}


Expand Down Expand Up @@ -66,7 +69,7 @@ public struct ProfileView: View {
Rectangle()
.foregroundColor(sheetManager.isPopup ? Color.basicBlackDimmed : .clear)
}
.profileModal(with: sheetManager, viewModel: viewModel)
.profileModal(with: sheetManager, viewModel: viewModel, cardChange: cardChange)
.ignoresSafeArea()
.navigationBarBackButtonHidden()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public struct ProfileModalView: View {


let didClose: () -> Void
var cardChange: () -> Void

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) {
public init(viewModel: CommonViewViewModel, config: SheetManager.Config, isPopup: Bool, defaultYoffset: CGFloat, didClose: @escaping () -> Void, cardChange: @escaping () -> Void) {
self._viewModel = StateObject(wrappedValue: viewModel)
self.config = config
self.isPopup = isPopup
self.didClose = didClose
self.cardChange = cardChange
self.defaultYoffset = defaultYoffset
}

Expand Down Expand Up @@ -231,6 +233,7 @@ private extension ProfileModalView {

Task {
await profileViewModel.profileUserPrefEditPUT(userPrefId: profileViewModel.userPrefId, flavors: flavorStringArray, sources: sourceStringArray) {
cardChange()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ struct ProfileModalViewModifier: ViewModifier {
@ObservedObject var sheetManager: SheetManager

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

// 커스텀 모달 y offset
let defaultYoffset: CGFloat = 30

public init(viewModel: CommonViewViewModel, sheetManager: SheetManager) {
public init(viewModel: CommonViewViewModel, sheetManager: SheetManager, cardChange: @escaping() -> Void) {
self._viewModel = StateObject(wrappedValue: viewModel)
self._sheetManager = ObservedObject(wrappedValue: sheetManager)
self.backAction = sheetManager.dismiss
self.cardChange = cardChange
}

func body(content: Content) -> some View {
Expand All @@ -37,18 +39,23 @@ struct ProfileModalViewModifier: ViewModifier {
defaultYoffset: defaultYoffset)
{
withAnimation(.spring()) {
// viewModel.cards = []
sheetManager.dismiss()
viewModel.offsetY = defaultYoffset
sheetManager.isPopup = false
}
} cardChange: {
DispatchQueue.main.asyncAfter(deadline: .now() + 1){
cardChange()
}
}
}
}
}
}

extension View {
public func profileModal(with sheetManager: SheetManager, viewModel: CommonViewViewModel) -> some View {
self.modifier(ProfileModalViewModifier(viewModel: viewModel, sheetManager: sheetManager))
public func profileModal(with sheetManager: SheetManager, viewModel: CommonViewViewModel, cardChange: @escaping() -> Void) -> some View {
self.modifier(ProfileModalViewModifier(viewModel: viewModel, sheetManager: sheetManager, cardChange: cardChange))
}
}

0 comments on commit 279052e

Please sign in to comment.