Skip to content

Commit b4b315d

Browse files
authored
Merge pull request #31 from Nexters/feature/add-create-proposal-by-gathering
모임 만남 제안 화면을 구현합니다.
2 parents da4f84d + 44b0c67 commit b4b315d

File tree

31 files changed

+879
-41
lines changed

31 files changed

+879
-41
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.plottwist.core.data.mapper.toDomainModel
44
import com.plottwist.core.domain.gathering.repository.GatheringRepository
55
import com.plottwist.core.domain.model.GatheringDetail
66
import com.plottwist.core.domain.model.Gatherings
7+
import com.plottwist.core.domain.model.Purposes
78
import com.plottwist.core.network.service.TukApiService
89
import javax.inject.Inject
910

@@ -25,4 +26,12 @@ class GatheringRepositoryImpl @Inject constructor(
2526
Result.failure(e)
2627
}
2728
}
29+
30+
override suspend fun getPurposes(): Result<Purposes> {
31+
return try {
32+
Result.success(tukApiService.getPurposes().toDomainModel())
33+
} catch (e: Exception) {
34+
Result.failure(e)
35+
}
36+
}
2837
}

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ class JoinGatheringRepositoryImpl @Inject constructor(
88
private val dataSource: JoinGatheringDataSource
99
) :JoinGatheringRepository{
1010
override suspend fun joinGathering(gatheringId: Long): Result<Long> {
11-
val response = dataSource.joinGathering(gatheringId)
12-
return if (response.success) {
13-
val id = response.data?.id
14-
if (id != null) Result.success(id)
15-
else Result.failure(Exception("ID 없음"))
16-
} else {
17-
Result.failure(Exception(response.meta?.errorMessage ?: "알 수 없는 에러"))
11+
try {
12+
val response = dataSource.joinGathering(gatheringId)
13+
return if (response.success) {
14+
val id = response.data?.id
15+
if (id != null) Result.success(id)
16+
else Result.failure(Exception("ID 없음"))
17+
} else {
18+
Result.failure(Exception(response.meta?.errorMessage ?: "알 수 없는 에러"))
19+
}
20+
}catch (e: Exception) {
21+
return Result.failure(e)
1822
}
1923
}
20-
}
24+
}

core/data/src/main/java/com/plottwist/core/data/mapper/Gathering.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import com.plottwist.core.domain.model.GatheringDetail
44
import com.plottwist.core.domain.model.GatheringMember
55
import com.plottwist.core.domain.model.GatheringOverviews
66
import com.plottwist.core.domain.model.Gatherings
7+
import com.plottwist.core.domain.model.Purposes
78
import com.plottwist.core.network.model.gathering.GatheringDetailData
89
import com.plottwist.core.network.model.gathering.GatheringMemberData
910
import com.plottwist.core.network.model.gathering.GatheringOverviewsData
1011
import com.plottwist.core.network.model.gathering.GatheringsData
12+
import com.plottwist.core.network.model.gathering.GetPurposesResponse
1113

1214
fun GatheringsData.toDomainModel() : Gatherings {
1315
return Gatherings(
@@ -22,15 +24,16 @@ fun GatheringOverviewsData.toDomainModel() : GatheringOverviews {
2224
return GatheringOverviews(
2325
gatheringId = this.gatheringId,
2426
gatheringName = this.gatheringName,
25-
lastNotificationRelativeTime = this.lastNotificationRelativeTime
27+
lastPushRelativeTime = this.lastPushRelativeTime
2628
)
2729
}
2830

2931
fun GatheringDetailData.toDomainModel() : GatheringDetail {
3032
return GatheringDetail(
3133
gatheringId = this.gatheringId,
3234
gatheringName = this.gatheringName,
33-
lastNotificationRelativeTime = this.lastNotificationRelativeTime,
35+
lastPushRelativeTime = this.lastPushRelativeTime,
36+
gatheringIntervalDays = this.gatheringIntervalDays,
3437
sentProposalCount = this.sentProposalCount,
3538
receivedProposalCount = this.receivedProposalCount,
3639
members = this.members.map { it.toDomainModel() }
@@ -43,3 +46,11 @@ fun GatheringMemberData.toDomainModel() : GatheringMember {
4346
memberName = this.memberName
4447
)
4548
}
49+
50+
fun GetPurposesResponse.toDomainModel() : Purposes {
51+
return Purposes(
52+
whatTags = this.data.whatTags,
53+
whereTags = this.data.whereTags,
54+
whenTags = this.data.whenTags
55+
)
56+
}

core/data/src/main/java/com/plottwist/core/data/onboarding/OnboardingRepositoryImpl.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ class OnboardingRepositoryImpl @Inject constructor(
1414
override suspend fun updateOnboardingInfo(
1515
name: String
1616
): Result<Unit> {
17-
val result = onboardingService.updateOnboardingInfo(UpdateOnboardingInfoRequest(name))
17+
try {
18+
val result = onboardingService.updateOnboardingInfo(UpdateOnboardingInfoRequest(name))
1819

19-
if (result.success) {
20-
authDataSource.setOnboardingCompleted(true).collect()
21-
return Result.success(Unit)
22-
}
20+
if (result.success) {
21+
authDataSource.setOnboardingCompleted(true).collect()
22+
return Result.success(Unit)
23+
}
2324

24-
return Result.failure(Exception("Fail to update onboarding info"))
25+
return Result.failure(Exception("Fail to update onboarding info"))
26+
} catch (e:Exception) {
27+
return Result.failure(Exception(e))
28+
}
2529
}
2630
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="14dp"
3+
android:height="14dp"
4+
android:viewportWidth="14"
5+
android:viewportHeight="14">
6+
<path
7+
android:pathData="M5.035,9.665L11.968,3.171C12.087,3.06 12.226,3.002 12.387,3C12.546,2.998 12.689,3.055 12.813,3.171C12.938,3.288 13,3.422 13,3.573C13,3.725 12.938,3.859 12.813,3.975L5.543,10.796C5.398,10.932 5.228,11 5.035,11C4.842,11 4.672,10.932 4.527,10.796L1.177,7.658C1.057,7.546 0.998,7.414 1,7.26C1.002,7.106 1.064,6.971 1.189,6.854C1.314,6.738 1.457,6.68 1.618,6.68C1.78,6.68 1.923,6.738 2.047,6.854L5.035,9.665Z"
8+
android:fillColor="#ffffff"/>
9+
</vector>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="14dp"
3+
android:height="14dp"
4+
android:viewportWidth="14"
5+
android:viewportHeight="14">
6+
<path
7+
android:pathData="M0,14V9.893L9.34,0.588C9.749,0.191 10.238,-0.005 10.807,0C11.376,0.005 11.855,0.214 12.243,0.628L13.422,1.833C13.81,2.241 14.002,2.732 14,3.304C13.998,3.877 13.794,4.359 13.39,4.751L4.113,14H0ZM1.266,12.721H3.605L9.805,6.53L8.648,5.374L7.492,4.217L1.266,10.408V12.721Z"
8+
android:fillColor="#1F1F1F"/>
9+
</vector>

core/designsystem/src/main/res/drawable/ic_refresh.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
android:viewportWidth="21"
55
android:viewportHeight="20">
66
<path
7-
android:pathData="M10.481,16.836C8.576,16.836 6.961,16.173 5.634,14.846C4.308,13.519 3.645,11.904 3.645,10C3.645,8.095 4.308,6.48 5.634,5.154C6.961,3.827 8.576,3.164 10.481,3.164C11.469,3.164 12.411,3.367 13.308,3.772C14.204,4.178 14.972,4.761 15.61,5.52V3.164H17.357V9.241H11.274V7.5H14.744C14.3,6.742 13.7,6.146 12.944,5.711C12.188,5.277 11.367,5.06 10.481,5.06C9.108,5.06 7.942,5.54 6.981,6.5C6.021,7.461 5.54,8.628 5.54,10C5.54,11.372 6.021,12.538 6.981,13.499C7.942,14.46 9.108,14.94 10.481,14.94C11.53,14.94 12.48,14.639 13.329,14.038C14.179,13.437 14.779,12.647 15.129,11.666H17.113C16.721,13.185 15.911,14.426 14.684,15.39C13.456,16.354 12.055,16.836 10.481,16.836Z"
7+
android:pathData="M10.519,16.836C12.424,16.836 14.039,16.173 15.366,14.846C16.692,13.52 17.355,11.904 17.355,10C17.355,8.096 16.692,6.48 15.366,5.154C14.039,3.827 12.424,3.164 10.519,3.164C9.531,3.164 8.589,3.367 7.692,3.773C6.796,4.179 6.028,4.761 5.39,5.521V3.164H3.643V9.242H9.726V7.5H6.256C6.7,6.742 7.3,6.146 8.056,5.712C8.812,5.277 9.633,5.06 10.519,5.06C11.892,5.06 13.058,5.54 14.019,6.501C14.979,7.461 15.46,8.628 15.46,10C15.46,11.372 14.979,12.539 14.019,13.5C13.058,14.46 11.892,14.94 10.519,14.94C9.47,14.94 8.52,14.64 7.671,14.039C6.821,13.438 6.221,12.647 5.871,11.667H3.887C4.279,13.186 5.089,14.427 6.317,15.391C7.544,16.354 8.945,16.836 10.519,16.836Z"
88
android:fillColor="#1F1F1F"/>
99
</vector>

core/designsystem/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@
4242
<string name="invite_gathering_share">공유하기</string>
4343

4444

45+
46+
<string name="common_next">다음</string>
47+
4548
</resources>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package com.plottwist.core.domain.gathering.repository
22

33
import com.plottwist.core.domain.model.GatheringDetail
44
import com.plottwist.core.domain.model.Gatherings
5+
import com.plottwist.core.domain.model.Purposes
56

67
interface GatheringRepository {
78
suspend fun getGatherings(): Result<Gatherings>
89
suspend fun getGatheringDetail(gatheringId: Long): Result<GatheringDetail>
10+
suspend fun getPurposes(): Result<Purposes>
911
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.plottwist.core.domain.gathering.usecase
2+
3+
import com.plottwist.core.domain.gathering.repository.GatheringRepository
4+
import com.plottwist.core.domain.model.Purposes
5+
import javax.inject.Inject
6+
7+
class GetPurposesUseCase @Inject constructor(
8+
private val gatheringRepository: GatheringRepository
9+
) {
10+
suspend operator fun invoke(): Result<Purposes> {
11+
return gatheringRepository.getPurposes()
12+
}
13+
}

0 commit comments

Comments
 (0)