Skip to content

Commit

Permalink
Merge pull request #192 from Nexters/release/1.0.1
Browse files Browse the repository at this point in the history
v1.0.1 Release -> Main
  • Loading branch information
leemhyungyu authored Aug 23, 2024
2 parents 7dc05ef + e28cc4f commit 43a24e3
Show file tree
Hide file tree
Showing 33 changed files with 358 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public extension ModulePath {

public extension ModulePath {
enum Domain: String, CaseIterable {
case User
case Report
case WebView
case Bottle
Expand Down
9 changes: 8 additions & 1 deletion Projects/Domain/Auth/Interface/Sources/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public struct AuthClient {
private let _revokeAppleLogin: () async throws -> Void
private let fetchAppleClientSecret: () async throws -> String
private let registerUserProfile: (String) async throws -> Void
private let _removeAllToken: () -> Void

public init(
signInWithKakao: @escaping () async throws -> UserInfo,
Expand All @@ -29,7 +30,8 @@ public struct AuthClient {
refreshAppleToken: @escaping () async throws -> AppleToken,
revokeAppleLogin: @escaping () async throws -> Void,
fetchAppleClientSecret: @escaping () async throws -> String,
registerUserProfile: @escaping (String) async throws -> Void
registerUserProfile: @escaping (String) async throws -> Void,
removeAllToken: @escaping () -> Void
) {
self.signInWithKakao = signInWithKakao
self.signInWithApple = signInWithApple
Expand All @@ -41,6 +43,7 @@ public struct AuthClient {
self._revokeAppleLogin = revokeAppleLogin
self.fetchAppleClientSecret = fetchAppleClientSecret
self.registerUserProfile = registerUserProfile
self._removeAllToken = removeAllToken
}

public func signInWithKakao() async throws -> UserInfo {
Expand Down Expand Up @@ -81,5 +84,9 @@ public struct AuthClient {
public func registerUserProfile(userName: String) async throws {
try await registerUserProfile(userName)
}

public func removeAllToken() {
_removeAllToken()
}
}

3 changes: 3 additions & 0 deletions Projects/Domain/Auth/Sources/AuthClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ extension AuthClient: DependencyKey {
registerUserProfile: { userName in
let requestDTO = ProfileRequestDTO(name: userName)
try await networkManager.reqeust(api: .apiType(AuthAPI.profile(requestDTO)))
},
removeAllToken: {
LocalAuthDataSourceImpl.removeAllToken()
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ struct LocalAuthDataSourceImpl: LocalAuthDataSource {
static func checkTokeinIsExist() -> Bool {
return !KeyChainTokenStore.shared.load(property: .accessToken).isEmpty
}

static func removeAllToken() {
KeyChainTokenStore.shared.deleteAll()
}
}
7 changes: 7 additions & 0 deletions Projects/Domain/Bottle/Interface/Sources/API/BottleAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum BottleAPI {
bottleID: Int,
registerLetterAnswerRequestDTO: RegisterLetterAnswerRequestDTO
)
case readBottle(bottleID: Int)
case imageShare(
bottleID: Int,
imageShareRequestDTO: BottleImageShareRequestDTO
Expand All @@ -37,6 +38,8 @@ extension BottleAPI: BaseTargetType {
return "api/v1/bottles/ping-pong"
case let .fetchBottlePingPong(bottleID):
return "api/v1/bottles/ping-pong/\(bottleID)"
case let .readBottle(bottleID):
return "api/v1/bottles/ping-pong/\(bottleID)/read"
case let .registerLetterAnswer(bottleID, _):
return "api/v1/bottles/ping-pong/\(bottleID)/letters"
case let .imageShare(bottleID, _):
Expand All @@ -56,6 +59,8 @@ extension BottleAPI: BaseTargetType {
return .get
case .fetchBottlePingPong:
return .get
case .readBottle:
return .post
case .registerLetterAnswer:
return .post
case .imageShare:
Expand All @@ -75,6 +80,8 @@ extension BottleAPI: BaseTargetType {
return .requestPlain
case .fetchBottlePingPong:
return .requestPlain
case .readBottle:
return .requestPlain
case let .registerLetterAnswer(_, registerLetterAnswerRequestDTO):
return .requestJSONEncodable(registerLetterAnswerRequestDTO)
case let .imageShare(_, imageShareRequestDTO):
Expand Down
7 changes: 7 additions & 0 deletions Projects/Domain/Bottle/Interface/Sources/BottleClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public struct BottleClient {
private let fetchUserBottleInfo: () async throws -> UserBottleInfo
private let fetchBottleStorageList: () async throws -> BottleStorageList
private let fetchBottlePingPong: (_ bottleID: Int) async throws -> BottlePingPong
private let readBottle: (_ bottleID: Int) async throws -> Void
private let registerLetterAnswer: (_ bottleID: Int, _ order: Int, _ answer: String) async throws -> Void
private let shareImage: (_ bottleID: Int, _ willShare: Bool) async throws -> Void
private let finalSelect: (_ bottleID: Int, _ willMatch: Bool) async throws -> Void
Expand All @@ -21,6 +22,7 @@ public struct BottleClient {
fetchUserBottleInfo: @escaping () async throws -> UserBottleInfo,
fetchBottleStorageList: @escaping () async throws -> BottleStorageList,
fetchBottlePingPong: @escaping (_ bottleID: Int) async throws -> BottlePingPong,
readBottle: @escaping (_ bottleID: Int) async throws -> Void,
registerLetterAnswer: @escaping (_ bottleID: Int, _ order: Int, _ answer: String) async throws -> Void,
shareImage: @escaping (_ bottleID: Int, _ willShare: Bool) async throws -> Void,
finalSelect: @escaping (_ bottleID: Int, _ willMatch: Bool) async throws -> Void,
Expand All @@ -29,6 +31,7 @@ public struct BottleClient {
self.fetchUserBottleInfo = fetchUserBottleInfo
self.fetchBottleStorageList = fetchBottleStorageList
self.fetchBottlePingPong = fetchBottlePingPong
self.readBottle = readBottle
self.registerLetterAnswer = registerLetterAnswer
self.shareImage = shareImage
self.finalSelect = finalSelect
Expand All @@ -47,6 +50,10 @@ public struct BottleClient {
try await fetchBottlePingPong(bottleID)
}

public func readBottle(bottleID: Int) async throws {
try await readBottle(bottleID)
}

public func registerLetterAnswer(bottleID: Int, order: Int, answer: String) async throws {
try await registerLetterAnswer(bottleID, order, answer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct BottleStorageList: Decodable {
public struct BottleStorageItem: Decodable, Equatable {
public let age: Int?
public let id: Int
public let isRead: Bool?
public let isRead: Bool
public let keyword: [String]
public let mbti: String
public let userImageUrl: String
Expand All @@ -31,7 +31,7 @@ public struct BottleStorageItem: Decodable, Equatable {
public init(
age: Int?,
id: Int,
isRead: Bool?,
isRead: Bool,
keyword: [String],
mbti: String,
userImageUrl: String,
Expand Down
3 changes: 3 additions & 0 deletions Projects/Domain/Bottle/Sources/BottleClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ extension BottleClient: DependencyKey {
).toDomain()
return bottlePingPong
},
readBottle: { id in
try await networkManager.reqeust(api: .apiType(BottleAPI.readBottle(bottleID: id)))
},
registerLetterAnswer: { bottleID, order, answer in
try await networkManager.reqeust(api: .apiType(BottleAPI.registerLetterAnswer(
bottleID: bottleID,
Expand Down
43 changes: 43 additions & 0 deletions Projects/Domain/User/Interface/Sources/UserClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// UserClient.swift
// DomainUserInterface
//
// Created by 임현규 on 8/22/24.
//

import Foundation

public struct UserClient {
private let _isLoggedIn: () -> Bool
private let _isAppDeleted: () -> Bool
private let updateLoginState: (Bool) -> Void
private let updateDeleteState: (Bool) -> Void

public init(
isLoggedIn: @escaping () -> Bool,
isAppDeleted: @escaping () -> Bool,
updateLoginState: @escaping (Bool) -> Void,
updateDeleteState: @escaping (Bool) -> Void
) {
self._isLoggedIn = isLoggedIn
self._isAppDeleted = isAppDeleted
self.updateLoginState = updateLoginState
self.updateDeleteState = updateDeleteState
}

public func isLoggedIn() -> Bool {
_isLoggedIn()
}

public func isAppDeleted() -> Bool {
_isAppDeleted()
}

public func updateLoginState(isLoggedIn: Bool) {
updateLoginState(isLoggedIn)
}

public func updateDeleteState(isDelete: Bool) {
updateDeleteState(isDelete)
}
}
42 changes: 42 additions & 0 deletions Projects/Domain/User/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.makeModule(
name: ModulePath.Domain.name+ModulePath.Domain.User.rawValue,
targets: [
.domain(
interface: .User,
factory: .init(dependencies: [
.core
])
),
.domain(
implements: .User,
factory: .init(
dependencies: [
.domain(interface: .User)
]
)
),

.domain(
testing: .User,
factory: .init(
dependencies: [
.domain(interface: .User)
]
)
),
.domain(
tests: .User,
factory: .init(
dependencies: [
.domain(testing: .User),
.domain(implements: .User)
]
)
),

]
)
45 changes: 45 additions & 0 deletions Projects/Domain/User/Sources/UserClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// UserClient.swift
// DomainUser
//
// Created by 임현규 on 8/22/24.
//

import Foundation

import DomainUserInterface

import CoreKeyChainStore

import ComposableArchitecture

extension UserClient: DependencyKey {
static public var liveValue: UserClient = .live()

static func live() -> UserClient {
return .init(
isLoggedIn: {
return UserDefaults.standard.bool(forKey: "loginState")
},

isAppDeleted: {
return !UserDefaults.standard.bool(forKey: "deleteState")
},

updateLoginState: { isLoggedIn in
UserDefaults.standard.set(isLoggedIn, forKey: "loginState")
},

updateDeleteState: { isDelete in
UserDefaults.standard.set(!isDelete, forKey: "deleteState")
}
)
}
}

extension DependencyValues {
public var userClient: UserClient {
get { self[UserClient.self] }
set { self[UserClient.self] = newValue }
}
}
1 change: 1 addition & 0 deletions Projects/Domain/User/Testing/Sources/UserTesting.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This is for Tuist
11 changes: 11 additions & 0 deletions Projects/Domain/User/Tests/Sources/UserTest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import XCTest

final class UserTests: XCTestCase {
override func setUpWithError() throws {}

override func tearDownWithError() throws {}

func testExample() {
XCTAssertEqual(1, 1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ extension BottleStorageFeature {
state.doneBottlsList = bottleStorageList.doneBottles
return .none

case let .bottleStorageItemDidTapped(bottleID, userName):
state.path.append(.pingPongDetail(.init(bottleID: bottleID, userName: userName)))
case let .bottleStorageItemDidTapped(bottleID, isRead, userName):
state.path.append(.pingPongDetail(.init(
bottleID: bottleID,
isRead: isRead,
userName: userName
)))
return .none

case let .bottleActiveStateTabButtonTapped(activeState):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public struct BottleStorageFeature {

// 보틀 리스트
case bottleStorageListFetched(BottleStorageList)
case bottleStorageItemDidTapped(bottleID: Int, userName: String)
case bottleStorageItemDidTapped(
bottleID: Int,
isRead: Bool,
userName: String
)
case selectedTabDidChanged(selectedTab: TabType)
case delegate(Delegate)
// ETC.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ private extension BottleStorageView {
mbti: bottle.mbti,
keywords: bottle.keyword,
imageURL: bottle.userImageUrl,
isRead: bottle.isRead ?? false
isRead: bottle.isRead
)
.asButton {
store.send(.bottleStorageItemDidTapped(bottleID: bottle.id, userName: bottle.userName ?? ""))
store.send(.bottleStorageItemDidTapped(
bottleID: bottle.id,
isRead: bottle.isRead,
userName: bottle.userName ?? ""
))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI

import SharedDesignSystem

public struct PhotoSharePingPongView: View {
Expand Down Expand Up @@ -139,20 +140,17 @@ private extension PhotoSharePingPongView {

@ViewBuilder
var peerProfileImage: some View {
if let peerProfileImageURL = photoShareState.peerProfileImageURL {
GeometryReader { geo in
RemoteImageView(
imageURL: peerProfileImageURL,
downsamplingWidth: 150,
downsamplingHeight: 150
)
.cornerRadius(.md, corenrs: [.topRight, .bottomLeft, .bottomRight])
.frame(height: geo.size.width)
}
.aspectRatio(1, contentMode: .fit)
} else {
EmptyView()
GeometryReader { geo in
RemoteImageView(
imageURL: photoShareState.peerProfileImageURL,
downsamplingWidth: 150,
downsamplingHeight: 150
)
.cornerRadius(.md, corenrs: [.topRight, .bottomLeft, .bottomRight])
.frame(height: geo.size.width)
}
.aspectRatio(1, contentMode: .fit)
.preventScreenshot()
}

@ViewBuilder
Expand All @@ -167,6 +165,7 @@ private extension PhotoSharePingPongView {
)
.cornerRadius(.md, corenrs: [.topRight, .topLeft, .bottomLeft])
.frame(height: geo.size.width)
.preventScreenshot()
}
.aspectRatio(1, contentMode: .fit)
} else {
Expand Down
Loading

0 comments on commit 43a24e3

Please sign in to comment.