mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 16:38:56 +03:30
beta commit
This commit is contained in:
@@ -0,0 +1,343 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
import 'package:cssd/config/routes.dart';
|
||||
import 'package:cssd/models/package_model.dart';
|
||||
import 'package:cssd/providers/connectivity.dart';
|
||||
import 'package:cssd/providers/my_packages.dart';
|
||||
import 'package:cssd/providers/users.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/banner.dart';
|
||||
import 'package:cssd/widgets/CycleScreens/Result/search_box.dart';
|
||||
import 'package:cssd/widgets/Global/internet_error.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/cancel_transfer_button.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_destroy_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class PackageTransferScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
final PackageDetailObject? packages;
|
||||
const PackageTransferScreen({
|
||||
super.key,
|
||||
this.isAdmin,
|
||||
this.packages,
|
||||
});
|
||||
|
||||
@override
|
||||
State<PackageTransferScreen> createState() => _PackageTransferScreenState();
|
||||
}
|
||||
|
||||
class _PackageTransferScreenState extends State<PackageTransferScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var userResults = Provider.of<UsersProvider>(context);
|
||||
userResults.setLoading();
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String)
|
||||
.then((_) {
|
||||
userResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var userResults = Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
userResults
|
||||
.getUsers(userResults.getUserMedicalCenter() as String);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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 SafeArea(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
},
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Package Details'),
|
||||
backgroundColor: Colors.black,
|
||||
leading: IconButton(
|
||||
icon: Icon(
|
||||
Icons.keyboard_arrow_left,
|
||||
size: 35,
|
||||
),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
),
|
||||
body: Consumer<ConnectivityProvider>(
|
||||
builder: (ct, connection, _) {
|
||||
return connection.conStatus != 'offline'
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 40,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Transfer to',
|
||||
hasFilterObject: false,
|
||||
push: Routes.myItemsFilterScreen,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
text: 'user',
|
||||
text2: 'name',
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
onChanged: (value) {
|
||||
Provider.of<UsersProvider>(context, listen: false)
|
||||
.searchUsers(value);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<UsersProvider>(
|
||||
builder: (context, userResults, _) {
|
||||
return userResults.isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
return TransferDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
user: userResults.usersBox?[index],
|
||||
isClicked:
|
||||
userResults.selectedUserIndex ==
|
||||
index,
|
||||
onTap: (userId) {
|
||||
Provider.of<UsersProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).selectUser(index);
|
||||
print(userId);
|
||||
Provider.of<UsersProvider>(
|
||||
context)
|
||||
.saveUserId = userId;
|
||||
},
|
||||
);
|
||||
},
|
||||
itemCount: userResults.usersBox?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkPurple,
|
||||
secondColor: kDarkPurpleSub,
|
||||
onTap: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Are you sure to transfer this Package?',
|
||||
style: TextStyle(
|
||||
fontSize: 4 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
content: SizedBox(
|
||||
width: _deviceBlockSize,
|
||||
height: 280,
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'By approving, all items in your package will be transferred the specified user. it can be undone unless the user reject the transfer.',
|
||||
style: TextStyle(
|
||||
fontSize: 3 * _deviceBlockSize,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
PackageCard(_deviceBlockSize),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Spacer(),
|
||||
Text('To'),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
PackageCard(_deviceBlockSize),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
TransferDestroyButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
firstColor: kDarkBlue,
|
||||
secondColor: kDarkBlueSub,
|
||||
onTap: () {
|
||||
Provider.of<MyPackageProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).transferPackage(
|
||||
PackageTransferScreen()
|
||||
.packages!
|
||||
.id,
|
||||
Provider.of<UsersProvider>(
|
||||
context,
|
||||
).saveUserId!,
|
||||
);
|
||||
},
|
||||
text: 'Transfer',
|
||||
),
|
||||
SizedBox(
|
||||
height: 5.0,
|
||||
),
|
||||
CancelTransferButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
color: kPink,
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
text: 'Transfer',
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container PackageCard(double _deviceBlockSize) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: const EdgeInsets.all(6.0),
|
||||
child: Text(
|
||||
PackageTransferScreen().packages!.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(
|
||||
PackageTransferScreen().packages!.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(
|
||||
// PackageTransferScreen().packages!.size,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// style: TextStyle(
|
||||
// fontWeight: FontWeight.w700,
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// width: 30 * _deviceBlockSize,
|
||||
// child: Row(
|
||||
// children: <Widget>[
|
||||
// Text(
|
||||
// 'User: ',
|
||||
// style: TextStyle(
|
||||
// color: Colors.grey,
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// PackageTransferScreen().packages!.userName,
|
||||
// style: TextStyle(
|
||||
// fontSize: 3 * _deviceBlockSize,
|
||||
// fontWeight: FontWeight.w700,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user