-
Notifications
You must be signed in to change notification settings - Fork 137
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
Shipping Labels Onboarding: Pre-install screen #6797
Merged
nbradbury
merged 12 commits into
trunk
from
issue/6587-wcship-installation-initial-screen
Jun 22, 2022
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
45f3d2b
Refactor the install screen to allow having multiple states
hichamboushaba c97914c
Rename classes to shorten the names a bit
hichamboushaba 50b1338
Add a new state for installation flow
hichamboushaba 2054342
Add first implementation of the pre-installation screen
hichamboushaba fd20db7
Fix issue with null displayName
hichamboushaba 5fd3854
Fix width of the circle
hichamboushaba c0ce018
Animate the navigation from CTA screen to pre-install screen
hichamboushaba 673de5d
Animate the entering of the pre-install screen
hichamboushaba 5e22674
Adjust easings of animations
hichamboushaba 6f5ae52
Add stub implementation for proceed and info callbacks
hichamboushaba 30f72ae
Make content scrollable
hichamboushaba 00fe3b6
Set a minimum height for the weighed spacers
hichamboushaba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
179 changes: 179 additions & 0 deletions
179
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/shipping/InstallWCShippingFlow.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,179 @@ | ||
package com.woocommerce.android.ui.shipping | ||
|
||
import androidx.compose.animation.core.CubicBezierEasing | ||
import androidx.compose.animation.core.Transition | ||
import androidx.compose.animation.core.animateInt | ||
import androidx.compose.animation.core.tween | ||
import androidx.compose.foundation.border | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.ColumnScope | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.offset | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.rememberScrollState | ||
import androidx.compose.foundation.shape.CircleShape | ||
import androidx.compose.foundation.verticalScroll | ||
import androidx.compose.material.Icon | ||
import androidx.compose.material.MaterialTheme | ||
import androidx.compose.material.Text | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.Info | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.res.colorResource | ||
import androidx.compose.ui.res.dimensionResource | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.text.font.FontWeight | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.woocommerce.android.R | ||
import com.woocommerce.android.ui.compose.component.WCColoredButton | ||
import com.woocommerce.android.ui.compose.component.WCTextButton | ||
import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground | ||
import com.woocommerce.android.ui.shipping.InstallWCShippingViewModel.ViewState.InstallationState | ||
import com.woocommerce.android.ui.shipping.InstallWCShippingViewModel.ViewState.InstallationState.PreInstallation | ||
|
||
@Composable | ||
fun InstallWCShippingFlow(viewState: InstallationState, transition: Transition<Boolean>? = null) { | ||
when (viewState) { | ||
is PreInstallation -> PreInstallationContent(viewState, transition) | ||
} | ||
} | ||
|
||
@Composable | ||
private fun PreInstallationContent(viewState: PreInstallation, transition: Transition<Boolean>? = null) { | ||
val offset by transition?.animateInt( | ||
transitionSpec = { | ||
tween( | ||
durationMillis = 500, | ||
delayMillis = 500, | ||
// Ensure a bit of elasticity at the end of the animation | ||
easing = CubicBezierEasing(0.7f, 0.6f, 0.74f, 1.3f) | ||
) | ||
}, | ||
label = "offset" | ||
) { | ||
if (it) 0 else 120 | ||
} ?: remember { mutableStateOf(0) } | ||
|
||
Column( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.padding( | ||
horizontal = dimensionResource(id = R.dimen.major_100), | ||
vertical = dimensionResource(id = R.dimen.major_150) | ||
) | ||
) { | ||
Column( | ||
verticalArrangement = Arrangement.Center, | ||
modifier = Modifier | ||
.weight(1f) | ||
.verticalScroll(rememberScrollState()) | ||
.offset(y = -offset.dp) | ||
) { | ||
WCTextButton(onClick = viewState.onCancelClick) { | ||
Text(text = stringResource(id = R.string.cancel)) | ||
} | ||
SpacerWithMinHeight(1f, dimensionResource(id = R.dimen.major_100)) | ||
Box( | ||
modifier = Modifier | ||
.clip(CircleShape) | ||
.border( | ||
width = dimensionResource(id = R.dimen.major_75), | ||
color = colorResource(id = R.color.woo_purple_20), | ||
shape = CircleShape | ||
) | ||
.size(dimensionResource(id = R.dimen.image_major_120)) | ||
) { | ||
Icon( | ||
painter = painterResource(id = R.drawable.ic_arrow_forward_rounded), | ||
contentDescription = null, | ||
tint = colorResource(id = R.color.woo_purple_50), | ||
modifier = Modifier | ||
.align(Alignment.Center) | ||
.size(dimensionResource(id = R.dimen.image_major_64)) | ||
) | ||
} | ||
Spacer(modifier = Modifier.height(dimensionResource(id = R.dimen.major_150))) | ||
Text( | ||
text = stringResource(id = R.string.install_wc_shipping_preinstall_title), | ||
style = MaterialTheme.typography.h4, | ||
fontWeight = FontWeight.Bold | ||
) | ||
Text( | ||
text = stringResource(id = viewState.extensionsName), | ||
style = MaterialTheme.typography.h4, | ||
fontWeight = FontWeight.Bold, | ||
color = colorResource(id = R.color.woo_purple_50) | ||
) | ||
Spacer(modifier = Modifier.height(dimensionResource(id = R.dimen.major_150))) | ||
Text( | ||
text = viewState.siteName, | ||
style = MaterialTheme.typography.h4 | ||
) | ||
SpacerWithMinHeight(0.75f, dimensionResource(id = R.dimen.major_100)) | ||
Row( | ||
horizontalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.minor_100)), | ||
modifier = Modifier | ||
.clickable(onClick = viewState.onInfoClick) | ||
) { | ||
Icon( | ||
imageVector = Icons.Outlined.Info, | ||
contentDescription = null, | ||
tint = colorResource(id = R.color.link_text) | ||
) | ||
Text( | ||
style = MaterialTheme.typography.subtitle1, | ||
color = colorResource(id = R.color.link_text), | ||
text = stringResource(id = R.string.install_wc_shipping_installation_info), | ||
) | ||
} | ||
SpacerWithMinHeight(0.75f, dimensionResource(id = R.dimen.major_100)) | ||
} | ||
WCColoredButton( | ||
onClick = viewState.onProceedClick, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
.offset(y = offset.dp) | ||
) { | ||
Text(text = stringResource(id = R.string.install_wc_shipping_proceed_button)) | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
private fun ColumnScope.SpacerWithMinHeight(weight: Float, minHeight: Dp) { | ||
Spacer(modifier = Modifier.height(minHeight)) | ||
Spacer(modifier = Modifier.weight(weight)) | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun PreInstallationPreview() { | ||
WooThemeWithBackground { | ||
PreInstallationContent( | ||
viewState = PreInstallation( | ||
extensionsName = R.string.install_wc_shipping_extension_name, | ||
siteName = "Site", | ||
onCancelClick = {}, | ||
onProceedClick = {}, | ||
onInfoClick = {} | ||
) | ||
) | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!