trash_cell.dart 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'package:flowy_infra/image.dart';
  2. import 'package:flowy_infra_ui/flowy_infra_ui.dart';
  3. import 'package:appflowy_backend/protobuf/flowy-folder/trash.pb.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:intl/intl.dart';
  6. import 'package:fixnum/fixnum.dart' as $fixnum;
  7. import 'sizes.dart';
  8. class TrashCell extends StatelessWidget {
  9. final VoidCallback onRestore;
  10. final VoidCallback onDelete;
  11. final TrashPB object;
  12. const TrashCell({
  13. required this.object,
  14. required this.onRestore,
  15. required this.onDelete,
  16. Key? key,
  17. }) : super(key: key);
  18. @override
  19. Widget build(BuildContext context) {
  20. return Row(
  21. children: [
  22. SizedBox(
  23. width: TrashSizes.fileNameWidth,
  24. child: FlowyText(object.name),
  25. ),
  26. SizedBox(
  27. width: TrashSizes.lashModifyWidth,
  28. child: FlowyText(dateFormatter(object.modifiedTime)),
  29. ),
  30. SizedBox(
  31. width: TrashSizes.createTimeWidth,
  32. child: FlowyText(dateFormatter(object.createTime)),
  33. ),
  34. const Spacer(),
  35. FlowyIconButton(
  36. iconColorOnHover: Theme.of(context).colorScheme.onSurface,
  37. width: TrashSizes.actionIconWidth,
  38. onPressed: onRestore,
  39. iconPadding: const EdgeInsets.all(5),
  40. icon: const FlowySvg(name: 'editor/restore'),
  41. ),
  42. const HSpace(20),
  43. FlowyIconButton(
  44. iconColorOnHover: Theme.of(context).colorScheme.onSurface,
  45. width: TrashSizes.actionIconWidth,
  46. onPressed: onDelete,
  47. iconPadding: const EdgeInsets.all(5),
  48. icon: const FlowySvg(name: 'editor/delete'),
  49. ),
  50. ],
  51. );
  52. }
  53. String dateFormatter($fixnum.Int64 inputTimestamps) {
  54. final outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
  55. final date = DateTime.fromMillisecondsSinceEpoch(
  56. inputTimestamps.toInt() * 1000,
  57. isUtc: true,
  58. );
  59. final outputDate = outputFormat.format(date);
  60. return outputDate;
  61. }
  62. }