Skip to content

Commit f326a03

Browse files
authored
Merge pull request #42 from YAPP-Github/feature/#23-home-ui
[Feature/#23] 홈 화면 구현
2 parents 0c7cf49 + 6b13a06 commit f326a03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2844
-13
lines changed

app/src/main/java/com/threegap/bitnagil/MainNavHost.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import androidx.compose.ui.Modifier
55
import androidx.navigation.compose.NavHost
66
import androidx.navigation.compose.composable
77
import androidx.navigation.toRoute
8-
import com.threegap.bitnagil.presentation.home.HomeScreen
8+
import com.threegap.bitnagil.presentation.home.HomeScreenContainer
99
import com.threegap.bitnagil.presentation.intro.IntroScreenContainer
1010
import com.threegap.bitnagil.presentation.login.LoginScreenContainer
1111
import com.threegap.bitnagil.presentation.splash.SplashScreenContainer
@@ -66,7 +66,7 @@ fun MainNavHost(
6666
}
6767

6868
composable<Route.Home> {
69-
HomeScreen()
69+
HomeScreenContainer()
7070
}
7171

7272
composable<Route.WebView> {

app/src/main/java/com/threegap/bitnagil/di/data/DataSourceModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import com.threegap.bitnagil.data.emotion.datasource.EmotionDataSource
88
import com.threegap.bitnagil.data.emotion.datasourceImpl.EmotionDataSourceImpl
99
import com.threegap.bitnagil.data.onboarding.datasource.OnBoardingDataSource
1010
import com.threegap.bitnagil.data.onboarding.datasourceImpl.OnBoardingDataSourceImpl
11+
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
12+
import com.threegap.bitnagil.data.routine.datasourceImpl.RoutineRemoteDataSourceImpl
1113
import com.threegap.bitnagil.data.writeroutine.datasource.WriteRoutineDataSource
1214
import com.threegap.bitnagil.data.writeroutine.datasourceImpl.WriteRoutineDataSourceImpl
1315
import dagger.Binds
@@ -32,6 +34,10 @@ abstract class DataSourceModule {
3234
@Singleton
3335
abstract fun bindOnBoardingDataSource(onBoardingDataSourceImpl: OnBoardingDataSourceImpl): OnBoardingDataSource
3436

37+
@Binds
38+
@Singleton
39+
abstract fun bindRoutineDataSource(routineDataSourceImpl: RoutineRemoteDataSourceImpl): RoutineRemoteDataSource
40+
3541
@Binds
3642
@Singleton
3743
abstract fun bindEmotionDataSource(emotionDataSourceImpl: EmotionDataSourceImpl): EmotionDataSource

app/src/main/java/com/threegap/bitnagil/di/data/RepositoryModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ package com.threegap.bitnagil.di.data
33
import com.threegap.bitnagil.data.auth.repositoryimpl.AuthRepositoryImpl
44
import com.threegap.bitnagil.data.emotion.repositoryImpl.EmotionRepositoryImpl
55
import com.threegap.bitnagil.data.onboarding.repositoryImpl.OnBoardingRepositoryImpl
6+
import com.threegap.bitnagil.data.routine.repositoryImpl.RoutineRepositoryImpl
67
import com.threegap.bitnagil.data.writeroutine.repositoryImpl.WriteRoutineRepositoryImpl
78
import com.threegap.bitnagil.domain.auth.repository.AuthRepository
89
import com.threegap.bitnagil.domain.emotion.repository.EmotionRepository
910
import com.threegap.bitnagil.domain.onboarding.repository.OnBoardingRepository
11+
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
1012
import com.threegap.bitnagil.domain.writeroutine.repository.WriteRoutineRepository
1113
import dagger.Binds
1214
import dagger.Module
@@ -26,6 +28,10 @@ abstract class RepositoryModule {
2628
@Singleton
2729
abstract fun bindOnBoardingRepository(onBoardingRepositoryImpl: OnBoardingRepositoryImpl): OnBoardingRepository
2830

31+
@Binds
32+
@Singleton
33+
abstract fun bindRoutineRepository(routineRepositoryImpl: RoutineRepositoryImpl): RoutineRepository
34+
2935
@Binds
3036
@Singleton
3137
abstract fun bindEmotionRepository(emotionRepositoryImpl: EmotionRepositoryImpl): EmotionRepository

app/src/main/java/com/threegap/bitnagil/di/data/ServiceModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.threegap.bitnagil.di.data
33
import com.threegap.bitnagil.data.auth.service.AuthService
44
import com.threegap.bitnagil.data.emotion.service.EmotionService
55
import com.threegap.bitnagil.data.onboarding.service.OnBoardingService
6+
import com.threegap.bitnagil.data.routine.service.RoutineService
67
import com.threegap.bitnagil.data.writeroutine.service.WriteRoutineService
78
import com.threegap.bitnagil.di.core.Auth
89
import com.threegap.bitnagil.di.core.NoneAuth
@@ -28,6 +29,11 @@ object ServiceModule {
2829
fun providerOnBoardingService(@Auth retrofit: Retrofit): OnBoardingService =
2930
retrofit.create(OnBoardingService::class.java)
3031

32+
@Provides
33+
@Singleton
34+
fun provideRoutineService(@Auth retrofit: Retrofit): RoutineService =
35+
retrofit.create(RoutineService::class.java)
36+
3137
@Provides
3238
@Singleton
3339
fun providerEmotionService(@Auth retrofit: Retrofit): EmotionService =
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.threegap.bitnagil.data.routine.datasource
2+
3+
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
4+
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
5+
6+
interface RoutineRemoteDataSource {
7+
suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result<RoutinesResponseDto>
8+
suspend fun syncRoutineCompletion(routineCompletionRequestDto: RoutineCompletionRequestDto): Result<Unit>
9+
suspend fun deleteRoutine(routineId: String): Result<Unit>
10+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.threegap.bitnagil.data.routine.datasourceImpl
2+
3+
import com.threegap.bitnagil.data.common.safeApiCall
4+
import com.threegap.bitnagil.data.common.safeUnitApiCall
5+
import com.threegap.bitnagil.data.routine.datasource.RoutineRemoteDataSource
6+
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
7+
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
8+
import com.threegap.bitnagil.data.routine.service.RoutineService
9+
import javax.inject.Inject
10+
11+
class RoutineRemoteDataSourceImpl @Inject constructor(
12+
private val routineService: RoutineService,
13+
) : RoutineRemoteDataSource {
14+
override suspend fun fetchWeeklyRoutines(startDate: String, endDate: String): Result<RoutinesResponseDto> =
15+
safeApiCall {
16+
routineService.fetchRoutines(startDate, endDate)
17+
}
18+
19+
override suspend fun syncRoutineCompletion(routineCompletionRequestDto: RoutineCompletionRequestDto): Result<Unit> =
20+
safeUnitApiCall {
21+
routineService.routineCompletion(routineCompletionRequestDto)
22+
}
23+
24+
override suspend fun deleteRoutine(routineId: String): Result<Unit> =
25+
safeUnitApiCall {
26+
routineService.deleteRoutine(routineId)
27+
}
28+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.threegap.bitnagil.data.routine.mapper
2+
3+
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionInfoDto
4+
import com.threegap.bitnagil.data.routine.model.request.RoutineCompletionRequestDto
5+
import com.threegap.bitnagil.data.routine.model.response.RoutineDto
6+
import com.threegap.bitnagil.data.routine.model.response.RoutinesResponseDto
7+
import com.threegap.bitnagil.data.routine.model.response.SubRoutineDto
8+
import com.threegap.bitnagil.domain.routine.model.DayOfWeek
9+
import com.threegap.bitnagil.domain.routine.model.Routine
10+
import com.threegap.bitnagil.domain.routine.model.RoutineCompletion
11+
import com.threegap.bitnagil.domain.routine.model.RoutineCompletionInfo
12+
import com.threegap.bitnagil.domain.routine.model.RoutineType
13+
import com.threegap.bitnagil.domain.routine.model.Routines
14+
import com.threegap.bitnagil.domain.routine.model.SubRoutine
15+
16+
// toDomain
17+
internal fun RoutinesResponseDto.toDomain() =
18+
Routines(
19+
routinesByDate = this.routines.mapValues { (_, routineDto) ->
20+
routineDto.map { it.toDomain() }
21+
},
22+
)
23+
24+
internal fun RoutineDto.toDomain() =
25+
Routine(
26+
routineId = this.routineId,
27+
historySeq = this.historySeq,
28+
routineName = this.routineName,
29+
executionTime = this.executionTime,
30+
subRoutines = this.subRoutines.map { it.toDomain() },
31+
isModified = this.isModified,
32+
isCompleted = this.isCompleted,
33+
repeatDay = this.repeatDay.map { DayOfWeek.fromString(it) },
34+
routineType = RoutineType.fromString(this.routineType),
35+
)
36+
37+
internal fun SubRoutineDto.toDomain() =
38+
SubRoutine(
39+
subRoutineId = this.subRoutineId,
40+
historySeq = this.historySeq,
41+
subRoutineName = this.subRoutineName,
42+
isModified = this.isModified,
43+
sortOrder = this.sortOrder,
44+
isCompleted = this.isCompleted,
45+
routineType = RoutineType.fromString(this.routineType),
46+
)
47+
48+
// toDto
49+
internal fun RoutineCompletion.toDto() =
50+
RoutineCompletionRequestDto(
51+
performedDate = this.performedDate,
52+
routineCompletions = this.routineCompletions.map { it.toDto() },
53+
)
54+
55+
internal fun RoutineCompletionInfo.toDto() =
56+
RoutineCompletionInfoDto(
57+
routineType = this.routineType.name,
58+
routineId = this.routineId,
59+
historySeq = this.historySeq,
60+
isCompleted = this.isCompleted,
61+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.threegap.bitnagil.data.routine.model.request
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class RoutineCompletionInfoDto(
8+
@SerialName("routineType")
9+
val routineType: String,
10+
@SerialName("routineId")
11+
val routineId: String,
12+
@SerialName("historySeq")
13+
val historySeq: Int,
14+
@SerialName("completeYn")
15+
val isCompleted: Boolean,
16+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.threegap.bitnagil.data.routine.model.request
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class RoutineCompletionRequestDto(
8+
@SerialName("performedDate")
9+
val performedDate: String,
10+
@SerialName("routineCompletionInfos")
11+
val routineCompletions: List<RoutineCompletionInfoDto>,
12+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.threegap.bitnagil.data.routine.model.response
2+
3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
5+
6+
@Serializable
7+
data class RoutineDto(
8+
@SerialName("routineId")
9+
val routineId: String,
10+
@SerialName("historySeq")
11+
val historySeq: Int,
12+
@SerialName("routineName")
13+
val routineName: String,
14+
@SerialName("repeatDay")
15+
val repeatDay: List<String>,
16+
@SerialName("executionTime")
17+
val executionTime: String,
18+
@SerialName("subRoutineSearchResultDto")
19+
val subRoutines: List<SubRoutineDto>,
20+
@SerialName("modifiedYn")
21+
val isModified: Boolean,
22+
@SerialName("completeYn")
23+
val isCompleted: Boolean,
24+
@SerialName("routineType")
25+
val routineType: String,
26+
)

0 commit comments

Comments
 (0)