services_main_page.dart 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import 'package:cs_resources/generated/assets.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:auto_route/auto_route.dart';
  4. import 'package:flutter/rendering.dart';
  5. import 'package:flutter_hooks/flutter_hooks.dart';
  6. import 'package:hooks_riverpod/hooks_riverpod.dart';
  7. import 'package:plugin_basic/provider/user_config/user_config_service.dart';
  8. import 'package:router/ext/auto_router_extensions.dart';
  9. import 'package:shared/utils/color_utils.dart';
  10. import 'package:shared/utils/log_utils.dart';
  11. import 'package:widgets/custom_sliver_persistent_header_delegate.dart';
  12. import 'package:widgets/my_load_image.dart';
  13. import 'package:widgets/ext/ex_widget.dart';
  14. import 'package:widgets/my_text_view.dart';
  15. import 'package:widgets/my_appbar.dart';
  16. import 'package:cs_resources/theme/app_colors_theme.dart';
  17. import 'package:widgets/widget_export.dart';
  18. import '../../router/page/services_page_router.dart';
  19. import 'inProgress/in_progress_page.dart';
  20. import 'repair/repair_page.dart';
  21. import 'services_page.dart';
  22. enum ServicesType {
  23. cleaning,
  24. repair,
  25. }
  26. @RoutePage()
  27. class ServicesMainPage extends HookConsumerWidget {
  28. ServicesMainPage({Key? key}) : super(key: key);
  29. //启动当前页面
  30. static void startInstance({BuildContext? context}) {
  31. if (context != null) {
  32. context.router.push( ServicesMainPageRoute());
  33. } else {
  34. appRouter.push( ServicesMainPageRoute());
  35. }
  36. }
  37. @override
  38. Widget build(BuildContext context, WidgetRef ref) {
  39. useEffect(() {
  40. // 监听窗口
  41. }, []);
  42. useEffect(() {
  43. Log.d("ServicesMainPage initState");
  44. // 延迟监听
  45. }, []);
  46. return Scaffold(
  47. appBar: MyAppBar.appBar(
  48. context,
  49. "ServicesMain",
  50. backgroundColor: context.appColors.whiteBG,
  51. ),
  52. backgroundColor: context.appColors.backgroundDefault,
  53. body: Container(
  54. child: GridView.count(
  55. crossAxisCount: 2,
  56. padding: EdgeInsets.all(10),
  57. mainAxisSpacing: 10,
  58. crossAxisSpacing: 10,
  59. children: [
  60. _buildServiceCard(
  61. context,
  62. ServicesType.cleaning,
  63. Assets.serviceInProgress,
  64. "Home Services",
  65. ServicesPage.startInstance,
  66. ),
  67. _buildServiceCard(
  68. context,
  69. ServicesType.repair,
  70. Assets.serviceHistory,
  71. "Maintenance",
  72. RepairPage.startInstance,
  73. ),
  74. ]
  75. ),
  76. ),
  77. );
  78. }
  79. Widget _buildServiceCard(
  80. BuildContext context,
  81. ServicesType type,
  82. String imagePath,
  83. String title,
  84. Function() onTap,
  85. ) {
  86. return Container(
  87. decoration: BoxDecoration(
  88. color: context.appColors.whiteBG,
  89. borderRadius: BorderRadius.circular(10),
  90. boxShadow: [
  91. BoxShadow(
  92. color: context.appColors.whiteBG,
  93. blurRadius: 5,
  94. offset: Offset(0, 3),
  95. ),
  96. ],
  97. ),
  98. ).onTap((){
  99. if(type == ServicesType.cleaning){
  100. ServicesPage.startInstance();
  101. }else if(type == ServicesType.repair){
  102. RepairPage.startInstance();
  103. }
  104. });
  105. }
  106. }