mirror of
https://github.com/Iconica-Development/flutter_shopping.git
synced 2025-05-19 08:53:46 +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:flutter_shopping/main.dart";
|
||||||
import "package:go_router/go_router.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(
|
OrderDetailConfiguration getDefaultOrderDetailConfiguration(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
FlutterShoppingConfiguration configuration,
|
FlutterShoppingConfiguration configuration,
|
||||||
|
|
|
@ -1,46 +1,39 @@
|
||||||
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";
|
||||||
|
|
||||||
/// TODO
|
/// Configuration class for the flutter_shopping user-story.
|
||||||
class FlutterShoppingConfiguration {
|
class FlutterShoppingConfiguration {
|
||||||
/// TODO
|
/// Constructor for the FlutterShoppingConfiguration.
|
||||||
const FlutterShoppingConfiguration({
|
const FlutterShoppingConfiguration({
|
||||||
required this.shopBuilder,
|
required this.shopBuilder,
|
||||||
required this.shoppingCartBuilder,
|
required this.shoppingCartBuilder,
|
||||||
required this.onCompleteUserStory,
|
required this.onCompleteUserStory,
|
||||||
this.showOrderDetails = false,
|
|
||||||
this.orderDetailsBuilder,
|
this.orderDetailsBuilder,
|
||||||
this.onCompleteOrderDetails,
|
this.onCompleteOrderDetails,
|
||||||
this.orderSuccessBuilder,
|
this.orderSuccessBuilder,
|
||||||
this.orderFailedBuilder,
|
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;
|
final Widget Function(BuildContext context) shopBuilder;
|
||||||
|
|
||||||
/// TODO
|
/// Builder for the shopping cart page.
|
||||||
final Widget Function(BuildContext context) shoppingCartBuilder;
|
final Widget Function(BuildContext context) shoppingCartBuilder;
|
||||||
|
|
||||||
/// TODO
|
/// Function that is called when the user-story is completed.
|
||||||
final Function(BuildContext context) onCompleteUserStory;
|
final Function(BuildContext context) onCompleteUserStory;
|
||||||
|
|
||||||
/// TODO
|
/// Builder for the order details page. This does not have to be set if you
|
||||||
final bool showOrderDetails;
|
/// are using the default order details page.
|
||||||
|
|
||||||
/// TODO
|
|
||||||
final Widget Function(BuildContext context)? orderDetailsBuilder;
|
final Widget Function(BuildContext context)? orderDetailsBuilder;
|
||||||
|
|
||||||
/// Allows you to execute actions before
|
/// Allows you to execute actions before
|
||||||
final Future<bool> Function(BuildContext context, OrderResult result)?
|
final Future<bool> Function(BuildContext context, OrderResult result)?
|
||||||
onCompleteOrderDetails;
|
onCompleteOrderDetails;
|
||||||
|
|
||||||
/// TODO
|
/// Builder for when the order is successful.
|
||||||
final Widget Function(BuildContext context)? orderSuccessBuilder;
|
final Widget Function(BuildContext context)? orderSuccessBuilder;
|
||||||
|
|
||||||
/// TODO
|
/// Builder for when the order failed.
|
||||||
final Widget Function(BuildContext context)? orderFailedBuilder;
|
final Widget Function(BuildContext context)? orderFailedBuilder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:go_router/go_router.dart";
|
import "package:go_router/go_router.dart";
|
||||||
|
|
||||||
/// TODO
|
/// Builder with a fade transition for when navigating to a new screen.
|
||||||
CustomTransitionPage buildScreenWithFadeTransition<T>({
|
CustomTransitionPage buildScreenWithFadeTransition<T>({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required GoRouterState state,
|
required GoRouterState state,
|
||||||
|
@ -14,7 +14,7 @@ CustomTransitionPage buildScreenWithFadeTransition<T>({
|
||||||
FadeTransition(opacity: animation, child: child),
|
FadeTransition(opacity: animation, child: child),
|
||||||
);
|
);
|
||||||
|
|
||||||
/// TODO
|
/// Builder without a transition for when navigating to a new screen.
|
||||||
CustomTransitionPage buildScreenWithoutTransition<T>({
|
CustomTransitionPage buildScreenWithoutTransition<T>({
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
required GoRouterState state,
|
required GoRouterState state,
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
/// TODO
|
/// All the routes used in the user-story.
|
||||||
mixin FlutterShoppingRoutes {
|
mixin FlutterShoppingRoutes {
|
||||||
/// TODO
|
/// The shop page route.
|
||||||
static const String shop = "/shop";
|
static const String shop = "/shop";
|
||||||
|
|
||||||
/// TODO
|
/// The shopping cart page route.
|
||||||
static const String shoppingCart = "/shopping-cart";
|
static const String shoppingCart = "/shopping-cart";
|
||||||
|
|
||||||
/// TODO
|
/// The order details page route.
|
||||||
static const String orderDetails = "/order-details";
|
static const String orderDetails = "/order-details";
|
||||||
|
|
||||||
/// TODO
|
/// The order success page route.
|
||||||
static const String orderSuccess = "/order-success";
|
static const String orderSuccess = "/order-success";
|
||||||
|
|
||||||
/// TODO
|
/// The order failed page route.
|
||||||
static const String orderFailed = "/order-failed";
|
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:flutter_shopping/src/widgets/default_order_succes_widget.dart";
|
||||||
import "package:go_router/go_router.dart";
|
import "package:go_router/go_router.dart";
|
||||||
|
|
||||||
/// TODO
|
/// All the routes for the shopping story.
|
||||||
List<GoRoute> getShoppingStoryRoutes({
|
List<GoRoute> getShoppingStoryRoutes({
|
||||||
required FlutterShoppingConfiguration configuration,
|
required FlutterShoppingConfiguration configuration,
|
||||||
}) =>
|
}) =>
|
||||||
|
@ -36,8 +36,7 @@ List<GoRoute> getShoppingStoryRoutes({
|
||||||
name: "orderDetails",
|
name: "orderDetails",
|
||||||
path: FlutterShoppingRoutes.orderDetails,
|
path: FlutterShoppingRoutes.orderDetails,
|
||||||
pageBuilder: (BuildContext context, GoRouterState state) {
|
pageBuilder: (BuildContext context, GoRouterState state) {
|
||||||
if (configuration.showOrderDetails &&
|
if (configuration.orderDetailsBuilder != null) {
|
||||||
configuration.orderDetailsBuilder != null) {
|
|
||||||
return buildScreenWithFadeTransition(
|
return buildScreenWithFadeTransition(
|
||||||
context: context,
|
context: context,
|
||||||
state: state,
|
state: state,
|
||||||
|
|
|
@ -3,7 +3,11 @@ import "package:flutter_order_details/flutter_order_details.dart";
|
||||||
import "package:flutter_shopping/main.dart";
|
import "package:flutter_shopping/main.dart";
|
||||||
import "package:go_router/go_router.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(
|
Future<void> onCompleteOrderDetails(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
FlutterShoppingConfiguration configuration,
|
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(
|
void onCompleteShoppingCart(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) {
|
) {
|
||||||
context.go(FlutterShoppingRoutes.orderDetails);
|
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(
|
void onCompleteProductPage(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:flutter_shopping/main.dart";
|
import "package:flutter_shopping/main.dart";
|
||||||
|
|
||||||
/// TODO
|
/// Default order failed widget.
|
||||||
class DefaultOrderFailed extends StatelessWidget {
|
class DefaultOrderFailed extends StatelessWidget {
|
||||||
/// TODO
|
/// Constructor for the DefaultOrderFailed.
|
||||||
const DefaultOrderFailed({
|
const DefaultOrderFailed({
|
||||||
required this.configuration,
|
required this.configuration,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// TODO
|
/// Configuration for the user-story.
|
||||||
final FlutterShoppingConfiguration configuration;
|
final FlutterShoppingConfiguration configuration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:flutter_shopping/main.dart";
|
import "package:flutter_shopping/main.dart";
|
||||||
|
|
||||||
/// TODO
|
/// Default order success widget.
|
||||||
class DefaultOrderSucces extends StatelessWidget {
|
class DefaultOrderSucces extends StatelessWidget {
|
||||||
/// TODO
|
/// Constructor for the DefaultOrderSucces.
|
||||||
const DefaultOrderSucces({
|
const DefaultOrderSucces({
|
||||||
required this.configuration,
|
required this.configuration,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// TODO
|
/// Configuration for the user-story.
|
||||||
final FlutterShoppingConfiguration configuration;
|
final FlutterShoppingConfiguration configuration;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Reference in a new issue