Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat#136] 캐릭터 이미지 추가 #139

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
public enum TokenProperties: String {
case accessToken = "ACCESS-TOKEN"
case expiresAt = "ACCESS-EXPIRES-AT"
case userId = "USERID"
case loginType = "LOGIN-TYPE"
case oauth2Id = "OAUTH2ID"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public struct SignInWithAppleResponseDTO: Decodable, Equatable {
public func toDomain() -> Token {
return Token(accessToken: accessToken,
expiresAt: expiresAt,
userId: nil,
loginType: loginType,
oauth2Id: oauth2Id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,33 @@ import Foundation
public struct SignUpResponseDTO: Codable {
let accessToken: String?
let expiresAt: String?
let userId: String?

enum CodingKeys: String, CodingKey {
case accessToken
case expiresAt = "expiredTime"
case userId
}

public init(accessToken: String?, expiresAt: String?) {
public init(accessToken: String?,
expiresAt: String?,
userId: String?) {
self.accessToken = accessToken
self.expiresAt = expiresAt
self.userId = userId
}

public func toDomain() -> Token {
return Token(accessToken: accessToken,
expiresAt: expiresAt,
userId: userId,
loginType: nil,
oauth2Id: nil)
}
}

public extension SignUpResponseDTO {
static let mock = SignUpResponseDTO(accessToken: "MockAccessToken", expiresAt: "2023-06-29T10:59:14.131+00:00")
static let mock = SignUpResponseDTO(accessToken: "MockAccessToken",
expiresAt: "2023-06-29T10:59:14.131+00:00",
userId: "MockUserId")
}
68 changes: 68 additions & 0 deletions Projects/Domain/Auth/Interface/Sources/Models/CharacterType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import Foundation
import Shared
import SwiftUI

public enum CharacterType: String, CaseIterable {
case a = "A"
Expand All @@ -20,4 +22,70 @@ public enum CharacterType: String, CaseIterable {
case j = "J"
case k = "K"
case l = "L"

public func getCharacterImage(body: Bool = true, head: Bool = false) -> Image {
switch self {
case .a:
if body {
return PumpingImages.bodyA.swiftUIImage
}
return PumpingImages.headA.swiftUIImage
case .b:
if body {
return PumpingImages.bodyB.swiftUIImage
}
return PumpingImages.headB.swiftUIImage
case .c:
if body {
return PumpingImages.bodyC.swiftUIImage
}
return PumpingImages.headC.swiftUIImage
case .d:
if body {
return PumpingImages.bodyD.swiftUIImage
}
return PumpingImages.headD.swiftUIImage
case .e:
if body {
return PumpingImages.bodyE.swiftUIImage
}
return PumpingImages.headE.swiftUIImage
case .f:
if body {
return PumpingImages.bodyF.swiftUIImage
}
return PumpingImages.headF.swiftUIImage
case .g:
if body {
return PumpingImages.bodyG.swiftUIImage
}
return PumpingImages.headG.swiftUIImage
case .h:
if body {
return PumpingImages.bodyH.swiftUIImage
}
return PumpingImages.headH.swiftUIImage
case .i:
if body {
return PumpingImages.bodyI.swiftUIImage
}
return PumpingImages.headI.swiftUIImage
case .j:
if body {
return PumpingImages.bodyJ.swiftUIImage
}
return PumpingImages.headJ.swiftUIImage
case .k:
if body {
return PumpingImages.bodyK.swiftUIImage
}
return PumpingImages.headK.swiftUIImage
case .l:
if body {
return PumpingImages.bodyL.swiftUIImage
}
return PumpingImages.headL.swiftUIImage
}
}

}
9 changes: 8 additions & 1 deletion Projects/Domain/Auth/Interface/Sources/Models/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ import Foundation
public struct Token: Equatable {
public let accessToken: String?
public let expiresAt: String?
public let userId: String?
public let loginType: String?
public let oauth2Id: String?

public init(accessToken: String?,
expiresAt: String?,
userId: String?,
loginType: String?,
oauth2Id: String?) {
self.accessToken = accessToken
self.expiresAt = expiresAt
self.userId = userId
self.loginType = loginType
self.oauth2Id = oauth2Id
}
}

public extension Token {
static let mock = Self(accessToken: "mockAccessToken", expiresAt: "2023-10-23", loginType: "Apple", oauth2Id: "MockoAuth2Id")
static let mock = Self(accessToken: "mockAccessToken",
expiresAt: "2023-10-23",
userId: "djkfjldsf",
loginType: "Apple",
oauth2Id: "MockoAuth2Id")
}
5 changes: 5 additions & 0 deletions Projects/Domain/Auth/Sources/LocalAuthStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class LocalAuthStore : LocalAuthStoreInterface {
return Token(
accessToken: KeyChainStore.shared.load(property: .accessToken),
expiresAt: KeyChainStore.shared.load(property: .expiresAt),
userId: KeyChainStore.shared.load(property: .userId),
loginType: KeyChainStore.shared.load(property: .loginType),
oauth2Id: KeyChainStore.shared.load(property: .oauth2Id)
)
Expand All @@ -29,6 +30,10 @@ public final class LocalAuthStore : LocalAuthStoreInterface {
KeyChainStore.shared.save(property: .expiresAt, value: expiresAt)
}

if let userId = token.userId {
KeyChainStore.shared.save(property: .userId, value: userId)
}

if let loginType = token.loginType {
KeyChainStore.shared.save(property: .loginType, value: loginType)
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/Domain/Crew/Interface/Sources/CrewEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CoreNetworkInterface
import CoreKeyChainStore

public struct CrewEndpoint {
public static func fetchCrew() -> Endpoint<[CrewInfoResponseDTO]> {
public static func fetchCrew() -> Endpoint<CrewInfoResponseDTO> {
let accessToken = KeyChainStore.shared.load(property: .accessToken)

return Endpoint(path: "crews",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,39 @@ import Foundation

public struct CrewInfoResponseDTO: Codable, Equatable {

public let crews: [CrewInfoResponseItemDTO]

public func toDomain() -> [CrewInfo] {
return crews.map{
CrewInfo(crewName: $0.crewName, crewId: $0.crewId, code: $0.code, createDate: $0.createDate)
}
}
}

public struct CrewInfoResponseItemDTO: Codable, Equatable {
public let crewName: String
public let crewId: String
public let code: String
public let createDate: String

public init(crewName: String,
crewId: String,
code: String,
createDate: String) {
self.crewName = crewName
self.crewId = crewId
self.code = code
self.createDate = createDate
}

public func toDomain() -> CrewInfo {
return CrewInfo(crewName: crewName, crewId: crewId, createDate: createDate)
}
}

public extension CrewInfoResponseItemDTO {
static let mock = CrewInfoResponseItemDTO(crewName: "너만 오면 고",
crewId: "fikemjwmn",
code: "dd",
createDate: "")
}

public extension CrewInfoResponseDTO {
static let mock = CrewInfoResponseDTO(crewName: "너만 오면 고", crewId: "fikemjwmn", createDate: "")
static let mock = CrewInfoResponseDTO(crews: [CrewInfoResponseItemDTO.mock])
}
3 changes: 3 additions & 0 deletions Projects/Domain/Crew/Interface/Sources/Models/CrewInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import Foundation
public struct CrewInfo: Equatable {
public let crewName: String
public let crewId: String
public let code: String
public let createDate: String

public init(crewName: String,
crewId: String,
code: String,
createDate: String) {
self.crewName = crewName
self.crewId = crewId
self.code = code
self.createDate = createDate
}
}
7 changes: 2 additions & 5 deletions Projects/Domain/Crew/Sources/CrewClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ extension CrewClient: DependencyKey {
public static let liveValue = CrewClient(
fetchCrew: {
let apiEndpoint = CrewEndpoint.fetchCrew()
let responseDTOList = try await NetworkProvider.shared.sendRequest(apiEndpoint)
let responseList = responseDTOList.map {
CrewInfo(crewName: $0.crewName, crewId: $0.crewId, createDate: $0.createDate)
}
let response = try await NetworkProvider.shared.sendRequest(apiEndpoint).toDomain()

return responseList
return response
},
makeCrew: { crewName, goalCount in
let makeCrewRequestDTO = MakeCrewRequestDTO(crewName: crewName, goalCount: goalCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public struct CrewHomeStore: ReducerProtocol {
public var crewJoin: CrewJoinStore.State?
public var crewMake: CrewMakeStore.State?


public var crewList: [CrewInfo] = []

public var userRecordList: IdentifiedArrayOf<PersonalRecordCellStore.State> = [
.init(id: .init(), avatarName: "몰라", ranking: "4", userName: "보민", numberOfExerciseGoals: "3 / 5회", workoutTime: "02:40"),
.init(id: .init(), avatarName: "몰라", ranking: "1", userName: "희원", numberOfExerciseGoals: "3 / 5회", workoutTime: "02:40"),
Expand Down
24 changes: 23 additions & 1 deletion Projects/Feature/Crew/Interface/Sources/Home/CrewListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import SwiftUI
import UIKit
import ComposableArchitecture
import SharedDesignSystem

Expand All @@ -22,8 +23,9 @@ public struct CrewListView: View {
Text("크루")
.font(.pretendard(size: 21, type: .semiBold))
.foregroundColor(.colorGrey900)
.padding(.bottom, 50)

// 크루 리스트..
crewListView(viewStore: viewStore)

Spacer()

Expand All @@ -45,6 +47,26 @@ public struct CrewListView: View {
.padding(23)
}
}

private func crewListView(viewStore : ViewStoreOf<CrewHomeStore>) -> some View {
VStack(alignment: .leading, spacing: 20) {
ForEach(viewStore.crewList, id: \.self.crewId) { crew in
HStack {
Text(crew.crewName)
.font(.pretendard(size: 16, type: .semiBold))
.foregroundColor(.colorGrey600)

Spacer()

Button {
UIPasteboard.general.string = crew.code
} label: {
PumpingImages.crewcode.swiftUIImage
}
}
}
}
}

private func buttonView(viewStore : ViewStoreOf<CrewHomeStore>) -> some View {
HStack {
Expand Down
6 changes: 3 additions & 3 deletions Projects/Feature/Crew/Sources/Home/CrewHomeStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ extension CrewHomeStore {
)
}

case let .fetchCrewResponse(.success(crewInfo)):
print(crewInfo)
case let .fetchCrewResponse(.success(crewList)):
state.crewList = crewList
print(crewList)
return .none

case let .fetchCrewResponse(.failure(error)):
print(error)
return .none


case .presentCrewListView:
state.showCrewListView = true
return .none
Expand Down
2 changes: 1 addition & 1 deletion Projects/Feature/Crew/Sources/Root/CrewRootStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension CrewRootStore {
switch action {
case .goToProfileView:
state.path.append(.profile)
state.profileHome = .init(type: .other)//TODO: other이 아닌경우 체크 해야함
state.profileHome = .init(userId: "", type: .other)//TODO: other이 아닌경우 체크 해야함
return .none

//TODO: 머지 컨플릭트 해결후 버그
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public struct OnboardingAvatarStore : ReducerProtocol {

public enum Action: BindableAction, Equatable {
case binding(BindingAction<State>)
case getRandomCharacter
case getRandomCharacter(selctedGender: GenderType?)
case signUp
case goToMain
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
import Foundation
import SwiftUI
import ComposableArchitecture
import Domain
import SharedDesignSystem

struct OnboardingAvatarView: View {
public let selectedGender: GenderType?
public let store: StoreOf<OnboardingAvatarStore>

public var body: some View {
WithViewStore(self.store) { viewStore in
ZStack {

if let character = viewStore.state.pickedCharacter {
PumpingLottieView(asset: AnimationAsset.confetti)
if viewStore.state.pickedCharacter != nil {
viewStore.pickedCharacter?.getCharacterImage()
} else {
PumpingLottieView(asset: AnimationAsset.confetti)
PumpingLottieView(asset: AnimationAsset.characterLoop, contentMode: .scaleToFill)
}

VStack(alignment : .leading) {
Expand Down Expand Up @@ -55,7 +57,7 @@ struct OnboardingAvatarView: View {
if viewStore.isAvatarPicked {
viewStore.send(.signUp)
} else {
viewStore.send(.getRandomCharacter)
viewStore.send(.getRandomCharacter(selctedGender: selectedGender))
}
}
.padding([.horizontal, .bottom])
Expand Down
Loading