|
@@ -2,8 +2,10 @@ import 'package:cpt_main/modules/home/home_state.dart';
|
|
|
import 'package:cs_resources/generated/assets.dart';
|
|
|
import 'package:cs_resources/generated/l10n.dart';
|
|
|
import 'package:cs_resources/theme/app_colors_theme.dart';
|
|
|
+import 'package:cs_resources/theme/theme_config.dart';
|
|
|
import 'package:domain/entity/home_list_entity.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter/services.dart';
|
|
|
import 'package:flutter/src/widgets/framework.dart';
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
@@ -47,114 +49,168 @@ class HomePage extends HookConsumerWidget {
|
|
|
};
|
|
|
}, []);
|
|
|
|
|
|
- return Scaffold(
|
|
|
- //根据当前时间生成欢迎文本
|
|
|
- appBar: MyAppBar.appBar(context, _formatNowGreetingText(ref),
|
|
|
- showBackButton: false,
|
|
|
- backgroundColor: context.appColors.backgroundWhite,
|
|
|
- actions: [
|
|
|
- Center(
|
|
|
- child: Stack(
|
|
|
- clipBehavior: Clip.none, // 不裁剪超出边界的内容
|
|
|
- alignment: Alignment.topLeft,
|
|
|
- children: <Widget>[
|
|
|
- // 通知图标
|
|
|
- MyAssetImage(
|
|
|
- Assets.mainHomeNotificationIcon,
|
|
|
- width: 19,
|
|
|
- height: 20,
|
|
|
- color: context.appColors.imageDarkModelWhite,
|
|
|
- ),
|
|
|
-
|
|
|
- //未读消息
|
|
|
- Positioned(
|
|
|
- left: 0,
|
|
|
- top: 0,
|
|
|
- child: Transform.translate(
|
|
|
- offset: const Offset(-10, -5),
|
|
|
- child: MyTextView(
|
|
|
- "99",
|
|
|
- boxWidth: 20.0,
|
|
|
- textColor: Colors.white,
|
|
|
- fontSize: 10,
|
|
|
- isFontLight: true,
|
|
|
- backgroundColor: context.appColors.redDefault,
|
|
|
- cornerRadius: 8,
|
|
|
- paddingTop: 2,
|
|
|
- paddingBottom: 2,
|
|
|
- textAlign: TextAlign.center,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ).onTap(viewModel.gotoNotificationPage))
|
|
|
- .marginOnly(right: 15),
|
|
|
- ],
|
|
|
- showBottomDivider: true),
|
|
|
- backgroundColor: context.appColors.backgroundDefault,
|
|
|
- body: EasyRefresh(
|
|
|
- controller: viewModel.refreshController,
|
|
|
- onRefresh: viewModel.onRefresh,
|
|
|
- child: CustomScrollView(
|
|
|
- scrollDirection: Axis.vertical,
|
|
|
- slivers: [
|
|
|
- //支付与奖励
|
|
|
- _buildPaymentAndRewardsWidget(context, ref),
|
|
|
-
|
|
|
- //间距
|
|
|
- _buildSliverSpace(20),
|
|
|
-
|
|
|
- //九宫选项组 (固定)
|
|
|
- _buildCategoryWidget(context, ref),
|
|
|
-
|
|
|
- //轮播图片 (动态)
|
|
|
- _buildBannerImage(ref, bannerIndex),
|
|
|
-
|
|
|
- //最新的新闻(动态)
|
|
|
- _buildLastNews(context, ref),
|
|
|
-
|
|
|
- //最新的交易
|
|
|
- SliverToBoxAdapter(
|
|
|
- child: MyTextView(
|
|
|
- marginTop: 14,
|
|
|
- marginLeft: 15,
|
|
|
- marginBottom: 14,
|
|
|
- S.current.latest_transactions,
|
|
|
- textColor: context.appColors.textPrimary,
|
|
|
- fontSize: 16,
|
|
|
- isFontMedium: true,
|
|
|
+ return AnnotatedRegion<SystemUiOverlayStyle>(
|
|
|
+ value: MediaQuery.of(context).platformBrightness == Brightness.dark
|
|
|
+ ? ThemeConfig.systemUiOverlayStyleDarkTheme
|
|
|
+ : ThemeConfig.systemUiOverlayStyleLightThemeWhite,
|
|
|
+ child: Scaffold(
|
|
|
+ backgroundColor: context.appColors.backgroundDefault,
|
|
|
+ body: Stack(
|
|
|
+ children: [
|
|
|
+ // 固定顶部的背景图片
|
|
|
+ const Positioned(
|
|
|
+ top: 0,
|
|
|
+ left: 0,
|
|
|
+ right: 0,
|
|
|
+ child: MyAssetImage(
|
|
|
+ Assets.mainHomeTopImgBg,
|
|
|
+ width: double.infinity,
|
|
|
+ fit: BoxFit.cover,
|
|
|
+ height: 325,
|
|
|
+ ), // 替换为你的图片路径
|
|
|
),
|
|
|
- ),
|
|
|
|
|
|
- //最新交易列表 (动态)
|
|
|
- _buildLastTransaction(context, state),
|
|
|
-
|
|
|
- //房产新闻
|
|
|
- SliverToBoxAdapter(
|
|
|
- child: MyTextView(
|
|
|
- marginTop: 14,
|
|
|
- marginLeft: 15,
|
|
|
- marginBottom: 14,
|
|
|
- onClick: viewModel.gotoPropertyNewsPage,
|
|
|
- S.current.property_news,
|
|
|
- textColor: context.appColors.textPrimary,
|
|
|
- fontSize: 16,
|
|
|
- isFontMedium: true,
|
|
|
+ Positioned(
|
|
|
+ top: 58,
|
|
|
+ left: 0,
|
|
|
+ right: 0,
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ _formatNowGreetingText(ref),
|
|
|
+ marginLeft: 17,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ isFontBold: true,
|
|
|
+ fontSize: 20,
|
|
|
+ ).expanded(),
|
|
|
+
|
|
|
+ //通知角标
|
|
|
+ Center(
|
|
|
+ child: Stack(
|
|
|
+ clipBehavior: Clip.none, // 不裁剪超出边界的内容
|
|
|
+ alignment: Alignment.topLeft,
|
|
|
+ children: <Widget>[
|
|
|
+ // 通知图标
|
|
|
+ MyAssetImage(
|
|
|
+ Assets.mainHomeNotificationIcon,
|
|
|
+ width: 17,
|
|
|
+ height: 19,
|
|
|
+ color: context.appColors.imageDarkModelWhite,
|
|
|
+ ),
|
|
|
+
|
|
|
+ //未读消息
|
|
|
+ Positioned(
|
|
|
+ left: 0,
|
|
|
+ top: 0,
|
|
|
+ child: Transform.translate(
|
|
|
+ offset: const Offset(-10, -5),
|
|
|
+ child: MyTextView(
|
|
|
+ "99",
|
|
|
+ boxWidth: 20.0,
|
|
|
+ textColor: Colors.white,
|
|
|
+ fontSize: 10,
|
|
|
+ isFontLight: true,
|
|
|
+ backgroundColor: context.appColors.redDefault,
|
|
|
+ cornerRadius: 8,
|
|
|
+ paddingTop: 2,
|
|
|
+ paddingBottom: 2,
|
|
|
+ textAlign: TextAlign.center,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ).onTap(viewModel.gotoNotificationPage))
|
|
|
+ .marginOnly(right: 17),
|
|
|
+ ],
|
|
|
+ ), // 替换为你的图片路径
|
|
|
),
|
|
|
- ),
|
|
|
-
|
|
|
- //房产新闻列表 (动态)
|
|
|
- _buildPropertyNews(context, ref),
|
|
|
|
|
|
- //管理员介绍 (固定)
|
|
|
- _buildManagementGuides(context, ref),
|
|
|
-
|
|
|
- //间距
|
|
|
- _buildSliverSpace(15),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
+ Positioned(
|
|
|
+ top: 100,
|
|
|
+ left: 0,
|
|
|
+ right: 0,
|
|
|
+ bottom: 0,
|
|
|
+ child: EasyRefresh(
|
|
|
+ controller: viewModel.refreshController,
|
|
|
+ onRefresh: viewModel.onRefresh,
|
|
|
+ child: CustomScrollView(
|
|
|
+ scrollDirection: Axis.vertical,
|
|
|
+ slivers: [
|
|
|
+ //支付与奖励
|
|
|
+ _buildPaymentAndRewardsWidget(context, ref),
|
|
|
+
|
|
|
+ //间距
|
|
|
+ _buildSliverSpace(20),
|
|
|
+
|
|
|
+ //九宫选项组 (固定)
|
|
|
+ _buildCategoryWidget(context, ref),
|
|
|
+
|
|
|
+ //轮播图片 (动态)
|
|
|
+ _buildBannerImage(ref, bannerIndex),
|
|
|
+
|
|
|
+ //最新的新闻(动态)
|
|
|
+ _buildLastNews(context, ref),
|
|
|
+
|
|
|
+ //最新的交易
|
|
|
+ SliverToBoxAdapter(
|
|
|
+ child: MyTextView(
|
|
|
+ marginTop: 32,
|
|
|
+ marginLeft: 15,
|
|
|
+ marginBottom: 14,
|
|
|
+ S.current.latest_transactions,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 16,
|
|
|
+ isFontMedium: true,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+
|
|
|
+ //最新交易列表 (动态)
|
|
|
+ _buildLastTransaction(context, state),
|
|
|
+
|
|
|
+ //房产新闻
|
|
|
+ SliverToBoxAdapter(
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ MyTextView(
|
|
|
+ marginTop: 30,
|
|
|
+ marginLeft: 15,
|
|
|
+ marginBottom: 14,
|
|
|
+ S.current.property_news,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 16,
|
|
|
+ isFontMedium: true,
|
|
|
+ ).expanded(),
|
|
|
+ MyTextView(
|
|
|
+ marginTop: 30,
|
|
|
+ marginLeft: 15,
|
|
|
+ marginRight: 15,
|
|
|
+ marginBottom: 14,
|
|
|
+ onClick: viewModel.gotoPropertyNewsPage,
|
|
|
+ S.current.all,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 15,
|
|
|
+ isFontMedium: true,
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+
|
|
|
+ //房产新闻列表 (动态)
|
|
|
+ _buildPropertyNews(context, ref),
|
|
|
+
|
|
|
+ //管理员介绍 (固定)
|
|
|
+ _buildManagementGuides(context, ref),
|
|
|
+
|
|
|
+ //间距
|
|
|
+ _buildSliverSpace(15),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
//顶部的支付与奖励的布局
|
|
@@ -162,66 +218,67 @@ class HomePage extends HookConsumerWidget {
|
|
|
final viewModel = ref.read(homeViewModelProvider.notifier);
|
|
|
|
|
|
return SliverToBoxAdapter(
|
|
|
- child: Container(
|
|
|
- color: context.appColors.whiteBG,
|
|
|
- width: double.infinity,
|
|
|
- height: 45,
|
|
|
- child: Column(
|
|
|
- children: [
|
|
|
- Row(
|
|
|
- children: [
|
|
|
- Row(
|
|
|
- mainAxisSize: MainAxisSize.max,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: [
|
|
|
- MyAssetImage(
|
|
|
- Assets.mainHomePaymentIcon,
|
|
|
- width: 16.5,
|
|
|
- height: 18,
|
|
|
- color: context.appColors.imageDarkModelWhite,
|
|
|
- ).marginOnly(left: 20),
|
|
|
- MyTextView(
|
|
|
- S.current.payment,
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
- fontSize: 15,
|
|
|
- isFontMedium: true,
|
|
|
- ).paddingOnly(left: 13, right: 13).expanded(),
|
|
|
- const MyAssetImage(Assets.mainHomeMoreIcon, width: 6, height: 8.5).marginOnly(right: 15),
|
|
|
- ],
|
|
|
- ).onTap(viewModel.gotoPaymentPage).expanded(),
|
|
|
- Container(color: context.appColors.dividerDefault, width: 0.5, height: double.infinity),
|
|
|
- Row(
|
|
|
- mainAxisSize: MainAxisSize.max,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: [
|
|
|
- MyAssetImage(
|
|
|
- Assets.mainHomeRewardsIcon,
|
|
|
- width: 16.5,
|
|
|
- height: 17,
|
|
|
- color: context.appColors.imageDarkModelWhite,
|
|
|
- ).marginOnly(left: 20),
|
|
|
- MyTextView(
|
|
|
- S.current.rewards,
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
- fontSize: 15,
|
|
|
- isFontMedium: true,
|
|
|
- ).paddingOnly(left: 13, right: 4).expanded(),
|
|
|
- MyTextView(
|
|
|
- "9568",
|
|
|
- textColor: context.appColors.textBlack,
|
|
|
- fontSize: 15,
|
|
|
- isFontBold: true,
|
|
|
- ).paddingOnly(left: 1, right: 4),
|
|
|
- const MyAssetImage(Assets.mainHomeMoreIcon, width: 6, height: 8.5).marginOnly(right: 15),
|
|
|
- ],
|
|
|
- ).onTap(viewModel.gotoRewardsPage).expanded(),
|
|
|
- ],
|
|
|
- ).expanded(),
|
|
|
- //底部分割线
|
|
|
- Container(color: context.appColors.dividerDefault, height: 0.5, width: double.infinity),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ const MyAssetImage(
|
|
|
+ Assets.mainHomePaymentIcon,
|
|
|
+ width: 24.5,
|
|
|
+ height: 24.5,
|
|
|
+ ).marginOnly(left: 10),
|
|
|
+ MyTextView(
|
|
|
+ S.current.payment,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 14,
|
|
|
+ isFontRegular: true,
|
|
|
+ ).paddingOnly(left: 8, right: 8).expanded(),
|
|
|
+ const MyAssetImage(Assets.mainHomeMoreIcon, width: 6, height: 8.5).marginOnly(right: 15),
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ .constrained(height: 46)
|
|
|
+ .decorated(
|
|
|
+ color: const Color(0xFFE0E3FF).withOpacity(0.5),
|
|
|
+ borderRadius: BorderRadius.circular(9.0),
|
|
|
+ )
|
|
|
+ .onTap(viewModel.gotoPaymentPage)
|
|
|
+ .expanded(),
|
|
|
+ const SizedBox(width: 14.5),
|
|
|
+ Row(
|
|
|
+ mainAxisSize: MainAxisSize.max,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ const MyAssetImage(
|
|
|
+ Assets.mainHomeRewardsIcon,
|
|
|
+ width: 24.5,
|
|
|
+ height: 24.5,
|
|
|
+ ).marginOnly(left: 10),
|
|
|
+ MyTextView(
|
|
|
+ S.current.rewards,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 14,
|
|
|
+ isFontRegular: true,
|
|
|
+ ).paddingOnly(left: 8, right: 4).expanded(),
|
|
|
+ MyTextView(
|
|
|
+ "9568",
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
+ fontSize: 14,
|
|
|
+ isFontBold: true,
|
|
|
+ ).paddingOnly(left: 1, right: 4),
|
|
|
+ const MyAssetImage(Assets.mainHomeMoreIcon, width: 6, height: 8.5).marginOnly(right: 8),
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ .constrained(height: 46)
|
|
|
+ .decorated(
|
|
|
+ color: const Color(0xFFE0E3FF).withOpacity(0.5),
|
|
|
+ borderRadius: BorderRadius.circular(9.0),
|
|
|
+ )
|
|
|
+ .onTap(viewModel.gotoRewardsPage)
|
|
|
+ .expanded(),
|
|
|
+ ],
|
|
|
+ ).paddingOnly(left: 15, right: 15, top: 10),
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -239,9 +296,8 @@ class HomePage extends HookConsumerWidget {
|
|
|
return SliverGrid(
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
crossAxisCount: 3, // 三列
|
|
|
- mainAxisSpacing: 15.0, // 主轴(上下)的间距
|
|
|
+ mainAxisSpacing: 0.0, // 主轴(上下)的间距
|
|
|
crossAxisSpacing: 0.0, // 交叉轴(左右)的间距
|
|
|
- childAspectRatio: 10 / 8, // 子组件的宽高比
|
|
|
),
|
|
|
delegate: SliverChildBuilderDelegate(
|
|
|
(BuildContext context, int index) {
|
|
@@ -264,7 +320,7 @@ class HomePage extends HookConsumerWidget {
|
|
|
return SliverToBoxAdapter(
|
|
|
child: Container(
|
|
|
width: double.infinity,
|
|
|
- margin: const EdgeInsets.only(top: 21, left: 15, right: 15),
|
|
|
+ margin: const EdgeInsets.only(top: 30, left: 15, right: 15),
|
|
|
child: state.homeIndex != null && state.homeIndex!.banners.isNotEmpty
|
|
|
? Stack(
|
|
|
alignment: Alignment.bottomCenter, // 设置 Stack 的对齐方式为底部中心
|
|
@@ -342,11 +398,11 @@ class HomePage extends HookConsumerWidget {
|
|
|
MyTextView(
|
|
|
S.current.latest_news,
|
|
|
fontSize: 16,
|
|
|
- marginTop: 14,
|
|
|
+ marginTop: 30,
|
|
|
marginBottom: 14,
|
|
|
isFontMedium: true,
|
|
|
onClick: viewModel.gotoLastNewsPage,
|
|
|
- textColor: context.appColors.textPrimary,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
),
|
|
|
Row(
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, // 均匀排布
|
|
@@ -412,27 +468,16 @@ class HomePage extends HookConsumerWidget {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- //房产新闻的双列表
|
|
|
+ //房产新闻的列表
|
|
|
Widget _buildPropertyNews(BuildContext context, WidgetRef ref) {
|
|
|
final state = ref.watch(homeViewModelProvider);
|
|
|
final propertyNewsList = state.homeIndex?.propertyNews ?? [];
|
|
|
|
|
|
- // 计算行数和每行的元素
|
|
|
- int totalItems = propertyNewsList.length;
|
|
|
- int firstRowCount = (totalItems + 1) ~/ 2; // 第1行的数量 (奇数时多一个)
|
|
|
- int secondRowCount = totalItems ~/ 2; // 第2行的数量
|
|
|
-
|
|
|
return SliverList(
|
|
|
delegate: SliverChildListDelegate(
|
|
|
[
|
|
|
// 第一个水平滑动列表
|
|
|
- _buildPropertyNewsHorizontalList(propertyNewsList.sublist(0, firstRowCount)),
|
|
|
-
|
|
|
- const SizedBox(height: 10),
|
|
|
-
|
|
|
- // 第二个水平滑动列表
|
|
|
- if (secondRowCount > 0) // 只有在有第二行内容时才显示
|
|
|
- _buildPropertyNewsHorizontalList(propertyNewsList.sublist(firstRowCount, firstRowCount + secondRowCount)),
|
|
|
+ _buildPropertyNewsHorizontalList(propertyNewsList),
|
|
|
],
|
|
|
),
|
|
|
);
|
|
@@ -464,11 +509,11 @@ class HomePage extends HookConsumerWidget {
|
|
|
MyTextView(
|
|
|
S.current.strata_management_guides,
|
|
|
fontSize: 16,
|
|
|
- marginTop: 14,
|
|
|
+ marginTop: 30,
|
|
|
marginBottom: 14,
|
|
|
onClick: viewModel.gotoManageGuidePage,
|
|
|
isFontMedium: true,
|
|
|
- textColor: context.appColors.textPrimary,
|
|
|
+ textColor: context.appColors.textBlack,
|
|
|
),
|
|
|
SingleChildScrollView(
|
|
|
scrollDirection: Axis.horizontal,
|