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,
|
checkingPages: checkingPages,
|
||||||
),
|
),
|
||||||
pages: widget.configuration.pages?.call(context) ??
|
pages: widget.configuration.pages?.call(context) ??
|
||||||
defaultPages(context),
|
defaultPages(context, () {
|
||||||
|
setState(() {});
|
||||||
|
}),
|
||||||
onFinished: (data) async {
|
onFinished: (data) async {
|
||||||
widget.configuration.onStepsCompleted.call(
|
widget.configuration.onStepsCompleted.call(
|
||||||
widget.configuration.shoppingService.shopService.selectedShop!.id,
|
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/material.dart";
|
||||||
import "package:flutter_order_details/flutter_order_details.dart";
|
import "package:flutter_order_details/flutter_order_details.dart";
|
||||||
|
|
||||||
|
|
||||||
/// Default pages for the order details screen.
|
/// 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 theme = Theme.of(context);
|
||||||
|
|
||||||
var morningTimes = <String>[
|
var morningTimes = <String>[
|
||||||
|
@ -307,11 +309,10 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
||||||
toggleColor: theme.colorScheme.primary,
|
toggleColor: theme.colorScheme.primary,
|
||||||
onSwitch: (value) {
|
onSwitch: (value) {
|
||||||
switchStatus.value = value;
|
switchStatus.value = value;
|
||||||
|
onSwitched();
|
||||||
},
|
},
|
||||||
childLeft: Center(
|
childLeft: Center(
|
||||||
child: ListenableBuilder(
|
child: Text(
|
||||||
listenable: switchStatus,
|
|
||||||
builder: (context, widget) => Text(
|
|
||||||
"Morning",
|
"Morning",
|
||||||
style: theme.textTheme.titleSmall?.copyWith(
|
style: theme.textTheme.titleSmall?.copyWith(
|
||||||
color: switchStatus.value
|
color: switchStatus.value
|
||||||
|
@ -320,11 +321,8 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
childRight: Center(
|
childRight: Center(
|
||||||
child: ListenableBuilder(
|
child: Text(
|
||||||
listenable: switchStatus,
|
|
||||||
builder: (context, widget) => Text(
|
|
||||||
"Afternoon",
|
"Afternoon",
|
||||||
style: theme.textTheme.titleSmall?.copyWith(
|
style: theme.textTheme.titleSmall?.copyWith(
|
||||||
color: switchStatus.value
|
color: switchStatus.value
|
||||||
|
@ -335,13 +333,10 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8,
|
height: 8,
|
||||||
),
|
),
|
||||||
ListenableBuilder(
|
FlutterFormInputMultipleChoice(
|
||||||
listenable: switchStatus,
|
|
||||||
builder: (context, widget) => FlutterFormInputMultipleChoice(
|
|
||||||
validationMessage: "Select a Time",
|
validationMessage: "Select a Time",
|
||||||
controller: multipleChoiceController,
|
controller: multipleChoiceController,
|
||||||
options: switchStatus.value ? afternoonTimes : morningTimes,
|
options: switchStatus.value ? afternoonTimes : morningTimes,
|
||||||
|
@ -349,8 +344,7 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
||||||
crossAxisSpacing: 5,
|
crossAxisSpacing: 5,
|
||||||
childAspectRatio: 2,
|
childAspectRatio: 2,
|
||||||
height: MediaQuery.of(context).size.height * 0.6,
|
height: MediaQuery.of(context).size.height * 0.6,
|
||||||
builder:
|
builder: (context, index, selected, controller, options, state) =>
|
||||||
(context, index, selected, controller, options, state) =>
|
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
state.didChange(options[index]);
|
state.didChange(options[index]);
|
||||||
|
@ -371,7 +365,6 @@ List<FlutterFormPage> defaultPages(BuildContext context) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -54,7 +54,9 @@ class ProductPageScreen extends StatelessWidget {
|
||||||
context,
|
context,
|
||||||
data.error,
|
data.error,
|
||||||
) ??
|
) ??
|
||||||
DefaultError(error: data.error);
|
DefaultError(
|
||||||
|
error: data.error,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Shop>? shops = data.data;
|
List<Shop>? shops = data.data;
|
||||||
|
@ -102,32 +104,9 @@ class ProductPageScreen extends StatelessWidget {
|
||||||
configuration.onShopSelectionChange?.call(
|
configuration.onShopSelectionChange?.call(
|
||||||
configuration.shoppingService.shopService.selectedShop!,
|
configuration.shoppingService.shopService.selectedShop!,
|
||||||
);
|
);
|
||||||
return _ProductPage(
|
return Stack(
|
||||||
configuration: configuration,
|
children: [
|
||||||
shops: shops,
|
SingleChildScrollView(
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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(
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -135,12 +114,14 @@ class _ProductPage extends StatelessWidget {
|
||||||
context,
|
context,
|
||||||
configuration,
|
configuration,
|
||||||
shops,
|
shops,
|
||||||
configuration.shoppingService.shopService.selectShop,
|
configuration
|
||||||
|
.shoppingService.shopService.selectShop,
|
||||||
) ??
|
) ??
|
||||||
ShopSelector(
|
ShopSelector(
|
||||||
configuration: configuration,
|
configuration: configuration,
|
||||||
shops: shops,
|
shops: shops,
|
||||||
onTap: configuration.shoppingService.shopService.selectShop,
|
onTap: configuration
|
||||||
|
.shoppingService.shopService.selectShop,
|
||||||
),
|
),
|
||||||
configuration.selectedCategoryBuilder?.call(
|
configuration.selectedCategoryBuilder?.call(
|
||||||
configuration,
|
configuration,
|
||||||
|
@ -153,11 +134,7 @@ class _ProductPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
|
|
||||||
return Stack(
|
|
||||||
children: [
|
|
||||||
pageContent,
|
|
||||||
Align(
|
Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: configuration.shoppingCartButtonBuilder != null
|
child: configuration.shoppingCartButtonBuilder != null
|
||||||
|
@ -171,7 +148,13 @@ class _ProductPage extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ShopContents 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/material.dart";
|
||||||
import "package:flutter_shopping/flutter_shopping.dart";
|
import "package:flutter_shopping/flutter_shopping.dart";
|
||||||
import "package:flutter_shopping_local/flutter_shopping_local.dart";
|
import "package:flutter_shopping_local/flutter_shopping_local.dart";
|
||||||
|
|
||||||
|
/// User story for the shopping navigator.
|
||||||
class ShoppingNavigatorUserStory extends StatelessWidget {
|
class ShoppingNavigatorUserStory extends StatelessWidget {
|
||||||
|
/// Constructor for the shopping navigator user story.
|
||||||
const ShoppingNavigatorUserStory({
|
const ShoppingNavigatorUserStory({
|
||||||
this.shoppingConfiguration,
|
this.shoppingConfiguration,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Shopping configuration.
|
||||||
final ShoppingConfiguration? shoppingConfiguration;
|
final ShoppingConfiguration? shoppingConfiguration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -21,11 +22,15 @@ class ShoppingNavigatorUserStory extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shopping product page.
|
||||||
class ShoppingProductPage extends StatelessWidget {
|
class ShoppingProductPage extends StatelessWidget {
|
||||||
|
/// Constructor for the shopping product page.
|
||||||
const ShoppingProductPage({
|
const ShoppingProductPage({
|
||||||
required this.shoppingConfiguration,
|
required this.shoppingConfiguration,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Shopping configuration.
|
||||||
final ShoppingConfiguration shoppingConfiguration;
|
final ShoppingConfiguration shoppingConfiguration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -103,12 +108,15 @@ class ShoppingProductPage extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shopping cart.
|
||||||
class ShoppingCart extends StatelessWidget {
|
class ShoppingCart extends StatelessWidget {
|
||||||
|
/// Constructor for the shopping cart.
|
||||||
const ShoppingCart({
|
const ShoppingCart({
|
||||||
required this.shoppingConfiguration,
|
required this.shoppingConfiguration,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Shopping configuration.
|
||||||
final ShoppingConfiguration shoppingConfiguration;
|
final ShoppingConfiguration shoppingConfiguration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -150,12 +158,15 @@ class ShoppingCart extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Shopping order details.
|
||||||
class ShoppingOrderDetails extends StatelessWidget {
|
class ShoppingOrderDetails extends StatelessWidget {
|
||||||
|
/// Constructor for the shopping order details.
|
||||||
const ShoppingOrderDetails({
|
const ShoppingOrderDetails({
|
||||||
required this.shoppingConfiguration,
|
required this.shoppingConfiguration,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// Shopping configuration.
|
||||||
final ShoppingConfiguration shoppingConfiguration;
|
final ShoppingConfiguration shoppingConfiguration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Reference in a new issue