feat: new date picker and new logic

This commit is contained in:
2025-11-02 17:27:45 +03:30
parent 858fb48f68
commit f93d9bb275
14 changed files with 727 additions and 103 deletions

View File

@@ -19,6 +19,7 @@ import 'package:rasadyar_chicken/data/models/response/segmentation_model/segment
import 'package:rasadyar_chicken/data/models/response/steward_free_bar/steward_free_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_remain_weight/steward_remain_weight.dart';
import 'package:rasadyar_chicken/data/models/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/user_profile/user_profile.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart'
@@ -174,4 +175,6 @@ abstract class ChickenRemoteDatasource {
required String token,
Map<String, dynamic>? queryParameters,
});
Future<StewardRemainWeight?> getStewardRemainWeight({required String token});
}

View File

@@ -19,6 +19,7 @@ import 'package:rasadyar_chicken/data/models/response/segmentation_model/segment
import 'package:rasadyar_chicken/data/models/response/steward_free_bar/steward_free_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_remain_weight/steward_remain_weight.dart';
import 'package:rasadyar_chicken/data/models/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/user_profile/user_profile.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart'
@@ -533,4 +534,15 @@ class ChickenRemoteDatasourceImp implements ChickenRemoteDatasource {
return res.data;
}
@override
Future<StewardRemainWeight?> getStewardRemainWeight({required String token}) async {
var res = await _httpClient.get(
'/steward-remain-weight/',
headers: {'Authorization': 'Bearer $token'},
fromJson: StewardRemainWeight.fromJson,
);
return res.data;
}
}

View File

@@ -0,0 +1,26 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'steward_remain_weight.freezed.dart';
part 'steward_remain_weight.g.dart';
@freezed
abstract class StewardRemainWeight with _$StewardRemainWeight {
const factory StewardRemainWeight({
List<RemainWeightDay>? governmental,
List<RemainWeightDay>? free,
}) = _StewardRemainWeight;
factory StewardRemainWeight.fromJson(Map<String, dynamic> json) =>
_$StewardRemainWeightFromJson(json);
}
@freezed
abstract class RemainWeightDay with _$RemainWeightDay {
const factory RemainWeightDay({
String? day,
double? amount,
}) = _RemainWeightDay;
factory RemainWeightDay.fromJson(Map<String, dynamic> json) =>
_$RemainWeightDayFromJson(json);
}

View File

@@ -0,0 +1,562 @@
// 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 'steward_remain_weight.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$StewardRemainWeight {
List<RemainWeightDay>? get governmental; List<RemainWeightDay>? get free;
/// Create a copy of StewardRemainWeight
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$StewardRemainWeightCopyWith<StewardRemainWeight> get copyWith => _$StewardRemainWeightCopyWithImpl<StewardRemainWeight>(this as StewardRemainWeight, _$identity);
/// Serializes this StewardRemainWeight to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is StewardRemainWeight&&const DeepCollectionEquality().equals(other.governmental, governmental)&&const DeepCollectionEquality().equals(other.free, free));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(governmental),const DeepCollectionEquality().hash(free));
@override
String toString() {
return 'StewardRemainWeight(governmental: $governmental, free: $free)';
}
}
/// @nodoc
abstract mixin class $StewardRemainWeightCopyWith<$Res> {
factory $StewardRemainWeightCopyWith(StewardRemainWeight value, $Res Function(StewardRemainWeight) _then) = _$StewardRemainWeightCopyWithImpl;
@useResult
$Res call({
List<RemainWeightDay>? governmental, List<RemainWeightDay>? free
});
}
/// @nodoc
class _$StewardRemainWeightCopyWithImpl<$Res>
implements $StewardRemainWeightCopyWith<$Res> {
_$StewardRemainWeightCopyWithImpl(this._self, this._then);
final StewardRemainWeight _self;
final $Res Function(StewardRemainWeight) _then;
/// Create a copy of StewardRemainWeight
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? governmental = freezed,Object? free = freezed,}) {
return _then(_self.copyWith(
governmental: freezed == governmental ? _self.governmental : governmental // ignore: cast_nullable_to_non_nullable
as List<RemainWeightDay>?,free: freezed == free ? _self.free : free // ignore: cast_nullable_to_non_nullable
as List<RemainWeightDay>?,
));
}
}
/// Adds pattern-matching-related methods to [StewardRemainWeight].
extension StewardRemainWeightPatterns on StewardRemainWeight {
/// 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 extends Object?>(TResult Function( _StewardRemainWeight value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _StewardRemainWeight() 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 extends Object?>(TResult Function( _StewardRemainWeight value) $default,){
final _that = this;
switch (_that) {
case _StewardRemainWeight():
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 extends Object?>(TResult? Function( _StewardRemainWeight value)? $default,){
final _that = this;
switch (_that) {
case _StewardRemainWeight() 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 extends Object?>(TResult Function( List<RemainWeightDay>? governmental, List<RemainWeightDay>? free)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _StewardRemainWeight() when $default != null:
return $default(_that.governmental,_that.free);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 extends Object?>(TResult Function( List<RemainWeightDay>? governmental, List<RemainWeightDay>? free) $default,) {final _that = this;
switch (_that) {
case _StewardRemainWeight():
return $default(_that.governmental,_that.free);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 extends Object?>(TResult? Function( List<RemainWeightDay>? governmental, List<RemainWeightDay>? free)? $default,) {final _that = this;
switch (_that) {
case _StewardRemainWeight() when $default != null:
return $default(_that.governmental,_that.free);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _StewardRemainWeight implements StewardRemainWeight {
const _StewardRemainWeight({final List<RemainWeightDay>? governmental, final List<RemainWeightDay>? free}): _governmental = governmental,_free = free;
factory _StewardRemainWeight.fromJson(Map<String, dynamic> json) => _$StewardRemainWeightFromJson(json);
final List<RemainWeightDay>? _governmental;
@override List<RemainWeightDay>? get governmental {
final value = _governmental;
if (value == null) return null;
if (_governmental is EqualUnmodifiableListView) return _governmental;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
final List<RemainWeightDay>? _free;
@override List<RemainWeightDay>? get free {
final value = _free;
if (value == null) return null;
if (_free is EqualUnmodifiableListView) return _free;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(value);
}
/// Create a copy of StewardRemainWeight
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$StewardRemainWeightCopyWith<_StewardRemainWeight> get copyWith => __$StewardRemainWeightCopyWithImpl<_StewardRemainWeight>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$StewardRemainWeightToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _StewardRemainWeight&&const DeepCollectionEquality().equals(other._governmental, _governmental)&&const DeepCollectionEquality().equals(other._free, _free));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_governmental),const DeepCollectionEquality().hash(_free));
@override
String toString() {
return 'StewardRemainWeight(governmental: $governmental, free: $free)';
}
}
/// @nodoc
abstract mixin class _$StewardRemainWeightCopyWith<$Res> implements $StewardRemainWeightCopyWith<$Res> {
factory _$StewardRemainWeightCopyWith(_StewardRemainWeight value, $Res Function(_StewardRemainWeight) _then) = __$StewardRemainWeightCopyWithImpl;
@override @useResult
$Res call({
List<RemainWeightDay>? governmental, List<RemainWeightDay>? free
});
}
/// @nodoc
class __$StewardRemainWeightCopyWithImpl<$Res>
implements _$StewardRemainWeightCopyWith<$Res> {
__$StewardRemainWeightCopyWithImpl(this._self, this._then);
final _StewardRemainWeight _self;
final $Res Function(_StewardRemainWeight) _then;
/// Create a copy of StewardRemainWeight
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? governmental = freezed,Object? free = freezed,}) {
return _then(_StewardRemainWeight(
governmental: freezed == governmental ? _self._governmental : governmental // ignore: cast_nullable_to_non_nullable
as List<RemainWeightDay>?,free: freezed == free ? _self._free : free // ignore: cast_nullable_to_non_nullable
as List<RemainWeightDay>?,
));
}
}
/// @nodoc
mixin _$RemainWeightDay {
String? get day; double? get amount;
/// Create a copy of RemainWeightDay
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$RemainWeightDayCopyWith<RemainWeightDay> get copyWith => _$RemainWeightDayCopyWithImpl<RemainWeightDay>(this as RemainWeightDay, _$identity);
/// Serializes this RemainWeightDay to a JSON map.
Map<String, dynamic> toJson();
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is RemainWeightDay&&(identical(other.day, day) || other.day == day)&&(identical(other.amount, amount) || other.amount == amount));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,day,amount);
@override
String toString() {
return 'RemainWeightDay(day: $day, amount: $amount)';
}
}
/// @nodoc
abstract mixin class $RemainWeightDayCopyWith<$Res> {
factory $RemainWeightDayCopyWith(RemainWeightDay value, $Res Function(RemainWeightDay) _then) = _$RemainWeightDayCopyWithImpl;
@useResult
$Res call({
String? day, double? amount
});
}
/// @nodoc
class _$RemainWeightDayCopyWithImpl<$Res>
implements $RemainWeightDayCopyWith<$Res> {
_$RemainWeightDayCopyWithImpl(this._self, this._then);
final RemainWeightDay _self;
final $Res Function(RemainWeightDay) _then;
/// Create a copy of RemainWeightDay
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? day = freezed,Object? amount = freezed,}) {
return _then(_self.copyWith(
day: freezed == day ? _self.day : day // ignore: cast_nullable_to_non_nullable
as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
as double?,
));
}
}
/// Adds pattern-matching-related methods to [RemainWeightDay].
extension RemainWeightDayPatterns on RemainWeightDay {
/// 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 extends Object?>(TResult Function( _RemainWeightDay value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _RemainWeightDay() 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 extends Object?>(TResult Function( _RemainWeightDay value) $default,){
final _that = this;
switch (_that) {
case _RemainWeightDay():
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 extends Object?>(TResult? Function( _RemainWeightDay value)? $default,){
final _that = this;
switch (_that) {
case _RemainWeightDay() 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 extends Object?>(TResult Function( String? day, double? amount)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _RemainWeightDay() when $default != null:
return $default(_that.day,_that.amount);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 extends Object?>(TResult Function( String? day, double? amount) $default,) {final _that = this;
switch (_that) {
case _RemainWeightDay():
return $default(_that.day,_that.amount);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 extends Object?>(TResult? Function( String? day, double? amount)? $default,) {final _that = this;
switch (_that) {
case _RemainWeightDay() when $default != null:
return $default(_that.day,_that.amount);case _:
return null;
}
}
}
/// @nodoc
@JsonSerializable()
class _RemainWeightDay implements RemainWeightDay {
const _RemainWeightDay({this.day, this.amount});
factory _RemainWeightDay.fromJson(Map<String, dynamic> json) => _$RemainWeightDayFromJson(json);
@override final String? day;
@override final double? amount;
/// Create a copy of RemainWeightDay
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$RemainWeightDayCopyWith<_RemainWeightDay> get copyWith => __$RemainWeightDayCopyWithImpl<_RemainWeightDay>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$RemainWeightDayToJson(this, );
}
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RemainWeightDay&&(identical(other.day, day) || other.day == day)&&(identical(other.amount, amount) || other.amount == amount));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,day,amount);
@override
String toString() {
return 'RemainWeightDay(day: $day, amount: $amount)';
}
}
/// @nodoc
abstract mixin class _$RemainWeightDayCopyWith<$Res> implements $RemainWeightDayCopyWith<$Res> {
factory _$RemainWeightDayCopyWith(_RemainWeightDay value, $Res Function(_RemainWeightDay) _then) = __$RemainWeightDayCopyWithImpl;
@override @useResult
$Res call({
String? day, double? amount
});
}
/// @nodoc
class __$RemainWeightDayCopyWithImpl<$Res>
implements _$RemainWeightDayCopyWith<$Res> {
__$RemainWeightDayCopyWithImpl(this._self, this._then);
final _RemainWeightDay _self;
final $Res Function(_RemainWeightDay) _then;
/// Create a copy of RemainWeightDay
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? day = freezed,Object? amount = freezed,}) {
return _then(_RemainWeightDay(
day: freezed == day ? _self.day : day // ignore: cast_nullable_to_non_nullable
as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable
as double?,
));
}
}
// dart format on

View File

@@ -0,0 +1,33 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'steward_remain_weight.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_StewardRemainWeight _$StewardRemainWeightFromJson(Map<String, dynamic> json) =>
_StewardRemainWeight(
governmental: (json['governmental'] as List<dynamic>?)
?.map((e) => RemainWeightDay.fromJson(e as Map<String, dynamic>))
.toList(),
free: (json['free'] as List<dynamic>?)
?.map((e) => RemainWeightDay.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$StewardRemainWeightToJson(
_StewardRemainWeight instance,
) => <String, dynamic>{
'governmental': instance.governmental,
'free': instance.free,
};
_RemainWeightDay _$RemainWeightDayFromJson(Map<String, dynamic> json) =>
_RemainWeightDay(
day: json['day'] as String?,
amount: (json['amount'] as num?)?.toDouble(),
);
Map<String, dynamic> _$RemainWeightDayToJson(_RemainWeightDay instance) =>
<String, dynamic>{'day': instance.day, 'amount': instance.amount};

View File

@@ -19,6 +19,7 @@ import 'package:rasadyar_chicken/data/models/response/segmentation_model/segment
import 'package:rasadyar_chicken/data/models/response/steward_free_bar/steward_free_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_remain_weight/steward_remain_weight.dart';
import 'package:rasadyar_chicken/data/models/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/user_profile/user_profile.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart'
@@ -182,6 +183,8 @@ abstract class ChickenRepository {
Map<String, dynamic>? queryParameters,
});
Future<StewardRemainWeight?> getStewardRemainWeight({required String token});
//endregion

View File

@@ -22,6 +22,7 @@ import 'package:rasadyar_chicken/data/models/response/segmentation_model/segment
import 'package:rasadyar_chicken/data/models/response/steward_free_bar/steward_free_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_bar_dashboard/steward_free_bar_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/steward_free_sale_bar/steward_free_sale_bar.dart';
import 'package:rasadyar_chicken/data/models/response/steward_remain_weight/steward_remain_weight.dart';
import 'package:rasadyar_chicken/data/models/response/steward_sales_info_dashboard/steward_sales_info_dashboard.dart';
import 'package:rasadyar_chicken/data/models/response/user_profile/user_profile.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart'
@@ -423,5 +424,10 @@ class ChickenRepositoryImp implements ChickenRepository {
);
}
@override
Future<StewardRemainWeight?> getStewardRemainWeight({required String token}) async {
return await remote.getStewardRemainWeight(token: token);
}
//endregion
}