import 'package:flutter/material.dart'; import 'package:rasadyar_chicken/data/common/fa_user_role.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_core/core.dart'; import 'logic.dart'; class RolePage extends GetView { const RolePage({super.key}); @override Widget build(BuildContext context) { return ChickenBasePage( isBase: true, child: Column( children: [ Assets.images.selectRole.image(height: 212.h, width: Get.width.w, fit: BoxFit.cover), 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 { try { String route = role.values.first; await controller.gService.saveRoute(Module.chicken, route); await controller.gService.saveRole(Module.chicken, data[index]); Get.offAllNamed(route); } catch (e) { eLog( "احتمالا در\n ``getFaUserRoleWithOnTap`` \nروت اش را تعریف نکردی 👻👻 ==>$e ", ); } }, ); }, ), ); }, controller.roles), ], ), ); } } Widget roleCard({required String title, Function()? onTap, int? width, int? height}) { return Container( width: width?.w ?? 128.w, height: height?.h ?? 48.h, margin: EdgeInsets.all(8.w), decoration: BoxDecoration( color: Colors.white, 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, ), ), ), ); }