Browse Source

ui resource

master
daivph 5 years ago
parent
commit
99fc44ed43
3 changed files with 89 additions and 70 deletions
  1. +40
    -23
      lib/presentation/screens/actions/resource_device_activity/sc_device_activity.dart
  2. +43
    -32
      lib/presentation/screens/resources/sc_resource_helper.dart
  3. +6
    -15
      lib/presentation/screens/resources/widget_search.dart

+ 40
- 23
lib/presentation/screens/actions/resource_device_activity/sc_device_activity.dart View File

@@ -1,5 +1,6 @@
import 'package:farm_tpf/custom_model/Device.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/loading_list_page.dart';
import 'package:farm_tpf/utils/const_string.dart';
@@ -33,8 +34,9 @@ class HoldInfinityWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _scaffoldKey,
appBar: AppBar(title: Text("Chọn thiết bị")),
appBar: AppBarWidget(),
body: InfinityView(selectedId: selectedId));
}
}
@@ -67,18 +69,32 @@ class _InfinityViewState extends State<InfinityView> {
if (state.items.isEmpty) {
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(
child: LoadingListPage(),
@@ -101,16 +117,17 @@ class ItemInfinityWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
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: () {});
}
}

+ 43
- 32
lib/presentation/screens/resources/sc_resource_helper.dart View File

@@ -1,6 +1,7 @@
import 'package:farm_tpf/custom_model/SuppliesUsing.dart';
import 'package:farm_tpf/custom_model/Supply.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/loading_list_page.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart';
@@ -61,10 +62,19 @@ class HoldInfinityWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
key: _scaffoldKey,
appBar: AppBar(title: Text("Chọn $titleName")),
appBar: AppBarWidget(),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'$titleName',
style: TextStyle(fontWeight: FontWeight.w500, fontSize: 22),
),
),
WidgetSearch(
type: type,
selectedId: selectedId,
@@ -162,39 +172,40 @@ class ItemInfinityWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
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 {
//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: () {});
}
}

+ 6
- 15
lib/presentation/screens/resources/widget_search.dart View File

@@ -36,18 +36,6 @@ class _WidgetSearchState extends State<WidgetSearch> {
child: Padding(
padding: const EdgeInsets.only(right: 8, top: 8, bottom: 0),
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(
padding: const EdgeInsets.only(
left: 16, right: 16, top: 4, bottom: 4),
@@ -57,9 +45,12 @@ class _WidgetSearchState extends State<WidgetSearch> {
onChanged: (String txt) {},
cursorColor: AppColors.GRAY1,
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) {
FocusScope.of(context).requestFocus(FocusNode());
BlocProvider.of<SupplyBloc>(_blocContext).add(OnSearch(

Loading…
Cancel
Save