feat : sale in provence
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
library;
|
||||
|
||||
//models
|
||||
export 'data/model/pagination_model/pagination_model.dart';
|
||||
|
||||
//other packages
|
||||
export 'package:flutter_localizations/flutter_localizations.dart';
|
||||
export 'package:flutter_map/flutter_map.dart';
|
||||
@@ -9,7 +12,7 @@ export 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
export 'package:flutter_slidable/flutter_slidable.dart';
|
||||
export 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
export 'package:device_info_plus/device_info_plus.dart';
|
||||
export 'package:dio/dio.dart' ;
|
||||
export 'package:dio/dio.dart';
|
||||
export 'package:pretty_dio_logger/pretty_dio_logger.dart';
|
||||
export 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
@@ -17,6 +20,7 @@ export 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
export 'package:freezed_annotation/freezed_annotation.dart';
|
||||
export 'package:geolocator/geolocator.dart';
|
||||
export 'package:get/get.dart' hide FormData, MultipartFile, Response;
|
||||
|
||||
//di
|
||||
export 'package:get_it/get_it.dart';
|
||||
export 'injection/di.dart';
|
||||
@@ -29,7 +33,7 @@ export 'infrastructure/local/hive_local_storage.dart';
|
||||
//export 'package:encrypt/encrypt.dart' show Encrypted;
|
||||
|
||||
//Map and location
|
||||
export 'package:latlong2/latlong.dart' ;
|
||||
export 'package:latlong2/latlong.dart';
|
||||
export 'package:persian_datetime_picker/persian_datetime_picker.dart';
|
||||
export 'package:rasadyar_core/presentation/common/common.dart';
|
||||
export 'package:rasadyar_core/presentation/utils/utils.dart';
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'pagination_model.freezed.dart';
|
||||
part 'pagination_model.g.dart';
|
||||
|
||||
@Freezed(genericArgumentFactories: true)
|
||||
abstract class PaginationModel<T> with _$PaginationModel<T> {
|
||||
const factory PaginationModel({
|
||||
int? count,
|
||||
String? next,
|
||||
String? previous,
|
||||
List<T>? results,
|
||||
}) = _PaginationModel<T>;
|
||||
|
||||
factory PaginationModel.fromJson(
|
||||
Map<String, dynamic> json,
|
||||
T Function(Object?) fromJsonT,
|
||||
) => _$PaginationModelFromJson(json, fromJsonT);
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
// dart format width=80
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// 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 'pagination_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaginationModel<T> {
|
||||
|
||||
int? get count; String? get next; String? get previous; List<T>? get results;
|
||||
/// Create a copy of PaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$PaginationModelCopyWith<T, PaginationModel<T>> get copyWith => _$PaginationModelCopyWithImpl<T, PaginationModel<T>>(this as PaginationModel<T>, _$identity);
|
||||
|
||||
/// Serializes this PaginationModel to a JSON map.
|
||||
Map<String, dynamic> toJson(Object? Function(T) toJsonT);
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is PaginationModel<T>&&(identical(other.count, count) || other.count == count)&&(identical(other.next, next) || other.next == next)&&(identical(other.previous, previous) || other.previous == previous)&&const DeepCollectionEquality().equals(other.results, results));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,count,next,previous,const DeepCollectionEquality().hash(results));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaginationModel<$T>(count: $count, next: $next, previous: $previous, results: $results)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $PaginationModelCopyWith<T,$Res> {
|
||||
factory $PaginationModelCopyWith(PaginationModel<T> value, $Res Function(PaginationModel<T>) _then) = _$PaginationModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int? count, String? next, String? previous, List<T>? results
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$PaginationModelCopyWithImpl<T,$Res>
|
||||
implements $PaginationModelCopyWith<T, $Res> {
|
||||
_$PaginationModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final PaginationModel<T> _self;
|
||||
final $Res Function(PaginationModel<T>) _then;
|
||||
|
||||
/// Create a copy of PaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? count = freezed,Object? next = freezed,Object? previous = freezed,Object? results = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
count: freezed == count ? _self.count : count // ignore: cast_nullable_to_non_nullable
|
||||
as int?,next: freezed == next ? _self.next : next // ignore: cast_nullable_to_non_nullable
|
||||
as String?,previous: freezed == previous ? _self.previous : previous // ignore: cast_nullable_to_non_nullable
|
||||
as String?,results: freezed == results ? _self.results : results // ignore: cast_nullable_to_non_nullable
|
||||
as List<T>?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable(genericArgumentFactories: true)
|
||||
|
||||
class _PaginationModel<T> implements PaginationModel<T> {
|
||||
const _PaginationModel({this.count, this.next, this.previous, final List<T>? results}): _results = results;
|
||||
factory _PaginationModel.fromJson(Map<String, dynamic> json,T Function(Object?) fromJsonT) => _$PaginationModelFromJson(json,fromJsonT);
|
||||
|
||||
@override final int? count;
|
||||
@override final String? next;
|
||||
@override final String? previous;
|
||||
final List<T>? _results;
|
||||
@override List<T>? get results {
|
||||
final value = _results;
|
||||
if (value == null) return null;
|
||||
if (_results is EqualUnmodifiableListView) return _results;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(value);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of PaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$PaginationModelCopyWith<T, _PaginationModel<T>> get copyWith => __$PaginationModelCopyWithImpl<T, _PaginationModel<T>>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson(Object? Function(T) toJsonT) {
|
||||
return _$PaginationModelToJson<T>(this, toJsonT);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaginationModel<T>&&(identical(other.count, count) || other.count == count)&&(identical(other.next, next) || other.next == next)&&(identical(other.previous, previous) || other.previous == previous)&&const DeepCollectionEquality().equals(other._results, _results));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,count,next,previous,const DeepCollectionEquality().hash(_results));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaginationModel<$T>(count: $count, next: $next, previous: $previous, results: $results)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$PaginationModelCopyWith<T,$Res> implements $PaginationModelCopyWith<T, $Res> {
|
||||
factory _$PaginationModelCopyWith(_PaginationModel<T> value, $Res Function(_PaginationModel<T>) _then) = __$PaginationModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int? count, String? next, String? previous, List<T>? results
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$PaginationModelCopyWithImpl<T,$Res>
|
||||
implements _$PaginationModelCopyWith<T, $Res> {
|
||||
__$PaginationModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _PaginationModel<T> _self;
|
||||
final $Res Function(_PaginationModel<T>) _then;
|
||||
|
||||
/// Create a copy of PaginationModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? count = freezed,Object? next = freezed,Object? previous = freezed,Object? results = freezed,}) {
|
||||
return _then(_PaginationModel<T>(
|
||||
count: freezed == count ? _self.count : count // ignore: cast_nullable_to_non_nullable
|
||||
as int?,next: freezed == next ? _self.next : next // ignore: cast_nullable_to_non_nullable
|
||||
as String?,previous: freezed == previous ? _self.previous : previous // ignore: cast_nullable_to_non_nullable
|
||||
as String?,results: freezed == results ? _self._results : results // ignore: cast_nullable_to_non_nullable
|
||||
as List<T>?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'pagination_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_PaginationModel<T> _$PaginationModelFromJson<T>(
|
||||
Map<String, dynamic> json,
|
||||
T Function(Object? json) fromJsonT,
|
||||
) => _PaginationModel<T>(
|
||||
count: (json['count'] as num?)?.toInt(),
|
||||
next: json['next'] as String?,
|
||||
previous: json['previous'] as String?,
|
||||
results: (json['results'] as List<dynamic>?)?.map(fromJsonT).toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PaginationModelToJson<T>(
|
||||
_PaginationModel<T> instance,
|
||||
Object? Function(T value) toJsonT,
|
||||
) => <String, dynamic>{
|
||||
'count': instance.count,
|
||||
'next': instance.next,
|
||||
'previous': instance.previous,
|
||||
'results': instance.results?.map(toJsonT).toList(),
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_core/data/model/pagination_model/pagination_model.dart';
|
||||
|
||||
enum ListType { builder, separated }
|
||||
|
||||
@@ -24,7 +25,7 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
this.physics = const BouncingScrollPhysics(),
|
||||
});
|
||||
|
||||
final Resource<List<T>> resource;
|
||||
final Resource<PaginationModel<T>> resource;
|
||||
final NullableIndexedWidgetBuilder itemBuilder;
|
||||
final IndexedWidgetBuilder? separatorBuilder;
|
||||
final Future<void> Function()? onRefresh;
|
||||
@@ -54,7 +55,7 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
return errorWidget ?? Center(child: Text(resource.message ?? 'خطا'));
|
||||
}
|
||||
|
||||
if (resource.isEmpty || resource.data?.isEmpty == true) {
|
||||
if (resource.isEmpty || resource.data?.results?.isEmpty == true) {
|
||||
return emptyWidget ?? const EmptyWidget();
|
||||
}
|
||||
|
||||
@@ -80,9 +81,12 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
itemCount: itemCount + (isPaginating ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (isPaginating && index == itemCount) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(child: CupertinoActivityIndicator()),
|
||||
return SizedBox(
|
||||
height: 50,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(child: CupertinoActivityIndicator()),
|
||||
),
|
||||
);
|
||||
}
|
||||
return itemBuilder(context, index);
|
||||
@@ -96,9 +100,12 @@ class RPaginatedListView<T> extends StatelessWidget {
|
||||
itemCount: itemCount + (isPaginating ? 1 : 0),
|
||||
itemBuilder: (context, index) {
|
||||
if (isPaginating && index == itemCount) {
|
||||
return const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(child: CupertinoActivityIndicator()),
|
||||
return SizedBox(
|
||||
height: 50,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(16),
|
||||
child: Center(child: CupertinoActivityIndicator()),
|
||||
),
|
||||
);
|
||||
}
|
||||
return itemBuilder(context, index);
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
enum Status {
|
||||
initial,
|
||||
loading,
|
||||
success,
|
||||
error,
|
||||
empty,
|
||||
}
|
||||
|
||||
enum Status { initial, loading, success, error, empty }
|
||||
|
||||
class Resource<T> {
|
||||
final Status status;
|
||||
final T? data;
|
||||
final String? message;
|
||||
|
||||
const Resource._({
|
||||
required this.status,
|
||||
this.data,
|
||||
this.message,
|
||||
});
|
||||
const Resource._({required this.status, this.data, this.message});
|
||||
|
||||
const Resource.initial() : this._(status: Status.initial);
|
||||
|
||||
@@ -28,7 +17,6 @@ class Resource<T> {
|
||||
|
||||
const Resource.empty() : this._(status: Status.empty);
|
||||
|
||||
|
||||
bool get isInitial => status == Status.initial;
|
||||
|
||||
bool get isLoading => status == Status.loading;
|
||||
@@ -43,4 +31,4 @@ class Resource<T> {
|
||||
String toString() {
|
||||
return 'Resource{status: $status, data: $data, message: $message}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user