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: Several fixes for product addition #5978

Merged
merged 1 commit into from
Dec 1, 2024
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 @@ -28,6 +28,9 @@ import 'package:smooth_app/pages/product/product_image_swipeable_view.dart';
import 'package:smooth_app/pages/product/product_type_extensions.dart';
import 'package:smooth_app/pages/product/simple_input_page_helpers.dart';
import 'package:smooth_app/query/product_query.dart';
import 'package:smooth_app/themes/smooth_theme.dart';
import 'package:smooth_app/themes/smooth_theme_colors.dart';
import 'package:smooth_app/themes/theme_provider.dart';
import 'package:smooth_app/widgets/smooth_scaffold.dart';
import 'package:smooth_app/widgets/v2/smooth_buttons_bar.dart';
import 'package:smooth_app/widgets/will_pop_scope.dart';
Expand Down Expand Up @@ -98,6 +101,7 @@ class _AddNewProductPageState extends State<AddNewProductPage>
(widget.displayPictures ? 1 : 0);

double get _progress => (_pageNumber + 1) / _totalPages;

bool get _isLastPage => (_pageNumber + 1) == _totalPages;
ProductType? _inputProductType;
late ColorScheme _colorScheme;
Expand Down Expand Up @@ -236,6 +240,7 @@ class _AddNewProductPageState extends State<AddNewProductPage>
onWillPop: () async => (await _onWillPop(), null),
child: SmoothScaffold(
body: SafeArea(
bottom: false,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expand All @@ -261,6 +266,10 @@ class _AddNewProductPageState extends State<AddNewProductPage>
Expanded(
child: PageView(
controller: _pageController,
physics:
widget.displayProductType && _inputProductType == null
? const NeverScrollableScrollPhysics()
: null,
children: <Widget>[
if (widget.displayProductType)
_buildCard(_getProductTypes(context)),
Expand Down Expand Up @@ -460,6 +469,9 @@ class _AddNewProductPageState extends State<AddNewProductPage>

List<Widget> _getEcoscoreRows(final BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
final SmoothColorsThemeExtension extension =
context.extension<SmoothColorsThemeExtension>();

final Attribute? attribute = _getAttribute(Attribute.ATTRIBUTE_ECOSCORE);
return <Widget>[
AddNewProductTitle(appLocalizations.new_product_title_ecoscore),
Expand All @@ -474,18 +486,21 @@ class _AddNewProductPageState extends State<AddNewProductPage>
),
),
const SizedBox(height: 15.0),
GestureDetector(
InkWell(
borderRadius: ROUNDED_BORDER_RADIUS,
onTap: () {
setState(() => _ecoscoreExpanded = !_ecoscoreExpanded);
},
child: Container(
child: Ink(
padding: const EdgeInsets.symmetric(
vertical: BALANCED_SPACE,
horizontal: 15.0,
),
decoration: BoxDecoration(
borderRadius: ROUNDED_BORDER_RADIUS,
color: _colorScheme.surface,
color: context.lightTheme()
? extension.primaryNormal
: extension.primaryMedium,
),
child: Row(
children: <Widget>[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class ProductIncompleteCard extends StatelessWidget {
Icons.bolt,
color: Colors.amber,
),
onPressed: () async => Navigator.push<void>(
context,
onPressed: () async =>
Navigator.of(context, rootNavigator: true).push<void>(
MaterialPageRoute<void>(
builder: (BuildContext context) => AddNewProductPage.fromProduct(
product,
Expand Down