69 lines
2.1 KiB
Dart
69 lines
2.1 KiB
Dart
import 'package:auto_route/auto_route.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
import '../../../application/checkout/checkout_form/checkout_form_bloc.dart';
|
|
import '../../../application/payment_method/payment_method_loader/payment_method_loader_bloc.dart';
|
|
import '../../../common/theme/theme.dart';
|
|
import '../../../injection.dart';
|
|
import '../../components/spaces/space.dart';
|
|
import 'widgets/checkout_left_panel.dart';
|
|
import 'widgets/checkout_right_panel.dart';
|
|
|
|
@RoutePage()
|
|
class CheckoutPage extends StatelessWidget implements AutoRouteWrapper {
|
|
const CheckoutPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
child: Hero(
|
|
tag: 'checkout_screen',
|
|
child: BlocBuilder<CheckoutFormBloc, CheckoutFormState>(
|
|
builder: (context, state) {
|
|
final price = state.items.fold(
|
|
0,
|
|
(previousValue, element) =>
|
|
previousValue +
|
|
(element.product.price.toInt() +
|
|
(element.variant?.priceModifier.toInt() ?? 0)) *
|
|
element.quantity,
|
|
);
|
|
|
|
return Scaffold(
|
|
backgroundColor: AppColor.white,
|
|
body: Row(
|
|
children: [
|
|
Expanded(
|
|
flex: 3,
|
|
child: CheckoutLeftPanel(
|
|
checkoutState: state,
|
|
price: price,
|
|
),
|
|
),
|
|
SpaceWidth(2),
|
|
Expanded(
|
|
flex: 3,
|
|
child: CheckoutRightPanel(
|
|
checkoutState: state,
|
|
price: price,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget wrappedRoute(BuildContext context) => BlocProvider(
|
|
create: (context) =>
|
|
getIt<PaymentMethodLoaderBloc>()
|
|
..add(PaymentMethodLoaderEvent.fetched(isRefresh: true)),
|
|
child: this,
|
|
);
|
|
}
|