Skip to content

Commit

Permalink
feat(ui): configure initial selected download type
Browse files Browse the repository at this point in the history
  • Loading branch information
JunkFood02 committed Mar 7, 2024
1 parent f7e1e72 commit b1781c6
Show file tree
Hide file tree
Showing 13 changed files with 315 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,43 +121,32 @@ public fun materialSharedAxisXOut(
/**
* [materialSharedAxisY] allows to switch a layout with shared Y-axis transition.
*
* @param forward whether the direction of the animation is forward.
* @param slideDistance the slide distance of transition.
* @param durationMillis the duration of transition.
*/
public fun materialSharedAxisY(
forward: Boolean,
slideDistance: Int,
initialOffsetX: (fullWidth: Int) -> Int,
targetOffsetY: (fullWidth: Int) -> Int,
durationMillis: Int = MotionConstants.DefaultMotionDuration,
): ContentTransform = materialSharedAxisYIn(
forward = forward,
slideDistance = slideDistance,
initialOffsetX = initialOffsetX,
durationMillis = durationMillis
) togetherWith materialSharedAxisYOut(
forward = forward,
slideDistance = slideDistance,
targetOffsetY = targetOffsetY,
durationMillis = durationMillis
)

/**
* [materialSharedAxisYIn] allows to switch a layout with shared Y-axis enter transition.
*
* @param forward whether the direction of the animation is forward.
* @param slideDistance the slide distance of the enter transition.
* @param durationMillis the duration of the enter transition.
*/
public fun materialSharedAxisYIn(
forward: Boolean,
slideDistance: Int,
initialOffsetX: (fullWidth: Int) -> Int,
durationMillis: Int = MotionConstants.DefaultMotionDuration,
): EnterTransition = slideInVertically(
animationSpec = tween(
durationMillis = durationMillis,
easing = FastOutSlowInEasing
),
initialOffsetY = {
if (forward) slideDistance else -slideDistance
}
initialOffsetY = initialOffsetX
) + fadeIn(
animationSpec = tween(
durationMillis = durationMillis.ForIncoming,
Expand All @@ -169,22 +158,16 @@ public fun materialSharedAxisYIn(
/**
* [materialSharedAxisYOut] allows to switch a layout with shared Y-axis exit transition.
*
* @param forward whether the direction of the animation is forward.
* @param slideDistance the slide distance of the exit transition.
* @param durationMillis the duration of the exit transition.
*/
public fun materialSharedAxisYOut(
forward: Boolean,
slideDistance: Int,
targetOffsetY: (fullWidth: Int) -> Int,
durationMillis: Int = MotionConstants.DefaultMotionDuration,
): ExitTransition = slideOutVertically(
animationSpec = tween(
durationMillis = durationMillis,
easing = FastOutSlowInEasing
),
targetOffsetY = {
if (forward) -slideDistance else slideDistance
}
targetOffsetY = targetOffsetY
) + fadeOut(
animationSpec = tween(
durationMillis = durationMillis.ForOutgoing,
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/junkfood/seal/ui/component/Buttons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fun TextButtonWithIcon(
text: String,
contentColor: Color = MaterialTheme.colorScheme.primary,
onClick: () -> Unit,
) {
) {
TextButton(
modifier = modifier,
onClick = onClick,
Expand Down Expand Up @@ -123,14 +123,16 @@ fun FilledTonalButtonWithIcon(
@Composable
fun FilledButtonWithIcon(
modifier: Modifier = Modifier,
onClick: () -> Unit,
icon: ImageVector,
text: String
text: String,
enabled: Boolean = true,
onClick: () -> Unit,
) {
Button(
modifier = modifier,
onClick = onClick,
contentPadding = ButtonDefaults.ButtonWithIconContentPadding
contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
enabled = enabled
)
{
Icon(
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/java/com/junkfood/seal/ui/component/DialogItems.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun SingleChoiceItem(
fun DialogSingleChoiceItem(
modifier: Modifier = Modifier,
text: String,
selected: Boolean,
Expand Down Expand Up @@ -69,15 +69,18 @@ fun SingleChoiceItem(
fun SingleChoiceItemPreview() {
Surface {
Column {
SingleChoiceItemWithLabel(
DialogSingleChoiceItemWithLabel(
text = "Better compatibility", label = "For sharing to other apps", selected = false
) {

}
SingleChoiceItemWithLabel(
DialogSingleChoiceItemWithLabel(
text = "Better quality", label = "For watching in compatible apps", selected = true
) {

}
DialogSingleChoiceItem(text = "Preview", selected = true) {

}
}

Expand All @@ -86,7 +89,7 @@ fun SingleChoiceItemPreview() {
}

@Composable
fun SingleChoiceItemWithLabel(
fun DialogSingleChoiceItemWithLabel(
modifier: Modifier = Modifier,
text: String,
label: String?,
Expand Down Expand Up @@ -157,7 +160,7 @@ fun CheckBoxItem(
}

@Composable
fun SwitchItem(
fun DialogSwitchItem(
modifier: Modifier = Modifier,
text: String,
value: Boolean,
Expand Down Expand Up @@ -209,7 +212,7 @@ fun SwitchItem(
private fun SwitchItemPrev() {
var value by remember { mutableStateOf(false) }
Surface {
SwitchItem(text = "Use cookies", value = value) {
DialogSwitchItem(text = "Use cookies", value = value) {
value = it
}
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/junkfood/seal/ui/component/Dialogs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ fun HelpDialog(
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SealDialog(
onDismissRequest: () -> Unit,
confirmButton: @Composable () -> Unit,
modifier: Modifier = Modifier,
onDismissRequest: () -> Unit,
confirmButton: @Composable (() -> Unit)?,
dismissButton: @Composable (() -> Unit)? = null,
icon: @Composable (() -> Unit)? = null,
title: @Composable (() -> Unit)? = null,
Expand Down Expand Up @@ -159,7 +159,7 @@ fun SealDialog(
crossAxisSpacing = ButtonsCrossAxisSpacing
) {
dismissButton?.invoke()
confirmButton()
confirmButton?.invoke()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,18 @@ fun PreferenceItem(
@Composable
@Preview
fun PreferenceItemPreview() {
Column {
PreferenceItem(title = "title", description = "description", icon = 0)
PreferenceItem(title = "title", description = "description", icon = Icons.Outlined.Update)
SealTheme {
Surface {
Column {
PreferenceSubtitle(text = "Preview")
PreferenceItem(title = "title", description = "description")
PreferenceItem(
title = "title",
description = "description",
icon = Icons.Outlined.Update
)
}
}
}
}

Expand Down Expand Up @@ -834,7 +843,7 @@ fun TemplateItem(
@Composable
fun PreferenceSubtitle(
modifier: Modifier = Modifier,
contentPadding: PaddingValues = PaddingValues(start = 18.dp, top = 24.dp, bottom = 12.dp),
contentPadding: PaddingValues = PaddingValues(start = 20.dp, top = 24.dp, bottom = 12.dp),
text: String,
color: Color = MaterialTheme.colorScheme.primary,
) {
Expand Down
Loading

0 comments on commit b1781c6

Please sign in to comment.