import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart' hide BasePage; import 'package:rasadyar_inspection/presentation/pages/records/view.dart'; import 'package:rasadyar_inspection/presentation/pages/statistics/view.dart'; import 'package:rasadyar_inspection/presentation/pages/users/view.dart'; import 'package:rasadyar_inspection/presentation/widget/base_page/view.dart'; import 'logic.dart'; class ActionPage extends GetView { const ActionPage({super.key}); @override Widget build(BuildContext context) { return BasePage( hasBack: false, hasFilter: true, hasSearch: true, widgets: [ SizedBox(height: 20), ObxValue((data) { return Row( mainAxisAlignment: MainAxisAlignment.center, children: List.generate(controller.headersIcons.length, (index) { return headerWidget( iconPath: controller.headersIcons[index], title: controller.headersTitle[index], onTap: () { controller.updateSelectedIndex(index); }, isSelected: controller.selectedIndex.value == index, ); }), ); }, controller.selectedIndex), Expanded( child: Container( color: Colors.white, child: ObxValue((index) { return switch (index.value) { 0 => UsersPage(), 1 => RecordsPage(), 2 => StatisticsPage(), int() => throw UnimplementedError(), }; }, controller.selectedIndex), ), ), ], ); } Widget supervisionHistoryWidget() { return ObxValue((data) { return ListView.builder( itemBuilder: (context, index) { return historyItem(data[index], () { data[index] = !data[index]; }); }, shrinkWrap: true, physics: BouncingScrollPhysics(), itemCount: data.length, ); }, controller.supervisionHistoryList); } Widget headerWidget({ required String iconPath, required String title, required VoidCallback onTap, bool isSelected = false, }) { return GestureDetector( onTap: onTap, child: Container( width: 93.w, height: 104.h, margin: EdgeInsets.symmetric(horizontal: 8.w), padding: EdgeInsets.symmetric(horizontal: 12.w,vertical: 8.h), decoration: BoxDecoration( color: isSelected ? Colors.white : Colors.transparent, borderRadius: BorderRadius.only( topLeft: Radius.circular(20), topRight: Radius.circular(20), ), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, spacing: 8, children: [ Container( width: 48.w, height: 48.h, padding: EdgeInsets.all(8), decoration: ShapeDecoration( color: isSelected ? AppColor.blueLightActive : Colors.transparent, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), ), child: SvgGenImage.vec(iconPath).svg( width: 24.w, height: 24.h, colorFilter: ColorFilter.mode( isSelected ? AppColor.blueNormalActive : AppColor.blueNormal, BlendMode.srcIn, ), ), ), Text( title, style: AppFonts.yekan12.copyWith( color: isSelected ? AppColor.blueNormalActive : AppColor.blueNormal, ), ), ], ), ), ); } Widget slidableWidgetTwo({required VoidCallback onTap}) { return Slidable( key: Key('selectedLocationWidget'), controller: controller.slidController.value, endActionPane: ActionPane( motion: StretchMotion(), children: [ CustomSlidableAction( onPressed: (context) {}, backgroundColor: AppColor.blueNormal, foregroundColor: Colors.white, padding: EdgeInsets.all(16), borderRadius: BorderRadius.only( topRight: Radius.circular(8), bottomRight: Radius.circular(8), ), autoClose: true, child: Assets.vec.trashSvg.svg(width: 24, height: 24), ), CustomSlidableAction( onPressed: (context) {}, backgroundColor: AppColor.redNormal, foregroundColor: Colors.white, padding: EdgeInsets.all(16), borderRadius: BorderRadius.only( topLeft: Radius.circular(8), bottomLeft: Radius.circular(8), ), autoClose: true, child: Assets.vec.trashSvg.svg(width: 24, height: 24), ), ], ), child: GestureDetector( onTap: onTap, child: Container( height: 62, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), border: Border.all(width: 1, color: AppColor.blackLightHover), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Column( spacing: 4, children: [ Text( 'داود خرم مهری پور', style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal), ), Text( '03295224154', style: AppFonts.yekan12.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), Column( spacing: 4, children: [ Text( 'افزودن کاربر', style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal), ), Text( 'ثبت بازرسی', style: AppFonts.yekan12.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), Column( spacing: 4, children: [ Text('همدان', style: AppFonts.yekan10.copyWith(color: AppColor.blueNormal)), Text( 'همدان', style: AppFonts.yekan12.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), ], ), ), ), ); } Widget historyItem(bool isExpanded, VoidCallback onTap) { return AnimatedContainer( margin: EdgeInsets.symmetric(horizontal: 30, vertical: 10), curve: Curves.easeInOut, duration: Duration(seconds: 1), height: isExpanded ? 364 : 62, child: isExpanded ? markerDetailsWidget(ontap: onTap) : slidableWidgetTwo(onTap: onTap), ); } Widget markerDetailsWidget({required VoidCallback ontap}) { return GestureDetector( onTap: ontap, behavior: HitTestBehavior.opaque, child: Container( clipBehavior: Clip.antiAlias, padding: EdgeInsets.symmetric(horizontal: 20, vertical: 10), decoration: ShapeDecoration( color: Colors.white, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), ), child: Column( spacing: 15, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, spacing: 12, children: [ vecWidgetWithOnTap( child: Assets.vec.editSvg.svg(), onTap: () {}, width: 24, height: 24, color: AppColor.blueNormal, ), Text( 'سوابق بازرسی من', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), vecWidgetWithOnTap( child: Assets.vec.trashSvg.svg(), width: 24, height: 24, color: AppColor.redNormal, onTap: () {}, ), ], ), Container( height: 32, clipBehavior: Clip.antiAlias, padding: EdgeInsets.symmetric(horizontal: 10, vertical: 4), decoration: ShapeDecoration( color: AppColor.blueLight, shape: RoundedRectangleBorder( side: BorderSide(width: 1, color: AppColor.blueLightHover), ), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( 'تاریخ بازرسی', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), Text( '1403/12/12', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'شماره همراه', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), Text( '0326598653', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'آخرین فعالیت', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), Text( '1409/12/12', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'موجودی', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), Text( '5کیلوگرم', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), ...List.generate( 5, (index) => Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( 'فروش رفته', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), Text( '0 کیلوگرم', textAlign: TextAlign.center, style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDarkHover), ), ], ), ), ], ), ), ); } Column optionWidget({ required RxInt selected, required String title, required List options, }) { return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row(), Padding( padding: const EdgeInsets.symmetric(horizontal: 22, vertical: 10), child: Text( title, textAlign: TextAlign.center, style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal), ), ), Padding( padding: const EdgeInsets.symmetric(horizontal: 30), child: Wrap( runSpacing: 8, spacing: 8, children: options .map( (e) => ObxValue((data) { return ChoiceChip( onSelected: (value) { selected.value = options.indexOf(e); }, selectedColor: AppColor.blueNormal, labelStyle: data.value == options.indexOf(e) ? AppFonts.yekan13.copyWith(color: AppColor.whiteLight) : AppFonts.yekan12.copyWith(color: AppColor.darkGreyNormalActive), checkmarkColor: Colors.white, label: Text(e), selected: options.indexOf(e) == data.value, ); }, selected), ) .toList(), ), ), ], ); } Container headerInfo({required String title, required String description, Color? background}) { return Container( clipBehavior: Clip.antiAlias, padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12), decoration: ShapeDecoration( color: background ?? AppColor.blueLight, shape: RoundedRectangleBorder( side: BorderSide(width: 1, color: AppColor.blackLightHover), borderRadius: BorderRadius.circular(8), ), ), alignment: AlignmentDirectional.center, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, spacing: 10, children: [ Text(title, style: AppFonts.yekan10), Text(description, style: AppFonts.yekan12), ], ), ); } }