chooseHouseCleanContent_vm.dart 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:riverpod_annotation/riverpod_annotation.dart';
  4. import 'package:router/ext/auto_router_extensions.dart';
  5. import 'package:shared/utils/log_utils.dart';
  6. import 'package:widgets/dialog/dialog_content_wrap.dart';
  7. import '../../../respository/services_respository.dart';
  8. import 'chooseHouseCleanContent_state.dart';
  9. part 'chooseHouseCleanContent_vm.g.dart';
  10. List<Map<String, dynamic>> HouseCleanList = [
  11. {
  12. "name": "House Clean 1(unit)",
  13. "id": 1,
  14. "price": 40.0,
  15. "num":1,
  16. "areaSizeRange": "≤600 sqft",
  17. "isChecked": false,
  18. "isDisable": false,
  19. },
  20. {
  21. "name": "House Clean 2(unit)",
  22. "id": 2,
  23. "price": 57.0,
  24. "num":1,
  25. "areaSizeRange": "601-800 sqft",
  26. "isChecked": false,
  27. "isDisable": false,
  28. },
  29. {
  30. "name": "House Clean 3(unit)",
  31. "id": 3,
  32. "price": 72.0,
  33. "num":1,
  34. "areaSizeRange": "801-1000 sqft",
  35. "isChecked": false,
  36. "isDisable": false,
  37. },
  38. {
  39. "name": "House Clean 3(unit)",
  40. "id": 4,
  41. "price": 85.0,
  42. "num":1,
  43. "areaSizeRange": "1001-1200 sqft",
  44. "isChecked": false,
  45. "isDisable": false,
  46. },
  47. ];
  48. @riverpod
  49. class ChooseHouseCleanContentVm extends _$ChooseHouseCleanContentVm {
  50. late ServicesRespository serviceRespositoryInstance;
  51. late BuildContext _context;
  52. late Map<String, dynamic>? _initProps;
  53. ChooseHouseCleanContentState initState(){
  54. Log.d("--------------------------initState---------------------");
  55. List<HouseCleanContentItem> HouseCleanListNew = [];
  56. HouseCleanList.forEach((item) {
  57. HouseCleanContentItem newItem = HouseCleanContentItem()
  58. ..id = item['id']
  59. ..price = item['price'] as double
  60. ..name = item['name']
  61. ..num = 1
  62. ..areaSizeRange = item['areaSizeRange']
  63. ..isChecked = item['isChecked']
  64. ..isDisable = item['isDisable'];
  65. HouseCleanListNew.add(newItem);
  66. });
  67. return ChooseHouseCleanContentState(
  68. HouseCleanList: HouseCleanListNew,
  69. );
  70. }
  71. @override
  72. ChooseHouseCleanContentState build(){
  73. // 引入数据仓库
  74. serviceRespositoryInstance = ref.read(servicesRespositoryProvider);
  75. ChooseHouseCleanContentState state = initState();
  76. Log.d("--------------------------build---------------------");
  77. return state;
  78. }
  79. setInitPageData(BuildContext context, Map<String, dynamic>? params){
  80. _context = context;
  81. Log.d("--------------------------setInitPageData----------$params-----------");
  82. _initProps = params;
  83. }
  84. handlerChangeNum(BuildContext context, bool isChecked, int index){
  85. state.HouseCleanList[index].isChecked = isChecked;
  86. state = state.copyWith(
  87. HouseCleanList: state.HouseCleanList,
  88. );
  89. }
  90. }