chooseVisitTimeTitle.dart 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import 'package:cpt_services/components/chooseVisitTimeBottomFooter.dart';
  2. import 'package:cpt_services/components/chooseVisitTimeTitle_vm.dart';
  3. import 'package:cpt_services/modules/services/service_clean_detail/service_clean_detail_vm.dart';
  4. import 'package:cs_resources/theme/app_colors_theme.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:auto_route/auto_route.dart';
  7. import 'package:flutter_hooks/flutter_hooks.dart';
  8. import 'package:hooks_riverpod/hooks_riverpod.dart';
  9. import 'package:shared/utils/color_utils.dart';
  10. import 'package:shared/utils/log_utils.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import 'package:widgets/my_text_view.dart';
  13. import 'package:widgets/widget_export.dart';
  14. import 'chooseVisitTimeTitle_state.dart';
  15. import 'chooseVisitTimeTitle_vm.dart';
  16. class ChooseVisitTimeTitle extends HookConsumerWidget {
  17. final int id;
  18. final int serviceTypeCode;
  19. const ChooseVisitTimeTitle(
  20. {Key? key,required this.id, required this.serviceTypeCode,}) : super(key: key);
  21. @override
  22. Widget build(BuildContext context, WidgetRef ref) {
  23. final vm = ref.read(chooseVisitTimeTitleVmProvider.notifier);
  24. final state = ref.watch(chooseVisitTimeTitleVmProvider);
  25. List<DayInfoItem> dayInfoList = ref.watch(chooseVisitTimeTitleVmProvider.select((state) => state.dayInfoList))?? [];
  26. useEffect((){
  27. // 组件挂载时执行 - 执行接口请求
  28. // Future.microtask(() => vm.initPageData());
  29. return () {
  30. // 组件卸载时执行
  31. };
  32. },[]);
  33. return Container(
  34. child: Column(
  35. mainAxisAlignment: MainAxisAlignment.start,
  36. children: [
  37. Padding(
  38. padding: const EdgeInsets.only(left: 20, right: 20, top: 19, bottom: 16.5),
  39. child: Column(
  40. children: [
  41. MyTextView(
  42. "Please choose a visit time",
  43. textColor: context.appColors.textBlack,
  44. textAlign: TextAlign.left,
  45. isFontBold: true,
  46. fontSize: 17,
  47. boxWidth: double.infinity,
  48. // maxLines: 5,
  49. ),
  50. MyTextView(
  51. '30 minutes before the start of the service, free time modification is available',
  52. textColor: context.appColors.textDarkGray999,
  53. textAlign: TextAlign.left,
  54. isFontRegular: true,
  55. fontSize: 14,
  56. // maxLines: 5,
  57. boxWidth: double.infinity,
  58. ),
  59. ],
  60. ),
  61. ),
  62. Container(
  63. width: double.infinity,
  64. height: 65,
  65. // color: Colors.red,
  66. margin: const EdgeInsets.only(left: 20, right: 20, top: 0, bottom: 0),
  67. child: ListView.builder(
  68. itemCount: dayInfoList.length,
  69. shrinkWrap: true,
  70. scrollDirection: Axis.horizontal,
  71. itemBuilder: (context, index){
  72. DayInfoItem item = dayInfoList[index];
  73. return Container(
  74. width: 100,
  75. height: 65,
  76. decoration: BoxDecoration(
  77. color: item.isSelected ? ColorUtils.string2Color('#F5F5F7'): context.appColors.whiteBG,
  78. borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)),
  79. ),
  80. child: Column(
  81. mainAxisAlignment: MainAxisAlignment.center,
  82. children: [
  83. MyTextView(
  84. "${item.day}",
  85. textColor: context.appColors.textBlack,
  86. fontSize: 12,
  87. isFontBold: true,
  88. ),
  89. MyTextView(
  90. "${item.date}",
  91. textColor: context.appColors.textBlack,
  92. fontSize: 12,
  93. isFontBold: true,
  94. marginTop: 5,
  95. ),
  96. ]
  97. )
  98. ).onTap((){
  99. // 点击某一天
  100. vm.handlerClicKSomeDay(context, item, index);
  101. });
  102. }
  103. ),
  104. ),
  105. // 分割线
  106. Divider(
  107. color: context.appColors.grayBgE9,
  108. height: 1,
  109. ),
  110. ],
  111. ),
  112. );
  113. }
  114. }