mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Cleanup home page widget
This commit is contained in:
parent
54d8c1759c
commit
c1a1ef0ad2
@ -240,7 +240,7 @@ class InvenTreeAPI {
|
||||
|
||||
if (address.isEmpty || username.isEmpty || password.isEmpty) {
|
||||
showSnackIcon(
|
||||
"Incomplete profile details",
|
||||
L10().incompleteDetails,
|
||||
icon: FontAwesomeIcons.exclamationCircle,
|
||||
success: false
|
||||
);
|
||||
|
2
lib/l10n
2
lib/l10n
@ -1 +1 @@
|
||||
Subproject commit dba9551b897dca766088e5470704e20edb770499
|
||||
Subproject commit ed69d6efe7672770ee27f4d1b4fc8ab7793266da
|
@ -17,6 +17,7 @@ import 'package:inventree/widget/company_list.dart';
|
||||
import 'package:inventree/widget/location_display.dart';
|
||||
import 'package:inventree/widget/purchase_order_list.dart';
|
||||
import 'package:inventree/widget/search.dart';
|
||||
import 'package:inventree/widget/snacks.dart';
|
||||
import 'package:inventree/widget/spinner.dart';
|
||||
import 'package:inventree/widget/drawer.dart';
|
||||
|
||||
@ -204,37 +205,15 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _header(String label) {
|
||||
return Card(
|
||||
margin: EdgeInsets.symmetric(
|
||||
vertical: 1,
|
||||
horizontal: 10,
|
||||
),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
horizontal: 10,
|
||||
vertical: 1
|
||||
),
|
||||
title: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
Widget _iconButton(BuildContext context, String label, IconData icon, {Function()? callback, String role = "", String permission = ""}) {
|
||||
|
||||
Widget _grid(List<Widget> children) {
|
||||
return GridView.extent(
|
||||
maxCrossAxisExtent: 140,
|
||||
shrinkWrap: true,
|
||||
physics: ClampingScrollPhysics(),
|
||||
children: children,
|
||||
);
|
||||
}
|
||||
bool connected = InvenTreeAPI().isConnected();
|
||||
|
||||
Widget _iconButton(String label, IconData icon, {Function()? callback}) {
|
||||
bool allowed = true;
|
||||
|
||||
if (role.isNotEmpty || permission.isNotEmpty) {
|
||||
allowed = InvenTreeAPI().checkPermission(role, permission);
|
||||
}
|
||||
|
||||
return GestureDetector(
|
||||
child: Card(
|
||||
@ -247,7 +226,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
children: [
|
||||
FaIcon(
|
||||
icon,
|
||||
color: callback == null ? Colors.grey : COLOR_CLICK,
|
||||
color: connected && allowed ? COLOR_CLICK : Colors.grey,
|
||||
),
|
||||
Divider(
|
||||
height: 10,
|
||||
@ -258,11 +237,27 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
]
|
||||
)
|
||||
),
|
||||
onTap: callback,
|
||||
onTap: () {
|
||||
|
||||
if (!allowed) {
|
||||
showSnackIcon(
|
||||
L10().permissionRequired,
|
||||
icon: FontAwesomeIcons.exclamationCircle,
|
||||
success: false,
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (callback != null) {
|
||||
callback();
|
||||
}
|
||||
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@ -291,8 +286,13 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
physics: ClampingScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
_grid([
|
||||
GridView.extent(
|
||||
maxCrossAxisExtent: 140,
|
||||
shrinkWrap: true,
|
||||
physics: ClampingScrollPhysics(),
|
||||
children: [
|
||||
_iconButton(
|
||||
context,
|
||||
L10().scanBarcode,
|
||||
FontAwesomeIcons.barcode,
|
||||
callback: () {
|
||||
@ -300,6 +300,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
),
|
||||
_iconButton(
|
||||
context,
|
||||
L10().search,
|
||||
FontAwesomeIcons.search,
|
||||
callback: () {
|
||||
@ -307,6 +308,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
),
|
||||
_iconButton(
|
||||
context,
|
||||
L10().parts,
|
||||
FontAwesomeIcons.shapes,
|
||||
callback: () {
|
||||
@ -330,6 +332,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
*/
|
||||
|
||||
_iconButton(
|
||||
context,
|
||||
L10().stock,
|
||||
FontAwesomeIcons.boxes,
|
||||
callback: () {
|
||||
@ -337,6 +340,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
),
|
||||
_iconButton(
|
||||
context,
|
||||
L10().purchaseOrders,
|
||||
FontAwesomeIcons.shoppingCart,
|
||||
callback: () {
|
||||
@ -344,10 +348,12 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
),
|
||||
_iconButton(
|
||||
context,
|
||||
L10().salesOrders,
|
||||
FontAwesomeIcons.truck,
|
||||
),
|
||||
_iconButton(
|
||||
context,
|
||||
L10().suppliers,
|
||||
FontAwesomeIcons.building,
|
||||
callback: () {
|
||||
@ -355,6 +361,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
),
|
||||
_iconButton(
|
||||
context,
|
||||
L10().manufacturers,
|
||||
FontAwesomeIcons.industry,
|
||||
callback: () {
|
||||
@ -362,6 +369,7 @@ class _InvenTreeHomePageState extends State<InvenTreeHomePage> {
|
||||
}
|
||||
),
|
||||
_iconButton(
|
||||
context,
|
||||
L10().customers,
|
||||
FontAwesomeIcons.userTie,
|
||||
callback: () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user