Skip to content

Commit

Permalink
Merge pull request #154 from YAPP-Github/issue-140-plan-status
Browse files Browse the repository at this point in the history
[ISSUE-139&140] 약속 생성 - 시간대 선택 화면에서 뒤로가기 다이얼로그 처리, 약속 상태 가져오는 API 연동 & 링크 진입시 이동
  • Loading branch information
KwonDae authored Jul 31, 2022
2 parents 7b37bf7 + 200bdb2 commit 08f5370
Show file tree
Hide file tree
Showing 39 changed files with 831 additions and 232 deletions.
3 changes: 2 additions & 1 deletion buildSrc/src/main/java/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// alphabet 순서대로 정렬
object Versions {
const val ACCOMPANIST_PAGER = "0.12.0"
const val ACCOMPANIST_PAGER = "0.24.12-rc"
const val ACCOMPANIST_SYSTEM_UI_CONTROLLER = "0.24.12-rc"
const val ANDROID_APP_COMPAT = "1.4.1"
const val ANDROID_BUILD_TOOL = "7.2.0"
const val ANDROID_CORE = "1.7.0"
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/java/app/ModuleDependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ object ModuleDependencies {
val accompanist = arrayOf(
DependencyInfo("com.google.accompanist:accompanist-pager",
Versions.ACCOMPANIST_PAGER,
Method.IMPLEMENTATION),

DependencyInfo("com.google.accompanist:accompanist-systemuicontroller",
Versions.ACCOMPANIST_SYSTEM_UI_CONTROLLER,
Method.IMPLEMENTATION)
)

Expand Down
6 changes: 6 additions & 0 deletions data/src/main/java/com/yapp/growth/data/api/GrowthApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ interface GrowthApi {
@GET("/api/users/info")
suspend fun getUserInfo(): UserResponseImpl

// Plan Status
@GET("/api/promisings/{promisingId}/status")
suspend fun getUserPlanStatus(
@Path("promisingId") planId: String,
): UserPlanStatusResponseImpl

@POST("/api/users/resign-member")
suspend fun deleteUserInfo()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.yapp.growth.data.internal.response

import com.yapp.growth.data.response.UserPlanStatusResponse

data class UserPlanStatusResponseImpl(
override val status: String

): UserPlanStatusResponse
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ internal class PlanzDataSourceImpl @Inject constructor(
retrofitApi.getUserInfo().toUser()
}

override suspend fun getUserPlanStatus(planId: Long): NetworkResult<UserPlanStatus> =
handleApi {
retrofitApi.getUserPlanStatus(planId.toString()).status.toEnumValueOfOrNull<UserPlanStatus>() ?: UserPlanStatus.UNKNOWN
}

override suspend fun deleteUserInfo(): NetworkResult<Unit> =
handleApi {
retrofitApi.deleteUserInfo()
Expand Down
11 changes: 11 additions & 0 deletions data/src/main/java/com/yapp/growth/data/mapper/UserMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,14 @@ fun UserResponse.toUser(): User {
userName = response.userName
)
}

/**
* Returns an enum entry with the specified name or `null` if no such entry was found.
*/
inline fun <reified T : Enum<T>> enumValueOfOrNull(name: String): T? {
return enumValues<T>().find { it.name == name }
}

inline fun <reified T : Enum<T>> String.toEnumValueOfOrNull(): T? {
return enumValues<T>().find { it.name == this }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.yapp.growth.data.repository
import com.yapp.growth.data.source.PlanzDataSource
import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.entity.User
import com.yapp.growth.domain.entity.UserPlanStatus
import com.yapp.growth.domain.onSuccess
import com.yapp.growth.domain.repository.UserRepository
import javax.inject.Inject
Expand All @@ -23,7 +24,11 @@ internal class UserRepositoryImpl @Inject constructor(
return dataSource.getUserInfo().onSuccess { cachedUserInfo = it }
}

override suspend fun getCachedUserInfo(): User? = cachedUserInfo
override fun getCachedUserInfo(): User? = cachedUserInfo

override suspend fun getUserPlanStatus(planId: Long): NetworkResult<UserPlanStatus> {
return dataSource.getUserPlanStatus(planId)
}

override suspend fun deleteUserInfo(): NetworkResult<Unit> {
return dataSource.deleteUserInfo()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.yapp.growth.data.response

interface UserPlanStatusResponse {
val status: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ interface PlanzDataSource {

suspend fun signUp(): NetworkResult<User>
suspend fun getUserInfo(): NetworkResult<User>
suspend fun getUserPlanStatus(planId: Long): NetworkResult<UserPlanStatus>
suspend fun deleteUserInfo(): NetworkResult<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.yapp.growth.domain.entity

enum class UserPlanStatus {
OWNER, CONFIRMED, RESPONSE_ALREADY, RESPONSE_MAXIMUM, RESPONSE_POSSIBLE, UNKNOWN
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package com.yapp.growth.domain.repository

import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.entity.User
import com.yapp.growth.domain.entity.UserPlanStatus

interface UserRepository {
suspend fun signUp(): NetworkResult<User>
suspend fun getUserInfo(): NetworkResult<User>
suspend fun getCachedUserInfo(): User?
fun getCachedUserInfo(): User?

suspend fun getUserPlanStatus(planId: Long): NetworkResult<UserPlanStatus>
suspend fun deleteUserInfo(): NetworkResult<Unit>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ class GetUserInfoUseCase @Inject constructor(
return repository.getUserInfo()
}

suspend fun getCachedUserInfo(): User? = repository.getCachedUserInfo()
fun getCachedUserInfo(): User? = repository.getCachedUserInfo()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.yapp.growth.domain.usecase

import com.yapp.growth.domain.NetworkResult
import com.yapp.growth.domain.entity.UserPlanStatus
import com.yapp.growth.domain.repository.UserRepository
import javax.inject.Inject

class GetUserPlanStatusUseCase @Inject constructor(
private val repository: UserRepository
) {
suspend operator fun invoke(planId: Long): NetworkResult<UserPlanStatus> {
return repository.getUserPlanStatus(planId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,19 @@ private fun PlanzColorTextAppBar(
Box(
modifier = modifier
.fillMaxWidth()
.height(56.dp)
.height(80.dp)
) {
Row(
modifier = Modifier
.align(Alignment.CenterStart)
.padding(start = 20.dp),
horizontalArrangement = Arrangement.spacedBy(4.dp),
){
Text(
text = title,
style = PlanzTypography.h2,
color = MainPurple900,
maxLines = 1,
)

Text(
text = "약속",
style = PlanzTypography.h2,
color = Gray900,
maxLines = 1,
)
}
Text(
modifier = Modifier
.fillMaxWidth()
.padding(start = 20.dp)
.align(Alignment.CenterStart),
text = title,
style = PlanzTypography.h2,
color = Gray900,
maxLines = 1,
)

if(menu != null) {
Icon(
Expand Down Expand Up @@ -229,3 +220,12 @@ fun PlanzExitAppBarPreview() {
onExitClick = {},
)
}

@Preview(showBackground = true)
@Composable
fun PreviewPlanzColorTextWithExitAppBar() {
PlanzColorTextWithExitAppBar(
title = "식사",
onExitClick = { }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -34,13 +33,14 @@ fun PlanzBottomSheetScaffoldLayout(
scaffoldState = scaffoldState,
sheetBackgroundColor = Color.Transparent,
sheetPeekHeight = 0.dp,
sheetShape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp),
sheetContent = {
Column(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
) {
PlanzBottomSheet {
PlanzBottomSheetScaffold {
sheetContent()
}
}
Expand All @@ -53,14 +53,13 @@ fun PlanzBottomSheetScaffoldLayout(


@Composable
fun PlanzBottomSheet(
fun PlanzBottomSheetScaffold(
sheetContent: @Composable () -> Unit
) {
Spacer(
modifier = Modifier
.fillMaxWidth()
.height(24.dp)
.clip(RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp))
.height(20.dp)
.background(color = Color.White)
)

Expand Down Expand Up @@ -157,7 +156,7 @@ fun MonitorPlanBottomSheetContent(timeTable: TimeTable, currentClickUserData: Li
modifier = Modifier
.fillMaxWidth()
.background(Color.White)
.padding(top = 5.dp, start = 20.dp, end = 20.dp)) {
.padding(start = 20.dp, end = 20.dp)) {

Icon(
modifier = Modifier
Expand Down
Loading

0 comments on commit 08f5370

Please sign in to comment.