mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-27 21:16:48 +00:00
* Change from fontawesome to tabler icons - Consistent with the frontend * Cleanup conflicts * Use double quotes * remove unused import * Update release notes * Migrate some google icons to tabler icons * Icon update * Properly support display of custom icons * Fix lookup
81 lines
1.7 KiB
Dart
81 lines
1.7 KiB
Dart
import "package:flutter/material.dart";
|
|
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
|
import "package:inventree/inventree/model.dart";
|
|
import "package:inventree/widget/refreshable_state.dart";
|
|
import "package:flutter_markdown/flutter_markdown.dart";
|
|
import "package:inventree/l10.dart";
|
|
|
|
|
|
/*
|
|
* A widget for displaying the notes associated with a given model.
|
|
* We need to pass in the following parameters:
|
|
*
|
|
* - Model instance
|
|
* - Title for the app bar
|
|
*/
|
|
class NotesWidget extends StatefulWidget {
|
|
|
|
const NotesWidget(this.model, {Key? key}) : super(key: key);
|
|
|
|
final InvenTreeModel model;
|
|
|
|
@override
|
|
_NotesState createState() => _NotesState();
|
|
}
|
|
|
|
|
|
/*
|
|
* Class representing the state of the NotesWidget
|
|
*/
|
|
class _NotesState extends RefreshableState<NotesWidget> {
|
|
|
|
_NotesState();
|
|
|
|
@override
|
|
Future<void> request(BuildContext context) async {
|
|
await widget.model.reload();
|
|
}
|
|
|
|
@override
|
|
String getAppBarTitle() => L10().editNotes;
|
|
|
|
@override
|
|
List<Widget> appBarActions(BuildContext context) {
|
|
|
|
List<Widget> actions = [];
|
|
|
|
if (widget.model.canEdit) {
|
|
actions.add(
|
|
IconButton(
|
|
icon: Icon(TablerIcons.edit),
|
|
tooltip: L10().edit,
|
|
onPressed: () {
|
|
widget.model.editForm(
|
|
context,
|
|
L10().editNotes,
|
|
fields: {
|
|
"notes": {
|
|
"multiline": true,
|
|
}
|
|
},
|
|
onSuccess: (data) async {
|
|
refresh(context);
|
|
}
|
|
);
|
|
}
|
|
)
|
|
);
|
|
}
|
|
|
|
return actions;
|
|
}
|
|
|
|
@override
|
|
Widget getBody(BuildContext context) {
|
|
return Markdown(
|
|
selectable: false,
|
|
data: widget.model.notes,
|
|
);
|
|
}
|
|
|
|
} |