2021-10-14 14:34:22 +08:00
|
|
|
import 'package:flowy_infra/image.dart';
|
|
|
|
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-01-08 12:10:53 +08:00
|
|
|
import 'package:appflowy_backend/protobuf/flowy-folder/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;
|
2022-09-21 11:46:32 +08:00
|
|
|
const TrashCell(
|
|
|
|
{required this.object,
|
|
|
|
required this.onRestore,
|
|
|
|
required this.onDelete,
|
|
|
|
Key? key})
|
|
|
|
: super(key: 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(
|
2022-09-21 11:46:32 +08:00
|
|
|
width: 26,
|
2021-10-14 14:34:22 +08:00
|
|
|
onPressed: onRestore,
|
2022-09-21 11:46:32 +08:00
|
|
|
iconPadding: const EdgeInsets.all(5),
|
2022-11-10 14:22:18 +08:00
|
|
|
icon: svgWidget(
|
|
|
|
"editor/restore",
|
2023-03-29 20:44:37 -05:00
|
|
|
color: Theme.of(context).iconTheme.color,
|
2022-11-10 14:22:18 +08:00
|
|
|
),
|
2021-10-14 14:34:22 +08:00
|
|
|
),
|
|
|
|
const HSpace(20),
|
|
|
|
FlowyIconButton(
|
2022-09-21 11:46:32 +08:00
|
|
|
width: 26,
|
2021-10-14 14:34:22 +08:00
|
|
|
onPressed: onDelete,
|
2022-09-21 11:46:32 +08:00
|
|
|
iconPadding: const EdgeInsets.all(5),
|
2022-11-10 14:22:18 +08:00
|
|
|
icon: svgWidget(
|
|
|
|
"editor/delete",
|
2023-03-29 20:44:37 -05:00
|
|
|
color: Theme.of(context).iconTheme.color,
|
2022-11-10 14:22:18 +08:00
|
|
|
),
|
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');
|
|
|
|
final date = DateTime.fromMillisecondsSinceEpoch(
|
|
|
|
inputTimestamps.toInt() * 1000,
|
|
|
|
isUtc: true,
|
|
|
|
);
|
|
|
|
final outputDate = outputFormat.format(date);
|
2021-11-16 21:38:39 +08:00
|
|
|
return outputDate;
|
|
|
|
}
|
2021-10-14 14:34:22 +08:00
|
|
|
}
|