feat :
1 - AllocatedMadeModel 2 - RSegment widget 3 - buy in province
This commit is contained in:
@@ -4,26 +4,14 @@ part 'waiting_arrival.freezed.dart';
|
||||
part 'waiting_arrival.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class WaitingArrivalModel with _$WaitingArrivalModel {
|
||||
abstract class WaitingArrivalModel with _$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,
|
||||
ProductModel? product,
|
||||
KillHouseModel? killHouse,
|
||||
dynamic killHouse,
|
||||
dynamic toKillHouse,
|
||||
dynamic steward,
|
||||
@JsonKey(name: 'to_steward') ToStewardModel? toSteward,
|
||||
StewardModel? steward,
|
||||
StewardModel? toSteward,
|
||||
dynamic guilds,
|
||||
dynamic toGuilds,
|
||||
dynamic toColdHouse,
|
||||
@@ -67,95 +55,88 @@ abstract class ResultModel with _$ResultModel {
|
||||
bool? calculateStatus,
|
||||
bool? temporaryTrash,
|
||||
bool? temporaryDeleted,
|
||||
bool? overhead,
|
||||
dynamic createdBy,
|
||||
dynamic modifiedBy,
|
||||
dynamic wareHouse,
|
||||
dynamic stewardWareHouse,
|
||||
dynamic car,
|
||||
dynamic dispenser,
|
||||
}) = _ResultModel;
|
||||
}) = _WaitingArrivalModel;
|
||||
|
||||
factory ResultModel.fromJson(Map<String, dynamic> json) => _$ResultModelFromJson(json);
|
||||
factory WaitingArrivalModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$WaitingArrivalModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class ProductModel with _$ProductModel {
|
||||
factory ProductModel({
|
||||
double? weightAverage,
|
||||
}) = _ProductModel;
|
||||
factory ProductModel({String? name, double? weightAverage}) = _ProductModel;
|
||||
|
||||
factory ProductModel.fromJson(Map<String, dynamic> json) => _$ProductModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class ToStewardModel with _$ToStewardModel {
|
||||
factory ToStewardModel({
|
||||
abstract class StewardModel with _$StewardModel {
|
||||
factory StewardModel({
|
||||
int? id,
|
||||
ToStewardUserModel? user,
|
||||
StewardUserModel? user,
|
||||
AddressModel? address,
|
||||
GuildAreaActivityModel? guildAreaActivity,
|
||||
GuildTypeActivityModel? guildTypeActivity,
|
||||
dynamic guildAreaActivity,
|
||||
dynamic guildTypeActivity,
|
||||
List<dynamic>? killHouse,
|
||||
List<dynamic>? stewardKillHouse,
|
||||
List<dynamic>? stewards,
|
||||
GetPosStatusModel? getPosStatus,
|
||||
String? key,
|
||||
@JsonKey(name: 'create_date') String? createDate,
|
||||
@JsonKey(name: 'modify_date') String? modifyDate,
|
||||
String? createDate,
|
||||
String? modifyDate,
|
||||
bool? trash,
|
||||
bool? active,
|
||||
int? cityNumber,
|
||||
String? cityName,
|
||||
String? guildsId,
|
||||
String? licenseNumber,
|
||||
String? guildsName,
|
||||
String? phone,
|
||||
String? typeActivity,
|
||||
String? areaActivity,
|
||||
int? provinceNumber,
|
||||
String? provinceName,
|
||||
bool? steward,
|
||||
bool? hasPos,
|
||||
int? allocationLimit,
|
||||
bool? limitationAllocation,
|
||||
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
|
||||
abstract class ToStewardUserModel with _$ToStewardUserModel {
|
||||
factory ToStewardUserModel({
|
||||
abstract class StewardUserModel with _$StewardUserModel {
|
||||
factory StewardUserModel({
|
||||
String? fullname,
|
||||
@JsonKey(name: 'first_name') String? firstName,
|
||||
@JsonKey(name: 'last_name') String? lastName,
|
||||
String? firstName,
|
||||
String? lastName,
|
||||
String? mobile,
|
||||
@JsonKey(name: 'national_id') String? nationalId,
|
||||
String? nationalId,
|
||||
String? city,
|
||||
}) = _ToStewardUserModel;
|
||||
}) = _StewardUserModel;
|
||||
|
||||
factory ToStewardUserModel.fromJson(Map<String, dynamic> json) => _$ToStewardUserModelFromJson(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);
|
||||
factory StewardUserModel.fromJson(Map<String, dynamic> json) => _$StewardUserModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class AddressModel with _$AddressModel {
|
||||
factory AddressModel({
|
||||
ToStewardProvinceModel? province,
|
||||
ToStewardCityModel? city,
|
||||
ProvinceModel? province,
|
||||
CityModel? city,
|
||||
String? address,
|
||||
String? postalCode,
|
||||
}) = _AddressModel;
|
||||
@@ -164,103 +145,24 @@ abstract class AddressModel with _$AddressModel {
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GuildAreaActivityModel with _$GuildAreaActivityModel {
|
||||
factory GuildAreaActivityModel({
|
||||
String? key,
|
||||
String? title,
|
||||
}) = _GuildAreaActivityModel;
|
||||
abstract class ProvinceModel with _$ProvinceModel {
|
||||
factory ProvinceModel({String? key, String? name}) = _ProvinceModel;
|
||||
|
||||
factory GuildAreaActivityModel.fromJson(Map<String, dynamic> json) => _$GuildAreaActivityModelFromJson(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);
|
||||
factory ProvinceModel.fromJson(Map<String, dynamic> json) => _$ProvinceModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class CityModel with _$CityModel {
|
||||
factory 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({String? key, String? name}) = _CityModel;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,38 +6,21 @@ part of 'waiting_arrival.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_WaitingArrivalModel _$WaitingArrivalModelFromJson(Map<String, dynamic> json) =>
|
||||
_WaitingArrivalModel(
|
||||
count: (json['count'] as num).toInt(),
|
||||
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(
|
||||
_WaitingArrivalModel _$WaitingArrivalModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _WaitingArrivalModel(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
product: json['product'] == null
|
||||
? null
|
||||
: ProductModel.fromJson(json['product'] as Map<String, dynamic>),
|
||||
killHouse: json['kill_house'] == null
|
||||
? null
|
||||
: KillHouseModel.fromJson(json['kill_house'] as Map<String, dynamic>),
|
||||
killHouse: json['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
|
||||
? null
|
||||
: ToStewardModel.fromJson(json['to_steward'] as Map<String, dynamic>),
|
||||
: StewardModel.fromJson(json['to_steward'] as Map<String, dynamic>),
|
||||
guilds: json['guilds'],
|
||||
toGuilds: json['to_guilds'],
|
||||
toColdHouse: json['to_cold_house'],
|
||||
@@ -83,6 +66,7 @@ _ResultModel _$ResultModelFromJson(Map<String, dynamic> json) => _ResultModel(
|
||||
calculateStatus: json['calculate_status'] as bool?,
|
||||
temporaryTrash: json['temporary_trash'] as bool?,
|
||||
temporaryDeleted: json['temporary_deleted'] as bool?,
|
||||
overhead: json['overhead'] as bool?,
|
||||
createdBy: json['created_by'],
|
||||
modifiedBy: json['modified_by'],
|
||||
wareHouse: json['ware_house'],
|
||||
@@ -91,8 +75,8 @@ _ResultModel _$ResultModelFromJson(Map<String, dynamic> json) => _ResultModel(
|
||||
dispenser: json['dispenser'],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ResultModelToJson(
|
||||
_ResultModel instance,
|
||||
Map<String, dynamic> _$WaitingArrivalModelToJson(
|
||||
_WaitingArrivalModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'product': instance.product,
|
||||
@@ -143,6 +127,7 @@ Map<String, dynamic> _$ResultModelToJson(
|
||||
'calculate_status': instance.calculateStatus,
|
||||
'temporary_trash': instance.temporaryTrash,
|
||||
'temporary_deleted': instance.temporaryDeleted,
|
||||
'overhead': instance.overhead,
|
||||
'created_by': instance.createdBy,
|
||||
'modified_by': instance.modifiedBy,
|
||||
'ware_house': instance.wareHouse,
|
||||
@@ -152,30 +137,28 @@ Map<String, dynamic> _$ResultModelToJson(
|
||||
};
|
||||
|
||||
_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) =>
|
||||
<String, dynamic>{'weight_average': instance.weightAverage};
|
||||
<String, dynamic>{
|
||||
'name': instance.name,
|
||||
'weight_average': instance.weightAverage,
|
||||
};
|
||||
|
||||
_ToStewardModel _$ToStewardModelFromJson(Map<String, dynamic> json) =>
|
||||
_ToStewardModel(
|
||||
_StewardModel _$StewardModelFromJson(Map<String, dynamic> json) =>
|
||||
_StewardModel(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: ToStewardUserModel.fromJson(json['user'] as Map<String, dynamic>),
|
||||
: StewardUserModel.fromJson(json['user'] as Map<String, dynamic>),
|
||||
address: json['address'] == null
|
||||
? null
|
||||
: AddressModel.fromJson(json['address'] as Map<String, dynamic>),
|
||||
guildAreaActivity: json['guild_area_activity'] == null
|
||||
? null
|
||||
: 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>,
|
||||
),
|
||||
guildAreaActivity: json['guild_area_activity'],
|
||||
guildTypeActivity: json['guild_type_activity'],
|
||||
killHouse: json['kill_house'] as List<dynamic>?,
|
||||
stewardKillHouse: json['steward_kill_house'] 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?,
|
||||
trash: json['trash'] 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?,
|
||||
licenseNumber: json['license_number'] as String?,
|
||||
guildsName: json['guilds_name'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
typeActivity: json['type_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?,
|
||||
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?,
|
||||
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>{
|
||||
'id': instance.id,
|
||||
'user': instance.user,
|
||||
@@ -215,18 +212,31 @@ Map<String, dynamic> _$ToStewardModelToJson(_ToStewardModel instance) =>
|
||||
'modify_date': instance.modifyDate,
|
||||
'trash': instance.trash,
|
||||
'active': instance.active,
|
||||
'city_number': instance.cityNumber,
|
||||
'city_name': instance.cityName,
|
||||
'guilds_id': instance.guildsId,
|
||||
'license_number': instance.licenseNumber,
|
||||
'guilds_name': instance.guildsName,
|
||||
'phone': instance.phone,
|
||||
'type_activity': instance.typeActivity,
|
||||
'area_activity': instance.areaActivity,
|
||||
'province_number': instance.provinceNumber,
|
||||
'province_name': instance.provinceName,
|
||||
'steward': instance.steward,
|
||||
'has_pos': instance.hasPos,
|
||||
'allocation_limit': instance.allocationLimit,
|
||||
'limitation_allocation': instance.limitationAllocation,
|
||||
'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) =>
|
||||
_ToStewardUserModel(
|
||||
_StewardUserModel _$StewardUserModelFromJson(Map<String, dynamic> json) =>
|
||||
_StewardUserModel(
|
||||
fullname: json['fullname'] as String?,
|
||||
firstName: json['first_name'] as String?,
|
||||
lastName: json['last_name'] as String?,
|
||||
@@ -235,7 +245,7 @@ _ToStewardUserModel _$ToStewardUserModelFromJson(Map<String, dynamic> json) =>
|
||||
city: json['city'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ToStewardUserModelToJson(_ToStewardUserModel instance) =>
|
||||
Map<String, dynamic> _$StewardUserModelToJson(_StewardUserModel instance) =>
|
||||
<String, dynamic>{
|
||||
'fullname': instance.fullname,
|
||||
'first_name': instance.firstName,
|
||||
@@ -245,36 +255,14 @@ Map<String, dynamic> _$ToStewardUserModelToJson(_ToStewardUserModel instance) =>
|
||||
'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(
|
||||
province: json['province'] == null
|
||||
? null
|
||||
: ToStewardProvinceModel.fromJson(
|
||||
json['province'] as Map<String, dynamic>,
|
||||
),
|
||||
: ProvinceModel.fromJson(json['province'] as Map<String, dynamic>),
|
||||
city: json['city'] == null
|
||||
? null
|
||||
: ToStewardCityModel.fromJson(json['city'] as Map<String, dynamic>),
|
||||
: CityModel.fromJson(json['city'] as Map<String, dynamic>),
|
||||
address: json['address'] as String?,
|
||||
postalCode: json['postal_code'] as String?,
|
||||
);
|
||||
@@ -287,27 +275,17 @@ Map<String, dynamic> _$AddressModelToJson(_AddressModel instance) =>
|
||||
'postal_code': instance.postalCode,
|
||||
};
|
||||
|
||||
_GuildAreaActivityModel _$GuildAreaActivityModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GuildAreaActivityModel(
|
||||
key: json['key'] as String?,
|
||||
title: json['title'] as String?,
|
||||
);
|
||||
_ProvinceModel _$ProvinceModelFromJson(Map<String, dynamic> json) =>
|
||||
_ProvinceModel(key: json['key'] as String?, name: json['name'] as String?);
|
||||
|
||||
Map<String, dynamic> _$GuildAreaActivityModelToJson(
|
||||
_GuildAreaActivityModel instance,
|
||||
) => <String, dynamic>{'key': instance.key, 'title': instance.title};
|
||||
Map<String, dynamic> _$ProvinceModelToJson(_ProvinceModel instance) =>
|
||||
<String, dynamic>{'key': instance.key, 'name': instance.name};
|
||||
|
||||
_GuildTypeActivityModel _$GuildTypeActivityModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GuildTypeActivityModel(
|
||||
key: json['key'] as String?,
|
||||
title: json['title'] as String?,
|
||||
);
|
||||
_CityModel _$CityModelFromJson(Map<String, dynamic> json) =>
|
||||
_CityModel(key: json['key'] as String?, name: json['name'] as String?);
|
||||
|
||||
Map<String, dynamic> _$GuildTypeActivityModelToJson(
|
||||
_GuildTypeActivityModel instance,
|
||||
) => <String, dynamic>{'key': instance.key, 'title': instance.title};
|
||||
Map<String, dynamic> _$CityModelToJson(_CityModel instance) =>
|
||||
<String, dynamic>{'key': instance.key, 'name': instance.name};
|
||||
|
||||
_GetPosStatusModel _$GetPosStatusModelFromJson(Map<String, dynamic> json) =>
|
||||
_GetPosStatusModel(
|
||||
@@ -322,119 +300,3 @@ Map<String, dynamic> _$GetPosStatusModelToJson(_GetPosStatusModel instance) =>
|
||||
'has_pons': instance.hasPons,
|
||||
'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,
|
||||
};
|
||||
|
||||
@@ -33,9 +33,9 @@ abstract class ChickenRepository {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<WaitingArrivalModel?> getWaitingArrivals({
|
||||
Future<PaginationModel<WaitingArrivalModel>?> getWaitingArrivals({
|
||||
required String token,
|
||||
int? page,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
});
|
||||
|
||||
Future<void> setSateForArrivals({
|
||||
|
||||
@@ -33,18 +33,15 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
var res = await _httpClient.get(
|
||||
'/roles-products/?role=Steward',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
fromJsonList: (json) => (json)
|
||||
.map((item) => InventoryModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
fromJsonList: (json) =>
|
||||
(json).map((item) => InventoryModel.fromJson(item as Map<String, dynamic>)).toList(),
|
||||
);
|
||||
|
||||
return res.data;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<KillHouseDistributionInfo?> getKillHouseDistributionInfo({
|
||||
required String token,
|
||||
}) async {
|
||||
Future<KillHouseDistributionInfo?> getKillHouseDistributionInfo({required String token}) async {
|
||||
var res = await _httpClient.get(
|
||||
'/kill-house-distribution-info/?role=Steward',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
@@ -69,14 +66,18 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<WaitingArrivalModel?> getWaitingArrivals({
|
||||
Future<PaginationModel<WaitingArrivalModel>?> getWaitingArrivals({
|
||||
required String token,
|
||||
int? page,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
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'},
|
||||
fromJson: WaitingArrivalModel.fromJson,
|
||||
queryParameters: queryParameters,
|
||||
fromJson: (json) => PaginationModel<WaitingArrivalModel>.fromJson(
|
||||
json,
|
||||
(json) => WaitingArrivalModel.fromJson(json as Map<String, dynamic>),
|
||||
),
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
@@ -136,10 +137,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> denyAllocation({
|
||||
required String token,
|
||||
required String allocationToken,
|
||||
}) async {
|
||||
Future<void> denyAllocation({required String token, required String allocationToken}) async {
|
||||
await _httpClient.delete(
|
||||
'/steward-allocation/0/?steward_allocation_key=$allocationToken',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
@@ -163,9 +161,8 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
var res = await _httpClient.get(
|
||||
'/roles-products/?role=Steward',
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
fromJsonList: (json) => json
|
||||
.map((item) => ProductModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
fromJsonList: (json) =>
|
||||
json.map((item) => ProductModel.fromJson(item as Map<String, dynamic>)).toList(),
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
@@ -179,9 +176,8 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
'/guilds/?',
|
||||
queryParameters: queryParameters,
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
fromJsonList: (json) => json
|
||||
.map((item) => GuildModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
fromJsonList: (json) =>
|
||||
json.map((item) => GuildModel.fromJson(item as Map<String, dynamic>)).toList(),
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
@@ -261,8 +257,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PaginationModel<StewardFreeBar>?>
|
||||
getStewardPurchasesOutSideOfTheProvince({
|
||||
Future<PaginationModel<StewardFreeBar>?> getStewardPurchasesOutSideOfTheProvince({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
@@ -279,18 +274,12 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<IranProvinceCityModel>?> getCity({
|
||||
required String provinceName,
|
||||
}) async {
|
||||
Future<List<IranProvinceCityModel>?> getCity({required String provinceName}) async {
|
||||
var res = await _httpClient.get(
|
||||
'/iran_city/?',
|
||||
queryParameters: {'name': provinceName},
|
||||
fromJsonList: (json) => json
|
||||
.map(
|
||||
(item) =>
|
||||
IranProvinceCityModel.fromJson(item as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
fromJsonList: (json) =>
|
||||
json.map((item) => IranProvinceCityModel.fromJson(item as Map<String, dynamic>)).toList(),
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
@@ -299,12 +288,8 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
Future<List<IranProvinceCityModel>?> getProvince() async {
|
||||
var res = await _httpClient.get(
|
||||
'/iran_province/',
|
||||
fromJsonList: (json) => json
|
||||
.map(
|
||||
(item) =>
|
||||
IranProvinceCityModel.fromJson(item as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
fromJsonList: (json) =>
|
||||
json.map((item) => IranProvinceCityModel.fromJson(item as Map<String, dynamic>)).toList(),
|
||||
);
|
||||
return res.data;
|
||||
}
|
||||
@@ -334,8 +319,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PaginationModel<OutProvinceCarcassesBuyer>?>
|
||||
getOutProvinceCarcassesBuyer({
|
||||
Future<PaginationModel<OutProvinceCarcassesBuyer>?> getOutProvinceCarcassesBuyer({
|
||||
required String token,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
}) async {
|
||||
@@ -345,8 +329,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
fromJson: (json) => PaginationModel<OutProvinceCarcassesBuyer>.fromJson(
|
||||
json,
|
||||
(json) =>
|
||||
OutProvinceCarcassesBuyer.fromJson(json as Map<String, dynamic>),
|
||||
(json) => OutProvinceCarcassesBuyer.fromJson(json as Map<String, dynamic>),
|
||||
),
|
||||
);
|
||||
return res.data;
|
||||
@@ -402,10 +385,7 @@ class ChickenRepositoryImpl implements ChickenRepository {
|
||||
'/steward_free_sale_bar/0/',
|
||||
data: body.toJson()
|
||||
..removeWhere((key, value) => value == null)
|
||||
..addAll({
|
||||
'carcassWeight': body.weightOfCarcasses,
|
||||
'carcassCount': body.numberOfCarcasses,
|
||||
}),
|
||||
..addAll({'carcassWeight': body.weightOfCarcasses, 'carcassCount': body.numberOfCarcasses}),
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
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
|
||||
void onReady() {
|
||||
// TODO: implement onReady
|
||||
@@ -12,4 +37,9 @@ class BuyInProvinceLogic extends GetxController {
|
||||
// TODO: implement onClose
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
void setSearchValue(String? data) {
|
||||
searchedValue.value = data?.trim();
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
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';
|
||||
|
||||
@@ -8,9 +12,40 @@ class BuyInProvincePage extends GetView<BuyInProvinceLogic> {
|
||||
|
||||
@override
|
||||
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(
|
||||
color: Colors.amberAccent,
|
||||
Padding segmentWidget() {
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
),
|
||||
],
|
||||
),*/
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,7 +31,6 @@ class BuyOutOfProvinceLogic extends GetxController {
|
||||
RxnString editImageUrl = RxnString();
|
||||
|
||||
RootLogic get rootLogic => Get.find<RootLogic>();
|
||||
|
||||
BuyLogic get buyLogic => Get.find<BuyLogic>();
|
||||
|
||||
SaleLogic get outOfTheProvinceLogic => Get.find<SaleLogic>();
|
||||
|
||||
@@ -33,9 +33,9 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
@override
|
||||
void onReady() {
|
||||
super.onReady();
|
||||
//rootLogic.getInventory();
|
||||
|
||||
getBarGeneralInformation();
|
||||
getWaitingArrivals();
|
||||
|
||||
getImportedEntried();
|
||||
|
||||
scrollControllerImportedLoad.addListener(() {
|
||||
@@ -50,7 +50,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
if (scrollControllerWaitingForArrival.position.pixels >=
|
||||
scrollControllerWaitingForArrival.position.maxScrollExtent - 100) {
|
||||
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 {
|
||||
var request = StewardAllocationRequest(
|
||||
@@ -139,7 +108,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
},
|
||||
onSuccess: (result) {
|
||||
clearControllers();
|
||||
getWaitingArrivals();
|
||||
|
||||
getBarGeneralInformation();
|
||||
},
|
||||
);
|
||||
@@ -162,7 +131,7 @@ class EnteringTheWarehouseLogic extends GetxController {
|
||||
eLog(error);
|
||||
},
|
||||
onSuccess: (result) {
|
||||
getWaitingArrivals();
|
||||
|
||||
getBarGeneralInformation();
|
||||
},
|
||||
);
|
||||
|
||||
@@ -21,7 +21,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
ObxValue((data) {
|
||||
return generalBarInformation(data.value);
|
||||
}, controller.barInformation),
|
||||
waitingForArrival(),
|
||||
|
||||
importedLoads(),
|
||||
],
|
||||
),
|
||||
@@ -251,7 +251,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget waitingForArrival() {
|
||||
/* Widget waitingForArrival() {
|
||||
return Column(
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
@@ -398,7 +398,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
}, controller.waitingForArrival),
|
||||
],
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
Widget importedLoads() {
|
||||
return Column(
|
||||
@@ -546,7 +546,7 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget acceptBottomSheet(ResultModel resultModel) {
|
||||
/* Widget acceptBottomSheet(ResultModel resultModel) {
|
||||
return BaseBottomSheet(
|
||||
height: 500,
|
||||
child: Column(
|
||||
@@ -625,5 +625,5 @@ class EnteringTheWarehousePage extends GetView<EnteringTheWarehouseLogic> {
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -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_in_province/logic.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/view.dart';
|
||||
import 'package:rasadyar_chicken/presentation/pages/home/logic.dart';
|
||||
@@ -124,7 +126,10 @@ sealed class ChickenPages {
|
||||
middlewares: [AuthMiddleware()],
|
||||
binding: BindingsBuilder(() {
|
||||
Get.lazyPut(() => BaseLogic());
|
||||
Get.lazyPut(() => SearchLogic());
|
||||
Get.lazyPut(() => BuyInProvinceLogic());
|
||||
Get.lazyPut(() => BuyInProvinceWaitingLogic());
|
||||
Get.lazyPut(() => BuyInProvinceAllLogic());
|
||||
Get.lazyPut(() => RootLogic());
|
||||
}),
|
||||
),
|
||||
|
||||
@@ -9,8 +9,9 @@ import 'package:rasadyar_core/core.dart';
|
||||
class BasePage extends StatefulWidget {
|
||||
const BasePage({
|
||||
super.key,
|
||||
required this.routes,
|
||||
this.routes,
|
||||
required this.widgets,
|
||||
this.routesWidget,
|
||||
this.floatingActionButtonLocation,
|
||||
this.floatingActionButton,
|
||||
this.onSearchChanged,
|
||||
@@ -22,9 +23,14 @@ class BasePage extends StatefulWidget {
|
||||
this.onFilterTap,
|
||||
this.onSearchTap,
|
||||
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 FloatingActionButtonLocation? floatingActionButtonLocation;
|
||||
final Widget? floatingActionButton;
|
||||
@@ -85,7 +91,7 @@ class _BasePageState extends State<BasePage> {
|
||||
body: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
buildPageRoute(widget.routes),
|
||||
widget.routesWidget != null ? widget.routesWidget! : buildPageRoute(widget.routes!),
|
||||
const SizedBox(height: 8),
|
||||
if (!widget.isBase && widget.hasSearch) ...{
|
||||
SearchWidget(onSearchChanged: widget.onSearchChanged),
|
||||
|
||||
@@ -14,9 +14,7 @@ import 'package:flutter/rendering.dart';
|
||||
|
||||
// Minimum padding from edges of the segmented control to edges of
|
||||
// encompassing widget.
|
||||
const EdgeInsetsGeometry _kHorizontalItemPadding = EdgeInsets.symmetric(
|
||||
horizontal: 16.0,
|
||||
);
|
||||
const EdgeInsetsGeometry _kHorizontalItemPadding = EdgeInsets.symmetric(horizontal: 16.0);
|
||||
|
||||
// Minimum height of the segmented control.
|
||||
const double _kMinSegmentedControlHeight = 28.0;
|
||||
@@ -52,15 +50,17 @@ class NewCupertinoSegmentedControl<T extends Object> extends StatefulWidget {
|
||||
this.unselectedColor,
|
||||
this.selectedColor,
|
||||
this.borderColor,
|
||||
this.selectedBorderColor,
|
||||
this.pressedColor,
|
||||
this.disabledColor,
|
||||
this.disabledTextColor,
|
||||
this.padding,
|
||||
this.unselectedItemStyle,
|
||||
this.selectedItemStyle,
|
||||
this.disabledChildren = const <Never>{},
|
||||
}) : assert(children.length >= 2),
|
||||
assert(
|
||||
groupValue == null ||
|
||||
children.keys.any((T child) => child == groupValue),
|
||||
groupValue == null || children.keys.any((T child) => child == groupValue),
|
||||
'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.
|
||||
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
|
||||
/// 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.
|
||||
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
|
||||
State<NewCupertinoSegmentedControl<T>> createState() =>
|
||||
_SegmentedControlState<T>();
|
||||
State<NewCupertinoSegmentedControl<T>> createState() => _SegmentedControlState<T>();
|
||||
}
|
||||
|
||||
class _SegmentedControlState<T extends Object>
|
||||
extends State<NewCupertinoSegmentedControl<T>>
|
||||
class _SegmentedControlState<T extends Object> extends State<NewCupertinoSegmentedControl<T>>
|
||||
with TickerProviderStateMixin<NewCupertinoSegmentedControl<T>> {
|
||||
T? _pressedKey;
|
||||
|
||||
final List<AnimationController> _selectionControllers =
|
||||
<AnimationController>[];
|
||||
final List<AnimationController> _selectionControllers = <AnimationController>[];
|
||||
final List<ColorTween> _childTweens = <ColorTween>[];
|
||||
|
||||
late ColorTween _forwardBackgroundColorTween;
|
||||
@@ -148,74 +160,66 @@ class _SegmentedControlState<T extends Object>
|
||||
Color? _selectedColor;
|
||||
Color? _unselectedColor;
|
||||
Color? _borderColor;
|
||||
Color? _selectedBorderColor;
|
||||
Color? _pressedColor;
|
||||
Color? _selectedDisabledColor;
|
||||
Color? _unselectedDisabledColor;
|
||||
Color? _disabledTextColor;
|
||||
|
||||
AnimationController createAnimationController() {
|
||||
return AnimationController(duration: _kFadeDuration, vsync: this)
|
||||
..addListener(() {
|
||||
setState(() {
|
||||
// State of background/text colors has changed
|
||||
});
|
||||
return AnimationController(duration: _kFadeDuration, vsync: this)..addListener(() {
|
||||
setState(() {
|
||||
// State of background/text colors has changed
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bool _updateColors() {
|
||||
assert(mounted, 'This should only be called after didUpdateDependencies');
|
||||
bool changed = false;
|
||||
final Color disabledTextColor =
|
||||
widget.disabledTextColor ?? _kDisableTextColor;
|
||||
final Color disabledTextColor = widget.disabledTextColor ?? _kDisableTextColor;
|
||||
if (_disabledTextColor != disabledTextColor) {
|
||||
changed = true;
|
||||
_disabledTextColor = disabledTextColor;
|
||||
}
|
||||
final Color selectedColor =
|
||||
widget.selectedColor ?? CupertinoTheme.of(context).primaryColor;
|
||||
final Color selectedColor = widget.selectedColor ?? CupertinoTheme.of(context).primaryColor;
|
||||
if (_selectedColor != selectedColor) {
|
||||
changed = true;
|
||||
_selectedColor = selectedColor;
|
||||
}
|
||||
final Color unselectedColor =
|
||||
widget.unselectedColor ??
|
||||
CupertinoTheme.of(context).primaryContrastingColor;
|
||||
widget.unselectedColor ?? CupertinoTheme.of(context).primaryContrastingColor;
|
||||
if (_unselectedColor != unselectedColor) {
|
||||
changed = true;
|
||||
_unselectedColor = unselectedColor;
|
||||
}
|
||||
final Color selectedDisabledColor =
|
||||
widget.disabledColor ?? selectedColor.withOpacity(0.5);
|
||||
final Color unselectedDisabledColor =
|
||||
widget.disabledColor ?? unselectedColor;
|
||||
final Color selectedDisabledColor = widget.disabledColor ?? selectedColor.withOpacity(0.5);
|
||||
final Color unselectedDisabledColor = widget.disabledColor ?? unselectedColor;
|
||||
if (_selectedDisabledColor != selectedDisabledColor ||
|
||||
_unselectedDisabledColor != unselectedDisabledColor) {
|
||||
changed = true;
|
||||
_selectedDisabledColor = selectedDisabledColor;
|
||||
_unselectedDisabledColor = unselectedDisabledColor;
|
||||
}
|
||||
final Color borderColor =
|
||||
widget.borderColor ?? CupertinoTheme.of(context).primaryColor;
|
||||
final Color borderColor = widget.borderColor ?? CupertinoTheme.of(context).primaryColor;
|
||||
final Color selectedBorderColor = widget.selectedBorderColor ?? CupertinoTheme.of(context).primaryColor;
|
||||
if (_borderColor != borderColor) {
|
||||
changed = true;
|
||||
_borderColor = borderColor;
|
||||
}
|
||||
if (_selectedBorderColor != selectedBorderColor) {
|
||||
changed = true;
|
||||
_selectedBorderColor = selectedBorderColor;
|
||||
}
|
||||
final Color pressedColor =
|
||||
widget.pressedColor ??
|
||||
CupertinoTheme.of(context).primaryColor.withOpacity(0.2);
|
||||
widget.pressedColor ?? CupertinoTheme.of(context).primaryColor.withOpacity(0.2);
|
||||
if (_pressedColor != pressedColor) {
|
||||
changed = true;
|
||||
_pressedColor = pressedColor;
|
||||
}
|
||||
|
||||
_forwardBackgroundColorTween = ColorTween(
|
||||
begin: _pressedColor,
|
||||
end: _selectedColor,
|
||||
);
|
||||
_reverseBackgroundColorTween = ColorTween(
|
||||
begin: _unselectedColor,
|
||||
end: _selectedColor,
|
||||
);
|
||||
_forwardBackgroundColorTween = ColorTween(begin: _pressedColor, end: _selectedColor);
|
||||
_reverseBackgroundColorTween = ColorTween(begin: _unselectedColor, end: _selectedColor);
|
||||
_textColorTween = ColorTween(begin: _selectedColor, end: _unselectedColor);
|
||||
return changed;
|
||||
}
|
||||
@@ -229,8 +233,7 @@ class _SegmentedControlState<T extends Object>
|
||||
_childTweens.clear();
|
||||
|
||||
for (final T key in widget.children.keys) {
|
||||
final AnimationController animationController =
|
||||
createAnimationController();
|
||||
final AnimationController animationController = createAnimationController();
|
||||
if (widget.groupValue == key) {
|
||||
_childTweens.add(_reverseBackgroundColorTween);
|
||||
animationController.value = 1.0;
|
||||
@@ -254,8 +257,7 @@ class _SegmentedControlState<T extends Object>
|
||||
void didUpdateWidget(NewCupertinoSegmentedControl<T> oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
|
||||
if (_updateColors() ||
|
||||
oldWidget.children.length != widget.children.length) {
|
||||
if (_updateColors() || oldWidget.children.length != widget.children.length) {
|
||||
_updateAnimationControllers();
|
||||
}
|
||||
|
||||
@@ -276,8 +278,7 @@ class _SegmentedControlState<T extends Object>
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (final AnimationController animationController
|
||||
in _selectionControllers) {
|
||||
for (final AnimationController animationController in _selectionControllers) {
|
||||
animationController.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
@@ -324,9 +325,7 @@ class _SegmentedControlState<T extends Object>
|
||||
|
||||
Color? getBackgroundColor(int index, T currentKey) {
|
||||
if (widget.disabledChildren.contains(currentKey)) {
|
||||
return widget.groupValue == currentKey
|
||||
? _selectedDisabledColor
|
||||
: _unselectedDisabledColor;
|
||||
return widget.groupValue == currentKey ? _selectedDisabledColor : _unselectedDisabledColor;
|
||||
}
|
||||
if (_selectionControllers[index].isAnimating) {
|
||||
return _childTweens[index].evaluate(_selectionControllers[index]);
|
||||
@@ -350,13 +349,12 @@ class _SegmentedControlState<T extends Object>
|
||||
for (final T currentKey in widget.children.keys) {
|
||||
selectedIndex = (widget.groupValue == currentKey) ? index : selectedIndex;
|
||||
pressedIndex = (_pressedKey == currentKey) ? index : pressedIndex;
|
||||
final isSelected = widget.groupValue == currentKey;
|
||||
|
||||
final TextStyle textStyle = DefaultTextStyle.of(
|
||||
context,
|
||||
).style.copyWith(color: getTextColor(index, currentKey));
|
||||
final IconThemeData iconTheme = IconThemeData(
|
||||
color: getTextColor(index, currentKey),
|
||||
);
|
||||
final textStyle =
|
||||
(isSelected ? widget.selectedItemStyle : widget.unselectedItemStyle) ??
|
||||
DefaultTextStyle.of(context).style.copyWith(color: getTextColor(index, currentKey));
|
||||
final IconThemeData iconTheme = IconThemeData(color: getTextColor(index, currentKey));
|
||||
|
||||
Widget child = Center(child: widget.children[currentKey]);
|
||||
|
||||
@@ -364,16 +362,12 @@ class _SegmentedControlState<T extends Object>
|
||||
cursor: kIsWeb ? SystemMouseCursors.click : MouseCursor.defer,
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTapDown:
|
||||
widget.disabledChildren.contains(currentKey)
|
||||
? null
|
||||
: (TapDownDetails event) {
|
||||
_onTapDown(currentKey);
|
||||
},
|
||||
onTapCancel:
|
||||
widget.disabledChildren.contains(currentKey)
|
||||
? null
|
||||
: _onTapCancel,
|
||||
onTapDown: widget.disabledChildren.contains(currentKey)
|
||||
? null
|
||||
: (TapDownDetails event) {
|
||||
_onTapDown(currentKey);
|
||||
},
|
||||
onTapCancel: widget.disabledChildren.contains(currentKey) ? null : _onTapCancel,
|
||||
onTap: () {
|
||||
_onTap(currentKey);
|
||||
},
|
||||
@@ -402,6 +396,7 @@ class _SegmentedControlState<T extends Object>
|
||||
pressedIndex: pressedIndex,
|
||||
backgroundColors: backgroundColors,
|
||||
borderColor: _borderColor!,
|
||||
selectBorderColor: _selectedBorderColor ?? _borderColor!,
|
||||
children: gestureChildren,
|
||||
);
|
||||
|
||||
@@ -420,12 +415,14 @@ class _SegmentedControlRenderWidget<T> extends MultiChildRenderObjectWidget {
|
||||
required this.pressedIndex,
|
||||
required this.backgroundColors,
|
||||
required this.borderColor,
|
||||
required this.selectBorderColor,
|
||||
});
|
||||
|
||||
final int? selectedIndex;
|
||||
final int? pressedIndex;
|
||||
final List<Color> backgroundColors;
|
||||
final Color borderColor;
|
||||
final Color selectBorderColor;
|
||||
|
||||
@override
|
||||
RenderObject createRenderObject(BuildContext context) {
|
||||
@@ -435,25 +432,23 @@ class _SegmentedControlRenderWidget<T> extends MultiChildRenderObjectWidget {
|
||||
pressedIndex: pressedIndex,
|
||||
backgroundColors: backgroundColors,
|
||||
borderColor: borderColor,
|
||||
selectBorderColor: selectBorderColor,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void updateRenderObject(
|
||||
BuildContext context,
|
||||
_RenderSegmentedControl<T> renderObject,
|
||||
) {
|
||||
void updateRenderObject(BuildContext context, _RenderSegmentedControl<T> renderObject) {
|
||||
renderObject
|
||||
..textDirection = Directionality.of(context)
|
||||
..selectedIndex = selectedIndex
|
||||
..pressedIndex = pressedIndex
|
||||
..backgroundColors = backgroundColors
|
||||
..borderColor = borderColor;
|
||||
..borderColor = borderColor
|
||||
..selectedItemBorderColor = selectBorderColor;
|
||||
}
|
||||
}
|
||||
|
||||
class _SegmentedControlContainerBoxParentData
|
||||
extends ContainerBoxParentData<RenderBox> {
|
||||
class _SegmentedControlContainerBoxParentData extends ContainerBoxParentData<RenderBox> {
|
||||
RRect? surroundingRect;
|
||||
}
|
||||
|
||||
@@ -461,24 +456,20 @@ typedef _NextChild = RenderBox? Function(RenderBox child);
|
||||
|
||||
class _RenderSegmentedControl<T> extends RenderBox
|
||||
with
|
||||
ContainerRenderObjectMixin<
|
||||
RenderBox,
|
||||
ContainerBoxParentData<RenderBox>
|
||||
>,
|
||||
RenderBoxContainerDefaultsMixin<
|
||||
RenderBox,
|
||||
ContainerBoxParentData<RenderBox>
|
||||
> {
|
||||
ContainerRenderObjectMixin<RenderBox, ContainerBoxParentData<RenderBox>>,
|
||||
RenderBoxContainerDefaultsMixin<RenderBox, ContainerBoxParentData<RenderBox>> {
|
||||
_RenderSegmentedControl({
|
||||
required int? selectedIndex,
|
||||
required int? pressedIndex,
|
||||
required TextDirection textDirection,
|
||||
required List<Color> backgroundColors,
|
||||
required Color borderColor,
|
||||
required Color selectBorderColor,
|
||||
}) : _textDirection = textDirection,
|
||||
_selectedIndex = selectedIndex,
|
||||
_pressedIndex = pressedIndex,
|
||||
_backgroundColors = backgroundColors,
|
||||
_selectedBorderColor = selectBorderColor,
|
||||
_borderColor = borderColor;
|
||||
|
||||
int? get selectedIndex => _selectedIndex;
|
||||
@@ -536,6 +527,16 @@ class _RenderSegmentedControl<T> extends RenderBox
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
Color? _selectedBorderColor;
|
||||
|
||||
Color? get selectedItemBorderColor => _selectedBorderColor;
|
||||
|
||||
set selectedItemBorderColor(Color? value) {
|
||||
if (_selectedBorderColor == value) return;
|
||||
_selectedBorderColor = value;
|
||||
markNeedsPaint();
|
||||
}
|
||||
|
||||
@override
|
||||
double computeMinIntrinsicWidth(double height) {
|
||||
RenderBox? child = firstChild;
|
||||
@@ -604,11 +605,7 @@ class _RenderSegmentedControl<T> extends RenderBox
|
||||
}
|
||||
}
|
||||
|
||||
void _layoutRects(
|
||||
_NextChild nextChild,
|
||||
RenderBox? leftChild,
|
||||
RenderBox? rightChild,
|
||||
) {
|
||||
void _layoutRects(_NextChild nextChild, RenderBox? leftChild, RenderBox? rightChild) {
|
||||
RenderBox? child = leftChild;
|
||||
double start = 0.0;
|
||||
while (child != null) {
|
||||
@@ -616,12 +613,7 @@ class _RenderSegmentedControl<T> extends RenderBox
|
||||
child.parentData! as _SegmentedControlContainerBoxParentData;
|
||||
final Offset childOffset = Offset(start, 0.0);
|
||||
childParentData.offset = childOffset;
|
||||
final Rect childRect = Rect.fromLTWH(
|
||||
start,
|
||||
0.0,
|
||||
child.size.width,
|
||||
child.size.height,
|
||||
);
|
||||
final Rect childRect = Rect.fromLTWH(start, 0.0, child.size.width, child.size.height);
|
||||
final RRect rChildRect;
|
||||
if (child == leftChild) {
|
||||
rChildRect = RRect.fromRectAndCorners(
|
||||
@@ -649,10 +641,7 @@ class _RenderSegmentedControl<T> extends RenderBox
|
||||
double childWidth = constraints.minWidth / childCount;
|
||||
RenderBox? child = firstChild;
|
||||
while (child != null) {
|
||||
childWidth = math.max(
|
||||
childWidth,
|
||||
child.getMaxIntrinsicWidth(double.infinity),
|
||||
);
|
||||
childWidth = math.max(childWidth, child.getMaxIntrinsicWidth(double.infinity));
|
||||
child = childAfter(child);
|
||||
}
|
||||
childWidth = math.min(childWidth, constraints.maxWidth / childCount);
|
||||
@@ -666,25 +655,16 @@ class _RenderSegmentedControl<T> extends RenderBox
|
||||
}
|
||||
|
||||
Size _computeOverallSizeFromChildSize(Size childSize) {
|
||||
return constraints.constrain(
|
||||
Size(childSize.width * childCount, childSize.height),
|
||||
);
|
||||
return constraints.constrain(Size(childSize.width * childCount, childSize.height));
|
||||
}
|
||||
|
||||
@override
|
||||
double? computeDryBaseline(
|
||||
covariant BoxConstraints constraints,
|
||||
TextBaseline baseline,
|
||||
) {
|
||||
double? computeDryBaseline(covariant BoxConstraints constraints, TextBaseline baseline) {
|
||||
final Size childSize = _calculateChildSize(constraints);
|
||||
final BoxConstraints childConstraints = BoxConstraints.tight(childSize);
|
||||
|
||||
BaselineOffset baselineOffset = BaselineOffset.noBaseline;
|
||||
for (
|
||||
RenderBox? child = firstChild;
|
||||
child != null;
|
||||
child = childAfter(child)
|
||||
) {
|
||||
for (RenderBox? child = firstChild; child != null; child = childAfter(child)) {
|
||||
baselineOffset = baselineOffset.minOf(
|
||||
BaselineOffset(child.getDryBaseline(childConstraints, baseline)),
|
||||
);
|
||||
@@ -735,28 +715,29 @@ class _RenderSegmentedControl<T> extends RenderBox
|
||||
}
|
||||
}
|
||||
|
||||
void _paintChild(
|
||||
PaintingContext context,
|
||||
Offset offset,
|
||||
RenderBox child,
|
||||
int childIndex,
|
||||
) {
|
||||
void _paintChild(PaintingContext context, Offset offset, RenderBox child, int childIndex) {
|
||||
final _SegmentedControlContainerBoxParentData childParentData =
|
||||
child.parentData! as _SegmentedControlContainerBoxParentData;
|
||||
final RRect rect = childParentData.surroundingRect!.shift(offset);
|
||||
|
||||
context.canvas.drawRRect(
|
||||
childParentData.surroundingRect!.shift(offset),
|
||||
rect,
|
||||
Paint()
|
||||
..color = backgroundColors[childIndex]
|
||||
..style = PaintingStyle.fill,
|
||||
);
|
||||
context.canvas.drawRRect(
|
||||
childParentData.surroundingRect!.shift(offset),
|
||||
Paint()
|
||||
..color = borderColor
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke,
|
||||
);
|
||||
|
||||
|
||||
final isSelected = selectedIndex == childIndex;
|
||||
final borderPaint = Paint()
|
||||
..color = isSelected && selectedItemBorderColor != null
|
||||
? selectedItemBorderColor!
|
||||
: borderColor
|
||||
..strokeWidth = 1.0
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
context.canvas.drawRRect(rect, borderPaint);
|
||||
|
||||
|
||||
context.paintChild(child, childParentData.offset + offset);
|
||||
}
|
||||
|
||||
104
packages/core/lib/presentation/widget/tabs/r_segment.dart
Normal file
104
packages/core/lib/presentation/widget/tabs/r_segment.dart
Normal 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),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -24,5 +24,6 @@ export 'overlay_dropdown_widget/view.dart';
|
||||
export 'pagination/pagination_from_until.dart';
|
||||
export 'pagination/show_more.dart';
|
||||
export 'tabs/new_tab.dart';
|
||||
export 'tabs/r_segment.dart';
|
||||
export 'tabs/tab.dart';
|
||||
export 'vec_widget.dart';
|
||||
|
||||
Reference in New Issue
Block a user