// ignore_for_file: unused_local_variable import 'package:flutter/material.dart'; import 'package:lba/extension/screenSize.dart'; import 'package:lba/res/colors.dart'; import 'package:lba/widgets/button.dart'; import 'package:lba/widgets/optionSelector.dart'; class CustomBottomSheet extends StatefulWidget { final List options; const CustomBottomSheet({ super.key, required this.options, }); static void show(BuildContext context, List options) { showModalBottomSheet( context: context, isScrollControlled: true, useRootNavigator: true, backgroundColor: Colors.transparent, builder: (context) => CustomBottomSheet(options: options), ); } @override State createState() => _CustomBottomSheetState(); } class _CustomBottomSheetState extends State { List selectedOptions = []; void _onOptionToggled(String option) { setState(() { if (selectedOptions.contains(option)) { selectedOptions.remove(option); } else { selectedOptions.add(option); } }); } @override Widget build(BuildContext context) { return DraggableScrollableSheet( expand: false, initialChildSize: 0.6, minChildSize: 0.4, maxChildSize: 0.9, builder: (context, scrollController) { return Container( width: MediaQuery.of(context).size.width, decoration: BoxDecoration( color: AppColors.surface, borderRadius: BorderRadius.vertical(top: Radius.circular(16)), ), child: Column( children: [ Container( width: 50, height: 4, margin: const EdgeInsets.only(top: 8, bottom: 12), decoration: BoxDecoration( color: AppColors.greyBorder, borderRadius: BorderRadius.circular(2), ), ), Expanded( child: nearbySort(scrollController), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox(width: 30,), InkWell( child: Text("Clear all",style: TextStyle(fontWeight: FontWeight.bold),), onTap: () { setState(() { selectedOptions.clear(); }); }, ), const SizedBox(width: 50), Expanded( child: Button( text: "Apply", onPressed: () { Navigator.pop(context); }, color: AppColors.confirmButton), ), ], ), SizedBox(height: 15,) ], ), ), ], ), ); }, ); } Widget nearbySort(ScrollController scrollController) { final width = context.screenWidth; final height = context.screenHeight; return SingleChildScrollView( controller: scrollController, child: Container( margin: EdgeInsets.only(left: width/50,right: width/10), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ const SizedBox(height: 15), Text( "Categories", style: TextStyle( color: AppColors.hint, fontSize: 17, fontWeight: FontWeight.bold, ), ), const SizedBox(height: 12), OptionSelector( options: widget.options, selectedOptions: selectedOptions, onOptionToggled: _onOptionToggled, ), const SizedBox(height: 15), Padding( padding: const EdgeInsets.only(top: 16), child: Text( "OrderType", style: TextStyle( color: AppColors.hint, fontSize: 17, fontWeight: FontWeight.bold, ), ), ), const SizedBox(height: 12), OptionSelector( options: ["Delivery", "Pickup"], selectedOptions: selectedOptions, onOptionToggled: _onOptionToggled, ), ], ), ), ); } }