Skip to content

Commit

Permalink
Merge pull request #10 from Nexters/feature/#9_my-page
Browse files Browse the repository at this point in the history
#9: 마이페이지 구현
  • Loading branch information
yxnsx authored Aug 12, 2023
2 parents 17d91c4 + 687a7b4 commit 5e9e120
Show file tree
Hide file tree
Showing 55 changed files with 1,067 additions and 36 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Dependencies.setComposeDependencies
import Dependencies.setCoreKtxDependencies
import Dependencies.setHiltDependencies
import Dependencies.setKotlinStdLibDependencies
import Dependencies.setLoggerDependencies
import Dependencies.setSplashDependencies
import Dependencies.setTestDependencies

Expand Down Expand Up @@ -59,6 +60,8 @@ dependencies {

setTestDependencies()
setAndroidTestDependencies()

setLoggerDependencies()
}

kapt {
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/com/keyme/app/KeymeApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ package com.keyme.app

import android.app.Application
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber

@HiltAndroidApp
class KeymeApplication : Application()
class KeymeApplication : Application() {
override fun onCreate() {
super.onCreate()

if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
}
}
9 changes: 8 additions & 1 deletion app/src/main/java/com/keyme/app/ui/KeymeApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import com.keyme.presentation.alarm.ui.AlarmDestination
import com.keyme.presentation.alarm.ui.alarmGraph
import com.keyme.presentation.designsystem.theme.KeymeTheme
import com.keyme.presentation.feed.ui.feedGraph
import com.keyme.presentation.myprofile.ui.KeymeTestResultDetailDestination
import com.keyme.presentation.myprofile.ui.keymeTestResultDetailGraph
import com.keyme.presentation.myprofile.ui.myProfileGraph

@Composable
Expand Down Expand Up @@ -46,7 +48,12 @@ fun KeymeApp() {
alarmGraph(onBackClick = appState::onBackClick)
},
)
myProfileGraph()
myProfileGraph(
navigateToDetail = { appState.navigate(KeymeTestResultDetailDestination) },
nestedGraphs = {
keymeTestResultDetailGraph(onBackClick = appState::onBackClick)
},
)
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ object Dependencies {
// See https://developer.android.com/jetpack/compose/bom/bom-mapping
private val composeBom = "androidx.compose:compose-bom:${Versions.COMPOSE_BOM}"
private val composeMaterial = "androidx.compose.material3:material3"
private val composeTooling = "androidx.compose.ui:ui-tooling"
private val composePreview = "androidx.compose.ui:ui-tooling-preview"
private val composeLiveData = "androidx.compose.runtime:runtime-livedata"
private val composeViewModel = "androidx.lifecycle:lifecycle-viewmodel-compose:${Versions.COMPOSE_VIEW_MODEL}"
private val composeNavigation = "androidx.navigation:navigation-compose:${Versions.COMPOSE_NAVIGATION}"
private val runtime_compose = "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"


// ViewModel
private val viewModelKtx = "androidx.lifecycle:lifecycle-viewmodel-ktx:${Versions.LIFECYCLE}"
Expand Down Expand Up @@ -62,6 +65,9 @@ object Dependencies {
private val androidJunit = "androidx.test.ext:junit:${Versions.ANDROID_JUNIT}"
private val espressoCore = "androidx.test.espresso:espresso-core:${Versions.ESPRESSO_CORE}"

// Logger
private val timber = "com.jakewharton.timber:timber:4.7.1"

fun DependencyHandler.setActivityDepdendencies() {
implementation(activity)
implementation(activity_compose)
Expand All @@ -86,10 +92,12 @@ object Dependencies {
fun DependencyHandler.setComposeDependencies() {
implementation(platform(composeBom))
implementation(composeMaterial)
debugImplementation(composeTooling)
implementation(composePreview)
implementation(composeLiveData)
implementation(composeViewModel)
implementation(composeNavigation)
implementation(runtime_compose)
}

fun DependencyHandler.setViewModelDependencies() {
Expand Down Expand Up @@ -137,6 +145,10 @@ object Dependencies {
androidTestImplementation(espressoCore)
}

fun DependencyHandler.setLoggerDependencies() {
implementation(timber)
}


private fun DependencyHandler.ksp(dependency: String) {
add("ksp", dependency)
Expand All @@ -158,6 +170,14 @@ object Dependencies {
add("implementation", dependency)
}

private fun DependencyHandler.debugImplementation(dependency: String) {
add("debugImplementation", dependency)
}

private fun DependencyHandler.debugImplementation(dependency: Dependency) {
add("debugImplementation", dependency)
}

private fun DependencyHandler.annotationProcessor(dependency: String) {
add("annotationProcessor", dependency)
}
Expand Down
3 changes: 3 additions & 0 deletions data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Dependencies.setCoroutinesDependencies
import Dependencies.setDatabaseDependencies
import Dependencies.setHiltDependencies
import Dependencies.setKotlinStdLibDependencies
import Dependencies.setLoggerDependencies
import Dependencies.setNetworkDependencies
import Dependencies.setTestDependencies

Expand Down Expand Up @@ -47,6 +48,8 @@ dependencies {

setTestDependencies()
setAndroidTestDependencies()

setLoggerDependencies()
}

kapt {
Expand Down
7 changes: 7 additions & 0 deletions data/src/main/java/com/keyme/data/remote/api/KeymeApi.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.keyme.data.remote.api

import com.keyme.domain.entity.response.SampleResponse
import com.keyme.domain.entity.response.keymetest.KeymeTestResultStatisticsResponse
import retrofit2.http.GET
import retrofit2.http.Path

interface KeymeApi {

@GET("main/sample")
suspend fun getSample(): SampleResponse

@GET("tests/{id}/statistics")
suspend fun getKeymeTestResultStatistics(
@Path("id") questionId: String,
): KeymeTestResultStatisticsResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.keyme.data.remote.datasource

import com.keyme.domain.entity.response.Circle
import com.keyme.domain.entity.response.ResultCircleResponse
import javax.inject.Inject

class ResultCircleDataSource @Inject constructor() {
fun getSample(): ResultCircleResponse {
return ResultCircleResponse().apply {
data = circleDummy()
}
}
}

private fun circleDummy(): List<Circle> {
return listOf(
Circle(
x = -0.633232604611031,
y = -0.47732413442115296,
r = 0.09460444572843042,
level = 1,
ex = mapOf("datum" to 1),
),
Circle(
x = -0.7720311587589236,
y = 0.19946176418549022,
r = 0.13379089020993573,
level = 1,
ex = mapOf("datum" to 2),
),
Circle(
x = -0.43168871955473165,
y = -0.6391381648617572,
r = 0.16385970662353394,
level = 1,
ex = mapOf("datum" to 3),
),
Circle(
x = 0.595447603036083,
y = 0.5168251295666467,
r = 0.21154197162246005,
level = 1,
ex = mapOf("datum" to 5),
),
Circle(
x = -0.5480911056188739,
y = 0.5115139053491098,
r = 0.2502998363185337,
level = 1,
ex = mapOf("datum" to 7),
),
Circle(
x = 0.043747233552068686,
y = -0.6848366902134195,
r = 0.31376744998074435,
level = 1,
ex = mapOf("datum" to 11),
),
Circle(
x = 0.04298737651230445,
y = 0.5310431146935967,
r = 0.34110117996070605,
level = 1,
ex = mapOf("datum" to 13),
),
Circle(
x = -0.3375943908160698,
y = -0.09326467617622711,
r = 0.39006412239133215,
level = 1,
ex = mapOf("datum" to 17),
),
Circle(
x = 0.46484095011516874,
y = -0.09326467617622711,
r = 0.4123712185399064,
level = 1,
ex = mapOf("datum" to 19),
),
)
}
10 changes: 10 additions & 0 deletions data/src/main/java/com/keyme/data/remote/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.keyme.data.remote.di

import com.keyme.data.remote.repositoryimpl.ResultCircleRepositoryImpl
import com.keyme.data.remote.repositoryimpl.SampleRepositoryImpl
import com.keyme.data.remote.repositoryimpl.keymetest.KeymeTestResultRepositoryImpl
import com.keyme.domain.repository.ResultCircleRepository
import com.keyme.domain.repository.SampleRepository
import com.keyme.domain.repository.keymetest.KeymeTestResultRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -13,4 +17,10 @@ abstract class RepositoryModule {

@Binds
abstract fun bindSampleRepository(impl: SampleRepositoryImpl): SampleRepository

@Binds
abstract fun bindResultCircleRepository(impl: ResultCircleRepositoryImpl): ResultCircleRepository

@Binds
abstract fun bindKeymeTestResultRepository(impl: KeymeTestResultRepositoryImpl): KeymeTestResultRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.keyme.data.remote.repositoryimpl

import com.keyme.data.remote.datasource.ResultCircleDataSource
import com.keyme.domain.entity.response.ResultCircleResponse
import com.keyme.domain.repository.ResultCircleRepository
import javax.inject.Inject

class ResultCircleRepositoryImpl @Inject constructor(
private val resultCircleDataSource: ResultCircleDataSource,
) : ResultCircleRepository {

override suspend fun getDummy(): ResultCircleResponse {
return resultCircleDataSource.getSample().apply {
statusCode = "200"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.keyme.data.remote.repositoryimpl.keymetest

import com.keyme.data.remote.api.KeymeApi
import com.keyme.domain.entity.response.keymetest.KeymeTestResultStatisticsResponse
import com.keyme.domain.repository.keymetest.KeymeTestResultRepository
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class KeymeTestResultRepositoryImpl @Inject constructor(
private val keymeApi: KeymeApi,
) : KeymeTestResultRepository {

override suspend fun getStatistics(questionId: String): KeymeTestResultStatisticsResponse {
return keymeApi.getKeymeTestResultStatistics(questionId = questionId)
}
}
2 changes: 2 additions & 0 deletions domain/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Dependencies.setJavaXInjectDependencies
import Dependencies.setKotlinStdLibDependencies
import Dependencies.setLoggerDependencies
import Dependencies.setTestDependencies


Expand All @@ -18,4 +19,5 @@ dependencies {
setKotlinStdLibDependencies()
setJavaXInjectDependencies()
setTestDependencies()
setLoggerDependencies()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.keyme.domain.entity.response

import com.keyme.domain.entity.BaseResponse

class ResultCircleResponse : BaseResponse<List<Circle>>()

data class Circle(val x: Double, val y: Double, val r: Double, val level: Int, val ex: Map<String, Int>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.keyme.domain.entity.response.keymetest

import com.keyme.domain.entity.BaseResponse

class KeymeTestResultStatisticsResponse : BaseResponse<KeymeTestResultStatistics>()

data class KeymeTestResultStatistics(
val averageRate: Int,
val questionsStatistics: List<QuestionsStatistic>,
val solvedCount: Int,
)

data class Category(
val color: String,
val imageUrl: String,
val name: String,
)

data class QuestionsStatistic(
val averageScore: Int,
val category: Category,
val description: String,
val keyword: String,
val questionId: Int,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.keyme.domain.repository

import com.keyme.domain.entity.response.ResultCircleResponse

interface ResultCircleRepository {

suspend fun getDummy(): ResultCircleResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.keyme.domain.repository.keymetest

import com.keyme.domain.entity.response.keymetest.KeymeTestResultStatisticsResponse

interface KeymeTestResultRepository {

suspend fun getStatistics(questionId: String): KeymeTestResultStatisticsResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.keyme.domain.usecase

import com.keyme.domain.entity.ApiResult
import com.keyme.domain.entity.apiResult
import com.keyme.domain.entity.response.Circle
import com.keyme.domain.repository.ResultCircleRepository
import javax.inject.Inject

class GetResultCircleUseCase @Inject constructor(
private val resultCircleRepository: ResultCircleRepository,
) {
suspend operator fun invoke(): ApiResult<List<Circle>> {
return apiResult {
resultCircleRepository.getDummy()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.keyme.domain.usecase.keymetest

import com.keyme.domain.entity.ApiResult
import com.keyme.domain.entity.apiResult
import com.keyme.domain.entity.response.keymetest.KeymeTestResultStatistics
import com.keyme.domain.repository.keymetest.KeymeTestResultRepository
import javax.inject.Inject

class GetKeymeTestResultStatisticsUseCase @Inject constructor(
private val keymeTestResultRepository: KeymeTestResultRepository,
) {
suspend operator fun invoke(questionId: String): ApiResult<KeymeTestResultStatistics> {
return apiResult {
keymeTestResultRepository.getStatistics(questionId)
}
}
}
Loading

0 comments on commit 5e9e120

Please sign in to comment.