Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into Dev
  • Loading branch information
Roy-wonji committed Dec 13, 2023
2 parents 4b5b5f1 + dac3d4c commit 1559417
Show file tree
Hide file tree
Showing 31 changed files with 154 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public extension Project {
product: Product,
organizationName: String = "Wonji Suh",
packages: [Package] = [],
deploymentTarget: DeploymentTarget? = .iOS(targetVersion: "16.4", devices: [.iphone]),
deploymentTarget: DeploymentTarget? = .iOS(targetVersion: "16.0", devices: [.iphone]),
setting: Settings,
dependencies: [TargetDependency] = [],
sources: SourceFilesList = ["Sources/**"],
Expand Down Expand Up @@ -244,14 +244,14 @@ public extension Project {

}

public static func makeFramsWorkModule(
public static func makeFrameWorkModule(
name: String,
bundleId: String,
platform: Platform = .iOS,
product: Product,
organizationName: String = "Wonji Suh",
packages: [Package] = [],
deploymentTarget: DeploymentTarget? = .iOS(targetVersion: "16.4", devices: [.iphone]),
deploymentTarget: DeploymentTarget? = .iOS(targetVersion: "16.0", devices: [.iphone]),
setting: Settings,
dependencies: [TargetDependency] = [],
sources: SourceFilesList = ["Sources/**"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import DesignSystem
import Model
import API

@available(iOS 16.4, *)
@main
struct PingPongProjectApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Core/Authorization/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Authorization",
bundleId: .appBundleID(name: ".Authorization"),
product: .staticFramework,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class AuthorizationViewModel: ObservableObject {
var searchUserIdCancellable: AnyCancellable?

var loginEmailCancellable: AnyCancellable?
@AppStorage("userId") public var userid: Int = .zero
@AppStorage("userId") public var userid: String = ""
@Published public var userNickName: String = ""
@Published public var userRmk: String = ""

Expand All @@ -69,7 +69,7 @@ public class AuthorizationViewModel: ObservableObject {
public init() {
self.userSession = Auth.auth().currentUser
uid = UserDefaults.standard.string(forKey: "Uid") ?? ""
userid = UserDefaults.standard.integer(forKey: "userId")
userid = UserDefaults.standard.string(forKey: "userId") ?? ""
userUid = UserDefaults.standard.string(forKey: "userUid") ?? ""
randomAuthNickName = UserDefaults.standard.string(forKey: "randomNickName") ?? ""

Expand Down Expand Up @@ -273,13 +273,13 @@ public class AuthorizationViewModel: ObservableObject {
}, receiveValue: { [weak self] model in
if model.status == NetworkCode.success.status {
self?.signupToViewModel(model)
self?.userid = model.data?.id ?? .zero
self?.userid = String(model.data?.id ?? .zero)
self?.userUid = model.data?.uid ?? ""
print("회원가입 성공", model)
signupSuccessAction()
} else {
self?.signupToViewModel(model)
self?.userid = model.data?.id ?? .zero
self?.userid = String(model.data?.id ?? .zero)
print("회원가입 실패", model)
failSignUPAction()
}
Expand All @@ -291,7 +291,7 @@ public class AuthorizationViewModel: ObservableObject {
}

//MARK: - uid 로 회원정보 조회
public func searchUserIdRequest(uid: String) {
public func searchUserIdRequest(uid: String, failCompletion: @escaping () -> Void) {
if let cancellable = searchUserIdCancellable {
cancellable.cancel()
}
Expand All @@ -314,12 +314,11 @@ public class AuthorizationViewModel: ObservableObject {
print("아이디 조회 성공", model)
self?.userNickName = model.data?.nickname ?? ""
self?.userRmk = model.data?.rmk ?? ""
self?.userid = model.data?.id ?? .zero
self?.userid = String(model.data?.id ?? .zero)
} else {
self?.searchUserIdToViewModel(model)
print("아이디 조회 성공", model)
self?.userNickName = model.data?.nickname ?? ""
self?.userid = model.data?.id ?? .zero
print("아이디 조회 실패", model)
failCompletion()
}
})
}
Expand Down Expand Up @@ -349,16 +348,15 @@ public class AuthorizationViewModel: ObservableObject {
}, receiveValue: { [weak self] model in
if model.status == NetworkCode.success.status {
self?.signupToViewModel(model)
self?.userid = model.data?.id ?? .zero
self?.userid = String(model.data?.id ?? .zero)
self?.userUid = model.data?.uid ?? ""

print("로그인 성공", model)
succesCompletion(model)
} else {
self?.signupToViewModel(model)
self?.userid = model.data?.id ?? .zero
// self?.userid = String(model.data?.id ?? .zero)
print("로그인 실패", model)
succesCompletion(model)
failLoginCompletion()
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Core/Common/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Common",
bundleId: .appBundleID(name: ".Common"),
product: .staticFramework,
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Core/Domain/API/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "API",
bundleId: .appBundleID(name: ".API"),
product: .staticFramework,
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Core/Domain/Model/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Model",
bundleId: .appBundleID(name: ".Model"),
product: .staticFramework,
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Core/Domain/Service/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Service",
bundleId: .appBundleID(name: ".Service"),
product: .staticFramework,
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/DesignSystem/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "DesignSystem",
bundleId: .appBundleID(name: "DesignSystem"),
product: .staticFramework,
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Feature/Archive/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Archive",
bundleId: .appBundleID(name: "Archive"),
product: .staticFramework,
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Feature/Auth/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Auth",
bundleId: .appBundleID(name: "Auth"),
product: .staticFramework,
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Feature/Bake/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Bake",
bundleId: .appBundleID(name: "Bake"),
product: .staticFramework,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct FamousSayingBakeCardView: View {
self.viewModel.tmpChoicedTopping = nil
}
.task {
authViewModel.searchUserIdRequest(uid: "\(authViewModel.userid)")
authViewModel.searchUserIdRequest(uid: "\(authViewModel.userid)", failCompletion: {})
}
.onDisappear {
viewModel.tmpChoicedBread = nil
Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Feature/Core/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Core",
bundleId: .appBundleID(name: "Core"),
product: .staticFramework,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Model
import Home
import Profile

@available(iOS 16.4, *)
public struct CoreView: View {
@EnvironmentObject var sheetManager: SheetManager
@StateObject var appState: AppState = AppState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ public struct FamousSayingDetailView: View {

.onChange(of: viewModel.selectedCard.isBookrmark , perform: { newValue in
if viewModel.isLoginCheck {
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") {
for quoteContent in homeViewModel.homeRandomQuoteModel?.data?.content ?? [] {
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") { model in
for quoteContent in model.data?.content ?? [] {
let hashTags = viewModel.getHashtags(post: quoteContent)
viewModel.cards.append(CardInfomation(qouteId: quoteContent.quoteID ?? .zero, hashtags: hashTags, image: "", title: quoteContent.content ?? "", sources: quoteContent.author ?? "", isBookrmark: newValue, likeId: quoteContent.likeID))

Expand Down
2 changes: 1 addition & 1 deletion PingPong/Projects/Feature/Home/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MyPlugin


let localHelper = LocalHelper(name: "MyPlugin")
let project = Project.makeFramsWorkModule(
let project = Project.makeFrameWorkModule(
name: "Home",
bundleId: .appBundleID(name: "Home"),
product: .staticFramework,
Expand Down
111 changes: 97 additions & 14 deletions PingPong/Projects/Feature/Home/Sources/UI/View/HomeView/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,22 @@ public struct HomeView: View {
}
.navigationBarHidden(true)
.task {
await authViewModel.loginWithEmail(email: authViewModel.userEmail, succesCompletion: { model in
authViewModel.userNickName = model.data?.nickname ?? ""
authViewModel.userid = model.data?.id ?? .zero
}, failLoginCompletion: {})
authViewModel.searchUserIdRequest(uid: "\(authViewModel.userid)")
// Task {
// await authViewModel.loginWithEmail(email: authViewModel.userEmail, succesCompletion: { model in
// authViewModel.userNickName = model.data?.nickname ?? ""
// authViewModel.userid = String(model.data?.id ?? .zero)
// print("userid \(authViewModel.userid)")
// }, failLoginCompletion: {
// authViewModel.userid = ""
// })
// authViewModel.searchUserIdRequest(uid: "\(authViewModel.userid)", failCompletion: {
// authViewModel.userid = ""
// })
// }

}

.onAppear {
if !homeViewModel.isOn.isEmpty {
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") {
for quoteContent in homeViewModel.homeRandomQuoteModel?.data?.content ?? [] {
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") { model in
for quoteContent in model.data?.content ?? [] {
let hashTags = viewModel.getHashtags(post: quoteContent)
self.homeViewModel.isOn[quoteContent.quoteID ?? .zero].toggle()
self.homeViewModel.selecteLikeYn = quoteContent.likeID != nil
Expand All @@ -76,11 +80,47 @@ public struct HomeView: View {
}


}
}
} else if authViewModel.userid == authViewModel.userid {
viewModel.cards = []
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)
}
}
}
} else if authViewModel.userid == "" || authViewModel.userid == "0" || authViewModel.userid != authViewModel.userid {
viewModel.cards = []
homeViewModel.randomQuoteRequest(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)
}
}
}
} else {
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") {
for quoteContent in homeViewModel.homeRandomQuoteModel?.data?.content ?? [] {
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,
Expand All @@ -96,13 +136,56 @@ public struct HomeView: View {
}
}
}

}

.onAppear {
// if !homeViewModel.isOn.isEmpty {
// homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") { model in
// for quoteContent in model.data?.content ?? [] {
// let hashTags = viewModel.getHashtags(post: quoteContent)
// self.homeViewModel.isOn[quoteContent.quoteID ?? .zero].toggle()
// 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)
// }
//
//
// }
// }
// } else {
// 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)
// }
// }
// }
// }
}
.onChange(of: viewModel.selectedCard.isBookrmark , perform: { newValue in
if viewModel.isLoginCheck {
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") {
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") { model in
// 종아요일 때

for quoteContent in homeViewModel.homeRandomQuoteModel?.data?.content ?? [] {
for quoteContent in model.data?.content ?? [] {
let hashTags = viewModel.getHashtags(post: quoteContent)
viewModel.cards.append(CardInfomation(qouteId: quoteContent.quoteID ?? .zero, hashtags: hashTags, image: "", title: quoteContent.content ?? "", sources: quoteContent.author ?? "", isBookrmark: newValue, likeId: quoteContent.likeID))

Expand Down
Loading

0 comments on commit 1559417

Please sign in to comment.