mirror of
https://github.com/Iconica-Development/flutter_shopping.git
synced 2025-05-19 00:43:45 +02:00
feat: dart documentation
This commit is contained in:
parent
900aadf8f0
commit
2885ac9afa
8 changed files with 41 additions and 38 deletions
|
@ -3,7 +3,8 @@ import "package:flutter_order_details/flutter_order_details.dart";
|
|||
import "package:flutter_shopping/main.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
|
||||
/// TODO
|
||||
/// Default order detail configuration for the app.
|
||||
/// This configuration is used to create the order detail page.
|
||||
OrderDetailConfiguration getDefaultOrderDetailConfiguration(
|
||||
BuildContext context,
|
||||
FlutterShoppingConfiguration configuration,
|
||||
|
|
|
@ -1,46 +1,39 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_order_details/flutter_order_details.dart";
|
||||
|
||||
/// TODO
|
||||
/// Configuration class for the flutter_shopping user-story.
|
||||
class FlutterShoppingConfiguration {
|
||||
/// TODO
|
||||
/// Constructor for the FlutterShoppingConfiguration.
|
||||
const FlutterShoppingConfiguration({
|
||||
required this.shopBuilder,
|
||||
required this.shoppingCartBuilder,
|
||||
required this.onCompleteUserStory,
|
||||
this.showOrderDetails = false,
|
||||
this.orderDetailsBuilder,
|
||||
this.onCompleteOrderDetails,
|
||||
this.orderSuccessBuilder,
|
||||
this.orderFailedBuilder,
|
||||
}) : assert(
|
||||
showOrderDetails && orderDetailsBuilder != null ||
|
||||
!showOrderDetails && orderDetailsBuilder == null,
|
||||
"showOrderDetails and orderDetailsBuilder must be both set or unset.",
|
||||
);
|
||||
});
|
||||
|
||||
/// TODO
|
||||
/// Builder for the shop/product page.
|
||||
final Widget Function(BuildContext context) shopBuilder;
|
||||
|
||||
/// TODO
|
||||
/// Builder for the shopping cart page.
|
||||
final Widget Function(BuildContext context) shoppingCartBuilder;
|
||||
|
||||
/// TODO
|
||||
/// Function that is called when the user-story is completed.
|
||||
final Function(BuildContext context) onCompleteUserStory;
|
||||
|
||||
/// TODO
|
||||
final bool showOrderDetails;
|
||||
|
||||
/// TODO
|
||||
/// Builder for the order details page. This does not have to be set if you
|
||||
/// are using the default order details page.
|
||||
final Widget Function(BuildContext context)? orderDetailsBuilder;
|
||||
|
||||
/// Allows you to execute actions before
|
||||
final Future<bool> Function(BuildContext context, OrderResult result)?
|
||||
onCompleteOrderDetails;
|
||||
|
||||
/// TODO
|
||||
/// Builder for when the order is successful.
|
||||
final Widget Function(BuildContext context)? orderSuccessBuilder;
|
||||
|
||||
/// TODO
|
||||
/// Builder for when the order failed.
|
||||
final Widget Function(BuildContext context)? orderFailedBuilder;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
|
||||
/// TODO
|
||||
/// Builder with a fade transition for when navigating to a new screen.
|
||||
CustomTransitionPage buildScreenWithFadeTransition<T>({
|
||||
required BuildContext context,
|
||||
required GoRouterState state,
|
||||
|
@ -14,7 +14,7 @@ CustomTransitionPage buildScreenWithFadeTransition<T>({
|
|||
FadeTransition(opacity: animation, child: child),
|
||||
);
|
||||
|
||||
/// TODO
|
||||
/// Builder without a transition for when navigating to a new screen.
|
||||
CustomTransitionPage buildScreenWithoutTransition<T>({
|
||||
required BuildContext context,
|
||||
required GoRouterState state,
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
/// TODO
|
||||
/// All the routes used in the user-story.
|
||||
mixin FlutterShoppingRoutes {
|
||||
/// TODO
|
||||
/// The shop page route.
|
||||
static const String shop = "/shop";
|
||||
|
||||
/// TODO
|
||||
/// The shopping cart page route.
|
||||
static const String shoppingCart = "/shopping-cart";
|
||||
|
||||
/// TODO
|
||||
/// The order details page route.
|
||||
static const String orderDetails = "/order-details";
|
||||
|
||||
/// TODO
|
||||
/// The order success page route.
|
||||
static const String orderSuccess = "/order-success";
|
||||
|
||||
/// TODO
|
||||
/// The order failed page route.
|
||||
static const String orderFailed = "/order-failed";
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import "package:flutter_shopping/src/widgets/default_order_failed_widget.dart";
|
|||
import "package:flutter_shopping/src/widgets/default_order_succes_widget.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
|
||||
/// TODO
|
||||
/// All the routes for the shopping story.
|
||||
List<GoRoute> getShoppingStoryRoutes({
|
||||
required FlutterShoppingConfiguration configuration,
|
||||
}) =>
|
||||
|
@ -36,8 +36,7 @@ List<GoRoute> getShoppingStoryRoutes({
|
|||
name: "orderDetails",
|
||||
path: FlutterShoppingRoutes.orderDetails,
|
||||
pageBuilder: (BuildContext context, GoRouterState state) {
|
||||
if (configuration.showOrderDetails &&
|
||||
configuration.orderDetailsBuilder != null) {
|
||||
if (configuration.orderDetailsBuilder != null) {
|
||||
return buildScreenWithFadeTransition(
|
||||
context: context,
|
||||
state: state,
|
||||
|
|
|
@ -3,7 +3,11 @@ import "package:flutter_order_details/flutter_order_details.dart";
|
|||
import "package:flutter_shopping/main.dart";
|
||||
import "package:go_router/go_router.dart";
|
||||
|
||||
/// TODO
|
||||
/// Default on complete order details function.
|
||||
/// This function will navigate to the order success or order failed page.
|
||||
///
|
||||
/// You can create your own implementation if you decide to use a different
|
||||
/// approach.
|
||||
Future<void> onCompleteOrderDetails(
|
||||
BuildContext context,
|
||||
FlutterShoppingConfiguration configuration,
|
||||
|
@ -28,14 +32,20 @@ Future<void> onCompleteOrderDetails(
|
|||
}
|
||||
}
|
||||
|
||||
/// TODO
|
||||
/// Default on complete shopping cart function.
|
||||
///
|
||||
/// You can create your own implementation if you decide to use a different
|
||||
/// approach.
|
||||
void onCompleteShoppingCart(
|
||||
BuildContext context,
|
||||
) {
|
||||
context.go(FlutterShoppingRoutes.orderDetails);
|
||||
}
|
||||
|
||||
/// TODO
|
||||
/// Default on complete product page function.
|
||||
///
|
||||
/// You can create your own implementation if you decide to use a different
|
||||
/// approach.
|
||||
void onCompleteProductPage(
|
||||
BuildContext context,
|
||||
) {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_shopping/main.dart";
|
||||
|
||||
/// TODO
|
||||
/// Default order failed widget.
|
||||
class DefaultOrderFailed extends StatelessWidget {
|
||||
/// TODO
|
||||
/// Constructor for the DefaultOrderFailed.
|
||||
const DefaultOrderFailed({
|
||||
required this.configuration,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// TODO
|
||||
/// Configuration for the user-story.
|
||||
final FlutterShoppingConfiguration configuration;
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import "package:flutter/material.dart";
|
||||
import "package:flutter_shopping/main.dart";
|
||||
|
||||
/// TODO
|
||||
/// Default order success widget.
|
||||
class DefaultOrderSucces extends StatelessWidget {
|
||||
/// TODO
|
||||
/// Constructor for the DefaultOrderSucces.
|
||||
const DefaultOrderSucces({
|
||||
required this.configuration,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// TODO
|
||||
/// Configuration for the user-story.
|
||||
final FlutterShoppingConfiguration configuration;
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue