chooseAirConditionTitle.dart 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import 'package:cpt_services/modules/services/service_clean_detail/service_clean_detail_vm.dart';
  2. import 'package:cs_resources/theme/app_colors_theme.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:auto_route/auto_route.dart';
  5. import 'package:flutter_hooks/flutter_hooks.dart';
  6. import 'package:hooks_riverpod/hooks_riverpod.dart';
  7. import 'package:shared/utils/log_utils.dart';
  8. import 'package:widgets/my_text_view.dart';
  9. import 'package:widgets/widget_export.dart';
  10. import 'chooseAirConditionContent_vm.dart';
  11. // import 'chooseAirConditionTitle_vm.dart';
  12. class ChooseAirConditionTitle extends HookConsumerWidget {
  13. final int id;
  14. final String cleanServiceType;
  15. const ChooseAirConditionTitle(
  16. {Key? key,required this.id, required this.cleanServiceType,}) : super(key: key);
  17. @override
  18. Widget build(BuildContext context, WidgetRef ref) {
  19. final totalPrice = useState<double>(0.0);
  20. ref.listen(
  21. chooseAirConditionContentVmProvider.select((state) => state.totalPrice ?? 0.0),
  22. (previous, next) {
  23. // 处理 totalPrice 变化
  24. // print('Total Price: $next');
  25. totalPrice.value = next.toDouble();
  26. },
  27. );
  28. useEffect((){
  29. // 组件挂载时执行 - 执行接口请求
  30. // Future.microtask(() => vm.initPageData());
  31. return () {
  32. // 组件卸载时执行
  33. };
  34. },[]);
  35. return Container(
  36. child: Column(
  37. mainAxisAlignment: MainAxisAlignment.start,
  38. children: [
  39. Padding(
  40. padding: const EdgeInsets.only(left: 20, right: 20, top: 10, bottom: 10),
  41. child: Column(
  42. children: [
  43. MyTextView(
  44. "Select Air Conditioner",
  45. textColor: context.appColors.textBlack,
  46. textAlign: TextAlign.left,
  47. isFontBold: true,
  48. fontSize: 17,
  49. boxWidth: double.infinity,
  50. // maxLines: 5,
  51. ),
  52. MyTextView(
  53. "\$${totalPrice.value}",
  54. textColor: context.appColors.textPrimary,
  55. textAlign: TextAlign.left,
  56. isFontMedium: true,
  57. fontSize: 17,
  58. // maxLines: 5,
  59. boxWidth: double.infinity,
  60. ),
  61. ],
  62. ),
  63. ),
  64. // 分割线
  65. Divider(
  66. color: context.appColors.grayBgE9,
  67. height: 1,
  68. ),
  69. ],
  70. ),
  71. );
  72. }
  73. }