|
@@ -1,3 +1,5 @@
|
|
|
+import 'dart:ffi';
|
|
|
+
|
|
|
import 'package:cpt_rewards/modules/rewards_address/rewards_address_page.dart';
|
|
|
import 'package:cpt_rewards/modules/rewards_code/rewards_code_page.dart';
|
|
|
import 'package:cpt_rewards/modules/rewards_history/rewards_history_page.dart';
|
|
@@ -16,9 +18,12 @@ import 'package:shared/utils/color_utils.dart';
|
|
|
import 'package:shared/utils/log_utils.dart';
|
|
|
import 'package:widgets/ext/ex_widget.dart';
|
|
|
import 'package:widgets/load_state_layout.dart';
|
|
|
+import 'package:widgets/my_appbar.dart';
|
|
|
import 'package:widgets/my_load_image.dart';
|
|
|
import 'package:widgets/widget_export.dart';
|
|
|
|
|
|
+import 'package:intl/intl.dart';
|
|
|
+
|
|
|
import '../../../router/page/rewards_page_router.dart';
|
|
|
import './rewards_vm.dart';
|
|
|
|
|
@@ -35,8 +40,8 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Widget _buildTop(BuildContext context, WidgetRef ref, _vm) {
|
|
|
- // List itemsList = _vm.state.list.toList();
|
|
|
+ Widget _buildTop(BuildContext context, WidgetRef ref, _vm, list) {
|
|
|
+ int points = list.points ?? 0;
|
|
|
return Container(
|
|
|
decoration: BoxDecoration(
|
|
|
border: Border(
|
|
@@ -110,9 +115,9 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
width: 23,
|
|
|
height: 23,
|
|
|
).marginOnly(right: 5),
|
|
|
- const Text(
|
|
|
- '1022',
|
|
|
- style: TextStyle(
|
|
|
+ Text(
|
|
|
+ '$points',
|
|
|
+ style: const TextStyle(
|
|
|
fontSize: 15.0,
|
|
|
color: Colors.white,
|
|
|
fontWeight: FontWeight.w400), // 设置字体大小
|
|
@@ -130,6 +135,23 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
}
|
|
|
|
|
|
Widget _buildSearch(BuildContext context, WidgetRef ref, _vm, list) {
|
|
|
+ final dateFormat = DateFormat('yyyy-MM-dd');
|
|
|
+ final now = DateFormat('yyyy-MM-dd').format(DateTime.now());
|
|
|
+ // final date = list.continuous.currentWeekCheckin[0] ?? now;
|
|
|
+ final date = now;
|
|
|
+ final date0 = DateFormat('MM-dd')
|
|
|
+ .format(dateFormat.parse(date).subtract(const Duration(days: 1)));
|
|
|
+ final date1 = DateFormat('MM-dd')
|
|
|
+ .format(dateFormat.parse(date).add(const Duration(days: 1)));
|
|
|
+ final date2 = DateFormat('MM-dd')
|
|
|
+ .format(dateFormat.parse(date).add(const Duration(days: 2)));
|
|
|
+ final date3 = DateFormat('MM-dd')
|
|
|
+ .format(dateFormat.parse(date).add(const Duration(days: 3)));
|
|
|
+ final date4 = DateFormat('MM-dd')
|
|
|
+ .format(dateFormat.parse(date).add(const Duration(days: 4)));
|
|
|
+ final date5 = DateFormat('MM-dd')
|
|
|
+ .format(dateFormat.parse(date).add(const Duration(days: 5)));
|
|
|
+ // final nextDate = date.add(Duration(days: 1));
|
|
|
return Container(
|
|
|
width: MediaQuery.of(context).size.width - 30,
|
|
|
decoration: BoxDecoration(
|
|
@@ -168,7 +190,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- '11/01',
|
|
|
+ '$date0',
|
|
|
style: TextStyle(
|
|
|
fontSize: 13.0,
|
|
|
color: ColorUtils.string2Color('#4161D0'),
|
|
@@ -244,7 +266,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- 'Today',
|
|
|
+ '$date1',
|
|
|
style: TextStyle(
|
|
|
fontSize: 13.0,
|
|
|
color: ColorUtils.string2Color('#000000'),
|
|
@@ -282,7 +304,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- 'Today',
|
|
|
+ '$date2',
|
|
|
style: TextStyle(
|
|
|
fontSize: 13.0,
|
|
|
color: ColorUtils.string2Color('#000000'),
|
|
@@ -324,7 +346,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- 'Today',
|
|
|
+ '$date3',
|
|
|
style: TextStyle(
|
|
|
fontSize: 13.0,
|
|
|
color: ColorUtils.string2Color('#000000'),
|
|
@@ -362,7 +384,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- 'Today',
|
|
|
+ '$date4',
|
|
|
style: TextStyle(
|
|
|
fontSize: 13.0,
|
|
|
color: ColorUtils.string2Color('#000000'),
|
|
@@ -404,7 +426,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- 'Today',
|
|
|
+ '$date5',
|
|
|
style: TextStyle(
|
|
|
fontSize: 13.0,
|
|
|
color: ColorUtils.string2Color('#000000'),
|
|
@@ -435,7 +457,8 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget _buildSwiper(BuildContext context, WidgetRef ref, _vm) {
|
|
|
+ Widget _buildSwiper(BuildContext context, WidgetRef ref, _vm, list) {
|
|
|
+ int points = list.points ?? 0;
|
|
|
return Container(
|
|
|
// color: Colors.white,
|
|
|
height: 55,
|
|
@@ -471,7 +494,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
color: ColorUtils.string2Color('#ffffff'),
|
|
|
fontWeight: FontWeight.w400), // 设置字体大小
|
|
|
).onTap(() {
|
|
|
- RewardsHomePage.startInstance();
|
|
|
+ RewardsHomePage.startInstance(points: points);
|
|
|
}),
|
|
|
),
|
|
|
],
|
|
@@ -479,7 +502,9 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
).marginOnly(top: 12, bottom: 12);
|
|
|
}
|
|
|
|
|
|
- Widget _buildList(BuildContext context, WidgetRef ref, _vm) {
|
|
|
+ Widget _buildList(BuildContext context, WidgetRef ref, _vm, list) {
|
|
|
+ bool newsFeed = list.tasks.newsFeedPost;
|
|
|
+ int giveLikes = list.tasks.give10Likes;
|
|
|
return Container(
|
|
|
decoration: BoxDecoration(
|
|
|
color: Colors.white,
|
|
@@ -544,7 +569,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
Assets.rewardsRewardsIconJb,
|
|
|
width: 14,
|
|
|
height: 14,
|
|
|
- )
|
|
|
+ ).marginOnly(left: 3)
|
|
|
],
|
|
|
)
|
|
|
],
|
|
@@ -606,7 +631,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- 'Daily Login',
|
|
|
+ 'News Feed Post',
|
|
|
style: TextStyle(
|
|
|
fontSize: 15.0,
|
|
|
color: ColorUtils.string2Color('#000000'),
|
|
@@ -625,7 +650,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
Assets.rewardsRewardsIconJb,
|
|
|
width: 14,
|
|
|
height: 14,
|
|
|
- )
|
|
|
+ ).marginOnly(left: 3)
|
|
|
],
|
|
|
)
|
|
|
],
|
|
@@ -643,7 +668,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
),
|
|
|
child: Center(
|
|
|
child: Text(
|
|
|
- 'Check In',
|
|
|
+ newsFeed == true ? 'Completed' : 'incomplete',
|
|
|
style: TextStyle(
|
|
|
fontSize: 14.0,
|
|
|
color: ColorUtils.string2Color('#4161D0'),
|
|
@@ -687,7 +712,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
children: [
|
|
|
Text(
|
|
|
- 'Daily Login',
|
|
|
+ 'Give 10 Likes',
|
|
|
style: TextStyle(
|
|
|
fontSize: 15.0,
|
|
|
color: ColorUtils.string2Color('#000000'),
|
|
@@ -706,7 +731,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
Assets.rewardsRewardsIconJb,
|
|
|
width: 14,
|
|
|
height: 14,
|
|
|
- )
|
|
|
+ ).marginOnly(left: 3)
|
|
|
],
|
|
|
)
|
|
|
],
|
|
@@ -724,7 +749,7 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
),
|
|
|
child: Center(
|
|
|
child: Text(
|
|
|
- 'Check In',
|
|
|
+ giveLikes == 10 ? 'Completed' : '$giveLikes/10',
|
|
|
style: TextStyle(
|
|
|
fontSize: 14.0,
|
|
|
color: ColorUtils.string2Color('#4161D0'),
|
|
@@ -740,7 +765,8 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
).marginOnly(bottom: 12);
|
|
|
}
|
|
|
|
|
|
- Widget _buildHistory(BuildContext context, WidgetRef ref, _vm) {
|
|
|
+ Widget _buildHistory(BuildContext context, WidgetRef ref, _vm, list) {
|
|
|
+ List latest = list.latest;
|
|
|
return Container(
|
|
|
decoration: BoxDecoration(
|
|
|
color: Colors.white,
|
|
@@ -774,135 +800,55 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
RewardsHistoryPage.startInstance();
|
|
|
})
|
|
|
]).paddingOnly(left: 15, right: 15, top: 15, bottom: 5),
|
|
|
- Container(
|
|
|
- padding:
|
|
|
- const EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15),
|
|
|
- decoration: BoxDecoration(
|
|
|
- border: Border(
|
|
|
- bottom: BorderSide(
|
|
|
- width: 1.0, // 底边边框的宽度
|
|
|
- color: ColorUtils.string2Color('#F2F3F6'), // 底边边框的颜色
|
|
|
- ))),
|
|
|
- child: Row(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: [
|
|
|
- Text(
|
|
|
- 'Daily Login',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 15.0,
|
|
|
- color: ColorUtils.string2Color('#000000'),
|
|
|
- fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
- ).marginOnly(bottom: 6),
|
|
|
- Text(
|
|
|
- '14 Oct 2024 10:00PM',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 13.0,
|
|
|
- color: ColorUtils.string2Color('#808DAF'),
|
|
|
- fontWeight: FontWeight.w400), // 设置字体大小
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- Text(
|
|
|
- '+2',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20.0,
|
|
|
- color: ColorUtils.string2Color('#FDB429'),
|
|
|
- fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- padding:
|
|
|
- const EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15),
|
|
|
- decoration: BoxDecoration(
|
|
|
- border: Border(
|
|
|
- bottom: BorderSide(
|
|
|
- width: 1.0, // 底边边框的宽度
|
|
|
- color: ColorUtils.string2Color('#F2F3F6'), // 底边边框的颜色
|
|
|
- ))),
|
|
|
- child: Row(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: [
|
|
|
- Text(
|
|
|
- 'Daily Login',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 15.0,
|
|
|
- color: ColorUtils.string2Color('#000000'),
|
|
|
- fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
- ).marginOnly(bottom: 6),
|
|
|
- Text(
|
|
|
- '14 Oct 2024 10:00PM',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 13.0,
|
|
|
- color: ColorUtils.string2Color('#808DAF'),
|
|
|
- fontWeight: FontWeight.w400), // 设置字体大小
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- Text(
|
|
|
- '+2',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20.0,
|
|
|
- color: ColorUtils.string2Color('#FDB429'),
|
|
|
- fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- Container(
|
|
|
- padding:
|
|
|
- const EdgeInsets.only(top: 15, bottom: 15, left: 15, right: 15),
|
|
|
- decoration: BoxDecoration(
|
|
|
- border: Border(
|
|
|
- bottom: BorderSide(
|
|
|
- width: 1.0, // 底边边框的宽度
|
|
|
- color: ColorUtils.string2Color('#F2F3F6'), // 底边边框的颜色
|
|
|
- ))),
|
|
|
- child: Row(
|
|
|
+ Column(
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: [
|
|
|
- Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- mainAxisAlignment: MainAxisAlignment.center,
|
|
|
- children: [
|
|
|
- Text(
|
|
|
- 'Daily Login',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 15.0,
|
|
|
- color: ColorUtils.string2Color('#000000'),
|
|
|
- fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
- ).marginOnly(bottom: 6),
|
|
|
- Text(
|
|
|
- '14 Oct 2024 10:00PM',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 13.0,
|
|
|
- color: ColorUtils.string2Color('#808DAF'),
|
|
|
- fontWeight: FontWeight.w400), // 设置字体大小
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- Text(
|
|
|
- '+2',
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 20.0,
|
|
|
- color: ColorUtils.string2Color('#FDB429'),
|
|
|
- fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: List.generate(latest.length, (index) {
|
|
|
+ int point = latest[index]['point'];
|
|
|
+ return Container(
|
|
|
+ padding: const EdgeInsets.only(
|
|
|
+ top: 15, bottom: 15, left: 15, right: 15),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ border: Border(
|
|
|
+ bottom: BorderSide(
|
|
|
+ width: 1.0, // 底边边框的宽度
|
|
|
+ color: ColorUtils.string2Color('#F2F3F6'), // 底边边框的颜色
|
|
|
+ ))),
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
+ children: [
|
|
|
+ Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ latest[index]['short_description'],
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 15.0,
|
|
|
+ color: ColorUtils.string2Color('#000000'),
|
|
|
+ fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
+ ).marginOnly(bottom: 6),
|
|
|
+ Text(
|
|
|
+ latest[index]['created_at'],
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 13.0,
|
|
|
+ color: ColorUtils.string2Color('#808DAF'),
|
|
|
+ fontWeight: FontWeight.w400), // 设置字体大小
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Text(
|
|
|
+ "$point",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 20.0,
|
|
|
+ color: ColorUtils.string2Color('#FDB429'),
|
|
|
+ fontWeight: FontWeight.w500), // 设置字体大小
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }))
|
|
|
],
|
|
|
),
|
|
|
).marginOnly(bottom: 12);
|
|
@@ -922,37 +868,42 @@ class RewardsPage extends HookConsumerWidget {
|
|
|
};
|
|
|
}, []);
|
|
|
return Scaffold(
|
|
|
- // appBar: AppBar(title: Text("奖励")),
|
|
|
+ // appBar: MyAppBar.appBar(
|
|
|
+ // context,
|
|
|
+ // "Daily Login",
|
|
|
+ // backgroundColor: ColorUtils.string2Color('#4161D0'),
|
|
|
+ // ),
|
|
|
body: Column(children: [
|
|
|
Expanded(
|
|
|
- child:
|
|
|
- LoadStateLayout(
|
|
|
+ child: LoadStateLayout(
|
|
|
state: state.loadingState,
|
|
|
errorMessage: state.errorMessage,
|
|
|
errorRetry: () {
|
|
|
_vm.retryRequest();
|
|
|
},
|
|
|
successWidget: SingleChildScrollView(
|
|
|
- scrollDirection: Axis.vertical,
|
|
|
- physics: const BouncingScrollPhysics(),
|
|
|
- clipBehavior: Clip.none,
|
|
|
- child: Column(
|
|
|
+ scrollDirection: Axis.vertical,
|
|
|
+ physics: const BouncingScrollPhysics(),
|
|
|
+ clipBehavior: Clip.none,
|
|
|
+ child: Column(
|
|
|
children: [
|
|
|
- _buildTop(context, ref, _vm),
|
|
|
+ _buildTop(context, ref, _vm, list)
|
|
|
+ .paddingOnly(top: MediaQuery.of(context).padding.top),
|
|
|
Container(
|
|
|
transform: Matrix4.translationValues(0.0, -45.0, 0.0),
|
|
|
child: Column(
|
|
|
children: [
|
|
|
_buildSearch(context, ref, _vm, list),
|
|
|
- _buildSwiper(context, ref, _vm),
|
|
|
- _buildList(context, ref, _vm),
|
|
|
- _buildHistory(context, ref, _vm),
|
|
|
+ _buildSwiper(context, ref, _vm, list),
|
|
|
+ list?.points != 0
|
|
|
+ ? _buildList(context, ref, _vm, list)
|
|
|
+ : const SizedBox.shrink(),
|
|
|
+ _buildHistory(context, ref, _vm, list),
|
|
|
],
|
|
|
), // 使用负数margin
|
|
|
).paddingOnly(left: 15, right: 15),
|
|
|
],
|
|
|
- )
|
|
|
- ),
|
|
|
+ )),
|
|
|
),
|
|
|
),
|
|
|
]).backgroundColor(ColorUtils.string2Color('#F2F3F6')),
|