mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-11 18:08:54 +03:30
104 lines
3.0 KiB
Dart
Executable File
104 lines
3.0 KiB
Dart
Executable File
import 'package:cssd/config/routes.dart';
|
|
import 'package:cssd/models/item_model.dart';
|
|
import 'package:cssd/providers/items.dart';
|
|
import 'package:cssd/widgets/MyItemsScreens/Detail/my_items_detail_box_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../../providers/connectivity.dart';
|
|
import '../../widgets/Global/internet_error.dart';
|
|
|
|
class ItemDetailScreen extends StatefulWidget {
|
|
final String? testResultId;
|
|
|
|
ItemDetailScreen({
|
|
this.testResultId,
|
|
});
|
|
|
|
@override
|
|
_ItemDetailScreenState createState() => _ItemDetailScreenState();
|
|
}
|
|
|
|
class _ItemDetailScreenState extends State<ItemDetailScreen> {
|
|
bool isInit = true;
|
|
bool isEmpty = false;
|
|
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(
|
|
() {
|
|
if (result.id == 'null') {
|
|
isEmpty = true;
|
|
}
|
|
datas = result;
|
|
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: Scaffold(
|
|
appBar: AppBar(
|
|
titleSpacing: -10,
|
|
title: Text(
|
|
'Items',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
backgroundColor: Colors.black,
|
|
leading: IconButton(
|
|
icon: Icon(
|
|
Icons.keyboard_arrow_left,
|
|
color: Colors.white,
|
|
size: 35,
|
|
),
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
),
|
|
),
|
|
body: Consumer<ConnectivityProvider>(
|
|
builder: (ct, connection, _) {
|
|
return connection.conStatus != 'offline'
|
|
? isInit
|
|
? Center(
|
|
child: CircularProgressIndicator(
|
|
color: Colors.black,
|
|
),
|
|
)
|
|
: isEmpty
|
|
? Center(
|
|
child: Text('This Item does\'nt exists!'),
|
|
)
|
|
: ItemDetailsDataBox(
|
|
datas: datas!,
|
|
deviceBlockSize: _deviceBlockSize,
|
|
push: () {
|
|
Navigator.pushNamed(
|
|
context, Routes.itemsTransferScreen,
|
|
arguments: datas);
|
|
},
|
|
)
|
|
: ConnectionErrorBox();
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|