From f571a5b646a48d5c297593a492be1afca63e1a36 Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Tue, 5 Aug 2025 14:49:01 +0330 Subject: [PATCH] feat : request tagging --- .../response/address/address.freezed.dart | 650 ++++++++++ .../model/response/address/address.g.dart | 81 ++ .../page/request_tagging/view.dart | 1081 +++++++++++++++-- .../presentation/widgets/base_page/view.dart | 30 +- 4 files changed, 1707 insertions(+), 135 deletions(-) create mode 100644 packages/livestock/lib/data/model/response/address/address.freezed.dart create mode 100644 packages/livestock/lib/data/model/response/address/address.g.dart diff --git a/packages/livestock/lib/data/model/response/address/address.freezed.dart b/packages/livestock/lib/data/model/response/address/address.freezed.dart new file mode 100644 index 0000000..425bb41 --- /dev/null +++ b/packages/livestock/lib/data/model/response/address/address.freezed.dart @@ -0,0 +1,650 @@ +// 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 'address.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$Address { + + String? get road; String? get neighbourhood; String? get suburb; String? get state; String? get borough; String? get city; String? get district; String? get county; String? get province; String? get ISO3166_2_lvl4; String? get postcode; String? get country; String? get country_code; +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$AddressCopyWith
get copyWith => _$AddressCopyWithImpl
(this as Address, _$identity); + + /// Serializes this Address to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Address&&(identical(other.road, road) || other.road == road)&&(identical(other.neighbourhood, neighbourhood) || other.neighbourhood == neighbourhood)&&(identical(other.suburb, suburb) || other.suburb == suburb)&&(identical(other.state, state) || other.state == state)&&(identical(other.borough, borough) || other.borough == borough)&&(identical(other.city, city) || other.city == city)&&(identical(other.district, district) || other.district == district)&&(identical(other.county, county) || other.county == county)&&(identical(other.province, province) || other.province == province)&&(identical(other.ISO3166_2_lvl4, ISO3166_2_lvl4) || other.ISO3166_2_lvl4 == ISO3166_2_lvl4)&&(identical(other.postcode, postcode) || other.postcode == postcode)&&(identical(other.country, country) || other.country == country)&&(identical(other.country_code, country_code) || other.country_code == country_code)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,road,neighbourhood,suburb,state,borough,city,district,county,province,ISO3166_2_lvl4,postcode,country,country_code); + +@override +String toString() { + return 'Address(road: $road, neighbourhood: $neighbourhood, suburb: $suburb, state: $state, borough: $borough, city: $city, district: $district, county: $county, province: $province, ISO3166_2_lvl4: $ISO3166_2_lvl4, postcode: $postcode, country: $country, country_code: $country_code)'; +} + + +} + +/// @nodoc +abstract mixin class $AddressCopyWith<$Res> { + factory $AddressCopyWith(Address value, $Res Function(Address) _then) = _$AddressCopyWithImpl; +@useResult +$Res call({ + String? road, String? neighbourhood, String? suburb, String? state, String? borough, String? city, String? district, String? county, String? province, String? ISO3166_2_lvl4, String? postcode, String? country, String? country_code +}); + + + + +} +/// @nodoc +class _$AddressCopyWithImpl<$Res> + implements $AddressCopyWith<$Res> { + _$AddressCopyWithImpl(this._self, this._then); + + final Address _self; + final $Res Function(Address) _then; + +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? road = freezed,Object? neighbourhood = freezed,Object? suburb = freezed,Object? state = freezed,Object? borough = freezed,Object? city = freezed,Object? district = freezed,Object? county = freezed,Object? province = freezed,Object? ISO3166_2_lvl4 = freezed,Object? postcode = freezed,Object? country = freezed,Object? country_code = freezed,}) { + return _then(_self.copyWith( +road: freezed == road ? _self.road : road // ignore: cast_nullable_to_non_nullable +as String?,neighbourhood: freezed == neighbourhood ? _self.neighbourhood : neighbourhood // ignore: cast_nullable_to_non_nullable +as String?,suburb: freezed == suburb ? _self.suburb : suburb // ignore: cast_nullable_to_non_nullable +as String?,state: freezed == state ? _self.state : state // ignore: cast_nullable_to_non_nullable +as String?,borough: freezed == borough ? _self.borough : borough // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable +as String?,district: freezed == district ? _self.district : district // ignore: cast_nullable_to_non_nullable +as String?,county: freezed == county ? _self.county : county // ignore: cast_nullable_to_non_nullable +as String?,province: freezed == province ? _self.province : province // ignore: cast_nullable_to_non_nullable +as String?,ISO3166_2_lvl4: freezed == ISO3166_2_lvl4 ? _self.ISO3166_2_lvl4 : ISO3166_2_lvl4 // ignore: cast_nullable_to_non_nullable +as String?,postcode: freezed == postcode ? _self.postcode : postcode // ignore: cast_nullable_to_non_nullable +as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable +as String?,country_code: freezed == country_code ? _self.country_code : country_code // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [Address]. +extension AddressPatterns on Address { +/// 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( _Address value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Address() 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( _Address value) $default,){ +final _that = this; +switch (_that) { +case _Address(): +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( _Address value)? $default,){ +final _that = this; +switch (_that) { +case _Address() 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( String? road, String? neighbourhood, String? suburb, String? state, String? borough, String? city, String? district, String? county, String? province, String? ISO3166_2_lvl4, String? postcode, String? country, String? country_code)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Address() when $default != null: +return $default(_that.road,_that.neighbourhood,_that.suburb,_that.state,_that.borough,_that.city,_that.district,_that.county,_that.province,_that.ISO3166_2_lvl4,_that.postcode,_that.country,_that.country_code);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( String? road, String? neighbourhood, String? suburb, String? state, String? borough, String? city, String? district, String? county, String? province, String? ISO3166_2_lvl4, String? postcode, String? country, String? country_code) $default,) {final _that = this; +switch (_that) { +case _Address(): +return $default(_that.road,_that.neighbourhood,_that.suburb,_that.state,_that.borough,_that.city,_that.district,_that.county,_that.province,_that.ISO3166_2_lvl4,_that.postcode,_that.country,_that.country_code);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( String? road, String? neighbourhood, String? suburb, String? state, String? borough, String? city, String? district, String? county, String? province, String? ISO3166_2_lvl4, String? postcode, String? country, String? country_code)? $default,) {final _that = this; +switch (_that) { +case _Address() when $default != null: +return $default(_that.road,_that.neighbourhood,_that.suburb,_that.state,_that.borough,_that.city,_that.district,_that.county,_that.province,_that.ISO3166_2_lvl4,_that.postcode,_that.country,_that.country_code);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _Address implements Address { + const _Address({this.road, this.neighbourhood, this.suburb, this.state, this.borough, this.city, this.district, this.county, this.province, this.ISO3166_2_lvl4, this.postcode, this.country, this.country_code}); + factory _Address.fromJson(Map json) => _$AddressFromJson(json); + +@override final String? road; +@override final String? neighbourhood; +@override final String? suburb; +@override final String? state; +@override final String? borough; +@override final String? city; +@override final String? district; +@override final String? county; +@override final String? province; +@override final String? ISO3166_2_lvl4; +@override final String? postcode; +@override final String? country; +@override final String? country_code; + +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AddressCopyWith<_Address> get copyWith => __$AddressCopyWithImpl<_Address>(this, _$identity); + +@override +Map toJson() { + return _$AddressToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Address&&(identical(other.road, road) || other.road == road)&&(identical(other.neighbourhood, neighbourhood) || other.neighbourhood == neighbourhood)&&(identical(other.suburb, suburb) || other.suburb == suburb)&&(identical(other.state, state) || other.state == state)&&(identical(other.borough, borough) || other.borough == borough)&&(identical(other.city, city) || other.city == city)&&(identical(other.district, district) || other.district == district)&&(identical(other.county, county) || other.county == county)&&(identical(other.province, province) || other.province == province)&&(identical(other.ISO3166_2_lvl4, ISO3166_2_lvl4) || other.ISO3166_2_lvl4 == ISO3166_2_lvl4)&&(identical(other.postcode, postcode) || other.postcode == postcode)&&(identical(other.country, country) || other.country == country)&&(identical(other.country_code, country_code) || other.country_code == country_code)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,road,neighbourhood,suburb,state,borough,city,district,county,province,ISO3166_2_lvl4,postcode,country,country_code); + +@override +String toString() { + return 'Address(road: $road, neighbourhood: $neighbourhood, suburb: $suburb, state: $state, borough: $borough, city: $city, district: $district, county: $county, province: $province, ISO3166_2_lvl4: $ISO3166_2_lvl4, postcode: $postcode, country: $country, country_code: $country_code)'; +} + + +} + +/// @nodoc +abstract mixin class _$AddressCopyWith<$Res> implements $AddressCopyWith<$Res> { + factory _$AddressCopyWith(_Address value, $Res Function(_Address) _then) = __$AddressCopyWithImpl; +@override @useResult +$Res call({ + String? road, String? neighbourhood, String? suburb, String? state, String? borough, String? city, String? district, String? county, String? province, String? ISO3166_2_lvl4, String? postcode, String? country, String? country_code +}); + + + + +} +/// @nodoc +class __$AddressCopyWithImpl<$Res> + implements _$AddressCopyWith<$Res> { + __$AddressCopyWithImpl(this._self, this._then); + + final _Address _self; + final $Res Function(_Address) _then; + +/// Create a copy of Address +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? road = freezed,Object? neighbourhood = freezed,Object? suburb = freezed,Object? state = freezed,Object? borough = freezed,Object? city = freezed,Object? district = freezed,Object? county = freezed,Object? province = freezed,Object? ISO3166_2_lvl4 = freezed,Object? postcode = freezed,Object? country = freezed,Object? country_code = freezed,}) { + return _then(_Address( +road: freezed == road ? _self.road : road // ignore: cast_nullable_to_non_nullable +as String?,neighbourhood: freezed == neighbourhood ? _self.neighbourhood : neighbourhood // ignore: cast_nullable_to_non_nullable +as String?,suburb: freezed == suburb ? _self.suburb : suburb // ignore: cast_nullable_to_non_nullable +as String?,state: freezed == state ? _self.state : state // ignore: cast_nullable_to_non_nullable +as String?,borough: freezed == borough ? _self.borough : borough // ignore: cast_nullable_to_non_nullable +as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable +as String?,district: freezed == district ? _self.district : district // ignore: cast_nullable_to_non_nullable +as String?,county: freezed == county ? _self.county : county // ignore: cast_nullable_to_non_nullable +as String?,province: freezed == province ? _self.province : province // ignore: cast_nullable_to_non_nullable +as String?,ISO3166_2_lvl4: freezed == ISO3166_2_lvl4 ? _self.ISO3166_2_lvl4 : ISO3166_2_lvl4 // ignore: cast_nullable_to_non_nullable +as String?,postcode: freezed == postcode ? _self.postcode : postcode // ignore: cast_nullable_to_non_nullable +as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable +as String?,country_code: freezed == country_code ? _self.country_code : country_code // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$LocationDetails { + + int? get place_id; String? get licence; String? get osm_type; int? get osm_id; String? get lat; String? get lon; String? get class_; String? get type; int? get place_rank; double? get importance; String? get addresstype; String? get name; String? get display_name; Address? get address; List? get boundingbox; +/// Create a copy of LocationDetails +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LocationDetailsCopyWith get copyWith => _$LocationDetailsCopyWithImpl(this as LocationDetails, _$identity); + + /// Serializes this LocationDetails to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LocationDetails&&(identical(other.place_id, place_id) || other.place_id == place_id)&&(identical(other.licence, licence) || other.licence == licence)&&(identical(other.osm_type, osm_type) || other.osm_type == osm_type)&&(identical(other.osm_id, osm_id) || other.osm_id == osm_id)&&(identical(other.lat, lat) || other.lat == lat)&&(identical(other.lon, lon) || other.lon == lon)&&(identical(other.class_, class_) || other.class_ == class_)&&(identical(other.type, type) || other.type == type)&&(identical(other.place_rank, place_rank) || other.place_rank == place_rank)&&(identical(other.importance, importance) || other.importance == importance)&&(identical(other.addresstype, addresstype) || other.addresstype == addresstype)&&(identical(other.name, name) || other.name == name)&&(identical(other.display_name, display_name) || other.display_name == display_name)&&(identical(other.address, address) || other.address == address)&&const DeepCollectionEquality().equals(other.boundingbox, boundingbox)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,place_id,licence,osm_type,osm_id,lat,lon,class_,type,place_rank,importance,addresstype,name,display_name,address,const DeepCollectionEquality().hash(boundingbox)); + +@override +String toString() { + return 'LocationDetails(place_id: $place_id, licence: $licence, osm_type: $osm_type, osm_id: $osm_id, lat: $lat, lon: $lon, class_: $class_, type: $type, place_rank: $place_rank, importance: $importance, addresstype: $addresstype, name: $name, display_name: $display_name, address: $address, boundingbox: $boundingbox)'; +} + + +} + +/// @nodoc +abstract mixin class $LocationDetailsCopyWith<$Res> { + factory $LocationDetailsCopyWith(LocationDetails value, $Res Function(LocationDetails) _then) = _$LocationDetailsCopyWithImpl; +@useResult +$Res call({ + int? place_id, String? licence, String? osm_type, int? osm_id, String? lat, String? lon, String? class_, String? type, int? place_rank, double? importance, String? addresstype, String? name, String? display_name, Address? address, List? boundingbox +}); + + +$AddressCopyWith<$Res>? get address; + +} +/// @nodoc +class _$LocationDetailsCopyWithImpl<$Res> + implements $LocationDetailsCopyWith<$Res> { + _$LocationDetailsCopyWithImpl(this._self, this._then); + + final LocationDetails _self; + final $Res Function(LocationDetails) _then; + +/// Create a copy of LocationDetails +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? place_id = freezed,Object? licence = freezed,Object? osm_type = freezed,Object? osm_id = freezed,Object? lat = freezed,Object? lon = freezed,Object? class_ = freezed,Object? type = freezed,Object? place_rank = freezed,Object? importance = freezed,Object? addresstype = freezed,Object? name = freezed,Object? display_name = freezed,Object? address = freezed,Object? boundingbox = freezed,}) { + return _then(_self.copyWith( +place_id: freezed == place_id ? _self.place_id : place_id // ignore: cast_nullable_to_non_nullable +as int?,licence: freezed == licence ? _self.licence : licence // ignore: cast_nullable_to_non_nullable +as String?,osm_type: freezed == osm_type ? _self.osm_type : osm_type // ignore: cast_nullable_to_non_nullable +as String?,osm_id: freezed == osm_id ? _self.osm_id : osm_id // ignore: cast_nullable_to_non_nullable +as int?,lat: freezed == lat ? _self.lat : lat // ignore: cast_nullable_to_non_nullable +as String?,lon: freezed == lon ? _self.lon : lon // ignore: cast_nullable_to_non_nullable +as String?,class_: freezed == class_ ? _self.class_ : class_ // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,place_rank: freezed == place_rank ? _self.place_rank : place_rank // ignore: cast_nullable_to_non_nullable +as int?,importance: freezed == importance ? _self.importance : importance // ignore: cast_nullable_to_non_nullable +as double?,addresstype: freezed == addresstype ? _self.addresstype : addresstype // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,display_name: freezed == display_name ? _self.display_name : display_name // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as Address?,boundingbox: freezed == boundingbox ? _self.boundingbox : boundingbox // ignore: cast_nullable_to_non_nullable +as List?, + )); +} +/// Create a copy of LocationDetails +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$AddressCopyWith<$Res>? get address { + if (_self.address == null) { + return null; + } + + return $AddressCopyWith<$Res>(_self.address!, (value) { + return _then(_self.copyWith(address: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [LocationDetails]. +extension LocationDetailsPatterns on LocationDetails { +/// 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( _LocationDetails value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LocationDetails() 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( _LocationDetails value) $default,){ +final _that = this; +switch (_that) { +case _LocationDetails(): +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( _LocationDetails value)? $default,){ +final _that = this; +switch (_that) { +case _LocationDetails() 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( int? place_id, String? licence, String? osm_type, int? osm_id, String? lat, String? lon, String? class_, String? type, int? place_rank, double? importance, String? addresstype, String? name, String? display_name, Address? address, List? boundingbox)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LocationDetails() when $default != null: +return $default(_that.place_id,_that.licence,_that.osm_type,_that.osm_id,_that.lat,_that.lon,_that.class_,_that.type,_that.place_rank,_that.importance,_that.addresstype,_that.name,_that.display_name,_that.address,_that.boundingbox);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( int? place_id, String? licence, String? osm_type, int? osm_id, String? lat, String? lon, String? class_, String? type, int? place_rank, double? importance, String? addresstype, String? name, String? display_name, Address? address, List? boundingbox) $default,) {final _that = this; +switch (_that) { +case _LocationDetails(): +return $default(_that.place_id,_that.licence,_that.osm_type,_that.osm_id,_that.lat,_that.lon,_that.class_,_that.type,_that.place_rank,_that.importance,_that.addresstype,_that.name,_that.display_name,_that.address,_that.boundingbox);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( int? place_id, String? licence, String? osm_type, int? osm_id, String? lat, String? lon, String? class_, String? type, int? place_rank, double? importance, String? addresstype, String? name, String? display_name, Address? address, List? boundingbox)? $default,) {final _that = this; +switch (_that) { +case _LocationDetails() when $default != null: +return $default(_that.place_id,_that.licence,_that.osm_type,_that.osm_id,_that.lat,_that.lon,_that.class_,_that.type,_that.place_rank,_that.importance,_that.addresstype,_that.name,_that.display_name,_that.address,_that.boundingbox);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _LocationDetails implements LocationDetails { + const _LocationDetails({this.place_id, this.licence, this.osm_type, this.osm_id, this.lat, this.lon, this.class_, this.type, this.place_rank, this.importance, this.addresstype, this.name, this.display_name, this.address, final List? boundingbox}): _boundingbox = boundingbox; + factory _LocationDetails.fromJson(Map json) => _$LocationDetailsFromJson(json); + +@override final int? place_id; +@override final String? licence; +@override final String? osm_type; +@override final int? osm_id; +@override final String? lat; +@override final String? lon; +@override final String? class_; +@override final String? type; +@override final int? place_rank; +@override final double? importance; +@override final String? addresstype; +@override final String? name; +@override final String? display_name; +@override final Address? address; + final List? _boundingbox; +@override List? get boundingbox { + final value = _boundingbox; + if (value == null) return null; + if (_boundingbox is EqualUnmodifiableListView) return _boundingbox; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + + +/// Create a copy of LocationDetails +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LocationDetailsCopyWith<_LocationDetails> get copyWith => __$LocationDetailsCopyWithImpl<_LocationDetails>(this, _$identity); + +@override +Map toJson() { + return _$LocationDetailsToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LocationDetails&&(identical(other.place_id, place_id) || other.place_id == place_id)&&(identical(other.licence, licence) || other.licence == licence)&&(identical(other.osm_type, osm_type) || other.osm_type == osm_type)&&(identical(other.osm_id, osm_id) || other.osm_id == osm_id)&&(identical(other.lat, lat) || other.lat == lat)&&(identical(other.lon, lon) || other.lon == lon)&&(identical(other.class_, class_) || other.class_ == class_)&&(identical(other.type, type) || other.type == type)&&(identical(other.place_rank, place_rank) || other.place_rank == place_rank)&&(identical(other.importance, importance) || other.importance == importance)&&(identical(other.addresstype, addresstype) || other.addresstype == addresstype)&&(identical(other.name, name) || other.name == name)&&(identical(other.display_name, display_name) || other.display_name == display_name)&&(identical(other.address, address) || other.address == address)&&const DeepCollectionEquality().equals(other._boundingbox, _boundingbox)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,place_id,licence,osm_type,osm_id,lat,lon,class_,type,place_rank,importance,addresstype,name,display_name,address,const DeepCollectionEquality().hash(_boundingbox)); + +@override +String toString() { + return 'LocationDetails(place_id: $place_id, licence: $licence, osm_type: $osm_type, osm_id: $osm_id, lat: $lat, lon: $lon, class_: $class_, type: $type, place_rank: $place_rank, importance: $importance, addresstype: $addresstype, name: $name, display_name: $display_name, address: $address, boundingbox: $boundingbox)'; +} + + +} + +/// @nodoc +abstract mixin class _$LocationDetailsCopyWith<$Res> implements $LocationDetailsCopyWith<$Res> { + factory _$LocationDetailsCopyWith(_LocationDetails value, $Res Function(_LocationDetails) _then) = __$LocationDetailsCopyWithImpl; +@override @useResult +$Res call({ + int? place_id, String? licence, String? osm_type, int? osm_id, String? lat, String? lon, String? class_, String? type, int? place_rank, double? importance, String? addresstype, String? name, String? display_name, Address? address, List? boundingbox +}); + + +@override $AddressCopyWith<$Res>? get address; + +} +/// @nodoc +class __$LocationDetailsCopyWithImpl<$Res> + implements _$LocationDetailsCopyWith<$Res> { + __$LocationDetailsCopyWithImpl(this._self, this._then); + + final _LocationDetails _self; + final $Res Function(_LocationDetails) _then; + +/// Create a copy of LocationDetails +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? place_id = freezed,Object? licence = freezed,Object? osm_type = freezed,Object? osm_id = freezed,Object? lat = freezed,Object? lon = freezed,Object? class_ = freezed,Object? type = freezed,Object? place_rank = freezed,Object? importance = freezed,Object? addresstype = freezed,Object? name = freezed,Object? display_name = freezed,Object? address = freezed,Object? boundingbox = freezed,}) { + return _then(_LocationDetails( +place_id: freezed == place_id ? _self.place_id : place_id // ignore: cast_nullable_to_non_nullable +as int?,licence: freezed == licence ? _self.licence : licence // ignore: cast_nullable_to_non_nullable +as String?,osm_type: freezed == osm_type ? _self.osm_type : osm_type // ignore: cast_nullable_to_non_nullable +as String?,osm_id: freezed == osm_id ? _self.osm_id : osm_id // ignore: cast_nullable_to_non_nullable +as int?,lat: freezed == lat ? _self.lat : lat // ignore: cast_nullable_to_non_nullable +as String?,lon: freezed == lon ? _self.lon : lon // ignore: cast_nullable_to_non_nullable +as String?,class_: freezed == class_ ? _self.class_ : class_ // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,place_rank: freezed == place_rank ? _self.place_rank : place_rank // ignore: cast_nullable_to_non_nullable +as int?,importance: freezed == importance ? _self.importance : importance // ignore: cast_nullable_to_non_nullable +as double?,addresstype: freezed == addresstype ? _self.addresstype : addresstype // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,display_name: freezed == display_name ? _self.display_name : display_name // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as Address?,boundingbox: freezed == boundingbox ? _self._boundingbox : boundingbox // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + +/// Create a copy of LocationDetails +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$AddressCopyWith<$Res>? get address { + if (_self.address == null) { + return null; + } + + return $AddressCopyWith<$Res>(_self.address!, (value) { + return _then(_self.copyWith(address: value)); + }); +} +} + +// dart format on diff --git a/packages/livestock/lib/data/model/response/address/address.g.dart b/packages/livestock/lib/data/model/response/address/address.g.dart new file mode 100644 index 0000000..5cf9150 --- /dev/null +++ b/packages/livestock/lib/data/model/response/address/address.g.dart @@ -0,0 +1,81 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'address.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_Address _$AddressFromJson(Map json) => _Address( + road: json['road'] as String?, + neighbourhood: json['neighbourhood'] as String?, + suburb: json['suburb'] as String?, + state: json['state'] as String?, + borough: json['borough'] as String?, + city: json['city'] as String?, + district: json['district'] as String?, + county: json['county'] as String?, + province: json['province'] as String?, + ISO3166_2_lvl4: json['ISO3166_2_lvl4'] as String?, + postcode: json['postcode'] as String?, + country: json['country'] as String?, + country_code: json['country_code'] as String?, +); + +Map _$AddressToJson(_Address instance) => { + 'road': instance.road, + 'neighbourhood': instance.neighbourhood, + 'suburb': instance.suburb, + 'state': instance.state, + 'borough': instance.borough, + 'city': instance.city, + 'district': instance.district, + 'county': instance.county, + 'province': instance.province, + 'ISO3166_2_lvl4': instance.ISO3166_2_lvl4, + 'postcode': instance.postcode, + 'country': instance.country, + 'country_code': instance.country_code, +}; + +_LocationDetails _$LocationDetailsFromJson(Map json) => + _LocationDetails( + place_id: (json['place_id'] as num?)?.toInt(), + licence: json['licence'] as String?, + osm_type: json['osm_type'] as String?, + osm_id: (json['osm_id'] as num?)?.toInt(), + lat: json['lat'] as String?, + lon: json['lon'] as String?, + class_: json['class_'] as String?, + type: json['type'] as String?, + place_rank: (json['place_rank'] as num?)?.toInt(), + importance: (json['importance'] as num?)?.toDouble(), + addresstype: json['addresstype'] as String?, + name: json['name'] as String?, + display_name: json['display_name'] as String?, + address: json['address'] == null + ? null + : Address.fromJson(json['address'] as Map), + boundingbox: (json['boundingbox'] as List?) + ?.map((e) => e as String) + .toList(), + ); + +Map _$LocationDetailsToJson(_LocationDetails instance) => + { + 'place_id': instance.place_id, + 'licence': instance.licence, + 'osm_type': instance.osm_type, + 'osm_id': instance.osm_id, + 'lat': instance.lat, + 'lon': instance.lon, + 'class_': instance.class_, + 'type': instance.type, + 'place_rank': instance.place_rank, + 'importance': instance.importance, + 'addresstype': instance.addresstype, + 'name': instance.name, + 'display_name': instance.display_name, + 'address': instance.address, + 'boundingbox': instance.boundingbox, + }; diff --git a/packages/livestock/lib/presentation/page/request_tagging/view.dart b/packages/livestock/lib/presentation/page/request_tagging/view.dart index 73ed45c..085d317 100644 --- a/packages/livestock/lib/presentation/page/request_tagging/view.dart +++ b/packages/livestock/lib/presentation/page/request_tagging/view.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart'; -import 'package:rasadyar_livestock/presentation/routes/app_pages.dart'; +import 'package:rasadyar_livestock/presentation/widgets/base_page/view.dart'; import 'logic.dart'; @@ -12,53 +12,59 @@ class RequestTaggingPage extends GetView { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Colors.white, - appBar: RAppBar( - title: 'درخواست پلاک کوبی', - leadingWidth: 40, - leading: Assets.vec.messageAddSvg.svg(width: 12, height: 12), - ), - body: Padding( - padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 15), - child: ObxValue((index) { - return Column( - children: [ - Expanded(child: _buildStep(index.value)), - nextOrPreviousWidget(), - ], + return BasePage( + title: 'درخواست پلاک کوبی', + hasSearch: false, + hasFilter: false, + hasBack: true, + avoidBottomInset: false, + widgets: [ + ObxValue((index) { + return Expanded( + child: Padding(padding: const EdgeInsets.all(8.0), child: _buildStep(index.value)), ); }, controller.currentIndex), - ), + + nextOrPreviousWidget(), + SizedBox(height: 10.h), + ], ); } - Row nextOrPreviousWidget() { - return Row( - spacing: 10, - children: [ - ObxValue( - (data) => Expanded( - flex: 2, - child: RElevated( - height: 40.h, - enabled: data.value, - onPressed: controller.onNext, - child: Text('بعدی'), - backgroundColor: AppColor.blueNormal, + Widget nextOrPreviousWidget() { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + spacing: 10, + children: [ + ObxValue( + (data) => Expanded( + flex: 2, + child: RElevated( + height: 40.h, + onPressed: () { + controller.currentIndex.value++; + }, + enabled: data.value, + // onPressed: controller.onNext, + child: Text('بعدی'), + backgroundColor: AppColor.blueNormal, + ), ), + controller.nextButtonEnabled, ), - controller.nextButtonEnabled, - ), - Expanded( - child: ROutlinedElevated( - enabled: controller.currentIndex.value > 0, - onPressed: controller.onPrevious, - child: Text('قبلی'), - borderColor: AppColor.error, + Expanded( + child: ObxValue((data) { + return ROutlinedElevated( + enabled: data.value > 0, + onPressed: controller.onPrevious, + child: Text('قبلی'), + borderColor: AppColor.error, + ); + }, controller.currentIndex), ), - ), - ], + ], + ), ); } @@ -66,6 +72,10 @@ class RequestTaggingPage extends GetView { switch (index) { case 0: return firstStepWidget(); + case 1: + return secondStepWidget(); + case 2: + return thirdStepWidget(); default: return Center( child: Text( @@ -77,6 +87,50 @@ class RequestTaggingPage extends GetView { } } + //TODO + Future showCropDialog() async { + await Get.dialog( + Dialog( + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + 'آیا نیازی به برش تصویر دارید؟', + style: AppFonts.yekan16Bold, + textAlign: TextAlign.center, + ), + + const SizedBox(height: 24), + + Row( + spacing: 12.w, + children: [ + RElevated( + width: 150.w, + height: 40.h, + onPressed: () async { + Get.back(); + await controller.cropImage(); + }, + child: const Text('بله'), + ), + ROutlinedElevated( + width: 150.w, + onPressed: () => Get.back(), + child: const Text('خیر'), + borderColor: AppColor.error, + ), + ], + ), + ], + ), + ), + ); + } + + //region First Step Widget Widget firstStepWidget() { return Form( child: Column( @@ -160,8 +214,6 @@ class RequestTaggingPage extends GetView { ), ), - Spacer(), - /* RElevated( text: 'ارسال تصویر گله', onPressed: () { @@ -177,40 +229,455 @@ class RequestTaggingPage extends GetView { ); } - Future showCropDialog() async { - await Get.dialog( - Dialog( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + //endregion + + //region Second Step Widget + Widget secondStepWidget() { + return Column( + spacing: 12.h, + children: [ + SizedBox(height: 20), + + Container( + padding: EdgeInsets.all(8.r), + decoration: BoxDecoration( + border: Border.all(color: AppColor.borderColor, width: 1.w), + borderRadius: BorderRadius.circular(8.r), + ), + child: Column( + spacing: 12.h, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row(children: [Text('مشخصات موقعیت', style: AppFonts.yekan16Bold)]), + ObxValue((data) { + if (data.value.status == ResourceStatus.loading || + data.value.status == ResourceStatus.initial) { + return Center(child: CupertinoActivityIndicator()); + } else if (data.value.status == ResourceStatus.error) { + return Center( + child: Column( + children: [ + Text( + 'خطا در دریافت اطلاعات', + style: AppFonts.yekan16.copyWith(color: AppColor.redNormal), + ), + ROutlinedElevated( + onPressed: () async { + await controller.determineCurrentPosition(); + }, + child: Text('تلاش مجدد'), + borderColor: AppColor.error, + ), + ], + ), + ); + } else if (data.value.status == ResourceStatus.success) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + spacing: 8.h, + children: [ + RichText( + text: TextSpan( + children: [ + TextSpan( + text: 'موقعیت مکانی: ', + style: AppFonts.yekan16Bold.copyWith(color: AppColor.textColor), + ), + TextSpan( + text: controller.addressLocationValue.string ?? 'N/A', + style: AppFonts.yekan14.copyWith(color: AppColor.textColor), + ), + ], + ), + ), + Text( + controller.addressDetailsValue.string ?? 'N/A', + style: AppFonts.yekan14.copyWith(color: AppColor.textColor), + ), + ], + ); + } else { + return SizedBox.shrink(); + } + }, controller.addressDetails), + ], + ), + ), + + SizedBox( + width: Get.width, + height: 356.h, + child: Container( + padding: EdgeInsets.all(8.r), + decoration: BoxDecoration( + border: Border.all(color: AppColor.borderColor, width: 1.w), + borderRadius: BorderRadius.circular(8.r), + ), + child: Column( + spacing: 12.h, + children: [ + Row(children: [Text('تصویر گله', style: AppFonts.yekan16Bold)]), + Expanded( + child: Container( + width: Get.width, + decoration: BoxDecoration( + color: AppColor.lightGreyNormal, + borderRadius: BorderRadius.circular(8.r), + ), + child: Center( + child: ObxValue((tmpImage) { + if (tmpImage.value == null) { + return Assets.vec.placeHolderSvg.svg(height: 150.h, width: 200.w); + } else { + return Image.file(File(tmpImage.value!.path), fit: BoxFit.cover); + } + }, controller.herdImage), + ), + ), + ), + GestureDetector( + onTap: () async { + await controller.pickImage(); + await showCropDialog(); + }, + child: Container( + width: Get.width, + height: 40.h, + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + color: AppColor.blueNormal, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + ), + child: Padding( + padding: EdgeInsets.all(10.r), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(' دوربین', style: AppFonts.yekan14.copyWith(color: Colors.white)), + Icon(CupertinoIcons.arrow_up_doc, color: Colors.white), + ], + ), + ), + ), + ), + ], + ), + ), + ), + + Spacer(), + + RElevated( + text: 'ارسال تصویر گله', + onPressed: () {}, + height: 40, + isFullWidth: true, + backgroundColor: AppColor.greenNormal, + textStyle: AppFonts.yekan16.copyWith(color: Colors.white), + ), + ], + ); + } + + //endregion + + //region Third Step Widget + + Widget thirdStepWidget() { + return Stack( + children: [ + Column( + children: [ + _buildFilterWidget(), + _buildSearchWidget(), + _buildInfoDetails(), + _buildListContent(), + SizedBox(height: 10), + + Padding( + padding: const EdgeInsets.fromLTRB(35, 0, 35, 20), + child: RElevated( + text: 'ثبت نهایی و ارسال به اتحادیه', + textStyle: AppFonts.yekan18, + height: 40, + backgroundColor: AppColor.greenNormal, + onPressed: () {}, + isFullWidth: true, + ), + ), + ], + ), + Positioned( + right: 10, + bottom: 75, + child: RFab.add( + onPressed: () { + Get.bottomSheet(_buildBottomSheet(), isScrollControlled: true); + }, + ), + ), + ], + ); + } + + Container _buildInfoDetails() { + return Container( + height: 40.h, + margin: EdgeInsets.symmetric(vertical: 8.h), + decoration: BoxDecoration( + color: AppColor.greenLightHover, + borderRadius: BorderRadius.circular(8.r), + border: Border.all(color: AppColor.darkGreyLight), + ), + alignment: Alignment.center, + child: Text('پلاک شده : سبک 5 و سنگین 8 راس'), + ); + } + + Expanded _buildListContent() { + return Expanded( + child: RListView.separated( + itemCount: 20, + padding: EdgeInsets.symmetric(horizontal: 8.w), + itemBuilder: (BuildContext context, int index) { + return ObxValue((val) { + return ExpandableListItem2( + isTag: true, + selected: val.contains(index), + onTap: () => controller.isExpandedList.toggle(index), + index: index, + child: itemListWidget(index), + secondChild: itemListExpandedWidget(index), + labelColor: AppColor.blueLight, + labelIcon: Assets.vec.virtualSvg.path, + ); + }, controller.isExpandedList); + }, + resource: Resource.success(List.generate(20, (i) => i)), + separatorBuilder: (BuildContext context, int index) => SizedBox(height: 8.h), + ), + ); + } + + Stack _buildItemList(int index) { + return Stack( + clipBehavior: Clip.none, + children: [ + Positioned( + right: -12, + top: 0, + bottom: 0, + child: Container( + width: 30, + height: 30, + child: Stack( + alignment: Alignment.center, + children: [ + Assets.vec.tagLabelSvg.svg(width: 30, height: 30), + Positioned( + bottom: 25, + right: 2, + left: 2, + child: Text( + (index > 10 ? index * 1000 : index + 1).toString(), + textAlign: TextAlign.center, + style: AppFonts.yekan10.copyWith( + fontSize: ((index > 10 ? index * 1000 : index + 1).toString()).length > 3 + ? 6 + : 8, + color: AppColor.blueDarkActive, + ), + textScaler: TextScaler.linear(1.5), + ), + ), + ], + ), + ), + ), + ], + ); + } + + Widget _buildBottomSheet() { + return BaseBottomSheet( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + spacing: 8, + children: [ + _buildLiveStockSpecies(), + _buildLivestockBirthday(), + _buildLivestockGender(), + + _buildLivestockBreed(), + + _buildMotherTagNumber(), + _buildFatherTagNumber(), + _buildTagNumber(), + _buildTagType(), + + _buildLiveStockImage(), + + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: RElevated( + text: 'افزودن دام به گله', + textStyle: AppFonts.yekan18.copyWith(color: Colors.white), + width: Get.width, + backgroundColor: AppColor.greenNormal, + height: 40, + onPressed: () { + Get.back(); + }, + ), + ), + ], + ), + ); + } + + Widget _buildInfoBottomSheet() { + return BaseBottomSheet( + height: Get.height * 0.5, + bgColor: const Color(0xFFF5F5F5), + child: Card( + color: Colors.white, child: Padding( - padding: const EdgeInsets.all(20), + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8), child: Column( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.center, + spacing: 15, children: [ - Text( - 'آیا نیازی به برش تصویر دارید؟', - style: AppFonts.yekan16Bold, - textAlign: TextAlign.center, - ), - - const SizedBox(height: 24), - Row( - mainAxisAlignment: MainAxisAlignment.end, - spacing: 12.w, + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - RElevated( - height: 40.h, - onPressed: () async { - Get.back(); - await controller.cropImage(); - }, - child: const Text('بله'), + Assets.vec.editSvg.svg( + width: 16, + height: 16, + colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), ), - ROutlinedElevated( - onPressed: () => Get.back(), - child: const Text('خیر'), - borderColor: AppColor.error, + Text('محمد احمدی', style: AppFonts.yekan14), + + GestureDetector( + onTap: () { + _buildDeleteDialog(onConfirm: () {}); + }, + child: Assets.vec.trashSvg.svg( + width: 16, + height: 16, + colorFilter: ColorFilter.mode(AppColor.error, BlendMode.srcIn), + ), + ), + ], + ), + Container( + height: 32, + padding: EdgeInsets.all(8), + decoration: BoxDecoration(color: AppColor.blueLightHover), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'تاریخ ثبت', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + Text( + '1404/2/2', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'شماره پلاک', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + Text( + '123456789012346', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'جنسیت ', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + Text( + 'ماده', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'نوع نژاد', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + Text( + 'افشاری', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'نوع گله', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + Text( + 'روستایی', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'شهر', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + Text( + 'کرج', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'سن', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), + ), + Text( + '18 ماه', + textAlign: TextAlign.center, + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark), ), ], ), @@ -221,72 +688,434 @@ class RequestTaggingPage extends GetView { ); } - Column secondStepWidget() { - return Column( - children: [ - RTextField(controller: controller.phoneController, label: 'تلفن دامدار'), + void _buildDeleteDialog({required VoidCallback onConfirm}) { + Get.defaultDialog( + title: 'حذف دام', + middleText: 'آیا از حذف این دام مطمئن هستید؟', + confirm: ElevatedButton( + style: ElevatedButton.styleFrom( + backgroundColor: AppColor.error, + foregroundColor: Colors.white, + ), + onPressed: onConfirm, + child: Text('بله'), + ), + cancel: ElevatedButton( + onPressed: () { + Get.back(); + }, + child: Text('خیر'), + ), + ); + } - SizedBox( - width: Get.width, - height: 356, - child: Card( - color: Colors.white, - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - children: [ - Expanded( - child: Container( - width: Get.width, + SizedBox _buildLiveStockImage() { + return SizedBox( + width: Get.width, + height: 350, + child: Card( + color: Colors.white, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + children: [ + Expanded( + child: Container( + width: Get.width, + decoration: BoxDecoration( + color: AppColor.lightGreyNormal, + borderRadius: BorderRadius.circular(8), + ), + child: Center(child: Assets.images.placeHolder.image(height: 150, width: 200)), + ), + ), + SizedBox(height: 15), + Container( + width: Get.width, + height: 40, + clipBehavior: Clip.antiAlias, + decoration: ShapeDecoration( + color: AppColor.blueNormal, + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), + ), + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text('تصویر دام', style: AppFonts.yekan14.copyWith(color: Colors.white)), + Icon(CupertinoIcons.arrow_up_doc, color: Colors.white), + ], + ), + ), + ), + ], + ), + ), + ), + ); + } - decoration: BoxDecoration( - color: AppColor.lightGreyNormal, - borderRadius: BorderRadius.circular(8), - ), - child: Center( - child: Assets.images.placeHolder.image(height: 150, width: 200), - ), - ), - ), - SizedBox(height: 15), - Container( - width: Get.width, - height: 40, - clipBehavior: Clip.antiAlias, - decoration: ShapeDecoration( - color: AppColor.blueNormal, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)), - ), - child: Padding( - padding: const EdgeInsets.all(10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(' تصویر گله', style: AppFonts.yekan14.copyWith(color: Colors.white)), - Icon(CupertinoIcons.arrow_up_doc, color: Colors.white), - ], - ), - ), - ), - ], + OverlayDropdownWidget _buildTagType() { + return OverlayDropdownWidget( + items: ['نوع پلاک 1', 'نوع پلاک 2', 'نوع پلاک 3'], + onChanged: (value) { + print('Selected Breed: $value'); + }, + itemBuilder: (item) => Text(item), + labelBuilder: (item) => Text(item ?? 'نوع پلاک'), + ); + } + + TextFiledFixedHint _buildTagNumber() { + return TextFiledFixedHint( + inputType: InputType.number, + hintText: 'پلاک دام', + onChanged: (String value) { + eLog('father Tag: $value'); + }, + ); + } + + TextFiledFixedHint _buildFatherTagNumber() { + return TextFiledFixedHint( + inputType: InputType.number, + hintText: 'پلاک پدر ', + onChanged: (String value) { + eLog('father Tag: $value'); + }, + ); + } + + TextFiledFixedHint _buildMotherTagNumber() { + return TextFiledFixedHint( + inputType: InputType.number, + hintText: 'پلاک مادر ', + onChanged: (String value) { + eLog('Mother Tag: $value'); + }, + ); + } + + OverlayDropdownWidget _buildLivestockBreed() { + return OverlayDropdownWidget( + items: ['نوع نژاد 1', 'نوع نژاد 2', 'نوع نژاد 3'], + onChanged: (value) { + print('Selected Breed: $value'); + }, + itemBuilder: (item) => Text(item), + labelBuilder: (item) => Text(item ?? 'نژاد'), + ); + } + + ObxValue _buildLivestockGender() { + return ObxValue( + (data) => CupertinoSlidingSegmentedControl( + children: { + 0: Padding( + padding: const EdgeInsets.symmetric(horizontal: 12), + child: Text( + 'نر', + style: AppFonts.yekan14.copyWith( + color: data.value == 0 ? AppColor.whiteGreyLight : AppColor.darkGreyNormalActive, ), ), ), - ), + 1: Padding( + padding: const EdgeInsets.symmetric(horizontal: 10), + child: Text( + 'ماده', + style: AppFonts.yekan14.copyWith( + color: data.value == 1 ? AppColor.whiteGreyLight : AppColor.darkGreyNormalActive, + ), + ), + ), + }, + onValueChanged: (int? value) { + if (value != null) { + controller.selectedSegment.value = value; + } + }, + proportionalWidth: true, + groupValue: data.value, + thumbColor: AppColor.blueNormal, + backgroundColor: CupertinoColors.systemGrey6, + ), + controller.selectedSegment, + ); + } + + Container _buildLivestockBirthday() { + return Container( + height: 40, + width: Get.width, + padding: const EdgeInsets.symmetric(horizontal: 12), + decoration: BoxDecoration( + border: Border.all(color: AppColor.darkGreyLight), + borderRadius: BorderRadius.circular(8), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + 'تاریخ تولد', + style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyNormalActive), + ), + Text('1404/5/5', style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyNormalActive)), + ], + ), + ); + } + + OverlayDropdownWidget _buildLiveStockSpecies() { + return OverlayDropdownWidget( + items: ['گوسفند ماده', 'گوسفند نر', 'بز ماده', 'بز نر', 'گوساله ماده', 'گوساله نر'], + onChanged: (value) { + print('Selected: $value'); + }, + itemBuilder: (item) => Text(item), + labelBuilder: (item) => Text(item ?? 'گونه دام'), + ); + } + + ObxValue _buildFilterWidget() { + return ObxValue((data) { + return AnimatedContainer( + duration: Duration(milliseconds: 300), + padding: EdgeInsets.only(top: 5), + curve: Curves.easeInOut, + height: data.value ? 50 : 0, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + padding: EdgeInsets.symmetric(horizontal: 12), + child: ObxValue((data) { + return Row( + spacing: 12, + children: [ + CustomChip( + title: 'انتخاب فیلتر', + index: 0, + isSelected: true, + selectedColor: AppColor.blueNormal, + onTap: (index) {}, + ), + + RFilterChips( + title: 'درخواست‌های من', + index: 1, + isSelected: data.contains(1), + selectedColor: AppColor.yellowNormal, + onTap: (index) { + if (data.contains(1)) { + data.remove(1); + } else { + data.add(1); + } + }, + ), + + RFilterChips( + title: 'در انتظار ثبت ', + index: 2, + selectedColor: AppColor.greenLightActive, + isSelected: data.contains(2), + onTap: (index) { + if (data.contains(2)) { + data.remove(2); + } else { + data.add(2); + } + }, + ), + + RFilterChips( + title: 'ارجاع به تعاونی', + index: 3, + selectedColor: AppColor.blueLightHover, + isSelected: data.contains(3), + onTap: (index) { + if (data.contains(3)) { + data.remove(3); + } else { + data.add(3); + } + }, + ), + ], + ); + }, controller.filterSelected), + ), + ); + }, controller.filterIsSelected); + } + + ObxValue _buildSearchWidget() { + return ObxValue((data) { + return AnimatedContainer( + duration: Duration(milliseconds: 300), + padding: EdgeInsets.only(top: 5), + curve: Curves.easeInOut, + height: data.value ? 50 : 0, + child: Visibility( + visible: data.value, + child: Padding( + padding: const EdgeInsets.only(right: 8.0, left: 20.0), + child: RTextField( + suffixIcon: Padding( + padding: const EdgeInsets.all(12.0), + child: Assets.vec.searchSvg.svg( + width: 10, + height: 10, + colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), + ), + ), + hintText: 'جستجو', + onChanged: (value) { + //controller.search(value); + }, + controller: TextEditingController(), + ), + ), + ), + ); + }, controller.searchIsSelected); + } + + Row itemListWidget(int index) { + return Row( + children: [ + SizedBox(width: 30), + Text('123456789012346', style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal)), Spacer(), - - RElevated( - text: 'ارسال تصویر گله', - onPressed: () { - Get.toNamed(LiveStockRoutes.tagging); - }, - height: 40, - isFullWidth: true, - backgroundColor: AppColor.greenNormal, - textStyle: AppFonts.yekan16.copyWith(color: Colors.white), + Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text('گوسفند ماده', style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal)), + SizedBox(height: 4), + Text('نوع نژاد', style: AppFonts.yekan14.copyWith(color: AppColor.bgDark)), + ], ), + Spacer(), + Text('18 ماه', style: AppFonts.yekan14.copyWith(color: AppColor.darkGreyDark)), + Spacer(), + Assets.vec.scanSvg.svg( + width: 32.w, + height: 32.h, + colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn), + ), + SizedBox(width: 12), ], ); } + + Container itemListExpandedWidget(int index) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 8), + decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)), + child: Column( + spacing: 8, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + 'fullname' ?? 'N/A', + textAlign: TextAlign.center, + style: AppFonts.yekan16.copyWith(color: AppColor.greenDark), + ), + Spacer(), + Text( + 'در انتظار', + textAlign: TextAlign.center, + style: AppFonts.yekan10.copyWith(color: AppColor.darkGreyDark), + ), + SizedBox(width: 7), + Assets.vec.clockSvg.svg(width: 16.w, height: 16.h), + ], + ), + Container( + height: 32, + padding: EdgeInsets.symmetric(horizontal: 8), + decoration: ShapeDecoration( + color: AppColor.blueLight, + shape: RoundedRectangleBorder( + side: BorderSide(width: 1, color: AppColor.blueLightHover), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + spacing: 3, + children: [ + Text( + Jalali.now().formatter.wN ?? 'N/A', + style: AppFonts.yekan14.copyWith(color: AppColor.textColor), + ), + + Text( + '${Jalali.now().formatter.d} ${Jalali.now().formatter.mN ?? 'N/A'}', + style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal), + ), + ], + ), + + Text( + '${Jalali.now().formatter.y}', + style: AppFonts.yekan20.copyWith(color: AppColor.textColor), + ), + + Text( + '${Jalali.now().formatter.tHH}:${Jalali.now().formatter.tMM ?? 'N/A'}', + style: AppFonts.yekan14.copyWith(color: AppColor.textColor), + ), + ], + ), + ), + + buildRow(title: 'مشخصات دام', value: 'مشخصات دام'), + + buildRow(title: 'نژاد', value: 'نژاد'), + buildRow(title: 'وزن خریداری شده', value: ' 10 کیلوگرم'), + buildRow(title: 'قیمت کل', value: '10000'), + Row( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 16.w, + children: [ + ObxValue((data) { + return RElevated( + text: 'تایید', + width: 150.w, + height: 40.h, + isLoading: data.value, + onPressed: () async {}, + textStyle: AppFonts.yekan20.copyWith(color: Colors.white), + backgroundColor: AppColor.greenNormal, + ); + }, controller.tst1), + ROutlinedElevated( + text: 'رد', + textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal), + width: 150.w, + height: 40.h, + onPressed: () { + buildWarningDialog( + title: 'اخطار', + middleText: 'آیا از رد شدن این مورد اطمینان دارید؟', + onConfirm: () async {}, + onRefresh: () async {}, + ); + }, + borderColor: AppColor.redNormal, + ), + ], + ), + ], + ), + ); + } + + //endregion } diff --git a/packages/livestock/lib/presentation/widgets/base_page/view.dart b/packages/livestock/lib/presentation/widgets/base_page/view.dart index adeea02..e9e42dd 100644 --- a/packages/livestock/lib/presentation/widgets/base_page/view.dart +++ b/packages/livestock/lib/presentation/widgets/base_page/view.dart @@ -23,6 +23,9 @@ class BasePage extends StatefulWidget { this.onFilterTap, this.onSearchTap, this.filteringWidget, + this.title, + this.padding, + this.avoidBottomInset = true, }); final List? routes; @@ -37,9 +40,13 @@ class BasePage extends StatefulWidget { final bool hasFilter; final bool hasSearch; final bool isBase; + final bool avoidBottomInset; + final VoidCallback? onBackPressed; final GestureTapCallback? onFilterTap; final GestureTapCallback? onSearchTap; + final String? title; + final EdgeInsets? padding; @override State createState() => _BasePageState(); @@ -115,7 +122,9 @@ class _BasePageState extends State { onPopInvokedWithResult: (didPop, result) => widget.onBackPressed, child: Scaffold( backgroundColor: AppColor.bgLight, + resizeToAvoidBottomInset: widget.avoidBottomInset, appBar: liveStockAppBar( + title: widget.title, hasBack: widget.isBase ? false : widget.hasBack, onBackPressed: widget.onBackPressed, hasFilter: widget.hasFilter, @@ -124,15 +133,18 @@ class _BasePageState extends State { onFilterTap: widget.hasFilter ? _onFilterTap : null, onSearchTap: widget.hasSearch ? () => controller.toggleSearch() : null, ), - body: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - //widget.routesWidget != null ? widget.routesWidget! : buildPageRoute(widget.routes!), - if (!widget.isBase && widget.hasSearch && widget.defaultSearch) ...{ - SearchWidget(onSearchChanged: widget.onSearchChanged), - }, - ...widget.widgets, - ], + body: Padding( + padding: widget.padding ?? const EdgeInsets.all(0.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + //widget.routesWidget != null ? widget.routesWidget! : buildPageRoute(widget.routes!), + if (!widget.isBase && widget.hasSearch && widget.defaultSearch) ...{ + SearchWidget(onSearchChanged: widget.onSearchChanged), + }, + ...widget.widgets, + ], + ), ), floatingActionButtonLocation: widget.floatingActionButtonLocation ?? FloatingActionButtonLocation.startFloat,