Files
rasadyar_application/packages/chicken/lib/features/common/role/view.dart

80 lines
2.6 KiB
Dart
Raw Normal View History

2025-09-02 15:59:49 +03:30
import 'package:flutter/material.dart';
2025-09-06 14:50:02 +03:30
import 'package:rasadyar_chicken/data/common/fa_user_role.dart';
2025-09-25 17:25:55 +03:30
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
2025-09-02 15:59:49 +03:30
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class RolePage extends GetView<RoleLogic> {
const RolePage({super.key});
@override
Widget build(BuildContext context) {
2025-09-25 17:25:55 +03:30
return ChickenBasePage(
isBase: true,
child: Column(
2025-09-02 15:59:49 +03:30
children: [
Assets.images.selectRole.image(height: 212.h, width: Get.width.w, fit: BoxFit.cover),
2025-09-06 22:08:27 +03:30
ObxValue((data) {
return Expanded(
child: GridView.builder(
physics: BouncingScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 12.h,
crossAxisSpacing: 12.w,
childAspectRatio: 2,
),
itemCount: data.length,
hitTestBehavior: HitTestBehavior.opaque,
itemBuilder: (BuildContext context, int index) {
Map role = getFaUserRoleWithOnTap(data[index]);
return roleCard(
title: role.keys.first,
onTap: () async {
2025-11-26 16:23:18 +03:30
try {
String route = role.values.first;
await controller.gService.saveRoute(Module.chicken, route);
2025-11-26 16:23:18 +03:30
await controller.gService.saveRole(Module.chicken, data[index]);
Get.offAllNamed(route);
} catch (e) {
eLog(
"احتمالا در\n ``getFaUserRoleWithOnTap`` \nروت اش را تعریف نکردی 👻👻 ==>$e ",
);
}
2025-09-06 22:08:27 +03:30
},
);
},
2025-09-02 15:59:49 +03:30
),
2025-09-06 22:08:27 +03:30
);
}, controller.roles),
2025-09-02 15:59:49 +03:30
],
),
2025-09-06 22:08:27 +03:30
);
2025-09-02 15:59:49 +03:30
}
2025-09-06 22:08:27 +03:30
}
Widget roleCard({required String title, Function()? onTap, int? width, int? height}) {
2025-09-06 22:08:27 +03:30
return Container(
width: width?.w ?? 128.w,
height: height?.h ?? 48.h,
margin: EdgeInsets.all(8.w),
decoration: BoxDecoration(
2025-09-25 17:25:55 +03:30
color: Colors.white,
2025-09-06 22:08:27 +03:30
borderRadius: BorderRadius.circular(8.r),
border: Border.all(color: AppColor.blueNormal, width: 1.w),
),
child: InkWell(
onTap: onTap,
child: Center(
child: Text(
title,
style: AppFonts.yekan12Bold.copyWith(color: AppColor.blueNormal),
textAlign: TextAlign.center,
2025-09-02 15:59:49 +03:30
),
),
2025-09-06 22:08:27 +03:30
),
);
2025-09-02 15:59:49 +03:30
}