Skip to content

Commit 5e0d94f

Browse files
committed
fix: app
1 parent a25a4aa commit 5e0d94f

File tree

9 files changed

+265
-8
lines changed

9 files changed

+265
-8
lines changed

lib/Adaptor/Episode/EpisodeAdaptor.dart

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'package:dantotsu/Functions/Function.dart';
22
import 'package:dantotsu/api/Mangayomi/Eval/dart/model/video.dart';
33
import 'package:dantotsu/api/Mangayomi/Search/getVideo.dart';
44
import 'package:flutter/material.dart';
5+
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
56
import 'package:get/get.dart';
67

78
import '../../Animation/ScaleAnimation.dart';
@@ -11,6 +12,7 @@ import '../../Screens/Info/Tabs/Watch/Anime/Player/Player.dart';
1112
import '../../Widgets/CustomBottomDialog.dart';
1213
import '../../api/Mangayomi/Model/Source.dart';
1314
import 'EpisodeListViewHolder.dart';
15+
import 'EpisodeGridViewHolder.dart';
1416

1517
class EpisodeAdaptor extends StatefulWidget {
1618
final int type;
@@ -55,7 +57,7 @@ class EpisodeAdaptorState extends State<EpisodeAdaptor> {
5557
case 0:
5658
return _buildListLayout();
5759
case 1:
58-
return _buildListLayout();
60+
return _buildGridLayout();
5961
case 2:
6062
return const SizedBox();
6163
default:
@@ -101,6 +103,56 @@ class EpisodeAdaptorState extends State<EpisodeAdaptor> {
101103
),
102104
);
103105
}
106+
107+
Widget _buildGridLayout() {
108+
return LayoutBuilder(
109+
builder: (context, constraints) {
110+
final parentWidth = constraints.maxWidth;
111+
var crossAxisCount = (parentWidth / 180).floor();
112+
if (crossAxisCount < 1) crossAxisCount = 1;
113+
return AnimatedSwitcher(
114+
duration: const Duration(milliseconds: 500),
115+
child: Padding(
116+
padding:
117+
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 16.0),
118+
child: StaggeredGrid.count(
119+
crossAxisCount: crossAxisCount,
120+
children: List.generate(
121+
episodeList.length,
122+
(index) {
123+
return SlideAndScaleAnimation(
124+
initialScale: 0.0,
125+
finalScale: 1.0,
126+
initialOffset: const Offset(1.0, 0.0),
127+
finalOffset: Offset.zero,
128+
duration: const Duration(milliseconds: 200),
129+
child: GestureDetector(
130+
onTap: () => onEpisodeClick(
131+
context,
132+
episodeList[index],
133+
widget.source,
134+
widget.mediaData,
135+
widget.onEpisodeClick,
136+
),
137+
onLongPress: () {},
138+
child: SizedBox(
139+
width: 180,
140+
height: 120,
141+
child: EpisodeCardView(
142+
episode: episodeList[index],
143+
mediaData: widget.mediaData,
144+
),
145+
),
146+
),
147+
);
148+
},
149+
),
150+
),
151+
),
152+
);
153+
},
154+
);
155+
}
104156
}
105157

106158
void onEpisodeClick(
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
import 'package:dantotsu/Functions/string_extensions.dart';
2+
import 'package:flutter/material.dart';
3+
import 'package:provider/provider.dart';
4+
import 'package:dantotsu/Widgets/CachedNetworkImage.dart';
5+
import 'package:dantotsu/Theme/ThemeProvider.dart';
6+
import '../../DataClass/Episode.dart';
7+
import '../../DataClass/Media.dart';
8+
import '../../Theme/Colors.dart';
9+
10+
class EpisodeCardView extends StatelessWidget {
11+
final Episode episode;
12+
final Media mediaData;
13+
final bool isWatched;
14+
15+
EpisodeCardView({
16+
super.key,
17+
required this.episode,
18+
required this.mediaData,
19+
}) : isWatched = (mediaData.userProgress != null &&
20+
mediaData.userProgress! > 0)
21+
? mediaData.userProgress!.toDouble() >= episode.number.toDouble()
22+
: false;
23+
24+
@override
25+
Widget build(BuildContext context) {
26+
final theme = Theme.of(context).colorScheme;
27+
final themeManager = Provider.of<ThemeNotifier>(context);
28+
final isDark = themeManager.isDarkMode;
29+
30+
Color cardColor = isWatched
31+
? theme.surface.withOpacity(0.5)
32+
: theme.surfaceContainerHighest;
33+
34+
return Card(
35+
margin: const EdgeInsets.all(8),
36+
shape: RoundedRectangleBorder(
37+
borderRadius: BorderRadius.circular(16),
38+
),
39+
elevation: 4,
40+
color: cardColor,
41+
child: Stack(
42+
children: [
43+
_buildBackgroundImage(context),
44+
if (episode.filler ?? false) _fillerColor(context),
45+
_buildEpisodeInfo(context),
46+
if (isWatched) _buildWatchedOverlay(context),
47+
if (isWatched) _buildWatchedIcon(context),
48+
_buildNumber(context),
49+
],
50+
),
51+
);
52+
}
53+
Widget _fillerColor(BuildContext context) {
54+
final themeManager = Provider.of<ThemeNotifier>(context);
55+
final isDark = themeManager.isDarkMode;
56+
var color= !(episode.filler ?? false)
57+
? (isDark ? fillerDark : fillerLight)
58+
: Colors.transparent;
59+
return Card(
60+
elevation: 4,
61+
color: color,
62+
child: Container()
63+
);
64+
}
65+
Widget _buildNumber(BuildContext context) {
66+
var theme = Theme.of(context).colorScheme;
67+
return Align(
68+
alignment: Alignment.bottomRight,
69+
child: Transform.translate(
70+
offset: Offset(0, 6),
71+
child: Padding(
72+
padding: const EdgeInsets.only(right: 8, bottom: 0),
73+
child: Text(
74+
episode.number.toString(),
75+
style: TextStyle(
76+
fontFamily: 'Poppins',
77+
fontWeight: FontWeight.bold,
78+
color: theme.onSurface.withOpacity(0.6),
79+
fontSize: 42),
80+
),
81+
),
82+
),
83+
);
84+
}
85+
86+
Widget _buildBackgroundImage(BuildContext context) {
87+
return ClipRRect(
88+
borderRadius: BorderRadius.circular(16),
89+
child: cachedNetworkImage(
90+
width: double.infinity,
91+
height: 120,
92+
imageUrl: episode.thumb ?? '',
93+
fit: BoxFit.cover,
94+
placeholder: (context, url) => Container(
95+
color: Colors.white12,
96+
width: 180,
97+
height: 120,
98+
child: const Center(
99+
child: CircularProgressIndicator(),
100+
),
101+
),
102+
),
103+
);
104+
}
105+
106+
Widget _buildEpisodeInfo(BuildContext context) {
107+
return Align(
108+
alignment: Alignment.topLeft,
109+
child: Padding(
110+
padding: const EdgeInsets.all(16),
111+
child: Column(
112+
crossAxisAlignment: CrossAxisAlignment.start,
113+
mainAxisSize: MainAxisSize.min,
114+
children: [
115+
if (episode.title != null)
116+
Text(
117+
episode.title!,
118+
maxLines: 3,
119+
overflow: TextOverflow.ellipsis,
120+
style: const TextStyle(
121+
fontFamily: 'Poppins',
122+
fontWeight: FontWeight.bold,
123+
color: Colors.white,
124+
),
125+
),
126+
],
127+
),
128+
),
129+
);
130+
}
131+
132+
Widget _buildWatchedOverlay(BuildContext context) {
133+
return Container(
134+
decoration: BoxDecoration(
135+
color: Colors.black.withOpacity(0.55),
136+
borderRadius: BorderRadius.circular(16),
137+
),
138+
);
139+
}
140+
141+
Widget _buildWatchedIcon(BuildContext context) {
142+
return Align(
143+
alignment: Alignment.bottomLeft,
144+
child: Padding(
145+
padding: const EdgeInsets.all(8),
146+
child: Icon(
147+
Icons.remove_red_eye,
148+
color: Theme.of(context).colorScheme.onBackground,
149+
),
150+
),
151+
);
152+
}
153+
}

lib/Screens/Login/LoginScreen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class LoginScreenState extends State<LoginScreen> {
3939
),
4040
),
4141
const SizedBox(height: 8),
42-
const Text(
42+
Text(
4343
getString.appTagline,
4444
textAlign: TextAlign.center,
4545
style: TextStyle(fontSize: 14),

lib/Screens/Settings/SettingsPlayerScreen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ List<Widget> playerSettings(
112112
),
113113
],
114114
),
115-
const Text(
115+
Text(
116116
getString.subtitles,
117117
style: TextStyle(
118118
fontSize: 14,

lib/Widgets/CachedNetworkImage.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Widget cachedNetworkImage({
1313
return Icon(Icons.image_not_supported, weight: width ?? 24);
1414
}
1515
return CachedNetworkImage(
16+
filterQuality: FilterQuality.high,
1617
imageUrl: imageUrl,
1718
fit: fit,
1819
width: width,

linux/flutter/generated_plugins.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
1616
)
1717

1818
list(APPEND FLUTTER_FFI_PLUGIN_LIST
19-
media_kit_native_event_loop
2019
)
2120

2221
set(PLUGIN_BUNDLED_LIBRARIES)

pubspec.lock

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,14 @@ packages:
473473
url: "https://github.com/kodjodevf/flutter_qjs.git"
474474
source: git
475475
version: "0.0.1"
476+
flutter_riverpod:
477+
dependency: "direct main"
478+
description:
479+
name: flutter_riverpod
480+
sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1"
481+
url: "https://pub.dev"
482+
source: hosted
483+
version: "2.6.1"
476484
flutter_rust_bridge:
477485
dependency: "direct main"
478486
description:
@@ -683,14 +691,30 @@ packages:
683691
url: "https://pub.dev"
684692
source: hosted
685693
version: "0.1.2"
694+
isar:
695+
dependency: "direct main"
696+
description:
697+
name: isar
698+
sha256: "99165dadb2cf2329d3140198363a7e7bff9bbd441871898a87e26914d25cf1ea"
699+
url: "https://pub.dev"
700+
source: hosted
701+
version: "3.1.0+1"
702+
isar_flutter_libs:
703+
dependency: "direct main"
704+
description:
705+
name: isar_flutter_libs
706+
sha256: bc6768cc4b9c61aabff77152e7f33b4b17d2fc93134f7af1c3dd51500fe8d5e8
707+
url: "https://pub.dev"
708+
source: hosted
709+
version: "3.1.0+1"
686710
js:
687-
dependency: transitive
711+
dependency: "direct overridden"
688712
description:
689713
name: js
690-
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
714+
sha256: "4186c61b32f99e60f011f7160e32c89a758ae9b1d0c6d28e2c02ef0382300e2b"
691715
url: "https://pub.dev"
692716
source: hosted
693-
version: "0.7.1"
717+
version: "0.7.0"
694718
js_packer:
695719
dependency: "direct main"
696720
description:
@@ -1158,6 +1182,22 @@ packages:
11581182
url: "https://pub.dev"
11591183
source: hosted
11601184
version: "0.2.0"
1185+
riverpod:
1186+
dependency: transitive
1187+
description:
1188+
name: riverpod
1189+
sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959"
1190+
url: "https://pub.dev"
1191+
source: hosted
1192+
version: "2.6.1"
1193+
riverpod_annotation:
1194+
dependency: "direct main"
1195+
description:
1196+
name: riverpod_annotation
1197+
sha256: e14b0bf45b71326654e2705d462f21b958f987087be850afd60578fcd502d1b8
1198+
url: "https://pub.dev"
1199+
source: hosted
1200+
version: "2.6.1"
11611201
rxdart:
11621202
dependency: transitive
11631203
description:
@@ -1387,6 +1427,14 @@ packages:
13871427
url: "https://pub.dev"
13881428
source: hosted
13891429
version: "1.12.0"
1430+
state_notifier:
1431+
dependency: transitive
1432+
description:
1433+
name: state_notifier
1434+
sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb
1435+
url: "https://pub.dev"
1436+
source: hosted
1437+
version: "1.0.0"
13901438
stream_channel:
13911439
dependency: transitive
13921440
description:

pubspec.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ dependencies:
1818
flutter_localizations:
1919
sdk: flutter
2020
# State Management
21+
flutter_riverpod: ^2.6.1
22+
riverpod_annotation: ^2.6.1
2123
provider: ^6.1.2
2224
get: ^4.6.6
2325

@@ -34,6 +36,8 @@ dependencies:
3436
json_annotation: ^4.9.0
3537

3638
# Local Storage
39+
isar: 3.1.0+1
40+
isar_flutter_libs: 3.1.0+1
3741
path_provider: ^2.1.5
3842
path: ^1.9.0
3943
hive: ^2.2.3
@@ -100,6 +104,7 @@ dev_dependencies:
100104
build_runner: ^2.1.7
101105
dependency_overrides:
102106
analyzer: ">=5.2.0 <7.0.0"
107+
js: ">=0.6.3 <0.7.1"
103108
collection: ^1.19.0
104109

105110
media_kit:

windows/flutter/generated_plugins.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
2020
)
2121

2222
list(APPEND FLUTTER_FFI_PLUGIN_LIST
23-
media_kit_native_event_loop
2423
)
2524

2625
set(PLUGIN_BUNDLED_LIBRARIES)

0 commit comments

Comments
 (0)