mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Merge pull request #160 from inventree/attachment-links
Adds ability to display "links" uploaded to attachment fields
This commit is contained in:
commit
8eba549bb0
@ -4,7 +4,8 @@
|
|||||||
### 0.7.3 - June 2022
|
### 0.7.3 - June 2022
|
||||||
---
|
---
|
||||||
|
|
||||||
-
|
- Adds ability to display link URLs in attachments view
|
||||||
|
- Updated translations
|
||||||
|
|
||||||
### 0.7.2 - June 2022
|
### 0.7.2 - June 2022
|
||||||
---
|
---
|
||||||
|
@ -9,11 +9,13 @@ import "dart:io";
|
|||||||
|
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||||
|
import "package:inventree/app_colors.dart";
|
||||||
import "package:inventree/inventree/model.dart";
|
import "package:inventree/inventree/model.dart";
|
||||||
import "package:inventree/widget/fields.dart";
|
import "package:inventree/widget/fields.dart";
|
||||||
import "package:inventree/widget/snacks.dart";
|
import "package:inventree/widget/snacks.dart";
|
||||||
import "package:inventree/widget/refreshable_state.dart";
|
import "package:inventree/widget/refreshable_state.dart";
|
||||||
import "package:inventree/l10.dart";
|
import "package:inventree/l10.dart";
|
||||||
|
import "package:url_launcher/url_launcher.dart";
|
||||||
|
|
||||||
class AttachmentWidget extends StatefulWidget {
|
class AttachmentWidget extends StatefulWidget {
|
||||||
|
|
||||||
@ -114,15 +116,32 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
|||||||
|
|
||||||
List<Widget> tiles = [];
|
List<Widget> tiles = [];
|
||||||
|
|
||||||
|
// An "attachment" can either be a file, or a URL
|
||||||
for (var attachment in attachments) {
|
for (var attachment in attachments) {
|
||||||
tiles.add(ListTile(
|
|
||||||
title: Text(attachment.filename),
|
if (attachment.filename.isNotEmpty) {
|
||||||
subtitle: Text(attachment.comment),
|
tiles.add(ListTile(
|
||||||
leading: FaIcon(attachment.icon),
|
title: Text(attachment.filename),
|
||||||
onTap: () async {
|
subtitle: Text(attachment.comment),
|
||||||
await attachment.downloadAttachment();
|
leading: FaIcon(attachment.icon, color: COLOR_CLICK),
|
||||||
},
|
onTap: () async {
|
||||||
));
|
await attachment.downloadAttachment();
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (attachment.link.isNotEmpty) {
|
||||||
|
tiles.add(ListTile(
|
||||||
|
title: Text(attachment.link),
|
||||||
|
subtitle: Text(attachment.comment),
|
||||||
|
leading: FaIcon(FontAwesomeIcons.link, color: COLOR_CLICK),
|
||||||
|
onTap: () async {
|
||||||
|
if (await canLaunch(attachment.link)) {
|
||||||
|
await launch(attachment.link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tiles.isEmpty) {
|
if (tiles.isEmpty) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user