-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from SWM-KAWAI-MANS/PAR-381
#PAR-381 : 싱글 모드 단일 조회 API 연동 + Shimmer Effect 적용
- Loading branch information
Showing
18 changed files
with
362 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 17 additions & 26 deletions
43
...ain/java/online/partyrun/partyrunapplication/core/designsystem/component/ShimmerEffect.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,41 @@ | ||
package online.partyrun.partyrunapplication.core.designsystem.component | ||
|
||
import androidx.compose.animation.core.animateFloat | ||
import androidx.compose.animation.core.infiniteRepeatable | ||
import androidx.compose.animation.core.rememberInfiniteTransition | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.animation.core.* | ||
import androidx.compose.foundation.background | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.composed | ||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.graphics.Brush | ||
import androidx.compose.ui.layout.onGloballyPositioned | ||
import androidx.compose.ui.unit.IntSize | ||
import online.partyrun.partyrunapplication.core.designsystem.theme.Purple50 | ||
import online.partyrun.partyrunapplication.core.designsystem.theme.Purple60 | ||
import online.partyrun.partyrunapplication.core.designsystem.theme.* | ||
|
||
private const val shimmerAnimationDuration = 1000 | ||
private const val SHIMMER_ANIMATION_DURATION = 1000 | ||
|
||
fun Modifier.shimmerEffect(): Modifier = composed { | ||
var size by remember { | ||
mutableStateOf(IntSize.Zero) | ||
} | ||
private val DarkThemeColors = listOf(Gray20, Gray10, Gray20) | ||
private val PartyRunThemeColors = listOf(Purple60, Purple50, Purple60) | ||
|
||
fun Modifier.shimmerEffect(isDarkTheme: Boolean): Modifier = composed { | ||
val colors = if (isDarkTheme) DarkThemeColors else PartyRunThemeColors | ||
|
||
var size by remember { mutableStateOf(IntSize.Zero) } | ||
val transition = rememberInfiniteTransition() | ||
val startOffsetX by transition.animateFloat( | ||
initialValue = -2 * size.width.toFloat(), | ||
targetValue = 2 * size.width.toFloat(), | ||
animationSpec = infiniteRepeatable( | ||
animation = tween(shimmerAnimationDuration) | ||
animation = tween(SHIMMER_ANIMATION_DURATION) | ||
) | ||
) | ||
|
||
background( | ||
brush = Brush.linearGradient( | ||
colors = listOf( | ||
Purple60, | ||
Purple50, | ||
Purple60, | ||
), | ||
colors = colors, | ||
start = Offset(startOffsetX, 0f), | ||
end = Offset(startOffsetX + size.width.toFloat(), size.height.toFloat()) | ||
) | ||
) | ||
.onGloballyPositioned { | ||
size = it.size | ||
} | ||
} | ||
).onGloballyPositioned { | ||
size = it.size | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...n/java/online/partyrun/partyrunapplication/core/domain/my_page/GetSingleHistoryUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package online.partyrun.partyrunapplication.core.domain.my_page | ||
|
||
import online.partyrun.partyrunapplication.core.data.repository.ResultRepository | ||
import javax.inject.Inject | ||
|
||
class GetSingleHistoryUseCase @Inject constructor( | ||
private val resultRepository: ResultRepository | ||
) { | ||
suspend operator fun invoke() = resultRepository.getSingleHistory() | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
.../main/java/online/partyrun/partyrunapplication/core/model/my_page/RunningHistoryDetail.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package online.partyrun.partyrunapplication.core.model.my_page | ||
|
||
data class RunningHistoryDetail( | ||
val id: String, | ||
val date: String, | ||
val runningTime: String, | ||
val distanceFormatted: String | ||
) |
5 changes: 5 additions & 0 deletions
5
.../main/java/online/partyrun/partyrunapplication/core/model/my_page/SingleRunningHistory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package online.partyrun.partyrunapplication.core.model.my_page | ||
|
||
data class SingleRunningHistory( | ||
val history: List<RunningHistoryDetail> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...e/partyrun/partyrunapplication/core/network/model/response/SingleHistoryDetailResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package online.partyrun.partyrunapplication.core.network.model.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import online.partyrun.partyrunapplication.core.model.my_page.RunningHistoryDetail | ||
import online.partyrun.partyrunapplication.core.model.running.RunningTime | ||
import online.partyrun.partyrunapplication.core.model.running.toElapsedTimeString | ||
import online.partyrun.partyrunapplication.core.model.util.DateTimeUtils | ||
import online.partyrun.partyrunapplication.core.network.model.util.formatDate | ||
import online.partyrun.partyrunapplication.core.network.model.util.formatDistanceWithComma | ||
import java.time.LocalDateTime | ||
|
||
data class SingleHistoryDetailResponse( | ||
@SerializedName("id") | ||
val id: String?, | ||
@SerializedName("startTime") | ||
val startTime: String?, | ||
@SerializedName("runningTime") | ||
val runningTime: RunningTime?, | ||
@SerializedName("distance") | ||
val distance: Double? | ||
) | ||
|
||
fun SingleHistoryDetailResponse.toDomainModel(): RunningHistoryDetail { | ||
val parsedDate = startTime?.let { | ||
LocalDateTime.parse( | ||
it, | ||
DateTimeUtils.localDateTimeFormatter | ||
) | ||
} | ||
|
||
return RunningHistoryDetail( | ||
id = this.id ?: "", | ||
date = parsedDate?.let { formatDate(it) } ?: "", | ||
runningTime = this.runningTime?.toElapsedTimeString() ?: "00:00:00", | ||
distanceFormatted = formatDistanceWithComma(this.distance?.toInt() ?: 0) | ||
) | ||
} |
14 changes: 14 additions & 0 deletions
14
.../online/partyrun/partyrunapplication/core/network/model/response/SingleHistoryResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package online.partyrun.partyrunapplication.core.network.model.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import online.partyrun.partyrunapplication.core.model.my_page.SingleRunningHistory | ||
|
||
data class SingleHistoryResponse( | ||
@SerializedName("history") | ||
val history: List<SingleHistoryDetailResponse>? | ||
) | ||
|
||
fun SingleHistoryResponse.toDomainModel(): SingleRunningHistory { | ||
val transformedHistory = history?.map { it.toDomainModel() }?.reversed() ?: emptyList() | ||
return SingleRunningHistory(history = transformedHistory) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.