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

合并分支 'test' 到 'sim'

Test 查看合并请求 kiwitap/zijing-app!26
...@@ -22,6 +22,9 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -22,6 +22,9 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
// 图书 // 图书
BookDetailModel bookDetails = BookDetailModel(); BookDetailModel bookDetails = BookDetailModel();
// 是否能点击
bool canTap = true;
@override @override
void onInit() { void onInit() {
...@@ -147,7 +150,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -147,7 +150,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
update(); update();
} }
/// 收藏 与 取消收藏 /// 收藏 与 取消收藏
void love({ Future<void> love({
required String bookId, required String bookId,
required num isCollection required num isCollection
}) async { }) async {
...@@ -160,8 +163,9 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt ...@@ -160,8 +163,9 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
bool result = await CommonAPI.love( bool result = await CommonAPI.love(
bookId: bookId, love: isCollection.toString()); bookId: bookId, love: isCollection.toString());
if (result) { if (result) {
getBookDetails(); bookDetails.isCollection = isCollection;
} }
update();
} }
// 获取当前的章节id // 获取当前的章节id
......
...@@ -37,8 +37,12 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid ...@@ -37,8 +37,12 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
icon: Image.asset( icon: Image.asset(
controller.bookDetails.isCollection == 0? 'assets/images/unlove.png':'assets/images/love.png', controller.bookDetails.isCollection == 0? 'assets/images/unlove.png':'assets/images/love.png',
), ),
onPressed: () { onPressed: () async {
controller.love(bookId: controller.bookDetails.bookId.toString(), isCollection: controller.bookDetails.isCollection!); if(controller.canTap == true) {
controller.canTap = false;
await controller.love(bookId: controller.bookDetails.bookId.toString(), isCollection: controller.bookDetails.isCollection!);
controller.canTap = true;
}
}, },
), ),
], ],
......
...@@ -52,6 +52,9 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -52,6 +52,9 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
bool _show = false; bool _show = false;
late UModel _getModel; late UModel _getModel;
// 是否可点击收藏
bool canTap = true;
bool get show => _show; bool get show => _show;
void setShow(bool value) { void setShow(bool value) {
...@@ -233,7 +236,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{ ...@@ -233,7 +236,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
} }
/// 收藏 与 取消收藏 /// 收藏 与 取消收藏
void love({ Future<void> love({
required CourseModel model required CourseModel model
}) async { }) async {
......
...@@ -37,9 +37,14 @@ class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticK ...@@ -37,9 +37,14 @@ class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticK
onTap: (){ onTap: (){
context.pushNamed(Routes.bookDetail,queryParameters: {'book_id':model.bookId.toString()}); context.pushNamed(Routes.bookDetail,queryParameters: {'book_id':model.bookId.toString()});
}, },
child: LibraryCell(model: model,onTap: (){ child: LibraryCell(model: model,onTap: () async{
if(UserStore.to.isLogin){ if(UserStore.to.isLogin){
widget.controller.love(model: model); if(widget.controller.canTap == true){
widget.controller.canTap = false;
await widget.controller.love(model: model);
widget.controller.canTap = true;
}
} }
else{ else{
context.pushNamed(Routes.login); context.pushNamed(Routes.login);
......
...@@ -743,6 +743,89 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -743,6 +743,89 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
queryLocalNote(); queryLocalNote();
} }
// 获取离线数据
void getOffLineInfo() async {
Map<String, dynamic> data = {};
data['chapter_name'] = chapterName;
// 1、根据当前章节id名称 获取内容
String toReadHtmlPath = await getLocalReadHtml(chapterId);
// 2、获取 离线文件的内容
final enCodeContent = await readHtmlFileContent(toReadHtmlPath);
// 3、解密离线的内容
String deCodeContent = EncryptUtil.aesDecrypt(enCodeContent!);
data['content'] = deCodeContent;
// 4、获取上一章节信息
Map<String, dynamic> upChapter = {};
final upId = await getChapterId(type: 0);
if(upId.isEmpty) {
data['up_chapter'] = '';
}
else{
String upName = getChapterName(upId);
upChapter['name'] = upName;
upChapter['id'] = int.parse(upId);
}
// 5、获取下一章节信息
Map<String, dynamic> nextChapter = {};
final nextId = await getChapterId(type: 1);
if(nextId.isEmpty) {
data['next_chapter'] = '';
}
else{
String nextName = getChapterName(upId);
nextChapter['name'] = nextName;
nextChapter['id'] = int.parse(nextId);
}
// 6、获取离线高亮和划线
final Map<String, dynamic> temp = await queryNewLocalNote();
data.addAll(temp);
// 7、 给前端参数
String jsonStr = jsonEncode(data);
webViewController.evaluateJavascript(source: 'offlineCallbackInFlutterComponent($jsonStr)');
}
// 获取上一章节或下一章节 id
Future<String> getChapterId({required int type}) async{
String docPath = await _getDirectory();
String filePath = '$docPath/$bookId';
Directory directory = Directory(filePath);
// 获取目录下的所有文件
List<FileSystemEntity> files = directory.listSync(recursive: true);
int findIndex = int.parse(currentHtmlName.split('-').first);
if(type == 0){
findIndex--;
if(findIndex <0){
Toast.show('前面已没有章节');
// 已到最前
return '';
}
}
else{
findIndex++;
if(findIndex >files.length -1){
// 已到最后
return '';
}
}
for (var file in files) {
if (file is File && file.path.toLowerCase().endsWith('.html')) {
String fileName = path.basenameWithoutExtension(file.path);
if (int.parse(fileName.split('-').first) == findIndex){
Console.log('HTML File--------------------------------${file.path}');
String chapterId = fileName.split('-').last;
return chapterId;
}
}
}
return '';
}
// 本地阅读 读取上一章节 或 下一章节 // 本地阅读 读取上一章节 或 下一章节
// 0 上一章节 // 0 上一章节
// 1 下一章节 // 1 下一章节
...@@ -828,6 +911,11 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide ...@@ -828,6 +911,11 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
return ''; return '';
} }
Future<Map<String,dynamic>> queryNewLocalNote() async {
final result = await SqlManager.queryLocalNote(bookId: int.parse(bookId), chapterId: int.parse(chapterId));
return result;
}
// 查询本地划线高亮笔记 // 查询本地划线高亮笔记
void queryLocalNote() async { void queryLocalNote() async {
final result = await SqlManager.queryLocalNote(bookId: int.parse(bookId), chapterId: int.parse(chapterId)); final result = await SqlManager.queryLocalNote(bookId: int.parse(bookId), chapterId: int.parse(chapterId));
......
...@@ -35,6 +35,9 @@ class DiscussController extends GetxController { ...@@ -35,6 +35,9 @@ class DiscussController extends GetxController {
// 搜全文 // 搜全文
List<SearchAllModel> searchALlResults = []; List<SearchAllModel> searchALlResults = [];
// 是否能点击
bool canTap = true;
@override @override
void onReady() { void onReady() {
......
...@@ -23,6 +23,7 @@ class UserDiscussDesController extends GetxController { ...@@ -23,6 +23,7 @@ class UserDiscussDesController extends GetxController {
// 当前要回复父级的模型 // 当前要回复父级的模型
late DiscussModel fatherDiscussModel; late DiscussModel fatherDiscussModel;
bool canTap= true;
@override @override
void onReady() { void onReady() {
......
...@@ -73,7 +73,7 @@ class _UserDiscussDesPageState extends State<UserDiscussDesPage> { ...@@ -73,7 +73,7 @@ class _UserDiscussDesPageState extends State<UserDiscussDesPage> {
height: 0.5.w, height: 0.5.w,
color: Colours.cF2, color: Colours.cF2,
), ),
SizedBox(height:10.w), // SizedBox(height:10.w),
Expanded( Expanded(
child: TabBarView( child: TabBarView(
children: List.generate(tabs.length, (index){ children: List.generate(tabs.length, (index){
......
...@@ -25,7 +25,7 @@ class _BuildDiscussState extends State<BuildDiscuss> { ...@@ -25,7 +25,7 @@ class _BuildDiscussState extends State<BuildDiscuss> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
margin: EdgeInsets.only(left: 10.w,right: 10.w), margin: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.w),
padding: EdgeInsets.all(10.w), padding: EdgeInsets.all(10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.w), borderRadius: BorderRadius.circular(4.w),
...@@ -188,8 +188,16 @@ class _BuildDiscussState extends State<BuildDiscuss> { ...@@ -188,8 +188,16 @@ class _BuildDiscussState extends State<BuildDiscuss> {
children: [ children: [
GestureDetector( GestureDetector(
onTap: () async{ onTap: () async{
widget.controller?.commentLove(discussModel: model); if (widget.controller?.canTap == true) {
widget.userDiscussDesController?.commentLove(discussModel: model); widget.controller?.canTap = false;
await widget.controller?.commentLove(discussModel: model);
widget.controller?.canTap = true;
}
if (widget.userDiscussDesController?.canTap == true) {
widget.userDiscussDesController?.canTap = false;
await widget.userDiscussDesController?.commentLove(discussModel: model);
widget.userDiscussDesController?.canTap = true;
}
}, },
child: SizedBox( child: SizedBox(
height: 20.w, height: 20.w,
......
...@@ -7,8 +7,8 @@ abstract class AssetsPicker { ...@@ -7,8 +7,8 @@ abstract class AssetsPicker {
static Future<XFile?> image({ static Future<XFile?> image({
required BuildContext context, required BuildContext context,
ImageSource source = ImageSource.gallery, ImageSource source = ImageSource.gallery,
double maxWidth = 512, double maxWidth = 1024,
double maxHeight = 512, double maxHeight = 1024,
}) async { }) async {
if (!(await Access.photos())) { if (!(await Access.photos())) {
if (context.mounted) { if (context.mounted) {
...@@ -22,8 +22,9 @@ abstract class AssetsPicker { ...@@ -22,8 +22,9 @@ abstract class AssetsPicker {
} }
return _imagePicker.pickImage( return _imagePicker.pickImage(
source: source, source: source,
maxWidth: maxWidth, // maxWidth: maxWidth,
maxHeight: maxHeight, // maxHeight: maxHeight,
// imageQuality: 100
); );
} }
/// 拍照 /// 拍照
...@@ -45,8 +46,8 @@ abstract class AssetsPicker { ...@@ -45,8 +46,8 @@ abstract class AssetsPicker {
} }
return _imagePicker.pickImage( return _imagePicker.pickImage(
source: source, source: source,
maxWidth: maxWidth, // maxWidth: maxWidth,
maxHeight: maxHeight, // maxHeight: maxHeight,
); );
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论