Skip to content

Commit

Permalink
[Feature/#906] soptamp report api 연결 및 웹뷰 연결 (#911)
Browse files Browse the repository at this point in the history
* feature #906: change navBack check

* feature #906: change background color

* feature #906: connect report button with webView

* feature #906: add default value and check current

* feature #906: change apis

* feature #906: change apis

* feature #906: feat stamp url api

* feature #906: feat dialog design

* feature #906: change navBack check

* feature #906: change background color

* feature #906: connect report button with webView

* feature #906: add default value and check current

* feature #906: change apis

* feature #906: change apis

* feature #906: feat stamp url api

* feature #906: feat dialog design

* feature #906: change collectAsState ->
collectAsStateWithLifecycle

* feature #906: delete unused file

* feature #906: apply BaselineProfile

* feature #906: apply spotlessApply
  • Loading branch information
chattymin authored Oct 16, 2024
1 parent e7b182a commit 9785e2f
Show file tree
Hide file tree
Showing 32 changed files with 583 additions and 1,770 deletions.
345 changes: 155 additions & 190 deletions app/src/release/generated/baselineProfiles/baseline-prof.txt

Large diffs are not rendered by default.

345 changes: 155 additions & 190 deletions app/src/release/generated/baselineProfiles/startup-prof.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
package org.sopt.official.data.soptamp.remote.api

import org.sopt.official.data.soptamp.remote.model.response.MissionResponse
import org.sopt.official.data.soptamp.remote.model.response.MissionStatusResponse
import retrofit2.http.GET

internal interface SoptampService {
@GET("mission/all")
suspend fun getAllMissions(): List<MissionResponse>

@GET("mission/complete")
suspend fun getCompleteMissions(): List<MissionResponse>
suspend fun getCompleteMissions(): List<MissionStatusResponse>

@GET("mission/incomplete")
suspend fun getIncompleteMissions(): List<MissionResponse>
suspend fun getIncompleteMissions(): List<MissionStatusResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package org.sopt.official.data.soptamp.remote.api

import org.sopt.official.data.soptamp.remote.model.request.StampRequest
import org.sopt.official.data.soptamp.remote.model.response.ModifyStampResponse
import org.sopt.official.data.soptamp.remote.model.response.ReportUrlResponse
import org.sopt.official.data.soptamp.remote.model.response.S3URLResponse
import org.sopt.official.data.soptamp.remote.model.response.StampResponse
import retrofit2.http.Body
Expand All @@ -52,6 +53,9 @@ interface StampService {
@DELETE("stamp/all")
suspend fun deleteAllStamps()

@GET("stamp/report")
suspend fun getReportUrl(): ReportUrlResponse

@GET("s3/stamp")
suspend fun getS3URL(): S3URLResponse
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MIT License
* Copyright 2023-2024 SOPT - Shout Our Passion Together
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -22,21 +22,18 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.sopt.official.stamp.feature.setting.component.section

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.sopt.official.stamp.designsystem.style.SoptTheme
package org.sopt.official.data.soptamp.remote.mapper

@Composable
fun Header(modifier: Modifier, title: String) {
Text(
text = title,
style = SoptTheme.typography.caption1,
color = SoptTheme.colors.onSurface50,
modifier = modifier.padding(bottom = 4.dp)
)
}
import org.sopt.official.data.soptamp.remote.model.MissionData
import org.sopt.official.data.soptamp.remote.model.response.MissionStatusResponse

internal fun List<MissionStatusResponse>.toData(isCompleted: Boolean = false): List<MissionData> = this.map { it.toData(isCompleted) }

internal fun MissionStatusResponse.toData(isCompleted: Boolean = false): MissionData = MissionData(
id = this.id,
title = this.title,
level = this.level,
profileImage = this.profileImage,
isCompleted = isCompleted
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package org.sopt.official.data.soptamp.remote.model.response

import kotlinx.serialization.Serializable

@Serializable
data class MissionStatusResponse(
val id: Int,
val title: String,
val level: Int,
val profileImage: List<String>?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* MIT License
* Copyright 2024 SOPT - Shout Our Passion Together
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package org.sopt.official.data.soptamp.remote.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class ReportUrlResponse(
@SerialName("reportUrl")
val reportUrl: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.sopt.official.data.soptamp.remote.model.MissionData
import org.sopt.official.data.soptamp.source.MissionsDataSource

internal class RemoteMissionsDataSource @Inject constructor(
private val soptampService: SoptampService
private val soptampService: SoptampService,
) : MissionsDataSource {
override suspend fun getAllMission(): Result<List<MissionData>> {
val result = kotlin.runCatching { soptampService.getAllMissions().toData() }
Expand All @@ -43,4 +43,12 @@ internal class RemoteMissionsDataSource @Inject constructor(
else -> Result.failure(exception)
}
}

override suspend fun getCompleteMissions(): Result<List<MissionData>> = runCatching {
soptampService.getCompleteMissions().toData(true)
}

override suspend fun getIncompleteMissions(): Result<List<MissionData>> = runCatching {
soptampService.getIncompleteMissions().toData()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
package org.sopt.official.data.soptamp.repository

import javax.inject.Inject
import org.sopt.official.data.soptamp.error.ErrorData
import org.sopt.official.data.soptamp.mapper.toDomain
import org.sopt.official.data.soptamp.source.MissionsDataSource
import org.sopt.official.domain.soptamp.model.Mission
import org.sopt.official.domain.soptamp.repository.MissionsRepository
import javax.inject.Inject

internal class RemoteMissionsRepository @Inject constructor(
private val remote: MissionsDataSource
private val remote: MissionsDataSource,
) : MissionsRepository {
override suspend fun getAllMissions(): Result<List<Mission>> {
val result = remote.getAllMission()
Expand All @@ -46,10 +46,8 @@ internal class RemoteMissionsRepository @Inject constructor(
}

override suspend fun getCompleteMissions(): Result<List<Mission>> {
val result = remote.getAllMission()
.mapCatching {
it.filter { mission -> mission.isCompleted }.toDomain()
}
val result = remote.getCompleteMissions().map { it.toDomain() }

val exception = result.exceptionOrNull()
return if (exception is ErrorData) {
Result.failure(exception.toDomain())
Expand All @@ -59,8 +57,8 @@ internal class RemoteMissionsRepository @Inject constructor(
}

override suspend fun getInCompleteMissions(): Result<List<Mission>> {
val result = remote.getAllMission()
.mapCatching { it.filter { mission -> !mission.isCompleted }.toDomain() }
val result = remote.getIncompleteMissions().map { it.toDomain() }

val exception = result.exceptionOrNull()
return if (exception is ErrorData) {
Result.failure(exception.toDomain())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,16 @@
*/
package org.sopt.official.data.soptamp.repository

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import org.sopt.official.data.soptamp.remote.api.StampService
import org.sopt.official.data.soptamp.remote.mapper.toData
import org.sopt.official.domain.soptamp.model.Archive
import org.sopt.official.domain.soptamp.model.Stamp
import org.sopt.official.domain.soptamp.repository.StampRepository
import javax.inject.Inject

class StampRepositoryImpl @Inject constructor(
@ApplicationContext private val context: Context,
private val service: StampService,
private val json: Json
) : StampRepository {
@Serializable
private data class Content(
@SerialName("contents")
val contents: String
)

override suspend fun completeMission(stamp: Stamp): Result<Archive> {
return runCatching {
Expand Down Expand Up @@ -80,6 +68,10 @@ class StampRepositoryImpl @Inject constructor(
}
}

override suspend fun getReportUrl(): Result<String> = runCatching {
service.getReportUrl().reportUrl
}

override suspend fun deleteAllStamps(): Result<Unit> {
return runCatching { service.deleteAllStamps() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ import org.sopt.official.data.soptamp.remote.model.MissionData

interface MissionsDataSource {
suspend fun getAllMission(): Result<List<MissionData>>
suspend fun getCompleteMissions(): Result<List<MissionData>>
suspend fun getIncompleteMissions(): Result<List<MissionData>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ object FakeStampRepository : StampRepository {
override suspend fun deleteMission(missionId: Int) = runCatching { }

override suspend fun deleteAllStamps(): Result<Unit> = runCatching { }

override suspend fun getReportUrl(): Result<String> = runCatching { "" }
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ interface StampRepository {
suspend fun deleteMission(missionId: Int): Result<Unit>

suspend fun deleteAllStamps(): Result<Unit>

suspend fun getReportUrl(): Result<String>
}
5 changes: 5 additions & 0 deletions feature/soptamp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ android {
}

dependencies {
// domain
implementation(projects.domain.soptamp)
implementation(projects.domain.mypage)

// core
implementation(projects.core.common)
implementation(projects.core.analytics)
implementation(projects.core.webview)

implementation(libs.kotlin.datetime)
implementation(libs.kotlin.collections.immutable)
implementation(platform(libs.compose.bom))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.AlertDialog
import androidx.compose.material3.Text
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.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import org.sopt.official.stamp.designsystem.component.util.noRippleClickable
import org.sopt.official.stamp.designsystem.style.SoptTheme
Expand All @@ -53,33 +55,34 @@ fun SingleOptionDialog(onConfirm: () -> Unit) {
AlertDialog(
onDismissRequest = { onConfirm() },
title = {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.fillMaxWidth()
Column(
modifier = Modifier
.padding(horizontal = 7.dp, vertical = 12.dp)
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
Column {
Text(
text = "네트워크가 원활하지 않습니다.",
style = SoptTheme.typography.sub1,
color = Color.Black
)
Spacer(modifier = Modifier.size(13.dp))
Text(
text = "인터넷 연결을 확인하고 다시 시도해 주세요.",
style = SoptTheme.typography.caption3,
color = SoptTheme.colors.onSurface50
)
Spacer(modifier = Modifier.size(28.dp))
}
Text(
text = "네트워크가 원활하지 않습니다.",
style = SoptTheme.typography.sub1,
color = Color.Black
)
Spacer(modifier = Modifier.padding(vertical = 10.dp))
Text(
text = "인터넷 연결을 확인하고 다시 시도해 주세요.",
style = SoptTheme.typography.caption3,
color = SoptTheme.colors.onSurface90
)
}
},
buttons = {
Box(
modifier = Modifier
.padding(horizontal = 7.dp, vertical = 12.dp)
.fillMaxWidth()
.background(color = Color(0xFFFF8080))
.clip(RoundedCornerShape(10.dp))
.background(color = SoptTheme.colors.black)
.noRippleClickable { onConfirm() }
.padding(vertical = 15.dp),
.padding(vertical = 10.dp),
contentAlignment = Alignment.Center
) {
Text(
Expand All @@ -92,3 +95,11 @@ fun SingleOptionDialog(onConfirm: () -> Unit) {
)
}
}

@Preview
@Composable
fun SingleOptionDialogPreview() {
SoptTheme {
SingleOptionDialog(onConfirm = { })
}
}
Loading

0 comments on commit 9785e2f

Please sign in to comment.