mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 19:48:55 +03:30
beta commit
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
import 'package:cssd/models/my_item_model.dart';
|
||||
import 'package:cssd/providers/auth.dart';
|
||||
import 'package:cssd/providers/users.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Detail/transfer_data_box.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/History/my_items_history_date_widget.dart';
|
||||
import 'package:cssd/widgets/MyItemsScreens/Result/my_items_data_box_widget.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class MyItemsHistoryScreen extends StatefulWidget {
|
||||
final bool? isAdmin;
|
||||
final MyItemResultObject? items;
|
||||
|
||||
MyItemsHistoryScreen({this.isAdmin, this.items});
|
||||
|
||||
@override
|
||||
_MyItemsHistoryScreenState createState() => _MyItemsHistoryScreenState();
|
||||
}
|
||||
|
||||
class _MyItemsHistoryScreenState extends State<MyItemsHistoryScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
|
||||
@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) {
|
||||
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;
|
||||
final userData = Provider.of<Auth>(context, listen: false).user;
|
||||
return SafeArea(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('My Items'),
|
||||
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: 60,
|
||||
left: 20,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
ResultBanner(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'Item History',
|
||||
push: Routes.itemFilterScreen,
|
||||
hasFilterObject: false,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
MyItemsItemDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
hasHistoryBtn: false,
|
||||
items: MyItemsHistoryScreen().items!,
|
||||
isAdmin: userData['roles']?.contains('User')
|
||||
? false
|
||||
: true,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Divider(
|
||||
color: Colors.grey,
|
||||
height: 2.0,
|
||||
),
|
||||
SizedBox(
|
||||
height: 10.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<UsersProvider>(
|
||||
builder: (context, userResults, child) {
|
||||
return userResults.isLoading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
return Column(
|
||||
children: [
|
||||
ItemHistoryDate(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
items:
|
||||
MyItemsHistoryScreen().items!,
|
||||
),
|
||||
SizedBox(
|
||||
height: 20.0,
|
||||
),
|
||||
TransferDataBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
user:
|
||||
userResults.usersBox?[index],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
itemCount: userResults.usersBox?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user