view.dart 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import 'package:flutter/material.dart';
  2. import 'package:get/get.dart';
  3. import 'package:pull_to_refresh/pull_to_refresh.dart';
  4. import 'index.dart';
  5. import 'widgets/widgets.dart';
  6. class DefaultIndexPage extends GetView<DefaultIndexController> {
  7. const DefaultIndexPage({Key? key}) : super(key: key);
  8. /// 主视图
  9. Widget _mainBuildView(BuildContext context) {
  10. return Obx(() => SmartRefresher(
  11. enablePullDown: true,
  12. enablePullUp: controller.state.hasMoreData,
  13. controller: controller.refreshController,
  14. onRefresh: () => controller.onRefresh(),
  15. onLoading: () => controller.loadMoreData(),
  16. child: ListView(
  17. children: [
  18. // 滚动大图和应用快捷列表
  19. const BannerAndAppsWidget(),
  20. const SizedBox(height: 8),
  21. _cmsAndTaskTabView(context),
  22. const SizedBox(height: 10),
  23. controller.state.listType == 1
  24. ? const TaskListWidget()
  25. : const CmsListWidget()
  26. ],
  27. )));
  28. }
  29. /// Tab 信息中心 办公中心
  30. Widget _cmsAndTaskTabView(BuildContext context) {
  31. return Obx(() => Row(
  32. mainAxisAlignment: MainAxisAlignment.center,
  33. children: [
  34. GestureDetector(
  35. onTap: () => controller.clickChangeListType(0),
  36. child: Padding(
  37. padding: const EdgeInsets.only(
  38. left: 10, right: 10, top: 5, bottom: 5),
  39. child: Text(
  40. 'home_index_cms_center'.tr,
  41. style: controller.state.listType == 0
  42. ? Theme.of(context).textTheme.titleMedium?.copyWith(
  43. color: Theme.of(context).colorScheme.primary,
  44. fontWeight: FontWeight.bold)
  45. : Theme.of(context)
  46. .textTheme
  47. .titleMedium
  48. ?.copyWith(fontWeight: FontWeight.normal),
  49. )),
  50. ),
  51. const SizedBox(width: 15),
  52. GestureDetector(
  53. onTap: () => controller.clickChangeListType(1),
  54. child: Padding(
  55. padding: const EdgeInsets.only(
  56. left: 10, right: 10, top: 5, bottom: 5),
  57. child: Text('home_index_task_center'.tr,
  58. style: controller.state.listType == 1
  59. ? Theme.of(context).textTheme.titleMedium?.copyWith(
  60. color: Theme.of(context).colorScheme.primary,
  61. fontWeight: FontWeight.bold)
  62. : Theme.of(context)
  63. .textTheme
  64. .titleMedium
  65. ?.copyWith(fontWeight: FontWeight.normal))),
  66. )
  67. ],
  68. ));
  69. }
  70. @override
  71. Widget build(BuildContext context) {
  72. return GetBuilder<DefaultIndexController>(
  73. builder: (_) {
  74. return Scaffold(
  75. body: Container(
  76. color: Theme.of(context).scaffoldBackgroundColor,
  77. child: Column(
  78. children: [
  79. // 顶部搜索栏
  80. const TopBarWidget(),
  81. Expanded(flex: 1, child: _mainBuildView(context))
  82. ],
  83. )),
  84. );
  85. },
  86. );
  87. }
  88. }