Skip to content

Commit ca0c8a5

Browse files
barcodes always in black on white
Impacted files: * `add_new_product_page.dart`: minor refactoring * `new_product_footer_barcode.dart`: minor refactoring * `product_dialog_helper.dart`: minor refactoring * `smooth_barcode_widget.dart`: now const color, background color and padding * `smooth_product_base_card.dart`: minor refactoring
1 parent 26a1696 commit ca0c8a5

5 files changed

Lines changed: 64 additions & 87 deletions

File tree

packages/smooth_app/lib/cards/product_cards/smooth_product_base_card.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,15 +301,12 @@ class ScanProductBaseCardBarcode extends StatelessWidget {
301301
child: Center(
302302
child: ConstrainedBox(
303303
constraints: BoxConstraints(minHeight: dense ? 75.0 : 100.0),
304-
child: SmoothBarcodeWidget(
305-
height: height,
304+
child: Padding(
306305
padding: EdgeInsetsDirectional.symmetric(
307306
horizontal: 30.0,
308307
vertical: dense ? SMALL_SPACE : MEDIUM_SPACE,
309308
),
310-
color: Colors.black,
311-
backgroundColor: lightTheme ? Colors.white : Colors.transparent,
312-
barcode: barcode,
309+
child: SmoothBarcodeWidget(barcode: barcode, height: height),
313310
),
314311
),
315312
),

packages/smooth_app/lib/pages/product/add_new_product/add_new_product_page.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,15 +616,13 @@ class _AddNewProductPageState extends State<AddNewProductPage>
616616
);
617617
}
618618
rows.add(
619-
SmoothBarcodeWidget(
620-
height: 75,
619+
Padding(
621620
padding: const EdgeInsetsDirectional.only(
622621
start: VERY_LARGE_SPACE,
623622
end: VERY_LARGE_SPACE,
624623
top: VERY_LARGE_SPACE,
625624
),
626-
color: context.lightTheme() ? Colors.black : Colors.white,
627-
barcode: barcode,
625+
child: SmoothBarcodeWidget(barcode: barcode, height: 75),
628626
),
629627
);
630628
return rows;

packages/smooth_app/lib/pages/product/common/product_dialog_helper.dart

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,15 @@ class ProductDialogHelper {
116116
? theme.primaryMedium
117117
: theme.primaryLight,
118118
),
119-
child: SmoothBarcodeWidget(
120-
barcode: barcode,
121-
height: 75.0,
122-
padding: const EdgeInsetsDirectional.only(
123-
top: MEDIUM_SPACE,
124-
start: VERY_LARGE_SPACE,
125-
end: VERY_LARGE_SPACE,
126-
bottom: MEDIUM_SPACE,
119+
child: Padding(
120+
padding: const EdgeInsetsDirectional.symmetric(
121+
vertical: MEDIUM_SPACE,
122+
horizontal: VERY_LARGE_SPACE,
123+
),
124+
child: SmoothBarcodeWidget(
125+
barcode: barcode,
126+
height: 75.0,
127127
),
128-
color: Colors.black,
129-
backgroundColor: lightTheme
130-
? Colors.white
131-
: Colors.transparent,
132128
),
133129
),
134130
const SizedBox(height: MEDIUM_SPACE * 2),

packages/smooth_app/lib/pages/product/product_page/footer/new_product_footer_barcode.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ class ProductFooterBarcodeButton extends StatelessWidget {
4444
children: <Widget>[
4545
FractionallySizedBox(
4646
widthFactor: 0.65,
47-
child: SmoothBarcodeWidget(
48-
padding: EdgeInsets.zero,
49-
color: context.lightTheme() ? Colors.black : Colors.white,
50-
barcode: barcode,
51-
height: 110.0,
52-
),
47+
child: SmoothBarcodeWidget(barcode: barcode, height: 110.0),
5348
),
5449
const SizedBox(height: LARGE_SPACE),
5550
OutlinedButton(

packages/smooth_app/lib/widgets/smooth_barcode_widget.dart

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,82 +10,73 @@ class SmoothBarcodeWidget extends StatelessWidget {
1010
const SmoothBarcodeWidget({
1111
required this.barcode,
1212
required this.height,
13-
required this.color,
14-
this.backgroundColor,
15-
this.padding,
1613
super.key,
1714
}) : assert(barcode.length > 0);
1815

1916
final String barcode;
2017
final double height;
21-
final Color color;
22-
final Color? backgroundColor;
23-
final EdgeInsetsGeometry? padding;
2418

2519
@override
2620
Widget build(BuildContext context) {
21+
const Color color = Colors.black;
22+
const Color backgroundColor = Colors.white;
2723
final AppLocalizations appLocalizations = AppLocalizations.of(context);
2824
return Semantics(
2925
label: appLocalizations.barcode_accessibility_label(barcode),
3026
excludeSemantics: true,
31-
child: Padding(
32-
padding: padding ?? EdgeInsets.zero,
33-
child: ColoredBox(
34-
color: backgroundColor ?? Colors.transparent,
35-
child: BarcodeWidget(
36-
padding: EdgeInsets.zero,
37-
data: barcode,
38-
barcode: _barcodeType,
39-
color: color,
40-
style: TextStyle(color: color),
41-
errorBuilder: (final BuildContext context, String? error) {
42-
return Container(
43-
width: double.infinity,
44-
height: height,
45-
padding: const EdgeInsets.symmetric(
46-
horizontal: SMALL_SPACE,
47-
vertical: SMALL_SPACE,
48-
),
49-
color: Colors.grey.withValues(alpha: 0.2),
50-
child: Column(
51-
mainAxisSize: MainAxisSize.max,
52-
mainAxisAlignment: MainAxisAlignment.spaceAround,
53-
crossAxisAlignment: CrossAxisAlignment.center,
54-
children: <Widget>[
55-
Row(
56-
mainAxisSize: MainAxisSize.min,
57-
mainAxisAlignment: MainAxisAlignment.center,
58-
crossAxisAlignment: CrossAxisAlignment.center,
59-
children: <Widget>[
60-
icons.Warning(color: color),
61-
const SizedBox(width: SMALL_SPACE),
62-
Expanded(
63-
child: FittedBox(
64-
fit: BoxFit.contain,
65-
child: Text(
66-
appLocalizations.barcode_probably_invalid,
67-
style: TextStyle(color: color),
68-
),
27+
child: Container(
28+
color: backgroundColor,
29+
padding: const EdgeInsetsDirectional.all(SMALL_SPACE),
30+
child: BarcodeWidget(
31+
padding: EdgeInsets.zero,
32+
data: barcode,
33+
barcode: _barcodeType,
34+
color: color,
35+
style: const TextStyle(color: color),
36+
errorBuilder: (final BuildContext context, String? error) {
37+
return Container(
38+
width: double.infinity,
39+
height: height,
40+
padding: const EdgeInsets.symmetric(
41+
horizontal: SMALL_SPACE,
42+
vertical: SMALL_SPACE,
43+
),
44+
child: Column(
45+
mainAxisSize: MainAxisSize.max,
46+
mainAxisAlignment: MainAxisAlignment.spaceAround,
47+
crossAxisAlignment: CrossAxisAlignment.center,
48+
children: <Widget>[
49+
Row(
50+
mainAxisSize: MainAxisSize.min,
51+
mainAxisAlignment: MainAxisAlignment.center,
52+
crossAxisAlignment: CrossAxisAlignment.center,
53+
children: <Widget>[
54+
const icons.Warning(color: color),
55+
const SizedBox(width: SMALL_SPACE),
56+
Expanded(
57+
child: FittedBox(
58+
fit: BoxFit.contain,
59+
child: Text(
60+
appLocalizations.barcode_probably_invalid,
61+
style: const TextStyle(color: color),
6962
),
7063
),
71-
],
72-
),
73-
Text(
74-
'<$barcode>',
75-
style: TextStyle(
76-
letterSpacing: 6.0,
77-
fontFeatures: const <FontFeature>[
78-
FontFeature.tabularFigures(),
79-
],
80-
color: color,
8164
),
65+
],
66+
),
67+
Text(
68+
'<$barcode>',
69+
style: const TextStyle(
70+
letterSpacing: 6.0,
71+
fontFeatures: <FontFeature>[FontFeature.tabularFigures()],
72+
color: color,
8273
),
83-
],
84-
),
85-
);
86-
},
87-
height: height,
88-
),
74+
),
75+
],
76+
),
77+
);
78+
},
79+
height: height,
8980
),
9081
),
9182
);

0 commit comments

Comments
 (0)