mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Add function to open a link
- Does not seem to actually ... work.. yet
This commit is contained in:
parent
fc6e90ce0b
commit
02cfeef31e
@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:InvenTree/api.dart';
|
||||
import 'package:InvenTree/widget/dialogs.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
@ -54,6 +55,19 @@ class InvenTreeModel {
|
||||
// Legacy API provided external link as "URL", while newer API uses "link"
|
||||
String get link => jsondata['link'] ?? jsondata['URL'] ?? '';
|
||||
|
||||
void openLink() async {
|
||||
|
||||
if (link.isNotEmpty) {
|
||||
print("Opening link: ${link}");
|
||||
|
||||
if (await canLaunch(link)) {
|
||||
await launch(url);
|
||||
} else {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String get keywords => jsondata['keywords'] as String ?? '';
|
||||
|
||||
// Create a new object from JSON data (not a constructor!)
|
||||
|
@ -267,6 +267,7 @@ class PartList extends StatelessWidget {
|
||||
return ListTile(
|
||||
title: Text("${part.name}"),
|
||||
subtitle: Text("${part.description}"),
|
||||
trailing: Text("${part.inStock}"),
|
||||
leading: InvenTreeAPI().getImage(
|
||||
part.thumbnail,
|
||||
width: 40,
|
||||
|
@ -1,17 +1,18 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:InvenTree/inventree/part.dart';
|
||||
import 'package:InvenTree/widget/category_display.dart';
|
||||
import 'package:InvenTree/widget/dialogs.dart';
|
||||
import 'package:InvenTree/widget/fields.dart';
|
||||
import 'package:InvenTree/widget/part_stock_detail.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:InvenTree/api.dart';
|
||||
import 'package:InvenTree/widget/refreshable_state.dart';
|
||||
import 'package:InvenTree/widget/drawer.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
class PartDetailWidget extends StatefulWidget {
|
||||
|
||||
@ -268,7 +269,9 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
title: Text("${part.link}"),
|
||||
leading: FaIcon(FontAwesomeIcons.link),
|
||||
trailing: Text(""),
|
||||
onTap: null,
|
||||
onTap: () {
|
||||
part.openLink();
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
42
pubspec.lock
42
pubspec.lock
@ -511,6 +511,48 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.3.0-nullsafety.3"
|
||||
url_launcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: url_launcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.7.10"
|
||||
url_launcher_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+4"
|
||||
url_launcher_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+9"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.9"
|
||||
url_launcher_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_web
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.5+1"
|
||||
url_launcher_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.1+3"
|
||||
usage:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -35,6 +35,7 @@ dependencies:
|
||||
sentry: ^3.0.1 # Error reporting
|
||||
flutter_typeahead: ^1.8.1 # Auto-complete input field
|
||||
image_picker: ^0.6.6 # Select or take photos
|
||||
url_launcher: ^5.7.10 # Open link in system browser
|
||||
|
||||
camera:
|
||||
path_provider:
|
||||
|
Loading…
x
Reference in New Issue
Block a user