select_birthday_dialog.dart 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_screenutil/flutter_screenutil.dart';
  4. import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
  5. import 'package:keyboard/resource/string.gen.dart';
  6. import 'package:keyboard/utils/styles.dart';
  7. import '../widget/birthday_date_picker.dart';
  8. class SelectBirthdayDialog {
  9. static const tag = "SelectBirthdayDialog";
  10. static show({
  11. required DateTime initialDate,
  12. required DateTime minimumDate,
  13. required Function(DateTime) onDateChanged,
  14. }) {
  15. DateTime currentDate = initialDate;
  16. SmartDialog.show(
  17. backType: SmartBackType.block,
  18. clickMaskDismiss: true,
  19. alignment: Alignment.bottomCenter,
  20. animationType: SmartAnimationType.centerScale_otherSlide,
  21. tag: tag,
  22. keepSingle: true,
  23. builder:
  24. (_) =>
  25. Container(
  26. decoration: ShapeDecoration(
  27. color: Colors.white,
  28. shape: RoundedRectangleBorder(
  29. borderRadius: BorderRadius.only(
  30. topLeft: Radius.circular(18.r),
  31. topRight: Radius.circular(18.r),
  32. ),
  33. ),
  34. ),
  35. child: Column(
  36. mainAxisSize: MainAxisSize.min,
  37. children: [
  38. Container(
  39. padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 16.w),
  40. child: Row(
  41. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  42. children: [
  43. GestureDetector(
  44. onTap: () {
  45. SmartDialog.dismiss(tag: tag);
  46. },
  47. child: Container(
  48. width: 87.w,
  49. height: 38.h,
  50. decoration: ShapeDecoration(
  51. color: const Color(0xFFF5F4F9),
  52. shape: RoundedRectangleBorder(
  53. borderRadius: BorderRadius.circular(28.r),
  54. ),
  55. ),
  56. child: Center(
  57. child: Text(
  58. StringName.selectBirthdayDialogCancel,
  59. style: Styles.getTextStyleBlack204W500(14.sp),
  60. ),
  61. ),
  62. ),
  63. ),
  64. Text(
  65. StringName.selectBirthdayDialogTitle,
  66. style: Styles.getTextStyleBlack204W500(16.sp),
  67. ),
  68. GestureDetector(
  69. onTap: () {
  70. onDateChanged(currentDate);
  71. SmartDialog.dismiss(tag: tag);
  72. },
  73. child: Container(
  74. width: 87.w,
  75. height: 38.h,
  76. decoration: Styles.getActivateButtonDecoration(28.r),
  77. child: Center(
  78. child: Text(
  79. StringName.selectBirthdayDialogConfirm,
  80. style: Styles.getTextStyleWhiteW500(14.sp),
  81. ),
  82. ),
  83. ),
  84. ),
  85. ],
  86. ),
  87. ),
  88. SizedBox(height: 30.h),
  89. SizedBox(
  90. height: 150.h,
  91. width: 320.w,
  92. child: BirthdayDatePicker(
  93. initialDate: initialDate,
  94. minimumDate: minimumDate,
  95. backgroundColor: Color(0xffF6F5FA),
  96. maximumDate: DateTime.now(),
  97. onDateChanged: (dateTime) {
  98. currentDate = dateTime;
  99. },
  100. ),
  101. ),
  102. SizedBox(height: 30.h),
  103. ],
  104. ),
  105. ),
  106. );
  107. }
  108. }