Skip to content

Commit

Permalink
feat: Tiny UI tweaks for the product edition (openfoodfacts#4456)
Browse files Browse the repository at this point in the history
* UI tweaks on the product edition

* Some other tweaks
  • Loading branch information
g123k authored Aug 6, 2023
1 parent aa6632d commit a4998cd
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -458,36 +458,40 @@ class _SmoothActionFlatButton extends StatelessWidget {
value: buttonData.text,
button: true,
excludeSemantics: true,
child: TextButton(
onPressed: buttonData.onPressed,
style: TextButton.styleFrom(
shape: const RoundedRectangleBorder(
borderRadius: ROUNDED_BORDER_RADIUS,
),
textStyle: themeData.textTheme.bodyMedium!.copyWith(
color: themeData.colorScheme.onPrimary,
),
padding: const EdgeInsets.symmetric(
horizontal: SMALL_SPACE,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0),
child: TextButton(
onPressed: buttonData.onPressed,
style: TextButton.styleFrom(
shape: const RoundedRectangleBorder(
borderRadius: ROUNDED_BORDER_RADIUS,
),
textStyle: themeData.textTheme.bodyMedium!.copyWith(
color: themeData.colorScheme.onPrimary,
),
padding: const EdgeInsets.symmetric(
horizontal: SMALL_SPACE,
),
minimumSize: const Size(0, 46.0),
),
minimumSize: const Size(0, 50.0),
),
child: SizedBox(
height: buttonData.lines != null
? VERY_LARGE_SPACE * buttonData.lines!
: null,
width: buttonData.minWidth,
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
buttonData.text.toUpperCase(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: buttonData.textColor ?? themeData.colorScheme.primary,
child: SizedBox(
height: buttonData.lines != null
? VERY_LARGE_SPACE * buttonData.lines!
: null,
width: buttonData.minWidth,
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
buttonData.text.toUpperCase(),
style: TextStyle(
fontWeight: FontWeight.bold,
color:
buttonData.textColor ?? themeData.colorScheme.primary,
),
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
maxLines: buttonData.lines ?? 2,
),
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
maxLines: buttonData.lines ?? 2,
),
),
),
Expand Down
9 changes: 6 additions & 3 deletions packages/smooth_app/lib/pages/product/edit_image_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class EditImageButton extends StatelessWidget {
),
),
onPressed: onPressed,
label: Padding(
padding: EdgeInsets.all(borderWidth ?? 0),
child: Text(label),
label: SizedBox(
width: double.infinity,
child: Padding(
padding: EdgeInsets.all(borderWidth ?? 0),
child: Text(label),
),
),
);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/smooth_app/lib/pages/product/explanation_widget.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';

/// Widget that displays explanations as a list, with expand/collapse mode.
class ExplanationWidget extends StatefulWidget {
Expand Down Expand Up @@ -55,6 +56,10 @@ class _CollapsedExplanation extends StatelessWidget {
overflow: TextOverflow.ellipsis,
),
trailing: const Icon(Icons.info_outline),
contentPadding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE * 2,
end: SMALL_SPACE,
),
);
}
}
Expand Down Expand Up @@ -83,6 +88,10 @@ class _ExpandedExplanation extends StatelessWidget {
quarterTurns: 2,
child: Icon(Icons.expand_circle_down_outlined),
),
contentPadding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE * 2,
end: SMALL_SPACE,
),
),
);
} else {
Expand Down
15 changes: 8 additions & 7 deletions packages/smooth_app/lib/pages/product/product_image_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ class _ProductImageViewerState extends State<ProductImageViewer>
width: 3,
),
),
child: Padding(
padding: const EdgeInsets.all(SMALL_SPACE),
child: LanguageSelector(
setLanguage: widget.setLanguage,
displayedLanguage: widget.language,
selectedLanguages: selectedLanguages,
foregroundColor: Colors.white,
child: LanguageSelector(
setLanguage: widget.setLanguage,
displayedLanguage: widget.language,
selectedLanguages: selectedLanguages,
foregroundColor: Colors.white,
padding: const EdgeInsetsDirectional.symmetric(
horizontal: 13.0,
vertical: SMALL_SPACE,
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions packages/smooth_app/lib/pages/product/simple_input_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
Expand Down Expand Up @@ -94,9 +93,10 @@ class _SimpleInputPageState extends State<SimpleInputPage> {
fixKeyboard: true,
appBar: SmoothAppBar(
centerTitle: false,
title: AutoSizeText(
title: Text(
getProductName(widget.product, appLocalizations),
maxLines: widget.product.barcode?.isNotEmpty == true ? 1 : 2,
overflow: TextOverflow.ellipsis,
),
subTitle: widget.product.barcode != null
? ExcludeSemantics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SimpleInputTextField extends StatefulWidget {
this.minLengthForSuggestions = 1,
this.categories,
this.shapeProvider,
this.padding,
});

final FocusNode focusNode;
Expand All @@ -32,6 +33,7 @@ class SimpleInputTextField extends StatefulWidget {
final int minLengthForSuggestions;
final String? categories;
final String? Function()? shapeProvider;
final EdgeInsetsGeometry? padding;

@override
State<SimpleInputTextField> createState() => _SimpleInputTextFieldState();
Expand Down Expand Up @@ -100,7 +102,8 @@ class _SimpleInputTextFieldState extends State<SimpleInputTextField> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsetsDirectional.only(start: LARGE_SPACE),
padding: widget.padding ??
const EdgeInsetsDirectional.only(start: LARGE_SPACE),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
Expand Down
10 changes: 5 additions & 5 deletions packages/smooth_app/lib/pages/product/simple_input_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class _SimpleInputWidgetState extends State<SimpleInputWidget> {
tagType: widget.helper.getTagType(),
hintText: widget.helper.getAddHint(appLocalizations),
controller: widget.controller,
padding: const EdgeInsetsDirectional.only(
start: 9.0,
),
),
),
Tooltip(
Expand All @@ -93,13 +96,13 @@ class _SimpleInputWidgetState extends State<SimpleInputWidget> {
child: IconButton(
onPressed: _onAddItem,
icon: const Icon(Icons.add_circle),
splashRadius: 20,
),
)
],
);
},
),
Divider(color: themeData.colorScheme.onBackground),
AnimatedList(
key: _listKey,
initialItemCount: _localTerms.length,
Expand All @@ -123,10 +126,7 @@ class _SimpleInputWidgetState extends State<SimpleInputWidget> {
customBorder: const CircleBorder(),
onTap: () => _onRemoveItem(term, child),
child: const Padding(
padding: EdgeInsets.symmetric(
horizontal: MEDIUM_SPACE,
vertical: SMALL_SPACE,
),
padding: EdgeInsets.all(SMALL_SPACE),
child: Icon(Icons.delete),
),
),
Expand Down
2 changes: 1 addition & 1 deletion packages/smooth_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ packages:
source: hosted
version: "7.0.0"
async:
dependency: transitive
dependency: "direct main"
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
Expand Down

0 comments on commit a4998cd

Please sign in to comment.