Skip to content

Commit

Permalink
feat: percent_indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-ding committed Jul 15, 2024
1 parent b2c4b69 commit 7a19521
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 26 deletions.
16 changes: 11 additions & 5 deletions ui/lib/activity.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
import 'package:ui/providers/activity.dart';
import 'package:ui/widgets/progress_indicator.dart';

Expand Down Expand Up @@ -34,7 +35,7 @@ class ActivityPage extends ConsumerWidget {
return const MyProgressIndicator(
size: 20,
);
}else if (activity.status == "fail") {
} else if (activity.status == "fail") {
return const Icon(
Icons.close,
color: Colors.red,
Expand All @@ -46,10 +47,15 @@ class ActivityPage extends ConsumerWidget {
);
}

double p = activity.progress == null ? 0:activity.progress!.toDouble() / 100;
return MyProgressIndicator(
value: p,
size: 20,
double p = activity.progress == null
? 0
: activity.progress!.toDouble() / 100;
return CircularPercentIndicator(
radius: 15.0,
lineWidth: 5.0,
percent: p,
center: Text("${p * 100}"),
progressColor: Colors.green,
);
}()),
DataCell(IconButton(
Expand Down
40 changes: 19 additions & 21 deletions ui/lib/providers/activity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ class ActivityData extends AutoDisposeAsyncNotifier<List<Activity>> {
}

class Activity {
Activity({
required this.id,
required this.seriesId,
required this.episodeId,
required this.sourceTitle,
required this.date,
required this.targetDir,
required this.status,
required this.saved,
required this.progress
});
Activity(
{required this.id,
required this.seriesId,
required this.episodeId,
required this.sourceTitle,
required this.date,
required this.targetDir,
required this.status,
required this.saved,
required this.progress});

final int? id;
final int? seriesId;
Expand All @@ -60,15 +59,14 @@ class Activity {

factory Activity.fromJson(Map<String, dynamic> json) {
return Activity(
id: json["id"],
seriesId: json["series_id"],
episodeId: json["episode_id"],
sourceTitle: json["source_title"],
date: DateTime.tryParse(json["date"] ?? ""),
targetDir: json["target_dir"],
status: json["status"],
saved: json["saved"],
progress: json["progress"]
);
id: json["id"],
seriesId: json["series_id"],
episodeId: json["episode_id"],
sourceTitle: json["source_title"],
date: DateTime.tryParse(json["date"] ?? ""),
targetDir: json["target_dir"],
status: json["status"],
saved: json["saved"],
progress: json["progress"]);
}
}
8 changes: 8 additions & 0 deletions ui/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.3.0"
percent_indicator:
dependency: "direct main"
description:
name: percent_indicator
sha256: c37099ad833a883c9d71782321cb65c3a848c21b6939b6185f0ff6640d05814c
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.2.3"
phone_numbers_parser:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies:
quiver: ^3.2.1
flutter_login: ^5.0.0
shared_preferences: ^2.2.3
percent_indicator: ^4.2.3

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 7a19521

Please sign in to comment.