mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-10 19:19:17 +03:30
224 lines
8.8 KiB
Dart
Executable File
224 lines
8.8 KiB
Dart
Executable File
import 'package:cssd/providers/auth.dart';
|
|
import 'package:cssd/providers/cycles.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../../config/colors.dart';
|
|
import '../../../config/routes.dart';
|
|
import '../../../models/cycles_models.dart';
|
|
|
|
class CycleItemBox extends StatelessWidget {
|
|
final CycleResultObject? item;
|
|
final String? labels;
|
|
|
|
const CycleItemBox({
|
|
Key? key,
|
|
required double deviceBlockSize,
|
|
this.item,
|
|
this.labels,
|
|
}) : _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.cycleDetailScreen,
|
|
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!.id,
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.w400,
|
|
fontSize: 5 * _deviceBlockSize,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
width: 30 * _deviceBlockSize,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Text(
|
|
'labels: ',
|
|
style: TextStyle(
|
|
color: Colors.grey,
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
Text(
|
|
item!.label.join(','),
|
|
style: TextStyle(
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
width: 30 * _deviceBlockSize,
|
|
child: Row(
|
|
children: <Widget>[
|
|
Text(
|
|
'date:',
|
|
style: TextStyle(
|
|
color: Colors.grey,
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
Text(
|
|
DateFormat('y-M-d').format(
|
|
DateTime.parse(
|
|
item!.createdAt,
|
|
),
|
|
),
|
|
style: TextStyle(
|
|
fontSize: 3 * _deviceBlockSize,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
),
|
|
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.cycleUpdateScreen,
|
|
// 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 Cycle?',
|
|
),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text('Yes'),
|
|
onPressed: () {
|
|
Navigator.of(context).pop();
|
|
Provider.of<CyclesProvider>(context,
|
|
listen: false)
|
|
.removeCycles(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.cycleDetailScreen,
|
|
// 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,
|
|
// ),
|
|
// ),
|
|
// ),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|