refactor : ui and use utils
This commit is contained in:
@@ -37,7 +37,7 @@ class ModulesPage extends GetView<ModulesLogic> {
|
||||
final module = controller.moduleList[index];
|
||||
return CardIcon(
|
||||
title: module.title,
|
||||
icon: module.icon,
|
||||
svgIcon: module.icon,
|
||||
borderColor: module.borderColor,
|
||||
backgroundColor: module.backgroundColor,
|
||||
titleColor: module.titleColor,
|
||||
|
||||
@@ -44,7 +44,8 @@ class InspectionPoultryScienceLogic extends GetxController {
|
||||
getHatchingList();
|
||||
getHatchingReport();
|
||||
|
||||
checkPermission(request: true);
|
||||
checkLocationPermission(request: true);
|
||||
|
||||
ever(pickedImages, (callback) {
|
||||
_multiPartPickedImages.clear();
|
||||
for (var element in pickedImages) {
|
||||
@@ -143,15 +144,7 @@ class InspectionPoultryScienceLogic extends GetxController {
|
||||
|
||||
Future<void> pickImages() async {
|
||||
determineCurrentPosition();
|
||||
var tmp = await ImagePicker().pickImage(
|
||||
source: ImageSource.camera,
|
||||
imageQuality: 50,
|
||||
preferredCameraDevice: CameraDevice.front,
|
||||
maxHeight: 720,
|
||||
maxWidth: 1080,
|
||||
);
|
||||
getFileSizeInKB(tmp?.path ?? '', tag: 'Picked');
|
||||
|
||||
var tmp = await pickCameraImage();
|
||||
if (tmp?.path != null && pickedImages.length < 7) {
|
||||
pickedImages.add(tmp!);
|
||||
}
|
||||
@@ -172,23 +165,16 @@ class InspectionPoultryScienceLogic extends GetxController {
|
||||
var ls = [];
|
||||
|
||||
for (var element in pickedImages) {
|
||||
ls.add(
|
||||
await MultipartFile.fromFile(
|
||||
element.path,
|
||||
filename: element.name,
|
||||
),
|
||||
);
|
||||
ls.add(await MultipartFile.fromFile(element.path, filename: element.name));
|
||||
}
|
||||
|
||||
var data = FormData.fromMap({
|
||||
'file':ls,
|
||||
'file': ls,
|
||||
'hatching_id': id.toString(),
|
||||
'lat': currentLocation.value.latitude.toString(),
|
||||
'log': currentLocation.value.longitude.toString(),
|
||||
});
|
||||
|
||||
|
||||
|
||||
safeCall(
|
||||
call: () async => await rootLogic.poultryRepository.submitPoultryScienceReport(
|
||||
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() {
|
||||
Get.back();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ class InspectionPoultrySciencePage extends GetView<InspectionPoultryScienceLogic
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BasePage(
|
||||
isBase: true,
|
||||
hasBack: true,
|
||||
hasFilter: false,
|
||||
routesWidget: ObxValue((route) => buildPageRoute(route), controller.routesName),
|
||||
onBackPressed: () => Get.back(id: 0),
|
||||
widgets: [
|
||||
|
||||
@@ -19,27 +19,39 @@ class PoultryActionPage extends GetView<PoultryActionLogic> {
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Assets.images.poultryAction.image(
|
||||
bannerWidget(),
|
||||
itemGridWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Image bannerWidget() {
|
||||
return Assets.images.poultryAction.image(
|
||||
height: 212.h,
|
||||
width: Get.width.w,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
ObxValue((data) {
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemGridWidget() {
|
||||
return ObxValue((data) {
|
||||
return Expanded(
|
||||
child: GridView.builder(
|
||||
physics: BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.symmetric(horizontal: 31.w),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 12.h,
|
||||
crossAxisSpacing: 12.w,
|
||||
mainAxisSpacing: 24.h,
|
||||
crossAxisSpacing: 24.w,
|
||||
),
|
||||
itemCount: data.length,
|
||||
hitTestBehavior: HitTestBehavior.opaque,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
var item = data[index];
|
||||
return roleCardWithIcon(
|
||||
return CardIcon(
|
||||
title: item.title,
|
||||
icon: item.icon,
|
||||
vecIcon: item.icon,
|
||||
onTap: () async {
|
||||
Get.toNamed(item.route, id: 0);
|
||||
},
|
||||
@@ -47,45 +59,6 @@ class PoultryActionPage extends GetView<PoultryActionLogic> {
|
||||
},
|
||||
),
|
||||
);
|
||||
}, controller.items),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.items);
|
||||
}
|
||||
}
|
||||
|
||||
Widget roleCardWithIcon({
|
||||
required String title,
|
||||
required String icon,
|
||||
Function()? onTap,
|
||||
int? width,
|
||||
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(
|
||||
title,
|
||||
style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ export 'bottom_sheet/base_bottom_sheet.dart';
|
||||
export 'bottom_sheet/date_picker_bottom_sheet.dart';
|
||||
//buttons
|
||||
export 'buttons/buttons.dart';
|
||||
export 'card/card_with_icon_with_border.dart';
|
||||
export 'card/card_icon_widget.dart';
|
||||
export 'chips/r_chips.dart';
|
||||
export 'dialog/dialog.dart';
|
||||
export 'draggable_bottom_sheet/bottom_sheet_manger.dart';
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
export 'apk_updater.dart';
|
||||
export 'camera_utils.dart';
|
||||
export 'extension/date_time_utils.dart';
|
||||
export 'extension/num_utils.dart';
|
||||
export 'extension/string_utils.dart';
|
||||
export 'file_utils.dart';
|
||||
export 'local/local_utils.dart';
|
||||
export 'location_utils.dart';
|
||||
export 'logger_utils.dart';
|
||||
export 'map_utils.dart';
|
||||
export 'mixins/pagination_controller_mixin.dart';
|
||||
export 'network/network.dart';
|
||||
export 'number_utils.dart';
|
||||
export 'parser.dart';
|
||||
export 'route_utils.dart';
|
||||
export 'separator_input_formatter.dart';
|
||||
export 'number_utils.dart';
|
||||
|
||||
Reference in New Issue
Block a user