Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix for ScrollController has no ScrollPosition #4387

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class UserPreferencesPage extends StatefulWidget {

class _UserPreferencesPageState extends State<UserPreferencesPage>
with TraceableClientMixin {
final ScrollController _controller = ScrollController();

@override
String get traceTitle => 'user_preferences_page';

Expand Down Expand Up @@ -120,6 +122,7 @@ class _UserPreferencesPageState extends State<UserPreferencesPage>
final ListView list;
if (addDividers) {
list = ListView.separated(
controller: _controller,
padding: padding,
itemCount: children.length,
itemBuilder: (BuildContext context, int position) => children[position],
Expand All @@ -128,6 +131,7 @@ class _UserPreferencesPageState extends State<UserPreferencesPage>
);
} else {
list = ListView.builder(
controller: _controller,
padding: padding,
itemCount: children.length,
itemBuilder: (BuildContext context, int position) => children[position],
Expand All @@ -143,7 +147,10 @@ class _UserPreferencesPageState extends State<UserPreferencesPage>
),
leading: const SmoothBackButton(),
),
body: Scrollbar(child: list),
body: Scrollbar(
controller: _controller,
child: list,
),
);
}
final bool dark = Theme.of(context).brightness == Brightness.dark;
Expand Down Expand Up @@ -174,7 +181,10 @@ class _UserPreferencesPageState extends State<UserPreferencesPage>
maxLines: 2,
),
),
body: ListView(children: children),
body: ListView(
controller: _controller,
children: children,
),
);
}

Expand Down
217 changes: 107 additions & 110 deletions packages/smooth_app/lib/pages/product/edit_product_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,130 +123,127 @@ class _EditProductPageState extends State<EditProductPage> with UpToDateMixin {
barcode: barcode,
widget: this,
),
child: PrimaryScrollController(
child: Scrollbar(
controller: _controller,
child: Scrollbar(
child: ListView(
children: <Widget>[
if (_ProductBarcode.isAValidBarcode(barcode))
_ProductBarcode(product: upToDateProduct),
_ListTitleItem(
title: appLocalizations.edit_product_form_item_details_title,
subtitle:
appLocalizations.edit_product_form_item_details_subtitle,
onTap: () async => ProductFieldDetailsEditor().edit(
context: context,
product: upToDateProduct,
),
child: ListView(
controller: _controller,
children: <Widget>[
if (_ProductBarcode.isAValidBarcode(barcode))
_ProductBarcode(product: upToDateProduct),
_ListTitleItem(
title: appLocalizations.edit_product_form_item_details_title,
subtitle:
appLocalizations.edit_product_form_item_details_subtitle,
onTap: () async => ProductFieldDetailsEditor().edit(
context: context,
product: upToDateProduct,
),
_ListTitleItem(
leading: const Icon(Icons.add_a_photo_rounded),
title: appLocalizations.edit_product_form_item_photos_title,
subtitle:
appLocalizations.edit_product_form_item_photos_subtitle,
onTap: () async {
AnalyticsHelper.trackProductEdit(
AnalyticsEditEvents.photos,
barcode,
);
),
_ListTitleItem(
leading: const Icon(Icons.add_a_photo_rounded),
title: appLocalizations.edit_product_form_item_photos_title,
subtitle:
appLocalizations.edit_product_form_item_photos_subtitle,
onTap: () async {
AnalyticsHelper.trackProductEdit(
AnalyticsEditEvents.photos,
barcode,
);

await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) =>
ProductImageGalleryView(
product: upToDateProduct,
),
fullscreenDialog: true,
await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (BuildContext context) =>
ProductImageGalleryView(
product: upToDateProduct,
),
);
},
),
_getMultipleListTileItem(
<AbstractSimpleInputPageHelper>[
SimpleInputPageLabelHelper(),
SimpleInputPageStoreHelper(),
SimpleInputPageOriginHelper(),
SimpleInputPageEmbCodeHelper(),
SimpleInputPageCountryHelper(),
SimpleInputPageCategoryHelper(),
],
fullscreenDialog: true,
),
);
},
),
_getMultipleListTileItem(
<AbstractSimpleInputPageHelper>[
SimpleInputPageLabelHelper(),
SimpleInputPageStoreHelper(),
SimpleInputPageOriginHelper(),
SimpleInputPageEmbCodeHelper(),
SimpleInputPageCountryHelper(),
SimpleInputPageCategoryHelper(),
],
),
_ListTitleItem(
leading: const _SvgIcon('assets/cacheTintable/ingredients.svg'),
title:
appLocalizations.edit_product_form_item_ingredients_title,
onTap: () async => ProductFieldOcrIngredientEditor().edit(
context: context,
product: upToDateProduct,
),
_ListTitleItem(
),
_getSimpleListTileItem(SimpleInputPageCategoryHelper()),
_ListTitleItem(
leading:
const _SvgIcon('assets/cacheTintable/ingredients.svg'),
title:
appLocalizations.edit_product_form_item_ingredients_title,
onTap: () async => ProductFieldOcrIngredientEditor().edit(
context: context,
product: upToDateProduct,
),
),
_getSimpleListTileItem(SimpleInputPageCategoryHelper()),
_ListTitleItem(
leading: const _SvgIcon(
'assets/cacheTintable/scale-balance.svg'),
title: appLocalizations
.edit_product_form_item_nutrition_facts_title,
subtitle: appLocalizations
.edit_product_form_item_nutrition_facts_subtitle,
onTap: () async {
AnalyticsHelper.trackProductEdit(
AnalyticsEditEvents.nutrition_Facts,
barcode,
);
await NutritionPageLoaded.showNutritionPage(
product: upToDateProduct,
isLoggedInMandatory: true,
context: context,
);
}),
_getSimpleListTileItem(SimpleInputPageLabelHelper()),
_ListTitleItem(
leading: const _SvgIcon('assets/cacheTintable/packaging.svg'),
title: appLocalizations.edit_packagings_title,
onTap: () async => ProductFieldPackagingEditor().edit(
context: context,
product: upToDateProduct,
),
),
_ListTitleItem(
leading: const Icon(Icons.recycling),
title:
appLocalizations.edit_product_form_item_packaging_title,
onTap: () async => ProductFieldOcrPackagingEditor().edit(
context: context,
product: upToDateProduct,
),
),
_getSimpleListTileItem(SimpleInputPageStoreHelper()),
_getSimpleListTileItem(SimpleInputPageOriginHelper()),
_getSimpleListTileItem(SimpleInputPageEmbCodeHelper()),
_getSimpleListTileItem(SimpleInputPageCountryHelper()),
_ListTitleItem(
const _SvgIcon('assets/cacheTintable/scale-balance.svg'),
title: appLocalizations
.edit_product_form_item_other_details_title,
.edit_product_form_item_nutrition_facts_title,
subtitle: appLocalizations
.edit_product_form_item_other_details_subtitle,
.edit_product_form_item_nutrition_facts_subtitle,
onTap: () async {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
AnalyticsHelper.trackProductEdit(
AnalyticsEditEvents.otherDetails,
AnalyticsEditEvents.nutrition_Facts,
barcode,
);
await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (_) => AddOtherDetailsPage(upToDateProduct),
fullscreenDialog: true,
),
await NutritionPageLoaded.showNutritionPage(
product: upToDateProduct,
isLoggedInMandatory: true,
context: context,
);
},
}),
_getSimpleListTileItem(SimpleInputPageLabelHelper()),
_ListTitleItem(
leading: const _SvgIcon('assets/cacheTintable/packaging.svg'),
title: appLocalizations.edit_packagings_title,
onTap: () async => ProductFieldPackagingEditor().edit(
context: context,
product: upToDateProduct,
),
],
),
),
_ListTitleItem(
leading: const Icon(Icons.recycling),
title: appLocalizations.edit_product_form_item_packaging_title,
onTap: () async => ProductFieldOcrPackagingEditor().edit(
context: context,
product: upToDateProduct,
),
),
_getSimpleListTileItem(SimpleInputPageStoreHelper()),
_getSimpleListTileItem(SimpleInputPageOriginHelper()),
_getSimpleListTileItem(SimpleInputPageEmbCodeHelper()),
_getSimpleListTileItem(SimpleInputPageCountryHelper()),
_ListTitleItem(
title:
appLocalizations.edit_product_form_item_other_details_title,
subtitle: appLocalizations
.edit_product_form_item_other_details_subtitle,
onTap: () async {
if (!await ProductRefresher().checkIfLoggedIn(context)) {
return;
}
AnalyticsHelper.trackProductEdit(
AnalyticsEditEvents.otherDetails,
barcode,
);
await Navigator.push<void>(
context,
MaterialPageRoute<void>(
builder: (_) => AddOtherDetailsPage(upToDateProduct),
fullscreenDialog: true,
),
);
},
),
],
),
),
),
Expand Down