Files
cssd/lib/widgets/LabelScreens/Result/data_box.dart
T

238 lines
9.3 KiB
Dart
Executable File

import 'package:cssd/providers/auth.dart';
import 'package:cssd/providers/labels.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../../config/colors.dart';
import '../../../config/routes.dart';
import '../../../models/label_models.dart';
class LabelItemBox extends StatelessWidget {
final LabelResultObject? item;
const LabelItemBox({
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.labelDetailScreen,
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),
// 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: 30 * _deviceBlockSize,
child: Text(
item!.packageName,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 4 * _deviceBlockSize,
),
),
),
Container(
width: 50 * _deviceBlockSize,
child: Row(
children: [
Text(
"ID: ",
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.grey,
),
),
Text(
item!.id,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.black87,
),
),
Text(
" | ",
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.grey,
),
),
Text(
'Expire: ',
style: TextStyle(
color: Colors.grey,
fontSize: 3 * _deviceBlockSize,
),
),
Text(
item!.expireDate,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
),
)
],
),
),
Container(
width: 30 * _deviceBlockSize,
child: Row(
children: [
Text(
"package ID:: ",
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.grey,
),
),
Text(
item!.packageId,
style: TextStyle(
fontSize: 3 * _deviceBlockSize,
color: Colors.black87,
),
),
],
),
)
],
),
Spacer(),
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
// userData['roles']?.contains('User') ?? false
// ? Container()
// : InkWell(
// customBorder: CircleBorder(),
// onTap: () {
// Navigator.of(context).pushNamed(
// Routes.labelUpdateScreen,
// arguments: item!.id,
// );
// },
// child: Icon(
// Icons.edit,
// size: 5 * _deviceBlockSize,
// color: Colors.black,
// ),
// ),
// SizedBox(
// width: 5.0,
// ),
userData['roles']?.contains('User') ?? false
? Container()
: InkWell(
customBorder: CircleBorder(),
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('Delete'),
content: Text(
'Are you sure you want delete this Label?'),
actions: <Widget>[
TextButton(
child: Text('Yes'),
onPressed: () {
Navigator.of(context).pop();
Provider.of<LabelsProvider>(context,
listen: false)
.removeLabels(item!.id);
},
),
TextButton(
child: Text('No'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
},
child: Container(
padding: EdgeInsets.all(7),
width: 8 * _deviceBlockSize,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: kPink,
),
child: Icon(
Icons.delete_outlined,
size: 4 * _deviceBlockSize,
color: Colors.white,
),
),
),
SizedBox(
width: 5.0,
),
// InkWell(
// customBorder: CircleBorder(),
// onTap: () {
// Navigator.of(context).pushNamed(
// Routes.labelDetailScreen,
// 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,
// ),
// ),
// ),
],
),
],
),
],
),
),
),
);
}
}