mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Merge pull request #13 from SchrodingersGat/icons
Add FontAwesome icons
This commit is contained in:
commit
804ed72dc6
@ -8,6 +8,8 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
import 'barcode.dart';
|
import 'barcode.dart';
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
@ -116,7 +118,29 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
bool _serverConnection = false;
|
bool _serverConnection = false;
|
||||||
|
|
||||||
|
FaIcon _serverIcon = new FaIcon(FontAwesomeIcons.spinner);
|
||||||
|
|
||||||
Color _serverStatusColor = Color.fromARGB(255, 50, 50, 250);
|
Color _serverStatusColor = Color.fromARGB(255, 50, 50, 250);
|
||||||
|
|
||||||
|
void onConnectSuccess(String msg) {
|
||||||
|
_serverConnection = true;
|
||||||
|
_serverMessage = msg;
|
||||||
|
_serverStatus = "Connected to $_serverAddress";
|
||||||
|
_serverStatusColor = Color.fromARGB(255, 50, 250, 50);
|
||||||
|
_serverIcon = new FaIcon(FontAwesomeIcons.checkCircle, color: _serverStatusColor);
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
|
void onConnectFailure(String msg) {
|
||||||
|
_serverConnection = false;
|
||||||
|
_serverMessage = msg;
|
||||||
|
_serverStatus = "Could not connect to $_serverAddress";
|
||||||
|
_serverStatusColor = Color.fromARGB(255, 250, 50, 50);
|
||||||
|
_serverIcon = new FaIcon(FontAwesomeIcons.timesCircle, color: _serverStatusColor);
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test the server connection
|
* Test the server connection
|
||||||
@ -125,40 +149,32 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
|
|
||||||
var prefs = await SharedPreferences.getInstance();
|
var prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
print("Checking server connection");
|
|
||||||
|
|
||||||
_serverAddress = prefs.getString("server");
|
_serverAddress = prefs.getString("server");
|
||||||
|
|
||||||
InvenTreeAPI().connect().then((bool result) {
|
InvenTreeAPI().connect().then((bool result) {
|
||||||
print("Connection status: $result");
|
|
||||||
_serverConnection = result;
|
|
||||||
|
|
||||||
if (_serverConnection) {
|
if (result) {
|
||||||
_serverStatus = "Connected to server: $_serverAddress";
|
onConnectSuccess("");
|
||||||
_serverMessage = "";
|
|
||||||
_serverStatusColor = Color.fromARGB(255, 50, 250, 50);
|
|
||||||
} else {
|
} else {
|
||||||
_serverStatus = "Could not connect to server: $_serverAddress";
|
onConnectFailure("Could not connect to server");
|
||||||
_serverStatusColor = Color.fromARGB(255, 250, 50, 50);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {});
|
|
||||||
|
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
|
|
||||||
|
String fault = "Connection error";
|
||||||
|
|
||||||
_serverConnection = false;
|
_serverConnection = false;
|
||||||
_serverStatusColor = Color.fromARGB(255, 250, 50, 50);
|
_serverStatusColor = Color.fromARGB(255, 250, 50, 50);
|
||||||
|
|
||||||
_serverStatus = "Error connecting to $_serverAddress";
|
_serverStatus = "Error connecting to $_serverAddress";
|
||||||
|
|
||||||
if (e is TimeoutException) {
|
if (e is TimeoutException) {
|
||||||
_serverMessage = "No response from server";
|
fault = "Timeout: No response from server";
|
||||||
} else {
|
} else {
|
||||||
_serverMessage = e.toString();
|
fault = e.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Server error: $_serverMessage");
|
onConnectFailure(fault);
|
||||||
|
|
||||||
setState(() {});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +233,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Column(
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: new Icon(Icons.search),
|
icon: new FaIcon(FontAwesomeIcons.search),
|
||||||
tooltip: 'Search',
|
tooltip: 'Search',
|
||||||
onPressed: _search,
|
onPressed: _search,
|
||||||
),
|
),
|
||||||
@ -227,7 +243,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Column(
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: new Icon(Icons.search),
|
icon: new FaIcon(FontAwesomeIcons.barcode),
|
||||||
tooltip: 'Scan Barcode',
|
tooltip: 'Scan Barcode',
|
||||||
onPressed: _scan,
|
onPressed: _scan,
|
||||||
),
|
),
|
||||||
@ -253,7 +269,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Column(
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: new Icon(Icons.map),
|
icon: new FaIcon(FontAwesomeIcons.boxes),
|
||||||
tooltip: 'Stock',
|
tooltip: 'Stock',
|
||||||
onPressed: _stock,
|
onPressed: _stock,
|
||||||
),
|
),
|
||||||
@ -263,7 +279,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
Column(
|
Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: new Icon(Icons.business),
|
icon: new FaIcon(FontAwesomeIcons.industry),
|
||||||
tooltip: 'Suppliers',
|
tooltip: 'Suppliers',
|
||||||
onPressed: _suppliers,
|
onPressed: _suppliers,
|
||||||
),
|
),
|
||||||
@ -278,23 +294,14 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Card(
|
child: ListTile(
|
||||||
child: Column(
|
title: Text("$_serverStatus",
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
style: TextStyle(color: _serverStatusColor),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Text('$_serverStatus',
|
|
||||||
style: TextStyle(
|
|
||||||
color: _serverStatusColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text('$_serverMessage',
|
|
||||||
style: TextStyle(
|
|
||||||
color: _serverStatusColor,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
subtitle: Text("$_serverMessage",
|
||||||
|
style: TextStyle(color: _serverStatusColor),
|
||||||
),
|
),
|
||||||
|
leading: _serverIcon,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -5,6 +5,7 @@ import 'package:InvenTree/widget/category_display.dart';
|
|||||||
import 'package:InvenTree/widget/location_display.dart';
|
import 'package:InvenTree/widget/location_display.dart';
|
||||||
|
|
||||||
import 'package:InvenTree/settings.dart';
|
import 'package:InvenTree/settings.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
class InvenTreeDrawer extends StatelessWidget {
|
class InvenTreeDrawer extends StatelessWidget {
|
||||||
|
|
||||||
@ -78,13 +79,13 @@ class InvenTreeDrawer extends StatelessWidget {
|
|||||||
new Divider(),
|
new Divider(),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
title: new Text("Search"),
|
title: new Text("Search"),
|
||||||
leading: new Icon(Icons.search),
|
leading: new FaIcon(FontAwesomeIcons.search),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
),
|
),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
title: new Text("Scan"),
|
title: new Text("Scan Barcode"),
|
||||||
onTap: _scan,
|
onTap: _scan,
|
||||||
leading: new Icon(Icons.search),
|
leading: new FaIcon(FontAwesomeIcons.barcode),
|
||||||
),
|
),
|
||||||
new Divider(),
|
new Divider(),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
@ -94,11 +95,12 @@ class InvenTreeDrawer extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
title: new Text("Stock"),
|
title: new Text("Stock"),
|
||||||
|
leading: new FaIcon(FontAwesomeIcons.boxes),
|
||||||
onTap: _showStock,
|
onTap: _showStock,
|
||||||
),
|
),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
title: new Text("Suppliers"),
|
title: new Text("Suppliers"),
|
||||||
leading: new Icon(Icons.business),
|
leading: new FaIcon(FontAwesomeIcons.industry),
|
||||||
onTap: null,
|
onTap: null,
|
||||||
),
|
),
|
||||||
new Divider(),
|
new Divider(),
|
||||||
|
@ -100,6 +100,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
font_awesome_flutter:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: font_awesome_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "8.8.1"
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -34,6 +34,8 @@ dependencies:
|
|||||||
|
|
||||||
package_info: ^0.4.0+16
|
package_info: ^0.4.0+16
|
||||||
|
|
||||||
|
font_awesome_flutter: ^8.8.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user