fix : sale out of Province
This commit is contained in:
@@ -50,3 +50,5 @@ export 'utils/date_time_utils.dart';
|
||||
export 'utils/num_utils.dart';
|
||||
export 'utils/map_utils.dart';
|
||||
export 'utils/route_utils.dart';
|
||||
export 'utils/string_utils.dart';
|
||||
export 'utils/separator_input_formatter.dart';
|
||||
|
||||
@@ -87,6 +87,9 @@ class $AssetsIconsGen {
|
||||
/// File path: assets/icons/home.svg
|
||||
SvgGenImage get home => const SvgGenImage('assets/icons/home.svg');
|
||||
|
||||
/// File path: assets/icons/hot_chicken.svg
|
||||
SvgGenImage get hotChicken => const SvgGenImage('assets/icons/hot_chicken.svg');
|
||||
|
||||
/// File path: assets/icons/information.svg
|
||||
SvgGenImage get information => const SvgGenImage('assets/icons/information.svg');
|
||||
|
||||
@@ -209,6 +212,7 @@ class $AssetsIconsGen {
|
||||
filterOutline,
|
||||
gps,
|
||||
home,
|
||||
hotChicken,
|
||||
information,
|
||||
inside,
|
||||
inspection,
|
||||
@@ -348,6 +352,9 @@ class $AssetsVecGen {
|
||||
/// File path: assets/vec/home.svg.vec
|
||||
SvgGenImage get homeSvg => const SvgGenImage.vec('assets/vec/home.svg.vec');
|
||||
|
||||
/// File path: assets/vec/hot_chicken.svg.vec
|
||||
SvgGenImage get hotChickenSvg => const SvgGenImage.vec('assets/vec/hot_chicken.svg.vec');
|
||||
|
||||
/// File path: assets/vec/information.svg.vec
|
||||
SvgGenImage get informationSvg => const SvgGenImage.vec('assets/vec/information.svg.vec');
|
||||
|
||||
@@ -470,6 +477,7 @@ class $AssetsVecGen {
|
||||
filterOutlineSvg,
|
||||
gpsSvg,
|
||||
homeSvg,
|
||||
hotChickenSvg,
|
||||
informationSvg,
|
||||
insideSvg,
|
||||
inspectionSvg,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
enum RTextFieldVariant {
|
||||
@@ -38,6 +39,7 @@ class RTextField extends StatefulWidget {
|
||||
final FormFieldValidator<String>? validator;
|
||||
final void Function(String)? onChanged;
|
||||
final void Function(String)? onSubmitted;
|
||||
final List<TextInputFormatter>? inputFormatters;
|
||||
|
||||
const RTextField({
|
||||
super.key,
|
||||
@@ -69,6 +71,7 @@ class RTextField extends StatefulWidget {
|
||||
this.onChanged,
|
||||
this.onSubmitted,
|
||||
this.borderColor,
|
||||
this.inputFormatters
|
||||
});
|
||||
|
||||
|
||||
@@ -147,6 +150,7 @@ class _RTextFieldState extends State<RTextField> {
|
||||
maxLines: widget.maxLines,
|
||||
onChanged: widget.onChanged,
|
||||
validator: widget.validator,
|
||||
inputFormatters: widget.inputFormatters,
|
||||
enabled: widget.enabled,
|
||||
obscureText: obscure,
|
||||
onTapOutside: (_) => FocusScope.of(context).unfocus(),
|
||||
|
||||
@@ -2,9 +2,6 @@ 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 'package:rasadyar_core/presentation/common/app_fonts.dart';
|
||||
|
||||
|
||||
|
||||
class OverlayDropdownWidget<T> extends StatefulWidget {
|
||||
final List<T> items;
|
||||
@@ -15,7 +12,7 @@ class OverlayDropdownWidget<T> extends StatefulWidget {
|
||||
final void Function(T selected)? onChanged;
|
||||
final EdgeInsets? contentPadding;
|
||||
|
||||
const OverlayDropdownWidget({
|
||||
const OverlayDropdownWidget({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.itemBuilder,
|
||||
@@ -23,7 +20,7 @@ class OverlayDropdownWidget<T> extends StatefulWidget {
|
||||
this.initialValue,
|
||||
this.onChanged,
|
||||
this.selectedItem,
|
||||
this.contentPadding
|
||||
this.contentPadding,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -34,7 +31,7 @@ class _OverlayDropdownState<T> extends State<OverlayDropdownWidget<T>> {
|
||||
final GlobalKey _key = GlobalKey();
|
||||
OverlayEntry? _overlayEntry;
|
||||
final RxBool _isOpen = false.obs;
|
||||
T? selectedItem ;
|
||||
T? selectedItem;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -48,51 +45,54 @@ class _OverlayDropdownState<T> extends State<OverlayDropdownWidget<T>> {
|
||||
final offset = renderBox.localToGlobal(Offset.zero);
|
||||
|
||||
_overlayEntry = OverlayEntry(
|
||||
builder:
|
||||
(_) => GestureDetector(
|
||||
onTap: _removeOverlay,
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: offset.dx,
|
||||
top: offset.dy + size.height + 4,
|
||||
width: size.width,
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
builder: (_) => GestureDetector(
|
||||
onTap: _removeOverlay,
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
left: offset.dx,
|
||||
top: offset.dy + size.height + 4,
|
||||
width: size.width,
|
||||
child: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: AppColor.darkGreyLight),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: AppColor.darkGreyLight),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: ListView(
|
||||
padding: EdgeInsets.zero,
|
||||
shrinkWrap: true,
|
||||
children:
|
||||
widget.items.map((item) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
widget.onChanged?.call(item);
|
||||
setState(() {
|
||||
selectedItem = item;
|
||||
});
|
||||
_removeOverlay();
|
||||
},
|
||||
child: Padding(
|
||||
padding:widget.contentPadding?? const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: widget.itemBuilder(item),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
constraints: BoxConstraints(maxHeight: 300),
|
||||
child: ListView(
|
||||
padding: EdgeInsets.only(bottom: 50),
|
||||
shrinkWrap: true,
|
||||
physics: BouncingScrollPhysics(),
|
||||
scrollDirection: Axis.vertical,
|
||||
children: widget.items.map((item) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
widget.onChanged?.call(item);
|
||||
setState(() {
|
||||
selectedItem = item;
|
||||
});
|
||||
_removeOverlay();
|
||||
},
|
||||
child: Padding(
|
||||
padding: widget.contentPadding ?? const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: widget.itemBuilder(item),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Overlay.of(context).insert(_overlayEntry!);
|
||||
@@ -130,12 +130,7 @@ class _OverlayDropdownState<T> extends State<OverlayDropdownWidget<T>> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
widget.labelBuilder(selectedItem),
|
||||
Icon(
|
||||
_isOpen.value
|
||||
? CupertinoIcons.chevron_up
|
||||
: CupertinoIcons.chevron_down,
|
||||
size: 14,
|
||||
),
|
||||
Icon(_isOpen.value ? CupertinoIcons.chevron_up : CupertinoIcons.chevron_down, size: 14),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
extension XNumExtension on num? {
|
||||
String get toFormatted {
|
||||
String get separatedByComma {
|
||||
final formatter = NumberFormat('#,###', 'fa_IR');
|
||||
return this == null ? '':formatter.format(this);
|
||||
}
|
||||
|
||||
27
packages/core/lib/utils/separator_input_formatter.dart
Normal file
27
packages/core/lib/utils/separator_input_formatter.dart
Normal file
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class SeparatorInputFormatter extends TextInputFormatter {
|
||||
final NumberFormat _formatter;
|
||||
|
||||
SeparatorInputFormatter() : _formatter = NumberFormat('#,###');
|
||||
|
||||
@override
|
||||
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
if (newValue.text.isEmpty) {
|
||||
return newValue;
|
||||
}
|
||||
String tmpText = newValue.text;
|
||||
String cleanedText = tmpText.replaceAll(RegExp(r'\D'), '');
|
||||
int? number = int.tryParse(cleanedText);
|
||||
if (number == null) {
|
||||
return oldValue;
|
||||
}
|
||||
String formattedText = _formatter.format(number);
|
||||
int selectionIndex = formattedText.length;
|
||||
return TextEditingValue(
|
||||
text: formattedText,
|
||||
selection: TextSelection.collapsed(offset: selectionIndex),
|
||||
);
|
||||
}
|
||||
}
|
||||
11
packages/core/lib/utils/string_utils.dart
Normal file
11
packages/core/lib/utils/string_utils.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
extension XString on String {
|
||||
get separatedByComma {
|
||||
final formatter = NumberFormat('#,###');
|
||||
return formatter.format(this);
|
||||
}
|
||||
get clearComma{
|
||||
return replaceAll(RegExp(r'\D'), '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user