Skip to content

Commit

Permalink
feat: Add checkmarks on 'add new product' screen (openfoodfacts#3080)
Browse files Browse the repository at this point in the history
* feat: New product basic details checkmark

* refactor: New product page added row

* feat: New product nutrition facts checkmark

* chore: Fix new product page code formatting

* fix: Change icon on new product page

Closes: openfoodfacts#2974

* refactor: Add new product page added row to widget
  • Loading branch information
WildOrangutan authored Oct 3, 2022
1 parent 6644d59 commit 8b08a85
Showing 1 changed file with 45 additions and 76 deletions.
121 changes: 45 additions & 76 deletions packages/smooth_app/lib/pages/product/add_new_product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,34 +201,9 @@ class _AddNewProductPageState extends State<AddNewProductPage> {

Widget _buildImageUploadedRow(
BuildContext context, ImageField imageType, File image) {
final ThemeData themeData = Theme.of(context);
return Padding(
padding: _ROW_PADDING_TOP,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 50,
width: 50,
child: ClipRRect(
borderRadius: ROUNDED_BORDER_RADIUS,
child: Image.file(image, fit: BoxFit.cover),
),
),
Expanded(
child: Center(
child: Text(
_getAddPhotoButtonText(context, imageType),
style: themeData.textTheme.bodyText1,
),
),
),
Icon(
Icons.check_box,
color: themeData.bottomNavigationBarTheme.selectedItemColor,
)
],
),
return _InfoAddedRow(
text: _getAddPhotoButtonText(context, imageType),
imgStart: image,
);
}

Expand Down Expand Up @@ -258,31 +233,8 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
return const SizedBox();
}
if (_nutritionFactsAdded) {
return Padding(
padding: _ROW_PADDING_TOP,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(
width: 50.0,
child: Icon(
Icons.check,
color: Theme.of(context)
.bottomNavigationBarTheme
.selectedItemColor,
),
),
Expanded(
child: Center(
child: Text(
AppLocalizations.of(context).nutritional_facts_added,
style: Theme.of(context).textTheme.bodyText1),
),
),
],
),
);
return _InfoAddedRow(
text: AppLocalizations.of(context).nutritional_facts_added);
}

return Padding(
Expand Down Expand Up @@ -333,29 +285,8 @@ class _AddNewProductPageState extends State<AddNewProductPage> {

Widget _buildaddInputDetailsButton() {
if (_basicDetailsAdded) {
final ThemeData themeData = Theme.of(context);
return Padding(
padding: _ROW_PADDING_TOP,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(
width: 50.0,
child: Icon(
Icons.check,
color: themeData.bottomNavigationBarTheme.selectedItemColor,
),
),
Expanded(
child: Center(
child: Text(
AppLocalizations.of(context).basic_details_add_success,
style: Theme.of(context).textTheme.bodyText1),
),
),
],
));
return _InfoAddedRow(
text: AppLocalizations.of(context).basic_details_add_success);
}

return Padding(
Expand Down Expand Up @@ -383,3 +314,41 @@ class _AddNewProductPageState extends State<AddNewProductPage> {
);
}
}

class _InfoAddedRow extends StatelessWidget {
const _InfoAddedRow({required this.text, this.imgStart});

final String text;
final File? imgStart;

@override
Widget build(BuildContext context) {
final ThemeData themeData = Theme.of(context);
return Padding(
padding: _ROW_PADDING_TOP,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
height: 50,
width: 50,
child: ClipRRect(
borderRadius: ROUNDED_BORDER_RADIUS,
child: imgStart == null
? null
: Image.file(imgStart!, fit: BoxFit.cover),
),
),
Expanded(
child: Center(
child: Text(text, style: themeData.textTheme.bodyText1),
),
),
Icon(
Icons.check,
color: themeData.bottomNavigationBarTheme.selectedItemColor,
)
],
));
}
}

0 comments on commit 8b08a85

Please sign in to comment.