property_page.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import 'package:cpt_property/modules/ioan/page/property_ioan_page.dart';
  2. import 'package:cpt_property/modules/news/page/property_news_page.dart';
  3. import 'package:cpt_property/modules/rent/page/property_rent_page.dart';
  4. import 'package:cpt_property/modules/sale/page/property_sale_page.dart';
  5. import 'package:flutter/material.dart';
  6. import 'package:auto_route/auto_route.dart';
  7. import 'package:hooks_riverpod/hooks_riverpod.dart';
  8. import 'package:router/ext/auto_router_extensions.dart';
  9. import 'package:shared/utils/log_utils.dart';
  10. import 'package:widgets/my_load_image.dart';
  11. import 'package:widgets/ext/ex_widget.dart';
  12. import '../../../router/page/property_page_router.dart';
  13. import '../vm/property_vm.dart';
  14. @RoutePage()
  15. class PropertyPage extends HookConsumerWidget {
  16. const PropertyPage({Key? key}) : super(key: key);
  17. //启动当前页面
  18. static void startInstance({BuildContext? context}) {
  19. if (context != null) {
  20. context.router.push(const PropertyPageRoute());
  21. } else {
  22. appRouter.push(const PropertyPageRoute());
  23. }
  24. }
  25. // 顶部tab 切换
  26. Widget _buildTopSection(BuildContext context, WidgetRef ref, _vm) {
  27. final topSectionsData = _vm.topSectionsData;
  28. return Container(
  29. color: Colors.white,
  30. child: Center(
  31. child: Row(
  32. mainAxisAlignment: MainAxisAlignment.center,
  33. crossAxisAlignment: CrossAxisAlignment.center,
  34. children: List.generate(topSectionsData.length, (index) {
  35. final item = topSectionsData[index];
  36. return Container(
  37. child: Column(
  38. children: [
  39. MyAssetImage(item['icon'], width: 70, height: 70,).onTap((){
  40. Log.d("fdjskfds${item['title']}");
  41. _vm.switchPage(index, context);
  42. switch(index){
  43. case 0:
  44. PropertySalePage.startInstance(context: context);
  45. break;
  46. case 1:
  47. PropertyRentPage.startInstance(context: context);
  48. break;
  49. case 2:
  50. PropertyIoanPage.startInstance(context: context);
  51. break;
  52. case 3:
  53. PropertyNewsPage.startInstance(context: context);
  54. break;
  55. }
  56. },
  57. type: ClickType.throttle,
  58. ),
  59. TextButton(
  60. onPressed: () {
  61. // _vm.selectTab(index);
  62. },
  63. child: Text(item['title']),
  64. ),
  65. ],
  66. ),
  67. ).marginOnly(left:18,right:18,top: 10,bottom: 10);
  68. }),
  69. ),
  70. ),
  71. );
  72. }
  73. @override
  74. Widget build(BuildContext context, WidgetRef ref) {
  75. final _vm = ref.read(propertyVmProvider.notifier);
  76. return DefaultTabController(
  77. length: 4,
  78. child: Scaffold(
  79. appBar: AppBar(
  80. title: Text("Property"),
  81. bottomOpacity: 0.0, // 取消下横线
  82. titleTextStyle: TextStyle(color: Colors.black),
  83. ),
  84. body: Row(
  85. children: [
  86. Expanded(
  87. child: Column(
  88. children: [
  89. _buildTopSection(context, ref, _vm),
  90. Expanded(
  91. child: AutoRouter(),
  92. )
  93. ],
  94. ),
  95. )
  96. ],
  97. )
  98. ),
  99. );
  100. }
  101. }