| import 'package:farm_tpf/custom_model/Device.dart'; | import 'package:farm_tpf/custom_model/Device.dart'; | ||||
| import 'package:farm_tpf/data/repository/repository.dart'; | import 'package:farm_tpf/data/repository/repository.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | ||||
| import 'package:farm_tpf/utils/const_string.dart'; | import 'package:farm_tpf/utils/const_string.dart'; | ||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Scaffold( | return Scaffold( | ||||
| backgroundColor: Colors.white, | |||||
| key: _scaffoldKey, | key: _scaffoldKey, | ||||
| appBar: AppBar(title: Text("Chọn thiết bị")), | |||||
| appBar: AppBarWidget(), | |||||
| body: InfinityView(selectedId: selectedId)); | body: InfinityView(selectedId: selectedId)); | ||||
| } | } | ||||
| } | } | ||||
| if (state.items.isEmpty) { | if (state.items.isEmpty) { | ||||
| return Center(child: Text(label_list_empty)); | return Center(child: Text(label_list_empty)); | ||||
| } | } | ||||
| return RefreshIndicator( | |||||
| child: ListView.builder( | |||||
| itemBuilder: (BuildContext context, int index) { | |||||
| return index >= state.items.length | |||||
| ? BottomLoader() | |||||
| : ItemInfinityWidget(item: state.items[index]); | |||||
| }, | |||||
| itemCount: state.items.length), | |||||
| onRefresh: () async { | |||||
| _deviceActivityBloc | |||||
| .add(OnRefresh(selectedId: widget.selectedId)); | |||||
| }); | |||||
| return Column( | |||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: [ | |||||
| Padding( | |||||
| padding: const EdgeInsets.all(8.0), | |||||
| child: Text( | |||||
| 'Chọn thiết bị', | |||||
| style: TextStyle(fontWeight: FontWeight.w500, fontSize: 22), | |||||
| ), | |||||
| ), | |||||
| Expanded( | |||||
| child: RefreshIndicator( | |||||
| child: ListView.builder( | |||||
| itemBuilder: (BuildContext context, int index) { | |||||
| return index >= state.items.length | |||||
| ? BottomLoader() | |||||
| : ItemInfinityWidget(item: state.items[index]); | |||||
| }, | |||||
| itemCount: state.items.length), | |||||
| onRefresh: () async { | |||||
| _deviceActivityBloc | |||||
| .add(OnRefresh(selectedId: widget.selectedId)); | |||||
| }), | |||||
| ), | |||||
| ], | |||||
| ); | |||||
| } | } | ||||
| return Center( | return Center( | ||||
| child: LoadingListPage(), | child: LoadingListPage(), | ||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return GestureDetector( | return GestureDetector( | ||||
| child: Card( | |||||
| child: Material( | |||||
| child: RadioListTile( | |||||
| title: Text(item.name.toString()), | |||||
| value: item, | |||||
| groupValue: item.isSelected == false ? null : item, | |||||
| onChanged: (Device value) { | |||||
| Navigator.of(context).pop(value); | |||||
| }), | |||||
| )), | |||||
| child: Container( | |||||
| decoration: BoxDecoration( | |||||
| border: Border( | |||||
| bottom: BorderSide(color: Colors.grey, width: 0.35))), | |||||
| child: RadioListTile( | |||||
| title: Text(item.name.toString()), | |||||
| value: item, | |||||
| groupValue: item.isSelected == false ? null : item, | |||||
| onChanged: (Device value) { | |||||
| Navigator.of(context).pop(value); | |||||
| })), | |||||
| onTap: () {}); | onTap: () {}); | ||||
| } | } | ||||
| } | } |
| import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | import 'package:farm_tpf/custom_model/SuppliesUsing.dart'; | ||||
| import 'package:farm_tpf/custom_model/Supply.dart'; | import 'package:farm_tpf/custom_model/Supply.dart'; | ||||
| import 'package:farm_tpf/data/repository/repository.dart'; | import 'package:farm_tpf/data/repository/repository.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/app_bar_widget.dart'; | |||||
| import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | import 'package:farm_tpf/presentation/custom_widgets/loading_list_page.dart'; | ||||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | ||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return Scaffold( | return Scaffold( | ||||
| backgroundColor: Colors.white, | |||||
| key: _scaffoldKey, | key: _scaffoldKey, | ||||
| appBar: AppBar(title: Text("Chọn $titleName")), | |||||
| appBar: AppBarWidget(), | |||||
| body: Column( | body: Column( | ||||
| crossAxisAlignment: CrossAxisAlignment.start, | |||||
| children: <Widget>[ | children: <Widget>[ | ||||
| Padding( | |||||
| padding: const EdgeInsets.all(8.0), | |||||
| child: Text( | |||||
| '$titleName', | |||||
| style: TextStyle(fontWeight: FontWeight.w500, fontSize: 22), | |||||
| ), | |||||
| ), | |||||
| WidgetSearch( | WidgetSearch( | ||||
| type: type, | type: type, | ||||
| selectedId: selectedId, | selectedId: selectedId, | ||||
| @override | @override | ||||
| Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
| return GestureDetector( | return GestureDetector( | ||||
| child: Card( | |||||
| child: Material( | |||||
| child: RadioListTile( | |||||
| title: Row( | |||||
| children: [ | |||||
| Expanded(child: Text(item.tbSuppliesName.toString())), | |||||
| Text( | |||||
| "${item.quantity.formatNumtoStringDecimal()} ${item.unit}") | |||||
| ], | |||||
| ), | |||||
| subtitle: Text(item.tbWarehouseName.toString()), | |||||
| value: item, | |||||
| groupValue: item.isSelected == false ? null : item, | |||||
| onChanged: (Supply value) { | |||||
| if (value.quantity <= 0) { | |||||
| Utils.showSnackBarWarning(message: "Vật tư đã hết"); | |||||
| } else { | |||||
| var editedId = (currentEditId > 0) ? currentEditId : -1; | |||||
| if (currentItems | |||||
| .map((e) => e.tbSuppliesInWarehouseId) | |||||
| .contains(item.id) && | |||||
| item.id != editedId) { | |||||
| Utils.showSnackBarWarning( | |||||
| message: | |||||
| "Vật tư đã được thêm, vui lòng chọn vật tư khác"); | |||||
| child: Container( | |||||
| decoration: BoxDecoration( | |||||
| border: Border( | |||||
| bottom: BorderSide(color: Colors.grey, width: 0.35))), | |||||
| child: RadioListTile( | |||||
| title: Row( | |||||
| children: [ | |||||
| Expanded(child: Text(item.tbSuppliesName.toString())), | |||||
| Text( | |||||
| "${item.quantity.formatNumtoStringDecimal()} ${item.unit}") | |||||
| ], | |||||
| ), | |||||
| subtitle: Text(item.tbWarehouseName.toString()), | |||||
| value: item, | |||||
| groupValue: item.isSelected == false ? null : item, | |||||
| onChanged: (Supply value) { | |||||
| if (value.quantity <= 0) { | |||||
| Utils.showSnackBarWarning(message: "Vật tư đã hết"); | |||||
| } else { | } else { | ||||
| //close nackbar if open | |||||
| if (Get.isSnackbarOpen) Get.back(); | |||||
| Navigator.of(context).pop(value); | |||||
| var editedId = (currentEditId > 0) ? currentEditId : -1; | |||||
| if (currentItems | |||||
| .map((e) => e.tbSuppliesInWarehouseId) | |||||
| .contains(item.id) && | |||||
| item.id != editedId) { | |||||
| Utils.showSnackBarWarning( | |||||
| message: | |||||
| "Vật tư đã được thêm, vui lòng chọn vật tư khác"); | |||||
| } else { | |||||
| //close nackbar if open | |||||
| if (Get.isSnackbarOpen) Get.back(); | |||||
| Navigator.of(context).pop(value); | |||||
| } | |||||
| } | } | ||||
| } | |||||
| }), | |||||
| )), | |||||
| })), | |||||
| onTap: () {}); | onTap: () {}); | ||||
| } | } | ||||
| } | } |
| child: Padding( | child: Padding( | ||||
| padding: const EdgeInsets.only(right: 8, top: 8, bottom: 0), | padding: const EdgeInsets.only(right: 8, top: 8, bottom: 0), | ||||
| child: Container( | child: Container( | ||||
| decoration: BoxDecoration( | |||||
| color: Colors.white, | |||||
| borderRadius: const BorderRadius.all( | |||||
| Radius.circular(38.0), | |||||
| ), | |||||
| boxShadow: <BoxShadow>[ | |||||
| BoxShadow( | |||||
| color: Colors.grey.withOpacity(0.2), | |||||
| offset: const Offset(0, 2), | |||||
| blurRadius: 8.0), | |||||
| ], | |||||
| ), | |||||
| child: Padding( | child: Padding( | ||||
| padding: const EdgeInsets.only( | padding: const EdgeInsets.only( | ||||
| left: 16, right: 16, top: 4, bottom: 4), | left: 16, right: 16, top: 4, bottom: 4), | ||||
| onChanged: (String txt) {}, | onChanged: (String txt) {}, | ||||
| cursorColor: AppColors.GRAY1, | cursorColor: AppColors.GRAY1, | ||||
| decoration: InputDecoration( | decoration: InputDecoration( | ||||
| border: InputBorder.none, | |||||
| hintText: 'Tìm kiếm ...', | |||||
| ), | |||||
| suffixIcon: Icon( | |||||
| Icons.search, | |||||
| size: 30, | |||||
| ), | |||||
| hintText: 'Tìm kiếm ...', | |||||
| hintStyle: TextStyle(color: Colors.grey[500])), | |||||
| onSubmitted: (value) { | onSubmitted: (value) { | ||||
| FocusScope.of(context).requestFocus(FocusNode()); | FocusScope.of(context).requestFocus(FocusNode()); | ||||
| BlocProvider.of<SupplyBloc>(_blocContext).add(OnSearch( | BlocProvider.of<SupplyBloc>(_blocContext).add(OnSearch( |