Skip to content

Commit

Permalink
Merge branch 'openfoodfacts:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimaelQuemerais authored Jan 27, 2025
2 parents d39ef88 + 74fe856 commit 1997595
Show file tree
Hide file tree
Showing 170 changed files with 8,817 additions and 1,769 deletions.
5 changes: 3 additions & 2 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ History:
⚙️🥗 Food preferences:
- changed-files:
- any-glob-to-any-file: 'packages/smooth_app/lib/widgets/attribute_button.dart'

- any-glob-to-any-file: 'packages/smooth_app/lib/pages/preferences/user_preferences_attribute_group.dart'

🤗 Onboarding:
- changed-files:
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/onboarding/**/*'
Expand Down Expand Up @@ -254,6 +255,7 @@ autocomplete:
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/simple_input_page.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/simple_input_page_helpers.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/simple_input_text_field.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/nutrition_page/widgets/edit_product_image_viewer.dart'

✏️ Editing - Nutrition input:
- changed-files:
Expand All @@ -264,7 +266,6 @@ autocomplete:
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/nutrition_page/widgets/nutrition_availability_container.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/nutrition_page/widgets/nutrition_container_helper.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/nutrition_page/widgets/nutrition_facts_editor.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/nutrition_page/widgets/nutrition_image_viewer.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/nutrition_page/widgets/nutrition_serving_size.dart'
- any-glob-to-any-file: 'packages/smooth_app/lib/pages/product/nutrition_page/widgets/nutrition_serving_switch.dart'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/checkout@v4

- name: crowdin action
uses: crowdin/[email protected].1
uses: crowdin/[email protected].2
continue-on-error: true
with:
# Upload sources to Crowdin
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@ jobs:
tag_name: ${{ steps.release_please.outputs.tag_name }}
steps:
- name: Release-please
uses: googleapis/release-please-action@v4
uses: googleapis/release-please-action@v4.1.1
id: release_please
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple
pull-request-title-pattern: "chore${scope}: 🚀 Open Food Facts Mobile app - Release${component} ${version}."
changelog-types: '[{"type":"feat","section":"🚀 Features","hidden":false},{"type":"fix","section":"🐛 Bug Fixes","hidden":false},{"type":"docs","section":"📖 Documentation","hidden":false},{"type":"ci","section":"🤖 Automation","hidden":false},{"type":"refactor","section":"👷 Refactoring","hidden":false},{"type":"chore","section":"🛠 Miscellaneous","hidden":false},{"type":"l10n","section":"🌍 Translations","hidden":false}]'
changelog-types: |
[
{"type":"feat","section":"🚀 Features","hidden":false},
{"type":"fix","section":"🐛 Bug Fixes","hidden":false},
{"type":"docs","section":"📖 Documentation","hidden":false},
{"type":"ci","section":"🤖 Automation","hidden":false},
{"type":"refactor","section":"👷 Refactoring","hidden":false},
{"type":"chore","section":"🛠 Miscellaneous","hidden":false},
{"type":"l10n","section":"🌍 Translations","hidden":false}
]
create-release:
concurrency:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ class UserPreferences extends ChangeNotifier {
'taglineFeedNewsDisplayed';
static const String _TAG_TAGLINE_FEED_NEWS_CLICKED = 'taglineFeedNewsClicked';

/// Info messages
static const String _TAG_SHOW_BANNER_INPUT_PRODUCT_NAME =
'bannerInputProductName';

Future<void> init(final ProductPreferences productPreferences) async {
await _onMigrate();

Expand Down Expand Up @@ -483,6 +487,17 @@ class UserPreferences extends ChangeNotifier {
}
}

bool showInputProductNameBanner() =>
_sharedPreferences.getBool(_TAG_SHOW_BANNER_INPUT_PRODUCT_NAME) ?? true;

Future<void> hideInputProductNameBanner() async {
await _sharedPreferences.setBool(
_TAG_SHOW_BANNER_INPUT_PRODUCT_NAME,
false,
);
notifyListeners();
}

ProductType get latestProductType =>
ProductType.fromOffTag(
_sharedPreferences.getString(_TAG_LATEST_PRODUCT_TYPE)) ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,20 +682,34 @@ abstract class SizeWidget implements Widget {
class SmoothModalSheetBodyContainer extends StatelessWidget {
const SmoothModalSheetBodyContainer({
required this.child,
this.padding,
this.safeArea = true,
super.key,
});

final Widget child;
final EdgeInsetsGeometry? padding;
final bool safeArea;

@override
Widget build(BuildContext context) {
EdgeInsetsGeometry padding = this.padding ??
const EdgeInsetsDirectional.only(
start: MEDIUM_SPACE,
end: MEDIUM_SPACE,
top: VERY_SMALL_SPACE,
bottom: VERY_SMALL_SPACE,
);

if (safeArea) {
padding = padding.add(
EdgeInsetsDirectional.only(
bottom: MediaQuery.viewPaddingOf(context).bottom,
),
);
}
return Padding(
padding: EdgeInsetsDirectional.only(
start: MEDIUM_SPACE,
end: MEDIUM_SPACE,
top: VERY_SMALL_SPACE,
bottom: VERY_SMALL_SPACE + MediaQuery.viewPaddingOf(context).bottom,
),
padding: padding,
child: DefaultTextStyle.merge(
style: const TextStyle(
fontSize: 15.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SmoothHtmlChip extends StatelessWidget {
return CustomPaint(
painter: _HtmlChipPainter(
color:
context.lightTheme() ? extension.greyLight : extension.greyNormal,
context.lightTheme() ? extension.greyMedium : extension.greyNormal,
textDirection: Directionality.of(context),
),
child: const SizedBox.square(dimension: 10.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class SmoothHtmlDecimal extends StatelessWidget {
return CustomPaint(
painter: _HtmlDecimalPainter(
color:
context.lightTheme() ? extension.greyLight : extension.greyNormal,
context.lightTheme() ? extension.greyMedium : extension.greyNormal,
index: index,
textDirection: Directionality.of(context),
textStyle: const TextStyle(
Expand Down
60 changes: 51 additions & 9 deletions packages/smooth_app/lib/generic_lib/widgets/smooth_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class SmoothCardWithRoundedHeader extends StatelessWidget {
this.titleBackgroundColor,
this.contentBackgroundColor,
this.borderRadius,
this.includeShadow = true,
super.key,
});

Expand All @@ -133,20 +134,23 @@ class SmoothCardWithRoundedHeader extends StatelessWidget {
final Color? titleBackgroundColor;
final Color? contentBackgroundColor;
final BorderRadius? borderRadius;
final bool includeShadow;

@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
borderRadius: borderRadius ?? ROUNDED_BORDER_RADIUS,
boxShadow: const <BoxShadow>[
BoxShadow(
color: Color(0x03000000),
blurRadius: 2.0,
spreadRadius: 0.0,
offset: Offset(0.0, 2.0),
),
],
boxShadow: includeShadow
? const <BoxShadow>[
BoxShadow(
color: Color(0x10000000),
blurRadius: 2.0,
spreadRadius: 0.0,
offset: Offset(0.0, 2.0),
),
]
: null,
),
child: Column(
children: <Widget>[
Expand Down Expand Up @@ -209,6 +213,10 @@ class SmoothCardWithRoundedHeaderTop extends StatelessWidget {
painter: _SmoothCardWithRoundedHeaderBackgroundPainter(
color: color,
radius: borderRadius?.topRight ?? ROUNDED_RADIUS,
shadowElevation:
SmoothCardWithRoundedHeaderTopShadowProvider.of(context)
?.shadow ??
0.0,
),
child: Padding(
padding: titlePadding ??
Expand Down Expand Up @@ -282,6 +290,30 @@ class SmoothCardWithRoundedHeaderTop extends StatelessWidget {
}
}

class SmoothCardWithRoundedHeaderTopShadowProvider extends InheritedWidget {
const SmoothCardWithRoundedHeaderTopShadowProvider({
required this.shadow,
required super.child,
super.key,
});

final double shadow;

static SmoothCardWithRoundedHeaderTopShadowProvider? of(
BuildContext context) {
final SmoothCardWithRoundedHeaderTopShadowProvider? result =
context.dependOnInheritedWidgetOfExactType<
SmoothCardWithRoundedHeaderTopShadowProvider>();
return result;
}

@override
bool updateShouldNotify(
SmoothCardWithRoundedHeaderTopShadowProvider oldWidget) {
return oldWidget.shadow != shadow;
}
}

class SmoothCardWithRoundedHeaderBody extends StatelessWidget {
const SmoothCardWithRoundedHeaderBody({
required this.child,
Expand Down Expand Up @@ -320,10 +352,12 @@ class _SmoothCardWithRoundedHeaderBackgroundPainter extends CustomPainter {
_SmoothCardWithRoundedHeaderBackgroundPainter({
required Color color,
required this.radius,
required this.shadowElevation,
}) : _paint = Paint()..color = color;

final Radius radius;
final Paint _paint;
final double shadowElevation;

@override
void paint(Canvas canvas, Size size) {
Expand Down Expand Up @@ -355,14 +389,22 @@ class _SmoothCardWithRoundedHeaderBackgroundPainter extends CustomPainter {
)
..close();

if (shadowElevation > 0.0) {
canvas.drawShadow(
path,
Colors.black.withValues(alpha: shadowElevation),
2.0,
false,
);
}
canvas.drawPath(path, _paint);
}

@override
bool shouldRepaint(
_SmoothCardWithRoundedHeaderBackgroundPainter oldDelegate,
) =>
false;
shadowElevation != oldDelegate.shadowElevation;

@override
bool shouldRebuildSemantics(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:sliver_tools/sliver_tools.dart';
import 'package:smooth_app/generic_lib/design_constants.dart';
import 'package:smooth_app/generic_lib/widgets/smooth_card.dart';
import 'package:smooth_app/helpers/num_utils.dart';
import 'package:smooth_app/widgets/widget_height.dart';

class SliverCardWithRoundedHeader extends StatefulWidget {
Expand Down Expand Up @@ -125,7 +126,10 @@ class _SliverCardWithRoundedHeaderDelegate
width: double.infinity,
),
),
child,
SmoothCardWithRoundedHeaderTopShadowProvider(
shadow: shrinkOffset.progressAndClamp(0.0, 30.0, 1.0),
child: child,
),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class SmoothTextFormField extends StatefulWidget {
this.spellCheckConfiguration,
this.allowEmojis = true,
this.maxLines,
this.borderRadius,
this.contentPadding,
});

final TextFieldTypes type;
Expand All @@ -51,6 +53,8 @@ class SmoothTextFormField extends StatefulWidget {
final SpellCheckConfiguration? spellCheckConfiguration;
final bool allowEmojis;
final int? maxLines;
final BorderRadius? borderRadius;
final EdgeInsetsGeometry? contentPadding;

@override
State<SmoothTextFormField> createState() => _SmoothTextFormFieldState();
Expand All @@ -76,7 +80,9 @@ class _SmoothTextFormFieldState extends State<SmoothTextFormField> {
Widget build(BuildContext context) {
final bool enableSuggestions = widget.type == TextFieldTypes.PLAIN_TEXT;
final bool autocorrect = widget.type == TextFieldTypes.PLAIN_TEXT;
final TextStyle textStyle = DefaultTextStyle.of(context).style;
final TextStyle textStyle = DefaultTextStyle.of(context).style.copyWith(
fontSize: 15.0,
);
final double textSize = textStyle.fontSize ?? 20.0;
final AppLocalizations appLocalization = AppLocalizations.of(context);

Expand Down Expand Up @@ -111,23 +117,25 @@ class _SmoothTextFormFieldState extends State<SmoothTextFormField> {
FilteringTextInputFormatter.deny(TextHelper.emojiRegex),
],
decoration: InputDecoration(
contentPadding: const EdgeInsets.symmetric(
horizontal: LARGE_SPACE,
vertical: SMALL_SPACE,
),
contentPadding: widget.contentPadding ??
const EdgeInsets.symmetric(
horizontal: LARGE_SPACE,
vertical: SMALL_SPACE,
),
isDense: widget.contentPadding != null,
prefixIcon: widget.prefixIcon,
filled: true,
hintStyle: (widget.hintTextStyle ?? const TextStyle()).apply(
overflow: TextOverflow.ellipsis,
),
hintText: widget.hintText,
hintMaxLines: widget.maxLines ?? 2,
border: const OutlineInputBorder(
borderRadius: CIRCULAR_BORDER_RADIUS,
border: OutlineInputBorder(
borderRadius: widget.borderRadius ?? CIRCULAR_BORDER_RADIUS,
),
enabledBorder: const OutlineInputBorder(
borderRadius: CIRCULAR_BORDER_RADIUS,
borderSide: BorderSide(
enabledBorder: OutlineInputBorder(
borderRadius: widget.borderRadius ?? CIRCULAR_BORDER_RADIUS,
borderSide: const BorderSide(
color: Colors.transparent,
width: 5.0,
),
Expand Down
35 changes: 35 additions & 0 deletions packages/smooth_app/lib/helpers/paint_helper.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:flutter/rendering.dart';

class DashedLinePainter extends CustomPainter {
DashedLinePainter({
required Color color,
this.dashGap = 3.0,
this.dashSpace = 3.0,
}) : _paint = Paint()
..color = color
..strokeWidth = 1.0;

final double dashGap;
final double dashSpace;

final Paint _paint;

@override
void paint(Canvas canvas, Size size) {
double startX = 0.0;

while (startX < size.width) {
canvas.drawLine(
Offset(startX, 0),
Offset(startX + dashGap, 0),
_paint,
);

startX += dashGap + dashSpace;
}
}

@override
bool shouldRepaint(DashedLinePainter oldDelegate) =>
dashGap != oldDelegate.dashGap || dashSpace != oldDelegate.dashSpace;
}
Loading

0 comments on commit 1997595

Please sign in to comment.