mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:28:56 +03:30
237 lines
8.9 KiB
Dart
Executable File
237 lines
8.9 KiB
Dart
Executable File
import 'package:cssd/config/colors.dart';
|
|
import 'package:cssd/models/my_item_model.dart';
|
|
import 'package:cssd/providers/my_items.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../config/routes.dart';
|
|
|
|
class RequestsDataBox extends StatelessWidget {
|
|
final MyItemResultObject? item;
|
|
|
|
const RequestsDataBox({
|
|
Key? key,
|
|
required double deviceBlockSize,
|
|
required this.isAdmin,
|
|
this.item,
|
|
}) : _deviceBlockSize = deviceBlockSize,
|
|
super(key: key);
|
|
|
|
final double _deviceBlockSize;
|
|
final bool isAdmin;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
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>[
|
|
Container(
|
|
padding: const EdgeInsets.all(6.0),
|
|
child: Text(
|
|
item!.id,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 5 * _deviceBlockSize,
|
|
),
|
|
),
|
|
),
|
|
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(
|
|
'Size: ',
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontSize: 3 * _deviceBlockSize,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
Text(
|
|
item!.size,
|
|
overflow: TextOverflow.ellipsis,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w700,
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (isAdmin)
|
|
Container(
|
|
width: 30 * _deviceBlockSize,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Text(
|
|
'User: ',
|
|
style: TextStyle(
|
|
color: Colors.grey,
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
Text(
|
|
item!.userName.toString(),
|
|
style: TextStyle(
|
|
fontSize: 3 * _deviceBlockSize,
|
|
fontWeight: FontWeight.w700,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Spacer(),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: <Widget>[
|
|
InkWell(
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
title: Text('Accept'),
|
|
content: Text(
|
|
'Are you sure for approve this item?',
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
onPressed: () async {
|
|
Provider.of<MyItemProvider>(context,
|
|
listen: false)
|
|
.verifyItemRequests(
|
|
item!.requestId!, 'approved')
|
|
.then((result) {
|
|
if (result) {
|
|
print('true');
|
|
}
|
|
Navigator.of(ctx).pop();
|
|
Navigator.of(context).popAndPushNamed(
|
|
Routes.myItemsResultScreen);
|
|
});
|
|
},
|
|
child: Text('Yes'),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(ctx).pop();
|
|
},
|
|
child: Text('No'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(7),
|
|
width: 8 * _deviceBlockSize,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: kDarkBlue,
|
|
),
|
|
child: Icon(
|
|
Icons.check,
|
|
size: 4 * _deviceBlockSize,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: 3,
|
|
),
|
|
InkWell(
|
|
onTap: () {
|
|
showDialog(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
title: Text('Reject'),
|
|
content: Text(
|
|
'Are you sure for reject this item?',
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
onPressed: () async {
|
|
Provider.of<MyItemProvider>(context,
|
|
listen: false)
|
|
.verifyItemRequests(
|
|
item!.requestId!, 'rejected')
|
|
.then((result) {
|
|
if (result) {
|
|
print('false');
|
|
}
|
|
Navigator.of(ctx).pop();
|
|
Navigator.of(context).popAndPushNamed(
|
|
Routes.myItemsResultScreen);
|
|
});
|
|
},
|
|
child: Text('Yes'),
|
|
),
|
|
TextButton(
|
|
onPressed: () {
|
|
Navigator.of(ctx).pop();
|
|
},
|
|
child: Text('No'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
child: Container(
|
|
padding: EdgeInsets.all(7),
|
|
width: 8 * _deviceBlockSize,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
color: kPink,
|
|
),
|
|
child: Icon(
|
|
Icons.close,
|
|
size: 4 * _deviceBlockSize,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
width: _deviceBlockSize,
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|