提交 ea72baed authored 作者: 岳维路's avatar 岳维路

合并分支 'test' 到 'sim'

Test 查看合并请求 kiwitap/zijing-app!14
......@@ -595,9 +595,11 @@ class SearchAllModel {
class PopBackModel {
PopBackModel({
required this.chapterId,
required this.back
required this.back,
required this.chapterName
});
String chapterId;
String chapterName;
bool back;
}
......@@ -144,7 +144,7 @@ class _BuildItemState extends State<BuildItem> {
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.currentRead?AppTheme.primary:chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Gaps.hGaps5,
chapterModel.isReading == 1? Container(
margin: const EdgeInsets.fromLTRB(0, 6, 0, 0),
......
......@@ -5,7 +5,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
final String bookId;
BookDetailController(this.bookId);
late TabController tabController;
final PageController pageController = PageController(initialPage: 0);
List <Widget>tabs = [
const Tab(text: '目录',),
......@@ -13,6 +13,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
const Tab(text: '简介',),
const Tab(text: '本书信息',),
];
late TabController tabController = TabController(length: tabs.length, vsync: this);
num currentChapterId = 0;
......@@ -24,7 +25,6 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
@override
void onInit() {
tabController = TabController(length: tabs.length, vsync: this);
super.onInit();
}
......@@ -50,25 +50,60 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
}
}
/// 设置当前读的章节id
void setCurrentReadChapterId(){
for(ChapterModel chapterModel in chapters){
writeCurrentReadChapterIdToData(chapterModel);
}
}
void writeCurrentReadChapterIdToData(ChapterModel chapterModel){
for(ChapterModel cModel in chapterModel.children!){
void writeCurrentReadChapterIdToData(List<ChapterModel> data) {
for(ChapterModel cModel in data){
cModel.currentRead = false;
if(cModel.id == currentChapterId){
cModel.currentRead = true;
cModel.selected = true;
chapterModel.selected = true;
}
writeCurrentReadChapterIdToData(chapterModel);
else{
writeCurrentReadChapterIdToData(cModel.children!);
}
}
ChapterModel? tModel = findChapterById(chapters, currentChapterId);
if(tModel != null){
updateParentsStatus(chapters, tModel!);
}
}
ChapterModel? findChapterById(List<ChapterModel> data,num id){
for (ChapterModel cModel in data){
if(cModel.id == id){
return cModel;
}
ChapterModel? tModel = findChapterById(cModel.children!, id);
if(tModel !=null){
return tModel;
}
}
return null;
}
void updateParentsStatus(List<ChapterModel> data, ChapterModel model) {
ChapterModel? parentNode = findParentChapter(data, model);
while (parentNode != null) {
parentNode.selected = true;
parentNode = findParentChapter(data, parentNode);
}
}
ChapterModel? findParentChapter(List<ChapterModel> data, ChapterModel model){
for (ChapterModel tModel in data){
if(tModel.id == model.pid){
return tModel;
}
ChapterModel? cModel = findParentChapter(tModel.children!, model);
if(cModel != null) {
return cModel;
}
}
return null;
}
/// 写入特定数据
......@@ -89,7 +124,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
writeData(chapters, result);
chapters = result;
setCurrentReadChapterId();
writeCurrentReadChapterIdToData(chapters);
update();
}
......
......@@ -118,6 +118,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
controller.getChapters();
// controller.setCurrentReadChapterId(backModel!.chapterId);
controller.currentChapterId = int.parse(backModel!.chapterId);
controller.getBookDetails();
}
}
},
......@@ -217,6 +218,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
if (backModel!.back == true){
controller.getChapters();
controller.currentChapterId = int.parse(backModel!.chapterId);
controller.getBookDetails();
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
}
......@@ -249,6 +251,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
final PopBackModel? backModel = await context.pushNamed(Routes.web,queryParameters: {'book_id': controller.bookDetails.bookId.toString(),'chapter_id': chapterId,'chapter_name':chapterName,'note_id':'0'},extra: controller.bookDetails);
if (backModel!.back == true){
controller.getChapters();
controller.getBookDetails();
controller.currentChapterId = int.parse(backModel!.chapterId);
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
......@@ -263,6 +266,7 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
if (backModel!.back == true){
controller.getChapters();
controller.currentChapterId = int.parse(backModel!.chapterId);
controller.getBookDetails();
// controller.setCurrentReadChapterId(backModel!.chapterId);
}
......
......@@ -88,7 +88,7 @@ class LoginController extends GetxController {
});
/// 测试账号
if (kDebugMode) {
phoneInput.text = '13521054068';
phoneInput.text = '18810760819';
passwordInput.text = '12345678';
// phoneInput.text = '17311837355';
// passwordInput.text = '12345678';
......@@ -151,9 +151,8 @@ class LoginController extends GetxController {
// UserStore.to.profile(),
// ]);
if (!context.mounted) return;
if (context.canPop()){
context.pop();
if (context.mounted){
context.goNamed(Routes.main);
}else {
context.goNamed(Routes.main);
}
......
......@@ -157,12 +157,13 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
update();
}
// 设置 chapterId 和 chapterName
void setChapterInfo({required String id,required String name}){
chapterId = id;
chapterName = name;
update();
}
// // 设置 chapterId 和 chapterName
// void setChapterInfo({required String id,required String name}){
// chapterId = id;
// chapterName = name;
// writeCurrentReadChapterIdToData(chapters);
// update();
// }
void setShow(bool value) {
_show = !value;
update();
......@@ -180,6 +181,7 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
void selectChapter(ChapterModel model) {
chapterName = model.name??'';
chapterId = model.id.toString();
writeCurrentReadChapterIdToData(chapters);
update();
}
......@@ -455,8 +457,21 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
// 图片链接数组
List<String> images = [];
final status = await Tools.checkCurrentNetStatus();
if(chatType == 0){
if(contentInput.text.isEmpty && discussInputImages.isEmpty){
Toast.show('话题必须填写内容或选择图片');
return false;
}
}
else if(chatType == 1){
if(contentInput.text.isEmpty && discussInputImages.isEmpty && discussInputAudios.isEmpty){
Toast.show('笔记必须填写内容或选择图片或音频');
}
return false;
}
// 有网情况下 先直传oss 获取到url
if (status){
CustomToast.loading();
......@@ -841,9 +856,62 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
/// 获取目录信息
void _getChapters() async {
chapters = await LibraryAPI.chapters(bookId: bookId);
writeCurrentReadChapterIdToData(chapters);
update();
}
void writeCurrentReadChapterIdToData(List<ChapterModel> data) {
for(ChapterModel cModel in data){
cModel.currentRead = false;
if(cModel.id == int.parse(chapterId)){
cModel.currentRead = true;
cModel.selected = true;
}
else{
writeCurrentReadChapterIdToData(cModel.children!);
}
}
ChapterModel? tModel = findChapterById(chapters, int.parse(chapterId));
if(tModel != null){
updateParentsStatus(chapters, tModel!);
}
}
ChapterModel? findChapterById(List<ChapterModel> data,num id){
for (ChapterModel cModel in data){
if(cModel.id == id){
return cModel;
}
ChapterModel? tModel = findChapterById(cModel.children!, id);
if(tModel !=null){
return tModel;
}
}
return null;
}
void updateParentsStatus(List<ChapterModel> data, ChapterModel model) {
ChapterModel? parentNode = findParentChapter(data, model);
while (parentNode != null) {
parentNode.selected = true;
parentNode = findParentChapter(data, parentNode);
}
}
ChapterModel? findParentChapter(List<ChapterModel> data, ChapterModel model){
for (ChapterModel tModel in data){
if(tModel.id == model.pid){
return tModel;
}
ChapterModel? cModel = findParentChapter(tModel.children!, model);
if(cModel != null) {
return cModel;
}
}
return null;
}
/// 添加阅读时长
void _addReadTime({required type}) async{
......
......@@ -27,16 +27,16 @@ class _ReadPageState extends State<ReadPage> {
}
@override
Widget build(BuildContext context) {
PopBackModel backModel = PopBackModel(chapterId: widget.chapterId,back: true);
return WillPopScope(
return GetBuilder(
init: ReadController(bookId: widget.bookId, chapterId: widget.chapterId,chapterName: widget.chapterName,bookDetailModel: widget.bookDetailModel,noteId: widget.noteId),
builder: (readController) => WillPopScope(
onWillPop: () async {
PopBackModel backModel = PopBackModel(chapterId: readController.chapterId,back: true,chapterName: readController.chapterId);
context.pop(backModel);
CustomToast.dismiss();
return false;
},
child: GetBuilder<ReadController>(
init: ReadController(bookId: widget.bookId, chapterId: widget.chapterId,chapterName: widget.chapterName,bookDetailModel: widget.bookDetailModel,noteId: widget.noteId),
builder: (readController) => Scaffold(
child:Scaffold(
appBar: CustomAppBar(
titleSpacing: 0,
title: Align(
......@@ -200,7 +200,9 @@ class _ReadPageState extends State<ReadPage> {
controller.addJavaScriptHandler(handlerName: 'loadChapterCallBack', callback: (args){
String chapterId = args.first[0].toString();
String chapterName = args.first[1].toString();
readController.setChapterInfo(id: chapterId, name: chapterName ?? '');
ChapterModel chapterModel = ChapterModel(id: int.parse(chapterId), name: chapterName);
// readController.setChapterInfo(id: chapterId, name: chapterName ?? '');
readController.selectChapter(chapterModel);
Console.log('监听 上一节 下一节------------------------------------------------$args');
});
......@@ -232,6 +234,17 @@ class _ReadPageState extends State<ReadPage> {
Console.log('监听画廊 扩展于都---------------给页面传参---------------------------------$params');
context.pushNamed(Routes.readInfo,queryParameters: params);
});
// 图片预览
controller.addJavaScriptHandler(handlerName: 'scaleImageCallback', callback: (args){
String url = args.first[0].toString();
String title = args.first[1].toString();
Map<String,String> params = {
'url':url,
'title':title,
};
Console.log('监听图片预览---------------给页面传参---------------------------------$params');
context.pushNamed(Routes.scaleImage,queryParameters: params);
});
/// 离线需要参数
......@@ -409,6 +422,7 @@ class _ReadPageState extends State<ReadPage> {
controller.chooseTool(model);
// 选择了新的章节 刷新 webview
controller.webViewController.reload();
// controller.setCurrentReadChapterId();
},
);
}
......
......@@ -101,11 +101,12 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
searchALlResults: controller.searchALlResults,
),
)):
controller.showSearch?const SizedBox():BuildBook(bookDetailModel: widget.bookDetailModel,),
controller.showSearch?const SizedBox():Expanded(
child: Stack(
Expanded(child: Stack(
children: [
CustomPullScrollView(
Column(
children: [
BuildBook(bookDetailModel: widget.bookDetailModel,),
Expanded(child: CustomPullScrollView(
controller: controller.refreshController,
onRefresh: controller.onRefresh,
onLoading: controller.onLoading,
......@@ -123,15 +124,31 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
},
itemCount: controller.discuss.length,
),
),),
],
),
Visibility(
visible: controller.showReply,
child: Positioned(
bottom: MediaQuery.of(context).viewInsets.bottom -69 ,
bottom:-69,
left: 0,
right: 0,
top: 0,
child: GestureDetector(
onTap: (){
controller.setShow();
},
child: Container(
// color: Colors.white,
color: const Color(0xFF000000).withOpacity(0.5),
child: SingleChildScrollView(
reverse: true,
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: (){},
child: Container(
color: Colors.white,
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
......@@ -177,11 +194,13 @@ class _ReadDiscussPageState extends State<ReadDiscussPage> {
),
),
),
),
),
)
],
)
),
)
],
),)
],
),
),
......
......@@ -100,6 +100,7 @@ class _BuildItemState extends State<BuildItem> {
onTap: (){
if(chapterModel.children!.isEmpty){
widget.onTapChapter(chapterModel);
chapterModel.currentRead= true;
}
else{
setState(() {
......@@ -130,7 +131,7 @@ class _BuildItemState extends State<BuildItem> {
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Text(chapterModel.name??'',style: TextStyle(fontSize: 14.w,color: chapterModel.currentRead ?AppTheme.primary: chapterModel.seen ==0? Colours.c3:Colours.c9,fontWeight: Fonts.medium,height: 2),),
Gaps.hGaps5,
chapterModel.isReading == 1? Container(
margin: const EdgeInsets.fromLTRB(0, 6, 0, 0),
......
library scale_image;
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:go_router/go_router.dart';
import '../../utils/index.dart';
part 'view.dart';
\ No newline at end of file
part of scale_image;
class ScaleImagePage extends StatefulWidget {
final Map<String,String> params;
const ScaleImagePage({
Key? key,
required this.params
}) : super(key: key);
@override
State<ScaleImagePage> createState() => _ScaleImagePageState();
}
class _ScaleImagePageState extends State<ScaleImagePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('${widget.params['title']}'),
),
body: InAppWebView(
initialUrlRequest: URLRequest(
url: WebUri.uri(Uri.parse(kScaleImage))
),
onLoadStop: (controller, url) {
String jsonStr = jsonEncode(widget.params);
controller.evaluateJavascript(source: 'callbackInFlutterComponent($jsonStr)');
},
onConsoleMessage: (controller, consoleMessage) {
// 接收从 WebView 发送的消息
Console.log("图片预览-------Received message from WebView-----------------------------: ${consoleMessage.message}");
},
)
);
}
}
......@@ -56,6 +56,7 @@ import '../pages/bai_dict/index.dart';
import '../pages/bai_ke/index.dart';
import '../pages/image_view/index.dart';
import '../pages/read_web/index.dart';
import '../pages/scale_image/index.dart';
import '../pages/user_edit_note/index.dart';
import '../pages/user_order/index.dart';
import '../pages/user_order_cancel_detail/index.dart';
......
......@@ -13,6 +13,7 @@ abstract class Routes {
static const web = 'read_web';
static const answer = 'answer';
static const readInfo = 'read_info';
static const scaleImage = 'scale_image';
// 支付界面
static const bookPay = 'book_pay';
......@@ -714,6 +715,17 @@ abstract class Routes {
)
)
),
GoRoute( // 画廊 扩展阅读
path: '/$scaleImage',
name: scaleImage,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: ScaleImagePage(
params: state.uri.queryParameters,
)
)
),
GoRoute( // 图片预览
path: '/$imageView',
name: imageView,
......
......@@ -2,8 +2,8 @@ part of utils;
// 服务器地址
// const String kServerUrl = 'http://192.168.11.88:81';
const String kServerUrl = 'http://8.141.148.247:7421';
// const String kServerUrl = 'http://1507.superge.cn:81';
// const String kServerUrl = 'http://8.141.148.247:7421';
const String kServerUrl = 'http://1507.superge.cn:81';
const String kLocalToken = 'local_token';
const String kLocalAccessToken = 'local_access_token';
const String kLocalAccount = 'local_account';
......@@ -18,17 +18,18 @@ const String kUserPriAgreement = '/html/agreement/pri_agreement.html';
const String kUserRechargeAgreement = '/html/agreement/rec_agreement.html';
// 错题详情页 html
const String kUserWrongDes = '$kServerUrl/html/app/evaluating_wrong.html';
const String kUserWrongDes = 'http://150.158.138.40:9200/evaluating_wrong.html';
// 阅读页 html
const String kReadTestUnderLineBook = 'http://150.158.138.40:9200/read-unline.html';
const String kReadBook = '$kServerUrl/html/app/read.html';
const String kReadBook = 'http://150.158.138.40:9200/read.html';
// 答题页
const String kAnswer = '$kServerUrl/html/app/evaluating.html';
const String kAnswer = 'http://150.158.138.40:9200/evaluating.html';
// 答题结果页
const String kAnswerResult = '$kServerUrl/html/app/evaluating_result.html';
// 画廊 扩展阅读
const String kReadInfo = '$kServerUrl/html/app/read_info.html';
const String kReadInfo = 'http://150.158.138.40:9200/read_info.html';
// 阅读页 图片预览
const String kScaleImage = 'http://150.158.138.40:9200/read_img.html';
abstract class C {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论