mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 15:08:55 +03:30
beta commit
This commit is contained in:
@@ -0,0 +1,295 @@
|
||||
import 'package:cssd/config/colors.dart';
|
||||
|
||||
import '../../config/routes.dart';
|
||||
|
||||
import '../../providers/connectivity.dart';
|
||||
import '../../widgets/CycleScreens/Result/banner.dart';
|
||||
import '../../widgets/CycleScreens/Result/data_box.dart';
|
||||
import '../../widgets/CycleScreens/Result/filter_objects.dart';
|
||||
import '../../widgets/CycleScreens/Result/search_box.dart';
|
||||
import '../../widgets/Global/internet_error.dart';
|
||||
|
||||
import '../../providers/cycles.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class CycleResultScreen extends StatefulWidget {
|
||||
// static const route = '/CycleResultScreen';
|
||||
final bool? isAdmin;
|
||||
|
||||
CycleResultScreen({this.isAdmin});
|
||||
|
||||
@override
|
||||
_CycleResultScreenState createState() => _CycleResultScreenState();
|
||||
}
|
||||
|
||||
class _CycleResultScreenState extends State<CycleResultScreen> {
|
||||
bool _isInit = true;
|
||||
ScrollController? sc;
|
||||
TextEditingController searchCTRL = new TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
sc = new ScrollController();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
if (_isInit) {
|
||||
var testResults = Provider.of<CyclesProvider>(context);
|
||||
testResults.setLoading();
|
||||
testResults.resetPageNumber();
|
||||
testResults.getCycleResults().then((_) {
|
||||
testResults.resetLoading();
|
||||
sc!.addListener(
|
||||
() {
|
||||
if (sc!.position.pixels == sc!.position.maxScrollExtent &&
|
||||
searchCTRL.text == '') {
|
||||
var testResults = Provider.of<CyclesProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
);
|
||||
testResults.getCycleResults();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
_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(
|
||||
floatingActionButton: CycleResultFloatingButton(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
),
|
||||
appBar: AppBar(
|
||||
titleSpacing: -10,
|
||||
title: Text('Home'),
|
||||
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: 'Cycles',
|
||||
push: Routes.cycleFilterScreen,
|
||||
),
|
||||
Consumer<CyclesProvider>(builder: (ctx, cycle, _) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: ListView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
shrinkWrap: true,
|
||||
children: <Widget>[
|
||||
cycle.filters!.id != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'ID',
|
||||
id: '',
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.cycleNumber != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Cycle Number',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber: '',
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.sterilizerId != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Sterilizer ID',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId: '',
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.hospital != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Hospital',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: '',
|
||||
date: cycle.filters!.date,
|
||||
)
|
||||
: Container(),
|
||||
cycle.filters!.date != ''
|
||||
? CycleFilterChip(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
label: 'Date',
|
||||
id: cycle.filters!.id,
|
||||
cycleNumber:
|
||||
cycle.filters!.cycleNumber,
|
||||
sterilizerId:
|
||||
cycle.filters!.sterilizerId,
|
||||
hospital: cycle.filters!.hospital,
|
||||
date: '',
|
||||
)
|
||||
: Container(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
ResultSearchBox(
|
||||
searchCTRL: searchCTRL,
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
text: 'cycle',
|
||||
onChanged: (value) {
|
||||
Provider.of<CyclesProvider>(context,
|
||||
listen: false)
|
||||
.search(value);
|
||||
},
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<CyclesProvider>(
|
||||
builder: (context, cycleResults, _) {
|
||||
return cycleResults.isloading
|
||||
? Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
controller: sc,
|
||||
itemBuilder: (context, index) {
|
||||
String labels = '';
|
||||
for (var label in cycleResults
|
||||
.items![index].label) {
|
||||
labels += label;
|
||||
labels += ' , ';
|
||||
}
|
||||
if (labels.length >= 3) {
|
||||
labels = labels.substring(
|
||||
0,
|
||||
labels.length -
|
||||
3); // remove extra ,
|
||||
}
|
||||
return CycleItemBox(
|
||||
deviceBlockSize: _deviceBlockSize,
|
||||
item: cycleResults.items?[index],
|
||||
labels: labels,
|
||||
);
|
||||
},
|
||||
itemCount: cycleResults.items?.length,
|
||||
shrinkWrap: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ConnectionErrorBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CycleResultFloatingButton extends StatelessWidget {
|
||||
const CycleResultFloatingButton({
|
||||
Key? key,
|
||||
required double deviceBlockSize,
|
||||
}) : _deviceBlockSize = deviceBlockSize,
|
||||
super(key: key);
|
||||
|
||||
final double _deviceBlockSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Routes.cycleScanScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(2.5 * _deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.qr_code_scanner,
|
||||
size: 7.1 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 2 * _deviceBlockSize,
|
||||
),
|
||||
InkWell(
|
||||
customBorder: CircleBorder(),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushReplacementNamed(Routes.cycleAddScreen);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(_deviceBlockSize),
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: kPink,
|
||||
),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
size: 10 * _deviceBlockSize,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user