feat : home page
This commit is contained in:
10
assets/icons/cube_bottom_rotation.svg
Normal file
10
assets/icons/cube_bottom_rotation.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="56" height="56" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M36.9926 16.1878L28.4431 11.3838C27.5446 10.8721 26.4554 10.8721 25.5569 11.3838L17.0074 16.1878C16.3812 16.5289 16 17.2396 16 18.0071C16 18.7746 16.3812 19.4853 17.0074 19.8264L25.5569 24.6305C26.0198 24.8863 26.5099 25 27 25C27.4901 25 27.9802 24.8863 28.4431 24.6305L36.9926 19.8264C37.6188 19.4853 38 18.7746 38 18.0071C38 17.2396 37.5916 16.5574 36.9926 16.1878Z"
|
||||
fill="#FFFFFF"/>
|
||||
<path d="M24.1935 26.7603L16.6581 23.1852C16.0903 22.9158 15.4194 22.9403 14.8516 23.2586C14.3355 23.577 14 24.1402 14 24.7524V31.5109C14 32.6863 14.671 33.7392 15.7806 34.2534L23.3161 37.8286C23.5742 37.9265 23.8581 38 24.1419 38C24.4774 38 24.8129 37.902 25.1226 37.7306C25.6645 37.4123 26 36.8491 26 36.2369V29.4784C26 28.3275 25.3032 27.2746 24.1935 26.7603Z"
|
||||
fill="#FFFFFF"/>
|
||||
<path d="M38.1957 23.2586C37.6989 22.9403 37.0839 22.9158 36.5398 23.1852L29.6323 26.7603C28.6151 27.2746 28 28.3275 28 29.5029V36.2614C28 36.8736 28.3075 37.4368 28.8043 37.7551C29.0882 37.9021 29.3957 38 29.7032 38C29.9634 38 30.2237 37.9265 30.4602 37.8041L37.3677 34.229C38.3849 33.7147 39 32.6618 39 31.4864V24.7279C39 24.1402 38.6925 23.577 38.1957 23.2586Z"
|
||||
fill="#FFFFFF"/>
|
||||
<path d="M30.4555 48.6485C29.8209 48.6653 29.2239 48.3281 28.904 47.7953C28.5841 47.2624 28.5659 46.5803 28.8806 46.0306L31.2391 41.8488C31.7101 40.9889 32.7844 40.7014 33.6437 41.1728C34.503 41.6443 34.7903 42.7194 34.3192 43.5793L33.7127 44.6546C40.1591 42.9533 44.8693 36.9907 44.6842 30.0284C44.6586 29.0641 45.4364 28.2431 46.4001 28.2175C47.3637 28.1919 48.1841 28.9703 48.2098 29.9347C48.4533 39.9788 40.4916 48.3816 30.4555 48.6485Z"
|
||||
fill="#FFFFFF"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
10
assets/icons/cube_top_rotation.svg
Normal file
10
assets/icons/cube_top_rotation.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="56" height="56" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10.4331 31.737C9.49523 31.9647 8.52877 31.376 8.30122 30.4385C5.93139 20.675 11.9607 10.7855 21.7285 8.41467C22.3462 8.26476 23.0013 8.46893 23.4263 8.92266C23.8513 9.37638 24.0123 10.0395 23.8197 10.6431L22.3946 15.2505C22.1084 16.1673 21.1227 16.6971 20.1771 16.394C19.2599 16.1081 18.7301 15.123 19.0336 14.1776L19.4015 12.9988C13.4257 16.0231 10.0898 22.8375 11.7325 29.6057C11.9601 30.5432 11.371 31.5094 10.4331 31.737Z"
|
||||
fill="#FFFFFF"/>
|
||||
<path d="M39.6586 21.2435L31.1091 16.4394C30.2106 15.9277 29.1215 15.9277 28.2229 16.4394L19.6734 21.2435C19.0472 21.5846 18.666 22.2953 18.666 23.0628C18.666 23.8303 19.0472 24.5409 19.6734 24.8821L28.2229 29.6861C28.6858 29.942 29.1759 30.0557 29.666 30.0557C30.1561 30.0557 30.6462 29.942 31.1091 29.6861L39.6586 24.8821C40.2848 24.5409 40.666 23.8303 40.666 23.0628C40.666 22.2953 40.2576 21.613 39.6586 21.2435Z"
|
||||
fill="#FFFFFF"/>
|
||||
<path d="M27.0101 31.816L20.1026 28.2408C19.5821 27.9715 18.9671 27.996 18.4467 28.3143C17.9735 28.6326 17.666 29.1959 17.666 29.808V36.5665C17.666 37.7419 18.2811 38.7949 19.2983 39.3091L26.2058 42.8843C26.4424 42.9822 26.7026 43.0557 26.9628 43.0557C27.2703 43.0557 27.5778 42.9577 27.8617 42.7863C28.3585 42.468 28.666 41.9048 28.666 41.2926V34.5341C28.666 33.3832 28.0273 32.3302 27.0101 31.816Z"
|
||||
fill="#FFFFFF"/>
|
||||
<path d="M41.7886 28.3143C41.2467 27.996 40.5757 27.9715 39.9821 28.2408L32.4467 31.816C31.337 32.3302 30.666 33.3832 30.666 34.5586V41.3171C30.666 41.9293 31.0015 42.4925 31.5434 42.8108C31.8531 42.9577 32.1886 43.0557 32.5241 43.0557C32.808 43.0557 33.0918 42.9822 33.3499 42.8598L40.8854 39.2846C41.995 38.7704 42.666 37.7174 42.666 36.542V29.7835C42.666 29.1959 42.3305 28.6326 41.7886 28.3143Z"
|
||||
fill="#FFFFFF"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/vec/cube_bottom_rotation.svg.vec
Normal file
BIN
assets/vec/cube_bottom_rotation.svg.vec
Normal file
Binary file not shown.
BIN
assets/vec/cube_top_rotation.svg.vec
Normal file
BIN
assets/vec/cube_top_rotation.svg.vec
Normal file
Binary file not shown.
@@ -19,7 +19,7 @@ abstract class ChickenRepository {
|
||||
required String token,
|
||||
});
|
||||
|
||||
Future<BarInformation?> getGeneralBarInformation({required String token});
|
||||
Future<BarInformation?> getGeneralBarInformation({required String token,Map<String, dynamic>? queryParameters});
|
||||
|
||||
Future<WaitingArrivalModel?> getWaitingArrivals({
|
||||
required String token,
|
||||
|
||||
@@ -49,9 +49,11 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
@override
|
||||
Future<BarInformation?> getGeneralBarInformation({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters
|
||||
}) async {
|
||||
var res = await _httpClient.get(
|
||||
'/bars_for_kill_house_dashboard/?role=Steward',
|
||||
queryParameters: queryParameters,
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
fromJson: BarInformation.fromJson,
|
||||
);
|
||||
|
||||
@@ -33,7 +33,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
rootLogic.getInventory();
|
||||
//rootLogic.getInventory();
|
||||
getBarGeneralInformation();
|
||||
getWaitingArrivals();
|
||||
getImportedEntried();
|
||||
|
||||
@@ -43,7 +43,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
ObxValue(
|
||||
/* ObxValue(
|
||||
(data) => data.isEmpty
|
||||
? Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 2),
|
||||
@@ -101,7 +101,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
},
|
||||
),
|
||||
controller.rootLogic.inventoryList,
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,17 +1,103 @@
|
||||
|
||||
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
import 'package:rasadyar_chicken/chicken.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class HomeLogic extends GetxController {
|
||||
RootLogic root = Get.find<RootLogic>();
|
||||
RxnInt totalWeightTodayBars = RxnInt();
|
||||
Rxn<InventoryModel> inventoryModel = Rxn<InventoryModel>();
|
||||
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
getTodayBars();
|
||||
getInventory();
|
||||
getDistributionInformation();
|
||||
}
|
||||
|
||||
Future<void> getTodayBars() async {
|
||||
await safeCall<BarInformation?>(
|
||||
call: () async => await root.chickenRepository.getGeneralBarInformation(
|
||||
token: root.tokenService.accessToken.value!,
|
||||
queryParameters: buildQueryParams(fromDate: DateTime.now(), toDate: DateTime.now()),
|
||||
),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
totalWeightTodayBars.value = result.totalBarsWeight?.toInt();
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
switch (error.response?.statusCode) {
|
||||
case 401:
|
||||
errorHandler(error);
|
||||
break;
|
||||
case 403:
|
||||
errorHandler(error);
|
||||
break;
|
||||
default:
|
||||
errorHandler(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getInventory() async {
|
||||
await safeCall<List<InventoryModel>?>(
|
||||
call: () async => await root.chickenRepository.getInventory(token: root.tokenService.accessToken.value!),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
inventoryModel.value = result.first;
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
switch (error.response?.statusCode) {
|
||||
case 401:
|
||||
errorHandler(error);
|
||||
break;
|
||||
case 403:
|
||||
errorHandler(error);
|
||||
break;
|
||||
default:
|
||||
errorHandler(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getDistributionInformation() async {
|
||||
await safeCall<KillHouseDistributionInfo?>(
|
||||
call: () async => await root.chickenRepository.getIKillHouseDistributionInfo(token: root.tokenService.accessToken.value!),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
iLog(result);
|
||||
killHouseDistributionInfo.value = result;
|
||||
iLog(killHouseDistributionInfo.value);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void errorHandler(DioException error) {
|
||||
handleGeneric(error, () {
|
||||
root.tokenService.deleteTokens();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
import 'logic.dart';
|
||||
@@ -70,111 +69,19 @@ class HomePage extends GetView<HomeLogic> {
|
||||
SizedBox(height: 8),
|
||||
_todayShipmentWidget(),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده انبار',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.cubeSearchSvg.path,
|
||||
iconColor: const Color(0xFF426060),
|
||||
bgDescriptionColor: const Color(0xFFC7DFE0),
|
||||
bgLabelColor: const Color(0xFFA5D1D2),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'توزیع شده',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.cubeRotateSvg.path,
|
||||
iconColor: Color(0xFF5C4D64),
|
||||
bgLabelColor: Color(0xFFC8B8D1),
|
||||
bgDescriptionColor: Color(0xFFDAD4DD),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_inventoryWidget(),
|
||||
|
||||
Row(
|
||||
children: [Text('اطلاعات بارها', textAlign: TextAlign.right, style: AppFonts.yekan16)],
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'داخل استان',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.a3dCubeSquareSvg.path,
|
||||
iconColor: const Color(0xFF6C5D60),
|
||||
bgDescriptionColor: const Color(0xFFEDDCE0),
|
||||
bgLabelColor: const Color(0xFFDDC0C7),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'خارج استان',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.cubeSearchSvg.path,
|
||||
iconColor: Color(0xFF2D5FFF),
|
||||
bgLabelColor: const Color(0xFFAFCBFF),
|
||||
bgDescriptionColor: const Color(0xFFCEDFFF),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_informationShipment(),
|
||||
|
||||
Row(
|
||||
children: [Text('اطلاعات توزیع', textAlign: TextAlign.right, style: AppFonts.yekan16)],
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationIconCard(
|
||||
title: 'توزیع داخل استان',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.truckSvg.path,
|
||||
iconColor: const Color.fromRGBO(85, 97, 93, 1),
|
||||
bgDescriptionColor: const Color(0xFFE6FAF5),
|
||||
bgLabelColor: const Color(0xFFB0EFDF),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationIconCard(
|
||||
title: 'توزیع خارج استان',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.truckFastSvg.path,
|
||||
iconColor: Color(0xFF647379),
|
||||
bgDescriptionColor: const Color(0xFFEAEFFF),
|
||||
bgLabelColor: const Color(0xFFD4DEFF),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationIconCard(
|
||||
title: 'قطعه بندی',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.convertCubeSvg.path,
|
||||
iconColor: const Color(0xFF6F6164),
|
||||
bgDescriptionColor: const Color(0xFFEDDCE0),
|
||||
bgLabelColor: const Color(0xFFE0BCC5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
distributionInformationWidget(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -226,64 +133,190 @@ class HomePage extends GetView<HomeLogic> {
|
||||
),
|
||||
);
|
||||
}
|
||||
Container _todayShipmentWidget() {
|
||||
return Container(
|
||||
height: 70,
|
||||
width: Get.width / 2,
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [const Color(0xFFEAEFFF), Colors.white],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Assets.icons.cubeScan.svg(width: 30, height: 30),
|
||||
Text(
|
||||
'بارهای امروز',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
|
||||
Widget distributionInformationWidget() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
|
||||
child: ObxValue((data) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationIconCard(
|
||||
title: 'توزیع داخل استان',
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.freeSalesWeight.toFormatted ?? '0',
|
||||
iconPath: Assets.vec.truckSvg.path,
|
||||
iconColor: const Color.fromRGBO(85, 97, 93, 1),
|
||||
bgDescriptionColor: const Color(0xFFE6FAF5),
|
||||
bgLabelColor: const Color(0xFFB0EFDF),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
'2،225،256',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
Text(
|
||||
'کیلوگرم',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: _informationIconCard(
|
||||
title: 'توزیع خارج استان',
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.stewardAllocationsWeight.toFormatted ?? '0',
|
||||
iconPath: Assets.vec.truckFastSvg.path,
|
||||
iconColor: Color(0xFF647379),
|
||||
bgDescriptionColor: const Color(0xFFEAEFFF),
|
||||
bgLabelColor: const Color(0xFFD4DEFF),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: _informationIconCard(
|
||||
title: 'قطعه بندی',
|
||||
description: '2،225،256',
|
||||
iconPath: Assets.vec.convertCubeSvg.path,
|
||||
iconColor: const Color(0xFF6F6164),
|
||||
bgDescriptionColor: const Color(0xFFEDDCE0),
|
||||
bgLabelColor: const Color(0xFFE0BCC5),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.killHouseDistributionInfo),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _informationShipment() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 13),
|
||||
child: ObxValue((data) {
|
||||
return Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'داخل استان',
|
||||
isLoading: data.value == null,
|
||||
description: data.value != null
|
||||
? ((data.value?.provinceGovernmentalCarcassesWeight ?? 0) +
|
||||
(data.value?.provinceFreeCarcassesWeight ?? 0))
|
||||
.toFormatted
|
||||
: '0',
|
||||
iconPath: Assets.vec.a3dCubeSquareSvg.path,
|
||||
iconColor: const Color(0xFF6C5D60),
|
||||
bgDescriptionColor: const Color(0xFFEDDCE0),
|
||||
bgLabelColor: const Color(0xFFDDC0C7),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'خارج استان',
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.freeBuyingCarcassesWeight.toFormatted ?? '0',
|
||||
iconPath: Assets.vec.cubeSearchSvg.path,
|
||||
iconColor: Color(0xFF2D5FFF),
|
||||
bgLabelColor: const Color(0xFFAFCBFF),
|
||||
bgDescriptionColor: const Color(0xFFCEDFFF),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.inventoryModel),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _inventoryWidget() {
|
||||
return ObxValue((data) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده انبار',
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.totalRemainWeight.toFormatted ?? '0',
|
||||
iconPath: Assets.vec.cubeSearchSvg.path,
|
||||
iconColor: const Color(0xFF426060),
|
||||
bgDescriptionColor: const Color(0xFFC7DFE0),
|
||||
bgLabelColor: const Color(0xFFA5D1D2),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'توزیع شده',
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.realAllocatedWeight.toFormatted ?? '0',
|
||||
iconPath: Assets.vec.cubeRotateSvg.path,
|
||||
iconColor: Color(0xFF5C4D64),
|
||||
bgLabelColor: Color(0xFFC8B8D1),
|
||||
bgDescriptionColor: Color(0xFFDAD4DD),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.inventoryModel);
|
||||
}
|
||||
|
||||
Widget _todayShipmentWidget() {
|
||||
return ObxValue((data) {
|
||||
return Container(
|
||||
height: 70,
|
||||
width: Get.width / 2,
|
||||
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [const Color(0xFFEAEFFF), Colors.white],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Assets.icons.cubeScan.svg(width: 30, height: 30),
|
||||
Text(
|
||||
'بارهای امروز',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: data.value == null
|
||||
? CupertinoActivityIndicator()
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
data.value.toFormatted,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
Text(
|
||||
'کیلوگرم',
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.textColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}, controller.totalWeightTodayBars);
|
||||
}
|
||||
|
||||
Container _informationLabelCard({
|
||||
required String title,
|
||||
required String description,
|
||||
String unit = 'کیلوگرم',
|
||||
bool isLoading = false,
|
||||
required String iconPath,
|
||||
required Color iconColor,
|
||||
required Color bgDescriptionColor,
|
||||
@@ -326,22 +359,24 @@ class HomePage extends GetView<HomeLogic> {
|
||||
color: bgDescriptionColor,
|
||||
borderRadius: BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8)),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
description,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
Text(
|
||||
unit,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: isLoading
|
||||
? Center(child: CupertinoActivityIndicator())
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
description,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
Text(
|
||||
unit,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -353,6 +388,7 @@ class HomePage extends GetView<HomeLogic> {
|
||||
required String title,
|
||||
required String description,
|
||||
String unit = 'کیلوگرم',
|
||||
bool isLoading = false,
|
||||
required String iconPath,
|
||||
required Color iconColor,
|
||||
required Color bgDescriptionColor,
|
||||
@@ -385,11 +421,14 @@ class HomePage extends GetView<HomeLogic> {
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
Text(
|
||||
description,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
|
||||
isLoading
|
||||
? Center(child: CupertinoActivityIndicator())
|
||||
: Text(
|
||||
description,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
Text(
|
||||
unit,
|
||||
textAlign: TextAlign.center,
|
||||
@@ -483,7 +522,7 @@ class HomePage extends GetView<HomeLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
/* Column oldPage() {
|
||||
/* Column oldPage() {
|
||||
return Column(
|
||||
children: [
|
||||
inventoryWidget(),
|
||||
@@ -652,19 +691,19 @@ class HomePage extends GetView<HomeLogic> {
|
||||
),
|
||||
child: model != null
|
||||
? Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text(
|
||||
'اطلاعات ارسالی',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
buildRow('فروش و توزیع داخل استان (کیلوگرم)', model.stewardAllocationsWeight!.toInt().toString()),
|
||||
buildRow('فروش و توزیع خارج استان (کیلوگرم)', model.freeSalesWeight!.toInt().toString()),
|
||||
],
|
||||
)
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 10,
|
||||
children: [
|
||||
Text(
|
||||
'اطلاعات ارسالی',
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
buildRow('فروش و توزیع داخل استان (کیلوگرم)', model.stewardAllocationsWeight!.toInt().toString()),
|
||||
buildRow('فروش و توزیع خارج استان (کیلوگرم)', model.freeSalesWeight!.toInt().toString()),
|
||||
],
|
||||
)
|
||||
: const Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import 'package:flutter/material.dart' show Text, EdgeInsets, Colors;
|
||||
import 'package:flutter/material.dart' show Colors;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
|
||||
import 'package:rasadyar_auth/data/utils/safe_call.dart';
|
||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/inventory/inventory_model.dart';
|
||||
import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart';
|
||||
import 'package:rasadyar_chicken/data/repositories/chicken_repository.dart';
|
||||
import 'package:rasadyar_chicken/data/repositories/chicken_repository_imp.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/home/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/utils.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
enum ErrorLocationType { serviceDisabled, permissionDenied, none }
|
||||
@@ -24,15 +23,14 @@ class RootLogic extends GetxController {
|
||||
Container(color: Colors.amber),
|
||||
];
|
||||
|
||||
RxList<ErrorLocationType> errorLocationType = RxList();
|
||||
RxMap<int, dynamic> inventoryExpandedList = RxMap();
|
||||
late DioRemote dioRemote;
|
||||
var tokenService = Get.find<TokenStorageService>();
|
||||
late ChickenRepository chickenRepository;
|
||||
late DioRemote dioRemote;
|
||||
RxInt count = 5.obs;
|
||||
|
||||
RxList<InventoryModel> inventoryList = RxList();
|
||||
Rxn<KillHouseDistributionInfo> killHouseDistributionInfo = Rxn<KillHouseDistributionInfo>();
|
||||
RxList<ErrorLocationType> errorLocationType = RxList();
|
||||
RxMap<int, dynamic> inventoryExpandedList = RxMap();
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -40,8 +38,9 @@ class RootLogic extends GetxController {
|
||||
dioRemote = DioRemote(baseUrl: tokenService.baseurl.value);
|
||||
dioRemote.init();
|
||||
chickenRepository = ChickenRepositoryImpl(dioRemote);
|
||||
getInventory();
|
||||
getKillHouseDistributionInfo();
|
||||
|
||||
/*getInventory();
|
||||
getKillHouseDistributionInfo();*/
|
||||
}
|
||||
|
||||
void toggleExpanded(int index) {
|
||||
@@ -52,63 +51,16 @@ class RootLogic extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getInventory() async {
|
||||
await safeCall<List<InventoryModel>?>(
|
||||
call: () async => await chickenRepository.getInventory(token: tokenService.accessToken.value!),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
iLog(result);
|
||||
inventoryList.clear();
|
||||
inventoryList.addAll(result);
|
||||
iLog(inventoryList);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
switch (error.response?.statusCode) {
|
||||
case 401:
|
||||
_handleGeneric(error);
|
||||
break;
|
||||
case 403:
|
||||
_handleGeneric(error);
|
||||
break;
|
||||
default:
|
||||
_handleGeneric(error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
void rootErrorHandler(DioException error) {
|
||||
handleGeneric(error, () {
|
||||
tokenService.deleteTokens();
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> getKillHouseDistributionInfo() async {
|
||||
await safeCall<KillHouseDistributionInfo?>(
|
||||
call: () async => await chickenRepository.getIKillHouseDistributionInfo(token: tokenService.accessToken.value!),
|
||||
onSuccess: (result) {
|
||||
if (result != null) {
|
||||
iLog(result);
|
||||
killHouseDistributionInfo.value = result;
|
||||
iLog(killHouseDistributionInfo.value);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {},
|
||||
);
|
||||
}
|
||||
|
||||
void _handleGeneric(DioException error) {
|
||||
Get.showSnackbar(_errorSnackBar('اعتبار توکن شما منقضی شده است لطفا دوباره وارد شوید'));
|
||||
tokenService.deleteTokens();
|
||||
Get.offAllNamed(AuthPaths.auth, arguments: Module.chicken);
|
||||
}
|
||||
|
||||
GetSnackBar _errorSnackBar(String message) {
|
||||
return GetSnackBar(
|
||||
titleText: Text('خطا', style: AppFonts.yekan14.copyWith(color: Colors.white)),
|
||||
messageText: Text(message, style: AppFonts.yekan12.copyWith(color: Colors.white)),
|
||||
backgroundColor: AppColor.error,
|
||||
margin: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
borderRadius: 12,
|
||||
duration: Duration(milliseconds: 3500),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
}
|
||||
|
||||
void changePage(int index) {
|
||||
currentPage.value = index;
|
||||
|
||||
@@ -326,7 +326,7 @@ class RootPage extends GetView<RootLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
Column oldPage() {
|
||||
/*Column oldPage() {
|
||||
return Column(
|
||||
children: [
|
||||
inventoryWidget(),
|
||||
@@ -455,7 +455,7 @@ class RootPage extends GetView<RootLogic> {
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
Widget buildRow(String title, String value) {
|
||||
return Padding(
|
||||
|
||||
@@ -37,7 +37,7 @@ class SalesInProvinceLogic extends GetxController {
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
rootLogic.getInventory();
|
||||
//rootLogic.getInventory();
|
||||
getAllocatedMade();
|
||||
getRolesProducts();
|
||||
getGuilds();
|
||||
|
||||
@@ -48,7 +48,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
ObxValue(
|
||||
/* ObxValue(
|
||||
(data) => data.isEmpty
|
||||
? Container(
|
||||
margin: const EdgeInsets.symmetric(vertical: 2),
|
||||
@@ -106,7 +106,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
|
||||
},
|
||||
),
|
||||
controller.rootLogic.inventoryList,
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -47,7 +47,14 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
SizedBox(height: 12),
|
||||
_typeOuterInfoCard(
|
||||
title: 'خرید خارج استان',
|
||||
iconPath: Assets.vec.searchSvg.path,
|
||||
backgroundColor: AppColor.blueLight,
|
||||
foregroundColor: AppColor.blueNormal,
|
||||
),
|
||||
|
||||
/* SizedBox(height: 12),
|
||||
ObxValue((model) => summaryOfInformation(model.value), controller.stewardFreeDashboard),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
@@ -107,11 +114,92 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
|
||||
separatorBuilder: (BuildContext context, int index) => SizedBox(height: 6),
|
||||
itemCount: 3,
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
floatingActionButton: RFab.add(
|
||||
onPressed: () {
|
||||
Get.bottomSheet(addSaleOutOfTheProvinceBottomSheet());
|
||||
},
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
|
||||
);
|
||||
}
|
||||
|
||||
Widget addSaleOutOfTheProvinceBottomSheet() {
|
||||
return BaseBottomSheet(
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(height: 20),
|
||||
Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Text('ثبت فروش خارج استان', style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal)),
|
||||
),
|
||||
SizedBox(height: 4),
|
||||
RElevated(text: 'ثبت توزیع/ فروش', onPressed: () {}),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container _typeOuterInfoCard({
|
||||
required String title,
|
||||
required String iconPath,
|
||||
required Color backgroundColor,
|
||||
required Color foregroundColor,
|
||||
}) {
|
||||
return Container(
|
||||
height: 110,
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Stack(
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
left: 0,
|
||||
child: Container(
|
||||
height: 120,
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(width: 1, color: foregroundColor),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
child: Container(
|
||||
width: 50,
|
||||
height: 50,
|
||||
decoration: ShapeDecoration(
|
||||
color: backgroundColor,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
side: BorderSide(width: 1, color: foregroundColor),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: SvgGenImage.vec(
|
||||
iconPath,
|
||||
).svg(width: 36, height: 36, colorFilter: ColorFilter.mode(foregroundColor, BlendMode.srcIn)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: RFab.add(onPressed: () {}),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
22
packages/chicken/lib/presentation/utils/utils.dart
Normal file
22
packages/chicken/lib/presentation/utils/utils.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
|
||||
import 'package:rasadyar_auth/presentation/routes/pages.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
void handleGeneric(DioException error,[void Function()? onError]) {
|
||||
Get.showSnackbar(_errorSnackBar('اعتبار توکن شما منقضی شده است لطفا دوباره وارد شوید'));
|
||||
|
||||
Get.offAllNamed(AuthPaths.auth, arguments: Module.chicken);
|
||||
}
|
||||
|
||||
GetSnackBar _errorSnackBar(String message) {
|
||||
return GetSnackBar(
|
||||
titleText: Text('خطا', style: AppFonts.yekan14.copyWith(color: Colors.white)),
|
||||
messageText: Text(message, style: AppFonts.yekan12.copyWith(color: Colors.white)),
|
||||
backgroundColor: AppColor.error,
|
||||
margin: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
borderRadius: 12,
|
||||
duration: Duration(milliseconds: 3500),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
library;
|
||||
|
||||
|
||||
//other packages
|
||||
export 'package:flutter_localizations/flutter_localizations.dart';
|
||||
export 'package:flutter_map/flutter_map.dart';
|
||||
@@ -44,3 +43,5 @@ export 'injection/di.dart';
|
||||
export 'utils/logger_utils.dart';
|
||||
export 'utils/safe_call_utils.dart';
|
||||
export 'utils/date_time_utils.dart';
|
||||
export 'utils/num_utils.dart';
|
||||
export 'utils/map_utils.dart';
|
||||
|
||||
@@ -48,6 +48,9 @@ class $AssetsIconsGen {
|
||||
/// File path: assets/icons/cube.svg
|
||||
SvgGenImage get cube => const SvgGenImage('assets/icons/cube.svg');
|
||||
|
||||
/// File path: assets/icons/cube_bottom_rotation.svg
|
||||
SvgGenImage get cubeBottomRotation => const SvgGenImage('assets/icons/cube_bottom_rotation.svg');
|
||||
|
||||
/// File path: assets/icons/cube_rotate.svg
|
||||
SvgGenImage get cubeRotate => const SvgGenImage('assets/icons/cube_rotate.svg');
|
||||
|
||||
@@ -57,6 +60,9 @@ class $AssetsIconsGen {
|
||||
/// File path: assets/icons/cube_search.svg
|
||||
SvgGenImage get cubeSearch => const SvgGenImage('assets/icons/cube_search.svg');
|
||||
|
||||
/// File path: assets/icons/cube_top_rotation.svg
|
||||
SvgGenImage get cubeTopRotation => const SvgGenImage('assets/icons/cube_top_rotation.svg');
|
||||
|
||||
/// File path: assets/icons/diagram.svg
|
||||
SvgGenImage get diagram => const SvgGenImage('assets/icons/diagram.svg');
|
||||
|
||||
@@ -187,9 +193,11 @@ class $AssetsIconsGen {
|
||||
chicken,
|
||||
convertCube,
|
||||
cube,
|
||||
cubeBottomRotation,
|
||||
cubeRotate,
|
||||
cubeScan,
|
||||
cubeSearch,
|
||||
cubeTopRotation,
|
||||
diagram,
|
||||
download,
|
||||
edit,
|
||||
@@ -297,6 +305,9 @@ class $AssetsVecGen {
|
||||
/// File path: assets/vec/cube.svg.vec
|
||||
SvgGenImage get cubeSvg => const SvgGenImage.vec('assets/vec/cube.svg.vec');
|
||||
|
||||
/// File path: assets/vec/cube_bottom_rotation.svg.vec
|
||||
SvgGenImage get cubeBottomRotationSvg => const SvgGenImage.vec('assets/vec/cube_bottom_rotation.svg.vec');
|
||||
|
||||
/// File path: assets/vec/cube_rotate.svg.vec
|
||||
SvgGenImage get cubeRotateSvg => const SvgGenImage.vec('assets/vec/cube_rotate.svg.vec');
|
||||
|
||||
@@ -306,6 +317,9 @@ class $AssetsVecGen {
|
||||
/// File path: assets/vec/cube_search.svg.vec
|
||||
SvgGenImage get cubeSearchSvg => const SvgGenImage.vec('assets/vec/cube_search.svg.vec');
|
||||
|
||||
/// File path: assets/vec/cube_top_rotation.svg.vec
|
||||
SvgGenImage get cubeTopRotationSvg => const SvgGenImage.vec('assets/vec/cube_top_rotation.svg.vec');
|
||||
|
||||
/// File path: assets/vec/diagram.svg.vec
|
||||
SvgGenImage get diagramSvg => const SvgGenImage.vec('assets/vec/diagram.svg.vec');
|
||||
|
||||
@@ -436,9 +450,11 @@ class $AssetsVecGen {
|
||||
chickenSvg,
|
||||
convertCubeSvg,
|
||||
cubeSvg,
|
||||
cubeBottomRotationSvg,
|
||||
cubeRotateSvg,
|
||||
cubeScanSvg,
|
||||
cubeSearchSvg,
|
||||
cubeTopRotationSvg,
|
||||
diagramSvg,
|
||||
downloadSvg,
|
||||
editSvg,
|
||||
|
||||
44
packages/core/lib/utils/map_utils.dart
Normal file
44
packages/core/lib/utils/map_utils.dart
Normal file
@@ -0,0 +1,44 @@
|
||||
import 'package:rasadyar_core/presentation/utils/data_time_utils.dart';
|
||||
|
||||
Map<String, dynamic> buildQueryParams({
|
||||
Map<String, dynamic>? queryParams,
|
||||
String? search,
|
||||
String? value,
|
||||
int? page,
|
||||
int? pageSize,
|
||||
DateTime? fromDate,
|
||||
DateTime? toDate,
|
||||
|
||||
}) {
|
||||
final params = <String, dynamic>{};
|
||||
|
||||
if (queryParams != null) {
|
||||
params.addAll(queryParams);
|
||||
}
|
||||
|
||||
if (fromDate != null) {
|
||||
params['date1'] = fromDate.formattedDashedGregorian;
|
||||
}
|
||||
|
||||
if (toDate != null) {
|
||||
params['date2'] = toDate.formattedDashedGregorian;
|
||||
}
|
||||
|
||||
if (search != null && search.isNotEmpty) {
|
||||
params['search'] = search;
|
||||
}
|
||||
|
||||
if (value != null && value.isNotEmpty) {
|
||||
params['value'] = value;
|
||||
}
|
||||
|
||||
if (page != null) {
|
||||
params['page'] = page;
|
||||
}
|
||||
|
||||
if (pageSize != null) {
|
||||
params['page_size'] = pageSize;
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
8
packages/core/lib/utils/num_utils.dart
Normal file
8
packages/core/lib/utils/num_utils.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
extension XNumExtension on num? {
|
||||
String get toFormatted {
|
||||
final formatter = NumberFormat('#,###', 'fa_IR');
|
||||
return this == null ? '':formatter.format(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user