Skip to content

Commit

Permalink
style: revert back to page view in manga details
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanYuuki committed Dec 1, 2024
1 parent 9aa2c41 commit fb54d14
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 124 deletions.
49 changes: 29 additions & 20 deletions lib/components/android/common/expandable_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,35 @@ class _ExpandablePageViewState extends State<ExpandablePageView> {
}

Widget _itemBuilder(BuildContext context, int index) {
final item = widget.itemBuilder(context, index);
return OverflowBox(
minHeight: 0,
maxHeight: double.infinity,
alignment: Alignment.topCenter,
child: SizeReportingWidget(
onSizeChange: (size) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {
if ((size.height - widget.defaultHeight).abs() > 10) {
_heights[index] = size.height;
}
});
}
});
},
child: item,
),
);
if (mounted) {
final item = widget.itemBuilder(context, index);
return OverflowBox(
minHeight: 0,
maxHeight: double.infinity,
alignment: Alignment.topCenter,
child: SizeReportingWidget(
onSizeChange: (size) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) {
setState(() {
if ((size.height - widget.defaultHeight).abs() > 10) {
_heights[index] = size.height;
}
});
}
});
},
child: item,
),
);
} else {
return const SizedBox(
height: 500,
child: Center(
child: CircularProgressIndicator(),
),
);
}
}

void _updatePage() {
Expand Down
235 changes: 132 additions & 103 deletions lib/components/android/manga/chapters.dart
Original file line number Diff line number Diff line change
@@ -1,132 +1,161 @@
import 'package:anymex/pages/Android/Manga/read_page.dart';
import 'package:flutter/material.dart';
import 'package:text_scroll/text_scroll.dart';
import 'package:anymex/pages/Android/Manga/read_page.dart';

class ChapterList extends StatelessWidget {
final List<dynamic> chaptersData; // Ensure this is a list
final dynamic chaptersData;
final String? id;
final String? posterUrl;
final String anilistId;
final String currentSource;
final dynamic rawChapters;
final String description;

const ChapterList({
super.key,
required this.chaptersData,
required this.id,
required this.posterUrl,
required this.currentSource,
required this.anilistId,
required this.rawChapters,
required this.description,
});
const ChapterList(
{super.key,
this.chaptersData,
required this.id,
required this.posterUrl,
required this.currentSource,
required this.anilistId,
required this.rawChapters,
required this.description});

@override
Widget build(BuildContext context) {
if (chaptersData.isEmpty) {
if (chaptersData == null) {
return const SizedBox(
height: 300,
child: Center(
child: CircularProgressIndicator(),
),
);
}

return Column(
children: chaptersData.map((manga) {
return Container(
margin: const EdgeInsets.only(bottom: 20),
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
width: MediaQuery.of(context).size.width,
height: 70,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Theme.of(context).colorScheme.surfaceContainerHighest,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 140,
child: TextScroll(
manga['title'] ?? '?',
mode: TextScrollMode.endless,
velocity: const Velocity(pixelsPerSecond: Offset(30, 0)),
delayBefore: const Duration(milliseconds: 500),
pauseBetween: const Duration(milliseconds: 1000),
textAlign: TextAlign.start,
style: const TextStyle(fontSize: 16),
),
),
const SizedBox(height: 5),
Text(
manga['date']?.toString() ?? '',
style: TextStyle(
fontSize: 12,
color: Colors.grey[400],
),
return SizedBox(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 400,
child: ListView.builder(
itemCount: chaptersData.length,
itemBuilder: (context, index) {
final manga = chaptersData[index];
return Container(
margin: const EdgeInsets.only(bottom: 20),
padding:
const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
width: MediaQuery.of(context).size.width,
height: 70,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color:
Theme.of(context).colorScheme.surfaceContainerHighest,
),
],
),
Row(
children: [
const Icon(
Icons.whatshot,
size: 16,
),
const SizedBox(width: 5),
Text(
manga['views']?.toString() ?? '??',
style: const TextStyle(
fontSize: 14,
),
),
const SizedBox(width: 15),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ReadingPage(
id: manga['id'],
mangaId: id!,
posterUrl: posterUrl!,
currentSource: currentSource,
anilistId: anilistId,
chapterList: rawChapters,
description: description,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 140,
child: TextScroll(
manga?['title'] ?? '?',
mode: TextScrollMode.endless,
velocity: const Velocity(
pixelsPerSecond: Offset(30, 0)),
delayBefore: const Duration(milliseconds: 500),
pauseBetween: const Duration(milliseconds: 1000),
textAlign: TextAlign.center,
selectable: true,
style: const TextStyle(fontSize: 16),
),
),
const SizedBox(height: 5),
Text(
manga['date'].toString(),
style: TextStyle(
fontSize: 12,
color: Colors.grey[400],
),
),
),
);
},
style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(horizontal: 20),
backgroundColor:
Theme.of(context).colorScheme.secondaryContainer,
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
],
),
),
child: const Text(
'Read',
style: TextStyle(
color: Colors.white,
fontSize: 14,
Row(
children: [
Row(
children: [
const Icon(
Icons.whatshot,
size: 16,
),
const SizedBox(width: 5),
Text(
manga['views'],
style: const TextStyle(
fontSize: 14,
),
),
],
),
const SizedBox(width: 15),
ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ReadingPage(
id: manga['id'],
mangaId: id!,
posterUrl: posterUrl!,
currentSource: currentSource,
anilistId: anilistId,
chapterList: rawChapters,
description: description,
)));
},
style: ElevatedButton.styleFrom(
padding:
const EdgeInsets.symmetric(horizontal: 20),
backgroundColor: Theme.of(context)
.colorScheme
.secondaryContainer,
elevation: 10,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
child: Text(
'Read',
style: TextStyle(
color: Theme.of(context)
.colorScheme
.inverseSurface ==
Theme.of(context)
.colorScheme
.onPrimaryFixedVariant
? Colors.black
: Theme.of(context)
.colorScheme
.onPrimaryFixedVariant ==
const Color(0xffe2e2e2)
? Colors.black
: Colors.white,
fontSize: 14,
),
),
),
],
),
),
],
),
],
),
],
);
},
),
),
);
}).toList(),
],
),
);
}
}
3 changes: 2 additions & 1 deletion lib/components/desktop/manga/chapters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class DesktopChapterList extends StatelessWidget {
return (screenWidth / itemWidth).floor().clamp(1, 3);
}

return Container(
return SizedBox(
height: 500,
child: GridView.builder(
itemCount: chaptersData.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
Expand Down

0 comments on commit fb54d14

Please sign in to comment.