Files
rasadyar_application/packages/chicken/lib/presentation/widget/widely_used/view.dart

225 lines
7.8 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class WidelyUsedWidget extends StatelessWidget {
const WidelyUsedWidget({super.key});
@override
Widget build(BuildContext context) {
final WidelyUsedLogic controller = Get.put(WidelyUsedLogic());
return Column(
children: [
Padding(
padding: EdgeInsetsGeometry.all(6),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('پر کاربرد ها', textAlign: TextAlign.right, style: AppFonts.yekan16),
/* ObxValue((data) {
return GestureDetector(
onTap: () {
controller.toggleType();
},
child: controller.isOnEdit()
? Assets.vec.checkSvg.svg(
width: 12.w,
height: 12.h,
colorFilter: ColorFilter.mode(AppColor.greenNormal, BlendMode.srcIn),
)
: Assets.vec.editSvg.svg(
width: 16.w,
height: 16.h,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
);
}, controller.type)*/
],
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.0, vertical: 2),
child: Wrap(
spacing: 15,
runSpacing: 8,
children: [
widelyUsed(
title: 'خرید خارج استان',
iconPath: Assets.vec.truckFastSvg.path,
isOnEdit: false,
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.buysOutOfProvince, id: 0);
},
),
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);
},
),
],
),
),
],
);
}
Widget widelyUsed({
required String title,
required String iconPath,
required VoidCallback onTap,
required bool isOnEdit,
Color? cardColor,
Color? labelColor,
Color? textColor,
}) {
return GestureDetector(
onTap: !isOnEdit ? onTap : null,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
spacing: 4,
children: [
Stack(
clipBehavior: Clip.none,
children: [
Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: cardColor ?? Color(0xFFBECDFF),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: Container(
width: 40,
height: 40,
decoration: ShapeDecoration(
color: labelColor ?? AppColor.blueNormal,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: SvgGenImage.vec(iconPath).svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(Colors.white, BlendMode.srcIn),
fit: BoxFit.cover,
),
),
),
Visibility(
visible: isOnEdit,
child: Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: Colors.white60,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
),
),
Visibility(
visible: isOnEdit,
child: Positioned(
top: -15,
left: -12,
child: SizedBox(
width: 32.w,
height: 32.h,
child: GestureDetector(
onTap: () {},
behavior: HitTestBehavior.translucent,
child: Center(
child: Container(
width: 16,
height: 16,
decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.white),
alignment: Alignment.center,
child: Icon(CupertinoIcons.minus, color: AppColor.error, size: 15),
),
),
),
),
),
),
],
),
Text(title, style: AppFonts.yekan10.copyWith(color: textColor ?? AppColor.blueNormal)),
],
),
);
}
Widget addWidelyUsed({required VoidCallback onTap}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
spacing: 4,
children: [
Container(
width: 48,
height: 48,
padding: EdgeInsets.all(4),
decoration: ShapeDecoration(
color: const Color(0xFFD9F7F0),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
child: Assets.vec.messageAddSvg.svg(
width: 40,
height: 40,
colorFilter: ColorFilter.mode(AppColor.greenNormal, BlendMode.srcIn),
fit: BoxFit.cover,
),
),
Text('افزودن', style: AppFonts.yekan10.copyWith(color: AppColor.greenDarkHover)),
],
);
}
}