import 'package:wanisclient/config/custom_text.dart'; import 'package:wanisclient/utils/colors.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:beemwidget/text_styles/beem_text_styles.dart'; import 'package:provider/provider.dart'; import '../config/language/language_enum.dart'; import '../providers/language_provider.dart'; import 'custom_button.dart'; class OrderSummary extends StatelessWidget { final String startlocation; // start location final String endLocation; // destination final String price; // ticket price as string (e.g. "24") final double time; // minutes, e.g. 3.0 final double systembottompadding; // minutes, e.g. 3.0 // optional extras (kept lowercase, no special chars) final double feeRate; // 0.30 -> 30% final double distance; // 0.30 -> 30% final double couponpercentage; // 0.04 -> 4% final double couponvalue; // 0.04 -> 4% final String couponcode; // 0.04 -> 4% final String currency; // "TND" final String paymentMethod; // "TND" final VoidCallback onConfirm; final VoidCallback onSearch; // kept to respect your ctor, not used in this UI const OrderSummary({ super.key, required this.startlocation, required this.endLocation, required this.price, required this.time, required this.systembottompadding, required this.onConfirm, required this.onSearch, this.feeRate = 0.30, this.distance = 0.30, this.couponpercentage = 0.0, this.couponvalue = 0.0, this.couponcode = "not_exist", this.currency = "TND", this.paymentMethod = "CASH", }); @override Widget build(BuildContext context) { final double ticket = double.tryParse(price) ?? 0.0; final languageProvider = context.watch(); bool isArabic = languageProvider.currentLangCode == Language.ar; // Get the safe area padding final EdgeInsets safeAreaPadding = MediaQuery.of(context).padding; final double bottomPadding = safeAreaPadding.bottom; // Button height including padding const double buttonHeight = 50; const double buttonContainerPadding = 24; // 12 top + 12 bottom final double totalBottomSpace = buttonHeight + buttonContainerPadding + bottomPadding; return Scaffold( backgroundColor: Colors.white, // This ensures the content doesn't go under system UI body: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // Scrollable content Expanded( child: SingleChildScrollView( padding: EdgeInsets.only( top: 30, left: 0, right: 0, // Add enough bottom padding for the button + navigation bar bottom: totalBottomSpace-systembottompadding, // extra 10 for breathing room ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ // from -> to card + estimated time Padding( padding: EdgeInsets.only(left: 15.sp, right: 15.sp, bottom: 10.sp), child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.r), border: Border.all(color: AppNewColors.primaryColor, width: 2), ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 10.h), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Text( startlocation, maxLines: 1, overflow: TextOverflow.ellipsis, style: BeemTextStyles.poppinsRegular14, ), ), Padding( padding: EdgeInsets.symmetric(horizontal: 8.w), child: Icon(Icons.arrow_right_alt_rounded, size: 20.sp, color: Colors.black), ), Expanded( child: Text( endLocation, maxLines: 1, overflow: TextOverflow.ellipsis, textAlign: TextAlign.right, style: BeemTextStyles.poppinsRegular14, ), ), ], ), const Padding( padding: EdgeInsets.symmetric(horizontal: 1.0, vertical: 10), child: Divider(thickness: 0.5, color: Colors.grey), ), Row( children: [ const Icon(Icons.access_time, size: 16, color: Colors.black), SizedBox(width: 6.w), Txt( text: "Estimated time", style: BeemTextStyles.poppinsRegular12 .copyWith(color: Colors.black), ), const Spacer(), Text( "${time.toStringAsFixed(2)} min", style: BeemTextStyles.poppinsMedium14, ), ], ), ], ), ), ), ), // pricing card Padding( padding: EdgeInsets.only(left: 15.sp, right: 15.sp), child: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(15.r), border: Border.all(color: const Color(0xffEDEDED), width: 2), boxShadow: const [ BoxShadow( color: Color(0x0F000000), blurRadius: 10, offset: Offset(0, 2), ), ], ), child: Padding( padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 14.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ _priceRow( label: "${ticket.toStringAsFixed(2)}$currency ${languageSingleton.translate('(Booking fee) + meter rate')}", value: "", description: "The reservation fees is not the trip total", clictext: "", IsArabic: isArabic, onclick: () { return; }), SizedBox(height: 16.h), _priceRow( label: "Coupon", value: "${couponvalue.toStringAsFixed(2)} $currency", description: languageProvider.translate("Including taxes and fees"), clictext: languageProvider.translate("View details"), onclick: () { return; }, IsArabic: isArabic), ], ), ), ), ), ], ), ), ), // Fixed bottom button _buildConfirmButton(context), ], ), ); } Widget _buildConfirmButton(BuildContext context) { // Get the safe area padding return Container( padding: const EdgeInsets.fromLTRB(20, 15, 20,25), decoration: BoxDecoration( color: Colors.white, boxShadow: const [ BoxShadow( color: Color(0x0F000000), blurRadius: 10, offset: Offset(0, 2), ), ], border: Border( top: BorderSide(color: Colors.grey.shade200, width: 1.0) ), ), child: CustomButton( onClick: onConfirm, width: double.infinity, fontSize: 18, height: 50, borderRadius: 12, txtColor: Colors.white, title: "Confirm order", backgroundColor: AppNewColors.primaryBtnColor, borderColor: AppNewColors.primaryBtnColor, loadercolor: Colors.white, ), ); } Widget _priceRow({ required String label, required String value, required bool IsArabic, required String description, required String clictext, required VoidCallback onclick, }) { return Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Txt( text: label, textAlign: TextAlign.start, style: BeemTextStyles.poppinsMedium14, overflow: TextOverflow.ellipsis, ), if (description.isNotEmpty) ...[ const SizedBox(height: 6), RichText( text: TextSpan( style: BeemTextStyles.poppinsRegular12.copyWith( color: const Color(0xFF9B9B9B), height: 1.25), children: [ TextSpan( text: languageSingleton.translate(description), style: BeemTextStyles.poppinsRegular12.copyWith( color: const Color(0xFF9B9B9B), fontSize: 12, fontFamily: IsArabic ? "Readex_Pro" : 'Inter', fontWeight: FontWeight.w400, height: 1.25, ), ), if (clictext.isNotEmpty) TextSpan( text: " $clictext", style: BeemTextStyles.poppinsRegular12.copyWith( color: AppNewColors.primaryBtnColor, fontSize: 10, fontFamily: IsArabic ? "Readex_Pro" : 'Inter', fontWeight: FontWeight.w600, height: 1.25, ), recognizer: TapGestureRecognizer()..onTap = onclick, ), ], ), ), ], ], ), ), const SizedBox(width: 10), Txt( text: value, textAlign: TextAlign.right, style: BeemTextStyles.poppinsMedium16.copyWith( fontSize: 13, fontFamily: IsArabic ? "Readex_Pro" : 'Inter', fontWeight: FontWeight.w600, height: 1.85, ), ), ], ); } }