123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- import 'index.dart';
- import 'widgets/widgets.dart';
- class DefaultIndexPage extends GetView<DefaultIndexController> {
- const DefaultIndexPage({Key? key}) : super(key: key);
- /// 主视图
- Widget _mainBuildView(BuildContext context) {
- return Obx(() => SmartRefresher(
- enablePullDown: true,
- enablePullUp: controller.state.hasMoreData,
- controller: controller.refreshController,
- onRefresh: () => controller.onRefresh(),
- onLoading: () => controller.loadMoreData(),
- child: ListView(
- children: [
- // 滚动大图和应用快捷列表
- const BannerAndAppsWidget(),
- const SizedBox(height: 8),
- _cmsAndTaskTabView(context),
- const SizedBox(height: 10),
- controller.state.listType == 1
- ? const TaskListWidget()
- : const CmsListWidget()
- ],
- )));
- }
- /// Tab 信息中心 办公中心
- Widget _cmsAndTaskTabView(BuildContext context) {
- return Obx(() => Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- GestureDetector(
- onTap: () => controller.clickChangeListType(0),
- child: Padding(
- padding: const EdgeInsets.only(
- left: 10, right: 10, top: 5, bottom: 5),
- child: Text(
- 'home_index_cms_center'.tr,
- style: controller.state.listType == 0
- ? Theme.of(context).textTheme.titleMedium?.copyWith(
- color: Theme.of(context).colorScheme.primary,
- fontWeight: FontWeight.bold)
- : Theme.of(context)
- .textTheme
- .titleMedium
- ?.copyWith(fontWeight: FontWeight.normal),
- )),
- ),
- const SizedBox(width: 15),
- GestureDetector(
- onTap: () => controller.clickChangeListType(1),
- child: Padding(
- padding: const EdgeInsets.only(
- left: 10, right: 10, top: 5, bottom: 5),
- child: Text('home_index_task_center'.tr,
- style: controller.state.listType == 1
- ? Theme.of(context).textTheme.titleMedium?.copyWith(
- color: Theme.of(context).colorScheme.primary,
- fontWeight: FontWeight.bold)
- : Theme.of(context)
- .textTheme
- .titleMedium
- ?.copyWith(fontWeight: FontWeight.normal))),
- )
- ],
- ));
- }
- @override
- Widget build(BuildContext context) {
- return GetBuilder<DefaultIndexController>(
- builder: (_) {
- return Scaffold(
- body: Container(
- color: Theme.of(context).scaffoldBackgroundColor,
- child: Column(
- children: [
- // 顶部搜索栏
- const TopBarWidget(),
- Expanded(flex: 1, child: _mainBuildView(context))
- ],
- )),
- );
- },
- );
- }
- }
|