提交 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 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论