Skip to content

Commit

Permalink
chore(#20) : improve progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
JordyHers committed Jun 28, 2023
1 parent 96f6807 commit d3adcac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
16 changes: 12 additions & 4 deletions lib/app/helpers/parsing_extension.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:intl/intl.dart';
import 'package:times_up_flutter/common_widgets/show_logger.dart';

extension ParseResult on String {
String t() {
Expand Down Expand Up @@ -111,14 +110,23 @@ double calculatePercentage(Duration duration) {
hours: hours,
minutes: minutes,
);
var totalDuration = const Duration(days: 1, hours: 2);

if (parsedDuration.inDays > 60) {
totalDuration = const Duration(days: 340, hours: 2);
}
if (parsedDuration.inDays > 30 && parsedDuration.inDays < 60) {
totalDuration = const Duration(days: 240, hours: 2);
}

if (parsedDuration.inDays > 7 && parsedDuration.inDays < 30) {
totalDuration = const Duration(days: 30, hours: 2);
}

const totalDuration = Duration(days: 30, hours: 2);
final milliseconds = parsedDuration.inMilliseconds;
final totalMilliseconds = totalDuration.inMilliseconds;

final res = (milliseconds / totalMilliseconds) * 100;

JHLogger.$.w(duration);
JHLogger.$.w(res);
return res;
}
3 changes: 2 additions & 1 deletion lib/common_widgets/jh_summary_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import 'package:times_up_flutter/common_widgets/jh_size_config.dart';
import 'package:times_up_flutter/theme/theme.dart';

class JHSummaryTile extends StatelessWidget {
const JHSummaryTile({Key? key,
const JHSummaryTile({
required this.title,
required this.time,
Key? key,
this.progressValue = 75,
}) : super(key: key);
final String title;
Expand Down
16 changes: 9 additions & 7 deletions lib/services/app_usage_local_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ class AppUsageInfo {
factory AppUsageInfo.fromMap(Map<String, dynamic> data) => AppUsageInfo(
data['appName'] as String,
data['usage'].toString().p(),
data['startDate'] as DateTime,
data['endDate'] as DateTime,
data['startDate'],
data['endDate'],
appIcon: base64Decode(data['appIcon'] as String),
);
late String _packageName, _appName;
late String _packageName;
late String _appName;
late Uint8List? _appIcon;
late Duration _usage;
DateTime _startDate, _endDate;
dynamic _startDate;
dynamic _endDate;

Map<String, dynamic> toMap() => {
'appName': _appName,
Expand All @@ -58,9 +60,9 @@ class AppUsageInfo {

Duration get usage => _usage;

DateTime get startDate => _startDate;
DateTime get startDate => _startDate as DateTime;

DateTime get endDate => _endDate;
DateTime get endDate => _endDate as DateTime;

Uint8List? get appIcon => _appIcon;

Expand Down Expand Up @@ -118,7 +120,7 @@ class AppUsage {
element.usage.inMilliseconds.toDouble(),
element.startDate,
element.endDate,
appIcon: app.icon!,
appIcon: app.icon,
),
);
}
Expand Down

0 comments on commit d3adcac

Please sign in to comment.