Skip to content

Commit

Permalink
fix: 4231 - "new product" scan card with display flexibility (#4232)
Browse files Browse the repository at this point in the history
* fix: 4231 - "new product" scan card with flexibility

* fix: 4231 - "circled cross" icon

Impacted files:
* `smooth_product_base_card.dart`: added an optional `iconData` parameter
* `smooth_product_card_not_found.dart`: specific "circled cross" icon parameter
  • Loading branch information
monsieurtanuki committed Jun 25, 2023
1 parent e4a02f8 commit a281b6c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ class SmoothProductBaseCard extends StatelessWidget {
class ProductCardCloseButton extends StatelessWidget {
const ProductCardCloseButton({
this.onRemove,
super.key,
this.iconData = Icons.clear_rounded,
});

final OnRemoveCallback? onRemove;
final IconData iconData;

@override
Widget build(BuildContext context) {
Expand All @@ -68,10 +69,10 @@ class ProductCardCloseButton extends StatelessWidget {
onTap: () => onRemove?.call(context),
child: Tooltip(
message: appLocalizations.product_card_remove_product_tooltip,
child: const Padding(
padding: EdgeInsets.all(SMALL_SPACE),
child: Padding(
padding: const EdgeInsets.all(SMALL_SPACE),
child: Icon(
Icons.clear_rounded,
iconData,
size: DEFAULT_ICON_SIZE,
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:smooth_app/cards/product_cards/smooth_product_base_card.dart';
Expand All @@ -24,71 +26,55 @@ class SmoothProductCardNotFound extends StatelessWidget {

return SmoothProductBaseCard(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Align(
alignment: AlignmentDirectional.topEnd,
child: ProductCardCloseButton(onRemove: (BuildContext context) {
AnalyticsHelper.trackEvent(
AnalyticsEvent.ignoreProductNotFound,
barcode: barcode,
);
child: ProductCardCloseButton(
onRemove: (BuildContext context) {
AnalyticsHelper.trackEvent(
AnalyticsEvent.ignoreProductNotFound,
barcode: barcode,
);

onRemoveProduct?.call(context);
}),
onRemoveProduct?.call(context);
},
iconData: CupertinoIcons.clear_circled,
),
),
Expanded(
flex: 2,
child: AutoSizeText(
appLocalizations.missing_product,
style: textTheme.displayMedium,
textAlign: TextAlign.center,
),
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: textTheme.headlineSmall,
children: <InlineSpan>[
TextSpan(
text: appLocalizations.missing_product,
style: textTheme.displayMedium,
),
const WidgetSpan(
alignment: PlaceholderAlignment.belowBaseline,
baseline: TextBaseline.alphabetic,
child: SizedBox(
height: LARGE_SPACE,
),
),
TextSpan(
text: '\n${appLocalizations.add_product_take_photos}\n',
style: textTheme.bodyMedium,
),
TextSpan(
text: '(${appLocalizations.barcode_barcode(barcode)})',
style: textTheme.bodyMedium,
),
],
),
flex: 3,
child: AutoSizeText(
'\n${appLocalizations.add_product_take_photos}\n'
'(${appLocalizations.barcode_barcode(barcode)})',
style: textTheme.bodyMedium,
textAlign: TextAlign.center,
),
),
SmoothLargeButtonWithIcon(
text: appLocalizations.add_product_information_button_label,
icon: Icons.add,
padding: const EdgeInsets.symmetric(vertical: LARGE_SPACE),
onPressed: () async {
await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) =>
AddNewProductPage(barcode: barcode),
),
Padding(
padding: const EdgeInsetsDirectional.only(top: LARGE_SPACE),
child: SmoothLargeButtonWithIcon(
text: appLocalizations.add_product_information_button_label,
icon: Icons.add,
padding: const EdgeInsets.symmetric(vertical: LARGE_SPACE),
onPressed: () async {
await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) =>
AddNewProductPage(barcode: barcode),
),
);
);

await onAddProduct?.call();
},
),
),
],
),
await onAddProduct?.call();
},
),
],
),
Expand Down

0 comments on commit a281b6c

Please sign in to comment.