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';
|
2022-07-04 15:00:54 +08:00
|
|
|
import 'package:flowy_sdk/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(
|
|
|
|
width: TrashSizes.fileNameWidth,
|
|
|
|
child: FlowyText(object.name, fontSize: 12)),
|
|
|
|
SizedBox(
|
|
|
|
width: TrashSizes.lashModifyWidth,
|
|
|
|
child: FlowyText(dateFormatter(object.modifiedTime), fontSize: 12)),
|
|
|
|
SizedBox(
|
|
|
|
width: TrashSizes.createTimeWidth,
|
|
|
|
child: FlowyText(dateFormatter(object.createTime), fontSize: 12)),
|
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",
|
|
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
|
|
),
|
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",
|
|
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
|
|
),
|
2021-10-14 14:34:22 +08:00
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
2021-11-16 21:38:39 +08:00
|
|
|
|
|
|
|
String dateFormatter($fixnum.Int64 inputTimestamps) {
|
|
|
|
var outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
|
2022-09-21 11:46:32 +08:00
|
|
|
var date =
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(inputTimestamps.toInt() * 1000);
|
2021-11-16 21:38:39 +08:00
|
|
|
var outputDate = outputFormat.format(date);
|
|
|
|
return outputDate;
|
|
|
|
}
|
2021-10-14 14:34:22 +08:00
|
|
|
}
|