Skip to content

Commit

Permalink
fix: Image gallery language not selectable (+ too long AppBar title (#…
Browse files Browse the repository at this point in the history
…5968)

* Ensure the AppBar title is on a single line when there is a subtitle

* Fix: impossible to add a new language

* Fix build error
  • Loading branch information
g123k authored Nov 30, 2024
1 parent 3aadddf commit 47b6ee3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class _ImageGalleryLanguagesProvider
Product? product;

void attachProduct(final Product product) {
if (product != this.product) {
if (!equalsProduct(product)) {
this.product = product;
refreshLanguages(initial: true);
}
Expand Down Expand Up @@ -311,6 +311,33 @@ class _ImageGalleryLanguagesProvider
hasNewLanguage: false,
);
}

bool equalsProduct(Product product) {
if (this.product == null) {
return false;
}

return product.barcode == this.product!.barcode &&
product.productType == this.product!.productType &&
product.imageFrontUrl == this.product!.imageFrontUrl &&
product.imageFrontSmallUrl == this.product!.imageFrontSmallUrl &&
product.imageIngredientsUrl == this.product!.imageIngredientsUrl &&
product.imageIngredientsSmallUrl ==
this.product!.imageIngredientsSmallUrl &&
product.imageNutritionUrl == this.product!.imageNutritionUrl &&
product.imageNutritionSmallUrl ==
this.product!.imageNutritionSmallUrl &&
product.imagePackagingUrl == this.product!.imagePackagingUrl &&
product.imagePackagingSmallUrl ==
this.product!.imagePackagingSmallUrl &&
const ListEquality<ProductImage>()
.equals(product.selectedImages, this.product!.selectedImages) &&
const ListEquality<ProductImage>()
.equals(product.images, this.product!.images) &&
product.lastImage == this.product!.lastImage &&
const ListEquality<String>()
.equals(product.lastImageDates, this.product!.lastImageDates);
}
}

class _ImageGalleryLanguagesState {
Expand Down
2 changes: 2 additions & 0 deletions packages/smooth_app/lib/widgets/smooth_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ class _AppBarTitle extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
DefaultTextStyle(
maxLines: subTitle != null ? 1 : 2,
overflow: TextOverflow.ellipsis,
style: (titleTextStyle ??
AppBarTheme.of(context).titleTextStyle ??
theme.appBarTheme.titleTextStyle?.copyWith(
Expand Down

0 comments on commit 47b6ee3

Please sign in to comment.