diff --git a/packages/chicken/lib/presentation/pages/root/view.dart b/packages/chicken/lib/presentation/pages/root/view.dart index e442966..81c54f0 100644 --- a/packages/chicken/lib/presentation/pages/root/view.dart +++ b/packages/chicken/lib/presentation/pages/root/view.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/chicken.dart'; import 'package:rasadyar_chicken/data/models/response/kill_house_distribution_info/kill_house_distribution_info.dart'; -import 'package:rasadyar_chicken/presentation/pages/buys_out_of_province/view.dart'; -import 'package:rasadyar_chicken/presentation/pages/sales_out_of_province/view.dart'; import 'package:rasadyar_core/core.dart'; class RootPage extends GetView { @@ -17,35 +15,37 @@ class RootPage extends GetView { children: [ Navigator( key: controller.navigatorKeys[0], - onGenerateRoute: (settings) => GetPageRoute(page: () => controller.pages[0]), + onGenerateRoute: (settings) => + GetPageRoute(page: () => controller.pages[0]), ), Navigator( key: Get.nestedKey(1), onGenerateRoute: (settings) { - Widget page; - if (settings.name == ChickenRoutes.outOfProvince) { - page = controller.pages[1]; - } else if (settings.name == ChickenRoutes.salesOutOfProvince) { - page = SalesOutOfProvincePage(); - } else if (settings.name == ChickenRoutes.buysOutOfProvince) { - page = BuysOutOfProvincePage(); - } else { - page = controller.pages[1]; - } - return GetPageRoute(page: () => page); + final page = ChickenPages.pages.firstWhere( + (e) => e.name == settings.name, + orElse: () => ChickenPages.pages.firstWhere( + (e) => e.name == ChickenRoutes.outOfProvince, + ), + ); + + return buildRouteFromGetPage(page); + }, ), Navigator( key: controller.navigatorKeys[2], - onGenerateRoute: (settings) => GetPageRoute(page: () => controller.pages[2]), + onGenerateRoute: (settings) => + GetPageRoute(page: () => controller.pages[2]), ), Navigator( key: controller.navigatorKeys[3], - onGenerateRoute: (settings) => GetPageRoute(page: () => controller.pages[3]), + onGenerateRoute: (settings) => + GetPageRoute(page: () => controller.pages[3]), ), Navigator( key: controller.navigatorKeys[4], - onGenerateRoute: (settings) => GetPageRoute(page: () => controller.pages[4]), + onGenerateRoute: (settings) => + GetPageRoute(page: () => controller.pages[4]), ), ], index: data.value, @@ -106,7 +106,10 @@ class RootPage extends GetView { return Container( height: 70, width: Get.width / 2, - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), clipBehavior: Clip.hardEdge, child: Row( children: [ @@ -127,7 +130,9 @@ class RootPage extends GetView { Text( 'بارهای امروز', textAlign: TextAlign.right, - style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + style: AppFonts.yekan14.copyWith( + color: AppColor.blueNormal, + ), ), ], ), @@ -177,19 +182,26 @@ class RootPage extends GetView { height: 82, decoration: BoxDecoration( color: bgLabelColor, - borderRadius: BorderRadius.only(topRight: Radius.circular(8), bottomRight: Radius.circular(8)), + borderRadius: BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8), + ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, spacing: 4, children: [ - SvgGenImage.vec( - iconPath, - ).svg(width: 24, height: 24, colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn)), + SvgGenImage.vec(iconPath).svg( + width: 24, + height: 24, + colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn), + ), Text( title, textAlign: TextAlign.right, - style: AppFonts.yekan14.copyWith(color: AppColor.mediumGreyDarkActive), + style: AppFonts.yekan14.copyWith( + color: AppColor.mediumGreyDarkActive, + ), ), ], ), @@ -200,7 +212,10 @@ class RootPage extends GetView { child: Container( decoration: BoxDecoration( color: bgDescriptionColor, - borderRadius: BorderRadius.only(topLeft: Radius.circular(8), bottomLeft: Radius.circular(8)), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8), + ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -209,12 +224,16 @@ class RootPage extends GetView { Text( description, textAlign: TextAlign.right, - style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkActive), + style: AppFonts.yekan16.copyWith( + color: AppColor.mediumGreyDarkActive, + ), ), Text( unit, textAlign: TextAlign.center, - style: AppFonts.yekan12.copyWith(color: AppColor.mediumGreyDarkActive), + style: AppFonts.yekan12.copyWith( + color: AppColor.mediumGreyDarkActive, + ), ), ], ), @@ -259,17 +278,23 @@ class RootPage extends GetView { Text( title, textAlign: TextAlign.right, - style: AppFonts.yekan14.copyWith(color: AppColor.mediumGreyDarkActive), + style: AppFonts.yekan14.copyWith( + color: AppColor.mediumGreyDarkActive, + ), ), Text( description, textAlign: TextAlign.right, - style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkActive), + style: AppFonts.yekan16.copyWith( + color: AppColor.mediumGreyDarkActive, + ), ), Text( unit, textAlign: TextAlign.center, - style: AppFonts.yekan12.copyWith(color: AppColor.mediumGreyDarkActive), + style: AppFonts.yekan12.copyWith( + color: AppColor.mediumGreyDarkActive, + ), ), ], ), @@ -288,9 +313,11 @@ class RootPage extends GetView { ), ), child: Center( - child: SvgGenImage.vec( - iconPath, - ).svg(width: 24, height: 24, colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn)), + child: SvgGenImage.vec(iconPath).svg( + width: 24, + height: 24, + colorFilter: ColorFilter.mode(iconColor, BlendMode.srcIn), + ), ), ), ), @@ -299,7 +326,11 @@ class RootPage extends GetView { ); } - Widget widelyUsed({required String title, required String iconPath, required VoidCallback onTap}) { + Widget widelyUsed({ + required String title, + required String iconPath, + required VoidCallback onTap, + }) { return Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.start, @@ -311,14 +342,18 @@ class RootPage extends GetView { padding: EdgeInsets.all(4), decoration: ShapeDecoration( color: const Color(0xFFBECDFF), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), ), child: Container( width: 40, height: 40, decoration: ShapeDecoration( color: AppColor.blueNormal, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), ), child: SvgGenImage.vec(iconPath).svg( width: 24, @@ -328,7 +363,10 @@ class RootPage extends GetView { ), ), ), - Text(title, style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal)), + Text( + title, + style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal), + ), ], ); } @@ -345,16 +383,24 @@ class RootPage extends GetView { padding: EdgeInsets.all(4), decoration: ShapeDecoration( color: const Color(0xFFD9F7F0), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + ), ), child: Assets.vec.messageAddSvg.svg( width: 40, height: 40, - colorFilter: ColorFilter.mode(AppColor.greenNormal, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + AppColor.greenNormal, + BlendMode.srcIn, + ), fit: BoxFit.cover, ), ), - Text('افزودن', style: AppFonts.yekan10.copyWith(color: AppColor.greenDarkHover)), + Text( + 'افزودن', + style: AppFonts.yekan10.copyWith(color: AppColor.greenDarkHover), + ), ], ); } @@ -501,7 +547,9 @@ class RootPage extends GetView { child: Text( title, textAlign: TextAlign.right, - style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), + style: AppFonts.yekan14.copyWith( + color: AppColor.darkGreyDarkHover, + ), ), ), Flexible( @@ -509,7 +557,9 @@ class RootPage extends GetView { child: Text( value, textAlign: TextAlign.center, - style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), + style: AppFonts.yekan14.copyWith( + color: AppColor.darkGreyDarkHover, + ), ), ), ], @@ -535,18 +585,30 @@ class RootPage extends GetView { Text( 'اطلاعات ارسالی', textAlign: TextAlign.right, - style: AppFonts.yekan16Bold.copyWith(color: AppColor.blueNormal), + style: AppFonts.yekan16Bold.copyWith( + color: AppColor.blueNormal, + ), ), const SizedBox(height: 12), - buildRow('فروش و توزیع داخل استان (کیلوگرم)', model.stewardAllocationsWeight!.toInt().toString()), - buildRow('فروش و توزیع خارج استان (کیلوگرم)', model.freeSalesWeight!.toInt().toString()), + buildRow( + 'فروش و توزیع داخل استان (کیلوگرم)', + model.stewardAllocationsWeight!.toInt().toString(), + ), + buildRow( + 'فروش و توزیع خارج استان (کیلوگرم)', + model.freeSalesWeight!.toInt().toString(), + ), ], ) : const Center(child: CircularProgressIndicator()), ); } - Widget cardWidget({required String title, required String iconPath, required VoidCallback onTap}) { + Widget cardWidget({ + required String title, + required String iconPath, + required VoidCallback onTap, + }) { return Container( width: Get.width / 4, height: 130, diff --git a/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart b/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart index 7d36522..cc17bb4 100644 --- a/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart +++ b/packages/chicken/lib/presentation/pages/sales_out_of_province/view.dart @@ -11,8 +11,6 @@ class SalesOutOfProvincePage extends GetView { Widget build(BuildContext context) { return Scaffold( appBar: RAppBar( - title: 'رصدطیور', - iconTitle: Assets.vec.chickenSvg.path, titleTextStyle: AppFonts.yekan16Bold.copyWith(color: Colors.white), centerTitle: true, hasBack: true, @@ -24,12 +22,18 @@ class SalesOutOfProvincePage extends GetView { mainAxisSize: MainAxisSize.min, spacing: 6, children: [ - Assets.vec.cubeSearchSvg.svg( + Assets.vec.chickenSvg.svg( width: 24, height: 24, - colorFilter: const ColorFilter.mode(Colors.white, BlendMode.srcIn), + colorFilter: const ColorFilter.mode( + Colors.white, + BlendMode.srcIn, + ), + ), + Text( + 'رصدطیور', + style: AppFonts.yekan16Bold.copyWith(color: Colors.white), ), - Text('خرید خارج استان', style: AppFonts.yekan16Bold.copyWith(color: Colors.white)), ], ), additionalActions: [ @@ -47,123 +51,182 @@ class SalesOutOfProvincePage extends GetView { SizedBox(width: 8), ], ), - body: ListView.separated( - padding: EdgeInsets.fromLTRB(8, 8, 18, 80), - itemBuilder: (context, index) { - return ObxValue( - (data) => GestureDetector( + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + routePageWidget(), + saleListWidget(), + ], + ), + floatingActionButton: RFab.add(onPressed: () {}), + floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, + ); + } + + ListView saleListWidget() { + return ListView.separated( + shrinkWrap: true, + padding: EdgeInsets.fromLTRB(8, 8, 18, 80), + itemBuilder: (context, index) { + return ObxValue( + (data) => saleListItem(data, index), + controller.isExpandedList, + ); + }, + separatorBuilder: (context, index) => SizedBox(height: 8), + itemCount: 5, + ); + } + + GestureDetector saleListItem(RxList data, int index) { + return GestureDetector( onTap: () { - if(data.contains(index)){ + if (data.contains(index)) { controller.isExpandedList.remove(index); - }else{ + } else { controller.isExpandedList.add(index); } - }, child: AnimatedContainer( duration: Duration(milliseconds: 400), alignment: Alignment.center, - height: data.contains(index)? 210 : 56, + height: data.contains(index) ? 210 : 56, child: Stack( clipBehavior: Clip.none, alignment: Alignment.centerRight, children: [ AnimatedContainer( width: Get.width - 30, - duration: Duration(milliseconds: 400), + duration: Duration(milliseconds: 300), height: data.contains(index) ? 210 : 56, alignment: Alignment.center, decoration: BoxDecoration( color: Colors.transparent, borderRadius: BorderRadius.circular(8), - border: Border.all(width: 0.5, color: AppColor.darkGreyNormal), + border: Border.all( + width: 0.5, + color: AppColor.darkGreyNormal, + ), ), child: AnimatedCrossFade( alignment: Alignment.center, firstChild: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text( '1403/5/5', textAlign: TextAlign.center, - style: AppFonts.yekan14.copyWith(color: AppColor.bgDark), + style: AppFonts.yekan14.copyWith( + color: AppColor.bgDark, + ), ), Text( 'افلاک', textAlign: TextAlign.center, - style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + style: AppFonts.yekan14.copyWith( + color: AppColor.blueNormal, + ), ), Text( 'kg 200 مرغ گرم ', textAlign: TextAlign.center, - style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + style: AppFonts.yekan14.copyWith( + color: AppColor.blueNormal, + ), ), Text( 'لرستان-خرم آباد', textAlign: TextAlign.center, - style: AppFonts.yekan14.copyWith(color: AppColor.bgDark), + style: AppFonts.yekan14.copyWith( + color: AppColor.bgDark, + ), ), - Icon(CupertinoIcons.chevron_down,size: 12,) + Icon(CupertinoIcons.chevron_down, size: 12), ], ), secondChild: Container( padding: EdgeInsets.fromLTRB(8, 12, 14, 12), - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), child: Column( spacing: 8, children: [ Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: + MainAxisAlignment.spaceBetween, children: [ Assets.vec.editSvg.svg( width: 20, height: 20, - colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + AppColor.blueNormal, + BlendMode.srcIn, + ), ), Text( 'لرستان - خرم آباد', textAlign: TextAlign.center, - style: AppFonts.yekan16.copyWith(color: AppColor.greenDark), + style: AppFonts.yekan16.copyWith( + color: AppColor.greenDark, + ), ), Assets.vec.trashSvg.svg( width: 20, height: 20, - colorFilter: ColorFilter.mode(AppColor.error, BlendMode.srcIn), + colorFilter: ColorFilter.mode( + AppColor.error, + BlendMode.srcIn, + ), ), ], ), Container( height: 32, - padding: EdgeInsets.symmetric(horizontal: 4), + padding: EdgeInsets.symmetric( + horizontal: 4, + ), decoration: ShapeDecoration( color: AppColor.blueLight, shape: RoundedRectangleBorder( - side: BorderSide(width: 1, color: AppColor.blueLightHover), + side: BorderSide( + width: 1, + color: AppColor.blueLightHover, + ), borderRadius: BorderRadius.circular(8), ), ), - child: buildRow('تاریخ', '07:15:00 - 1402/07/01'), + child: buildRow( + 'تاریخ', + '07:15:00 - 1402/07/01', + ), ), - buildRow('مشخصات فروشنده', 'افلاک - 09203659874'), + buildRow( + 'مشخصات فروشنده', + 'افلاک - 09203659874', + ), buildRow('وزن خریداری شده', '200 کیلوگرم'), buildRow('لاشه خریداری شده', '200 عدد'), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Icon(CupertinoIcons.chevron_up,size: 12,) + Icon(CupertinoIcons.chevron_up, size: 12), ], - ) + ), ], ), ), - crossFadeState: data.contains(index)?CrossFadeState.showSecond:CrossFadeState.showFirst, - duration: Duration(milliseconds: 200), + crossFadeState: data.contains(index) + ? CrossFadeState.showSecond + : CrossFadeState.showFirst, + duration: Duration(milliseconds: 300), ), ), Positioned( @@ -175,25 +238,58 @@ class SalesOutOfProvincePage extends GetView { decoration: BoxDecoration( color: AppColor.greenLightHover, borderRadius: BorderRadius.circular(4), - border: Border.all(width: 0.50, color: AppColor.greenDarkActive), + border: Border.all( + width: 0.50, + color: AppColor.greenDarkActive, + ), ), alignment: Alignment.center, - child: Text((index + 1).toString(), style: AppFonts.yekan12.copyWith(color: Colors.black)), + child: Text( + (index + 1).toString(), + style: AppFonts.yekan12.copyWith( + color: Colors.black, + ), + ), ), ), ], ), ), + ); + } + + Row routePageWidget() { + return Row( + children: [ + SizedBox(width: 8), + RichText( + text: TextSpan( + style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + children: [ + WidgetSpan( + child: Row( + children: [ + Assets.vec.cubeSearchSvg.svg( + width: 24, + height: 24, + colorFilter: const ColorFilter.mode( + AppColor.blueNormal, + BlendMode.srcIn, + ), + ), + SizedBox(width: 6,) + ], + ), + ), + + TextSpan(text: 'خارج استان'), + TextSpan(text: '/'), + TextSpan(text: 'خرید'), + ], + ), ), - controller.isExpandedList, - ); - }, - separatorBuilder: (context, index) => SizedBox(height: 8), - itemCount: 5, - ), - floatingActionButton: RFab.add(onPressed: () {}), - floatingActionButtonLocation: FloatingActionButtonLocation.startFloat, - ); + ], + ); } Widget buildRow(String title, String value) { @@ -207,7 +303,9 @@ class SalesOutOfProvincePage extends GetView { child: Text( title, textAlign: TextAlign.right, - style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), + style: AppFonts.yekan14.copyWith( + color: AppColor.darkGreyDarkHover, + ), ), ), Flexible( @@ -215,13 +313,13 @@ class SalesOutOfProvincePage extends GetView { child: Text( value, textAlign: TextAlign.left, - style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), + style: AppFonts.yekan14.copyWith( + color: AppColor.darkGreyDarkHover, + ), ), ), ], ), ); } - - } diff --git a/packages/core/lib/core.dart b/packages/core/lib/core.dart index 1ad8104..a2b70e5 100644 --- a/packages/core/lib/core.dart +++ b/packages/core/lib/core.dart @@ -45,3 +45,4 @@ export 'utils/safe_call_utils.dart'; export 'utils/date_time_utils.dart'; export 'utils/num_utils.dart'; export 'utils/map_utils.dart'; +export 'utils/route_utils.dart'; diff --git a/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart b/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart index d48c8c2..b14fe91 100644 --- a/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart +++ b/packages/core/lib/presentation/widget/app_bar/r_app_bar.dart @@ -3,7 +3,7 @@ import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart'; class RAppBar extends StatelessWidget implements PreferredSizeWidget { - final String title; + final String? title; final String? iconTitle; final Color backgroundColor; final Color iconColor; @@ -18,7 +18,7 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { const RAppBar({ super.key, - required this.title, + this.title, this.iconTitle, this.backgroundColor = AppColor.blueNormal, this.iconColor = Colors.white, @@ -43,15 +43,15 @@ class RAppBar extends StatelessWidget implements PreferredSizeWidget { centerTitle: centerTitle, titleTextStyle: titleTextStyle ?? AppFonts.yekan16.copyWith(color: Colors.white), - title: Row( + title:title != null ? Row( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Text(title), + Text(title!), if (iconTitle != null) ...{const SizedBox(width: 8)}, if (iconTitle != null) ...{SvgGenImage.vec(iconTitle!).svg(width: 24, height: 24)}, ], - ), + ): null, leadingWidth: leadingWidth?.toDouble(), leading: leading != null ? Padding(padding: const EdgeInsets.only(right: 6), child: leading) : null, titleSpacing: 8, diff --git a/packages/core/lib/utils/route_utils.dart b/packages/core/lib/utils/route_utils.dart new file mode 100644 index 0000000..64e23d3 --- /dev/null +++ b/packages/core/lib/utils/route_utils.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +GetPageRoute buildRouteFromGetPage(GetPage page) { + return GetPageRoute( + page: page.page, + settings: RouteSettings(name: page.name), + transition: page.transition, + curve: page.curve, + binding: page.binding, + bindings: page.bindings, + routeName: page.name, + title: page.title, + gestureWidth: page.gestureWidth, + alignment: page.alignment, + maintainState: page.maintainState, + customTransition: page.customTransition, + transitionDuration: page.transitionDuration ?? const Duration(milliseconds: 300), + fullscreenDialog: page.fullscreenDialog, + opaque: page.opaque, + popGesture: page.popGesture, + showCupertinoParallax: page.showCupertinoParallax, + ); +} \ No newline at end of file