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 @@ -49,13 +49,22 @@ fun PrezelAccordion(
title: String,
modifier: Modifier = Modifier,
initiallyExpanded: Boolean = false,
expanded: Boolean? = null,
onExpandedChange: ((Boolean) -> Unit)? = null,
nested: Boolean = false,
showDivider: Boolean = false,
leadingContent: @Composable (() -> Unit)? = null,
trailingContent: @Composable (() -> Unit)? = null,
content: @Composable (() -> Unit),
) {
var expanded by rememberSaveable { mutableStateOf(initiallyExpanded) }
var internalExpanded by rememberSaveable { mutableStateOf(initiallyExpanded) }
val currentExpanded = expanded ?: internalExpanded
val updateExpanded: (Boolean) -> Unit = { nextExpanded ->
if (expanded == null) {
internalExpanded = nextExpanded
}
onExpandedChange?.invoke(nextExpanded)
}

Column(
modifier = modifier
Expand All @@ -71,26 +80,26 @@ fun PrezelAccordion(
.clickable(
interactionSource = null,
indication = null,
onClick = { expanded = !expanded },
onClick = { updateExpanded(!currentExpanded) },
),
size = if (nested) PrezelListSize.SMALL else PrezelListSize.REGULAR,
nested = nested,
leadingContent = leadingContent,
trailingContent = {
trailingContent?.invoke()
PrezelAccordionChevron(expanded = expanded)
PrezelAccordionChevron(expanded = currentExpanded)
},
)
}

if (showDivider && !expanded) {
if (showDivider && !currentExpanded) {
PrezelHorizontalDivider(
type = PrezelDividerType.THICK,
)
}

PrezelAccordionContent(
expanded = expanded,
expanded = currentExpanded,
content = content,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fun PrezelDatePicker(
}

DatePickerFooter(
enabled = initialSelectedDate != selectedDate,
enabled = selectedDate != null,
onClick = { selectedDate?.let(onConfirm) },
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.team.prezel.core.designsystem.component.navigations

enum class PrezelTabSize { REGULAR, MEDIUM }
enum class PrezelTabSize { REGULAR, SMALL }
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ private fun PrezelTab(
Tab(
selected = selected,
onClick = onClick,
modifier = modifier.height(if (size == PrezelTabSize.REGULAR) 36.dp else 48.dp),
modifier = modifier.height(if (size == PrezelTabSize.SMALL) 36.dp else 48.dp),
text = {
Text(
text = label,
style = if (size == PrezelTabSize.REGULAR) PrezelTextStyles.Body3Medium.toTextStyle() else PrezelTextStyles.Body2Bold.toTextStyle(),
style = if (size == PrezelTabSize.SMALL) PrezelTextStyles.Body3Medium.toTextStyle() else PrezelTextStyles.Body2Bold.toTextStyle(),
)
},
selectedContentColor = PrezelTheme.colors.solidBlack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private fun PrezelMediumTabPreview() {
PrezelTabsPager(
tabs = tabs,
pagerState = pagerState,
size = PrezelTabSize.MEDIUM,
size = PrezelTabSize.SMALL,
modifier = Modifier,
) { page ->
Box(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
Expand Down Expand Up @@ -46,6 +48,7 @@ fun PrezelTextArea(
status: PrezelTextFieldStatus = PrezelTextFieldStatus.DEFAULT,
enabled: Boolean = true,
showCount: Boolean = false,
fillContainerHeight: Boolean = false,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
keyboardActions: KeyboardActions = KeyboardActions.Default,
) {
Expand Down Expand Up @@ -82,6 +85,7 @@ fun PrezelTextArea(
label = label,
enabled = enabled,
showCount = showCount,
fillContainerHeight = fillContainerHeight,
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
)
Expand All @@ -99,6 +103,7 @@ private fun PrezelTextArea(
label: String?,
enabled: Boolean,
showCount: Boolean,
fillContainerHeight: Boolean,
keyboardOptions: KeyboardOptions,
keyboardActions: KeyboardActions,
modifier: Modifier = Modifier,
Expand All @@ -115,8 +120,13 @@ private fun PrezelTextArea(
enabled = enabled,
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 72.dp)
.onFocusChanged { focusState -> onFocusChange(focusState.isFocused) },
.then(
if (fillContainerHeight) {
Modifier.weight(1f)
} else {
Modifier.heightIn(min = 72.dp)
},
).onFocusChanged { focusState -> onFocusChange(focusState.isFocused) },
textStyle = PrezelTheme.typography.body2Regular.copy(color = style.textColor()),
cursorBrush = SolidColor(PrezelTheme.colors.interactiveRegular),
keyboardOptions = keyboardOptions,
Expand All @@ -133,7 +143,8 @@ private fun PrezelTextArea(
Counter(currentLength = value.text.length, maxLength = maxLength, state = style)
}
},
modifier = Modifier.heightIn(min = 72.dp),
modifier = if (fillContainerHeight) Modifier.fillMaxHeight() else Modifier.heightIn(min = 72.dp),
fillContainerHeight = fillContainerHeight,
)
},
)
Expand Down Expand Up @@ -170,6 +181,7 @@ private fun PrezelTextAreaDecorationBox(
state: PrezelTextFieldStyle,
showCounter: Boolean,
modifier: Modifier = Modifier,
fillContainerHeight: Boolean = false,
) {
Surface(
modifier = modifier.fillMaxWidth(),
Expand All @@ -180,12 +192,12 @@ private fun PrezelTextAreaDecorationBox(
) {
Box(
modifier = Modifier
.fillMaxWidth()
.then(if (fillContainerHeight) Modifier.fillMaxSize() else Modifier.fillMaxWidth())
.padding(PrezelTheme.spacing.V12),
) {
Box(
modifier = Modifier
.fillMaxWidth()
.then(if (fillContainerHeight) Modifier.fillMaxSize() else Modifier.fillMaxWidth())
.padding(bottom = if (showCounter) PrezelTheme.spacing.V24 else 0.dp),
) {
innerTextField()
Expand Down Expand Up @@ -335,6 +347,7 @@ private fun PrezelTextAreaPreviewItem(
onFocusChange = {},
enabled = enabled,
showCount = true,
fillContainerHeight = false,
keyboardOptions = KeyboardOptions.Default,
keyboardActions = KeyboardActions.Default,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.ime
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.text.BasicTextField
Expand All @@ -27,6 +29,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.TextFieldValue
Expand Down Expand Up @@ -56,6 +59,9 @@ fun PrezelTextField(
) {
var focused by remember { mutableStateOf(false) }
var textFieldValue by remember { mutableStateOf(TextFieldValue(text = value, selection = TextRange(value.length))) }
val density = LocalDensity.current
val imeVisible = WindowInsets.ime.getBottom(density) > 0
val typing = focused && imeVisible

LaunchedEffect(value) {
if (value != textFieldValue.text) {
Expand All @@ -66,7 +72,7 @@ fun PrezelTextField(
val state = rememberPrezelTextFieldState(
value = textFieldValue.text,
enabled = enabled,
focused = focused,
focused = typing,
).let { state -> PrezelTextFieldStyle(state = state, status = status) }

PrezelTextField(
Expand All @@ -80,7 +86,7 @@ fun PrezelTextField(
},
placeholder = placeholder,
style = state,
focused = focused,
focused = typing,
onFocusChange = { isFocused -> focused = isFocused },
modifier = modifier,
label = label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.clipRect
import androidx.compose.ui.graphics.drawscope.withTransform
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.team.prezel.core.designsystem.R
import com.team.prezel.core.designsystem.preview.BasicPreview
import com.team.prezel.core.designsystem.preview.LargeDevicePreview
import com.team.prezel.core.designsystem.preview.PreviewColumn
Expand Down Expand Up @@ -166,13 +164,13 @@ private fun VoiceChromeTitle(
)

VoiceChromeStatus.LISTENING -> Text(
text = stringResource(R.string.core_designsystem_voice_chrome_listening),
text = titleText,
style = baseStyle,
color = color,
)

VoiceChromeStatus.WAITING -> Text(
text = stringResource(R.string.core_designsystem_voice_chrome_waiting),
text = titleText,
style = baseStyle,
color = color,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ internal val AnalysisFlowUiState.shouldResetAudioOnBack: Boolean

internal fun AnalysisFlowUiState.backClearedFormOrNull(): AnalysisForm? =
when (step) {
AnalysisFlowStep.PRESENTATION_SITUATION -> form.takeIf { it.hasSituationInput }?.clearSituationInput()
AnalysisFlowStep.SCRIPT_INPUT -> form.takeIf { it.hasScriptInput }?.clearScriptInput()
AnalysisFlowStep.PRESENTATION_SITUATION,
AnalysisFlowStep.PRESENTATION_SCHEDULE,
AnalysisFlowStep.AUDIO_UPLOAD,
AnalysisFlowStep.VOICE_RECORDING,
Expand All @@ -25,20 +25,9 @@ internal fun AnalysisFlowUiState.backClearedFormOrNull(): AnalysisForm? =
-> null
}

private val AnalysisForm.hasSituationInput: Boolean
get() = listOf(category, purpose, style, audience).any { it != null }

private val AnalysisForm.hasScriptInput: Boolean
get() = script.isNotBlank() || scriptFileUri != null

private fun AnalysisForm.clearSituationInput(): AnalysisForm =
copy(
category = null,
purpose = null,
style = null,
audience = null,
)

private fun AnalysisForm.clearScriptInput(): AnalysisForm =
copy(
script = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import com.team.prezel.core.common.error.AppError
import com.team.prezel.core.common.error.AppException
import com.team.prezel.feature.analysis.impl.contract.AnalysisUploadType
import com.team.prezel.feature.analysis.impl.model.AnalysisUiMessage
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.TimeoutCancellationException

internal sealed interface AnalysisFailureAction {
data object RetryAnalysis : AnalysisFailureAction
Expand All @@ -18,6 +20,14 @@ internal sealed interface AnalysisFailureAction {
}

internal fun Throwable.toAnalysisFailureAction(): AnalysisFailureAction {
if (this is TimeoutCancellationException) {
return AnalysisFailureAction.RetryAnalysis
}

if (this is CancellationException) {
return AnalysisFailureAction.RetryAnalysis
}

val error = (this as? AppException)?.error

return when (error) {
Expand All @@ -27,11 +37,12 @@ internal fun Throwable.toAnalysisFailureAction(): AnalysisFailureAction {
AppError.SCRIPT_FILE_RECOGNITION_FAILED -> AnalysisFailureAction.RetryFileUpload(uploadType = AnalysisUploadType.SCRIPT)

AppError.UNAUTHORIZED -> AnalysisFailureAction.ShowMessage(message = AnalysisUiMessage.AUTH_EXPIRED)
AppError.VOICE_RECOGNITION_FAILED,
AppError.VOICE_RECOGNITION_FAILED -> AnalysisFailureAction.RetryFileUpload(uploadType = AnalysisUploadType.AUDIO)

AppError.VOICE_ANALYSIS_FAILED,
AppError.SERVER_ERROR,
AppError.NETWORK,
-> AnalysisFailureAction.RetryAnalysis
AppError.SERVER_ERROR -> AnalysisFailureAction.ShowMessage(message = AnalysisUiMessage.ANALYSIS_FAILED)
AppError.NETWORK -> AnalysisFailureAction.ShowMessage(message = AnalysisUiMessage.NETWORK_FAILED)

AppError.NOT_FOUND,
AppError.DUPLICATE,
Expand Down
Loading