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

[온보딩] 결과 페이지 #72

Merged
merged 18 commits into from
Aug 21, 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
Binary file modified Encrypted/Secrets/GoogleService-Info.plist.encrypted
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public class HapticManager {
generator.notificationOccurred(.error)
}

/// 통통
public func tongtong() {
let generator = UINotificationFeedbackGenerator()
generator.prepare()
generator.notificationOccurred(.success)
}

/// 톡
public func tok() {
let generator = UIImpactFeedbackGenerator(style: .rigid)
Expand Down
2 changes: 1 addition & 1 deletion Projects/Core/Util/Sources/KFImageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class KFImageManager {
public func toImage(url: String) -> KFImage {
return KFImage(URL(string: url))
.placeholder {
Image(systemName: "x.circle.fill")
Image(systemName: "questionmark.circle.fill")
}
.retry(maxCount: 3, interval: .seconds(3))
.onFailure { error in print("Kingfisher Error: \(error)") }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x3A",
"green" : "0x3A",
"red" : "0x3A"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x3A",
"green" : "0x3A",
"red" : "0x3A"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "Group 4487407.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Projects/DSKit/Sources/Button/SegmentControlView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct SegmentControlView<SegmentType: Identifiable, Content: View>: View
.cornerRadius(16)
.overlay(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.stroke(Color.hex("232323"), lineWidth: 1)
.stroke(.white.opacity(0.1), lineWidth: 1)
)
}
}
Expand Down
3 changes: 2 additions & 1 deletion Projects/DSKit/Sources/MyPage/CircleContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Domain
import Kingfisher
import SwiftUI

public struct CircleContentView: View {
Expand All @@ -28,7 +29,7 @@ public struct CircleContentView: View {

public var body: some View {
VStack(spacing: imageSize / 4) {
metadata.icon
KFImage(metadata.iconURL)
.resizable()
.scaledToFit()
.frame(width: imageSize)
Expand Down
16 changes: 15 additions & 1 deletion Projects/Domain/Sources/Client/KeymeTestsClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Network
public struct KeymeTestsClient {
public var fetchOnboardingTests: @Sendable () async throws -> KeymeTestsModel
public var fetchDailyTests: @Sendable () async throws -> KeymeTestsModel
public var fetchTestResult: @Sendable (Int) async throws -> [TestResultModel]
public var postTestResult: @Sendable (String) async throws -> String
}

extension DependencyValues {
Expand All @@ -32,10 +34,22 @@ extension KeymeTestsClient: DependencyKey {
return response.toIconModel()
}, fetchDailyTests: {
let api = KeymeTestsAPI.daily
// var response = try await KeymeTestsAPIManager.shared.requestWithSampleData(api, object: KeymeTestsDTO.self)
// var response = try await KeymeTestsAPIManager.shared.requestWithSampleData(api, object: KeymeTestsDTO.self)
var response = try await KeymeTestsAPIManager.shared.request(api, object: KeymeTestsDTO.self)

return response.toIconModel()
}, fetchTestResult: { testResultId in
let api = KeymeTestsAPI.result(testResultId)
// var response = try await KeymeTestsAPIManager.shared.requestWithSampleData(api, object: TestResultDTO.self)
var response = try await KeymeTestsAPIManager.shared.request(api, object: TestResultDTO.self)

return response.data.results.map { $0.toModel() }
}, postTestResult: { resultCode in
let api = KeymeTestsAPI.register(resultCode)
// var response = try await KeymeTestsAPIManager.shared.requestWithSampleData(api, object: BaseDTO<String>.self)
var response = try await KeymeTestsAPIManager.shared.request(api, object: BaseDTO<String>.self)

return response.message
}
)
}
148 changes: 70 additions & 78 deletions Projects/Domain/Sources/Model/CirclePack/CircleData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,84 +59,76 @@ public struct CircleData {
}

// 네트워크 데이터
//public extension CircleData {
// // MARK: - AppResult
// struct NetworkResult: Codable {
// let data: DataField
//
// struct DataField: Codable {
// let memberID: Int
// let results: [Result]
//
// enum CodingKeys: String, CodingKey {
// case memberID = "memberId"
// case results
// }
// }
// }
//}
//
//extension CircleData.NetworkResult {
// struct Result: Codable {
// let questionStatistic: QuestionStatistic
// let coordinate: Coordinate
// }
//
// struct Coordinate: Codable {
// let x, y, r: Double
// }
//
// struct QuestionStatistic: Codable {
// let questionID: Int
// let title, keyword: String
// let category: Category
// let avgScore: Int
//
// enum CodingKeys: String, CodingKey {
// case questionID = "questionId"
// case title, keyword, category, avgScore
// }
// }
//
// struct Category: Codable {
// let iconURL: String
// let name, color: String
//
// enum CodingKeys: String, CodingKey {
// case iconURL = "iconUrl"
// case name, color
// }
// }
//}
//
//public extension CircleData.NetworkResult {
// func toCircleData() -> [CircleData] {
// return self.data.results.map { result -> CircleData in
// let coordinate = result.coordinate
// let questionStatistic = result.questionStatistic
// let category = questionStatistic.category
//
// let color = Color.hex(category.color)
//
// let icon = Image(systemName: "person")
//
// let metadata = CircleMetadata(
// icon: icon,
// keyword: questionStatistic.keyword,
// averageScore: Float(questionStatistic.avgScore),
// myScore: 0
// )
//
// return CircleData(
// color: color,
// xPoint: CGFloat(coordinate.x),
// yPoint: CGFloat(coordinate.y),
// radius: CGFloat(coordinate.r),
// metadata: metadata
// )
// }
// }
//}
public extension CircleData {
// MARK: - AppResult
struct NetworkResult: Codable {
let code: Int
let data: ResponseData
}
}

extension CircleData.NetworkResult {
struct ResponseData: Codable {
let memberId: Int
let results: [ResultItem]
}

struct ResultItem: Codable {
let questionStatistic: QuestionStatistic
let coordinate: Coordinate
}

struct QuestionStatistic: Codable {
let questionId: Int
let title: String
let keyword: String
let category: Category
let avgScore: Double
let ownerScore: Double
}

struct Category: Codable {
let iconUrl: String
let name: String
let color: String
}

struct Coordinate: Codable {
let x: Double
let y: Double
let r: Double
}
}

import Kingfisher

public extension CircleData.NetworkResult {
func toCircleData() -> [CircleData] {
return self.data.results.map { result -> CircleData in
let coordinate = result.coordinate
let questionStatistic = result.questionStatistic
let category = questionStatistic.category

let color = Color.hex(category.color)

let metadata = CircleMetadata(
questionId: questionStatistic.questionId,
iconURL: URL(string: category.iconUrl),
keyword: questionStatistic.keyword,
averageScore: Float(questionStatistic.avgScore),
myScore: Float(questionStatistic.ownerScore)
)

return CircleData(
color: color,
xPoint: CGFloat(coordinate.x),
yPoint: CGFloat(coordinate.y),
radius: CGFloat(coordinate.r),
metadata: metadata
)
}
}
}

extension CircleData: Equatable {
public static func == (lhs: CircleData, rhs: CircleData) -> Bool {
Expand Down
11 changes: 7 additions & 4 deletions Projects/Domain/Sources/Model/CirclePack/CircleMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,30 @@ import SwiftUI
import Foundation

public struct CircleMetadata {
public let questionId: Int
public let animationId: Int
public let icon: Image
public let iconURL: URL?
public let keyword: String
public let averageScore: Float
public let myScore: Float

public init(
questionId: Int,
animationId: Int = Int.random(in: 0...99999),
icon: Image,
iconURL: URL?,
keyword: String,
averageScore: Float,
myScore: Float
) {
self.questionId = questionId
self.animationId = animationId
self.icon = icon
self.iconURL = iconURL
self.keyword = keyword
self.averageScore = averageScore
self.myScore = myScore
}

public static var emptyData: CircleMetadata {
return CircleMetadata(animationId: -1, icon: Image(""), keyword: "", averageScore: 0.0, myScore: 0.0)
return CircleMetadata(questionId: -1, animationId: -1, iconURL: URL(string: "temp"), keyword: "", averageScore: 0.0, myScore: 0.0)
}
}
10 changes: 5 additions & 5 deletions Projects/Domain/Sources/Model/KeymeTestsModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ public struct KeymeTestsModel: Equatable {
public let icons: [IconModel]
}

public struct IconModel: Equatable {
public let image: String
public struct IconModel: Equatable, Hashable {
public let imageURL: String
public let color: Color

public static var EMPTY: IconModel = .init(image: "", color: Color.hex(""))
public static let EMPTY: IconModel = .init(imageURL: "", color: Color.hex(""))
}

public extension KeymeTestsDTO {
func toIconModel() -> KeymeTestsModel {
let nickname = data.owner.nickname
let icons = data.questions.map {
IconModel(image: $0.category.iconUrl,
IconModel(imageURL: $0.category.iconUrl,
color: Color.hex($0.category.color))
}
return KeymeTestsModel(nickname: nickname ?? "키미키미",
return KeymeTestsModel(nickname: nickname ?? "키미",
testId: data.testId,
icons: icons)
}
Expand Down
15 changes: 15 additions & 0 deletions Projects/Domain/Sources/Model/KeymeWebModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// KeymeWebViewModel.swift
// Domain
//
// Created by 김영인 on 2023/08/18.
// Copyright © 2023 team.humanwave. All rights reserved.
//

import Foundation

public struct KeymeWebViewModel: Codable, Equatable {
public let matchRate: Int
public let resultCode: String
public let testResultId: Int
}
Loading