Skip to content

Commit

Permalink
delete zooming in desktop ver
Browse files Browse the repository at this point in the history
  • Loading branch information
appdevelpo committed Dec 11, 2023
1 parent 4bdd9bf commit 2ef68f9
Showing 1 changed file with 94 additions and 75 deletions.
169 changes: 94 additions & 75 deletions lib/views/pages/watch/reader/comic/comic_reader_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,88 +98,107 @@ class _ComicReaderContentState extends State<ComicReaderContent> {
final cuurentPage = _c.currentPage.value;
if (readerType == MangaReadMode.webTonn) {
//zooming is inspired by: https://github.com/flutter/flutter/issues/86531
if (Platform.isAndroid) {
return Stack(children: [
InteractiveViewer(
minScale: minScaleValue,
// maxScale: 2.0,

return Stack(children: [
InteractiveViewer(
minScale: minScaleValue,
// maxScale: 2.0,
transformationController: transformationController,
onInteractionEnd: (ScaleEndDetails endDetails) {
setState(() {
isZoomed = false;
});
},
onInteractionUpdate: (x) {
double correctScaleValue =
transformationController.value.getMaxScaleOnAxis();
if (correctScaleValue > minScaleValue) {}
if (x.scale == correctScaleValue) {
transformationController: transformationController,
onInteractionEnd: (ScaleEndDetails endDetails) {
setState(() {
isZoomed = false;
});
}
setState(() {
isZoomed = true;
});
debugPrint("${x.scale}");
},
child: ScrollablePositionedList.builder(
padding: EdgeInsets.symmetric(
horizontal: viewPadding,
),
initialScrollIndex: cuurentPage,
itemScrollController: _c.itemScrollController,
itemPositionsListener: _c.itemPositionsListener,
scrollOffsetController: _c.scrollOffsetController,
scrollOffsetListener: _c.scrolloffsetListener,
physics: isZoomed
? const NeverScrollableScrollPhysics()
: const ScrollPhysics(),
itemBuilder: (context, index) {
final url = images[index];
return Obx(
() => CacheNetWorkImageComic(
url,
fit: BoxFit.cover,
headers: _c.watchData.value?.headers,
),
);
},
itemCount: images.length,
onInteractionUpdate: (x) {
double correctScaleValue =
transformationController.value.getMaxScaleOnAxis();
if (correctScaleValue > minScaleValue) {}
if (x.scale == correctScaleValue) {
setState(() {
isZoomed = false;
});
}
setState(() {
isZoomed = true;
});
debugPrint("${x.scale}");
},
child: ScrollablePositionedList.builder(
padding: EdgeInsets.symmetric(
horizontal: viewPadding,
),
initialScrollIndex: cuurentPage,
itemScrollController: _c.itemScrollController,
itemPositionsListener: _c.itemPositionsListener,
scrollOffsetController: _c.scrollOffsetController,
scrollOffsetListener: _c.scrolloffsetListener,
physics: isZoomed
? const NeverScrollableScrollPhysics()
: const ScrollPhysics(),
itemBuilder: (context, index) {
final url = images[index];
return Obx(
() => CacheNetWorkImageComic(
url,
fit: BoxFit.cover,
headers: _c.watchData.value?.headers,
),
);
},
itemCount: images.length,
),
),
Positioned.fill(
top: 120,
bottom: 120,
child: GestureDetector(
onTapDown: (TapDownDetails details) {
final xPos = details.globalPosition.dx;
if (xPos > Get.width * 4 / 5) {
return _c.nextPage();
}
if (xPos < Get.width / 5) {
return _c.previousPage();
}
},
)),
Container(
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(bottom: 40),
child: Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(40),
),
alignment: Alignment.center,
width: 200,
height: 30,
child: Text(
"${cuurentPage + 1}/${images.length}",
style: const TextStyle(
color: Colors.white, fontSize: 15),
)))
]);
}
return ScrollablePositionedList.builder(
padding: EdgeInsets.symmetric(
horizontal: viewPadding,
),
Positioned.fill(
top: 120,
bottom: 120,
child: GestureDetector(
onTapDown: (TapDownDetails details) {
final xPos = details.globalPosition.dx;
if (xPos > Get.width * 4 / 5) {
return _c.nextPage();
}
if (xPos < Get.width / 5) {
return _c.previousPage();
}
},
)),
Container(
alignment: Alignment.bottomCenter,
margin: const EdgeInsets.only(bottom: 40),
child: Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(40),
),
alignment: Alignment.center,
width: 200,
height: 30,
child: Text(
"${cuurentPage + 1}/${images.length}",
style: const TextStyle(
color: Colors.white, fontSize: 15),
)))
]);

initialScrollIndex: cuurentPage,
itemScrollController: _c.itemScrollController,
itemPositionsListener: _c.itemPositionsListener,
scrollOffsetController: _c.scrollOffsetController,
itemBuilder: (context, index) {
final url = images[index];
return CacheNetWorkImagePic(
url,
fit: BoxFit.fitWidth,
headers: _c.watchData.value?.headers,
);
},
itemCount: images.length,
);
//works but lots of bugs
// return Stack(children: [
// Obx(() => Transform.scale(
Expand Down

0 comments on commit 2ef68f9

Please sign in to comment.