mirror of
https://github.com/Iconica-Development/flutter_shopping.git
synced 2025-05-19 08:53:46 +02:00
feat: remove listenablebuilders from order details
This commit is contained in:
parent
1b307e3084
commit
2bf42c4acb
4 changed files with 104 additions and 115 deletions
|
@ -49,7 +49,9 @@ class _OrderDetailScreenState extends State<OrderDetailScreen> {
|
|||
checkingPages: checkingPages,
|
||||
),
|
||||
pages: widget.configuration.pages?.call(context) ??
|
||||
defaultPages(context),
|
||||
defaultPages(context, () {
|
||||
setState(() {});
|
||||
}),
|
||||
onFinished: (data) async {
|
||||
widget.configuration.onStepsCompleted.call(
|
||||
widget.configuration.shoppingService.shopService.selectedShop!.id,
|
||||
|
|
|
@ -2,9 +2,11 @@ import "package:animated_toggle/animated_toggle.dart";
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_order_details/flutter_order_details.dart";
|
||||
|
||||
|
||||
/// Default pages for the order details screen.
|
||||
List<FlutterFormPage> defaultPages(BuildContext context) {
|
||||
List<FlutterFormPage> defaultPages(
|
||||
BuildContext context,
|
||||
Function() onSwitched,
|
||||
) {
|
||||
var theme = Theme.of(context);
|
||||
|
||||
var morningTimes = <String>[
|
||||
|
@ -307,11 +309,10 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
|||
toggleColor: theme.colorScheme.primary,
|
||||
onSwitch: (value) {
|
||||
switchStatus.value = value;
|
||||
onSwitched();
|
||||
},
|
||||
childLeft: Center(
|
||||
child: ListenableBuilder(
|
||||
listenable: switchStatus,
|
||||
builder: (context, widget) => Text(
|
||||
child: Text(
|
||||
"Morning",
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
color: switchStatus.value
|
||||
|
@ -320,11 +321,8 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
childRight: Center(
|
||||
child: ListenableBuilder(
|
||||
listenable: switchStatus,
|
||||
builder: (context, widget) => Text(
|
||||
child: Text(
|
||||
"Afternoon",
|
||||
style: theme.textTheme.titleSmall?.copyWith(
|
||||
color: switchStatus.value
|
||||
|
@ -335,13 +333,10 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
ListenableBuilder(
|
||||
listenable: switchStatus,
|
||||
builder: (context, widget) => FlutterFormInputMultipleChoice(
|
||||
FlutterFormInputMultipleChoice(
|
||||
validationMessage: "Select a Time",
|
||||
controller: multipleChoiceController,
|
||||
options: switchStatus.value ? afternoonTimes : morningTimes,
|
||||
|
@ -349,8 +344,7 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
|||
crossAxisSpacing: 5,
|
||||
childAspectRatio: 2,
|
||||
height: MediaQuery.of(context).size.height * 0.6,
|
||||
builder:
|
||||
(context, index, selected, controller, options, state) =>
|
||||
builder: (context, index, selected, controller, options, state) =>
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
state.didChange(options[index]);
|
||||
|
@ -371,7 +365,6 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -54,7 +54,9 @@ class ProductPageScreen extends StatelessWidget {
|
|||
context,
|
||||
data.error,
|
||||
) ??
|
||||
DefaultError(error: data.error);
|
||||
DefaultError(
|
||||
error: data.error,
|
||||
);
|
||||
}
|
||||
|
||||
List<Shop>? shops = data.data;
|
||||
|
@ -102,32 +104,9 @@ class ProductPageScreen extends StatelessWidget {
|
|||
configuration.onShopSelectionChange?.call(
|
||||
configuration.shoppingService.shopService.selectedShop!,
|
||||
);
|
||||
return _ProductPage(
|
||||
configuration: configuration,
|
||||
shops: shops,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _ProductPage extends StatelessWidget {
|
||||
const _ProductPage({
|
||||
required this.configuration,
|
||||
required this.shops,
|
||||
});
|
||||
|
||||
final ProductPageConfiguration configuration;
|
||||
|
||||
final List<Shop> shops;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var pageContent = SingleChildScrollView(
|
||||
return Stack(
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
@ -135,12 +114,14 @@ class _ProductPage extends StatelessWidget {
|
|||
context,
|
||||
configuration,
|
||||
shops,
|
||||
configuration.shoppingService.shopService.selectShop,
|
||||
configuration
|
||||
.shoppingService.shopService.selectShop,
|
||||
) ??
|
||||
ShopSelector(
|
||||
configuration: configuration,
|
||||
shops: shops,
|
||||
onTap: configuration.shoppingService.shopService.selectShop,
|
||||
onTap: configuration
|
||||
.shoppingService.shopService.selectShop,
|
||||
),
|
||||
configuration.selectedCategoryBuilder?.call(
|
||||
configuration,
|
||||
|
@ -153,11 +134,7 @@ class _ProductPage extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
pageContent,
|
||||
),
|
||||
Align(
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: configuration.shoppingCartButtonBuilder != null
|
||||
|
@ -171,7 +148,13 @@ class _ProductPage extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _ShopContents extends StatelessWidget {
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
// ignore_for_file: public_member_api_docs
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_shopping/flutter_shopping.dart";
|
||||
import "package:flutter_shopping_local/flutter_shopping_local.dart";
|
||||
|
||||
/// User story for the shopping navigator.
|
||||
class ShoppingNavigatorUserStory extends StatelessWidget {
|
||||
/// Constructor for the shopping navigator user story.
|
||||
const ShoppingNavigatorUserStory({
|
||||
this.shoppingConfiguration,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// Shopping configuration.
|
||||
final ShoppingConfiguration? shoppingConfiguration;
|
||||
|
||||
@override
|
||||
|
@ -21,11 +22,15 @@ class ShoppingNavigatorUserStory extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
/// Shopping product page.
|
||||
class ShoppingProductPage extends StatelessWidget {
|
||||
/// Constructor for the shopping product page.
|
||||
const ShoppingProductPage({
|
||||
required this.shoppingConfiguration,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// Shopping configuration.
|
||||
final ShoppingConfiguration shoppingConfiguration;
|
||||
|
||||
@override
|
||||
|
@ -103,12 +108,15 @@ class ShoppingProductPage extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
/// Shopping cart.
|
||||
class ShoppingCart extends StatelessWidget {
|
||||
/// Constructor for the shopping cart.
|
||||
const ShoppingCart({
|
||||
required this.shoppingConfiguration,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// Shopping configuration.
|
||||
final ShoppingConfiguration shoppingConfiguration;
|
||||
|
||||
@override
|
||||
|
@ -150,12 +158,15 @@ class ShoppingCart extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
/// Shopping order details.
|
||||
class ShoppingOrderDetails extends StatelessWidget {
|
||||
/// Constructor for the shopping order details.
|
||||
const ShoppingOrderDetails({
|
||||
required this.shoppingConfiguration,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// Shopping configuration.
|
||||
final ShoppingConfiguration shoppingConfiguration;
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue