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

合并分支 'test' 到 'sim'

Test 查看合并请求 kiwitap/zijing-app!26
......@@ -22,6 +22,9 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
// 图书
BookDetailModel bookDetails = BookDetailModel();
// 是否能点击
bool canTap = true;
@override
void onInit() {
......@@ -147,7 +150,7 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
update();
}
/// 收藏 与 取消收藏
void love({
Future<void> love({
required String bookId,
required num isCollection
}) async {
......@@ -160,8 +163,9 @@ class BookDetailController extends GetxController with GetSingleTickerProviderSt
bool result = await CommonAPI.love(
bookId: bookId, love: isCollection.toString());
if (result) {
getBookDetails();
bookDetails.isCollection = isCollection;
}
update();
}
// 获取当前的章节id
......
......@@ -37,8 +37,12 @@ class _BookDetailPageState extends State<BookDetailPage> with SingleTickerProvid
icon: Image.asset(
controller.bookDetails.isCollection == 0? 'assets/images/unlove.png':'assets/images/love.png',
),
onPressed: () {
controller.love(bookId: controller.bookDetails.bookId.toString(), isCollection: controller.bookDetails.isCollection!);
onPressed: () async {
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{
bool _show = false;
late UModel _getModel;
// 是否可点击收藏
bool canTap = true;
bool get show => _show;
void setShow(bool value) {
......@@ -233,7 +236,7 @@ class LibraryController extends GetxController with GetTickerProviderStateMixin{
}
/// 收藏 与 取消收藏
void love({
Future<void> love({
required CourseModel model
}) async {
......
......@@ -37,9 +37,14 @@ class _LibraryContentPageState extends State<LibraryContentPage> with AutomaticK
onTap: (){
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){
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{
context.pushNamed(Routes.login);
......
......@@ -743,6 +743,89 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
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 上一章节
// 1 下一章节
......@@ -828,6 +911,11 @@ class ReadController extends FullLifeCycleController with GetSingleTickerProvide
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 {
final result = await SqlManager.queryLocalNote(bookId: int.parse(bookId), chapterId: int.parse(chapterId));
......
......@@ -35,6 +35,9 @@ class DiscussController extends GetxController {
// 搜全文
List<SearchAllModel> searchALlResults = [];
// 是否能点击
bool canTap = true;
@override
void onReady() {
......
......@@ -23,6 +23,7 @@ class UserDiscussDesController extends GetxController {
// 当前要回复父级的模型
late DiscussModel fatherDiscussModel;
bool canTap= true;
@override
void onReady() {
......
......@@ -73,7 +73,7 @@ class _UserDiscussDesPageState extends State<UserDiscussDesPage> {
height: 0.5.w,
color: Colours.cF2,
),
SizedBox(height:10.w),
// SizedBox(height:10.w),
Expanded(
child: TabBarView(
children: List.generate(tabs.length, (index){
......
......@@ -25,7 +25,7 @@ class _BuildDiscussState extends State<BuildDiscuss> {
@override
Widget build(BuildContext context) {
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),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.w),
......@@ -188,8 +188,16 @@ class _BuildDiscussState extends State<BuildDiscuss> {
children: [
GestureDetector(
onTap: () async{
widget.controller?.commentLove(discussModel: model);
widget.userDiscussDesController?.commentLove(discussModel: model);
if (widget.controller?.canTap == true) {
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(
height: 20.w,
......
......@@ -7,8 +7,8 @@ abstract class AssetsPicker {
static Future<XFile?> image({
required BuildContext context,
ImageSource source = ImageSource.gallery,
double maxWidth = 512,
double maxHeight = 512,
double maxWidth = 1024,
double maxHeight = 1024,
}) async {
if (!(await Access.photos())) {
if (context.mounted) {
......@@ -22,8 +22,9 @@ abstract class AssetsPicker {
}
return _imagePicker.pickImage(
source: source,
maxWidth: maxWidth,
maxHeight: maxHeight,
// maxWidth: maxWidth,
// maxHeight: maxHeight,
// imageQuality: 100
);
}
/// 拍照
......@@ -45,8 +46,8 @@ abstract class AssetsPicker {
}
return _imagePicker.pickImage(
source: source,
maxWidth: maxWidth,
maxHeight: maxHeight,
// maxWidth: maxWidth,
// maxHeight: maxHeight,
);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论