diff --git a/packages/chicken/build/native_assets/windows/native_assets.json b/packages/chicken/build/native_assets/windows/native_assets.json new file mode 100644 index 0000000..523bfc7 --- /dev/null +++ b/packages/chicken/build/native_assets/windows/native_assets.json @@ -0,0 +1 @@ +{"format-version":[1,0,0],"native-assets":{}} \ No newline at end of file diff --git a/packages/chicken/build/test_cache/build/7e4aebe516b998635f34742713e086a8.cache.dill.track.dill b/packages/chicken/build/test_cache/build/7e4aebe516b998635f34742713e086a8.cache.dill.track.dill new file mode 100644 index 0000000..ce89ca3 Binary files /dev/null and b/packages/chicken/build/test_cache/build/7e4aebe516b998635f34742713e086a8.cache.dill.track.dill differ diff --git a/packages/chicken/build/unit_test_assets/AssetManifest.bin b/packages/chicken/build/unit_test_assets/AssetManifest.bin new file mode 100644 index 0000000..1dbd5dc --- /dev/null +++ b/packages/chicken/build/unit_test_assets/AssetManifest.bin @@ -0,0 +1 @@ + 2packages/cupertino_icons/assets/CupertinoIcons.ttf  asset2packages/cupertino_icons/assets/CupertinoIcons.ttf4packages/flutter_map/lib/assets/flutter_map_logo.png  asset4packages/flutter_map/lib/assets/flutter_map_logo.png \ No newline at end of file diff --git a/packages/chicken/build/unit_test_assets/AssetManifest.json b/packages/chicken/build/unit_test_assets/AssetManifest.json new file mode 100644 index 0000000..1bdca23 --- /dev/null +++ b/packages/chicken/build/unit_test_assets/AssetManifest.json @@ -0,0 +1 @@ +{"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"],"packages/flutter_map/lib/assets/flutter_map_logo.png":["packages/flutter_map/lib/assets/flutter_map_logo.png"]} \ No newline at end of file diff --git a/packages/chicken/build/unit_test_assets/FontManifest.json b/packages/chicken/build/unit_test_assets/FontManifest.json new file mode 100644 index 0000000..7bea289 --- /dev/null +++ b/packages/chicken/build/unit_test_assets/FontManifest.json @@ -0,0 +1 @@ +[{"family":"packages/cupertino_icons/CupertinoIcons","fonts":[{"asset":"packages/cupertino_icons/assets/CupertinoIcons.ttf"}]}] \ No newline at end of file diff --git a/packages/chicken/build/unit_test_assets/NOTICES.Z b/packages/chicken/build/unit_test_assets/NOTICES.Z new file mode 100644 index 0000000..e8201f5 Binary files /dev/null and b/packages/chicken/build/unit_test_assets/NOTICES.Z differ diff --git a/packages/chicken/build/unit_test_assets/NativeAssetsManifest.json b/packages/chicken/build/unit_test_assets/NativeAssetsManifest.json new file mode 100644 index 0000000..523bfc7 --- /dev/null +++ b/packages/chicken/build/unit_test_assets/NativeAssetsManifest.json @@ -0,0 +1 @@ +{"format-version":[1,0,0],"native-assets":{}} \ No newline at end of file diff --git a/packages/chicken/build/unit_test_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf b/packages/chicken/build/unit_test_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf new file mode 100644 index 0000000..d580ce7 Binary files /dev/null and b/packages/chicken/build/unit_test_assets/packages/cupertino_icons/assets/CupertinoIcons.ttf differ diff --git a/packages/chicken/build/unit_test_assets/packages/flutter_map/lib/assets/flutter_map_logo.png b/packages/chicken/build/unit_test_assets/packages/flutter_map/lib/assets/flutter_map_logo.png new file mode 100644 index 0000000..8603d0a Binary files /dev/null and b/packages/chicken/build/unit_test_assets/packages/flutter_map/lib/assets/flutter_map_logo.png differ diff --git a/packages/chicken/build/unit_test_assets/shaders/ink_sparkle.frag b/packages/chicken/build/unit_test_assets/shaders/ink_sparkle.frag new file mode 100644 index 0000000..85fc357 Binary files /dev/null and b/packages/chicken/build/unit_test_assets/shaders/ink_sparkle.frag differ diff --git a/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote.dart b/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote.dart index e6f04b8..142e638 100644 --- a/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote.dart +++ b/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote.dart @@ -5,6 +5,7 @@ import 'package:rasadyar_chicken/data/models/request/steward_free_sale_bar/stewa import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart'; +import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.dart'; import 'package:rasadyar_chicken/data/models/response/dashboard_kill_house_free_bar/dashboard_kill_house_free_bar.dart'; import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; import 'package:rasadyar_chicken/data/models/response/guild_profile/guild_profile.dart'; @@ -152,4 +153,7 @@ abstract class ChickenRemoteDatasource { Future editSegmentation({required String token, required SegmentationModel model}); Future deleteSegmentation({required String token, required String key}); + + Future getBroadcastPrice({required String token}); + } diff --git a/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote_imp.dart b/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote_imp.dart index 4fa0122..ab0acdd 100644 --- a/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote_imp.dart +++ b/packages/chicken/lib/data/data_source/remote/chicken/chicken_remote_imp.dart @@ -1,4 +1,3 @@ - import 'package:rasadyar_chicken/data/models/request/change_password/change_password_request_model.dart'; import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart'; import 'package:rasadyar_chicken/data/models/request/create_steward_free_bar/create_steward_free_bar.dart'; @@ -6,6 +5,7 @@ import 'package:rasadyar_chicken/data/models/request/steward_free_sale_bar/stewa import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart'; +import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.dart'; import 'package:rasadyar_chicken/data/models/response/dashboard_kill_house_free_bar/dashboard_kill_house_free_bar.dart'; import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; import 'package:rasadyar_chicken/data/models/response/guild_profile/guild_profile.dart'; @@ -482,4 +482,16 @@ class ChickenRemoteDatasourceImp implements ChickenRemoteDatasource { return res.data; } + + @override + Future getBroadcastPrice({required String token}) async { + var res = await _httpClient.get( + '/broadcast-price/', + headers: {'Authorization': 'Bearer $token'}, + + fromJson: (json) => BroadcastPrice.fromJson(json), + ); + + return res.data; + } } diff --git a/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.dart b/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.dart new file mode 100644 index 0000000..f04585e --- /dev/null +++ b/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.dart @@ -0,0 +1,16 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'broadcast_price.freezed.dart'; +part 'broadcast_price.g.dart'; + +@freezed +abstract class BroadcastPrice with _$BroadcastPrice { + const factory BroadcastPrice({ + bool? active, + int? killHousePrice, + int? stewardPrice, + int? guildPrice, + }) = _BroadcastPrice; + + factory BroadcastPrice.fromJson(Map json) => _$BroadcastPriceFromJson(json); +} diff --git a/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.freezed.dart b/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.freezed.dart new file mode 100644 index 0000000..699e4c3 --- /dev/null +++ b/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.freezed.dart @@ -0,0 +1,286 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'broadcast_price.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$BroadcastPrice { + + bool? get active; int? get killHousePrice; int? get stewardPrice; int? get guildPrice; +/// Create a copy of BroadcastPrice +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$BroadcastPriceCopyWith get copyWith => _$BroadcastPriceCopyWithImpl(this as BroadcastPrice, _$identity); + + /// Serializes this BroadcastPrice to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is BroadcastPrice&&(identical(other.active, active) || other.active == active)&&(identical(other.killHousePrice, killHousePrice) || other.killHousePrice == killHousePrice)&&(identical(other.stewardPrice, stewardPrice) || other.stewardPrice == stewardPrice)&&(identical(other.guildPrice, guildPrice) || other.guildPrice == guildPrice)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,active,killHousePrice,stewardPrice,guildPrice); + +@override +String toString() { + return 'BroadcastPrice(active: $active, killHousePrice: $killHousePrice, stewardPrice: $stewardPrice, guildPrice: $guildPrice)'; +} + + +} + +/// @nodoc +abstract mixin class $BroadcastPriceCopyWith<$Res> { + factory $BroadcastPriceCopyWith(BroadcastPrice value, $Res Function(BroadcastPrice) _then) = _$BroadcastPriceCopyWithImpl; +@useResult +$Res call({ + bool? active, int? killHousePrice, int? stewardPrice, int? guildPrice +}); + + + + +} +/// @nodoc +class _$BroadcastPriceCopyWithImpl<$Res> + implements $BroadcastPriceCopyWith<$Res> { + _$BroadcastPriceCopyWithImpl(this._self, this._then); + + final BroadcastPrice _self; + final $Res Function(BroadcastPrice) _then; + +/// Create a copy of BroadcastPrice +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? active = freezed,Object? killHousePrice = freezed,Object? stewardPrice = freezed,Object? guildPrice = freezed,}) { + return _then(_self.copyWith( +active: freezed == active ? _self.active : active // ignore: cast_nullable_to_non_nullable +as bool?,killHousePrice: freezed == killHousePrice ? _self.killHousePrice : killHousePrice // ignore: cast_nullable_to_non_nullable +as int?,stewardPrice: freezed == stewardPrice ? _self.stewardPrice : stewardPrice // ignore: cast_nullable_to_non_nullable +as int?,guildPrice: freezed == guildPrice ? _self.guildPrice : guildPrice // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [BroadcastPrice]. +extension BroadcastPricePatterns on BroadcastPrice { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _BroadcastPrice value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _BroadcastPrice() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _BroadcastPrice value) $default,){ +final _that = this; +switch (_that) { +case _BroadcastPrice(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _BroadcastPrice value)? $default,){ +final _that = this; +switch (_that) { +case _BroadcastPrice() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( bool? active, int? killHousePrice, int? stewardPrice, int? guildPrice)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _BroadcastPrice() when $default != null: +return $default(_that.active,_that.killHousePrice,_that.stewardPrice,_that.guildPrice);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( bool? active, int? killHousePrice, int? stewardPrice, int? guildPrice) $default,) {final _that = this; +switch (_that) { +case _BroadcastPrice(): +return $default(_that.active,_that.killHousePrice,_that.stewardPrice,_that.guildPrice);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( bool? active, int? killHousePrice, int? stewardPrice, int? guildPrice)? $default,) {final _that = this; +switch (_that) { +case _BroadcastPrice() when $default != null: +return $default(_that.active,_that.killHousePrice,_that.stewardPrice,_that.guildPrice);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _BroadcastPrice implements BroadcastPrice { + const _BroadcastPrice({this.active, this.killHousePrice, this.stewardPrice, this.guildPrice}); + factory _BroadcastPrice.fromJson(Map json) => _$BroadcastPriceFromJson(json); + +@override final bool? active; +@override final int? killHousePrice; +@override final int? stewardPrice; +@override final int? guildPrice; + +/// Create a copy of BroadcastPrice +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$BroadcastPriceCopyWith<_BroadcastPrice> get copyWith => __$BroadcastPriceCopyWithImpl<_BroadcastPrice>(this, _$identity); + +@override +Map toJson() { + return _$BroadcastPriceToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _BroadcastPrice&&(identical(other.active, active) || other.active == active)&&(identical(other.killHousePrice, killHousePrice) || other.killHousePrice == killHousePrice)&&(identical(other.stewardPrice, stewardPrice) || other.stewardPrice == stewardPrice)&&(identical(other.guildPrice, guildPrice) || other.guildPrice == guildPrice)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,active,killHousePrice,stewardPrice,guildPrice); + +@override +String toString() { + return 'BroadcastPrice(active: $active, killHousePrice: $killHousePrice, stewardPrice: $stewardPrice, guildPrice: $guildPrice)'; +} + + +} + +/// @nodoc +abstract mixin class _$BroadcastPriceCopyWith<$Res> implements $BroadcastPriceCopyWith<$Res> { + factory _$BroadcastPriceCopyWith(_BroadcastPrice value, $Res Function(_BroadcastPrice) _then) = __$BroadcastPriceCopyWithImpl; +@override @useResult +$Res call({ + bool? active, int? killHousePrice, int? stewardPrice, int? guildPrice +}); + + + + +} +/// @nodoc +class __$BroadcastPriceCopyWithImpl<$Res> + implements _$BroadcastPriceCopyWith<$Res> { + __$BroadcastPriceCopyWithImpl(this._self, this._then); + + final _BroadcastPrice _self; + final $Res Function(_BroadcastPrice) _then; + +/// Create a copy of BroadcastPrice +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? active = freezed,Object? killHousePrice = freezed,Object? stewardPrice = freezed,Object? guildPrice = freezed,}) { + return _then(_BroadcastPrice( +active: freezed == active ? _self.active : active // ignore: cast_nullable_to_non_nullable +as bool?,killHousePrice: freezed == killHousePrice ? _self.killHousePrice : killHousePrice // ignore: cast_nullable_to_non_nullable +as int?,stewardPrice: freezed == stewardPrice ? _self.stewardPrice : stewardPrice // ignore: cast_nullable_to_non_nullable +as int?,guildPrice: freezed == guildPrice ? _self.guildPrice : guildPrice // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.g.dart b/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.g.dart new file mode 100644 index 0000000..09f73f8 --- /dev/null +++ b/packages/chicken/lib/data/models/response/broadcast_price/broadcast_price.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'broadcast_price.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_BroadcastPrice _$BroadcastPriceFromJson(Map json) => + _BroadcastPrice( + active: json['active'] as bool?, + killHousePrice: (json['kill_house_price'] as num?)?.toInt(), + stewardPrice: (json['steward_price'] as num?)?.toInt(), + guildPrice: (json['guild_price'] as num?)?.toInt(), + ); + +Map _$BroadcastPriceToJson(_BroadcastPrice instance) => + { + 'active': instance.active, + 'kill_house_price': instance.killHousePrice, + 'steward_price': instance.stewardPrice, + 'guild_price': instance.guildPrice, + }; diff --git a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart index c9b1052..0108a27 100644 --- a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart +++ b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.dart @@ -11,6 +11,8 @@ abstract class SegmentationModel with _$SegmentationModel { String? productKey, String? guildKey, String? result, + String? quota, + String? saleType, int? weight, Buyer? buyer, DateTime? date, diff --git a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart index 5efe966..3995a0f 100644 --- a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart +++ b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.freezed.dart @@ -15,7 +15,7 @@ T _$identity(T value) => value; /// @nodoc mixin _$SegmentationModel { - String? get key; String? get productKey; String? get guildKey; String? get result; int? get weight; Buyer? get buyer; DateTime? get date; ToGuild? get toGuild; + String? get key; String? get productKey; String? get guildKey; String? get result; String? get quota; String? get saleType; int? get weight; Buyer? get buyer; DateTime? get date; ToGuild? get toGuild; /// Create a copy of SegmentationModel /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -28,16 +28,16 @@ $SegmentationModelCopyWith get copyWith => _$SegmentationMode @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.result, result) || other.result == result)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.result, result) || other.result == result)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,result,weight,buyer,date,toGuild); +int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,result,quota,saleType,weight,buyer,date,toGuild); @override String toString() { - return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, result: $result, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; + return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, result: $result, quota: $quota, saleType: $saleType, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; } @@ -48,7 +48,7 @@ abstract mixin class $SegmentationModelCopyWith<$Res> { factory $SegmentationModelCopyWith(SegmentationModel value, $Res Function(SegmentationModel) _then) = _$SegmentationModelCopyWithImpl; @useResult $Res call({ - String? key, String? productKey, String? guildKey, String? result, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild + String? key, String? productKey, String? guildKey, String? result, String? quota, String? saleType, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild }); @@ -65,12 +65,14 @@ class _$SegmentationModelCopyWithImpl<$Res> /// Create a copy of SegmentationModel /// with the given fields replaced by the non-null parameter values. -@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? result = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { +@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? result = freezed,Object? quota = freezed,Object? saleType = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { return _then(_self.copyWith( key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable +as String?,quota: freezed == quota ? _self.quota : quota // ignore: cast_nullable_to_non_nullable +as String?,saleType: freezed == saleType ? _self.saleType : saleType // ignore: cast_nullable_to_non_nullable as String?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable @@ -184,10 +186,10 @@ return $default(_that);case _: /// } /// ``` -@optionalTypeArgs TResult maybeWhen(TResult Function( String? key, String? productKey, String? guildKey, String? result, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild)? $default,{required TResult orElse(),}) {final _that = this; +@optionalTypeArgs TResult maybeWhen(TResult Function( String? key, String? productKey, String? guildKey, String? result, String? quota, String? saleType, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild)? $default,{required TResult orElse(),}) {final _that = this; switch (_that) { case _SegmentationModel() when $default != null: -return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.weight,_that.buyer,_that.date,_that.toGuild);case _: +return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.quota,_that.saleType,_that.weight,_that.buyer,_that.date,_that.toGuild);case _: return orElse(); } @@ -205,10 +207,10 @@ return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.wei /// } /// ``` -@optionalTypeArgs TResult when(TResult Function( String? key, String? productKey, String? guildKey, String? result, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild) $default,) {final _that = this; +@optionalTypeArgs TResult when(TResult Function( String? key, String? productKey, String? guildKey, String? result, String? quota, String? saleType, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild) $default,) {final _that = this; switch (_that) { case _SegmentationModel(): -return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.weight,_that.buyer,_that.date,_that.toGuild);case _: +return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.quota,_that.saleType,_that.weight,_that.buyer,_that.date,_that.toGuild);case _: throw StateError('Unexpected subclass'); } @@ -225,10 +227,10 @@ return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.wei /// } /// ``` -@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? key, String? productKey, String? guildKey, String? result, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild)? $default,) {final _that = this; +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? key, String? productKey, String? guildKey, String? result, String? quota, String? saleType, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild)? $default,) {final _that = this; switch (_that) { case _SegmentationModel() when $default != null: -return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.weight,_that.buyer,_that.date,_that.toGuild);case _: +return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.quota,_that.saleType,_that.weight,_that.buyer,_that.date,_that.toGuild);case _: return null; } @@ -240,13 +242,15 @@ return $default(_that.key,_that.productKey,_that.guildKey,_that.result,_that.wei @JsonSerializable() class _SegmentationModel implements SegmentationModel { - const _SegmentationModel({this.key, this.productKey, this.guildKey, this.result, this.weight, this.buyer, this.date, this.toGuild}); + const _SegmentationModel({this.key, this.productKey, this.guildKey, this.result, this.quota, this.saleType, this.weight, this.buyer, this.date, this.toGuild}); factory _SegmentationModel.fromJson(Map json) => _$SegmentationModelFromJson(json); @override final String? key; @override final String? productKey; @override final String? guildKey; @override final String? result; +@override final String? quota; +@override final String? saleType; @override final int? weight; @override final Buyer? buyer; @override final DateTime? date; @@ -265,16 +269,16 @@ Map toJson() { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.result, result) || other.result == result)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey)&&(identical(other.result, result) || other.result == result)&&(identical(other.quota, quota) || other.quota == quota)&&(identical(other.saleType, saleType) || other.saleType == saleType)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.toGuild, toGuild) || other.toGuild == toGuild)); } @JsonKey(includeFromJson: false, includeToJson: false) @override -int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,result,weight,buyer,date,toGuild); +int get hashCode => Object.hash(runtimeType,key,productKey,guildKey,result,quota,saleType,weight,buyer,date,toGuild); @override String toString() { - return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, result: $result, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; + return 'SegmentationModel(key: $key, productKey: $productKey, guildKey: $guildKey, result: $result, quota: $quota, saleType: $saleType, weight: $weight, buyer: $buyer, date: $date, toGuild: $toGuild)'; } @@ -285,7 +289,7 @@ abstract mixin class _$SegmentationModelCopyWith<$Res> implements $SegmentationM factory _$SegmentationModelCopyWith(_SegmentationModel value, $Res Function(_SegmentationModel) _then) = __$SegmentationModelCopyWithImpl; @override @useResult $Res call({ - String? key, String? productKey, String? guildKey, String? result, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild + String? key, String? productKey, String? guildKey, String? result, String? quota, String? saleType, int? weight, Buyer? buyer, DateTime? date, ToGuild? toGuild }); @@ -302,12 +306,14 @@ class __$SegmentationModelCopyWithImpl<$Res> /// Create a copy of SegmentationModel /// with the given fields replaced by the non-null parameter values. -@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? result = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { +@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? guildKey = freezed,Object? result = freezed,Object? quota = freezed,Object? saleType = freezed,Object? weight = freezed,Object? buyer = freezed,Object? date = freezed,Object? toGuild = freezed,}) { return _then(_SegmentationModel( key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable as String?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable +as String?,quota: freezed == quota ? _self.quota : quota // ignore: cast_nullable_to_non_nullable +as String?,saleType: freezed == saleType ? _self.saleType : saleType // ignore: cast_nullable_to_non_nullable as String?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable as int?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullable_to_non_nullable as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable diff --git a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart index 6f4411a..dfa75db 100644 --- a/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart +++ b/packages/chicken/lib/data/models/response/segmentation_model/segmentation_model.g.dart @@ -12,6 +12,8 @@ _SegmentationModel _$SegmentationModelFromJson(Map json) => productKey: json['product_key'] as String?, guildKey: json['guild_key'] as String?, result: json['result'] as String?, + quota: json['quota'] as String?, + saleType: json['sale_type'] as String?, weight: (json['weight'] as num?)?.toInt(), buyer: json['buyer'] == null ? null @@ -30,6 +32,8 @@ Map _$SegmentationModelToJson(_SegmentationModel instance) => 'product_key': instance.productKey, 'guild_key': instance.guildKey, 'result': instance.result, + 'quota': instance.quota, + 'sale_type': instance.saleType, 'weight': instance.weight, 'buyer': instance.buyer, 'date': instance.date?.toIso8601String(), diff --git a/packages/chicken/lib/data/repositories/chicken/chicken_repository.dart b/packages/chicken/lib/data/repositories/chicken/chicken_repository.dart index 1d57de4..d4d3ff9 100644 --- a/packages/chicken/lib/data/repositories/chicken/chicken_repository.dart +++ b/packages/chicken/lib/data/repositories/chicken/chicken_repository.dart @@ -5,6 +5,7 @@ import 'package:rasadyar_chicken/data/models/request/steward_free_sale_bar/stewa import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart'; +import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.dart'; import 'package:rasadyar_chicken/data/models/response/dashboard_kill_house_free_bar/dashboard_kill_house_free_bar.dart'; import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; import 'package:rasadyar_chicken/data/models/response/guild_profile/guild_profile.dart'; @@ -158,6 +159,7 @@ abstract class ChickenRepository { Future deleteSegmentation({required String token, required String key}); + Future getBroadcastPrice({required String token}); //endregion diff --git a/packages/chicken/lib/data/repositories/chicken/chicken_repository_imp.dart b/packages/chicken/lib/data/repositories/chicken/chicken_repository_imp.dart index 63e9545..8b053c2 100644 --- a/packages/chicken/lib/data/repositories/chicken/chicken_repository_imp.dart +++ b/packages/chicken/lib/data/repositories/chicken/chicken_repository_imp.dart @@ -8,6 +8,7 @@ import 'package:rasadyar_chicken/data/models/request/steward_free_sale_bar/stewa import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; import 'package:rasadyar_chicken/data/models/response/bar_information/bar_information.dart'; +import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.dart'; import 'package:rasadyar_chicken/data/models/response/dashboard_kill_house_free_bar/dashboard_kill_house_free_bar.dart'; import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; import 'package:rasadyar_chicken/data/models/response/guild_profile/guild_profile.dart'; @@ -323,6 +324,12 @@ class ChickenRepositoryImp implements ChickenRepository { return res; } + @override + Future getBroadcastPrice({required String token}) async { + var res = await remote.getBroadcastPrice(token: token); + return res; + } + //endregion //region local @@ -330,6 +337,7 @@ class ChickenRepositoryImp implements ChickenRepository { WidelyUsedLocalModel? getAllWidely() => local.getAllWidely(); @override - Future initWidleyUsed() async => local.initWidleyUsed(); + Future initWidleyUsed() async {} + //endregion } diff --git a/packages/chicken/lib/presentation/pages/common/profile/view.dart b/packages/chicken/lib/presentation/pages/common/profile/view.dart index 44e2a0d..a5b868d 100644 --- a/packages/chicken/lib/presentation/pages/common/profile/view.dart +++ b/packages/chicken/lib/presentation/pages/common/profile/view.dart @@ -18,7 +18,7 @@ class ProfilePage extends GetView { spacing: 30, children: [ Expanded( - flex: 1, + child: Container( color: AppColor.blueNormal, child: Column( @@ -142,6 +142,7 @@ class ProfilePage extends GetView { ), ), ], + ), ), ), diff --git a/packages/chicken/lib/presentation/pages/steward/buy/logic.dart b/packages/chicken/lib/presentation/pages/steward/buy/logic.dart index 0220183..3b7dc5e 100644 --- a/packages/chicken/lib/presentation/pages/steward/buy/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/buy/logic.dart @@ -1,8 +1,9 @@ +import 'package:flutter/services.dart'; import 'package:rasadyar_core/core.dart'; class BuyLogic extends GetxController { - List routesName = ['خرید']; + DateTime? _lastBackPressed; @override void onInit() { @@ -11,7 +12,7 @@ class BuyLogic extends GetxController { @override void onReady() { - // TODO: implement onReady + fLog('BuyLogic onReady'); super.onReady(); } @@ -20,4 +21,20 @@ class BuyLogic extends GetxController { // TODO: implement onClose super.onClose(); } + + void onPopScopTaped() async { + final now = DateTime.now(); + if (_lastBackPressed == null || now.difference(_lastBackPressed!) > Duration(seconds: 2)) { + _lastBackPressed = now; + Get.snackbar( + 'خروج از برنامه', + 'برای خروج دوباره بازگشت را بزنید', + snackPosition: SnackPosition.TOP, + duration: Duration(seconds: 2), + backgroundColor: AppColor.warning, + ); + } else { + await SystemNavigator.pop(); + } + } } diff --git a/packages/chicken/lib/presentation/pages/steward/buy_in_province/logic.dart b/packages/chicken/lib/presentation/pages/steward/buy_in_province/logic.dart index 0f929a8..576b0b4 100644 --- a/packages/chicken/lib/presentation/pages/steward/buy_in_province/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/buy_in_province/logic.dart @@ -23,10 +23,10 @@ class BuyInProvinceLogic extends GetxController { void onInit() { super.onInit(); routesName.value = [...buyLogic.routesName, 'داخل استان'].toList(); - routesName.add(selectedSegmentIndex.value == 0 ? 'در انتظار' : 'بایگانی'); + routesName.add(selectedSegmentIndex.value == 0 ? 'در انتظار' : 'کل خریدها'); ever(selectedSegmentIndex, (callback) { routesName.removeLast(); - routesName.add(callback == 0 ? 'در انتظار' : 'بایگانی'); + routesName.add(callback == 0 ? 'در انتظار' : 'کل خریدها'); }); ever(fromDateFilter, (callback) => _setFromDateFilter(callback)); @@ -35,7 +35,7 @@ class BuyInProvinceLogic extends GetxController { @override void onReady() { - // TODO: implement onReady + fLog('BuyInProvinceLogic onReady'); super.onReady(); } diff --git a/packages/chicken/lib/presentation/pages/steward/buy_in_province/view.dart b/packages/chicken/lib/presentation/pages/steward/buy_in_province/view.dart index 4606c5d..7bcbf2b 100644 --- a/packages/chicken/lib/presentation/pages/steward/buy_in_province/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/buy_in_province/view.dart @@ -41,7 +41,7 @@ class BuyInProvincePage extends GetView { children: [ Expanded( child: RSegment( - children: ['در انتظار', 'بایگانی'], + children: ['در انتظار', 'کل خریدها'], selectedIndex: 0, borderColor: const Color(0xFFB4B4B4), selectedBorderColor: AppColor.blueNormal, diff --git a/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/logic.dart b/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/logic.dart index 1a806e3..251bec8 100644 --- a/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/logic.dart @@ -5,8 +5,8 @@ import 'package:rasadyar_core/core.dart'; class BuyInProvinceAllLogic extends GetxController { RxList isExpandedList = [].obs; - Rxn fromDateFilter = Rxn(); - Rxn toDateFilter = Rxn(); + Rx fromDateFilter = Jalali.now().obs; + Rx toDateFilter = Jalali.now().obs; RxnString searchedValue = RxnString(); RxMap isLoadingConfirmMap = RxMap(); final RxBool isLoadingMoreAllocationsMade = false.obs; diff --git a/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/view.dart b/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/view.dart index 5efc567..2b30ca0 100644 --- a/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/buy_in_province_all/view.dart @@ -12,6 +12,7 @@ class BuyInProvinceAllPage extends GetView { @override Widget build(BuildContext context) { + eLog("BuyInProvinceAllPage"); return Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: ObxValue((data) { diff --git a/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/logic.dart b/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/logic.dart index 5ca6bdb..282d374 100644 --- a/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/logic.dart @@ -9,8 +9,8 @@ import 'package:rasadyar_core/core.dart'; class BuyInProvinceWaitingLogic extends GetxController { RxList isExpandedList = [].obs; - Rxn fromDateFilter = Rxn(); - Rxn toDateFilter = Rxn(); + Rx fromDateFilter = Jalali.now().obs; + Rx toDateFilter = Jalali.now().obs; RxnString searchedValue = RxnString(); RxMap isLoadingConfirmMap = RxMap(); Rx bgConfirmAllColor = AppColor.blueNormal.obs; @@ -21,8 +21,6 @@ class BuyInProvinceWaitingLogic extends GetxController { Rx>> waitingProduct = Resource>.loading().obs; - - @override void onInit() { super.onInit(); @@ -37,7 +35,6 @@ class BuyInProvinceWaitingLogic extends GetxController { void onReady() { super.onReady(); getWaitingArrivals(); - } @override @@ -95,8 +92,6 @@ class BuyInProvinceWaitingLogic extends GetxController { ); } - - Future acceptEntries(WaitingArrivalModel model) async { var request = StewardAllocationRequest( allocationKey: model.key, diff --git a/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/view.dart b/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/view.dart index 6af8799..e53aa90 100644 --- a/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/buy_in_province_waiting/view.dart @@ -12,6 +12,7 @@ class BuyInProvinceWaitingPage extends GetView { @override Widget build(BuildContext context) { + eLog("BuyInProvinceWaitingPage"); return Scaffold( backgroundColor: Colors.transparent, body: Padding( diff --git a/packages/chicken/lib/presentation/pages/steward/root/logic.dart b/packages/chicken/lib/presentation/pages/steward/root/logic.dart index 6911564..52add18 100644 --- a/packages/chicken/lib/presentation/pages/steward/root/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/root/logic.dart @@ -15,6 +15,7 @@ import 'package:rasadyar_chicken/presentation/pages/steward/home/view.dart'; import 'package:rasadyar_chicken/presentation/pages/steward/sale/view.dart'; import 'package:rasadyar_chicken/presentation/pages/steward/segmentation/view.dart'; import 'package:rasadyar_chicken/presentation/routes/routes.dart'; +import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart'; import 'package:rasadyar_chicken/presentation/utils/utils.dart'; import 'package:rasadyar_core/core.dart'; @@ -157,12 +158,36 @@ class StewardRootLogic extends GetxController { ); } - void onPopScopTaped() async { - final nestedKey = Get.nestedKey(currentPage.value); - final currentNavigator = nestedKey?.currentState; + int getNestedKey() { + switch (currentPage.value) { + case 0: + return stewardFirstKey; + case 1: + return stewardSecondKey; + case 2: + return stewardThirdKey; + + case 3: + return stewardFourthKey; + + case 4: + return stewardFourthKey; + + default: + return stewardThirdKey; + } + } + + void onPopScopTaped() async { + final nestedKeyId = getNestedKey(); + GlobalKey? currentNestedKey = Get.nestedKey(nestedKeyId); + + fLog("onPopScopTaped ==> ${currentNestedKey?.currentState?.canPop()}"); + if (currentNestedKey?.currentState?.canPop() == true) { + iLog(currentNestedKey?.currentState?.canPop()); + iLog(currentNestedKey?.currentContext ); + currentNestedKey?.currentState?.popUntil((route) => route.isFirst); - if (currentNavigator?.canPop() ?? false) { - currentNavigator?.pop(); } else { final now = DateTime.now(); if (_lastBackPressed == null || now.difference(_lastBackPressed!) > Duration(seconds: 2)) { diff --git a/packages/chicken/lib/presentation/pages/steward/sale/logic.dart b/packages/chicken/lib/presentation/pages/steward/sale/logic.dart index 0e28a3c..cbb403a 100644 --- a/packages/chicken/lib/presentation/pages/steward/sale/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/sale/logic.dart @@ -1,4 +1,5 @@ +import 'package:flutter/services.dart'; import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; @@ -17,7 +18,7 @@ class SaleLogic extends GetxController { StewardRootLogic rootLogic = Get.find(); List routesName = ['فروش']; - + DateTime? _lastBackPressed; @override void onReady() { @@ -114,4 +115,23 @@ class SaleLogic extends GetxController { rootLogic.inventoryExpandedList.clear(); super.dispose(); } + + + void onPopScopTaped() async { + + final now = DateTime.now(); + if (_lastBackPressed == null || now.difference(_lastBackPressed!) > Duration(seconds: 2)) { + _lastBackPressed = now; + Get.snackbar( + 'خروج از برنامه', + 'برای خروج دوباره بازگشت را بزنید', + snackPosition: SnackPosition.TOP, + duration: Duration(seconds: 2), + backgroundColor: AppColor.warning, + ); + } else { + await SystemNavigator.pop(); + } + + } } diff --git a/packages/chicken/lib/presentation/pages/steward/sale/view.dart b/packages/chicken/lib/presentation/pages/steward/sale/view.dart index 1e351d6..5fe6500 100644 --- a/packages/chicken/lib/presentation/pages/steward/sale/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/sale/view.dart @@ -3,7 +3,6 @@ import 'package:rasadyar_chicken/chicken.dart'; import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart'; import 'package:rasadyar_chicken/presentation/utils/nested_keys_utils.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; -import 'package:rasadyar_chicken/presentation/widget/sale_buy_card_item.dart'; import 'package:rasadyar_core/core.dart'; import 'logic.dart'; @@ -21,7 +20,6 @@ class SalePage extends GetView { mainAxisAlignment: MainAxisAlignment.center, spacing: 21, children: [ - GlassMorphismCardIcon( title: 'فروش داخل استان', vecIcon: Assets.vec.map2Svg.path, diff --git a/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart b/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart index ca73d66..3d48965 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_in_province/logic.dart @@ -1,10 +1,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; - import 'package:rasadyar_chicken/data/models/request/conform_allocation/conform_allocation.dart'; import 'package:rasadyar_chicken/data/models/request/submit_steward_allocation/submit_steward_allocation.dart'; import 'package:rasadyar_chicken/data/models/response/allocated_made/allocated_made.dart'; +import 'package:rasadyar_chicken/data/models/response/broadcast_price/broadcast_price.dart'; import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; import 'package:rasadyar_chicken/data/models/response/guild_profile/guild_profile.dart'; import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; @@ -33,8 +33,8 @@ class SalesInProvinceLogic extends GetxController { GlobalKey formKey = GlobalKey(); - Rxn fromDateFilter = Rxn(null); - Rxn toDateFilter = Rxn(null); + Rx fromDateFilter = Jalali.now().obs; + Rx toDateFilter = Jalali.now().obs; Rxn selectedProductModel = Rxn(); Rxn selectedGuildModel = Rxn(); Rxn guildProfile = Rxn(); @@ -52,6 +52,7 @@ class SalesInProvinceLogic extends GetxController { final RxBool addPageAllocationsMade = false.obs; final RxBool hasMoreDataAllocationsMade = true.obs; + Rxn broadcastPrice = Rxn(); Rxn selectedAllocationModelForUpdate = Rxn(); SubmitStewardAllocation? tmpStewardAllocation; @@ -63,29 +64,29 @@ class SalesInProvinceLogic extends GetxController { getRolesProducts(); getGuilds(); getGuildProfile(); + getBroadcastPrice(); ever(saleType, (callback) { getGuilds(); }); + debounce(weight, time: Duration(milliseconds: 110), (callback) { - totalCost.value = callback * weight.value; + iLog('weight: $callback, pricePerKilo: ${pricePerKilo.value}'); + totalCost.value = callback * pricePerKilo.value; }); debounce(pricePerKilo, time: Duration(milliseconds: 100), (callback) { totalCost.value = callback * weight.value; }); - totalCost.listen((data) { - totalCostController.text = data - .toString() - .separatedByComma; + totalCostController.text = data.toString().separatedByComma; isValid.value = weight.value > 0 && - pricePerKilo.value > 0 && - totalCost.value > 0 && - selectedProductModel.value != null && - selectedGuildModel.value != null; + pricePerKilo.value > 0 && + totalCost.value > 0 && + selectedProductModel.value != null && + selectedGuildModel.value != null; }); everAll([ totalCost, @@ -93,8 +94,8 @@ class SalesInProvinceLogic extends GetxController { pricePerKilo, totalCost, selectedProductModel, - selectedGuildModel - ], (callback) => checkVerification(),); + selectedGuildModel, + ], (callback) => checkVerification()); scrollControllerAllocationsMade.addListener(() { if (scrollControllerAllocationsMade.position.pixels >= @@ -106,7 +107,7 @@ class SalesInProvinceLogic extends GetxController { debounce( searchedValue, - (callback) => getAllocatedMade(), + (callback) => getAllocatedMade(), time: Duration(milliseconds: timeDebounce), ); } @@ -125,8 +126,7 @@ class SalesInProvinceLogic extends GetxController { } safeCall( - call: () async => - await rootLogic.chickenRepository.getAllocatedMade( + call: () async => await rootLogic.chickenRepository.getAllocatedMade( token: rootLogic.tokenService.accessToken.value!, queryParameters: buildQueryParams( page: currentPage.value, @@ -134,6 +134,8 @@ class SalesInProvinceLogic extends GetxController { search: 'filter', role: 'Steward', value: searchedValue.value, + fromDate: fromDateFilter.value.toDateTime(), + toDate: toDateFilter.value.toDateTime(), ), ), onSuccess: (res) async { @@ -166,16 +168,15 @@ class SalesInProvinceLogic extends GetxController { void checkVerification() { isValid.value = weight.value > 0 && - pricePerKilo.value > 0 && - totalCost.value > 0 && - selectedProductModel.value != null && - selectedGuildModel.value != null; + pricePerKilo.value > 0 && + totalCost.value > 0 && + selectedProductModel.value != null && + selectedGuildModel.value != null; } void confirmAllocation(ConformAllocation allocation) { safeCall( - call: () async => - await rootLogic.chickenRepository.confirmAllocation( + call: () async => await rootLogic.chickenRepository.confirmAllocation( token: rootLogic.tokenService.accessToken.value!, allocation: allocation.toJson(), ), @@ -188,8 +189,7 @@ class SalesInProvinceLogic extends GetxController { void denyAllocation(String token) { safeCall( - call: () async => - await rootLogic.chickenRepository.denyAllocation( + call: () async => await rootLogic.chickenRepository.denyAllocation( token: rootLogic.tokenService.accessToken.value!, allocationToken: token, ), @@ -202,8 +202,7 @@ class SalesInProvinceLogic extends GetxController { Future confirmAllAllocations() async { safeCall( - call: () async => - await rootLogic.chickenRepository.confirmAllAllocation( + call: () async => await rootLogic.chickenRepository.confirmAllAllocation( token: rootLogic.tokenService.accessToken.value!, allocationTokens: allocatedList.value.data?.results?.map((e) => e.key!).toList() ?? [], ), @@ -216,8 +215,7 @@ class SalesInProvinceLogic extends GetxController { Future getRolesProducts() async { safeCall( - call: () async => - await rootLogic.chickenRepository.getRolesProducts( + call: () async => await rootLogic.chickenRepository.getRolesProducts( token: rootLogic.tokenService.accessToken.value!, ), onSuccess: (result) { @@ -232,8 +230,7 @@ class SalesInProvinceLogic extends GetxController { Future getGuilds() async { safeCall( - call: () async => - await rootLogic.chickenRepository.getGuilds( + call: () async => await rootLogic.chickenRepository.getGuilds( token: rootLogic.tokenService.accessToken.value!, queryParameters: buildQueryParams( queryParams: {'free': saleType.value == 2 ? true : false}, @@ -264,8 +261,7 @@ class SalesInProvinceLogic extends GetxController { Future getGuildProfile() async { await safeCall( - call: () async => - await rootLogic.chickenRepository.getProfile( + call: () async => await rootLogic.chickenRepository.getProfile( token: rootLogic.tokenService.accessToken.value!, ), onError: (error, stackTrace) {}, @@ -279,8 +275,7 @@ class SalesInProvinceLogic extends GetxController { tmpStewardAllocation = SubmitStewardAllocation( approvedPriceStatus: false, allocationType: - '${guildProfile.value?.steward == true ? "steward" : "guild"}_${selectedGuildModel.value - ?.steward == true ? "steward" : "guild"}', + '${guildProfile.value?.steward == true ? "steward" : "guild"}_${selectedGuildModel.value?.steward == true ? "steward" : "guild"}', sellerType: guildProfile.value?.steward == true ? "Steward" : "Guild", buyerType: selectedGuildModel.value?.steward == true ? "Steward" : "Guild", amount: pricePerKilo.value, @@ -290,17 +285,14 @@ class SalesInProvinceLogic extends GetxController { numberOfCarcasses: 0, guildKey: selectedGuildModel.value?.key, productKey: selectedProductModel.value?.key, - date: DateTime - .now() - .formattedDashedGregorian, + date: DateTime.now().formattedDashedGregorian, type: "manual", ); } Future submitAllocation() async { safeCall( - call: () async => - await rootLogic.chickenRepository.postSubmitStewardAllocation( + call: () async => await rootLogic.chickenRepository.postSubmitStewardAllocation( token: rootLogic.tokenService.accessToken.value!, request: tmpStewardAllocation!, ), @@ -314,8 +306,7 @@ class SalesInProvinceLogic extends GetxController { Future deleteAllocation(AllocatedMadeModel model) async { safeCall( - call: () async => - await rootLogic.chickenRepository.deleteStewardAllocation( + call: () async => await rootLogic.chickenRepository.deleteStewardAllocation( token: rootLogic.tokenService.accessToken.value!, queryParameters: {'steward_allocation_key': model.key}, ), @@ -341,25 +332,23 @@ class SalesInProvinceLogic extends GetxController { weight.value = item.weightOfCarcasses ?? 0; pricePerKilo.value = item.amount ?? 0; totalCost.value = item.totalAmount ?? 0; - weightController.text = weight.value - .toString() - .separatedByComma; - pricePerKiloController.text = pricePerKilo.value - .toString() - .separatedByComma; - totalCostController.text = totalCost.value - .toString() - .separatedByComma; + weightController.text = weight.value.toString().separatedByComma; + pricePerKiloController.text = pricePerKilo.value.toString().separatedByComma; + totalCostController.text = totalCost.value.toString().separatedByComma; isValid.value = true; } void clearForm() { selectedGuildModel.value = null; weight.value = 0; - pricePerKilo.value = 0; + totalCost.value = 0; weightController.clear(); - pricePerKiloController.clear(); + if (broadcastPrice.value?.active == false) { + pricePerKilo.value = 0; + pricePerKiloController.clear(); + } + totalCostController.clear(); isValid.value = false; } @@ -374,8 +363,7 @@ class SalesInProvinceLogic extends GetxController { ); safeCall( - call: () async => - await rootLogic.chickenRepository.updateStewardAllocation( + call: () async => await rootLogic.chickenRepository.updateStewardAllocation( token: rootLogic.tokenService.accessToken.value!, request: updatedAllocationModel, ), @@ -416,4 +404,20 @@ class SalesInProvinceLogic extends GetxController { return model.steward; } } + + Future getBroadcastPrice() async { + safeCall( + call: () async => await rootLogic.chickenRepository.getBroadcastPrice( + token: rootLogic.tokenService.accessToken.value!, + ), + onSuccess: (result) { + broadcastPrice.value = result; + if (broadcastPrice.value?.active == true) { + pricePerKilo.value = broadcastPrice.value?.stewardPrice ?? 0; + pricePerKiloController.text = pricePerKilo.value.toString().separatedByComma; + } + }, + onError: (error, stacktrace) {}, + ); + } } diff --git a/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart b/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart index 88dc1d7..e821761 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_in_province/view.dart @@ -20,7 +20,6 @@ class SalesInProvincePage extends GetView { routes: controller.routesName, backId: stewardSecondKey, onSearchChanged: (data) => controller.setSearchValue(data), - onFilterTap: () { Get.bottomSheet(filterBottomSheet()); }, @@ -418,7 +417,12 @@ class SalesInProvincePage extends GetView { controller.selectedGuildModel.refresh(); }, ), - Text('فروش اختصاصی', style: AppFonts.yekan14), + ObxValue((data) { + return Text( + (data.value?.active == true) ? 'قیمت مصوب' : 'فروش اختصاصی', + style: AppFonts.yekan14, + ); + }, controller.broadcastPrice), SizedBox(width: 12), Radio( value: 2, @@ -498,24 +502,30 @@ class SalesInProvincePage extends GetView { onChanged: (p0) { controller.weight.value = int.tryParse(p0.clearComma) ?? 0; }, - label: 'وزن لاشه', + label: 'وزن لاشه (کیلوگرم)', ), - RTextField( - controller: controller.pricePerKiloController, - borderColor: AppColor.darkGreyLight, - inputFormatters: [ - FilteringTextInputFormatter.digitsOnly, - SeparatorInputFormatter(), - ], - filledColor: AppColor.bgLight, - filled: true, - onChanged: (p0) { - controller.pricePerKilo.value = int.tryParse(p0.clearComma) ?? 0; - }, - keyboardType: TextInputType.number, - label: 'قیمت هر کیلو', - ), + Obx(() { + return RTextField( + variant: RTextFieldVariant.noBorder, + controller: controller.pricePerKiloController, + borderColor: AppColor.darkGreyLight, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + SeparatorInputFormatter(), + ], + filledColor: AppColor.bgLight, + filled: true, + enabled: + (controller.broadcastPrice.value?.active == false || + controller.saleType.value == 2), + onChanged: (p0) { + controller.pricePerKilo.value = int.tryParse(p0.clearComma) ?? 0; + }, + keyboardType: TextInputType.number, + label: 'قیمت هر کیلو (ريال)', + ); + }), RTextField( variant: RTextFieldVariant.noBorder, @@ -528,7 +538,7 @@ class SalesInProvincePage extends GetView { SeparatorInputFormatter(), ], controller: controller.totalCostController, - label: 'هزینه کل', + label: 'هزینه کل (ريال)', ), ObxValue((data) { @@ -662,7 +672,7 @@ class SalesInProvincePage extends GetView { GestureDetector timeFilterWidget({ isFrom = true, - required Rxn date, + required Rx date, required Function(Jalali jalali) onChanged, }) { return GestureDetector( diff --git a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart index d1fc710..bd5d28d 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/logic.dart @@ -17,12 +17,12 @@ class SalesOutOfProvinceLogic extends GetxController { SaleLogic get saleLogic => Get.find(); - SalesOutOfProvinceBuyersLogic get buyersLogic => Get.find(); + SalesOutOfProvinceSalesListLogic get saleListLogic => Get.find(); - SalesOutOfProvinceBuyersLogic get buyerLogic => Get.find(); + SalesOutOfProvinceBuyersLogic buyerLogic = Get.find(); RxBool isExpanded = false.obs; RxInt currentPage = 1.obs; diff --git a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart index a705efe..e58f674 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province/view.dart @@ -285,7 +285,7 @@ class SalesOutOfProvincePage extends GetView { buildRow(title: 'مشخصات خریدار', value: item.buyer?.fullname ?? 'N/A'), buildRow(title: 'تلفن خریدار', value: item.buyer?.mobile ?? 'N/A'), buildRow(title: 'نام واحد', value: item.buyer?.unitName ?? 'N/A'), - buildRow(title: 'وزن لاشه', value: '${item.weightOfCarcasses?.separatedByCommaFa}'), + buildRow(title: 'وزن لاشه (ريال)', value: '${item.weightOfCarcasses?.separatedByCommaFa}'), Row( mainAxisAlignment: MainAxisAlignment.center, diff --git a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_buyers/view.dart b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_buyers/view.dart index 499b45c..772a264 100644 --- a/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_buyers/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/sales_out_of_province_buyers/view.dart @@ -21,35 +21,58 @@ class SalesOutOfProvinceBuyersPage extends GetView controller.getOutProvinceCarcassesBuyer(true), - onRefresh: () async { - controller.currentPage.value = 1; - await controller.getOutProvinceCarcassesBuyer(); - }, - hasMore: data.value.data?.next != null, - listType: ListType.separated, - resource: data.value, - padding: EdgeInsets.fromLTRB(8, 8, 8, 80), - itemBuilder: (context, index) { - var item = data.value.data!.results![index]; - return ObxValue((val) { - return ExpandableListItem2( - selected: val.contains(index), - onTap: () => controller.isExpandedList.toggle(index), - index: index, - child: itemListWidget(item), - secondChild: itemListExpandedWidget(item), - labelColor: AppColor.blueLight, - labelIcon: Assets.vec.userRaduisSvg.path, + child: Column( + children: [ + Container( + width: Get.width, + height: 39, + margin: EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: AppColor.greenLight, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.textColor, width: 0.5), + ), + alignment: Alignment.center, + child:Text( + 'لیست خریداران خارج از استان', + style: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkHover), + ), + ), + + + Expanded( + child: ObxValue((data) { + return RPaginatedListView( + onLoadMore: () async => controller.getOutProvinceCarcassesBuyer(true), + onRefresh: () async { + controller.currentPage.value = 1; + await controller.getOutProvinceCarcassesBuyer(); + }, + hasMore: data.value.data?.next != null, + listType: ListType.separated, + resource: data.value, + padding: EdgeInsets.fromLTRB(8, 8, 8, 80), + itemBuilder: (context, index) { + var item = data.value.data!.results![index]; + return ObxValue((val) { + return ExpandableListItem2( + selected: val.contains(index), + onTap: () => controller.isExpandedList.toggle(index), + index: index, + child: itemListWidget(item), + secondChild: itemListExpandedWidget(item), + labelColor: AppColor.blueLight, + labelIcon: Assets.vec.userRaduisSvg.path, + ); + }, controller.isExpandedList); + }, + itemCount: data.value.data?.results?.length ?? 0, + separatorBuilder: (context, index) => SizedBox(height: 8.h), ); - }, controller.isExpandedList); - }, - itemCount: data.value.data?.results?.length ?? 0, - separatorBuilder: (context, index) => SizedBox(height: 8.h), - ); - }, controller.buyerList), + }, controller.buyerList), + ), + ], + ), ), Positioned( bottom: 100, diff --git a/packages/chicken/lib/presentation/pages/steward/segmentation/logic.dart b/packages/chicken/lib/presentation/pages/steward/segmentation/logic.dart index f1c745b..c4bacb5 100644 --- a/packages/chicken/lib/presentation/pages/steward/segmentation/logic.dart +++ b/packages/chicken/lib/presentation/pages/steward/segmentation/logic.dart @@ -1,6 +1,5 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; - import 'package:rasadyar_chicken/data/models/response/guild/guild_model.dart'; import 'package:rasadyar_chicken/data/models/response/roles_products/roles_products.dart'; import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart'; @@ -22,7 +21,9 @@ class SegmentationLogic extends GetxController { Rx fromDateFilter = Jalali.now().obs; Rx toDateFilter = Jalali.now().obs; RxnString searchedValue = RxnString(); + RxInt segmentType = 1.obs; RxInt saleType = 1.obs; + RxInt quotaType = 1.obs; GlobalKey formKey = GlobalKey(); TextEditingController weightController = TextEditingController(text: '0'); RxBool isSubmitButtonEnabled = false.obs; @@ -82,6 +83,9 @@ class SegmentationLogic extends GetxController { weightController.text = '0'; selectedSegment.value = null; selectedGuildModel.value = null; + segmentType.value = 1; + saleType.value = 1; + quotaType.value = 1; } void validateForm() { @@ -178,8 +182,10 @@ class SegmentationLogic extends GetxController { SegmentationModel segmentationModel = SegmentationModel( productKey: selectedProduct.value?.key, weight: int.tryParse(weightController.text.clearComma) ?? 0, + saleType: saleType.value == 1 ? 'governmental' : 'free', + quota: quotaType.value == 1 ? 'governmental' : 'free', ); - if (saleType.value == 2) { + if (segmentType.value == 2) { segmentationModel = segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key); } await safeCall( @@ -189,6 +195,8 @@ class SegmentationLogic extends GetxController { ), onSuccess: (result) { res = true; + isSubmitButtonEnabled.value = true; + }, onError: (error, stacktrace) { res = false; diff --git a/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart b/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart index 34edd1a..130dc0c 100644 --- a/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart +++ b/packages/chicken/lib/presentation/pages/steward/segmentation/view.dart @@ -5,8 +5,6 @@ import 'package:rasadyar_chicken/data/models/response/roles_products/roles_produ import 'package:rasadyar_chicken/data/models/response/segmentation_model/segmentation_model.dart'; import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart'; import 'package:rasadyar_chicken/presentation/widget/filter_bottom_sheet.dart'; - - import 'package:rasadyar_core/core.dart'; import 'logic.dart'; @@ -23,53 +21,56 @@ class SegmentationPage extends GetView { hasBack: false, child: Stack( children: [ - Positioned.fill(child: ObxValue((data) { - return RPaginatedListView( - onLoadMore: () async => controller.getAllSegmentation(true), - onRefresh: () async { - controller.currentPage.value = 1; - await controller.getAllSegmentation(); - }, - hasMore: data.value.data?.next != null, - listType: ListType.separated, - resource: data.value, - padding: EdgeInsets.fromLTRB(8, 8, 8, 80), - itemBuilder: (context, index) { - var item = data.value.data!.results![index]; - return ObxValue((val) { - return ExpandableListItem2( - selected: val.contains(index), - onTap: () => controller.isExpandedList.toggle(index), - index: index, - child: itemListWidget(item), - secondChild: itemListExpandedWidget(item, index), - labelColor: AppColor.blueLight, - labelIconColor: AppColor.customGrey, - labelIcon: Assets.vec.convertCubeSvg.path, - ); - }, controller.isExpandedList); - }, - itemCount: data.value.data?.results?.length ?? 0, - separatorBuilder: (context, index) => SizedBox(height: 8.h), - ); - }, controller.segmentationList)), + Positioned.fill( + child: ObxValue((data) { + return RPaginatedListView( + onLoadMore: () async => controller.getAllSegmentation(true), + onRefresh: () async { + controller.currentPage.value = 1; + await controller.getAllSegmentation(); + }, + hasMore: data.value.data?.next != null, + listType: ListType.separated, + resource: data.value, + padding: EdgeInsets.fromLTRB(8, 8, 8, 80), + itemBuilder: (context, index) { + var item = data.value.data!.results![index]; + return ObxValue((val) { + return ExpandableListItem2( + selected: val.contains(index), + onTap: () => controller.isExpandedList.toggle(index), + index: index, + child: itemListWidget(item), + secondChild: itemListExpandedWidget(item, index), + labelColor: AppColor.blueLight, + labelIconColor: AppColor.customGrey, + labelIcon: Assets.vec.convertCubeSvg.path, + ); + }, controller.isExpandedList); + }, + itemCount: data.value.data?.results?.length ?? 0, + separatorBuilder: (context, index) => SizedBox(height: 8.h), + ); + }, controller.segmentationList), + ), Positioned( - right: 10, - bottom: 90.h, - child: RFab.add( - onPressed: () { - Get.bottomSheet( - addOrEditBottomSheet(), - isScrollControlled: true, - ignoreSafeArea: false, - ).whenComplete(() { - controller.clearForm(); - }); - }, - )) + right: 10, + bottom: 90.h, + child: RFab.add( + onPressed: () { + Get.bottomSheet( + addOrEditBottomSheet(), + isScrollControlled: true, + ignoreSafeArea: false, + ).whenComplete(() { + controller.clearForm(); + //defaultShowSuccessMessage('با موفقیت ثبت شد'); + }); + }, + ), + ), ], ), - ); } @@ -257,7 +258,7 @@ class SegmentationPage extends GetView { Widget addOrEditBottomSheet([bool isOnEdit = false]) { return BaseBottomSheet( - height: 430.h, + height: 480.h, child: SingleChildScrollView( child: Form( key: controller.formKey, @@ -284,25 +285,25 @@ class SegmentationPage extends GetView { height: 40, child: ObxValue((data) { return Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, children: [ Radio( value: 1, - groupValue: controller.saleType.value, + groupValue: controller.segmentType.value, onChanged: (value) { - controller.saleType.value = value!; + controller.segmentType.value = value!; controller.selectedGuildModel.value = null; controller.selectedGuildModel.refresh(); }, ), - Text('قطعه‌بندی(مباشر)', style: AppFonts.yekan14), + Text('قطعه‌بندی(کاربر)', style: AppFonts.yekan14), SizedBox(width: 12), Radio( value: 2, - groupValue: controller.saleType.value, + groupValue: controller.segmentType.value, onChanged: (value) { - controller.saleType.value = value!; + controller.segmentType.value = value!; }, ), Text('تخصیص به قطعه‌بند', style: AppFonts.yekan14), @@ -312,7 +313,68 @@ class SegmentationPage extends GetView { ), const SizedBox(height: 12), - guildsDropDown(), + ObxValue((data) { + return Visibility(visible: data.value == 2, child: guildsDropDown()); + }, controller.segmentType), + ], + ), + ), + Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + border: Border.all(color: AppColor.darkGreyLight, width: 1), + ), + + child: Column( + children: [ + const SizedBox(height: 8), + SizedBox( + height: 40, + child: ObxValue((data) { + return RadioGroup( + onChanged: (value) { + controller.saleType.value = value ?? 0; + controller.selectedGuildModel.value = null; + controller.selectedGuildModel.refresh(); + }, + groupValue: controller.saleType.value, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Radio(value: 1), + Text('فروش دولتی', style: AppFonts.yekan14), + SizedBox(width: 12), + Radio(value: 2), + Text('فروش آزاد', style: AppFonts.yekan14), + ], + ), + ); + }, controller.saleType), + ), + const SizedBox(height: 12), + SizedBox( + height: 40, + child: ObxValue((data) { + return RadioGroup( + onChanged: (value) { + controller.quotaType.value = value ?? 0; + }, + groupValue: controller.quotaType.value, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Radio(value: 1), + Text('انبار دولتی', style: AppFonts.yekan14), + SizedBox(width: 12), + Radio(value: 2), + Text('انبار آزاد', style: AppFonts.yekan14), + ], + ), + ); + }, controller.saleType), + ), ], ), ), diff --git a/packages/chicken/lib/presentation/routes/pages.dart b/packages/chicken/lib/presentation/routes/pages.dart index cb45241..03c1924 100644 --- a/packages/chicken/lib/presentation/routes/pages.dart +++ b/packages/chicken/lib/presentation/routes/pages.dart @@ -84,6 +84,7 @@ sealed class ChickenPages { Get.lazyPut(() => SaleLogic()); Get.lazyPut(() => BaseLogic()); Get.lazyPut(() => SalesOutOfProvinceLogic()); + Get.lazyPut(() => SalesOutOfProvinceBuyersLogic()); Get.lazyPut(() => StewardRootLogic()); }), ), diff --git a/packages/chicken/test/data/common/constant_test.dart b/packages/chicken/test/data/common/constant_test.dart new file mode 100644 index 0000000..d939728 --- /dev/null +++ b/packages/chicken/test/data/common/constant_test.dart @@ -0,0 +1,15 @@ +// File: packages/chicken/test/data/common/constant_test.dart +import 'package:flutter_test/flutter_test.dart'; +import 'package:rasadyar_chicken/data/common/constant.dart'; + +void main() { + group('ApiEnvironment', () { + test('dam environment returns correct baseUrl', () { + expect(ApiEnvironment.dam.baseUrl, 'https://api.dam.rasadyar.net/'); + }); + + test('dam environment url property is correct', () { + expect(ApiEnvironment.dam.url, 'https://api.dam.rasadyar.net/'); + }); + }); +} \ No newline at end of file diff --git a/packages/chicken/test/data/common/dio_error_handler_test.dart b/packages/chicken/test/data/common/dio_error_handler_test.dart new file mode 100644 index 0000000..3353a8a --- /dev/null +++ b/packages/chicken/test/data/common/dio_error_handler_test.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; +import 'package:rasadyar_chicken/data/common/dio_error_handler.dart'; +import 'package:rasadyar_core/core.dart'; + +class MockGet extends Mock implements GetInterface {} + +void main() { + late DioErrorHandler errorHandler; + late MockGet mockGet; + + setUp(() { + errorHandler = DioErrorHandler(); + mockGet = MockGet(); + Get.testMode = true; + Get.put(mockGet); + }); + + /*test('handle 410 Error', () { + final error = DioException( + response: Response(statusCode: 410, requestOptions: RequestOptions(path: "/")), + requestOptions: RequestOptions(path: "/"), + ); + + errorHandler.handle(error); + + verify( + () => mockGet.showSnackbar( + any( + that: isA().having( + (s) => (s.messageText as Text).data, + 'messageText', + 'نام کاربری یا رمز عبور اشتباه است', + ), + ), + ), + ).called(1); + });*/ +} diff --git a/packages/chicken/test/data/common/fa_user_role_test.dart b/packages/chicken/test/data/common/fa_user_role_test.dart new file mode 100644 index 0000000..e16bf4e --- /dev/null +++ b/packages/chicken/test/data/common/fa_user_role_test.dart @@ -0,0 +1,26 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:rasadyar_chicken/data/common/fa_user_role.dart'; +import 'package:rasadyar_chicken/presentation/routes/routes.dart'; + +void main() { + group('getFaUserRole', () { + test('returns correct Farsi role for known roles and unknown/null', () { + expect(getFaUserRole('Admin'), 'ادمین استان'); + expect(getFaUserRole('Poultry'), 'مرغدار'); + expect(getFaUserRole('ProvinceFinancial'), 'مالی اتحادیه'); + expect(getFaUserRole('SuperAdmin'), 'ادمین کل'); + expect(getFaUserRole('UnknownRole'), 'نامشخص'); + expect(getFaUserRole(null), 'نامشخص'); + }); + }); + + group('getFaUserRoleWithOnTap', () { + test('returns correct map for known roles and unknown/null', () { + expect(getFaUserRoleWithOnTap('Admin'), {'ادمین استان': null}); + expect(getFaUserRoleWithOnTap('Steward'), {'مباشر': ChickenRoutes.initSteward}); + expect(getFaUserRoleWithOnTap('PoultryScience'), {'کارشناس طیور': ChickenRoutes.initPoultryScience}); + expect(getFaUserRoleWithOnTap('UnknownRole'), {'نامشخص': null}); + expect(getFaUserRoleWithOnTap(null), {'نامشخص': null}); + }); + }); +} \ No newline at end of file diff --git a/packages/chicken/test/data/di/chicken_di_test.dart b/packages/chicken/test/data/di/chicken_di_test.dart new file mode 100644 index 0000000..c4a3db0 --- /dev/null +++ b/packages/chicken/test/data/di/chicken_di_test.dart @@ -0,0 +1,19 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:rasadyar_chicken/data/common/dio_error_handler.dart'; +import 'package:rasadyar_chicken/data/di/chicken_di.dart'; +import 'package:rasadyar_core/core.dart'; + +void main() { + setUp(() async { + await setupAllCoreProvider(); + Get.put(TokenStorageService()); + await setupChickenDI(); + }); + + group('Check class type registered', () { + test('DioErrorHandler is registered', () { + expect(diChicken, isA()); + expect(diChicken.isRegistered(), true); + }); + }); +} diff --git a/packages/core/lib/presentation/widget/base_page/view.dart b/packages/core/lib/presentation/widget/base_page/view.dart index ed65c9a..18599b9 100644 --- a/packages/core/lib/presentation/widget/base_page/view.dart +++ b/packages/core/lib/presentation/widget/base_page/view.dart @@ -93,6 +93,8 @@ class BasePage extends GetView { return PopScope( canPop: false, onPopInvokedWithResult: (didPop, result) { + tLog("PopScope Tapped ==> $didPop"); + if (!didPop) { onPopScopTaped!(); }