2023-08-14 13:34:01 -07:00
|
|
|
import 'package:appflowy/generated/flowy_svgs.g.dart';
|
2021-10-14 14:34:22 +08:00
|
|
|
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
|
|
|
import 'package:flowy_infra_ui/style_widget/text.dart';
|
|
|
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
2023-04-04 08:41:16 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder2/trash.pb.dart';
|
2021-10-14 14:34:22 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2021-11-16 21:38:39 +08:00
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:fixnum/fixnum.dart' as $fixnum;
|
2021-10-14 14:34:22 +08:00
|
|
|
|
|
|
|
import 'sizes.dart';
|
|
|
|
|
|
|
|
class TrashCell extends StatelessWidget {
|
|
|
|
final VoidCallback onRestore;
|
|
|
|
final VoidCallback onDelete;
|
2022-07-19 14:11:29 +08:00
|
|
|
final TrashPB object;
|
2023-04-10 15:10:42 +08:00
|
|
|
const TrashCell({
|
|
|
|
required this.object,
|
|
|
|
required this.onRestore,
|
|
|
|
required this.onDelete,
|
2023-12-08 20:01:54 +07:00
|
|
|
super.key,
|
|
|
|
});
|
2021-10-14 14:34:22 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Row(
|
|
|
|
children: [
|
2022-09-21 11:46:32 +08:00
|
|
|
SizedBox(
|
2022-11-19 17:53:30 +08:00
|
|
|
width: TrashSizes.fileNameWidth,
|
|
|
|
child: FlowyText(object.name),
|
|
|
|
),
|
2022-09-21 11:46:32 +08:00
|
|
|
SizedBox(
|
2022-11-19 17:53:30 +08:00
|
|
|
width: TrashSizes.lashModifyWidth,
|
|
|
|
child: FlowyText(dateFormatter(object.modifiedTime)),
|
|
|
|
),
|
2022-09-21 11:46:32 +08:00
|
|
|
SizedBox(
|
2022-11-19 17:53:30 +08:00
|
|
|
width: TrashSizes.createTimeWidth,
|
|
|
|
child: FlowyText(dateFormatter(object.createTime)),
|
|
|
|
),
|
2021-10-14 14:34:22 +08:00
|
|
|
const Spacer(),
|
|
|
|
FlowyIconButton(
|
2023-04-26 22:27:07 -05:00
|
|
|
iconColorOnHover: Theme.of(context).colorScheme.onSurface,
|
|
|
|
width: TrashSizes.actionIconWidth,
|
2021-10-14 14:34:22 +08:00
|
|
|
onPressed: onRestore,
|
2022-09-21 11:46:32 +08:00
|
|
|
iconPadding: const EdgeInsets.all(5),
|
2023-08-14 13:34:01 -07:00
|
|
|
icon: const FlowySvg(FlowySvgs.restore_s),
|
2021-10-14 14:34:22 +08:00
|
|
|
),
|
|
|
|
const HSpace(20),
|
|
|
|
FlowyIconButton(
|
2023-04-26 22:27:07 -05:00
|
|
|
iconColorOnHover: Theme.of(context).colorScheme.onSurface,
|
|
|
|
width: TrashSizes.actionIconWidth,
|
2021-10-14 14:34:22 +08:00
|
|
|
onPressed: onDelete,
|
2022-09-21 11:46:32 +08:00
|
|
|
iconPadding: const EdgeInsets.all(5),
|
2023-08-14 13:34:01 -07:00
|
|
|
icon: const FlowySvg(FlowySvgs.delete_s),
|
2021-10-14 14:34:22 +08:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2021-11-16 21:38:39 +08:00
|
|
|
|
|
|
|
String dateFormatter($fixnum.Int64 inputTimestamps) {
|
2023-03-10 17:33:25 +08:00
|
|
|
final outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
|
2023-05-09 22:37:20 +08:00
|
|
|
final date =
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(inputTimestamps.toInt() * 1000);
|
2023-03-10 17:33:25 +08:00
|
|
|
final outputDate = outputFormat.format(date);
|
2021-11-16 21:38:39 +08:00
|
|
|
return outputDate;
|
|
|
|
}
|
2021-10-14 14:34:22 +08:00
|
|
|
}
|