cdb_ui/lib/pages/flow/flow_note.dart

59 lines
1.5 KiB
Dart
Raw Permalink Normal View History

2024-09-25 07:02:50 +00:00
import 'package:cdb_ui/pages/transaction.dart';
import 'package:flutter/material.dart';
import 'package:cdb_ui/api.dart' as API;
class AddNotePage extends StatelessWidget {
late final TextEditingController _noteController = TextEditingController();
final API.Flow flow;
final Function refresh;
AddNotePage(this.flow, this.refresh, {super.key});
2024-09-25 16:14:42 +00:00
void _submit(BuildContext context) {
2024-09-25 07:02:50 +00:00
API.API().addNoteToFlow(flow.id, _noteController.text).then((x) {
refresh();
Navigator.of(context).pop();
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Add Note"),
),
body: Column(
children: [
TextFormField(
decoration: const InputDecoration(labelText: 'Note'),
controller: _noteController,
maxLines: 10),
const SizedBox(
height: 14,
),
ElevatedButton(
2024-09-25 16:14:42 +00:00
onPressed: () => _submit(context), child: const Text("Add Note"))
2024-09-25 07:02:50 +00:00
],
),
);
}
}
class FlowNoteCard extends StatelessWidget {
final API.FlowNote note;
const FlowNoteCard(this.note, {super.key});
@override
Widget build(BuildContext context) {
return Card(
child: ListTile(
2024-09-26 18:20:39 +00:00
dense: true,
2024-09-25 07:02:50 +00:00
title: Text(tsFormat(note.timestamp),
style: const TextStyle(fontSize: 12)),
subtitle: Text(note.content, overflow: TextOverflow.ellipsis),
),
);
}
}