feat : buy in province all
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import 'package:rasadyar_chicken/chicken.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
enum WidelyUsedType { edit, normal }
|
||||
|
||||
class WidelyUsedLogic extends GetxController {
|
||||
Rx<WidelyUsedType> type = WidelyUsedType.normal.obs;
|
||||
RootLogic rootLogic = Get.find<RootLogic>();
|
||||
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
bool isOnEdit() => type.value == WidelyUsedType.edit;
|
||||
|
||||
void toggleType() {
|
||||
fLog(rootLogic.widelyUsedList);
|
||||
if (type.value == WidelyUsedType.edit) {
|
||||
type.value = WidelyUsedType.normal;
|
||||
} else {
|
||||
type.value = WidelyUsedType.edit;
|
||||
}
|
||||
}
|
||||
}
|
||||
180
packages/chicken/lib/presentation/widget/widely_used/view.dart
Normal file
180
packages/chicken/lib/presentation/widget/widely_used/view.dart
Normal file
@@ -0,0 +1,180 @@
|
||||
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: ObxValue((data) {
|
||||
return Wrap(
|
||||
spacing: 4,
|
||||
runSpacing: 18,
|
||||
children: [
|
||||
widelyUsed(
|
||||
title: 'خرید خارج استان',
|
||||
isOnEdit: controller.type.value == WidelyUsedType.edit,
|
||||
iconPath: Assets.vec.truckFastSvg.path,
|
||||
onTap: () async {
|
||||
controller.rootLogic.currentPage.value = 0;
|
||||
controller.rootLogic.currentPage.refresh();
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
Get.toNamed(ChickenRoutes.buysOutOfProvince, id: 0);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}, controller.type),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget widelyUsed({
|
||||
required String title,
|
||||
required String iconPath,
|
||||
required VoidCallback onTap,
|
||||
required bool isOnEdit,
|
||||
}) {
|
||||
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: Color(0xFFBECDFF),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||
),
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: ShapeDecoration(
|
||||
color: 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: 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)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user