Skip to content

Commit ef80290

Browse files
authored
Merge pull request #42 from Nexters/faeture/add-alarm-setting
모임 상세에서 모임 주기 설정 화면으로 이동하여 모임 주기를 설정할 수 있습니다.
2 parents adbed3b + 0bad8e2 commit ef80290

File tree

18 files changed

+383
-32
lines changed

18 files changed

+383
-32
lines changed

core/data/src/main/java/com/plottwist/core/data/gathering/repository/GatheringRepository.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.plottwist.core.domain.model.Proposal
88
import com.plottwist.core.domain.model.Purposes
99
import com.plottwist.core.network.model.gathering.CreateProposeData
1010
import com.plottwist.core.network.model.gathering.CreateProposeRequest
11+
import com.plottwist.core.network.model.gathering.UpdateGatheringRequest
1112
import com.plottwist.core.network.service.TukApiService
1213
import javax.inject.Inject
1314

@@ -65,4 +66,26 @@ class GatheringRepositoryImpl @Inject constructor(
6566
return Result.failure(e)
6667
}
6768
}
69+
70+
override suspend fun updateGathering(
71+
gatheringId: Long,
72+
intervalDays: Int
73+
) : Result<Unit> {
74+
try {
75+
val result = tukApiService.updateGathering(
76+
gatheringId = gatheringId,
77+
updateGatheringRequest = UpdateGatheringRequest(
78+
gatheringIntervalDays = intervalDays
79+
)
80+
)
81+
82+
return if(result.success) {
83+
Result.success(Unit)
84+
}else {
85+
Result.failure(Exception(result.meta?.errorMessage))
86+
}
87+
} catch (e: Exception) {
88+
return Result.failure(e)
89+
}
90+
}
6891
}

core/domain/src/main/java/com/plottwist/core/domain/gathering/repository/GatheringRepository.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ interface GatheringRepository {
1515
whenTag: String,
1616
whatTag: String
1717
): Result<Proposal>
18+
suspend fun updateGathering(
19+
gatheringId: Long,
20+
intervalDays: Int
21+
) : Result<Unit>
1822
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.plottwist.core.domain.gathering.usecase
2+
3+
import com.plottwist.core.domain.gathering.repository.GatheringRepository
4+
import javax.inject.Inject
5+
6+
class UpdateGatheringUseCase @Inject constructor(
7+
private val repository: GatheringRepository
8+
){
9+
suspend operator fun invoke(
10+
gatheringId: Long,
11+
intervalDays: Int
12+
):Result<Unit> {
13+
return repository.updateGathering(gatheringId, intervalDays)
14+
}
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.plottwist.core.domain.model
2+
3+
val gatheringIntervalDaysOptions = listOf(
4+
Triple(30, "한달", "매월 만남"),
5+
Triple(60, "2개월", "2개월 마다 만남"),
6+
Triple(90, "3개월", "분기별 만남"),
7+
Triple(180, "6개월", "6개월 마다 만남")
8+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.plottwist.core.network.model.gathering
2+
3+
import kotlinx.serialization.Serializable
4+
5+
@Serializable
6+
data class UpdateGatheringRequest(
7+
val gatheringIntervalDays: Int
8+
)
9+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.plottwist.core.network.model.gathering
2+
3+
import com.plottwist.core.network.model.auth.Meta
4+
import kotlinx.serialization.Serializable
5+
6+
7+
@Serializable
8+
data class UpdateGatheringResponse(
9+
val success: Boolean,
10+
val data: UpdateGatheringData,
11+
val meta: Meta?
12+
)
13+
14+
@Serializable
15+
data class UpdateGatheringData(
16+
val gatheringId: Long,
17+
val gatheringName: String,
18+
val intervalDays: Int
19+
)

core/network/src/main/java/com/plottwist/core/network/service/TukApiService.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import com.plottwist.core.network.model.gathering.GatheringDetailResponse
1010
import com.plottwist.core.network.model.gathering.GatheringsResponse
1111
import com.plottwist.core.network.model.gathering.GetPurposesResponse
1212
import com.plottwist.core.network.model.gathering.GetTagsResponse
13+
import com.plottwist.core.network.model.gathering.UpdateGatheringRequest
14+
import com.plottwist.core.network.model.gathering.UpdateGatheringResponse
1315
import retrofit2.Response
1416
import retrofit2.http.Body
1517
import retrofit2.http.GET
18+
import retrofit2.http.PATCH
1619
import retrofit2.http.POST
1720
import retrofit2.http.Path
1821

@@ -46,10 +49,15 @@ interface TukApiService {
4649
@Path("gatheringId") gatheringId: Long
4750
): GetGatheringNameResponse
4851

49-
5052
@POST("/api/v1/gatherings/{gatheringId}/proposals")
5153
suspend fun createPropose(
5254
@Path("gatheringId") gatheringId: Long?,
5355
@Body createProposeRequest : CreateProposeRequest
5456
): CreateProposeResponse
57+
58+
@PATCH("/api/v1/gatherings/{gatheringId}")
59+
suspend fun updateGathering(
60+
@Path("gatheringId") gatheringId: Long?,
61+
@Body updateGatheringRequest : UpdateGatheringRequest
62+
): UpdateGatheringResponse
5563
}

core/ui-navigation/src/main/java/com/plottwist/core/ui/navigation/Route.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,10 @@ sealed interface Route {
7777

7878
@Serializable
7979
data class CompleteProposal(val encodedUrl : String): Route
80+
81+
@Serializable
82+
data class GatheringAlarmSetting(
83+
val gatheringId: Long,
84+
val selectedIntervalDays : Long
85+
): Route
8086
}

feature/create_gathering/src/main/java/com/plottwist/create_gathering/page/IntervalDaysPage.kt

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,20 @@
11
package com.plottwist.create_gathering.page
22

3-
import androidx.compose.foundation.clickable
43
import androidx.compose.foundation.layout.Arrangement
5-
import androidx.compose.foundation.layout.Column
64
import androidx.compose.foundation.layout.Row
7-
import androidx.compose.foundation.layout.Spacer
8-
import androidx.compose.foundation.layout.fillMaxSize
95
import androidx.compose.foundation.layout.fillMaxWidth
10-
import androidx.compose.foundation.layout.height
116
import androidx.compose.foundation.layout.padding
12-
import androidx.compose.foundation.lazy.items
137
import androidx.compose.foundation.lazy.itemsIndexed
14-
import androidx.compose.material3.Text
158
import androidx.compose.runtime.Composable
16-
import androidx.compose.ui.Alignment
179
import androidx.compose.ui.Modifier
18-
import androidx.compose.ui.graphics.Color
19-
import androidx.compose.ui.text.TextStyle
20-
import androidx.compose.ui.text.style.TextDecoration
2110
import androidx.compose.ui.tooling.preview.Preview
2211
import androidx.compose.ui.unit.dp
23-
import androidx.compose.ui.unit.sp
2412
import com.plottwist.core.designsystem.component.TukOutlinedButton
2513
import com.plottwist.core.designsystem.component.TukSolidButton
2614
import com.plottwist.core.designsystem.component.TukSolidButtonType
27-
import com.plottwist.core.designsystem.foundation.type.TukPretendardTypography
15+
import com.plottwist.core.domain.model.gatheringIntervalDaysOptions
2816
import com.plottwist.core.ui.component.RadioButtonItem
29-
import com.plottwist.core.ui.component.StableImage
3017
import com.plottwist.core.ui.component.TukScaffold
31-
import com.plottwist.tuk.feature.create_gathering.R
3218

3319
@Composable
3420
fun CreateGatheringSelectIntervalDays(
@@ -37,12 +23,6 @@ fun CreateGatheringSelectIntervalDays(
3723
onClickPrev: () -> Unit,
3824
onNext: () -> Unit
3925
) {
40-
val options = listOf(
41-
Triple(30, "한달", "매월 만남"),
42-
Triple(60, "2개월", "2개월 마다 만남"),
43-
Triple(90, "3개월", "분기별 만남"),
44-
Triple(180, "6개월", "6개월 마다 만남")
45-
)
4626
TukScaffold(
4727
title = "앞으로는 얼마나\n자주 만나면 좋을까요?",
4828
description = "부담없는 주기가 제일 오래가요",
@@ -71,13 +51,13 @@ fun CreateGatheringSelectIntervalDays(
7151
}
7252
) {
7353

74-
itemsIndexed(options) { index, (days, title, subtitle) ->
54+
itemsIndexed(gatheringIntervalDaysOptions) { index, (days, title, subtitle) ->
7555
RadioButtonItem(
7656
title = title,
7757
subtitle = subtitle,
7858
selected = selectedOption == days,
7959
onClick = { onOptionSelected(days) },
80-
hasDivider = index < options.lastIndex
60+
hasDivider = index < gatheringIntervalDaysOptions.lastIndex
8161
)
8262
}
8363
}

feature/gathering-detail/src/main/java/com/plottwist/feature/gathering_detail/GatheringDetailContract.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ sealed class GatheringDetailAction {
1212
data object ClickReceivedProposal: GatheringDetailAction()
1313
data object ClickInviteMember: GatheringDetailAction()
1414
data object ClickProposal: GatheringDetailAction()
15+
data object ClickAlarmSetting: GatheringDetailAction()
1516
}
1617

1718
sealed class GatheringDetailSideEffect {
@@ -22,4 +23,8 @@ sealed class GatheringDetailSideEffect {
2223
val gatheringId: Long,
2324
val gatheringName: String
2425
): GatheringDetailSideEffect()
26+
data class NavigateToGatheringDetailAlarmSetting(
27+
val gatheringId: Long,
28+
val selectedIntervalDays: Long
29+
): GatheringDetailSideEffect()
2530
}

0 commit comments

Comments
 (0)