feat : new ui for steward
This commit is contained in:
11
assets/icons/cube_card_free.svg
Normal file
11
assets/icons/cube_card_free.svg
Normal file
@@ -0,0 +1,11 @@
|
||||
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="30" height="30" rx="8" fill="#9758FF"/>
|
||||
<path d="M20.6 8.31125L14.95 5.27125C14.35 4.95125 13.64 4.95125 13.04 5.27125L7.39998 8.31125C6.98998 8.54125 6.72998 8.98125 6.72998 9.46125C6.72998 9.95125 6.97998 10.3913 7.39998 10.6112L13.05 13.6512C13.35 13.8112 13.68 13.8913 14 13.8913C14.32 13.8913 14.66 13.8112 14.95 13.6512L20.6 10.6112C21.01 10.3913 21.27 9.95125 21.27 9.46125C21.27 8.98125 21.01 8.54125 20.6 8.31125Z"
|
||||
fill="white"/>
|
||||
<path d="M12.12 14.7106L6.87 12.0906C6.46 11.8806 6 11.9106 5.61 12.1406C5.23 12.3806 5 12.7906 5 13.2406V18.2006C5 19.0606 5.48 19.8306 6.25 20.2206L11.5 22.8406C11.68 22.9306 11.88 22.9806 12.08 22.9806C12.31 22.9806 12.55 22.9106 12.76 22.7906C13.14 22.5506 13.37 22.1406 13.37 21.6906V16.7306C13.36 15.8706 12.88 15.1006 12.12 14.7106Z"
|
||||
fill="white"/>
|
||||
<path d="M23.0001 13.2406V15.7006C22.5201 15.5606 22.0101 15.5006 21.5001 15.5006C20.1401 15.5006 18.8101 15.9706 17.7601 16.8106C16.3201 17.9406 15.5001 19.6506 15.5001 21.5006C15.5001 21.9906 15.5601 22.4806 15.6901 22.9506C15.5401 22.9306 15.3901 22.8706 15.2501 22.7806C14.8701 22.5506 14.6401 22.1406 14.6401 21.6906V16.7306C14.6401 15.8706 15.1201 15.1006 15.8801 14.7106L21.1301 12.0906C21.5401 11.8806 22.0001 11.9106 22.3901 12.1406C22.7701 12.3806 23.0001 12.7906 23.0001 13.2406Z"
|
||||
fill="white"/>
|
||||
<path d="M24.6799 18.3206C23.7899 17.4306 22.6099 16.9806 21.4399 17.0006C20.3099 17.0106 19.1799 17.4606 18.3199 18.3206C17.7199 18.9106 17.3299 19.6506 17.1399 20.4206C17.0299 20.8406 16.9899 21.2706 17.0199 21.7006V21.7506C17.0199 21.8206 17.0299 21.8806 17.0399 21.9606C17.0399 21.9606 17.0399 21.9606 17.0499 21.9706V22.0006C17.1399 22.9806 17.5599 23.9306 18.3199 24.6806C19.4799 25.8406 21.1099 26.2306 22.5799 25.8606C23.0199 25.7506 23.4499 25.5706 23.8499 25.3306C24.1499 25.1606 24.4299 24.9406 24.6799 24.6806C25.4299 23.9306 25.8599 22.9806 25.9499 21.9906C25.9599 21.9906 25.9599 21.9706 25.9599 21.9606C25.9799 21.8906 25.9799 21.8106 25.9799 21.7406C25.9799 21.7306 25.9899 21.7106 25.9899 21.6906C26.0499 20.4806 25.6099 19.2406 24.6799 18.3206ZM23.2299 23.2106C22.9399 23.5006 22.4699 23.5006 22.1699 23.2106L21.5099 22.5506L20.8299 23.2306C20.5299 23.5306 20.0599 23.5306 19.7699 23.2306C19.4699 22.9406 19.4699 22.4706 19.7699 22.1706L20.4499 21.4906L19.7899 20.8306C19.4999 20.5306 19.4999 20.0606 19.7899 19.7706C20.0899 19.4706 20.5599 19.4706 20.8599 19.7706L21.5099 20.4306L22.1399 19.7906C22.4399 19.5006 22.9099 19.5006 23.2099 19.7906C23.4999 20.0906 23.4999 20.5606 23.2099 20.8606L22.5699 21.4906L23.2299 22.1406C23.5299 22.4406 23.5299 22.9106 23.2299 23.2106Z"
|
||||
fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
5
assets/icons/cube_card_goverment.svg
Normal file
5
assets/icons/cube_card_goverment.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="30" height="30" rx="8" fill="#FFAE00"/>
|
||||
<path d="M25 24.2512H23.75V14.0012C23.75 11.5812 22.42 10.2512 20 10.2512H15.75V9.02116C16.33 9.16116 16.91 9.24116 17.5 9.24116C18.44 9.24116 19.38 9.06116 20.28 8.70116C20.56 8.59116 20.75 8.31117 20.75 8.00117V5.00117C20.75 4.75117 20.63 4.52117 20.42 4.38117C20.21 4.24117 19.95 4.21117 19.72 4.30117C18.29 4.87117 16.71 4.87117 15.28 4.30117C15.05 4.21117 14.79 4.24117 14.58 4.38117C14.37 4.52117 14.25 4.75117 14.25 5.00117V8.00117V10.2512H10C7.58 10.2512 6.25 11.5812 6.25 14.0012V24.2512H5C4.59 24.2512 4.25 24.5912 4.25 25.0012C4.25 25.4112 4.59 25.7512 5 25.7512H7H23H25C25.41 25.7512 25.75 25.4112 25.75 25.0012C25.75 24.5912 25.41 24.2512 25 24.2512ZM10.24 24.2512H7.75V15.7512H10.24V24.2512ZM14.24 24.2512H11.74V15.7512H14.24V24.2512ZM18.24 24.2512H15.74V15.7512H18.24V24.2512ZM22.25 24.2512H19.74V15.7512H22.25V24.2512Z"
|
||||
fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
BIN
assets/vec/cube_card_free.svg.vec
Normal file
BIN
assets/vec/cube_card_free.svg.vec
Normal file
Binary file not shown.
BIN
assets/vec/cube_card_goverment.svg.vec
Normal file
BIN
assets/vec/cube_card_goverment.svg.vec
Normal file
Binary file not shown.
@@ -65,7 +65,7 @@ class HomePage extends GetView<HomeLogic> {
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
_todayShipmentWidget(),
|
||||
|
||||
_todayShipmentWidget2(),
|
||||
_inventoryWidget(),
|
||||
|
||||
Row(
|
||||
@@ -102,11 +102,10 @@ class HomePage extends GetView<HomeLogic> {
|
||||
Row(
|
||||
spacing: 8,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Icon(CupertinoIcons.chevron_down, size: 18),
|
||||
],
|
||||
children: [Icon(CupertinoIcons.chevron_down, size: 18)],
|
||||
),
|
||||
_todayShipmentWidget(),
|
||||
_todayShipmentWidget2(),
|
||||
_inventoryWidget(),
|
||||
],
|
||||
),
|
||||
@@ -278,10 +277,10 @@ class HomePage extends GetView<HomeLogic> {
|
||||
(data) => _informationLabelCard(
|
||||
title: 'بارهای امروز',
|
||||
titleColor: AppColor.blueNormal,
|
||||
borderColor: Color(0xFF77A6FF),
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.separatedByCommaFa ?? '0',
|
||||
iconPath: Assets.vec.cubeSearchSvg.path,
|
||||
iconColor: AppColor.blueNormal,
|
||||
iconPath: Assets.vec.cubeScanWithLabelSvg.path,
|
||||
bgDescriptionColor: Colors.white,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
@@ -297,16 +296,67 @@ class HomePage extends GetView<HomeLogic> {
|
||||
child: ObxValue((data) {
|
||||
return _informationLabelCard(
|
||||
title: 'درانتظار تایید',
|
||||
borderColor: AppColor.greenNormal,
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.totalNotEnteredBars.separatedByCommaFa ?? '0',
|
||||
unit:
|
||||
'(${data.value?.totalNotEnteredKillHouseRequestsWeight.separatedByCommaFa})\nکیلوگرم',
|
||||
iconPath: Assets.vec.cubeWattingSvg.path,
|
||||
iconPath: Assets.vec.cubeCardSvg.path,
|
||||
bgDescriptionColor: Colors.white,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [const Color(0xFFFFE7BB), Colors.white],
|
||||
colors: [const Color(0xFFD9F7F0), Colors.white],
|
||||
),
|
||||
);
|
||||
}, controller.barInformation),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _todayShipmentWidget2() {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 10, 0, 13),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ObxValue(
|
||||
(data) => _informationLabelCard(
|
||||
title: 'مانده دولتی',
|
||||
titleColor: AppColor.blueNormal,
|
||||
borderColor: Color(0xFFFFAE00),
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.separatedByCommaFa ?? '0',
|
||||
iconPath: Assets.vec.cubeCardGovermentSvg.path,
|
||||
bgDescriptionColor: Colors.white,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFFFFD47A), Colors.white],
|
||||
),
|
||||
),
|
||||
controller.totalWeightTodayBars,
|
||||
),
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: ObxValue((data) {
|
||||
return _informationLabelCard(
|
||||
title: 'مانده آزاد',
|
||||
borderColor: const Color(0xFF9758FF),
|
||||
isLoading: data.value == null,
|
||||
description: data.value?.totalNotEnteredBars.separatedByCommaFa ?? '0',
|
||||
unit:
|
||||
'(${data.value?.totalNotEnteredKillHouseRequestsWeight.separatedByCommaFa})\nکیلوگرم',
|
||||
iconPath: Assets.vec.cubeCardFreeSvg.path,
|
||||
bgDescriptionColor: Colors.white,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [const Color(0xFFD3B9FF), Colors.white],
|
||||
),
|
||||
);
|
||||
}, controller.barInformation),
|
||||
@@ -321,6 +371,7 @@ class HomePage extends GetView<HomeLogic> {
|
||||
required String description,
|
||||
required String iconPath,
|
||||
required Color bgDescriptionColor,
|
||||
Color? borderColor,
|
||||
String unit = 'کیلوگرم',
|
||||
bool isLoading = false,
|
||||
Color? iconColor,
|
||||
@@ -330,7 +381,10 @@ class HomePage extends GetView<HomeLogic> {
|
||||
}) {
|
||||
return Container(
|
||||
height: 82,
|
||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(8)),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: borderColor != null ? Border.all(width: 1, color: borderColor) : null,
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@@ -31,6 +31,45 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
|
||||
child: Column(
|
||||
children: [
|
||||
inventoryWidget(controller.rootLogic),
|
||||
/*Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده دولتی',
|
||||
titleColor: AppColor.textColor,
|
||||
borderColor: Color(0xFFFFAE00),
|
||||
|
||||
description: 356952222222.separatedByCommaFa,
|
||||
iconPath: Assets.vec.cubeCardGovermentSvg.path,
|
||||
bgDescriptionColor: Colors.white,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [Color(0xFFFFD47A), Colors.white],
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _informationLabelCard(
|
||||
title: 'مانده آزاد',
|
||||
borderColor: const Color(0xFF9758FF),
|
||||
description: 9658554788.separatedByCommaFa,
|
||||
unit: 'KG',
|
||||
iconPath: Assets.vec.cubeCardFreeSvg.path,
|
||||
bgDescriptionColor: Colors.white,
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [const Color(0xFFD3B9FF), Colors.white],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),*/
|
||||
ObxValue((data) {
|
||||
return RPaginatedListView(
|
||||
onLoadMore: () async => controller.getOutProvinceSales(true),
|
||||
@@ -533,4 +572,99 @@ class SalesOutOfProvincePage extends GetView<SalesOutOfProvinceLogic> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Container _informationLabelCard({
|
||||
required String title,
|
||||
required String description,
|
||||
required String iconPath,
|
||||
required Color bgDescriptionColor,
|
||||
Color? borderColor,
|
||||
String unit = 'KG',
|
||||
bool isLoading = false,
|
||||
Color? iconColor,
|
||||
Color? titleColor,
|
||||
Color? bgLabelColor,
|
||||
LinearGradient? gradient,
|
||||
}) {
|
||||
return Container(
|
||||
height: 40.h,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: borderColor != null ? Border.all(width: 1, color: borderColor) : null,
|
||||
),
|
||||
clipBehavior: Clip.hardEdge,
|
||||
child: Row(
|
||||
children: [
|
||||
// Left side with icon and title
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 82,
|
||||
decoration: BoxDecoration(
|
||||
color: gradient == null ? bgLabelColor : null,
|
||||
borderRadius: BorderRadius.only(
|
||||
topRight: Radius.circular(8),
|
||||
bottomRight: Radius.circular(8),
|
||||
),
|
||||
gradient: gradient,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
SvgGenImage.vec(iconPath).svg(
|
||||
width: 24,
|
||||
height: 24,
|
||||
colorFilter: iconColor != null
|
||||
? ColorFilter.mode(iconColor, BlendMode.srcIn)
|
||||
: null,
|
||||
),
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.right,
|
||||
style: AppFonts.yekan14.copyWith(
|
||||
color: titleColor ?? AppColor.mediumGreyDarkActive,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Right side with description and unit
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(2),
|
||||
decoration: BoxDecoration(
|
||||
color: bgDescriptionColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(8),
|
||||
bottomLeft: Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: isLoading
|
||||
? Center(child: CupertinoActivityIndicator())
|
||||
: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(
|
||||
description,
|
||||
textAlign: TextAlign.left,
|
||||
maxLines: 1,
|
||||
textDirection: TextDirection.ltr,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: AppFonts.yekan14.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
Text(
|
||||
unit,
|
||||
textAlign: TextAlign.center,
|
||||
style: AppFonts.yekan12.copyWith(color: AppColor.mediumGreyDarkActive),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,7 +413,6 @@ class SegmentationPage extends GetView<SegmentationLogic> {
|
||||
return OverlayDropdownWidget<GuildModel>(
|
||||
key: ValueKey(item?.user?.fullname ?? ''),
|
||||
items: controller.guildsModel,
|
||||
isDisabled: controller.saleType.value == 1,
|
||||
onChanged: (value) {
|
||||
controller.selectedGuildModel.value = value;
|
||||
},
|
||||
|
||||
@@ -137,6 +137,12 @@ class $AssetsIconsGen {
|
||||
/// File path: assets/icons/cube_card.svg
|
||||
SvgGenImage get cubeCard => const SvgGenImage('assets/icons/cube_card.svg');
|
||||
|
||||
/// File path: assets/icons/cube_card_free.svg
|
||||
SvgGenImage get cubeCardFree => const SvgGenImage('assets/icons/cube_card_free.svg');
|
||||
|
||||
/// File path: assets/icons/cube_card_goverment.svg
|
||||
SvgGenImage get cubeCardGoverment => const SvgGenImage('assets/icons/cube_card_goverment.svg');
|
||||
|
||||
/// File path: assets/icons/cube_rotate.svg
|
||||
SvgGenImage get cubeRotate => const SvgGenImage('assets/icons/cube_rotate.svg');
|
||||
|
||||
@@ -396,6 +402,8 @@ class $AssetsIconsGen {
|
||||
cube,
|
||||
cubeBottomRotation,
|
||||
cubeCard,
|
||||
cubeCardFree,
|
||||
cubeCardGoverment,
|
||||
cubeRotate,
|
||||
cubeScan,
|
||||
cubeScanWithLabel,
|
||||
@@ -623,6 +631,12 @@ class $AssetsVecGen {
|
||||
/// File path: assets/vec/cube_card.svg.vec
|
||||
SvgGenImage get cubeCardSvg => const SvgGenImage.vec('assets/vec/cube_card.svg.vec');
|
||||
|
||||
/// File path: assets/vec/cube_card_free.svg.vec
|
||||
SvgGenImage get cubeCardFreeSvg => const SvgGenImage.vec('assets/vec/cube_card_free.svg.vec');
|
||||
|
||||
/// File path: assets/vec/cube_card_goverment.svg.vec
|
||||
SvgGenImage get cubeCardGovermentSvg => const SvgGenImage.vec('assets/vec/cube_card_goverment.svg.vec');
|
||||
|
||||
/// File path: assets/vec/cube_rotate.svg.vec
|
||||
SvgGenImage get cubeRotateSvg => const SvgGenImage.vec('assets/vec/cube_rotate.svg.vec');
|
||||
|
||||
@@ -882,6 +896,8 @@ class $AssetsVecGen {
|
||||
cubeSvg,
|
||||
cubeBottomRotationSvg,
|
||||
cubeCardSvg,
|
||||
cubeCardFreeSvg,
|
||||
cubeCardGovermentSvg,
|
||||
cubeRotateSvg,
|
||||
cubeScanSvg,
|
||||
cubeScanWithLabelSvg,
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rasadyar_core/presentation/common/app_color.dart';
|
||||
|
||||
import 'multi_select_dropdown_logic.dart';
|
||||
|
||||
class MultiSelectDropdown<T> extends StatelessWidget {
|
||||
final List<T> items;
|
||||
final T? selectedItem;
|
||||
final T? initialValue;
|
||||
final Widget Function(T item) itemBuilder;
|
||||
final Widget Function(T? selected) labelBuilder;
|
||||
final void Function(T selected)? onChanged;
|
||||
final EdgeInsets? contentPadding;
|
||||
final String Function(T item)? itemToString;
|
||||
|
||||
const MultiSelectDropdown({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.itemBuilder,
|
||||
required this.labelBuilder,
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
this.selectedItem,
|
||||
this.contentPadding,
|
||||
this.itemToString,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetBuilder<MultiSelectDropdownLogic<T>>(
|
||||
init: MultiSelectDropdownLogic<T>(
|
||||
items: items,
|
||||
selectedItem: selectedItem,
|
||||
initialValue: initialValue,
|
||||
itemToString: itemToString,
|
||||
onChanged: onChanged,
|
||||
contentPadding: contentPadding,
|
||||
itemBuilder: itemBuilder,
|
||||
),
|
||||
builder: (controller) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
controller.isOpen.value ? controller.removeOverlay() : controller.showOverlay(context);
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: Get.width,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
decoration: BoxDecoration(
|
||||
color: items.isEmpty ? Colors.grey.shade200 : AppColor.bgLight,
|
||||
border: Border.all(color: AppColor.darkGreyLight),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(child: labelBuilder(controller.selectedItem.value)),
|
||||
Icon(
|
||||
controller.isOpen.value ? CupertinoIcons.chevron_up : CupertinoIcons.chevron_down,
|
||||
size: 14,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:rasadyar_core/presentation/common/app_color.dart';
|
||||
|
||||
class MultiSelectDropdownLogic<T> extends GetxController {
|
||||
final List<T> items;
|
||||
final T? initialValue;
|
||||
final String Function(T item)? itemToString;
|
||||
final void Function(T selected)? onChanged;
|
||||
|
||||
RxBool isOpen = false.obs;
|
||||
Rx<T?> selectedItem;
|
||||
late TextEditingController searchController;
|
||||
late RxList<T> filteredItems;
|
||||
late EdgeInsets? contentPadding;
|
||||
late Widget Function(T item) itemBuilder;
|
||||
|
||||
MultiSelectDropdownLogic({
|
||||
required this.items,
|
||||
this.initialValue,
|
||||
this.itemToString,
|
||||
this.onChanged,
|
||||
T? selectedItem,
|
||||
this.contentPadding,
|
||||
required this.itemBuilder,
|
||||
}) : selectedItem = Rx(selectedItem ?? initialValue);
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
searchController = TextEditingController();
|
||||
filteredItems = RxList<T>(items);
|
||||
}
|
||||
|
||||
void showOverlay(BuildContext context) {
|
||||
final RenderBox renderBox = (context.findRenderObject() as RenderBox);
|
||||
final size = renderBox.size;
|
||||
final offset = renderBox.localToGlobal(Offset.zero);
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
|
||||
final bool openUp = offset.dy + size.height + 300 > screenHeight;
|
||||
|
||||
searchController.clear();
|
||||
filteredItems.value = items;
|
||||
|
||||
OverlayEntry overlayEntry = OverlayEntry(
|
||||
builder: (_) => GestureDetector(
|
||||
onTap: () {
|
||||
removeOverlay();
|
||||
},
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: offset.dx,
|
||||
top: openUp ? offset.dy - 300 - 4 : offset.dy + size.height + 4,
|
||||
width: size.width,
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Obx(
|
||||
() => Container(
|
||||
decoration: BoxDecoration(
|
||||
color: AppColor.bgLight,
|
||||
border: Border.all(color: AppColor.darkGreyLight),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
constraints: BoxConstraints(maxHeight: 300),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: TextField(
|
||||
controller: searchController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'جستجو...',
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
onChanged: (query) {
|
||||
filteredItems.value = items
|
||||
.where(
|
||||
(item) =>
|
||||
itemToString
|
||||
?.call(item)
|
||||
.toLowerCase()
|
||||
.contains(query.toLowerCase()) ??
|
||||
false,
|
||||
)
|
||||
.toList();
|
||||
},
|
||||
),
|
||||
),
|
||||
if (filteredItems.isEmpty)
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(16.0),
|
||||
child: Text("نتیجهای یافت نشد."),
|
||||
),
|
||||
if (filteredItems.isNotEmpty)
|
||||
Flexible(
|
||||
child: ListView.builder(
|
||||
itemCount: filteredItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
var item = filteredItems[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
onChanged?.call(item);
|
||||
selectedItem.value = item;
|
||||
removeOverlay();
|
||||
},
|
||||
child: Padding(
|
||||
padding:
|
||||
contentPadding ??
|
||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: itemBuilder(item),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Overlay.of(context).insert(overlayEntry);
|
||||
isOpen.value = true;
|
||||
}
|
||||
|
||||
void removeOverlay() {
|
||||
isOpen.value = false;
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
searchController.dispose();
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ class OverlayDropdownWidget<T> extends StatefulWidget {
|
||||
final void Function(T selected)? onChanged;
|
||||
final EdgeInsets? contentPadding;
|
||||
final bool isDisabled;
|
||||
|
||||
const OverlayDropdownWidget({
|
||||
super.key,
|
||||
required this.items,
|
||||
@@ -46,7 +47,6 @@ class _OverlayDropdownState<T> extends State<OverlayDropdownWidget<T>> {
|
||||
selectedItem = widget.selectedItem ?? widget.initialValue;
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant OverlayDropdownWidget<T> oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
@@ -274,11 +274,11 @@ class _OverlayDropdownState2<T> extends State<OverlayDropdownWidget2<T>> {
|
||||
child: Text("نتیجهای یافت نشد."),
|
||||
),
|
||||
if (_filteredItems.isNotEmpty)
|
||||
Expanded(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
children: _filteredItems.map((item) {
|
||||
Flexible(
|
||||
child: ListView.builder(
|
||||
itemCount: _filteredItems.length,
|
||||
itemBuilder: (context, index) {
|
||||
var item = _filteredItems[index];
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
widget.onChanged?.call(item);
|
||||
@@ -294,7 +294,8 @@ class _OverlayDropdownState2<T> extends State<OverlayDropdownWidget2<T>> {
|
||||
child: widget.itemBuilder(item),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
},
|
||||
physics: const BouncingScrollPhysics(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
export 'base_page/logic.dart';
|
||||
//base page
|
||||
export 'base_page/view.dart';
|
||||
export 'base_page/widgets/back_ground_widget.dart';
|
||||
export 'base_page/widgets/breadcrumb.dart';
|
||||
export 'base_page/widgets/r_app_bar.dart';
|
||||
export 'base_page/widgets/search_widget.dart';
|
||||
export 'bottom_navigation/r_bottom_navigation.dart';
|
||||
export 'bottom_navigation/wave_bottom_navigation.dart';
|
||||
export 'bottom_sheet/base_bottom_sheet.dart';
|
||||
export 'bottom_sheet/date_picker_bottom_sheet.dart';
|
||||
export 'check_box/check_box_widget.dart';
|
||||
//base page
|
||||
export 'base_page/view.dart';
|
||||
export 'base_page/logic.dart';
|
||||
export 'base_page/widgets/back_ground_widget.dart';
|
||||
export 'base_page/widgets/breadcrumb.dart';
|
||||
export 'base_page/widgets/search_widget.dart';
|
||||
|
||||
export 'buttons/buttons.dart';
|
||||
//buttons - enhanced core widgets
|
||||
export 'buttons/core_button.dart';
|
||||
export 'buttons/buttons.dart';
|
||||
export 'card/card_icon_widget.dart';
|
||||
export 'check_box/check_box_widget.dart';
|
||||
export 'chips/r_chips.dart';
|
||||
//custom
|
||||
export 'custom/information_tag_widget.dart';
|
||||
@@ -38,6 +37,8 @@ export 'loading/loading_widget.dart';
|
||||
// other
|
||||
export 'logo_widget.dart';
|
||||
export 'marquee/r_marquee.dart';
|
||||
export 'overlay_dropdown_widget/multi_select_dropdown/multi_select_dropdown.dart';
|
||||
export 'overlay_dropdown_widget/multi_select_dropdown/multi_select_dropdown_logic.dart';
|
||||
export 'overlay_dropdown_widget/overlay_dropdown.dart';
|
||||
export 'overlay_dropdown_widget/resource_overlay_dropdown.dart';
|
||||
export 'pagination/pagination_from_until.dart';
|
||||
|
||||
Reference in New Issue
Block a user