Skip to content
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 @@ -79,7 +79,14 @@ internal fun HistoryScreen(
uiState = uiState,
modifier = modifier,
pagerState = pagerState,
onClickHistoryItem = { viewModel.onIntent(HistoryUiIntent.ClickItem(presentationId = it.presentationId)) },
onClickHistoryItem = { item, pageType ->
viewModel.onIntent(
HistoryUiIntent.ClickItem(
presentationId = item.presentationId,
pageType = pageType,
),
)
},
onClickAddPresentation = navigateToAnalysis,
)
}
Expand All @@ -89,7 +96,7 @@ internal fun HistoryScreen(
internal fun HistoryScreen(
uiState: HistoryUiState,
pagerState: PagerState,
onClickHistoryItem: (HistoryUiModel) -> Unit,
onClickHistoryItem: (HistoryUiModel, HistoryPageType) -> Unit,
onClickAddPresentation: () -> Unit,
modifier: Modifier = Modifier,
) {
Expand All @@ -116,7 +123,7 @@ internal fun HistoryScreen(
private fun HistoryContent(
uiState: HistoryUiState,
pagerState: PagerState,
onClickHistoryItem: (HistoryUiModel) -> Unit,
onClickHistoryItem: (HistoryUiModel, HistoryPageType) -> Unit,
onClickAddPresentation: () -> Unit,
) {
val tabs = persistentListOf(
Expand Down Expand Up @@ -158,7 +165,7 @@ private fun HistoryContent(
} else {
HistoryItemList(
items = items.toImmutableList(),
onClickItem = onClickHistoryItem,
onClickItem = { item -> onClickHistoryItem(item, pageType) },
modifier = Modifier.fillMaxSize(),
)
}
Expand Down Expand Up @@ -216,7 +223,7 @@ private fun HistoryScreenPreview() {
HistoryScreen(
uiState = previewState,
pagerState = pagerState,
onClickHistoryItem = { },
onClickHistoryItem = { _, _ -> },
onClickAddPresentation = {},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ internal class HistoryViewModel @Inject constructor(
override fun onIntent(intent: HistoryUiIntent) {
when (intent) {
HistoryUiIntent.FetchData -> fetchData()
is HistoryUiIntent.ClickItem -> handleClickItem(presentationId = intent.presentationId)
is HistoryUiIntent.ClickItem -> handleClickItem(
presentationId = intent.presentationId,
pageType = intent.pageType,
)
}
}

Expand Down Expand Up @@ -61,12 +64,19 @@ internal class HistoryViewModel @Inject constructor(
}
}

private fun handleClickItem(presentationId: Long) {
val pastItems = (currentState as? HistoryUiState.Content)?.currentPageItem(type = HistoryPageType.COMPLETED).orEmpty()
val isPast = pastItems.any { history -> history.presentationId == presentationId }
private fun handleClickItem(
presentationId: Long,
pageType: HistoryPageType,
) {
val isPast = pageType == HistoryPageType.COMPLETED

viewModelScope.launch {
sendEffect(HistoryUiEffect.NavigateToReport(presentationId = presentationId, isPast = isPast))
sendEffect(
HistoryUiEffect.NavigateToReport(
presentationId = presentationId,
isPast = isPast,
),
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.compose.ui.unit.dp
import com.team.prezel.core.designsystem.component.actions.button.PrezelButton
import com.team.prezel.core.designsystem.component.actions.button.config.ButtonSize
import com.team.prezel.core.designsystem.component.actions.button.config.ButtonType
import com.team.prezel.core.designsystem.icon.PrezelIcons
import com.team.prezel.core.designsystem.preview.BasicPreview
import com.team.prezel.core.designsystem.theme.PrezelTheme
import com.team.prezel.core.ui.component.StatusView
Expand Down Expand Up @@ -42,6 +43,7 @@ internal fun HistoryEmptyContent(
{
PrezelButton(
text = stringResource(R.string.feature_history_impl_add_presentation),
iconResId = PrezelIcons.Plus,
type = ButtonType.OUTLINED,
size = ButtonSize.SMALL,
isRounded = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package com.team.prezel.feature.history.impl.component
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand Down Expand Up @@ -104,13 +105,14 @@ private fun HistoryPresentationCardTitle(
}

@Composable
@OptIn(ExperimentalLayoutApi::class)
private fun HistoryPresentationCardChips(
item: HistoryUiModel,
modifier: Modifier = Modifier,
) {
Row(
modifier = modifier,
modifier = modifier
.fillMaxWidth()
.horizontalScroll(rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(PrezelTheme.spacing.V8),
verticalAlignment = Alignment.CenterVertically,
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.team.prezel.feature.history.impl.contract

import com.team.prezel.core.ui.base.UiIntent
import com.team.prezel.feature.history.impl.model.HistoryPageType

internal sealed interface HistoryUiIntent : UiIntent {
data object FetchData : HistoryUiIntent

data class ClickItem(
val presentationId: Long,
val pageType: HistoryPageType,
) : HistoryUiIntent
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ internal fun EntryProviderScope<NavKey>.featureHistoryEntryBuilder() {

HistoryScreen(
navigateToReport = { presentationId, isPast ->
navigator.navigate(ReportNavKey(presentationId = presentationId, isPast = isPast))
navigator.navigate(
ReportNavKey(
presentationId = presentationId,
isPast = isPast,
showBackButton = true,
),
)
},
navigateToAnalysis = {
navigator.navigate(AnalysisNavKey.Schedule())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import kotlinx.serialization.Serializable
data class ReportNavKey(
val presentationId: Long,
val isPast: Boolean = false,
val showBackButton: Boolean = false,
) : NavKey
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private fun EntryProviderScope<NavKey>.reportEntry() {

AnalysisReportScreen(
onBack = { navigator.goBack() },
showBackButton = key.showBackButton,
navigateToAnalysisScript = { presentationId, isPast ->
navigator.navigateToAnalysisScript(
presentationId = presentationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal fun AnalysisReportScreen(
navigateToSpeechAccuracy: (analysisResultId: Long) -> Unit,
navigateToScriptMatch: (analysisResultId: Long) -> Unit,
modifier: Modifier = Modifier,
showBackButton: Boolean = false,
viewModel: AnalysisReportViewModel = hiltViewModel(),
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -74,6 +75,7 @@ internal fun AnalysisReportScreen(

AnalysisReportScreen(
uiState = uiState,
showBackButton = showBackButton,
onBackClick = onBack,
onDeleteClick = { viewModel.onIntent(AnalysisReportUiIntent.ClickDelete) },
onImprovementCardIndexChange = { index -> viewModel.onIntent(AnalysisReportUiIntent.ClickGrowthGraphItem(index)) },
Expand Down Expand Up @@ -104,11 +106,13 @@ internal fun AnalysisReportScreen(
onSpeechAccuracyClick: () -> Unit,
onScriptMatchClick: () -> Unit,
modifier: Modifier = Modifier,
showBackButton: Boolean = false,
) {
when (uiState) {
is AnalysisReportUiState.Content -> {
AnalysisReportScreenContent(
uiState = uiState,
showBackButton = showBackButton,
onBackClick = onBackClick,
onDeleteClick = onDeleteClick,
modifier = modifier,
Expand All @@ -131,6 +135,7 @@ internal fun AnalysisReportScreen(
@Composable
private fun AnalysisReportScreenContent(
uiState: AnalysisReportUiState.Content,
showBackButton: Boolean,
onBackClick: () -> Unit,
onDeleteClick: () -> Unit,
onImprovementCardIndexChange: (index: Int) -> Unit,
Expand All @@ -154,14 +159,18 @@ private fun AnalysisReportScreenContent(

ReportScreenLayout(
appBarTitle = uiState.presentationInfo.title,
leadingIcon = {
IconButton(onClick = onBackClick) {
Icon(
painter = painterResource(PrezelIcons.ArrowLeft),
contentDescription = stringResource(R.string.feature_report_impl_back),
tint = PrezelTheme.colors.iconRegular,
)
leadingIcon = if (showBackButton) {
{
IconButton(onClick = onBackClick) {
Icon(
painter = painterResource(PrezelIcons.ArrowLeft),
contentDescription = stringResource(R.string.feature_report_impl_back),
tint = PrezelTheme.colors.iconRegular,
)
}
}
} else {
{}
},
headerContent = { titleModifier ->
ReportHeaderContent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ internal fun ReportBodyContent(
)
GrowthGraphSection(
growthGraphData = uiState.growthGraphData,
showReRecordingButton = !uiState.isPast,
onCardIndexChange = onImprovementCardIndexChange,
onReRecordingClick = onReRecordingClick,
)
ScriptAnalysisSection(
isWrittenScript = uiState.isScriptWritten,
scriptAnalysisGraphData = uiState.scriptAnalysisGraphData,
showReWriteScriptButton = !uiState.isPast,
onReWriteScriptClick = onReWriteScriptClick,
onScriptAnalysisClick = onScriptAnalysisClick,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ import kotlinx.collections.immutable.persistentListOf
@Composable
internal fun GrowthGraphSection(
growthGraphData: GrowthGraphData,
showReRecordingButton: Boolean = true,
onCardIndexChange: (Int) -> Unit,
onReRecordingClick: () -> Unit,
) {
ReportSection(
title = { GrowthGraphSectionTitle(onReRecordingClick = onReRecordingClick) },
title = {
GrowthGraphSectionTitle(
showReRecordingButton = showReRecordingButton,
onReRecordingClick = onReRecordingClick,
)
},
) {
GrowthGraphContent(
growthGraphData = growthGraphData,
Expand All @@ -62,7 +68,10 @@ internal fun GrowthGraphSection(
}

@Composable
private fun GrowthGraphSectionTitle(onReRecordingClick: () -> Unit) {
private fun GrowthGraphSectionTitle(
showReRecordingButton: Boolean,
onReRecordingClick: () -> Unit,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
Expand All @@ -86,15 +95,17 @@ private fun GrowthGraphSectionTitle(onReRecordingClick: () -> Unit) {
)
}
}
PrezelButton(
text = stringResource(R.string.feature_report_impl_re_recording),
iconResId = PrezelIcons.Mic,
type = ButtonType.OUTLINED,
size = ButtonSize.XSMALL,
hierarchy = ButtonHierarchy.SECONDARY,
isRounded = true,
onClick = onReRecordingClick,
)
if (showReRecordingButton) {
PrezelButton(
text = stringResource(R.string.feature_report_impl_re_recording),
iconResId = PrezelIcons.Mic,
type = ButtonType.OUTLINED,
size = ButtonSize.XSMALL,
hierarchy = ButtonHierarchy.SECONDARY,
isRounded = true,
onClick = onReRecordingClick,
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ import kotlinx.collections.immutable.toPersistentMap
internal fun ScriptAnalysisSection(
isWrittenScript: Boolean,
scriptAnalysisGraphData: ScriptAnalysisGraphData,
showReWriteScriptButton: Boolean = true,
onReWriteScriptClick: () -> Unit,
onScriptAnalysisClick: () -> Unit,
) {
ReportSection(
title = {
ScriptAnalysisSectionTitle(
showReWriteButton = isWrittenScript,
showReWriteButton = isWrittenScript && showReWriteScriptButton,
onReWriteScriptClick = onReWriteScriptClick,
)
},
Expand All @@ -54,24 +55,32 @@ internal fun ScriptAnalysisSection(
return@ReportSection
}

EmptyStateContent(onReWriteScriptClick = onReWriteScriptClick)
EmptyStateContent(
showWriteScriptButton = showReWriteScriptButton,
onReWriteScriptClick = onReWriteScriptClick,
)
}
}

@Composable
private fun EmptyStateContent(onReWriteScriptClick: () -> Unit) {
private fun EmptyStateContent(
showWriteScriptButton: Boolean,
onReWriteScriptClick: () -> Unit,
) {
EmptyStateCard(text = stringResource(R.string.feature_report_impl_script_analysis_empty_state_message))

Spacer(modifier = Modifier.height(PrezelTheme.spacing.V16))
if (showWriteScriptButton) {
Spacer(modifier = Modifier.height(PrezelTheme.spacing.V16))

PrezelTextButton(
text = stringResource(R.string.feature_report_impl_write_script),
size = ButtonSize.REGULAR,
type = ButtonType.FILLED,
hierarchy = ButtonHierarchy.SECONDARY,
onClick = onReWriteScriptClick,
modifier = Modifier.fillMaxWidth(),
)
PrezelTextButton(
text = stringResource(R.string.feature_report_impl_write_script),
size = ButtonSize.REGULAR,
type = ButtonType.FILLED,
hierarchy = ButtonHierarchy.SECONDARY,
onClick = onReWriteScriptClick,
modifier = Modifier.fillMaxWidth(),
)
}
}

@Composable
Expand Down