property_page.dart 2.6 KB

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