Skip to content

Commit be445a3

Browse files
committed
feat: basic reader
1 parent 39dd6b2 commit be445a3

File tree

3 files changed

+55
-22
lines changed

3 files changed

+55
-22
lines changed

lib/Screens/Manga/MangaReader/Reader.dart

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:dartotsu/Widgets/CachedNetworkImage.dart';
2+
import 'package:dartotsu/Widgets/ScrollConfig.dart';
13
import 'package:flutter/material.dart';
24
import 'package:get/get.dart';
35
import '../../../DataClass/Chapter.dart';
@@ -44,28 +46,44 @@ class MediaReaderState extends State<MediaReader> {
4446
}
4547

4648
Widget _buildReader() {
47-
return Obx(() {
48-
return Stack(alignment: Alignment.center, children: [
49-
Center(
50-
child: Text('Media Reader'),
49+
return KeyboardListener(
50+
focusNode: focusNode,
51+
child: GestureDetector(
52+
onTap: () => showControls.value = !showControls.value,
53+
child: Stack(
54+
alignment: Alignment.center,
55+
children: [
56+
_buildWebtoonMode(),
57+
_buildOverlay(),
58+
],
5159
),
52-
KeyboardListener(
53-
focusNode: focusNode,
54-
child: GestureDetector(
55-
onTap: () => showControls.value = !showControls.value,
56-
child: AnimatedOpacity(
57-
opacity: showControls.value ? 0.3 : 0.0,
58-
duration: const Duration(milliseconds: 300),
59-
child: Container(color: Colors.black),
60+
),
61+
);
62+
}
63+
64+
Widget _buildWebtoonMode() {
65+
return ScrollConfig(
66+
context,
67+
child: SingleChildScrollView(
68+
child: Column(
69+
children: [
70+
...widget.pages.map(
71+
(p) {
72+
return Center(
73+
child: cachedNetworkImage(
74+
imageUrl: p.url,
75+
fit: BoxFit.cover,
76+
),
77+
);
78+
},
6079
),
61-
),
80+
],
6281
),
63-
_buildVideoOverlay(),
64-
]);
65-
});
82+
),
83+
);
6684
}
6785

68-
Widget _buildVideoOverlay() {
86+
Widget _buildOverlay() {
6987
return Obx(() {
7088
return Positioned.fill(
7189
child: AnimatedOpacity(

lib/Screens/Manga/MangaReader/ReaderController.dart

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,25 @@ class _ReaderControllerState extends State<ReaderController> {
3535

3636
@override
3737
Widget build(BuildContext context) {
38-
return Padding(
39-
padding: const EdgeInsets.all(16),
40-
child: Stack(
41-
children: [_buildTopControls()],
42-
),
38+
return Stack(
39+
children: [
40+
Container(
41+
height: 124,
42+
decoration: BoxDecoration(
43+
gradient: LinearGradient(
44+
begin: Alignment.topCenter,
45+
end: Alignment.bottomCenter,
46+
colors: [
47+
Colors.black.withOpacity(0.9),
48+
Colors.black.withOpacity(0.5),
49+
Colors.black.withOpacity(0.0),
50+
],
51+
),
52+
),
53+
padding: EdgeInsets.all(16),
54+
child: _buildTopControls(),
55+
),
56+
],
4357
);
4458
}
4559

lib/Widgets/ScrollConfig.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Widget ScrollConfig(BuildContext context, {required Widget child}) {
1111
PointerDeviceKind.touch,
1212
PointerDeviceKind.mouse,
1313
PointerDeviceKind.trackpad,
14+
1415
},
1516
),
1617
child: child,

0 commit comments

Comments
 (0)