refactor : ui and use utils
This commit is contained in:
@@ -37,7 +37,7 @@ class ModulesPage extends GetView<ModulesLogic> {
|
|||||||
final module = controller.moduleList[index];
|
final module = controller.moduleList[index];
|
||||||
return CardIcon(
|
return CardIcon(
|
||||||
title: module.title,
|
title: module.title,
|
||||||
icon: module.icon,
|
svgIcon: module.icon,
|
||||||
borderColor: module.borderColor,
|
borderColor: module.borderColor,
|
||||||
backgroundColor: module.backgroundColor,
|
backgroundColor: module.backgroundColor,
|
||||||
titleColor: module.titleColor,
|
titleColor: module.titleColor,
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ class InspectionPoultryScienceLogic extends GetxController {
|
|||||||
getHatchingList();
|
getHatchingList();
|
||||||
getHatchingReport();
|
getHatchingReport();
|
||||||
|
|
||||||
checkPermission(request: true);
|
checkLocationPermission(request: true);
|
||||||
|
|
||||||
ever(pickedImages, (callback) {
|
ever(pickedImages, (callback) {
|
||||||
_multiPartPickedImages.clear();
|
_multiPartPickedImages.clear();
|
||||||
for (var element in pickedImages) {
|
for (var element in pickedImages) {
|
||||||
@@ -143,15 +144,7 @@ class InspectionPoultryScienceLogic extends GetxController {
|
|||||||
|
|
||||||
Future<void> pickImages() async {
|
Future<void> pickImages() async {
|
||||||
determineCurrentPosition();
|
determineCurrentPosition();
|
||||||
var tmp = await ImagePicker().pickImage(
|
var tmp = await pickCameraImage();
|
||||||
source: ImageSource.camera,
|
|
||||||
imageQuality: 50,
|
|
||||||
preferredCameraDevice: CameraDevice.front,
|
|
||||||
maxHeight: 720,
|
|
||||||
maxWidth: 1080,
|
|
||||||
);
|
|
||||||
getFileSizeInKB(tmp?.path ?? '', tag: 'Picked');
|
|
||||||
|
|
||||||
if (tmp?.path != null && pickedImages.length < 7) {
|
if (tmp?.path != null && pickedImages.length < 7) {
|
||||||
pickedImages.add(tmp!);
|
pickedImages.add(tmp!);
|
||||||
}
|
}
|
||||||
@@ -172,23 +165,16 @@ class InspectionPoultryScienceLogic extends GetxController {
|
|||||||
var ls = [];
|
var ls = [];
|
||||||
|
|
||||||
for (var element in pickedImages) {
|
for (var element in pickedImages) {
|
||||||
ls.add(
|
ls.add(await MultipartFile.fromFile(element.path, filename: element.name));
|
||||||
await MultipartFile.fromFile(
|
|
||||||
element.path,
|
|
||||||
filename: element.name,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = FormData.fromMap({
|
var data = FormData.fromMap({
|
||||||
'file':ls,
|
'file': ls,
|
||||||
'hatching_id': id.toString(),
|
'hatching_id': id.toString(),
|
||||||
'lat': currentLocation.value.latitude.toString(),
|
'lat': currentLocation.value.latitude.toString(),
|
||||||
'log': currentLocation.value.longitude.toString(),
|
'log': currentLocation.value.longitude.toString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
safeCall(
|
safeCall(
|
||||||
call: () async => await rootLogic.poultryRepository.submitPoultryScienceReport(
|
call: () async => await rootLogic.poultryRepository.submitPoultryScienceReport(
|
||||||
token: rootLogic.tokenService.accessToken.value!,
|
token: rootLogic.tokenService.accessToken.value!,
|
||||||
@@ -214,41 +200,6 @@ class InspectionPoultryScienceLogic extends GetxController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> determineCurrentPosition() async {
|
|
||||||
final position = await Geolocator.getCurrentPosition(
|
|
||||||
locationSettings: AndroidSettings(accuracy: LocationAccuracy.best),
|
|
||||||
);
|
|
||||||
final latLng = LatLng(position.latitude, position.longitude);
|
|
||||||
|
|
||||||
currentLocation.value = latLng;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> checkPermission({bool request = false}) async {
|
|
||||||
try {
|
|
||||||
final LocationPermission permission = await Geolocator.checkPermission();
|
|
||||||
|
|
||||||
switch (permission) {
|
|
||||||
case LocationPermission.denied:
|
|
||||||
final LocationPermission requestResult = await Geolocator.requestPermission();
|
|
||||||
return requestResult != LocationPermission.denied &&
|
|
||||||
requestResult != LocationPermission.deniedForever;
|
|
||||||
|
|
||||||
case LocationPermission.deniedForever:
|
|
||||||
return request ? await Geolocator.openAppSettings() : false;
|
|
||||||
|
|
||||||
case LocationPermission.always:
|
|
||||||
case LocationPermission.whileInUse:
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
eLog(e);
|
|
||||||
return await Geolocator.openLocationSettings();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void closeBottomSheet() {
|
void closeBottomSheet() {
|
||||||
Get.back();
|
Get.back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ class InspectionPoultrySciencePage extends GetView<InspectionPoultryScienceLogic
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return BasePage(
|
return BasePage(
|
||||||
isBase: true,
|
hasBack: true,
|
||||||
|
hasFilter: false,
|
||||||
routesWidget: ObxValue((route) => buildPageRoute(route), controller.routesName),
|
routesWidget: ObxValue((route) => buildPageRoute(route), controller.routesName),
|
||||||
onBackPressed: () => Get.back(id: 0),
|
onBackPressed: () => Get.back(id: 0),
|
||||||
widgets: [
|
widgets: [
|
||||||
|
|||||||
@@ -19,73 +19,46 @@ class PoultryActionPage extends GetView<PoultryActionLogic> {
|
|||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Assets.images.poultryAction.image(
|
bannerWidget(),
|
||||||
height: 212.h,
|
itemGridWidget(),
|
||||||
width: Get.width.w,
|
|
||||||
fit: BoxFit.cover,
|
|
||||||
),
|
|
||||||
ObxValue((data) {
|
|
||||||
return Expanded(
|
|
||||||
child: GridView.builder(
|
|
||||||
physics: BouncingScrollPhysics(),
|
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
||||||
crossAxisCount: 2,
|
|
||||||
mainAxisSpacing: 12.h,
|
|
||||||
crossAxisSpacing: 12.w,
|
|
||||||
),
|
|
||||||
itemCount: data.length,
|
|
||||||
hitTestBehavior: HitTestBehavior.opaque,
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
var item = data[index];
|
|
||||||
return roleCardWithIcon(
|
|
||||||
title: item.title,
|
|
||||||
icon: item.icon,
|
|
||||||
onTap: () async {
|
|
||||||
Get.toNamed(item.route, id: 0);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}, controller.items),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Widget roleCardWithIcon({
|
Image bannerWidget() {
|
||||||
required String title,
|
return Assets.images.poultryAction.image(
|
||||||
required String icon,
|
height: 212.h,
|
||||||
Function()? onTap,
|
width: Get.width.w,
|
||||||
int? width,
|
fit: BoxFit.cover,
|
||||||
int? height,
|
);
|
||||||
}) {
|
}
|
||||||
return Container(
|
|
||||||
width: width?.w ?? 128.w,
|
|
||||||
height: height?.h ?? 48.h,
|
|
||||||
margin: EdgeInsets.all(8.w),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(8.r),
|
|
||||||
border: Border.all(color: AppColor.blueNormal, width: 1.w),
|
|
||||||
),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: onTap,
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
spacing: 8,
|
|
||||||
children: [
|
|
||||||
SvgGenImage.vec(icon).svg(width: 46.w, height: 46.h,colorFilter: ColorFilter.mode(
|
|
||||||
AppColor.blueNormal,
|
|
||||||
BlendMode.srcIn
|
|
||||||
)),
|
|
||||||
|
|
||||||
Text(
|
Widget itemGridWidget() {
|
||||||
title,
|
return ObxValue((data) {
|
||||||
style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal),
|
return Expanded(
|
||||||
),
|
child: GridView.builder(
|
||||||
],
|
physics: BouncingScrollPhysics(),
|
||||||
),
|
padding: EdgeInsets.symmetric(horizontal: 31.w),
|
||||||
),
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
);
|
crossAxisCount: 2,
|
||||||
|
mainAxisSpacing: 24.h,
|
||||||
|
crossAxisSpacing: 24.w,
|
||||||
|
),
|
||||||
|
itemCount: data.length,
|
||||||
|
hitTestBehavior: HitTestBehavior.opaque,
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
var item = data[index];
|
||||||
|
return CardIcon(
|
||||||
|
title: item.title,
|
||||||
|
vecIcon: item.icon,
|
||||||
|
onTap: () async {
|
||||||
|
Get.toNamed(item.route, id: 0);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}, controller.items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export 'bottom_sheet/base_bottom_sheet.dart';
|
|||||||
export 'bottom_sheet/date_picker_bottom_sheet.dart';
|
export 'bottom_sheet/date_picker_bottom_sheet.dart';
|
||||||
//buttons
|
//buttons
|
||||||
export 'buttons/buttons.dart';
|
export 'buttons/buttons.dart';
|
||||||
export 'card/card_with_icon_with_border.dart';
|
export 'card/card_icon_widget.dart';
|
||||||
export 'chips/r_chips.dart';
|
export 'chips/r_chips.dart';
|
||||||
export 'dialog/dialog.dart';
|
export 'dialog/dialog.dart';
|
||||||
export 'draggable_bottom_sheet/bottom_sheet_manger.dart';
|
export 'draggable_bottom_sheet/bottom_sheet_manger.dart';
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
export 'apk_updater.dart';
|
export 'apk_updater.dart';
|
||||||
|
export 'camera_utils.dart';
|
||||||
export 'extension/date_time_utils.dart';
|
export 'extension/date_time_utils.dart';
|
||||||
export 'extension/num_utils.dart';
|
export 'extension/num_utils.dart';
|
||||||
export 'extension/string_utils.dart';
|
export 'extension/string_utils.dart';
|
||||||
export 'file_utils.dart';
|
export 'file_utils.dart';
|
||||||
export 'local/local_utils.dart';
|
export 'local/local_utils.dart';
|
||||||
|
export 'location_utils.dart';
|
||||||
export 'logger_utils.dart';
|
export 'logger_utils.dart';
|
||||||
export 'map_utils.dart';
|
export 'map_utils.dart';
|
||||||
export 'mixins/pagination_controller_mixin.dart';
|
export 'mixins/pagination_controller_mixin.dart';
|
||||||
export 'network/network.dart';
|
export 'network/network.dart';
|
||||||
|
export 'number_utils.dart';
|
||||||
export 'parser.dart';
|
export 'parser.dart';
|
||||||
export 'route_utils.dart';
|
export 'route_utils.dart';
|
||||||
export 'separator_input_formatter.dart';
|
export 'separator_input_formatter.dart';
|
||||||
export 'number_utils.dart';
|
|
||||||
|
|||||||
Reference in New Issue
Block a user