Skip to content

Commit bdc9747

Browse files
committed
feat: basic bottom controls
1 parent 662b72f commit bdc9747

File tree

3 files changed

+109
-3
lines changed

3 files changed

+109
-3
lines changed

lib/Adaptor/Chapter/ChapterAdaptor.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Future<void> onChapterClick(
171171

172172
final pages = await getPagesList(source: source, mangaId: chapter.link!);
173173
if (context.mounted) {
174+
onChapterClick?.call();
174175
Navigator.pop(context);
175176
navigateToPage(
176177
context,

lib/Screens/Manga/MangaReader/Reader.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ class MediaReaderState extends State<MediaReader> {
6161
);
6262
}
6363

64+
ScrollController scrollController = ScrollController();
6465
Widget _buildWebtoonMode() {
6566
return ScrollConfig(
6667
context,
6768
child: SingleChildScrollView(
69+
controller: scrollController,
6870
child: Column(
6971
children: [
7072
...widget.pages.map(
@@ -73,9 +75,6 @@ class MediaReaderState extends State<MediaReader> {
7375
child: CachedNetworkImage(
7476
imageUrl: p.url,
7577
fit: BoxFit.cover,
76-
httpHeaders: {
77-
'Referer': widget.source.baseUrl!,
78-
},
7978
progressIndicatorBuilder: (b, c, p) => SizedBox(
8079
height: MediaQuery.of(context).size.height,
8180
width: double.infinity,
@@ -87,6 +86,8 @@ class MediaReaderState extends State<MediaReader> {
8786
);
8887
},
8988
),
89+
const SizedBox(height: 10),
90+
9091
],
9192
),
9293
),

lib/Screens/Manga/MangaReader/ReaderController.dart

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import 'package:dartotsu/Adaptor/Chapter/ChapterAdaptor.dart';
12
import 'package:flutter/material.dart';
23

34
import 'package:dartotsu/DataClass/Media.dart';
5+
import 'package:get/get.dart';
46
import '../../../Api/Sources/Eval/dart/model/page.dart';
57
import '../../../Api/Sources/Model/Source.dart';
68
import '../../../DataClass/Chapter.dart';
@@ -53,6 +55,27 @@ class _ReaderControllerState extends State<ReaderController> {
5355
padding: EdgeInsets.all(16),
5456
child: _buildTopControls(),
5557
),
58+
Column(
59+
mainAxisAlignment: MainAxisAlignment.end,
60+
children: [
61+
Container(
62+
height: 124,
63+
decoration: BoxDecoration(
64+
gradient: LinearGradient(
65+
begin: Alignment.topCenter,
66+
end: Alignment.bottomCenter,
67+
colors: [
68+
Colors.black.withOpacity(0.0),
69+
Colors.black.withOpacity(0.5),
70+
Colors.black.withOpacity(0.9),
71+
],
72+
),
73+
),
74+
padding: EdgeInsets.all(16),
75+
child: _buildBottomControls(),
76+
),
77+
],
78+
),
5679
],
5780
);
5881
}
@@ -120,6 +143,87 @@ class _ReaderControllerState extends State<ReaderController> {
120143
);
121144
}
122145

146+
Widget _buildBottomControls() {
147+
var chapterList = media.manga!.chapters!.toList();
148+
var index = chapterList.indexOf(currentChapter);
149+
var previousChapter = index > 0 ? chapterList[index - 1] : null;
150+
var nextChapter =
151+
index < chapterList.length - 1 ? chapterList[index + 1] : null;
152+
return Column(
153+
crossAxisAlignment: CrossAxisAlignment.end,
154+
children: [
155+
Expanded(
156+
child: Row(
157+
crossAxisAlignment: CrossAxisAlignment.end,
158+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
159+
children: [
160+
previousChapter != null
161+
? Row(
162+
children: [
163+
_buildControlButton(
164+
icon: Icons.skip_previous_rounded,
165+
color: Colors.white,
166+
onPressed: () {
167+
onChapterClick(
168+
context,
169+
previousChapter,
170+
source,
171+
media,
172+
() => Get.back(),
173+
);
174+
},
175+
),
176+
SizedBox(width: 12),
177+
Text(
178+
previousChapter.title.toString(),
179+
style: const TextStyle(
180+
color: Colors.white,
181+
fontSize: 14,
182+
fontWeight: FontWeight.bold,
183+
),
184+
maxLines: 1,
185+
overflow: TextOverflow.ellipsis,
186+
),
187+
],
188+
)
189+
: SizedBox(),
190+
nextChapter != null
191+
? Row(
192+
children: [
193+
Text(
194+
nextChapter.title.toString(),
195+
style: const TextStyle(
196+
color: Colors.white,
197+
fontSize: 14,
198+
fontWeight: FontWeight.bold,
199+
),
200+
maxLines: 1,
201+
overflow: TextOverflow.ellipsis,
202+
),
203+
SizedBox(width: 12),
204+
_buildControlButton(
205+
icon: Icons.skip_next_rounded,
206+
color: Colors.white,
207+
onPressed: () {
208+
onChapterClick(
209+
context,
210+
nextChapter,
211+
source,
212+
media,
213+
() => Get.back(),
214+
);
215+
},
216+
),
217+
],
218+
)
219+
: SizedBox(),
220+
],
221+
),
222+
),
223+
],
224+
);
225+
}
226+
123227
Widget _buildControlButton({
124228
required IconData icon,
125229
required VoidCallback onPressed,

0 commit comments

Comments
 (0)