This commit is contained in:
unknown
2023-12-09 17:52:53 +03:30
parent 6464557956
commit ede10a2efe
36 changed files with 2252 additions and 1821 deletions
+56 -21
View File
@@ -1,7 +1,14 @@
// ignore_for_file: unused_local_variable
import 'dart:isolate';
import 'dart:ui';
import 'package:cssd/config/colors.dart';
import 'package:cssd/providers/items.dart';
import 'package:cssd/widgets/ItemScreens/Filter/item_filter_object.dart';
import 'package:cssd/widgets/ItemScreens/Result/item_data_box.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:permission_handler/permission_handler.dart';
import '../../config/routes.dart';
import '../../providers/connectivity.dart';
@@ -25,11 +32,30 @@ class _ItemResultScreenState extends State<ItemResultScreen> {
bool _isInit = true;
ScrollController? sc;
TextEditingController searchCTRL = new TextEditingController();
ReceivePort _port = ReceivePort();
@override
void initState() {
sc = new ScrollController();
super.initState();
IsolateNameServer.registerPortWithName(_port.sendPort, 'downloader_send_port');
_port.listen((dynamic data) {
String id = data[0];
DownloadTaskStatus status = data[1];
int progress = data[2];
if (status == DownloadTaskStatus.complete) {
print('Downloaded');
}
setState((){ });
});
FlutterDownloader.registerCallback(downloadCallback);
}
@pragma('vm:entry-point')
static void downloadCallback(String id, int status, int progress) {
final SendPort? send = IsolateNameServer.lookupPortByName('downloader_send_port');
send!.send([id, status, progress]);
}
@override
@@ -58,6 +84,12 @@ class _ItemResultScreenState extends State<ItemResultScreen> {
super.didChangeDependencies();
}
@override
void dispose() {
IsolateNameServer.removePortNameMapping('downloader_send_port');
super.dispose();
}
@override
Widget build(BuildContext context) {
final _media = MediaQuery.of(context);
@@ -252,27 +284,30 @@ class ItemResultFloatingButton extends StatelessWidget {
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
// InkWell(
// customBorder: CircleBorder(),
// onTap: () {
// Provider.of<ItemProvider>(context, listen: false).exportItems();
// },
// child: Container(
// padding: EdgeInsets.all(_deviceBlockSize),
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.black,
// ),
// child: Icon(
// Icons.import_export,
// size: 10 * _deviceBlockSize,
// color: Colors.white,
// ),
// ),
// ),
// SizedBox(
// width: 2 * _deviceBlockSize,
// ),
InkWell(
customBorder: CircleBorder(),
onTap: () async {
var status = await Permission.storage.request();
if (status.isGranted) {
Provider.of<ItemProvider>(context, listen: false).exportItems();
}
},
child: Container(
padding: EdgeInsets.all(_deviceBlockSize),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black,
),
child: Icon(
Icons.import_export,
size: 10 * _deviceBlockSize,
color: Colors.white,
),
),
),
SizedBox(
width: 2 * _deviceBlockSize,
),
InkWell(
customBorder: CircleBorder(),
onTap: () {
+311 -311
View File
@@ -1,317 +1,317 @@
import 'package:cssd/models/item_model.dart';
import 'package:cssd/providers/items.dart';
import 'package:cssd/widgets/ItemScreens/Add/item_update_button.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:provider/provider.dart';
import '../../config/routes.dart';
import '../../providers/connectivity.dart';
import '../../widgets/Global/internet_error.dart';
// import 'package:cssd/models/item_model.dart';
// import 'package:cssd/providers/items.dart';
// import 'package:cssd/widgets/ItemScreens/Add/item_update_button.dart';
// import 'package:flutter/material.dart';
// import 'package:font_awesome_flutter/font_awesome_flutter.dart';
// import 'package:provider/provider.dart';
// import '../../config/routes.dart';
// import '../../providers/connectivity.dart';
// import '../../widgets/Global/internet_error.dart';
class ItemUpdateScreen extends StatefulWidget {
@override
_ItemUpdateScreenState createState() => _ItemUpdateScreenState();
}
// class ItemUpdateScreen extends StatefulWidget {
// @override
// _ItemUpdateScreenState createState() => _ItemUpdateScreenState();
// }
class _ItemUpdateScreenState extends State<ItemUpdateScreen> {
final _itemSizeFocusNode = FocusNode();
final _itemSpecificFocusNode = FocusNode();
final _itemUdiFocusNode = FocusNode();
final _descriptionFocusNode = FocusNode();
TextEditingController descriptionCTRL = new TextEditingController();
TextEditingController udiCTRL = new TextEditingController();
TextEditingController nameCTRL = new TextEditingController();
TextEditingController specificCTRL = new TextEditingController();
TextEditingController sizeCTRL = new TextEditingController();
TextEditingController dateCTRL = new TextEditingController();
// class _ItemUpdateScreenState extends State<ItemUpdateScreen> {
// final _itemSizeFocusNode = FocusNode();
// final _itemSpecificFocusNode = FocusNode();
// final _itemUdiFocusNode = FocusNode();
// final _descriptionFocusNode = FocusNode();
// TextEditingController descriptionCTRL = new TextEditingController();
// TextEditingController udiCTRL = new TextEditingController();
// TextEditingController nameCTRL = new TextEditingController();
// TextEditingController specificCTRL = new TextEditingController();
// TextEditingController sizeCTRL = new TextEditingController();
// TextEditingController dateCTRL = new TextEditingController();
final _form = GlobalKey<FormState>();
// final _form = GlobalKey<FormState>();
bool isEmpty = false;
bool isInit = true;
ItemDetailObject? datas;
// bool isEmpty = false;
// bool isInit = true;
// ItemDetailObject? datas;
@override
void didChangeDependencies() async {
if (isInit) {
var _id = ModalRoute.of(context)!.settings.arguments;
await Provider.of<ItemProvider>(context, listen: false)
.showItemResult(_id.toString())
.then(
(result) {
setState(
() {
datas = result;
nameCTRL.text = datas!.name;
udiCTRL.text = datas!.udi;
descriptionCTRL.text = datas!.description;
sizeCTRL.text = datas!.size;
specificCTRL.text = datas!.specific;
},
);
},
);
await Provider.of<ItemProvider>(context, listen: false)
.getItemResults()
.then(
(result) {
setState(
() {
isInit = false;
},
);
},
);
}
super.didChangeDependencies();
}
// @override
// void didChangeDependencies() async {
// if (isInit) {
// var _id = ModalRoute.of(context)!.settings.arguments;
// await Provider.of<ItemProvider>(context, listen: false)
// .showItemResult(_id.toString())
// .then(
// (result) {
// setState(
// () {
// datas = result;
// nameCTRL.text = datas!.name;
// udiCTRL.text = datas!.udi;
// descriptionCTRL.text = datas!.description;
// sizeCTRL.text = datas!.size;
// specificCTRL.text = datas!.specific;
// },
// );
// },
// );
// await Provider.of<ItemProvider>(context, listen: false)
// .getItemResults()
// .then(
// (result) {
// setState(
// () {
// isInit = false;
// },
// );
// },
// );
// }
// super.didChangeDependencies();
// }
@override
Widget build(BuildContext context) {
final _media = MediaQuery.of(context);
final double _devicewidth = _media.size.width;
final double _deviceBlockSize = _devicewidth / 100;
return WillPopScope(
onWillPop: () async {
Navigator.pushReplacementNamed(
context,
Routes.itemResultScreen,
);
return true;
},
child: SafeArea(
child: Scaffold(
appBar: AppBar(
titleSpacing: -10,
backgroundColor: Colors.black,
title: Text('Items', style: TextStyle(color: Colors.white,),),
leading: IconButton(
icon: Icon(
Icons.keyboard_arrow_left,
color: Colors.white,
size: 35,
),
onPressed: () => Navigator.of(context)
.pushReplacementNamed(Routes.itemResultScreen),
),
),
body: Consumer<ConnectivityProvider>(
builder: (ct, connection, _) {
return connection.conStatus != 'offline'
? isInit
? Center(
child: CircularProgressIndicator(color: Colors.black),
)
: Form(
key: _form,
child: Padding(
padding: EdgeInsets.all(20),
child: ListView(
children: <Widget>[
Text(
'Update a Item',
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 6 * _deviceBlockSize,
letterSpacing: 3,
),
),
SizedBox(
height: 20,
),
TextFormField(
validator: (val) {
if (val!.isEmpty) {
return 'Name required!';
}
return null;
},
controller: nameCTRL,
decoration: InputDecoration(
icon: Icon(FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize),
isDense: true,
labelText: 'Item Name',
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.next,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemSizeFocusNode);
},
),
SizedBox(
height: 20,
),
TextFormField(
validator: (val) {
if (val!.isEmpty) {
return 'Size required!';
}
return null;
},
controller: sizeCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.sortNumericDown,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Size',
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
focusNode: _itemSizeFocusNode,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemSpecificFocusNode);
},
),
SizedBox(
height: 20,
),
TextFormField(
controller: specificCTRL,
validator: (val) {
if (val!.isEmpty) {
return 'Specific required!';
}
return null;
},
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Specific',
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.visiblePassword,
focusNode: _itemSpecificFocusNode,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_itemUdiFocusNode);
},
),
SizedBox(
height: 20,
),
TextFormField(
controller: udiCTRL,
validator: (val) {
if (val!.isEmpty) {
return 'UDI required!';
}
return null;
},
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'UDI',
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.visiblePassword,
focusNode: _itemUdiFocusNode,
onFieldSubmitted: (_) {
FocusScope.of(context)
.requestFocus(_descriptionFocusNode);
},
),
SizedBox(
height: 20,
),
TextFormField(
controller: descriptionCTRL,
decoration: InputDecoration(
icon: Icon(
FontAwesomeIcons.alignLeft,
size: 7 * _deviceBlockSize,
),
labelStyle: TextStyle(
fontWeight: FontWeight.w100,
fontSize: 4 * _deviceBlockSize,
),
isDense: true,
labelText: 'Description',
contentPadding: EdgeInsets.symmetric(
vertical: 2, horizontal: 3),
),
style: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 5 * _deviceBlockSize,
),
keyboardType: TextInputType.multiline,
focusNode: _descriptionFocusNode,
minLines: 1,
maxLines: 5,
),
SizedBox(
height: 70,
),
ItemUpdateButton(
form: _form,
id: datas!.id,
nameCTRL: nameCTRL,
udiCTRL: udiCTRL,
sizeCTRL: sizeCTRL,
specificCTRL: specificCTRL,
deviceBlockSize: _deviceBlockSize,
descriptionCTRL: descriptionCTRL,
),
SizedBox(
height: 100,
),
],
),
),
)
: ConnectionErrorBox();
},
),
),
),
);
}
}
// @override
// Widget build(BuildContext context) {
// final _media = MediaQuery.of(context);
// final double _devicewidth = _media.size.width;
// final double _deviceBlockSize = _devicewidth / 100;
// return WillPopScope(
// onWillPop: () async {
// Navigator.pushReplacementNamed(
// context,
// Routes.itemResultScreen,
// );
// return true;
// },
// child: SafeArea(
// child: Scaffold(
// appBar: AppBar(
// titleSpacing: -10,
// backgroundColor: Colors.black,
// title: Text('Items', style: TextStyle(color: Colors.white,),),
// leading: IconButton(
// icon: Icon(
// Icons.keyboard_arrow_left,
// color: Colors.white,
// size: 35,
// ),
// onPressed: () => Navigator.of(context)
// .pushReplacementNamed(Routes.itemResultScreen),
// ),
// ),
// body: Consumer<ConnectivityProvider>(
// builder: (ct, connection, _) {
// return connection.conStatus != 'offline'
// ? isInit
// ? Center(
// child: CircularProgressIndicator(color: Colors.black),
// )
// : Form(
// key: _form,
// child: Padding(
// padding: EdgeInsets.all(20),
// child: ListView(
// children: <Widget>[
// Text(
// 'Update a Item',
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 6 * _deviceBlockSize,
// letterSpacing: 3,
// ),
// ),
// SizedBox(
// height: 20,
// ),
// TextFormField(
// validator: (val) {
// if (val!.isEmpty) {
// return 'Name required!';
// }
// return null;
// },
// controller: nameCTRL,
// decoration: InputDecoration(
// icon: Icon(FontAwesomeIcons.alignLeft,
// size: 7 * _deviceBlockSize),
// isDense: true,
// labelText: 'Item Name',
// contentPadding: EdgeInsets.symmetric(
// vertical: 2, horizontal: 3),
// labelStyle: TextStyle(
// fontWeight: FontWeight.w100,
// fontSize: 4 * _deviceBlockSize,
// ),
// ),
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 5 * _deviceBlockSize,
// ),
// keyboardType: TextInputType.text,
// textInputAction: TextInputAction.next,
// onFieldSubmitted: (_) {
// FocusScope.of(context)
// .requestFocus(_itemSizeFocusNode);
// },
// ),
// SizedBox(
// height: 20,
// ),
// TextFormField(
// validator: (val) {
// if (val!.isEmpty) {
// return 'Size required!';
// }
// return null;
// },
// controller: sizeCTRL,
// decoration: InputDecoration(
// icon: Icon(
// FontAwesomeIcons.sortNumericDown,
// size: 7 * _deviceBlockSize,
// ),
// labelStyle: TextStyle(
// fontWeight: FontWeight.w100,
// fontSize: 4 * _deviceBlockSize,
// ),
// isDense: true,
// labelText: 'Size',
// contentPadding: EdgeInsets.symmetric(
// vertical: 2, horizontal: 3),
// ),
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 5 * _deviceBlockSize,
// ),
// focusNode: _itemSizeFocusNode,
// keyboardType: TextInputType.number,
// textInputAction: TextInputAction.done,
// onFieldSubmitted: (_) {
// FocusScope.of(context)
// .requestFocus(_itemSpecificFocusNode);
// },
// ),
// SizedBox(
// height: 20,
// ),
// TextFormField(
// controller: specificCTRL,
// validator: (val) {
// if (val!.isEmpty) {
// return 'Specific required!';
// }
// return null;
// },
// decoration: InputDecoration(
// icon: Icon(
// FontAwesomeIcons.alignLeft,
// size: 7 * _deviceBlockSize,
// ),
// labelStyle: TextStyle(
// fontWeight: FontWeight.w100,
// fontSize: 4 * _deviceBlockSize,
// ),
// isDense: true,
// labelText: 'Specific',
// contentPadding: EdgeInsets.symmetric(
// vertical: 2, horizontal: 3),
// ),
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 5 * _deviceBlockSize,
// ),
// keyboardType: TextInputType.visiblePassword,
// focusNode: _itemSpecificFocusNode,
// onFieldSubmitted: (_) {
// FocusScope.of(context)
// .requestFocus(_itemUdiFocusNode);
// },
// ),
// SizedBox(
// height: 20,
// ),
// TextFormField(
// controller: udiCTRL,
// validator: (val) {
// if (val!.isEmpty) {
// return 'UDI required!';
// }
// return null;
// },
// decoration: InputDecoration(
// icon: Icon(
// FontAwesomeIcons.alignLeft,
// size: 7 * _deviceBlockSize,
// ),
// labelStyle: TextStyle(
// fontWeight: FontWeight.w100,
// fontSize: 4 * _deviceBlockSize,
// ),
// isDense: true,
// labelText: 'UDI',
// contentPadding: EdgeInsets.symmetric(
// vertical: 2, horizontal: 3),
// ),
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 5 * _deviceBlockSize,
// ),
// keyboardType: TextInputType.visiblePassword,
// focusNode: _itemUdiFocusNode,
// onFieldSubmitted: (_) {
// FocusScope.of(context)
// .requestFocus(_descriptionFocusNode);
// },
// ),
// SizedBox(
// height: 20,
// ),
// TextFormField(
// controller: descriptionCTRL,
// decoration: InputDecoration(
// icon: Icon(
// FontAwesomeIcons.alignLeft,
// size: 7 * _deviceBlockSize,
// ),
// labelStyle: TextStyle(
// fontWeight: FontWeight.w100,
// fontSize: 4 * _deviceBlockSize,
// ),
// isDense: true,
// labelText: 'Description',
// contentPadding: EdgeInsets.symmetric(
// vertical: 2, horizontal: 3),
// ),
// style: TextStyle(
// fontWeight: FontWeight.w700,
// fontSize: 5 * _deviceBlockSize,
// ),
// keyboardType: TextInputType.multiline,
// focusNode: _descriptionFocusNode,
// minLines: 1,
// maxLines: 5,
// ),
// SizedBox(
// height: 70,
// ),
// ItemUpdateButton(
// form: _form,
// id: datas!.id,
// nameCTRL: nameCTRL,
// udiCTRL: udiCTRL,
// sizeCTRL: sizeCTRL,
// specificCTRL: specificCTRL,
// deviceBlockSize: _deviceBlockSize,
// descriptionCTRL: descriptionCTRL,
// ),
// SizedBox(
// height: 100,
// ),
// ],
// ),
// ),
// )
// : ConnectionErrorBox();
// },
// ),
// ),
// ),
// );
// }
// }