onTapPassportExpiry method
Implementation
Future<void> onTapPassportExpiry(GlobalKey passportKey, BuildContext context) async {
final RenderBox renderBox = passportKey.currentContext!.findRenderObject() as RenderBox;
final position = renderBox.localToGlobal(Offset.zero);
final size = renderBox.size;
showMenu(
context: context,
elevation: 8,
surfaceTintColor: Colors.transparent,
shadowColor: ColorHelper.black,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
color: Colors.white,
constraints: BoxConstraints(maxWidth: 420.dp),
position: RelativeRect.fromLTRB(
position.dx,
position.dy + size.height,
position.dx + size.width,
position.dy + size.height * 2,
),
items: [
PopupMenuItem(
enabled: false,
child: Container(
width: 500.dp,
alignment: Alignment.center,
child: CalendarDatePicker2(
onValueChanged: (value) {
String formattedDate = DateFormat('yyyy-MM-dd').format(value.firstOrNull ?? DateTime(1990));
passportExpiryController.text = formattedDate;
specificPassenger.refresh();
closeDialog();
},
displayedMonthDate: DateTime.now(),
value: const [],
config: CalendarDatePicker2Config(
weekdayLabels: ['SUN','MON', 'TUE', 'WED', 'THU', 'FRI','SAT'],
weekdayLabelTextStyle: const TextStyle(
fontWeight: FontWeight.w600,
color: ColorHelper.neutralLightText
),
disabledDayTextStyle: const TextStyle(
fontWeight: FontWeight.w400,
color: ColorHelper.neutralLight1
),
dayTextStyle: const TextStyle(
fontWeight: FontWeight.w400,
color: ColorHelper.neutralDark
),
todayTextStyle: const TextStyle(
fontWeight: FontWeight.w500,
color: ColorHelper.primaryColor1
),
daySplashColor: ColorHelper.primaryColor1,
selectedDayHighlightColor: ColorHelper.primaryColor1,
selectedRangeHighlightColor: ColorHelper.primaryColor1,
firstDate: DateTime(1930),
lastDate: DateTime(2040),
calendarType: CalendarDatePicker2Type.single,
),
),
),
),
],
);
}