chooseVisitTimeTitle.dart 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 String cleanServiceType;
  19. const ChooseVisitTimeTitle(
  20. {Key? key,required this.id, required this.cleanServiceType,}) : 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. ],
  51. ),
  52. ),
  53. Container(
  54. width: double.infinity,
  55. height: 65,
  56. // color: Colors.red,
  57. margin: const EdgeInsets.only(left: 20, right: 20, top: 0, bottom: 0),
  58. child: ListView.builder(
  59. itemCount: dayInfoList.length,
  60. shrinkWrap: true,
  61. scrollDirection: Axis.horizontal,
  62. itemBuilder: (context, index){
  63. DayInfoItem item = dayInfoList[index];
  64. return Container(
  65. width: 100,
  66. height: 65,
  67. decoration: BoxDecoration(
  68. color: item.isSelected ? ColorUtils.string2Color('#F5F5F7'): context.appColors.whiteBG,
  69. borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)),
  70. ),
  71. child: Column(
  72. mainAxisAlignment: MainAxisAlignment.center,
  73. children: [
  74. MyTextView(
  75. "${item.day}",
  76. textColor: context.appColors.textBlack,
  77. fontSize: 12,
  78. isFontBold: true,
  79. ),
  80. MyTextView(
  81. "${item.date}",
  82. textColor: context.appColors.textBlack,
  83. fontSize: 12,
  84. isFontBold: true,
  85. marginTop: 5,
  86. ),
  87. ]
  88. )
  89. ).onTap((){
  90. // 点击某一天
  91. vm.handlerClicKSomeDay(context, item, index);
  92. });
  93. }
  94. ),
  95. ),
  96. // 分割线
  97. Divider(
  98. color: context.appColors.grayBgE9,
  99. height: 1,
  100. ),
  101. ],
  102. ),
  103. );
  104. }
  105. }