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

Address selection #13235

Merged
merged 3 commits into from
Jan 4, 2025
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 @@ -16,6 +16,7 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.sizeIn
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
Expand All @@ -24,8 +25,11 @@ import androidx.compose.material.BottomSheetScaffoldState
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.ModalBottomSheetState
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
Expand All @@ -43,7 +47,6 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.woocommerce.android.R
import com.woocommerce.android.extensions.appendWithIfNotEmpty
import com.woocommerce.android.model.Address
import com.woocommerce.android.ui.compose.animations.SkeletonView
import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground
import com.woocommerce.android.ui.orders.wooshippinglabels.address.AddressSectionLandscape
Expand All @@ -58,15 +61,14 @@ import kotlinx.parcelize.Parcelize
@Composable
fun ShipmentDetails(
scaffoldState: BottomSheetScaffoldState,
shipFromSelectionBottomSheetState: ModalBottomSheetState,
shippableItems: ShippableItemsUI,
shippingLines: List<ShippingLineSummaryUI>,
shippingAddresses: WooShippingAddresses,
shippingRateSummary: ShippingRateSummaryUI?,
modifier: Modifier = Modifier,
markOrderComplete: Boolean = false,
onMarkOrderCompleteChange: (Boolean) -> Unit = {},
onShippingFromAddressChange: (OriginShippingAddress) -> Unit = {},
onShippingToAddressChange: (Address) -> Unit = {},
handlerModifier: Modifier = Modifier,
isReadOnly: Boolean = false
) {
Expand Down Expand Up @@ -102,39 +104,41 @@ fun ShipmentDetails(
tint = colorResource(id = R.color.color_primary),
)
AnimatedVisibility(visible = scaffoldState.bottomSheetState.isCollapsed) {
Text(
text = stringResource(R.string.shipping_label_shipment_details_title),
color = MaterialTheme.colors.primary,
modifier = Modifier
.padding(top = dimensionResource(R.dimen.minor_100))
Column {
Text(
text = stringResource(R.string.shipping_label_shipment_details_title),
color = MaterialTheme.colors.primary,
modifier = Modifier
.padding(top = dimensionResource(R.dimen.minor_100))
)
Spacer(modifier = Modifier.size(dimensionResource(id = R.dimen.major_200)))
}
}

if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE) {
ShipmentDetailsLandscape(
shippableItems = shippableItems,
shippingLines = shippingLines,
shippingAddresses = shippingAddresses,
shippingRateSummary = shippingRateSummary,
modifier = modifier.padding(top = dimensionResource(R.dimen.major_100)),
isReadOnly = isReadOnly,
shipFromSelectionBottomSheetState = shipFromSelectionBottomSheetState
)
} else {
ShipmentDetailsPortrait(
shippableItems = shippableItems,
shippingLines = shippingLines,
markOrderComplete = markOrderComplete,
onMarkOrderCompleteChange = onMarkOrderCompleteChange,
shippingAddresses = shippingAddresses,
shippingRateSummary = shippingRateSummary,
modifier = modifier.padding(top = dimensionResource(R.dimen.minor_100)),
isReadOnly = isReadOnly,
shipFromSelectionBottomSheetState = shipFromSelectionBottomSheetState
)
}
}
if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE) {
ShipmentDetailsLandscape(
shippableItems = shippableItems,
shippingLines = shippingLines,
shippingAddresses = shippingAddresses,
onShippingFromAddressChange = onShippingFromAddressChange,
onShippingToAddressChange = onShippingToAddressChange,
shippingRateSummary = shippingRateSummary,
modifier = modifier,
isReadOnly = isReadOnly
)
} else {
ShipmentDetailsPortrait(
shippableItems = shippableItems,
shippingLines = shippingLines,
markOrderComplete = markOrderComplete,
onMarkOrderCompleteChange = onMarkOrderCompleteChange,
shippingAddresses = shippingAddresses,
onShippingFromAddressChange = onShippingFromAddressChange,
onShippingToAddressChange = onShippingToAddressChange,
shippingRateSummary = shippingRateSummary,
modifier = modifier,
isReadOnly = isReadOnly
)
}
}

@Composable
Expand All @@ -145,28 +149,25 @@ private fun ShipmentDetailsPortrait(
markOrderComplete: Boolean,
onMarkOrderCompleteChange: (Boolean) -> Unit,
shippingRateSummary: ShippingRateSummaryUI?,
shipFromSelectionBottomSheetState: ModalBottomSheetState,
modifier: Modifier = Modifier,
onShippingFromAddressChange: (OriginShippingAddress) -> Unit = {},
onShippingToAddressChange: (Address) -> Unit = {},
isReadOnly: Boolean = false
) {
Column(modifier) {
Column(
Modifier
.fillMaxWidth()
.padding(top = dimensionResource(R.dimen.major_200))
.weight(1f)
.verticalScroll(rememberScrollState())

) {
OrderDetailsSection(
shippingAddresses = shippingAddresses,
onShippingFromAddressChange = onShippingFromAddressChange,
onShippingToAddressChange = onShippingToAddressChange,
totalItems = shippableItems.shippableItems.size,
totalItemsCost = shippableItems.formattedTotalPrice,
shippingLines = shippingLines,
isReadOnly = isReadOnly
isReadOnly = isReadOnly,
shipFromSelectionBottomSheetState = shipFromSelectionBottomSheetState
)
Divider(modifier = Modifier.padding(horizontal = dimensionResource(R.dimen.major_100)))
ShipmentCostSection(
Expand All @@ -190,26 +191,23 @@ private fun ShipmentDetailsLandscape(
shippingLines: List<ShippingLineSummaryUI>,
shippingAddresses: WooShippingAddresses,
shippingRateSummary: ShippingRateSummaryUI?,
shipFromSelectionBottomSheetState: ModalBottomSheetState,
modifier: Modifier = Modifier,
onShippingFromAddressChange: (OriginShippingAddress) -> Unit = {},
onShippingToAddressChange: (Address) -> Unit = {},
isReadOnly: Boolean = false
) {
Column(modifier) {
Column(
Modifier
.fillMaxWidth()
.padding(top = dimensionResource(R.dimen.major_200))
.weight(1f)
.verticalScroll(rememberScrollState())

) {
AddressSectionLandscape(
shippingAddresses = shippingAddresses,
onShippingFromAddressChange = onShippingFromAddressChange,
onShippingToAddressChange = onShippingToAddressChange,
modifier = Modifier.padding(horizontal = dimensionResource(R.dimen.major_100)),
isReadOnly = isReadOnly
isReadOnly = isReadOnly,
shipFromSelectionBottomSheetState = shipFromSelectionBottomSheetState
)
Row(
modifier = Modifier
Expand All @@ -235,7 +233,7 @@ private fun ShipmentDetailsLandscape(
}

@Composable
private fun ShipmentDetailsSectionTitle(
internal fun ShipmentDetailsSectionTitle(
title: String,
modifier: Modifier = Modifier
) {
Expand All @@ -258,11 +256,10 @@ private fun ShipmentDetailsSectionTitlePreview() {
@Composable
private fun OrderDetailsSection(
shippingAddresses: WooShippingAddresses,
onShippingFromAddressChange: (OriginShippingAddress) -> Unit,
onShippingToAddressChange: (Address) -> Unit,
totalItems: Int,
totalItemsCost: String,
shippingLines: List<ShippingLineSummaryUI>,
shipFromSelectionBottomSheetState: ModalBottomSheetState,
modifier: Modifier = Modifier,
isReadOnly: Boolean = false
) {
Expand All @@ -274,11 +271,9 @@ private fun OrderDetailsSection(
Spacer(modifier = Modifier.height(dimensionResource(R.dimen.major_100)))
AddressSectionPortrait(
shippingAddresses = shippingAddresses,
originAddresses = shippingAddresses.originAddresses,
onShippingFromAddressChange = onShippingFromAddressChange,
onShippingToAddressChange = onShippingToAddressChange,
modifier = Modifier.padding(horizontal = dimensionResource(R.dimen.major_100)),
isReadOnly = isReadOnly
isReadOnly = isReadOnly,
shipFromSelectionBottomSheetState = shipFromSelectionBottomSheetState
)
TotalCard(
totalItems = totalItems,
Expand Down Expand Up @@ -330,7 +325,8 @@ fun ShipmentDetailsLandscapePreview() {
shipTo = getShipTo(),
originAddresses = listOf(getShipFrom())
),
shippingRateSummary = null
shippingRateSummary = null,
shipFromSelectionBottomSheetState = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
)
}
}
Expand Down
Loading
Loading