ios_debug_info_tile.dart 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import 'package:flutter/material.dart';
  2. import 'package:hooks_riverpod/hooks_riverpod.dart';
  3. import 'package:immich_mobile/modules/backup/providers/ios_background_settings.provider.dart';
  4. import 'package:intl/intl.dart';
  5. /// This is a simple debug widget which should be removed later on when we are
  6. /// more confident about background sync
  7. class IosDebugInfoTile extends HookConsumerWidget {
  8. final IOSBackgroundSettings settings;
  9. const IosDebugInfoTile({
  10. super.key,
  11. required this.settings,
  12. });
  13. @override
  14. Widget build(BuildContext context, WidgetRef ref) {
  15. final fetch = settings.timeOfLastFetch;
  16. final processing = settings.timeOfLastProcessing;
  17. final processes = settings.numberOfBackgroundTasksQueued;
  18. final processOrProcesses = processes == 1 ? 'process' : 'processes';
  19. final numberOrZero = processes == 0 ? 'No' : processes.toString();
  20. final title = '$numberOrZero background $processOrProcesses queued';
  21. final df = DateFormat.yMd().add_jm();
  22. final String subtitle;
  23. if (fetch == null && processing == null) {
  24. subtitle = 'No background sync job has run yet';
  25. } else if (fetch != null && processing == null) {
  26. subtitle = 'Fetch ran ${df.format(fetch)}';
  27. } else if (processing != null && fetch == null) {
  28. subtitle = 'Processing ran ${df.format(processing)}';
  29. } else {
  30. final fetchOrProcessing =
  31. fetch!.isAfter(processing!) ? fetch : processing;
  32. subtitle = 'Last sync ${df.format(fetchOrProcessing)}';
  33. }
  34. return ListTile(
  35. key: ValueKey(title),
  36. title: Text(
  37. title,
  38. style: TextStyle(
  39. fontWeight: FontWeight.bold,
  40. fontSize: 14,
  41. color: Theme.of(context).primaryColor,
  42. ),
  43. ),
  44. subtitle: Text(
  45. subtitle,
  46. style: const TextStyle(
  47. fontSize: 14,
  48. ),
  49. ),
  50. leading: Icon(
  51. Icons.bug_report,
  52. color: Theme.of(context).primaryColor,
  53. ),
  54. );
  55. }
  56. }