diff --git a/docs/superpowers/specs/2026-08-11-unified-resource-upload-design.md b/docs/superpowers/specs/2026-08-11-unified-resource-upload-design.md new file mode 100644 index 0000000..3202ea1 --- /dev/null +++ b/docs/superpowers/specs/2026-08-11-unified-resource-upload-design.md @@ -0,0 +1,180 @@ +# Gộp upload tài nguyên về một đường + +Ngày: 2026-08-11 + +## Vấn đề + +Sàn có đúng **một** cách đưa bytes lên: giữ chỗ (`POST /{module}/uploads`), PUT vào +signed URL, rồi xác nhận (`POST /{module}/uploads/{id}/confirmation`). Chỉ có prefix +là khác nhau theo module — `listings`, `me`, `orders`, `conversations`, `reviews`. + +Trong app, ba bước đó được chép tay **bảy lần**: + +| File | Method | Module | +|---|---|---| +| `features/seller/data/repositories/listing_composer_repository.dart` | `uploadPhoto` | catalog | +| `features/account/data/repositories/account_repository.dart` | `uploadAvatar` | account | +| `features/account/data/repositories/account_repository.dart` | `uploadOrderEvidence` | order | +| `features/kyc/data/repositories/kyc_repository.dart` | `uploadKycScan` | account | +| `features/chat/data/repositories/chat_repository.dart` | `uploadAttachment` | chat | +| `features/ticket/data/repositories/ticket_repository.dart` | `uploadAttachment` | chat | +| `features/account/data/repositories/rating_repository.dart` | `uploadReviewPhoto` | trust | + +Bước PUT đã được gom vào `core/network/resource_upload.dart#putToSlot` từ trước — +đó là bằng chứng rằng phần còn lại cũng gom được, chứ không phải lý do để dừng ở đó. + +**Và cả bảy chỗ đều vứt đi câu trả lời của bước xác nhận.** Hợp đồng nói rất rõ về +câu trả lời đó: + +> The answer carries a signed `url` for the bytes just uploaded. That is the only +> time it is handed over unasked: a second confirmation is refused, and the resource +> is otherwise only seen through whatever it gets attached to. + +Nên sau khi upload xong, app chỉ còn một cái id — và không có route nào đổi một id +trần lấy ảnh (`internal/gateway/router.go`: *"No /resources or /options routes"*). +Màn nào muốn khoe tấm ảnh vừa tải lên thì không có gì để vẽ. Đó là báo cáo "upload +xong show ảnh rỗng", ở cả bốn nhóm màn: chat, đăng bán, avatar/KYC, đánh giá/hoàn tiền. + +Phía UI thì bốn màn tự dựng lại cùng một dải thumbnail — `listing_suggestion_screen`, +`confirm_receipt_sheet`, `refund_evidence_sheet`, `kyc_card_picker_widget` — mỗi màn +một cách báo lỗi, một cách báo đang tải, và không màn nào cho thử lại một ảnh hỏng. + +## Mục tiêu + +Một đường cho phần dữ liệu, một widget cho phần nhìn, và tấm ảnh vừa tải lên luôn +hiện ra được. + +## Ngoài phạm vi + +- Không đổi hợp đồng API. Năm prefix vẫn là năm prefix; đây là chuyện của client. +- Không đổi cách các route *đính kèm* nhận resource — chúng vẫn nhận id, và id vẫn + là thứ caller gửi đi. +- Không đụng `putToSlot`. Nó đã đúng và đã được chia sẻ. + +## Phần A — `ResourceUploader` + +`lib/core/upload/resource_uploader.dart` + +```dart +enum UploadTarget { listing, avatar, identityDocument, order, conversation, review } + +class ResourceUploader { + Future upload( + UploadTarget target, { + required List bytes, + required String filename, + required String mime, + }); +} +``` + +Một method, một enum. Mỗi `UploadTarget` biết đúng cặp gọi của module mình; năm +module trả về năm lớp wrapper khác nhau nhưng đều mang `Resource data`, nên chúng +quy về một kiểu trả về duy nhất. + +`avatar` và `identityDocument` cùng đi qua `POST /me/uploads` nhưng khác `kind` — +đó là lý do chúng là hai giá trị enum chứ không phải một: server phải được cho biết +nó đang ký cho loại nào *trước khi* một byte di chuyển, vì chỉ ảnh đại diện mới được +phép resolve ra link công khai. + +Trả về **`Resource` đã xác nhận**, không phải mỗi id. Đây là điểm chính của cả spec: +`Resource.url` chỉ tồn tại ở đúng câu trả lời này, và caller nào cần khoe ảnh thì +lấy ở đây, còn caller nào chỉ cần đính kèm thì đọc `.id`. + +Chặn kích thước trước khi gửi byte nào — 100 MB cho video, 10 MB cho phần còn lại, +đúng ngưỡng server trả 413. Một vòng lên xuống 10 MB để nhận về một lỗi biết trước +là thứ trả bằng pin và 4G của người dùng. + +## Phần B — `ImageUploadField` + +`lib/shared/widgets/image_upload_field.dart` + +Dải thumbnail dùng chung, thay bốn bản chép tay: + +```dart +ImageUploadField( + target: UploadTarget.order, + maxPhotos: 10, + onChanged: (List uploaded) { ... }, +) +``` + +- Đang tải thì vẽ **file local**, xong thì đổi sang `Resource.url`. Không có khoảng + trống nào ở giữa: ảnh hiện ngay lúc chọn, và thứ thay thế nó là ảnh thật trên + server — cũng là cách màn hình tự chứng minh bytes đã tới nơi. +- Spinner trên từng ảnh, không phải một spinner cho cả dải: mười ảnh tải song song + và một cái hỏng không được làm chín cái kia trông như đang chờ. +- Ảnh hỏng mang câu lỗi của nó và một nút **thử lại**. Hiện tại đường duy nhất là + xoá rồi chọn lại từ đầu. +- Nút xoá từng ảnh, và chặn ở `maxPhotos`. + +## Phần C — Chuyển đổi + +Hai nhịp, mỗi nhịp tự đứng được: + +1. Bảy method repository giữ nguyên tên và chữ ký cũ — vẫn trả `String` id — nhưng + bên trong chỉ còn một dòng gọi `ResourceUploader` và đọc `.id`. Không caller nào + phải sửa, và ba bước chép tay biến mất. +2. Các màn có dải thumbnail đổi sang `ImageUploadField`. Widget này gọi thẳng + `ResourceUploader` chứ không đi qua repository, vì nó là chỗ duy nhất cần `url` + — nhờ vậy bảy chữ ký ở nhịp 1 không phải đổi theo. + + Đã đổi: `confirm_receipt_sheet` và `refund_evidence_sheet`. **Chưa đổi**, có lý + do chứ không phải bỏ sót: + + - `kyc_card_picker_widget` là ba ô đơn có nhãn và mô tả riêng ("mặt trước", + "mặt sau", "chân dung"), không phải một dải n ảnh. Nhét nó vào một widget + dải sẽ làm méo cả hai. + - `listing_suggestion_screen` giữ ảnh trong máy trạng thái riêng của luồng gợi + ý AI — resource id của chúng đi vào `POST /listings/suggestions` rồi vào + `attachments` của tin đăng, và màn còn có nút camera riêng mà dải chung chưa + có. Nó đã dùng chung đường dữ liệu qua `ResourceUploader`. + +## Luồng dữ liệu + +``` +chọn ảnh → bytes + → uploader.upload(target) + → POST /{prefix}/uploads (giữ chỗ, nhận signed URL + resource_id) + → PUT (putToSlot, header lấy nguyên từ slot) + → POST /{prefix}/uploads/{id}/confirmation + → Resource { id, url } + → id đi vào request đính kèm + → url đi vào chỗ vẽ ảnh +``` + +## Lỗi + +| Tình huống | Kết quả | +|---|---| +| Quá ngưỡng kích thước | `UploadTooLarge`, ném trước khi có HTTP nào | +| 422 — server không nhận loại file đó | `UploadTypeRejected` | +| PUT hoặc confirm hỏng | `DioException` nổi lên nguyên vẹn; dải ảnh đánh dấu đúng ảnh đó là hỏng, các ảnh khác giữ nguyên trạng thái | + +## Test + +Unit — `test/resource_uploader_test.dart`: + +- mỗi `UploadTarget` gọi đúng hai path của module mình, đúng thứ tự +- PUT mang đúng header slot trả về, không thêm không đè +- **thứ trả ra là `Resource` của bước confirm, có `url`** — không phải id của slot +- quá ngưỡng thì bị từ chối trước khi có request nào + +`ImageUploadField` **chưa có** test. Đã thử và đã bỏ: widget đọc file thật rồi đi +qua Dio, cả hai là I/O thật nên `pump` không đẩy chúng đi; chạy trong `runAsync` +thì `Image.network` lại treo trong môi trường test. Một bài test không chạy được +tệ hơn là không có bài test nào, nên nó bị xoá thay vì để đó. + +Phần logic quan trọng nhất của widget — *lấy url từ đâu* — nằm ở `ResourceUploader` +và đã được phủ. Phần còn lại (dải ảnh, spinner, nút thử lại) hiện chỉ được kiểm +bằng tay. Muốn phủ nó thì phải tiêm được `ImagePicker` và bộ giải mã ảnh vào +widget; đó là một thay đổi riêng, không phải một dòng thêm vào bài test. + +## Điều spec này không hứa + +Nó không chứng minh được rằng "ảnh rỗng" chỉ do một nguyên nhân. Kiểm tra trên API +thật (`reserve → PUT → confirm → GET`, cho listing, avatar và chat) đều trả signed +URL hợp lệ và phục vụ đúng bytes, nên phía server lành. Việc vứt đi url của bước +confirm là một lỗi có thật và giải thích được triệu chứng ở những màn khoe ảnh ngay +sau khi tải lên; nếu sau khi làm xong vẫn còn màn nào rỗng thì đó là một nguyên nhân +khác và cần bắt riêng. diff --git a/lib/api/api_providers.g.dart b/lib/api/api_providers.g.dart index ee21970..d38a3d1 100644 --- a/lib/api/api_providers.g.dart +++ b/lib/api/api_providers.g.dart @@ -6,134 +6,319 @@ part of 'api_providers.dart'; // RiverpodGenerator // ************************************************************************** -String _$accountApiHash() => r'6a88a7694ec8c415b62e00a97e21b1b33dccc3e4'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// The generated endpoint groups, each built on the app's own [dioProvider] so /// every call goes through the auth header, the 401 refresh and the logging /// interceptor. `ShopnexusApi` from the generated barrel is deliberately unused: /// it would build a second Dio with none of that. /// /// `AdminApi` has no provider — this app has no staff surface. -/// -/// Copied from [accountApi]. + @ProviderFor(accountApi) -final accountApiProvider = AutoDisposeProvider.internal( - accountApi, - name: r'accountApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$accountApiHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef AccountApiRef = AutoDisposeProviderRef; -String _$catalogApiHash() => r'32c800e9ff4823801461dfbfa53f6b653152fd36'; +const accountApiProvider = AccountApiProvider._(); + +/// The generated endpoint groups, each built on the app's own [dioProvider] so +/// every call goes through the auth header, the 401 refresh and the logging +/// interceptor. `ShopnexusApi` from the generated barrel is deliberately unused: +/// it would build a second Dio with none of that. +/// +/// `AdminApi` has no provider — this app has no staff surface. + +final class AccountApiProvider + extends $FunctionalProvider + with $Provider { + /// The generated endpoint groups, each built on the app's own [dioProvider] so + /// every call goes through the auth header, the 401 refresh and the logging + /// interceptor. `ShopnexusApi` from the generated barrel is deliberately unused: + /// it would build a second Dio with none of that. + /// + /// `AdminApi` has no provider — this app has no staff surface. + const AccountApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'accountApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$accountApiHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + AccountApi create(Ref ref) { + return accountApi(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AccountApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$accountApiHash() => r'6a88a7694ec8c415b62e00a97e21b1b33dccc3e4'; -/// See also [catalogApi]. @ProviderFor(catalogApi) -final catalogApiProvider = AutoDisposeProvider.internal( - catalogApi, - name: r'catalogApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$catalogApiHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CatalogApiRef = AutoDisposeProviderRef; -String _$chatApiHash() => r'5cb98140944bbcbc38f3578bdb75410a652054e5'; +const catalogApiProvider = CatalogApiProvider._(); + +final class CatalogApiProvider + extends $FunctionalProvider + with $Provider { + const CatalogApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'catalogApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$catalogApiHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + CatalogApi create(Ref ref) { + return catalogApi(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(CatalogApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$catalogApiHash() => r'32c800e9ff4823801461dfbfa53f6b653152fd36'; -/// See also [chatApi]. @ProviderFor(chatApi) -final chatApiProvider = AutoDisposeProvider.internal( - chatApi, - name: r'chatApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$chatApiHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef ChatApiRef = AutoDisposeProviderRef; -String _$commonApiHash() => r'8f21f95ff4166dee0d58a25f39550f1aaa5340b5'; +const chatApiProvider = ChatApiProvider._(); + +final class ChatApiProvider + extends $FunctionalProvider + with $Provider { + const ChatApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'chatApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$chatApiHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + ChatApi create(Ref ref) { + return chatApi(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(ChatApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$chatApiHash() => r'5cb98140944bbcbc38f3578bdb75410a652054e5'; /// The registry every module's pluggable choices are read through — the payment rails and /// the carriers. Its own group because the endpoint belongs to no single module. -/// -/// Copied from [commonApi]. + @ProviderFor(commonApi) -final commonApiProvider = AutoDisposeProvider.internal( - commonApi, - name: r'commonApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$commonApiHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CommonApiRef = AutoDisposeProviderRef; -String _$financeApiHash() => r'e93bbdc19c1651833c22a437f01c25d5bb7f510b'; +const commonApiProvider = CommonApiProvider._(); + +/// The registry every module's pluggable choices are read through — the payment rails and +/// the carriers. Its own group because the endpoint belongs to no single module. + +final class CommonApiProvider + extends $FunctionalProvider + with $Provider { + /// The registry every module's pluggable choices are read through — the payment rails and + /// the carriers. Its own group because the endpoint belongs to no single module. + const CommonApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'commonApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$commonApiHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + CommonApi create(Ref ref) { + return commonApi(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(CommonApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$commonApiHash() => r'8f21f95ff4166dee0d58a25f39550f1aaa5340b5'; -/// See also [financeApi]. @ProviderFor(financeApi) -final financeApiProvider = AutoDisposeProvider.internal( - financeApi, - name: r'financeApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$financeApiHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef FinanceApiRef = AutoDisposeProviderRef; -String _$orderApiHash() => r'a9ae52c081dba9da7eb0869186fee133b27b0cf8'; +const financeApiProvider = FinanceApiProvider._(); + +final class FinanceApiProvider + extends $FunctionalProvider + with $Provider { + const FinanceApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'financeApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$financeApiHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + FinanceApi create(Ref ref) { + return financeApi(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(FinanceApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$financeApiHash() => r'e93bbdc19c1651833c22a437f01c25d5bb7f510b'; -/// See also [orderApi]. @ProviderFor(orderApi) -final orderApiProvider = AutoDisposeProvider.internal( - orderApi, - name: r'orderApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$orderApiHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef OrderApiRef = AutoDisposeProviderRef; -String _$trustApiHash() => r'ffbc21f0316988be634d78e61a82f23b3d2d3a28'; +const orderApiProvider = OrderApiProvider._(); + +final class OrderApiProvider + extends $FunctionalProvider + with $Provider { + const OrderApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'orderApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$orderApiHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + OrderApi create(Ref ref) { + return orderApi(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(OrderApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$orderApiHash() => r'a9ae52c081dba9da7eb0869186fee133b27b0cf8'; -/// See also [trustApi]. @ProviderFor(trustApi) -final trustApiProvider = AutoDisposeProvider.internal( - trustApi, - name: r'trustApiProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$trustApiHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef TrustApiRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const trustApiProvider = TrustApiProvider._(); + +final class TrustApiProvider + extends $FunctionalProvider + with $Provider { + const TrustApiProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'trustApiProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$trustApiHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + TrustApi create(Ref ref) { + return trustApi(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(TrustApi value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$trustApiHash() => r'ffbc21f0316988be634d78e61a82f23b3d2d3a28'; diff --git a/lib/api/generated/model/checkout_offer_request.g.dart b/lib/api/generated/model/checkout_offer_request.g.dart index 307fdc4..be5078c 100644 --- a/lib/api/generated/model/checkout_offer_request.g.dart +++ b/lib/api/generated/model/checkout_offer_request.g.dart @@ -30,6 +30,6 @@ Map _$CheckoutOfferRequestToJson( CheckoutOfferRequest instance, ) => { 'contact_id': instance.contactId, - if (instance.note case final value?) 'note': value, + 'note': ?instance.note, 'transport_option': instance.transportOption, }; diff --git a/lib/api/generated/model/checkout_request.g.dart b/lib/api/generated/model/checkout_request.g.dart index cc0bbb7..9cd4290 100644 --- a/lib/api/generated/model/checkout_request.g.dart +++ b/lib/api/generated/model/checkout_request.g.dart @@ -48,6 +48,6 @@ Map _$CheckoutRequestToJson(CheckoutRequest instance) => 'contact_id': instance.contactId, 'currency': instance.currency, 'lines': instance.lines.map((e) => e.toJson()).toList(), - if (instance.note case final value?) 'note': value, + 'note': ?instance.note, 'transport_option': instance.transportOption, }; diff --git a/lib/api/generated/model/create_bank_account_request.g.dart b/lib/api/generated/model/create_bank_account_request.g.dart index 04aa910..a91e381 100644 --- a/lib/api/generated/model/create_bank_account_request.g.dart +++ b/lib/api/generated/model/create_bank_account_request.g.dart @@ -38,5 +38,5 @@ Map _$CreateBankAccountRequestToJson( 'account_holder': instance.accountHolder, 'account_number': instance.accountNumber, 'bank_code': instance.bankCode, - if (instance.isDefault case final value?) 'is_default': value, + 'is_default': ?instance.isDefault, }; diff --git a/lib/api/generated/model/create_category_request.g.dart b/lib/api/generated/model/create_category_request.g.dart index eb8b37a..b794aef 100644 --- a/lib/api/generated/model/create_category_request.g.dart +++ b/lib/api/generated/model/create_category_request.g.dart @@ -21,7 +21,7 @@ CreateCategoryRequest _$CreateCategoryRequestFromJson( Map _$CreateCategoryRequestToJson( CreateCategoryRequest instance, ) => { - if (instance.description case final value?) 'description': value, + 'description': ?instance.description, 'name': instance.name, - if (instance.parentId case final value?) 'parent_id': value, + 'parent_id': ?instance.parentId, }; diff --git a/lib/api/generated/model/create_contact_request.g.dart b/lib/api/generated/model/create_contact_request.g.dart index c89924a..b8914c7 100644 --- a/lib/api/generated/model/create_contact_request.g.dart +++ b/lib/api/generated/model/create_contact_request.g.dart @@ -76,19 +76,18 @@ Map _$CreateContactRequestToJson( CreateContactRequest instance, ) => { 'address': instance.address, - if (instance.addressDetail case final value?) 'address_detail': value, + 'address_detail': ?instance.addressDetail, 'address_type': _$ContactAddressTypeEnumMap[instance.addressType]!, 'country': instance.country, - if (instance.districtCode case final value?) 'district_code': value, - if (instance.districtName case final value?) 'district_name': value, + 'district_code': ?instance.districtCode, + 'district_name': ?instance.districtName, 'full_name': instance.fullName, - if (instance.isDefaultDelivery case final value?) - 'is_default_delivery': value, - if (instance.isDefaultPickup case final value?) 'is_default_pickup': value, - if (instance.latitude case final value?) 'latitude': value, - if (instance.longitude case final value?) 'longitude': value, + 'is_default_delivery': ?instance.isDefaultDelivery, + 'is_default_pickup': ?instance.isDefaultPickup, + 'latitude': ?instance.latitude, + 'longitude': ?instance.longitude, 'phone': instance.phone, - if (instance.postalCode case final value?) 'postal_code': value, + 'postal_code': ?instance.postalCode, 'province_code': instance.provinceCode, 'province_name': instance.provinceName, 'ward_code': instance.wardCode, diff --git a/lib/api/generated/model/create_listing_request.g.dart b/lib/api/generated/model/create_listing_request.g.dart index dbddc22..55994d6 100644 --- a/lib/api/generated/model/create_listing_request.g.dart +++ b/lib/api/generated/model/create_listing_request.g.dart @@ -67,15 +67,15 @@ CreateListingRequest _$CreateListingRequestFromJson( Map _$CreateListingRequestToJson( CreateListingRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, + 'attachments': ?instance.attachments, 'category_id': instance.categoryId, 'condition': _$ListingConditionEnumMap[instance.condition]!, 'currency': instance.currency, - if (instance.description case final value?) 'description': value, + 'description': ?instance.description, 'name': instance.name, 'price_mode': _$PriceModeEnumMap[instance.priceMode]!, - if (instance.specifications case final value?) 'specifications': value, - if (instance.tags case final value?) 'tags': value, + 'specifications': ?instance.specifications, + 'tags': ?instance.tags, 'variants': instance.variants.map((e) => e.toJson()).toList(), }; diff --git a/lib/api/generated/model/create_offer_request.g.dart b/lib/api/generated/model/create_offer_request.g.dart index af99343..ee37792 100644 --- a/lib/api/generated/model/create_offer_request.g.dart +++ b/lib/api/generated/model/create_offer_request.g.dart @@ -21,7 +21,7 @@ CreateOfferRequest _$CreateOfferRequestFromJson(Map json) => Map _$CreateOfferRequestToJson(CreateOfferRequest instance) => { 'quantity': instance.quantity, - if (instance.reason case final value?) 'reason': value, + 'reason': ?instance.reason, 'total': instance.total, 'variant_id': instance.variantId, }; diff --git a/lib/api/generated/model/create_refund_request.g.dart b/lib/api/generated/model/create_refund_request.g.dart index 9cf1c17..6a1b637 100644 --- a/lib/api/generated/model/create_refund_request.g.dart +++ b/lib/api/generated/model/create_refund_request.g.dart @@ -22,6 +22,6 @@ CreateRefundRequest _$CreateRefundRequestFromJson(Map json) => Map _$CreateRefundRequestToJson( CreateRefundRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, + 'attachments': ?instance.attachments, 'reason': instance.reason, }; diff --git a/lib/api/generated/model/create_variant_request.g.dart b/lib/api/generated/model/create_variant_request.g.dart index 56e91e3..a5e8bc2 100644 --- a/lib/api/generated/model/create_variant_request.g.dart +++ b/lib/api/generated/model/create_variant_request.g.dart @@ -42,9 +42,9 @@ CreateVariantRequest _$CreateVariantRequestFromJson( Map _$CreateVariantRequestToJson( CreateVariantRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, + 'attachments': ?instance.attachments, 'attributes': instance.attributes, 'package_details': instance.packageDetails, 'price': instance.price, - if (instance.quantity case final value?) 'quantity': value, + 'quantity': ?instance.quantity, }; diff --git a/lib/api/generated/model/error_error.g.dart b/lib/api/generated/model/error_error.g.dart index cd9cc1f..2ab36b6 100644 --- a/lib/api/generated/model/error_error.g.dart +++ b/lib/api/generated/model/error_error.g.dart @@ -26,8 +26,7 @@ ErrorError _$ErrorErrorFromJson(Map json) => Map _$ErrorErrorToJson(ErrorError instance) => { 'code': instance.code, - if (instance.fields?.map((e) => e.toJson()).toList() case final value?) - 'fields': value, + 'fields': ?instance.fields?.map((e) => e.toJson()).toList(), 'message': instance.message, 'request_id': instance.requestId, }; diff --git a/lib/api/generated/model/identity_verdict_request.g.dart b/lib/api/generated/model/identity_verdict_request.g.dart index d6b24ac..929c285 100644 --- a/lib/api/generated/model/identity_verdict_request.g.dart +++ b/lib/api/generated/model/identity_verdict_request.g.dart @@ -35,9 +35,8 @@ IdentityVerdictRequest _$IdentityVerdictRequestFromJson( Map _$IdentityVerdictRequestToJson( IdentityVerdictRequest instance, ) => { - if (instance.expiresAt?.toIso8601String() case final value?) - 'expires_at': value, - if (instance.rejectionReason case final value?) 'rejection_reason': value, + 'expires_at': ?instance.expiresAt?.toIso8601String(), + 'rejection_reason': ?instance.rejectionReason, 'status': _$IdentityVerdictRequestStatusEnumEnumMap[instance.status]!, }; diff --git a/lib/api/generated/model/logout_request.g.dart b/lib/api/generated/model/logout_request.g.dart index b044be9..5ab4f90 100644 --- a/lib/api/generated/model/logout_request.g.dart +++ b/lib/api/generated/model/logout_request.g.dart @@ -15,6 +15,4 @@ LogoutRequest _$LogoutRequestFromJson(Map json) => }, fieldKeyMap: const {'deviceId': 'device_id'}); Map _$LogoutRequestToJson(LogoutRequest instance) => - { - if (instance.deviceId case final value?) 'device_id': value, - }; + {'device_id': ?instance.deviceId}; diff --git a/lib/api/generated/model/mark_conversation_read_request.g.dart b/lib/api/generated/model/mark_conversation_read_request.g.dart index 1c6caec..6f71b39 100644 --- a/lib/api/generated/model/mark_conversation_read_request.g.dart +++ b/lib/api/generated/model/mark_conversation_read_request.g.dart @@ -20,6 +20,4 @@ MarkConversationReadRequest _$MarkConversationReadRequestFromJson( Map _$MarkConversationReadRequestToJson( MarkConversationReadRequest instance, -) => { - if (instance.before?.toIso8601String() case final value?) 'before': value, -}; +) => {'before': ?instance.before?.toIso8601String()}; diff --git a/lib/api/generated/model/mark_notifications_read_request.g.dart b/lib/api/generated/model/mark_notifications_read_request.g.dart index d7e6879..cb23723 100644 --- a/lib/api/generated/model/mark_notifications_read_request.g.dart +++ b/lib/api/generated/model/mark_notifications_read_request.g.dart @@ -20,6 +20,4 @@ MarkNotificationsReadRequest _$MarkNotificationsReadRequestFromJson( Map _$MarkNotificationsReadRequestToJson( MarkNotificationsReadRequest instance, -) => { - if (instance.before?.toIso8601String() case final value?) 'before': value, -}; +) => {'before': ?instance.before?.toIso8601String()}; diff --git a/lib/api/generated/model/moderation_note_request.g.dart b/lib/api/generated/model/moderation_note_request.g.dart index fb1f702..827aa17 100644 --- a/lib/api/generated/model/moderation_note_request.g.dart +++ b/lib/api/generated/model/moderation_note_request.g.dart @@ -17,4 +17,4 @@ ModerationNoteRequest _$ModerationNoteRequestFromJson( Map _$ModerationNoteRequestToJson( ModerationNoteRequest instance, -) => {if (instance.note case final value?) 'note': value}; +) => {'note': ?instance.note}; diff --git a/lib/api/generated/model/o_auth_login_request.g.dart b/lib/api/generated/model/o_auth_login_request.g.dart index da46be1..fa580a7 100644 --- a/lib/api/generated/model/o_auth_login_request.g.dart +++ b/lib/api/generated/model/o_auth_login_request.g.dart @@ -21,9 +21,9 @@ OAuthLoginRequest _$OAuthLoginRequestFromJson(Map json) => Map _$OAuthLoginRequestToJson(OAuthLoginRequest instance) => { - if (instance.country case final value?) 'country': value, + 'country': ?instance.country, 'credential': instance.credential, - if (instance.locale case final value?) 'locale': value, + 'locale': ?instance.locale, 'provider': instance.provider, - if (instance.timezone case final value?) 'timezone': value, + 'timezone': ?instance.timezone, }; diff --git a/lib/api/generated/model/open_ticket_request.g.dart b/lib/api/generated/model/open_ticket_request.g.dart index a0c5263..d9ebac8 100644 --- a/lib/api/generated/model/open_ticket_request.g.dart +++ b/lib/api/generated/model/open_ticket_request.g.dart @@ -29,16 +29,15 @@ OpenTicketRequest _$OpenTicketRequestFromJson(Map json) => return val; }, fieldKeyMap: const {'refId': 'ref_id'}); -Map _$OpenTicketRequestToJson( - OpenTicketRequest instance, -) => { - if (instance.attachments case final value?) 'attachments': value, - if (instance.body case final value?) 'body': value, - 'kind': _$TicketKindEnumMap[instance.kind]!, - if (_$TicketReasonEnumMap[instance.reason] case final value?) 'reason': value, - if (instance.refId case final value?) 'ref_id': value, - 'subject': instance.subject, -}; +Map _$OpenTicketRequestToJson(OpenTicketRequest instance) => + { + 'attachments': ?instance.attachments, + 'body': ?instance.body, + 'kind': _$TicketKindEnumMap[instance.kind]!, + 'reason': ?_$TicketReasonEnumMap[instance.reason], + 'ref_id': ?instance.refId, + 'subject': instance.subject, + }; const _$TicketKindEnumMap = { TicketKind.reportListing: 'report-listing', diff --git a/lib/api/generated/model/publish_listing_request.g.dart b/lib/api/generated/model/publish_listing_request.g.dart index 1947ae5..1eb38bb 100644 --- a/lib/api/generated/model/publish_listing_request.g.dart +++ b/lib/api/generated/model/publish_listing_request.g.dart @@ -25,6 +25,4 @@ PublishListingRequest _$PublishListingRequestFromJson( Map _$PublishListingRequestToJson( PublishListingRequest instance, -) => { - if (instance.pickupContactId case final value?) 'pickup_contact_id': value, -}; +) => {'pickup_contact_id': ?instance.pickupContactId}; diff --git a/lib/api/generated/model/put_tag_request.g.dart b/lib/api/generated/model/put_tag_request.g.dart index 64d55e9..5d5dcb6 100644 --- a/lib/api/generated/model/put_tag_request.g.dart +++ b/lib/api/generated/model/put_tag_request.g.dart @@ -15,6 +15,4 @@ PutTagRequest _$PutTagRequestFromJson(Map json) => }); Map _$PutTagRequestToJson(PutTagRequest instance) => - { - if (instance.description case final value?) 'description': value, - }; + {'description': ?instance.description}; diff --git a/lib/api/generated/model/refund_verdict_request.g.dart b/lib/api/generated/model/refund_verdict_request.g.dart index d2d8acb..126bc6a 100644 --- a/lib/api/generated/model/refund_verdict_request.g.dart +++ b/lib/api/generated/model/refund_verdict_request.g.dart @@ -21,5 +21,5 @@ Map _$RefundVerdictRequestToJson( RefundVerdictRequest instance, ) => { 'buyer_wins': instance.buyerWins, - if (instance.note case final value?) 'note': value, + 'note': ?instance.note, }; diff --git a/lib/api/generated/model/register_request.g.dart b/lib/api/generated/model/register_request.g.dart index 929bae6..b27554c 100644 --- a/lib/api/generated/model/register_request.g.dart +++ b/lib/api/generated/model/register_request.g.dart @@ -34,11 +34,11 @@ RegisterRequest _$RegisterRequestFromJson(Map json) => Map _$RegisterRequestToJson(RegisterRequest instance) => { 'country': instance.country, - if (instance.email case final value?) 'email': value, + 'email': ?instance.email, 'locale': instance.locale, 'name': instance.name, 'password': instance.password, - if (instance.phone case final value?) 'phone': value, + 'phone': ?instance.phone, 'timezone': instance.timezone, - if (instance.username case final value?) 'username': value, + 'username': ?instance.username, }; diff --git a/lib/api/generated/model/resolve_ticket_request.g.dart b/lib/api/generated/model/resolve_ticket_request.g.dart index 35d6af3..4835be3 100644 --- a/lib/api/generated/model/resolve_ticket_request.g.dart +++ b/lib/api/generated/model/resolve_ticket_request.g.dart @@ -24,7 +24,7 @@ Map _$ResolveTicketRequestToJson( ResolveTicketRequest instance, ) => { 'action_taken': _$TicketResolutionActionEnumMap[instance.actionTaken]!, - if (instance.note case final value?) 'note': value, + 'note': ?instance.note, }; const _$TicketResolutionActionEnumMap = { diff --git a/lib/api/generated/model/save_option_request.g.dart b/lib/api/generated/model/save_option_request.g.dart index 6236e45..b575753 100644 --- a/lib/api/generated/model/save_option_request.g.dart +++ b/lib/api/generated/model/save_option_request.g.dart @@ -20,9 +20,9 @@ SaveOptionRequest _$SaveOptionRequestFromJson(Map json) => Map _$SaveOptionRequestToJson(SaveOptionRequest instance) => { - if (instance.description case final value?) 'description': value, - if (instance.isEnabled case final value?) 'is_enabled': value, - if (instance.name case final value?) 'name': value, - if (instance.priority case final value?) 'priority': value, - if (instance.provider case final value?) 'provider': value, + 'description': ?instance.description, + 'is_enabled': ?instance.isEnabled, + 'name': ?instance.name, + 'priority': ?instance.priority, + 'provider': ?instance.provider, }; diff --git a/lib/api/generated/model/send_message_request.g.dart b/lib/api/generated/model/send_message_request.g.dart index 6a52751..719b78c 100644 --- a/lib/api/generated/model/send_message_request.g.dart +++ b/lib/api/generated/model/send_message_request.g.dart @@ -26,7 +26,7 @@ SendMessageRequest _$SendMessageRequestFromJson(Map json) => Map _$SendMessageRequestToJson(SendMessageRequest instance) => { - if (instance.attachments case final value?) 'attachments': value, - if (instance.body case final value?) 'body': value, - if (instance.refs case final value?) 'refs': value, + 'attachments': ?instance.attachments, + 'body': ?instance.body, + 'refs': ?instance.refs, }; diff --git a/lib/api/generated/model/shipping_quotes_request.g.dart b/lib/api/generated/model/shipping_quotes_request.g.dart index 7ace0eb..b5e4912 100644 --- a/lib/api/generated/model/shipping_quotes_request.g.dart +++ b/lib/api/generated/model/shipping_quotes_request.g.dart @@ -38,11 +38,10 @@ ShippingQuotesRequest _$ShippingQuotesRequestFromJson( Map _$ShippingQuotesRequestToJson( ShippingQuotesRequest instance, ) => { - if (instance.contactId case final value?) 'contact_id': value, - if (instance.draftId case final value?) 'draft_id': value, - if (instance.lines?.map((e) => e.toJson()).toList() case final value?) - 'lines': value, - if (instance.offerId case final value?) 'offer_id': value, - if (instance.quantity case final value?) 'quantity': value, - if (instance.variantId case final value?) 'variant_id': value, + 'contact_id': ?instance.contactId, + 'draft_id': ?instance.draftId, + 'lines': ?instance.lines?.map((e) => e.toJson()).toList(), + 'offer_id': ?instance.offerId, + 'quantity': ?instance.quantity, + 'variant_id': ?instance.variantId, }; diff --git a/lib/api/generated/model/start_identity_verification_request.g.dart b/lib/api/generated/model/start_identity_verification_request.g.dart index 13238d1..b5ad30a 100644 --- a/lib/api/generated/model/start_identity_verification_request.g.dart +++ b/lib/api/generated/model/start_identity_verification_request.g.dart @@ -45,7 +45,7 @@ StartIdentityVerificationRequest _$StartIdentityVerificationRequestFromJson( Map _$StartIdentityVerificationRequestToJson( StartIdentityVerificationRequest instance, ) => { - if (instance.backResourceId case final value?) 'back_resource_id': value, + 'back_resource_id': ?instance.backResourceId, 'doc_type': _$IdentityDocumentTypeEnumMap[instance.docType]!, 'front_resource_id': instance.frontResourceId, 'selfie_resource_id': instance.selfieResourceId, diff --git a/lib/api/generated/model/start_payment_request.g.dart b/lib/api/generated/model/start_payment_request.g.dart index ba8d3b6..46682d1 100644 --- a/lib/api/generated/model/start_payment_request.g.dart +++ b/lib/api/generated/model/start_payment_request.g.dart @@ -28,7 +28,7 @@ StartPaymentRequest _$StartPaymentRequestFromJson(Map json) => Map _$StartPaymentRequestToJson( StartPaymentRequest instance, ) => { - if (instance.amount case final value?) 'amount': value, + 'amount': ?instance.amount, 'payment_option': instance.paymentOption, - if (instance.returnUrl case final value?) 'return_url': value, + 'return_url': ?instance.returnUrl, }; diff --git a/lib/api/generated/model/submit_feedback_request.g.dart b/lib/api/generated/model/submit_feedback_request.g.dart index 79f6b4a..e805202 100644 --- a/lib/api/generated/model/submit_feedback_request.g.dart +++ b/lib/api/generated/model/submit_feedback_request.g.dart @@ -19,7 +19,4 @@ SubmitFeedbackRequest _$SubmitFeedbackRequestFromJson( Map _$SubmitFeedbackRequestToJson( SubmitFeedbackRequest instance, -) => { - if (instance.comment case final value?) 'comment': value, - 'rating': instance.rating, -}; +) => {'comment': ?instance.comment, 'rating': instance.rating}; diff --git a/lib/api/generated/model/submit_review_request.g.dart b/lib/api/generated/model/submit_review_request.g.dart index c316dd2..ab0ca22 100644 --- a/lib/api/generated/model/submit_review_request.g.dart +++ b/lib/api/generated/model/submit_review_request.g.dart @@ -24,8 +24,8 @@ SubmitReviewRequest _$SubmitReviewRequestFromJson(Map json) => Map _$SubmitReviewRequestToJson( SubmitReviewRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, - if (instance.body case final value?) 'body': value, + 'attachments': ?instance.attachments, + 'body': ?instance.body, 'order_id': instance.orderId, 'rating': instance.rating, }; diff --git a/lib/api/generated/model/suggest_listing_request.g.dart b/lib/api/generated/model/suggest_listing_request.g.dart index e8ce117..4789f8b 100644 --- a/lib/api/generated/model/suggest_listing_request.g.dart +++ b/lib/api/generated/model/suggest_listing_request.g.dart @@ -33,9 +33,9 @@ SuggestListingRequest _$SuggestListingRequestFromJson( Map _$SuggestListingRequestToJson( SuggestListingRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, - if (instance.language case final value?) 'language': value, - if (instance.note case final value?) 'note': value, - if (instance.voiceNote case final value?) 'voice_note': value, - if (instance.voiceNoteMime case final value?) 'voice_note_mime': value, + 'attachments': ?instance.attachments, + 'language': ?instance.language, + 'note': ?instance.note, + 'voice_note': ?instance.voiceNote, + 'voice_note_mime': ?instance.voiceNoteMime, }; diff --git a/lib/api/generated/model/suspend_account_request.g.dart b/lib/api/generated/model/suspend_account_request.g.dart index 01c0ca1..0eecd70 100644 --- a/lib/api/generated/model/suspend_account_request.g.dart +++ b/lib/api/generated/model/suspend_account_request.g.dart @@ -24,5 +24,5 @@ Map _$SuspendAccountRequestToJson( SuspendAccountRequest instance, ) => { 'reason': instance.reason, - if (instance.until?.toIso8601String() case final value?) 'until': value, + 'until': ?instance.until?.toIso8601String(), }; diff --git a/lib/api/generated/model/takedown_request.g.dart b/lib/api/generated/model/takedown_request.g.dart index ad7c57a..89d49b7 100644 --- a/lib/api/generated/model/takedown_request.g.dart +++ b/lib/api/generated/model/takedown_request.g.dart @@ -21,6 +21,6 @@ TakedownRequest _$TakedownRequestFromJson(Map json) => Map _$TakedownRequestToJson(TakedownRequest instance) => { - if (instance.notifySeller case final value?) 'notify_seller': value, + 'notify_seller': ?instance.notifySeller, 'reason': instance.reason, }; diff --git a/lib/api/generated/model/tax_verification_request.g.dart b/lib/api/generated/model/tax_verification_request.g.dart index 5c47385..124f03c 100644 --- a/lib/api/generated/model/tax_verification_request.g.dart +++ b/lib/api/generated/model/tax_verification_request.g.dart @@ -24,7 +24,7 @@ TaxVerificationRequest _$TaxVerificationRequestFromJson( Map _$TaxVerificationRequestToJson( TaxVerificationRequest instance, ) => { - if (instance.note case final value?) 'note': value, + 'note': ?instance.note, 'source': instance.source_, 'status': _$TaxVerificationRequestStatusEnumEnumMap[instance.status]!, }; diff --git a/lib/api/generated/model/update_account_request.g.dart b/lib/api/generated/model/update_account_request.g.dart index fc3ed1c..dc206d5 100644 --- a/lib/api/generated/model/update_account_request.g.dart +++ b/lib/api/generated/model/update_account_request.g.dart @@ -32,10 +32,10 @@ UpdateAccountRequest _$UpdateAccountRequestFromJson( Map _$UpdateAccountRequestToJson( UpdateAccountRequest instance, ) => { - if (instance.clearEmail case final value?) 'clear_email': value, - if (instance.clearPhone case final value?) 'clear_phone': value, - if (instance.clearUsername case final value?) 'clear_username': value, - if (instance.email case final value?) 'email': value, - if (instance.phone case final value?) 'phone': value, - if (instance.username case final value?) 'username': value, + 'clear_email': ?instance.clearEmail, + 'clear_phone': ?instance.clearPhone, + 'clear_username': ?instance.clearUsername, + 'email': ?instance.email, + 'phone': ?instance.phone, + 'username': ?instance.username, }; diff --git a/lib/api/generated/model/update_category_request.g.dart b/lib/api/generated/model/update_category_request.g.dart index 28d0096..21e7b36 100644 --- a/lib/api/generated/model/update_category_request.g.dart +++ b/lib/api/generated/model/update_category_request.g.dart @@ -29,8 +29,8 @@ UpdateCategoryRequest _$UpdateCategoryRequestFromJson( Map _$UpdateCategoryRequestToJson( UpdateCategoryRequest instance, ) => { - if (instance.clearParentId case final value?) 'clear_parent_id': value, - if (instance.description case final value?) 'description': value, - if (instance.name case final value?) 'name': value, - if (instance.parentId case final value?) 'parent_id': value, + 'clear_parent_id': ?instance.clearParentId, + 'description': ?instance.description, + 'name': ?instance.name, + 'parent_id': ?instance.parentId, }; diff --git a/lib/api/generated/model/update_contact_request.g.dart b/lib/api/generated/model/update_contact_request.g.dart index 2232d70..f808984 100644 --- a/lib/api/generated/model/update_contact_request.g.dart +++ b/lib/api/generated/model/update_contact_request.g.dart @@ -69,30 +69,27 @@ UpdateContactRequest _$UpdateContactRequestFromJson( Map _$UpdateContactRequestToJson( UpdateContactRequest instance, ) => { - if (instance.address case final value?) 'address': value, - if (instance.addressDetail case final value?) 'address_detail': value, - if (_$ContactAddressTypeEnumMap[instance.addressType] case final value?) - 'address_type': value, - if (instance.clearAddressDetail case final value?) - 'clear_address_detail': value, - if (instance.clearDistrict case final value?) 'clear_district': value, - if (instance.clearLocation case final value?) 'clear_location': value, - if (instance.clearPostalCode case final value?) 'clear_postal_code': value, - if (instance.country case final value?) 'country': value, - if (instance.districtCode case final value?) 'district_code': value, - if (instance.districtName case final value?) 'district_name': value, - if (instance.fullName case final value?) 'full_name': value, - if (instance.isDefaultDelivery case final value?) - 'is_default_delivery': value, - if (instance.isDefaultPickup case final value?) 'is_default_pickup': value, - if (instance.latitude case final value?) 'latitude': value, - if (instance.longitude case final value?) 'longitude': value, - if (instance.phone case final value?) 'phone': value, - if (instance.postalCode case final value?) 'postal_code': value, - if (instance.provinceCode case final value?) 'province_code': value, - if (instance.provinceName case final value?) 'province_name': value, - if (instance.wardCode case final value?) 'ward_code': value, - if (instance.wardName case final value?) 'ward_name': value, + 'address': ?instance.address, + 'address_detail': ?instance.addressDetail, + 'address_type': ?_$ContactAddressTypeEnumMap[instance.addressType], + 'clear_address_detail': ?instance.clearAddressDetail, + 'clear_district': ?instance.clearDistrict, + 'clear_location': ?instance.clearLocation, + 'clear_postal_code': ?instance.clearPostalCode, + 'country': ?instance.country, + 'district_code': ?instance.districtCode, + 'district_name': ?instance.districtName, + 'full_name': ?instance.fullName, + 'is_default_delivery': ?instance.isDefaultDelivery, + 'is_default_pickup': ?instance.isDefaultPickup, + 'latitude': ?instance.latitude, + 'longitude': ?instance.longitude, + 'phone': ?instance.phone, + 'postal_code': ?instance.postalCode, + 'province_code': ?instance.provinceCode, + 'province_name': ?instance.provinceName, + 'ward_code': ?instance.wardCode, + 'ward_name': ?instance.wardName, }; const _$ContactAddressTypeEnumMap = { diff --git a/lib/api/generated/model/update_listing_request.g.dart b/lib/api/generated/model/update_listing_request.g.dart index 7f15a7e..cd69b0c 100644 --- a/lib/api/generated/model/update_listing_request.g.dart +++ b/lib/api/generated/model/update_listing_request.g.dart @@ -60,20 +60,16 @@ UpdateListingRequest _$UpdateListingRequestFromJson( Map _$UpdateListingRequestToJson( UpdateListingRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, - if (instance.categoryId case final value?) 'category_id': value, - if (instance.clearFeaturedVariantId case final value?) - 'clear_featured_variant_id': value, - if (_$ListingConditionEnumMap[instance.condition] case final value?) - 'condition': value, - if (instance.description case final value?) 'description': value, - if (instance.featuredVariantId case final value?) - 'featured_variant_id': value, - if (instance.name case final value?) 'name': value, - if (_$PriceModeEnumMap[instance.priceMode] case final value?) - 'price_mode': value, - if (instance.specifications case final value?) 'specifications': value, - if (instance.tags case final value?) 'tags': value, + 'attachments': ?instance.attachments, + 'category_id': ?instance.categoryId, + 'clear_featured_variant_id': ?instance.clearFeaturedVariantId, + 'condition': ?_$ListingConditionEnumMap[instance.condition], + 'description': ?instance.description, + 'featured_variant_id': ?instance.featuredVariantId, + 'name': ?instance.name, + 'price_mode': ?_$PriceModeEnumMap[instance.priceMode], + 'specifications': ?instance.specifications, + 'tags': ?instance.tags, }; const _$ListingConditionEnumMap = { diff --git a/lib/api/generated/model/update_offer_request.g.dart b/lib/api/generated/model/update_offer_request.g.dart index 4f674a9..7fdae19 100644 --- a/lib/api/generated/model/update_offer_request.g.dart +++ b/lib/api/generated/model/update_offer_request.g.dart @@ -20,6 +20,6 @@ UpdateOfferRequest _$UpdateOfferRequestFromJson(Map json) => Map _$UpdateOfferRequestToJson(UpdateOfferRequest instance) => { 'quantity': instance.quantity, - if (instance.reason case final value?) 'reason': value, + 'reason': ?instance.reason, 'total': instance.total, }; diff --git a/lib/api/generated/model/update_profile_request.g.dart b/lib/api/generated/model/update_profile_request.g.dart index d5db5d6..6f97240 100644 --- a/lib/api/generated/model/update_profile_request.g.dart +++ b/lib/api/generated/model/update_profile_request.g.dart @@ -53,20 +53,18 @@ UpdateProfileRequest _$UpdateProfileRequestFromJson( Map _$UpdateProfileRequestToJson( UpdateProfileRequest instance, ) => { - if (instance.avatarResourceId case final value?) 'avatar_resource_id': value, - if (instance.clearAvatarResourceId case final value?) - 'clear_avatar_resource_id': value, - if (instance.clearDateOfBirth case final value?) 'clear_date_of_birth': value, - if (instance.clearDescription case final value?) 'clear_description': value, - if (instance.clearGender case final value?) 'clear_gender': value, - if (instance.country case final value?) 'country': value, - if (instance.dateOfBirth case final value?) 'date_of_birth': value, - if (instance.description case final value?) 'description': value, - if (_$ProfileGenderEnumMap[instance.gender] case final value?) - 'gender': value, - if (instance.locale case final value?) 'locale': value, - if (instance.name case final value?) 'name': value, - if (instance.timezone case final value?) 'timezone': value, + 'avatar_resource_id': ?instance.avatarResourceId, + 'clear_avatar_resource_id': ?instance.clearAvatarResourceId, + 'clear_date_of_birth': ?instance.clearDateOfBirth, + 'clear_description': ?instance.clearDescription, + 'clear_gender': ?instance.clearGender, + 'country': ?instance.country, + 'date_of_birth': ?instance.dateOfBirth, + 'description': ?instance.description, + 'gender': ?_$ProfileGenderEnumMap[instance.gender], + 'locale': ?instance.locale, + 'name': ?instance.name, + 'timezone': ?instance.timezone, }; const _$ProfileGenderEnumMap = { diff --git a/lib/api/generated/model/update_review_request.g.dart b/lib/api/generated/model/update_review_request.g.dart index a7c9ee2..f910a82 100644 --- a/lib/api/generated/model/update_review_request.g.dart +++ b/lib/api/generated/model/update_review_request.g.dart @@ -22,7 +22,7 @@ UpdateReviewRequest _$UpdateReviewRequestFromJson(Map json) => Map _$UpdateReviewRequestToJson( UpdateReviewRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, - if (instance.body case final value?) 'body': value, - if (instance.rating case final value?) 'rating': value, + 'attachments': ?instance.attachments, + 'body': ?instance.body, + 'rating': ?instance.rating, }; diff --git a/lib/api/generated/model/update_variant_request.g.dart b/lib/api/generated/model/update_variant_request.g.dart index b284a17..3d05a1d 100644 --- a/lib/api/generated/model/update_variant_request.g.dart +++ b/lib/api/generated/model/update_variant_request.g.dart @@ -44,10 +44,10 @@ UpdateVariantRequest _$UpdateVariantRequestFromJson( Map _$UpdateVariantRequestToJson( UpdateVariantRequest instance, ) => { - if (instance.attachments case final value?) 'attachments': value, - if (instance.attributes case final value?) 'attributes': value, - if (instance.isFeatured case final value?) 'is_featured': value, - if (instance.packageDetails case final value?) 'package_details': value, - if (instance.price case final value?) 'price': value, - if (instance.quantity case final value?) 'quantity': value, + 'attachments': ?instance.attachments, + 'attributes': ?instance.attributes, + 'is_featured': ?instance.isFeatured, + 'package_details': ?instance.packageDetails, + 'price': ?instance.price, + 'quantity': ?instance.quantity, }; diff --git a/lib/api/generated/model/wallet_adjustment_request.g.dart b/lib/api/generated/model/wallet_adjustment_request.g.dart index 490aa40..fd8c297 100644 --- a/lib/api/generated/model/wallet_adjustment_request.g.dart +++ b/lib/api/generated/model/wallet_adjustment_request.g.dart @@ -41,9 +41,9 @@ WalletAdjustmentRequest _$WalletAdjustmentRequestFromJson( Map _$WalletAdjustmentRequestToJson( WalletAdjustmentRequest instance, ) => { - if (instance.availableDelta case final value?) 'available_delta': value, + 'available_delta': ?instance.availableDelta, 'currency': instance.currency, - if (instance.heldDelta case final value?) 'held_delta': value, + 'held_delta': ?instance.heldDelta, 'idempotency_key': instance.idempotencyKey, 'reason': instance.reason, }; diff --git a/lib/api/generated/model/withdrawal_approval_request.g.dart b/lib/api/generated/model/withdrawal_approval_request.g.dart index 149adc5..ba2d71d 100644 --- a/lib/api/generated/model/withdrawal_approval_request.g.dart +++ b/lib/api/generated/model/withdrawal_approval_request.g.dart @@ -24,6 +24,6 @@ WithdrawalApprovalRequest _$WithdrawalApprovalRequestFromJson( Map _$WithdrawalApprovalRequestToJson( WithdrawalApprovalRequest instance, ) => { - if (instance.providerRef case final value?) 'provider_ref': value, - if (instance.reason case final value?) 'reason': value, + 'provider_ref': ?instance.providerRef, + 'reason': ?instance.reason, }; diff --git a/lib/core/network/dio_client.dart b/lib/core/network/dio_client.dart index e150712..6d2390e 100644 --- a/lib/core/network/dio_client.dart +++ b/lib/core/network/dio_client.dart @@ -13,6 +13,14 @@ Dio dio(Ref ref) { baseUrl: ApiEndpoints.baseUrl, connectTimeout: const Duration(seconds: 30), receiveTimeout: const Duration(seconds: 30), + // Every array query parameter this API has — `/listings?ids`, `/tags?near`, + // `/categories?near` — is `style: form, explode: false`, i.e. one parameter + // holding a comma-joined list. Dio's default is the opposite (`ids=a&ids=b`), + // and the server reads only the first value of a repeated key: an + // order with three lines resolved exactly one listing, so the other two + // rendered "Sản phẩm không còn trong danh mục" for products that were never + // gone. + listFormat: ListFormat.csv, headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', diff --git a/lib/core/network/dio_client.g.dart b/lib/core/network/dio_client.g.dart index ef57c61..50b211c 100644 --- a/lib/core/network/dio_client.g.dart +++ b/lib/core/network/dio_client.g.dart @@ -6,22 +6,45 @@ part of 'dio_client.dart'; // RiverpodGenerator // ************************************************************************** -String _$dioHash() => r'c7cc8a0be806250576646757cfa60f806e84f7e5'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [dio]. @ProviderFor(dio) -final dioProvider = AutoDisposeProvider.internal( - dio, - name: r'dioProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$dioHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef DioRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const dioProvider = DioProvider._(); + +final class DioProvider extends $FunctionalProvider + with $Provider { + const DioProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'dioProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$dioHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + Dio create(Ref ref) { + return dio(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(Dio value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$dioHash() => r'f10704cb6759dbfd944eed2f6ee8df9f1ad08489'; diff --git a/lib/core/network/resource_upload.dart b/lib/core/network/resource_upload.dart index 994bfb1..3307646 100644 --- a/lib/core/network/resource_upload.dart +++ b/lib/core/network/resource_upload.dart @@ -18,11 +18,12 @@ import 'package:shopnexus_flutter_app/api/generated/model/upload_slot.dart'; /// Một hàm, một cách làm. Header lấy nguyên từ slot: đó là những gì chữ ký đã /// bao gồm, nên thêm hay đè lên chúng là cách chắc chắn nhất để nhận 403 từ /// object store. -Future putToSlot(UploadSlot slot, List bytes) async { - // Dio trần: URL đã ký sẵn cho đúng key và đúng method, và bearer token của sàn - // không có việc gì ở một object store không phải API này — vài store còn từ - // chối request mang cả hai. - await Dio().put( +/// [client] chỉ để test thay được: mặc định là một Dio trần, và đó mới là điều +/// đúng khi chạy thật. URL đã ký sẵn cho đúng key và đúng method, còn bearer +/// token của sàn thì không có việc gì ở một object store không phải API này — +/// vài store còn từ chối thẳng request mang cả hai. +Future putToSlot(UploadSlot slot, List bytes, {Dio? client}) async { + await (client ?? Dio()).put( slot.url, data: Stream>.fromIterable([bytes]), options: Options( diff --git a/lib/core/providers/option_names_provider.g.dart b/lib/core/providers/option_names_provider.g.dart index 7822bd2..b2fb2ee 100644 --- a/lib/core/providers/option_names_provider.g.dart +++ b/lib/core/providers/option_names_provider.g.dart @@ -6,29 +6,8 @@ part of 'option_names_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$optionNamesHash() => r'c45bbd39552fad0d62ed4779952bbdf06e2c3397'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Tên hiển thị của một `option` slug, cho cả hai nhóm dùng nó. /// /// Một bản ghi đã xong giữ slug làm bằng — `transaction.payment_option`, @@ -38,10 +17,9 @@ class _SystemHash { /// /// `keepAlive`: danh sách này đổi khi vận hành đổi nó, không đổi theo màn hình, và /// mỗi lần mở một sheet mà gọi lại là một request cho dữ liệu vừa đọc xong. -/// -/// Copied from [optionNames]. + @ProviderFor(optionNames) -const optionNamesProvider = OptionNamesFamily(); +const optionNamesProvider = OptionNamesFamily._(); /// Tên hiển thị của một `option` slug, cho cả hai nhóm dùng nó. /// @@ -52,22 +30,17 @@ const optionNamesProvider = OptionNamesFamily(); /// /// `keepAlive`: danh sách này đổi khi vận hành đổi nó, không đổi theo màn hình, và /// mỗi lần mở một sheet mà gọi lại là một request cho dữ liệu vừa đọc xong. -/// -/// Copied from [optionNames]. -class OptionNamesFamily extends Family>> { - /// Tên hiển thị của một `option` slug, cho cả hai nhóm dùng nó. - /// - /// Một bản ghi đã xong giữ slug làm bằng — `transaction.payment_option`, - /// `transport.option` — nên chỗ nào vẽ nó cũng cần tra tên. Trước đây ba màn in - /// thẳng slug: người mua đọc "sepay-bank-transfer" và "mock-standard" thay vì - /// "Chuyển khoản ngân hàng (SePay)". - /// - /// `keepAlive`: danh sách này đổi khi vận hành đổi nó, không đổi theo màn hình, và - /// mỗi lần mở một sheet mà gọi lại là một request cho dữ liệu vừa đọc xong. - /// - /// Copied from [optionNames]. - const OptionNamesFamily(); +final class OptionNamesProvider + extends + $FunctionalProvider< + AsyncValue>, + Map, + FutureOr> + > + with + $FutureModifier>, + $FutureProvider> { /// Tên hiển thị của một `option` slug, cho cả hai nhóm dùng nó. /// /// Một bản ghi đã xong giữ slug làm bằng — `transaction.payment_option`, @@ -77,34 +50,52 @@ class OptionNamesFamily extends Family>> { /// /// `keepAlive`: danh sách này đổi khi vận hành đổi nó, không đổi theo màn hình, và /// mỗi lần mở một sheet mà gọi lại là một request cho dữ liệu vừa đọc xong. - /// - /// Copied from [optionNames]. - OptionNamesProvider call(OptionCategoryName category) { - return OptionNamesProvider(category); - } + const OptionNamesProvider._({ + required OptionNamesFamily super.from, + required OptionCategoryName super.argument, + }) : super( + retry: null, + name: r'optionNamesProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - OptionNamesProvider getProviderOverride( - covariant OptionNamesProvider provider, - ) { - return call(provider.category); - } + String debugGetCreateSourceHash() => _$optionNamesHash(); - static const Iterable? _dependencies = null; + @override + String toString() { + return r'optionNamesProvider' + '' + '($argument)'; + } + @$internal @override - Iterable? get dependencies => _dependencies; + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); - static const Iterable? _allTransitiveDependencies = null; + @override + FutureOr> create(Ref ref) { + final argument = this.argument as OptionCategoryName; + return optionNames(ref, argument); + } @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; + bool operator ==(Object other) { + return other is OptionNamesProvider && other.argument == argument; + } @override - String? get name => r'optionNamesProvider'; + int get hashCode { + return argument.hashCode; + } } +String _$optionNamesHash() => r'c45bbd39552fad0d62ed4779952bbdf06e2c3397'; + /// Tên hiển thị của một `option` slug, cho cả hai nhóm dùng nó. /// /// Một bản ghi đã xong giữ slug làm bằng — `transaction.payment_option`, @@ -114,9 +105,22 @@ class OptionNamesFamily extends Family>> { /// /// `keepAlive`: danh sách này đổi khi vận hành đổi nó, không đổi theo màn hình, và /// mỗi lần mở một sheet mà gọi lại là một request cho dữ liệu vừa đọc xong. -/// -/// Copied from [optionNames]. -class OptionNamesProvider extends FutureProvider> { + +final class OptionNamesFamily extends $Family + with + $FunctionalFamilyOverride< + FutureOr>, + OptionCategoryName + > { + const OptionNamesFamily._() + : super( + retry: null, + name: r'optionNamesProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: false, + ); + /// Tên hiển thị của một `option` slug, cho cả hai nhóm dùng nó. /// /// Một bản ghi đã xong giữ slug làm bằng — `transaction.payment_option`, @@ -126,85 +130,10 @@ class OptionNamesProvider extends FutureProvider> { /// /// `keepAlive`: danh sách này đổi khi vận hành đổi nó, không đổi theo màn hình, và /// mỗi lần mở một sheet mà gọi lại là một request cho dữ liệu vừa đọc xong. - /// - /// Copied from [optionNames]. - OptionNamesProvider(OptionCategoryName category) - : this._internal( - (ref) => optionNames(ref as OptionNamesRef, category), - from: optionNamesProvider, - name: r'optionNamesProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$optionNamesHash, - dependencies: OptionNamesFamily._dependencies, - allTransitiveDependencies: OptionNamesFamily._allTransitiveDependencies, - category: category, - ); - - OptionNamesProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.category, - }) : super.internal(); - - final OptionCategoryName category; - @override - Override overrideWith( - FutureOr> Function(OptionNamesRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: OptionNamesProvider._internal( - (ref) => create(ref as OptionNamesRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - category: category, - ), - ); - } + OptionNamesProvider call(OptionCategoryName category) => + OptionNamesProvider._(argument: category, from: this); @override - FutureProviderElement> createElement() { - return _OptionNamesProviderElement(this); - } - - @override - bool operator ==(Object other) { - return other is OptionNamesProvider && other.category == category; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, category.hashCode); - - return _SystemHash.finish(hash); - } -} - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin OptionNamesRef on FutureProviderRef> { - /// The parameter `category` of this provider. - OptionCategoryName get category; -} - -class _OptionNamesProviderElement - extends FutureProviderElement> - with OptionNamesRef { - _OptionNamesProviderElement(super.provider); - - @override - OptionCategoryName get category => (origin as OptionNamesProvider).category; + String toString() => r'optionNamesProvider'; } - -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/core/realtime/realtime_client.g.dart b/lib/core/realtime/realtime_client.g.dart index 3c79ae3..794c93b 100644 --- a/lib/core/realtime/realtime_client.g.dart +++ b/lib/core/realtime/realtime_client.g.dart @@ -6,46 +6,103 @@ part of 'realtime_client.dart'; // RiverpodGenerator // ************************************************************************** -String _$realtimeClientHash() => r'925d7ef196e3a00f47651a1d509ee4a603ae7c51'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Kept alive for the whole session and connected only while signed in — the /// handshake needs a token, and a revoked session's socket is closed by the /// backend anyway. -/// -/// Copied from [realtimeClient]. + @ProviderFor(realtimeClient) -final realtimeClientProvider = Provider.internal( - realtimeClient, - name: r'realtimeClientProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$realtimeClientHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef RealtimeClientRef = ProviderRef; -String _$realtimeEventsHash() => r'3c93518cd4e7be9c99aa039f66afe022788de8e4'; +const realtimeClientProvider = RealtimeClientProvider._(); + +/// Kept alive for the whole session and connected only while signed in — the +/// handshake needs a token, and a revoked session's socket is closed by the +/// backend anyway. + +final class RealtimeClientProvider + extends $FunctionalProvider + with $Provider { + /// Kept alive for the whole session and connected only while signed in — the + /// handshake needs a token, and a revoked session's socket is closed by the + /// backend anyway. + const RealtimeClientProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'realtimeClientProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$realtimeClientHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + RealtimeClient create(Ref ref) { + return realtimeClient(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(RealtimeClient value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$realtimeClientHash() => r'925d7ef196e3a00f47651a1d509ee4a603ae7c51'; /// What a screen watches: the raw event feed, filtered by whatever it cares /// about. Watching this is also what makes the socket connect. -/// -/// Copied from [realtimeEvents]. + @ProviderFor(realtimeEvents) -final realtimeEventsProvider = StreamProvider.internal( - realtimeEvents, - name: r'realtimeEventsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$realtimeEventsHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef RealtimeEventsRef = StreamProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const realtimeEventsProvider = RealtimeEventsProvider._(); + +/// What a screen watches: the raw event feed, filtered by whatever it cares +/// about. Watching this is also what makes the socket connect. + +final class RealtimeEventsProvider + extends + $FunctionalProvider< + AsyncValue, + RealtimeEvent, + Stream + > + with $FutureModifier, $StreamProvider { + /// What a screen watches: the raw event feed, filtered by whatever it cares + /// about. Watching this is also what makes the socket connect. + const RealtimeEventsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'realtimeEventsProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$realtimeEventsHash(); + + @$internal + @override + $StreamProviderElement $createElement( + $ProviderPointer pointer, + ) => $StreamProviderElement(pointer); + + @override + Stream create(Ref ref) { + return realtimeEvents(ref); + } +} + +String _$realtimeEventsHash() => r'3c93518cd4e7be9c99aa039f66afe022788de8e4'; diff --git a/lib/core/routing/app_router.g.dart b/lib/core/routing/app_router.g.dart index 4ffbd89..e8cf1d6 100644 --- a/lib/core/routing/app_router.g.dart +++ b/lib/core/routing/app_router.g.dart @@ -6,22 +6,46 @@ part of 'app_router.dart'; // RiverpodGenerator // ************************************************************************** -String _$appRouterHash() => r'653d55b6f9222d364f517b8eb36e90487a44e8d8'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [appRouter]. @ProviderFor(appRouter) -final appRouterProvider = AutoDisposeProvider.internal( - appRouter, - name: r'appRouterProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$appRouterHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef AppRouterRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const appRouterProvider = AppRouterProvider._(); + +final class AppRouterProvider + extends $FunctionalProvider + with $Provider { + const AppRouterProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'appRouterProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$appRouterHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + GoRouter create(Ref ref) { + return appRouter(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(GoRouter value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$appRouterHash() => r'653d55b6f9222d364f517b8eb36e90487a44e8d8'; diff --git a/lib/core/storage/hive_storage.g.dart b/lib/core/storage/hive_storage.g.dart index 4c242e4..972f29c 100644 --- a/lib/core/storage/hive_storage.g.dart +++ b/lib/core/storage/hive_storage.g.dart @@ -6,24 +6,50 @@ part of 'hive_storage.dart'; // RiverpodGenerator // ************************************************************************** -String _$hiveServiceHash() => r'9a3c04f5e3ba12b75b6539b2a85c574ab706653b'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Riverpod Provider cung cấp instance của HiveService -/// -/// Copied from [hiveService]. + @ProviderFor(hiveService) -final hiveServiceProvider = AutoDisposeProvider.internal( - hiveService, - name: r'hiveServiceProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$hiveServiceHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef HiveServiceRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const hiveServiceProvider = HiveServiceProvider._(); + +/// Riverpod Provider cung cấp instance của HiveService + +final class HiveServiceProvider + extends $FunctionalProvider + with $Provider { + /// Riverpod Provider cung cấp instance của HiveService + const HiveServiceProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'hiveServiceProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$hiveServiceHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + HiveService create(Ref ref) { + return hiveService(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(HiveService value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$hiveServiceHash() => r'9a3c04f5e3ba12b75b6539b2a85c574ab706653b'; diff --git a/lib/core/theme/theme_provider.g.dart b/lib/core/theme/theme_provider.g.dart index f20e15e..4751d02 100644 --- a/lib/core/theme/theme_provider.g.dart +++ b/lib/core/theme/theme_provider.g.dart @@ -6,21 +6,58 @@ part of 'theme_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$appThemeModeHash() => r'4a52648d1537f9f894e54a1c064a69d082e58a8d'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [AppThemeMode]. @ProviderFor(AppThemeMode) -final appThemeModeProvider = - AutoDisposeNotifierProvider.internal( - AppThemeMode.new, - name: r'appThemeModeProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$appThemeModeHash, - dependencies: null, - allTransitiveDependencies: null, +const appThemeModeProvider = AppThemeModeProvider._(); + +final class AppThemeModeProvider + extends $NotifierProvider { + const AppThemeModeProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'appThemeModeProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$appThemeModeHash(); + + @$internal + @override + AppThemeMode create() => AppThemeMode(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(ThemeMode value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} + +String _$appThemeModeHash() => r'4a52648d1537f9f894e54a1c064a69d082e58a8d'; -typedef _$AppThemeMode = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$AppThemeMode extends $Notifier { + ThemeMode build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + ThemeMode, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/lib/core/upload/resource_uploader.dart b/lib/core/upload/resource_uploader.dart new file mode 100644 index 0000000..047ee32 --- /dev/null +++ b/lib/core/upload/resource_uploader.dart @@ -0,0 +1,212 @@ +import 'package:dio/dio.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +import 'package:shopnexus_flutter_app/api/api_providers.dart'; +import 'package:shopnexus_flutter_app/api/generated/api/account_api.dart'; +import 'package:shopnexus_flutter_app/api/generated/api/catalog_api.dart'; +import 'package:shopnexus_flutter_app/api/generated/api/chat_api.dart'; +import 'package:shopnexus_flutter_app/api/generated/api/order_api.dart'; +import 'package:shopnexus_flutter_app/api/generated/api/trust_api.dart'; +import 'package:shopnexus_flutter_app/api/generated/model/account_create_upload_request.dart'; +import 'package:shopnexus_flutter_app/api/generated/model/create_upload_request.dart'; +import 'package:shopnexus_flutter_app/api/generated/model/resource.dart'; +import 'package:shopnexus_flutter_app/api/generated/model/upload_slot.dart'; +import 'package:shopnexus_flutter_app/core/network/resource_upload.dart'; + +part 'resource_uploader.g.dart'; + +/// Chỗ tấm ảnh sẽ được gắn vào, và cũng là module giữ nó. +/// +/// Bytes không bao giờ đi qua API: mọi upload đều là giữ chỗ, PUT vào một URL đã +/// ký, rồi xác nhận. Chỉ *prefix* là khác nhau theo module — resource của một +/// module không đính vào module khác được, nên nơi gắn quyết định nơi tải lên. +/// +/// [avatar] và [identityDocument] cùng đi qua `POST /me/uploads` mà vẫn là hai giá +/// trị: server phải biết nó đang ký cho loại nào **trước khi** một byte di chuyển, +/// vì chỉ ảnh đại diện mới được phép resolve ra một link công khai. +enum UploadTarget { + listing, + avatar, + identityDocument, + order, + conversation, + review, +} + +/// Tấm ảnh lớn hơn ngưỡng của loại nó. Ném trước khi có request nào: một vòng +/// lên xuống 10 MB để nhận về một lỗi biết trước là thứ trả bằng pin và 4G của +/// người dùng. +class UploadTooLarge implements Exception { + const UploadTooLarge({required this.bytes, required this.limit}); + + final int bytes; + final int limit; + + @override + String toString() => + 'Ảnh lớn hơn ${limit ~/ (1024 * 1024)} MB (${bytes ~/ (1024 * 1024)} MB).'; +} + +/// Loại file sàn không lưu. Đây là 422 của server, đặt tên lại để phía gọi không +/// phải đọc mã lỗi trong một `DioException`. +class UploadTypeRejected implements Exception { + const UploadTypeRejected(this.mime); + + final String mime; + + @override + String toString() => 'Định dạng $mime không được nhận.'; +} + +/// Ba bước của một upload, một lần, cho cả năm module. +/// +/// Trả về **`Resource` đã xác nhận**, không phải mỗi id — và đó là lý do lớp này +/// tồn tại. Hợp đồng nói: câu trả lời của bước xác nhận mang một `url` đã ký cho +/// đúng những bytes vừa lên, *và đó là lần duy nhất nó được đưa ra*; xác nhận lần +/// hai bị từ chối, còn một id trần thì không có route nào đổi lấy ảnh. Bảy chỗ +/// chép tay trước đây đều vứt câu trả lời đó đi, nên màn nào muốn khoe tấm ảnh vừa +/// tải lên đều không có gì để vẽ. +class ResourceUploader { + ResourceUploader({ + required AccountApi account, + required CatalogApi catalog, + required ChatApi chat, + required OrderApi order, + required TrustApi trust, + Dio? storeClient, + }) : _storeClient = storeClient, + _account = account, + _catalog = catalog, + _chat = chat, + _order = order, + _trust = trust; + + final AccountApi _account; + final CatalogApi _catalog; + final ChatApi _chat; + final OrderApi _order; + final TrustApi _trust; + + /// Client dùng cho bước PUT. Null là một Dio trần dựng tại chỗ — đúng thứ cần + /// khi chạy thật, vì object store không phải API này; test thì đưa vào một + /// client giả để bước PUT cũng được nhìn thấy. + final Dio? _storeClient; + + /// Ngưỡng của server, kiểm ở đây để khỏi phải đi hỏi. Một giới hạn phụ thuộc + /// vào loại file thì không viết thành một con số được. + static const _videoLimit = 100 * 1024 * 1024; + static const _otherLimit = 10 * 1024 * 1024; + + static int limitFor(String mime) => + mime.startsWith('video/') ? _videoLimit : _otherLimit; + + Future upload( + UploadTarget target, { + required List bytes, + required String filename, + required String mime, + }) async { + final limit = limitFor(mime); + if (bytes.length > limit) { + throw UploadTooLarge(bytes: bytes.length, limit: limit); + } + + final UploadSlot slot; + try { + slot = await _reserve(target, filename: filename, mime: mime, size: bytes.length); + } on DioException catch (e) { + if (e.response?.statusCode == 422) throw UploadTypeRejected(mime); + rethrow; + } + + await putToSlot(slot, bytes, client: _storeClient); + + return _confirm(target, slot.resourceId); + } + + Future _reserve( + UploadTarget target, { + required String filename, + required String mime, + required int size, + }) async { + // `/me/uploads` nhận thêm `kind`; bốn route kia dùng chung một request body. + if (target == UploadTarget.avatar || + target == UploadTarget.identityDocument) { + final response = await _account.meUploadsPost( + accountCreateUploadRequest: AccountCreateUploadRequest( + filename: filename, + mime: mime, + size: size, + kind: target == UploadTarget.avatar + ? AccountCreateUploadRequestKindEnum.avatar + : AccountCreateUploadRequestKindEnum.identity, + ), + ); + return _slotOf(response.data?.data); + } + + final request = CreateUploadRequest( + filename: filename, + mime: mime, + size: size, + ); + final response = switch (target) { + UploadTarget.listing => await _catalog.listingsUploadsPost( + createUploadRequest: request, + ), + UploadTarget.order => await _order.ordersUploadsPost( + createUploadRequest: request, + ), + UploadTarget.conversation => await _chat.conversationsUploadsPost( + createUploadRequest: request, + ), + UploadTarget.review => await _trust.reviewsUploadsPost( + createUploadRequest: request, + ), + // Đã xử lý ở trên; nhánh này giữ cho `switch` là exhaustive. + UploadTarget.avatar || UploadTarget.identityDocument => throw StateError( + 'unreachable', + ), + }; + return _slotOf(response.data?.data); + } + + Future _confirm(UploadTarget target, String resourceId) async { + final response = switch (target) { + UploadTarget.listing => await _catalog.listingsUploadsIdConfirmationPost( + id: resourceId, + ), + UploadTarget.avatar || + UploadTarget.identityDocument => await _account + .meUploadsIdConfirmationPost(id: resourceId), + UploadTarget.order => await _order.ordersUploadsIdConfirmationPost( + id: resourceId, + ), + UploadTarget.conversation => await _chat + .conversationsUploadsIdConfirmationPost(id: resourceId), + UploadTarget.review => await _trust.reviewsUploadsIdConfirmationPost( + id: resourceId, + ), + }; + final resource = response.data?.data; + if (resource == null) { + throw StateError('empty confirmation response'); + } + return resource; + } + + static UploadSlot _slotOf(UploadSlot? slot) { + if (slot == null) throw StateError('empty upload slot'); + return slot; + } +} + +@riverpod +ResourceUploader resourceUploader(Ref ref) => ResourceUploader( + account: ref.watch(accountApiProvider), + catalog: ref.watch(catalogApiProvider), + chat: ref.watch(chatApiProvider), + order: ref.watch(orderApiProvider), + trust: ref.watch(trustApiProvider), +); diff --git a/lib/core/upload/resource_uploader.g.dart b/lib/core/upload/resource_uploader.g.dart new file mode 100644 index 0000000..2e63c08 --- /dev/null +++ b/lib/core/upload/resource_uploader.g.dart @@ -0,0 +1,56 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'resource_uploader.dart'; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(resourceUploader) +const resourceUploaderProvider = ResourceUploaderProvider._(); + +final class ResourceUploaderProvider + extends + $FunctionalProvider< + ResourceUploader, + ResourceUploader, + ResourceUploader + > + with $Provider { + const ResourceUploaderProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'resourceUploaderProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$resourceUploaderHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + ResourceUploader create(Ref ref) { + return resourceUploader(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(ResourceUploader value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$resourceUploaderHash() => r'75099405081cd5863cb27e902ebe13d4566a89db'; diff --git a/lib/core/utils/error_handler.dart b/lib/core/utils/error_handler.dart index 53b9a06..d5025cc 100644 --- a/lib/core/utils/error_handler.dart +++ b/lib/core/utils/error_handler.dart @@ -10,6 +10,10 @@ class ErrorHandler { 'identity_required': 'Bạn cần định danh trước khi đăng bán. Mọi người bán trên ShopNexus ' 'đều đã định danh — đó là lý do người mua dám mua.', + // Cả hai màn nhập giá đều chặn trước khi gửi; câu này là cho đường còn lại — + // người bán hạ giá niêm yết trong lúc bên kia đang gõ. + 'offer_above_asking': + 'Mức giá đề nghị không được cao hơn giá niêm yết của sản phẩm.', }; static String getErrorMessage(dynamic error) { diff --git a/lib/features/account/data/data_sources/account_api_service.g.dart b/lib/features/account/data/data_sources/account_api_service.g.dart index 834be43..0e49d8b 100644 --- a/lib/features/account/data/data_sources/account_api_service.g.dart +++ b/lib/features/account/data/data_sources/account_api_service.g.dart @@ -2,11 +2,13 @@ part of 'account_api_service.dart'; +// dart format off + // ************************************************************************** // RetrofitGenerator // ************************************************************************** -// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations,unused_element_parameter +// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations,unused_element_parameter,avoid_unused_constructor_parameters,unreachable_from_main class _AccountApiService implements AccountApiService { _AccountApiService(this._dio, {this.baseUrl, this.errorLogger}) { @@ -43,7 +45,7 @@ class _AccountApiService implements AccountApiService { (json) => Me.fromJson(json as Map), ); } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); + errorLogger?.logError(e, s, _options, response: _result); rethrow; } return _value; @@ -93,7 +95,7 @@ class _AccountApiService implements AccountApiService { (json) => PublicAccount.fromJson(json as Map), ); } on Object catch (e, s) { - errorLogger?.logError(e, s, _options); + errorLogger?.logError(e, s, _options, response: _result); rethrow; } return _value; @@ -165,27 +167,58 @@ class _AccountApiService implements AccountApiService { } } +// dart format on + // ************************************************************************** // RiverpodGenerator // ************************************************************************** -String _$accountApiServiceHash() => r'07a1668779729e55a83f850c5c5ed69747262356'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [accountApiService]. @ProviderFor(accountApiService) -final accountApiServiceProvider = - AutoDisposeProvider.internal( - accountApiService, - name: r'accountApiServiceProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$accountApiServiceHash, - dependencies: null, - allTransitiveDependencies: null, +const accountApiServiceProvider = AccountApiServiceProvider._(); + +final class AccountApiServiceProvider + extends + $FunctionalProvider< + AccountApiService, + AccountApiService, + AccountApiService + > + with $Provider { + const AccountApiServiceProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'accountApiServiceProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$accountApiServiceHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + AccountApiService create(Ref ref) { + return accountApiService(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AccountApiService value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef AccountApiServiceRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +String _$accountApiServiceHash() => r'07a1668779729e55a83f850c5c5ed69747262356'; diff --git a/lib/features/account/data/models/account_model.freezed.dart b/lib/features/account/data/models/account_model.freezed.dart index 9c01b54..fe2c485 100644 --- a/lib/features/account/data/models/account_model.freezed.dart +++ b/lib/features/account/data/models/account_model.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,1089 +9,898 @@ part of 'account_model.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - -Profile _$ProfileFromJson(Map json) { - return _Profile.fromJson(json); -} - /// @nodoc mixin _$Profile { - String get name => throw _privateConstructorUsedError; - String get country => throw _privateConstructorUsedError; - String get locale => throw _privateConstructorUsedError; - String get timezone => throw _privateConstructorUsedError; - @JsonKey(name: 'created_at') - String get createdAt => throw _privateConstructorUsedError; - Resource? get avatar => throw _privateConstructorUsedError; - @JsonKey(name: 'date_of_birth') - String? get dateOfBirth => throw _privateConstructorUsedError; - String? get description => throw _privateConstructorUsedError; - String? get gender => throw _privateConstructorUsedError; + + String get name; String get country; String get locale; String get timezone;@JsonKey(name: 'created_at') String get createdAt; Resource? get avatar;@JsonKey(name: 'date_of_birth') String? get dateOfBirth; String? get description; String? get gender; +/// Create a copy of Profile +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ProfileCopyWith get copyWith => _$ProfileCopyWithImpl(this as Profile, _$identity); /// Serializes this Profile to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ProfileCopyWith get copyWith => throw _privateConstructorUsedError; + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Profile&&(identical(other.name, name) || other.name == name)&&(identical(other.country, country) || other.country == country)&&(identical(other.locale, locale) || other.locale == locale)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.avatar, avatar) || other.avatar == avatar)&&(identical(other.dateOfBirth, dateOfBirth) || other.dateOfBirth == dateOfBirth)&&(identical(other.description, description) || other.description == description)&&(identical(other.gender, gender) || other.gender == gender)); } -/// @nodoc -abstract class $ProfileCopyWith<$Res> { - factory $ProfileCopyWith(Profile value, $Res Function(Profile) then) = - _$ProfileCopyWithImpl<$Res, Profile>; - @useResult - $Res call({ - String name, - String country, - String locale, - String timezone, - @JsonKey(name: 'created_at') String createdAt, - Resource? avatar, - @JsonKey(name: 'date_of_birth') String? dateOfBirth, - String? description, - String? gender, - }); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,name,country,locale,timezone,createdAt,avatar,dateOfBirth,description,gender); + +@override +String toString() { + return 'Profile(name: $name, country: $country, locale: $locale, timezone: $timezone, createdAt: $createdAt, avatar: $avatar, dateOfBirth: $dateOfBirth, description: $description, gender: $gender)'; +} + + } /// @nodoc -class _$ProfileCopyWithImpl<$Res, $Val extends Profile> +abstract mixin class $ProfileCopyWith<$Res> { + factory $ProfileCopyWith(Profile value, $Res Function(Profile) _then) = _$ProfileCopyWithImpl; +@useResult +$Res call({ + String name, String country, String locale, String timezone,@JsonKey(name: 'created_at') String createdAt, Resource? avatar,@JsonKey(name: 'date_of_birth') String? dateOfBirth, String? description, String? gender +}); + + + + +} +/// @nodoc +class _$ProfileCopyWithImpl<$Res> implements $ProfileCopyWith<$Res> { - _$ProfileCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = null, - Object? country = null, - Object? locale = null, - Object? timezone = null, - Object? createdAt = null, - Object? avatar = freezed, - Object? dateOfBirth = freezed, - Object? description = freezed, - Object? gender = freezed, - }) { - return _then( - _value.copyWith( - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - country: null == country - ? _value.country - : country // ignore: cast_nullable_to_non_nullable - as String, - locale: null == locale - ? _value.locale - : locale // ignore: cast_nullable_to_non_nullable - as String, - timezone: null == timezone - ? _value.timezone - : timezone // ignore: cast_nullable_to_non_nullable - as String, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - avatar: freezed == avatar - ? _value.avatar - : avatar // ignore: cast_nullable_to_non_nullable - as Resource?, - dateOfBirth: freezed == dateOfBirth - ? _value.dateOfBirth - : dateOfBirth // ignore: cast_nullable_to_non_nullable - as String?, - description: freezed == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, - gender: freezed == gender - ? _value.gender - : gender // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } + _$ProfileCopyWithImpl(this._self, this._then); + + final Profile _self; + final $Res Function(Profile) _then; + +/// Create a copy of Profile +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = null,Object? country = null,Object? locale = null,Object? timezone = null,Object? createdAt = null,Object? avatar = freezed,Object? dateOfBirth = freezed,Object? description = freezed,Object? gender = freezed,}) { + return _then(_self.copyWith( +name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable +as String,locale: null == locale ? _self.locale : locale // ignore: cast_nullable_to_non_nullable +as String,timezone: null == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable +as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable +as Resource?,dateOfBirth: freezed == dateOfBirth ? _self.dateOfBirth : dateOfBirth // ignore: cast_nullable_to_non_nullable +as String?,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String?,gender: freezed == gender ? _self.gender : gender // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$ProfileImplCopyWith<$Res> implements $ProfileCopyWith<$Res> { - factory _$$ProfileImplCopyWith( - _$ProfileImpl value, - $Res Function(_$ProfileImpl) then, - ) = __$$ProfileImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String name, - String country, - String locale, - String timezone, - @JsonKey(name: 'created_at') String createdAt, - Resource? avatar, - @JsonKey(name: 'date_of_birth') String? dateOfBirth, - String? description, - String? gender, - }); } -/// @nodoc -class __$$ProfileImplCopyWithImpl<$Res> - extends _$ProfileCopyWithImpl<$Res, _$ProfileImpl> - implements _$$ProfileImplCopyWith<$Res> { - __$$ProfileImplCopyWithImpl( - _$ProfileImpl _value, - $Res Function(_$ProfileImpl) _then, - ) : super(_value, _then); - - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = null, - Object? country = null, - Object? locale = null, - Object? timezone = null, - Object? createdAt = null, - Object? avatar = freezed, - Object? dateOfBirth = freezed, - Object? description = freezed, - Object? gender = freezed, - }) { - return _then( - _$ProfileImpl( - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - country: null == country - ? _value.country - : country // ignore: cast_nullable_to_non_nullable - as String, - locale: null == locale - ? _value.locale - : locale // ignore: cast_nullable_to_non_nullable - as String, - timezone: null == timezone - ? _value.timezone - : timezone // ignore: cast_nullable_to_non_nullable - as String, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - avatar: freezed == avatar - ? _value.avatar - : avatar // ignore: cast_nullable_to_non_nullable - as Resource?, - dateOfBirth: freezed == dateOfBirth - ? _value.dateOfBirth - : dateOfBirth // ignore: cast_nullable_to_non_nullable - as String?, - description: freezed == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, - gender: freezed == gender - ? _value.gender - : gender // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } + +/// Adds pattern-matching-related methods to [Profile]. +extension ProfilePatterns on Profile { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Profile value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Profile() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Profile value) $default,){ +final _that = this; +switch (_that) { +case _Profile(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Profile value)? $default,){ +final _that = this; +switch (_that) { +case _Profile() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String name, String country, String locale, String timezone, @JsonKey(name: 'created_at') String createdAt, Resource? avatar, @JsonKey(name: 'date_of_birth') String? dateOfBirth, String? description, String? gender)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Profile() when $default != null: +return $default(_that.name,_that.country,_that.locale,_that.timezone,_that.createdAt,_that.avatar,_that.dateOfBirth,_that.description,_that.gender);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String name, String country, String locale, String timezone, @JsonKey(name: 'created_at') String createdAt, Resource? avatar, @JsonKey(name: 'date_of_birth') String? dateOfBirth, String? description, String? gender) $default,) {final _that = this; +switch (_that) { +case _Profile(): +return $default(_that.name,_that.country,_that.locale,_that.timezone,_that.createdAt,_that.avatar,_that.dateOfBirth,_that.description,_that.gender);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String name, String country, String locale, String timezone, @JsonKey(name: 'created_at') String createdAt, Resource? avatar, @JsonKey(name: 'date_of_birth') String? dateOfBirth, String? description, String? gender)? $default,) {final _that = this; +switch (_that) { +case _Profile() when $default != null: +return $default(_that.name,_that.country,_that.locale,_that.timezone,_that.createdAt,_that.avatar,_that.dateOfBirth,_that.description,_that.gender);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$ProfileImpl implements _Profile { - const _$ProfileImpl({ - required this.name, - required this.country, - required this.locale, - required this.timezone, - @JsonKey(name: 'created_at') required this.createdAt, - this.avatar, - @JsonKey(name: 'date_of_birth') this.dateOfBirth, - this.description, - this.gender, - }); - factory _$ProfileImpl.fromJson(Map json) => - _$$ProfileImplFromJson(json); - - @override - final String name; - @override - final String country; - @override - final String locale; - @override - final String timezone; - @override - @JsonKey(name: 'created_at') - final String createdAt; - @override - final Resource? avatar; - @override - @JsonKey(name: 'date_of_birth') - final String? dateOfBirth; - @override - final String? description; - @override - final String? gender; - - @override - String toString() { - return 'Profile(name: $name, country: $country, locale: $locale, timezone: $timezone, createdAt: $createdAt, avatar: $avatar, dateOfBirth: $dateOfBirth, description: $description, gender: $gender)'; - } +class _Profile implements Profile { + const _Profile({required this.name, required this.country, required this.locale, required this.timezone, @JsonKey(name: 'created_at') required this.createdAt, this.avatar, @JsonKey(name: 'date_of_birth') this.dateOfBirth, this.description, this.gender}); + factory _Profile.fromJson(Map json) => _$ProfileFromJson(json); + +@override final String name; +@override final String country; +@override final String locale; +@override final String timezone; +@override@JsonKey(name: 'created_at') final String createdAt; +@override final Resource? avatar; +@override@JsonKey(name: 'date_of_birth') final String? dateOfBirth; +@override final String? description; +@override final String? gender; + +/// Create a copy of Profile +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ProfileCopyWith<_Profile> get copyWith => __$ProfileCopyWithImpl<_Profile>(this, _$identity); + +@override +Map toJson() { + return _$ProfileToJson(this, ); +} - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ProfileImpl && - (identical(other.name, name) || other.name == name) && - (identical(other.country, country) || other.country == country) && - (identical(other.locale, locale) || other.locale == locale) && - (identical(other.timezone, timezone) || - other.timezone == timezone) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.avatar, avatar) || other.avatar == avatar) && - (identical(other.dateOfBirth, dateOfBirth) || - other.dateOfBirth == dateOfBirth) && - (identical(other.description, description) || - other.description == description) && - (identical(other.gender, gender) || other.gender == gender)); - } +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Profile&&(identical(other.name, name) || other.name == name)&&(identical(other.country, country) || other.country == country)&&(identical(other.locale, locale) || other.locale == locale)&&(identical(other.timezone, timezone) || other.timezone == timezone)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.avatar, avatar) || other.avatar == avatar)&&(identical(other.dateOfBirth, dateOfBirth) || other.dateOfBirth == dateOfBirth)&&(identical(other.description, description) || other.description == description)&&(identical(other.gender, gender) || other.gender == gender)); +} - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - name, - country, - locale, - timezone, - createdAt, - avatar, - dateOfBirth, - description, - gender, - ); - - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ProfileImplCopyWith<_$ProfileImpl> get copyWith => - __$$ProfileImplCopyWithImpl<_$ProfileImpl>(this, _$identity); - - @override - Map toJson() { - return _$$ProfileImplToJson(this); - } +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,name,country,locale,timezone,createdAt,avatar,dateOfBirth,description,gender); + +@override +String toString() { + return 'Profile(name: $name, country: $country, locale: $locale, timezone: $timezone, createdAt: $createdAt, avatar: $avatar, dateOfBirth: $dateOfBirth, description: $description, gender: $gender)'; } -abstract class _Profile implements Profile { - const factory _Profile({ - required final String name, - required final String country, - required final String locale, - required final String timezone, - @JsonKey(name: 'created_at') required final String createdAt, - final Resource? avatar, - @JsonKey(name: 'date_of_birth') final String? dateOfBirth, - final String? description, - final String? gender, - }) = _$ProfileImpl; - - factory _Profile.fromJson(Map json) = _$ProfileImpl.fromJson; - - @override - String get name; - @override - String get country; - @override - String get locale; - @override - String get timezone; - @override - @JsonKey(name: 'created_at') - String get createdAt; - @override - Resource? get avatar; - @override - @JsonKey(name: 'date_of_birth') - String? get dateOfBirth; - @override - String? get description; - @override - String? get gender; - - /// Create a copy of Profile - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ProfileImplCopyWith<_$ProfileImpl> get copyWith => - throw _privateConstructorUsedError; -} - -Me _$MeFromJson(Map json) { - return _Me.fromJson(json); + } +/// @nodoc +abstract mixin class _$ProfileCopyWith<$Res> implements $ProfileCopyWith<$Res> { + factory _$ProfileCopyWith(_Profile value, $Res Function(_Profile) _then) = __$ProfileCopyWithImpl; +@override @useResult +$Res call({ + String name, String country, String locale, String timezone,@JsonKey(name: 'created_at') String createdAt, Resource? avatar,@JsonKey(name: 'date_of_birth') String? dateOfBirth, String? description, String? gender +}); + + + + +} +/// @nodoc +class __$ProfileCopyWithImpl<$Res> + implements _$ProfileCopyWith<$Res> { + __$ProfileCopyWithImpl(this._self, this._then); + + final _Profile _self; + final $Res Function(_Profile) _then; + +/// Create a copy of Profile +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? country = null,Object? locale = null,Object? timezone = null,Object? createdAt = null,Object? avatar = freezed,Object? dateOfBirth = freezed,Object? description = freezed,Object? gender = freezed,}) { + return _then(_Profile( +name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable +as String,locale: null == locale ? _self.locale : locale // ignore: cast_nullable_to_non_nullable +as String,timezone: null == timezone ? _self.timezone : timezone // ignore: cast_nullable_to_non_nullable +as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable +as Resource?,dateOfBirth: freezed == dateOfBirth ? _self.dateOfBirth : dateOfBirth // ignore: cast_nullable_to_non_nullable +as String?,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String?,gender: freezed == gender ? _self.gender : gender // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + /// @nodoc mixin _$Me { - String get id => throw _privateConstructorUsedError; - @JsonKey(name: 'created_at') - String get createdAt => throw _privateConstructorUsedError; - String? get email => throw _privateConstructorUsedError; - @JsonKey(name: 'email_verified') - bool get emailVerified => throw _privateConstructorUsedError; - @JsonKey(name: 'has_password') - bool get hasPassword => throw _privateConstructorUsedError; - @JsonKey(name: 'identity_verified') - bool get identityVerified => throw _privateConstructorUsedError; - String? get phone => throw _privateConstructorUsedError; - Profile? get profile => throw _privateConstructorUsedError; - String get role => throw _privateConstructorUsedError; - String get status => throw _privateConstructorUsedError; - String? get username => throw _privateConstructorUsedError; + + String get id;@JsonKey(name: 'created_at') String get createdAt; String? get email;@JsonKey(name: 'email_verified') bool get emailVerified;@JsonKey(name: 'has_password') bool get hasPassword;@JsonKey(name: 'identity_verified') bool get identityVerified; String? get phone; Profile? get profile; String get role; String get status; String? get username; +/// Create a copy of Me +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$MeCopyWith get copyWith => _$MeCopyWithImpl(this as Me, _$identity); /// Serializes this Me to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of Me - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $MeCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Me&&(identical(other.id, id) || other.id == id)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.email, email) || other.email == email)&&(identical(other.emailVerified, emailVerified) || other.emailVerified == emailVerified)&&(identical(other.hasPassword, hasPassword) || other.hasPassword == hasPassword)&&(identical(other.identityVerified, identityVerified) || other.identityVerified == identityVerified)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.profile, profile) || other.profile == profile)&&(identical(other.role, role) || other.role == role)&&(identical(other.status, status) || other.status == status)&&(identical(other.username, username) || other.username == username)); } -/// @nodoc -abstract class $MeCopyWith<$Res> { - factory $MeCopyWith(Me value, $Res Function(Me) then) = - _$MeCopyWithImpl<$Res, Me>; - @useResult - $Res call({ - String id, - @JsonKey(name: 'created_at') String createdAt, - String? email, - @JsonKey(name: 'email_verified') bool emailVerified, - @JsonKey(name: 'has_password') bool hasPassword, - @JsonKey(name: 'identity_verified') bool identityVerified, - String? phone, - Profile? profile, - String role, - String status, - String? username, - }); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,createdAt,email,emailVerified,hasPassword,identityVerified,phone,profile,role,status,username); - $ProfileCopyWith<$Res>? get profile; +@override +String toString() { + return 'Me(id: $id, createdAt: $createdAt, email: $email, emailVerified: $emailVerified, hasPassword: $hasPassword, identityVerified: $identityVerified, phone: $phone, profile: $profile, role: $role, status: $status, username: $username)'; } -/// @nodoc -class _$MeCopyWithImpl<$Res, $Val extends Me> implements $MeCopyWith<$Res> { - _$MeCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Me - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? createdAt = null, - Object? email = freezed, - Object? emailVerified = null, - Object? hasPassword = null, - Object? identityVerified = null, - Object? phone = freezed, - Object? profile = freezed, - Object? role = null, - Object? status = null, - Object? username = freezed, - }) { - return _then( - _value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - email: freezed == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String?, - emailVerified: null == emailVerified - ? _value.emailVerified - : emailVerified // ignore: cast_nullable_to_non_nullable - as bool, - hasPassword: null == hasPassword - ? _value.hasPassword - : hasPassword // ignore: cast_nullable_to_non_nullable - as bool, - identityVerified: null == identityVerified - ? _value.identityVerified - : identityVerified // ignore: cast_nullable_to_non_nullable - as bool, - phone: freezed == phone - ? _value.phone - : phone // ignore: cast_nullable_to_non_nullable - as String?, - profile: freezed == profile - ? _value.profile - : profile // ignore: cast_nullable_to_non_nullable - as Profile?, - role: null == role - ? _value.role - : role // ignore: cast_nullable_to_non_nullable - as String, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - username: freezed == username - ? _value.username - : username // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } - /// Create a copy of Me - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ProfileCopyWith<$Res>? get profile { - if (_value.profile == null) { - return null; - } - - return $ProfileCopyWith<$Res>(_value.profile!, (value) { - return _then(_value.copyWith(profile: value) as $Val); - }); - } } /// @nodoc -abstract class _$$MeImplCopyWith<$Res> implements $MeCopyWith<$Res> { - factory _$$MeImplCopyWith(_$MeImpl value, $Res Function(_$MeImpl) then) = - __$$MeImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String id, - @JsonKey(name: 'created_at') String createdAt, - String? email, - @JsonKey(name: 'email_verified') bool emailVerified, - @JsonKey(name: 'has_password') bool hasPassword, - @JsonKey(name: 'identity_verified') bool identityVerified, - String? phone, - Profile? profile, - String role, - String status, - String? username, - }); +abstract mixin class $MeCopyWith<$Res> { + factory $MeCopyWith(Me value, $Res Function(Me) _then) = _$MeCopyWithImpl; +@useResult +$Res call({ + String id,@JsonKey(name: 'created_at') String createdAt, String? email,@JsonKey(name: 'email_verified') bool emailVerified,@JsonKey(name: 'has_password') bool hasPassword,@JsonKey(name: 'identity_verified') bool identityVerified, String? phone, Profile? profile, String role, String status, String? username +}); - @override - $ProfileCopyWith<$Res>? get profile; -} +$ProfileCopyWith<$Res>? get profile; + +} /// @nodoc -class __$$MeImplCopyWithImpl<$Res> extends _$MeCopyWithImpl<$Res, _$MeImpl> - implements _$$MeImplCopyWith<$Res> { - __$$MeImplCopyWithImpl(_$MeImpl _value, $Res Function(_$MeImpl) _then) - : super(_value, _then); - - /// Create a copy of Me - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? createdAt = null, - Object? email = freezed, - Object? emailVerified = null, - Object? hasPassword = null, - Object? identityVerified = null, - Object? phone = freezed, - Object? profile = freezed, - Object? role = null, - Object? status = null, - Object? username = freezed, - }) { - return _then( - _$MeImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - email: freezed == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String?, - emailVerified: null == emailVerified - ? _value.emailVerified - : emailVerified // ignore: cast_nullable_to_non_nullable - as bool, - hasPassword: null == hasPassword - ? _value.hasPassword - : hasPassword // ignore: cast_nullable_to_non_nullable - as bool, - identityVerified: null == identityVerified - ? _value.identityVerified - : identityVerified // ignore: cast_nullable_to_non_nullable - as bool, - phone: freezed == phone - ? _value.phone - : phone // ignore: cast_nullable_to_non_nullable - as String?, - profile: freezed == profile - ? _value.profile - : profile // ignore: cast_nullable_to_non_nullable - as Profile?, - role: null == role - ? _value.role - : role // ignore: cast_nullable_to_non_nullable - as String, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - username: freezed == username - ? _value.username - : username // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); +class _$MeCopyWithImpl<$Res> + implements $MeCopyWith<$Res> { + _$MeCopyWithImpl(this._self, this._then); + + final Me _self; + final $Res Function(Me) _then; + +/// Create a copy of Me +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? createdAt = null,Object? email = freezed,Object? emailVerified = null,Object? hasPassword = null,Object? identityVerified = null,Object? phone = freezed,Object? profile = freezed,Object? role = null,Object? status = null,Object? username = freezed,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,emailVerified: null == emailVerified ? _self.emailVerified : emailVerified // ignore: cast_nullable_to_non_nullable +as bool,hasPassword: null == hasPassword ? _self.hasPassword : hasPassword // ignore: cast_nullable_to_non_nullable +as bool,identityVerified: null == identityVerified ? _self.identityVerified : identityVerified // ignore: cast_nullable_to_non_nullable +as bool,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,profile: freezed == profile ? _self.profile : profile // ignore: cast_nullable_to_non_nullable +as Profile?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable +as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable +as String?, + )); +} +/// Create a copy of Me +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ProfileCopyWith<$Res>? get profile { + if (_self.profile == null) { + return null; } + + return $ProfileCopyWith<$Res>(_self.profile!, (value) { + return _then(_self.copyWith(profile: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [Me]. +extension MePatterns on Me { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Me value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Me() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Me value) $default,){ +final _that = this; +switch (_that) { +case _Me(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Me value)? $default,){ +final _that = this; +switch (_that) { +case _Me() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, @JsonKey(name: 'created_at') String createdAt, String? email, @JsonKey(name: 'email_verified') bool emailVerified, @JsonKey(name: 'has_password') bool hasPassword, @JsonKey(name: 'identity_verified') bool identityVerified, String? phone, Profile? profile, String role, String status, String? username)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Me() when $default != null: +return $default(_that.id,_that.createdAt,_that.email,_that.emailVerified,_that.hasPassword,_that.identityVerified,_that.phone,_that.profile,_that.role,_that.status,_that.username);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String id, @JsonKey(name: 'created_at') String createdAt, String? email, @JsonKey(name: 'email_verified') bool emailVerified, @JsonKey(name: 'has_password') bool hasPassword, @JsonKey(name: 'identity_verified') bool identityVerified, String? phone, Profile? profile, String role, String status, String? username) $default,) {final _that = this; +switch (_that) { +case _Me(): +return $default(_that.id,_that.createdAt,_that.email,_that.emailVerified,_that.hasPassword,_that.identityVerified,_that.phone,_that.profile,_that.role,_that.status,_that.username);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, @JsonKey(name: 'created_at') String createdAt, String? email, @JsonKey(name: 'email_verified') bool emailVerified, @JsonKey(name: 'has_password') bool hasPassword, @JsonKey(name: 'identity_verified') bool identityVerified, String? phone, Profile? profile, String role, String status, String? username)? $default,) {final _that = this; +switch (_that) { +case _Me() when $default != null: +return $default(_that.id,_that.createdAt,_that.email,_that.emailVerified,_that.hasPassword,_that.identityVerified,_that.phone,_that.profile,_that.role,_that.status,_that.username);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$MeImpl extends _Me { - const _$MeImpl({ - required this.id, - @JsonKey(name: 'created_at') required this.createdAt, - this.email, - @JsonKey(name: 'email_verified') required this.emailVerified, - @JsonKey(name: 'has_password') required this.hasPassword, - @JsonKey(name: 'identity_verified') required this.identityVerified, - this.phone, - this.profile, - required this.role, - required this.status, - this.username, - }) : super._(); - - factory _$MeImpl.fromJson(Map json) => - _$$MeImplFromJson(json); - - @override - final String id; - @override - @JsonKey(name: 'created_at') - final String createdAt; - @override - final String? email; - @override - @JsonKey(name: 'email_verified') - final bool emailVerified; - @override - @JsonKey(name: 'has_password') - final bool hasPassword; - @override - @JsonKey(name: 'identity_verified') - final bool identityVerified; - @override - final String? phone; - @override - final Profile? profile; - @override - final String role; - @override - final String status; - @override - final String? username; - - @override - String toString() { - return 'Me(id: $id, createdAt: $createdAt, email: $email, emailVerified: $emailVerified, hasPassword: $hasPassword, identityVerified: $identityVerified, phone: $phone, profile: $profile, role: $role, status: $status, username: $username)'; - } - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$MeImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.email, email) || other.email == email) && - (identical(other.emailVerified, emailVerified) || - other.emailVerified == emailVerified) && - (identical(other.hasPassword, hasPassword) || - other.hasPassword == hasPassword) && - (identical(other.identityVerified, identityVerified) || - other.identityVerified == identityVerified) && - (identical(other.phone, phone) || other.phone == phone) && - (identical(other.profile, profile) || other.profile == profile) && - (identical(other.role, role) || other.role == role) && - (identical(other.status, status) || other.status == status) && - (identical(other.username, username) || - other.username == username)); - } +class _Me extends Me { + const _Me({required this.id, @JsonKey(name: 'created_at') required this.createdAt, this.email, @JsonKey(name: 'email_verified') required this.emailVerified, @JsonKey(name: 'has_password') required this.hasPassword, @JsonKey(name: 'identity_verified') required this.identityVerified, this.phone, this.profile, required this.role, required this.status, this.username}): super._(); + factory _Me.fromJson(Map json) => _$MeFromJson(json); + +@override final String id; +@override@JsonKey(name: 'created_at') final String createdAt; +@override final String? email; +@override@JsonKey(name: 'email_verified') final bool emailVerified; +@override@JsonKey(name: 'has_password') final bool hasPassword; +@override@JsonKey(name: 'identity_verified') final bool identityVerified; +@override final String? phone; +@override final Profile? profile; +@override final String role; +@override final String status; +@override final String? username; + +/// Create a copy of Me +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$MeCopyWith<_Me> get copyWith => __$MeCopyWithImpl<_Me>(this, _$identity); + +@override +Map toJson() { + return _$MeToJson(this, ); +} - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - createdAt, - email, - emailVerified, - hasPassword, - identityVerified, - phone, - profile, - role, - status, - username, - ); - - /// Create a copy of Me - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$MeImplCopyWith<_$MeImpl> get copyWith => - __$$MeImplCopyWithImpl<_$MeImpl>(this, _$identity); - - @override - Map toJson() { - return _$$MeImplToJson(this); - } +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Me&&(identical(other.id, id) || other.id == id)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.email, email) || other.email == email)&&(identical(other.emailVerified, emailVerified) || other.emailVerified == emailVerified)&&(identical(other.hasPassword, hasPassword) || other.hasPassword == hasPassword)&&(identical(other.identityVerified, identityVerified) || other.identityVerified == identityVerified)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.profile, profile) || other.profile == profile)&&(identical(other.role, role) || other.role == role)&&(identical(other.status, status) || other.status == status)&&(identical(other.username, username) || other.username == username)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,createdAt,email,emailVerified,hasPassword,identityVerified,phone,profile,role,status,username); + +@override +String toString() { + return 'Me(id: $id, createdAt: $createdAt, email: $email, emailVerified: $emailVerified, hasPassword: $hasPassword, identityVerified: $identityVerified, phone: $phone, profile: $profile, role: $role, status: $status, username: $username)'; } -abstract class _Me extends Me { - const factory _Me({ - required final String id, - @JsonKey(name: 'created_at') required final String createdAt, - final String? email, - @JsonKey(name: 'email_verified') required final bool emailVerified, - @JsonKey(name: 'has_password') required final bool hasPassword, - @JsonKey(name: 'identity_verified') required final bool identityVerified, - final String? phone, - final Profile? profile, - required final String role, - required final String status, - final String? username, - }) = _$MeImpl; - const _Me._() : super._(); - - factory _Me.fromJson(Map json) = _$MeImpl.fromJson; - - @override - String get id; - @override - @JsonKey(name: 'created_at') - String get createdAt; - @override - String? get email; - @override - @JsonKey(name: 'email_verified') - bool get emailVerified; - @override - @JsonKey(name: 'has_password') - bool get hasPassword; - @override - @JsonKey(name: 'identity_verified') - bool get identityVerified; - @override - String? get phone; - @override - Profile? get profile; - @override - String get role; - @override - String get status; - @override - String? get username; - - /// Create a copy of Me - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$MeImplCopyWith<_$MeImpl> get copyWith => - throw _privateConstructorUsedError; -} - -PublicAccount _$PublicAccountFromJson(Map json) { - return _PublicAccount.fromJson(json); + } /// @nodoc -mixin _$PublicAccount { - String get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - @JsonKey(name: 'follower_count') - int get followerCount => throw _privateConstructorUsedError; - @JsonKey(name: 'identity_verified') - bool get identityVerified => throw _privateConstructorUsedError; - - /// Quan hệ của *người đọc* với account này — false khi đọc ẩn danh và trên - /// trang của chính mình. Nút theo dõi không có nó thì không biết vẽ chiều nào. - @JsonKey(name: 'following') - bool get following => throw _privateConstructorUsedError; - @JsonKey(name: 'created_at') - String get createdAt => throw _privateConstructorUsedError; - String? get description => throw _privateConstructorUsedError; - Resource? get avatar => throw _privateConstructorUsedError; +abstract mixin class _$MeCopyWith<$Res> implements $MeCopyWith<$Res> { + factory _$MeCopyWith(_Me value, $Res Function(_Me) _then) = __$MeCopyWithImpl; +@override @useResult +$Res call({ + String id,@JsonKey(name: 'created_at') String createdAt, String? email,@JsonKey(name: 'email_verified') bool emailVerified,@JsonKey(name: 'has_password') bool hasPassword,@JsonKey(name: 'identity_verified') bool identityVerified, String? phone, Profile? profile, String role, String status, String? username +}); - /// Serializes this PublicAccount to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - /// Create a copy of PublicAccount - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PublicAccountCopyWith get copyWith => - throw _privateConstructorUsedError; -} +@override $ProfileCopyWith<$Res>? get profile; +} /// @nodoc -abstract class $PublicAccountCopyWith<$Res> { - factory $PublicAccountCopyWith( - PublicAccount value, - $Res Function(PublicAccount) then, - ) = _$PublicAccountCopyWithImpl<$Res, PublicAccount>; - @useResult - $Res call({ - String id, - String name, - @JsonKey(name: 'follower_count') int followerCount, - @JsonKey(name: 'identity_verified') bool identityVerified, - @JsonKey(name: 'following') bool following, - @JsonKey(name: 'created_at') String createdAt, - String? description, - Resource? avatar, +class __$MeCopyWithImpl<$Res> + implements _$MeCopyWith<$Res> { + __$MeCopyWithImpl(this._self, this._then); + + final _Me _self; + final $Res Function(_Me) _then; + +/// Create a copy of Me +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? createdAt = null,Object? email = freezed,Object? emailVerified = null,Object? hasPassword = null,Object? identityVerified = null,Object? phone = freezed,Object? profile = freezed,Object? role = null,Object? status = null,Object? username = freezed,}) { + return _then(_Me( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,email: freezed == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String?,emailVerified: null == emailVerified ? _self.emailVerified : emailVerified // ignore: cast_nullable_to_non_nullable +as bool,hasPassword: null == hasPassword ? _self.hasPassword : hasPassword // ignore: cast_nullable_to_non_nullable +as bool,identityVerified: null == identityVerified ? _self.identityVerified : identityVerified // ignore: cast_nullable_to_non_nullable +as bool,phone: freezed == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String?,profile: freezed == profile ? _self.profile : profile // ignore: cast_nullable_to_non_nullable +as Profile?,role: null == role ? _self.role : role // ignore: cast_nullable_to_non_nullable +as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,username: freezed == username ? _self.username : username // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +/// Create a copy of Me +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ProfileCopyWith<$Res>? get profile { + if (_self.profile == null) { + return null; + } + + return $ProfileCopyWith<$Res>(_self.profile!, (value) { + return _then(_self.copyWith(profile: value)); }); } +} + /// @nodoc -class _$PublicAccountCopyWithImpl<$Res, $Val extends PublicAccount> - implements $PublicAccountCopyWith<$Res> { - _$PublicAccountCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PublicAccount - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? name = null, - Object? followerCount = null, - Object? identityVerified = null, - Object? following = null, - Object? createdAt = null, - Object? description = freezed, - Object? avatar = freezed, - }) { - return _then( - _value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - followerCount: null == followerCount - ? _value.followerCount - : followerCount // ignore: cast_nullable_to_non_nullable - as int, - identityVerified: null == identityVerified - ? _value.identityVerified - : identityVerified // ignore: cast_nullable_to_non_nullable - as bool, - following: null == following - ? _value.following - : following // ignore: cast_nullable_to_non_nullable - as bool, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - description: freezed == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, - avatar: freezed == avatar - ? _value.avatar - : avatar // ignore: cast_nullable_to_non_nullable - as Resource?, - ) - as $Val, - ); - } +mixin _$PublicAccount { + + String get id; String get name;@JsonKey(name: 'follower_count') int get followerCount;@JsonKey(name: 'identity_verified') bool get identityVerified;/// Quan hệ của *người đọc* với account này — false khi đọc ẩn danh và trên +/// trang của chính mình. Nút theo dõi không có nó thì không biết vẽ chiều nào. +@JsonKey(name: 'following') bool get following;@JsonKey(name: 'created_at') String get createdAt; String? get description; Resource? get avatar; +/// Create a copy of PublicAccount +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicAccountCopyWith get copyWith => _$PublicAccountCopyWithImpl(this as PublicAccount, _$identity); + + /// Serializes this PublicAccount to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicAccount&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.followerCount, followerCount) || other.followerCount == followerCount)&&(identical(other.identityVerified, identityVerified) || other.identityVerified == identityVerified)&&(identical(other.following, following) || other.following == following)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.description, description) || other.description == description)&&(identical(other.avatar, avatar) || other.avatar == avatar)); } +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,followerCount,identityVerified,following,createdAt,description,avatar); + +@override +String toString() { + return 'PublicAccount(id: $id, name: $name, followerCount: $followerCount, identityVerified: $identityVerified, following: $following, createdAt: $createdAt, description: $description, avatar: $avatar)'; +} + + +} + +/// @nodoc +abstract mixin class $PublicAccountCopyWith<$Res> { + factory $PublicAccountCopyWith(PublicAccount value, $Res Function(PublicAccount) _then) = _$PublicAccountCopyWithImpl; +@useResult +$Res call({ + String id, String name,@JsonKey(name: 'follower_count') int followerCount,@JsonKey(name: 'identity_verified') bool identityVerified,@JsonKey(name: 'following') bool following,@JsonKey(name: 'created_at') String createdAt, String? description, Resource? avatar +}); + + + + +} /// @nodoc -abstract class _$$PublicAccountImplCopyWith<$Res> +class _$PublicAccountCopyWithImpl<$Res> implements $PublicAccountCopyWith<$Res> { - factory _$$PublicAccountImplCopyWith( - _$PublicAccountImpl value, - $Res Function(_$PublicAccountImpl) then, - ) = __$$PublicAccountImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String id, - String name, - @JsonKey(name: 'follower_count') int followerCount, - @JsonKey(name: 'identity_verified') bool identityVerified, - @JsonKey(name: 'following') bool following, - @JsonKey(name: 'created_at') String createdAt, - String? description, - Resource? avatar, - }); + _$PublicAccountCopyWithImpl(this._self, this._then); + + final PublicAccount _self; + final $Res Function(PublicAccount) _then; + +/// Create a copy of PublicAccount +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? followerCount = null,Object? identityVerified = null,Object? following = null,Object? createdAt = null,Object? description = freezed,Object? avatar = freezed,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,followerCount: null == followerCount ? _self.followerCount : followerCount // ignore: cast_nullable_to_non_nullable +as int,identityVerified: null == identityVerified ? _self.identityVerified : identityVerified // ignore: cast_nullable_to_non_nullable +as bool,following: null == following ? _self.following : following // ignore: cast_nullable_to_non_nullable +as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String?,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable +as Resource?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PublicAccount]. +extension PublicAccountPatterns on PublicAccount { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _PublicAccount value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PublicAccount() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _PublicAccount value) $default,){ +final _that = this; +switch (_that) { +case _PublicAccount(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _PublicAccount value)? $default,){ +final _that = this; +switch (_that) { +case _PublicAccount() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String name, @JsonKey(name: 'follower_count') int followerCount, @JsonKey(name: 'identity_verified') bool identityVerified, @JsonKey(name: 'following') bool following, @JsonKey(name: 'created_at') String createdAt, String? description, Resource? avatar)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PublicAccount() when $default != null: +return $default(_that.id,_that.name,_that.followerCount,_that.identityVerified,_that.following,_that.createdAt,_that.description,_that.avatar);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String id, String name, @JsonKey(name: 'follower_count') int followerCount, @JsonKey(name: 'identity_verified') bool identityVerified, @JsonKey(name: 'following') bool following, @JsonKey(name: 'created_at') String createdAt, String? description, Resource? avatar) $default,) {final _that = this; +switch (_that) { +case _PublicAccount(): +return $default(_that.id,_that.name,_that.followerCount,_that.identityVerified,_that.following,_that.createdAt,_that.description,_that.avatar);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String name, @JsonKey(name: 'follower_count') int followerCount, @JsonKey(name: 'identity_verified') bool identityVerified, @JsonKey(name: 'following') bool following, @JsonKey(name: 'created_at') String createdAt, String? description, Resource? avatar)? $default,) {final _that = this; +switch (_that) { +case _PublicAccount() when $default != null: +return $default(_that.id,_that.name,_that.followerCount,_that.identityVerified,_that.following,_that.createdAt,_that.description,_that.avatar);case _: + return null; + +} } -/// @nodoc -class __$$PublicAccountImplCopyWithImpl<$Res> - extends _$PublicAccountCopyWithImpl<$Res, _$PublicAccountImpl> - implements _$$PublicAccountImplCopyWith<$Res> { - __$$PublicAccountImplCopyWithImpl( - _$PublicAccountImpl _value, - $Res Function(_$PublicAccountImpl) _then, - ) : super(_value, _then); - - /// Create a copy of PublicAccount - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? name = null, - Object? followerCount = null, - Object? identityVerified = null, - Object? following = null, - Object? createdAt = null, - Object? description = freezed, - Object? avatar = freezed, - }) { - return _then( - _$PublicAccountImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - followerCount: null == followerCount - ? _value.followerCount - : followerCount // ignore: cast_nullable_to_non_nullable - as int, - identityVerified: null == identityVerified - ? _value.identityVerified - : identityVerified // ignore: cast_nullable_to_non_nullable - as bool, - following: null == following - ? _value.following - : following // ignore: cast_nullable_to_non_nullable - as bool, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - description: freezed == description - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String?, - avatar: freezed == avatar - ? _value.avatar - : avatar // ignore: cast_nullable_to_non_nullable - as Resource?, - ), - ); - } } /// @nodoc @JsonSerializable() -class _$PublicAccountImpl extends _PublicAccount { - const _$PublicAccountImpl({ - required this.id, - required this.name, - @JsonKey(name: 'follower_count') required this.followerCount, - @JsonKey(name: 'identity_verified') required this.identityVerified, - @JsonKey(name: 'following') required this.following, - @JsonKey(name: 'created_at') required this.createdAt, - this.description, - this.avatar, - }) : super._(); - - factory _$PublicAccountImpl.fromJson(Map json) => - _$$PublicAccountImplFromJson(json); - - @override - final String id; - @override - final String name; - @override - @JsonKey(name: 'follower_count') - final int followerCount; - @override - @JsonKey(name: 'identity_verified') - final bool identityVerified; - - /// Quan hệ của *người đọc* với account này — false khi đọc ẩn danh và trên - /// trang của chính mình. Nút theo dõi không có nó thì không biết vẽ chiều nào. - @override - @JsonKey(name: 'following') - final bool following; - @override - @JsonKey(name: 'created_at') - final String createdAt; - @override - final String? description; - @override - final Resource? avatar; - - @override - String toString() { - return 'PublicAccount(id: $id, name: $name, followerCount: $followerCount, identityVerified: $identityVerified, following: $following, createdAt: $createdAt, description: $description, avatar: $avatar)'; - } - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PublicAccountImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.name, name) || other.name == name) && - (identical(other.followerCount, followerCount) || - other.followerCount == followerCount) && - (identical(other.identityVerified, identityVerified) || - other.identityVerified == identityVerified) && - (identical(other.following, following) || - other.following == following) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.description, description) || - other.description == description) && - (identical(other.avatar, avatar) || other.avatar == avatar)); - } +class _PublicAccount extends PublicAccount { + const _PublicAccount({required this.id, required this.name, @JsonKey(name: 'follower_count') required this.followerCount, @JsonKey(name: 'identity_verified') required this.identityVerified, @JsonKey(name: 'following') required this.following, @JsonKey(name: 'created_at') required this.createdAt, this.description, this.avatar}): super._(); + factory _PublicAccount.fromJson(Map json) => _$PublicAccountFromJson(json); + +@override final String id; +@override final String name; +@override@JsonKey(name: 'follower_count') final int followerCount; +@override@JsonKey(name: 'identity_verified') final bool identityVerified; +/// Quan hệ của *người đọc* với account này — false khi đọc ẩn danh và trên +/// trang của chính mình. Nút theo dõi không có nó thì không biết vẽ chiều nào. +@override@JsonKey(name: 'following') final bool following; +@override@JsonKey(name: 'created_at') final String createdAt; +@override final String? description; +@override final Resource? avatar; + +/// Create a copy of PublicAccount +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PublicAccountCopyWith<_PublicAccount> get copyWith => __$PublicAccountCopyWithImpl<_PublicAccount>(this, _$identity); + +@override +Map toJson() { + return _$PublicAccountToJson(this, ); +} - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - name, - followerCount, - identityVerified, - following, - createdAt, - description, - avatar, - ); - - /// Create a copy of PublicAccount - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PublicAccountImplCopyWith<_$PublicAccountImpl> get copyWith => - __$$PublicAccountImplCopyWithImpl<_$PublicAccountImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PublicAccountImplToJson(this); - } +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PublicAccount&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.followerCount, followerCount) || other.followerCount == followerCount)&&(identical(other.identityVerified, identityVerified) || other.identityVerified == identityVerified)&&(identical(other.following, following) || other.following == following)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.description, description) || other.description == description)&&(identical(other.avatar, avatar) || other.avatar == avatar)); } -abstract class _PublicAccount extends PublicAccount { - const factory _PublicAccount({ - required final String id, - required final String name, - @JsonKey(name: 'follower_count') required final int followerCount, - @JsonKey(name: 'identity_verified') required final bool identityVerified, - @JsonKey(name: 'following') required final bool following, - @JsonKey(name: 'created_at') required final String createdAt, - final String? description, - final Resource? avatar, - }) = _$PublicAccountImpl; - const _PublicAccount._() : super._(); - - factory _PublicAccount.fromJson(Map json) = - _$PublicAccountImpl.fromJson; - - @override - String get id; - @override - String get name; - @override - @JsonKey(name: 'follower_count') - int get followerCount; - @override - @JsonKey(name: 'identity_verified') - bool get identityVerified; - - /// Quan hệ của *người đọc* với account này — false khi đọc ẩn danh và trên - /// trang của chính mình. Nút theo dõi không có nó thì không biết vẽ chiều nào. - @override - @JsonKey(name: 'following') - bool get following; - @override - @JsonKey(name: 'created_at') - String get createdAt; - @override - String? get description; - @override - Resource? get avatar; - - /// Create a copy of PublicAccount - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PublicAccountImplCopyWith<_$PublicAccountImpl> get copyWith => - throw _privateConstructorUsedError; +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,followerCount,identityVerified,following,createdAt,description,avatar); + +@override +String toString() { + return 'PublicAccount(id: $id, name: $name, followerCount: $followerCount, identityVerified: $identityVerified, following: $following, createdAt: $createdAt, description: $description, avatar: $avatar)'; +} + + } + +/// @nodoc +abstract mixin class _$PublicAccountCopyWith<$Res> implements $PublicAccountCopyWith<$Res> { + factory _$PublicAccountCopyWith(_PublicAccount value, $Res Function(_PublicAccount) _then) = __$PublicAccountCopyWithImpl; +@override @useResult +$Res call({ + String id, String name,@JsonKey(name: 'follower_count') int followerCount,@JsonKey(name: 'identity_verified') bool identityVerified,@JsonKey(name: 'following') bool following,@JsonKey(name: 'created_at') String createdAt, String? description, Resource? avatar +}); + + + + +} +/// @nodoc +class __$PublicAccountCopyWithImpl<$Res> + implements _$PublicAccountCopyWith<$Res> { + __$PublicAccountCopyWithImpl(this._self, this._then); + + final _PublicAccount _self; + final $Res Function(_PublicAccount) _then; + +/// Create a copy of PublicAccount +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? followerCount = null,Object? identityVerified = null,Object? following = null,Object? createdAt = null,Object? description = freezed,Object? avatar = freezed,}) { + return _then(_PublicAccount( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,followerCount: null == followerCount ? _self.followerCount : followerCount // ignore: cast_nullable_to_non_nullable +as int,identityVerified: null == identityVerified ? _self.identityVerified : identityVerified // ignore: cast_nullable_to_non_nullable +as bool,following: null == following ? _self.following : following // ignore: cast_nullable_to_non_nullable +as bool,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String?,avatar: freezed == avatar ? _self.avatar : avatar // ignore: cast_nullable_to_non_nullable +as Resource?, + )); +} + + +} + +// dart format on diff --git a/lib/features/account/data/models/account_model.g.dart b/lib/features/account/data/models/account_model.g.dart index 9df45db..d6397b5 100644 --- a/lib/features/account/data/models/account_model.g.dart +++ b/lib/features/account/data/models/account_model.g.dart @@ -6,35 +6,33 @@ part of 'account_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$ProfileImpl _$$ProfileImplFromJson(Map json) => - _$ProfileImpl( - name: json['name'] as String, - country: json['country'] as String, - locale: json['locale'] as String, - timezone: json['timezone'] as String, - createdAt: json['created_at'] as String, - avatar: json['avatar'] == null - ? null - : Resource.fromJson(json['avatar'] as Map), - dateOfBirth: json['date_of_birth'] as String?, - description: json['description'] as String?, - gender: json['gender'] as String?, - ); +_Profile _$ProfileFromJson(Map json) => _Profile( + name: json['name'] as String, + country: json['country'] as String, + locale: json['locale'] as String, + timezone: json['timezone'] as String, + createdAt: json['created_at'] as String, + avatar: json['avatar'] == null + ? null + : Resource.fromJson(json['avatar'] as Map), + dateOfBirth: json['date_of_birth'] as String?, + description: json['description'] as String?, + gender: json['gender'] as String?, +); -Map _$$ProfileImplToJson(_$ProfileImpl instance) => - { - 'name': instance.name, - 'country': instance.country, - 'locale': instance.locale, - 'timezone': instance.timezone, - 'created_at': instance.createdAt, - 'avatar': instance.avatar, - 'date_of_birth': instance.dateOfBirth, - 'description': instance.description, - 'gender': instance.gender, - }; +Map _$ProfileToJson(_Profile instance) => { + 'name': instance.name, + 'country': instance.country, + 'locale': instance.locale, + 'timezone': instance.timezone, + 'created_at': instance.createdAt, + 'avatar': instance.avatar, + 'date_of_birth': instance.dateOfBirth, + 'description': instance.description, + 'gender': instance.gender, +}; -_$MeImpl _$$MeImplFromJson(Map json) => _$MeImpl( +_Me _$MeFromJson(Map json) => _Me( id: json['id'] as String, createdAt: json['created_at'] as String, email: json['email'] as String?, @@ -50,7 +48,7 @@ _$MeImpl _$$MeImplFromJson(Map json) => _$MeImpl( username: json['username'] as String?, ); -Map _$$MeImplToJson(_$MeImpl instance) => { +Map _$MeToJson(_Me instance) => { 'id': instance.id, 'created_at': instance.createdAt, 'email': instance.email, @@ -64,8 +62,8 @@ Map _$$MeImplToJson(_$MeImpl instance) => { 'username': instance.username, }; -_$PublicAccountImpl _$$PublicAccountImplFromJson(Map json) => - _$PublicAccountImpl( +_PublicAccount _$PublicAccountFromJson(Map json) => + _PublicAccount( id: json['id'] as String, name: json['name'] as String, followerCount: (json['follower_count'] as num).toInt(), @@ -78,7 +76,7 @@ _$PublicAccountImpl _$$PublicAccountImplFromJson(Map json) => : Resource.fromJson(json['avatar'] as Map), ); -Map _$$PublicAccountImplToJson(_$PublicAccountImpl instance) => +Map _$PublicAccountToJson(_PublicAccount instance) => { 'id': instance.id, 'name': instance.name, diff --git a/lib/features/account/data/models/order_view.dart b/lib/features/account/data/models/order_view.dart index ed89914..c4728f3 100644 --- a/lib/features/account/data/models/order_view.dart +++ b/lib/features/account/data/models/order_view.dart @@ -3,6 +3,7 @@ import 'package:shopnexus_flutter_app/api/generated/model/listing.dart'; import 'package:shopnexus_flutter_app/api/generated/model/order.dart'; import 'package:shopnexus_flutter_app/api/generated/model/order_item.dart'; import 'package:shopnexus_flutter_app/api/generated/model/order_state.dart'; +import 'package:shopnexus_flutter_app/api/generated/model/refund_summary.dart'; import 'package:shopnexus_flutter_app/api/generated/model/transport_status.dart'; import 'package:shopnexus_flutter_app/core/utils/deadline_utils.dart'; @@ -111,6 +112,23 @@ abstract class OrderView with _$OrderView { order.receivedAt == null && order.transport?.status == TransportStatus.delivered; + /// Vụ hoàn tiền đang mở trên đơn này, nếu có. + /// + /// `settled` là câu server bảo phải hỏi: các trạng thái chặn là của một cái + /// index, không phải một danh sách để mỗi client tự dựng lại. + RefundSummary? get openRefund { + final refund = order.refund; + return refund != null && !refund.settled ? refund : null; + } + + /// Người mua mở được một vụ hoàn tiền. Đúng hai điều kiện server đặt ra: + /// `POST /orders/{id}/refunds` trả 409 khi escrow đã kết — đơn đã hoàn thành + /// hoặc đã hủy — và khi đã có một vụ chưa xong trên cùng đơn. + /// + /// Hỏi trước chứ không để người mua điền xong biểu mẫu rồi mới nhận 409: một + /// nút chỉ nên có mặt khi nó bấm được. + bool get canRequestRefund => !isFinished && openRefund == null; + /// Kiện hàng chưa rời kho. Đây là cửa sổ duy nhất còn hủy được, và nó đúng cho /// **cả hai bên** — server cho bất kỳ ai trong đơn hủy, rồi từ chối nếu hàng đã /// đi (`Cancel(transport.Shipped())`), nên nút hỏi đúng câu server hỏi. diff --git a/lib/features/account/data/models/order_view.freezed.dart b/lib/features/account/data/models/order_view.freezed.dart index b120be0..93bbc13 100644 --- a/lib/features/account/data/models/order_view.freezed.dart +++ b/lib/features/account/data/models/order_view.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,319 +9,532 @@ part of 'order_view.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - /// @nodoc mixin _$OrderLineView { - OrderItem get item => throw _privateConstructorUsedError; - Listing? get listing => throw _privateConstructorUsedError; - /// Create a copy of OrderLineView - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $OrderLineViewCopyWith get copyWith => - throw _privateConstructorUsedError; + OrderItem get item; Listing? get listing; +/// Create a copy of OrderLineView +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OrderLineViewCopyWith get copyWith => _$OrderLineViewCopyWithImpl(this as OrderLineView, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is OrderLineView&&(identical(other.item, item) || other.item == item)&&(identical(other.listing, listing) || other.listing == listing)); } -/// @nodoc -abstract class $OrderLineViewCopyWith<$Res> { - factory $OrderLineViewCopyWith( - OrderLineView value, - $Res Function(OrderLineView) then, - ) = _$OrderLineViewCopyWithImpl<$Res, OrderLineView>; - @useResult - $Res call({OrderItem item, Listing? listing}); + +@override +int get hashCode => Object.hash(runtimeType,item,listing); + +@override +String toString() { + return 'OrderLineView(item: $item, listing: $listing)'; } -/// @nodoc -class _$OrderLineViewCopyWithImpl<$Res, $Val extends OrderLineView> - implements $OrderLineViewCopyWith<$Res> { - _$OrderLineViewCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of OrderLineView - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? item = null, Object? listing = freezed}) { - return _then( - _value.copyWith( - item: null == item - ? _value.item - : item // ignore: cast_nullable_to_non_nullable - as OrderItem, - listing: freezed == listing - ? _value.listing - : listing // ignore: cast_nullable_to_non_nullable - as Listing?, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$OrderLineViewImplCopyWith<$Res> +abstract mixin class $OrderLineViewCopyWith<$Res> { + factory $OrderLineViewCopyWith(OrderLineView value, $Res Function(OrderLineView) _then) = _$OrderLineViewCopyWithImpl; +@useResult +$Res call({ + OrderItem item, Listing? listing +}); + + + + +} +/// @nodoc +class _$OrderLineViewCopyWithImpl<$Res> implements $OrderLineViewCopyWith<$Res> { - factory _$$OrderLineViewImplCopyWith( - _$OrderLineViewImpl value, - $Res Function(_$OrderLineViewImpl) then, - ) = __$$OrderLineViewImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({OrderItem item, Listing? listing}); + _$OrderLineViewCopyWithImpl(this._self, this._then); + + final OrderLineView _self; + final $Res Function(OrderLineView) _then; + +/// Create a copy of OrderLineView +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? item = null,Object? listing = freezed,}) { + return _then(_self.copyWith( +item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable +as OrderItem,listing: freezed == listing ? _self.listing : listing // ignore: cast_nullable_to_non_nullable +as Listing?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [OrderLineView]. +extension OrderLineViewPatterns on OrderLineView { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _OrderLineView value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _OrderLineView() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _OrderLineView value) $default,){ +final _that = this; +switch (_that) { +case _OrderLineView(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _OrderLineView value)? $default,){ +final _that = this; +switch (_that) { +case _OrderLineView() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( OrderItem item, Listing? listing)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _OrderLineView() when $default != null: +return $default(_that.item,_that.listing);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( OrderItem item, Listing? listing) $default,) {final _that = this; +switch (_that) { +case _OrderLineView(): +return $default(_that.item,_that.listing);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( OrderItem item, Listing? listing)? $default,) {final _that = this; +switch (_that) { +case _OrderLineView() when $default != null: +return $default(_that.item,_that.listing);case _: + return null; + +} +} + } /// @nodoc -class __$$OrderLineViewImplCopyWithImpl<$Res> - extends _$OrderLineViewCopyWithImpl<$Res, _$OrderLineViewImpl> - implements _$$OrderLineViewImplCopyWith<$Res> { - __$$OrderLineViewImplCopyWithImpl( - _$OrderLineViewImpl _value, - $Res Function(_$OrderLineViewImpl) _then, - ) : super(_value, _then); - - /// Create a copy of OrderLineView - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? item = null, Object? listing = freezed}) { - return _then( - _$OrderLineViewImpl( - item: null == item - ? _value.item - : item // ignore: cast_nullable_to_non_nullable - as OrderItem, - listing: freezed == listing - ? _value.listing - : listing // ignore: cast_nullable_to_non_nullable - as Listing?, - ), - ); - } + + +class _OrderLineView extends OrderLineView { + const _OrderLineView({required this.item, this.listing}): super._(); + + +@override final OrderItem item; +@override final Listing? listing; + +/// Create a copy of OrderLineView +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OrderLineViewCopyWith<_OrderLineView> get copyWith => __$OrderLineViewCopyWithImpl<_OrderLineView>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OrderLineView&&(identical(other.item, item) || other.item == item)&&(identical(other.listing, listing) || other.listing == listing)); +} + + +@override +int get hashCode => Object.hash(runtimeType,item,listing); + +@override +String toString() { + return 'OrderLineView(item: $item, listing: $listing)'; +} + + } /// @nodoc +abstract mixin class _$OrderLineViewCopyWith<$Res> implements $OrderLineViewCopyWith<$Res> { + factory _$OrderLineViewCopyWith(_OrderLineView value, $Res Function(_OrderLineView) _then) = __$OrderLineViewCopyWithImpl; +@override @useResult +$Res call({ + OrderItem item, Listing? listing +}); + + + + +} +/// @nodoc +class __$OrderLineViewCopyWithImpl<$Res> + implements _$OrderLineViewCopyWith<$Res> { + __$OrderLineViewCopyWithImpl(this._self, this._then); + + final _OrderLineView _self; + final $Res Function(_OrderLineView) _then; + +/// Create a copy of OrderLineView +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? item = null,Object? listing = freezed,}) { + return _then(_OrderLineView( +item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable +as OrderItem,listing: freezed == listing ? _self.listing : listing // ignore: cast_nullable_to_non_nullable +as Listing?, + )); +} + -class _$OrderLineViewImpl extends _OrderLineView { - const _$OrderLineViewImpl({required this.item, this.listing}) : super._(); - - @override - final OrderItem item; - @override - final Listing? listing; - - @override - String toString() { - return 'OrderLineView(item: $item, listing: $listing)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$OrderLineViewImpl && - (identical(other.item, item) || other.item == item) && - (identical(other.listing, listing) || other.listing == listing)); - } - - @override - int get hashCode => Object.hash(runtimeType, item, listing); - - /// Create a copy of OrderLineView - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$OrderLineViewImplCopyWith<_$OrderLineViewImpl> get copyWith => - __$$OrderLineViewImplCopyWithImpl<_$OrderLineViewImpl>(this, _$identity); -} - -abstract class _OrderLineView extends OrderLineView { - const factory _OrderLineView({ - required final OrderItem item, - final Listing? listing, - }) = _$OrderLineViewImpl; - const _OrderLineView._() : super._(); - - @override - OrderItem get item; - @override - Listing? get listing; - - /// Create a copy of OrderLineView - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$OrderLineViewImplCopyWith<_$OrderLineViewImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$OrderView { - Order get order => throw _privateConstructorUsedError; - List get lines => throw _privateConstructorUsedError; - /// Create a copy of OrderView - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $OrderViewCopyWith get copyWith => - throw _privateConstructorUsedError; + Order get order; List get lines; +/// Create a copy of OrderView +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OrderViewCopyWith get copyWith => _$OrderViewCopyWithImpl(this as OrderView, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is OrderView&&(identical(other.order, order) || other.order == order)&&const DeepCollectionEquality().equals(other.lines, lines)); } -/// @nodoc -abstract class $OrderViewCopyWith<$Res> { - factory $OrderViewCopyWith(OrderView value, $Res Function(OrderView) then) = - _$OrderViewCopyWithImpl<$Res, OrderView>; - @useResult - $Res call({Order order, List lines}); + +@override +int get hashCode => Object.hash(runtimeType,order,const DeepCollectionEquality().hash(lines)); + +@override +String toString() { + return 'OrderView(order: $order, lines: $lines)'; } -/// @nodoc -class _$OrderViewCopyWithImpl<$Res, $Val extends OrderView> - implements $OrderViewCopyWith<$Res> { - _$OrderViewCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of OrderView - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? order = null, Object? lines = null}) { - return _then( - _value.copyWith( - order: null == order - ? _value.order - : order // ignore: cast_nullable_to_non_nullable - as Order, - lines: null == lines - ? _value.lines - : lines // ignore: cast_nullable_to_non_nullable - as List, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$OrderViewImplCopyWith<$Res> +abstract mixin class $OrderViewCopyWith<$Res> { + factory $OrderViewCopyWith(OrderView value, $Res Function(OrderView) _then) = _$OrderViewCopyWithImpl; +@useResult +$Res call({ + Order order, List lines +}); + + + + +} +/// @nodoc +class _$OrderViewCopyWithImpl<$Res> implements $OrderViewCopyWith<$Res> { - factory _$$OrderViewImplCopyWith( - _$OrderViewImpl value, - $Res Function(_$OrderViewImpl) then, - ) = __$$OrderViewImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({Order order, List lines}); + _$OrderViewCopyWithImpl(this._self, this._then); + + final OrderView _self; + final $Res Function(OrderView) _then; + +/// Create a copy of OrderView +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? order = null,Object? lines = null,}) { + return _then(_self.copyWith( +order: null == order ? _self.order : order // ignore: cast_nullable_to_non_nullable +as Order,lines: null == lines ? _self.lines : lines // ignore: cast_nullable_to_non_nullable +as List, + )); +} + +} + + +/// Adds pattern-matching-related methods to [OrderView]. +extension OrderViewPatterns on OrderView { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _OrderView value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _OrderView() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _OrderView value) $default,){ +final _that = this; +switch (_that) { +case _OrderView(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _OrderView value)? $default,){ +final _that = this; +switch (_that) { +case _OrderView() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( Order order, List lines)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _OrderView() when $default != null: +return $default(_that.order,_that.lines);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( Order order, List lines) $default,) {final _that = this; +switch (_that) { +case _OrderView(): +return $default(_that.order,_that.lines);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( Order order, List lines)? $default,) {final _that = this; +switch (_that) { +case _OrderView() when $default != null: +return $default(_that.order,_that.lines);case _: + return null; + +} +} + } /// @nodoc -class __$$OrderViewImplCopyWithImpl<$Res> - extends _$OrderViewCopyWithImpl<$Res, _$OrderViewImpl> - implements _$$OrderViewImplCopyWith<$Res> { - __$$OrderViewImplCopyWithImpl( - _$OrderViewImpl _value, - $Res Function(_$OrderViewImpl) _then, - ) : super(_value, _then); - - /// Create a copy of OrderView - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? order = null, Object? lines = null}) { - return _then( - _$OrderViewImpl( - order: null == order - ? _value.order - : order // ignore: cast_nullable_to_non_nullable - as Order, - lines: null == lines - ? _value._lines - : lines // ignore: cast_nullable_to_non_nullable - as List, - ), - ); - } + + +class _OrderView extends OrderView { + const _OrderView({required this.order, required final List lines}): _lines = lines,super._(); + + +@override final Order order; + final List _lines; +@override List get lines { + if (_lines is EqualUnmodifiableListView) return _lines; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_lines); +} + + +/// Create a copy of OrderView +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OrderViewCopyWith<_OrderView> get copyWith => __$OrderViewCopyWithImpl<_OrderView>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OrderView&&(identical(other.order, order) || other.order == order)&&const DeepCollectionEquality().equals(other._lines, _lines)); } + +@override +int get hashCode => Object.hash(runtimeType,order,const DeepCollectionEquality().hash(_lines)); + +@override +String toString() { + return 'OrderView(order: $order, lines: $lines)'; +} + + +} + +/// @nodoc +abstract mixin class _$OrderViewCopyWith<$Res> implements $OrderViewCopyWith<$Res> { + factory _$OrderViewCopyWith(_OrderView value, $Res Function(_OrderView) _then) = __$OrderViewCopyWithImpl; +@override @useResult +$Res call({ + Order order, List lines +}); + + + + +} /// @nodoc +class __$OrderViewCopyWithImpl<$Res> + implements _$OrderViewCopyWith<$Res> { + __$OrderViewCopyWithImpl(this._self, this._then); + + final _OrderView _self; + final $Res Function(_OrderView) _then; + +/// Create a copy of OrderView +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? order = null,Object? lines = null,}) { + return _then(_OrderView( +order: null == order ? _self.order : order // ignore: cast_nullable_to_non_nullable +as Order,lines: null == lines ? _self._lines : lines // ignore: cast_nullable_to_non_nullable +as List, + )); +} + -class _$OrderViewImpl extends _OrderView { - const _$OrderViewImpl({ - required this.order, - required final List lines, - }) : _lines = lines, - super._(); - - @override - final Order order; - final List _lines; - @override - List get lines { - if (_lines is EqualUnmodifiableListView) return _lines; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_lines); - } - - @override - String toString() { - return 'OrderView(order: $order, lines: $lines)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$OrderViewImpl && - (identical(other.order, order) || other.order == order) && - const DeepCollectionEquality().equals(other._lines, _lines)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - order, - const DeepCollectionEquality().hash(_lines), - ); - - /// Create a copy of OrderView - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$OrderViewImplCopyWith<_$OrderViewImpl> get copyWith => - __$$OrderViewImplCopyWithImpl<_$OrderViewImpl>(this, _$identity); -} - -abstract class _OrderView extends OrderView { - const factory _OrderView({ - required final Order order, - required final List lines, - }) = _$OrderViewImpl; - const _OrderView._() : super._(); - - @override - Order get order; - @override - List get lines; - - /// Create a copy of OrderView - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$OrderViewImplCopyWith<_$OrderViewImpl> get copyWith => - throw _privateConstructorUsedError; } + +// dart format on diff --git a/lib/features/account/data/repositories/account_repository.dart b/lib/features/account/data/repositories/account_repository.dart index b7e78e0..01cc502 100644 --- a/lib/features/account/data/repositories/account_repository.dart +++ b/lib/features/account/data/repositories/account_repository.dart @@ -11,9 +11,7 @@ import 'package:shopnexus_flutter_app/api/generated/model/update_notification_pr import 'package:shopnexus_flutter_app/api/generated/model/update_notification_preferences_request_items_inner.dart'; import 'package:shopnexus_flutter_app/api/generated/model/account_summary.dart'; import 'package:shopnexus_flutter_app/api/generated/model/verify_contact_phone_request.dart'; -import 'package:shopnexus_flutter_app/api/generated/model/account_create_upload_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/confirm_receipt_request.dart'; -import 'package:shopnexus_flutter_app/api/generated/model/create_upload_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/administrative_area.dart'; import 'package:shopnexus_flutter_app/api/generated/model/contact.dart'; import 'package:shopnexus_flutter_app/api/generated/model/device.dart'; @@ -30,7 +28,7 @@ import 'package:shopnexus_flutter_app/api/generated/model/update_profile_request import 'package:shopnexus_flutter_app/features/account/data/data_sources/account_api_service.dart'; import 'package:shopnexus_flutter_app/features/account/data/models/account_model.dart'; import 'package:shopnexus_flutter_app/features/account/data/models/order_view.dart'; -import 'package:shopnexus_flutter_app/core/network/resource_upload.dart'; +import 'package:shopnexus_flutter_app/core/upload/resource_uploader.dart'; part 'account_repository.g.dart'; @@ -39,38 +37,31 @@ class AccountRepository { final generated.AccountApi _api; final OrderApi _orderApi; final CatalogApi _catalogApi; + final ResourceUploader _uploader; AccountRepository( this._apiService, this._api, this._orderApi, this._catalogApi, + this._uploader, ); - /// Reserve a slot, PUT the bytes to the signed URL, confirm — the bytes never - /// pass through this API, and until the confirmation lands the resource - /// resolves to nothing, so a profile can never show an avatar that never - /// arrived. Returns the resource id for - /// `UpdateProfileRequest.avatarResourceId`. + /// Returns the resource id for `UpdateProfileRequest.avatarResourceId`. The + /// three steps behind it — reserve, PUT, confirm — are [ResourceUploader]'s, + /// the same ones every other upload on the platform takes. Future uploadAvatar({ required List bytes, required String filename, required String mime, }) async { - final reserved = (await _api.meUploadsPost( - accountCreateUploadRequest: AccountCreateUploadRequest( - filename: filename, - kind: AccountCreateUploadRequestKindEnum.avatar, - mime: mime, - size: bytes.length, - ), - )).data?.data; - if (reserved == null) throw StateError('empty upload slot'); - - await putToSlot(reserved, bytes); - - await _api.meUploadsIdConfirmationPost(id: reserved.resourceId); - return reserved.resourceId; + final resource = await _uploader.upload( + UploadTarget.avatar, + bytes: bytes, + filename: filename, + mime: mime, + ); + return resource.id; } /// Ảnh mở hộp, cho lúc xác nhận đã nhận hàng. Cùng ba bước như mọi upload khác: @@ -81,19 +72,13 @@ class AccountRepository { required String filename, required String mime, }) async { - final reserved = (await _orderApi.ordersUploadsPost( - createUploadRequest: CreateUploadRequest( - filename: filename, - mime: mime, - size: bytes.length, - ), - )).data?.data; - if (reserved == null) throw StateError('empty upload slot'); - - await putToSlot(reserved, bytes); - - await _orderApi.ordersUploadsIdConfirmationPost(id: reserved.resourceId); - return reserved.resourceId; + final resource = await _uploader.upload( + UploadTarget.order, + bytes: bytes, + filename: filename, + mime: mime, + ); + return resource.id; } /// Người mua nói hàng đã tới. Đây là thứ khởi động đồng hồ trả tiền cho người @@ -457,4 +442,5 @@ AccountRepository accountRepository(Ref ref) => AccountRepository( ref.watch(accountApiProvider), ref.watch(orderApiProvider), ref.watch(catalogApiProvider), + ref.watch(resourceUploaderProvider), ); diff --git a/lib/features/account/data/repositories/account_repository.g.dart b/lib/features/account/data/repositories/account_repository.g.dart index 6244a8e..6f496f6 100644 --- a/lib/features/account/data/repositories/account_repository.g.dart +++ b/lib/features/account/data/repositories/account_repository.g.dart @@ -6,23 +6,52 @@ part of 'account_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$accountRepositoryHash() => r'32add2659feaf2181af3521deb0d99239da5ebf0'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [accountRepository]. @ProviderFor(accountRepository) -final accountRepositoryProvider = - AutoDisposeProvider.internal( - accountRepository, - name: r'accountRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$accountRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, +const accountRepositoryProvider = AccountRepositoryProvider._(); + +final class AccountRepositoryProvider + extends + $FunctionalProvider< + AccountRepository, + AccountRepository, + AccountRepository + > + with $Provider { + const AccountRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'accountRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$accountRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + AccountRepository create(Ref ref) { + return accountRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AccountRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef AccountRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +String _$accountRepositoryHash() => r'32add2659feaf2181af3521deb0d99239da5ebf0'; diff --git a/lib/features/account/data/repositories/rating_repository.dart b/lib/features/account/data/repositories/rating_repository.dart index ef9f954..335b62b 100644 --- a/lib/features/account/data/repositories/rating_repository.dart +++ b/lib/features/account/data/repositories/rating_repository.dart @@ -4,7 +4,6 @@ import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:shopnexus_flutter_app/api/api_providers.dart'; import 'package:shopnexus_flutter_app/api/generated/api/trust_api.dart'; -import 'package:shopnexus_flutter_app/api/generated/model/create_upload_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/order_feedback.dart'; import 'package:shopnexus_flutter_app/api/generated/model/review.dart'; import 'package:shopnexus_flutter_app/api/generated/model/review_reply.dart'; @@ -14,7 +13,7 @@ import 'package:shopnexus_flutter_app/api/generated/model/submit_review_reply_re import 'package:shopnexus_flutter_app/api/generated/model/submit_review_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/update_review_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/vote_review_request.dart'; -import 'package:shopnexus_flutter_app/core/network/resource_upload.dart'; +import 'package:shopnexus_flutter_app/core/upload/resource_uploader.dart'; part 'rating_repository.g.dart'; @@ -32,10 +31,12 @@ part 'rating_repository.g.dart'; /// sinh ra cả hai và cộng chung sẽ tính đơn đó hai lần. @riverpod RatingRepository ratingRepository(Ref ref) => - RatingRepository(ref.watch(trustApiProvider)); + RatingRepository(ref.watch(trustApiProvider), ref.watch(resourceUploaderProvider)); class RatingRepository { - const RatingRepository(this._trustApi); + const RatingRepository(this._trustApi, this._uploader); + + final ResourceUploader _uploader; /// Cả hai hệ đều là trust's, kể cả cái treo trên route `/orders/{id}/feedback`: /// đơn chỉ là thứ đánh giá đó nói *về*, còn uy tín là của trust. @@ -164,22 +165,14 @@ class RatingRepository { return tally; } - /// Ảnh kèm đánh giá. Ba bước như mọi upload khác trong app: giữ chỗ, PUT bằng - /// [putToSlot], rồi xác nhận — trước khi xác nhận thì resource không resolve ra gì. + /// Ảnh kèm đánh giá. Ba bước là của [ResourceUploader], như mọi upload khác. Future uploadReviewPhoto(File file, {required String mime}) async { - final size = await file.length(); - final reserved = (await _trustApi.reviewsUploadsPost( - createUploadRequest: CreateUploadRequest( - filename: file.uri.pathSegments.last, - mime: mime, - size: size, - ), - )).data?.data; - if (reserved == null) throw StateError('empty upload slot'); - - await putToSlot(reserved, await file.readAsBytes()); - - await _trustApi.reviewsUploadsIdConfirmationPost(id: reserved.resourceId); - return reserved.resourceId; + final resource = await _uploader.upload( + UploadTarget.review, + bytes: await file.readAsBytes(), + filename: file.uri.pathSegments.last, + mime: mime, + ); + return resource.id; } } diff --git a/lib/features/account/data/repositories/rating_repository.g.dart b/lib/features/account/data/repositories/rating_repository.g.dart index 3d6fffa..e6c0468 100644 --- a/lib/features/account/data/repositories/rating_repository.g.dart +++ b/lib/features/account/data/repositories/rating_repository.g.dart @@ -6,8 +6,8 @@ part of 'rating_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$ratingRepositoryHash() => r'cbc43fddacb0629e7ccc4e15b64b879b5204895b'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Một đơn sinh ra **hai** thứ chấm điểm, và một nhà cho cả hai vì người dùng thấy /// một việc: /// @@ -20,21 +20,74 @@ String _$ratingRepositoryHash() => r'cbc43fddacb0629e7ccc4e15b64b879b5204895b'; /// /// Server đếm chúng ở hai cặp cột riêng trên cùng một hàng, đúng vì một đơn có thể /// sinh ra cả hai và cộng chung sẽ tính đơn đó hai lần. -/// -/// Copied from [ratingRepository]. + @ProviderFor(ratingRepository) -final ratingRepositoryProvider = AutoDisposeProvider.internal( - ratingRepository, - name: r'ratingRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$ratingRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef RatingRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const ratingRepositoryProvider = RatingRepositoryProvider._(); + +/// Một đơn sinh ra **hai** thứ chấm điểm, và một nhà cho cả hai vì người dùng thấy +/// một việc: +/// +/// - **Feedback** (`/orders/{id}/feedback`) là đánh giá *giao dịch*: **kín** cho tới +/// khi cả hai bên gửi hoặc hết cửa sổ mù, hai bên chấm nhau, và nó cộng vào uy tín +/// của account. Chiều được suy từ việc người gọi đứng ở phía nào của đơn — không +/// ai gửi nó lên. +/// - **Review** (`/listings/{id}/reviews`) là đánh giá *sản phẩm*: công khai ngay, và +/// nó cộng vào `cached_rating` của tin. +/// +/// Server đếm chúng ở hai cặp cột riêng trên cùng một hàng, đúng vì một đơn có thể +/// sinh ra cả hai và cộng chung sẽ tính đơn đó hai lần. + +final class RatingRepositoryProvider + extends + $FunctionalProvider< + RatingRepository, + RatingRepository, + RatingRepository + > + with $Provider { + /// Một đơn sinh ra **hai** thứ chấm điểm, và một nhà cho cả hai vì người dùng thấy + /// một việc: + /// + /// - **Feedback** (`/orders/{id}/feedback`) là đánh giá *giao dịch*: **kín** cho tới + /// khi cả hai bên gửi hoặc hết cửa sổ mù, hai bên chấm nhau, và nó cộng vào uy tín + /// của account. Chiều được suy từ việc người gọi đứng ở phía nào của đơn — không + /// ai gửi nó lên. + /// - **Review** (`/listings/{id}/reviews`) là đánh giá *sản phẩm*: công khai ngay, và + /// nó cộng vào `cached_rating` của tin. + /// + /// Server đếm chúng ở hai cặp cột riêng trên cùng một hàng, đúng vì một đơn có thể + /// sinh ra cả hai và cộng chung sẽ tính đơn đó hai lần. + const RatingRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'ratingRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$ratingRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + RatingRepository create(Ref ref) { + return ratingRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(RatingRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$ratingRepositoryHash() => r'cbc43fddacb0629e7ccc4e15b64b879b5204895b'; diff --git a/lib/features/account/data/repositories/reputation_repository.g.dart b/lib/features/account/data/repositories/reputation_repository.g.dart index 8a10b79..7566123 100644 --- a/lib/features/account/data/repositories/reputation_repository.g.dart +++ b/lib/features/account/data/repositories/reputation_repository.g.dart @@ -6,24 +6,53 @@ part of 'reputation_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$reputationRepositoryHash() => - r'2a6cd0fed9dc15202ba300062938bc4c1a607629'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [reputationRepository]. @ProviderFor(reputationRepository) -final reputationRepositoryProvider = - AutoDisposeProvider.internal( - reputationRepository, - name: r'reputationRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$reputationRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, +const reputationRepositoryProvider = ReputationRepositoryProvider._(); + +final class ReputationRepositoryProvider + extends + $FunctionalProvider< + ReputationRepository, + ReputationRepository, + ReputationRepository + > + with $Provider { + const ReputationRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'reputationRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$reputationRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + ReputationRepository create(Ref ref) { + return reputationRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(ReputationRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef ReputationRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +String _$reputationRepositoryHash() => + r'2a6cd0fed9dc15202ba300062938bc4c1a607629'; diff --git a/lib/features/account/presentation/providers/account_provider.g.dart b/lib/features/account/presentation/providers/account_provider.g.dart index 365cba7..5633226 100644 --- a/lib/features/account/presentation/providers/account_provider.g.dart +++ b/lib/features/account/presentation/providers/account_provider.g.dart @@ -6,162 +6,149 @@ part of 'account_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$profileHash() => r'5f4ca96096caad1c75abb32ca4013f387cb76fbb'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [profile]. @ProviderFor(profile) -final profileProvider = AutoDisposeFutureProvider.internal( - profile, - name: r'profileProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$profileHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef ProfileRef = AutoDisposeFutureProviderRef; -String _$publicProfileHash() => r'34d64cd73a71c9663e0919fc480853985677a1c2'; +const profileProvider = ProfileProvider._(); + +final class ProfileProvider + extends $FunctionalProvider, Me, FutureOr> + with $FutureModifier, $FutureProvider { + const ProfileProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'profileProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); + @override + String debugGetCreateSourceHash() => _$profileHash(); - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); + @override + FutureOr create(Ref ref) { + return profile(ref); } } -/// See also [publicProfile]. -@ProviderFor(publicProfile) -const publicProfileProvider = PublicProfileFamily(); +String _$profileHash() => r'5f4ca96096caad1c75abb32ca4013f387cb76fbb'; -/// See also [publicProfile]. -class PublicProfileFamily extends Family> { - /// See also [publicProfile]. - const PublicProfileFamily(); +@ProviderFor(publicProfile) +const publicProfileProvider = PublicProfileFamily._(); + +final class PublicProfileProvider + extends + $FunctionalProvider< + AsyncValue, + PublicAccount, + FutureOr + > + with $FutureModifier, $FutureProvider { + const PublicProfileProvider._({ + required PublicProfileFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'publicProfileProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// See also [publicProfile]. - PublicProfileProvider call(String accountId) { - return PublicProfileProvider(accountId); - } + @override + String debugGetCreateSourceHash() => _$publicProfileHash(); @override - PublicProfileProvider getProviderOverride( - covariant PublicProfileProvider provider, - ) { - return call(provider.accountId); + String toString() { + return r'publicProfileProvider' + '' + '($argument)'; } - static const Iterable? _dependencies = null; - + @$internal @override - Iterable? get dependencies => _dependencies; + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); - static const Iterable? _allTransitiveDependencies = null; + @override + FutureOr create(Ref ref) { + final argument = this.argument as String; + return publicProfile(ref, argument); + } @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; + bool operator ==(Object other) { + return other is PublicProfileProvider && other.argument == argument; + } @override - String? get name => r'publicProfileProvider'; + int get hashCode { + return argument.hashCode; + } } -/// See also [publicProfile]. -class PublicProfileProvider extends AutoDisposeFutureProvider { - /// See also [publicProfile]. - PublicProfileProvider(String accountId) - : this._internal( - (ref) => publicProfile(ref as PublicProfileRef, accountId), - from: publicProfileProvider, - name: r'publicProfileProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$publicProfileHash, - dependencies: PublicProfileFamily._dependencies, - allTransitiveDependencies: - PublicProfileFamily._allTransitiveDependencies, - accountId: accountId, - ); - - PublicProfileProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.accountId, - }) : super.internal(); - - final String accountId; +String _$publicProfileHash() => r'34d64cd73a71c9663e0919fc480853985677a1c2'; - @override - Override overrideWith( - FutureOr Function(PublicProfileRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: PublicProfileProvider._internal( - (ref) => create(ref as PublicProfileRef), - from: from, - name: null, +final class PublicProfileFamily extends $Family + with $FunctionalFamilyOverride, String> { + const PublicProfileFamily._() + : super( + retry: null, + name: r'publicProfileProvider', dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - accountId: accountId, - ), - ); - } + $allTransitiveDependencies: null, + isAutoDispose: true, + ); - @override - AutoDisposeFutureProviderElement createElement() { - return _PublicProfileProviderElement(this); - } + PublicProfileProvider call(String accountId) => + PublicProfileProvider._(argument: accountId, from: this); @override - bool operator ==(Object other) { - return other is PublicProfileProvider && other.accountId == accountId; - } + String toString() => r'publicProfileProvider'; +} - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, accountId.hashCode); +/// Gọi bằng `read` chứ không `watch`, nên không gì giữ notifier sống qua các +/// `await` bên dưới: ghi `state` sau đó ném "Cannot use the Ref ... after it has +/// been disposed" trong khi thay đổi *đã* được lưu trên server. - return _SystemHash.finish(hash); - } -} +@ProviderFor(AccountController) +const accountControllerProvider = AccountControllerProvider._(); -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin PublicProfileRef on AutoDisposeFutureProviderRef { - /// The parameter `accountId` of this provider. - String get accountId; -} +/// Gọi bằng `read` chứ không `watch`, nên không gì giữ notifier sống qua các +/// `await` bên dưới: ghi `state` sau đó ném "Cannot use the Ref ... after it has +/// been disposed" trong khi thay đổi *đã* được lưu trên server. +final class AccountControllerProvider + extends $AsyncNotifierProvider { + /// Gọi bằng `read` chứ không `watch`, nên không gì giữ notifier sống qua các + /// `await` bên dưới: ghi `state` sau đó ném "Cannot use the Ref ... after it has + /// been disposed" trong khi thay đổi *đã* được lưu trên server. + const AccountControllerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'accountControllerProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); -class _PublicProfileProviderElement - extends AutoDisposeFutureProviderElement - with PublicProfileRef { - _PublicProfileProviderElement(super.provider); + @override + String debugGetCreateSourceHash() => _$accountControllerHash(); + @$internal @override - String get accountId => (origin as PublicProfileProvider).accountId; + AccountController create() => AccountController(); } String _$accountControllerHash() => r'd2699ef1d93203ac21fa2946d816ea5b9460cf17'; @@ -169,20 +156,22 @@ String _$accountControllerHash() => r'd2699ef1d93203ac21fa2946d816ea5b9460cf17'; /// Gọi bằng `read` chứ không `watch`, nên không gì giữ notifier sống qua các /// `await` bên dưới: ghi `state` sau đó ném "Cannot use the Ref ... after it has /// been disposed" trong khi thay đổi *đã* được lưu trên server. -/// -/// Copied from [AccountController]. -@ProviderFor(AccountController) -final accountControllerProvider = - AutoDisposeAsyncNotifierProvider.internal( - AccountController.new, - name: r'accountControllerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$accountControllerHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -typedef _$AccountController = AutoDisposeAsyncNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package + +abstract class _$AccountController extends $AsyncNotifier { + FutureOr build(); + @$mustCallSuper + @override + void runBuild() { + build(); + final ref = this.ref as $Ref, void>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, void>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, null); + } +} diff --git a/lib/features/account/presentation/providers/action_inbox_provider.g.dart b/lib/features/account/presentation/providers/action_inbox_provider.g.dart index 48e2deb..5c61e6f 100644 --- a/lib/features/account/presentation/providers/action_inbox_provider.g.dart +++ b/lib/features/account/presentation/providers/action_inbox_provider.g.dart @@ -6,29 +6,63 @@ part of 'action_inbox_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$actionInboxHash() => r'de580754fcd882769ce2681ea5d8007ea374c112'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Số việc đang chờ chính người dùng này, gom từ cả hai vai. /// /// Mỗi con số hỏi đúng cái nó nói. `summary.open` từng là nguồn cho phần đơn /// hàng và sai hai lần: `open` là đơn *đã* được xác nhận — nên việc gấp nhất, /// đơn chờ xác nhận, không nằm trong đó — và summary chỉ tính trong cửa sổ thời /// gian của nó, nên một đơn cũ hơn cửa sổ đơn giản là biến mất khỏi badge. -/// -/// Copied from [actionInbox]. + @ProviderFor(actionInbox) -final actionInboxProvider = AutoDisposeFutureProvider.internal( - actionInbox, - name: r'actionInboxProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$actionInboxHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef ActionInboxRef = AutoDisposeFutureProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const actionInboxProvider = ActionInboxProvider._(); + +/// Số việc đang chờ chính người dùng này, gom từ cả hai vai. +/// +/// Mỗi con số hỏi đúng cái nó nói. `summary.open` từng là nguồn cho phần đơn +/// hàng và sai hai lần: `open` là đơn *đã* được xác nhận — nên việc gấp nhất, +/// đơn chờ xác nhận, không nằm trong đó — và summary chỉ tính trong cửa sổ thời +/// gian của nó, nên một đơn cũ hơn cửa sổ đơn giản là biến mất khỏi badge. + +final class ActionInboxProvider + extends + $FunctionalProvider< + AsyncValue, + ActionInbox, + FutureOr + > + with $FutureModifier, $FutureProvider { + /// Số việc đang chờ chính người dùng này, gom từ cả hai vai. + /// + /// Mỗi con số hỏi đúng cái nó nói. `summary.open` từng là nguồn cho phần đơn + /// hàng và sai hai lần: `open` là đơn *đã* được xác nhận — nên việc gấp nhất, + /// đơn chờ xác nhận, không nằm trong đó — và summary chỉ tính trong cửa sổ thời + /// gian của nó, nên một đơn cũ hơn cửa sổ đơn giản là biến mất khỏi badge. + const ActionInboxProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'actionInboxProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$actionInboxHash(); + + @$internal + @override + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return actionInbox(ref); + } +} + +String _$actionInboxHash() => r'de580754fcd882769ce2681ea5d8007ea374c112'; diff --git a/lib/features/account/presentation/providers/addresses_provider.g.dart b/lib/features/account/presentation/providers/addresses_provider.g.dart index d6f15e1..3dd8cda 100644 --- a/lib/features/account/presentation/providers/addresses_provider.g.dart +++ b/lib/features/account/presentation/providers/addresses_provider.g.dart @@ -6,39 +6,90 @@ part of 'addresses_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$buyerContactsHash() => r'40863f4e9a54616a93002544d796a363b890efc1'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [buyerContacts]. @ProviderFor(buyerContacts) -final buyerContactsProvider = AutoDisposeFutureProvider>.internal( - buyerContacts, - name: r'buyerContactsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$buyerContactsHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef BuyerContactsRef = AutoDisposeFutureProviderRef>; +const buyerContactsProvider = BuyerContactsProvider._(); + +final class BuyerContactsProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with $FutureModifier>, $FutureProvider> { + const BuyerContactsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'buyerContactsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$buyerContactsHash(); + + @$internal + @override + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr> create(Ref ref) { + return buyerContacts(ref); + } +} + +String _$buyerContactsHash() => r'40863f4e9a54616a93002544d796a363b890efc1'; + +@ProviderFor(AddressesController) +const addressesControllerProvider = AddressesControllerProvider._(); + +final class AddressesControllerProvider + extends $AsyncNotifierProvider { + const AddressesControllerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'addressesControllerProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$addressesControllerHash(); + + @$internal + @override + AddressesController create() => AddressesController(); +} + String _$addressesControllerHash() => r'9c901d09ef1f93bb35bd0d0c499a7b0d172f2e58'; -/// See also [AddressesController]. -@ProviderFor(AddressesController) -final addressesControllerProvider = - AutoDisposeAsyncNotifierProvider.internal( - AddressesController.new, - name: r'addressesControllerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$addressesControllerHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -typedef _$AddressesController = AutoDisposeAsyncNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$AddressesController extends $AsyncNotifier { + FutureOr build(); + @$mustCallSuper + @override + void runBuild() { + build(); + final ref = this.ref as $Ref, void>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, void>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, null); + } +} diff --git a/lib/features/account/presentation/providers/administrative_areas_provider.g.dart b/lib/features/account/presentation/providers/administrative_areas_provider.g.dart index 2a8c217..ee67923 100644 --- a/lib/features/account/presentation/providers/administrative_areas_provider.g.dart +++ b/lib/features/account/presentation/providers/administrative_areas_provider.g.dart @@ -6,183 +6,150 @@ part of 'administrative_areas_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$provincesHash() => r'16b1ef34563787d7207fe02cb9bb2d4a97327da3'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// The area vocabulary the address form writes an address in and the browse /// filter narrows by. It is public, unauthenticated and changes about once a /// decade, so each level is held for the session instead of refetched every time /// a picker opens. -/// -/// Copied from [provinces]. + @ProviderFor(provinces) -final provincesProvider = FutureProvider>.internal( - provinces, - name: r'provincesProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$provincesHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef ProvincesRef = FutureProviderRef>; -String _$wardsHash() => r'c51d90dc5ac1fa93bef845684e53709185d254c7'; +const provincesProvider = ProvincesProvider._(); -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); +/// The area vocabulary the address form writes an address in and the browse +/// filter narrows by. It is public, unauthenticated and changes about once a +/// decade, so each level is held for the session instead of refetched every time +/// a picker opens. - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } +final class ProvincesProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with + $FutureModifier>, + $FutureProvider> { + /// The area vocabulary the address form writes an address in and the browse + /// filter narrows by. It is public, unauthenticated and changes about once a + /// decade, so each level is held for the session instead of refetched every time + /// a picker opens. + const ProvincesProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'provincesProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); + @override + String debugGetCreateSourceHash() => _$provincesHash(); + + @$internal + @override + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr> create(Ref ref) { + return provinces(ref); } } +String _$provincesHash() => r'16b1ef34563787d7207fe02cb9bb2d4a97327da3'; + /// A province answers every one of its wards in one response — up to 549 — which /// is why the picker searches the list rather than scrolling it. -/// -/// Copied from [wards]. + @ProviderFor(wards) -const wardsProvider = WardsFamily(); +const wardsProvider = WardsFamily._(); /// A province answers every one of its wards in one response — up to 549 — which /// is why the picker searches the list rather than scrolling it. -/// -/// Copied from [wards]. -class WardsFamily extends Family>> { - /// A province answers every one of its wards in one response — up to 549 — which - /// is why the picker searches the list rather than scrolling it. - /// - /// Copied from [wards]. - const WardsFamily(); +final class WardsProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with + $FutureModifier>, + $FutureProvider> { /// A province answers every one of its wards in one response — up to 549 — which /// is why the picker searches the list rather than scrolling it. - /// - /// Copied from [wards]. - WardsProvider call(String provinceCode) { - return WardsProvider(provinceCode); - } + const WardsProvider._({ + required WardsFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'wardsProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - WardsProvider getProviderOverride(covariant WardsProvider provider) { - return call(provider.provinceCode); - } - - static const Iterable? _dependencies = null; + String debugGetCreateSourceHash() => _$wardsHash(); @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'wardsProvider'; -} - -/// A province answers every one of its wards in one response — up to 549 — which -/// is why the picker searches the list rather than scrolling it. -/// -/// Copied from [wards]. -class WardsProvider extends FutureProvider> { - /// A province answers every one of its wards in one response — up to 549 — which - /// is why the picker searches the list rather than scrolling it. - /// - /// Copied from [wards]. - WardsProvider(String provinceCode) - : this._internal( - (ref) => wards(ref as WardsRef, provinceCode), - from: wardsProvider, - name: r'wardsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$wardsHash, - dependencies: WardsFamily._dependencies, - allTransitiveDependencies: WardsFamily._allTransitiveDependencies, - provinceCode: provinceCode, - ); - - WardsProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.provinceCode, - }) : super.internal(); - - final String provinceCode; + String toString() { + return r'wardsProvider' + '' + '($argument)'; + } + @$internal @override - Override overrideWith( - FutureOr> Function(WardsRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: WardsProvider._internal( - (ref) => create(ref as WardsRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - provinceCode: provinceCode, - ), - ); - } + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); @override - FutureProviderElement> createElement() { - return _WardsProviderElement(this); + FutureOr> create(Ref ref) { + final argument = this.argument as String; + return wards(ref, argument); } @override bool operator ==(Object other) { - return other is WardsProvider && other.provinceCode == provinceCode; + return other is WardsProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, provinceCode.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin WardsRef on FutureProviderRef> { - /// The parameter `provinceCode` of this provider. - String get provinceCode; -} +String _$wardsHash() => r'c51d90dc5ac1fa93bef845684e53709185d254c7'; + +/// A province answers every one of its wards in one response — up to 549 — which +/// is why the picker searches the list rather than scrolling it. + +final class WardsFamily extends $Family + with $FunctionalFamilyOverride>, String> { + const WardsFamily._() + : super( + retry: null, + name: r'wardsProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: false, + ); -class _WardsProviderElement - extends FutureProviderElement> - with WardsRef { - _WardsProviderElement(super.provider); + /// A province answers every one of its wards in one response — up to 549 — which + /// is why the picker searches the list rather than scrolling it. + + WardsProvider call(String provinceCode) => + WardsProvider._(argument: provinceCode, from: this); @override - String get provinceCode => (origin as WardsProvider).provinceCode; + String toString() => r'wardsProvider'; } - -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/account/presentation/providers/buyer_orders_provider.g.dart b/lib/features/account/presentation/providers/buyer_orders_provider.g.dart index d04835e..6aa6e84 100644 --- a/lib/features/account/presentation/providers/buyer_orders_provider.g.dart +++ b/lib/features/account/presentation/providers/buyer_orders_provider.g.dart @@ -6,176 +6,102 @@ part of 'buyer_orders_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$buyerOrderDetailHash() => r'dfee0a4d5e60d9ddec915e03be7aa2f83f52eb02'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Bốn provider lọc theo tab từng ở đây — `buyerOpenOrders`, `buyerCompletedOrders`, /// `buyerCancelledOrders`, `buyerCancelledItems` — đã đi cùng chín cái tab: một lượt /// đọc `/orders?role=X` trả về cả bốn trạng thái và màn hình chia nhóm lấy. Chi tiết /// một đơn thì vẫn là một lượt đọc riêng, vì nó là một route riêng. -/// -/// Copied from [buyerOrderDetail]. + @ProviderFor(buyerOrderDetail) -const buyerOrderDetailProvider = BuyerOrderDetailFamily(); +const buyerOrderDetailProvider = BuyerOrderDetailFamily._(); /// Bốn provider lọc theo tab từng ở đây — `buyerOpenOrders`, `buyerCompletedOrders`, /// `buyerCancelledOrders`, `buyerCancelledItems` — đã đi cùng chín cái tab: một lượt /// đọc `/orders?role=X` trả về cả bốn trạng thái và màn hình chia nhóm lấy. Chi tiết /// một đơn thì vẫn là một lượt đọc riêng, vì nó là một route riêng. -/// -/// Copied from [buyerOrderDetail]. -class BuyerOrderDetailFamily extends Family> { - /// Bốn provider lọc theo tab từng ở đây — `buyerOpenOrders`, `buyerCompletedOrders`, - /// `buyerCancelledOrders`, `buyerCancelledItems` — đã đi cùng chín cái tab: một lượt - /// đọc `/orders?role=X` trả về cả bốn trạng thái và màn hình chia nhóm lấy. Chi tiết - /// một đơn thì vẫn là một lượt đọc riêng, vì nó là một route riêng. - /// - /// Copied from [buyerOrderDetail]. - const BuyerOrderDetailFamily(); +final class BuyerOrderDetailProvider + extends + $FunctionalProvider< + AsyncValue, + OrderView, + FutureOr + > + with $FutureModifier, $FutureProvider { /// Bốn provider lọc theo tab từng ở đây — `buyerOpenOrders`, `buyerCompletedOrders`, /// `buyerCancelledOrders`, `buyerCancelledItems` — đã đi cùng chín cái tab: một lượt /// đọc `/orders?role=X` trả về cả bốn trạng thái và màn hình chia nhóm lấy. Chi tiết /// một đơn thì vẫn là một lượt đọc riêng, vì nó là một route riêng. - /// - /// Copied from [buyerOrderDetail]. - BuyerOrderDetailProvider call(String orderId) { - return BuyerOrderDetailProvider(orderId); - } + const BuyerOrderDetailProvider._({ + required BuyerOrderDetailFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'buyerOrderDetailProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - BuyerOrderDetailProvider getProviderOverride( - covariant BuyerOrderDetailProvider provider, - ) { - return call(provider.orderId); - } + String debugGetCreateSourceHash() => _$buyerOrderDetailHash(); - static const Iterable? _dependencies = null; + @override + String toString() { + return r'buyerOrderDetailProvider' + '' + '($argument)'; + } + @$internal @override - Iterable? get dependencies => _dependencies; + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); - static const Iterable? _allTransitiveDependencies = null; + @override + FutureOr create(Ref ref) { + final argument = this.argument as String; + return buyerOrderDetail(ref, argument); + } @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; + bool operator ==(Object other) { + return other is BuyerOrderDetailProvider && other.argument == argument; + } @override - String? get name => r'buyerOrderDetailProvider'; + int get hashCode { + return argument.hashCode; + } } +String _$buyerOrderDetailHash() => r'dfee0a4d5e60d9ddec915e03be7aa2f83f52eb02'; + /// Bốn provider lọc theo tab từng ở đây — `buyerOpenOrders`, `buyerCompletedOrders`, /// `buyerCancelledOrders`, `buyerCancelledItems` — đã đi cùng chín cái tab: một lượt /// đọc `/orders?role=X` trả về cả bốn trạng thái và màn hình chia nhóm lấy. Chi tiết /// một đơn thì vẫn là một lượt đọc riêng, vì nó là một route riêng. -/// -/// Copied from [buyerOrderDetail]. -class BuyerOrderDetailProvider extends AutoDisposeFutureProvider { + +final class BuyerOrderDetailFamily extends $Family + with $FunctionalFamilyOverride, String> { + const BuyerOrderDetailFamily._() + : super( + retry: null, + name: r'buyerOrderDetailProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + /// Bốn provider lọc theo tab từng ở đây — `buyerOpenOrders`, `buyerCompletedOrders`, /// `buyerCancelledOrders`, `buyerCancelledItems` — đã đi cùng chín cái tab: một lượt /// đọc `/orders?role=X` trả về cả bốn trạng thái và màn hình chia nhóm lấy. Chi tiết /// một đơn thì vẫn là một lượt đọc riêng, vì nó là một route riêng. - /// - /// Copied from [buyerOrderDetail]. - BuyerOrderDetailProvider(String orderId) - : this._internal( - (ref) => buyerOrderDetail(ref as BuyerOrderDetailRef, orderId), - from: buyerOrderDetailProvider, - name: r'buyerOrderDetailProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$buyerOrderDetailHash, - dependencies: BuyerOrderDetailFamily._dependencies, - allTransitiveDependencies: - BuyerOrderDetailFamily._allTransitiveDependencies, - orderId: orderId, - ); - - BuyerOrderDetailProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.orderId, - }) : super.internal(); - - final String orderId; - @override - Override overrideWith( - FutureOr Function(BuyerOrderDetailRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: BuyerOrderDetailProvider._internal( - (ref) => create(ref as BuyerOrderDetailRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - orderId: orderId, - ), - ); - } + BuyerOrderDetailProvider call(String orderId) => + BuyerOrderDetailProvider._(argument: orderId, from: this); @override - AutoDisposeFutureProviderElement createElement() { - return _BuyerOrderDetailProviderElement(this); - } - - @override - bool operator ==(Object other) { - return other is BuyerOrderDetailProvider && other.orderId == orderId; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, orderId.hashCode); - - return _SystemHash.finish(hash); - } + String toString() => r'buyerOrderDetailProvider'; } - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin BuyerOrderDetailRef on AutoDisposeFutureProviderRef { - /// The parameter `orderId` of this provider. - String get orderId; -} - -class _BuyerOrderDetailProviderElement - extends AutoDisposeFutureProviderElement - with BuyerOrderDetailRef { - _BuyerOrderDetailProviderElement(super.provider); - - @override - String get orderId => (origin as BuyerOrderDetailProvider).orderId; -} - -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/account/presentation/providers/my_reviews_provider.g.dart b/lib/features/account/presentation/providers/my_reviews_provider.g.dart index e4044ab..4ee0062 100644 --- a/lib/features/account/presentation/providers/my_reviews_provider.g.dart +++ b/lib/features/account/presentation/providers/my_reviews_provider.g.dart @@ -6,313 +6,191 @@ part of 'my_reviews_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$myFeedbackHash() => r'dc1a6efcdd4d3d3285c320336c560901ab176b3f'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Đánh giá người dùng hiện tại nhận được ở một vai. /// /// Id lấy từ hồ sơ chứ không truyền vào: màn hình này luôn nói về chính mình, và /// một tham số id ở đây chỉ mở đường cho việc gọi nhầm sang tài khoản khác. -/// -/// Copied from [myFeedback]. + @ProviderFor(myFeedback) -const myFeedbackProvider = MyFeedbackFamily(); +const myFeedbackProvider = MyFeedbackFamily._(); /// Đánh giá người dùng hiện tại nhận được ở một vai. /// /// Id lấy từ hồ sơ chứ không truyền vào: màn hình này luôn nói về chính mình, và /// một tham số id ở đây chỉ mở đường cho việc gọi nhầm sang tài khoản khác. -/// -/// Copied from [myFeedback]. -class MyFeedbackFamily extends Family>> { - /// Đánh giá người dùng hiện tại nhận được ở một vai. - /// - /// Id lấy từ hồ sơ chứ không truyền vào: màn hình này luôn nói về chính mình, và - /// một tham số id ở đây chỉ mở đường cho việc gọi nhầm sang tài khoản khác. - /// - /// Copied from [myFeedback]. - const MyFeedbackFamily(); +final class MyFeedbackProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with $FutureModifier>, $FutureProvider> { /// Đánh giá người dùng hiện tại nhận được ở một vai. /// /// Id lấy từ hồ sơ chứ không truyền vào: màn hình này luôn nói về chính mình, và /// một tham số id ở đây chỉ mở đường cho việc gọi nhầm sang tài khoản khác. - /// - /// Copied from [myFeedback]. - MyFeedbackProvider call(ReputationRole role) { - return MyFeedbackProvider(role); - } + const MyFeedbackProvider._({ + required MyFeedbackFamily super.from, + required ReputationRole super.argument, + }) : super( + retry: null, + name: r'myFeedbackProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - MyFeedbackProvider getProviderOverride( - covariant MyFeedbackProvider provider, - ) { - return call(provider.role); - } + String debugGetCreateSourceHash() => _$myFeedbackHash(); - static const Iterable? _dependencies = null; + @override + String toString() { + return r'myFeedbackProvider' + '' + '($argument)'; + } + @$internal @override - Iterable? get dependencies => _dependencies; + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); - static const Iterable? _allTransitiveDependencies = null; + @override + FutureOr> create(Ref ref) { + final argument = this.argument as ReputationRole; + return myFeedback(ref, argument); + } @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; + bool operator ==(Object other) { + return other is MyFeedbackProvider && other.argument == argument; + } @override - String? get name => r'myFeedbackProvider'; + int get hashCode { + return argument.hashCode; + } } +String _$myFeedbackHash() => r'dc1a6efcdd4d3d3285c320336c560901ab176b3f'; + /// Đánh giá người dùng hiện tại nhận được ở một vai. /// /// Id lấy từ hồ sơ chứ không truyền vào: màn hình này luôn nói về chính mình, và /// một tham số id ở đây chỉ mở đường cho việc gọi nhầm sang tài khoản khác. -/// -/// Copied from [myFeedback]. -class MyFeedbackProvider extends AutoDisposeFutureProvider> { + +final class MyFeedbackFamily extends $Family + with $FunctionalFamilyOverride>, ReputationRole> { + const MyFeedbackFamily._() + : super( + retry: null, + name: r'myFeedbackProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + /// Đánh giá người dùng hiện tại nhận được ở một vai. /// /// Id lấy từ hồ sơ chứ không truyền vào: màn hình này luôn nói về chính mình, và /// một tham số id ở đây chỉ mở đường cho việc gọi nhầm sang tài khoản khác. - /// - /// Copied from [myFeedback]. - MyFeedbackProvider(ReputationRole role) - : this._internal( - (ref) => myFeedback(ref as MyFeedbackRef, role), - from: myFeedbackProvider, - name: r'myFeedbackProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$myFeedbackHash, - dependencies: MyFeedbackFamily._dependencies, - allTransitiveDependencies: MyFeedbackFamily._allTransitiveDependencies, - role: role, - ); - - MyFeedbackProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.role, - }) : super.internal(); - - final ReputationRole role; - - @override - Override overrideWith( - FutureOr> Function(MyFeedbackRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: MyFeedbackProvider._internal( - (ref) => create(ref as MyFeedbackRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - role: role, - ), - ); - } - - @override - AutoDisposeFutureProviderElement> createElement() { - return _MyFeedbackProviderElement(this); - } - - @override - bool operator ==(Object other) { - return other is MyFeedbackProvider && other.role == role; - } - - @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, role.hashCode); - - return _SystemHash.finish(hash); - } -} - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin MyFeedbackRef on AutoDisposeFutureProviderRef> { - /// The parameter `role` of this provider. - ReputationRole get role; -} -class _MyFeedbackProviderElement - extends AutoDisposeFutureProviderElement> - with MyFeedbackRef { - _MyFeedbackProviderElement(super.provider); + MyFeedbackProvider call(ReputationRole role) => + MyFeedbackProvider._(argument: role, from: this); @override - ReputationRole get role => (origin as MyFeedbackProvider).role; + String toString() => r'myFeedbackProvider'; } -String _$sellerReputationHash() => r'dba7f9d761f633ebcfb4afdca4fd825b6ea133ef'; - /// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu /// người bán bằng, thay cho một câu quảng cáo viết cứng. -/// -/// Copied from [sellerReputation]. + @ProviderFor(sellerReputation) -const sellerReputationProvider = SellerReputationFamily(); +const sellerReputationProvider = SellerReputationFamily._(); /// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu /// người bán bằng, thay cho một câu quảng cáo viết cứng. -/// -/// Copied from [sellerReputation]. -class SellerReputationFamily extends Family> { - /// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu - /// người bán bằng, thay cho một câu quảng cáo viết cứng. - /// - /// Copied from [sellerReputation]. - const SellerReputationFamily(); +final class SellerReputationProvider + extends + $FunctionalProvider< + AsyncValue, + Reputation, + FutureOr + > + with $FutureModifier, $FutureProvider { /// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu /// người bán bằng, thay cho một câu quảng cáo viết cứng. - /// - /// Copied from [sellerReputation]. - SellerReputationProvider call(String accountId) { - return SellerReputationProvider(accountId); - } + const SellerReputationProvider._({ + required SellerReputationFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'sellerReputationProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - SellerReputationProvider getProviderOverride( - covariant SellerReputationProvider provider, - ) { - return call(provider.accountId); - } - - static const Iterable? _dependencies = null; + String debugGetCreateSourceHash() => _$sellerReputationHash(); @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; - - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; - - @override - String? get name => r'sellerReputationProvider'; -} - -/// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu -/// người bán bằng, thay cho một câu quảng cáo viết cứng. -/// -/// Copied from [sellerReputation]. -class SellerReputationProvider extends AutoDisposeFutureProvider { - /// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu - /// người bán bằng, thay cho một câu quảng cáo viết cứng. - /// - /// Copied from [sellerReputation]. - SellerReputationProvider(String accountId) - : this._internal( - (ref) => sellerReputation(ref as SellerReputationRef, accountId), - from: sellerReputationProvider, - name: r'sellerReputationProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$sellerReputationHash, - dependencies: SellerReputationFamily._dependencies, - allTransitiveDependencies: - SellerReputationFamily._allTransitiveDependencies, - accountId: accountId, - ); - - SellerReputationProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.accountId, - }) : super.internal(); - - final String accountId; + String toString() { + return r'sellerReputationProvider' + '' + '($argument)'; + } + @$internal @override - Override overrideWith( - FutureOr Function(SellerReputationRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: SellerReputationProvider._internal( - (ref) => create(ref as SellerReputationRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - accountId: accountId, - ), - ); - } + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); @override - AutoDisposeFutureProviderElement createElement() { - return _SellerReputationProviderElement(this); + FutureOr create(Ref ref) { + final argument = this.argument as String; + return sellerReputation(ref, argument); } @override bool operator ==(Object other) { - return other is SellerReputationProvider && other.accountId == accountId; + return other is SellerReputationProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, accountId.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin SellerReputationRef on AutoDisposeFutureProviderRef { - /// The parameter `accountId` of this provider. - String get accountId; -} +String _$sellerReputationHash() => r'dba7f9d761f633ebcfb4afdca4fd825b6ea133ef'; -class _SellerReputationProviderElement - extends AutoDisposeFutureProviderElement - with SellerReputationRef { - _SellerReputationProviderElement(super.provider); +/// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu +/// người bán bằng, thay cho một câu quảng cáo viết cứng. + +final class SellerReputationFamily extends $Family + with $FunctionalFamilyOverride, String> { + const SellerReputationFamily._() + : super( + retry: null, + name: r'sellerReputationProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// Uy tín người bán của một tài khoản bất kỳ — cái trang sản phẩm giới thiệu + /// người bán bằng, thay cho một câu quảng cáo viết cứng. + + SellerReputationProvider call(String accountId) => + SellerReputationProvider._(argument: accountId, from: this); @override - String get accountId => (origin as SellerReputationProvider).accountId; + String toString() => r'sellerReputationProvider'; } - -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/account/presentation/providers/notifications_provider.freezed.dart b/lib/features/account/presentation/providers/notifications_provider.freezed.dart index 0bffb09..8cd3f8f 100644 --- a/lib/features/account/presentation/providers/notifications_provider.freezed.dart +++ b/lib/features/account/presentation/providers/notifications_provider.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,201 +9,275 @@ part of 'notifications_provider.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - /// @nodoc mixin _$NotificationFeed { - List get items => throw _privateConstructorUsedError; - String? get nextCursor => throw _privateConstructorUsedError; - bool get loadingMore => throw _privateConstructorUsedError; - /// Create a copy of NotificationFeed - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $NotificationFeedCopyWith get copyWith => - throw _privateConstructorUsedError; + List get items; String? get nextCursor; bool get loadingMore; +/// Create a copy of NotificationFeed +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$NotificationFeedCopyWith get copyWith => _$NotificationFeedCopyWithImpl(this as NotificationFeed, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is NotificationFeed&&const DeepCollectionEquality().equals(other.items, items)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.loadingMore, loadingMore) || other.loadingMore == loadingMore)); } -/// @nodoc -abstract class $NotificationFeedCopyWith<$Res> { - factory $NotificationFeedCopyWith( - NotificationFeed value, - $Res Function(NotificationFeed) then, - ) = _$NotificationFeedCopyWithImpl<$Res, NotificationFeed>; - @useResult - $Res call({List items, String? nextCursor, bool loadingMore}); + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items),nextCursor,loadingMore); + +@override +String toString() { + return 'NotificationFeed(items: $items, nextCursor: $nextCursor, loadingMore: $loadingMore)'; } -/// @nodoc -class _$NotificationFeedCopyWithImpl<$Res, $Val extends NotificationFeed> - implements $NotificationFeedCopyWith<$Res> { - _$NotificationFeedCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of NotificationFeed - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? items = null, - Object? nextCursor = freezed, - Object? loadingMore = null, - }) { - return _then( - _value.copyWith( - items: null == items - ? _value.items - : items // ignore: cast_nullable_to_non_nullable - as List, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - loadingMore: null == loadingMore - ? _value.loadingMore - : loadingMore // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$NotificationFeedImplCopyWith<$Res> +abstract mixin class $NotificationFeedCopyWith<$Res> { + factory $NotificationFeedCopyWith(NotificationFeed value, $Res Function(NotificationFeed) _then) = _$NotificationFeedCopyWithImpl; +@useResult +$Res call({ + List items, String? nextCursor, bool loadingMore +}); + + + + +} +/// @nodoc +class _$NotificationFeedCopyWithImpl<$Res> implements $NotificationFeedCopyWith<$Res> { - factory _$$NotificationFeedImplCopyWith( - _$NotificationFeedImpl value, - $Res Function(_$NotificationFeedImpl) then, - ) = __$$NotificationFeedImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({List items, String? nextCursor, bool loadingMore}); + _$NotificationFeedCopyWithImpl(this._self, this._then); + + final NotificationFeed _self; + final $Res Function(NotificationFeed) _then; + +/// Create a copy of NotificationFeed +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? nextCursor = freezed,Object? loadingMore = null,}) { + return _then(_self.copyWith( +items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?,loadingMore: null == loadingMore ? _self.loadingMore : loadingMore // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [NotificationFeed]. +extension NotificationFeedPatterns on NotificationFeed { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _NotificationFeed value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _NotificationFeed() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _NotificationFeed value) $default,){ +final _that = this; +switch (_that) { +case _NotificationFeed(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _NotificationFeed value)? $default,){ +final _that = this; +switch (_that) { +case _NotificationFeed() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( List items, String? nextCursor, bool loadingMore)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _NotificationFeed() when $default != null: +return $default(_that.items,_that.nextCursor,_that.loadingMore);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( List items, String? nextCursor, bool loadingMore) $default,) {final _that = this; +switch (_that) { +case _NotificationFeed(): +return $default(_that.items,_that.nextCursor,_that.loadingMore);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( List items, String? nextCursor, bool loadingMore)? $default,) {final _that = this; +switch (_that) { +case _NotificationFeed() when $default != null: +return $default(_that.items,_that.nextCursor,_that.loadingMore);case _: + return null; + +} +} + } /// @nodoc -class __$$NotificationFeedImplCopyWithImpl<$Res> - extends _$NotificationFeedCopyWithImpl<$Res, _$NotificationFeedImpl> - implements _$$NotificationFeedImplCopyWith<$Res> { - __$$NotificationFeedImplCopyWithImpl( - _$NotificationFeedImpl _value, - $Res Function(_$NotificationFeedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of NotificationFeed - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? items = null, - Object? nextCursor = freezed, - Object? loadingMore = null, - }) { - return _then( - _$NotificationFeedImpl( - items: null == items - ? _value._items - : items // ignore: cast_nullable_to_non_nullable - as List, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - loadingMore: null == loadingMore - ? _value.loadingMore - : loadingMore // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } + + +class _NotificationFeed implements NotificationFeed { + const _NotificationFeed({required final List items, this.nextCursor, this.loadingMore = false}): _items = items; + + + final List _items; +@override List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); +} + +@override final String? nextCursor; +@override@JsonKey() final bool loadingMore; + +/// Create a copy of NotificationFeed +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NotificationFeedCopyWith<_NotificationFeed> get copyWith => __$NotificationFeedCopyWithImpl<_NotificationFeed>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotificationFeed&&const DeepCollectionEquality().equals(other._items, _items)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.loadingMore, loadingMore) || other.loadingMore == loadingMore)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),nextCursor,loadingMore); + +@override +String toString() { + return 'NotificationFeed(items: $items, nextCursor: $nextCursor, loadingMore: $loadingMore)'; +} + + } /// @nodoc +abstract mixin class _$NotificationFeedCopyWith<$Res> implements $NotificationFeedCopyWith<$Res> { + factory _$NotificationFeedCopyWith(_NotificationFeed value, $Res Function(_NotificationFeed) _then) = __$NotificationFeedCopyWithImpl; +@override @useResult +$Res call({ + List items, String? nextCursor, bool loadingMore +}); + + -class _$NotificationFeedImpl implements _NotificationFeed { - const _$NotificationFeedImpl({ - required final List items, - this.nextCursor, - this.loadingMore = false, - }) : _items = items; - - final List _items; - @override - List get items { - if (_items is EqualUnmodifiableListView) return _items; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_items); - } - - @override - final String? nextCursor; - @override - @JsonKey() - final bool loadingMore; - - @override - String toString() { - return 'NotificationFeed(items: $items, nextCursor: $nextCursor, loadingMore: $loadingMore)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NotificationFeedImpl && - const DeepCollectionEquality().equals(other._items, _items) && - (identical(other.nextCursor, nextCursor) || - other.nextCursor == nextCursor) && - (identical(other.loadingMore, loadingMore) || - other.loadingMore == loadingMore)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_items), - nextCursor, - loadingMore, - ); - - /// Create a copy of NotificationFeed - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NotificationFeedImplCopyWith<_$NotificationFeedImpl> get copyWith => - __$$NotificationFeedImplCopyWithImpl<_$NotificationFeedImpl>( - this, - _$identity, - ); -} - -abstract class _NotificationFeed implements NotificationFeed { - const factory _NotificationFeed({ - required final List items, - final String? nextCursor, - final bool loadingMore, - }) = _$NotificationFeedImpl; - - @override - List get items; - @override - String? get nextCursor; - @override - bool get loadingMore; - - /// Create a copy of NotificationFeed - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NotificationFeedImplCopyWith<_$NotificationFeedImpl> get copyWith => - throw _privateConstructorUsedError; + +} +/// @nodoc +class __$NotificationFeedCopyWithImpl<$Res> + implements _$NotificationFeedCopyWith<$Res> { + __$NotificationFeedCopyWithImpl(this._self, this._then); + + final _NotificationFeed _self; + final $Res Function(_NotificationFeed) _then; + +/// Create a copy of NotificationFeed +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? nextCursor = freezed,Object? loadingMore = null,}) { + return _then(_NotificationFeed( +items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?,loadingMore: null == loadingMore ? _self.loadingMore : loadingMore // ignore: cast_nullable_to_non_nullable +as bool, + )); } + + +} + +// dart format on diff --git a/lib/features/account/presentation/providers/notifications_provider.g.dart b/lib/features/account/presentation/providers/notifications_provider.g.dart index 2022990..294df46 100644 --- a/lib/features/account/presentation/providers/notifications_provider.g.dart +++ b/lib/features/account/presentation/providers/notifications_provider.g.dart @@ -6,44 +6,87 @@ part of 'notifications_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$unreadNotificationsCountHash() => - r'8acc408c967694430e248ed34c6647eb897e4d20'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning + +@ProviderFor(NotificationsController) +const notificationsControllerProvider = NotificationsControllerProvider._(); + +final class NotificationsControllerProvider + extends $AsyncNotifierProvider { + const NotificationsControllerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'notificationsControllerProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$notificationsControllerHash(); + + @$internal + @override + NotificationsController create() => NotificationsController(); +} -/// See also [unreadNotificationsCount]. -@ProviderFor(unreadNotificationsCount) -final unreadNotificationsCountProvider = - AutoDisposeFutureProvider.internal( - unreadNotificationsCount, - name: r'unreadNotificationsCountProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$unreadNotificationsCountHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef UnreadNotificationsCountRef = AutoDisposeFutureProviderRef; String _$notificationsControllerHash() => r'78d71a54bc05cd0a305dc7575034fc97eea1d7a3'; -/// See also [NotificationsController]. -@ProviderFor(NotificationsController) -final notificationsControllerProvider = - AutoDisposeAsyncNotifierProvider< - NotificationsController, - NotificationFeed - >.internal( - NotificationsController.new, - name: r'notificationsControllerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$notificationsControllerHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -typedef _$NotificationsController = AutoDisposeAsyncNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$NotificationsController + extends $AsyncNotifier { + FutureOr build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = + this.ref as $Ref, NotificationFeed>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, NotificationFeed>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} + +@ProviderFor(unreadNotificationsCount) +const unreadNotificationsCountProvider = UnreadNotificationsCountProvider._(); + +final class UnreadNotificationsCountProvider + extends $FunctionalProvider, int, FutureOr> + with $FutureModifier, $FutureProvider { + const UnreadNotificationsCountProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'unreadNotificationsCountProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$unreadNotificationsCountHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return unreadNotificationsCount(ref); + } +} + +String _$unreadNotificationsCountHash() => + r'8acc408c967694430e248ed34c6647eb897e4d20'; diff --git a/lib/features/account/presentation/providers/orders_actions_provider.dart b/lib/features/account/presentation/providers/orders_actions_provider.dart index cee6506..193dadc 100644 --- a/lib/features/account/presentation/providers/orders_actions_provider.dart +++ b/lib/features/account/presentation/providers/orders_actions_provider.dart @@ -43,24 +43,16 @@ class OrdersActions extends _$OrdersActions { Future cancelItem(String itemId) => _run(() => ref.read(accountRepositoryProvider).cancelItem(itemId)); - /// Ảnh mở hộp được upload trước, rồi mới xác nhận: server đòi ít nhất một - /// resource *đã* confirm, nên upload hỏng phải làm cả việc hỏng chứ không được - /// gửi một xác nhận rỗng. - Future confirmReceipt(String orderId, List photos) => - _run(() async { - final repository = ref.read(accountRepositoryProvider); - final ids = []; - for (final photo in photos) { - ids.add( - await repository.uploadOrderEvidence( - bytes: photo.bytes, - filename: photo.filename, - mime: photo.mime, - ), - ); - } - await repository.confirmReceipt(orderId, ids); - }); + /// [attachments] là resource **đã confirm** — server từ chối cả danh sách rỗng + /// lẫn một id chưa xác nhận. Việc đưa ảnh lên là của `ImageUploadField`, xảy ra + /// lúc người mua chọn ảnh: gộp nó vào đây thì một ảnh hỏng làm hỏng cả lần xác + /// nhận, và người mua không có cách nào biết ảnh nào là cái hỏng. + Future confirmReceipt(String orderId, List attachments) => + _run( + () => ref + .read(accountRepositoryProvider) + .confirmReceipt(orderId, attachments), + ); Future _act(Future Function(SellerRepository) action) => _run(() => action(ref.read(sellerRepositoryProvider))); @@ -86,17 +78,3 @@ class OrdersActionsState { final bool isLoading; final String? errorMessage; } - -/// Một ảnh đã đọc thành bytes, để tầng provider không phải biết ảnh từ camera hay -/// từ thư viện. -class ReceiptPhoto { - const ReceiptPhoto({ - required this.bytes, - required this.filename, - required this.mime, - }); - - final List bytes; - final String filename; - final String mime; -} diff --git a/lib/features/account/presentation/providers/orders_actions_provider.g.dart b/lib/features/account/presentation/providers/orders_actions_provider.g.dart index 2d02f7b..c9d42e2 100644 --- a/lib/features/account/presentation/providers/orders_actions_provider.g.dart +++ b/lib/features/account/presentation/providers/orders_actions_provider.g.dart @@ -6,8 +6,8 @@ part of 'orders_actions_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$ordersActionsHash() => r'e263f0a7db0bc78d12c104d9922039f9662758fc'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Những gì một người bán trả lời một đơn đã trả tiền: xác nhận, từ chối, hủy. /// /// Tách ra khỏi provider giữ danh sách, vì hai việc đó có tuổi khác nhau: danh @@ -23,20 +23,102 @@ String _$ordersActionsHash() => r'e263f0a7db0bc78d12c104d9922039f9662758fc'; /// sẽ vứt notifier ngay khi câu lệnh vừa được gọi, rồi lần ghi state sau `await` /// ném lỗi — nên đơn *đã* được xác nhận trên server mà người bán thấy một thông /// báo thất bại. -/// -/// Copied from [OrdersActions]. + @ProviderFor(OrdersActions) -final ordersActionsProvider = - NotifierProvider.internal( - OrdersActions.new, - name: r'ordersActionsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$ordersActionsHash, - dependencies: null, - allTransitiveDependencies: null, +const ordersActionsProvider = OrdersActionsProvider._(); + +/// Những gì một người bán trả lời một đơn đã trả tiền: xác nhận, từ chối, hủy. +/// +/// Tách ra khỏi provider giữ danh sách, vì hai việc đó có tuổi khác nhau: danh +/// sách bị vứt đi và nạp lại mỗi lần đổi vai hoặc kéo để refresh, còn một lời +/// xác nhận đang bay thì không. Ở chung, các hành động này chết cùng cái màn hình +/// bị xoá — và một màn mới vẫn compile mà không có nút nào là kiểu mất chức năng +/// không ai thấy. +/// +/// Không tự nạp lại danh sách sau khi xong: ai đang mở danh sách nào thì người đó +/// biết, và một provider hành động đoán hộ sẽ chọn sai một trong hai. +/// +/// `keepAlive` vì một lời xác nhận được gọi bằng `read`, không `watch`: autoDispose +/// sẽ vứt notifier ngay khi câu lệnh vừa được gọi, rồi lần ghi state sau `await` +/// ném lỗi — nên đơn *đã* được xác nhận trên server mà người bán thấy một thông +/// báo thất bại. +final class OrdersActionsProvider + extends $NotifierProvider { + /// Những gì một người bán trả lời một đơn đã trả tiền: xác nhận, từ chối, hủy. + /// + /// Tách ra khỏi provider giữ danh sách, vì hai việc đó có tuổi khác nhau: danh + /// sách bị vứt đi và nạp lại mỗi lần đổi vai hoặc kéo để refresh, còn một lời + /// xác nhận đang bay thì không. Ở chung, các hành động này chết cùng cái màn hình + /// bị xoá — và một màn mới vẫn compile mà không có nút nào là kiểu mất chức năng + /// không ai thấy. + /// + /// Không tự nạp lại danh sách sau khi xong: ai đang mở danh sách nào thì người đó + /// biết, và một provider hành động đoán hộ sẽ chọn sai một trong hai. + /// + /// `keepAlive` vì một lời xác nhận được gọi bằng `read`, không `watch`: autoDispose + /// sẽ vứt notifier ngay khi câu lệnh vừa được gọi, rồi lần ghi state sau `await` + /// ném lỗi — nên đơn *đã* được xác nhận trên server mà người bán thấy một thông + /// báo thất bại. + const OrdersActionsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'ordersActionsProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$ordersActionsHash(); + + @$internal + @override + OrdersActions create() => OrdersActions(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(OrdersActionsState value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} + +String _$ordersActionsHash() => r'e263f0a7db0bc78d12c104d9922039f9662758fc'; + +/// Những gì một người bán trả lời một đơn đã trả tiền: xác nhận, từ chối, hủy. +/// +/// Tách ra khỏi provider giữ danh sách, vì hai việc đó có tuổi khác nhau: danh +/// sách bị vứt đi và nạp lại mỗi lần đổi vai hoặc kéo để refresh, còn một lời +/// xác nhận đang bay thì không. Ở chung, các hành động này chết cùng cái màn hình +/// bị xoá — và một màn mới vẫn compile mà không có nút nào là kiểu mất chức năng +/// không ai thấy. +/// +/// Không tự nạp lại danh sách sau khi xong: ai đang mở danh sách nào thì người đó +/// biết, và một provider hành động đoán hộ sẽ chọn sai một trong hai. +/// +/// `keepAlive` vì một lời xác nhận được gọi bằng `read`, không `watch`: autoDispose +/// sẽ vứt notifier ngay khi câu lệnh vừa được gọi, rồi lần ghi state sau `await` +/// ném lỗi — nên đơn *đã* được xác nhận trên server mà người bán thấy một thông +/// báo thất bại. -typedef _$OrdersActions = Notifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$OrdersActions extends $Notifier { + OrdersActionsState build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + OrdersActionsState, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/lib/features/account/presentation/providers/orders_provider.g.dart b/lib/features/account/presentation/providers/orders_provider.g.dart index ac2ef5d..50f9f6e 100644 --- a/lib/features/account/presentation/providers/orders_provider.g.dart +++ b/lib/features/account/presentation/providers/orders_provider.g.dart @@ -6,46 +6,109 @@ part of 'orders_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$unsettledItemsHash() => r'782d3fd2e8fe11e516f38968b63066054955dcef'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Dòng đã trả tiền mà chưa thành đơn — cửa sổ duy nhất còn bỏ được. /// /// Không gộp vào [Orders]: đây là `/items?pending=true`, một endpoint khác trả về /// dòng chứ không phải đơn, và một trong hai hỏng thì không được làm mất bên kia. -/// -/// Copied from [unsettledItems]. + @ProviderFor(unsettledItems) -final unsettledItemsProvider = - AutoDisposeFutureProvider>.internal( - unsettledItems, - name: r'unsettledItemsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$unsettledItemsHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef UnsettledItemsRef = AutoDisposeFutureProviderRef>; -String _$ordersHash() => r'6d834304dd4d39d6ab1a959597b18cff3c509d4e'; +const unsettledItemsProvider = UnsettledItemsProvider._(); -/// Notifier quản lý đơn hàng của phía Người mua (buyer). +/// Dòng đã trả tiền mà chưa thành đơn — cửa sổ duy nhất còn bỏ được. /// -/// Copied from [Orders]. +/// Không gộp vào [Orders]: đây là `/items?pending=true`, một endpoint khác trả về +/// dòng chứ không phải đơn, và một trong hai hỏng thì không được làm mất bên kia. + +final class UnsettledItemsProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with + $FutureModifier>, + $FutureProvider> { + /// Dòng đã trả tiền mà chưa thành đơn — cửa sổ duy nhất còn bỏ được. + /// + /// Không gộp vào [Orders]: đây là `/items?pending=true`, một endpoint khác trả về + /// dòng chứ không phải đơn, và một trong hai hỏng thì không được làm mất bên kia. + const UnsettledItemsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'unsettledItemsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$unsettledItemsHash(); + + @$internal + @override + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr> create(Ref ref) { + return unsettledItems(ref); + } +} + +String _$unsettledItemsHash() => r'782d3fd2e8fe11e516f38968b63066054955dcef'; + +/// Notifier quản lý đơn hàng của phía Người mua (buyer). + @ProviderFor(Orders) -final ordersProvider = - AutoDisposeAsyncNotifierProvider.internal( - Orders.new, - name: r'ordersProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$ordersHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -typedef _$Orders = AutoDisposeAsyncNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const ordersProvider = OrdersProvider._(); + +/// Notifier quản lý đơn hàng của phía Người mua (buyer). +final class OrdersProvider extends $AsyncNotifierProvider { + /// Notifier quản lý đơn hàng của phía Người mua (buyer). + const OrdersProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'ordersProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$ordersHash(); + + @$internal + @override + Orders create() => Orders(); +} + +String _$ordersHash() => r'6d834304dd4d39d6ab1a959597b18cff3c509d4e'; + +/// Notifier quản lý đơn hàng của phía Người mua (buyer). + +abstract class _$Orders extends $AsyncNotifier { + FutureOr build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref, OrdersFeed>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, OrdersFeed>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/lib/features/account/presentation/providers/rate_order_provider.g.dart b/lib/features/account/presentation/providers/rate_order_provider.g.dart index 8961527..adbf9eb 100644 --- a/lib/features/account/presentation/providers/rate_order_provider.g.dart +++ b/lib/features/account/presentation/providers/rate_order_provider.g.dart @@ -6,7 +6,20 @@ part of 'rate_order_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$rateOrderHash() => r'a1074b83f7d63862bc900334e959139672edef51'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning +/// Gửi cả hai nửa của một lần chấm điểm, theo thứ tự **kín trước, công khai sau**. +/// +/// Thứ tự đó là cố ý. Đánh giá giao dịch là thứ cộng vào uy tín và là thứ mù — nếu +/// nửa công khai đi trước rồi nửa kín hỏng, người dùng đã công bố một điểm cho tin +/// mà bên kia không nhận được gì, và họ sẽ không mở lại biểu mẫu đã "gửi xong". +/// +/// Nửa công khai là **tuỳ chọn**: một tin hàng cũ độc bản bán một lần, nên đánh giá +/// sản phẩm ở đó gần như không có ai đọc — còn uy tín người bán thì luôn được đọc. +/// Bắt buộc cả hai là bắt người ta viết một thứ vô ích để làm xong một thứ hữu ích. + +@ProviderFor(RateOrder) +const rateOrderProvider = RateOrderProvider._(); /// Gửi cả hai nửa của một lần chấm điểm, theo thứ tự **kín trước, công khai sau**. /// @@ -17,19 +30,71 @@ String _$rateOrderHash() => r'a1074b83f7d63862bc900334e959139672edef51'; /// Nửa công khai là **tuỳ chọn**: một tin hàng cũ độc bản bán một lần, nên đánh giá /// sản phẩm ở đó gần như không có ai đọc — còn uy tín người bán thì luôn được đọc. /// Bắt buộc cả hai là bắt người ta viết một thứ vô ích để làm xong một thứ hữu ích. +final class RateOrderProvider + extends $NotifierProvider { + /// Gửi cả hai nửa của một lần chấm điểm, theo thứ tự **kín trước, công khai sau**. + /// + /// Thứ tự đó là cố ý. Đánh giá giao dịch là thứ cộng vào uy tín và là thứ mù — nếu + /// nửa công khai đi trước rồi nửa kín hỏng, người dùng đã công bố một điểm cho tin + /// mà bên kia không nhận được gì, và họ sẽ không mở lại biểu mẫu đã "gửi xong". + /// + /// Nửa công khai là **tuỳ chọn**: một tin hàng cũ độc bản bán một lần, nên đánh giá + /// sản phẩm ở đó gần như không có ai đọc — còn uy tín người bán thì luôn được đọc. + /// Bắt buộc cả hai là bắt người ta viết một thứ vô ích để làm xong một thứ hữu ích. + const RateOrderProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'rateOrderProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$rateOrderHash(); + + @$internal + @override + RateOrder create() => RateOrder(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(RateOrderState value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$rateOrderHash() => r'a1074b83f7d63862bc900334e959139672edef51'; + +/// Gửi cả hai nửa của một lần chấm điểm, theo thứ tự **kín trước, công khai sau**. /// -/// Copied from [RateOrder]. -@ProviderFor(RateOrder) -final rateOrderProvider = NotifierProvider.internal( - RateOrder.new, - name: r'rateOrderProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$rateOrderHash, - dependencies: null, - allTransitiveDependencies: null, -); - -typedef _$RateOrder = Notifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +/// Thứ tự đó là cố ý. Đánh giá giao dịch là thứ cộng vào uy tín và là thứ mù — nếu +/// nửa công khai đi trước rồi nửa kín hỏng, người dùng đã công bố một điểm cho tin +/// mà bên kia không nhận được gì, và họ sẽ không mở lại biểu mẫu đã "gửi xong". +/// +/// Nửa công khai là **tuỳ chọn**: một tin hàng cũ độc bản bán một lần, nên đánh giá +/// sản phẩm ở đó gần như không có ai đọc — còn uy tín người bán thì luôn được đọc. +/// Bắt buộc cả hai là bắt người ta viết một thứ vô ích để làm xong một thứ hữu ích. + +abstract class _$RateOrder extends $Notifier { + RateOrderState build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + RateOrderState, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/lib/features/account/presentation/providers/wishlist_provider.g.dart b/lib/features/account/presentation/providers/wishlist_provider.g.dart index a8b3082..7a93a61 100644 --- a/lib/features/account/presentation/providers/wishlist_provider.g.dart +++ b/lib/features/account/presentation/providers/wishlist_provider.g.dart @@ -6,45 +6,103 @@ part of 'wishlist_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$wishlistProductsHash() => r'2ed77c7a3d39e28708fcabe13ec8fd36d315b06a'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// The wishlist is a catalog query, not a list of its own: `GET /listings` with /// `favorited=true` answers cards, so the screen gets the price and the cover it /// draws. Resolving saved ids one detail request at a time gave neither — a /// `ListingDetail` carries no card price, which is why every row read 0 ₫. -/// -/// Copied from [wishlistProducts]. + @ProviderFor(wishlistProducts) -final wishlistProductsProvider = - AutoDisposeFutureProvider>.internal( - wishlistProducts, - name: r'wishlistProductsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$wishlistProductsHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef WishlistProductsRef = AutoDisposeFutureProviderRef>; +const wishlistProductsProvider = WishlistProductsProvider._(); + +/// The wishlist is a catalog query, not a list of its own: `GET /listings` with +/// `favorited=true` answers cards, so the screen gets the price and the cover it +/// draws. Resolving saved ids one detail request at a time gave neither — a +/// `ListingDetail` carries no card price, which is why every row read 0 ₫. + +final class WishlistProductsProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with $FutureModifier>, $FutureProvider> { + /// The wishlist is a catalog query, not a list of its own: `GET /listings` with + /// `favorited=true` answers cards, so the screen gets the price and the cover it + /// draws. Resolving saved ids one detail request at a time gave neither — a + /// `ListingDetail` carries no card price, which is why every row read 0 ₫. + const WishlistProductsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'wishlistProductsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$wishlistProductsHash(); + + @$internal + @override + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); + + @override + FutureOr> create(Ref ref) { + return wishlistProducts(ref); + } +} + +String _$wishlistProductsHash() => r'2ed77c7a3d39e28708fcabe13ec8fd36d315b06a'; + +@ProviderFor(WishlistController) +const wishlistControllerProvider = WishlistControllerProvider._(); + +final class WishlistControllerProvider + extends $AsyncNotifierProvider { + const WishlistControllerProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'wishlistControllerProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$wishlistControllerHash(); + + @$internal + @override + WishlistController create() => WishlistController(); +} + String _$wishlistControllerHash() => r'72106fa0429854c706ce4a706cdeeb8ba1e87182'; -/// See also [WishlistController]. -@ProviderFor(WishlistController) -final wishlistControllerProvider = - AutoDisposeAsyncNotifierProvider.internal( - WishlistController.new, - name: r'wishlistControllerProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$wishlistControllerHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -typedef _$WishlistController = AutoDisposeAsyncNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$WishlistController extends $AsyncNotifier { + FutureOr build(); + @$mustCallSuper + @override + void runBuild() { + build(); + final ref = this.ref as $Ref, void>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, void>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, null); + } +} diff --git a/lib/features/account/presentation/screens/order_detail_screen.dart b/lib/features/account/presentation/screens/order_detail_screen.dart index 123a43f..cc941ce 100644 --- a/lib/features/account/presentation/screens/order_detail_screen.dart +++ b/lib/features/account/presentation/screens/order_detail_screen.dart @@ -10,6 +10,8 @@ import 'package:shopnexus_flutter_app/features/ticket/presentation/widgets/raise import 'package:shopnexus_flutter_app/api/generated/model/ticket_kind.dart'; import 'package:shopnexus_flutter_app/features/account/data/models/order_view.dart'; import 'package:shopnexus_flutter_app/features/account/presentation/providers/buyer_orders_provider.dart'; +import 'package:shopnexus_flutter_app/features/account/presentation/providers/orders_provider.dart'; +import 'package:shopnexus_flutter_app/features/account/presentation/widgets/confirm_receipt_sheet.dart'; class OrderDetailScreen extends ConsumerWidget { final String orderId; @@ -45,6 +47,8 @@ class OrderDetailScreen extends ConsumerWidget { onPressed: () => context.pop(), ), actions: [ + // Chỉ còn "báo sự cố": đó là câu hỏi cho support, không phải một bước + // của đơn. Hoàn tiền đã xuống thanh dưới, nơi nó chỉ hiện khi bấm được. PopupMenuButton<_OrderHelpAction>( icon: Icon( Icons.more_horiz_rounded, @@ -52,10 +56,6 @@ class OrderDetailScreen extends ConsumerWidget { ), onSelected: (action) => _handleHelpAction(context, action), itemBuilder: (_) => const [ - PopupMenuItem( - value: _OrderHelpAction.requestRefund, - child: Text('Yêu cầu hoàn tiền'), - ), PopupMenuItem( value: _OrderHelpAction.reportIssue, child: Text('Báo sự cố đơn hàng'), @@ -64,6 +64,13 @@ class OrderDetailScreen extends ConsumerWidget { ), ], ), + // Việc của đơn nằm ở chỗ ngón tay đang đứng, không nằm sau ba chấm: một + // menu là nơi để tìm, còn "đã nhận hàng" và "yêu cầu hoàn tiền" là hai + // việc người ta mở màn này ra để làm. + bottomNavigationBar: orderDetailAsync.maybeWhen( + data: (view) => _buildActionBar(context, ref, view), + orElse: () => null, + ), body: RefreshIndicator( color: theme.colorScheme.primary, onRefresh: () => ref.refresh(buyerOrderDetailProvider(orderId).future), @@ -163,6 +170,83 @@ class OrderDetailScreen extends ConsumerWidget { ); } + /// Thanh việc dưới cùng, hoặc không có thanh nào. + /// + /// Trả `null` chứ không trả một thanh rỗng: một đơn đã xong không còn việc gì, + /// và một dải trắng cao 80px ở đáy màn hình nói rằng có. + /// + /// Hoàn tiền chỉ hiện khi server nhận: đã có vụ đang mở thì đường đi là *xem* + /// nó, vì mở vụ thứ hai trên cùng đơn trả 409 — nút thứ hai chỉ để dẫn người + /// mua tới một thông báo lỗi. + Widget? _buildActionBar(BuildContext context, WidgetRef ref, OrderView view) { + final theme = Theme.of(context); + final openRefund = view.openRefund; + + final actions = [ + if (view.canConfirmReceipt) + FilledButton.icon( + onPressed: () => _confirmReceipt(context, ref), + icon: const Icon(Icons.inventory_2_outlined, size: 20), + label: const Text('Đã nhận hàng'), + ), + if (openRefund != null) + OutlinedButton.icon( + onPressed: () => + context.push('/account/refunds/${openRefund.id}'), + icon: const Icon(Icons.assignment_return_outlined, size: 20), + label: const Text('Xem yêu cầu hoàn tiền'), + ) + else if (view.canRequestRefund) + OutlinedButton.icon( + onPressed: () => _requestRefund(context, ref), + icon: const Icon(Icons.assignment_return_outlined, size: 20), + label: const Text('Yêu cầu hoàn tiền'), + ), + ]; + if (actions.isEmpty) return null; + + return Container( + decoration: BoxDecoration( + color: theme.colorScheme.surface, + border: Border( + top: BorderSide(color: theme.colorScheme.outlineVariant, width: 0.5), + ), + ), + child: SafeArea( + minimum: const EdgeInsets.fromLTRB(16, 12, 16, 12), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + for (final action in actions) ...[ + if (action != actions.first) const SizedBox(height: 8), + SizedBox(width: double.infinity, height: 48, child: action), + ], + ], + ), + ), + ); + } + + /// Xác nhận đã nhận hàng, ngay tại màn chi tiết. Trước đây việc này chỉ có ở + /// danh sách, nên người mở đơn ra xem rồi mới quyết định phải quay lại mới làm + /// được — và `received_at` là thứ mở đồng hồ trả tiền cho người bán. + Future _confirmReceipt(BuildContext context, WidgetRef ref) async { + final confirmed = await ConfirmReceiptSheet.show(context, orderId: orderId); + if (confirmed != true || !context.mounted) return; + // Sheet đã tự báo lỗi của nó; ở đây chỉ còn việc nạp lại cả chi tiết lẫn + // danh sách phía sau, vì đơn vừa đổi trạng thái. + ref.invalidate(buyerOrderDetailProvider(orderId)); + ref.invalidate(ordersProvider); + ref.invalidate(unsettledItemsProvider); + } + + Future _requestRefund(BuildContext context, WidgetRef ref) async { + final refund = await RequestRefundSheet.show(context, orderId); + if (refund == null || !context.mounted) return; + ref.invalidate(buyerOrderDetailProvider(orderId)); + context.push('/account/refunds/${refund.id}'); + } + Widget _buildStatusCard(BuildContext context, OrderView view) { final order = view.order; final theme = Theme.of(context); @@ -593,18 +677,14 @@ class OrderDetailScreen extends ConsumerWidget { ); } - /// Both live on the order, but only one of them is about money: a refund is - /// order's own state machine, while a `order-issue` ticket is a question for - /// support. + /// Hỏi support, chứ không phải một bước của đơn: một `order-issue` ticket là + /// câu hỏi cho người, còn hoàn tiền là máy trạng thái của chính đơn và sống ở + /// thanh dưới. Future _handleHelpAction( BuildContext context, _OrderHelpAction action, ) async { switch (action) { - case _OrderHelpAction.requestRefund: - final refund = await RequestRefundSheet.show(context, orderId); - if (refund == null || !context.mounted) return; - context.push('/account/refunds/${refund.id}'); case _OrderHelpAction.reportIssue: final ticket = await RaiseTicketSheet.show( context, @@ -619,4 +699,4 @@ class OrderDetailScreen extends ConsumerWidget { } } -enum _OrderHelpAction { requestRefund, reportIssue } +enum _OrderHelpAction { reportIssue } diff --git a/lib/features/account/presentation/widgets/confirm_receipt_sheet.dart b/lib/features/account/presentation/widgets/confirm_receipt_sheet.dart index 0bb0a35..265fa83 100644 --- a/lib/features/account/presentation/widgets/confirm_receipt_sheet.dart +++ b/lib/features/account/presentation/widgets/confirm_receipt_sheet.dart @@ -1,10 +1,10 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:image_picker/image_picker.dart'; +import 'package:shopnexus_flutter_app/api/generated/model/resource.dart'; +import 'package:shopnexus_flutter_app/core/upload/resource_uploader.dart'; import 'package:shopnexus_flutter_app/features/account/presentation/providers/orders_actions_provider.dart'; +import 'package:shopnexus_flutter_app/shared/widgets/image_upload_field.dart'; /// Người mua nói hàng đã tới, kèm ảnh mở hộp. /// @@ -37,32 +37,32 @@ class ConfirmReceiptSheet extends ConsumerStatefulWidget { class _ConfirmReceiptSheetState extends ConsumerState { static const _maxPhotos = 10; - final _picker = ImagePicker(); - final List _photos = []; + /// Resource đã xác nhận, do [ImageUploadField] tải lên. Ảnh được đưa lên ngay + /// lúc chọn chứ không đợi lúc bấm gửi: server chỉ nhận resource *đã* confirm, + /// nên gộp hai việc vào một lần bấm biến một ảnh hỏng thành cả lần xác nhận hỏng. + List _photos = const []; bool _submitting = false; - Future _pickPhotos() async { - final picked = await _picker.pickMultiImage(); - if (picked.isEmpty) return; - setState(() { - for (final file in picked) { - if (_photos.length >= _maxPhotos) break; - _photos.add(File(file.path)); - } - }); - } + /// Vì sao lần bấm vừa rồi chưa gửi được. Giữ ở đây chứ không chỉ ném snackbar: + /// câu trả lời nằm ngay trên dải ảnh, đúng chỗ phải sửa. + String? _error; Future _submit() async { - setState(() => _submitting = true); + // Nút không bị vô hiệu hoá khi chưa có ảnh, nó *trả lời*: một nút bấm vào + // không xảy ra gì là cách chắc chắn nhất để người dùng kết luận app hỏng — + // và đó đúng là chuyện đã xảy ra ở đây. + if (_photos.isEmpty) { + setState(() => _error = 'Cần ít nhất một ảnh mở hộp trước khi xác nhận.'); + return; + } + setState(() { + _submitting = true; + _error = null; + }); final ok = await ref .read(ordersActionsProvider.notifier) .confirmReceipt(widget.orderId, [ - for (final photo in _photos) - ReceiptPhoto( - bytes: await photo.readAsBytes(), - filename: photo.uri.pathSegments.last, - mime: 'image/jpeg', - ), + for (final photo in _photos) photo.id, ]); if (!mounted) return; if (ok) { @@ -80,7 +80,6 @@ class _ConfirmReceiptSheetState extends ConsumerState { @override Widget build(BuildContext context) { final theme = Theme.of(context); - final canSubmit = _photos.isNotEmpty && !_submitting; return Padding( padding: EdgeInsets.only( @@ -125,20 +124,29 @@ class _ConfirmReceiptSheetState extends ConsumerState { ), ), const SizedBox(height: 12), - _PhotoStrip( - photos: _photos, - onAdd: _submitting || _photos.length >= _maxPhotos - ? null - : _pickPhotos, - onRemove: _submitting - ? null - : (index) => setState(() => _photos.removeAt(index)), + ImageUploadField( + target: UploadTarget.order, + maxPhotos: _maxPhotos, + enabled: !_submitting, + onChanged: (photos) => setState(() { + _photos = photos; + if (photos.isNotEmpty) _error = null; + }), ), + if (_error case final error?) ...[ + const SizedBox(height: 8), + Text( + error, + style: theme.textTheme.bodySmall?.copyWith( + color: theme.colorScheme.error, + ), + ), + ], const SizedBox(height: 20), SizedBox( width: double.infinity, child: ElevatedButton( - onPressed: canSubmit ? _submit : null, + onPressed: _submitting ? null : _submit, child: Text( _submitting ? 'Đang gửi…' : 'Xác nhận đã nhận hàng', ), @@ -160,71 +168,3 @@ class _ConfirmReceiptSheetState extends ConsumerState { ); } } - -/// Ảnh đã chọn, cộng một ô "thêm" ở cuối — cùng hình dạng với chỗ đính kèm của -/// ticket, để hai nơi chụp ảnh trong app không trông như hai sản phẩm. -class _PhotoStrip extends StatelessWidget { - const _PhotoStrip({ - required this.photos, - required this.onAdd, - required this.onRemove, - }); - - final List photos; - final VoidCallback? onAdd; - final void Function(int index)? onRemove; - - @override - Widget build(BuildContext context) { - final theme = Theme.of(context); - - return Wrap( - spacing: 8, - runSpacing: 8, - children: [ - for (var index = 0; index < photos.length; index++) - SizedBox( - width: 72, - height: 72, - child: Stack( - fit: StackFit.expand, - children: [ - ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Image.file(photos[index], fit: BoxFit.cover), - ), - if (onRemove != null) - Positioned( - top: -6, - right: -6, - child: IconButton( - iconSize: 18, - icon: const Icon(Icons.cancel_rounded), - color: theme.colorScheme.error, - onPressed: () => onRemove!(index), - ), - ), - ], - ), - ), - if (onAdd != null) - InkWell( - onTap: onAdd, - borderRadius: BorderRadius.circular(10), - child: Container( - width: 72, - height: 72, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - border: Border.all(color: theme.colorScheme.outlineVariant), - ), - child: Icon( - Icons.add_a_photo_outlined, - color: theme.colorScheme.onSurfaceVariant, - ), - ), - ), - ], - ); - } -} diff --git a/lib/features/auth/data/repositories/auth_repository.g.dart b/lib/features/auth/data/repositories/auth_repository.g.dart index 8ac6dde..b8940a1 100644 --- a/lib/features/auth/data/repositories/auth_repository.g.dart +++ b/lib/features/auth/data/repositories/auth_repository.g.dart @@ -6,22 +6,46 @@ part of 'auth_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$authRepositoryHash() => r'14d67f94901c96173d88e8eb0f0189924b167742'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [authRepository]. @ProviderFor(authRepository) -final authRepositoryProvider = AutoDisposeProvider.internal( - authRepository, - name: r'authRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$authRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef AuthRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const authRepositoryProvider = AuthRepositoryProvider._(); + +final class AuthRepositoryProvider + extends $FunctionalProvider + with $Provider { + const AuthRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'authRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$authRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + AuthRepository create(Ref ref) { + return authRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AuthRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$authRepositoryHash() => r'14d67f94901c96173d88e8eb0f0189924b167742'; diff --git a/lib/features/auth/presentation/providers/auth_provider.freezed.dart b/lib/features/auth/presentation/providers/auth_provider.freezed.dart index 5ac0e49..ef19fb4 100644 --- a/lib/features/auth/presentation/providers/auth_provider.freezed.dart +++ b/lib/features/auth/presentation/providers/auth_provider.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,799 +9,414 @@ part of 'auth_provider.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - /// @nodoc mixin _$AuthState { - @optionalTypeArgs - TResult when({ - required TResult Function() initial, - required TResult Function() loading, - required TResult Function(String accessToken, String refreshToken) - authenticated, - required TResult Function() unauthenticated, - required TResult Function(String message) error, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? initial, - TResult? Function()? loading, - TResult? Function(String accessToken, String refreshToken)? authenticated, - TResult? Function()? unauthenticated, - TResult? Function(String message)? error, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? initial, - TResult Function()? loading, - TResult Function(String accessToken, String refreshToken)? authenticated, - TResult Function()? unauthenticated, - TResult Function(String message)? error, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_Initial value) initial, - required TResult Function(_Loading value) loading, - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Error value) error, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Initial value)? initial, - TResult? Function(_Loading value)? loading, - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Error value)? error, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Initial value)? initial, - TResult Function(_Loading value)? loading, - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Error value)? error, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthState); } -/// @nodoc -abstract class $AuthStateCopyWith<$Res> { - factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) = - _$AuthStateCopyWithImpl<$Res, AuthState>; + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'AuthState()'; +} + + } /// @nodoc -class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState> - implements $AuthStateCopyWith<$Res> { - _$AuthStateCopyWithImpl(this._value, this._then); +class $AuthStateCopyWith<$Res> { +$AuthStateCopyWith(AuthState _, $Res Function(AuthState) __); +} + - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [AuthState]. +extension AuthStatePatterns on AuthState { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap({TResult Function( _Initial value)? initial,TResult Function( _Loading value)? loading,TResult Function( _Authenticated value)? authenticated,TResult Function( _Unauthenticated value)? unauthenticated,TResult Function( _Error value)? error,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Initial() when initial != null: +return initial(_that);case _Loading() when loading != null: +return loading(_that);case _Authenticated() when authenticated != null: +return authenticated(_that);case _Unauthenticated() when unauthenticated != null: +return unauthenticated(_that);case _Error() when error != null: +return error(_that);case _: + return orElse(); - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. } +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map({required TResult Function( _Initial value) initial,required TResult Function( _Loading value) loading,required TResult Function( _Authenticated value) authenticated,required TResult Function( _Unauthenticated value) unauthenticated,required TResult Function( _Error value) error,}){ +final _that = this; +switch (_that) { +case _Initial(): +return initial(_that);case _Loading(): +return loading(_that);case _Authenticated(): +return authenticated(_that);case _Unauthenticated(): +return unauthenticated(_that);case _Error(): +return error(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull({TResult? Function( _Initial value)? initial,TResult? Function( _Loading value)? loading,TResult? Function( _Authenticated value)? authenticated,TResult? Function( _Unauthenticated value)? unauthenticated,TResult? Function( _Error value)? error,}){ +final _that = this; +switch (_that) { +case _Initial() when initial != null: +return initial(_that);case _Loading() when loading != null: +return loading(_that);case _Authenticated() when authenticated != null: +return authenticated(_that);case _Unauthenticated() when unauthenticated != null: +return unauthenticated(_that);case _Error() when error != null: +return error(_that);case _: + return null; -/// @nodoc -abstract class _$$InitialImplCopyWith<$Res> { - factory _$$InitialImplCopyWith( - _$InitialImpl value, - $Res Function(_$InitialImpl) then, - ) = __$$InitialImplCopyWithImpl<$Res>; } +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen({TResult Function()? initial,TResult Function()? loading,TResult Function( String accessToken, String refreshToken)? authenticated,TResult Function()? unauthenticated,TResult Function( String message)? error,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Initial() when initial != null: +return initial();case _Loading() when loading != null: +return loading();case _Authenticated() when authenticated != null: +return authenticated(_that.accessToken,_that.refreshToken);case _Unauthenticated() when unauthenticated != null: +return unauthenticated();case _Error() when error != null: +return error(_that.message);case _: + return orElse(); -/// @nodoc -class __$$InitialImplCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$InitialImpl> - implements _$$InitialImplCopyWith<$Res> { - __$$InitialImplCopyWithImpl( - _$InitialImpl _value, - $Res Function(_$InitialImpl) _then, - ) : super(_value, _then); +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when({required TResult Function() initial,required TResult Function() loading,required TResult Function( String accessToken, String refreshToken) authenticated,required TResult Function() unauthenticated,required TResult Function( String message) error,}) {final _that = this; +switch (_that) { +case _Initial(): +return initial();case _Loading(): +return loading();case _Authenticated(): +return authenticated(_that.accessToken,_that.refreshToken);case _Unauthenticated(): +return unauthenticated();case _Error(): +return error(_that.message);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull({TResult? Function()? initial,TResult? Function()? loading,TResult? Function( String accessToken, String refreshToken)? authenticated,TResult? Function()? unauthenticated,TResult? Function( String message)? error,}) {final _that = this; +switch (_that) { +case _Initial() when initial != null: +return initial();case _Loading() when loading != null: +return loading();case _Authenticated() when authenticated != null: +return authenticated(_that.accessToken,_that.refreshToken);case _Unauthenticated() when unauthenticated != null: +return unauthenticated();case _Error() when error != null: +return error(_that.message);case _: + return null; + +} +} - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$InitialImpl implements _Initial { - const _$InitialImpl(); - - @override - String toString() { - return 'AuthState.initial()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$InitialImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() initial, - required TResult Function() loading, - required TResult Function(String accessToken, String refreshToken) - authenticated, - required TResult Function() unauthenticated, - required TResult Function(String message) error, - }) { - return initial(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? initial, - TResult? Function()? loading, - TResult? Function(String accessToken, String refreshToken)? authenticated, - TResult? Function()? unauthenticated, - TResult? Function(String message)? error, - }) { - return initial?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? initial, - TResult Function()? loading, - TResult Function(String accessToken, String refreshToken)? authenticated, - TResult Function()? unauthenticated, - TResult Function(String message)? error, - required TResult orElse(), - }) { - if (initial != null) { - return initial(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Initial value) initial, - required TResult Function(_Loading value) loading, - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Error value) error, - }) { - return initial(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Initial value)? initial, - TResult? Function(_Loading value)? loading, - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Error value)? error, - }) { - return initial?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Initial value)? initial, - TResult Function(_Loading value)? loading, - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Error value)? error, - required TResult orElse(), - }) { - if (initial != null) { - return initial(this); - } - return orElse(); - } -} - -abstract class _Initial implements AuthState { - const factory _Initial() = _$InitialImpl; + +class _Initial implements AuthState { + const _Initial(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Initial); } -/// @nodoc -abstract class _$$LoadingImplCopyWith<$Res> { - factory _$$LoadingImplCopyWith( - _$LoadingImpl value, - $Res Function(_$LoadingImpl) then, - ) = __$$LoadingImplCopyWithImpl<$Res>; + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'AuthState.initial()'; } -/// @nodoc -class __$$LoadingImplCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$LoadingImpl> - implements _$$LoadingImplCopyWith<$Res> { - __$$LoadingImplCopyWithImpl( - _$LoadingImpl _value, - $Res Function(_$LoadingImpl) _then, - ) : super(_value, _then); - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. } + + + /// @nodoc -class _$LoadingImpl implements _Loading { - const _$LoadingImpl(); - - @override - String toString() { - return 'AuthState.loading()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$LoadingImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() initial, - required TResult Function() loading, - required TResult Function(String accessToken, String refreshToken) - authenticated, - required TResult Function() unauthenticated, - required TResult Function(String message) error, - }) { - return loading(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? initial, - TResult? Function()? loading, - TResult? Function(String accessToken, String refreshToken)? authenticated, - TResult? Function()? unauthenticated, - TResult? Function(String message)? error, - }) { - return loading?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? initial, - TResult Function()? loading, - TResult Function(String accessToken, String refreshToken)? authenticated, - TResult Function()? unauthenticated, - TResult Function(String message)? error, - required TResult orElse(), - }) { - if (loading != null) { - return loading(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Initial value) initial, - required TResult Function(_Loading value) loading, - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Error value) error, - }) { - return loading(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Initial value)? initial, - TResult? Function(_Loading value)? loading, - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Error value)? error, - }) { - return loading?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Initial value)? initial, - TResult Function(_Loading value)? loading, - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Error value)? error, - required TResult orElse(), - }) { - if (loading != null) { - return loading(this); - } - return orElse(); - } -} - -abstract class _Loading implements AuthState { - const factory _Loading() = _$LoadingImpl; + +class _Loading implements AuthState { + const _Loading(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Loading); } -/// @nodoc -abstract class _$$AuthenticatedImplCopyWith<$Res> { - factory _$$AuthenticatedImplCopyWith( - _$AuthenticatedImpl value, - $Res Function(_$AuthenticatedImpl) then, - ) = __$$AuthenticatedImplCopyWithImpl<$Res>; - @useResult - $Res call({String accessToken, String refreshToken}); + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'AuthState.loading()'; } -/// @nodoc -class __$$AuthenticatedImplCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$AuthenticatedImpl> - implements _$$AuthenticatedImplCopyWith<$Res> { - __$$AuthenticatedImplCopyWithImpl( - _$AuthenticatedImpl _value, - $Res Function(_$AuthenticatedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? accessToken = null, Object? refreshToken = null}) { - return _then( - _$AuthenticatedImpl( - accessToken: null == accessToken - ? _value.accessToken - : accessToken // ignore: cast_nullable_to_non_nullable - as String, - refreshToken: null == refreshToken - ? _value.refreshToken - : refreshToken // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } + } + + + /// @nodoc -class _$AuthenticatedImpl implements _Authenticated { - const _$AuthenticatedImpl({ - required this.accessToken, - required this.refreshToken, - }); - - @override - final String accessToken; - @override - final String refreshToken; - - @override - String toString() { - return 'AuthState.authenticated(accessToken: $accessToken, refreshToken: $refreshToken)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$AuthenticatedImpl && - (identical(other.accessToken, accessToken) || - other.accessToken == accessToken) && - (identical(other.refreshToken, refreshToken) || - other.refreshToken == refreshToken)); - } - - @override - int get hashCode => Object.hash(runtimeType, accessToken, refreshToken); - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$AuthenticatedImplCopyWith<_$AuthenticatedImpl> get copyWith => - __$$AuthenticatedImplCopyWithImpl<_$AuthenticatedImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() initial, - required TResult Function() loading, - required TResult Function(String accessToken, String refreshToken) - authenticated, - required TResult Function() unauthenticated, - required TResult Function(String message) error, - }) { - return authenticated(accessToken, refreshToken); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? initial, - TResult? Function()? loading, - TResult? Function(String accessToken, String refreshToken)? authenticated, - TResult? Function()? unauthenticated, - TResult? Function(String message)? error, - }) { - return authenticated?.call(accessToken, refreshToken); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? initial, - TResult Function()? loading, - TResult Function(String accessToken, String refreshToken)? authenticated, - TResult Function()? unauthenticated, - TResult Function(String message)? error, - required TResult orElse(), - }) { - if (authenticated != null) { - return authenticated(accessToken, refreshToken); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Initial value) initial, - required TResult Function(_Loading value) loading, - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Error value) error, - }) { - return authenticated(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Initial value)? initial, - TResult? Function(_Loading value)? loading, - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Error value)? error, - }) { - return authenticated?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Initial value)? initial, - TResult Function(_Loading value)? loading, - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Error value)? error, - required TResult orElse(), - }) { - if (authenticated != null) { - return authenticated(this); - } - return orElse(); - } -} - -abstract class _Authenticated implements AuthState { - const factory _Authenticated({ - required final String accessToken, - required final String refreshToken, - }) = _$AuthenticatedImpl; - - String get accessToken; - String get refreshToken; - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$AuthenticatedImplCopyWith<_$AuthenticatedImpl> get copyWith => - throw _privateConstructorUsedError; + +class _Authenticated implements AuthState { + const _Authenticated({required this.accessToken, required this.refreshToken}); + + + final String accessToken; + final String refreshToken; + +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AuthenticatedCopyWith<_Authenticated> get copyWith => __$AuthenticatedCopyWithImpl<_Authenticated>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Authenticated&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)); } -/// @nodoc -abstract class _$$UnauthenticatedImplCopyWith<$Res> { - factory _$$UnauthenticatedImplCopyWith( - _$UnauthenticatedImpl value, - $Res Function(_$UnauthenticatedImpl) then, - ) = __$$UnauthenticatedImplCopyWithImpl<$Res>; + +@override +int get hashCode => Object.hash(runtimeType,accessToken,refreshToken); + +@override +String toString() { + return 'AuthState.authenticated(accessToken: $accessToken, refreshToken: $refreshToken)'; } -/// @nodoc -class __$$UnauthenticatedImplCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$UnauthenticatedImpl> - implements _$$UnauthenticatedImplCopyWith<$Res> { - __$$UnauthenticatedImplCopyWithImpl( - _$UnauthenticatedImpl _value, - $Res Function(_$UnauthenticatedImpl) _then, - ) : super(_value, _then); - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. } /// @nodoc +abstract mixin class _$AuthenticatedCopyWith<$Res> implements $AuthStateCopyWith<$Res> { + factory _$AuthenticatedCopyWith(_Authenticated value, $Res Function(_Authenticated) _then) = __$AuthenticatedCopyWithImpl; +@useResult +$Res call({ + String accessToken, String refreshToken +}); + + + + +} +/// @nodoc +class __$AuthenticatedCopyWithImpl<$Res> + implements _$AuthenticatedCopyWith<$Res> { + __$AuthenticatedCopyWithImpl(this._self, this._then); + + final _Authenticated _self; + final $Res Function(_Authenticated) _then; + +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? accessToken = null,Object? refreshToken = null,}) { + return _then(_Authenticated( +accessToken: null == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable +as String,refreshToken: null == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable +as String, + )); +} + -class _$UnauthenticatedImpl implements _Unauthenticated { - const _$UnauthenticatedImpl(); - - @override - String toString() { - return 'AuthState.unauthenticated()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$UnauthenticatedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() initial, - required TResult Function() loading, - required TResult Function(String accessToken, String refreshToken) - authenticated, - required TResult Function() unauthenticated, - required TResult Function(String message) error, - }) { - return unauthenticated(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? initial, - TResult? Function()? loading, - TResult? Function(String accessToken, String refreshToken)? authenticated, - TResult? Function()? unauthenticated, - TResult? Function(String message)? error, - }) { - return unauthenticated?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? initial, - TResult Function()? loading, - TResult Function(String accessToken, String refreshToken)? authenticated, - TResult Function()? unauthenticated, - TResult Function(String message)? error, - required TResult orElse(), - }) { - if (unauthenticated != null) { - return unauthenticated(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Initial value) initial, - required TResult Function(_Loading value) loading, - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Error value) error, - }) { - return unauthenticated(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Initial value)? initial, - TResult? Function(_Loading value)? loading, - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Error value)? error, - }) { - return unauthenticated?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Initial value)? initial, - TResult Function(_Loading value)? loading, - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Error value)? error, - required TResult orElse(), - }) { - if (unauthenticated != null) { - return unauthenticated(this); - } - return orElse(); - } -} - -abstract class _Unauthenticated implements AuthState { - const factory _Unauthenticated() = _$UnauthenticatedImpl; } /// @nodoc -abstract class _$$ErrorImplCopyWith<$Res> { - factory _$$ErrorImplCopyWith( - _$ErrorImpl value, - $Res Function(_$ErrorImpl) then, - ) = __$$ErrorImplCopyWithImpl<$Res>; - @useResult - $Res call({String message}); + + +class _Unauthenticated implements AuthState { + const _Unauthenticated(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Unauthenticated); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'AuthState.unauthenticated()'; } + +} + + + + /// @nodoc -class __$$ErrorImplCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$ErrorImpl> - implements _$$ErrorImplCopyWith<$Res> { - __$$ErrorImplCopyWithImpl( - _$ErrorImpl _value, - $Res Function(_$ErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? message = null}) { - return _then( - _$ErrorImpl( - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } + + +class _Error implements AuthState { + const _Error({required this.message}); + + + final String message; + +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ErrorCopyWith<_Error> get copyWith => __$ErrorCopyWithImpl<_Error>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Error&&(identical(other.message, message) || other.message == message)); } + +@override +int get hashCode => Object.hash(runtimeType,message); + +@override +String toString() { + return 'AuthState.error(message: $message)'; +} + + +} + +/// @nodoc +abstract mixin class _$ErrorCopyWith<$Res> implements $AuthStateCopyWith<$Res> { + factory _$ErrorCopyWith(_Error value, $Res Function(_Error) _then) = __$ErrorCopyWithImpl; +@useResult +$Res call({ + String message +}); + + + + +} /// @nodoc +class __$ErrorCopyWithImpl<$Res> + implements _$ErrorCopyWith<$Res> { + __$ErrorCopyWithImpl(this._self, this._then); + + final _Error _self; + final $Res Function(_Error) _then; + +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? message = null,}) { + return _then(_Error( +message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String, + )); +} + -class _$ErrorImpl implements _Error { - const _$ErrorImpl({required this.message}); - - @override - final String message; - - @override - String toString() { - return 'AuthState.error(message: $message)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ErrorImpl && - (identical(other.message, message) || other.message == message)); - } - - @override - int get hashCode => Object.hash(runtimeType, message); - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ErrorImplCopyWith<_$ErrorImpl> get copyWith => - __$$ErrorImplCopyWithImpl<_$ErrorImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() initial, - required TResult Function() loading, - required TResult Function(String accessToken, String refreshToken) - authenticated, - required TResult Function() unauthenticated, - required TResult Function(String message) error, - }) { - return error(message); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? initial, - TResult? Function()? loading, - TResult? Function(String accessToken, String refreshToken)? authenticated, - TResult? Function()? unauthenticated, - TResult? Function(String message)? error, - }) { - return error?.call(message); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? initial, - TResult Function()? loading, - TResult Function(String accessToken, String refreshToken)? authenticated, - TResult Function()? unauthenticated, - TResult Function(String message)? error, - required TResult orElse(), - }) { - if (error != null) { - return error(message); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Initial value) initial, - required TResult Function(_Loading value) loading, - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Error value) error, - }) { - return error(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Initial value)? initial, - TResult? Function(_Loading value)? loading, - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Error value)? error, - }) { - return error?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Initial value)? initial, - TResult Function(_Loading value)? loading, - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Error value)? error, - required TResult orElse(), - }) { - if (error != null) { - return error(this); - } - return orElse(); - } -} - -abstract class _Error implements AuthState { - const factory _Error({required final String message}) = _$ErrorImpl; - - String get message; - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ErrorImplCopyWith<_$ErrorImpl> get copyWith => - throw _privateConstructorUsedError; } + +// dart format on diff --git a/lib/features/auth/presentation/providers/auth_provider.g.dart b/lib/features/auth/presentation/providers/auth_provider.g.dart index 946127a..561c3a2 100644 --- a/lib/features/auth/presentation/providers/auth_provider.g.dart +++ b/lib/features/auth/presentation/providers/auth_provider.g.dart @@ -6,21 +6,58 @@ part of 'auth_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$authNotifierHash() => r'ca2a9efa27409be3254e2a512e2b9542d4151a23'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [AuthNotifier]. @ProviderFor(AuthNotifier) -final authNotifierProvider = - AutoDisposeNotifierProvider.internal( - AuthNotifier.new, - name: r'authNotifierProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$authNotifierHash, - dependencies: null, - allTransitiveDependencies: null, +const authProvider = AuthNotifierProvider._(); + +final class AuthNotifierProvider + extends $NotifierProvider { + const AuthNotifierProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'authProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$authNotifierHash(); + + @$internal + @override + AuthNotifier create() => AuthNotifier(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AuthState value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} + +String _$authNotifierHash() => r'ca2a9efa27409be3254e2a512e2b9542d4151a23'; -typedef _$AuthNotifier = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$AuthNotifier extends $Notifier { + AuthState build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + AuthState, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/lib/features/cart/data/repositories/cart_repository.g.dart b/lib/features/cart/data/repositories/cart_repository.g.dart index 0c0bec4..d9bf73f 100644 --- a/lib/features/cart/data/repositories/cart_repository.g.dart +++ b/lib/features/cart/data/repositories/cart_repository.g.dart @@ -6,22 +6,46 @@ part of 'cart_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$cartRepositoryHash() => r'ebf417bc684ccbbe55b9951276c959965906c385'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [cartRepository]. @ProviderFor(cartRepository) -final cartRepositoryProvider = AutoDisposeProvider.internal( - cartRepository, - name: r'cartRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$cartRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CartRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const cartRepositoryProvider = CartRepositoryProvider._(); + +final class CartRepositoryProvider + extends $FunctionalProvider + with $Provider { + const CartRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'cartRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$cartRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + CartRepository create(Ref ref) { + return cartRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(CartRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$cartRepositoryHash() => r'ebf417bc684ccbbe55b9951276c959965906c385'; diff --git a/lib/features/cart/presentation/providers/cart_provider.freezed.dart b/lib/features/cart/presentation/providers/cart_provider.freezed.dart index 0e4592c..8da5dc1 100644 --- a/lib/features/cart/presentation/providers/cart_provider.freezed.dart +++ b/lib/features/cart/presentation/providers/cart_provider.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,236 +9,284 @@ part of 'cart_provider.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - /// @nodoc mixin _$CartState { - List get items => throw _privateConstructorUsedError; - Map get listings => throw _privateConstructorUsedError; - bool get isLoading => throw _privateConstructorUsedError; - String? get errorMessage => throw _privateConstructorUsedError; - /// Create a copy of CartState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CartStateCopyWith get copyWith => - throw _privateConstructorUsedError; + List get items; Map get listings; bool get isLoading; String? get errorMessage; +/// Create a copy of CartState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CartStateCopyWith get copyWith => _$CartStateCopyWithImpl(this as CartState, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CartState&&const DeepCollectionEquality().equals(other.items, items)&&const DeepCollectionEquality().equals(other.listings, listings)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); } -/// @nodoc -abstract class $CartStateCopyWith<$Res> { - factory $CartStateCopyWith(CartState value, $Res Function(CartState) then) = - _$CartStateCopyWithImpl<$Res, CartState>; - @useResult - $Res call({ - List items, - Map listings, - bool isLoading, - String? errorMessage, - }); + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items),const DeepCollectionEquality().hash(listings),isLoading,errorMessage); + +@override +String toString() { + return 'CartState(items: $items, listings: $listings, isLoading: $isLoading, errorMessage: $errorMessage)'; } -/// @nodoc -class _$CartStateCopyWithImpl<$Res, $Val extends CartState> - implements $CartStateCopyWith<$Res> { - _$CartStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CartState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? items = null, - Object? listings = null, - Object? isLoading = null, - Object? errorMessage = freezed, - }) { - return _then( - _value.copyWith( - items: null == items - ? _value.items - : items // ignore: cast_nullable_to_non_nullable - as List, - listings: null == listings - ? _value.listings - : listings // ignore: cast_nullable_to_non_nullable - as Map, - isLoading: null == isLoading - ? _value.isLoading - : isLoading // ignore: cast_nullable_to_non_nullable - as bool, - errorMessage: freezed == errorMessage - ? _value.errorMessage - : errorMessage // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$CartStateImplCopyWith<$Res> +abstract mixin class $CartStateCopyWith<$Res> { + factory $CartStateCopyWith(CartState value, $Res Function(CartState) _then) = _$CartStateCopyWithImpl; +@useResult +$Res call({ + List items, Map listings, bool isLoading, String? errorMessage +}); + + + + +} +/// @nodoc +class _$CartStateCopyWithImpl<$Res> implements $CartStateCopyWith<$Res> { - factory _$$CartStateImplCopyWith( - _$CartStateImpl value, - $Res Function(_$CartStateImpl) then, - ) = __$$CartStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - List items, - Map listings, - bool isLoading, - String? errorMessage, - }); + _$CartStateCopyWithImpl(this._self, this._then); + + final CartState _self; + final $Res Function(CartState) _then; + +/// Create a copy of CartState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? listings = null,Object? isLoading = null,Object? errorMessage = freezed,}) { + return _then(_self.copyWith( +items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List,listings: null == listings ? _self.listings : listings // ignore: cast_nullable_to_non_nullable +as Map,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable +as bool,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CartState]. +extension CartStatePatterns on CartState { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _CartState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CartState() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _CartState value) $default,){ +final _that = this; +switch (_that) { +case _CartState(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _CartState value)? $default,){ +final _that = this; +switch (_that) { +case _CartState() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( List items, Map listings, bool isLoading, String? errorMessage)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CartState() when $default != null: +return $default(_that.items,_that.listings,_that.isLoading,_that.errorMessage);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( List items, Map listings, bool isLoading, String? errorMessage) $default,) {final _that = this; +switch (_that) { +case _CartState(): +return $default(_that.items,_that.listings,_that.isLoading,_that.errorMessage);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( List items, Map listings, bool isLoading, String? errorMessage)? $default,) {final _that = this; +switch (_that) { +case _CartState() when $default != null: +return $default(_that.items,_that.listings,_that.isLoading,_that.errorMessage);case _: + return null; + +} +} + } /// @nodoc -class __$$CartStateImplCopyWithImpl<$Res> - extends _$CartStateCopyWithImpl<$Res, _$CartStateImpl> - implements _$$CartStateImplCopyWith<$Res> { - __$$CartStateImplCopyWithImpl( - _$CartStateImpl _value, - $Res Function(_$CartStateImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CartState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? items = null, - Object? listings = null, - Object? isLoading = null, - Object? errorMessage = freezed, - }) { - return _then( - _$CartStateImpl( - items: null == items - ? _value._items - : items // ignore: cast_nullable_to_non_nullable - as List, - listings: null == listings - ? _value._listings - : listings // ignore: cast_nullable_to_non_nullable - as Map, - isLoading: null == isLoading - ? _value.isLoading - : isLoading // ignore: cast_nullable_to_non_nullable - as bool, - errorMessage: freezed == errorMessage - ? _value.errorMessage - : errorMessage // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } + + +class _CartState extends CartState { + const _CartState({final List items = const [], final Map listings = const {}, this.isLoading = false, this.errorMessage}): _items = items,_listings = listings,super._(); + + + final List _items; +@override@JsonKey() List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); +} + + final Map _listings; +@override@JsonKey() Map get listings { + if (_listings is EqualUnmodifiableMapView) return _listings; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_listings); +} + +@override@JsonKey() final bool isLoading; +@override final String? errorMessage; + +/// Create a copy of CartState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CartStateCopyWith<_CartState> get copyWith => __$CartStateCopyWithImpl<_CartState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CartState&&const DeepCollectionEquality().equals(other._items, _items)&&const DeepCollectionEquality().equals(other._listings, _listings)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),const DeepCollectionEquality().hash(_listings),isLoading,errorMessage); + +@override +String toString() { + return 'CartState(items: $items, listings: $listings, isLoading: $isLoading, errorMessage: $errorMessage)'; } + +} + +/// @nodoc +abstract mixin class _$CartStateCopyWith<$Res> implements $CartStateCopyWith<$Res> { + factory _$CartStateCopyWith(_CartState value, $Res Function(_CartState) _then) = __$CartStateCopyWithImpl; +@override @useResult +$Res call({ + List items, Map listings, bool isLoading, String? errorMessage +}); + + + + +} /// @nodoc +class __$CartStateCopyWithImpl<$Res> + implements _$CartStateCopyWith<$Res> { + __$CartStateCopyWithImpl(this._self, this._then); -class _$CartStateImpl extends _CartState { - const _$CartStateImpl({ - final List items = const [], - final Map listings = const {}, - this.isLoading = false, - this.errorMessage, - }) : _items = items, - _listings = listings, - super._(); - - final List _items; - @override - @JsonKey() - List get items { - if (_items is EqualUnmodifiableListView) return _items; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_items); - } - - final Map _listings; - @override - @JsonKey() - Map get listings { - if (_listings is EqualUnmodifiableMapView) return _listings; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_listings); - } - - @override - @JsonKey() - final bool isLoading; - @override - final String? errorMessage; - - @override - String toString() { - return 'CartState(items: $items, listings: $listings, isLoading: $isLoading, errorMessage: $errorMessage)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CartStateImpl && - const DeepCollectionEquality().equals(other._items, _items) && - const DeepCollectionEquality().equals(other._listings, _listings) && - (identical(other.isLoading, isLoading) || - other.isLoading == isLoading) && - (identical(other.errorMessage, errorMessage) || - other.errorMessage == errorMessage)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_items), - const DeepCollectionEquality().hash(_listings), - isLoading, - errorMessage, - ); - - /// Create a copy of CartState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CartStateImplCopyWith<_$CartStateImpl> get copyWith => - __$$CartStateImplCopyWithImpl<_$CartStateImpl>(this, _$identity); -} - -abstract class _CartState extends CartState { - const factory _CartState({ - final List items, - final Map listings, - final bool isLoading, - final String? errorMessage, - }) = _$CartStateImpl; - const _CartState._() : super._(); - - @override - List get items; - @override - Map get listings; - @override - bool get isLoading; - @override - String? get errorMessage; - - /// Create a copy of CartState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CartStateImplCopyWith<_$CartStateImpl> get copyWith => - throw _privateConstructorUsedError; + final _CartState _self; + final $Res Function(_CartState) _then; + +/// Create a copy of CartState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? listings = null,Object? isLoading = null,Object? errorMessage = freezed,}) { + return _then(_CartState( +items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List,listings: null == listings ? _self._listings : listings // ignore: cast_nullable_to_non_nullable +as Map,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable +as bool,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable +as String?, + )); } + + +} + +// dart format on diff --git a/lib/features/cart/presentation/providers/cart_provider.g.dart b/lib/features/cart/presentation/providers/cart_provider.g.dart index 774f1d9..e02ace5 100644 --- a/lib/features/cart/presentation/providers/cart_provider.g.dart +++ b/lib/features/cart/presentation/providers/cart_provider.g.dart @@ -6,21 +6,58 @@ part of 'cart_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$cartNotifierHash() => r'7b2c2d4a061cf1cbe718247bc97f31ef119f6bdc'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [CartNotifier]. @ProviderFor(CartNotifier) -final cartNotifierProvider = - AutoDisposeNotifierProvider.internal( - CartNotifier.new, - name: r'cartNotifierProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$cartNotifierHash, - dependencies: null, - allTransitiveDependencies: null, +const cartProvider = CartNotifierProvider._(); + +final class CartNotifierProvider + extends $NotifierProvider { + const CartNotifierProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'cartProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$cartNotifierHash(); + + @$internal + @override + CartNotifier create() => CartNotifier(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(CartState value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} + +String _$cartNotifierHash() => r'7b2c2d4a061cf1cbe718247bc97f31ef119f6bdc'; -typedef _$CartNotifier = AutoDisposeNotifier; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$CartNotifier extends $Notifier { + CartState build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + CartState, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/lib/features/catalog/data/models/catalog_model.freezed.dart b/lib/features/catalog/data/models/catalog_model.freezed.dart index a9e5ce0..0e53f46 100644 --- a/lib/features/catalog/data/models/catalog_model.freezed.dart +++ b/lib/features/catalog/data/models/catalog_model.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,312 +9,287 @@ part of 'catalog_model.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - -RecentListing _$RecentListingFromJson(Map json) { - return _RecentListing.fromJson(json); -} - /// @nodoc mixin _$RecentListing { - String get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - int get price => throw _privateConstructorUsedError; - @JsonKey(name: 'cover_url') - String? get coverUrl => throw _privateConstructorUsedError; - @JsonKey(name: 'seller_name') - String? get sellerName => throw _privateConstructorUsedError; - double get rating => throw _privateConstructorUsedError; - bool get negotiable => throw _privateConstructorUsedError; + + String get id; String get name; int get price;@JsonKey(name: 'cover_url') String? get coverUrl;@JsonKey(name: 'seller_name') String? get sellerName; double get rating; bool get negotiable; +/// Create a copy of RecentListing +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$RecentListingCopyWith get copyWith => _$RecentListingCopyWithImpl(this as RecentListing, _$identity); /// Serializes this RecentListing to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of RecentListing - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $RecentListingCopyWith get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is RecentListing&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.price, price) || other.price == price)&&(identical(other.coverUrl, coverUrl) || other.coverUrl == coverUrl)&&(identical(other.sellerName, sellerName) || other.sellerName == sellerName)&&(identical(other.rating, rating) || other.rating == rating)&&(identical(other.negotiable, negotiable) || other.negotiable == negotiable)); } -/// @nodoc -abstract class $RecentListingCopyWith<$Res> { - factory $RecentListingCopyWith( - RecentListing value, - $Res Function(RecentListing) then, - ) = _$RecentListingCopyWithImpl<$Res, RecentListing>; - @useResult - $Res call({ - String id, - String name, - int price, - @JsonKey(name: 'cover_url') String? coverUrl, - @JsonKey(name: 'seller_name') String? sellerName, - double rating, - bool negotiable, - }); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,price,coverUrl,sellerName,rating,negotiable); + +@override +String toString() { + return 'RecentListing(id: $id, name: $name, price: $price, coverUrl: $coverUrl, sellerName: $sellerName, rating: $rating, negotiable: $negotiable)'; } -/// @nodoc -class _$RecentListingCopyWithImpl<$Res, $Val extends RecentListing> - implements $RecentListingCopyWith<$Res> { - _$RecentListingCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of RecentListing - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? name = null, - Object? price = null, - Object? coverUrl = freezed, - Object? sellerName = freezed, - Object? rating = null, - Object? negotiable = null, - }) { - return _then( - _value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - price: null == price - ? _value.price - : price // ignore: cast_nullable_to_non_nullable - as int, - coverUrl: freezed == coverUrl - ? _value.coverUrl - : coverUrl // ignore: cast_nullable_to_non_nullable - as String?, - sellerName: freezed == sellerName - ? _value.sellerName - : sellerName // ignore: cast_nullable_to_non_nullable - as String?, - rating: null == rating - ? _value.rating - : rating // ignore: cast_nullable_to_non_nullable - as double, - negotiable: null == negotiable - ? _value.negotiable - : negotiable // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$RecentListingImplCopyWith<$Res> +abstract mixin class $RecentListingCopyWith<$Res> { + factory $RecentListingCopyWith(RecentListing value, $Res Function(RecentListing) _then) = _$RecentListingCopyWithImpl; +@useResult +$Res call({ + String id, String name, int price,@JsonKey(name: 'cover_url') String? coverUrl,@JsonKey(name: 'seller_name') String? sellerName, double rating, bool negotiable +}); + + + + +} +/// @nodoc +class _$RecentListingCopyWithImpl<$Res> implements $RecentListingCopyWith<$Res> { - factory _$$RecentListingImplCopyWith( - _$RecentListingImpl value, - $Res Function(_$RecentListingImpl) then, - ) = __$$RecentListingImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String id, - String name, - int price, - @JsonKey(name: 'cover_url') String? coverUrl, - @JsonKey(name: 'seller_name') String? sellerName, - double rating, - bool negotiable, - }); + _$RecentListingCopyWithImpl(this._self, this._then); + + final RecentListing _self; + final $Res Function(RecentListing) _then; + +/// Create a copy of RecentListing +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? price = null,Object? coverUrl = freezed,Object? sellerName = freezed,Object? rating = null,Object? negotiable = null,}) { + return _then(_self.copyWith( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,price: null == price ? _self.price : price // ignore: cast_nullable_to_non_nullable +as int,coverUrl: freezed == coverUrl ? _self.coverUrl : coverUrl // ignore: cast_nullable_to_non_nullable +as String?,sellerName: freezed == sellerName ? _self.sellerName : sellerName // ignore: cast_nullable_to_non_nullable +as String?,rating: null == rating ? _self.rating : rating // ignore: cast_nullable_to_non_nullable +as double,negotiable: null == negotiable ? _self.negotiable : negotiable // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [RecentListing]. +extension RecentListingPatterns on RecentListing { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _RecentListing value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _RecentListing() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _RecentListing value) $default,){ +final _that = this; +switch (_that) { +case _RecentListing(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _RecentListing value)? $default,){ +final _that = this; +switch (_that) { +case _RecentListing() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String id, String name, int price, @JsonKey(name: 'cover_url') String? coverUrl, @JsonKey(name: 'seller_name') String? sellerName, double rating, bool negotiable)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _RecentListing() when $default != null: +return $default(_that.id,_that.name,_that.price,_that.coverUrl,_that.sellerName,_that.rating,_that.negotiable);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String id, String name, int price, @JsonKey(name: 'cover_url') String? coverUrl, @JsonKey(name: 'seller_name') String? sellerName, double rating, bool negotiable) $default,) {final _that = this; +switch (_that) { +case _RecentListing(): +return $default(_that.id,_that.name,_that.price,_that.coverUrl,_that.sellerName,_that.rating,_that.negotiable);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String id, String name, int price, @JsonKey(name: 'cover_url') String? coverUrl, @JsonKey(name: 'seller_name') String? sellerName, double rating, bool negotiable)? $default,) {final _that = this; +switch (_that) { +case _RecentListing() when $default != null: +return $default(_that.id,_that.name,_that.price,_that.coverUrl,_that.sellerName,_that.rating,_that.negotiable);case _: + return null; + +} } -/// @nodoc -class __$$RecentListingImplCopyWithImpl<$Res> - extends _$RecentListingCopyWithImpl<$Res, _$RecentListingImpl> - implements _$$RecentListingImplCopyWith<$Res> { - __$$RecentListingImplCopyWithImpl( - _$RecentListingImpl _value, - $Res Function(_$RecentListingImpl) _then, - ) : super(_value, _then); - - /// Create a copy of RecentListing - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? name = null, - Object? price = null, - Object? coverUrl = freezed, - Object? sellerName = freezed, - Object? rating = null, - Object? negotiable = null, - }) { - return _then( - _$RecentListingImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - price: null == price - ? _value.price - : price // ignore: cast_nullable_to_non_nullable - as int, - coverUrl: freezed == coverUrl - ? _value.coverUrl - : coverUrl // ignore: cast_nullable_to_non_nullable - as String?, - sellerName: freezed == sellerName - ? _value.sellerName - : sellerName // ignore: cast_nullable_to_non_nullable - as String?, - rating: null == rating - ? _value.rating - : rating // ignore: cast_nullable_to_non_nullable - as double, - negotiable: null == negotiable - ? _value.negotiable - : negotiable // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } } /// @nodoc @JsonSerializable() -class _$RecentListingImpl extends _RecentListing { - const _$RecentListingImpl({ - required this.id, - required this.name, - required this.price, - @JsonKey(name: 'cover_url') this.coverUrl, - @JsonKey(name: 'seller_name') this.sellerName, - this.rating = 0.0, - this.negotiable = false, - }) : super._(); - - factory _$RecentListingImpl.fromJson(Map json) => - _$$RecentListingImplFromJson(json); - - @override - final String id; - @override - final String name; - @override - final int price; - @override - @JsonKey(name: 'cover_url') - final String? coverUrl; - @override - @JsonKey(name: 'seller_name') - final String? sellerName; - @override - @JsonKey() - final double rating; - @override - @JsonKey() - final bool negotiable; - - @override - String toString() { - return 'RecentListing(id: $id, name: $name, price: $price, coverUrl: $coverUrl, sellerName: $sellerName, rating: $rating, negotiable: $negotiable)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RecentListingImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.name, name) || other.name == name) && - (identical(other.price, price) || other.price == price) && - (identical(other.coverUrl, coverUrl) || - other.coverUrl == coverUrl) && - (identical(other.sellerName, sellerName) || - other.sellerName == sellerName) && - (identical(other.rating, rating) || other.rating == rating) && - (identical(other.negotiable, negotiable) || - other.negotiable == negotiable)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - name, - price, - coverUrl, - sellerName, - rating, - negotiable, - ); - - /// Create a copy of RecentListing - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RecentListingImplCopyWith<_$RecentListingImpl> get copyWith => - __$$RecentListingImplCopyWithImpl<_$RecentListingImpl>(this, _$identity); - - @override - Map toJson() { - return _$$RecentListingImplToJson(this); - } + +class _RecentListing extends RecentListing { + const _RecentListing({required this.id, required this.name, required this.price, @JsonKey(name: 'cover_url') this.coverUrl, @JsonKey(name: 'seller_name') this.sellerName, this.rating = 0.0, this.negotiable = false}): super._(); + factory _RecentListing.fromJson(Map json) => _$RecentListingFromJson(json); + +@override final String id; +@override final String name; +@override final int price; +@override@JsonKey(name: 'cover_url') final String? coverUrl; +@override@JsonKey(name: 'seller_name') final String? sellerName; +@override@JsonKey() final double rating; +@override@JsonKey() final bool negotiable; + +/// Create a copy of RecentListing +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RecentListingCopyWith<_RecentListing> get copyWith => __$RecentListingCopyWithImpl<_RecentListing>(this, _$identity); + +@override +Map toJson() { + return _$RecentListingToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _RecentListing&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.price, price) || other.price == price)&&(identical(other.coverUrl, coverUrl) || other.coverUrl == coverUrl)&&(identical(other.sellerName, sellerName) || other.sellerName == sellerName)&&(identical(other.rating, rating) || other.rating == rating)&&(identical(other.negotiable, negotiable) || other.negotiable == negotiable)); } -abstract class _RecentListing extends RecentListing { - const factory _RecentListing({ - required final String id, - required final String name, - required final int price, - @JsonKey(name: 'cover_url') final String? coverUrl, - @JsonKey(name: 'seller_name') final String? sellerName, - final double rating, - final bool negotiable, - }) = _$RecentListingImpl; - const _RecentListing._() : super._(); - - factory _RecentListing.fromJson(Map json) = - _$RecentListingImpl.fromJson; - - @override - String get id; - @override - String get name; - @override - int get price; - @override - @JsonKey(name: 'cover_url') - String? get coverUrl; - @override - @JsonKey(name: 'seller_name') - String? get sellerName; - @override - double get rating; - @override - bool get negotiable; - - /// Create a copy of RecentListing - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RecentListingImplCopyWith<_$RecentListingImpl> get copyWith => - throw _privateConstructorUsedError; +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,id,name,price,coverUrl,sellerName,rating,negotiable); + +@override +String toString() { + return 'RecentListing(id: $id, name: $name, price: $price, coverUrl: $coverUrl, sellerName: $sellerName, rating: $rating, negotiable: $negotiable)'; } + + +} + +/// @nodoc +abstract mixin class _$RecentListingCopyWith<$Res> implements $RecentListingCopyWith<$Res> { + factory _$RecentListingCopyWith(_RecentListing value, $Res Function(_RecentListing) _then) = __$RecentListingCopyWithImpl; +@override @useResult +$Res call({ + String id, String name, int price,@JsonKey(name: 'cover_url') String? coverUrl,@JsonKey(name: 'seller_name') String? sellerName, double rating, bool negotiable +}); + + + + +} +/// @nodoc +class __$RecentListingCopyWithImpl<$Res> + implements _$RecentListingCopyWith<$Res> { + __$RecentListingCopyWithImpl(this._self, this._then); + + final _RecentListing _self; + final $Res Function(_RecentListing) _then; + +/// Create a copy of RecentListing +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? name = null,Object? price = null,Object? coverUrl = freezed,Object? sellerName = freezed,Object? rating = null,Object? negotiable = null,}) { + return _then(_RecentListing( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,price: null == price ? _self.price : price // ignore: cast_nullable_to_non_nullable +as int,coverUrl: freezed == coverUrl ? _self.coverUrl : coverUrl // ignore: cast_nullable_to_non_nullable +as String?,sellerName: freezed == sellerName ? _self.sellerName : sellerName // ignore: cast_nullable_to_non_nullable +as String?,rating: null == rating ? _self.rating : rating // ignore: cast_nullable_to_non_nullable +as double,negotiable: null == negotiable ? _self.negotiable : negotiable // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/features/catalog/data/models/catalog_model.g.dart b/lib/features/catalog/data/models/catalog_model.g.dart index ba8abdd..3ac5bc7 100644 --- a/lib/features/catalog/data/models/catalog_model.g.dart +++ b/lib/features/catalog/data/models/catalog_model.g.dart @@ -6,8 +6,8 @@ part of 'catalog_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$RecentListingImpl _$$RecentListingImplFromJson(Map json) => - _$RecentListingImpl( +_RecentListing _$RecentListingFromJson(Map json) => + _RecentListing( id: json['id'] as String, name: json['name'] as String, price: (json['price'] as num).toInt(), @@ -17,7 +17,7 @@ _$RecentListingImpl _$$RecentListingImplFromJson(Map json) => negotiable: json['negotiable'] as bool? ?? false, ); -Map _$$RecentListingImplToJson(_$RecentListingImpl instance) => +Map _$RecentListingToJson(_RecentListing instance) => { 'id': instance.id, 'name': instance.name, diff --git a/lib/features/catalog/data/repositories/catalog_repository.dart b/lib/features/catalog/data/repositories/catalog_repository.dart index 1c0e7b2..dd31db2 100644 Binary files a/lib/features/catalog/data/repositories/catalog_repository.dart and b/lib/features/catalog/data/repositories/catalog_repository.dart differ diff --git a/lib/features/catalog/data/repositories/catalog_repository.g.dart b/lib/features/catalog/data/repositories/catalog_repository.g.dart index 5f80ffa..f3eb51a 100644 --- a/lib/features/catalog/data/repositories/catalog_repository.g.dart +++ b/lib/features/catalog/data/repositories/catalog_repository.g.dart @@ -6,23 +6,52 @@ part of 'catalog_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$catalogRepositoryHash() => r'5f23214d9328f8d8f89ef5d352a280afb4871fcf'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [catalogRepository]. @ProviderFor(catalogRepository) -final catalogRepositoryProvider = - AutoDisposeProvider.internal( - catalogRepository, - name: r'catalogRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$catalogRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, +const catalogRepositoryProvider = CatalogRepositoryProvider._(); + +final class CatalogRepositoryProvider + extends + $FunctionalProvider< + CatalogRepository, + CatalogRepository, + CatalogRepository + > + with $Provider { + const CatalogRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'catalogRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$catalogRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + CatalogRepository create(Ref ref) { + return catalogRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(CatalogRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CatalogRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +String _$catalogRepositoryHash() => r'5f23214d9328f8d8f89ef5d352a280afb4871fcf'; diff --git a/lib/features/catalog/presentation/providers/catalog_provider.freezed.dart b/lib/features/catalog/presentation/providers/catalog_provider.freezed.dart index 82b2484..d46ec07 100644 --- a/lib/features/catalog/presentation/providers/catalog_provider.freezed.dart +++ b/lib/features/catalog/presentation/providers/catalog_provider.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,944 +9,883 @@ part of 'catalog_provider.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - /// @nodoc mixin _$CatalogSearchFilters { - String? get keyword => throw _privateConstructorUsedError; - String? get categoryId => throw _privateConstructorUsedError; - int? get priceMin => throw _privateConstructorUsedError; - int? get priceMax => throw _privateConstructorUsedError; - String? get tag => throw _privateConstructorUsedError; - String? get sort => - throw _privateConstructorUsedError; // Where to look: the listing's own snapshot of the seller's pickup address. - // Send the narrowest level meant — a ward is already inside its province. - // There is no district: Vietnam goes province to ward, so a listing's - // snapshot has no district code for one to be matched against. - String? get provinceCode => throw _privateConstructorUsedError; - String? get wardCode => - throw _privateConstructorUsedError; // Codes carry no name, so the chip needs the label the user picked. - String? get areaLabel => - throw _privateConstructorUsedError; // Where the buyer is. A saved contact is the usual answer; lat/lon is - // supported all the way down to the request but no screen sets it, since - // the app has no geolocation plugin. - String? get nearContactId => throw _privateConstructorUsedError; - String? get nearLabel => throw _privateConstructorUsedError; - double? get lat => throw _privateConstructorUsedError; - double? get lon => throw _privateConstructorUsedError; - double? get radiusKm => throw _privateConstructorUsedError; - int get page => throw _privateConstructorUsedError; - int get size => throw _privateConstructorUsedError; - - /// Create a copy of CatalogSearchFilters - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CatalogSearchFiltersCopyWith get copyWith => - throw _privateConstructorUsedError; + + String? get keyword; String? get categoryId; int? get priceMin; int? get priceMax; String? get tag; String? get sort;// Where to look: the listing's own snapshot of the seller's pickup address. +// Send the narrowest level meant — a ward is already inside its province. +// There is no district: Vietnam goes province to ward, so a listing's +// snapshot has no district code for one to be matched against. + String? get provinceCode; String? get wardCode;// Codes carry no name, so the chip needs the label the user picked. + String? get areaLabel;// Where the buyer is. A saved contact is the usual answer; lat/lon is +// supported all the way down to the request but no screen sets it, since +// the app has no geolocation plugin. + String? get nearContactId; String? get nearLabel; double? get lat; double? get lon; double? get radiusKm; int get page; int get size; +/// Create a copy of CatalogSearchFilters +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CatalogSearchFiltersCopyWith get copyWith => _$CatalogSearchFiltersCopyWithImpl(this as CatalogSearchFilters, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CatalogSearchFilters&&(identical(other.keyword, keyword) || other.keyword == keyword)&&(identical(other.categoryId, categoryId) || other.categoryId == categoryId)&&(identical(other.priceMin, priceMin) || other.priceMin == priceMin)&&(identical(other.priceMax, priceMax) || other.priceMax == priceMax)&&(identical(other.tag, tag) || other.tag == tag)&&(identical(other.sort, sort) || other.sort == sort)&&(identical(other.provinceCode, provinceCode) || other.provinceCode == provinceCode)&&(identical(other.wardCode, wardCode) || other.wardCode == wardCode)&&(identical(other.areaLabel, areaLabel) || other.areaLabel == areaLabel)&&(identical(other.nearContactId, nearContactId) || other.nearContactId == nearContactId)&&(identical(other.nearLabel, nearLabel) || other.nearLabel == nearLabel)&&(identical(other.lat, lat) || other.lat == lat)&&(identical(other.lon, lon) || other.lon == lon)&&(identical(other.radiusKm, radiusKm) || other.radiusKm == radiusKm)&&(identical(other.page, page) || other.page == page)&&(identical(other.size, size) || other.size == size)); } -/// @nodoc -abstract class $CatalogSearchFiltersCopyWith<$Res> { - factory $CatalogSearchFiltersCopyWith( - CatalogSearchFilters value, - $Res Function(CatalogSearchFilters) then, - ) = _$CatalogSearchFiltersCopyWithImpl<$Res, CatalogSearchFilters>; - @useResult - $Res call({ - String? keyword, - String? categoryId, - int? priceMin, - int? priceMax, - String? tag, - String? sort, - String? provinceCode, - String? wardCode, - String? areaLabel, - String? nearContactId, - String? nearLabel, - double? lat, - double? lon, - double? radiusKm, - int page, - int size, - }); + +@override +int get hashCode => Object.hash(runtimeType,keyword,categoryId,priceMin,priceMax,tag,sort,provinceCode,wardCode,areaLabel,nearContactId,nearLabel,lat,lon,radiusKm,page,size); + +@override +String toString() { + return 'CatalogSearchFilters(keyword: $keyword, categoryId: $categoryId, priceMin: $priceMin, priceMax: $priceMax, tag: $tag, sort: $sort, provinceCode: $provinceCode, wardCode: $wardCode, areaLabel: $areaLabel, nearContactId: $nearContactId, nearLabel: $nearLabel, lat: $lat, lon: $lon, radiusKm: $radiusKm, page: $page, size: $size)'; } -/// @nodoc -class _$CatalogSearchFiltersCopyWithImpl< - $Res, - $Val extends CatalogSearchFilters -> - implements $CatalogSearchFiltersCopyWith<$Res> { - _$CatalogSearchFiltersCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CatalogSearchFilters - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? keyword = freezed, - Object? categoryId = freezed, - Object? priceMin = freezed, - Object? priceMax = freezed, - Object? tag = freezed, - Object? sort = freezed, - Object? provinceCode = freezed, - Object? wardCode = freezed, - Object? areaLabel = freezed, - Object? nearContactId = freezed, - Object? nearLabel = freezed, - Object? lat = freezed, - Object? lon = freezed, - Object? radiusKm = freezed, - Object? page = null, - Object? size = null, - }) { - return _then( - _value.copyWith( - keyword: freezed == keyword - ? _value.keyword - : keyword // ignore: cast_nullable_to_non_nullable - as String?, - categoryId: freezed == categoryId - ? _value.categoryId - : categoryId // ignore: cast_nullable_to_non_nullable - as String?, - priceMin: freezed == priceMin - ? _value.priceMin - : priceMin // ignore: cast_nullable_to_non_nullable - as int?, - priceMax: freezed == priceMax - ? _value.priceMax - : priceMax // ignore: cast_nullable_to_non_nullable - as int?, - tag: freezed == tag - ? _value.tag - : tag // ignore: cast_nullable_to_non_nullable - as String?, - sort: freezed == sort - ? _value.sort - : sort // ignore: cast_nullable_to_non_nullable - as String?, - provinceCode: freezed == provinceCode - ? _value.provinceCode - : provinceCode // ignore: cast_nullable_to_non_nullable - as String?, - wardCode: freezed == wardCode - ? _value.wardCode - : wardCode // ignore: cast_nullable_to_non_nullable - as String?, - areaLabel: freezed == areaLabel - ? _value.areaLabel - : areaLabel // ignore: cast_nullable_to_non_nullable - as String?, - nearContactId: freezed == nearContactId - ? _value.nearContactId - : nearContactId // ignore: cast_nullable_to_non_nullable - as String?, - nearLabel: freezed == nearLabel - ? _value.nearLabel - : nearLabel // ignore: cast_nullable_to_non_nullable - as String?, - lat: freezed == lat - ? _value.lat - : lat // ignore: cast_nullable_to_non_nullable - as double?, - lon: freezed == lon - ? _value.lon - : lon // ignore: cast_nullable_to_non_nullable - as double?, - radiusKm: freezed == radiusKm - ? _value.radiusKm - : radiusKm // ignore: cast_nullable_to_non_nullable - as double?, - page: null == page - ? _value.page - : page // ignore: cast_nullable_to_non_nullable - as int, - size: null == size - ? _value.size - : size // ignore: cast_nullable_to_non_nullable - as int, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$CatalogSearchFiltersImplCopyWith<$Res> +abstract mixin class $CatalogSearchFiltersCopyWith<$Res> { + factory $CatalogSearchFiltersCopyWith(CatalogSearchFilters value, $Res Function(CatalogSearchFilters) _then) = _$CatalogSearchFiltersCopyWithImpl; +@useResult +$Res call({ + String? keyword, String? categoryId, int? priceMin, int? priceMax, String? tag, String? sort, String? provinceCode, String? wardCode, String? areaLabel, String? nearContactId, String? nearLabel, double? lat, double? lon, double? radiusKm, int page, int size +}); + + + + +} +/// @nodoc +class _$CatalogSearchFiltersCopyWithImpl<$Res> implements $CatalogSearchFiltersCopyWith<$Res> { - factory _$$CatalogSearchFiltersImplCopyWith( - _$CatalogSearchFiltersImpl value, - $Res Function(_$CatalogSearchFiltersImpl) then, - ) = __$$CatalogSearchFiltersImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String? keyword, - String? categoryId, - int? priceMin, - int? priceMax, - String? tag, - String? sort, - String? provinceCode, - String? wardCode, - String? areaLabel, - String? nearContactId, - String? nearLabel, - double? lat, - double? lon, - double? radiusKm, - int page, - int size, - }); + _$CatalogSearchFiltersCopyWithImpl(this._self, this._then); + + final CatalogSearchFilters _self; + final $Res Function(CatalogSearchFilters) _then; + +/// Create a copy of CatalogSearchFilters +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? keyword = freezed,Object? categoryId = freezed,Object? priceMin = freezed,Object? priceMax = freezed,Object? tag = freezed,Object? sort = freezed,Object? provinceCode = freezed,Object? wardCode = freezed,Object? areaLabel = freezed,Object? nearContactId = freezed,Object? nearLabel = freezed,Object? lat = freezed,Object? lon = freezed,Object? radiusKm = freezed,Object? page = null,Object? size = null,}) { + return _then(_self.copyWith( +keyword: freezed == keyword ? _self.keyword : keyword // ignore: cast_nullable_to_non_nullable +as String?,categoryId: freezed == categoryId ? _self.categoryId : categoryId // ignore: cast_nullable_to_non_nullable +as String?,priceMin: freezed == priceMin ? _self.priceMin : priceMin // ignore: cast_nullable_to_non_nullable +as int?,priceMax: freezed == priceMax ? _self.priceMax : priceMax // ignore: cast_nullable_to_non_nullable +as int?,tag: freezed == tag ? _self.tag : tag // ignore: cast_nullable_to_non_nullable +as String?,sort: freezed == sort ? _self.sort : sort // ignore: cast_nullable_to_non_nullable +as String?,provinceCode: freezed == provinceCode ? _self.provinceCode : provinceCode // ignore: cast_nullable_to_non_nullable +as String?,wardCode: freezed == wardCode ? _self.wardCode : wardCode // ignore: cast_nullable_to_non_nullable +as String?,areaLabel: freezed == areaLabel ? _self.areaLabel : areaLabel // ignore: cast_nullable_to_non_nullable +as String?,nearContactId: freezed == nearContactId ? _self.nearContactId : nearContactId // ignore: cast_nullable_to_non_nullable +as String?,nearLabel: freezed == nearLabel ? _self.nearLabel : nearLabel // ignore: cast_nullable_to_non_nullable +as String?,lat: freezed == lat ? _self.lat : lat // ignore: cast_nullable_to_non_nullable +as double?,lon: freezed == lon ? _self.lon : lon // ignore: cast_nullable_to_non_nullable +as double?,radiusKm: freezed == radiusKm ? _self.radiusKm : radiusKm // ignore: cast_nullable_to_non_nullable +as double?,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,size: null == size ? _self.size : size // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CatalogSearchFilters]. +extension CatalogSearchFiltersPatterns on CatalogSearchFilters { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _CatalogSearchFilters value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CatalogSearchFilters() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _CatalogSearchFilters value) $default,){ +final _that = this; +switch (_that) { +case _CatalogSearchFilters(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _CatalogSearchFilters value)? $default,){ +final _that = this; +switch (_that) { +case _CatalogSearchFilters() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String? keyword, String? categoryId, int? priceMin, int? priceMax, String? tag, String? sort, String? provinceCode, String? wardCode, String? areaLabel, String? nearContactId, String? nearLabel, double? lat, double? lon, double? radiusKm, int page, int size)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CatalogSearchFilters() when $default != null: +return $default(_that.keyword,_that.categoryId,_that.priceMin,_that.priceMax,_that.tag,_that.sort,_that.provinceCode,_that.wardCode,_that.areaLabel,_that.nearContactId,_that.nearLabel,_that.lat,_that.lon,_that.radiusKm,_that.page,_that.size);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String? keyword, String? categoryId, int? priceMin, int? priceMax, String? tag, String? sort, String? provinceCode, String? wardCode, String? areaLabel, String? nearContactId, String? nearLabel, double? lat, double? lon, double? radiusKm, int page, int size) $default,) {final _that = this; +switch (_that) { +case _CatalogSearchFilters(): +return $default(_that.keyword,_that.categoryId,_that.priceMin,_that.priceMax,_that.tag,_that.sort,_that.provinceCode,_that.wardCode,_that.areaLabel,_that.nearContactId,_that.nearLabel,_that.lat,_that.lon,_that.radiusKm,_that.page,_that.size);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? keyword, String? categoryId, int? priceMin, int? priceMax, String? tag, String? sort, String? provinceCode, String? wardCode, String? areaLabel, String? nearContactId, String? nearLabel, double? lat, double? lon, double? radiusKm, int page, int size)? $default,) {final _that = this; +switch (_that) { +case _CatalogSearchFilters() when $default != null: +return $default(_that.keyword,_that.categoryId,_that.priceMin,_that.priceMax,_that.tag,_that.sort,_that.provinceCode,_that.wardCode,_that.areaLabel,_that.nearContactId,_that.nearLabel,_that.lat,_that.lon,_that.radiusKm,_that.page,_that.size);case _: + return null; + +} +} + } /// @nodoc -class __$$CatalogSearchFiltersImplCopyWithImpl<$Res> - extends _$CatalogSearchFiltersCopyWithImpl<$Res, _$CatalogSearchFiltersImpl> - implements _$$CatalogSearchFiltersImplCopyWith<$Res> { - __$$CatalogSearchFiltersImplCopyWithImpl( - _$CatalogSearchFiltersImpl _value, - $Res Function(_$CatalogSearchFiltersImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CatalogSearchFilters - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? keyword = freezed, - Object? categoryId = freezed, - Object? priceMin = freezed, - Object? priceMax = freezed, - Object? tag = freezed, - Object? sort = freezed, - Object? provinceCode = freezed, - Object? wardCode = freezed, - Object? areaLabel = freezed, - Object? nearContactId = freezed, - Object? nearLabel = freezed, - Object? lat = freezed, - Object? lon = freezed, - Object? radiusKm = freezed, - Object? page = null, - Object? size = null, - }) { - return _then( - _$CatalogSearchFiltersImpl( - keyword: freezed == keyword - ? _value.keyword - : keyword // ignore: cast_nullable_to_non_nullable - as String?, - categoryId: freezed == categoryId - ? _value.categoryId - : categoryId // ignore: cast_nullable_to_non_nullable - as String?, - priceMin: freezed == priceMin - ? _value.priceMin - : priceMin // ignore: cast_nullable_to_non_nullable - as int?, - priceMax: freezed == priceMax - ? _value.priceMax - : priceMax // ignore: cast_nullable_to_non_nullable - as int?, - tag: freezed == tag - ? _value.tag - : tag // ignore: cast_nullable_to_non_nullable - as String?, - sort: freezed == sort - ? _value.sort - : sort // ignore: cast_nullable_to_non_nullable - as String?, - provinceCode: freezed == provinceCode - ? _value.provinceCode - : provinceCode // ignore: cast_nullable_to_non_nullable - as String?, - wardCode: freezed == wardCode - ? _value.wardCode - : wardCode // ignore: cast_nullable_to_non_nullable - as String?, - areaLabel: freezed == areaLabel - ? _value.areaLabel - : areaLabel // ignore: cast_nullable_to_non_nullable - as String?, - nearContactId: freezed == nearContactId - ? _value.nearContactId - : nearContactId // ignore: cast_nullable_to_non_nullable - as String?, - nearLabel: freezed == nearLabel - ? _value.nearLabel - : nearLabel // ignore: cast_nullable_to_non_nullable - as String?, - lat: freezed == lat - ? _value.lat - : lat // ignore: cast_nullable_to_non_nullable - as double?, - lon: freezed == lon - ? _value.lon - : lon // ignore: cast_nullable_to_non_nullable - as double?, - radiusKm: freezed == radiusKm - ? _value.radiusKm - : radiusKm // ignore: cast_nullable_to_non_nullable - as double?, - page: null == page - ? _value.page - : page // ignore: cast_nullable_to_non_nullable - as int, - size: null == size - ? _value.size - : size // ignore: cast_nullable_to_non_nullable - as int, - ), - ); - } + + +class _CatalogSearchFilters extends CatalogSearchFilters { + const _CatalogSearchFilters({this.keyword, this.categoryId, this.priceMin, this.priceMax, this.tag, this.sort, this.provinceCode, this.wardCode, this.areaLabel, this.nearContactId, this.nearLabel, this.lat, this.lon, this.radiusKm, this.page = 1, this.size = 20}): super._(); + + +@override final String? keyword; +@override final String? categoryId; +@override final int? priceMin; +@override final int? priceMax; +@override final String? tag; +@override final String? sort; +// Where to look: the listing's own snapshot of the seller's pickup address. +// Send the narrowest level meant — a ward is already inside its province. +// There is no district: Vietnam goes province to ward, so a listing's +// snapshot has no district code for one to be matched against. +@override final String? provinceCode; +@override final String? wardCode; +// Codes carry no name, so the chip needs the label the user picked. +@override final String? areaLabel; +// Where the buyer is. A saved contact is the usual answer; lat/lon is +// supported all the way down to the request but no screen sets it, since +// the app has no geolocation plugin. +@override final String? nearContactId; +@override final String? nearLabel; +@override final double? lat; +@override final double? lon; +@override final double? radiusKm; +@override@JsonKey() final int page; +@override@JsonKey() final int size; + +/// Create a copy of CatalogSearchFilters +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CatalogSearchFiltersCopyWith<_CatalogSearchFilters> get copyWith => __$CatalogSearchFiltersCopyWithImpl<_CatalogSearchFilters>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CatalogSearchFilters&&(identical(other.keyword, keyword) || other.keyword == keyword)&&(identical(other.categoryId, categoryId) || other.categoryId == categoryId)&&(identical(other.priceMin, priceMin) || other.priceMin == priceMin)&&(identical(other.priceMax, priceMax) || other.priceMax == priceMax)&&(identical(other.tag, tag) || other.tag == tag)&&(identical(other.sort, sort) || other.sort == sort)&&(identical(other.provinceCode, provinceCode) || other.provinceCode == provinceCode)&&(identical(other.wardCode, wardCode) || other.wardCode == wardCode)&&(identical(other.areaLabel, areaLabel) || other.areaLabel == areaLabel)&&(identical(other.nearContactId, nearContactId) || other.nearContactId == nearContactId)&&(identical(other.nearLabel, nearLabel) || other.nearLabel == nearLabel)&&(identical(other.lat, lat) || other.lat == lat)&&(identical(other.lon, lon) || other.lon == lon)&&(identical(other.radiusKm, radiusKm) || other.radiusKm == radiusKm)&&(identical(other.page, page) || other.page == page)&&(identical(other.size, size) || other.size == size)); +} + + +@override +int get hashCode => Object.hash(runtimeType,keyword,categoryId,priceMin,priceMax,tag,sort,provinceCode,wardCode,areaLabel,nearContactId,nearLabel,lat,lon,radiusKm,page,size); + +@override +String toString() { + return 'CatalogSearchFilters(keyword: $keyword, categoryId: $categoryId, priceMin: $priceMin, priceMax: $priceMax, tag: $tag, sort: $sort, provinceCode: $provinceCode, wardCode: $wardCode, areaLabel: $areaLabel, nearContactId: $nearContactId, nearLabel: $nearLabel, lat: $lat, lon: $lon, radiusKm: $radiusKm, page: $page, size: $size)'; +} + + } /// @nodoc +abstract mixin class _$CatalogSearchFiltersCopyWith<$Res> implements $CatalogSearchFiltersCopyWith<$Res> { + factory _$CatalogSearchFiltersCopyWith(_CatalogSearchFilters value, $Res Function(_CatalogSearchFilters) _then) = __$CatalogSearchFiltersCopyWithImpl; +@override @useResult +$Res call({ + String? keyword, String? categoryId, int? priceMin, int? priceMax, String? tag, String? sort, String? provinceCode, String? wardCode, String? areaLabel, String? nearContactId, String? nearLabel, double? lat, double? lon, double? radiusKm, int page, int size +}); + + + + +} +/// @nodoc +class __$CatalogSearchFiltersCopyWithImpl<$Res> + implements _$CatalogSearchFiltersCopyWith<$Res> { + __$CatalogSearchFiltersCopyWithImpl(this._self, this._then); + + final _CatalogSearchFilters _self; + final $Res Function(_CatalogSearchFilters) _then; + +/// Create a copy of CatalogSearchFilters +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? keyword = freezed,Object? categoryId = freezed,Object? priceMin = freezed,Object? priceMax = freezed,Object? tag = freezed,Object? sort = freezed,Object? provinceCode = freezed,Object? wardCode = freezed,Object? areaLabel = freezed,Object? nearContactId = freezed,Object? nearLabel = freezed,Object? lat = freezed,Object? lon = freezed,Object? radiusKm = freezed,Object? page = null,Object? size = null,}) { + return _then(_CatalogSearchFilters( +keyword: freezed == keyword ? _self.keyword : keyword // ignore: cast_nullable_to_non_nullable +as String?,categoryId: freezed == categoryId ? _self.categoryId : categoryId // ignore: cast_nullable_to_non_nullable +as String?,priceMin: freezed == priceMin ? _self.priceMin : priceMin // ignore: cast_nullable_to_non_nullable +as int?,priceMax: freezed == priceMax ? _self.priceMax : priceMax // ignore: cast_nullable_to_non_nullable +as int?,tag: freezed == tag ? _self.tag : tag // ignore: cast_nullable_to_non_nullable +as String?,sort: freezed == sort ? _self.sort : sort // ignore: cast_nullable_to_non_nullable +as String?,provinceCode: freezed == provinceCode ? _self.provinceCode : provinceCode // ignore: cast_nullable_to_non_nullable +as String?,wardCode: freezed == wardCode ? _self.wardCode : wardCode // ignore: cast_nullable_to_non_nullable +as String?,areaLabel: freezed == areaLabel ? _self.areaLabel : areaLabel // ignore: cast_nullable_to_non_nullable +as String?,nearContactId: freezed == nearContactId ? _self.nearContactId : nearContactId // ignore: cast_nullable_to_non_nullable +as String?,nearLabel: freezed == nearLabel ? _self.nearLabel : nearLabel // ignore: cast_nullable_to_non_nullable +as String?,lat: freezed == lat ? _self.lat : lat // ignore: cast_nullable_to_non_nullable +as double?,lon: freezed == lon ? _self.lon : lon // ignore: cast_nullable_to_non_nullable +as double?,radiusKm: freezed == radiusKm ? _self.radiusKm : radiusKm // ignore: cast_nullable_to_non_nullable +as double?,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,size: null == size ? _self.size : size // ignore: cast_nullable_to_non_nullable +as int, + )); +} + -class _$CatalogSearchFiltersImpl extends _CatalogSearchFilters { - const _$CatalogSearchFiltersImpl({ - this.keyword, - this.categoryId, - this.priceMin, - this.priceMax, - this.tag, - this.sort, - this.provinceCode, - this.wardCode, - this.areaLabel, - this.nearContactId, - this.nearLabel, - this.lat, - this.lon, - this.radiusKm, - this.page = 1, - this.size = 20, - }) : super._(); - - @override - final String? keyword; - @override - final String? categoryId; - @override - final int? priceMin; - @override - final int? priceMax; - @override - final String? tag; - @override - final String? sort; - // Where to look: the listing's own snapshot of the seller's pickup address. - // Send the narrowest level meant — a ward is already inside its province. - // There is no district: Vietnam goes province to ward, so a listing's - // snapshot has no district code for one to be matched against. - @override - final String? provinceCode; - @override - final String? wardCode; - // Codes carry no name, so the chip needs the label the user picked. - @override - final String? areaLabel; - // Where the buyer is. A saved contact is the usual answer; lat/lon is - // supported all the way down to the request but no screen sets it, since - // the app has no geolocation plugin. - @override - final String? nearContactId; - @override - final String? nearLabel; - @override - final double? lat; - @override - final double? lon; - @override - final double? radiusKm; - @override - @JsonKey() - final int page; - @override - @JsonKey() - final int size; - - @override - String toString() { - return 'CatalogSearchFilters(keyword: $keyword, categoryId: $categoryId, priceMin: $priceMin, priceMax: $priceMax, tag: $tag, sort: $sort, provinceCode: $provinceCode, wardCode: $wardCode, areaLabel: $areaLabel, nearContactId: $nearContactId, nearLabel: $nearLabel, lat: $lat, lon: $lon, radiusKm: $radiusKm, page: $page, size: $size)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CatalogSearchFiltersImpl && - (identical(other.keyword, keyword) || other.keyword == keyword) && - (identical(other.categoryId, categoryId) || - other.categoryId == categoryId) && - (identical(other.priceMin, priceMin) || - other.priceMin == priceMin) && - (identical(other.priceMax, priceMax) || - other.priceMax == priceMax) && - (identical(other.tag, tag) || other.tag == tag) && - (identical(other.sort, sort) || other.sort == sort) && - (identical(other.provinceCode, provinceCode) || - other.provinceCode == provinceCode) && - (identical(other.wardCode, wardCode) || - other.wardCode == wardCode) && - (identical(other.areaLabel, areaLabel) || - other.areaLabel == areaLabel) && - (identical(other.nearContactId, nearContactId) || - other.nearContactId == nearContactId) && - (identical(other.nearLabel, nearLabel) || - other.nearLabel == nearLabel) && - (identical(other.lat, lat) || other.lat == lat) && - (identical(other.lon, lon) || other.lon == lon) && - (identical(other.radiusKm, radiusKm) || - other.radiusKm == radiusKm) && - (identical(other.page, page) || other.page == page) && - (identical(other.size, size) || other.size == size)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - keyword, - categoryId, - priceMin, - priceMax, - tag, - sort, - provinceCode, - wardCode, - areaLabel, - nearContactId, - nearLabel, - lat, - lon, - radiusKm, - page, - size, - ); - - /// Create a copy of CatalogSearchFilters - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CatalogSearchFiltersImplCopyWith<_$CatalogSearchFiltersImpl> - get copyWith => - __$$CatalogSearchFiltersImplCopyWithImpl<_$CatalogSearchFiltersImpl>( - this, - _$identity, - ); -} - -abstract class _CatalogSearchFilters extends CatalogSearchFilters { - const factory _CatalogSearchFilters({ - final String? keyword, - final String? categoryId, - final int? priceMin, - final int? priceMax, - final String? tag, - final String? sort, - final String? provinceCode, - final String? wardCode, - final String? areaLabel, - final String? nearContactId, - final String? nearLabel, - final double? lat, - final double? lon, - final double? radiusKm, - final int page, - final int size, - }) = _$CatalogSearchFiltersImpl; - const _CatalogSearchFilters._() : super._(); - - @override - String? get keyword; - @override - String? get categoryId; - @override - int? get priceMin; - @override - int? get priceMax; - @override - String? get tag; - @override - String? get sort; // Where to look: the listing's own snapshot of the seller's pickup address. - // Send the narrowest level meant — a ward is already inside its province. - // There is no district: Vietnam goes province to ward, so a listing's - // snapshot has no district code for one to be matched against. - @override - String? get provinceCode; - @override - String? get wardCode; // Codes carry no name, so the chip needs the label the user picked. - @override - String? get areaLabel; // Where the buyer is. A saved contact is the usual answer; lat/lon is - // supported all the way down to the request but no screen sets it, since - // the app has no geolocation plugin. - @override - String? get nearContactId; - @override - String? get nearLabel; - @override - double? get lat; - @override - double? get lon; - @override - double? get radiusKm; - @override - int get page; - @override - int get size; - - /// Create a copy of CatalogSearchFilters - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CatalogSearchFiltersImplCopyWith<_$CatalogSearchFiltersImpl> - get copyWith => throw _privateConstructorUsedError; } /// @nodoc mixin _$CatalogProductsState { - List get products => throw _privateConstructorUsedError; - bool get hasMore => throw _privateConstructorUsedError; - bool get isLoadingMore => throw _privateConstructorUsedError; - CatalogSearchFilters get filters => throw _privateConstructorUsedError; - /// Create a copy of CatalogProductsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CatalogProductsStateCopyWith get copyWith => - throw _privateConstructorUsedError; + List get products; bool get hasMore; bool get isLoadingMore; CatalogSearchFilters get filters; +/// Create a copy of CatalogProductsState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CatalogProductsStateCopyWith get copyWith => _$CatalogProductsStateCopyWithImpl(this as CatalogProductsState, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CatalogProductsState&&const DeepCollectionEquality().equals(other.products, products)&&(identical(other.hasMore, hasMore) || other.hasMore == hasMore)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.filters, filters) || other.filters == filters)); } -/// @nodoc -abstract class $CatalogProductsStateCopyWith<$Res> { - factory $CatalogProductsStateCopyWith( - CatalogProductsState value, - $Res Function(CatalogProductsState) then, - ) = _$CatalogProductsStateCopyWithImpl<$Res, CatalogProductsState>; - @useResult - $Res call({ - List products, - bool hasMore, - bool isLoadingMore, - CatalogSearchFilters filters, - }); - $CatalogSearchFiltersCopyWith<$Res> get filters; +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(products),hasMore,isLoadingMore,filters); + +@override +String toString() { + return 'CatalogProductsState(products: $products, hasMore: $hasMore, isLoadingMore: $isLoadingMore, filters: $filters)'; } -/// @nodoc -class _$CatalogProductsStateCopyWithImpl< - $Res, - $Val extends CatalogProductsState -> - implements $CatalogProductsStateCopyWith<$Res> { - _$CatalogProductsStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CatalogProductsState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? products = null, - Object? hasMore = null, - Object? isLoadingMore = null, - Object? filters = null, - }) { - return _then( - _value.copyWith( - products: null == products - ? _value.products - : products // ignore: cast_nullable_to_non_nullable - as List, - hasMore: null == hasMore - ? _value.hasMore - : hasMore // ignore: cast_nullable_to_non_nullable - as bool, - isLoadingMore: null == isLoadingMore - ? _value.isLoadingMore - : isLoadingMore // ignore: cast_nullable_to_non_nullable - as bool, - filters: null == filters - ? _value.filters - : filters // ignore: cast_nullable_to_non_nullable - as CatalogSearchFilters, - ) - as $Val, - ); - } - - /// Create a copy of CatalogProductsState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $CatalogSearchFiltersCopyWith<$Res> get filters { - return $CatalogSearchFiltersCopyWith<$Res>(_value.filters, (value) { - return _then(_value.copyWith(filters: value) as $Val); - }); - } + } /// @nodoc -abstract class _$$CatalogProductsStateImplCopyWith<$Res> +abstract mixin class $CatalogProductsStateCopyWith<$Res> { + factory $CatalogProductsStateCopyWith(CatalogProductsState value, $Res Function(CatalogProductsState) _then) = _$CatalogProductsStateCopyWithImpl; +@useResult +$Res call({ + List products, bool hasMore, bool isLoadingMore, CatalogSearchFilters filters +}); + + +$CatalogSearchFiltersCopyWith<$Res> get filters; + +} +/// @nodoc +class _$CatalogProductsStateCopyWithImpl<$Res> implements $CatalogProductsStateCopyWith<$Res> { - factory _$$CatalogProductsStateImplCopyWith( - _$CatalogProductsStateImpl value, - $Res Function(_$CatalogProductsStateImpl) then, - ) = __$$CatalogProductsStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - List products, - bool hasMore, - bool isLoadingMore, - CatalogSearchFilters filters, + _$CatalogProductsStateCopyWithImpl(this._self, this._then); + + final CatalogProductsState _self; + final $Res Function(CatalogProductsState) _then; + +/// Create a copy of CatalogProductsState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? products = null,Object? hasMore = null,Object? isLoadingMore = null,Object? filters = null,}) { + return _then(_self.copyWith( +products: null == products ? _self.products : products // ignore: cast_nullable_to_non_nullable +as List,hasMore: null == hasMore ? _self.hasMore : hasMore // ignore: cast_nullable_to_non_nullable +as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool,filters: null == filters ? _self.filters : filters // ignore: cast_nullable_to_non_nullable +as CatalogSearchFilters, + )); +} +/// Create a copy of CatalogProductsState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CatalogSearchFiltersCopyWith<$Res> get filters { + + return $CatalogSearchFiltersCopyWith<$Res>(_self.filters, (value) { + return _then(_self.copyWith(filters: value)); }); +} +} + + +/// Adds pattern-matching-related methods to [CatalogProductsState]. +extension CatalogProductsStatePatterns on CatalogProductsState { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _CatalogProductsState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CatalogProductsState() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _CatalogProductsState value) $default,){ +final _that = this; +switch (_that) { +case _CatalogProductsState(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _CatalogProductsState value)? $default,){ +final _that = this; +switch (_that) { +case _CatalogProductsState() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( List products, bool hasMore, bool isLoadingMore, CatalogSearchFilters filters)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CatalogProductsState() when $default != null: +return $default(_that.products,_that.hasMore,_that.isLoadingMore,_that.filters);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( List products, bool hasMore, bool isLoadingMore, CatalogSearchFilters filters) $default,) {final _that = this; +switch (_that) { +case _CatalogProductsState(): +return $default(_that.products,_that.hasMore,_that.isLoadingMore,_that.filters);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( List products, bool hasMore, bool isLoadingMore, CatalogSearchFilters filters)? $default,) {final _that = this; +switch (_that) { +case _CatalogProductsState() when $default != null: +return $default(_that.products,_that.hasMore,_that.isLoadingMore,_that.filters);case _: + return null; + +} +} - @override - $CatalogSearchFiltersCopyWith<$Res> get filters; } /// @nodoc -class __$$CatalogProductsStateImplCopyWithImpl<$Res> - extends _$CatalogProductsStateCopyWithImpl<$Res, _$CatalogProductsStateImpl> - implements _$$CatalogProductsStateImplCopyWith<$Res> { - __$$CatalogProductsStateImplCopyWithImpl( - _$CatalogProductsStateImpl _value, - $Res Function(_$CatalogProductsStateImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CatalogProductsState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? products = null, - Object? hasMore = null, - Object? isLoadingMore = null, - Object? filters = null, - }) { - return _then( - _$CatalogProductsStateImpl( - products: null == products - ? _value._products - : products // ignore: cast_nullable_to_non_nullable - as List, - hasMore: null == hasMore - ? _value.hasMore - : hasMore // ignore: cast_nullable_to_non_nullable - as bool, - isLoadingMore: null == isLoadingMore - ? _value.isLoadingMore - : isLoadingMore // ignore: cast_nullable_to_non_nullable - as bool, - filters: null == filters - ? _value.filters - : filters // ignore: cast_nullable_to_non_nullable - as CatalogSearchFilters, - ), - ); - } + + +class _CatalogProductsState implements CatalogProductsState { + const _CatalogProductsState({required final List products, required this.hasMore, required this.isLoadingMore, required this.filters}): _products = products; + + + final List _products; +@override List get products { + if (_products is EqualUnmodifiableListView) return _products; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_products); } +@override final bool hasMore; +@override final bool isLoadingMore; +@override final CatalogSearchFilters filters; + +/// Create a copy of CatalogProductsState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CatalogProductsStateCopyWith<_CatalogProductsState> get copyWith => __$CatalogProductsStateCopyWithImpl<_CatalogProductsState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CatalogProductsState&&const DeepCollectionEquality().equals(other._products, _products)&&(identical(other.hasMore, hasMore) || other.hasMore == hasMore)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.filters, filters) || other.filters == filters)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_products),hasMore,isLoadingMore,filters); + +@override +String toString() { + return 'CatalogProductsState(products: $products, hasMore: $hasMore, isLoadingMore: $isLoadingMore, filters: $filters)'; +} + + +} + +/// @nodoc +abstract mixin class _$CatalogProductsStateCopyWith<$Res> implements $CatalogProductsStateCopyWith<$Res> { + factory _$CatalogProductsStateCopyWith(_CatalogProductsState value, $Res Function(_CatalogProductsState) _then) = __$CatalogProductsStateCopyWithImpl; +@override @useResult +$Res call({ + List products, bool hasMore, bool isLoadingMore, CatalogSearchFilters filters +}); + + +@override $CatalogSearchFiltersCopyWith<$Res> get filters; + +} /// @nodoc +class __$CatalogProductsStateCopyWithImpl<$Res> + implements _$CatalogProductsStateCopyWith<$Res> { + __$CatalogProductsStateCopyWithImpl(this._self, this._then); + + final _CatalogProductsState _self; + final $Res Function(_CatalogProductsState) _then; + +/// Create a copy of CatalogProductsState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? products = null,Object? hasMore = null,Object? isLoadingMore = null,Object? filters = null,}) { + return _then(_CatalogProductsState( +products: null == products ? _self._products : products // ignore: cast_nullable_to_non_nullable +as List,hasMore: null == hasMore ? _self.hasMore : hasMore // ignore: cast_nullable_to_non_nullable +as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool,filters: null == filters ? _self.filters : filters // ignore: cast_nullable_to_non_nullable +as CatalogSearchFilters, + )); +} -class _$CatalogProductsStateImpl implements _CatalogProductsState { - const _$CatalogProductsStateImpl({ - required final List products, - required this.hasMore, - required this.isLoadingMore, - required this.filters, - }) : _products = products; - - final List _products; - @override - List get products { - if (_products is EqualUnmodifiableListView) return _products; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_products); - } - - @override - final bool hasMore; - @override - final bool isLoadingMore; - @override - final CatalogSearchFilters filters; - - @override - String toString() { - return 'CatalogProductsState(products: $products, hasMore: $hasMore, isLoadingMore: $isLoadingMore, filters: $filters)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CatalogProductsStateImpl && - const DeepCollectionEquality().equals(other._products, _products) && - (identical(other.hasMore, hasMore) || other.hasMore == hasMore) && - (identical(other.isLoadingMore, isLoadingMore) || - other.isLoadingMore == isLoadingMore) && - (identical(other.filters, filters) || other.filters == filters)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_products), - hasMore, - isLoadingMore, - filters, - ); - - /// Create a copy of CatalogProductsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CatalogProductsStateImplCopyWith<_$CatalogProductsStateImpl> - get copyWith => - __$$CatalogProductsStateImplCopyWithImpl<_$CatalogProductsStateImpl>( - this, - _$identity, - ); -} - -abstract class _CatalogProductsState implements CatalogProductsState { - const factory _CatalogProductsState({ - required final List products, - required final bool hasMore, - required final bool isLoadingMore, - required final CatalogSearchFilters filters, - }) = _$CatalogProductsStateImpl; - - @override - List get products; - @override - bool get hasMore; - @override - bool get isLoadingMore; - @override - CatalogSearchFilters get filters; - - /// Create a copy of CatalogProductsState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CatalogProductsStateImplCopyWith<_$CatalogProductsStateImpl> - get copyWith => throw _privateConstructorUsedError; +/// Create a copy of CatalogProductsState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CatalogSearchFiltersCopyWith<$Res> get filters { + + return $CatalogSearchFiltersCopyWith<$Res>(_self.filters, (value) { + return _then(_self.copyWith(filters: value)); + }); +} } /// @nodoc mixin _$ProductReviewsState { - List get reviews => throw _privateConstructorUsedError; - String? get nextCursor => throw _privateConstructorUsedError; - bool get isLoadingMore => throw _privateConstructorUsedError; - /// Create a copy of ProductReviewsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ProductReviewsStateCopyWith get copyWith => - throw _privateConstructorUsedError; + List get reviews; String? get nextCursor; bool get isLoadingMore; +/// Create a copy of ProductReviewsState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ProductReviewsStateCopyWith get copyWith => _$ProductReviewsStateCopyWithImpl(this as ProductReviewsState, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ProductReviewsState&&const DeepCollectionEquality().equals(other.reviews, reviews)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)); } -/// @nodoc -abstract class $ProductReviewsStateCopyWith<$Res> { - factory $ProductReviewsStateCopyWith( - ProductReviewsState value, - $Res Function(ProductReviewsState) then, - ) = _$ProductReviewsStateCopyWithImpl<$Res, ProductReviewsState>; - @useResult - $Res call({List reviews, String? nextCursor, bool isLoadingMore}); + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(reviews),nextCursor,isLoadingMore); + +@override +String toString() { + return 'ProductReviewsState(reviews: $reviews, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore)'; } -/// @nodoc -class _$ProductReviewsStateCopyWithImpl<$Res, $Val extends ProductReviewsState> - implements $ProductReviewsStateCopyWith<$Res> { - _$ProductReviewsStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of ProductReviewsState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? reviews = null, - Object? nextCursor = freezed, - Object? isLoadingMore = null, - }) { - return _then( - _value.copyWith( - reviews: null == reviews - ? _value.reviews - : reviews // ignore: cast_nullable_to_non_nullable - as List, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - isLoadingMore: null == isLoadingMore - ? _value.isLoadingMore - : isLoadingMore // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$ProductReviewsStateImplCopyWith<$Res> +abstract mixin class $ProductReviewsStateCopyWith<$Res> { + factory $ProductReviewsStateCopyWith(ProductReviewsState value, $Res Function(ProductReviewsState) _then) = _$ProductReviewsStateCopyWithImpl; +@useResult +$Res call({ + List reviews, String? nextCursor, bool isLoadingMore +}); + + + + +} +/// @nodoc +class _$ProductReviewsStateCopyWithImpl<$Res> implements $ProductReviewsStateCopyWith<$Res> { - factory _$$ProductReviewsStateImplCopyWith( - _$ProductReviewsStateImpl value, - $Res Function(_$ProductReviewsStateImpl) then, - ) = __$$ProductReviewsStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({List reviews, String? nextCursor, bool isLoadingMore}); + _$ProductReviewsStateCopyWithImpl(this._self, this._then); + + final ProductReviewsState _self; + final $Res Function(ProductReviewsState) _then; + +/// Create a copy of ProductReviewsState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? reviews = null,Object? nextCursor = freezed,Object? isLoadingMore = null,}) { + return _then(_self.copyWith( +reviews: null == reviews ? _self.reviews : reviews // ignore: cast_nullable_to_non_nullable +as List,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ProductReviewsState]. +extension ProductReviewsStatePatterns on ProductReviewsState { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _ProductReviewsState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ProductReviewsState() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _ProductReviewsState value) $default,){ +final _that = this; +switch (_that) { +case _ProductReviewsState(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ProductReviewsState value)? $default,){ +final _that = this; +switch (_that) { +case _ProductReviewsState() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( List reviews, String? nextCursor, bool isLoadingMore)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ProductReviewsState() when $default != null: +return $default(_that.reviews,_that.nextCursor,_that.isLoadingMore);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( List reviews, String? nextCursor, bool isLoadingMore) $default,) {final _that = this; +switch (_that) { +case _ProductReviewsState(): +return $default(_that.reviews,_that.nextCursor,_that.isLoadingMore);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( List reviews, String? nextCursor, bool isLoadingMore)? $default,) {final _that = this; +switch (_that) { +case _ProductReviewsState() when $default != null: +return $default(_that.reviews,_that.nextCursor,_that.isLoadingMore);case _: + return null; + +} +} + } /// @nodoc -class __$$ProductReviewsStateImplCopyWithImpl<$Res> - extends _$ProductReviewsStateCopyWithImpl<$Res, _$ProductReviewsStateImpl> - implements _$$ProductReviewsStateImplCopyWith<$Res> { - __$$ProductReviewsStateImplCopyWithImpl( - _$ProductReviewsStateImpl _value, - $Res Function(_$ProductReviewsStateImpl) _then, - ) : super(_value, _then); - - /// Create a copy of ProductReviewsState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? reviews = null, - Object? nextCursor = freezed, - Object? isLoadingMore = null, - }) { - return _then( - _$ProductReviewsStateImpl( - reviews: null == reviews - ? _value._reviews - : reviews // ignore: cast_nullable_to_non_nullable - as List, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - isLoadingMore: null == isLoadingMore - ? _value.isLoadingMore - : isLoadingMore // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } + + +class _ProductReviewsState extends ProductReviewsState { + const _ProductReviewsState({required final List reviews, this.nextCursor, this.isLoadingMore = false}): _reviews = reviews,super._(); + + + final List _reviews; +@override List get reviews { + if (_reviews is EqualUnmodifiableListView) return _reviews; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_reviews); +} + +@override final String? nextCursor; +@override@JsonKey() final bool isLoadingMore; + +/// Create a copy of ProductReviewsState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ProductReviewsStateCopyWith<_ProductReviewsState> get copyWith => __$ProductReviewsStateCopyWithImpl<_ProductReviewsState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ProductReviewsState&&const DeepCollectionEquality().equals(other._reviews, _reviews)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_reviews),nextCursor,isLoadingMore); + +@override +String toString() { + return 'ProductReviewsState(reviews: $reviews, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore)'; +} + + } /// @nodoc +abstract mixin class _$ProductReviewsStateCopyWith<$Res> implements $ProductReviewsStateCopyWith<$Res> { + factory _$ProductReviewsStateCopyWith(_ProductReviewsState value, $Res Function(_ProductReviewsState) _then) = __$ProductReviewsStateCopyWithImpl; +@override @useResult +$Res call({ + List reviews, String? nextCursor, bool isLoadingMore +}); + + + -class _$ProductReviewsStateImpl extends _ProductReviewsState { - const _$ProductReviewsStateImpl({ - required final List reviews, - this.nextCursor, - this.isLoadingMore = false, - }) : _reviews = reviews, - super._(); - - final List _reviews; - @override - List get reviews { - if (_reviews is EqualUnmodifiableListView) return _reviews; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_reviews); - } - - @override - final String? nextCursor; - @override - @JsonKey() - final bool isLoadingMore; - - @override - String toString() { - return 'ProductReviewsState(reviews: $reviews, nextCursor: $nextCursor, isLoadingMore: $isLoadingMore)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ProductReviewsStateImpl && - const DeepCollectionEquality().equals(other._reviews, _reviews) && - (identical(other.nextCursor, nextCursor) || - other.nextCursor == nextCursor) && - (identical(other.isLoadingMore, isLoadingMore) || - other.isLoadingMore == isLoadingMore)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_reviews), - nextCursor, - isLoadingMore, - ); - - /// Create a copy of ProductReviewsState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ProductReviewsStateImplCopyWith<_$ProductReviewsStateImpl> get copyWith => - __$$ProductReviewsStateImplCopyWithImpl<_$ProductReviewsStateImpl>( - this, - _$identity, - ); -} - -abstract class _ProductReviewsState extends ProductReviewsState { - const factory _ProductReviewsState({ - required final List reviews, - final String? nextCursor, - final bool isLoadingMore, - }) = _$ProductReviewsStateImpl; - const _ProductReviewsState._() : super._(); - - @override - List get reviews; - @override - String? get nextCursor; - @override - bool get isLoadingMore; - - /// Create a copy of ProductReviewsState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ProductReviewsStateImplCopyWith<_$ProductReviewsStateImpl> get copyWith => - throw _privateConstructorUsedError; } +/// @nodoc +class __$ProductReviewsStateCopyWithImpl<$Res> + implements _$ProductReviewsStateCopyWith<$Res> { + __$ProductReviewsStateCopyWithImpl(this._self, this._then); + + final _ProductReviewsState _self; + final $Res Function(_ProductReviewsState) _then; + +/// Create a copy of ProductReviewsState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? reviews = null,Object? nextCursor = freezed,Object? isLoadingMore = null,}) { + return _then(_ProductReviewsState( +reviews: null == reviews ? _self._reviews : reviews // ignore: cast_nullable_to_non_nullable +as List,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/features/catalog/presentation/providers/catalog_provider.g.dart b/lib/features/catalog/presentation/providers/catalog_provider.g.dart index 15c20ad..aafb44c 100644 --- a/lib/features/catalog/presentation/providers/catalog_provider.g.dart +++ b/lib/features/catalog/presentation/providers/catalog_provider.g.dart @@ -6,534 +6,516 @@ part of 'catalog_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$categoriesHash() => r'31469ca72056a492cb943427ab921b7eaf6fea87'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [categories]. @ProviderFor(categories) -final categoriesProvider = AutoDisposeFutureProvider>.internal( - categories, - name: r'categoriesProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$categoriesHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CategoriesRef = AutoDisposeFutureProviderRef>; -String _$productDetailHash() => r'3294526819909b4400afac89936d07159019638e'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } - - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } -} - -/// See also [productDetail]. -@ProviderFor(productDetail) -const productDetailProvider = ProductDetailFamily(); - -/// See also [productDetail]. -class ProductDetailFamily extends Family> { - /// See also [productDetail]. - const ProductDetailFamily(); - - /// See also [productDetail]. - ProductDetailProvider call({required String id}) { - return ProductDetailProvider(id: id); - } +const categoriesProvider = CategoriesProvider._(); - @override - ProductDetailProvider getProviderOverride( - covariant ProductDetailProvider provider, - ) { - return call(id: provider.id); - } - - static const Iterable? _dependencies = null; +final class CategoriesProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with $FutureModifier>, $FutureProvider> { + const CategoriesProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'categoriesProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; + String debugGetCreateSourceHash() => _$categoriesHash(); + @$internal @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); @override - String? get name => r'productDetailProvider'; + FutureOr> create(Ref ref) { + return categories(ref); + } } -/// See also [productDetail]. -class ProductDetailProvider extends AutoDisposeFutureProvider { - /// See also [productDetail]. - ProductDetailProvider({required String id}) - : this._internal( - (ref) => productDetail(ref as ProductDetailRef, id: id), - from: productDetailProvider, - name: r'productDetailProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$productDetailHash, - dependencies: ProductDetailFamily._dependencies, - allTransitiveDependencies: - ProductDetailFamily._allTransitiveDependencies, - id: id, - ); +String _$categoriesHash() => r'31469ca72056a492cb943427ab921b7eaf6fea87'; - ProductDetailProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.id, - }) : super.internal(); +@ProviderFor(CatalogProducts) +const catalogProductsProvider = CatalogProductsFamily._(); + +final class CatalogProductsProvider + extends $AsyncNotifierProvider { + const CatalogProductsProvider._({ + required CatalogProductsFamily super.from, + required CatalogSearchFilters super.argument, + }) : super( + retry: null, + name: r'catalogProductsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); - final String id; + @override + String debugGetCreateSourceHash() => _$catalogProductsHash(); @override - Override overrideWith( - FutureOr Function(ProductDetailRef provider) create, - ) { - return ProviderOverride( - origin: this, - override: ProductDetailProvider._internal( - (ref) => create(ref as ProductDetailRef), - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - id: id, - ), - ); + String toString() { + return r'catalogProductsProvider' + '' + '($argument)'; } + @$internal @override - AutoDisposeFutureProviderElement createElement() { - return _ProductDetailProviderElement(this); - } + CatalogProducts create() => CatalogProducts(); @override bool operator ==(Object other) { - return other is ProductDetailProvider && other.id == id; + return other is CatalogProductsProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, id.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin ProductDetailRef on AutoDisposeFutureProviderRef { - /// The parameter `id` of this provider. - String get id; -} +String _$catalogProductsHash() => r'49701f5618318de28cf53ee6d59eb7bd73752387'; -class _ProductDetailProviderElement - extends AutoDisposeFutureProviderElement - with ProductDetailRef { - _ProductDetailProviderElement(super.provider); +final class CatalogProductsFamily extends $Family + with + $ClassFamilyOverride< + CatalogProducts, + AsyncValue, + CatalogProductsState, + FutureOr, + CatalogSearchFilters + > { + const CatalogProductsFamily._() + : super( + retry: null, + name: r'catalogProductsProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + CatalogProductsProvider call(CatalogSearchFilters initialFilters) => + CatalogProductsProvider._(argument: initialFilters, from: this); @override - String get id => (origin as ProductDetailProvider).id; + String toString() => r'catalogProductsProvider'; } -String _$recentlyViewedProductsHash() => - r'68c7dc7488a27863e028794280585cd3046ddbdc'; - -/// See also [recentlyViewedProducts]. -@ProviderFor(recentlyViewedProducts) -final recentlyViewedProductsProvider = - AutoDisposeFutureProvider>.internal( - recentlyViewedProducts, - name: r'recentlyViewedProductsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$recentlyViewedProductsHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef RecentlyViewedProductsRef = - AutoDisposeFutureProviderRef>; -String _$catalogProductsHash() => r'49701f5618318de28cf53ee6d59eb7bd73752387'; - -abstract class _$CatalogProducts - extends BuildlessAutoDisposeAsyncNotifier { - late final CatalogSearchFilters initialFilters; +abstract class _$CatalogProducts extends $AsyncNotifier { + late final _$args = ref.$arg as CatalogSearchFilters; + CatalogSearchFilters get initialFilters => _$args; FutureOr build(CatalogSearchFilters initialFilters); + @$mustCallSuper + @override + void runBuild() { + final created = build(_$args); + final ref = + this.ref + as $Ref, CatalogProductsState>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier< + AsyncValue, + CatalogProductsState + >, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, created); + } } -/// See also [CatalogProducts]. -@ProviderFor(CatalogProducts) -const catalogProductsProvider = CatalogProductsFamily(); +/// `keepAlive` vì cùng lý do với `checkoutProvider`: bộ lọc được **đặt ở một màn +/// và đọc ở màn khác**. +/// +/// Trang Danh mục gọi `setCategory(id)` rồi `context.push('/search')`. Ở chế độ +/// autoDispose, không widget nào watch provider trong khoảng giữa hai câu đó, nên +/// nó bị bỏ đi và màn tìm kiếm mở ra với `categoryId` null — chạm vào một danh mục +/// cho ra *toàn bộ* sàn. +/// +/// Bộ lọc còn lại giữa hai lần vào là chấp nhận được: trang Danh mục luôn gọi +/// `reset()` ngay trước khi đặt, nên đường vào đó luôn sạch, còn người vào thẳng +/// `/search` thường muốn thấy lại lần tìm trước. -/// See also [CatalogProducts]. -class CatalogProductsFamily extends Family> { - /// See also [CatalogProducts]. - const CatalogProductsFamily(); +@ProviderFor(ActiveSearchFilters) +const activeSearchFiltersProvider = ActiveSearchFiltersProvider._(); - /// See also [CatalogProducts]. - CatalogProductsProvider call(CatalogSearchFilters initialFilters) { - return CatalogProductsProvider(initialFilters); - } +/// `keepAlive` vì cùng lý do với `checkoutProvider`: bộ lọc được **đặt ở một màn +/// và đọc ở màn khác**. +/// +/// Trang Danh mục gọi `setCategory(id)` rồi `context.push('/search')`. Ở chế độ +/// autoDispose, không widget nào watch provider trong khoảng giữa hai câu đó, nên +/// nó bị bỏ đi và màn tìm kiếm mở ra với `categoryId` null — chạm vào một danh mục +/// cho ra *toàn bộ* sàn. +/// +/// Bộ lọc còn lại giữa hai lần vào là chấp nhận được: trang Danh mục luôn gọi +/// `reset()` ngay trước khi đặt, nên đường vào đó luôn sạch, còn người vào thẳng +/// `/search` thường muốn thấy lại lần tìm trước. +final class ActiveSearchFiltersProvider + extends $NotifierProvider { + /// `keepAlive` vì cùng lý do với `checkoutProvider`: bộ lọc được **đặt ở một màn + /// và đọc ở màn khác**. + /// + /// Trang Danh mục gọi `setCategory(id)` rồi `context.push('/search')`. Ở chế độ + /// autoDispose, không widget nào watch provider trong khoảng giữa hai câu đó, nên + /// nó bị bỏ đi và màn tìm kiếm mở ra với `categoryId` null — chạm vào một danh mục + /// cho ra *toàn bộ* sàn. + /// + /// Bộ lọc còn lại giữa hai lần vào là chấp nhận được: trang Danh mục luôn gọi + /// `reset()` ngay trước khi đặt, nên đường vào đó luôn sạch, còn người vào thẳng + /// `/search` thường muốn thấy lại lần tìm trước. + const ActiveSearchFiltersProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'activeSearchFiltersProvider', + isAutoDispose: false, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - CatalogProductsProvider getProviderOverride( - covariant CatalogProductsProvider provider, - ) { - return call(provider.initialFilters); - } - - static const Iterable? _dependencies = null; + String debugGetCreateSourceHash() => _$activeSearchFiltersHash(); + @$internal @override - Iterable? get dependencies => _dependencies; + ActiveSearchFilters create() => ActiveSearchFilters(); - static const Iterable? _allTransitiveDependencies = null; + /// {@macro riverpod.override_with_value} + Override overrideWithValue(CatalogSearchFilters value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} - @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; +String _$activeSearchFiltersHash() => + r'5709d504e5839866bba7bdfa5e39b2e5487f31c8'; +/// `keepAlive` vì cùng lý do với `checkoutProvider`: bộ lọc được **đặt ở một màn +/// và đọc ở màn khác**. +/// +/// Trang Danh mục gọi `setCategory(id)` rồi `context.push('/search')`. Ở chế độ +/// autoDispose, không widget nào watch provider trong khoảng giữa hai câu đó, nên +/// nó bị bỏ đi và màn tìm kiếm mở ra với `categoryId` null — chạm vào một danh mục +/// cho ra *toàn bộ* sàn. +/// +/// Bộ lọc còn lại giữa hai lần vào là chấp nhận được: trang Danh mục luôn gọi +/// `reset()` ngay trước khi đặt, nên đường vào đó luôn sạch, còn người vào thẳng +/// `/search` thường muốn thấy lại lần tìm trước. + +abstract class _$ActiveSearchFilters extends $Notifier { + CatalogSearchFilters build(); + @$mustCallSuper @override - String? get name => r'catalogProductsProvider'; + void runBuild() { + final created = build(); + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + CatalogSearchFilters, + Object?, + Object? + >; + element.handleValue(ref, created); + } } -/// See also [CatalogProducts]. -class CatalogProductsProvider - extends - AutoDisposeAsyncNotifierProviderImpl< - CatalogProducts, - CatalogProductsState - > { - /// See also [CatalogProducts]. - CatalogProductsProvider(CatalogSearchFilters initialFilters) - : this._internal( - () => CatalogProducts()..initialFilters = initialFilters, - from: catalogProductsProvider, - name: r'catalogProductsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$catalogProductsHash, - dependencies: CatalogProductsFamily._dependencies, - allTransitiveDependencies: - CatalogProductsFamily._allTransitiveDependencies, - initialFilters: initialFilters, - ); +@ProviderFor(productDetail) +const productDetailProvider = ProductDetailFamily._(); - CatalogProductsProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.initialFilters, - }) : super.internal(); +final class ProductDetailProvider + extends + $FunctionalProvider< + AsyncValue, + ListingDetail, + FutureOr + > + with $FutureModifier, $FutureProvider { + const ProductDetailProvider._({ + required ProductDetailFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'productDetailProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); - final CatalogSearchFilters initialFilters; + @override + String debugGetCreateSourceHash() => _$productDetailHash(); @override - FutureOr runNotifierBuild( - covariant CatalogProducts notifier, - ) { - return notifier.build(initialFilters); + String toString() { + return r'productDetailProvider' + '' + '($argument)'; } + @$internal @override - Override overrideWith(CatalogProducts Function() create) { - return ProviderOverride( - origin: this, - override: CatalogProductsProvider._internal( - () => create()..initialFilters = initialFilters, - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - initialFilters: initialFilters, - ), - ); - } + $FutureProviderElement $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); @override - AutoDisposeAsyncNotifierProviderElement - createElement() { - return _CatalogProductsProviderElement(this); + FutureOr create(Ref ref) { + final argument = this.argument as String; + return productDetail(ref, id: argument); } @override bool operator ==(Object other) { - return other is CatalogProductsProvider && - other.initialFilters == initialFilters; + return other is ProductDetailProvider && other.argument == argument; } @override int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, initialFilters.hashCode); - - return _SystemHash.finish(hash); + return argument.hashCode; } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin CatalogProductsRef - on AutoDisposeAsyncNotifierProviderRef { - /// The parameter `initialFilters` of this provider. - CatalogSearchFilters get initialFilters; -} - -class _CatalogProductsProviderElement - extends - AutoDisposeAsyncNotifierProviderElement< - CatalogProducts, - CatalogProductsState - > - with CatalogProductsRef { - _CatalogProductsProviderElement(super.provider); - - @override - CatalogSearchFilters get initialFilters => - (origin as CatalogProductsProvider).initialFilters; -} - -String _$activeSearchFiltersHash() => - r'5709d504e5839866bba7bdfa5e39b2e5487f31c8'; - -/// `keepAlive` vì cùng lý do với `checkoutProvider`: bộ lọc được **đặt ở một màn -/// và đọc ở màn khác**. -/// -/// Trang Danh mục gọi `setCategory(id)` rồi `context.push('/search')`. Ở chế độ -/// autoDispose, không widget nào watch provider trong khoảng giữa hai câu đó, nên -/// nó bị bỏ đi và màn tìm kiếm mở ra với `categoryId` null — chạm vào một danh mục -/// cho ra *toàn bộ* sàn. -/// -/// Bộ lọc còn lại giữa hai lần vào là chấp nhận được: trang Danh mục luôn gọi -/// `reset()` ngay trước khi đặt, nên đường vào đó luôn sạch, còn người vào thẳng -/// `/search` thường muốn thấy lại lần tìm trước. -/// -/// Copied from [ActiveSearchFilters]. -@ProviderFor(ActiveSearchFilters) -final activeSearchFiltersProvider = - NotifierProvider.internal( - ActiveSearchFilters.new, - name: r'activeSearchFiltersProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$activeSearchFiltersHash, - dependencies: null, - allTransitiveDependencies: null, - ); +String _$productDetailHash() => r'3294526819909b4400afac89936d07159019638e'; -typedef _$ActiveSearchFilters = Notifier; -String _$productReviewsHash() => r'1678606e6adade1ec2e4da8cbbd749035b86acfc'; +final class ProductDetailFamily extends $Family + with $FunctionalFamilyOverride, String> { + const ProductDetailFamily._() + : super( + retry: null, + name: r'productDetailProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); -abstract class _$ProductReviews - extends BuildlessAutoDisposeAsyncNotifier { - late final String listingId; + ProductDetailProvider call({required String id}) => + ProductDetailProvider._(argument: id, from: this); - FutureOr build(String listingId); + @override + String toString() => r'productDetailProvider'; } /// Reviews are cursor-paginated, so "show more" carries the cursor the last page /// ended on — a page number would re-read rows a new review has already shifted. -/// -/// Copied from [ProductReviews]. + @ProviderFor(ProductReviews) -const productReviewsProvider = ProductReviewsFamily(); +const productReviewsProvider = ProductReviewsFamily._(); /// Reviews are cursor-paginated, so "show more" carries the cursor the last page /// ended on — a page number would re-read rows a new review has already shifted. -/// -/// Copied from [ProductReviews]. -class ProductReviewsFamily extends Family> { +final class ProductReviewsProvider + extends $AsyncNotifierProvider { /// Reviews are cursor-paginated, so "show more" carries the cursor the last page /// ended on — a page number would re-read rows a new review has already shifted. - /// - /// Copied from [ProductReviews]. - const ProductReviewsFamily(); + const ProductReviewsProvider._({ + required ProductReviewsFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'productReviewsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// Reviews are cursor-paginated, so "show more" carries the cursor the last page - /// ended on — a page number would re-read rows a new review has already shifted. - /// - /// Copied from [ProductReviews]. - ProductReviewsProvider call(String listingId) { - return ProductReviewsProvider(listingId); - } + @override + String debugGetCreateSourceHash() => _$productReviewsHash(); @override - ProductReviewsProvider getProviderOverride( - covariant ProductReviewsProvider provider, - ) { - return call(provider.listingId); + String toString() { + return r'productReviewsProvider' + '' + '($argument)'; } - static const Iterable? _dependencies = null; - + @$internal @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; + ProductReviews create() => ProductReviews(); @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; + bool operator ==(Object other) { + return other is ProductReviewsProvider && other.argument == argument; + } @override - String? get name => r'productReviewsProvider'; + int get hashCode { + return argument.hashCode; + } } +String _$productReviewsHash() => r'1678606e6adade1ec2e4da8cbbd749035b86acfc'; + /// Reviews are cursor-paginated, so "show more" carries the cursor the last page /// ended on — a page number would re-read rows a new review has already shifted. -/// -/// Copied from [ProductReviews]. -class ProductReviewsProvider - extends - AutoDisposeAsyncNotifierProviderImpl< + +final class ProductReviewsFamily extends $Family + with + $ClassFamilyOverride< ProductReviews, - ProductReviewsState + AsyncValue, + ProductReviewsState, + FutureOr, + String > { - /// Reviews are cursor-paginated, so "show more" carries the cursor the last page - /// ended on — a page number would re-read rows a new review has already shifted. - /// - /// Copied from [ProductReviews]. - ProductReviewsProvider(String listingId) - : this._internal( - () => ProductReviews()..listingId = listingId, - from: productReviewsProvider, + const ProductReviewsFamily._() + : super( + retry: null, name: r'productReviewsProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$productReviewsHash, - dependencies: ProductReviewsFamily._dependencies, - allTransitiveDependencies: - ProductReviewsFamily._allTransitiveDependencies, - listingId: listingId, + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, ); - ProductReviewsProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.listingId, - }) : super.internal(); + /// Reviews are cursor-paginated, so "show more" carries the cursor the last page + /// ended on — a page number would re-read rows a new review has already shifted. - final String listingId; + ProductReviewsProvider call(String listingId) => + ProductReviewsProvider._(argument: listingId, from: this); @override - FutureOr runNotifierBuild( - covariant ProductReviews notifier, - ) { - return notifier.build(listingId); - } + String toString() => r'productReviewsProvider'; +} - @override - Override overrideWith(ProductReviews Function() create) { - return ProviderOverride( - origin: this, - override: ProductReviewsProvider._internal( - () => create()..listingId = listingId, - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - listingId: listingId, - ), - ); - } +/// Reviews are cursor-paginated, so "show more" carries the cursor the last page +/// ended on — a page number would re-read rows a new review has already shifted. + +abstract class _$ProductReviews extends $AsyncNotifier { + late final _$args = ref.$arg as String; + String get listingId => _$args; + FutureOr build(String listingId); + @$mustCallSuper @override - AutoDisposeAsyncNotifierProviderElement - createElement() { - return _ProductReviewsProviderElement(this); + void runBuild() { + final created = build(_$args); + final ref = + this.ref as $Ref, ProductReviewsState>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, ProductReviewsState>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, created); } +} + +@ProviderFor(recentlyViewedProducts) +const recentlyViewedProductsProvider = RecentlyViewedProductsProvider._(); + +final class RecentlyViewedProductsProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + FutureOr> + > + with + $FutureModifier>, + $FutureProvider> { + const RecentlyViewedProductsProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'recentlyViewedProductsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - bool operator ==(Object other) { - return other is ProductReviewsProvider && other.listingId == listingId; - } + String debugGetCreateSourceHash() => _$recentlyViewedProductsHash(); + @$internal @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, listingId.hashCode); + $FutureProviderElement> $createElement( + $ProviderPointer pointer, + ) => $FutureProviderElement(pointer); - return _SystemHash.finish(hash); + @override + FutureOr> create(Ref ref) { + return recentlyViewedProducts(ref); } } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin ProductReviewsRef - on AutoDisposeAsyncNotifierProviderRef { - /// The parameter `listingId` of this provider. - String get listingId; -} +String _$recentlyViewedProductsHash() => + r'68c7dc7488a27863e028794280585cd3046ddbdc'; -class _ProductReviewsProviderElement - extends - AutoDisposeAsyncNotifierProviderElement< - ProductReviews, - ProductReviewsState - > - with ProductReviewsRef { - _ProductReviewsProviderElement(super.provider); +@ProviderFor(RecentSearches) +const recentSearchesProvider = RecentSearchesProvider._(); + +final class RecentSearchesProvider + extends $NotifierProvider> { + const RecentSearchesProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'recentSearchesProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); @override - String get listingId => (origin as ProductReviewsProvider).listingId; -} + String debugGetCreateSourceHash() => _$recentSearchesHash(); -String _$recentSearchesHash() => r'9b8f4aaf5633d5c8ac0b635e6bda1f5898cf7103'; + @$internal + @override + RecentSearches create() => RecentSearches(); -/// See also [RecentSearches]. -@ProviderFor(RecentSearches) -final recentSearchesProvider = - AutoDisposeNotifierProvider>.internal( - RecentSearches.new, - name: r'recentSearchesProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$recentSearchesHash, - dependencies: null, - allTransitiveDependencies: null, + /// {@macro riverpod.override_with_value} + Override overrideWithValue(List value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider>(value), ); + } +} + +String _$recentSearchesHash() => r'9b8f4aaf5633d5c8ac0b635e6bda1f5898cf7103'; -typedef _$RecentSearches = AutoDisposeNotifier>; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +abstract class _$RecentSearches extends $Notifier> { + List build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref, List>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, List>, + List, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/lib/features/catalog/presentation/widgets/send_offer_sheet.dart b/lib/features/catalog/presentation/widgets/send_offer_sheet.dart index c5de9b7..dc5abc0 100644 --- a/lib/features/catalog/presentation/widgets/send_offer_sheet.dart +++ b/lib/features/catalog/presentation/widgets/send_offer_sheet.dart @@ -84,6 +84,22 @@ class _SendOfferSheetState extends ConsumerState { return parsed; } + /// Vì sao mức giá đang gõ chưa gửi được, hoặc null nếu gửi được. + /// + /// Thương lượng chỉ đi xuống: giá niêm yết vốn đã là lời đề nghị bán ở mức đó, + /// nên đề xuất cao hơn là thứ không ai làm — người mua chỉ việc bấm mua. Server + /// trả 422 `offer_above_asking` cho đúng chuyện này; hỏi ở đây để người ta biết + /// ngay lúc gõ chứ không phải sau khi bấm gửi. + String? get _priceError { + final unitPrice = _unitPrice; + if (unitPrice == null) return null; + if (unitPrice > widget.variant.price) { + return 'Không cao hơn giá niêm yết ' + '(${MoneyUtils.format(widget.variant.price)}).'; + } + return null; + } + Future _send() async { final unitPrice = _unitPrice; if (unitPrice == null) { @@ -95,6 +111,9 @@ class _SendOfferSheetState extends ConsumerState { ); return; } + // Nút đã bị vô hiệu hoá ở trạng thái này; đây là chốt chặn cho đường vào còn + // lại — bàn phím gửi đi trong lúc `errorText` đang hiện. + if (_priceError != null) return; setState(() => _isSending = true); final reason = _reasonController.text.trim(); @@ -267,6 +286,7 @@ class _SendOfferSheetState extends ConsumerState { final isDarkMode = theme.brightness == Brightness.dark; final unitPrice = _unitPrice; final askingPrice = widget.variant.price; + final priceError = _priceError; final label = variantLabel(widget.variant); return SafeArea( @@ -347,6 +367,7 @@ class _SendOfferSheetState extends ConsumerState { decoration: InputDecoration( prefixIcon: const Icon(Icons.sell_outlined), hintText: 'Nhập số tiền...', + errorText: priceError, filled: true, fillColor: isDarkMode ? theme.colorScheme.surfaceContainerHighest @@ -385,7 +406,7 @@ class _SendOfferSheetState extends ConsumerState { ), ), const SizedBox(height: 8), - if (unitPrice != null) + if (unitPrice != null && priceError == null) Container( padding: const EdgeInsets.all(12), decoration: BoxDecoration( @@ -421,7 +442,7 @@ class _SendOfferSheetState extends ConsumerState { width: double.infinity, height: 48, child: ElevatedButton( - onPressed: _isSending ? null : _send, + onPressed: _isSending || priceError != null ? null : _send, style: ElevatedButton.styleFrom( backgroundColor: theme.colorScheme.primary, foregroundColor: theme.colorScheme.onPrimary, diff --git a/lib/features/chat/data/repositories/chat_repository.dart b/lib/features/chat/data/repositories/chat_repository.dart index f7b0e6d..171f499 100644 --- a/lib/features/chat/data/repositories/chat_repository.dart +++ b/lib/features/chat/data/repositories/chat_repository.dart @@ -5,7 +5,6 @@ import 'package:shopnexus_flutter_app/api/generated/api/chat_api.dart'; import 'package:shopnexus_flutter_app/api/generated/api/order_api.dart'; import 'package:shopnexus_flutter_app/api/generated/model/chat_unread_count.dart'; import 'package:shopnexus_flutter_app/api/generated/model/conversation.dart'; -import 'package:shopnexus_flutter_app/api/generated/model/create_upload_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/mark_conversation_read_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/message.dart'; import 'package:shopnexus_flutter_app/api/generated/model/offer.dart'; @@ -13,7 +12,7 @@ import 'package:shopnexus_flutter_app/api/generated/model/send_message_request.d import 'package:shopnexus_flutter_app/api/generated/model/start_conversation_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/update_message_request.dart'; import 'package:shopnexus_flutter_app/api/generated/model/update_offer_request.dart'; -import 'package:shopnexus_flutter_app/core/network/resource_upload.dart'; +import 'package:shopnexus_flutter_app/core/upload/resource_uploader.dart'; part 'chat_repository.g.dart'; @@ -29,10 +28,12 @@ class ChatPage { } class ChatRepository { - const ChatRepository(this._api, this._orderApi); + const ChatRepository(this._api, this._orderApi, this._uploader); final ChatApi _api; + final ResourceUploader _uploader; + /// A negotiation card names an offer and nothing else, so rendering a thread /// means reading — and answering — that offer. The terms live in order. final OrderApi _orderApi; @@ -110,26 +111,21 @@ class ChatRepository { return message; } - /// Reserve a slot, PUT the bytes to the signed URL, confirm the upload. + /// Hands back the resource id `SendMessageRequest.attachments` takes. The three + /// steps are [ResourceUploader]'s; a composer that wants to show the photo it + /// just sent calls that directly and keeps the `Resource`. Future uploadAttachment({ required List bytes, required String filename, required String mime, }) async { - final slotResponse = await _api.conversationsUploadsPost( - createUploadRequest: CreateUploadRequest( - filename: filename, - mime: mime, - size: bytes.length, - ), + final resource = await _uploader.upload( + UploadTarget.conversation, + bytes: bytes, + filename: filename, + mime: mime, ); - final slot = slotResponse.data?.data; - if (slot == null) throw StateError('empty upload slot response'); - - await putToSlot(slot, bytes); - - await _api.conversationsUploadsIdConfirmationPost(id: slot.resourceId); - return slot.resourceId; + return resource.id; } /// Omitting `before` marks the whole thread read. The answer is the updated @@ -222,5 +218,6 @@ ChatRepository chatRepository(Ref ref) { return ChatRepository( ref.watch(chatApiProvider), ref.watch(orderApiProvider), + ref.watch(resourceUploaderProvider), ); } diff --git a/lib/features/chat/data/repositories/chat_repository.g.dart b/lib/features/chat/data/repositories/chat_repository.g.dart index 77a1188..e078786 100644 --- a/lib/features/chat/data/repositories/chat_repository.g.dart +++ b/lib/features/chat/data/repositories/chat_repository.g.dart @@ -6,22 +6,46 @@ part of 'chat_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$chatRepositoryHash() => r'd291d926838447f140ddd11730e205a7b5fca89e'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [chatRepository]. @ProviderFor(chatRepository) -final chatRepositoryProvider = AutoDisposeProvider.internal( - chatRepository, - name: r'chatRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$chatRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef ChatRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const chatRepositoryProvider = ChatRepositoryProvider._(); + +final class ChatRepositoryProvider + extends $FunctionalProvider + with $Provider { + const ChatRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'chatRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$chatRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + ChatRepository create(Ref ref) { + return chatRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(ChatRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$chatRepositoryHash() => r'd291d926838447f140ddd11730e205a7b5fca89e'; diff --git a/lib/features/chat/presentation/providers/chat_notifier.g.dart b/lib/features/chat/presentation/providers/chat_notifier.g.dart index bd22c1f..88aa938 100644 --- a/lib/features/chat/presentation/providers/chat_notifier.g.dart +++ b/lib/features/chat/presentation/providers/chat_notifier.g.dart @@ -6,223 +6,186 @@ part of 'chat_notifier.dart'; // RiverpodGenerator // ************************************************************************** -String _$chatListNotifierHash() => r'b7533ee0aaf204f4dff929fb8b928209221ae978'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// The inbox. /// /// Every change to it arrives on the account's one socket; nothing is polled and /// nothing is replayed, so a re-handshake means refetching over REST. -/// -/// Copied from [ChatListNotifier]. + @ProviderFor(ChatListNotifier) -final chatListNotifierProvider = - AutoDisposeAsyncNotifierProvider.internal( - ChatListNotifier.new, - name: r'chatListNotifierProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$chatListNotifierHash, - dependencies: null, - allTransitiveDependencies: null, - ); - -typedef _$ChatListNotifier = AutoDisposeAsyncNotifier; -String _$chatDetailNotifierHash() => - r'f8baf60ababce1dfbbe4e9d8349578157f86ee43'; - -/// Copied from Dart SDK -class _SystemHash { - _SystemHash._(); - - static int combine(int hash, int value) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + value); - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x0007ffff & hash) << 10)); - return hash ^ (hash >> 6); - } +const chatListProvider = ChatListNotifierProvider._(); - static int finish(int hash) { - // ignore: parameter_assignments - hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); - // ignore: parameter_assignments - hash = hash ^ (hash >> 11); - return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); - } +/// The inbox. +/// +/// Every change to it arrives on the account's one socket; nothing is polled and +/// nothing is replayed, so a re-handshake means refetching over REST. +final class ChatListNotifierProvider + extends $AsyncNotifierProvider { + /// The inbox. + /// + /// Every change to it arrives on the account's one socket; nothing is polled and + /// nothing is replayed, so a re-handshake means refetching over REST. + const ChatListNotifierProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'chatListProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$chatListNotifierHash(); + + @$internal + @override + ChatListNotifier create() => ChatListNotifier(); } -abstract class _$ChatDetailNotifier - extends BuildlessAutoDisposeAsyncNotifier { - late final String conversationId; +String _$chatListNotifierHash() => r'b7533ee0aaf204f4dff929fb8b928209221ae978'; - FutureOr build(String conversationId); +/// The inbox. +/// +/// Every change to it arrives on the account's one socket; nothing is polled and +/// nothing is replayed, so a re-handshake means refetching over REST. + +abstract class _$ChatListNotifier extends $AsyncNotifier { + FutureOr build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref, ChatListState>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, ChatListState>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, created); + } } /// One open thread. /// /// Messages, read receipts and the negotiations its cards point at all arrive on /// the same socket; what the app sends, it sends over REST. -/// -/// Copied from [ChatDetailNotifier]. + @ProviderFor(ChatDetailNotifier) -const chatDetailNotifierProvider = ChatDetailNotifierFamily(); +const chatDetailProvider = ChatDetailNotifierFamily._(); /// One open thread. /// /// Messages, read receipts and the negotiations its cards point at all arrive on /// the same socket; what the app sends, it sends over REST. -/// -/// Copied from [ChatDetailNotifier]. -class ChatDetailNotifierFamily extends Family> { +final class ChatDetailNotifierProvider + extends $AsyncNotifierProvider { /// One open thread. /// /// Messages, read receipts and the negotiations its cards point at all arrive on /// the same socket; what the app sends, it sends over REST. - /// - /// Copied from [ChatDetailNotifier]. - const ChatDetailNotifierFamily(); + const ChatDetailNotifierProvider._({ + required ChatDetailNotifierFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'chatDetailProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); - /// One open thread. - /// - /// Messages, read receipts and the negotiations its cards point at all arrive on - /// the same socket; what the app sends, it sends over REST. - /// - /// Copied from [ChatDetailNotifier]. - ChatDetailNotifierProvider call(String conversationId) { - return ChatDetailNotifierProvider(conversationId); - } + @override + String debugGetCreateSourceHash() => _$chatDetailNotifierHash(); @override - ChatDetailNotifierProvider getProviderOverride( - covariant ChatDetailNotifierProvider provider, - ) { - return call(provider.conversationId); + String toString() { + return r'chatDetailProvider' + '' + '($argument)'; } - static const Iterable? _dependencies = null; - + @$internal @override - Iterable? get dependencies => _dependencies; - - static const Iterable? _allTransitiveDependencies = null; + ChatDetailNotifier create() => ChatDetailNotifier(); @override - Iterable? get allTransitiveDependencies => - _allTransitiveDependencies; + bool operator ==(Object other) { + return other is ChatDetailNotifierProvider && other.argument == argument; + } @override - String? get name => r'chatDetailNotifierProvider'; + int get hashCode { + return argument.hashCode; + } } +String _$chatDetailNotifierHash() => + r'e89324549ae42f39822883f4dbfa09c3ba841274'; + /// One open thread. /// /// Messages, read receipts and the negotiations its cards point at all arrive on /// the same socket; what the app sends, it sends over REST. -/// -/// Copied from [ChatDetailNotifier]. -class ChatDetailNotifierProvider - extends - AutoDisposeAsyncNotifierProviderImpl< + +final class ChatDetailNotifierFamily extends $Family + with + $ClassFamilyOverride< ChatDetailNotifier, - ChatDetailState + AsyncValue, + ChatDetailState, + FutureOr, + String > { + const ChatDetailNotifierFamily._() + : super( + retry: null, + name: r'chatDetailProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + /// One open thread. /// /// Messages, read receipts and the negotiations its cards point at all arrive on /// the same socket; what the app sends, it sends over REST. - /// - /// Copied from [ChatDetailNotifier]. - ChatDetailNotifierProvider(String conversationId) - : this._internal( - () => ChatDetailNotifier()..conversationId = conversationId, - from: chatDetailNotifierProvider, - name: r'chatDetailNotifierProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$chatDetailNotifierHash, - dependencies: ChatDetailNotifierFamily._dependencies, - allTransitiveDependencies: - ChatDetailNotifierFamily._allTransitiveDependencies, - conversationId: conversationId, - ); - - ChatDetailNotifierProvider._internal( - super._createNotifier, { - required super.name, - required super.dependencies, - required super.allTransitiveDependencies, - required super.debugGetCreateSourceHash, - required super.from, - required this.conversationId, - }) : super.internal(); - - final String conversationId; - - @override - FutureOr runNotifierBuild( - covariant ChatDetailNotifier notifier, - ) { - return notifier.build(conversationId); - } - - @override - Override overrideWith(ChatDetailNotifier Function() create) { - return ProviderOverride( - origin: this, - override: ChatDetailNotifierProvider._internal( - () => create()..conversationId = conversationId, - from: from, - name: null, - dependencies: null, - allTransitiveDependencies: null, - debugGetCreateSourceHash: null, - conversationId: conversationId, - ), - ); - } - - @override - AutoDisposeAsyncNotifierProviderElement - createElement() { - return _ChatDetailNotifierProviderElement(this); - } - @override - bool operator ==(Object other) { - return other is ChatDetailNotifierProvider && - other.conversationId == conversationId; - } + ChatDetailNotifierProvider call(String conversationId) => + ChatDetailNotifierProvider._(argument: conversationId, from: this); @override - int get hashCode { - var hash = _SystemHash.combine(0, runtimeType.hashCode); - hash = _SystemHash.combine(hash, conversationId.hashCode); - - return _SystemHash.finish(hash); - } + String toString() => r'chatDetailProvider'; } -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -mixin ChatDetailNotifierRef - on AutoDisposeAsyncNotifierProviderRef { - /// The parameter `conversationId` of this provider. - String get conversationId; -} +/// One open thread. +/// +/// Messages, read receipts and the negotiations its cards point at all arrive on +/// the same socket; what the app sends, it sends over REST. -class _ChatDetailNotifierProviderElement - extends - AutoDisposeAsyncNotifierProviderElement< - ChatDetailNotifier, - ChatDetailState - > - with ChatDetailNotifierRef { - _ChatDetailNotifierProviderElement(super.provider); +abstract class _$ChatDetailNotifier extends $AsyncNotifier { + late final _$args = ref.$arg as String; + String get conversationId => _$args; + FutureOr build(String conversationId); + @$mustCallSuper @override - String get conversationId => - (origin as ChatDetailNotifierProvider).conversationId; + void runBuild() { + final created = build(_$args); + final ref = this.ref as $Ref, ChatDetailState>; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, ChatDetailState>, + AsyncValue, + Object?, + Object? + >; + element.handleValue(ref, created); + } } - -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package diff --git a/lib/features/chat/presentation/providers/chat_state.freezed.dart b/lib/features/chat/presentation/providers/chat_state.freezed.dart index b30e8f7..346b51e 100644 --- a/lib/features/chat/presentation/providers/chat_state.freezed.dart +++ b/lib/features/chat/presentation/providers/chat_state.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,534 +9,574 @@ part of 'chat_state.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - /// @nodoc mixin _$ChatListState { - List get conversations => throw _privateConstructorUsedError; - String get searchQuery => throw _privateConstructorUsedError; - String? get nextCursor => throw _privateConstructorUsedError; - /// Create a copy of ChatListState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ChatListStateCopyWith get copyWith => - throw _privateConstructorUsedError; + List get conversations; String get searchQuery; String? get nextCursor; +/// Create a copy of ChatListState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ChatListStateCopyWith get copyWith => _$ChatListStateCopyWithImpl(this as ChatListState, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ChatListState&&const DeepCollectionEquality().equals(other.conversations, conversations)&&(identical(other.searchQuery, searchQuery) || other.searchQuery == searchQuery)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)); } -/// @nodoc -abstract class $ChatListStateCopyWith<$Res> { - factory $ChatListStateCopyWith( - ChatListState value, - $Res Function(ChatListState) then, - ) = _$ChatListStateCopyWithImpl<$Res, ChatListState>; - @useResult - $Res call({ - List conversations, - String searchQuery, - String? nextCursor, - }); + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(conversations),searchQuery,nextCursor); + +@override +String toString() { + return 'ChatListState(conversations: $conversations, searchQuery: $searchQuery, nextCursor: $nextCursor)'; } -/// @nodoc -class _$ChatListStateCopyWithImpl<$Res, $Val extends ChatListState> - implements $ChatListStateCopyWith<$Res> { - _$ChatListStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of ChatListState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? conversations = null, - Object? searchQuery = null, - Object? nextCursor = freezed, - }) { - return _then( - _value.copyWith( - conversations: null == conversations - ? _value.conversations - : conversations // ignore: cast_nullable_to_non_nullable - as List, - searchQuery: null == searchQuery - ? _value.searchQuery - : searchQuery // ignore: cast_nullable_to_non_nullable - as String, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$ChatListStateImplCopyWith<$Res> +abstract mixin class $ChatListStateCopyWith<$Res> { + factory $ChatListStateCopyWith(ChatListState value, $Res Function(ChatListState) _then) = _$ChatListStateCopyWithImpl; +@useResult +$Res call({ + List conversations, String searchQuery, String? nextCursor +}); + + + + +} +/// @nodoc +class _$ChatListStateCopyWithImpl<$Res> implements $ChatListStateCopyWith<$Res> { - factory _$$ChatListStateImplCopyWith( - _$ChatListStateImpl value, - $Res Function(_$ChatListStateImpl) then, - ) = __$$ChatListStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - List conversations, - String searchQuery, - String? nextCursor, - }); + _$ChatListStateCopyWithImpl(this._self, this._then); + + final ChatListState _self; + final $Res Function(ChatListState) _then; + +/// Create a copy of ChatListState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? conversations = null,Object? searchQuery = null,Object? nextCursor = freezed,}) { + return _then(_self.copyWith( +conversations: null == conversations ? _self.conversations : conversations // ignore: cast_nullable_to_non_nullable +as List,searchQuery: null == searchQuery ? _self.searchQuery : searchQuery // ignore: cast_nullable_to_non_nullable +as String,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ChatListState]. +extension ChatListStatePatterns on ChatListState { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _ChatListState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ChatListState() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _ChatListState value) $default,){ +final _that = this; +switch (_that) { +case _ChatListState(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ChatListState value)? $default,){ +final _that = this; +switch (_that) { +case _ChatListState() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( List conversations, String searchQuery, String? nextCursor)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ChatListState() when $default != null: +return $default(_that.conversations,_that.searchQuery,_that.nextCursor);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( List conversations, String searchQuery, String? nextCursor) $default,) {final _that = this; +switch (_that) { +case _ChatListState(): +return $default(_that.conversations,_that.searchQuery,_that.nextCursor);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( List conversations, String searchQuery, String? nextCursor)? $default,) {final _that = this; +switch (_that) { +case _ChatListState() when $default != null: +return $default(_that.conversations,_that.searchQuery,_that.nextCursor);case _: + return null; + +} +} + } /// @nodoc -class __$$ChatListStateImplCopyWithImpl<$Res> - extends _$ChatListStateCopyWithImpl<$Res, _$ChatListStateImpl> - implements _$$ChatListStateImplCopyWith<$Res> { - __$$ChatListStateImplCopyWithImpl( - _$ChatListStateImpl _value, - $Res Function(_$ChatListStateImpl) _then, - ) : super(_value, _then); - - /// Create a copy of ChatListState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? conversations = null, - Object? searchQuery = null, - Object? nextCursor = freezed, - }) { - return _then( - _$ChatListStateImpl( - conversations: null == conversations - ? _value._conversations - : conversations // ignore: cast_nullable_to_non_nullable - as List, - searchQuery: null == searchQuery - ? _value.searchQuery - : searchQuery // ignore: cast_nullable_to_non_nullable - as String, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } + + +class _ChatListState extends ChatListState { + const _ChatListState({final List conversations = const [], this.searchQuery = '', this.nextCursor}): _conversations = conversations,super._(); + + + final List _conversations; +@override@JsonKey() List get conversations { + if (_conversations is EqualUnmodifiableListView) return _conversations; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_conversations); +} + +@override@JsonKey() final String searchQuery; +@override final String? nextCursor; + +/// Create a copy of ChatListState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ChatListStateCopyWith<_ChatListState> get copyWith => __$ChatListStateCopyWithImpl<_ChatListState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChatListState&&const DeepCollectionEquality().equals(other._conversations, _conversations)&&(identical(other.searchQuery, searchQuery) || other.searchQuery == searchQuery)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)); +} + + +@override +int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_conversations),searchQuery,nextCursor); + +@override +String toString() { + return 'ChatListState(conversations: $conversations, searchQuery: $searchQuery, nextCursor: $nextCursor)'; +} + + } /// @nodoc +abstract mixin class _$ChatListStateCopyWith<$Res> implements $ChatListStateCopyWith<$Res> { + factory _$ChatListStateCopyWith(_ChatListState value, $Res Function(_ChatListState) _then) = __$ChatListStateCopyWithImpl; +@override @useResult +$Res call({ + List conversations, String searchQuery, String? nextCursor +}); + + + + +} +/// @nodoc +class __$ChatListStateCopyWithImpl<$Res> + implements _$ChatListStateCopyWith<$Res> { + __$ChatListStateCopyWithImpl(this._self, this._then); + + final _ChatListState _self; + final $Res Function(_ChatListState) _then; + +/// Create a copy of ChatListState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? conversations = null,Object? searchQuery = null,Object? nextCursor = freezed,}) { + return _then(_ChatListState( +conversations: null == conversations ? _self._conversations : conversations // ignore: cast_nullable_to_non_nullable +as List,searchQuery: null == searchQuery ? _self.searchQuery : searchQuery // ignore: cast_nullable_to_non_nullable +as String,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + -class _$ChatListStateImpl extends _ChatListState { - const _$ChatListStateImpl({ - final List conversations = const [], - this.searchQuery = '', - this.nextCursor, - }) : _conversations = conversations, - super._(); - - final List _conversations; - @override - @JsonKey() - List get conversations { - if (_conversations is EqualUnmodifiableListView) return _conversations; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_conversations); - } - - @override - @JsonKey() - final String searchQuery; - @override - final String? nextCursor; - - @override - String toString() { - return 'ChatListState(conversations: $conversations, searchQuery: $searchQuery, nextCursor: $nextCursor)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ChatListStateImpl && - const DeepCollectionEquality().equals( - other._conversations, - _conversations, - ) && - (identical(other.searchQuery, searchQuery) || - other.searchQuery == searchQuery) && - (identical(other.nextCursor, nextCursor) || - other.nextCursor == nextCursor)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_conversations), - searchQuery, - nextCursor, - ); - - /// Create a copy of ChatListState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ChatListStateImplCopyWith<_$ChatListStateImpl> get copyWith => - __$$ChatListStateImplCopyWithImpl<_$ChatListStateImpl>(this, _$identity); -} - -abstract class _ChatListState extends ChatListState { - const factory _ChatListState({ - final List conversations, - final String searchQuery, - final String? nextCursor, - }) = _$ChatListStateImpl; - const _ChatListState._() : super._(); - - @override - List get conversations; - @override - String get searchQuery; - @override - String? get nextCursor; - - /// Create a copy of ChatListState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ChatListStateImplCopyWith<_$ChatListStateImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$ChatDetailState { - String get conversationId => throw _privateConstructorUsedError; - Conversation? get conversation => throw _privateConstructorUsedError; - /// Oldest first, which is the reading order; the route answers newest first. - List get messages => throw _privateConstructorUsedError; + String get conversationId; Conversation? get conversation;/// Oldest first, which is the reading order; the route answers newest first. + List get messages;/// The negotiations the thread's cards point at, by offer id. A card carries +/// only the id, so the terms are read from here and a counter-offer can never +/// leave an old price on screen. + Map get offers; String? get nextCursor; bool get isSending; String? get errorMessage; +/// Create a copy of ChatDetailState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ChatDetailStateCopyWith get copyWith => _$ChatDetailStateCopyWithImpl(this as ChatDetailState, _$identity); + - /// The negotiations the thread's cards point at, by offer id. A card carries - /// only the id, so the terms are read from here and a counter-offer can never - /// leave an old price on screen. - Map get offers => throw _privateConstructorUsedError; - String? get nextCursor => throw _privateConstructorUsedError; - bool get isSending => throw _privateConstructorUsedError; - String? get errorMessage => throw _privateConstructorUsedError; - /// Create a copy of ChatDetailState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ChatDetailStateCopyWith get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ChatDetailState&&(identical(other.conversationId, conversationId) || other.conversationId == conversationId)&&(identical(other.conversation, conversation) || other.conversation == conversation)&&const DeepCollectionEquality().equals(other.messages, messages)&&const DeepCollectionEquality().equals(other.offers, offers)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isSending, isSending) || other.isSending == isSending)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); } -/// @nodoc -abstract class $ChatDetailStateCopyWith<$Res> { - factory $ChatDetailStateCopyWith( - ChatDetailState value, - $Res Function(ChatDetailState) then, - ) = _$ChatDetailStateCopyWithImpl<$Res, ChatDetailState>; - @useResult - $Res call({ - String conversationId, - Conversation? conversation, - List messages, - Map offers, - String? nextCursor, - bool isSending, - String? errorMessage, - }); + +@override +int get hashCode => Object.hash(runtimeType,conversationId,conversation,const DeepCollectionEquality().hash(messages),const DeepCollectionEquality().hash(offers),nextCursor,isSending,errorMessage); + +@override +String toString() { + return 'ChatDetailState(conversationId: $conversationId, conversation: $conversation, messages: $messages, offers: $offers, nextCursor: $nextCursor, isSending: $isSending, errorMessage: $errorMessage)'; } -/// @nodoc -class _$ChatDetailStateCopyWithImpl<$Res, $Val extends ChatDetailState> - implements $ChatDetailStateCopyWith<$Res> { - _$ChatDetailStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of ChatDetailState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? conversationId = null, - Object? conversation = freezed, - Object? messages = null, - Object? offers = null, - Object? nextCursor = freezed, - Object? isSending = null, - Object? errorMessage = freezed, - }) { - return _then( - _value.copyWith( - conversationId: null == conversationId - ? _value.conversationId - : conversationId // ignore: cast_nullable_to_non_nullable - as String, - conversation: freezed == conversation - ? _value.conversation - : conversation // ignore: cast_nullable_to_non_nullable - as Conversation?, - messages: null == messages - ? _value.messages - : messages // ignore: cast_nullable_to_non_nullable - as List, - offers: null == offers - ? _value.offers - : offers // ignore: cast_nullable_to_non_nullable - as Map, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - isSending: null == isSending - ? _value.isSending - : isSending // ignore: cast_nullable_to_non_nullable - as bool, - errorMessage: freezed == errorMessage - ? _value.errorMessage - : errorMessage // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } + } /// @nodoc -abstract class _$$ChatDetailStateImplCopyWith<$Res> +abstract mixin class $ChatDetailStateCopyWith<$Res> { + factory $ChatDetailStateCopyWith(ChatDetailState value, $Res Function(ChatDetailState) _then) = _$ChatDetailStateCopyWithImpl; +@useResult +$Res call({ + String conversationId, Conversation? conversation, List messages, Map offers, String? nextCursor, bool isSending, String? errorMessage +}); + + + + +} +/// @nodoc +class _$ChatDetailStateCopyWithImpl<$Res> implements $ChatDetailStateCopyWith<$Res> { - factory _$$ChatDetailStateImplCopyWith( - _$ChatDetailStateImpl value, - $Res Function(_$ChatDetailStateImpl) then, - ) = __$$ChatDetailStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String conversationId, - Conversation? conversation, - List messages, - Map offers, - String? nextCursor, - bool isSending, - String? errorMessage, - }); + _$ChatDetailStateCopyWithImpl(this._self, this._then); + + final ChatDetailState _self; + final $Res Function(ChatDetailState) _then; + +/// Create a copy of ChatDetailState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? conversationId = null,Object? conversation = freezed,Object? messages = null,Object? offers = null,Object? nextCursor = freezed,Object? isSending = null,Object? errorMessage = freezed,}) { + return _then(_self.copyWith( +conversationId: null == conversationId ? _self.conversationId : conversationId // ignore: cast_nullable_to_non_nullable +as String,conversation: freezed == conversation ? _self.conversation : conversation // ignore: cast_nullable_to_non_nullable +as Conversation?,messages: null == messages ? _self.messages : messages // ignore: cast_nullable_to_non_nullable +as List,offers: null == offers ? _self.offers : offers // ignore: cast_nullable_to_non_nullable +as Map,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?,isSending: null == isSending ? _self.isSending : isSending // ignore: cast_nullable_to_non_nullable +as bool,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ChatDetailState]. +extension ChatDetailStatePatterns on ChatDetailState { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _ChatDetailState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ChatDetailState() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _ChatDetailState value) $default,){ +final _that = this; +switch (_that) { +case _ChatDetailState(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _ChatDetailState value)? $default,){ +final _that = this; +switch (_that) { +case _ChatDetailState() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String conversationId, Conversation? conversation, List messages, Map offers, String? nextCursor, bool isSending, String? errorMessage)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ChatDetailState() when $default != null: +return $default(_that.conversationId,_that.conversation,_that.messages,_that.offers,_that.nextCursor,_that.isSending,_that.errorMessage);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String conversationId, Conversation? conversation, List messages, Map offers, String? nextCursor, bool isSending, String? errorMessage) $default,) {final _that = this; +switch (_that) { +case _ChatDetailState(): +return $default(_that.conversationId,_that.conversation,_that.messages,_that.offers,_that.nextCursor,_that.isSending,_that.errorMessage);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String conversationId, Conversation? conversation, List messages, Map offers, String? nextCursor, bool isSending, String? errorMessage)? $default,) {final _that = this; +switch (_that) { +case _ChatDetailState() when $default != null: +return $default(_that.conversationId,_that.conversation,_that.messages,_that.offers,_that.nextCursor,_that.isSending,_that.errorMessage);case _: + return null; + +} +} + } /// @nodoc -class __$$ChatDetailStateImplCopyWithImpl<$Res> - extends _$ChatDetailStateCopyWithImpl<$Res, _$ChatDetailStateImpl> - implements _$$ChatDetailStateImplCopyWith<$Res> { - __$$ChatDetailStateImplCopyWithImpl( - _$ChatDetailStateImpl _value, - $Res Function(_$ChatDetailStateImpl) _then, - ) : super(_value, _then); - - /// Create a copy of ChatDetailState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? conversationId = null, - Object? conversation = freezed, - Object? messages = null, - Object? offers = null, - Object? nextCursor = freezed, - Object? isSending = null, - Object? errorMessage = freezed, - }) { - return _then( - _$ChatDetailStateImpl( - conversationId: null == conversationId - ? _value.conversationId - : conversationId // ignore: cast_nullable_to_non_nullable - as String, - conversation: freezed == conversation - ? _value.conversation - : conversation // ignore: cast_nullable_to_non_nullable - as Conversation?, - messages: null == messages - ? _value._messages - : messages // ignore: cast_nullable_to_non_nullable - as List, - offers: null == offers - ? _value._offers - : offers // ignore: cast_nullable_to_non_nullable - as Map, - nextCursor: freezed == nextCursor - ? _value.nextCursor - : nextCursor // ignore: cast_nullable_to_non_nullable - as String?, - isSending: null == isSending - ? _value.isSending - : isSending // ignore: cast_nullable_to_non_nullable - as bool, - errorMessage: freezed == errorMessage - ? _value.errorMessage - : errorMessage // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } + + +class _ChatDetailState extends ChatDetailState { + const _ChatDetailState({required this.conversationId, this.conversation, final List messages = const [], final Map offers = const {}, this.nextCursor, this.isSending = false, this.errorMessage}): _messages = messages,_offers = offers,super._(); + + +@override final String conversationId; +@override final Conversation? conversation; +/// Oldest first, which is the reading order; the route answers newest first. + final List _messages; +/// Oldest first, which is the reading order; the route answers newest first. +@override@JsonKey() List get messages { + if (_messages is EqualUnmodifiableListView) return _messages; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_messages); +} + +/// The negotiations the thread's cards point at, by offer id. A card carries +/// only the id, so the terms are read from here and a counter-offer can never +/// leave an old price on screen. + final Map _offers; +/// The negotiations the thread's cards point at, by offer id. A card carries +/// only the id, so the terms are read from here and a counter-offer can never +/// leave an old price on screen. +@override@JsonKey() Map get offers { + if (_offers is EqualUnmodifiableMapView) return _offers; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_offers); +} + +@override final String? nextCursor; +@override@JsonKey() final bool isSending; +@override final String? errorMessage; + +/// Create a copy of ChatDetailState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ChatDetailStateCopyWith<_ChatDetailState> get copyWith => __$ChatDetailStateCopyWithImpl<_ChatDetailState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ChatDetailState&&(identical(other.conversationId, conversationId) || other.conversationId == conversationId)&&(identical(other.conversation, conversation) || other.conversation == conversation)&&const DeepCollectionEquality().equals(other._messages, _messages)&&const DeepCollectionEquality().equals(other._offers, _offers)&&(identical(other.nextCursor, nextCursor) || other.nextCursor == nextCursor)&&(identical(other.isSending, isSending) || other.isSending == isSending)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); } + +@override +int get hashCode => Object.hash(runtimeType,conversationId,conversation,const DeepCollectionEquality().hash(_messages),const DeepCollectionEquality().hash(_offers),nextCursor,isSending,errorMessage); + +@override +String toString() { + return 'ChatDetailState(conversationId: $conversationId, conversation: $conversation, messages: $messages, offers: $offers, nextCursor: $nextCursor, isSending: $isSending, errorMessage: $errorMessage)'; +} + + +} + +/// @nodoc +abstract mixin class _$ChatDetailStateCopyWith<$Res> implements $ChatDetailStateCopyWith<$Res> { + factory _$ChatDetailStateCopyWith(_ChatDetailState value, $Res Function(_ChatDetailState) _then) = __$ChatDetailStateCopyWithImpl; +@override @useResult +$Res call({ + String conversationId, Conversation? conversation, List messages, Map offers, String? nextCursor, bool isSending, String? errorMessage +}); + + + + +} /// @nodoc +class __$ChatDetailStateCopyWithImpl<$Res> + implements _$ChatDetailStateCopyWith<$Res> { + __$ChatDetailStateCopyWithImpl(this._self, this._then); + + final _ChatDetailState _self; + final $Res Function(_ChatDetailState) _then; + +/// Create a copy of ChatDetailState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? conversationId = null,Object? conversation = freezed,Object? messages = null,Object? offers = null,Object? nextCursor = freezed,Object? isSending = null,Object? errorMessage = freezed,}) { + return _then(_ChatDetailState( +conversationId: null == conversationId ? _self.conversationId : conversationId // ignore: cast_nullable_to_non_nullable +as String,conversation: freezed == conversation ? _self.conversation : conversation // ignore: cast_nullable_to_non_nullable +as Conversation?,messages: null == messages ? _self._messages : messages // ignore: cast_nullable_to_non_nullable +as List,offers: null == offers ? _self._offers : offers // ignore: cast_nullable_to_non_nullable +as Map,nextCursor: freezed == nextCursor ? _self.nextCursor : nextCursor // ignore: cast_nullable_to_non_nullable +as String?,isSending: null == isSending ? _self.isSending : isSending // ignore: cast_nullable_to_non_nullable +as bool,errorMessage: freezed == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + -class _$ChatDetailStateImpl extends _ChatDetailState { - const _$ChatDetailStateImpl({ - required this.conversationId, - this.conversation, - final List messages = const [], - final Map offers = const {}, - this.nextCursor, - this.isSending = false, - this.errorMessage, - }) : _messages = messages, - _offers = offers, - super._(); - - @override - final String conversationId; - @override - final Conversation? conversation; - - /// Oldest first, which is the reading order; the route answers newest first. - final List _messages; - - /// Oldest first, which is the reading order; the route answers newest first. - @override - @JsonKey() - List get messages { - if (_messages is EqualUnmodifiableListView) return _messages; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_messages); - } - - /// The negotiations the thread's cards point at, by offer id. A card carries - /// only the id, so the terms are read from here and a counter-offer can never - /// leave an old price on screen. - final Map _offers; - - /// The negotiations the thread's cards point at, by offer id. A card carries - /// only the id, so the terms are read from here and a counter-offer can never - /// leave an old price on screen. - @override - @JsonKey() - Map get offers { - if (_offers is EqualUnmodifiableMapView) return _offers; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_offers); - } - - @override - final String? nextCursor; - @override - @JsonKey() - final bool isSending; - @override - final String? errorMessage; - - @override - String toString() { - return 'ChatDetailState(conversationId: $conversationId, conversation: $conversation, messages: $messages, offers: $offers, nextCursor: $nextCursor, isSending: $isSending, errorMessage: $errorMessage)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ChatDetailStateImpl && - (identical(other.conversationId, conversationId) || - other.conversationId == conversationId) && - (identical(other.conversation, conversation) || - other.conversation == conversation) && - const DeepCollectionEquality().equals(other._messages, _messages) && - const DeepCollectionEquality().equals(other._offers, _offers) && - (identical(other.nextCursor, nextCursor) || - other.nextCursor == nextCursor) && - (identical(other.isSending, isSending) || - other.isSending == isSending) && - (identical(other.errorMessage, errorMessage) || - other.errorMessage == errorMessage)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - conversationId, - conversation, - const DeepCollectionEquality().hash(_messages), - const DeepCollectionEquality().hash(_offers), - nextCursor, - isSending, - errorMessage, - ); - - /// Create a copy of ChatDetailState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ChatDetailStateImplCopyWith<_$ChatDetailStateImpl> get copyWith => - __$$ChatDetailStateImplCopyWithImpl<_$ChatDetailStateImpl>( - this, - _$identity, - ); -} - -abstract class _ChatDetailState extends ChatDetailState { - const factory _ChatDetailState({ - required final String conversationId, - final Conversation? conversation, - final List messages, - final Map offers, - final String? nextCursor, - final bool isSending, - final String? errorMessage, - }) = _$ChatDetailStateImpl; - const _ChatDetailState._() : super._(); - - @override - String get conversationId; - @override - Conversation? get conversation; - - /// Oldest first, which is the reading order; the route answers newest first. - @override - List get messages; - - /// The negotiations the thread's cards point at, by offer id. A card carries - /// only the id, so the terms are read from here and a counter-offer can never - /// leave an old price on screen. - @override - Map get offers; - @override - String? get nextCursor; - @override - bool get isSending; - @override - String? get errorMessage; - - /// Create a copy of ChatDetailState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ChatDetailStateImplCopyWith<_$ChatDetailStateImpl> get copyWith => - throw _privateConstructorUsedError; } + +// dart format on diff --git a/lib/features/chat/presentation/providers/inbox_unread_provider.g.dart b/lib/features/chat/presentation/providers/inbox_unread_provider.g.dart index e62ba67..2714d39 100644 --- a/lib/features/chat/presentation/providers/inbox_unread_provider.g.dart +++ b/lib/features/chat/presentation/providers/inbox_unread_provider.g.dart @@ -6,24 +6,42 @@ part of 'inbox_unread_provider.dart'; // RiverpodGenerator // ************************************************************************** -String _$inboxUnreadHash() => r'9c0a4e3432ce08effdd9912be9735a45a98d9cbc'; - +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning /// Số tin nhắn Chat chưa đọc. -/// -/// Copied from [inboxUnread]. + @ProviderFor(inboxUnread) -final inboxUnreadProvider = AutoDisposeFutureProvider.internal( - inboxUnread, - name: r'inboxUnreadProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$inboxUnreadHash, - dependencies: null, - allTransitiveDependencies: null, -); - -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef InboxUnreadRef = AutoDisposeFutureProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +const inboxUnreadProvider = InboxUnreadProvider._(); + +/// Số tin nhắn Chat chưa đọc. + +final class InboxUnreadProvider + extends $FunctionalProvider, int, FutureOr> + with $FutureModifier, $FutureProvider { + /// Số tin nhắn Chat chưa đọc. + const InboxUnreadProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'inboxUnreadProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$inboxUnreadHash(); + + @$internal + @override + $FutureProviderElement $createElement($ProviderPointer pointer) => + $FutureProviderElement(pointer); + + @override + FutureOr create(Ref ref) { + return inboxUnread(ref); + } +} + +String _$inboxUnreadHash() => r'9c0a4e3432ce08effdd9912be9735a45a98d9cbc'; diff --git a/lib/features/chat/presentation/screens/chat_detail_screen.dart b/lib/features/chat/presentation/screens/chat_detail_screen.dart index 0c6d6d1..dd51b63 100644 --- a/lib/features/chat/presentation/screens/chat_detail_screen.dart +++ b/lib/features/chat/presentation/screens/chat_detail_screen.dart @@ -7,6 +7,7 @@ import 'package:image_picker/image_picker.dart'; import 'package:shopnexus_flutter_app/api/generated/model/ticket_kind.dart'; import 'package:shopnexus_flutter_app/features/ticket/presentation/widgets/raise_ticket_sheet.dart'; +import 'package:shopnexus_flutter_app/features/catalog/data/repositories/catalog_repository.dart'; import 'package:shopnexus_flutter_app/features/chat/data/models/chat_model.dart'; import 'package:shopnexus_flutter_app/features/chat/presentation/providers/chat_notifier.dart'; import 'package:shopnexus_flutter_app/features/chat/presentation/providers/chat_state.dart'; @@ -88,7 +89,17 @@ class _ChatDetailScreenState extends ConsumerState { } Future _counterOffer(Offer offer) async { - final terms = await CounterOfferDialog.show(context, offer); + // Giá niêm yết là trần của mức giá trả lại, và DTO của offer không mang nó — + // nó chỉ mang `variant_id`. Một lượt đọc để hộp thoại nói được câu "không + // cao hơn X" ngay lúc gõ; hỏng thì vẫn mở hộp thoại, và server là chỗ giữ + // luật. + final askingUnitPrice = await _askingUnitPrice(offer); + if (!mounted) return; + final terms = await CounterOfferDialog.show( + context, + offer, + askingUnitPrice: askingUnitPrice, + ); if (terms == null) return; await _notifier.counterOffer( offer.id, @@ -98,6 +109,24 @@ class _ChatDetailScreenState extends ConsumerState { ); } + /// Giá đang niêm yết của đúng biến thể đang thương lượng, hoặc null nếu không + /// tra được — biến thể bị gỡ, mạng hỏng, hay tin đăng đã xoá. + Future _askingUnitPrice(Offer offer) async { + try { + final detail = await ref + .read(catalogRepositoryProvider) + .listingDetail(offer.listingId); + for (final variant in detail.variants) { + if (variant.id == offer.variantId) return variant.price; + } + } catch (_) { + // Nuốt có chủ đích: đây là thứ làm câu báo lỗi đẹp hơn, không phải điều + // kiện để trả giá. Chặn người ta trả giá vì một lượt đọc phụ hỏng là đổi + // một bất tiện lấy một chức năng. + } + return null; + } + Future _reportCounterparty(Conversation conversation) async { final ticket = await RaiseTicketSheet.show( context, diff --git a/lib/features/chat/presentation/widgets/counter_offer_dialog.dart b/lib/features/chat/presentation/widgets/counter_offer_dialog.dart index feaaac0..a4eb7b5 100644 --- a/lib/features/chat/presentation/widgets/counter_offer_dialog.dart +++ b/lib/features/chat/presentation/widgets/counter_offer_dialog.dart @@ -23,14 +23,32 @@ class CounterOfferTerms { } class CounterOfferDialog extends StatefulWidget { - const CounterOfferDialog({super.key, required this.offer}); + const CounterOfferDialog({ + super.key, + required this.offer, + this.askingUnitPrice, + }); final Offer offer; - static Future show(BuildContext context, Offer offer) { + /// Giá niêm yết của biến thể đang thương lượng, và là trần của mọi mức giá gõ + /// ở đây: thương lượng chỉ đi xuống, nên server trả 422 `offer_above_asking` + /// cho một tổng vượt qua nó. + /// + /// Null khi người gọi không tra được — DTO của offer không mang giá niêm yết, + /// nên nó là một lượt đọc riêng và lượt đọc đó có thể hỏng. Lúc đó hộp thoại + /// không tự bịa ra một cái trần: server vẫn là chỗ giữ luật. + final int? askingUnitPrice; + + static Future show( + BuildContext context, + Offer offer, { + int? askingUnitPrice, + }) { return showDialog( context: context, - builder: (_) => CounterOfferDialog(offer: offer), + builder: (_) => + CounterOfferDialog(offer: offer, askingUnitPrice: askingUnitPrice), ); } @@ -48,6 +66,14 @@ class _CounterOfferDialogState extends State { ); late int _quantity = widget.offer.quantity; + /// Trần của **tổng tiền**, vì ô nhập là tổng chứ không phải giá mỗi cái — cùng + /// phép so sánh server làm. Đổi theo số lượng, nên nút cộng/trừ cũng phải chạy + /// lại `validate`. + int? get _ceiling { + final unit = widget.askingUnitPrice; + return unit == null || unit <= 0 ? null : unit * _quantity; + } + @override void dispose() { _totalController.dispose(); @@ -55,6 +81,13 @@ class _CounterOfferDialogState extends State { super.dispose(); } + /// Số lượng đổi thì cái trần đổi theo, nên câu báo lỗi đang hiện phải được hỏi + /// lại — không thì một tổng vừa hợp lệ vẫn đỏ, hoặc ngược lại. + void _setQuantity(int delta) { + setState(() => _quantity += delta); + if (_ceiling != null) _formKey.currentState?.validate(); + } + void _submit() { if (!(_formKey.currentState?.validate() ?? false)) return; Navigator.of(context).pop( @@ -100,6 +133,12 @@ class _CounterOfferDialogState extends State { if (parsed == null || parsed < 1) { return 'Vui lòng nhập số tiền hợp lệ'; } + final ceiling = _ceiling; + if (ceiling != null && parsed > ceiling) { + return 'Không cao hơn giá niêm yết ' + '(${MoneyUtils.format(ceiling, currency: currency)} ' + 'cho $_quantity sản phẩm)'; + } return null; }, ), @@ -110,14 +149,12 @@ class _CounterOfferDialogState extends State { child: Text('Số lượng', style: theme.textTheme.bodyMedium), ), IconButton( - onPressed: _quantity > 1 - ? () => setState(() => _quantity--) - : null, + onPressed: _quantity > 1 ? () => _setQuantity(-1) : null, icon: const Icon(Icons.remove_circle_outline), ), Text('$_quantity', style: theme.textTheme.titleMedium), IconButton( - onPressed: () => setState(() => _quantity++), + onPressed: () => _setQuantity(1), icon: const Icon(Icons.add_circle_outline), ), ], diff --git a/lib/features/checkout/data/repositories/checkout_repository.g.dart b/lib/features/checkout/data/repositories/checkout_repository.g.dart index da6fbd3..52aba3b 100644 --- a/lib/features/checkout/data/repositories/checkout_repository.g.dart +++ b/lib/features/checkout/data/repositories/checkout_repository.g.dart @@ -6,24 +6,53 @@ part of 'checkout_repository.dart'; // RiverpodGenerator // ************************************************************************** -String _$checkoutRepositoryHash() => - r'caecfc1b089323c4940b0b3eb6e68c011d3834ed'; +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning -/// See also [checkoutRepository]. @ProviderFor(checkoutRepository) -final checkoutRepositoryProvider = - AutoDisposeProvider.internal( - checkoutRepository, - name: r'checkoutRepositoryProvider', - debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product') - ? null - : _$checkoutRepositoryHash, - dependencies: null, - allTransitiveDependencies: null, +const checkoutRepositoryProvider = CheckoutRepositoryProvider._(); + +final class CheckoutRepositoryProvider + extends + $FunctionalProvider< + CheckoutRepository, + CheckoutRepository, + CheckoutRepository + > + with $Provider { + const CheckoutRepositoryProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'checkoutRepositoryProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$checkoutRepositoryHash(); + + @$internal + @override + $ProviderElement $createElement( + $ProviderPointer pointer, + ) => $ProviderElement(pointer); + + @override + CheckoutRepository create(Ref ref) { + return checkoutRepository(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(CheckoutRepository value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), ); + } +} -@Deprecated('Will be removed in 3.0. Use Ref instead') -// ignore: unused_element -typedef CheckoutRepositoryRef = AutoDisposeProviderRef; -// ignore_for_file: type=lint -// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member, deprecated_member_use_from_same_package +String _$checkoutRepositoryHash() => + r'caecfc1b089323c4940b0b3eb6e68c011d3834ed'; diff --git a/lib/features/checkout/presentation/providers/checkout_provider.freezed.dart b/lib/features/checkout/presentation/providers/checkout_provider.freezed.dart index c1045f1..8daf674 100644 --- a/lib/features/checkout/presentation/providers/checkout_provider.freezed.dart +++ b/lib/features/checkout/presentation/providers/checkout_provider.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,535 +9,348 @@ part of 'checkout_provider.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models', -); - /// @nodoc mixin _$CheckoutState { - CheckoutStep get step => throw _privateConstructorUsedError; - List get contacts => throw _privateConstructorUsedError; - Contact? get selectedContact => throw _privateConstructorUsedError; - List get lines => throw _privateConstructorUsedError; - - /// Phiên mua đã mở cho tin đăng này. Nó phải tồn tại **trước** khi hỏi phí vận - /// chuyển: `POST /shipping-quotes` bắt phải nêu đúng một nguồn — một variant, - /// một draft, hay một offer — và trang thanh toán có nhiều dòng nên nguồn của - /// nó là draft. Thiếu nó thì route trả 400 `quote_source_invalid`, và màn hình - /// chỉ thấy một danh sách rỗng nên nói nhầm thành "chưa có báo giá cho địa chỉ - /// này". - DraftOrder? get draft => throw _privateConstructorUsedError; - ShippingQuotes? get shippingQuotes => throw _privateConstructorUsedError; - - /// The carrier slug the buyer is buying, always one `POST /shipping-quotes` - /// answered — never a label. Null until a quote has been asked for. - String? get transportOption => throw _privateConstructorUsedError; - - /// The rails this deployment can charge on, and the one the buyer picked. Read from - /// `GET /options?category=payment` rather than named here: a hardcoded slug is a - /// checkout that breaks the day an operator retires that rail. - List