mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:19:17 +03:30
314 lines
14 KiB
Dart
Executable File
314 lines
14 KiB
Dart
Executable File
import 'package:cssd/config/colors.dart';
|
|
import 'package:cssd/models/item_model.dart';
|
|
import 'package:cssd/providers/auth.dart';
|
|
import 'package:cssd/providers/items.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../config/routes.dart';
|
|
|
|
class ItemItemBox extends StatelessWidget {
|
|
final ItemResultObject? item;
|
|
|
|
const ItemItemBox({
|
|
Key? key,
|
|
required double deviceBlockSize,
|
|
this.item,
|
|
}) : _deviceBlockSize = deviceBlockSize,
|
|
super(key: key);
|
|
|
|
final double _deviceBlockSize;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final userData = Provider.of<Auth>(context, listen: false).user;
|
|
return GestureDetector(
|
|
onTap: () => Navigator.of(context).pushNamed(
|
|
Routes.itemDetailScreen,
|
|
arguments: item!.id,
|
|
),
|
|
child: Card(
|
|
elevation: 1,
|
|
child: Container(
|
|
padding: EdgeInsets.all(8),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
// if (item!.udi != null)
|
|
// Container(
|
|
// padding: const EdgeInsets.all(6.0),
|
|
// child: Text(
|
|
// item!.udi!,
|
|
// style: TextStyle(
|
|
// fontWeight: FontWeight.w700,
|
|
// fontSize: 3 * _deviceBlockSize,
|
|
// ),
|
|
// ),
|
|
// ),
|
|
// if (item!.udi != null)
|
|
// SizedBox(
|
|
// width: 3 * _deviceBlockSize,
|
|
// ),
|
|
// Spacer(),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Container(
|
|
width: 40 * _deviceBlockSize,
|
|
child: Text(
|
|
item!.name,
|
|
style: TextStyle(
|
|
fontSize: 3 * _deviceBlockSize,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: 30 * _deviceBlockSize,
|
|
child: Row(
|
|
children: [
|
|
Text(
|
|
'Udi: ',
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontSize: 3 * _deviceBlockSize,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
Text(
|
|
item!.udi ?? '',
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: 30 * _deviceBlockSize,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Text(
|
|
'Owner: ',
|
|
style: TextStyle(
|
|
color: Colors.grey,
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
Text(
|
|
item!.userName,
|
|
style: TextStyle(
|
|
fontSize: 3 * _deviceBlockSize,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Spacer(),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: <Widget>[
|
|
userData['roles']?.contains('User') ?? false
|
|
? Container()
|
|
: InkWell(
|
|
customBorder: CircleBorder(),
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text(
|
|
item!.status == 1
|
|
? 'Are you Reject this item?'
|
|
: 'Are you Confirm this item?',
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
onPressed: () {
|
|
Provider.of<ItemProvider>(context,
|
|
listen: false)
|
|
.changeStatus(item!.id)
|
|
.then(
|
|
(value) {
|
|
if (value) {
|
|
print('true');
|
|
}
|
|
Navigator.of(context)
|
|
.popAndPushNamed(Routes
|
|
.itemResultScreen);
|
|
},
|
|
);
|
|
},
|
|
child: Text('Yes'),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
child: Text('No'),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(7),
|
|
width: 8 * _deviceBlockSize,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: item!.status == 1 ? kPink : kBlue,
|
|
),
|
|
child: Icon(
|
|
item!.status == 1 ? Icons.close : Icons.check,
|
|
size: 4 * _deviceBlockSize,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 5.0,
|
|
),
|
|
// userData['roles']?.contains('User') ?? false
|
|
// ? Container()
|
|
// : InkWell(
|
|
// onTap: () {
|
|
// Navigator.of(context).pushNamed(
|
|
// Routes.itemUpdateScreen,
|
|
// arguments: item!.id,
|
|
// );
|
|
// },
|
|
// child: Icon(
|
|
// Icons.edit,
|
|
// size: 5 * _deviceBlockSize,
|
|
// color: Colors.black,
|
|
// ),
|
|
// ),
|
|
// SizedBox(
|
|
// width: 5.0,
|
|
// ),
|
|
userData['roles']?.contains('Admin') ?? false
|
|
? InkWell(
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text('Delete'),
|
|
content: Text(
|
|
'Are you sure you want delete this Item?',),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text('Yes'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
Provider.of<ItemProvider>(context,
|
|
listen: false)
|
|
.removeItems(item!.id);
|
|
},
|
|
),
|
|
TextButton(
|
|
child: Text('No'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
child: Icon(
|
|
Icons.delete,
|
|
size: 5 * _deviceBlockSize,
|
|
color: Colors.black,
|
|
),
|
|
)
|
|
: userData['roles']?.contains('Supervisor')
|
|
? item!.packageId != null
|
|
? InkWell(
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return AlertDialog(
|
|
title: Text('Delete'),
|
|
content: Text(
|
|
'Are you sure you want delete this Item?',
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text('Yes'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
Provider.of<ItemProvider>(
|
|
context,
|
|
listen: false)
|
|
.removeItems(item!.id);
|
|
},
|
|
),
|
|
TextButton(
|
|
child: Text('No'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
},
|
|
child: Icon(
|
|
Icons.delete,
|
|
size: 5 * _deviceBlockSize,
|
|
color: Colors.black,
|
|
),
|
|
)
|
|
: Container()
|
|
: Container(),
|
|
SizedBox(
|
|
width: 5.0,
|
|
),
|
|
InkWell(
|
|
customBorder: CircleBorder(),
|
|
onTap: () {
|
|
Navigator.of(context).pushNamed(
|
|
Routes.itemDetailScreen,
|
|
arguments: item!.id,
|
|
);
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(7),
|
|
width: 9 * _deviceBlockSize,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: Colors.black,
|
|
),
|
|
child: Icon(
|
|
FontAwesomeIcons.fileAlt,
|
|
size: 5 * _deviceBlockSize,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|