fix : ui fix after release 1.3.3

This commit is contained in:
2025-07-16 18:31:47 +03:30
parent 3566e5820d
commit c28a0e6630
22 changed files with 229 additions and 203 deletions

View File

@@ -18,12 +18,14 @@ class CustomNavigationObserver extends NavigatorObserver {
_isWorkDone = true; _isWorkDone = true;
await setupInjection(); await setupInjection();
} }
iLog('message');
} }
@override @override
void didReplace({Route? newRoute, Route? oldRoute}) { void didReplace({Route? newRoute, Route? oldRoute}) {
super.didReplace(newRoute: newRoute, oldRoute: oldRoute); super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
iLog('didReplace');
} }
@@ -31,10 +33,12 @@ class CustomNavigationObserver extends NavigatorObserver {
void didPop(Route route, Route? previousRoute) { void didPop(Route route, Route? previousRoute) {
super.didPop(route, previousRoute); super.didPop(route, previousRoute);
iLog('didPop');
} }
@override @override
void didRemove(Route route, Route? previousRoute) { void didRemove(Route route, Route? previousRoute) {
super.didRemove(route, previousRoute); super.didRemove(route, previousRoute);
iLog('didRemove');
} }
} }

View File

@@ -13,8 +13,8 @@ Future<void> main() async {
await setupPreInjection(); await setupPreInjection();
Get.put(TokenStorageService()); Get.put(TokenStorageService());
var tokenService = Get.find<TokenStorageService>(); await Get.find<TokenStorageService>().init();
await tokenService.init();
Get.put(AuthMiddleware()); Get.put(AuthMiddleware());
Get.put(AuthService()); Get.put(AuthService());
runApp(MyApp()); runApp(MyApp());

View File

@@ -4,13 +4,12 @@ import 'package:rasadyar_chicken/data/models/local/widely_used_local_model.dart'
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
class ChickenLocalDataSourceImp implements ChickenLocalDataSource { class ChickenLocalDataSourceImp implements ChickenLocalDataSource {
HiveLocalStorage local =diCore.get<HiveLocalStorage>(); HiveLocalStorage local = diCore.get<HiveLocalStorage>();
final String boxName = 'Chicken_Widley_Box'; final String boxName = 'Chicken_Widley_Box';
@override @override
Future<void> openBox() async { Future<void> openBox() async {
await local.openBox(boxName); await local.openBox<WidelyUsedLocalModel>(boxName);
} }
@override @override
@@ -53,7 +52,6 @@ class ChickenLocalDataSourceImp implements ChickenLocalDataSource {
@override @override
WidelyUsedLocalModel? getAllWidely() { WidelyUsedLocalModel? getAllWidely() {
var res = local.readBox<WidelyUsedLocalModel>(boxName: boxName); var res = local.readBox<WidelyUsedLocalModel>(boxName: boxName);
fLog(res.toString()); return res?.first;
return res;
} }
} }

View File

@@ -44,7 +44,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
); );
}, controller.waitingProduct), }, controller.waitingProduct),
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, /* floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
floatingActionButton: ObxValue((data) { floatingActionButton: ObxValue((data) {
if ((data.value.data?.results?.length ?? 0) > 1) { if ((data.value.data?.results?.length ?? 0) > 1) {
return AnimatedFab( return AnimatedFab(
@@ -58,7 +58,7 @@ class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
} else { } else {
return SizedBox.shrink(); return SizedBox.shrink();
} }
}, controller.waitingProduct), }, controller.waitingProduct),*/
); );
} }

View File

@@ -17,6 +17,7 @@ class BuyOutOfProvinceLogic extends GetxController {
RxList<int> isExpandedList = <int>[].obs; RxList<int> isExpandedList = <int>[].obs;
final RxInt currentPage = 1.obs; final RxInt currentPage = 1.obs;
final RxBool isLoadingMoreAllocationsMade = false.obs; final RxBool isLoadingMoreAllocationsMade = false.obs;
final RxBool isOnLoadingSubmitOrEdit = false.obs;
//TODO add this to Di //TODO add this to Di
ImagePicker imagePicker = ImagePicker(); ImagePicker imagePicker = ImagePicker();
@@ -170,6 +171,7 @@ class BuyOutOfProvinceLogic extends GetxController {
Future<bool> createStewardPurchaseOutOfProvince() async { Future<bool> createStewardPurchaseOutOfProvince() async {
bool res = false; bool res = false;
isOnLoadingSubmitOrEdit.value = true;
if (!(formKey.currentState?.validate() ?? false)) { if (!(formKey.currentState?.validate() ?? false)) {
return res; return res;
} }
@@ -196,6 +198,7 @@ class BuyOutOfProvinceLogic extends GetxController {
res = true; res = true;
}, },
); );
isOnLoadingSubmitOrEdit.value = false;
return res; return res;
} }
@@ -205,7 +208,6 @@ class BuyOutOfProvinceLogic extends GetxController {
carcassWeightController.clear(); carcassWeightController.clear();
selectedProvince.value = null; selectedProvince.value = null;
selectedCity.value = null; selectedCity.value = null;
selectedProduct.value = null;
selectedImage.value = null; selectedImage.value = null;
_base64Image.value = null; _base64Image.value = null;
editImageUrl.value = null; editImageUrl.value = null;

View File

@@ -379,12 +379,13 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
} }
Widget submitButtonWidget(bool isOnEdit) { Widget submitButtonWidget(bool isOnEdit) {
return ObxValue((data) { return Obx(() {
return RElevated( return RElevated(
text: isOnEdit ? 'ویرایش' : 'ثبت', text: isOnEdit ? 'ویرایش' : 'ثبت',
width: Get.width, width: Get.width,
backgroundColor: AppColor.greenNormal, backgroundColor: AppColor.greenNormal,
onPressed: data.value isLoading: controller.isOnLoadingSubmitOrEdit.value,
onPressed: controller.isSubmitButtonEnabled.value
? () async { ? () async {
var res = await controller.createStewardPurchaseOutOfProvince(); var res = await controller.createStewardPurchaseOutOfProvince();
if (res) { if (res) {
@@ -394,7 +395,7 @@ class BuyOutOfProvincePage extends GetView<BuyOutOfProvinceLogic> {
: null, : null,
height: 40, height: 40,
); );
}, controller.isSubmitButtonEnabled); });
} }
Widget _productDropDown() { Widget _productDropDown() {

View File

@@ -57,59 +57,32 @@ class ProfilePage extends GetView<ProfileLogic> {
), ),
), ),
ObxValue((data) { Center(
return Padding( child: Wrap(
padding: const EdgeInsets.symmetric(horizontal: 20), alignment: WrapAlignment.center,
child: Wrap( spacing: 20,
spacing: 20, runSpacing: 10,
runSpacing: 10, children: [
children: [ cardActionWidget(
cardActionWidget( title: 'تغییر رمز عبور',
title: 'اطلاعات کاربری', selected: true,
onPressed: () { onPressed: () {
data.value = 0; Get.bottomSheet(changePasswordBottomSheet(), isScrollControlled: true);
}, },
icon: Assets.vec.profileUserSvg.path, icon: Assets.vec.lockSvg.path,
selected: data.value == 0, ),
), cardActionWidget(
title: 'خروج',
selected: true,
onPressed: () {
Get.bottomSheet(exitBottomSheet(), isScrollControlled: true);
},
icon: Assets.vec.logoutSvg.path,
),
],
),
),
cardActionWidget(
title: 'تغییر رمز عبور',
selected: true,
onPressed: () {
Get.bottomSheet(changePasswordBottomSheet(), isScrollControlled: true);
},
icon: Assets.vec.lockSvg.path,
),
cardActionWidget(
title: 'خروج',
selected: true,
onPressed: () {
Get.bottomSheet(exitBottomSheet(), isScrollControlled: true);
},
icon: Assets.vec.logoutSvg.path,
),
/*cardActionWidget(
title: 'اطلاعات بانکی',
onPressed: () {
data.value = 1;
},
icon: Assets.vec.informationSvg.path,
selected: data.value == 1,
),
cardActionWidget(
title: 'اطلاعات \nصدور فاکتور',
onPressed: () {
data.value = 2;
},
icon: Assets.vec.receiptDiscountSvg.path,
selected: data.value == 2,
),*/
],
),
);
}, controller.selectedInformationType),
SizedBox(height: 100), SizedBox(height: 100),
], ],

View File

@@ -49,10 +49,11 @@ class RootLogic extends GetxController {
super.onInit(); super.onInit();
localDatasource = diChicken.get<ChickenLocalDataSourceImp>(); localDatasource = diChicken.get<ChickenLocalDataSourceImp>();
chickenRepository = diChicken.get<ChickenRepositoryImp>(); chickenRepository = diChicken.get<ChickenRepositoryImp>();
localDatasource.openBox().then((value) async {
widelyUsedList.value = localDatasource.getAllWidely();
});
widelyUsedList.value = localDatasource.getAllWidely();
//getKillHouseDistributionInfo();
} }
@override @override
@@ -70,9 +71,7 @@ class RootLogic extends GetxController {
} }
if (widelyUsedList.value?.hasInit != true) { if (widelyUsedList.value?.hasInit != true) {
localDatasource.initWidleyUsed().then( localDatasource.initWidleyUsed().then((value) => localDatasource.getAllWidely());
(value) => localDatasource.getAllWidely(),
);
} }
} }

View File

@@ -86,13 +86,20 @@ class RootPage extends GetView<RootLogic> {
label: 'خرید', label: 'خرید',
icon: Assets.vec.buySvg.path, icon: Assets.vec.buySvg.path,
isSelected: controller.currentPage.value == 0, isSelected: controller.currentPage.value == 0,
onTap: () => controller.changePage(0), onTap: () {
Get.nestedKey(1)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(0);
},
), ),
RBottomNavigationItem( RBottomNavigationItem(
label: 'فروش', label: 'فروش',
icon: Assets.vec.saleSvg.path, icon: Assets.vec.saleSvg.path,
isSelected: controller.currentPage.value == 1, isSelected: controller.currentPage.value == 1,
onTap: () => controller.changePage(1), onTap: () {
Get.nestedKey(0)?.currentState?.popUntil((route) => route.isFirst);
controller.changePage(1);
},
), ),
RBottomNavigationItem( RBottomNavigationItem(
label: 'خانه', label: 'خانه',

View File

@@ -3,7 +3,6 @@ import 'package:flutter/services.dart';
import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart';
import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart';
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_chicken/presentation/utils/string_utils.dart'; import 'package:rasadyar_chicken/presentation/utils/string_utils.dart';
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
import 'package:rasadyar_chicken/presentation/widget/inventory_widget.dart'; import 'package:rasadyar_chicken/presentation/widget/inventory_widget.dart';
@@ -743,7 +742,7 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
Widget show2StepAddBottomSheet() { Widget show2StepAddBottomSheet() {
return BaseBottomSheet( return BaseBottomSheet(
height: Get.height * .35, height: Get.height * .39,
child: Column( child: Column(
spacing: 8, spacing: 8,
children: [ children: [
@@ -808,7 +807,9 @@ class SalesInProvincePage extends GetView<SalesInProvinceLogic> {
text: ' بازگشت', text: ' بازگشت',
textStyle: AppFonts.yekan18.copyWith(color: AppColor.error), textStyle: AppFonts.yekan18.copyWith(color: AppColor.error),
onPressed: () { onPressed: () {
Get.until((route) => route.settings.name == ChickenRoutes.salesInProvince); Get
..back()
..back();
}, },
), ),
), ),

View File

@@ -1,5 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_buyers/view.dart';
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_sales_list/view.dart'; import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_sales_list/view.dart';
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart'; import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart';
@@ -21,14 +20,8 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
filteringWidget: filterBottomSheet(), filteringWidget: filterBottomSheet(),
widgets: [ widgets: [
inventoryWidget(controller.rootLogic), inventoryWidget(controller.rootLogic),
segmentWidget(),
Expanded( Expanded(child: SalesOutOfProvinceSalesListPage()),
child: ObxValue((index) {
return index.value == 0
? SalesOutOfProvinceSalesListPage()
: SalesOutOfProvinceBuyersPage();
}, controller.selectedSegmentIndex),
),
], ],
); );
} }
@@ -61,5 +54,4 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
onChangedToDate: (jalali) => controller.toDateFilter.value = jalali, onChangedToDate: (jalali) => controller.toDateFilter.value = jalali,
onSubmit: () => controller.submitFilter(), onSubmit: () => controller.submitFilter(),
); );
} }

View File

@@ -1,8 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:rasadyar_chicken/data/models/response/out_province_carcasses_buyer/out_province_carcasses_buyer.dart'; import 'package:rasadyar_chicken/data/models/response/out_province_carcasses_buyer/out_province_carcasses_buyer.dart';
import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart'; import 'package:rasadyar_chicken/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart'; import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart';
import 'package:rasadyar_chicken/presentation/widget/list_row_item.dart'; import 'package:rasadyar_chicken/presentation/widget/list_row_item.dart';
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
@@ -44,10 +46,23 @@ class SalesOutOfProvinceSalesListPage extends GetView<SalesOutOfProvinceSalesLis
separatorBuilder: (context, index) => SizedBox(height: 8.h), separatorBuilder: (context, index) => SizedBox(height: 8.h),
); );
}, controller.salesList), }, controller.salesList),
floatingActionButton: RFab.add( floatingActionButton: Row(
onPressed: () { children: [
Get.bottomSheet(addOrEditSaleBottomSheet(), isScrollControlled: true); RFab.add(
}, onPressed: () {
Get.bottomSheet(addOrEditSaleBottomSheet(), isScrollControlled: true);
},
),
Spacer(),
RFab(
icon: Icon(CupertinoIcons.person_add_solid, color: Colors.white, size: 35.w),
backgroundColor: AppColor.blueNormal,
onPressed: () {
Get.toNamed(ChickenRoutes.salesOutOfProvinceBuyer, id: 1);
},
),
SizedBox(width: 25),
],
), ),
floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, floatingActionButtonLocation: FloatingActionButtonLocation.startFloat,
); );

View File

@@ -77,17 +77,15 @@ class SegmentationLogic extends GetxController {
void clearForm() { void clearForm() {
weightController.text = '0'; weightController.text = '0';
selectedSegment.value = null; selectedSegment.value = null;
} }
void validateForm() { void validateForm() {
isSubmitButtonEnabled = RxBool( var weight = int.tryParse(weightController.text.clearComma.trim());
isSubmitButtonEnabled.value =
selectedProduct.value != null && selectedProduct.value != null &&
selectedSegment.value != null &&
weightController.text.isNotEmpty && weightController.text.isNotEmpty &&
int.tryParse(weightController.text) != null && weight! > 0
int.tryParse(weightController.text)! > 0, ;
);
} }
Future<void> getAllSegmentation([bool isLoadingMore = false]) async { Future<void> getAllSegmentation([bool isLoadingMore = false]) async {

View File

@@ -19,6 +19,7 @@ import 'package:rasadyar_chicken/presentation/pages/sales_in_province/view.dart'
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province/view.dart'; import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province/view.dart';
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_buyers/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_buyers/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_buyers/view.dart';
import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_sales_list/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province_sales_list/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/segmentation/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/segmentation/logic.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart'; import 'package:rasadyar_chicken/presentation/routes/routes.dart';
@@ -79,6 +80,17 @@ sealed class ChickenPages {
Get.lazyPut(() => SalesOutOfProvinceSalesListLogic()); Get.lazyPut(() => SalesOutOfProvinceSalesListLogic());
}), }),
), ),
GetPage(
name: ChickenRoutes.salesOutOfProvinceBuyer,
page: () => SalesOutOfProvinceBuyersPage(),
middlewares: [AuthMiddleware()],
binding: BindingsBuilder(() {
Get.lazyPut(() => SearchLogic());
Get.lazyPut(() => SalesOutOfProvinceLogic());
Get.lazyPut(() => SalesOutOfProvinceBuyersLogic());
Get.lazyPut(() => SalesOutOfProvinceSalesListLogic());
}),
),
GetPage( GetPage(
name: ChickenRoutes.salesInProvince, name: ChickenRoutes.salesInProvince,
page: () => SalesInProvincePage(), page: () => SalesInProvincePage(),

View File

@@ -15,6 +15,7 @@ sealed class ChickenRoutes {
//sales //sales
static const salesInProvince = '$sale/SalesInProvince'; static const salesInProvince = '$sale/SalesInProvince';
static const salesOutOfProvince = '$sale/saleOutOfProvince'; static const salesOutOfProvince = '$sale/saleOutOfProvince';
static const salesOutOfProvinceBuyer = '$sale/saleOutOfProvinceBuyer ';
} }

View File

@@ -20,7 +20,7 @@ class WidelyUsedWidget extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text('پر کاربرد ها', textAlign: TextAlign.right, style: AppFonts.yekan16), Text('پر کاربرد ها', textAlign: TextAlign.right, style: AppFonts.yekan16),
ObxValue((data) { /* ObxValue((data) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
controller.toggleType(); controller.toggleType();
@@ -37,32 +37,73 @@ class WidelyUsedWidget extends StatelessWidget {
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
), ),
); );
}, controller.type), }, controller.type)*/
], ],
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.0, vertical: 2), padding: const EdgeInsets.symmetric(horizontal: 2.0, vertical: 2),
child: ObxValue((data) { child: Wrap(
return Wrap( spacing: 15,
spacing: 4, runSpacing: 8,
runSpacing: 18, children: [
children: [ widelyUsed(
widelyUsed( title: 'خرید خارج استان',
title: 'خرید خارج استان', iconPath: Assets.vec.truckFastSvg.path,
isOnEdit: controller.type.value == WidelyUsedType.edit, isOnEdit: false,
iconPath: Assets.vec.truckFastSvg.path,
onTap: () async { cardColor: AppColor.greenLightActive,
controller.rootLogic.currentPage.value = 0; labelColor: AppColor.greenNormal,
controller.rootLogic.currentPage.refresh(); textColor: AppColor.greenDarkHover,
await Future.delayed(Duration(milliseconds: 100)); onTap: () async {
Get.toNamed(ChickenRoutes.buysOutOfProvince, id: 0); controller.rootLogic.currentPage.value = 0;
}, controller.rootLogic.currentPage.refresh();
), await Future.delayed(Duration(milliseconds: 100));
], Get.toNamed(ChickenRoutes.buysOutOfProvince, id: 0);
); },
}, controller.type), ),
widelyUsed(
title: 'خرید داخل استان',
iconPath: Assets.vec.cubeSvg.path,
cardColor: AppColor.greenLightActive,
labelColor: AppColor.greenNormal,
textColor: AppColor.greenDarkHover,
onTap: () async {
controller.rootLogic.currentPage.value = 0;
controller.rootLogic.currentPage.refresh();
await Future.delayed(Duration(milliseconds: 100));
Get.toNamed(ChickenRoutes.buysInProvince, id: 0);
},
isOnEdit: false,
),
widelyUsed(
title: 'فروش خارج استان',
iconPath: Assets.vec.truckFastSvg.path,
isOnEdit: false,
onTap: () async {
controller.rootLogic.currentPage.value = 1;
controller.rootLogic.currentPage.refresh();
await Future.delayed(Duration(milliseconds: 100));
Get.toNamed(ChickenRoutes.salesOutOfProvince, id: 1);
},
),
widelyUsed(
title: 'فروش داخل استان',
iconPath: Assets.vec.cubeSvg.path,
isOnEdit: false,
onTap: () async {
controller.rootLogic.currentPage.value = 1;
controller.rootLogic.currentPage.refresh();
await Future.delayed(Duration(milliseconds: 100));
Get.toNamed(ChickenRoutes.salesInProvince, id: 1);
},
),
],
),
), ),
], ],
); );
@@ -73,6 +114,9 @@ class WidelyUsedWidget extends StatelessWidget {
required String iconPath, required String iconPath,
required VoidCallback onTap, required VoidCallback onTap,
required bool isOnEdit, required bool isOnEdit,
Color? cardColor,
Color? labelColor,
Color? textColor,
}) { }) {
return GestureDetector( return GestureDetector(
onTap: !isOnEdit ? onTap : null, onTap: !isOnEdit ? onTap : null,
@@ -89,14 +133,14 @@ class WidelyUsedWidget extends StatelessWidget {
height: 48, height: 48,
padding: EdgeInsets.all(4), padding: EdgeInsets.all(4),
decoration: ShapeDecoration( decoration: ShapeDecoration(
color: Color(0xFFBECDFF), color: cardColor ?? Color(0xFFBECDFF),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
), ),
child: Container( child: Container(
width: 40, width: 40,
height: 40, height: 40,
decoration: ShapeDecoration( decoration: ShapeDecoration(
color: AppColor.blueNormal, color: labelColor ?? AppColor.blueNormal,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
), ),
child: SvgGenImage.vec(iconPath).svg( child: SvgGenImage.vec(iconPath).svg(
@@ -146,7 +190,7 @@ class WidelyUsedWidget extends StatelessWidget {
), ),
], ],
), ),
Text(title, style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal)), Text(title, style: AppFonts.yekan10.copyWith(color: textColor ?? AppColor.blueNormal)),
], ],
), ),
); );

View File

@@ -2,14 +2,14 @@ import 'package:flutter/foundation.dart';
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
class HiveLocalStorage implements ILocalStorage { class HiveLocalStorage implements ILocalStorage {
HiveLocalStorage() {
Hive.initFlutter();
}
final Map<String, Box> _boxes = {};
@override @override
Future init() async => await Hive.initFlutter(); Future init() async {
if (kIsWeb) {
Hive.init('hive_storage_rasadyar');
} else {
await Hive.initFlutter();
}
}
@override @override
Future<void> openBox<T>( Future<void> openBox<T>(
@@ -20,13 +20,13 @@ class HiveLocalStorage implements ILocalStorage {
Uint8List? bytes, Uint8List? bytes,
String? collection, String? collection,
}) async { }) async {
if (!_boxes.containsKey(boxName)) { var exist = await Hive.boxExists(boxName);
final box = await Hive.openBox<T>( if (!exist || !Hive.isBoxOpen(boxName)) {
await Hive.openBox<T>(
boxName, boxName,
encryptionCipher: encryptionCipher, encryptionCipher: encryptionCipher,
crashRecovery: crashRecovery, crashRecovery: crashRecovery,
); );
_boxes[boxName] = box;
} }
} }
@@ -42,10 +42,10 @@ class HiveLocalStorage implements ILocalStorage {
} }
@override @override
T? readBox<T>({required String boxName}) { List<T>? readBox<T>({required String boxName}) {
try { try {
Box? box = getBox(boxName); Box? box = getBox<T>(boxName);
return box?.values as T?; return box?.values.cast<T>().toList();
} on Exception catch (e) { } on Exception catch (e) {
eLog(e); eLog(e);
return null; return null;
@@ -53,55 +53,51 @@ class HiveLocalStorage implements ILocalStorage {
} }
@override @override
Future<void> add({required String boxName, required dynamic value}) async { Future<void> add<T>({required String boxName, required dynamic value}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox<T>(boxName);
await box?.add(value); await box?.add(value);
} }
@override @override
Future<void> addAll({required String boxName, required Iterable values}) async { Future<void> addAll<T>({required String boxName, required Iterable values}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox<T>(boxName);
await box?.addAll(values); await box?.addAll(values);
} }
Box<T>? getBox<T>(String boxName) { Box<T>? getBox<T>(String boxName) {
final box = _boxes[boxName]; final box = Hive.box<T>(boxName);
if (box is Box<T>) { return box;
return box;
} else {
throw Exception('Box $boxName is not of exist');
}
} }
@override @override
Future<void> clear(String boxName) async { Future<void> clear(String boxName) async {
await _boxes[boxName]?.clear(); await Hive.box(boxName).clear();
} }
@override @override
Future<void> close(String boxName) async => await _boxes[boxName]?.close(); Future<void> close(String boxName) async => await Hive.box(boxName).close();
@override @override
Future<void> deleteValue({required String boxName, required String key}) async { Future<void> deleteValue<T>({required String boxName, required String key}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox<T>(boxName);
await box?.delete(key); await box?.delete(key);
} }
@override @override
Future<void> save({required String boxName, required String key, required value}) async { Future<void> save<T>({required String boxName, required String key, required value}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox<T>(boxName);
await box?.put(key, value); await box?.put(key, value);
} }
@override @override
Future<void> saveAll({required String boxName, required Map entries}) async { Future<void> saveAll<T>({required String boxName, required Map entries}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox<T>(boxName);
await box?.putAll(entries); await box?.putAll(entries);
} }
@override @override
Future<void> saveAt({required String boxName, required int index, required value}) async { Future<void> saveAt<T>({required String boxName, required int index, required value}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox<T>(boxName);
await box?.putAt(index, value); await box?.putAt(index, value);
} }
} }

View File

@@ -15,32 +15,21 @@ abstract class ILocalStorage<E> {
T? read<T>({required String boxName, required String key}); T? read<T>({required String boxName, required String key});
T? readBox<T>({required String boxName}); List<T>? readBox<T>({required String boxName});
Future<void> deleteValue({required String boxName, required String key}); Future<void> deleteValue<T>({required String boxName, required String key});
Future<void> add({required String boxName, required E value}); Future<void> add<T>({required String boxName, required E value});
Future<void> addAll({required String boxName, required Iterable<E> values}); Future<void> addAll<T>({required String boxName, required Iterable<E> values});
Future<void> clear(String boxName); Future<void> clear(String boxName);
Future<void> close(String boxName); Future<void> close(String boxName);
Future<void> save({ Future<void> save<T>({required String boxName, required String key, required dynamic value});
required String boxName,
required String key,
required dynamic value,
});
Future<void> saveAt({ Future<void> saveAt<T>({required String boxName, required int index, required dynamic value});
required String boxName,
required int index,
required dynamic value,
});
Future<void> saveAll({ Future<void> saveAll<T>({required String boxName, required Map<dynamic, E> entries});
required String boxName,
required Map<dynamic, E> entries,
});
} }

View File

@@ -15,10 +15,12 @@ class DioRemote implements IHttpClient {
if (kDebugMode) { if (kDebugMode) {
dio.interceptors.add( dio.interceptors.add(
PrettyDioLogger( PrettyDioLogger(
requestHeader: true, request: false,
responseHeader: true, enabled: false,
requestBody: true, requestHeader: false,
responseBody: true, responseHeader: false,
requestBody: false,
responseBody: false,
), ),
); );
} }

View File

@@ -100,11 +100,11 @@ class AppFonts {
); );
static const TextStyle yekan10 = TextStyle( static TextStyle yekan10 = TextStyle(
// Rounded from 10.24 // Rounded from 10.24
fontFamily: yekan, fontFamily: yekan,
fontWeight: regular, fontWeight: regular,
fontSize: 10, fontSize: 10.sp,
height: _height, height: _height,
); );

View File

@@ -1,7 +1,7 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:rasadyar_core/core.dart'; import 'package:rasadyar_core/core.dart';
class HiveLocalStorage implements ILocalStorage { class HiveLocalStorage implements ILocalStorage {
HiveLocalStorage() { HiveLocalStorage() {
Hive.initFlutter(); Hive.initFlutter();
} }
@@ -42,16 +42,13 @@ import 'package:rasadyar_core/core.dart';
} }
@override @override
Future<void> add({required String boxName, required dynamic value}) async { Future<void> add<T>({required String boxName, required dynamic value}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox(boxName);
await box?.add(value); await box?.add(value);
} }
@override @override
Future<void> addAll({ Future<void> addAll<T>({required String boxName, required Iterable values}) async {
required String boxName,
required Iterable values,
}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox(boxName);
await box?.addAll(values); await box?.addAll(values);
} }
@@ -67,44 +64,39 @@ import 'package:rasadyar_core/core.dart';
@override @override
Future<void> clear(String boxName) async { Future<void> clear(String boxName) async {
await _boxes[boxName]?.clear(); await Hive.box(boxName).clear();
} }
@override @override
Future<void> close(String boxName) async => await _boxes[boxName]?.close(); Future<void> close(String boxName) async => await _boxes[boxName]?.close();
@override @override
Future<void> deleteValue({ Future<void> deleteValue<T>({required String boxName, required String key}) async {
required String boxName, Box<dynamic>? box = getBox<T>(boxName);
required String key,
}) async {
Box<dynamic>? box = getBox(boxName);
await box?.delete(key); await box?.delete(key);
} }
@override @override
Future<void> save({ Future<void> save<T>({required String boxName, required String key, required value}) async {
required String boxName, Box<dynamic>? box = getBox<T>(boxName);
required String key,
required value,
}) async {
Box<dynamic>? box = getBox(boxName);
await box?.put(key, value); await box?.put(key, value);
} }
@override @override
Future<void> saveAll({required String boxName, required Map entries}) async { Future<void> saveAll<T>({required String boxName, required Map entries}) async {
Box<dynamic>? box = getBox(boxName); Box<dynamic>? box = getBox<T>(boxName);
await box?.putAll(entries); await box?.putAll(entries);
} }
@override @override
Future<void> saveAt({ Future<void> saveAt<T>({required String boxName, required int index, required value}) async {
required String boxName, Box<dynamic>? box = getBox<T>(boxName);
required int index,
required value,
}) async {
Box<dynamic>? box = getBox(boxName);
await box?.putAt(index, value); await box?.putAt(index, value);
} }
@override
T? readBox<T>({required String boxName}) {
// TODO: implement readBox
throw UnimplementedError();
}
} }

View File

@@ -1,7 +1,7 @@
name: rasadyar_app name: rasadyar_app
description: "A new Flutter project." description: "A new Flutter project."
publish_to: 'none' publish_to: 'none'
version: 1.3.0+2 version: 1.3.2+3
environment: environment:
sdk: ^3.8.1 sdk: ^3.8.1