Skip to content

Commit

Permalink
Visual improvements for the scan page (#5773)
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k authored Nov 2, 2024
1 parent 93b3503 commit 0cc9e47
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 126 deletions.
4 changes: 2 additions & 2 deletions packages/smooth_app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ SPEC CHECKSUMS:
mobile_scanner: 38dcd8a49d7d485f632b7de65e4900010187aef2
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
nanopb: 438bc412db1928dac798aa6fd75726007be04262
package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
Expand All @@ -302,7 +302,7 @@ SPEC CHECKSUMS:
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57
sentry_flutter: 0eb93e5279eb41e2392212afe1ccd2fecb4f8cbe
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
import 'package:provider/provider.dart';
import 'package:smooth_app/cards/product_cards/smooth_product_base_card.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/helpers/extension_on_text_helper.dart';
import 'package:smooth_app/helpers/product_cards_helper.dart';

Expand Down Expand Up @@ -52,15 +53,30 @@ class ProductTitleCard extends StatelessWidget {
];
} else {
children = <Widget>[
_ProductTitleCardName(
selectable: isSelectable,
dense: dense,
),
_ProductTitleCardBrand(
removable: isRemovable,
selectable: isSelectable,
Padding(
padding: const EdgeInsetsDirectional.only(top: VERY_SMALL_SPACE),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
_ProductTitleCardName(
selectable: isSelectable,
dense: dense,
),
_ProductTitleCardBrand(
removable: isRemovable,
selectable: isSelectable,
),
],
),
),
title,
],
),
),
title,
];
}

Expand Down Expand Up @@ -154,6 +170,11 @@ class _ProductTitleCardTrailing extends StatelessWidget {
alignment: AlignmentDirectional.centerEnd,
child: ProductCardCloseButton(
onRemove: onRemove,
padding: const EdgeInsetsDirectional.only(
start: SMALL_SPACE,
top: SMALL_SPACE,
bottom: SMALL_SPACE,
),
),
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ class ProductCardCloseButton extends StatelessWidget {
const ProductCardCloseButton({
this.onRemove,
this.iconData = Icons.clear_rounded,
this.padding,
});

final OnRemoveCallback? onRemove;
final IconData iconData;
final EdgeInsetsGeometry? padding;

@override
Widget build(BuildContext context) {
Expand All @@ -79,7 +81,7 @@ class ProductCardCloseButton extends StatelessWidget {
child: Tooltip(
message: appLocalizations.product_card_remove_product_tooltip,
child: Padding(
padding: const EdgeInsets.all(SMALL_SPACE),
padding: padding ?? const EdgeInsets.all(SMALL_SPACE),
child: Icon(
iconData,
size: DEFAULT_ICON_SIZE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class ProductCompatibilityHeader extends StatelessWidget {
helper.getHeaderText(appLocalizations),
style: themeData.textTheme.titleMedium?.copyWith(
color: helper.getHeaderForegroundColor(isDarkMode),
fontSize: 15.0,
fontWeight: FontWeight.w600,
),
),
),
Expand Down
87 changes: 62 additions & 25 deletions packages/smooth_app/lib/pages/product/summary_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import 'package:smooth_app/pages/product/product_field_editor.dart';
import 'package:smooth_app/pages/product/product_incomplete_card.dart';
import 'package:smooth_app/pages/product/product_questions_widget.dart';
import 'package:smooth_app/pages/product/summary_attribute_group.dart';
import 'package:smooth_app/resources/app_icons.dart' as icons;
import 'package:smooth_app/themes/smooth_theme_colors.dart';

const List<String> _ATTRIBUTE_GROUP_ORDER = <String>[
AttributeGroup.ATTRIBUTE_GROUP_ALLERGENS,
Expand All @@ -45,6 +47,7 @@ class SummaryCard extends StatefulWidget {
this.isProductEditable = true,
this.attributeGroupsClickable = true,
this.padding,
this.shadow,
});

final Product _product;
Expand Down Expand Up @@ -73,6 +76,9 @@ class SummaryCard extends StatefulWidget {

final EdgeInsetsGeometry? padding;

/// An optional shadow to apply to the card
final BoxShadow? shadow;

@override
State<SummaryCard> createState() => _SummaryCardState();
}
Expand Down Expand Up @@ -120,6 +126,9 @@ class _SummaryCardState extends State<SummaryCard> with UpToDateMixin {
}

Widget _buildLimitedSizeSummaryCard(double parentHeight) {
final SmoothColorsThemeExtension? themeExtension =
Theme.of(context).extension<SmoothColorsThemeExtension>();

return Padding(
padding: widget.padding ??
const EdgeInsets.symmetric(
Expand All @@ -128,23 +137,30 @@ class _SummaryCardState extends State<SummaryCard> with UpToDateMixin {
),
child: Stack(
children: <Widget>[
ClipRRect(
borderRadius: ROUNDED_BORDER_RADIUS,
child: OverflowBox(
alignment: AlignmentDirectional.topStart,
minHeight: parentHeight,
maxHeight: double.infinity,
child: buildProductSmoothCard(
header: ProductCompatibilityHeader(
product: upToDateProduct,
productPreferences: widget._productPreferences,
isSettingVisible: widget.isSettingVisible,
),
body: Padding(
padding: SMOOTH_CARD_PADDING,
child: _buildSummaryCardContent(context),
DecoratedBox(
decoration: BoxDecoration(
boxShadow:
widget.shadow != null ? <BoxShadow>[widget.shadow!] : null,
borderRadius: ROUNDED_BORDER_RADIUS,
),
child: ClipRRect(
borderRadius: ROUNDED_BORDER_RADIUS,
child: OverflowBox(
alignment: AlignmentDirectional.topStart,
minHeight: parentHeight,
maxHeight: double.infinity,
child: buildProductSmoothCard(
header: ProductCompatibilityHeader(
product: upToDateProduct,
productPreferences: widget._productPreferences,
isSettingVisible: widget.isSettingVisible,
),
body: Padding(
padding: SMOOTH_CARD_PADDING,
child: _buildSummaryCardContent(context),
),
margin: EdgeInsets.zero,
),
margin: EdgeInsets.zero,
),
),
),
Expand All @@ -157,18 +173,39 @@ class _SummaryCardState extends State<SummaryCard> with UpToDateMixin {
vertical: SMALL_SPACE,
),
decoration: BoxDecoration(
color: Theme.of(context).cardColor,
color: themeExtension!.primaryNormal,
borderRadius:
const BorderRadius.vertical(bottom: ROUNDED_RADIUS),
),
child: Center(
child: Text(
AppLocalizations.of(context).tap_for_more,
style:
Theme.of(context).primaryTextTheme.bodyLarge?.copyWith(
color: PRIMARY_BLUE_COLOR,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsetsDirectional.only(bottom: 2.0),
child: Text(
AppLocalizations.of(context).tap_for_more,
style: const TextStyle(
color: Colors.white,
fontSize: 15.0,
fontWeight: FontWeight.w600,
),
),
),
const SizedBox(
width: BALANCED_SPACE,
),
Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
),
padding: const EdgeInsets.all(VERY_SMALL_SPACE),
child: icons.Arrow.right(
color: themeExtension.primaryNormal,
size: 12.0,
),
)
],
),
),
],
Expand Down
Loading

0 comments on commit 0cc9e47

Please sign in to comment.