Skip to content

Commit 5e78eda

Browse files
committed
feat: progress bar in episode (without player cant use tho)
1 parent 59002f6 commit 5e78eda

File tree

6 files changed

+63
-90
lines changed

6 files changed

+63
-90
lines changed

lib/Adaptor/Episode/EpisodeAdaptor.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import 'package:dantotsu/Functions/string_extensions.dart';
12
import 'package:flutter/widgets.dart';
23

34
import '../../Animation/ScaleAnimation.dart';
45
import '../../DataClass/Episode.dart';
56
import '../../DataClass/Media.dart';
7+
import '../../api/Discord/Discord.dart';
68
import 'EpisodeListViewHolder.dart';
79

810
class EpisodeAdaptor extends StatefulWidget {
@@ -64,8 +66,8 @@ class EpisodeAdaptorState extends State<EpisodeAdaptor> {
6466
if (widget.mediaData.userProgress != null &&
6567
widget.mediaData.userProgress! > 0) {
6668
isWatched =
67-
double.parse(widget.mediaData.userProgress!.toString()) >=
68-
double.parse(episodeList[index].number);
69+
widget.mediaData.userProgress!.toString().toDouble() >=
70+
episodeList[index].number.toDouble();
6971
} else {
7072
isWatched = false;
7173
}
@@ -76,14 +78,14 @@ class EpisodeAdaptorState extends State<EpisodeAdaptor> {
7678
finalOffset: Offset.zero,
7779
duration: const Duration(milliseconds: 200),
7880
child: GestureDetector(
79-
onTap: () {},
81+
onTap: () => Discord.setRpc(widget.mediaData, episodeList[index]),
8082
child: Container(
8183
width: double.infinity,
8284
margin:
8385
const EdgeInsets.symmetric(horizontal: 18, vertical: 4),
8486
child: Opacity(
8587
opacity: isWatched ? 0.5 : 1.0,
86-
child: EpisodeListView(episode: episodeList[index], isWatched: isWatched,),
88+
child: EpisodeListView(episode: episodeList[index], isWatched: isWatched,mediaData: widget.mediaData),
8789
),
8890
),
8991
),

lib/Adaptor/Episode/EpisodeListViewHolder.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:dantotsu/Functions/string_extensions.dart';
12
import 'package:dantotsu/Theme/Colors.dart';
23
import 'package:dantotsu/Theme/ThemeProvider.dart';
34
import 'package:dantotsu/Widgets/CachedNetworkImage.dart';
@@ -6,13 +7,15 @@ import 'package:flutter/material.dart';
67
import 'package:provider/provider.dart';
78

89
import '../../DataClass/Episode.dart';
10+
import '../../DataClass/Media.dart';
11+
import 'Widget/HandleProgress.dart';
912

1013
class EpisodeListView extends StatelessWidget {
1114
final Episode episode;
1215
final bool isWatched;
13-
16+
final media mediaData;
1417
const EpisodeListView(
15-
{super.key, required this.episode, required this.isWatched});
18+
{super.key, required this.episode, required this.isWatched, required this.mediaData});
1619

1720
@override
1821
Widget build(BuildContext context) {
@@ -145,16 +148,12 @@ class EpisodeListView extends StatelessWidget {
145148
size: 26,
146149
),
147150
),
148-
SizedBox(
149-
width: 142,
150-
child: LinearProgressIndicator(
151-
value: 0.7,
152-
backgroundColor: Colors.grey,
153-
valueColor:
154-
AlwaysStoppedAnimation<Color>(Theme.of(context).primaryColor),
155-
minHeight: 3,
156-
),
157-
),
151+
handleProgress(
152+
context: context,
153+
mediaId: mediaData.id,
154+
ep: episode.number.toInt(),
155+
width: 142
156+
)
158157
],
159158
),
160159
);
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import 'package:flutter/material.dart';
2+
3+
import '../../../Preferences/PrefManager.dart';
4+
5+
Widget handleProgress({
6+
required BuildContext context,
7+
required int mediaId,
8+
required int ep,
9+
required double width,
10+
}) {
11+
var currentProgress = PrefManager.getCustomVal<int>("${mediaId}_$ep");
12+
var maxProgress = PrefManager.getCustomVal<int>("${mediaId}_${ep}_max");
13+
if (currentProgress == null || maxProgress == null || maxProgress == 0) {
14+
return const SizedBox.shrink();
15+
}
16+
17+
double progressValue = (currentProgress / maxProgress).clamp(0.0, 1.0);
18+
19+
return SizedBox(
20+
width: width,
21+
height: 3,
22+
child: Stack(
23+
children: [
24+
Container(
25+
color: Colors.grey,
26+
),
27+
FractionallySizedBox(
28+
widthFactor: progressValue,
29+
child: Container(
30+
color: Theme.of(context).primaryColor,
31+
),
32+
),
33+
],
34+
),
35+
);
36+
}

lib/Functions/string_extensions.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ extension StringExtensions on String {
1111
return split(pattern).last;
1212
}
1313

14+
double toDouble() {
15+
return double.parse(this);
16+
}
17+
18+
int toInt() {
19+
return int.parse(this);
20+
}
21+
1422
bool isEqualTo(String? other) {
1523
return this == other;
1624
}

pubspec.lock

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ packages:
2222
url: "https://pub.dev"
2323
source: hosted
2424
version: "6.8.0"
25-
analyzer_plugin:
26-
dependency: transitive
27-
description:
28-
name: analyzer_plugin
29-
sha256: "9661b30b13a685efaee9f02e5d01ed9f2b423bd889d28a304d02d704aee69161"
30-
url: "https://pub.dev"
31-
source: hosted
32-
version: "0.11.3"
3325
antlr4:
3426
dependency: transitive
3527
description:
@@ -278,22 +270,6 @@ packages:
278270
url: "https://pub.dev"
279271
source: hosted
280272
version: "1.0.8"
281-
custom_lint_core:
282-
dependency: transitive
283-
description:
284-
name: custom_lint_core
285-
sha256: "02450c3e45e2a6e8b26c4d16687596ab3c4644dd5792e3313aa9ceba5a49b7f5"
286-
url: "https://pub.dev"
287-
source: hosted
288-
version: "0.7.0"
289-
custom_lint_visitor:
290-
dependency: transitive
291-
description:
292-
name: custom_lint_visitor
293-
sha256: bfe9b7a09c4775a587b58d10ebb871d4fe618237639b1e84d5ec62d7dfef25f9
294-
url: "https://pub.dev"
295-
source: hosted
296-
version: "1.0.0+6.11.0"
297273
dart_eval:
298274
dependency: "direct main"
299275
description:
@@ -310,14 +286,6 @@ packages:
310286
url: "https://pub.dev"
311287
source: hosted
312288
version: "2.3.7"
313-
dartx:
314-
dependency: transitive
315-
description:
316-
name: dartx
317-
sha256: "8b25435617027257d43e6508b5fe061012880ddfdaa75a71d607c3de2a13d244"
318-
url: "https://pub.dev"
319-
source: hosted
320-
version: "1.2.0"
321289
dbus:
322290
dependency: transitive
323291
description:
@@ -726,14 +694,6 @@ packages:
726694
url: "https://pub.dev"
727695
source: hosted
728696
version: "3.1.0+1"
729-
isar_generator:
730-
dependency: "direct dev"
731-
description:
732-
name: isar_generator
733-
sha256: "76c121e1295a30423604f2f819bc255bc79f852f3bc8743a24017df6068ad133"
734-
url: "https://pub.dev"
735-
source: hosted
736-
version: "3.1.0+1"
737697
js:
738698
dependency: transitive
739699
description:
@@ -1198,14 +1158,6 @@ packages:
11981158
url: "https://pub.dev"
11991159
source: hosted
12001160
version: "2.6.1"
1201-
riverpod_analyzer_utils:
1202-
dependency: transitive
1203-
description:
1204-
name: riverpod_analyzer_utils
1205-
sha256: dc53a659cb543b203cdc35cd4e942ed08ea893eb6ef12029301323bdf18c5d95
1206-
url: "https://pub.dev"
1207-
source: hosted
1208-
version: "0.5.7"
12091161
riverpod_annotation:
12101162
dependency: "direct main"
12111163
description:
@@ -1214,14 +1166,6 @@ packages:
12141166
url: "https://pub.dev"
12151167
source: hosted
12161168
version: "2.6.1"
1217-
riverpod_generator:
1218-
dependency: "direct dev"
1219-
description:
1220-
name: riverpod_generator
1221-
sha256: "54458dac2fea976990dc9ed379060db6ae5c8790143f1963fedd0fb99980a326"
1222-
url: "https://pub.dev"
1223-
source: hosted
1224-
version: "2.6.2"
12251169
rxdart:
12261170
dependency: transitive
12271171
description:
@@ -1491,14 +1435,6 @@ packages:
14911435
url: "https://pub.dev"
14921436
source: hosted
14931437
version: "0.7.2"
1494-
time:
1495-
dependency: transitive
1496-
description:
1497-
name: time
1498-
sha256: ad8e018a6c9db36cb917a031853a1aae49467a93e0d464683e029537d848c221
1499-
url: "https://pub.dev"
1500-
source: hosted
1501-
version: "2.1.4"
15021438
timezone:
15031439
dependency: transitive
15041440
description:
@@ -1859,14 +1795,6 @@ packages:
18591795
url: "https://pub.dev"
18601796
source: hosted
18611797
version: "3.0.1"
1862-
xxh3:
1863-
dependency: transitive
1864-
description:
1865-
name: xxh3
1866-
sha256: cbeb0e1d10f4c6bf67b650f395eac0cc689425b5efc2ba0cc3d3e069a0beaeec
1867-
url: "https://pub.dev"
1868-
source: hosted
1869-
version: "1.1.0"
18701798
yaml:
18711799
dependency: transitive
18721800
description:

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ dev_dependencies:
9595
hive_generator: ^2.0.0
9696
json_serializable: ^6.0.1
9797
build_runner: ^2.1.7
98-
riverpod_generator: ^2.6.2
99-
isar_generator: ^3.1.0+1
98+
# riverpod_generator: ^2.6.2
99+
# isar_generator: ^3.1.0+1
100100
# MSIX Configuration (ensure this is correctly formatted for your packaging tools)
101101
msix_config:
102102
protocol_activation: dantotsu

0 commit comments

Comments
 (0)