mirror of
https://github.com/inventree/inventree-app.git
synced 2025-12-04 03:09:56 +00:00
Attachments refactor (#737)
* refactor attachment code into its own file * Add getters * Remove custom models for each type of attachment * Refactor existing widgets * Fix double camera open bug * Remove dead code * Remove unused imports * Refactor common code * format * Update release notes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_speed_dial/flutter_speed_dial.dart";
|
||||
import "package:flutter_tabler_icons/flutter_tabler_icons.dart";
|
||||
import "package:inventree/inventree/attachment.dart";
|
||||
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/api.dart";
|
||||
@@ -184,15 +185,15 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
}
|
||||
});
|
||||
|
||||
InvenTreeCompanyAttachment().countAttachments(widget.company.pk).then((
|
||||
value,
|
||||
) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
InvenTreeAttachment()
|
||||
.countAttachments(InvenTreeCompany.MODEL_TYPE, widget.company.pk)
|
||||
.then((value) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
attachmentCount = value;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> editCompany(BuildContext context) async {
|
||||
@@ -393,29 +394,19 @@ class _CompanyDetailState extends RefreshableState<CompanyDetailWidget> {
|
||||
);
|
||||
}
|
||||
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(L10().attachments),
|
||||
leading: Icon(TablerIcons.file, color: COLOR_ACTION),
|
||||
trailing: LinkIcon(
|
||||
text: attachmentCount > 0 ? attachmentCount.toString() : null,
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AttachmentWidget(
|
||||
InvenTreeCompanyAttachment(),
|
||||
widget.company.pk,
|
||||
widget.company.name,
|
||||
InvenTreeCompany().canEdit,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile? attachmentTile = ShowAttachmentsItem(
|
||||
context,
|
||||
InvenTreeCompany.MODEL_TYPE,
|
||||
widget.company.pk,
|
||||
widget.company.name,
|
||||
attachmentCount,
|
||||
widget.company.canEdit,
|
||||
);
|
||||
|
||||
if (attachmentTile != null) {
|
||||
tiles.add(attachmentTile);
|
||||
}
|
||||
|
||||
return tiles;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user