LCOV - code coverage report
Current view: top level - lib/models - redaction.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 19 0.0 %
Date: 2024-04-16 06:18:13 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/cupertino.dart';
       2             : import 'package:provider/provider.dart';
       3             : import 'package:flutter_gen/gen_l10n/app_localizations.dart';
       4             : import '../settings.dart';
       5             : import 'package:intl/intl.dart';
       6             : 
       7           0 : String redactedNick(BuildContext context, String handle, String nick) {
       8           0 :   var settings = Provider.of<Settings>(context, listen: false);
       9           0 :   if (settings.streamerMode) {
      10           0 :     if (handle == nick) {
      11           0 :       return handle.substring(0, 7) + "...";
      12             :     }
      13             :   }
      14             :   return nick;
      15             : }
      16             : 
      17           0 : String prettyDateString(BuildContext context, DateTime date) {
      18           0 :   var settings = Provider.of<Settings>(context, listen: false);
      19             :   // We want to display *Never* for epoch dates regardless of setting status
      20           0 :   if (date.millisecondsSinceEpoch == 0) {
      21           0 :     return AppLocalizations.of(context)!.conversationNotificationPolicyNever;
      22             :   }
      23           0 :   if (settings.streamerMode) {
      24           0 :     var now = DateTime.now();
      25           0 :     if (now.difference(date).abs().inDays > 1) {
      26           0 :       return AppLocalizations.of(context)!.xDaysAgo.replaceAll("\$days", now.difference(date).abs().inDays.toString());
      27             :     }
      28           0 :     if (now.difference(date).abs().inHours > 1) {
      29           0 :       return AppLocalizations.of(context)!.xHoursAgo.replaceAll("\$hours", now.difference(date).abs().inHours.toString());
      30             :     }
      31           0 :     if (now.difference(date).abs().inMinutes > 1) {
      32           0 :       return AppLocalizations.of(context)!.xMinutesAgo.replaceAll("\$minutes", now.difference(date).abs().inMinutes.toString());
      33             :     }
      34             :     // This updates too frequently and looks a little silly. Leaving here as documentation, just in case we want this for something else...
      35             :     // if (now.difference(date).abs().inSeconds > 1) {
      36             :     //   return AppLocalizations.of(context)!.xSecondsAgo.replaceAll("\$seconds", now.difference(date).abs().inSeconds.toString());
      37             :     // }
      38           0 :     return AppLocalizations.of(context)!.now;
      39             :   }
      40             :   // note: explicitly overriding the 'locale' here to force
      41             :   // a consistent YYYY-mm-dd HH::MM format.
      42           0 :   return DateFormat.yMd('en_CA').add_jm().format(date.toLocal());
      43             : }

Generated by: LCOV version 1.14