提交 74e379ca authored 作者: yueweilu's avatar yueweilu

调试接口

上级 7726d3a0
......@@ -2,7 +2,8 @@ part of apis;
abstract class AccountAPI {
/// 登录
/// 1、登录
///
static Future <UserModel> login({
required String phone,
required String type,
......@@ -37,7 +38,8 @@ abstract class AccountAPI {
return UserModel.fromJson(result.data);
}
/// 退出登录
/// 2、退出登录
///
static Future logout() async{
final result = await HttpService.to.post(
'/v1/members/login/logout',
......@@ -49,7 +51,8 @@ abstract class AccountAPI {
return false;
}
/// 注销
/// 3、注销
///
static Future delete() async{
final result = await HttpService.to.post(
'/v1/members/login/del',
......@@ -61,7 +64,8 @@ abstract class AccountAPI {
return false;
}
/// 发送验证码
/// 4、发送验证码
///
static Future sendCode({
required String phone,
required String type,
......@@ -81,7 +85,8 @@ abstract class AccountAPI {
return false;
}
/// 重置密码
/// 5、重置密码
///
static Future resetPassword({
required String phone,
required String code,
......
part of apis;
abstract class CommonAPI {
/// 1、广告位接口
///
static Future <List<AdModel>> list({
required String type,
}) async {
final result = await HttpService.to.post(
'/v1/ad/ad/getListAll',
params: {
'type': type,
},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return AdModel.fromJson(result.data['list'][index]);
});
}
/// 2、消息接口
///
static Future <List<MsgModel>> msgs({
int page = 1,
int limit = 10,
}) async {
final result = await HttpService.to.post(
'/v1/message/Message/getList',
params: {
'currentPage': page,
'pageSize': limit,
},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return MsgModel.fromJson(result.data['list'][index]);
});
}
/// 3、消息未读数
///
static Future <int> num() async {
final result = await HttpService.to.post(
'/v1/message/Message/getMessageNums',
params: {},
);
if (result.data is! Map ) return 0;
return result.data['num'];
}
/// 4、最近学习
///
static Future <List<StudyHistoryModel>> history({
int page = 1,
int limit = 10,
}) async {
final result = await HttpService.to.post(
'/v1/members/Information/myReadRecord',
params: {
'currentPage': page,
'pageSize': limit,
},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return StudyHistoryModel.fromJson(result.data['list'][index]);
});
}
/// 5、消息未读变已读
///
static Future <bool> read({
required String id
}) async {
final result = await HttpService.to.post(
'/v1/message/Message/editOneStatus',
params: {
'id':id
},
);
if (result.data is Map && result.data['is_success'] == 1){
return true;
}
return false;
}
}
\ No newline at end of file
......@@ -2,7 +2,8 @@ part of apis;
abstract class CourseAPI {
/// 获取课程 内书籍列表
/// 1、获取课程 内书籍列表
///
static Future <List<CourseModel>> list({
int page = 1,
int limit = 20,
......
library apis;
import 'dart:io';
import 'package:flutter_book/models/course.dart';
import 'package:flutter_book/store/index.dart';
import '../models/user_model.dart';
import '../models/index.dart';
import '../services/index.dart';
part 'account.dart';
part 'mine.dart';
part 'course.dart';
\ No newline at end of file
part 'course.dart';
part 'common.dart';
part 'library.dart';
part 'shop.dart';
\ No newline at end of file
part of apis;
\ No newline at end of file
part of apis;
\ No newline at end of file
part of models;
/// pic : "1.jpg"
/// url : "http://www.baidu.com"
class AdModel {
AdModel({
this.pic,
this.url,});
AdModel.fromJson(dynamic json) {
pic = json['pic'];
url = json['url'];
}
String? pic;
String? url;
AdModel copyWith({ String? pic,
String? url,
}) => AdModel( pic: pic ?? this.pic,
url: url ?? this.url,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['pic'] = pic;
map['url'] = url;
return map;
}
}
\ No newline at end of file
part of models;
/// book_id : 2
/// book_name : "五禽戏"
/// authors : "华佗"
......@@ -11,6 +13,9 @@ class CourseModel {
this.authors,
this.img,
this.progress,
this.lastChapter,
this.createTime,
this.days
});
CourseModel.fromJson(dynamic json) {
......@@ -19,12 +24,18 @@ class CourseModel {
authors = json['authors'];
img = json['img'];
progress = json['progress'];
lastChapter = json['lastChapter'];
createTime = json['create_time'];
days = json['days'];
}
num? bookId;
String? bookName;
String? authors;
String? img;
String? progress;
String? lastChapter;
String? createTime;
String? days;
int get type {
if (progress == '0.00%'){
......@@ -51,11 +62,17 @@ class CourseModel {
String? authors,
String? img,
String? progress,
String? lastChapter,
String? createTime,
String? days,
}) => CourseModel( bookId: bookId ?? this.bookId,
bookName: bookName ?? this.bookName,
authors: authors ?? this.authors,
img: img ?? this.img,
progress: progress ?? this.progress,
lastChapter: lastChapter ?? this.lastChapter,
createTime: createTime ?? this.createTime,
days: days ?? this.days,
);
Map<String, dynamic> toJson() {
......@@ -65,6 +82,9 @@ class CourseModel {
map['authors'] = authors;
map['img'] = img;
map['progress'] = progress;
map['lastChapter'] = lastChapter;
map['create_time'] = createTime;
map['days'] = days;
return map;
}
......
library models;
part 'response.dart';
\ No newline at end of file
part 'response.dart';
part 'course.dart';
part 'ad_model.dart';
part 'user_model.dart';
part 'msg.dart';
part 'study_history.dart';
\ No newline at end of file
part of models;
/// type : 1
/// title : "系统通知"
/// content : "v2.0上线了"
/// status : 0
/// url_id : 0
/// create_time : "2021-09-16 14:01:19"
class MsgModel {
MsgModel({
this.id,
this.type,
this.title,
this.content,
this.status,
this.urlId,
this.createTime,});
MsgModel.fromJson(dynamic json) {
id = json['id'];
type = json['type'];
title = json['title'];
content = json['content'];
status = json['status'];
urlId = json['url_id'];
createTime = json['create_time'];
}
num? id;
num? type;
String? title;
String? content;
num? status;
num? urlId;
String? createTime;
MsgModel copyWith({
num? id,
num? type,
String? title,
String? content,
num? status,
num? urlId,
String? createTime,
}) => MsgModel(
id: id ?? this.id,
type: type ?? this.type,
title: title ?? this.title,
content: content ?? this.content,
status: status ?? this.status,
urlId: urlId ?? this.urlId,
createTime: createTime ?? this.createTime,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = id;
map['type'] = type;
map['title'] = title;
map['content'] = content;
map['status'] = status;
map['url_id'] = urlId;
map['create_time'] = createTime;
return map;
}
}
\ No newline at end of file
part of models;
class StudyHistoryModel {
StudyHistoryModel({
this.time,
this.courses,
});
StudyHistoryModel.fromJson(dynamic json) {
time = json['time'];
courses = List.generate(json['list'].length, (index) => CourseModel.fromJson(index));
}
String? time;
List<CourseModel>? courses;
}
\ No newline at end of file
part of models;
/// members_id : 1
/// name : "555555"
/// password : "637641045c830d80190da7b94f69c2cd"
......
......@@ -3,7 +3,13 @@ part of course;
class CourseController extends GetxController {
// 课程数组
List<CourseModel> courses = [];
// 消息数组
List<AdModel> ads = [];
// 消息未读数
int num = 0;
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
......@@ -14,6 +20,12 @@ class CourseController extends GetxController {
int _page = 1;
bool _noMore = false;
@override
void onReady() {
_getAds();
getNums();
super.onReady();
}
@override
void onClose() {
......@@ -21,14 +33,28 @@ class CourseController extends GetxController {
super.onClose();
}
/// 获取广告数据
void _getAds() async {
ads = await CommonAPI.list(type: '2');
update();
}
/// 消息未读数
void getNums() async {
num = await CommonAPI.num();
update();
}
/// 获取课程内图书列表
Future<void> _getCourse([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
/// 网路请求
// 网路请求
final result = await CourseAPI.list(
page: _page,
limit: _limit
);
/// 如果是刷新 清理数据
// 如果是刷新 清理数据
if (isRefresh) courses.clear();
courses.addAll(result);
_page ++;
......
......@@ -5,15 +5,14 @@ import 'dart:math';
import 'package:carousel_slider/carousel_slider.dart';
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book/models/course.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:go_router/go_router.dart';
import 'package:ionicons/ionicons.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
import '../../routes/index.dart';
import '../../store/index.dart';
import '../../utils/index.dart';
......
......@@ -35,13 +35,17 @@ class _CoursePageState extends State<CoursePage> {
onPressed: () => context.pushNamed(Routes.studyHistory),
),
GestureDetector(
onTap: (){
context.pushNamed(Routes.msgs);
onTap: () async{
final result = await context.pushNamed(Routes.msgs);
if (result == true) {
controller.getNums();
}
// controller.logout(context);
},
child: badges.Badge(
position: badges.BadgePosition.topEnd(top: -5, end: 0),
badgeContent: const Text('10',style: TextStyle(fontSize: 7,color: Colors.white),),
showBadge: controller.num == 0?false:true,
badgeContent: Text(controller.num.toString(),style: const TextStyle(fontSize: 7,color: Colors.white),),
badgeStyle: const badges.BadgeStyle(
badgeColor: AppTheme.primary,
shape: badges.BadgeShape.circle
......@@ -56,23 +60,18 @@ class _CoursePageState extends State<CoursePage> {
),
),
)
// CustomButton.icon(
// padding: EdgeInsets.zero,
// backgroundColor: Colors.transparent,
// icon: const Icon(Ionicons.notifications),
// onPressed: () => context.pushNamed(Routes.msgs),
// ),
],
),
body:Container(
color: const Color(0xFFF9F9F9),
child: Column(
children: [
controller.ads.isNotEmpty?
Container(
color: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 10),
child: const BuildBanner(items: ['111','222','333'],),
),
padding: const EdgeInsets.symmetric(horizontal: 10),
child: BuildBanner(items:controller.ads),
):const SizedBox(),
Expanded(
child: CustomPullScrollView(
controller: controller.refreshController,
......
part of course;
class BuildBanner extends StatelessWidget {
final List items;
final List <AdModel>items;
const BuildBanner({
Key? key,
this.items = const [],
......@@ -39,7 +39,7 @@ class BuildBanner extends StatelessWidget {
),
child: Text('$item'),
child: Image.network(item.pic??''),
// child: CustomImage.asset(
// url: 'assets/images/banner.png',
// width: 130.w,
......
......@@ -37,7 +37,7 @@ class _LibraryContentPageState extends State<LibraryContentPage> {
Container(
color: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 10),
child: const BuildBanner(items: ['111','222','333'],),
// child: const BuildBanner(items: ['111','222','333'],),
),
])
)
......
......@@ -14,11 +14,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:go_router/go_router.dart';
import 'package:ionicons/ionicons.dart';
import '../../models/user_model.dart';
import '../../routes/index.dart';
import '../../services/index.dart';
import '../../widgets/index.dart';
......
library main;
import 'package:flutter/material.dart';
import 'package:flutter_book/pages/home/index.dart';
import 'package:flutter_book/pages/library/index.dart';
import 'package:flutter_book/pages/mine/index.dart';
import 'package:flutter_book/theme.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import 'package:ionicons/ionicons.dart';
import '../../routes/index.dart';
import '../../store/index.dart';
import '../../widgets/index.dart';
import '../book_shop/index.dart';
import '../course/index.dart';
import '../record/index.dart';
import '../tts/index.dart';
import '../web/index.dart';
part 'view.dart';
......
......@@ -4,4 +4,30 @@ part of mine;
class MineController extends GetxController {
List<AdModel> ads = [];
// 消息未读数
int num = 0;
@override
void onReady() {
_getAds();
_getNums();
super.onReady();
}
/// 获取广告数据
void _getAds() async {
ads = await CommonAPI.list(type: '4');
update();
}
/// 消息未读数
void _getNums() async {
num = await CommonAPI.num();
update();
}
}
\ No newline at end of file
......@@ -9,10 +9,12 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:go_router/go_router.dart';
import 'package:ionicons/ionicons.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
import '../../routes/index.dart';
import '../course/index.dart';
import 'package:badges/badges.dart' as badges;
part 'view.dart';
part 'controller.dart';
......
......@@ -33,14 +33,29 @@ class _MinePageState extends State<MinePage> {
),
onPressed: () => context.pushNamed(Routes.msgs),
),
CustomButton.icon(
padding: EdgeInsets.zero,
backgroundColor: Colors.transparent,
icon: Image.asset(
'assets/images/msg_black.png',
GestureDetector(
onTap: (){
context.pushNamed(Routes.msgs);
// controller.logout(context);
},
child: badges.Badge(
position: badges.BadgePosition.topEnd(top: -5, end: 0),
showBadge: controller.num == 0?false:true,
badgeContent: Text(controller.num.toString(),style: const TextStyle(fontSize: 7,color: Colors.white),),
badgeStyle: const badges.BadgeStyle(
badgeColor: AppTheme.primary,
shape: badges.BadgeShape.circle
),
child: CustomButton.icon(
padding: EdgeInsets.zero,
backgroundColor: Colors.transparent,
icon: Image.asset(
'assets/images/msg_black.png',
),
// onPressed: () => context.pushNamed(Routes.msgs),
),
),
onPressed: () => context.pushNamed(Routes.msgs),
),
)
],
),
body: SingleChildScrollView(
......@@ -53,8 +68,13 @@ class _MinePageState extends State<MinePage> {
},),
Gaps.vGaps10,
BuildRead(items: ['1','2','3','4'],),
Gaps.vGaps10,
BuildBanner(items: ['111','222','333'],),
controller.ads.isNotEmpty?Gaps.vGaps10:SizedBox(),
controller.ads.isNotEmpty?
Container(
color: Colors.transparent,
padding: const EdgeInsets.symmetric(horizontal: 10),
child: BuildBanner(items:controller.ads),
):const SizedBox(),
Gaps.vGaps10,
BuildAccount(items: ['1','11','紫荆币','1111'],),
Gaps.vGaps10,
......
part of study_history;
\ No newline at end of file
part of study_history;
class HistoryController extends GetxController {
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
controlFinishRefresh: true,
);
// 学习历史数组
List<StudyHistoryModel> histories = [];
final int _limit = 10;
int _page = 1;
bool _noMore = false;
@override
void onClose() {
refreshController.dispose();
super.onClose();
}
/// 获取 最近学习数据
Future<void> _getHistory([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await CommonAPI.history(
page: _page,
limit: _limit
);
print('11111111111111111111111111$result');
// 如果是刷新 清理数据
if (isRefresh) histories.clear();
histories.addAll(result);
_page ++;
_noMore = result.length < _limit;
update();
}
void onRefresh() async {
try {
await _getHistory(true);
refreshController.finishRefresh(IndicatorResult.success);
refreshController.resetFooter();
} catch (error) {
refreshController.finishRefresh(IndicatorResult.fail);
}
}
void onLoading() async {
if (_noMore) {
refreshController.finishLoad(IndicatorResult.noMore);
return;
}
try {
await _getHistory();
refreshController.finishLoad();
} catch (error) {
refreshController.finishLoad(IndicatorResult.fail);
}
}
}
\ No newline at end of file
......@@ -2,10 +2,15 @@ library study_history;
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:get/get.dart';
import '../../models/index.dart';
import '../../theme.dart';
import '../../utils/index.dart';
import '../../widgets/index.dart';
part 'view.dart';
......
......@@ -10,16 +10,24 @@ class StudyHistoryPage extends StatefulWidget {
class _StudyHistoryPageState extends State<StudyHistoryPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('最近学习'),
),
body: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return BuildDayItem();
},
itemCount: 4,
return GetBuilder<HistoryController>(
init: HistoryController(),
builder:(controller) => Scaffold(
appBar: AppBar(
centerTitle: true,
title: const Text('最近学习'),
),
body: CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: ListView.builder(
itemBuilder: (BuildContext context, int index) {
return BuildDayItem();
},
itemCount: 4,
),
),
),
);
}
......
......@@ -6,8 +6,7 @@ class BuildDayItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
// height: 300,
margin: EdgeInsets.only(left: 10,top: 10,right: 10),
margin: const EdgeInsets.only(left: 10,top: 10,right: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
boxShadow: [
......@@ -24,8 +23,14 @@ class BuildDayItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
decoration: const BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
topRight: Radius.circular(8.0),
),
color: Colors.cyan,
),
height: 32,
color: Colors.cyan,
alignment: Alignment.centerLeft,
child: Text('今天',style: TextStyle(fontSize: 13,height: 1.4,color: Colours.c6),),
),
......@@ -44,7 +49,7 @@ class BuildDayItem extends StatelessWidget {
Widget _buildItem(){
return Container(
margin: EdgeInsets.only(left: 10,right: 10),
margin: const EdgeInsets.only(left: 10,right: 10),
child: Column(
children: [
Container(
......@@ -52,30 +57,48 @@ class BuildDayItem extends StatelessWidget {
height: 2,
),
Container(
margin: EdgeInsets.only(top: 11.5,bottom: 14.5),
margin: const EdgeInsets.only(top: 11.5,bottom: 14.5),
// color: Colors.yellow,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: 72,
height: 87,
color: Colors.red,
),
Column(
children: [
Text('从现在开始,为精彩活过一百',style: TextStyle(fontSize: 14,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),maxLines: 1,overflow: TextOverflow.ellipsis,),
Text('李白',style: TextStyle(fontSize: 12,height: 1.4,color: Colours.c6),),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expanded(
child: Container(
// color: Colors.green,
padding: const EdgeInsets.only(top: 2.5,left: 13),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
color: Colors.cyan,
padding: const EdgeInsets.symmetric(horizontal: 3.5),
child: const Text('未学习',style: TextStyle(fontSize: 11,height: 1.3,color: Colours.c9),),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('从现在开始,为精彩活过一百',style: TextStyle(fontSize: 14,height: 1.5,fontWeight: Fonts.medium,color: Colours.c3),maxLines: 1,overflow: TextOverflow.ellipsis,),
Gaps.vGaps5,
Text('李白',style: TextStyle(fontSize: 12,height: 1.4,color: Colours.c6),),
],
),
const Text('继续学习',style: TextStyle(fontSize: 11,height: 1.3,color: AppTheme.primary),)
Gaps.vGaps25,
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
color: Colors.cyan,
padding: const EdgeInsets.symmetric(horizontal: 3.5),
child: const Text('未学习',style: TextStyle(fontSize: 11,height: 1.3,color: Colours.c9),),
),
// Spacer(),
const Text('继续学习',style: TextStyle(fontSize: 11,height: 1.3,color: AppTheme.primary),)
],
)
],
)
],
),
),
)
],
),
......
part of user_msg;
class MsgController extends GetxController {
List<MsgModel> msgs = [];
final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true,
controlFinishRefresh: true,
);
final int _limit = 20;
int _page = 1;
bool _noMore = false;
@override
void onClose() {
refreshController.dispose();
super.onClose();
}
/// 消息未读变已读
Future<bool> read(String id) async {
bool result = await CommonAPI.read(id: id);
return result;
}
/// 获取课程内图书列表
Future<void> _getMsgs([bool isRefresh = false]) async {
if (isRefresh) _page = 1;
// 网路请求
final result = await CommonAPI.msgs(
page: _page,
limit: _limit
);
// 如果是刷新 清理数据
if (isRefresh) msgs.clear();
msgs.addAll(result);
_page ++;
_noMore = result.length < _limit;
update();
}
void onRefresh() async {
try {
await _getMsgs(true);
refreshController.finishRefresh(IndicatorResult.success);
refreshController.resetFooter();
} catch (error) {
refreshController.finishRefresh(IndicatorResult.fail);
}
}
void onLoading() async {
if (_noMore) {
refreshController.finishLoad(IndicatorResult.noMore);
return;
}
try {
await _getMsgs();
refreshController.finishLoad();
} catch (error) {
refreshController.finishLoad(IndicatorResult.fail);
}
}
}
\ No newline at end of file
library user_msg;
import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:flutter_book/models/index.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
import '../../routes/index.dart';
import '../../theme.dart';
import '../../utils/index.dart';
import 'package:badges/badges.dart' as badges;
import '../../widgets/index.dart';
part 'view.dart';
part 'widgets/item.dart';
\ No newline at end of file
part 'widgets/item.dart';
part 'controller.dart';
\ No newline at end of file
......@@ -3,20 +3,45 @@ part of user_msg;
class MsgPage extends StatelessWidget {
const MsgPage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('消息中心'),
centerTitle: true,
),
body: Container(
color: Colours.cF9,
child: ListView.builder(
itemBuilder: (BuildContext context, int index){
return BuildItem();
},
itemCount: 5,
return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: GetBuilder<MsgController>(
init: MsgController(),
builder:(controller) => Scaffold(
appBar: AppBar(
title: const Text('消息中心'),
centerTitle: true,
),
body: Container(
color: Colours.cF9,
child: CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
child: ListView.builder(
itemBuilder: (BuildContext context, int index){
return GestureDetector(
child: BuildItem(model: controller.msgs[index],),
onTap: () async{
controller.read(controller.msgs[index].id.toString());
final result = await context.pushNamed(Routes.coin);
if (result == true){
controller.onRefresh();
}
},
);
},
itemCount: controller.msgs.length,
),
),
),
),
),
);
......
part of user_msg;
class BuildItem extends StatelessWidget {
const BuildItem({Key? key}) : super(key: key);
final MsgModel model;
const BuildItem({
Key? key,
required this.model
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(left: 10,right: 10,top:10),
padding: EdgeInsets.symmetric(horizontal: 10,vertical: 10),
padding: const EdgeInsets.symmetric(horizontal: 10,vertical: 10),
height: 75,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
......@@ -17,6 +21,7 @@ class BuildItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
badges.Badge(
showBadge: model.status == 1?false: true,
position: badges.BadgePosition.topEnd(top: 0, end: 0),
badgeStyle: const badges.BadgeStyle(
badgeColor: AppTheme.primary,
......@@ -36,18 +41,18 @@ class BuildItem extends StatelessWidget {
),
Gaps.hGaps10,
Expanded(
child: const Column(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('积分过期提醒',style: TextStyle(fontSize: 15,height: 1.4,fontWeight: Fonts.medium,color: Colours.c3),),
Text('2023-12-12',style: TextStyle(fontSize:11,height: 1.4,color: Colours.c9))
Text(model.title??'',style: const TextStyle(fontSize: 15,height: 1.4,fontWeight: Fonts.medium,color: Colours.c3),),
Text(model.createTime??'',style: const TextStyle(fontSize:11,height: 1.4,color: Colours.c9))
],
),
Gaps.vGaps5,
Text('您有2000积分即将过期。',style: TextStyle(fontSize: 13,height: 1.4,color: Colours.c6),)
Text(model.content??'',style: const TextStyle(fontSize: 13,height: 1.4,color: Colours.c6),)
],
),
)
......
......@@ -7,7 +7,7 @@ import 'package:flutter_book/services/index.dart';
import 'package:flutter_book/theme.dart';
import 'package:get/get.dart';
import '../models/user_model.dart';
import '../models/index.dart';
import '../utils/index.dart';
part 'config.dart';
......
......@@ -45,6 +45,7 @@ class Gaps {
static const Widget vGaps10 = SizedBox(height: 10,);
static const Widget vGaps13 = SizedBox(height: 13,);
static const Widget vGaps15 = SizedBox(height: 15,);
static const Widget vGaps25 = SizedBox(height: 25,);
static const Widget vGaps40 = SizedBox(height: 40,);
// static const Widget line = Padding(
// padding: EdgeInsets.symmetric(horizontal: 15.0),
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论