mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
* Add "global actions" to title bar * Implement actions * Add "speed dial" action buttons * tweak global action icons * Refactor actions for "stock item" display * Refactor "part" detail * part category * SupplierPart * More updates * Add BottomAppBar * Add a global bottom app bar * Move "edit" buttons back to the app bar * tweaks * Updates to drawer navigation menu * home screen improvements * text tweaks * Fix appBarTitle for notifications widget * Update "tabs" for category display * Fix for attachment widget * Update tabs for purchaseorder view * Update part display * Cleanup * Add "BOM" tab to part detail widget * Paginated list search cleanup * Update release notes * Update old function * linting * linting * Tweaks to bottomappbar - Increase icon size slightly - Adjust "actions" icon
78 lines
1.7 KiB
Dart
78 lines
1.7 KiB
Dart
import "dart:io";
|
|
|
|
import "package:flutter/material.dart";
|
|
|
|
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
|
|
|
import "package:inventree/api.dart";
|
|
import "package:inventree/inventree/part.dart";
|
|
import "package:inventree/widget/fields.dart";
|
|
import "package:inventree/widget/refreshable_state.dart";
|
|
import "package:inventree/widget/snacks.dart";
|
|
import "package:inventree/l10.dart";
|
|
|
|
class PartImageWidget extends StatefulWidget {
|
|
|
|
const PartImageWidget(this.part, {Key? key}) : super(key: key);
|
|
|
|
final InvenTreePart part;
|
|
|
|
@override
|
|
_PartImageState createState() => _PartImageState(part);
|
|
|
|
}
|
|
|
|
|
|
class _PartImageState extends RefreshableState<PartImageWidget> {
|
|
|
|
_PartImageState(this.part);
|
|
|
|
final InvenTreePart part;
|
|
|
|
@override
|
|
Future<void> request(BuildContext context) async {
|
|
await part.reload();
|
|
}
|
|
|
|
@override
|
|
String getAppBarTitle() => part.fullname;
|
|
|
|
@override
|
|
List<Widget> appBarActions(BuildContext context) {
|
|
|
|
List<Widget> actions = [];
|
|
|
|
if (InvenTreeAPI().checkPermission("part", "change")) {
|
|
|
|
// File upload
|
|
actions.add(
|
|
IconButton(
|
|
icon: FaIcon(FontAwesomeIcons.fileArrowUp),
|
|
onPressed: () async {
|
|
|
|
FilePickerDialog.pickFile(
|
|
onPicked: (File file) async {
|
|
final result = await part.uploadImage(file);
|
|
|
|
if (!result) {
|
|
showSnackIcon(L10().uploadFailed, success: false);
|
|
}
|
|
|
|
refresh(context);
|
|
}
|
|
);
|
|
|
|
},
|
|
)
|
|
);
|
|
}
|
|
|
|
return actions;
|
|
}
|
|
|
|
@override
|
|
Widget getBody(BuildContext context) {
|
|
return InvenTreeAPI().getImage(part.image);
|
|
}
|
|
|
|
} |