import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../config/custom_text.dart'; import '../utils/colors.dart'; class TimeSheet extends StatelessWidget { final TimeOfDay initialTime; final Future Function(TimeOfDay current) onPickTime; final void Function(TimeOfDay picked) onConfirm; final String Function(TimeOfDay t) formatter; final double systembottompadding; TimeSheet({ required this.initialTime, required this.onPickTime, required this.onConfirm, required this.formatter, required this.systembottompadding, }); @override Widget build(BuildContext context) { TimeOfDay current = initialTime; return StatefulBuilder( builder: (context, setSt) { return Container( margin: EdgeInsets.fromLTRB(16, 16, 16, 16 + systembottompadding), padding: const EdgeInsets.fromLTRB(16, 18, 16, 30 ), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(24), boxShadow: const [ BoxShadow(color: Color(0x1A000000), blurRadius: 16, offset: Offset(0, 6)), ], ), child: Column( mainAxisSize: MainAxisSize.min, children: [ const Align( alignment: Alignment.centerLeft, child: Txt( text: 'What time will you like to depart?', style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600), ), ), const SizedBox(height: 16), // time pill InkWell( onTap: () async { final picked = await onPickTime(current); setSt(() => current = picked); }, child: Container( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(30), border: Border.all(color: Colors.grey.shade400), ), child: Row( children: [ Expanded( child: Text( formatter(current), style: const TextStyle( fontSize: 28, fontWeight: FontWeight.w700, letterSpacing: 1, ), ), ), Icon(Icons.keyboard_arrow_down_rounded, size: 24, color:Colors.grey.shade400), ], ), ), ), const SizedBox(height: 16), // button SizedBox( width: double.infinity, child: ElevatedButton( onPressed: () => onConfirm(current), style: ElevatedButton.styleFrom( backgroundColor: AppNewColors.primaryBtnColor, minimumSize: const Size(double.infinity, 48), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), elevation: 0, ), child: const Txt( text: 'Set pickup time', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Colors.white), ), ), ), ], ), ); }, ); } }