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

Feature/implement board #25

Merged
merged 8 commits into from
Aug 13, 2024
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,9 +1,11 @@
package com.goalpanzi.mission_mate.core.data.di

import com.goalpanzi.mission_mate.core.data.repository.AuthRepositoryImpl
import com.goalpanzi.mission_mate.core.data.repository.MissionRepositoryImpl
import com.goalpanzi.mission_mate.core.data.repository.OnboardingRepositoryImpl
import com.goalpanzi.mission_mate.core.data.repository.ProfileRepositoryImpl
import com.goalpanzi.mission_mate.core.domain.repository.AuthRepository
import com.goalpanzi.mission_mate.core.domain.repository.MissionRepository
import com.goalpanzi.mission_mate.core.domain.repository.OnboardingRepository
import com.goalpanzi.mission_mate.core.domain.repository.ProfileRepository
import dagger.Binds
Expand All @@ -23,4 +25,7 @@ internal abstract class DataModule {

@Binds
abstract fun bindOnboardingRepository(impl: OnboardingRepositoryImpl): OnboardingRepository

@Binds
abstract fun bindMissionRepository(impl: MissionRepositoryImpl): MissionRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.goalpanzi.mission_mate.core.data.repository

import com.goalpanzi.mission_mate.core.domain.repository.MissionRepository
import com.goalpanzi.mission_mate.core.network.service.MissionService
import com.luckyoct.core.model.base.NetworkResult
import com.luckyoct.core.model.response.MissionBoardsResponse
import com.luckyoct.core.model.response.MissionDetailResponse
import com.luckyoct.core.model.response.MissionVerificationsResponse
import javax.inject.Inject

class MissionRepositoryImpl @Inject constructor(
private val missionService: MissionService
) : MissionRepository {
override suspend fun getMissionBoards(missionId: Long): NetworkResult<MissionBoardsResponse> = handleResult {
missionService.getMissionBoards(missionId)
}

override suspend fun getMission(missionId: Long): NetworkResult<MissionDetailResponse> = handleResult {
missionService.getMission(missionId)
}

override suspend fun getMissionVerifications(missionId: Long): NetworkResult<MissionVerificationsResponse> = handleResult {
missionService.getMissionVerifications(missionId)
}

override suspend fun deleteMission(missionId: Long): NetworkResult<MissionDetailResponse> = handleResult {
missionService.deleteMission(missionId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum class NavigationType {
@Composable
fun MissionMateTopAppBar(
modifier: Modifier = Modifier,
@StringRes titleRes: Int? = null,
title: String? = null,
navigationType: NavigationType,
onNavigationClick: () -> Unit = {},
containerColor: Color = MaterialTheme.colorScheme.surfaceDim,
Expand Down Expand Up @@ -72,7 +72,8 @@ fun MissionMateTopAppBar(
.fillMaxWidth()
.height(56.dp)
.background(containerColor)
.padding(horizontal = 12.dp)
.padding(horizontal = 12.dp),
contentAlignment = Alignment.CenterStart
) {
when (navigationType) {
NavigationType.BACK -> {
Expand All @@ -89,9 +90,9 @@ fun MissionMateTopAppBar(
)
}
}
titleRes?.let {
title?.let {
Text(
text = stringResource(id = it),
text = it,
modifier = Modifier.align(Alignment.Center),
style = MissionMateTypography.title_lg_bold,
color = ColorGray1_FF404249
Expand All @@ -114,7 +115,7 @@ fun AppTopBarBackPreview() {
navigationType = NavigationType.BACK,
onNavigationClick = {},
containerColor = Color.White,
titleRes = R.string.app_name
title = stringResource(id = R.string.app_name)
)
}

Expand Down
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_add_user.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M15.934,17.335C15.331,17.241 14.715,17.193 14.093,17.193C12.025,17.193 10.015,17.724 8.374,18.703C7.1,19.463 6.104,20.461 5.472,21.597C5.185,22.111 5.529,22.715 6.106,22.836C9.812,23.608 13.601,23.837 17.357,23.523V23.325H16.181C14.524,23.325 13.181,21.982 13.181,20.325C13.181,18.751 14.393,17.46 15.934,17.335Z"
android:fillColor="#404249"
android:fillType="evenOdd"/>
<path
android:pathData="M20.357,16.149L20.357,24.5"
android:strokeWidth="2.5"
android:fillColor="#00000000"
android:strokeColor="#404249"
android:strokeLineCap="round"/>
<path
android:pathData="M24.533,20.325L16.182,20.325"
android:strokeWidth="2.5"
android:fillColor="#00000000"
android:strokeColor="#404249"
android:strokeLineCap="round"/>
<path
android:pathData="M14.094,9.886m-5.219,0a5.219,5.219 0,1 1,10.439 0a5.219,5.219 0,1 1,-10.439 0"
android:fillColor="#404249"/>
</vector>
15 changes: 15 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_flag.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M6.3,5.4V15.7H12.085C12.392,15.7 12.545,15.7 12.668,15.777C12.79,15.854 12.856,15.993 12.988,16.271L13.729,17.829C13.86,18.107 13.926,18.245 14.049,18.323C14.171,18.4 14.325,18.4 14.632,18.4H21.2C21.435,18.4 21.553,18.4 21.627,18.327C21.7,18.253 21.7,18.136 21.7,17.9V8.1C21.7,7.864 21.7,7.746 21.627,7.673C21.553,7.6 21.435,7.6 21.2,7.6H14.632C14.325,7.6 14.171,7.6 14.049,7.523C13.926,7.445 13.86,7.307 13.729,7.029L12.988,5.471C12.856,5.193 12.79,5.055 12.668,4.977C12.545,4.9 12.392,4.9 12.085,4.9H6.8C6.564,4.9 6.446,4.9 6.373,4.973C6.3,5.046 6.3,5.164 6.3,5.4Z"
android:fillColor="#404249"/>
<path
android:pathData="M6.3,15.7V5.4C6.3,5.164 6.3,5.046 6.373,4.973C6.446,4.9 6.564,4.9 6.8,4.9H12.085C12.392,4.9 12.545,4.9 12.668,4.977C12.79,5.055 12.856,5.193 12.988,5.471L13.729,7.029C13.86,7.307 13.926,7.445 14.049,7.523C14.171,7.6 14.325,7.6 14.632,7.6H21.2C21.435,7.6 21.553,7.6 21.627,7.673C21.7,7.746 21.7,7.864 21.7,8.1V17.9C21.7,18.136 21.7,18.253 21.627,18.327C21.553,18.4 21.435,18.4 21.2,18.4H14.632C14.325,18.4 14.171,18.4 14.049,18.323C13.926,18.245 13.86,18.107 13.729,17.829L12.988,16.271C12.856,15.993 12.79,15.854 12.668,15.777C12.545,15.7 12.392,15.7 12.085,15.7H6.3ZM6.3,15.7V23.8"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#404249"
android:strokeLineCap="round"/>
</vector>
10 changes: 10 additions & 0 deletions core/designsystem/src/main/res/drawable/ic_time.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="25dp"
android:height="24dp"
android:viewportWidth="25"
android:viewportHeight="24">
<path
android:pathData="M12.5,21C17.471,21 21.5,16.971 21.5,12C21.5,7.029 17.471,3 12.5,3C7.529,3 3.5,7.029 3.5,12C3.5,16.971 7.529,21 12.5,21ZM13.5,6.5C13.5,5.948 13.052,5.5 12.5,5.5C11.948,5.5 11.5,5.948 11.5,6.5V11.75C11.5,12.44 12.06,13 12.75,13H16C16.552,13 17,12.552 17,12C17,11.448 16.552,11 16,11H13.5V6.5Z"
android:fillColor="#404249"
android:fillType="evenOdd"/>
</vector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.goalpanzi.mission_mate.core.domain.repository

import com.goalpanzi.mission_mate.core.network.ResultHandler
import com.luckyoct.core.model.base.NetworkResult
import com.luckyoct.core.model.response.MissionBoardsResponse
import com.luckyoct.core.model.response.MissionDetailResponse
import com.luckyoct.core.model.response.MissionVerificationsResponse

interface MissionRepository : ResultHandler {
suspend fun getMissionBoards(missionId : Long) : NetworkResult<MissionBoardsResponse>

suspend fun getMission(missionId : Long) : NetworkResult<MissionDetailResponse>

suspend fun getMissionVerifications(missionId: Long) : NetworkResult<MissionVerificationsResponse>

suspend fun deleteMission(missionId : Long) : NetworkResult<MissionDetailResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.goalpanzi.mission_mate.core.domain.usecase

import com.goalpanzi.mission_mate.core.domain.repository.MissionRepository
import com.luckyoct.core.model.base.NetworkResult
import com.luckyoct.core.model.response.MissionDetailResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class DeleteMissionUseCase @Inject constructor(
private val missionRepository: MissionRepository
) {
operator fun invoke(
missionId: Long
): Flow<NetworkResult<MissionDetailResponse>> = flow {
emit(missionRepository.deleteMission(missionId))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.goalpanzi.mission_mate.core.domain.usecase

import com.goalpanzi.mission_mate.core.domain.repository.MissionRepository
import com.luckyoct.core.model.base.NetworkResult
import com.luckyoct.core.model.response.MissionBoardsResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetMissionBoardsUseCase @Inject constructor(
private val missionRepository: MissionRepository
) {
operator fun invoke(
missionId : Long
): Flow<NetworkResult<MissionBoardsResponse>> = flow {
emit(missionRepository.getMissionBoards(missionId))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.goalpanzi.mission_mate.core.domain.usecase

import com.goalpanzi.mission_mate.core.domain.repository.MissionRepository
import com.luckyoct.core.model.base.NetworkResult
import com.luckyoct.core.model.response.MissionDetailResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetMissionUseCase @Inject constructor(
private val missionRepository: MissionRepository
) {
operator fun invoke(
missionId : Long
): Flow<NetworkResult<MissionDetailResponse>> = flow {
emit(missionRepository.getMission(missionId))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.goalpanzi.mission_mate.core.domain.usecase

import com.goalpanzi.mission_mate.core.domain.repository.MissionRepository
import com.luckyoct.core.model.base.NetworkResult
import com.luckyoct.core.model.response.MissionVerificationsResponse
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class GetMissionVerificationsUseCase @Inject constructor(
private val missionRepository: MissionRepository
) {
operator fun invoke(
missionId : Long
): Flow<NetworkResult<MissionVerificationsResponse>> = flow {
emit(missionRepository.getMissionVerifications(missionId))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.luckyoct.core.model.response

import com.luckyoct.core.model.request.CharacterType
import kotlinx.serialization.Serializable

@Serializable
data class MissionBoardMembersResponse(
val nickname : String,
val characterType : CharacterType = CharacterType.RABBIT
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.luckyoct.core.model.response

import kotlinx.serialization.Serializable

@Serializable
data class MissionBoardResponse(
val number : Int,
val reward : BoardReward = BoardReward.NONE,
val missionBoardMembers : List<MissionBoardMembersResponse>
)

enum class BoardReward {
ORANGE, CANOLA_FLOWER, DOLHARUBANG, HORSE_RIDING, HALLA_MOUNTAIN, WATERFALL, BLACK_PIG, SUNRISE, GREEN_TEA_FIELD, BEACH, NONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.luckyoct.core.model.response

import kotlinx.serialization.Serializable

@Serializable
data class MissionBoardsResponse(
val missionBoards : List<MissionBoardResponse>
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.luckyoct.core.model.response

import kotlinx.serialization.Serializable
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.format.TextStyle
Expand All @@ -19,6 +20,11 @@ data class MissionDetailResponse(
val boardCount : Int,
val invitationCode : String
){
val missionStartLocalDate: LocalDate by lazy {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")
LocalDate.parse(missionStartDate, formatter)
}

val missionPeriod : String by lazy {
try {
val inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss")
Expand All @@ -42,4 +48,9 @@ data class MissionDetailResponse(
missionDays
}
}

fun isStartedMission() : Boolean {
val currentDate = LocalDate.now()
return currentDate.isEqual(missionStartLocalDate) || currentDate.isAfter(missionStartLocalDate)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.luckyoct.core.model.response

import com.luckyoct.core.model.request.CharacterType
import kotlinx.serialization.Serializable

@Serializable
data class MissionVerificationResponse(
val nickname : String,
val characterType : CharacterType = CharacterType.RABBIT,
val image : String = "",
val verifiedAt : String = ""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.luckyoct.core.model.response

import kotlinx.serialization.Serializable

@Serializable
data class MissionVerificationsResponse(
val missionVerifications : List<MissionVerificationResponse>
)
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ sealed interface RouteModel {
@Serializable
data object Setting : Profile
}

@Serializable
data object Setting : RouteModel

@Serializable
data class Board(val missionId : Long) : RouteModel
}

sealed interface OnboardingRouteModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ internal object NetworkModule {
@Singleton
fun provideJson(): Json = Json {
ignoreUnknownKeys = true
coerceInputValues = true
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.goalpanzi.mission_mate.core.network.di

import com.goalpanzi.mission_mate.core.network.service.LoginService
import com.goalpanzi.mission_mate.core.network.service.MissionService
import com.goalpanzi.mission_mate.core.network.service.OnboardingService
import com.goalpanzi.mission_mate.core.network.service.ProfileService
import dagger.Module
Expand Down Expand Up @@ -31,4 +32,10 @@ object ServiceModule {
fun provideOnboardingService(retrofit: Retrofit): OnboardingService {
return retrofit.create(OnboardingService::class.java)
}

@Provides
@Singleton
fun provideMissionService(retrofit: Retrofit): MissionService {
return retrofit.create(MissionService::class.java)
}
}
Loading
Loading