1 - AllocatedMadeModel
2 - RSegment widget
3 - buy in province
This commit is contained in:
2025-07-02 16:29:29 +03:30
parent e0ac676f0a
commit d6f7cb4930
19 changed files with 1129 additions and 2021 deletions

View File

@@ -4,26 +4,14 @@ part 'waiting_arrival.freezed.dart';
part 'waiting_arrival.g.dart'; part 'waiting_arrival.g.dart';
@freezed @freezed
abstract class WaitingArrivalModel with _$WaitingArrivalModel { abstract class WaitingArrivalModel with _$WaitingArrivalModel {
factory WaitingArrivalModel({ factory WaitingArrivalModel({
required int count,
String? next,
String? previous,
required List<ResultModel> results,
}) = _WaitingArrivalModel;
factory WaitingArrivalModel.fromJson(Map<String, dynamic> json) => _$WaitingArrivalModelFromJson(json);
}
@freezed
abstract class ResultModel with _$ResultModel {
factory ResultModel({
int? id, int? id,
ProductModel? product, ProductModel? product,
KillHouseModel? killHouse, dynamic killHouse,
dynamic toKillHouse, dynamic toKillHouse,
dynamic steward, StewardModel? steward,
@JsonKey(name: 'to_steward') ToStewardModel? toSteward, StewardModel? toSteward,
dynamic guilds, dynamic guilds,
dynamic toGuilds, dynamic toGuilds,
dynamic toColdHouse, dynamic toColdHouse,
@@ -67,95 +55,88 @@ abstract class ResultModel with _$ResultModel {
bool? calculateStatus, bool? calculateStatus,
bool? temporaryTrash, bool? temporaryTrash,
bool? temporaryDeleted, bool? temporaryDeleted,
bool? overhead,
dynamic createdBy, dynamic createdBy,
dynamic modifiedBy, dynamic modifiedBy,
dynamic wareHouse, dynamic wareHouse,
dynamic stewardWareHouse, dynamic stewardWareHouse,
dynamic car, dynamic car,
dynamic dispenser, dynamic dispenser,
}) = _ResultModel; }) = _WaitingArrivalModel;
factory ResultModel.fromJson(Map<String, dynamic> json) => _$ResultModelFromJson(json); factory WaitingArrivalModel.fromJson(Map<String, dynamic> json) =>
_$WaitingArrivalModelFromJson(json);
} }
@freezed @freezed
abstract class ProductModel with _$ProductModel { abstract class ProductModel with _$ProductModel {
factory ProductModel({ factory ProductModel({String? name, double? weightAverage}) = _ProductModel;
double? weightAverage,
}) = _ProductModel;
factory ProductModel.fromJson(Map<String, dynamic> json) => _$ProductModelFromJson(json); factory ProductModel.fromJson(Map<String, dynamic> json) => _$ProductModelFromJson(json);
} }
@freezed @freezed
abstract class ToStewardModel with _$ToStewardModel { abstract class StewardModel with _$StewardModel {
factory ToStewardModel({ factory StewardModel({
int? id, int? id,
ToStewardUserModel? user, StewardUserModel? user,
AddressModel? address, AddressModel? address,
GuildAreaActivityModel? guildAreaActivity, dynamic guildAreaActivity,
GuildTypeActivityModel? guildTypeActivity, dynamic guildTypeActivity,
List<dynamic>? killHouse, List<dynamic>? killHouse,
List<dynamic>? stewardKillHouse, List<dynamic>? stewardKillHouse,
List<dynamic>? stewards, List<dynamic>? stewards,
GetPosStatusModel? getPosStatus, GetPosStatusModel? getPosStatus,
String? key, String? key,
@JsonKey(name: 'create_date') String? createDate, String? createDate,
@JsonKey(name: 'modify_date') String? modifyDate, String? modifyDate,
bool? trash, bool? trash,
bool? active, bool? active,
int? cityNumber,
String? cityName,
String? guildsId, String? guildsId,
String? licenseNumber, String? licenseNumber,
String? guildsName, String? guildsName,
String? phone,
String? typeActivity, String? typeActivity,
String? areaActivity, String? areaActivity,
int? provinceNumber,
String? provinceName,
bool? steward, bool? steward,
bool? hasPos, bool? hasPos,
int? allocationLimit,
bool? limitationAllocation,
String? provinceAcceptState, String? provinceAcceptState,
}) = _ToStewardModel; bool? stewardActive,
bool? stewardLimitationAllocation,
bool? license,
int? wallet,
List<dynamic>? cars,
List<dynamic>? userLevel,
}) = _StewardModel;
factory ToStewardModel.fromJson(Map<String, dynamic> json) => _$ToStewardModelFromJson(json); factory StewardModel.fromJson(Map<String, dynamic> json) => _$StewardModelFromJson(json);
} }
@freezed @freezed
abstract class ToStewardUserModel with _$ToStewardUserModel { abstract class StewardUserModel with _$StewardUserModel {
factory ToStewardUserModel({ factory StewardUserModel({
String? fullname, String? fullname,
@JsonKey(name: 'first_name') String? firstName, String? firstName,
@JsonKey(name: 'last_name') String? lastName, String? lastName,
String? mobile, String? mobile,
@JsonKey(name: 'national_id') String? nationalId, String? nationalId,
String? city, String? city,
}) = _ToStewardUserModel; }) = _StewardUserModel;
factory ToStewardUserModel.fromJson(Map<String, dynamic> json) => _$ToStewardUserModelFromJson(json); factory StewardUserModel.fromJson(Map<String, dynamic> json) => _$StewardUserModelFromJson(json);
}
@freezed
abstract class ToStewardCityModel with _$ToStewardCityModel {
factory ToStewardCityModel({
String? key,
@JsonKey(name: 'name') String? title,
}) = _ToStewardCityModel;
factory ToStewardCityModel.fromJson(Map<String, dynamic> json) => _$ToStewardCityModelFromJson(json);
}
@freezed
abstract class ToStewardProvinceModel with _$ToStewardProvinceModel {
factory ToStewardProvinceModel({
String? key,
@JsonKey(name: 'name') String? title,
}) = _ToStewardProvinceModel;
factory ToStewardProvinceModel.fromJson(Map<String, dynamic> json) => _$ToStewardProvinceModelFromJson(json);
} }
@freezed @freezed
abstract class AddressModel with _$AddressModel { abstract class AddressModel with _$AddressModel {
factory AddressModel({ factory AddressModel({
ToStewardProvinceModel? province, ProvinceModel? province,
ToStewardCityModel? city, CityModel? city,
String? address, String? address,
String? postalCode, String? postalCode,
}) = _AddressModel; }) = _AddressModel;
@@ -164,103 +145,24 @@ abstract class AddressModel with _$AddressModel {
} }
@freezed @freezed
abstract class GuildAreaActivityModel with _$GuildAreaActivityModel { abstract class ProvinceModel with _$ProvinceModel {
factory GuildAreaActivityModel({ factory ProvinceModel({String? key, String? name}) = _ProvinceModel;
String? key,
String? title,
}) = _GuildAreaActivityModel;
factory GuildAreaActivityModel.fromJson(Map<String, dynamic> json) => _$GuildAreaActivityModelFromJson(json); factory ProvinceModel.fromJson(Map<String, dynamic> json) => _$ProvinceModelFromJson(json);
}
@freezed
abstract class GuildTypeActivityModel with _$GuildTypeActivityModel {
factory GuildTypeActivityModel({
String? key,
String? title,
}) = _GuildTypeActivityModel;
factory GuildTypeActivityModel.fromJson(Map<String, dynamic> json) => _$GuildTypeActivityModelFromJson(json);
}
@freezed
abstract class GetPosStatusModel with _$GetPosStatusModel {
factory GetPosStatusModel({
int? lenActiveSessions,
bool? hasPons,
bool? hasActivePons,
}) = _GetPosStatusModel;
factory GetPosStatusModel.fromJson(Map<String, dynamic> json) => _$GetPosStatusModelFromJson(json);
}
@freezed
abstract class KillHouseModel with _$KillHouseModel {
factory KillHouseModel({
String? key,
@JsonKey(name: 'kill_house_operator') KillHouseOperatorModel? operator,
String? name,
bool? killer,
}) = _KillHouseModel;
factory KillHouseModel.fromJson(Map<String, dynamic> json) => _$KillHouseModelFromJson(json);
}
@freezed
abstract class KillHouseOperatorModel with _$KillHouseOperatorModel {
factory KillHouseOperatorModel({
UserModel? user,
}) = _KillHouseOperatorModel;
factory KillHouseOperatorModel.fromJson(Map<String, dynamic> json) => _$KillHouseOperatorModelFromJson(json);
}
@freezed
abstract class UserModel with _$UserModel {
factory UserModel({
String? fullname,
String? firstName,
String? lastName,
int? baseOrder,
String? mobile,
String? nationalId,
String? nationalCode,
String? key,
CityModel? city,
String? unitName,
String? unitNationalId,
String? unitRegistrationNumber,
String? unitEconomicalNumber,
String? unitProvince,
String? unitCity,
String? unitPostalCode,
String? unitAddress,
}) = _UserModel;
factory UserModel.fromJson(Map<String, dynamic> json) => _$UserModelFromJson(json);
} }
@freezed @freezed
abstract class CityModel with _$CityModel { abstract class CityModel with _$CityModel {
factory CityModel({ factory CityModel({String? key, String? name}) = _CityModel;
int? id,
String? key,
String? createDate,
String? modifyDate,
bool? trash,
int? provinceIdForeignKey,
int? cityIdKey,
String? name,
double? productPrice,
bool? provinceCenter,
int? cityNumber,
String? cityName,
int? provinceNumber,
String? provinceName,
dynamic createdBy,
dynamic modifiedBy,
int? province,
}) = _CityModel;
factory CityModel.fromJson(Map<String, dynamic> json) => _$CityModelFromJson(json); factory CityModel.fromJson(Map<String, dynamic> json) => _$CityModelFromJson(json);
} }
@freezed
abstract class GetPosStatusModel with _$GetPosStatusModel {
factory GetPosStatusModel({int? lenActiveSessions, bool? hasPons, bool? hasActivePons}) =
_GetPosStatusModel;
factory GetPosStatusModel.fromJson(Map<String, dynamic> json) =>
_$GetPosStatusModelFromJson(json);
}

View File

@@ -6,38 +6,21 @@ part of 'waiting_arrival.dart';
// JsonSerializableGenerator // JsonSerializableGenerator
// ************************************************************************** // **************************************************************************
_WaitingArrivalModel _$WaitingArrivalModelFromJson(Map<String, dynamic> json) => _WaitingArrivalModel _$WaitingArrivalModelFromJson(
_WaitingArrivalModel( Map<String, dynamic> json,
count: (json['count'] as num).toInt(), ) => _WaitingArrivalModel(
next: json['next'] as String?,
previous: json['previous'] as String?,
results: (json['results'] as List<dynamic>)
.map((e) => ResultModel.fromJson(e as Map<String, dynamic>))
.toList(),
);
Map<String, dynamic> _$WaitingArrivalModelToJson(
_WaitingArrivalModel instance,
) => <String, dynamic>{
'count': instance.count,
'next': instance.next,
'previous': instance.previous,
'results': instance.results,
};
_ResultModel _$ResultModelFromJson(Map<String, dynamic> json) => _ResultModel(
id: (json['id'] as num?)?.toInt(), id: (json['id'] as num?)?.toInt(),
product: json['product'] == null product: json['product'] == null
? null ? null
: ProductModel.fromJson(json['product'] as Map<String, dynamic>), : ProductModel.fromJson(json['product'] as Map<String, dynamic>),
killHouse: json['kill_house'] == null killHouse: json['kill_house'],
? null
: KillHouseModel.fromJson(json['kill_house'] as Map<String, dynamic>),
toKillHouse: json['to_kill_house'], toKillHouse: json['to_kill_house'],
steward: json['steward'], steward: json['steward'] == null
? null
: StewardModel.fromJson(json['steward'] as Map<String, dynamic>),
toSteward: json['to_steward'] == null toSteward: json['to_steward'] == null
? null ? null
: ToStewardModel.fromJson(json['to_steward'] as Map<String, dynamic>), : StewardModel.fromJson(json['to_steward'] as Map<String, dynamic>),
guilds: json['guilds'], guilds: json['guilds'],
toGuilds: json['to_guilds'], toGuilds: json['to_guilds'],
toColdHouse: json['to_cold_house'], toColdHouse: json['to_cold_house'],
@@ -83,6 +66,7 @@ _ResultModel _$ResultModelFromJson(Map<String, dynamic> json) => _ResultModel(
calculateStatus: json['calculate_status'] as bool?, calculateStatus: json['calculate_status'] as bool?,
temporaryTrash: json['temporary_trash'] as bool?, temporaryTrash: json['temporary_trash'] as bool?,
temporaryDeleted: json['temporary_deleted'] as bool?, temporaryDeleted: json['temporary_deleted'] as bool?,
overhead: json['overhead'] as bool?,
createdBy: json['created_by'], createdBy: json['created_by'],
modifiedBy: json['modified_by'], modifiedBy: json['modified_by'],
wareHouse: json['ware_house'], wareHouse: json['ware_house'],
@@ -91,8 +75,8 @@ _ResultModel _$ResultModelFromJson(Map<String, dynamic> json) => _ResultModel(
dispenser: json['dispenser'], dispenser: json['dispenser'],
); );
Map<String, dynamic> _$ResultModelToJson( Map<String, dynamic> _$WaitingArrivalModelToJson(
_ResultModel instance, _WaitingArrivalModel instance,
) => <String, dynamic>{ ) => <String, dynamic>{
'id': instance.id, 'id': instance.id,
'product': instance.product, 'product': instance.product,
@@ -143,6 +127,7 @@ Map<String, dynamic> _$ResultModelToJson(
'calculate_status': instance.calculateStatus, 'calculate_status': instance.calculateStatus,
'temporary_trash': instance.temporaryTrash, 'temporary_trash': instance.temporaryTrash,
'temporary_deleted': instance.temporaryDeleted, 'temporary_deleted': instance.temporaryDeleted,
'overhead': instance.overhead,
'created_by': instance.createdBy, 'created_by': instance.createdBy,
'modified_by': instance.modifiedBy, 'modified_by': instance.modifiedBy,
'ware_house': instance.wareHouse, 'ware_house': instance.wareHouse,
@@ -152,30 +137,28 @@ Map<String, dynamic> _$ResultModelToJson(
}; };
_ProductModel _$ProductModelFromJson(Map<String, dynamic> json) => _ProductModel _$ProductModelFromJson(Map<String, dynamic> json) =>
_ProductModel(weightAverage: (json['weight_average'] as num?)?.toDouble()); _ProductModel(
name: json['name'] as String?,
weightAverage: (json['weight_average'] as num?)?.toDouble(),
);
Map<String, dynamic> _$ProductModelToJson(_ProductModel instance) => Map<String, dynamic> _$ProductModelToJson(_ProductModel instance) =>
<String, dynamic>{'weight_average': instance.weightAverage}; <String, dynamic>{
'name': instance.name,
'weight_average': instance.weightAverage,
};
_ToStewardModel _$ToStewardModelFromJson(Map<String, dynamic> json) => _StewardModel _$StewardModelFromJson(Map<String, dynamic> json) =>
_ToStewardModel( _StewardModel(
id: (json['id'] as num?)?.toInt(), id: (json['id'] as num?)?.toInt(),
user: json['user'] == null user: json['user'] == null
? null ? null
: ToStewardUserModel.fromJson(json['user'] as Map<String, dynamic>), : StewardUserModel.fromJson(json['user'] as Map<String, dynamic>),
address: json['address'] == null address: json['address'] == null
? null ? null
: AddressModel.fromJson(json['address'] as Map<String, dynamic>), : AddressModel.fromJson(json['address'] as Map<String, dynamic>),
guildAreaActivity: json['guild_area_activity'] == null guildAreaActivity: json['guild_area_activity'],
? null guildTypeActivity: json['guild_type_activity'],
: GuildAreaActivityModel.fromJson(
json['guild_area_activity'] as Map<String, dynamic>,
),
guildTypeActivity: json['guild_type_activity'] == null
? null
: GuildTypeActivityModel.fromJson(
json['guild_type_activity'] as Map<String, dynamic>,
),
killHouse: json['kill_house'] as List<dynamic>?, killHouse: json['kill_house'] as List<dynamic>?,
stewardKillHouse: json['steward_kill_house'] as List<dynamic>?, stewardKillHouse: json['steward_kill_house'] as List<dynamic>?,
stewards: json['stewards'] as List<dynamic>?, stewards: json['stewards'] as List<dynamic>?,
@@ -189,17 +172,31 @@ _ToStewardModel _$ToStewardModelFromJson(Map<String, dynamic> json) =>
modifyDate: json['modify_date'] as String?, modifyDate: json['modify_date'] as String?,
trash: json['trash'] as bool?, trash: json['trash'] as bool?,
active: json['active'] as bool?, active: json['active'] as bool?,
cityNumber: (json['city_number'] as num?)?.toInt(),
cityName: json['city_name'] as String?,
guildsId: json['guilds_id'] as String?, guildsId: json['guilds_id'] as String?,
licenseNumber: json['license_number'] as String?, licenseNumber: json['license_number'] as String?,
guildsName: json['guilds_name'] as String?, guildsName: json['guilds_name'] as String?,
phone: json['phone'] as String?,
typeActivity: json['type_activity'] as String?, typeActivity: json['type_activity'] as String?,
areaActivity: json['area_activity'] as String?, areaActivity: json['area_activity'] as String?,
provinceNumber: (json['province_number'] as num?)?.toInt(),
provinceName: json['province_name'] as String?,
steward: json['steward'] as bool?, steward: json['steward'] as bool?,
hasPos: json['has_pos'] as bool?, hasPos: json['has_pos'] as bool?,
allocationLimit: (json['allocation_limit'] as num?)?.toInt(),
limitationAllocation: json['limitation_allocation'] as bool?,
provinceAcceptState: json['province_accept_state'] as String?, provinceAcceptState: json['province_accept_state'] as String?,
stewardActive: json['steward_active'] as bool?,
stewardLimitationAllocation:
json['steward_limitation_allocation'] as bool?,
license: json['license'] as bool?,
wallet: (json['wallet'] as num?)?.toInt(),
cars: json['cars'] as List<dynamic>?,
userLevel: json['user_level'] as List<dynamic>?,
); );
Map<String, dynamic> _$ToStewardModelToJson(_ToStewardModel instance) => Map<String, dynamic> _$StewardModelToJson(_StewardModel instance) =>
<String, dynamic>{ <String, dynamic>{
'id': instance.id, 'id': instance.id,
'user': instance.user, 'user': instance.user,
@@ -215,18 +212,31 @@ Map<String, dynamic> _$ToStewardModelToJson(_ToStewardModel instance) =>
'modify_date': instance.modifyDate, 'modify_date': instance.modifyDate,
'trash': instance.trash, 'trash': instance.trash,
'active': instance.active, 'active': instance.active,
'city_number': instance.cityNumber,
'city_name': instance.cityName,
'guilds_id': instance.guildsId, 'guilds_id': instance.guildsId,
'license_number': instance.licenseNumber, 'license_number': instance.licenseNumber,
'guilds_name': instance.guildsName, 'guilds_name': instance.guildsName,
'phone': instance.phone,
'type_activity': instance.typeActivity, 'type_activity': instance.typeActivity,
'area_activity': instance.areaActivity, 'area_activity': instance.areaActivity,
'province_number': instance.provinceNumber,
'province_name': instance.provinceName,
'steward': instance.steward, 'steward': instance.steward,
'has_pos': instance.hasPos, 'has_pos': instance.hasPos,
'allocation_limit': instance.allocationLimit,
'limitation_allocation': instance.limitationAllocation,
'province_accept_state': instance.provinceAcceptState, 'province_accept_state': instance.provinceAcceptState,
'steward_active': instance.stewardActive,
'steward_limitation_allocation': instance.stewardLimitationAllocation,
'license': instance.license,
'wallet': instance.wallet,
'cars': instance.cars,
'user_level': instance.userLevel,
}; };
_ToStewardUserModel _$ToStewardUserModelFromJson(Map<String, dynamic> json) => _StewardUserModel _$StewardUserModelFromJson(Map<String, dynamic> json) =>
_ToStewardUserModel( _StewardUserModel(
fullname: json['fullname'] as String?, fullname: json['fullname'] as String?,
firstName: json['first_name'] as String?, firstName: json['first_name'] as String?,
lastName: json['last_name'] as String?, lastName: json['last_name'] as String?,
@@ -235,7 +245,7 @@ _ToStewardUserModel _$ToStewardUserModelFromJson(Map<String, dynamic> json) =>
city: json['city'] as String?, city: json['city'] as String?,
); );
Map<String, dynamic> _$ToStewardUserModelToJson(_ToStewardUserModel instance) => Map<String, dynamic> _$StewardUserModelToJson(_StewardUserModel instance) =>
<String, dynamic>{ <String, dynamic>{
'fullname': instance.fullname, 'fullname': instance.fullname,
'first_name': instance.firstName, 'first_name': instance.firstName,
@@ -245,36 +255,14 @@ Map<String, dynamic> _$ToStewardUserModelToJson(_ToStewardUserModel instance) =>
'city': instance.city, 'city': instance.city,
}; };
_ToStewardCityModel _$ToStewardCityModelFromJson(Map<String, dynamic> json) =>
_ToStewardCityModel(
key: json['key'] as String?,
title: json['name'] as String?,
);
Map<String, dynamic> _$ToStewardCityModelToJson(_ToStewardCityModel instance) =>
<String, dynamic>{'key': instance.key, 'name': instance.title};
_ToStewardProvinceModel _$ToStewardProvinceModelFromJson(
Map<String, dynamic> json,
) => _ToStewardProvinceModel(
key: json['key'] as String?,
title: json['name'] as String?,
);
Map<String, dynamic> _$ToStewardProvinceModelToJson(
_ToStewardProvinceModel instance,
) => <String, dynamic>{'key': instance.key, 'name': instance.title};
_AddressModel _$AddressModelFromJson(Map<String, dynamic> json) => _AddressModel _$AddressModelFromJson(Map<String, dynamic> json) =>
_AddressModel( _AddressModel(
province: json['province'] == null province: json['province'] == null
? null ? null
: ToStewardProvinceModel.fromJson( : ProvinceModel.fromJson(json['province'] as Map<String, dynamic>),
json['province'] as Map<String, dynamic>,
),
city: json['city'] == null city: json['city'] == null
? null ? null
: ToStewardCityModel.fromJson(json['city'] as Map<String, dynamic>), : CityModel.fromJson(json['city'] as Map<String, dynamic>),
address: json['address'] as String?, address: json['address'] as String?,
postalCode: json['postal_code'] as String?, postalCode: json['postal_code'] as String?,
); );
@@ -287,27 +275,17 @@ Map<String, dynamic> _$AddressModelToJson(_AddressModel instance) =>
'postal_code': instance.postalCode, 'postal_code': instance.postalCode,
}; };
_GuildAreaActivityModel _$GuildAreaActivityModelFromJson( _ProvinceModel _$ProvinceModelFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> json, _ProvinceModel(key: json['key'] as String?, name: json['name'] as String?);
) => _GuildAreaActivityModel(
key: json['key'] as String?,
title: json['title'] as String?,
);
Map<String, dynamic> _$GuildAreaActivityModelToJson( Map<String, dynamic> _$ProvinceModelToJson(_ProvinceModel instance) =>
_GuildAreaActivityModel instance, <String, dynamic>{'key': instance.key, 'name': instance.name};
) => <String, dynamic>{'key': instance.key, 'title': instance.title};
_GuildTypeActivityModel _$GuildTypeActivityModelFromJson( _CityModel _$CityModelFromJson(Map<String, dynamic> json) =>
Map<String, dynamic> json, _CityModel(key: json['key'] as String?, name: json['name'] as String?);
) => _GuildTypeActivityModel(
key: json['key'] as String?,
title: json['title'] as String?,
);
Map<String, dynamic> _$GuildTypeActivityModelToJson( Map<String, dynamic> _$CityModelToJson(_CityModel instance) =>
_GuildTypeActivityModel instance, <String, dynamic>{'key': instance.key, 'name': instance.name};
) => <String, dynamic>{'key': instance.key, 'title': instance.title};
_GetPosStatusModel _$GetPosStatusModelFromJson(Map<String, dynamic> json) => _GetPosStatusModel _$GetPosStatusModelFromJson(Map<String, dynamic> json) =>
_GetPosStatusModel( _GetPosStatusModel(
@@ -322,119 +300,3 @@ Map<String, dynamic> _$GetPosStatusModelToJson(_GetPosStatusModel instance) =>
'has_pons': instance.hasPons, 'has_pons': instance.hasPons,
'has_active_pons': instance.hasActivePons, 'has_active_pons': instance.hasActivePons,
}; };
_KillHouseModel _$KillHouseModelFromJson(Map<String, dynamic> json) =>
_KillHouseModel(
key: json['key'] as String?,
operator: json['kill_house_operator'] == null
? null
: KillHouseOperatorModel.fromJson(
json['kill_house_operator'] as Map<String, dynamic>,
),
name: json['name'] as String?,
killer: json['killer'] as bool?,
);
Map<String, dynamic> _$KillHouseModelToJson(_KillHouseModel instance) =>
<String, dynamic>{
'key': instance.key,
'kill_house_operator': instance.operator,
'name': instance.name,
'killer': instance.killer,
};
_KillHouseOperatorModel _$KillHouseOperatorModelFromJson(
Map<String, dynamic> json,
) => _KillHouseOperatorModel(
user: json['user'] == null
? null
: UserModel.fromJson(json['user'] as Map<String, dynamic>),
);
Map<String, dynamic> _$KillHouseOperatorModelToJson(
_KillHouseOperatorModel instance,
) => <String, dynamic>{'user': instance.user};
_UserModel _$UserModelFromJson(Map<String, dynamic> json) => _UserModel(
fullname: json['fullname'] as String?,
firstName: json['first_name'] as String?,
lastName: json['last_name'] as String?,
baseOrder: (json['base_order'] as num?)?.toInt(),
mobile: json['mobile'] as String?,
nationalId: json['national_id'] as String?,
nationalCode: json['national_code'] as String?,
key: json['key'] as String?,
city: json['city'] == null
? null
: CityModel.fromJson(json['city'] as Map<String, dynamic>),
unitName: json['unit_name'] as String?,
unitNationalId: json['unit_national_id'] as String?,
unitRegistrationNumber: json['unit_registration_number'] as String?,
unitEconomicalNumber: json['unit_economical_number'] as String?,
unitProvince: json['unit_province'] as String?,
unitCity: json['unit_city'] as String?,
unitPostalCode: json['unit_postal_code'] as String?,
unitAddress: json['unit_address'] as String?,
);
Map<String, dynamic> _$UserModelToJson(_UserModel instance) =>
<String, dynamic>{
'fullname': instance.fullname,
'first_name': instance.firstName,
'last_name': instance.lastName,
'base_order': instance.baseOrder,
'mobile': instance.mobile,
'national_id': instance.nationalId,
'national_code': instance.nationalCode,
'key': instance.key,
'city': instance.city,
'unit_name': instance.unitName,
'unit_national_id': instance.unitNationalId,
'unit_registration_number': instance.unitRegistrationNumber,
'unit_economical_number': instance.unitEconomicalNumber,
'unit_province': instance.unitProvince,
'unit_city': instance.unitCity,
'unit_postal_code': instance.unitPostalCode,
'unit_address': instance.unitAddress,
};
_CityModel _$CityModelFromJson(Map<String, dynamic> json) => _CityModel(
id: (json['id'] as num?)?.toInt(),
key: json['key'] as String?,
createDate: json['create_date'] as String?,
modifyDate: json['modify_date'] as String?,
trash: json['trash'] as bool?,
provinceIdForeignKey: (json['province_id_foreign_key'] as num?)?.toInt(),
cityIdKey: (json['city_id_key'] as num?)?.toInt(),
name: json['name'] as String?,
productPrice: (json['product_price'] as num?)?.toDouble(),
provinceCenter: json['province_center'] as bool?,
cityNumber: (json['city_number'] as num?)?.toInt(),
cityName: json['city_name'] as String?,
provinceNumber: (json['province_number'] as num?)?.toInt(),
provinceName: json['province_name'] as String?,
createdBy: json['created_by'],
modifiedBy: json['modified_by'],
province: (json['province'] as num?)?.toInt(),
);
Map<String, dynamic> _$CityModelToJson(_CityModel instance) =>
<String, dynamic>{
'id': instance.id,
'key': instance.key,
'create_date': instance.createDate,
'modify_date': instance.modifyDate,
'trash': instance.trash,
'province_id_foreign_key': instance.provinceIdForeignKey,
'city_id_key': instance.cityIdKey,
'name': instance.name,
'product_price': instance.productPrice,
'province_center': instance.provinceCenter,
'city_number': instance.cityNumber,
'city_name': instance.cityName,
'province_number': instance.provinceNumber,
'province_name': instance.provinceName,
'created_by': instance.createdBy,
'modified_by': instance.modifiedBy,
'province': instance.province,
};

View File

@@ -33,9 +33,9 @@ abstract class ChickenRepository {
Map<String, dynamic>? queryParameters, Map<String, dynamic>? queryParameters,
}); });
Future<WaitingArrivalModel?> getWaitingArrivals({ Future<PaginationModel<WaitingArrivalModel>?> getWaitingArrivals({
required String token, required String token,
int? page, Map<String, dynamic>? queryParameters,
}); });
Future<void> setSateForArrivals({ Future<void> setSateForArrivals({

View File

@@ -33,18 +33,15 @@ class ChickenRepositoryImpl implements ChickenRepository {
var res = await _httpClient.get( var res = await _httpClient.get(
'/roles-products/?role=Steward', '/roles-products/?role=Steward',
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
fromJsonList: (json) => (json) fromJsonList: (json) =>
.map((item) => InventoryModel.fromJson(item as Map<String, dynamic>)) (json).map((item) => InventoryModel.fromJson(item as Map<String, dynamic>)).toList(),
.toList(),
); );
return res.data; return res.data;
} }
@override @override
Future<KillHouseDistributionInfo?> getKillHouseDistributionInfo({ Future<KillHouseDistributionInfo?> getKillHouseDistributionInfo({required String token}) async {
required String token,
}) async {
var res = await _httpClient.get( var res = await _httpClient.get(
'/kill-house-distribution-info/?role=Steward', '/kill-house-distribution-info/?role=Steward',
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
@@ -69,14 +66,18 @@ class ChickenRepositoryImpl implements ChickenRepository {
} }
@override @override
Future<WaitingArrivalModel?> getWaitingArrivals({ Future<PaginationModel<WaitingArrivalModel>?> getWaitingArrivals({
required String token, required String token,
int? page, Map<String, dynamic>? queryParameters,
}) async { }) async {
var res = await _httpClient.get( var res = await _httpClient.get(
'/steward-allocation/?search=filter&value=&role=Steward&page=${page ?? 1}&page_size=10&type=not_entered', '/steward-allocation/',
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
fromJson: WaitingArrivalModel.fromJson, queryParameters: queryParameters,
fromJson: (json) => PaginationModel<WaitingArrivalModel>.fromJson(
json,
(json) => WaitingArrivalModel.fromJson(json as Map<String, dynamic>),
),
); );
return res.data; return res.data;
} }
@@ -136,10 +137,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
} }
@override @override
Future<void> denyAllocation({ Future<void> denyAllocation({required String token, required String allocationToken}) async {
required String token,
required String allocationToken,
}) async {
await _httpClient.delete( await _httpClient.delete(
'/steward-allocation/0/?steward_allocation_key=$allocationToken', '/steward-allocation/0/?steward_allocation_key=$allocationToken',
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
@@ -163,9 +161,8 @@ class ChickenRepositoryImpl implements ChickenRepository {
var res = await _httpClient.get( var res = await _httpClient.get(
'/roles-products/?role=Steward', '/roles-products/?role=Steward',
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
fromJsonList: (json) => json fromJsonList: (json) =>
.map((item) => ProductModel.fromJson(item as Map<String, dynamic>)) json.map((item) => ProductModel.fromJson(item as Map<String, dynamic>)).toList(),
.toList(),
); );
return res.data; return res.data;
} }
@@ -179,9 +176,8 @@ class ChickenRepositoryImpl implements ChickenRepository {
'/guilds/?', '/guilds/?',
queryParameters: queryParameters, queryParameters: queryParameters,
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
fromJsonList: (json) => json fromJsonList: (json) =>
.map((item) => GuildModel.fromJson(item as Map<String, dynamic>)) json.map((item) => GuildModel.fromJson(item as Map<String, dynamic>)).toList(),
.toList(),
); );
return res.data; return res.data;
} }
@@ -261,8 +257,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
} }
@override @override
Future<PaginationModel<StewardFreeBar>?> Future<PaginationModel<StewardFreeBar>?> getStewardPurchasesOutSideOfTheProvince({
getStewardPurchasesOutSideOfTheProvince({
required String token, required String token,
Map<String, dynamic>? queryParameters, Map<String, dynamic>? queryParameters,
}) async { }) async {
@@ -279,18 +274,12 @@ class ChickenRepositoryImpl implements ChickenRepository {
} }
@override @override
Future<List<IranProvinceCityModel>?> getCity({ Future<List<IranProvinceCityModel>?> getCity({required String provinceName}) async {
required String provinceName,
}) async {
var res = await _httpClient.get( var res = await _httpClient.get(
'/iran_city/?', '/iran_city/?',
queryParameters: {'name': provinceName}, queryParameters: {'name': provinceName},
fromJsonList: (json) => json fromJsonList: (json) =>
.map( json.map((item) => IranProvinceCityModel.fromJson(item as Map<String, dynamic>)).toList(),
(item) =>
IranProvinceCityModel.fromJson(item as Map<String, dynamic>),
)
.toList(),
); );
return res.data; return res.data;
} }
@@ -299,12 +288,8 @@ class ChickenRepositoryImpl implements ChickenRepository {
Future<List<IranProvinceCityModel>?> getProvince() async { Future<List<IranProvinceCityModel>?> getProvince() async {
var res = await _httpClient.get( var res = await _httpClient.get(
'/iran_province/', '/iran_province/',
fromJsonList: (json) => json fromJsonList: (json) =>
.map( json.map((item) => IranProvinceCityModel.fromJson(item as Map<String, dynamic>)).toList(),
(item) =>
IranProvinceCityModel.fromJson(item as Map<String, dynamic>),
)
.toList(),
); );
return res.data; return res.data;
} }
@@ -334,8 +319,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
} }
@override @override
Future<PaginationModel<OutProvinceCarcassesBuyer>?> Future<PaginationModel<OutProvinceCarcassesBuyer>?> getOutProvinceCarcassesBuyer({
getOutProvinceCarcassesBuyer({
required String token, required String token,
Map<String, dynamic>? queryParameters, Map<String, dynamic>? queryParameters,
}) async { }) async {
@@ -345,8 +329,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
fromJson: (json) => PaginationModel<OutProvinceCarcassesBuyer>.fromJson( fromJson: (json) => PaginationModel<OutProvinceCarcassesBuyer>.fromJson(
json, json,
(json) => (json) => OutProvinceCarcassesBuyer.fromJson(json as Map<String, dynamic>),
OutProvinceCarcassesBuyer.fromJson(json as Map<String, dynamic>),
), ),
); );
return res.data; return res.data;
@@ -402,10 +385,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
'/steward_free_sale_bar/0/', '/steward_free_sale_bar/0/',
data: body.toJson() data: body.toJson()
..removeWhere((key, value) => value == null) ..removeWhere((key, value) => value == null)
..addAll({ ..addAll({'carcassWeight': body.weightOfCarcasses, 'carcassCount': body.numberOfCarcasses}),
'carcassWeight': body.weightOfCarcasses,
'carcassCount': body.numberOfCarcasses,
}),
headers: {'Authorization': 'Bearer $token'}, headers: {'Authorization': 'Bearer $token'},
); );
} }

View File

@@ -1,6 +1,31 @@
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/presentation/pages/buy/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
import 'package:rasadyar_core/core.dart';
class BuyInProvinceLogic extends GetxController { class BuyInProvinceLogic extends GetxController {
RxList<String> routesName = RxList();
RxList<int> isExpandedList = <int>[].obs;
RxnString searchedValue = RxnString();
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
RootLogic get rootLogic => Get.find<RootLogic>();
BuyLogic get buyLogic => Get.find<BuyLogic>();
RxInt selectedSegmentIndex = 0.obs;
@override
void onInit() {
super.onInit();
routesName.value = [...buyLogic.routesName, 'داخل استان'].toList();
routesName.add(selectedSegmentIndex.value ==0 ? 'در انتظار':'همه');
ever(selectedSegmentIndex, (callback) {
routesName.removeLast();
routesName.add(callback ==0 ? 'در انتظار':'همه');
},);
}
@override @override
void onReady() { void onReady() {
// TODO: implement onReady // TODO: implement onReady
@@ -12,4 +37,9 @@ class BuyInProvinceLogic extends GetxController {
// TODO: implement onClose // TODO: implement onClose
super.onClose(); super.onClose();
} }
void setSearchValue(String? data) {
searchedValue.value = data?.trim();
//TODO
}
} }

View File

@@ -1,5 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:rasadyar_chicken/presentation/pages/buy_in_province_all/view.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_in_province_waiting/view.dart';
import 'package:rasadyar_chicken/presentation/widget/base_page/view.dart';
import 'package:rasadyar_chicken/presentation/widget/page_route.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart'; import 'logic.dart';
@@ -8,9 +12,40 @@ class BuyInProvincePage extends GetView<BuyInProvinceLogic> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BasePage(
routesWidget: ObxValue((route) => buildPageRoute(route), controller.routesName),
onBackPressed: () => Get.back(id: 0),
onSearchChanged: (data) => controller.setSearchValue(data),
filteringWidget: Container(color: Colors.redAccent),
widgets: [
segmentWidget(),
ObxValue((index) {
return Expanded(
child: index.value == 0 ? BuyInProvinceWaitingPage() : BuyInProvinceAllPage(),
);
}, controller.selectedSegmentIndex),
],
);
}
return Container( Padding segmentWidget() {
color: Colors.amberAccent, return Padding(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 8),
child: Row(
children: [
Expanded(
child: RSegment(
children: ['در انتظار', 'همه'],
selectedIndex: 0,
borderColor: const Color(0xFFB4B4B4),
selectedBorderColor: AppColor.blueNormal,
selectedBackgroundColor: AppColor.blueLight,
onSegmentSelected: (index) => controller.selectedSegmentIndex.value = index,
backgroundColor: AppColor.whiteGreyNormal,
),
),
],
),
); );
} }
} }

View File

@@ -0,0 +1,15 @@
import 'package:rasadyar_core/core.dart';
class BuyInProvinceAllLogic extends GetxController {
@override
void onReady() {
// TODO: implement onReady
super.onReady();
}
@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}

View File

@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class BuyInProvinceAllPage extends GetView<BuyInProvinceAllLogic> {
const BuyInProvinceAllPage({super.key});
@override
Widget build(BuildContext context) {
return Container(color: Colors.blue);
}
}

View File

@@ -0,0 +1,58 @@
import 'package:rasadyar_auth/data/utils/safe_call.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
import 'package:rasadyar_chicken/presentation/pages/root/logic.dart';
import 'package:rasadyar_core/core.dart';
class BuyInProvinceWaitingLogic extends GetxController {
RxList<int> isExpandedList = <int>[].obs;
Rx<Jalali> fromDateFilter = Jalali.now().obs;
Rx<Jalali> toDateFilter = Jalali.now().obs;
RxnString searchedValue = RxnString();
RootLogic rootLogic = Get.find<RootLogic>();
Rx<Resource<List<WaitingArrivalModel>>> waitingProduct =
Resource<List<WaitingArrivalModel>>.loading().obs;
@override
void onReady() {
super.onReady();
getWaitingArrivals();
}
@override
void onClose() {
super.onClose();
}
Future<void> getWaitingArrivals() async {
safeCall(
call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
token: rootLogic.tokenService.accessToken.value!,
queryParameters: buildQueryParams(
queryParams: {
'type':'not_entered'
},
pageSize: 10,
page: 1,
search: 'filter',
role: 'Steward',
value: searchedValue.value,
fromDate: fromDateFilter.value.toDateTime(),
toDate: toDateFilter.value.toDateTime(),
),
),
onSuccess: (res) async {
await Future.delayed(Duration(milliseconds: 500));
if ((res?.count ?? 0) == 0) {
waitingProduct.value = Resource<List<WaitingArrivalModel>>.empty();
} else {
waitingProduct.value = Resource<List<WaitingArrivalModel>>.success(res!.results!);
}
},
);
}
void setSearchValue(String? data) {
searchedValue.value = data?.trim();
}
}

View File

@@ -0,0 +1,264 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_chicken/data/models/response/waiting_arrival/waiting_arrival.dart';
import 'package:rasadyar_chicken/presentation/widget/list_item/list_item.dart';
import 'package:rasadyar_chicken/presentation/widget/list_row_item.dart';
import 'package:rasadyar_core/core.dart';
import 'logic.dart';
class BuyInProvinceWaitingPage extends GetView<BuyInProvinceWaitingLogic> {
const BuyInProvinceWaitingPage({super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: ObxValue((data) {
return RPaginatedListView(
listType: ListType.separated,
resource: data.value,
padding: EdgeInsets.fromLTRB(8, 8, 8, 80),
itemBuilder: (context, index) {
var item = data.value.data![index];
return ObxValue((val) {
return ListItem2(
selected: val.contains(index),
onTap: () => controller.isExpandedList.toggle(index),
index: index,
child: itemListWidget(item),
secondChild: itemListExpandedWidget(item),
labelColor: AppColor.blueLight,
labelIcon: Assets.vec.truckFastOutlinedSvg.path,
);
}, controller.isExpandedList);
},
itemCount: data.value.data?.length ?? 0,
separatorBuilder: (context, index) => SizedBox(height: 8.h),
onLoadMore: () async {},
);
}, controller.waitingProduct),
);
}
Row itemListWidget(WaitingArrivalModel item) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
SizedBox(width: 20),
Expanded(
flex: 2,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 3,
children: [
Text(
item.toSteward?.user?.fullname ?? 'N/A',
textAlign: TextAlign.start,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
Text(
item.date?.formattedJalaliDate ?? 'N/A',
textAlign: TextAlign.center,
style: AppFonts.yekan14.copyWith(color: AppColor.bgDark),
),
],
),
),
Expanded(
flex: 3,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 3,
children: [
Visibility(
visible: item.product?.name?.contains('مرغ گرم') ?? false,
child: Assets.vec.hotChickenSvg.svg(
width: 24,
height: 24,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
),
Text(
'${item.weightOfCarcasses?.separatedByComma}kg',
textAlign: TextAlign.left,
style: AppFonts.yekan12.copyWith(color: AppColor.blueNormal),
),
],
),
SizedBox(height: 2),
],
),
),
Expanded(
flex: 1,
child: Assets.vec.scanSvg.svg(
width: 32.w,
height: 32.h,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
),
],
);
}
Container itemListExpandedWidget(WaitingArrivalModel item) {
return Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(8)),
child: Column(
spacing: 8,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text(
item.steward?.user?.fullname ?? 'N/A',
textAlign: TextAlign.center,
style: AppFonts.yekan16.copyWith(color: AppColor.greenDark),
),
],
),
Container(
height: 32,
padding: EdgeInsets.symmetric(horizontal: 4),
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(
item.date?.toJalali.formatter.wN ?? 'N/A',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
Text(
'${item.date?.toJalali.formatter.d} ${item.date?.toJalali.formatter.mN ?? 'N/A'}',
style: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
],
),
Text(
'${item.date?.toJalali.formatter.y}',
style: AppFonts.yekan20.copyWith(color: AppColor.textColor),
),
Text(
'${item.date?.toJalali.formatter.tHH}:${item.date?.toJalali.formatter.tMM ?? 'N/A'}',
style: AppFonts.yekan14.copyWith(color: AppColor.textColor),
),
],
),
),
// buildRow(title: 'مشخصات فروشنده', value: item.killHouseName ?? 'N/A'),
buildRow(
title: 'تلفن فروشنده',
value: item.steward?.user?.mobile ?? 'N/A',
valueStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
),
buildRow(title: 'محصول', value: item.product?.name ?? 'N/A'),
buildRow(
title: 'وزن خریداری شده',
value: '${item.weightOfCarcasses?.separatedByComma} کیلوگرم',
),
buildRowOnTapped(
title: 'مشاهده بارنامه',
titleStyle: AppFonts.yekan14.copyWith(color: AppColor.blueNormal),
valueWidget: Assets.vec.clipboardEyeSvg.svg(
width: 20,
height: 24,
colorFilter: ColorFilter.mode(AppColor.blueNormal, BlendMode.srcIn),
),
onTap: () {
Get.bottomSheet(
BaseBottomSheet(
height: 400,
child: Column(
spacing: 16,
children: [
Text(
'بارنامه',
style: AppFonts.yekan16Bold.copyWith(color: AppColor.darkGreyDarkHover),
),
/* Image.network(
item.barImage ?? '',
fit: BoxFit.cover,
height: 300,
errorBuilder: (context, error, stackTrace) {
eLog(error.toString());
return Center(child: Text('خطایی پیش آمده!'));
},
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress == null) return child;
return CupertinoActivityIndicator();
},
),*/
],
),
),
);
},
),
/* Row(
mainAxisAlignment: MainAxisAlignment.center,
spacing: 16.w,
children: [
RElevated(
text: 'ویرایش',
width: 150.w,
height: 40.h,
onPressed: () {
controller.setEditData(item);
Get.bottomSheet(
addPurchasedInformationBottomSheet(true),
isScrollControlled: true,
).whenComplete(() {
controller.resetSubmitForm();
});
},
textStyle: AppFonts.yekan20.copyWith(color: Colors.white),
backgroundColor: AppColor.greenNormal,
),
ROutlinedElevated(
text: 'حذف',
textStyle: AppFonts.yekan20.copyWith(color: AppColor.redNormal),
width: 150.w,
height: 40.h,
onPressed: () {
buildDeleteDialog(
onConfirm: () => controller.deleteStewardPurchaseOutOfProvince(item.key!),
onRefresh: () => controller.getStewardPurchaseOutOfProvince(),
);
},
borderColor: AppColor.redNormal,
),
],
),*/
],
),
);
}
}

View File

@@ -31,7 +31,6 @@ class BuyOutOfProvinceLogic extends GetxController {
RxnString editImageUrl = RxnString(); RxnString editImageUrl = RxnString();
RootLogic get rootLogic => Get.find<RootLogic>(); RootLogic get rootLogic => Get.find<RootLogic>();
BuyLogic get buyLogic => Get.find<BuyLogic>(); BuyLogic get buyLogic => Get.find<BuyLogic>();
SaleLogic get outOfTheProvinceLogic => Get.find<SaleLogic>(); SaleLogic get outOfTheProvinceLogic => Get.find<SaleLogic>();

View File

@@ -33,9 +33,9 @@ class EnteringTheWarehouseLogic extends GetxController {
@override @override
void onReady() { void onReady() {
super.onReady(); super.onReady();
//rootLogic.getInventory();
getBarGeneralInformation(); getBarGeneralInformation();
getWaitingArrivals();
getImportedEntried(); getImportedEntried();
scrollControllerImportedLoad.addListener(() { scrollControllerImportedLoad.addListener(() {
@@ -50,7 +50,7 @@ class EnteringTheWarehouseLogic extends GetxController {
if (scrollControllerWaitingForArrival.position.pixels >= if (scrollControllerWaitingForArrival.position.pixels >=
scrollControllerWaitingForArrival.position.maxScrollExtent - 100) { scrollControllerWaitingForArrival.position.maxScrollExtent - 100) {
addPageWaitingForArrival.value = true; addPageWaitingForArrival.value = true;
getWaitingArrivals();
} }
}); });
} }
@@ -72,38 +72,7 @@ class EnteringTheWarehouseLogic extends GetxController {
); );
} }
Future<void> getWaitingArrivals() async {
if (isLoadingMoreWaitingForArrival.value ||
!hasMoreDataWaitingForArrival.value) {
return;
}
if (addPageWaitingForArrival.value) {
currentPageWaitingForArrival.value++;
}
safeCall(
call: () async => await rootLogic.chickenRepository.getWaitingArrivals(
token: rootLogic.tokenService.accessToken.value!,
page: currentPageWaitingForArrival.value,
),
onError: (error, stackTrace) {
isLoadingMoreImportedLoad.value = false;
},
onSuccess: (result) {
if (result != null) {
waitingForArrival.value = result;
if (isLoadingMoreWaitingForArrival.value) {
waitingForArrival.value?.results.addAll(result.results);
} else {
waitingForArrival.value = result;
}
}
isLoadingMoreImportedLoad.value = false;
},
);
}
Future<void> acceptEntried(String key) async { Future<void> acceptEntried(String key) async {
var request = StewardAllocationRequest( var request = StewardAllocationRequest(
@@ -139,7 +108,7 @@ class EnteringTheWarehouseLogic extends GetxController {
}, },
onSuccess: (result) { onSuccess: (result) {
clearControllers(); clearControllers();
getWaitingArrivals();
getBarGeneralInformation(); getBarGeneralInformation();
}, },
); );
@@ -162,7 +131,7 @@ class EnteringTheWarehouseLogic extends GetxController {
eLog(error); eLog(error);
}, },
onSuccess: (result) { onSuccess: (result) {
getWaitingArrivals();
getBarGeneralInformation(); getBarGeneralInformation();
}, },
); );

View File

@@ -21,7 +21,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
ObxValue((data) { ObxValue((data) {
return generalBarInformation(data.value); return generalBarInformation(data.value);
}, controller.barInformation), }, controller.barInformation),
waitingForArrival(),
importedLoads(), importedLoads(),
], ],
), ),
@@ -251,7 +251,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
); );
} }
Widget waitingForArrival() { /* Widget waitingForArrival() {
return Column( return Column(
children: [ children: [
const SizedBox(height: 8), const SizedBox(height: 8),
@@ -398,7 +398,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
}, controller.waitingForArrival), }, controller.waitingForArrival),
], ],
); );
} }*/
Widget importedLoads() { Widget importedLoads() {
return Column( return Column(
@@ -546,7 +546,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
); );
} }
Widget acceptBottomSheet(ResultModel resultModel) { /* Widget acceptBottomSheet(ResultModel resultModel) {
return BaseBottomSheet( return BaseBottomSheet(
height: 500, height: 500,
child: Column( child: Column(
@@ -625,5 +625,5 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
], ],
), ),
); );
} }*/
} }

View File

@@ -3,6 +3,8 @@ import 'package:rasadyar_chicken/presentation/pages/buy/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/buy/view.dart'; import 'package:rasadyar_chicken/presentation/pages/buy/view.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_in_province/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/buy_in_province/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_in_province/view.dart'; import 'package:rasadyar_chicken/presentation/pages/buy_in_province/view.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_in_province_all/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_in_province_waiting/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_out_of_province/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/buy_out_of_province/logic.dart';
import 'package:rasadyar_chicken/presentation/pages/buy_out_of_province/view.dart'; import 'package:rasadyar_chicken/presentation/pages/buy_out_of_province/view.dart';
import 'package:rasadyar_chicken/presentation/pages/home/logic.dart'; import 'package:rasadyar_chicken/presentation/pages/home/logic.dart';
@@ -124,7 +126,10 @@ sealed class ChickenPages {
middlewares: [AuthMiddleware()], middlewares: [AuthMiddleware()],
binding: BindingsBuilder(() { binding: BindingsBuilder(() {
Get.lazyPut(() => BaseLogic()); Get.lazyPut(() => BaseLogic());
Get.lazyPut(() => SearchLogic());
Get.lazyPut(() => BuyInProvinceLogic()); Get.lazyPut(() => BuyInProvinceLogic());
Get.lazyPut(() => BuyInProvinceWaitingLogic());
Get.lazyPut(() => BuyInProvinceAllLogic());
Get.lazyPut(() => RootLogic()); Get.lazyPut(() => RootLogic());
}), }),
), ),

View File

@@ -9,8 +9,9 @@ import 'package:rasadyar_core/core.dart';
class BasePage extends StatefulWidget { class BasePage extends StatefulWidget {
const BasePage({ const BasePage({
super.key, super.key,
required this.routes, this.routes,
required this.widgets, required this.widgets,
this.routesWidget,
this.floatingActionButtonLocation, this.floatingActionButtonLocation,
this.floatingActionButton, this.floatingActionButton,
this.onSearchChanged, this.onSearchChanged,
@@ -22,9 +23,14 @@ class BasePage extends StatefulWidget {
this.onFilterTap, this.onFilterTap,
this.onSearchTap, this.onSearchTap,
this.filteringWidget, this.filteringWidget,
}); }):assert(
(routes != null ) || routesWidget != null,
'Either routes or routesWidget must be provided.',
);
final List<String> routes;
final List<String>? routes;
final Widget? routesWidget;
final List<Widget> widgets; final List<Widget> widgets;
final FloatingActionButtonLocation? floatingActionButtonLocation; final FloatingActionButtonLocation? floatingActionButtonLocation;
final Widget? floatingActionButton; final Widget? floatingActionButton;
@@ -85,7 +91,7 @@ class _BasePageState extends State<BasePage> {
body: Column( body: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
buildPageRoute(widget.routes), widget.routesWidget != null ? widget.routesWidget! : buildPageRoute(widget.routes!),
const SizedBox(height: 8), const SizedBox(height: 8),
if (!widget.isBase && widget.hasSearch) ...{ if (!widget.isBase && widget.hasSearch) ...{
SearchWidget(onSearchChanged: widget.onSearchChanged), SearchWidget(onSearchChanged: widget.onSearchChanged),

View File

@@ -14,9 +14,7 @@ import 'package:flutter/rendering.dart';
// Minimum padding from edges of the segmented control to edges of // Minimum padding from edges of the segmented control to edges of
// encompassing widget. // encompassing widget.
const EdgeInsetsGeometry _kHorizontalItemPadding = EdgeInsets.symmetric( const EdgeInsetsGeometry _kHorizontalItemPadding = EdgeInsets.symmetric(horizontal: 16.0);
horizontal: 16.0,
);
// Minimum height of the segmented control. // Minimum height of the segmented control.
const double _kMinSegmentedControlHeight = 28.0; const double _kMinSegmentedControlHeight = 28.0;
@@ -52,15 +50,17 @@ class NewCupertinoSegmentedControl<T extends Object> extends StatefulWidget {
this.unselectedColor, this.unselectedColor,
this.selectedColor, this.selectedColor,
this.borderColor, this.borderColor,
this.selectedBorderColor,
this.pressedColor, this.pressedColor,
this.disabledColor, this.disabledColor,
this.disabledTextColor, this.disabledTextColor,
this.padding, this.padding,
this.unselectedItemStyle,
this.selectedItemStyle,
this.disabledChildren = const <Never>{}, this.disabledChildren = const <Never>{},
}) : assert(children.length >= 2), }) : assert(children.length >= 2),
assert( assert(
groupValue == null || groupValue == null || children.keys.any((T child) => child == groupValue),
children.keys.any((T child) => child == groupValue),
'The groupValue must be either null or one of the keys in the children map.', 'The groupValue must be either null or one of the keys in the children map.',
); );
@@ -101,6 +101,11 @@ class NewCupertinoSegmentedControl<T extends Object> extends StatefulWidget {
/// Defaults to [CupertinoTheme]'s `primaryColor` if null. /// Defaults to [CupertinoTheme]'s `primaryColor` if null.
final Color? borderColor; final Color? borderColor;
/// The color used as the border around selected widget.
///
/// Defaults to [CupertinoTheme]'s `primaryColor` if null.
final Color? selectedBorderColor;
/// The color used to fill the background of the widget the user is /// The color used to fill the background of the widget the user is
/// temporarily interacting with through a long press or drag. /// temporarily interacting with through a long press or drag.
/// ///
@@ -127,18 +132,25 @@ class NewCupertinoSegmentedControl<T extends Object> extends StatefulWidget {
/// All segments are enabled by default. /// All segments are enabled by default.
final Set<T> disabledChildren; final Set<T> disabledChildren;
/// The text style for unselected items.
///
/// Defaults to null, which means it will use the default text style.
final TextStyle? unselectedItemStyle;
/// The text style for selected items.
///
/// Defaults to null, which means it will use the default text style.
final TextStyle? selectedItemStyle;
@override @override
State<NewCupertinoSegmentedControl<T>> createState() => State<NewCupertinoSegmentedControl<T>> createState() => _SegmentedControlState<T>();
_SegmentedControlState<T>();
} }
class _SegmentedControlState<T extends Object> class _SegmentedControlState<T extends Object> extends State<NewCupertinoSegmentedControl<T>>
extends State<NewCupertinoSegmentedControl<T>>
with TickerProviderStateMixin<NewCupertinoSegmentedControl<T>> { with TickerProviderStateMixin<NewCupertinoSegmentedControl<T>> {
T? _pressedKey; T? _pressedKey;
final List<AnimationController> _selectionControllers = final List<AnimationController> _selectionControllers = <AnimationController>[];
<AnimationController>[];
final List<ColorTween> _childTweens = <ColorTween>[]; final List<ColorTween> _childTweens = <ColorTween>[];
late ColorTween _forwardBackgroundColorTween; late ColorTween _forwardBackgroundColorTween;
@@ -148,74 +160,66 @@ class _SegmentedControlState<T extends Object>
Color? _selectedColor; Color? _selectedColor;
Color? _unselectedColor; Color? _unselectedColor;
Color? _borderColor; Color? _borderColor;
Color? _selectedBorderColor;
Color? _pressedColor; Color? _pressedColor;
Color? _selectedDisabledColor; Color? _selectedDisabledColor;
Color? _unselectedDisabledColor; Color? _unselectedDisabledColor;
Color? _disabledTextColor; Color? _disabledTextColor;
AnimationController createAnimationController() { AnimationController createAnimationController() {
return AnimationController(duration: _kFadeDuration, vsync: this) return AnimationController(duration: _kFadeDuration, vsync: this)..addListener(() {
..addListener(() { setState(() {
setState(() { // State of background/text colors has changed
// State of background/text colors has changed
});
}); });
});
} }
bool _updateColors() { bool _updateColors() {
assert(mounted, 'This should only be called after didUpdateDependencies'); assert(mounted, 'This should only be called after didUpdateDependencies');
bool changed = false; bool changed = false;
final Color disabledTextColor = final Color disabledTextColor = widget.disabledTextColor ?? _kDisableTextColor;
widget.disabledTextColor ?? _kDisableTextColor;
if (_disabledTextColor != disabledTextColor) { if (_disabledTextColor != disabledTextColor) {
changed = true; changed = true;
_disabledTextColor = disabledTextColor; _disabledTextColor = disabledTextColor;
} }
final Color selectedColor = final Color selectedColor = widget.selectedColor ?? CupertinoTheme.of(context).primaryColor;
widget.selectedColor ?? CupertinoTheme.of(context).primaryColor;
if (_selectedColor != selectedColor) { if (_selectedColor != selectedColor) {
changed = true; changed = true;
_selectedColor = selectedColor; _selectedColor = selectedColor;
} }
final Color unselectedColor = final Color unselectedColor =
widget.unselectedColor ?? widget.unselectedColor ?? CupertinoTheme.of(context).primaryContrastingColor;
CupertinoTheme.of(context).primaryContrastingColor;
if (_unselectedColor != unselectedColor) { if (_unselectedColor != unselectedColor) {
changed = true; changed = true;
_unselectedColor = unselectedColor; _unselectedColor = unselectedColor;
} }
final Color selectedDisabledColor = final Color selectedDisabledColor = widget.disabledColor ?? selectedColor.withOpacity(0.5);
widget.disabledColor ?? selectedColor.withOpacity(0.5); final Color unselectedDisabledColor = widget.disabledColor ?? unselectedColor;
final Color unselectedDisabledColor =
widget.disabledColor ?? unselectedColor;
if (_selectedDisabledColor != selectedDisabledColor || if (_selectedDisabledColor != selectedDisabledColor ||
_unselectedDisabledColor != unselectedDisabledColor) { _unselectedDisabledColor != unselectedDisabledColor) {
changed = true; changed = true;
_selectedDisabledColor = selectedDisabledColor; _selectedDisabledColor = selectedDisabledColor;
_unselectedDisabledColor = unselectedDisabledColor; _unselectedDisabledColor = unselectedDisabledColor;
} }
final Color borderColor = final Color borderColor = widget.borderColor ?? CupertinoTheme.of(context).primaryColor;
widget.borderColor ?? CupertinoTheme.of(context).primaryColor; final Color selectedBorderColor = widget.selectedBorderColor ?? CupertinoTheme.of(context).primaryColor;
if (_borderColor != borderColor) { if (_borderColor != borderColor) {
changed = true; changed = true;
_borderColor = borderColor; _borderColor = borderColor;
} }
if (_selectedBorderColor != selectedBorderColor) {
changed = true;
_selectedBorderColor = selectedBorderColor;
}
final Color pressedColor = final Color pressedColor =
widget.pressedColor ?? widget.pressedColor ?? CupertinoTheme.of(context).primaryColor.withOpacity(0.2);
CupertinoTheme.of(context).primaryColor.withOpacity(0.2);
if (_pressedColor != pressedColor) { if (_pressedColor != pressedColor) {
changed = true; changed = true;
_pressedColor = pressedColor; _pressedColor = pressedColor;
} }
_forwardBackgroundColorTween = ColorTween( _forwardBackgroundColorTween = ColorTween(begin: _pressedColor, end: _selectedColor);
begin: _pressedColor, _reverseBackgroundColorTween = ColorTween(begin: _unselectedColor, end: _selectedColor);
end: _selectedColor,
);
_reverseBackgroundColorTween = ColorTween(
begin: _unselectedColor,
end: _selectedColor,
);
_textColorTween = ColorTween(begin: _selectedColor, end: _unselectedColor); _textColorTween = ColorTween(begin: _selectedColor, end: _unselectedColor);
return changed; return changed;
} }
@@ -229,8 +233,7 @@ class _SegmentedControlState<T extends Object>
_childTweens.clear(); _childTweens.clear();
for (final T key in widget.children.keys) { for (final T key in widget.children.keys) {
final AnimationController animationController = final AnimationController animationController = createAnimationController();
createAnimationController();
if (widget.groupValue == key) { if (widget.groupValue == key) {
_childTweens.add(_reverseBackgroundColorTween); _childTweens.add(_reverseBackgroundColorTween);
animationController.value = 1.0; animationController.value = 1.0;
@@ -254,8 +257,7 @@ class _SegmentedControlState<T extends Object>
void didUpdateWidget(NewCupertinoSegmentedControl<T> oldWidget) { void didUpdateWidget(NewCupertinoSegmentedControl<T> oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (_updateColors() || if (_updateColors() || oldWidget.children.length != widget.children.length) {
oldWidget.children.length != widget.children.length) {
_updateAnimationControllers(); _updateAnimationControllers();
} }
@@ -276,8 +278,7 @@ class _SegmentedControlState<T extends Object>
@override @override
void dispose() { void dispose() {
for (final AnimationController animationController for (final AnimationController animationController in _selectionControllers) {
in _selectionControllers) {
animationController.dispose(); animationController.dispose();
} }
super.dispose(); super.dispose();
@@ -324,9 +325,7 @@ class _SegmentedControlState<T extends Object>
Color? getBackgroundColor(int index, T currentKey) { Color? getBackgroundColor(int index, T currentKey) {
if (widget.disabledChildren.contains(currentKey)) { if (widget.disabledChildren.contains(currentKey)) {
return widget.groupValue == currentKey return widget.groupValue == currentKey ? _selectedDisabledColor : _unselectedDisabledColor;
? _selectedDisabledColor
: _unselectedDisabledColor;
} }
if (_selectionControllers[index].isAnimating) { if (_selectionControllers[index].isAnimating) {
return _childTweens[index].evaluate(_selectionControllers[index]); return _childTweens[index].evaluate(_selectionControllers[index]);
@@ -350,13 +349,12 @@ class _SegmentedControlState<T extends Object>
for (final T currentKey in widget.children.keys) { for (final T currentKey in widget.children.keys) {
selectedIndex = (widget.groupValue == currentKey) ? index : selectedIndex; selectedIndex = (widget.groupValue == currentKey) ? index : selectedIndex;
pressedIndex = (_pressedKey == currentKey) ? index : pressedIndex; pressedIndex = (_pressedKey == currentKey) ? index : pressedIndex;
final isSelected = widget.groupValue == currentKey;
final TextStyle textStyle = DefaultTextStyle.of( final textStyle =
context, (isSelected ? widget.selectedItemStyle : widget.unselectedItemStyle) ??
).style.copyWith(color: getTextColor(index, currentKey)); DefaultTextStyle.of(context).style.copyWith(color: getTextColor(index, currentKey));
final IconThemeData iconTheme = IconThemeData( final IconThemeData iconTheme = IconThemeData(color: getTextColor(index, currentKey));
color: getTextColor(index, currentKey),
);
Widget child = Center(child: widget.children[currentKey]); Widget child = Center(child: widget.children[currentKey]);
@@ -364,16 +362,12 @@ class _SegmentedControlState<T extends Object>
cursor: kIsWeb ? SystemMouseCursors.click : MouseCursor.defer, cursor: kIsWeb ? SystemMouseCursors.click : MouseCursor.defer,
child: GestureDetector( child: GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTapDown: onTapDown: widget.disabledChildren.contains(currentKey)
widget.disabledChildren.contains(currentKey) ? null
? null : (TapDownDetails event) {
: (TapDownDetails event) { _onTapDown(currentKey);
_onTapDown(currentKey); },
}, onTapCancel: widget.disabledChildren.contains(currentKey) ? null : _onTapCancel,
onTapCancel:
widget.disabledChildren.contains(currentKey)
? null
: _onTapCancel,
onTap: () { onTap: () {
_onTap(currentKey); _onTap(currentKey);
}, },
@@ -402,6 +396,7 @@ class _SegmentedControlState<T extends Object>
pressedIndex: pressedIndex, pressedIndex: pressedIndex,
backgroundColors: backgroundColors, backgroundColors: backgroundColors,
borderColor: _borderColor!, borderColor: _borderColor!,
selectBorderColor: _selectedBorderColor ?? _borderColor!,
children: gestureChildren, children: gestureChildren,
); );
@@ -420,12 +415,14 @@ class _SegmentedControlRenderWidget<T> extends MultiChildRenderObjectWidget {
required this.pressedIndex, required this.pressedIndex,
required this.backgroundColors, required this.backgroundColors,
required this.borderColor, required this.borderColor,
required this.selectBorderColor,
}); });
final int? selectedIndex; final int? selectedIndex;
final int? pressedIndex; final int? pressedIndex;
final List<Color> backgroundColors; final List<Color> backgroundColors;
final Color borderColor; final Color borderColor;
final Color selectBorderColor;
@override @override
RenderObject createRenderObject(BuildContext context) { RenderObject createRenderObject(BuildContext context) {
@@ -435,25 +432,23 @@ class _SegmentedControlRenderWidget<T> extends MultiChildRenderObjectWidget {
pressedIndex: pressedIndex, pressedIndex: pressedIndex,
backgroundColors: backgroundColors, backgroundColors: backgroundColors,
borderColor: borderColor, borderColor: borderColor,
selectBorderColor: selectBorderColor,
); );
} }
@override @override
void updateRenderObject( void updateRenderObject(BuildContext context, _RenderSegmentedControl<T> renderObject) {
BuildContext context,
_RenderSegmentedControl<T> renderObject,
) {
renderObject renderObject
..textDirection = Directionality.of(context) ..textDirection = Directionality.of(context)
..selectedIndex = selectedIndex ..selectedIndex = selectedIndex
..pressedIndex = pressedIndex ..pressedIndex = pressedIndex
..backgroundColors = backgroundColors ..backgroundColors = backgroundColors
..borderColor = borderColor; ..borderColor = borderColor
..selectedItemBorderColor = selectBorderColor;
} }
} }
class _SegmentedControlContainerBoxParentData class _SegmentedControlContainerBoxParentData extends ContainerBoxParentData<RenderBox> {
extends ContainerBoxParentData<RenderBox> {
RRect? surroundingRect; RRect? surroundingRect;
} }
@@ -461,24 +456,20 @@ typedef _NextChild = RenderBox? Function(RenderBox child);
class _RenderSegmentedControl<T> extends RenderBox class _RenderSegmentedControl<T> extends RenderBox
with with
ContainerRenderObjectMixin< ContainerRenderObjectMixin<RenderBox, ContainerBoxParentData<RenderBox>>,
RenderBox, RenderBoxContainerDefaultsMixin<RenderBox, ContainerBoxParentData<RenderBox>> {
ContainerBoxParentData<RenderBox>
>,
RenderBoxContainerDefaultsMixin<
RenderBox,
ContainerBoxParentData<RenderBox>
> {
_RenderSegmentedControl({ _RenderSegmentedControl({
required int? selectedIndex, required int? selectedIndex,
required int? pressedIndex, required int? pressedIndex,
required TextDirection textDirection, required TextDirection textDirection,
required List<Color> backgroundColors, required List<Color> backgroundColors,
required Color borderColor, required Color borderColor,
required Color selectBorderColor,
}) : _textDirection = textDirection, }) : _textDirection = textDirection,
_selectedIndex = selectedIndex, _selectedIndex = selectedIndex,
_pressedIndex = pressedIndex, _pressedIndex = pressedIndex,
_backgroundColors = backgroundColors, _backgroundColors = backgroundColors,
_selectedBorderColor = selectBorderColor,
_borderColor = borderColor; _borderColor = borderColor;
int? get selectedIndex => _selectedIndex; int? get selectedIndex => _selectedIndex;
@@ -536,6 +527,16 @@ class _RenderSegmentedControl<T> extends RenderBox
markNeedsPaint(); markNeedsPaint();
} }
Color? _selectedBorderColor;
Color? get selectedItemBorderColor => _selectedBorderColor;
set selectedItemBorderColor(Color? value) {
if (_selectedBorderColor == value) return;
_selectedBorderColor = value;
markNeedsPaint();
}
@override @override
double computeMinIntrinsicWidth(double height) { double computeMinIntrinsicWidth(double height) {
RenderBox? child = firstChild; RenderBox? child = firstChild;
@@ -604,11 +605,7 @@ class _RenderSegmentedControl<T> extends RenderBox
} }
} }
void _layoutRects( void _layoutRects(_NextChild nextChild, RenderBox? leftChild, RenderBox? rightChild) {
_NextChild nextChild,
RenderBox? leftChild,
RenderBox? rightChild,
) {
RenderBox? child = leftChild; RenderBox? child = leftChild;
double start = 0.0; double start = 0.0;
while (child != null) { while (child != null) {
@@ -616,12 +613,7 @@ class _RenderSegmentedControl<T> extends RenderBox
child.parentData! as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final Offset childOffset = Offset(start, 0.0); final Offset childOffset = Offset(start, 0.0);
childParentData.offset = childOffset; childParentData.offset = childOffset;
final Rect childRect = Rect.fromLTWH( final Rect childRect = Rect.fromLTWH(start, 0.0, child.size.width, child.size.height);
start,
0.0,
child.size.width,
child.size.height,
);
final RRect rChildRect; final RRect rChildRect;
if (child == leftChild) { if (child == leftChild) {
rChildRect = RRect.fromRectAndCorners( rChildRect = RRect.fromRectAndCorners(
@@ -649,10 +641,7 @@ class _RenderSegmentedControl<T> extends RenderBox
double childWidth = constraints.minWidth / childCount; double childWidth = constraints.minWidth / childCount;
RenderBox? child = firstChild; RenderBox? child = firstChild;
while (child != null) { while (child != null) {
childWidth = math.max( childWidth = math.max(childWidth, child.getMaxIntrinsicWidth(double.infinity));
childWidth,
child.getMaxIntrinsicWidth(double.infinity),
);
child = childAfter(child); child = childAfter(child);
} }
childWidth = math.min(childWidth, constraints.maxWidth / childCount); childWidth = math.min(childWidth, constraints.maxWidth / childCount);
@@ -666,25 +655,16 @@ class _RenderSegmentedControl<T> extends RenderBox
} }
Size _computeOverallSizeFromChildSize(Size childSize) { Size _computeOverallSizeFromChildSize(Size childSize) {
return constraints.constrain( return constraints.constrain(Size(childSize.width * childCount, childSize.height));
Size(childSize.width * childCount, childSize.height),
);
} }
@override @override
double? computeDryBaseline( double? computeDryBaseline(covariant BoxConstraints constraints, TextBaseline baseline) {
covariant BoxConstraints constraints,
TextBaseline baseline,
) {
final Size childSize = _calculateChildSize(constraints); final Size childSize = _calculateChildSize(constraints);
final BoxConstraints childConstraints = BoxConstraints.tight(childSize); final BoxConstraints childConstraints = BoxConstraints.tight(childSize);
BaselineOffset baselineOffset = BaselineOffset.noBaseline; BaselineOffset baselineOffset = BaselineOffset.noBaseline;
for ( for (RenderBox? child = firstChild; child != null; child = childAfter(child)) {
RenderBox? child = firstChild;
child != null;
child = childAfter(child)
) {
baselineOffset = baselineOffset.minOf( baselineOffset = baselineOffset.minOf(
BaselineOffset(child.getDryBaseline(childConstraints, baseline)), BaselineOffset(child.getDryBaseline(childConstraints, baseline)),
); );
@@ -735,28 +715,29 @@ class _RenderSegmentedControl<T> extends RenderBox
} }
} }
void _paintChild( void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) {
PaintingContext context,
Offset offset,
RenderBox child,
int childIndex,
) {
final _SegmentedControlContainerBoxParentData childParentData = final _SegmentedControlContainerBoxParentData childParentData =
child.parentData! as _SegmentedControlContainerBoxParentData; child.parentData! as _SegmentedControlContainerBoxParentData;
final RRect rect = childParentData.surroundingRect!.shift(offset);
context.canvas.drawRRect( context.canvas.drawRRect(
childParentData.surroundingRect!.shift(offset), rect,
Paint() Paint()
..color = backgroundColors[childIndex] ..color = backgroundColors[childIndex]
..style = PaintingStyle.fill, ..style = PaintingStyle.fill,
); );
context.canvas.drawRRect(
childParentData.surroundingRect!.shift(offset),
Paint() final isSelected = selectedIndex == childIndex;
..color = borderColor final borderPaint = Paint()
..strokeWidth = 1.0 ..color = isSelected && selectedItemBorderColor != null
..style = PaintingStyle.stroke, ? selectedItemBorderColor!
); : borderColor
..strokeWidth = 1.0
..style = PaintingStyle.stroke;
context.canvas.drawRRect(rect, borderPaint);
context.paintChild(child, childParentData.offset + offset); context.paintChild(child, childParentData.offset + offset);
} }

View File

@@ -0,0 +1,104 @@
import 'package:flutter/material.dart';
import 'package:rasadyar_core/core.dart';
const Duration _kFadeDuration = Duration(milliseconds: 165);
class RSegment extends StatefulWidget {
const RSegment({
super.key,
required this.children,
required this.selectedIndex,
required this.onSegmentSelected,
required this.backgroundColor,
required this.selectedBackgroundColor,
required this.borderColor,
required this.selectedBorderColor,
this.padding,
});
final List<String> children;
final int selectedIndex;
final Function(int index)? onSegmentSelected;
final EdgeInsetsGeometry? padding;
final Color backgroundColor;
final Color borderColor;
final Color selectedBackgroundColor;
final Color selectedBorderColor;
@override
State<RSegment> createState() => _RSegmentState();
}
class _RSegmentState extends State<RSegment> {
late int selectedIndex;
@override
void initState() {
super.initState();
selectedIndex = widget.selectedIndex;
}
@override
void didUpdateWidget(covariant RSegment oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.selectedIndex != widget.selectedIndex) {
widget.onSegmentSelected?.call(widget.selectedIndex);
}
}
@override
Widget build(BuildContext context) {
return Row(
children: List.generate(
widget.children.length,
(index) => Expanded(
child: _generateChild(
index: index,
hasNext: widget.children.length > index + 1,
hasPrevious: index > 0,
),
),
),
);
}
Widget _generateChild({required int index, required bool hasNext, required bool hasPrevious}) {
final bool isSelected = selectedIndex == index;
return GestureDetector(
onTap: () {
setState(() {
selectedIndex = index;
});
widget.onSegmentSelected?.call(index);
},
child: AnimatedContainer(
duration: _kFadeDuration,
padding: widget.padding??EdgeInsets.symmetric(vertical: 8),
margin: EdgeInsets.zero,
decoration: BoxDecoration(
color: isSelected ? widget.selectedBackgroundColor : widget.backgroundColor,
borderRadius: BorderRadius.only(
topRight: !hasPrevious && hasNext ? Radius.circular(8) : Radius.zero,
bottomRight: !hasPrevious && hasNext ? Radius.circular(8) : Radius.zero,
bottomLeft: hasPrevious && !hasNext ? Radius.circular(8) : Radius.zero,
topLeft: hasPrevious && !hasNext ? Radius.circular(8) : Radius.zero,
),
border: Border.all(
width: 1,
color: isSelected ? widget.selectedBorderColor : widget.borderColor,
),
),
child: Center(
child: Text(
widget.children[index],
textAlign: TextAlign.center,
style: isSelected
? AppFonts.yekan16Bold.copyWith(color: widget.selectedBorderColor)
: AppFonts.yekan16.copyWith(color: AppColor.mediumGreyDarkHover),
),
),
),
);
}
}

View File

@@ -24,5 +24,6 @@ export 'overlay_dropdown_widget/view.dart';
export 'pagination/pagination_from_until.dart'; export 'pagination/pagination_from_until.dart';
export 'pagination/show_more.dart'; export 'pagination/show_more.dart';
export 'tabs/new_tab.dart'; export 'tabs/new_tab.dart';
export 'tabs/r_segment.dart';
export 'tabs/tab.dart'; export 'tabs/tab.dart';
export 'vec_widget.dart'; export 'vec_widget.dart';