提交 11406f8d authored 作者: yueweilu's avatar yueweilu

学习报告数据绑定

上级 5aa4ad33
...@@ -4,5 +4,5 @@ keyPassword=123456 ...@@ -4,5 +4,5 @@ keyPassword=123456
keyAlias=zijing keyAlias=zijing
#storeFile=/Users/apple/zijiing_key.jks storeFile=/Users/apple/zijiing_key.jks
storeFile=zijiing_key.jks #storeFile=zijiing_key.jks
\ No newline at end of file \ No newline at end of file
...@@ -34,6 +34,7 @@ abstract class CommonAPI { ...@@ -34,6 +34,7 @@ abstract class CommonAPI {
); );
if (result.data is! Map && result.data['list'] is! List) return []; if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){ return List.generate(result.data['list'].length, (index){
print(result.data['list'][index]);
return MsgModel.fromJson(result.data['list'][index]); return MsgModel.fromJson(result.data['list'][index]);
}); });
} }
......
...@@ -98,7 +98,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid ...@@ -98,7 +98,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: (){ onTap: (){
context.pushNamed(Routes.studyReport); context.pushNamed(Routes.studyReport,queryParameters: {'book_id':widget.bookId});
}, },
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
......
...@@ -60,12 +60,23 @@ class LoginController extends GetxController { ...@@ -60,12 +60,23 @@ class LoginController extends GetxController {
} }
void setCanClick(){ void setCanClick(){
if (loginType == 0){
if (ValidatorTool.isValidPhoneNumber(phoneInput.text) && ValidatorTool.isValidPassword(passwordInput.text)){ if (ValidatorTool.isValidPhoneNumber(phoneInput.text) && ValidatorTool.isValidPassword(passwordInput.text)){
_enable = true; _enable = true;
} }
else{ else{
_enable = false; _enable = false;
} }
}
else {
if (ValidatorTool.isValidPhoneNumber(phoneInput.text) && ValidatorTool.isValidCode(codeInput.text)){
_enable = true;
}
else{
_enable = false;
}
}
update(); update();
} }
...@@ -144,6 +155,10 @@ class LoginController extends GetxController { ...@@ -144,6 +155,10 @@ class LoginController extends GetxController {
} }
void sendCode() async { void sendCode() async {
if (!agree) {
Toast.show('请先阅读并同意《用户协议》和《隐私政策》');
return;
}
final result = await AccountAPI.sendCode(phone: phoneInput.text, type: 'login'); final result = await AccountAPI.sendCode(phone: phoneInput.text, type: 'login');
if (result){ if (result){
Toast.show('发送成功'); Toast.show('发送成功');
......
...@@ -113,6 +113,9 @@ class _LoginPageState extends State<LoginPage> { ...@@ -113,6 +113,9 @@ class _LoginPageState extends State<LoginPage> {
hintText: '请输入验证码', hintText: '请输入验证码',
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
controller: controller.codeInput, controller: controller.codeInput,
onChanged: (text){
controller.setCanClick();
},
), ),
Positioned( Positioned(
right: 10.w, right: 10.w,
......
part of study_report;
class StudyReportController extends GetxController {
final String bookId;
StudyReportController(this.bookId);
ReportModel model = ReportModel();
@override
void onReady() {
_getReport();
super.onReady();
}
void _getReport() async {
model = await LibraryAPI.report(bookId: bookId);
update();
}
}
\ No newline at end of file
library study_report; library study_report;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:flutter_book/utils/index.dart'; import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:get/get_state_manager/src/simple/get_state.dart';
import '../../models/index.dart';
part 'view.dart'; part 'view.dart';
part 'widgets/card.dart'; part 'widgets/card.dart';
part 'controller.dart';
\ No newline at end of file
part of study_report; part of study_report;
class StudyReportPage extends StatefulWidget { class StudyReportPage extends StatefulWidget {
const StudyReportPage({Key? key}) : super(key: key); final String bookId;
const StudyReportPage({
Key? key,
required this.bookId
}) : super(key: key);
@override @override
State<StudyReportPage> createState() => _StudyReportPageState(); State<StudyReportPage> createState() => _StudyReportPageState();
...@@ -9,10 +13,11 @@ class StudyReportPage extends StatefulWidget { ...@@ -9,10 +13,11 @@ class StudyReportPage extends StatefulWidget {
class _StudyReportPageState extends State<StudyReportPage> { class _StudyReportPageState extends State<StudyReportPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return GetBuilder<StudyReportController>(
init: StudyReportController(widget.bookId),
builder:(controller) => Scaffold(
appBar: AppBar( appBar: AppBar(
centerTitle: true, centerTitle: true,
title: const Text('学习报告'), title: const Text('学习报告'),
...@@ -22,15 +27,7 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -22,15 +27,7 @@ class _StudyReportPageState extends State<StudyReportPage> {
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
children: [ children: [
BuildCard(), BuildCard(model: controller.model,),
// Container(
// // height: 210,
// // width: 355,
// // color: Colors.cyan,
// child: Image.asset(
// 'assets/images/report_bg.png',
// ),
// ),
Gaps.vGaps10, Gaps.vGaps10,
Row( Row(
children: [ children: [
...@@ -41,7 +38,7 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -41,7 +38,7 @@ class _StudyReportPageState extends State<StudyReportPage> {
padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w), padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
color: Colors.yellow, color: Colors.white,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colours.cC7.withOpacity(0.5), color: Colours.cC7.withOpacity(0.5),
...@@ -59,12 +56,24 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -59,12 +56,24 @@ class _StudyReportPageState extends State<StudyReportPage> {
Container( Container(
width: 26.w, width: 26.w,
height: 26.w, height: 26.w,
color: Colors.cyan, // color: Colors.cyan,
child: Image.asset('assets/images/report_note.png'),
), ),
Gaps.hGaps10, Gaps.hGaps10,
Text('笔记',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),) Text('笔记',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),)
], ],
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildItem(title: '划线', num: controller.model.lineNums.toString()),
_buildItem(title: '高亮', num: controller.model.colorNums.toString()),
_buildItem(title: '笔记', num: controller.model.noteNums.toString()),
],
),
) )
], ],
), ),
...@@ -74,7 +83,7 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -74,7 +83,7 @@ class _StudyReportPageState extends State<StudyReportPage> {
padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w), padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
color: Colors.red, color: Colors.white,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colours.cC7.withOpacity(0.5), color: Colours.cC7.withOpacity(0.5),
...@@ -86,19 +95,28 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -86,19 +95,28 @@ class _StudyReportPageState extends State<StudyReportPage> {
), ),
height: 110.w, height: 110.w,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
children: [ children: [
Container( Container(
width: 26.w, width: 26.w,
height: 26.w, height: 26.w,
color: Colors.cyan, child: Image.asset('assets/images/report_study.png')
// color: Colors.cyan,
), ),
Gaps.hGaps10, Gaps.hGaps10,
Text('距离连续学习',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),) Text('距离连续学习',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),)
], ],
) ),
Gaps.vGaps5,
RichText(text: TextSpan(
children: [
TextSpan(text: controller.model.maxSecond!=null?controller.model.maxSecond.toString():'',style: TextStyle(fontSize: 21.w,height: 1.5,color: Colours.c3,fontWeight: Fonts.medium)),
TextSpan(text: '分钟',style: TextStyle(fontSize: 13.w,height: 1.5,color: Colours.c3)),
]
))
], ],
), ),
) )
...@@ -111,11 +129,11 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -111,11 +129,11 @@ class _StudyReportPageState extends State<StudyReportPage> {
child: Column( child: Column(
children: [ children: [
Container( Container(
padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w), padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w,right: 30),
height: 165, height: 165,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
color: Colors.cyan, color: Colors.white,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colours.cC7.withOpacity(0.5), color: Colours.cC7.withOpacity(0.5),
...@@ -132,12 +150,50 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -132,12 +150,50 @@ class _StudyReportPageState extends State<StudyReportPage> {
Container( Container(
width: 26.w, width: 26.w,
height: 26.w, height: 26.w,
color: Colors.cyan, child: Image.asset('assets/images/report_test.png')
// color: Colors.cyan,
), ),
Gaps.hGaps10, Gaps.hGaps10,
Text('知识测评',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),) Text('知识测评',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),)
], ],
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: 80.w,
child: Text('总回顾',style: TextStyle(fontSize: 14.w,height: 1.5,color: Colours.c9),),
),
RichText(text: TextSpan(
children: [
TextSpan(text:controller.model.questionAllNums !=null? controller.model.questionAllNums.toString():'' ,style: TextStyle(fontSize: 21.w,height: 1.5,color: Colours.c3,fontWeight: Fonts.medium)),
TextSpan(text: '/条',style: TextStyle(fontSize: 13.w,height: 1.5,color: Colours.c3)),
]
))
],
),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: 80.w,
child: Text('评论正确率',style: TextStyle(fontSize: 14.w,height: 1.5,color: Colours.c9),),
),
RichText(text: TextSpan(
children: [
TextSpan(text:controller.model.questionAccuracy!=null?controller.model.questionAccuracy.toString():'' ,style: TextStyle(fontSize: 21.w,height: 1.5,color: Colours.c3,fontWeight: Fonts.medium)),
TextSpan(text: '%',style: TextStyle(fontSize: 13.w,height: 1.5,color: Colours.c3)),
]
))
],
),
],
)
) )
], ],
), ),
...@@ -147,7 +203,7 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -147,7 +203,7 @@ class _StudyReportPageState extends State<StudyReportPage> {
padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w), padding: EdgeInsets.only(left: 15.w,top: 15.w,bottom: 15.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.w), borderRadius: BorderRadius.circular(8.w),
color: Colors.green, color: Colors.white,
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Colours.cC7.withOpacity(0.5), color: Colours.cC7.withOpacity(0.5),
...@@ -165,12 +221,22 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -165,12 +221,22 @@ class _StudyReportPageState extends State<StudyReportPage> {
Container( Container(
width: 26.w, width: 26.w,
height: 26.w, height: 26.w,
color: Colors.cyan, // color: Colors.cyan,
child: Image.asset('assets/images/report_discuss.png')
), ),
Gaps.hGaps10, Gaps.hGaps10,
Text('讨论',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),) Text('讨论',style: TextStyle(fontSize: 16.w,height: 1.3,color: Colours.c3,fontWeight: Fonts.medium),)
], ],
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildItem(title: '发起讨论', num: controller.model.commentPostNums.toString()),
_buildItem(title: '参与讨论', num: controller.model.commentReplyNums.toString())
],
),
) )
], ],
), ),
...@@ -185,6 +251,25 @@ class _StudyReportPageState extends State<StudyReportPage> { ...@@ -185,6 +251,25 @@ class _StudyReportPageState extends State<StudyReportPage> {
), ),
), ),
), ),
),
);
}
Widget _buildItem({
required String title,
required String num
}){
return Row(
children: [
Text(title,style: TextStyle(fontSize: 14.w,height: 1.5,color: Colours.c9),),
Gaps.hGaps5,
RichText(text: TextSpan(
children: [
TextSpan(text: num=='null'?'':num,style: TextStyle(fontSize: 21.w,height: 1.5,color: Colours.c3,fontWeight: Fonts.medium)),
TextSpan(text: '/条',style: TextStyle(fontSize: 13.w,height: 1.5,color: Colours.c3)),
]
))
],
); );
} }
......
part of study_report; part of study_report;
class BuildCard extends StatelessWidget { class BuildCard extends StatelessWidget {
const BuildCard({Key? key}) : super(key: key); final ReportModel model;
const BuildCard({
Key? key,
required this.model
}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
...@@ -29,13 +33,13 @@ class BuildCard extends StatelessWidget { ...@@ -29,13 +33,13 @@ class BuildCard extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text('恰如其分的孤独',style: TextStyle(fontSize: 20.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),), Text(model.bookName??'',style: TextStyle(fontSize: 20.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),),
Gaps.vGaps15, Gaps.vGaps15,
Row( Row(
children: [ children: [
Text('学习总进度',style: TextStyle(fontSize: 13.w,height: 1.4,color: Colors.white),), Text('学习总进度',style: TextStyle(fontSize: 13.w,height: 1.4,color: Colors.white),),
Gaps.hGaps15, Gaps.hGaps15,
Text('4.98%',style: TextStyle(fontSize: 16.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),), Text(model.progress??'',style: TextStyle(fontSize: 16.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),),
] ]
), ),
Gaps.vGaps10, Gaps.vGaps10,
...@@ -43,20 +47,20 @@ class BuildCard extends StatelessWidget { ...@@ -43,20 +47,20 @@ class BuildCard extends StatelessWidget {
children: [ children: [
Text('学习总时长',style: TextStyle(fontSize: 13.w,height: 1.4,color: Colors.white),), Text('学习总时长',style: TextStyle(fontSize: 13.w,height: 1.4,color: Colors.white),),
Gaps.hGaps15, Gaps.hGaps15,
Text('30分钟',style: TextStyle(fontSize: 16.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),), Text('${model.readSecond??''}分钟',style: TextStyle(fontSize: 16.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),),
] ]
), ),
Gaps.vGaps10, Gaps.vGaps10,
Text('上次读到',style: TextStyle(fontSize: 13.w,height: 1.4,color: Colors.white),), Text('上次读到',style: TextStyle(fontSize: 13.w,height: 1.4,color: Colors.white),),
Gaps.vGaps5, Gaps.vGaps5,
Text('第3章 情节…情节…情节情节情节情节',style: TextStyle(fontSize: 16.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),maxLines: 1,overflow: TextOverflow.ellipsis,), Text(model.lastChapter??'',style: TextStyle(fontSize: 16.w,height: 1.4,color: Colors.white,fontWeight: Fonts.medium),maxLines: 1,overflow: TextOverflow.ellipsis,),
] ]
), ),
), ),
Container( Container(
height: 120.w, height: 120.w,
width: 100.w, width: 100.w,
color: Colors.lime, child: CustomImage.asset(url: model.img??''),
) )
], ],
), ),
......
...@@ -2,14 +2,14 @@ part of user_msg; ...@@ -2,14 +2,14 @@ part of user_msg;
class MsgController extends GetxController { class MsgController extends GetxController {
List<MsgModel> msgs = [];
final EasyRefreshController refreshController = EasyRefreshController( final EasyRefreshController refreshController = EasyRefreshController(
controlFinishLoad: true, controlFinishLoad: true,
controlFinishRefresh: true, controlFinishRefresh: true,
); );
List<MsgModel> msgs = [];
final int _limit = 20; final int _limit = 10;
int _page = 1; int _page = 1;
bool _noMore = false; bool _noMore = false;
......
part of web; part of web;
class ReadController extends GetxController with GetSingleTickerProviderStateMixin{ class ReadController extends FullLifeCycleController with GetSingleTickerProviderStateMixin{
late AnimationController _controller; late AnimationController _controller;
bool _show = false; bool _show = false;
...@@ -43,4 +43,17 @@ class ReadController extends GetxController with GetSingleTickerProviderStateMix ...@@ -43,4 +43,17 @@ class ReadController extends GetxController with GetSingleTickerProviderStateMix
_controller.dispose(); _controller.dispose();
super.onClose(); super.onClose();
} }
void onResumed(){
print('onResumed');
}
void onPaused(){
print('onPaused');
}
void onInactive(){
print('onInactive');
}
void onDetached(){
print('onDetached');
}
} }
\ No newline at end of file
part of web; part of web;
class WebPage extends StatefulWidget { class ReadPage extends StatefulWidget {
const WebPage({Key? key}) : super(key: key); const ReadPage({Key? key}) : super(key: key);
@override @override
State<WebPage> createState() => _WebPageState(); State<ReadPage> createState() => _ReadPageState();
} }
class _WebPageState extends State<WebPage> { class _ReadPageState extends State<ReadPage> {
final GlobalKey webViewKey = GlobalKey(); final GlobalKey webViewKey = GlobalKey();
InAppWebViewController? webViewController; InAppWebViewController? webViewController;
late ContextMenu contextMenu; late ContextMenu contextMenu;
......
...@@ -173,7 +173,7 @@ abstract class Routes { ...@@ -173,7 +173,7 @@ abstract class Routes {
pageBuilder: (context, state) =>CupertinoPage( pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(), name: state.uri.toString(),
key: state.pageKey, key: state.pageKey,
child: const WebPage() child: const ReadPage()
) )
), ),
GoRoute( GoRoute(
...@@ -267,7 +267,9 @@ abstract class Routes { ...@@ -267,7 +267,9 @@ abstract class Routes {
pageBuilder: (context, state) =>CupertinoPage( pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(), name: state.uri.toString(),
key: state.pageKey, key: state.pageKey,
child: const StudyReportPage() child: StudyReportPage(
bookId: state.uri.queryParameters['book_id'].toString(),
)
) )
), ),
GoRoute( GoRoute(
......
...@@ -71,7 +71,7 @@ abstract class AppTheme { ...@@ -71,7 +71,7 @@ abstract class AppTheme {
static ThemeData get light { static ThemeData get light {
var scheme = ColorScheme.light( var scheme = ColorScheme.light(
background: Colours.cF9, background: Colors.white,
onBackground: const Color(0xFF333333), onBackground: const Color(0xFF333333),
surface: Colors.white, surface: Colors.white,
onSurface: const Color(0xFF333333), onSurface: const Color(0xFF333333),
......
...@@ -96,6 +96,12 @@ class ValidatorTool { ...@@ -96,6 +96,12 @@ class ValidatorTool {
RegExp passwordPattern = RegExp(r'^\d{6}$'); RegExp passwordPattern = RegExp(r'^\d{6}$');
return passwordPattern.hasMatch(value); return passwordPattern.hasMatch(value);
} }
static bool isValidCode(String value) {
// RegExp passwordPattern = RegExp(r'^[A-Za-z0-9!@#\$%^&*()_+{}\[\]:;<>,.?~\\/-]{8,12}$');
RegExp passwordPattern = RegExp(r'^\d{6}$');
return passwordPattern.hasMatch(value);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论