@@ -91,10 +91,9 @@ fun WooPosOrderDetails(
9191
9292 Spacer (Modifier .height(WooPosSpacing .Large .value))
9393
94- val lineItemsState = details.lineItems
95- if (lineItemsState is WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState .Loaded ) {
96- OrdersProducts (lineItems = lineItemsState.items)
97- }
94+ ProductsSection (lineItems = details.lineItems)
95+
96+ RefundedProductsSection (refundedLineItems = details.refundedLineItems)
9897
9998 Spacer (Modifier .height(WooPosSpacing .Medium .value))
10099
@@ -164,11 +163,56 @@ private fun OrdersHeader(details: WooPosOrdersState.OrderDetailsViewState.Comput
164163}
165164
166165@Composable
167- private fun OrdersProducts (lineItems : List <WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemRow >) {
166+ private fun ProductsSection (
167+ lineItems : WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState
168+ ) {
169+ when (lineItems) {
170+ is WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState .Loading ->
171+ ProductsShimmer (
172+ title = stringResource(R .string.woopos_orders_details_products_title)
173+ )
174+ is WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState .Loaded ->
175+ if (lineItems.items.isNotEmpty()) {
176+ OrdersProducts (
177+ title = stringResource(R .string.woopos_orders_details_products_title),
178+ lineItems = lineItems.items
179+ )
180+ }
181+ }
182+ }
183+
184+ @Composable
185+ private fun RefundedProductsSection (
186+ refundedLineItems : WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState
187+ ) {
188+ when (refundedLineItems) {
189+ is WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState .Loading -> {
190+ Spacer (Modifier .height(WooPosSpacing .Medium .value))
191+ ProductsShimmer (
192+ title = stringResource(R .string.woopos_orders_details_refunded_products_title)
193+ )
194+ }
195+ is WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState .Loaded -> {
196+ if (refundedLineItems.items.isNotEmpty()) {
197+ Spacer (Modifier .height(WooPosSpacing .Medium .value))
198+ OrdersProducts (
199+ title = stringResource(R .string.woopos_orders_details_refunded_products_title),
200+ lineItems = refundedLineItems.items
201+ )
202+ }
203+ }
204+ }
205+ }
206+
207+ @Composable
208+ private fun OrdersProducts (
209+ title : String ,
210+ lineItems : List <WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemRow >
211+ ) {
168212 WooPosCard (shadowType = ShadowType .Soft ) {
169213 Column (Modifier .padding(WooPosSpacing .Medium .value)) {
170214 WooPosText (
171- text = stringResource( R .string.woopos_orders_details_products_title) ,
215+ text = title ,
172216 style = WooPosTypography .BodyXLarge ,
173217 fontWeight = FontWeight .SemiBold ,
174218 )
@@ -186,6 +230,55 @@ private fun OrdersProducts(lineItems: List<WooPosOrdersState.OrderDetailsViewSta
186230 }
187231}
188232
233+ @Composable
234+ private fun ProductsShimmer (title : String ) {
235+ WooPosCard (shadowType = ShadowType .Soft ) {
236+ Column (Modifier .padding(WooPosSpacing .Medium .value)) {
237+ WooPosText (
238+ text = title,
239+ style = WooPosTypography .BodyXLarge ,
240+ fontWeight = FontWeight .SemiBold ,
241+ )
242+
243+ Spacer (Modifier .height(WooPosSpacing .Medium .value))
244+
245+ repeat(2 ) { index ->
246+ Row (
247+ modifier = Modifier
248+ .fillMaxWidth()
249+ .padding(vertical = WooPosSpacing .Small .value),
250+ verticalAlignment = Alignment .CenterVertically
251+ ) {
252+ WooPosShimmerBox (
253+ modifier = Modifier
254+ .size(56 .dp)
255+ .clip(RoundedCornerShape (WooPosCornerRadius .Small .value))
256+ )
257+ Spacer (Modifier .width(WooPosSpacing .Medium .value))
258+ Column (modifier = Modifier .weight(1f )) {
259+ WooPosShimmerBox (
260+ modifier = Modifier
261+ .fillMaxWidth(0.6f )
262+ .height(16 .dp)
263+ .clip(RoundedCornerShape (WooPosCornerRadius .Small .value))
264+ )
265+ Spacer (Modifier .height(WooPosSpacing .XSmall .value))
266+ WooPosShimmerBox (
267+ modifier = Modifier
268+ .fillMaxWidth(0.3f )
269+ .height(14 .dp)
270+ .clip(RoundedCornerShape (WooPosCornerRadius .Small .value))
271+ )
272+ }
273+ }
274+ if (index < 1 ) {
275+ DividerWithSpacing ()
276+ }
277+ }
278+ }
279+ }
280+ }
281+
189282@Composable
190283@Suppress(" DestructuringDeclarationWithTooManyEntries" )
191284private fun OrderProductItem (row : WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemRow ) {
@@ -493,7 +586,7 @@ fun WooPosOrderDetailsPreview() {
493586 ),
494587 WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemRow (
495588 id = 103 ,
496- name = " A vey tasty coffee that incidentally has a very long name " +
589+ name = " A very tasty coffee that incidentally has a very long name " +
497590 " and should go over a few lines without overlapping anything" ,
498591 attributesDescription = " Medium roast, Decaf" ,
499592 qtyAndUnitPrice = " 1 x $5.00" ,
@@ -513,6 +606,18 @@ fun WooPosOrderDetailsPreview() {
513606 )
514607 )
515608 ),
609+ refundedLineItems = WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemsState .Loaded (
610+ listOf (
611+ WooPosOrdersState .OrderDetailsViewState .Computed .Details .LineItemRow (
612+ id = 101 ,
613+ name = " Cup" ,
614+ attributesDescription = null ,
615+ qtyAndUnitPrice = " 1 x $4.00" ,
616+ lineTotal = " -$4.00" ,
617+ imageUrl = null
618+ )
619+ )
620+ ),
516621 breakdown = WooPosOrdersState .OrderDetailsViewState .Computed .Details .TotalsBreakdown (
517622 products = " $23.00" ,
518623 discount = " -$5.00" ,
0 commit comments