2
0
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:
Oliver 2020-04-05 13:07:14 +10:00 committed by GitHub
commit 804ed72dc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 40 deletions

View File

@ -8,6 +8,8 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'barcode.dart';
import 'dart:convert';
@ -116,8 +118,30 @@ class _MyHomePageState extends State<MyHomePage> {
bool _serverConnection = false;
FaIcon _serverIcon = new FaIcon(FontAwesomeIcons.spinner);
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
*/
@ -125,40 +149,32 @@ class _MyHomePageState extends State<MyHomePage> {
var prefs = await SharedPreferences.getInstance();
print("Checking server connection");
_serverAddress = prefs.getString("server");
InvenTreeAPI().connect().then((bool result) {
print("Connection status: $result");
_serverConnection = result;
if (_serverConnection) {
_serverStatus = "Connected to server: $_serverAddress";
_serverMessage = "";
_serverStatusColor = Color.fromARGB(255, 50, 250, 50);
if (result) {
onConnectSuccess("");
} else {
_serverStatus = "Could not connect to server: $_serverAddress";
_serverStatusColor = Color.fromARGB(255, 250, 50, 50);
onConnectFailure("Could not connect to server");
}
setState(() {});
}).catchError((e) {
String fault = "Connection error";
_serverConnection = false;
_serverStatusColor = Color.fromARGB(255, 250, 50, 50);
_serverStatus = "Error connecting to $_serverAddress";
if (e is TimeoutException) {
_serverMessage = "No response from server";
fault = "Timeout: No response from server";
} else {
_serverMessage = e.toString();
fault = e.toString();
}
print("Server error: $_serverMessage");
setState(() {});
onConnectFailure(fault);
});
}
@ -217,7 +233,7 @@ class _MyHomePageState extends State<MyHomePage> {
Column(
children: <Widget>[
IconButton(
icon: new Icon(Icons.search),
icon: new FaIcon(FontAwesomeIcons.search),
tooltip: 'Search',
onPressed: _search,
),
@ -227,7 +243,7 @@ class _MyHomePageState extends State<MyHomePage> {
Column(
children: <Widget>[
IconButton(
icon: new Icon(Icons.search),
icon: new FaIcon(FontAwesomeIcons.barcode),
tooltip: 'Scan Barcode',
onPressed: _scan,
),
@ -253,7 +269,7 @@ class _MyHomePageState extends State<MyHomePage> {
Column(
children: <Widget>[
IconButton(
icon: new Icon(Icons.map),
icon: new FaIcon(FontAwesomeIcons.boxes),
tooltip: 'Stock',
onPressed: _stock,
),
@ -263,7 +279,7 @@ class _MyHomePageState extends State<MyHomePage> {
Column(
children: <Widget>[
IconButton(
icon: new Icon(Icons.business),
icon: new FaIcon(FontAwesomeIcons.industry),
tooltip: 'Suppliers',
onPressed: _suppliers,
),
@ -278,23 +294,14 @@ class _MyHomePageState extends State<MyHomePage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: Card(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('$_serverStatus',
style: TextStyle(
color: _serverStatusColor,
),
),
Text('$_serverMessage',
style: TextStyle(
color: _serverStatusColor,
),
child: ListTile(
title: Text("$_serverStatus",
style: TextStyle(color: _serverStatusColor),
),
],
subtitle: Text("$_serverMessage",
style: TextStyle(color: _serverStatusColor),
),
leading: _serverIcon,
),
),
],

View File

@ -5,6 +5,7 @@ import 'package:InvenTree/widget/category_display.dart';
import 'package:InvenTree/widget/location_display.dart';
import 'package:InvenTree/settings.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class InvenTreeDrawer extends StatelessWidget {
@ -78,13 +79,13 @@ class InvenTreeDrawer extends StatelessWidget {
new Divider(),
new ListTile(
title: new Text("Search"),
leading: new Icon(Icons.search),
leading: new FaIcon(FontAwesomeIcons.search),
onTap: null,
),
new ListTile(
title: new Text("Scan"),
title: new Text("Scan Barcode"),
onTap: _scan,
leading: new Icon(Icons.search),
leading: new FaIcon(FontAwesomeIcons.barcode),
),
new Divider(),
new ListTile(
@ -94,11 +95,12 @@ class InvenTreeDrawer extends StatelessWidget {
),
new ListTile(
title: new Text("Stock"),
leading: new FaIcon(FontAwesomeIcons.boxes),
onTap: _showStock,
),
new ListTile(
title: new Text("Suppliers"),
leading: new Icon(Icons.business),
leading: new FaIcon(FontAwesomeIcons.industry),
onTap: null,
),
new Divider(),

View File

@ -100,6 +100,13 @@ packages:
description: flutter
source: sdk
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:
dependency: "direct main"
description:

View File

@ -34,6 +34,8 @@ dependencies:
package_info: ^0.4.0+16
font_awesome_flutter: ^8.8.1
dev_dependencies:
flutter_test:
sdk: flutter