Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : 대결에 참여한 러너 중 기록이 없는 경우 별도 처리 #233

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ fun calculateAverageAltitude(runnerStatus: RunnerStatus): Double {
}

fun calculateCumulativePacePerMinute(records: List<RunnerRecord>): List<Pair<String, Double>> {
if (records.isEmpty()) return emptyList()

val startTime = records.first().time
return records.drop(1).mapNotNull { record ->
val timeElapsed = Duration.between(startTime, record.time)
Expand All @@ -74,17 +76,19 @@ fun calculateCumulativePacePerMinute(records: List<RunnerRecord>): List<Pair<Str
}

fun calculateDistanceOverTime(records: List<RunnerRecord>): List<Pair<String, Double>> {
val startTime = records.first().time
if (records.isEmpty()) return emptyList()

val startTime = records.first().time
return records.map { record ->
val timeElapsed = Duration.between(startTime, record.time)
Pair(formatDurationToTimeString(timeElapsed), record.distance)
}
}

fun calculateAltitudeOverTime(records: List<RunnerRecord>): List<Pair<String, Double>> {
val startTime = records.first().time
if (records.isEmpty()) return emptyList()

val startTime = records.first().time
return records.map { record ->
val timeElapsed = Duration.between(startTime, record.time)
Pair(formatDurationToTimeString(timeElapsed), record.altitude.roundToInt().toDouble())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import online.partyrun.partyrunapplication.core.model.running_result.ui.BattleRe
import online.partyrun.partyrunapplication.core.model.running_result.ui.RunnerStatusUiModel
import online.partyrun.partyrunapplication.feature.running_result.R
import online.partyrun.partyrunapplication.feature.running_result.component.ChartScreen
import online.partyrun.partyrunapplication.feature.running_result.component.EmptyMapWidget
import online.partyrun.partyrunapplication.feature.running_result.component.FixedBottomNavigationSheet
import online.partyrun.partyrunapplication.feature.running_result.component.ResultLoadFailedBody
import online.partyrun.partyrunapplication.feature.running_result.component.MapWidget
Expand Down Expand Up @@ -133,11 +134,15 @@ private fun BattleResultBody(
.fillMaxWidth()
.heightIn(400.dp) // 지도의 높이는 400dp
) {
MapWidget(
isFromMyPage = isFromMyPage,
targetDistanceFormatted = battleResult.targetDistanceFormatted,
records = selectedRunner?.records
)
if (selectedRunner?.records.isNullOrEmpty()) {
EmptyMapWidget()
} else {
MapWidget(
isFromMyPage = isFromMyPage,
targetDistanceFormatted = battleResult.targetDistanceFormatted,
records = selectedRunner?.records
)
}
}

// 프레임 컴포넌트
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package online.partyrun.partyrunapplication.feature.running_result.component

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
Expand All @@ -14,6 +17,7 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
Expand All @@ -22,6 +26,7 @@ import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.google.android.gms.maps.model.BitmapDescriptor
import com.google.android.gms.maps.model.BitmapDescriptorFactory
Expand All @@ -37,6 +42,7 @@ import com.google.maps.android.compose.Marker
import com.google.maps.android.compose.MarkerState
import com.google.maps.android.compose.Polyline
import com.google.maps.android.compose.rememberCameraPositionState
import online.partyrun.partyrunapplication.core.designsystem.component.LottieImage
import online.partyrun.partyrunapplication.core.designsystem.icon.PartyRunIcons
import online.partyrun.partyrunapplication.core.model.running_result.ui.RunnerRecordUiModel
import online.partyrun.partyrunapplication.feature.running_result.R
Expand Down Expand Up @@ -187,3 +193,29 @@ private fun DistanceBox(targetDistance: String) {
)
}
}

@Composable
fun EmptyMapWidget() {
Column(
modifier = Modifier
.fillMaxSize()
.background(color = MaterialTheme.colorScheme.onPrimary),
verticalArrangement = Arrangement.Top,
horizontalAlignment = Alignment.CenterHorizontally
) {
LottieImage(
modifier = Modifier
.size(250.dp)
.padding(top = 70.dp),
rawAnimation = R.raw.no_records
)
}
Box(
modifier = Modifier
.padding(10.dp)
.clip(RoundedCornerShape(15.dp))
.background(color = MaterialTheme.colorScheme.primary)
) {
DistanceBox(stringResource(id = R.string.empty_records))
}
}
1 change: 1 addition & 0 deletions feature/running_result/src/main/res/raw/no_records.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions feature/running_result/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<string name="distance">거리</string>
<string name="pace">페이스</string>
<string name="altitude">고도</string>
<string name="empty_records">달린 기록이 없어요.</string>

<string name="navigate_to_top_level">돌아가기</string>

Expand Down