2022-10-23 15:57:59 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-29 20:55:38 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2022-10-23 15:57:59 +00:00
|
|
|
|
2022-10-29 20:55:38 +00:00
|
|
|
import '../canvas/drawing_page.dart';
|
|
|
|
import '../context/file_change_notifier.dart';
|
2022-10-29 19:39:08 +00:00
|
|
|
|
|
|
|
class NoteTileData {
|
|
|
|
final String name;
|
|
|
|
final String relativePath;
|
|
|
|
final DateTime lastModified;
|
|
|
|
|
|
|
|
NoteTileData(this.name, this.relativePath, this.lastModified);
|
|
|
|
}
|
|
|
|
|
2022-10-23 15:57:59 +00:00
|
|
|
class NoteTile extends StatelessWidget {
|
2022-10-29 19:39:08 +00:00
|
|
|
const NoteTile({Key? key, required this.data}) : super(key: key);
|
|
|
|
|
|
|
|
final NoteTileData data;
|
2022-10-23 15:57:59 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-10-29 19:39:08 +00:00
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
Navigator.push(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(
|
2022-10-30 20:57:13 +00:00
|
|
|
builder: (context) =>
|
|
|
|
DrawingPage(filePath: data.relativePath, name: data.name),
|
2022-10-23 15:57:59 +00:00
|
|
|
),
|
2022-10-29 20:55:38 +00:00
|
|
|
).then((value) =>
|
|
|
|
Provider.of<FileChangeNotifier>(context, listen: false)
|
|
|
|
.loadAllNotes());
|
2022-10-29 19:39:08 +00:00
|
|
|
},
|
|
|
|
child: SizedBox(
|
|
|
|
width: 100,
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
height: 150,
|
|
|
|
width: 100,
|
|
|
|
child: Container(
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
data.name,
|
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
Text('${data.lastModified.hour}:${data.lastModified.minute}',
|
|
|
|
style: const TextStyle(color: Colors.white))
|
|
|
|
],
|
|
|
|
),
|
2022-10-23 15:57:59 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|