diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml new file mode 100644 index 0000000..4b3d30e --- /dev/null +++ b/.github/workflows/ios.yml @@ -0,0 +1,150 @@ +name: Build & Deploy iOS to TestFlight + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: macos-26 + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + # Dipin biar CI nggak ikut naik versi diam-diam. + # Flutter 3.47 mensyaratkan iOS deployment target minimal 15.0. + flutter-version: "3.47.0" + cache: true + + - name: Install Dependencies + run: flutter pub get + + # ── Code Signing Setup ────────────────────────────────────────────────── + + - name: Install Apple Certificate + env: + BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} + P12_PASSWORD: ${{ secrets.P12_PASSWORD }} + KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }} + run: | + CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 + echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH + + KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db + security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security set-keychain-settings -lut 21600 $KEYCHAIN_PATH + security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + + security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A \ + -t cert -f pkcs12 -k $KEYCHAIN_PATH + security set-key-partition-list -S apple-tool:,apple: \ + -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH + security list-keychain -d user -s $KEYCHAIN_PATH + + - name: Install Provisioning Profile + env: + BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }} + run: | + PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision + echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH + + mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + + # Xcode requires the filename to be the profile's UUID + UUID=$(security cms -D -i $PP_PATH | plutil -extract UUID raw -) + cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles/$UUID.mobileprovision + echo "Installed provisioning profile UUID: $UUID" + + # ── Disable SPM ───────────────────────────────────────────────────────── + + - name: Disable Swift Package Manager + run: flutter config --no-enable-swift-package-manager + + # ── CocoaPods ─────────────────────────────────────────────────────────── + + - name: Install CocoaPods Dependencies + run: | + cd ios + rm -rf Pods Podfile.lock + pod install --repo-update + + # ── Build & Archive ───────────────────────────────────────────────────── + + - name: Build iOS (no codesign) + run: flutter build ios --release --no-codesign + + - name: Re-run pod install to apply Podfile signing settings + run: | + cd ios + pod install + + - name: Archive with Xcode + env: + TEAM_ID: ${{ secrets.TEAM_ID }} + run: | + cat > $RUNNER_TEMP/signing.xcconfig << 'XCCONFIG' + CODE_SIGN_STYLE = Manual + CODE_SIGN_IDENTITY = iPhone Distribution + PROVISIONING_PROFILE_SPECIFIER = Enaklo Customer + CODE_SIGNING_REQUIRED = YES + XCCONFIG + + xcodebuild archive \ + -workspace ios/Runner.xcworkspace \ + -scheme Runner \ + -configuration Release \ + -archivePath $RUNNER_TEMP/Runner.xcarchive \ + -destination "generic/platform=iOS" \ + -xcconfig $RUNNER_TEMP/signing.xcconfig \ + DEVELOPMENT_TEAM="$TEAM_ID" + + - name: Export IPA + run: | + xcodebuild -exportArchive \ + -archivePath $RUNNER_TEMP/Runner.xcarchive \ + -exportPath $RUNNER_TEMP/export \ + -exportOptionsPlist ios/ExportOptions.plist + + mkdir -p build/ios/ipa + cp $RUNNER_TEMP/export/*.ipa build/ios/ipa/ + + # ── Upload to TestFlight ──────────────────────────────────────────────── + + - name: Upload to TestFlight via Transporter + env: + APPLE_ID: ${{ secrets.APPLE_ID }} + APP_SPECIFIC_PASSWORD: ${{ secrets.APP_SPECIFIC_PASSWORD }} + run: | + IPA_PATH=$(find build/ios/ipa -name "*.ipa" | head -1) + echo "Uploading: $IPA_PATH" + xcrun altool --upload-app \ + --type ios \ + --file "$IPA_PATH" \ + --username "$APPLE_ID" \ + --password "$APP_SPECIFIC_PASSWORD" \ + --verbose + + # ── Cleanup ───────────────────────────────────────────────────────────── + + - name: Clean Up Keychain and Provisioning Profile + if: ${{ always() }} + run: | + security delete-keychain $RUNNER_TEMP/app-signing.keychain-db || true + rm -rf ~/Library/MobileDevice/Provisioning\ Profiles/*.mobileprovision || true + + # ── Artifact ──────────────────────────────────────────────────────────── + + - name: Upload IPA as Artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: ios-ipa + path: build/ios/ipa/*.ipa + retention-days: 7 diff --git a/analysis_options.yaml b/analysis_options.yaml index 1d331a6..cc6db84 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -18,3 +18,10 @@ analyzer: - test/generated/** - "**/**.g.dart" - "**/**.freezed.dart" + - build/** + - android/** + - ios/** + - web/** + - windows/** + - macos/** + - linux/** diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 0ff489c..5100454 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } android { - namespace = "com.appskel.enaklo" + namespace = "com.apskel.enaklocustomer" compileSdk = flutter.compileSdkVersion ndkVersion = "27.0.12077973" @@ -21,7 +21,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId = "com.appskel.enaklo" + applicationId = "com.apskel.enaklocustomer" // You can update the following values to match your application needs. // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion diff --git a/android/app/src/main/kotlin/com/apskel/enaklocustomer/MainActivity.kt b/android/app/src/main/kotlin/com/apskel/enaklocustomer/MainActivity.kt new file mode 100644 index 0000000..227117b --- /dev/null +++ b/android/app/src/main/kotlin/com/apskel/enaklocustomer/MainActivity.kt @@ -0,0 +1,36 @@ +package com.apskel.enaklocustomer + +import android.os.Build +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.FlutterEngine +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugins.webviewflutter.WebViewFlutterAndroidExternalApi + +class MainActivity : FlutterActivity() { + override fun configureFlutterEngine(flutterEngine: FlutterEngine) { + super.configureFlutterEngine(flutterEngine) + + // Pengaturan WebView yang tidak disediakan plugin webview_flutter. + MethodChannel(flutterEngine.dartExecutor.binaryMessenger, WEBVIEW_CHANNEL) + .setMethodCallHandler { call, result -> + when (call.method) { + "enableOffscreenPreRaster" -> { + val id = call.argument("webViewId")?.toLong() + @Suppress("DEPRECATION") + val webView = id?.let { + WebViewFlutterAndroidExternalApi.getWebView(flutterEngine, it) + } + if (webView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + webView.settings.offscreenPreRaster = true + } + result.success(webView != null) + } + else -> result.notImplemented() + } + } + } + + private companion object { + const val WEBVIEW_CHANNEL = "com.apskel.enaklocustomer/webview" + } +} diff --git a/android/app/src/main/kotlin/com/example/enaklo/MainActivity.kt b/android/app/src/main/kotlin/com/example/enaklo/MainActivity.kt deleted file mode 100644 index e15afe1..0000000 --- a/android/app/src/main/kotlin/com/example/enaklo/MainActivity.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.appskel.enaklo - -import io.flutter.embedding.android.FlutterActivity - -class MainActivity : FlutterActivity() diff --git a/android/build/reports/problems/problems-report.html b/android/build/reports/problems/problems-report.html new file mode 100644 index 0000000..d098403 --- /dev/null +++ b/android/build/reports/problems/problems-report.html @@ -0,0 +1,663 @@ + + + + + + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git a/android/gradle.properties b/android/gradle.properties index f018a61..475a628 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,3 +1,7 @@ org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true +# This builtInKotlin flag was added automatically by Flutter migrator +android.builtInKotlin=false +# This newDsl flag was added automatically by Flutter migrator +android.newDsl=false diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index ac3b479..74b269f 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts index ab39a10..da20e6d 100644 --- a/android/settings.gradle.kts +++ b/android/settings.gradle.kts @@ -18,8 +18,8 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" - id("com.android.application") version "8.7.3" apply false - id("org.jetbrains.kotlin.android") version "2.1.0" apply false + id("com.android.application") version "8.11.1" apply false + id("org.jetbrains.kotlin.android") version "2.2.20" apply false } include(":app") diff --git a/assets/icons/enakcoin_icon.png b/assets/icons/enakcoin_icon.png new file mode 100644 index 0000000..b32496c Binary files /dev/null and b/assets/icons/enakcoin_icon.png differ diff --git a/assets/icons/enakcommunity_icon.png b/assets/icons/enakcommunity_icon.png new file mode 100644 index 0000000..5801562 Binary files /dev/null and b/assets/icons/enakcommunity_icon.png differ diff --git a/assets/icons/enakgame_icon.png b/assets/icons/enakgame_icon.png new file mode 100644 index 0000000..0d74b79 Binary files /dev/null and b/assets/icons/enakgame_icon.png differ diff --git a/assets/icons/enaknews_icon.png b/assets/icons/enaknews_icon.png new file mode 100644 index 0000000..62305ba Binary files /dev/null and b/assets/icons/enaknews_icon.png differ diff --git a/assets/icons/enakpoint_icon.png b/assets/icons/enakpoint_icon.png new file mode 100644 index 0000000..6f43ebc Binary files /dev/null and b/assets/icons/enakpoint_icon.png differ diff --git a/assets/icons/enakpromo_icon.png b/assets/icons/enakpromo_icon.png new file mode 100644 index 0000000..ce3183d Binary files /dev/null and b/assets/icons/enakpromo_icon.png differ diff --git a/assets/icons/enakreward_icon.png b/assets/icons/enakreward_icon.png new file mode 100644 index 0000000..521b36a Binary files /dev/null and b/assets/icons/enakreward_icon.png differ diff --git a/assets/icons/enakshop_icon.png b/assets/icons/enakshop_icon.png new file mode 100644 index 0000000..46534c0 Binary files /dev/null and b/assets/icons/enakshop_icon.png differ diff --git a/assets/icons/enaktransfer_icon.png b/assets/icons/enaktransfer_icon.png new file mode 100644 index 0000000..b4a2c88 Binary files /dev/null and b/assets/icons/enaktransfer_icon.png differ diff --git a/docs/mobile-customer-enakpoint.md b/docs/mobile-customer-enakpoint.md new file mode 100644 index 0000000..4934510 --- /dev/null +++ b/docs/mobile-customer-enakpoint.md @@ -0,0 +1,617 @@ +# Prompt: fitur EnakPoint & EnakCoin di Mobile App Customer + +Kamu mengerjakan aplikasi mobile untuk **customer** (bukan kasir, bukan backoffice). +Tugasmu: membangun fitur loyalitas EnakPoint & EnakCoin di aplikasi, memakai API backend +yang sudah jadi dan dijelaskan di dokumen ini. Jangan mengarang endpoint, field, atau +aturan yang tidak tertulis di sini; kalau ada yang kurang jelas, tanyakan dulu. + +--- + +## 1. Konteks bisnis + +| | EnakPoint (`POINT`) | EnakCoin (`COIN`) | +| ----------------------------- | ---------------------------------------------------- | ----------------------------------- | +| Didapat dari | Belanja (order lunas), koreksi admin, tukar EnakCoin | Belanja, koreksi admin | +| Dipakai untuk | **Membayar order** | **Main game**, ditukar ke EnakPoint | +| Bisa dikirim ke customer lain | Ya | Ya | +| Bisa kedaluwarsa | Ya, bila owner mengaktifkan | Ya, bila owner mengaktifkan | + +Tidak ada lagi "token". Semua yang dulu token sekarang EnakCoin, dan endpoint serta +field bernama token sudah dihapus dari API. + +### Aturan yang wajib dipatuhi di UI + +1. **Semua jumlah bilangan bulat.** Tidak ada desimal pada EnakPoint atau EnakCoin. +2. **Saldo bukan uang.** Nilai rupiah EnakPoint selalu ditulis **"setara potongan + Rp …"**, tidak pernah "saldo Rp …" atau "uang". Tidak ada fitur tarik tunai. +3. **PIN 6 digit wajib** untuk: membuat kode bayar, tukar + EnakCoin, dan transfer. **Main game tidak butuh PIN.** Melihat saldo dan riwayat + tidak butuh PIN. +4. **PIN terpisah dari password login** dan selalu dikirim sebagai **string** (supaya + nol di depan tidak hilang). Jangan pernah menyimpan PIN di perangkat, log, atau + analytics. +5. **Satu akun customer = satu organisasi.** Saldo berlaku di semua outlet organisasi itu. +6. **Waktu memakai WIB.** Tanggal kedaluwarsa berarti saldo masih bisa dipakai sampai + 23:59:59 WIB di tanggal itu. + +--- + +## 2. Koneksi ke API + +- Base URL: `/api/v1` +- Semua endpoint customer: header `Authorization: Bearer ` +- Semua jumlah di request dan response berupa integer. + +### Registrasi customer + +`POST /api/v1/customer-auth/register/start` menerima `organization_id` (opsional): + +```json +{ "phone_number": "0812…", "name": "Budi", "birth_date": "2000-01-31", "organization_id": "648b96a0-1d1d-414e-baee-37e9d6317b4e" } +``` + +- Customer terdaftar di satu organisasi, dan saldonya berlaku di semua outlet organisasi itu. +- Bila `organization_id` tidak dikirim dan backend hanya punya satu organisasi, customer + otomatis masuk ke organisasi itu. Bila ada lebih dari satu, registrasi ditolak + ("organization_id is required"), jadi sebaiknya app selalu mengirimnya dari config per + environment/brand. +- `organization_id` yang dikirim harus ada; bila tidak, registrasi ditolak sebelum OTP dikirim. +- Wallet customer baru belum punya baris sampai saldo pertama kali bergerak; + `GET /customer/wallet` tetap menjawab saldo 0. + +### Format response + +Sukses: + +```json +{ "success": true, "data": { … }, "errors": null } +``` + +Gagal: + +```json +{ "success": false, "data": null, "errors": [{ "code": "304", "entity": "wallet_service", "cause": "wallet move refused: not enough EnakCoin" }] } +``` + +| `errors[0].code` | HTTP | Arti | Yang dilakukan app | +| ------------------ | ---- | ------------------------------------ | ------------------------------------------------------------------------------------------------- | +| `303`, `310` | 400 | Request tidak lengkap / salah format | Bug di app; tampilkan pesan umum | +| `304` | 400 | Ditolak aturan bisnis | Tampilkan pesan yang ramah (lihat tiap fitur); `cause` berbahasa Inggris, jangan tampilkan mentah | +| `404` | 404 | Tidak ditemukan | Tampilkan "tidak ditemukan" | +| `429` | 429 | Minta OTP terlalu cepat | Tampilkan hitung mundur sebelum boleh minta lagi | +| `PIN_NOT_SET` | 403 | Belum punya PIN | Buka alur buat PIN (§6.2) | +| `PIN_INVALID` | 400 | PIN salah | §6.5 | +| `PIN_LOCKED` | 423 | PIN terkunci | §6.5 | +| `TRANSFER_BLOCKED` | 403 | Transfer ditahan setelah reset PIN | §6.5 | +| `900` | 500 | Error server | "Terjadi kesalahan, coba lagi" | + +### Idempotency-Key + +Endpoint **tukar** dan **transfer** wajib header `Idempotency-Key` (string unik, maks. +50 karakter, mis. UUID v4). + +- Buat **satu key baru saat customer menekan tombol konfirmasi**. +- Bila request gagal karena jaringan/timeout, **kirim ulang dengan key yang sama**. + Server mengembalikan hasil pertama dengan `"replayed": true` dan tidak memotong saldo + dua kali. +- Jangan pakai ulang key untuk transaksi yang berbeda; server menolaknya (`304`). + +--- + +## 3. Layar yang perlu dibuat + +| Layar | Endpoint utama | Butuh PIN | +| -------------------------------- | ------------------------------------------------------------ | --------- | +| Beranda wallet | `GET /customer/wallet` | – | +| Riwayat mutasi | `GET /customer/wallet/transactions` | – | +| Saldo akan kedaluwarsa | `GET /customer/wallet/expiring` | – | +| Daftar outlet | `GET /customer/outlets` | – | +| Riwayat order + detail | `GET /customer/orders`, `GET /customer/orders/:id` | – | +| Kode bayar (angka + QR) | `POST /customer/wallet/payment-code` | Ya | +| Tukar EnakCoin | `GET …/exchange/preview`, `POST /customer/wallet/exchange` | Ya | +| Transfer | `GET …/transfer/recipient`, `POST /customer/wallet/transfer` | Ya | +| PIN (buat, ganti, lupa) | `/customer/pin/*` | – | +| Game | `POST /customer/spin` | – | +| (latar belakang) registrasi push | `PUT` / `DELETE /customer/devices` | – | + +--- + +## 4. Beranda wallet, riwayat, kedaluwarsa + +### 4.1 Beranda — `GET /customer/wallet` + +```json +{ + "point_balance": 12500, + "coin_balance": 8, + "point_value": 1, + "point_discount_value": 12500, + "nearest_expiring": { + "point": { "amount": 150, "date": "2026-12-31" }, + "coin": null + }, + "recent_transactions": [ + /* sama dengan item riwayat §4.2, maksimal 5 */ + ] +} +``` + +Tampilkan: + +- Saldo EnakPoint (`point_balance`) dengan keterangan "setara potongan Rp + {point_discount_value}" (format ribuan Indonesia: `Rp 12.500`). +- Saldo EnakCoin (`coin_balance`). +- Bila `nearest_expiring.point` / `.coin` tidak `null`: banner "{amount} EnakPoint akan + kedaluwarsa pada {date}" yang membuka layar §4.3. +- 5 mutasi terakhir dari `recent_transactions`, dengan tautan "Lihat semua" ke §4.2. +- Tombol aksi: Bayar di kasir (§7.1), Tukar EnakCoin (§8.1), Transfer (§8.2), Main game (§9). + +Muat ulang beranda setelah setiap transaksi dan saat menerima push (§5). + +Field `total_points`, `points_history`, `last_updated` di response ini **deprecated**; +jangan dipakai. + +### 4.2 Riwayat — `GET /customer/wallet/transactions` + +Query (semua opsional): + +| Query | Contoh | Keterangan | +| ------------ | -------------- | --------------------------------------------------- | +| `page` | `1` | Mulai dari 1 | +| `limit` | `20` | 1–100, default 20 | +| `currency` | `POINT` | `POINT` atau `COIN`; untuk tab EnakPoint / EnakCoin | +| `type` | `EARN,PAYMENT` | Satu atau beberapa tipe dipisah koma, untuk filter | +| `from`, `to` | `2026-09-01` | Tanggal WIB, inklusif | + +```json +{ + "data": [ + { + "id": "…", + "currency": "POINT", + "type": "EARN", + "amount": 875, + "balance_after": 12500, + "description": "Belanja #ORD-0123 di Outlet Kemang", + "source": { "type": "ORDER", "id": "…" }, + "outlet_id": "…", + "group_id": null, + "expires_at": "2026-12-31T23:59:59+07:00", + "lots": [{ "amount": 875, "remaining": 875, "expires_at": "2026-12-31T23:59:59+07:00" }], + "created_at": "2026-09-30T12:01:00Z" + } + ], + "pagination": { "page": 1, "limit": 20, "total_count": 42, "total_pages": 3 } +} +``` + +Aturan tampilan: + +- `amount` bertanda: positif tampil hijau dengan `+`, negatif merah dengan `−`. +- `description` sudah siap tampil (nama lawan transfer sudah disamarkan). Tampilkan apa + adanya. +- Mutasi masuk yang punya `expires_at` menampilkan "Berlaku sampai {tanggal}". +- Infinite scroll memakai `pagination.total_pages`. +- Riwayat tidak pernah berubah atau hilang; koreksi muncul sebagai baris baru. + +Label tipe: + +| `type` | Label | Arah | +| ---------------- | --------------------------------- | ----- | +| `EARN` | Dari belanja | + | +| `EARN_REVERSAL` | Dibatalkan (order di-void/refund) | − | +| `PAYMENT` | Bayar pesanan | − | +| `PAYMENT_REFUND` | Pengembalian pembayaran | + | +| `EXCHANGE_OUT` | Ditukar ke EnakPoint | − | +| `EXCHANGE_IN` | Hasil tukar EnakCoin | + | +| `TRANSFER_OUT` | Transfer keluar | − | +| `TRANSFER_IN` | Transfer masuk | + | +| `GAME_SPEND` | Main game | − | +| `EXPIRE` | Kedaluwarsa | − | +| `ADJUSTMENT` | Koreksi | + / − | +| `MIGRATION` | Saldo awal | + | + +### 4.3 Akan kedaluwarsa — `GET /customer/wallet/expiring` + +```json +{ + "point": [ + { "amount": 150, "date": "2026-10-31" }, + { "amount": 200, "date": "2026-12-31" } + ], + "coin": [] +} +``` + +Daftar per tanggal, paling dekat di atas. Daftar kosong: tampilkan "Tidak ada saldo +yang akan kedaluwarsa". Saldo yang kedaluwarsa hangus tanpa kompensasi. + +--- + +### 4.4 Daftar outlet — `GET /customer/outlets` + +Outlet aktif di organisasi customer, tempat saldo EnakPoint & EnakCoin berlaku. Urut +berdasarkan nama. + +```json +[ + { + "id": "…", + "name": "Gokuna Kemang", + "address": "Jl. Kemang Raya 10", + "accepts_point_payment": true, + "earns_points": true, + "earns_coins": false + } +] +``` + +- `address` bisa `null`. +- `accepts_point_payment`: kasir di outlet ini menerima pembayaran EnakPoint. Pakai + untuk label "Bisa bayar pakai EnakPoint". +- `earns_points` / `earns_coins`: belanja di outlet ini memberi EnakPoint / EnakCoin. +- Belum ada telepon, koordinat, atau jam buka; data itu belum disimpan di backend. + +### 4.5 Riwayat order — `GET /customer/orders` dan `GET /customer/orders/:id` + +Order milik customer yang login di semua outlet organisasinya, terbaru di atas. Order +hanya masuk ke sini bila kasir mengaitkannya ke customer. + +`GET /api/v1/customer/orders?page=1&limit=20` (`limit` 1–100, default 20): + +```json +{ + "data": [ + { + "id": "…", + "order_number": "ORD-0123", + "outlet_id": "…", + "outlet_name": "Gokuna 1", + "order_type": "dine_in", + "status": "completed", + "payment_status": "completed", + "total_amount": 99000, + "item_count": 2, + "is_void": false, + "is_refund": false, + "points_earned": 865, + "coins_earned": 3, + "created_at": "2026-09-30T12:01:00Z" + } + ], + "pagination": { "page": 1, "limit": 20, "total_count": 42, "total_pages": 3 } +} +``` + +`GET /api/v1/customer/orders/{id}` mengembalikan field yang sama, ditambah: + +```json +{ + "table_number": "A3", + "subtotal": 90000, + "discount_amount": 0, + "tax_amount": 9000, + "refund_amount": 0, + "items": [ + { + "id": "…", + "product_id": "…", + "product_name": "Kopi Susu", + "variant_name": "Large", + "quantity": 2, + "unit_price": 25000, + "total_price": 50000, + "refund_quantity": 0, + "modifiers": [], + "status": "completed" + }, + { + "id": "…", + "product_id": "…", + "product_name": "Ikan Tude", + "variant_name": null, + "quantity": 1, + "weight": 4.2, + "unit_name": "ons", + "unit_price": 4500, + "total_price": 18900, + "refund_quantity": 0, + "modifiers": [], + "status": "completed" + } + ], + "payments": [ + { "id": "…", "method_name": "EnakPoint", "method_type": "point", "amount": 12500, "status": "completed", "refund_amount": 0, "points_used": 12500, "point_value": 1, "created_at": "…" }, + { "id": "…", "method_name": "Cash", "method_type": "cash", "amount": 86500, "status": "completed", "refund_amount": 0, "created_at": "…" } + ] +} +``` + +- Order customer lain atau yang tidak ada → `404`. +- `points_earned` / `coins_earned`: yang didapat dari order ini; 0 bila tidak ada. +- Item timbangan membawa `weight` dan `unit_name`; tampilkan "1 × 4,2 ons". +- Pembayaran EnakPoint membawa `points_used`; tampilkan "EnakPoint 12.500 (Rp 12.500)". +- Order yang `is_void` atau `is_refund` tetap tampil, beri label "Dibatalkan" / + "Direfund". + +## 5. Notifikasi push (FCM) + +### 5.1 Registrasi device + +Setelah login berhasil **dan** setiap kali FCM memberi token baru (`onTokenRefresh`): + +`PUT /api/v1/customer/devices` + +```json +{ "device_id": "", "fcm_token": "", "platform": "android", "app_version": "2.4.0" } +``` + +- `device_id` wajib, stabil untuk satu instalasi (simpan di secure storage). +- `platform`: `android`, `ios`, atau `web`. +- Saat **logout**, panggil `DELETE /api/v1/customer/devices/{device_id}` sebelum + menghapus token login, supaya HP itu tidak lagi menerima notifikasi akun ini. + +Tanpa registrasi ini, customer tidak menerima push apa pun. + +### 5.2 Tipe push + +Semua nilai di `data` berupa string. + +| `data.type` | Kapan | Isi `data` lain | Aksi saat di-tap | +| -------------------- | ---------------------------------- | -------------------------------------------------- | --------------------------------- | +| `WALLET_TRANSFER_IN` | Menerima transfer | `transaction_id`, `group_id`, `currency`, `amount` | Buka riwayat, sorot transaksi itu | +| `WALLET_EXPIRING` | Beberapa hari sebelum saldo hangus | `currency`, `amount`, `expiry_date` | Buka layar kedaluwarsa (§4.3) | +| `WALLET_EXPIRED` | Saldo baru saja hangus | `currency`, `amount` | Buka riwayat | +| `PIN_LOCKED` | PIN terkunci setelah 5 kali salah | `locked_until` (RFC3339 UTC) | Buka layar lupa PIN (§6.4) | + +Saat app terbuka dan menerima push wallet, muat ulang beranda. + +--- + +## 6. PIN + +### 6.1 Kapan diminta + +Jangan minta PIN saat registrasi. Minta saat customer **pertama kali** melakukan aksi +yang butuh PIN. Cek dengan: + +`GET /api/v1/customer/pin/status` → `{ "has_pin": false, "locked_until": null, "transfer_blocked_until": null }` + +Bila `has_pin: false`, arahkan ke alur buat PIN, lalu kembali ke aksi semula. + +### 6.2 Buat PIN + +1. `POST /api/v1/customer/pin/otp` dengan `{ "purpose": "pin_setup" }`. + Response: `{ "purpose": "pin_setup", "otp_token": "…", "expires_at": "…" }`. + OTP dikirim ke WhatsApp customer. +2. Customer memasukkan kode OTP, lalu PIN dua kali. +3. `POST /api/v1/customer/pin` dengan + `{ "otp_token": "…", "otp_code": "123456", "pin": "482913", "confirm_pin": "482913" }`. + Response: status PIN. + +Validasi di app sebelum kirim (server juga memeriksa, jawab `304`): + +- Tepat 6 digit angka, dan konfirmasi sama. +- Bukan satu digit berulang (`111111`). +- Bukan berurutan naik/turun (`123456`, `654321`). +- Bukan tanggal lahir customer (`DDMMYY` atau `YYMMDD`). + +Minta OTP lagi terlalu cepat → `429`: tampilkan hitung mundur. + +### 6.3 Ganti PIN + +`PUT /api/v1/customer/pin` dengan `{ "old_pin": "…", "pin": "…", "confirm_pin": "…" }`. + +### 6.4 Lupa PIN + +1. `POST /customer/pin/otp` dengan `{ "purpose": "pin_reset" }`. +2. `POST /customer/pin/reset` dengan `{ "otp_token", "otp_code", "pin", "confirm_pin" }`. + +Reset juga membuka PIN yang terkunci. Setelah reset, **transfer keluar ditahan 24 jam**; +bayar dan tukar tetap bisa. Beri tahu customer hal ini di layar sukses. + +### 6.5 Menangani error PIN + +Semua endpoint yang menerima `pin` bisa menjawab error PIN. Pada error ini **`data` +tidak `null`**: + +```json +{ "success": false, "data": { "code": "PIN_INVALID", "remaining_attempts": 3 }, "errors": [ … ] } +``` + +| `data.code` | Field tambahan | Tampilan | +| ------------------ | ------------------------ | ---------------------------------------------------- | +| `PIN_NOT_SET` | – | Buka alur buat PIN (§6.2) | +| `PIN_INVALID` | `remaining_attempts` | "PIN salah, sisa {n} percobaan." Kosongkan input PIN | +| `PIN_LOCKED` | `locked_until` | "PIN terkunci sampai {jam}." Tombol "Lupa PIN" | +| `TRANSFER_BLOCKED` | `transfer_blocked_until` | "Transfer bisa dilakukan lagi pada {waktu}." | + +5 kali salah berturut-turut mengunci PIN 30 menit; selama terkunci PIN yang benar pun +ditolak. Penghitung ada di server, jadi jangan membuat penghitung sendiri di app. + +--- + +## 7. Membayar dengan EnakPoint + +App customer tidak membuat atau membayar order; order hanya bisa dilihat (§4.5). +EnakPoint hanya dipakai membayar di kasir, lewat kode bayar dari app. Jangan membangun +layar checkout atau memanggil `POST /customer/orders/:id/pay-with-points`. + +### 7.1 Di kasir — kode bayar + +Customer tidak pernah mengetik PIN di mesin kasir. Alurnya: + +1. Customer membuka "Bayar di kasir" dan memasukkan PIN. +2. `POST /api/v1/customer/wallet/payment-code` dengan `{ "pin": "482913" }`: + + ```json + { "code": "482913", "qr_payload": "enakpoint:482913", "expires_at": "2026-09-30T05:02:00Z" } + ``` + +3. Tampilkan `code` besar (angka) **dan** QR dari `qr_payload` (string apa adanya). +4. Tampilkan hitung mundur ke `expires_at` (2 menit). Setelah habis, sembunyikan kode + dan tampilkan tombol "Buat kode baru". +5. Kasir memindai/mengetik kode dan memilih jumlah EnakPoint. App tidak menerima + callback; setelah customer kembali ke beranda, muat ulang saldo. + +Kode sekali pakai. Membuat kode baru membatalkan kode lama. + +### 7.2 Refund + +Bila order yang dibayar EnakPoint dibatalkan atau direfund, EnakPoint kembali sebagai +EnakPoint (tidak pernah tunai) dan muncul di riwayat sebagai `PAYMENT_REFUND`. + +--- + +## 8. Tukar dan transfer + +### 8.1 Tukar EnakCoin → EnakPoint + +1. Customer mengetik jumlah EnakCoin. Panggil preview (debounce saat mengetik): + + `GET /api/v1/customer/wallet/exchange/preview?coins=30` + + ```json + { "coin_amount": 10, "point_amount": 3, "coin_balance": 35, "coins": 30, "points": 9, "valid": true } + ``` + + - Kurs: `coin_amount` EnakCoin = `point_amount` EnakPoint. Tampilkan "10 EnakCoin = + 3 EnakPoint". + - Bila `valid: false`, tampilkan `reason` sebagai alasan dan nonaktifkan tombol. Jumlah + harus kelipatan `coin_amount`. + - Tampilkan "Kamu akan mendapat {points} EnakPoint". + +2. Konfirmasi (tukar tidak bisa dibatalkan) → minta PIN → + + `POST /api/v1/customer/wallet/exchange` + header `Idempotency-Key` + + ```json + { "coins": 30, "pin": "482913" } + ``` + + ```json + { + "group_id": "…", + "coins": 30, + "points": 9, + "coin_amount": 10, + "point_amount": 3, + "lots": [{ "amount": 9, "expires_at": "2026-12-31T23:59:59+07:00" }], + "coin_balance": 5, + "point_balance": 9, + "replayed": false + } + ``` + +3. Layar sukses: saldo baru, dan bila `lots[].expires_at` ada, "EnakPoint ini berlaku + sampai {tanggal}". + +### 8.2 Transfer + +1. Pilih mata uang (EnakPoint / EnakCoin), isi nomor HP penerima dan jumlah. +2. Cek penerima: + + `GET /api/v1/customer/wallet/transfer/recipient?phone=081234561234` + + ```json + { "name": "Bu*** Sa***", "phone_number": "08**-****-1234" } + ``` + + | Hasil | Tampilan | + | ------ | ---------------------------------------------------------------- | + | Sukses | "Kirim ke Bu*** Sa*** (08**-\*\***-1234)?" | + | `404` | "Nomor ini tidak terdaftar" | + | `304` | "Tidak bisa mengirim ke nomor ini" (diri sendiri, akun nonaktif) | + +3. Konfirmasi (transfer final, tidak bisa dibatalkan) → minta PIN → + + `POST /api/v1/customer/wallet/transfer` + header `Idempotency-Key` + + ```json + { "currency": "POINT", "amount": 120, "recipient_phone": "081234561234", "pin": "482913" } + ``` + + ```json + { + "group_id": "…", + "currency": "POINT", + "amount": 120, + "recipient": { "name": "Bu*** Sa***", "phone_number": "08**-****-1234" }, + "lots": [ + { "amount": 100, "expires_at": "2026-12-31T23:59:59+07:00" }, + { "amount": 20, "expires_at": null } + ], + "balance": 30, + "replayed": false + } + ``` + +4. Layar sukses: saldo tersisa (`balance`). Bila ada `lots[].expires_at`, tampilkan + "Saldo yang dikirim berlaku sampai {tanggal}" (tanggal kedaluwarsa ikut terbawa ke + penerima). + +Penolakan `304` yang mungkin: transfer dimatikan owner, di bawah minimal, di atas +maksimal per transaksi, melewati batas harian (reset tengah malam WIB), saldo tidak +cukup. Tampilkan pesan umum "Transfer tidak bisa diproses" plus alasan yang sesuai +bila bisa dikenali. Bila kena `TRANSFER_BLOCKED`, ikuti §6.5. + +Penerima mendapat push `WALLET_TRANSFER_IN`. + +--- + +## 9. Game (memakai EnakCoin) + +`POST /api/v1/customer/spin` dengan `{ "spin_id": "" }`. Tanpa PIN. + +```json +{ + "game_play": { "id": "…", "game_id": "…", "coins_used": 1, "created_at": "…" }, + "prize_won": { "id": "…", "name": "Voucher 10rb" }, + "coins_remaining": 7 +} +``` + +- Setiap game punya biaya sendiri: `metadata.coin_cost` pada data game dari + `GET /api/v1/customer/games` (atau `GET /customer/ferris-wheel`), default 1 bila kosong. + Tampilkan biaya sebelum main, dan nonaktifkan tombol bila `coin_balance` kurang. +- `304`: EnakCoin kurang, game nonaktif, atau hadiah baru saja habis. Tidak ada + EnakCoin yang terpotong; tampilkan pesan dan biarkan customer mencoba lagi. +- Setelah main, perbarui saldo EnakCoin dari `coins_remaining`. + +--- + +## 10. Yang sudah dihapus / deprecated + +Sudah **dihapus** dari API (jangan dipanggil, akan error / tidak ada): + +| Lama | Pengganti | +| ------------------------------------------------- | ----------------------------------------------------------------- | +| `GET /customer/tokens` | `GET /customer/wallet` → `coin_balance` | +| `total_tokens`, `tokens_history` | `coin_balance`, `GET /customer/wallet/transactions?currency=COIN` | +| `token_used`, `tokens_remaining` di response game | `coins_used`, `coins_remaining` | + +Masih ada tapi **deprecated** (akan dihapus, jangan dipakai di kode baru): + +| Lama | Pengganti | +| ---------------------------------------------------------------------- | ---------------------------------------- | +| `GET /customer/points` | `GET /customer/wallet` → `point_balance` | +| `total_points`, `points_history`, `last_updated` di `/customer/wallet` | `point_balance`, `recent_transactions` | + +--- + +## 11. Checklist selesai + +- [ ] Beranda menampilkan saldo EnakPoint ("setara potongan Rp …"), EnakCoin, dan banner kedaluwarsa terdekat. +- [ ] Riwayat dengan tab per mata uang, filter tipe/tanggal, infinite scroll, label tipe sesuai §4.2. +- [ ] Layar saldo akan kedaluwarsa. +- [ ] Registrasi device FCM setelah login dan saat token berganti; unregister saat logout. +- [ ] Penanganan tap untuk keempat tipe push. +- [ ] PIN diminta hanya saat aksi yang membutuhkan; alur buat, ganti, dan lupa PIN lewat OTP. +- [ ] Keempat error PIN ditangani di semua layar yang meminta PIN. +- [ ] Kode bayar: angka + QR, hitung mundur 2 menit, tombol buat ulang. +- [ ] Tukar dengan preview, kelipatan kurs, konfirmasi, `Idempotency-Key`, retry dengan key sama. +- [ ] Transfer dengan cek penerima tersamar, konfirmasi, `Idempotency-Key`, retry dengan key sama. +- [ ] Game memakai `coins_used` / `coins_remaining` dan menampilkan biaya per game. +- [ ] Riwayat order dengan pagination dan layar detail (item, pembayaran, EnakPoint/EnakCoin yang didapat). +- [ ] Tidak ada pemakaian endpoint atau field di §10. +- [ ] PIN tidak pernah disimpan, di-log, atau dikirim ke analytics. diff --git a/ios/ExportOptions.plist b/ios/ExportOptions.plist new file mode 100644 index 0000000..bf41619 --- /dev/null +++ b/ios/ExportOptions.plist @@ -0,0 +1,36 @@ + + + + + + method + app-store-connect + + + teamID + 5TRC3M8UZG + + + signingStyle + manual + + + provisioningProfiles + + com.apskel.enaklocustomer + Enaklo Customer + + + stripSwiftSymbols + + + uploadBitcode + + + uploadSymbols + + + compileBitcode + + + diff --git a/ios/Flutter/AppFrameworkInfo.plist b/ios/Flutter/AppFrameworkInfo.plist index 7c56964..0d14080 100644 --- a/ios/Flutter/AppFrameworkInfo.plist +++ b/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 12.0 + 15.0 diff --git a/ios/Podfile b/ios/Podfile index e549ee2..6b8f3cb 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '12.0' +platform :ios, '15.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -39,5 +39,12 @@ end post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0' + # Disable code signing for all Pod targets — only Runner needs signing + config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO' + config.build_settings['CODE_SIGNING_REQUIRED'] = 'NO' + config.build_settings['CODE_SIGN_IDENTITY'] = '' + end end end diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index daae6ee..9eb2d77 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -346,7 +346,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -368,7 +368,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; @@ -384,7 +384,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -401,7 +401,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -416,7 +416,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; @@ -472,7 +472,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -523,7 +523,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -547,7 +547,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -569,7 +569,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_VERSION = 5.0; diff --git a/lib/application/auth/auth_bloc.freezed.dart b/lib/application/auth/auth_bloc.freezed.dart index 7fd3e02..5358c66 100644 --- a/lib/application/auth/auth_bloc.freezed.dart +++ b/lib/application/auth/auth_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'auth_bloc.dart'; @@ -9,798 +9,770 @@ part of 'auth_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$AuthEvent { - @optionalTypeArgs - TResult when({ - required TResult Function() fetchCurrentUser, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? fetchCurrentUser, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? fetchCurrentUser, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_FetchCurrentUser value) fetchCurrentUser, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_FetchCurrentUser value)? fetchCurrentUser, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_FetchCurrentUser value)? fetchCurrentUser, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'AuthEvent()'; +} + + } /// @nodoc -abstract class $AuthEventCopyWith<$Res> { - factory $AuthEventCopyWith(AuthEvent value, $Res Function(AuthEvent) then) = - _$AuthEventCopyWithImpl<$Res, AuthEvent>; +class $AuthEventCopyWith<$Res> { +$AuthEventCopyWith(AuthEvent _, $Res Function(AuthEvent) __); } -/// @nodoc -class _$AuthEventCopyWithImpl<$Res, $Val extends AuthEvent> - implements $AuthEventCopyWith<$Res> { - _$AuthEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [AuthEvent]. +extension AuthEventPatterns on AuthEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of AuthEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _FetchCurrentUser value)? fetchCurrentUser,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _FetchCurrentUser() when fetchCurrentUser != null: +return fetchCurrentUser(_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({required TResult Function( _FetchCurrentUser value) fetchCurrentUser,}){ +final _that = this; +switch (_that) { +case _FetchCurrentUser(): +return fetchCurrentUser(_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( _FetchCurrentUser value)? fetchCurrentUser,}){ +final _that = this; +switch (_that) { +case _FetchCurrentUser() when fetchCurrentUser != null: +return fetchCurrentUser(_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()? fetchCurrentUser,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _FetchCurrentUser() when fetchCurrentUser != null: +return fetchCurrentUser();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({required TResult Function() fetchCurrentUser,}) {final _that = this; +switch (_that) { +case _FetchCurrentUser(): +return fetchCurrentUser();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()? fetchCurrentUser,}) {final _that = this; +switch (_that) { +case _FetchCurrentUser() when fetchCurrentUser != null: +return fetchCurrentUser();case _: + return null; + +} } -/// @nodoc -abstract class _$$FetchCurrentUserImplCopyWith<$Res> { - factory _$$FetchCurrentUserImplCopyWith( - _$FetchCurrentUserImpl value, - $Res Function(_$FetchCurrentUserImpl) then, - ) = __$$FetchCurrentUserImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$FetchCurrentUserImplCopyWithImpl<$Res> - extends _$AuthEventCopyWithImpl<$Res, _$FetchCurrentUserImpl> - implements _$$FetchCurrentUserImplCopyWith<$Res> { - __$$FetchCurrentUserImplCopyWithImpl( - _$FetchCurrentUserImpl _value, - $Res Function(_$FetchCurrentUserImpl) _then, - ) : super(_value, _then); - - /// Create a copy of AuthEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$FetchCurrentUserImpl implements _FetchCurrentUser { - const _$FetchCurrentUserImpl(); - @override - String toString() { +class _FetchCurrentUser implements AuthEvent { + const _FetchCurrentUser(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _FetchCurrentUser); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'AuthEvent.fetchCurrentUser()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$FetchCurrentUserImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() fetchCurrentUser, - }) { - return fetchCurrentUser(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? fetchCurrentUser, - }) { - return fetchCurrentUser?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? fetchCurrentUser, - required TResult orElse(), - }) { - if (fetchCurrentUser != null) { - return fetchCurrentUser(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_FetchCurrentUser value) fetchCurrentUser, - }) { - return fetchCurrentUser(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_FetchCurrentUser value)? fetchCurrentUser, - }) { - return fetchCurrentUser?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_FetchCurrentUser value)? fetchCurrentUser, - required TResult orElse(), - }) { - if (fetchCurrentUser != null) { - return fetchCurrentUser(this); - } - return orElse(); - } } -abstract class _FetchCurrentUser implements AuthEvent { - const factory _FetchCurrentUser() = _$FetchCurrentUserImpl; + } + + + /// @nodoc mixin _$AuthState { - User get user => throw _privateConstructorUsedError; - AuthStatus get status => throw _privateConstructorUsedError; - Option get failureOption => throw _privateConstructorUsedError; - bool get isFetching => throw _privateConstructorUsedError; - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $AuthStateCopyWith get copyWith => - throw _privateConstructorUsedError; + User get user; AuthStatus get status; Option get failureOption; bool get isFetching; +/// 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') +$AuthStateCopyWith get copyWith => _$AuthStateCopyWithImpl(this as AuthState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as AuthState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthState&&(identical(other.user, _this.user) || other.user == _this.user)&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)); +} + + +@override +int get hashCode { + final _this = this as AuthState; + return Object.hash(runtimeType,_this.user,_this.status,_this.failureOption,_this.isFetching); +} + +@override +String toString() { + final _this = this as AuthState; + return 'AuthState(user: ${_this.user}, status: ${_this.status}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching})'; +} + + } /// @nodoc -abstract class $AuthStateCopyWith<$Res> { - factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) = - _$AuthStateCopyWithImpl<$Res, AuthState>; - @useResult - $Res call({ - User user, - AuthStatus status, - Option failureOption, - bool isFetching, - }); +abstract mixin class $AuthStateCopyWith<$Res> { + factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) _then) = _$AuthStateCopyWithImpl; +@useResult +$Res call({ + User user, AuthStatus status, Option failureOption, bool isFetching +}); + + +$UserCopyWith<$Res> get user;$AuthStatusCopyWith<$Res> get status; - $UserCopyWith<$Res> get user; - $AuthStatusCopyWith<$Res> get status; } - /// @nodoc -class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState> +class _$AuthStateCopyWithImpl<$Res> implements $AuthStateCopyWith<$Res> { - _$AuthStateCopyWithImpl(this._value, this._then); + _$AuthStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final AuthState _self; + final $Res Function(AuthState) _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? user = null, - Object? status = null, - Object? failureOption = null, - Object? isFetching = null, - }) { - return _then( - _value.copyWith( - user: null == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as User, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as AuthStatus, - failureOption: null == failureOption - ? _value.failureOption - : failureOption // ignore: cast_nullable_to_non_nullable - as Option, - isFetching: null == isFetching - ? _value.isFetching - : isFetching // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $UserCopyWith<$Res> get user { - return $UserCopyWith<$Res>(_value.user, (value) { - return _then(_value.copyWith(user: value) as $Val); - }); - } - - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $AuthStatusCopyWith<$Res> get status { - return $AuthStatusCopyWith<$Res>(_value.status, (value) { - return _then(_value.copyWith(status: value) as $Val); - }); - } +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? user = null,Object? status = null,Object? failureOption = null,Object? isFetching = null,}) { + return _then(AuthState( +user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as User,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as AuthStatus,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); } - -/// @nodoc -abstract class _$$AuthStateImplCopyWith<$Res> - implements $AuthStateCopyWith<$Res> { - factory _$$AuthStateImplCopyWith( - _$AuthStateImpl value, - $Res Function(_$AuthStateImpl) then, - ) = __$$AuthStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - User user, - AuthStatus status, - Option failureOption, - bool isFetching, +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserCopyWith<$Res> get user { + + return $UserCopyWith<$Res>(_self.user, (value) { + return _then(_self.copyWith(user: value)); }); - - @override - $UserCopyWith<$Res> get user; - @override - $AuthStatusCopyWith<$Res> get status; +}/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$AuthStatusCopyWith<$Res> get status { + + return $AuthStatusCopyWith<$Res>(_self.status, (value) { + return _then(_self.copyWith(status: value)); + }); +} } -/// @nodoc -class __$$AuthStateImplCopyWithImpl<$Res> - extends _$AuthStateCopyWithImpl<$Res, _$AuthStateImpl> - implements _$$AuthStateImplCopyWith<$Res> { - __$$AuthStateImplCopyWithImpl( - _$AuthStateImpl _value, - $Res Function(_$AuthStateImpl) _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? user = null, - Object? status = null, - Object? failureOption = null, - Object? isFetching = null, - }) { - return _then( - _$AuthStateImpl( - user: null == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as User, - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as AuthStatus, - failureOption: null == failureOption - ? _value.failureOption - : failureOption // ignore: cast_nullable_to_non_nullable - as Option, - isFetching: null == isFetching - ? _value.isFetching - : isFetching // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// 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( _AuthState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _AuthState() 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( _AuthState value) $default,){ +final _that = this; +switch (_that) { +case _AuthState(): +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( _AuthState value)? $default,){ +final _that = this; +switch (_that) { +case _AuthState() 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( User user, AuthStatus status, Option failureOption, bool isFetching)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _AuthState() when $default != null: +return $default(_that.user,_that.status,_that.failureOption,_that.isFetching);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( User user, AuthStatus status, Option failureOption, bool isFetching) $default,) {final _that = this; +switch (_that) { +case _AuthState(): +return $default(_that.user,_that.status,_that.failureOption,_that.isFetching);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( User user, AuthStatus status, Option failureOption, bool isFetching)? $default,) {final _that = this; +switch (_that) { +case _AuthState() when $default != null: +return $default(_that.user,_that.status,_that.failureOption,_that.isFetching);case _: + return null; + +} +} + } /// @nodoc -class _$AuthStateImpl extends _AuthState { - const _$AuthStateImpl({ - required this.user, - this.status = const AuthStatus.initial(), - required this.failureOption, - this.isFetching = false, - }) : super._(); - @override - final User user; - @override - @JsonKey() - final AuthStatus status; - @override - final Option failureOption; - @override - @JsonKey() - final bool isFetching; +class _AuthState extends AuthState { + const _AuthState({required this.user, this.status = const AuthStatus.initial(), required this.failureOption, this.isFetching = false}): super._(); + - @override - String toString() { +@override final User user; +@override@JsonKey() final AuthStatus status; +@override final Option failureOption; +@override@JsonKey() final bool isFetching; + +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AuthStateCopyWith<_AuthState> get copyWith => __$AuthStateCopyWithImpl<_AuthState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AuthState&&(identical(other.user, user) || other.user == user)&&(identical(other.status, status) || other.status == status)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,user,status,failureOption,isFetching); +} + +@override +String toString() { return 'AuthState(user: $user, status: $status, failureOption: $failureOption, isFetching: $isFetching)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$AuthStateImpl && - (identical(other.user, user) || other.user == user) && - (identical(other.status, status) || other.status == status) && - (identical(other.failureOption, failureOption) || - other.failureOption == failureOption) && - (identical(other.isFetching, isFetching) || - other.isFetching == isFetching)); - } - - @override - int get hashCode => - Object.hash(runtimeType, user, status, failureOption, isFetching); - - /// 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') - _$$AuthStateImplCopyWith<_$AuthStateImpl> get copyWith => - __$$AuthStateImplCopyWithImpl<_$AuthStateImpl>(this, _$identity); } -abstract class _AuthState extends AuthState { - const factory _AuthState({ - required final User user, - final AuthStatus status, - required final Option failureOption, - final bool isFetching, - }) = _$AuthStateImpl; - const _AuthState._() : super._(); - @override - User get user; - @override - AuthStatus get status; - @override - Option get failureOption; - @override - bool get isFetching; +} - /// Create a copy of AuthState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$AuthStateImplCopyWith<_$AuthStateImpl> get copyWith => - throw _privateConstructorUsedError; +/// @nodoc +abstract mixin class _$AuthStateCopyWith<$Res> implements $AuthStateCopyWith<$Res> { + factory _$AuthStateCopyWith(_AuthState value, $Res Function(_AuthState) _then) = __$AuthStateCopyWithImpl; +@override @useResult +$Res call({ + User user, AuthStatus status, Option failureOption, bool isFetching +}); + + +@override $UserCopyWith<$Res> get user;@override $AuthStatusCopyWith<$Res> get status; + +} +/// @nodoc +class __$AuthStateCopyWithImpl<$Res> + implements _$AuthStateCopyWith<$Res> { + __$AuthStateCopyWithImpl(this._self, this._then); + + final _AuthState _self; + final $Res Function(_AuthState) _then; + +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? user = null,Object? status = null,Object? failureOption = null,Object? isFetching = null,}) { + return _then(_AuthState( +user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as User,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as AuthStatus,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserCopyWith<$Res> get user { + + return $UserCopyWith<$Res>(_self.user, (value) { + return _then(_self.copyWith(user: value)); + }); +}/// Create a copy of AuthState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$AuthStatusCopyWith<$Res> get status { + + return $AuthStatusCopyWith<$Res>(_self.status, (value) { + return _then(_self.copyWith(status: value)); + }); +} } /// @nodoc mixin _$AuthStatus { - @optionalTypeArgs - TResult when({ - required TResult Function() authenticated, - required TResult Function() unauthenticated, - required TResult Function() initial, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? authenticated, - TResult? Function()? unauthenticated, - TResult? Function()? initial, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? authenticated, - TResult Function()? unauthenticated, - TResult Function()? initial, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Initial value) initial, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Initial value)? initial, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Initial value)? initial, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthStatus); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'AuthStatus()'; +} + + } /// @nodoc -abstract class $AuthStatusCopyWith<$Res> { - factory $AuthStatusCopyWith( - AuthStatus value, - $Res Function(AuthStatus) then, - ) = _$AuthStatusCopyWithImpl<$Res, AuthStatus>; +class $AuthStatusCopyWith<$Res> { +$AuthStatusCopyWith(AuthStatus _, $Res Function(AuthStatus) __); } -/// @nodoc -class _$AuthStatusCopyWithImpl<$Res, $Val extends AuthStatus> - implements $AuthStatusCopyWith<$Res> { - _$AuthStatusCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [AuthStatus]. +extension AuthStatusPatterns on AuthStatus { +/// 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(); +/// } +/// ``` - /// Create a copy of AuthStatus - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _Authenticated value)? authenticated,TResult Function( _Unauthenticated value)? unauthenticated,TResult Function( _Initial value)? initial,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Authenticated() when authenticated != null: +return authenticated(_that);case _Unauthenticated() when unauthenticated != null: +return unauthenticated(_that);case _Initial() when initial != null: +return initial(_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({required TResult Function( _Authenticated value) authenticated,required TResult Function( _Unauthenticated value) unauthenticated,required TResult Function( _Initial value) initial,}){ +final _that = this; +switch (_that) { +case _Authenticated(): +return authenticated(_that);case _Unauthenticated(): +return unauthenticated(_that);case _Initial(): +return initial(_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( _Authenticated value)? authenticated,TResult? Function( _Unauthenticated value)? unauthenticated,TResult? Function( _Initial value)? initial,}){ +final _that = this; +switch (_that) { +case _Authenticated() when authenticated != null: +return authenticated(_that);case _Unauthenticated() when unauthenticated != null: +return unauthenticated(_that);case _Initial() when initial != null: +return initial(_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()? authenticated,TResult Function()? unauthenticated,TResult Function()? initial,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Authenticated() when authenticated != null: +return authenticated();case _Unauthenticated() when unauthenticated != null: +return unauthenticated();case _Initial() when initial != null: +return initial();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({required TResult Function() authenticated,required TResult Function() unauthenticated,required TResult Function() initial,}) {final _that = this; +switch (_that) { +case _Authenticated(): +return authenticated();case _Unauthenticated(): +return unauthenticated();case _Initial(): +return initial();} +} +/// 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()? authenticated,TResult? Function()? unauthenticated,TResult? Function()? initial,}) {final _that = this; +switch (_that) { +case _Authenticated() when authenticated != null: +return authenticated();case _Unauthenticated() when unauthenticated != null: +return unauthenticated();case _Initial() when initial != null: +return initial();case _: + return null; + +} } -/// @nodoc -abstract class _$$AuthenticatedImplCopyWith<$Res> { - factory _$$AuthenticatedImplCopyWith( - _$AuthenticatedImpl value, - $Res Function(_$AuthenticatedImpl) then, - ) = __$$AuthenticatedImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$AuthenticatedImplCopyWithImpl<$Res> - extends _$AuthStatusCopyWithImpl<$Res, _$AuthenticatedImpl> - implements _$$AuthenticatedImplCopyWith<$Res> { - __$$AuthenticatedImplCopyWithImpl( - _$AuthenticatedImpl _value, - $Res Function(_$AuthenticatedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of AuthStatus - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$AuthenticatedImpl implements _Authenticated { - const _$AuthenticatedImpl(); - @override - String toString() { +class _Authenticated implements AuthStatus { + const _Authenticated(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Authenticated); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'AuthStatus.authenticated()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$AuthenticatedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() authenticated, - required TResult Function() unauthenticated, - required TResult Function() initial, - }) { - return authenticated(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? authenticated, - TResult? Function()? unauthenticated, - TResult? Function()? initial, - }) { - return authenticated?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? authenticated, - TResult Function()? unauthenticated, - TResult Function()? initial, - required TResult orElse(), - }) { - if (authenticated != null) { - return authenticated(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Initial value) initial, - }) { - return authenticated(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Initial value)? initial, - }) { - return authenticated?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Initial value)? initial, - required TResult orElse(), - }) { - if (authenticated != null) { - return authenticated(this); - } - return orElse(); - } } -abstract class _Authenticated implements AuthStatus { - const factory _Authenticated() = _$AuthenticatedImpl; + } -/// @nodoc -abstract class _$$UnauthenticatedImplCopyWith<$Res> { - factory _$$UnauthenticatedImplCopyWith( - _$UnauthenticatedImpl value, - $Res Function(_$UnauthenticatedImpl) then, - ) = __$$UnauthenticatedImplCopyWithImpl<$Res>; -} -/// @nodoc -class __$$UnauthenticatedImplCopyWithImpl<$Res> - extends _$AuthStatusCopyWithImpl<$Res, _$UnauthenticatedImpl> - implements _$$UnauthenticatedImplCopyWith<$Res> { - __$$UnauthenticatedImplCopyWithImpl( - _$UnauthenticatedImpl _value, - $Res Function(_$UnauthenticatedImpl) _then, - ) : super(_value, _then); - /// Create a copy of AuthStatus - /// with the given fields replaced by the non-null parameter values. -} /// @nodoc -class _$UnauthenticatedImpl implements _Unauthenticated { - const _$UnauthenticatedImpl(); - @override - String toString() { +class _Unauthenticated implements AuthStatus { + 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 'AuthStatus.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() authenticated, - required TResult Function() unauthenticated, - required TResult Function() initial, - }) { - return unauthenticated(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? authenticated, - TResult? Function()? unauthenticated, - TResult? Function()? initial, - }) { - return unauthenticated?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? authenticated, - TResult Function()? unauthenticated, - TResult Function()? initial, - required TResult orElse(), - }) { - if (unauthenticated != null) { - return unauthenticated(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Initial value) initial, - }) { - return unauthenticated(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Initial value)? initial, - }) { - return unauthenticated?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Initial value)? initial, - required TResult orElse(), - }) { - if (unauthenticated != null) { - return unauthenticated(this); - } - return orElse(); - } } -abstract class _Unauthenticated implements AuthStatus { - const factory _Unauthenticated() = _$UnauthenticatedImpl; + } -/// @nodoc -abstract class _$$InitialImplCopyWith<$Res> { - factory _$$InitialImplCopyWith( - _$InitialImpl value, - $Res Function(_$InitialImpl) then, - ) = __$$InitialImplCopyWithImpl<$Res>; -} -/// @nodoc -class __$$InitialImplCopyWithImpl<$Res> - extends _$AuthStatusCopyWithImpl<$Res, _$InitialImpl> - implements _$$InitialImplCopyWith<$Res> { - __$$InitialImplCopyWithImpl( - _$InitialImpl _value, - $Res Function(_$InitialImpl) _then, - ) : super(_value, _then); - /// Create a copy of AuthStatus - /// with the given fields replaced by the non-null parameter values. -} /// @nodoc -class _$InitialImpl implements _Initial { - const _$InitialImpl(); - @override - String toString() { +class _Initial implements AuthStatus { + const _Initial(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Initial); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'AuthStatus.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() authenticated, - required TResult Function() unauthenticated, - required TResult Function() initial, - }) { - return initial(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? authenticated, - TResult? Function()? unauthenticated, - TResult? Function()? initial, - }) { - return initial?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? authenticated, - TResult Function()? unauthenticated, - TResult Function()? initial, - required TResult orElse(), - }) { - if (initial != null) { - return initial(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Authenticated value) authenticated, - required TResult Function(_Unauthenticated value) unauthenticated, - required TResult Function(_Initial value) initial, - }) { - return initial(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Authenticated value)? authenticated, - TResult? Function(_Unauthenticated value)? unauthenticated, - TResult? Function(_Initial value)? initial, - }) { - return initial?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Authenticated value)? authenticated, - TResult Function(_Unauthenticated value)? unauthenticated, - TResult Function(_Initial value)? initial, - required TResult orElse(), - }) { - if (initial != null) { - return initial(this); - } - return orElse(); - } } -abstract class _Initial implements AuthStatus { - const factory _Initial() = _$InitialImpl; + } + + + + +// dart format on diff --git a/lib/application/auth/auth_event.dart b/lib/application/auth/auth_event.dart index 6c3c293..615054c 100644 --- a/lib/application/auth/auth_event.dart +++ b/lib/application/auth/auth_event.dart @@ -1,6 +1,6 @@ part of 'auth_bloc.dart'; @freezed -class AuthEvent with _$AuthEvent { +abstract class AuthEvent with _$AuthEvent { const factory AuthEvent.fetchCurrentUser() = _FetchCurrentUser; } diff --git a/lib/application/auth/auth_state.dart b/lib/application/auth/auth_state.dart index 483740d..e3ef55b 100644 --- a/lib/application/auth/auth_state.dart +++ b/lib/application/auth/auth_state.dart @@ -1,7 +1,7 @@ part of 'auth_bloc.dart'; @freezed -class AuthState with _$AuthState { +abstract class AuthState with _$AuthState { const AuthState._(); const factory AuthState({ diff --git a/lib/application/auth/check_phone_form/check_phone_form_bloc.freezed.dart b/lib/application/auth/check_phone_form/check_phone_form_bloc.freezed.dart index 4a86bec..a017444 100644 --- a/lib/application/auth/check_phone_form/check_phone_form_bloc.freezed.dart +++ b/lib/application/auth/check_phone_form/check_phone_form_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'check_phone_form_bloc.dart'; @@ -9,544 +9,546 @@ part of 'check_phone_form_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$CheckPhoneFormEvent { - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function() submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function()? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function()? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_Submitted value) submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_Submitted value)? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is CheckPhoneFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'CheckPhoneFormEvent()'; +} + + } /// @nodoc -abstract class $CheckPhoneFormEventCopyWith<$Res> { - factory $CheckPhoneFormEventCopyWith( - CheckPhoneFormEvent value, - $Res Function(CheckPhoneFormEvent) then, - ) = _$CheckPhoneFormEventCopyWithImpl<$Res, CheckPhoneFormEvent>; +class $CheckPhoneFormEventCopyWith<$Res> { +$CheckPhoneFormEventCopyWith(CheckPhoneFormEvent _, $Res Function(CheckPhoneFormEvent) __); } -/// @nodoc -class _$CheckPhoneFormEventCopyWithImpl<$Res, $Val extends CheckPhoneFormEvent> - implements $CheckPhoneFormEventCopyWith<$Res> { - _$CheckPhoneFormEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [CheckPhoneFormEvent]. +extension CheckPhoneFormEventPatterns on CheckPhoneFormEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of CheckPhoneFormEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _PhoneNumberChanged value)? phoneNumberChanged,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _PhoneNumberChanged value) phoneNumberChanged,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that);case _Submitted(): +return submitted(_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( _PhoneNumberChanged value)? phoneNumberChanged,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _Submitted() when submitted != null: +return submitted(_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 phoneNumber)? phoneNumberChanged,TResult Function()? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _Submitted() when submitted != null: +return submitted();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({required TResult Function( String phoneNumber) phoneNumberChanged,required TResult Function() submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that.phoneNumber);case _Submitted(): +return submitted();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 phoneNumber)? phoneNumberChanged,TResult? Function()? submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _Submitted() when submitted != null: +return submitted();case _: + return null; + +} } -/// @nodoc -abstract class _$$PhoneNumberChangedImplCopyWith<$Res> { - factory _$$PhoneNumberChangedImplCopyWith( - _$PhoneNumberChangedImpl value, - $Res Function(_$PhoneNumberChangedImpl) then, - ) = __$$PhoneNumberChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String phoneNumber}); -} - -/// @nodoc -class __$$PhoneNumberChangedImplCopyWithImpl<$Res> - extends _$CheckPhoneFormEventCopyWithImpl<$Res, _$PhoneNumberChangedImpl> - implements _$$PhoneNumberChangedImplCopyWith<$Res> { - __$$PhoneNumberChangedImplCopyWithImpl( - _$PhoneNumberChangedImpl _value, - $Res Function(_$PhoneNumberChangedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CheckPhoneFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? phoneNumber = null}) { - return _then( - _$PhoneNumberChangedImpl( - null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$PhoneNumberChangedImpl implements _PhoneNumberChanged { - const _$PhoneNumberChangedImpl(this.phoneNumber); - @override - final String phoneNumber; +class _PhoneNumberChanged implements CheckPhoneFormEvent { + const _PhoneNumberChanged(this.phoneNumber); + - @override - String toString() { + final String phoneNumber; + +/// Create a copy of CheckPhoneFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PhoneNumberChangedCopyWith<_PhoneNumberChanged> get copyWith => __$PhoneNumberChangedCopyWithImpl<_PhoneNumberChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PhoneNumberChanged&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber); +} + +@override +String toString() { return 'CheckPhoneFormEvent.phoneNumberChanged(phoneNumber: $phoneNumber)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PhoneNumberChangedImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber)); - } - - @override - int get hashCode => Object.hash(runtimeType, phoneNumber); - - /// Create a copy of CheckPhoneFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - __$$PhoneNumberChangedImplCopyWithImpl<_$PhoneNumberChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function() submitted, - }) { - return phoneNumberChanged(phoneNumber); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function()? submitted, - }) { - return phoneNumberChanged?.call(phoneNumber); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(phoneNumber); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_Submitted value) submitted, - }) { - return phoneNumberChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return phoneNumberChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(this); - } - return orElse(); - } } -abstract class _PhoneNumberChanged implements CheckPhoneFormEvent { - const factory _PhoneNumberChanged(final String phoneNumber) = - _$PhoneNumberChangedImpl; - String get phoneNumber; - - /// Create a copy of CheckPhoneFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$SubmittedImplCopyWith<$Res> { - factory _$$SubmittedImplCopyWith( - _$SubmittedImpl value, - $Res Function(_$SubmittedImpl) then, - ) = __$$SubmittedImplCopyWithImpl<$Res>; +abstract mixin class _$PhoneNumberChangedCopyWith<$Res> implements $CheckPhoneFormEventCopyWith<$Res> { + factory _$PhoneNumberChangedCopyWith(_PhoneNumberChanged value, $Res Function(_PhoneNumberChanged) _then) = __$PhoneNumberChangedCopyWithImpl; +@useResult +$Res call({ + String phoneNumber +}); + + + + +} +/// @nodoc +class __$PhoneNumberChangedCopyWithImpl<$Res> + implements _$PhoneNumberChangedCopyWith<$Res> { + __$PhoneNumberChangedCopyWithImpl(this._self, this._then); + + final _PhoneNumberChanged _self; + final $Res Function(_PhoneNumberChanged) _then; + +/// Create a copy of CheckPhoneFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,}) { + return _then(_PhoneNumberChanged( +null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$SubmittedImplCopyWithImpl<$Res> - extends _$CheckPhoneFormEventCopyWithImpl<$Res, _$SubmittedImpl> - implements _$$SubmittedImplCopyWith<$Res> { - __$$SubmittedImplCopyWithImpl( - _$SubmittedImpl _value, - $Res Function(_$SubmittedImpl) _then, - ) : super(_value, _then); - /// Create a copy of CheckPhoneFormEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$SubmittedImpl implements _Submitted { - const _$SubmittedImpl(); - @override - String toString() { +class _Submitted implements CheckPhoneFormEvent { + const _Submitted(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'CheckPhoneFormEvent.submitted()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$SubmittedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function() submitted, - }) { - return submitted(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function()? submitted, - }) { - return submitted?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_Submitted value) submitted, - }) { - return submitted(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return submitted?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(this); - } - return orElse(); - } } -abstract class _Submitted implements CheckPhoneFormEvent { - const factory _Submitted() = _$SubmittedImpl; + } + + + /// @nodoc mixin _$CheckPhoneFormState { - String get phoneNumber => throw _privateConstructorUsedError; - Option> get failureOrCheckPhoneOption => - throw _privateConstructorUsedError; - bool get isSubmitting => throw _privateConstructorUsedError; - bool get showErrorMessages => throw _privateConstructorUsedError; - /// Create a copy of CheckPhoneFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CheckPhoneFormStateCopyWith get copyWith => - throw _privateConstructorUsedError; + String get phoneNumber; Option> get failureOrCheckPhoneOption; bool get isSubmitting; bool get showErrorMessages; +/// Create a copy of CheckPhoneFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CheckPhoneFormStateCopyWith get copyWith => _$CheckPhoneFormStateCopyWithImpl(this as CheckPhoneFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as CheckPhoneFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CheckPhoneFormState&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)&&(identical(other.failureOrCheckPhoneOption, _this.failureOrCheckPhoneOption) || other.failureOrCheckPhoneOption == _this.failureOrCheckPhoneOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.showErrorMessages, _this.showErrorMessages) || other.showErrorMessages == _this.showErrorMessages)); +} + + +@override +int get hashCode { + final _this = this as CheckPhoneFormState; + return Object.hash(runtimeType,_this.phoneNumber,_this.failureOrCheckPhoneOption,_this.isSubmitting,_this.showErrorMessages); +} + +@override +String toString() { + final _this = this as CheckPhoneFormState; + return 'CheckPhoneFormState(phoneNumber: ${_this.phoneNumber}, failureOrCheckPhoneOption: ${_this.failureOrCheckPhoneOption}, isSubmitting: ${_this.isSubmitting}, showErrorMessages: ${_this.showErrorMessages})'; +} + + } /// @nodoc -abstract class $CheckPhoneFormStateCopyWith<$Res> { - factory $CheckPhoneFormStateCopyWith( - CheckPhoneFormState value, - $Res Function(CheckPhoneFormState) then, - ) = _$CheckPhoneFormStateCopyWithImpl<$Res, CheckPhoneFormState>; - @useResult - $Res call({ - String phoneNumber, - Option> failureOrCheckPhoneOption, - bool isSubmitting, - bool showErrorMessages, - }); -} +abstract mixin class $CheckPhoneFormStateCopyWith<$Res> { + factory $CheckPhoneFormStateCopyWith(CheckPhoneFormState value, $Res Function(CheckPhoneFormState) _then) = _$CheckPhoneFormStateCopyWithImpl; +@useResult +$Res call({ + String phoneNumber, Option> failureOrCheckPhoneOption, bool isSubmitting, bool showErrorMessages +}); + + + +} /// @nodoc -class _$CheckPhoneFormStateCopyWithImpl<$Res, $Val extends CheckPhoneFormState> +class _$CheckPhoneFormStateCopyWithImpl<$Res> implements $CheckPhoneFormStateCopyWith<$Res> { - _$CheckPhoneFormStateCopyWithImpl(this._value, this._then); + _$CheckPhoneFormStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final CheckPhoneFormState _self; + final $Res Function(CheckPhoneFormState) _then; - /// Create a copy of CheckPhoneFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? failureOrCheckPhoneOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _value.copyWith( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - failureOrCheckPhoneOption: null == failureOrCheckPhoneOption - ? _value.failureOrCheckPhoneOption - : failureOrCheckPhoneOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } +/// Create a copy of CheckPhoneFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? phoneNumber = null,Object? failureOrCheckPhoneOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(CheckPhoneFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,failureOrCheckPhoneOption: null == failureOrCheckPhoneOption ? _self.failureOrCheckPhoneOption : failureOrCheckPhoneOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$CheckPhoneFormStateImplCopyWith<$Res> - implements $CheckPhoneFormStateCopyWith<$Res> { - factory _$$CheckPhoneFormStateImplCopyWith( - _$CheckPhoneFormStateImpl value, - $Res Function(_$CheckPhoneFormStateImpl) then, - ) = __$$CheckPhoneFormStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String phoneNumber, - Option> failureOrCheckPhoneOption, - bool isSubmitting, - bool showErrorMessages, - }); } -/// @nodoc -class __$$CheckPhoneFormStateImplCopyWithImpl<$Res> - extends _$CheckPhoneFormStateCopyWithImpl<$Res, _$CheckPhoneFormStateImpl> - implements _$$CheckPhoneFormStateImplCopyWith<$Res> { - __$$CheckPhoneFormStateImplCopyWithImpl( - _$CheckPhoneFormStateImpl _value, - $Res Function(_$CheckPhoneFormStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of CheckPhoneFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? failureOrCheckPhoneOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _$CheckPhoneFormStateImpl( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - failureOrCheckPhoneOption: null == failureOrCheckPhoneOption - ? _value.failureOrCheckPhoneOption - : failureOrCheckPhoneOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [CheckPhoneFormState]. +extension CheckPhoneFormStatePatterns on CheckPhoneFormState { +/// 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( _CheckPhoneFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CheckPhoneFormState() 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( _CheckPhoneFormState value) $default,){ +final _that = this; +switch (_that) { +case _CheckPhoneFormState(): +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( _CheckPhoneFormState value)? $default,){ +final _that = this; +switch (_that) { +case _CheckPhoneFormState() 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 phoneNumber, Option> failureOrCheckPhoneOption, bool isSubmitting, bool showErrorMessages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CheckPhoneFormState() when $default != null: +return $default(_that.phoneNumber,_that.failureOrCheckPhoneOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, Option> failureOrCheckPhoneOption, bool isSubmitting, bool showErrorMessages) $default,) {final _that = this; +switch (_that) { +case _CheckPhoneFormState(): +return $default(_that.phoneNumber,_that.failureOrCheckPhoneOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, Option> failureOrCheckPhoneOption, bool isSubmitting, bool showErrorMessages)? $default,) {final _that = this; +switch (_that) { +case _CheckPhoneFormState() when $default != null: +return $default(_that.phoneNumber,_that.failureOrCheckPhoneOption,_that.isSubmitting,_that.showErrorMessages);case _: + return null; + +} +} + } /// @nodoc -class _$CheckPhoneFormStateImpl implements _CheckPhoneFormState { - const _$CheckPhoneFormStateImpl({ - required this.phoneNumber, - required this.failureOrCheckPhoneOption, - this.isSubmitting = false, - this.showErrorMessages = false, - }); - @override - final String phoneNumber; - @override - final Option> failureOrCheckPhoneOption; - @override - @JsonKey() - final bool isSubmitting; - @override - @JsonKey() - final bool showErrorMessages; +class _CheckPhoneFormState implements CheckPhoneFormState { + const _CheckPhoneFormState({required this.phoneNumber, required this.failureOrCheckPhoneOption, this.isSubmitting = false, this.showErrorMessages = false}); + - @override - String toString() { +@override final String phoneNumber; +@override final Option> failureOrCheckPhoneOption; +@override@JsonKey() final bool isSubmitting; +@override@JsonKey() final bool showErrorMessages; + +/// Create a copy of CheckPhoneFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CheckPhoneFormStateCopyWith<_CheckPhoneFormState> get copyWith => __$CheckPhoneFormStateCopyWithImpl<_CheckPhoneFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CheckPhoneFormState&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.failureOrCheckPhoneOption, failureOrCheckPhoneOption) || other.failureOrCheckPhoneOption == failureOrCheckPhoneOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.showErrorMessages, showErrorMessages) || other.showErrorMessages == showErrorMessages)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber,failureOrCheckPhoneOption,isSubmitting,showErrorMessages); +} + +@override +String toString() { return 'CheckPhoneFormState(phoneNumber: $phoneNumber, failureOrCheckPhoneOption: $failureOrCheckPhoneOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CheckPhoneFormStateImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber) && - (identical( - other.failureOrCheckPhoneOption, - failureOrCheckPhoneOption, - ) || - other.failureOrCheckPhoneOption == failureOrCheckPhoneOption) && - (identical(other.isSubmitting, isSubmitting) || - other.isSubmitting == isSubmitting) && - (identical(other.showErrorMessages, showErrorMessages) || - other.showErrorMessages == showErrorMessages)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - phoneNumber, - failureOrCheckPhoneOption, - isSubmitting, - showErrorMessages, - ); - - /// Create a copy of CheckPhoneFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CheckPhoneFormStateImplCopyWith<_$CheckPhoneFormStateImpl> get copyWith => - __$$CheckPhoneFormStateImplCopyWithImpl<_$CheckPhoneFormStateImpl>( - this, - _$identity, - ); } -abstract class _CheckPhoneFormState implements CheckPhoneFormState { - const factory _CheckPhoneFormState({ - required final String phoneNumber, - required final Option> - failureOrCheckPhoneOption, - final bool isSubmitting, - final bool showErrorMessages, - }) = _$CheckPhoneFormStateImpl; - @override - String get phoneNumber; - @override - Option> get failureOrCheckPhoneOption; - @override - bool get isSubmitting; - @override - bool get showErrorMessages; - - /// Create a copy of CheckPhoneFormState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CheckPhoneFormStateImplCopyWith<_$CheckPhoneFormStateImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$CheckPhoneFormStateCopyWith<$Res> implements $CheckPhoneFormStateCopyWith<$Res> { + factory _$CheckPhoneFormStateCopyWith(_CheckPhoneFormState value, $Res Function(_CheckPhoneFormState) _then) = __$CheckPhoneFormStateCopyWithImpl; +@override @useResult +$Res call({ + String phoneNumber, Option> failureOrCheckPhoneOption, bool isSubmitting, bool showErrorMessages +}); + + + + +} +/// @nodoc +class __$CheckPhoneFormStateCopyWithImpl<$Res> + implements _$CheckPhoneFormStateCopyWith<$Res> { + __$CheckPhoneFormStateCopyWithImpl(this._self, this._then); + + final _CheckPhoneFormState _self; + final $Res Function(_CheckPhoneFormState) _then; + +/// Create a copy of CheckPhoneFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,Object? failureOrCheckPhoneOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(_CheckPhoneFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,failureOrCheckPhoneOption: null == failureOrCheckPhoneOption ? _self.failureOrCheckPhoneOption : failureOrCheckPhoneOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/auth/check_phone_form/check_phone_form_event.dart b/lib/application/auth/check_phone_form/check_phone_form_event.dart index 5c5aaff..0e45bfa 100644 --- a/lib/application/auth/check_phone_form/check_phone_form_event.dart +++ b/lib/application/auth/check_phone_form/check_phone_form_event.dart @@ -1,7 +1,7 @@ part of 'check_phone_form_bloc.dart'; @freezed -class CheckPhoneFormEvent with _$CheckPhoneFormEvent { +abstract class CheckPhoneFormEvent with _$CheckPhoneFormEvent { const factory CheckPhoneFormEvent.phoneNumberChanged(String phoneNumber) = _PhoneNumberChanged; const factory CheckPhoneFormEvent.submitted() = _Submitted; diff --git a/lib/application/auth/check_phone_form/check_phone_form_state.dart b/lib/application/auth/check_phone_form/check_phone_form_state.dart index 1ff0d4b..4619c00 100644 --- a/lib/application/auth/check_phone_form/check_phone_form_state.dart +++ b/lib/application/auth/check_phone_form/check_phone_form_state.dart @@ -1,7 +1,7 @@ part of 'check_phone_form_bloc.dart'; @freezed -class CheckPhoneFormState with _$CheckPhoneFormState { +abstract class CheckPhoneFormState with _$CheckPhoneFormState { const factory CheckPhoneFormState({ required String phoneNumber, required Option> failureOrCheckPhoneOption, diff --git a/lib/application/auth/login_form/login_form_bloc.freezed.dart b/lib/application/auth/login_form/login_form_bloc.freezed.dart index 8387862..02e19b6 100644 --- a/lib/application/auth/login_form/login_form_bloc.freezed.dart +++ b/lib/application/auth/login_form/login_form_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'login_form_bloc.dart'; @@ -9,732 +9,623 @@ part of 'login_form_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$LoginFormEvent { - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String password) passwordChanged, - required TResult Function() submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function()? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String password)? passwordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_Submitted value) submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_Submitted value)? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'LoginFormEvent()'; +} + + } /// @nodoc -abstract class $LoginFormEventCopyWith<$Res> { - factory $LoginFormEventCopyWith( - LoginFormEvent value, - $Res Function(LoginFormEvent) then, - ) = _$LoginFormEventCopyWithImpl<$Res, LoginFormEvent>; +class $LoginFormEventCopyWith<$Res> { +$LoginFormEventCopyWith(LoginFormEvent _, $Res Function(LoginFormEvent) __); } -/// @nodoc -class _$LoginFormEventCopyWithImpl<$Res, $Val extends LoginFormEvent> - implements $LoginFormEventCopyWith<$Res> { - _$LoginFormEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [LoginFormEvent]. +extension LoginFormEventPatterns on LoginFormEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _PhoneNumberChanged value)? phoneNumberChanged,TResult Function( _PasswordChanged value)? passwordChanged,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _PhoneNumberChanged value) phoneNumberChanged,required TResult Function( _PasswordChanged value) passwordChanged,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that);case _PasswordChanged(): +return passwordChanged(_that);case _Submitted(): +return submitted(_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( _PhoneNumberChanged value)? phoneNumberChanged,TResult? Function( _PasswordChanged value)? passwordChanged,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that);case _Submitted() when submitted != null: +return submitted(_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 phoneNumber)? phoneNumberChanged,TResult Function( String password)? passwordChanged,TResult Function()? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that.password);case _Submitted() when submitted != null: +return submitted();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({required TResult Function( String phoneNumber) phoneNumberChanged,required TResult Function( String password) passwordChanged,required TResult Function() submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that.phoneNumber);case _PasswordChanged(): +return passwordChanged(_that.password);case _Submitted(): +return submitted();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 phoneNumber)? phoneNumberChanged,TResult? Function( String password)? passwordChanged,TResult? Function()? submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that.password);case _Submitted() when submitted != null: +return submitted();case _: + return null; + +} } -/// @nodoc -abstract class _$$PhoneNumberChangedImplCopyWith<$Res> { - factory _$$PhoneNumberChangedImplCopyWith( - _$PhoneNumberChangedImpl value, - $Res Function(_$PhoneNumberChangedImpl) then, - ) = __$$PhoneNumberChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String phoneNumber}); -} - -/// @nodoc -class __$$PhoneNumberChangedImplCopyWithImpl<$Res> - extends _$LoginFormEventCopyWithImpl<$Res, _$PhoneNumberChangedImpl> - implements _$$PhoneNumberChangedImplCopyWith<$Res> { - __$$PhoneNumberChangedImplCopyWithImpl( - _$PhoneNumberChangedImpl _value, - $Res Function(_$PhoneNumberChangedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? phoneNumber = null}) { - return _then( - _$PhoneNumberChangedImpl( - null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$PhoneNumberChangedImpl implements _PhoneNumberChanged { - const _$PhoneNumberChangedImpl(this.phoneNumber); - @override - final String phoneNumber; +class _PhoneNumberChanged implements LoginFormEvent { + const _PhoneNumberChanged(this.phoneNumber); + - @override - String toString() { + final String phoneNumber; + +/// Create a copy of LoginFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PhoneNumberChangedCopyWith<_PhoneNumberChanged> get copyWith => __$PhoneNumberChangedCopyWithImpl<_PhoneNumberChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PhoneNumberChanged&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber); +} + +@override +String toString() { return 'LoginFormEvent.phoneNumberChanged(phoneNumber: $phoneNumber)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PhoneNumberChangedImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber)); - } - - @override - int get hashCode => Object.hash(runtimeType, phoneNumber); - - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - __$$PhoneNumberChangedImplCopyWithImpl<_$PhoneNumberChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String password) passwordChanged, - required TResult Function() submitted, - }) { - return phoneNumberChanged(phoneNumber); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function()? submitted, - }) { - return phoneNumberChanged?.call(phoneNumber); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String password)? passwordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(phoneNumber); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_Submitted value) submitted, - }) { - return phoneNumberChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return phoneNumberChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(this); - } - return orElse(); - } } -abstract class _PhoneNumberChanged implements LoginFormEvent { - const factory _PhoneNumberChanged(final String phoneNumber) = - _$PhoneNumberChangedImpl; - String get phoneNumber; - - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$PasswordChangedImplCopyWith<$Res> { - factory _$$PasswordChangedImplCopyWith( - _$PasswordChangedImpl value, - $Res Function(_$PasswordChangedImpl) then, - ) = __$$PasswordChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String password}); +abstract mixin class _$PhoneNumberChangedCopyWith<$Res> implements $LoginFormEventCopyWith<$Res> { + factory _$PhoneNumberChangedCopyWith(_PhoneNumberChanged value, $Res Function(_PhoneNumberChanged) _then) = __$PhoneNumberChangedCopyWithImpl; +@useResult +$Res call({ + String phoneNumber +}); + + + + +} +/// @nodoc +class __$PhoneNumberChangedCopyWithImpl<$Res> + implements _$PhoneNumberChangedCopyWith<$Res> { + __$PhoneNumberChangedCopyWithImpl(this._self, this._then); + + final _PhoneNumberChanged _self; + final $Res Function(_PhoneNumberChanged) _then; + +/// Create a copy of LoginFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,}) { + return _then(_PhoneNumberChanged( +null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$PasswordChangedImplCopyWithImpl<$Res> - extends _$LoginFormEventCopyWithImpl<$Res, _$PasswordChangedImpl> - implements _$$PasswordChangedImplCopyWith<$Res> { - __$$PasswordChangedImplCopyWithImpl( - _$PasswordChangedImpl _value, - $Res Function(_$PasswordChangedImpl) _then, - ) : super(_value, _then); - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? password = null}) { - return _then( - _$PasswordChangedImpl( - null == password - ? _value.password - : password // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$PasswordChangedImpl implements _PasswordChanged { - const _$PasswordChangedImpl(this.password); - @override - final String password; +class _PasswordChanged implements LoginFormEvent { + const _PasswordChanged(this.password); + - @override - String toString() { + final String password; + +/// Create a copy of LoginFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PasswordChangedCopyWith<_PasswordChanged> get copyWith => __$PasswordChangedCopyWithImpl<_PasswordChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PasswordChanged&&(identical(other.password, password) || other.password == password)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,password); +} + +@override +String toString() { return 'LoginFormEvent.passwordChanged(password: $password)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PasswordChangedImpl && - (identical(other.password, password) || - other.password == password)); - } - - @override - int get hashCode => Object.hash(runtimeType, password); - - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith => - __$$PasswordChangedImplCopyWithImpl<_$PasswordChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String password) passwordChanged, - required TResult Function() submitted, - }) { - return passwordChanged(password); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function()? submitted, - }) { - return passwordChanged?.call(password); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String password)? passwordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (passwordChanged != null) { - return passwordChanged(password); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_Submitted value) submitted, - }) { - return passwordChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return passwordChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (passwordChanged != null) { - return passwordChanged(this); - } - return orElse(); - } } -abstract class _PasswordChanged implements LoginFormEvent { - const factory _PasswordChanged(final String password) = _$PasswordChangedImpl; - String get password; - - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$SubmittedImplCopyWith<$Res> { - factory _$$SubmittedImplCopyWith( - _$SubmittedImpl value, - $Res Function(_$SubmittedImpl) then, - ) = __$$SubmittedImplCopyWithImpl<$Res>; +abstract mixin class _$PasswordChangedCopyWith<$Res> implements $LoginFormEventCopyWith<$Res> { + factory _$PasswordChangedCopyWith(_PasswordChanged value, $Res Function(_PasswordChanged) _then) = __$PasswordChangedCopyWithImpl; +@useResult +$Res call({ + String password +}); + + + + +} +/// @nodoc +class __$PasswordChangedCopyWithImpl<$Res> + implements _$PasswordChangedCopyWith<$Res> { + __$PasswordChangedCopyWithImpl(this._self, this._then); + + final _PasswordChanged _self; + final $Res Function(_PasswordChanged) _then; + +/// Create a copy of LoginFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? password = null,}) { + return _then(_PasswordChanged( +null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$SubmittedImplCopyWithImpl<$Res> - extends _$LoginFormEventCopyWithImpl<$Res, _$SubmittedImpl> - implements _$$SubmittedImplCopyWith<$Res> { - __$$SubmittedImplCopyWithImpl( - _$SubmittedImpl _value, - $Res Function(_$SubmittedImpl) _then, - ) : super(_value, _then); - /// Create a copy of LoginFormEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$SubmittedImpl implements _Submitted { - const _$SubmittedImpl(); - @override - String toString() { +class _Submitted implements LoginFormEvent { + const _Submitted(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'LoginFormEvent.submitted()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$SubmittedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String password) passwordChanged, - required TResult Function() submitted, - }) { - return submitted(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function()? submitted, - }) { - return submitted?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String password)? passwordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_Submitted value) submitted, - }) { - return submitted(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return submitted?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(this); - } - return orElse(); - } } -abstract class _Submitted implements LoginFormEvent { - const factory _Submitted() = _$SubmittedImpl; + } + + + /// @nodoc mixin _$LoginFormState { - String get phoneNumber => throw _privateConstructorUsedError; - String get password => throw _privateConstructorUsedError; - Option> get failureOrLoginOption => - throw _privateConstructorUsedError; - bool get isSubmitting => throw _privateConstructorUsedError; - bool get showErrorMessages => throw _privateConstructorUsedError; - /// Create a copy of LoginFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $LoginFormStateCopyWith get copyWith => - throw _privateConstructorUsedError; + String get phoneNumber; String get password; Option> get failureOrLoginOption; bool get isSubmitting; bool get showErrorMessages; +/// Create a copy of LoginFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LoginFormStateCopyWith get copyWith => _$LoginFormStateCopyWithImpl(this as LoginFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as LoginFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginFormState&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)&&(identical(other.password, _this.password) || other.password == _this.password)&&(identical(other.failureOrLoginOption, _this.failureOrLoginOption) || other.failureOrLoginOption == _this.failureOrLoginOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.showErrorMessages, _this.showErrorMessages) || other.showErrorMessages == _this.showErrorMessages)); +} + + +@override +int get hashCode { + final _this = this as LoginFormState; + return Object.hash(runtimeType,_this.phoneNumber,_this.password,_this.failureOrLoginOption,_this.isSubmitting,_this.showErrorMessages); +} + +@override +String toString() { + final _this = this as LoginFormState; + return 'LoginFormState(phoneNumber: ${_this.phoneNumber}, password: ${_this.password}, failureOrLoginOption: ${_this.failureOrLoginOption}, isSubmitting: ${_this.isSubmitting}, showErrorMessages: ${_this.showErrorMessages})'; +} + + } /// @nodoc -abstract class $LoginFormStateCopyWith<$Res> { - factory $LoginFormStateCopyWith( - LoginFormState value, - $Res Function(LoginFormState) then, - ) = _$LoginFormStateCopyWithImpl<$Res, LoginFormState>; - @useResult - $Res call({ - String phoneNumber, - String password, - Option> failureOrLoginOption, - bool isSubmitting, - bool showErrorMessages, - }); -} +abstract mixin class $LoginFormStateCopyWith<$Res> { + factory $LoginFormStateCopyWith(LoginFormState value, $Res Function(LoginFormState) _then) = _$LoginFormStateCopyWithImpl; +@useResult +$Res call({ + String phoneNumber, String password, Option> failureOrLoginOption, bool isSubmitting, bool showErrorMessages +}); + + + +} /// @nodoc -class _$LoginFormStateCopyWithImpl<$Res, $Val extends LoginFormState> +class _$LoginFormStateCopyWithImpl<$Res> implements $LoginFormStateCopyWith<$Res> { - _$LoginFormStateCopyWithImpl(this._value, this._then); + _$LoginFormStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final LoginFormState _self; + final $Res Function(LoginFormState) _then; - /// Create a copy of LoginFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? password = null, - Object? failureOrLoginOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _value.copyWith( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - password: null == password - ? _value.password - : password // ignore: cast_nullable_to_non_nullable - as String, - failureOrLoginOption: null == failureOrLoginOption - ? _value.failureOrLoginOption - : failureOrLoginOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } +/// Create a copy of LoginFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? phoneNumber = null,Object? password = null,Object? failureOrLoginOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(LoginFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable +as String,failureOrLoginOption: null == failureOrLoginOption ? _self.failureOrLoginOption : failureOrLoginOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$LoginFormStateImplCopyWith<$Res> - implements $LoginFormStateCopyWith<$Res> { - factory _$$LoginFormStateImplCopyWith( - _$LoginFormStateImpl value, - $Res Function(_$LoginFormStateImpl) then, - ) = __$$LoginFormStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String phoneNumber, - String password, - Option> failureOrLoginOption, - bool isSubmitting, - bool showErrorMessages, - }); } -/// @nodoc -class __$$LoginFormStateImplCopyWithImpl<$Res> - extends _$LoginFormStateCopyWithImpl<$Res, _$LoginFormStateImpl> - implements _$$LoginFormStateImplCopyWith<$Res> { - __$$LoginFormStateImplCopyWithImpl( - _$LoginFormStateImpl _value, - $Res Function(_$LoginFormStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of LoginFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? password = null, - Object? failureOrLoginOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _$LoginFormStateImpl( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - password: null == password - ? _value.password - : password // ignore: cast_nullable_to_non_nullable - as String, - failureOrLoginOption: null == failureOrLoginOption - ? _value.failureOrLoginOption - : failureOrLoginOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [LoginFormState]. +extension LoginFormStatePatterns on LoginFormState { +/// 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( _LoginFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LoginFormState() 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( _LoginFormState value) $default,){ +final _that = this; +switch (_that) { +case _LoginFormState(): +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( _LoginFormState value)? $default,){ +final _that = this; +switch (_that) { +case _LoginFormState() 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 phoneNumber, String password, Option> failureOrLoginOption, bool isSubmitting, bool showErrorMessages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LoginFormState() when $default != null: +return $default(_that.phoneNumber,_that.password,_that.failureOrLoginOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, String password, Option> failureOrLoginOption, bool isSubmitting, bool showErrorMessages) $default,) {final _that = this; +switch (_that) { +case _LoginFormState(): +return $default(_that.phoneNumber,_that.password,_that.failureOrLoginOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, String password, Option> failureOrLoginOption, bool isSubmitting, bool showErrorMessages)? $default,) {final _that = this; +switch (_that) { +case _LoginFormState() when $default != null: +return $default(_that.phoneNumber,_that.password,_that.failureOrLoginOption,_that.isSubmitting,_that.showErrorMessages);case _: + return null; + +} +} + } /// @nodoc -class _$LoginFormStateImpl implements _LoginFormState { - const _$LoginFormStateImpl({ - required this.phoneNumber, - required this.password, - required this.failureOrLoginOption, - this.isSubmitting = false, - this.showErrorMessages = false, - }); - @override - final String phoneNumber; - @override - final String password; - @override - final Option> failureOrLoginOption; - @override - @JsonKey() - final bool isSubmitting; - @override - @JsonKey() - final bool showErrorMessages; +class _LoginFormState implements LoginFormState { + const _LoginFormState({required this.phoneNumber, required this.password, required this.failureOrLoginOption, this.isSubmitting = false, this.showErrorMessages = false}); + - @override - String toString() { +@override final String phoneNumber; +@override final String password; +@override final Option> failureOrLoginOption; +@override@JsonKey() final bool isSubmitting; +@override@JsonKey() final bool showErrorMessages; + +/// Create a copy of LoginFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LoginFormStateCopyWith<_LoginFormState> get copyWith => __$LoginFormStateCopyWithImpl<_LoginFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginFormState&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.password, password) || other.password == password)&&(identical(other.failureOrLoginOption, failureOrLoginOption) || other.failureOrLoginOption == failureOrLoginOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.showErrorMessages, showErrorMessages) || other.showErrorMessages == showErrorMessages)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber,password,failureOrLoginOption,isSubmitting,showErrorMessages); +} + +@override +String toString() { return 'LoginFormState(phoneNumber: $phoneNumber, password: $password, failureOrLoginOption: $failureOrLoginOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LoginFormStateImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber) && - (identical(other.password, password) || - other.password == password) && - (identical(other.failureOrLoginOption, failureOrLoginOption) || - other.failureOrLoginOption == failureOrLoginOption) && - (identical(other.isSubmitting, isSubmitting) || - other.isSubmitting == isSubmitting) && - (identical(other.showErrorMessages, showErrorMessages) || - other.showErrorMessages == showErrorMessages)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - phoneNumber, - password, - failureOrLoginOption, - isSubmitting, - showErrorMessages, - ); - - /// Create a copy of LoginFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$LoginFormStateImplCopyWith<_$LoginFormStateImpl> get copyWith => - __$$LoginFormStateImplCopyWithImpl<_$LoginFormStateImpl>( - this, - _$identity, - ); } -abstract class _LoginFormState implements LoginFormState { - const factory _LoginFormState({ - required final String phoneNumber, - required final String password, - required final Option> failureOrLoginOption, - final bool isSubmitting, - final bool showErrorMessages, - }) = _$LoginFormStateImpl; - @override - String get phoneNumber; - @override - String get password; - @override - Option> get failureOrLoginOption; - @override - bool get isSubmitting; - @override - bool get showErrorMessages; - - /// Create a copy of LoginFormState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$LoginFormStateImplCopyWith<_$LoginFormStateImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$LoginFormStateCopyWith<$Res> implements $LoginFormStateCopyWith<$Res> { + factory _$LoginFormStateCopyWith(_LoginFormState value, $Res Function(_LoginFormState) _then) = __$LoginFormStateCopyWithImpl; +@override @useResult +$Res call({ + String phoneNumber, String password, Option> failureOrLoginOption, bool isSubmitting, bool showErrorMessages +}); + + + + +} +/// @nodoc +class __$LoginFormStateCopyWithImpl<$Res> + implements _$LoginFormStateCopyWith<$Res> { + __$LoginFormStateCopyWithImpl(this._self, this._then); + + final _LoginFormState _self; + final $Res Function(_LoginFormState) _then; + +/// Create a copy of LoginFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,Object? password = null,Object? failureOrLoginOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(_LoginFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable +as String,failureOrLoginOption: null == failureOrLoginOption ? _self.failureOrLoginOption : failureOrLoginOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/auth/login_form/login_form_event.dart b/lib/application/auth/login_form/login_form_event.dart index ca70b88..776bab0 100644 --- a/lib/application/auth/login_form/login_form_event.dart +++ b/lib/application/auth/login_form/login_form_event.dart @@ -1,7 +1,7 @@ part of 'login_form_bloc.dart'; @freezed -class LoginFormEvent with _$LoginFormEvent { +abstract class LoginFormEvent with _$LoginFormEvent { const factory LoginFormEvent.phoneNumberChanged(String phoneNumber) = _PhoneNumberChanged; const factory LoginFormEvent.passwordChanged(String password) = diff --git a/lib/application/auth/login_form/login_form_state.dart b/lib/application/auth/login_form/login_form_state.dart index 3f51301..d1b9565 100644 --- a/lib/application/auth/login_form/login_form_state.dart +++ b/lib/application/auth/login_form/login_form_state.dart @@ -1,7 +1,7 @@ part of 'login_form_bloc.dart'; @freezed -class LoginFormState with _$LoginFormState { +abstract class LoginFormState with _$LoginFormState { const factory LoginFormState({ required String phoneNumber, required String password, diff --git a/lib/application/auth/logout_form/logout_form_bloc.dart b/lib/application/auth/logout_form/logout_form_bloc.dart index e07ca2f..0f8d2e0 100644 --- a/lib/application/auth/logout_form/logout_form_bloc.dart +++ b/lib/application/auth/logout_form/logout_form_bloc.dart @@ -4,6 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:injectable/injectable.dart'; import '../../../domain/auth/auth.dart'; +import '../../../domain/wallet/wallet.dart'; part 'logout_form_event.dart'; part 'logout_form_state.dart'; @@ -12,8 +13,10 @@ part 'logout_form_bloc.freezed.dart'; @injectable class LogoutFormBloc extends Bloc { final IAuthRepository _repository; + final IDeviceRepository _deviceRepository; - LogoutFormBloc(this._repository) : super(LogoutFormState.initial()) { + LogoutFormBloc(this._repository, this._deviceRepository) + : super(LogoutFormState.initial()) { on(_onLogoutFormEvent); } @@ -24,6 +27,9 @@ class LogoutFormBloc extends Bloc { return event.map( submitted: (e) async { emit(state.copyWith(isSubmitting: true, failureOrAuthOption: none())); + // Hapus registrasi push sebelum token login dihapus. Kegagalannya + // tidak menghalangi logout. + await _deviceRepository.unregister(); final failureOrAuth = await _repository.logout(); emit( state.copyWith( diff --git a/lib/application/auth/logout_form/logout_form_bloc.freezed.dart b/lib/application/auth/logout_form/logout_form_bloc.freezed.dart index 2bdad02..fbca7e5 100644 --- a/lib/application/auth/logout_form/logout_form_bloc.freezed.dart +++ b/lib/application/auth/logout_form/logout_form_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'logout_form_bloc.dart'; @@ -9,327 +9,466 @@ part of 'logout_form_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$LogoutFormEvent { - @optionalTypeArgs - TResult when({ - required TResult Function() submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_Submitted value) submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Submitted value)? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is LogoutFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'LogoutFormEvent()'; +} + + } /// @nodoc -abstract class $LogoutFormEventCopyWith<$Res> { - factory $LogoutFormEventCopyWith( - LogoutFormEvent value, - $Res Function(LogoutFormEvent) then, - ) = _$LogoutFormEventCopyWithImpl<$Res, LogoutFormEvent>; +class $LogoutFormEventCopyWith<$Res> { +$LogoutFormEventCopyWith(LogoutFormEvent _, $Res Function(LogoutFormEvent) __); } -/// @nodoc -class _$LogoutFormEventCopyWithImpl<$Res, $Val extends LogoutFormEvent> - implements $LogoutFormEventCopyWith<$Res> { - _$LogoutFormEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [LogoutFormEvent]. +extension LogoutFormEventPatterns on LogoutFormEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of LogoutFormEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _Submitted(): +return submitted(_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( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_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()? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted();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({required TResult Function() submitted,}) {final _that = this; +switch (_that) { +case _Submitted(): +return submitted();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()? submitted,}) {final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted();case _: + return null; + +} } -/// @nodoc -abstract class _$$SubmittedImplCopyWith<$Res> { - factory _$$SubmittedImplCopyWith( - _$SubmittedImpl value, - $Res Function(_$SubmittedImpl) then, - ) = __$$SubmittedImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$SubmittedImplCopyWithImpl<$Res> - extends _$LogoutFormEventCopyWithImpl<$Res, _$SubmittedImpl> - implements _$$SubmittedImplCopyWith<$Res> { - __$$SubmittedImplCopyWithImpl( - _$SubmittedImpl _value, - $Res Function(_$SubmittedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of LogoutFormEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$SubmittedImpl implements _Submitted { - const _$SubmittedImpl(); - @override - String toString() { +class _Submitted implements LogoutFormEvent { + const _Submitted(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'LogoutFormEvent.submitted()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$SubmittedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function() submitted, - }) { - return submitted(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? submitted, - }) { - return submitted?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Submitted value) submitted, - }) { - return submitted(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Submitted value)? submitted, - }) { - return submitted?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(this); - } - return orElse(); - } } -abstract class _Submitted implements LogoutFormEvent { - const factory _Submitted() = _$SubmittedImpl; + } + + + /// @nodoc mixin _$LogoutFormState { - Option> get failureOrAuthOption => - throw _privateConstructorUsedError; - bool get isSubmitting => throw _privateConstructorUsedError; - /// Create a copy of LogoutFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $LogoutFormStateCopyWith get copyWith => - throw _privateConstructorUsedError; + Option> get failureOrAuthOption; bool get isSubmitting; +/// Create a copy of LogoutFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LogoutFormStateCopyWith get copyWith => _$LogoutFormStateCopyWithImpl(this as LogoutFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as LogoutFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is LogoutFormState&&(identical(other.failureOrAuthOption, _this.failureOrAuthOption) || other.failureOrAuthOption == _this.failureOrAuthOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)); +} + + +@override +int get hashCode { + final _this = this as LogoutFormState; + return Object.hash(runtimeType,_this.failureOrAuthOption,_this.isSubmitting); +} + +@override +String toString() { + final _this = this as LogoutFormState; + return 'LogoutFormState(failureOrAuthOption: ${_this.failureOrAuthOption}, isSubmitting: ${_this.isSubmitting})'; +} + + } /// @nodoc -abstract class $LogoutFormStateCopyWith<$Res> { - factory $LogoutFormStateCopyWith( - LogoutFormState value, - $Res Function(LogoutFormState) then, - ) = _$LogoutFormStateCopyWithImpl<$Res, LogoutFormState>; - @useResult - $Res call({ - Option> failureOrAuthOption, - bool isSubmitting, - }); -} +abstract mixin class $LogoutFormStateCopyWith<$Res> { + factory $LogoutFormStateCopyWith(LogoutFormState value, $Res Function(LogoutFormState) _then) = _$LogoutFormStateCopyWithImpl; +@useResult +$Res call({ + Option> failureOrAuthOption, bool isSubmitting +}); + + + +} /// @nodoc -class _$LogoutFormStateCopyWithImpl<$Res, $Val extends LogoutFormState> +class _$LogoutFormStateCopyWithImpl<$Res> implements $LogoutFormStateCopyWith<$Res> { - _$LogoutFormStateCopyWithImpl(this._value, this._then); + _$LogoutFormStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final LogoutFormState _self; + final $Res Function(LogoutFormState) _then; - /// Create a copy of LogoutFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? failureOrAuthOption = null, Object? isSubmitting = null}) { - return _then( - _value.copyWith( - failureOrAuthOption: null == failureOrAuthOption - ? _value.failureOrAuthOption - : failureOrAuthOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } +/// Create a copy of LogoutFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? failureOrAuthOption = null,Object? isSubmitting = null,}) { + return _then(LogoutFormState( +failureOrAuthOption: null == failureOrAuthOption ? _self.failureOrAuthOption : failureOrAuthOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$LogoutFormStateImplCopyWith<$Res> - implements $LogoutFormStateCopyWith<$Res> { - factory _$$LogoutFormStateImplCopyWith( - _$LogoutFormStateImpl value, - $Res Function(_$LogoutFormStateImpl) then, - ) = __$$LogoutFormStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - Option> failureOrAuthOption, - bool isSubmitting, - }); } -/// @nodoc -class __$$LogoutFormStateImplCopyWithImpl<$Res> - extends _$LogoutFormStateCopyWithImpl<$Res, _$LogoutFormStateImpl> - implements _$$LogoutFormStateImplCopyWith<$Res> { - __$$LogoutFormStateImplCopyWithImpl( - _$LogoutFormStateImpl _value, - $Res Function(_$LogoutFormStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of LogoutFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? failureOrAuthOption = null, Object? isSubmitting = null}) { - return _then( - _$LogoutFormStateImpl( - failureOrAuthOption: null == failureOrAuthOption - ? _value.failureOrAuthOption - : failureOrAuthOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [LogoutFormState]. +extension LogoutFormStatePatterns on LogoutFormState { +/// 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( _LogoutFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LogoutFormState() 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( _LogoutFormState value) $default,){ +final _that = this; +switch (_that) { +case _LogoutFormState(): +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( _LogoutFormState value)? $default,){ +final _that = this; +switch (_that) { +case _LogoutFormState() 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( Option> failureOrAuthOption, bool isSubmitting)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LogoutFormState() when $default != null: +return $default(_that.failureOrAuthOption,_that.isSubmitting);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( Option> failureOrAuthOption, bool isSubmitting) $default,) {final _that = this; +switch (_that) { +case _LogoutFormState(): +return $default(_that.failureOrAuthOption,_that.isSubmitting);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( Option> failureOrAuthOption, bool isSubmitting)? $default,) {final _that = this; +switch (_that) { +case _LogoutFormState() when $default != null: +return $default(_that.failureOrAuthOption,_that.isSubmitting);case _: + return null; + +} +} + } /// @nodoc -class _$LogoutFormStateImpl implements _LogoutFormState { - const _$LogoutFormStateImpl({ - required this.failureOrAuthOption, - this.isSubmitting = false, - }); - @override - final Option> failureOrAuthOption; - @override - @JsonKey() - final bool isSubmitting; +class _LogoutFormState implements LogoutFormState { + const _LogoutFormState({required this.failureOrAuthOption, this.isSubmitting = false}); + - @override - String toString() { +@override final Option> failureOrAuthOption; +@override@JsonKey() final bool isSubmitting; + +/// Create a copy of LogoutFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LogoutFormStateCopyWith<_LogoutFormState> get copyWith => __$LogoutFormStateCopyWithImpl<_LogoutFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LogoutFormState&&(identical(other.failureOrAuthOption, failureOrAuthOption) || other.failureOrAuthOption == failureOrAuthOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,failureOrAuthOption,isSubmitting); +} + +@override +String toString() { return 'LogoutFormState(failureOrAuthOption: $failureOrAuthOption, isSubmitting: $isSubmitting)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LogoutFormStateImpl && - (identical(other.failureOrAuthOption, failureOrAuthOption) || - other.failureOrAuthOption == failureOrAuthOption) && - (identical(other.isSubmitting, isSubmitting) || - other.isSubmitting == isSubmitting)); - } - - @override - int get hashCode => - Object.hash(runtimeType, failureOrAuthOption, isSubmitting); - - /// Create a copy of LogoutFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$LogoutFormStateImplCopyWith<_$LogoutFormStateImpl> get copyWith => - __$$LogoutFormStateImplCopyWithImpl<_$LogoutFormStateImpl>( - this, - _$identity, - ); } -abstract class _LogoutFormState implements LogoutFormState { - const factory _LogoutFormState({ - required final Option> failureOrAuthOption, - final bool isSubmitting, - }) = _$LogoutFormStateImpl; - @override - Option> get failureOrAuthOption; - @override - bool get isSubmitting; - - /// Create a copy of LogoutFormState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$LogoutFormStateImplCopyWith<_$LogoutFormStateImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$LogoutFormStateCopyWith<$Res> implements $LogoutFormStateCopyWith<$Res> { + factory _$LogoutFormStateCopyWith(_LogoutFormState value, $Res Function(_LogoutFormState) _then) = __$LogoutFormStateCopyWithImpl; +@override @useResult +$Res call({ + Option> failureOrAuthOption, bool isSubmitting +}); + + + + +} +/// @nodoc +class __$LogoutFormStateCopyWithImpl<$Res> + implements _$LogoutFormStateCopyWith<$Res> { + __$LogoutFormStateCopyWithImpl(this._self, this._then); + + final _LogoutFormState _self; + final $Res Function(_LogoutFormState) _then; + +/// Create a copy of LogoutFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? failureOrAuthOption = null,Object? isSubmitting = null,}) { + return _then(_LogoutFormState( +failureOrAuthOption: null == failureOrAuthOption ? _self.failureOrAuthOption : failureOrAuthOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/auth/logout_form/logout_form_event.dart b/lib/application/auth/logout_form/logout_form_event.dart index 606bf91..fa2dff8 100644 --- a/lib/application/auth/logout_form/logout_form_event.dart +++ b/lib/application/auth/logout_form/logout_form_event.dart @@ -1,6 +1,6 @@ part of 'logout_form_bloc.dart'; @freezed -class LogoutFormEvent with _$LogoutFormEvent { +abstract class LogoutFormEvent with _$LogoutFormEvent { const factory LogoutFormEvent.submitted() = _Submitted; } diff --git a/lib/application/auth/logout_form/logout_form_state.dart b/lib/application/auth/logout_form/logout_form_state.dart index 613c5e1..5f25b8f 100644 --- a/lib/application/auth/logout_form/logout_form_state.dart +++ b/lib/application/auth/logout_form/logout_form_state.dart @@ -1,7 +1,7 @@ part of 'logout_form_bloc.dart'; @freezed -class LogoutFormState with _$LogoutFormState { +abstract class LogoutFormState with _$LogoutFormState { const factory LogoutFormState({ required Option> failureOrAuthOption, @Default(false) bool isSubmitting, diff --git a/lib/application/auth/register_form/register_form_bloc.freezed.dart b/lib/application/auth/register_form/register_form_bloc.freezed.dart index cbd87c8..32707c0 100644 --- a/lib/application/auth/register_form/register_form_bloc.freezed.dart +++ b/lib/application/auth/register_form/register_form_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'register_form_bloc.dart'; @@ -9,936 +9,700 @@ part of 'register_form_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$RegisterFormEvent { - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String name) nameChanged, - required TResult Function(DateTime birthDate) birthDateChanged, - required TResult Function() submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String name)? nameChanged, - TResult? Function(DateTime birthDate)? birthDateChanged, - TResult? Function()? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String name)? nameChanged, - TResult Function(DateTime birthDate)? birthDateChanged, - TResult Function()? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_NameChanged value) nameChanged, - required TResult Function(_BirthDateChanged value) birthDateChanged, - required TResult Function(_Submitted value) submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_NameChanged value)? nameChanged, - TResult? Function(_BirthDateChanged value)? birthDateChanged, - TResult? Function(_Submitted value)? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_NameChanged value)? nameChanged, - TResult Function(_BirthDateChanged value)? birthDateChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'RegisterFormEvent()'; +} + + } /// @nodoc -abstract class $RegisterFormEventCopyWith<$Res> { - factory $RegisterFormEventCopyWith( - RegisterFormEvent value, - $Res Function(RegisterFormEvent) then, - ) = _$RegisterFormEventCopyWithImpl<$Res, RegisterFormEvent>; +class $RegisterFormEventCopyWith<$Res> { +$RegisterFormEventCopyWith(RegisterFormEvent _, $Res Function(RegisterFormEvent) __); } -/// @nodoc -class _$RegisterFormEventCopyWithImpl<$Res, $Val extends RegisterFormEvent> - implements $RegisterFormEventCopyWith<$Res> { - _$RegisterFormEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [RegisterFormEvent]. +extension RegisterFormEventPatterns on RegisterFormEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _PhoneNumberChanged value)? phoneNumberChanged,TResult Function( _NameChanged value)? nameChanged,TResult Function( _BirthDateChanged value)? birthDateChanged,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _NameChanged() when nameChanged != null: +return nameChanged(_that);case _BirthDateChanged() when birthDateChanged != null: +return birthDateChanged(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _PhoneNumberChanged value) phoneNumberChanged,required TResult Function( _NameChanged value) nameChanged,required TResult Function( _BirthDateChanged value) birthDateChanged,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that);case _NameChanged(): +return nameChanged(_that);case _BirthDateChanged(): +return birthDateChanged(_that);case _Submitted(): +return submitted(_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( _PhoneNumberChanged value)? phoneNumberChanged,TResult? Function( _NameChanged value)? nameChanged,TResult? Function( _BirthDateChanged value)? birthDateChanged,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _NameChanged() when nameChanged != null: +return nameChanged(_that);case _BirthDateChanged() when birthDateChanged != null: +return birthDateChanged(_that);case _Submitted() when submitted != null: +return submitted(_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 phoneNumber)? phoneNumberChanged,TResult Function( String name)? nameChanged,TResult Function( DateTime birthDate)? birthDateChanged,TResult Function()? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _NameChanged() when nameChanged != null: +return nameChanged(_that.name);case _BirthDateChanged() when birthDateChanged != null: +return birthDateChanged(_that.birthDate);case _Submitted() when submitted != null: +return submitted();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({required TResult Function( String phoneNumber) phoneNumberChanged,required TResult Function( String name) nameChanged,required TResult Function( DateTime birthDate) birthDateChanged,required TResult Function() submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that.phoneNumber);case _NameChanged(): +return nameChanged(_that.name);case _BirthDateChanged(): +return birthDateChanged(_that.birthDate);case _Submitted(): +return submitted();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 phoneNumber)? phoneNumberChanged,TResult? Function( String name)? nameChanged,TResult? Function( DateTime birthDate)? birthDateChanged,TResult? Function()? submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _NameChanged() when nameChanged != null: +return nameChanged(_that.name);case _BirthDateChanged() when birthDateChanged != null: +return birthDateChanged(_that.birthDate);case _Submitted() when submitted != null: +return submitted();case _: + return null; + +} } -/// @nodoc -abstract class _$$PhoneNumberChangedImplCopyWith<$Res> { - factory _$$PhoneNumberChangedImplCopyWith( - _$PhoneNumberChangedImpl value, - $Res Function(_$PhoneNumberChangedImpl) then, - ) = __$$PhoneNumberChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String phoneNumber}); -} - -/// @nodoc -class __$$PhoneNumberChangedImplCopyWithImpl<$Res> - extends _$RegisterFormEventCopyWithImpl<$Res, _$PhoneNumberChangedImpl> - implements _$$PhoneNumberChangedImplCopyWith<$Res> { - __$$PhoneNumberChangedImplCopyWithImpl( - _$PhoneNumberChangedImpl _value, - $Res Function(_$PhoneNumberChangedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? phoneNumber = null}) { - return _then( - _$PhoneNumberChangedImpl( - null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$PhoneNumberChangedImpl implements _PhoneNumberChanged { - const _$PhoneNumberChangedImpl(this.phoneNumber); - @override - final String phoneNumber; +class _PhoneNumberChanged implements RegisterFormEvent { + const _PhoneNumberChanged(this.phoneNumber); + - @override - String toString() { + final String phoneNumber; + +/// Create a copy of RegisterFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PhoneNumberChangedCopyWith<_PhoneNumberChanged> get copyWith => __$PhoneNumberChangedCopyWithImpl<_PhoneNumberChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PhoneNumberChanged&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber); +} + +@override +String toString() { return 'RegisterFormEvent.phoneNumberChanged(phoneNumber: $phoneNumber)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PhoneNumberChangedImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber)); - } - - @override - int get hashCode => Object.hash(runtimeType, phoneNumber); - - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - __$$PhoneNumberChangedImplCopyWithImpl<_$PhoneNumberChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String name) nameChanged, - required TResult Function(DateTime birthDate) birthDateChanged, - required TResult Function() submitted, - }) { - return phoneNumberChanged(phoneNumber); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String name)? nameChanged, - TResult? Function(DateTime birthDate)? birthDateChanged, - TResult? Function()? submitted, - }) { - return phoneNumberChanged?.call(phoneNumber); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String name)? nameChanged, - TResult Function(DateTime birthDate)? birthDateChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(phoneNumber); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_NameChanged value) nameChanged, - required TResult Function(_BirthDateChanged value) birthDateChanged, - required TResult Function(_Submitted value) submitted, - }) { - return phoneNumberChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_NameChanged value)? nameChanged, - TResult? Function(_BirthDateChanged value)? birthDateChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return phoneNumberChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_NameChanged value)? nameChanged, - TResult Function(_BirthDateChanged value)? birthDateChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(this); - } - return orElse(); - } } -abstract class _PhoneNumberChanged implements RegisterFormEvent { - const factory _PhoneNumberChanged(final String phoneNumber) = - _$PhoneNumberChangedImpl; - String get phoneNumber; - - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$NameChangedImplCopyWith<$Res> { - factory _$$NameChangedImplCopyWith( - _$NameChangedImpl value, - $Res Function(_$NameChangedImpl) then, - ) = __$$NameChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String name}); +abstract mixin class _$PhoneNumberChangedCopyWith<$Res> implements $RegisterFormEventCopyWith<$Res> { + factory _$PhoneNumberChangedCopyWith(_PhoneNumberChanged value, $Res Function(_PhoneNumberChanged) _then) = __$PhoneNumberChangedCopyWithImpl; +@useResult +$Res call({ + String phoneNumber +}); + + + + +} +/// @nodoc +class __$PhoneNumberChangedCopyWithImpl<$Res> + implements _$PhoneNumberChangedCopyWith<$Res> { + __$PhoneNumberChangedCopyWithImpl(this._self, this._then); + + final _PhoneNumberChanged _self; + final $Res Function(_PhoneNumberChanged) _then; + +/// Create a copy of RegisterFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,}) { + return _then(_PhoneNumberChanged( +null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$NameChangedImplCopyWithImpl<$Res> - extends _$RegisterFormEventCopyWithImpl<$Res, _$NameChangedImpl> - implements _$$NameChangedImplCopyWith<$Res> { - __$$NameChangedImplCopyWithImpl( - _$NameChangedImpl _value, - $Res Function(_$NameChangedImpl) _then, - ) : super(_value, _then); - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? name = null}) { - return _then( - _$NameChangedImpl( - null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$NameChangedImpl implements _NameChanged { - const _$NameChangedImpl(this.name); - @override - final String name; +class _NameChanged implements RegisterFormEvent { + const _NameChanged(this.name); + - @override - String toString() { + final String name; + +/// Create a copy of RegisterFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NameChangedCopyWith<_NameChanged> get copyWith => __$NameChangedCopyWithImpl<_NameChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NameChanged&&(identical(other.name, name) || other.name == name)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,name); +} + +@override +String toString() { return 'RegisterFormEvent.nameChanged(name: $name)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NameChangedImpl && - (identical(other.name, name) || other.name == name)); - } - - @override - int get hashCode => Object.hash(runtimeType, name); - - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith => - __$$NameChangedImplCopyWithImpl<_$NameChangedImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String name) nameChanged, - required TResult Function(DateTime birthDate) birthDateChanged, - required TResult Function() submitted, - }) { - return nameChanged(name); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String name)? nameChanged, - TResult? Function(DateTime birthDate)? birthDateChanged, - TResult? Function()? submitted, - }) { - return nameChanged?.call(name); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String name)? nameChanged, - TResult Function(DateTime birthDate)? birthDateChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (nameChanged != null) { - return nameChanged(name); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_NameChanged value) nameChanged, - required TResult Function(_BirthDateChanged value) birthDateChanged, - required TResult Function(_Submitted value) submitted, - }) { - return nameChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_NameChanged value)? nameChanged, - TResult? Function(_BirthDateChanged value)? birthDateChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return nameChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_NameChanged value)? nameChanged, - TResult Function(_BirthDateChanged value)? birthDateChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (nameChanged != null) { - return nameChanged(this); - } - return orElse(); - } } -abstract class _NameChanged implements RegisterFormEvent { - const factory _NameChanged(final String name) = _$NameChangedImpl; - String get name; - - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$BirthDateChangedImplCopyWith<$Res> { - factory _$$BirthDateChangedImplCopyWith( - _$BirthDateChangedImpl value, - $Res Function(_$BirthDateChangedImpl) then, - ) = __$$BirthDateChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({DateTime birthDate}); +abstract mixin class _$NameChangedCopyWith<$Res> implements $RegisterFormEventCopyWith<$Res> { + factory _$NameChangedCopyWith(_NameChanged value, $Res Function(_NameChanged) _then) = __$NameChangedCopyWithImpl; +@useResult +$Res call({ + String name +}); + + + + +} +/// @nodoc +class __$NameChangedCopyWithImpl<$Res> + implements _$NameChangedCopyWith<$Res> { + __$NameChangedCopyWithImpl(this._self, this._then); + + final _NameChanged _self; + final $Res Function(_NameChanged) _then; + +/// Create a copy of RegisterFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? name = null,}) { + return _then(_NameChanged( +null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$BirthDateChangedImplCopyWithImpl<$Res> - extends _$RegisterFormEventCopyWithImpl<$Res, _$BirthDateChangedImpl> - implements _$$BirthDateChangedImplCopyWith<$Res> { - __$$BirthDateChangedImplCopyWithImpl( - _$BirthDateChangedImpl _value, - $Res Function(_$BirthDateChangedImpl) _then, - ) : super(_value, _then); - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? birthDate = null}) { - return _then( - _$BirthDateChangedImpl( - null == birthDate - ? _value.birthDate - : birthDate // ignore: cast_nullable_to_non_nullable - as DateTime, - ), - ); - } } /// @nodoc -class _$BirthDateChangedImpl implements _BirthDateChanged { - const _$BirthDateChangedImpl(this.birthDate); - @override - final DateTime birthDate; +class _BirthDateChanged implements RegisterFormEvent { + const _BirthDateChanged(this.birthDate); + - @override - String toString() { + final DateTime birthDate; + +/// Create a copy of RegisterFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$BirthDateChangedCopyWith<_BirthDateChanged> get copyWith => __$BirthDateChangedCopyWithImpl<_BirthDateChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _BirthDateChanged&&(identical(other.birthDate, birthDate) || other.birthDate == birthDate)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,birthDate); +} + +@override +String toString() { return 'RegisterFormEvent.birthDateChanged(birthDate: $birthDate)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$BirthDateChangedImpl && - (identical(other.birthDate, birthDate) || - other.birthDate == birthDate)); - } - - @override - int get hashCode => Object.hash(runtimeType, birthDate); - - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$BirthDateChangedImplCopyWith<_$BirthDateChangedImpl> get copyWith => - __$$BirthDateChangedImplCopyWithImpl<_$BirthDateChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String name) nameChanged, - required TResult Function(DateTime birthDate) birthDateChanged, - required TResult Function() submitted, - }) { - return birthDateChanged(birthDate); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String name)? nameChanged, - TResult? Function(DateTime birthDate)? birthDateChanged, - TResult? Function()? submitted, - }) { - return birthDateChanged?.call(birthDate); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String name)? nameChanged, - TResult Function(DateTime birthDate)? birthDateChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (birthDateChanged != null) { - return birthDateChanged(birthDate); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_NameChanged value) nameChanged, - required TResult Function(_BirthDateChanged value) birthDateChanged, - required TResult Function(_Submitted value) submitted, - }) { - return birthDateChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_NameChanged value)? nameChanged, - TResult? Function(_BirthDateChanged value)? birthDateChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return birthDateChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_NameChanged value)? nameChanged, - TResult Function(_BirthDateChanged value)? birthDateChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (birthDateChanged != null) { - return birthDateChanged(this); - } - return orElse(); - } } -abstract class _BirthDateChanged implements RegisterFormEvent { - const factory _BirthDateChanged(final DateTime birthDate) = - _$BirthDateChangedImpl; - DateTime get birthDate; - - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$BirthDateChangedImplCopyWith<_$BirthDateChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$SubmittedImplCopyWith<$Res> { - factory _$$SubmittedImplCopyWith( - _$SubmittedImpl value, - $Res Function(_$SubmittedImpl) then, - ) = __$$SubmittedImplCopyWithImpl<$Res>; +abstract mixin class _$BirthDateChangedCopyWith<$Res> implements $RegisterFormEventCopyWith<$Res> { + factory _$BirthDateChangedCopyWith(_BirthDateChanged value, $Res Function(_BirthDateChanged) _then) = __$BirthDateChangedCopyWithImpl; +@useResult +$Res call({ + DateTime birthDate +}); + + + + +} +/// @nodoc +class __$BirthDateChangedCopyWithImpl<$Res> + implements _$BirthDateChangedCopyWith<$Res> { + __$BirthDateChangedCopyWithImpl(this._self, this._then); + + final _BirthDateChanged _self; + final $Res Function(_BirthDateChanged) _then; + +/// Create a copy of RegisterFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? birthDate = null,}) { + return _then(_BirthDateChanged( +null == birthDate ? _self.birthDate : birthDate // ignore: cast_nullable_to_non_nullable +as DateTime, + )); } -/// @nodoc -class __$$SubmittedImplCopyWithImpl<$Res> - extends _$RegisterFormEventCopyWithImpl<$Res, _$SubmittedImpl> - implements _$$SubmittedImplCopyWith<$Res> { - __$$SubmittedImplCopyWithImpl( - _$SubmittedImpl _value, - $Res Function(_$SubmittedImpl) _then, - ) : super(_value, _then); - /// Create a copy of RegisterFormEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$SubmittedImpl implements _Submitted { - const _$SubmittedImpl(); - @override - String toString() { +class _Submitted implements RegisterFormEvent { + const _Submitted(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'RegisterFormEvent.submitted()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$SubmittedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String name) nameChanged, - required TResult Function(DateTime birthDate) birthDateChanged, - required TResult Function() submitted, - }) { - return submitted(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String name)? nameChanged, - TResult? Function(DateTime birthDate)? birthDateChanged, - TResult? Function()? submitted, - }) { - return submitted?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String name)? nameChanged, - TResult Function(DateTime birthDate)? birthDateChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_NameChanged value) nameChanged, - required TResult Function(_BirthDateChanged value) birthDateChanged, - required TResult Function(_Submitted value) submitted, - }) { - return submitted(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_NameChanged value)? nameChanged, - TResult? Function(_BirthDateChanged value)? birthDateChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return submitted?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_NameChanged value)? nameChanged, - TResult Function(_BirthDateChanged value)? birthDateChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(this); - } - return orElse(); - } } -abstract class _Submitted implements RegisterFormEvent { - const factory _Submitted() = _$SubmittedImpl; + } + + + /// @nodoc mixin _$RegisterFormState { - String get phoneNumber => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - DateTime get birthDate => throw _privateConstructorUsedError; - Option> get failureOrRegisterOption => - throw _privateConstructorUsedError; - bool get isSubmitting => throw _privateConstructorUsedError; - bool get showErrorMessages => throw _privateConstructorUsedError; - /// Create a copy of RegisterFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $RegisterFormStateCopyWith get copyWith => - throw _privateConstructorUsedError; + String get phoneNumber; String get name; DateTime get birthDate; Option> get failureOrRegisterOption; bool get isSubmitting; bool get showErrorMessages; +/// Create a copy of RegisterFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$RegisterFormStateCopyWith get copyWith => _$RegisterFormStateCopyWithImpl(this as RegisterFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as RegisterFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterFormState&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.birthDate, _this.birthDate) || other.birthDate == _this.birthDate)&&(identical(other.failureOrRegisterOption, _this.failureOrRegisterOption) || other.failureOrRegisterOption == _this.failureOrRegisterOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.showErrorMessages, _this.showErrorMessages) || other.showErrorMessages == _this.showErrorMessages)); +} + + +@override +int get hashCode { + final _this = this as RegisterFormState; + return Object.hash(runtimeType,_this.phoneNumber,_this.name,_this.birthDate,_this.failureOrRegisterOption,_this.isSubmitting,_this.showErrorMessages); +} + +@override +String toString() { + final _this = this as RegisterFormState; + return 'RegisterFormState(phoneNumber: ${_this.phoneNumber}, name: ${_this.name}, birthDate: ${_this.birthDate}, failureOrRegisterOption: ${_this.failureOrRegisterOption}, isSubmitting: ${_this.isSubmitting}, showErrorMessages: ${_this.showErrorMessages})'; +} + + } /// @nodoc -abstract class $RegisterFormStateCopyWith<$Res> { - factory $RegisterFormStateCopyWith( - RegisterFormState value, - $Res Function(RegisterFormState) then, - ) = _$RegisterFormStateCopyWithImpl<$Res, RegisterFormState>; - @useResult - $Res call({ - String phoneNumber, - String name, - DateTime birthDate, - Option> failureOrRegisterOption, - bool isSubmitting, - bool showErrorMessages, - }); -} +abstract mixin class $RegisterFormStateCopyWith<$Res> { + factory $RegisterFormStateCopyWith(RegisterFormState value, $Res Function(RegisterFormState) _then) = _$RegisterFormStateCopyWithImpl; +@useResult +$Res call({ + String phoneNumber, String name, DateTime birthDate, Option> failureOrRegisterOption, bool isSubmitting, bool showErrorMessages +}); + + + +} /// @nodoc -class _$RegisterFormStateCopyWithImpl<$Res, $Val extends RegisterFormState> +class _$RegisterFormStateCopyWithImpl<$Res> implements $RegisterFormStateCopyWith<$Res> { - _$RegisterFormStateCopyWithImpl(this._value, this._then); + _$RegisterFormStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final RegisterFormState _self; + final $Res Function(RegisterFormState) _then; - /// Create a copy of RegisterFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? name = null, - Object? birthDate = null, - Object? failureOrRegisterOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _value.copyWith( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - birthDate: null == birthDate - ? _value.birthDate - : birthDate // ignore: cast_nullable_to_non_nullable - as DateTime, - failureOrRegisterOption: null == failureOrRegisterOption - ? _value.failureOrRegisterOption - : failureOrRegisterOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } +/// Create a copy of RegisterFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? phoneNumber = null,Object? name = null,Object? birthDate = null,Object? failureOrRegisterOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(RegisterFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,birthDate: null == birthDate ? _self.birthDate : birthDate // ignore: cast_nullable_to_non_nullable +as DateTime,failureOrRegisterOption: null == failureOrRegisterOption ? _self.failureOrRegisterOption : failureOrRegisterOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$RegisterFormStateImplCopyWith<$Res> - implements $RegisterFormStateCopyWith<$Res> { - factory _$$RegisterFormStateImplCopyWith( - _$RegisterFormStateImpl value, - $Res Function(_$RegisterFormStateImpl) then, - ) = __$$RegisterFormStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String phoneNumber, - String name, - DateTime birthDate, - Option> failureOrRegisterOption, - bool isSubmitting, - bool showErrorMessages, - }); } -/// @nodoc -class __$$RegisterFormStateImplCopyWithImpl<$Res> - extends _$RegisterFormStateCopyWithImpl<$Res, _$RegisterFormStateImpl> - implements _$$RegisterFormStateImplCopyWith<$Res> { - __$$RegisterFormStateImplCopyWithImpl( - _$RegisterFormStateImpl _value, - $Res Function(_$RegisterFormStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of RegisterFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? name = null, - Object? birthDate = null, - Object? failureOrRegisterOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _$RegisterFormStateImpl( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - birthDate: null == birthDate - ? _value.birthDate - : birthDate // ignore: cast_nullable_to_non_nullable - as DateTime, - failureOrRegisterOption: null == failureOrRegisterOption - ? _value.failureOrRegisterOption - : failureOrRegisterOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [RegisterFormState]. +extension RegisterFormStatePatterns on RegisterFormState { +/// 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( _RegisterFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _RegisterFormState() 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( _RegisterFormState value) $default,){ +final _that = this; +switch (_that) { +case _RegisterFormState(): +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( _RegisterFormState value)? $default,){ +final _that = this; +switch (_that) { +case _RegisterFormState() 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 phoneNumber, String name, DateTime birthDate, Option> failureOrRegisterOption, bool isSubmitting, bool showErrorMessages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _RegisterFormState() when $default != null: +return $default(_that.phoneNumber,_that.name,_that.birthDate,_that.failureOrRegisterOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, String name, DateTime birthDate, Option> failureOrRegisterOption, bool isSubmitting, bool showErrorMessages) $default,) {final _that = this; +switch (_that) { +case _RegisterFormState(): +return $default(_that.phoneNumber,_that.name,_that.birthDate,_that.failureOrRegisterOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, String name, DateTime birthDate, Option> failureOrRegisterOption, bool isSubmitting, bool showErrorMessages)? $default,) {final _that = this; +switch (_that) { +case _RegisterFormState() when $default != null: +return $default(_that.phoneNumber,_that.name,_that.birthDate,_that.failureOrRegisterOption,_that.isSubmitting,_that.showErrorMessages);case _: + return null; + +} +} + } /// @nodoc -class _$RegisterFormStateImpl implements _RegisterFormState { - const _$RegisterFormStateImpl({ - required this.phoneNumber, - required this.name, - required this.birthDate, - required this.failureOrRegisterOption, - this.isSubmitting = false, - this.showErrorMessages = false, - }); - @override - final String phoneNumber; - @override - final String name; - @override - final DateTime birthDate; - @override - final Option> failureOrRegisterOption; - @override - @JsonKey() - final bool isSubmitting; - @override - @JsonKey() - final bool showErrorMessages; +class _RegisterFormState implements RegisterFormState { + const _RegisterFormState({required this.phoneNumber, required this.name, required this.birthDate, required this.failureOrRegisterOption, this.isSubmitting = false, this.showErrorMessages = false}); + - @override - String toString() { +@override final String phoneNumber; +@override final String name; +@override final DateTime birthDate; +@override final Option> failureOrRegisterOption; +@override@JsonKey() final bool isSubmitting; +@override@JsonKey() final bool showErrorMessages; + +/// Create a copy of RegisterFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RegisterFormStateCopyWith<_RegisterFormState> get copyWith => __$RegisterFormStateCopyWithImpl<_RegisterFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _RegisterFormState&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.name, name) || other.name == name)&&(identical(other.birthDate, birthDate) || other.birthDate == birthDate)&&(identical(other.failureOrRegisterOption, failureOrRegisterOption) || other.failureOrRegisterOption == failureOrRegisterOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.showErrorMessages, showErrorMessages) || other.showErrorMessages == showErrorMessages)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber,name,birthDate,failureOrRegisterOption,isSubmitting,showErrorMessages); +} + +@override +String toString() { return 'RegisterFormState(phoneNumber: $phoneNumber, name: $name, birthDate: $birthDate, failureOrRegisterOption: $failureOrRegisterOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RegisterFormStateImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber) && - (identical(other.name, name) || other.name == name) && - (identical(other.birthDate, birthDate) || - other.birthDate == birthDate) && - (identical( - other.failureOrRegisterOption, - failureOrRegisterOption, - ) || - other.failureOrRegisterOption == failureOrRegisterOption) && - (identical(other.isSubmitting, isSubmitting) || - other.isSubmitting == isSubmitting) && - (identical(other.showErrorMessages, showErrorMessages) || - other.showErrorMessages == showErrorMessages)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - phoneNumber, - name, - birthDate, - failureOrRegisterOption, - isSubmitting, - showErrorMessages, - ); - - /// Create a copy of RegisterFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RegisterFormStateImplCopyWith<_$RegisterFormStateImpl> get copyWith => - __$$RegisterFormStateImplCopyWithImpl<_$RegisterFormStateImpl>( - this, - _$identity, - ); } -abstract class _RegisterFormState implements RegisterFormState { - const factory _RegisterFormState({ - required final String phoneNumber, - required final String name, - required final DateTime birthDate, - required final Option> - failureOrRegisterOption, - final bool isSubmitting, - final bool showErrorMessages, - }) = _$RegisterFormStateImpl; - @override - String get phoneNumber; - @override - String get name; - @override - DateTime get birthDate; - @override - Option> get failureOrRegisterOption; - @override - bool get isSubmitting; - @override - bool get showErrorMessages; - - /// Create a copy of RegisterFormState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RegisterFormStateImplCopyWith<_$RegisterFormStateImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$RegisterFormStateCopyWith<$Res> implements $RegisterFormStateCopyWith<$Res> { + factory _$RegisterFormStateCopyWith(_RegisterFormState value, $Res Function(_RegisterFormState) _then) = __$RegisterFormStateCopyWithImpl; +@override @useResult +$Res call({ + String phoneNumber, String name, DateTime birthDate, Option> failureOrRegisterOption, bool isSubmitting, bool showErrorMessages +}); + + + + +} +/// @nodoc +class __$RegisterFormStateCopyWithImpl<$Res> + implements _$RegisterFormStateCopyWith<$Res> { + __$RegisterFormStateCopyWithImpl(this._self, this._then); + + final _RegisterFormState _self; + final $Res Function(_RegisterFormState) _then; + +/// Create a copy of RegisterFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,Object? name = null,Object? birthDate = null,Object? failureOrRegisterOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(_RegisterFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,birthDate: null == birthDate ? _self.birthDate : birthDate // ignore: cast_nullable_to_non_nullable +as DateTime,failureOrRegisterOption: null == failureOrRegisterOption ? _self.failureOrRegisterOption : failureOrRegisterOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/auth/register_form/register_form_event.dart b/lib/application/auth/register_form/register_form_event.dart index b92677a..d14f3af 100644 --- a/lib/application/auth/register_form/register_form_event.dart +++ b/lib/application/auth/register_form/register_form_event.dart @@ -1,7 +1,7 @@ part of 'register_form_bloc.dart'; @freezed -class RegisterFormEvent with _$RegisterFormEvent { +abstract class RegisterFormEvent with _$RegisterFormEvent { const factory RegisterFormEvent.phoneNumberChanged(String phoneNumber) = _PhoneNumberChanged; const factory RegisterFormEvent.nameChanged(String name) = _NameChanged; diff --git a/lib/application/auth/register_form/register_form_state.dart b/lib/application/auth/register_form/register_form_state.dart index 4ed224b..4afaffe 100644 --- a/lib/application/auth/register_form/register_form_state.dart +++ b/lib/application/auth/register_form/register_form_state.dart @@ -1,7 +1,7 @@ part of 'register_form_bloc.dart'; @freezed -class RegisterFormState with _$RegisterFormState { +abstract class RegisterFormState with _$RegisterFormState { const factory RegisterFormState({ required String phoneNumber, required String name, diff --git a/lib/application/auth/resend_form/resend_form_bloc.freezed.dart b/lib/application/auth/resend_form/resend_form_bloc.freezed.dart index 65aefe4..9067c67 100644 --- a/lib/application/auth/resend_form/resend_form_bloc.freezed.dart +++ b/lib/application/auth/resend_form/resend_form_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'resend_form_bloc.dart'; @@ -9,730 +9,623 @@ part of 'resend_form_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$ResendFormEvent { - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String purpose) purposeChanged, - required TResult Function() submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String purpose)? purposeChanged, - TResult? Function()? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String purpose)? purposeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PurposeChanged value) purposeChanged, - required TResult Function(_Submitted value) submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PurposeChanged value)? purposeChanged, - TResult? Function(_Submitted value)? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PurposeChanged value)? purposeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ResendFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'ResendFormEvent()'; +} + + } /// @nodoc -abstract class $ResendFormEventCopyWith<$Res> { - factory $ResendFormEventCopyWith( - ResendFormEvent value, - $Res Function(ResendFormEvent) then, - ) = _$ResendFormEventCopyWithImpl<$Res, ResendFormEvent>; +class $ResendFormEventCopyWith<$Res> { +$ResendFormEventCopyWith(ResendFormEvent _, $Res Function(ResendFormEvent) __); } -/// @nodoc -class _$ResendFormEventCopyWithImpl<$Res, $Val extends ResendFormEvent> - implements $ResendFormEventCopyWith<$Res> { - _$ResendFormEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [ResendFormEvent]. +extension ResendFormEventPatterns on ResendFormEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _PhoneNumberChanged value)? phoneNumberChanged,TResult Function( _PurposeChanged value)? purposeChanged,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _PurposeChanged() when purposeChanged != null: +return purposeChanged(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _PhoneNumberChanged value) phoneNumberChanged,required TResult Function( _PurposeChanged value) purposeChanged,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that);case _PurposeChanged(): +return purposeChanged(_that);case _Submitted(): +return submitted(_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( _PhoneNumberChanged value)? phoneNumberChanged,TResult? Function( _PurposeChanged value)? purposeChanged,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that);case _PurposeChanged() when purposeChanged != null: +return purposeChanged(_that);case _Submitted() when submitted != null: +return submitted(_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 phoneNumber)? phoneNumberChanged,TResult Function( String purpose)? purposeChanged,TResult Function()? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _PurposeChanged() when purposeChanged != null: +return purposeChanged(_that.purpose);case _Submitted() when submitted != null: +return submitted();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({required TResult Function( String phoneNumber) phoneNumberChanged,required TResult Function( String purpose) purposeChanged,required TResult Function() submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged(): +return phoneNumberChanged(_that.phoneNumber);case _PurposeChanged(): +return purposeChanged(_that.purpose);case _Submitted(): +return submitted();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 phoneNumber)? phoneNumberChanged,TResult? Function( String purpose)? purposeChanged,TResult? Function()? submitted,}) {final _that = this; +switch (_that) { +case _PhoneNumberChanged() when phoneNumberChanged != null: +return phoneNumberChanged(_that.phoneNumber);case _PurposeChanged() when purposeChanged != null: +return purposeChanged(_that.purpose);case _Submitted() when submitted != null: +return submitted();case _: + return null; + +} } -/// @nodoc -abstract class _$$PhoneNumberChangedImplCopyWith<$Res> { - factory _$$PhoneNumberChangedImplCopyWith( - _$PhoneNumberChangedImpl value, - $Res Function(_$PhoneNumberChangedImpl) then, - ) = __$$PhoneNumberChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String phoneNumber}); -} - -/// @nodoc -class __$$PhoneNumberChangedImplCopyWithImpl<$Res> - extends _$ResendFormEventCopyWithImpl<$Res, _$PhoneNumberChangedImpl> - implements _$$PhoneNumberChangedImplCopyWith<$Res> { - __$$PhoneNumberChangedImplCopyWithImpl( - _$PhoneNumberChangedImpl _value, - $Res Function(_$PhoneNumberChangedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? phoneNumber = null}) { - return _then( - _$PhoneNumberChangedImpl( - null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$PhoneNumberChangedImpl implements _PhoneNumberChanged { - const _$PhoneNumberChangedImpl(this.phoneNumber); - @override - final String phoneNumber; +class _PhoneNumberChanged implements ResendFormEvent { + const _PhoneNumberChanged(this.phoneNumber); + - @override - String toString() { + final String phoneNumber; + +/// Create a copy of ResendFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PhoneNumberChangedCopyWith<_PhoneNumberChanged> get copyWith => __$PhoneNumberChangedCopyWithImpl<_PhoneNumberChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PhoneNumberChanged&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber); +} + +@override +String toString() { return 'ResendFormEvent.phoneNumberChanged(phoneNumber: $phoneNumber)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PhoneNumberChangedImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber)); - } - - @override - int get hashCode => Object.hash(runtimeType, phoneNumber); - - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - __$$PhoneNumberChangedImplCopyWithImpl<_$PhoneNumberChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String purpose) purposeChanged, - required TResult Function() submitted, - }) { - return phoneNumberChanged(phoneNumber); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String purpose)? purposeChanged, - TResult? Function()? submitted, - }) { - return phoneNumberChanged?.call(phoneNumber); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String purpose)? purposeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(phoneNumber); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PurposeChanged value) purposeChanged, - required TResult Function(_Submitted value) submitted, - }) { - return phoneNumberChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PurposeChanged value)? purposeChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return phoneNumberChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PurposeChanged value)? purposeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (phoneNumberChanged != null) { - return phoneNumberChanged(this); - } - return orElse(); - } } -abstract class _PhoneNumberChanged implements ResendFormEvent { - const factory _PhoneNumberChanged(final String phoneNumber) = - _$PhoneNumberChangedImpl; - String get phoneNumber; - - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PhoneNumberChangedImplCopyWith<_$PhoneNumberChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$PurposeChangedImplCopyWith<$Res> { - factory _$$PurposeChangedImplCopyWith( - _$PurposeChangedImpl value, - $Res Function(_$PurposeChangedImpl) then, - ) = __$$PurposeChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String purpose}); +abstract mixin class _$PhoneNumberChangedCopyWith<$Res> implements $ResendFormEventCopyWith<$Res> { + factory _$PhoneNumberChangedCopyWith(_PhoneNumberChanged value, $Res Function(_PhoneNumberChanged) _then) = __$PhoneNumberChangedCopyWithImpl; +@useResult +$Res call({ + String phoneNumber +}); + + + + +} +/// @nodoc +class __$PhoneNumberChangedCopyWithImpl<$Res> + implements _$PhoneNumberChangedCopyWith<$Res> { + __$PhoneNumberChangedCopyWithImpl(this._self, this._then); + + final _PhoneNumberChanged _self; + final $Res Function(_PhoneNumberChanged) _then; + +/// Create a copy of ResendFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,}) { + return _then(_PhoneNumberChanged( +null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$PurposeChangedImplCopyWithImpl<$Res> - extends _$ResendFormEventCopyWithImpl<$Res, _$PurposeChangedImpl> - implements _$$PurposeChangedImplCopyWith<$Res> { - __$$PurposeChangedImplCopyWithImpl( - _$PurposeChangedImpl _value, - $Res Function(_$PurposeChangedImpl) _then, - ) : super(_value, _then); - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? purpose = null}) { - return _then( - _$PurposeChangedImpl( - null == purpose - ? _value.purpose - : purpose // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$PurposeChangedImpl implements _PurposeChanged { - const _$PurposeChangedImpl(this.purpose); - @override - final String purpose; +class _PurposeChanged implements ResendFormEvent { + const _PurposeChanged(this.purpose); + - @override - String toString() { + final String purpose; + +/// Create a copy of ResendFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PurposeChangedCopyWith<_PurposeChanged> get copyWith => __$PurposeChangedCopyWithImpl<_PurposeChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PurposeChanged&&(identical(other.purpose, purpose) || other.purpose == purpose)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,purpose); +} + +@override +String toString() { return 'ResendFormEvent.purposeChanged(purpose: $purpose)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PurposeChangedImpl && - (identical(other.purpose, purpose) || other.purpose == purpose)); - } - - @override - int get hashCode => Object.hash(runtimeType, purpose); - - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PurposeChangedImplCopyWith<_$PurposeChangedImpl> get copyWith => - __$$PurposeChangedImplCopyWithImpl<_$PurposeChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String purpose) purposeChanged, - required TResult Function() submitted, - }) { - return purposeChanged(purpose); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String purpose)? purposeChanged, - TResult? Function()? submitted, - }) { - return purposeChanged?.call(purpose); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String purpose)? purposeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (purposeChanged != null) { - return purposeChanged(purpose); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PurposeChanged value) purposeChanged, - required TResult Function(_Submitted value) submitted, - }) { - return purposeChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PurposeChanged value)? purposeChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return purposeChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PurposeChanged value)? purposeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (purposeChanged != null) { - return purposeChanged(this); - } - return orElse(); - } } -abstract class _PurposeChanged implements ResendFormEvent { - const factory _PurposeChanged(final String purpose) = _$PurposeChangedImpl; - String get purpose; - - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PurposeChangedImplCopyWith<_$PurposeChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$SubmittedImplCopyWith<$Res> { - factory _$$SubmittedImplCopyWith( - _$SubmittedImpl value, - $Res Function(_$SubmittedImpl) then, - ) = __$$SubmittedImplCopyWithImpl<$Res>; +abstract mixin class _$PurposeChangedCopyWith<$Res> implements $ResendFormEventCopyWith<$Res> { + factory _$PurposeChangedCopyWith(_PurposeChanged value, $Res Function(_PurposeChanged) _then) = __$PurposeChangedCopyWithImpl; +@useResult +$Res call({ + String purpose +}); + + + + +} +/// @nodoc +class __$PurposeChangedCopyWithImpl<$Res> + implements _$PurposeChangedCopyWith<$Res> { + __$PurposeChangedCopyWithImpl(this._self, this._then); + + final _PurposeChanged _self; + final $Res Function(_PurposeChanged) _then; + +/// Create a copy of ResendFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? purpose = null,}) { + return _then(_PurposeChanged( +null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$SubmittedImplCopyWithImpl<$Res> - extends _$ResendFormEventCopyWithImpl<$Res, _$SubmittedImpl> - implements _$$SubmittedImplCopyWith<$Res> { - __$$SubmittedImplCopyWithImpl( - _$SubmittedImpl _value, - $Res Function(_$SubmittedImpl) _then, - ) : super(_value, _then); - /// Create a copy of ResendFormEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$SubmittedImpl implements _Submitted { - const _$SubmittedImpl(); - @override - String toString() { +class _Submitted implements ResendFormEvent { + const _Submitted(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'ResendFormEvent.submitted()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$SubmittedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String phoneNumber) phoneNumberChanged, - required TResult Function(String purpose) purposeChanged, - required TResult Function() submitted, - }) { - return submitted(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String phoneNumber)? phoneNumberChanged, - TResult? Function(String purpose)? purposeChanged, - TResult? Function()? submitted, - }) { - return submitted?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String phoneNumber)? phoneNumberChanged, - TResult Function(String purpose)? purposeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_PhoneNumberChanged value) phoneNumberChanged, - required TResult Function(_PurposeChanged value) purposeChanged, - required TResult Function(_Submitted value) submitted, - }) { - return submitted(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult? Function(_PurposeChanged value)? purposeChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return submitted?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_PhoneNumberChanged value)? phoneNumberChanged, - TResult Function(_PurposeChanged value)? purposeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(this); - } - return orElse(); - } } -abstract class _Submitted implements ResendFormEvent { - const factory _Submitted() = _$SubmittedImpl; + } + + + /// @nodoc mixin _$ResendFormState { - String get phoneNumber => throw _privateConstructorUsedError; - String get purpose => throw _privateConstructorUsedError; - Option> get failureOrResendOption => - throw _privateConstructorUsedError; - bool get isSubmitting => throw _privateConstructorUsedError; - bool get showErrorMessages => throw _privateConstructorUsedError; - /// Create a copy of ResendFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ResendFormStateCopyWith get copyWith => - throw _privateConstructorUsedError; + String get phoneNumber; String get purpose; Option> get failureOrResendOption; bool get isSubmitting; bool get showErrorMessages; +/// Create a copy of ResendFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ResendFormStateCopyWith get copyWith => _$ResendFormStateCopyWithImpl(this as ResendFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as ResendFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ResendFormState&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)&&(identical(other.purpose, _this.purpose) || other.purpose == _this.purpose)&&(identical(other.failureOrResendOption, _this.failureOrResendOption) || other.failureOrResendOption == _this.failureOrResendOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.showErrorMessages, _this.showErrorMessages) || other.showErrorMessages == _this.showErrorMessages)); +} + + +@override +int get hashCode { + final _this = this as ResendFormState; + return Object.hash(runtimeType,_this.phoneNumber,_this.purpose,_this.failureOrResendOption,_this.isSubmitting,_this.showErrorMessages); +} + +@override +String toString() { + final _this = this as ResendFormState; + return 'ResendFormState(phoneNumber: ${_this.phoneNumber}, purpose: ${_this.purpose}, failureOrResendOption: ${_this.failureOrResendOption}, isSubmitting: ${_this.isSubmitting}, showErrorMessages: ${_this.showErrorMessages})'; +} + + } /// @nodoc -abstract class $ResendFormStateCopyWith<$Res> { - factory $ResendFormStateCopyWith( - ResendFormState value, - $Res Function(ResendFormState) then, - ) = _$ResendFormStateCopyWithImpl<$Res, ResendFormState>; - @useResult - $Res call({ - String phoneNumber, - String purpose, - Option> failureOrResendOption, - bool isSubmitting, - bool showErrorMessages, - }); -} +abstract mixin class $ResendFormStateCopyWith<$Res> { + factory $ResendFormStateCopyWith(ResendFormState value, $Res Function(ResendFormState) _then) = _$ResendFormStateCopyWithImpl; +@useResult +$Res call({ + String phoneNumber, String purpose, Option> failureOrResendOption, bool isSubmitting, bool showErrorMessages +}); + + + +} /// @nodoc -class _$ResendFormStateCopyWithImpl<$Res, $Val extends ResendFormState> +class _$ResendFormStateCopyWithImpl<$Res> implements $ResendFormStateCopyWith<$Res> { - _$ResendFormStateCopyWithImpl(this._value, this._then); + _$ResendFormStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final ResendFormState _self; + final $Res Function(ResendFormState) _then; - /// Create a copy of ResendFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? purpose = null, - Object? failureOrResendOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _value.copyWith( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - purpose: null == purpose - ? _value.purpose - : purpose // ignore: cast_nullable_to_non_nullable - as String, - failureOrResendOption: null == failureOrResendOption - ? _value.failureOrResendOption - : failureOrResendOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } +/// Create a copy of ResendFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? phoneNumber = null,Object? purpose = null,Object? failureOrResendOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(ResendFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,purpose: null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as String,failureOrResendOption: null == failureOrResendOption ? _self.failureOrResendOption : failureOrResendOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$ResendFormStateImplCopyWith<$Res> - implements $ResendFormStateCopyWith<$Res> { - factory _$$ResendFormStateImplCopyWith( - _$ResendFormStateImpl value, - $Res Function(_$ResendFormStateImpl) then, - ) = __$$ResendFormStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String phoneNumber, - String purpose, - Option> failureOrResendOption, - bool isSubmitting, - bool showErrorMessages, - }); } -/// @nodoc -class __$$ResendFormStateImplCopyWithImpl<$Res> - extends _$ResendFormStateCopyWithImpl<$Res, _$ResendFormStateImpl> - implements _$$ResendFormStateImplCopyWith<$Res> { - __$$ResendFormStateImplCopyWithImpl( - _$ResendFormStateImpl _value, - $Res Function(_$ResendFormStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of ResendFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? phoneNumber = null, - Object? purpose = null, - Object? failureOrResendOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _$ResendFormStateImpl( - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - purpose: null == purpose - ? _value.purpose - : purpose // ignore: cast_nullable_to_non_nullable - as String, - failureOrResendOption: null == failureOrResendOption - ? _value.failureOrResendOption - : failureOrResendOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [ResendFormState]. +extension ResendFormStatePatterns on ResendFormState { +/// 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( _ResendFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ResendFormState() 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( _ResendFormState value) $default,){ +final _that = this; +switch (_that) { +case _ResendFormState(): +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( _ResendFormState value)? $default,){ +final _that = this; +switch (_that) { +case _ResendFormState() 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 phoneNumber, String purpose, Option> failureOrResendOption, bool isSubmitting, bool showErrorMessages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ResendFormState() when $default != null: +return $default(_that.phoneNumber,_that.purpose,_that.failureOrResendOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, String purpose, Option> failureOrResendOption, bool isSubmitting, bool showErrorMessages) $default,) {final _that = this; +switch (_that) { +case _ResendFormState(): +return $default(_that.phoneNumber,_that.purpose,_that.failureOrResendOption,_that.isSubmitting,_that.showErrorMessages);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 phoneNumber, String purpose, Option> failureOrResendOption, bool isSubmitting, bool showErrorMessages)? $default,) {final _that = this; +switch (_that) { +case _ResendFormState() when $default != null: +return $default(_that.phoneNumber,_that.purpose,_that.failureOrResendOption,_that.isSubmitting,_that.showErrorMessages);case _: + return null; + +} +} + } /// @nodoc -class _$ResendFormStateImpl implements _ResendFormState { - const _$ResendFormStateImpl({ - required this.phoneNumber, - required this.purpose, - required this.failureOrResendOption, - this.isSubmitting = false, - this.showErrorMessages = false, - }); - @override - final String phoneNumber; - @override - final String purpose; - @override - final Option> failureOrResendOption; - @override - @JsonKey() - final bool isSubmitting; - @override - @JsonKey() - final bool showErrorMessages; +class _ResendFormState implements ResendFormState { + const _ResendFormState({required this.phoneNumber, required this.purpose, required this.failureOrResendOption, this.isSubmitting = false, this.showErrorMessages = false}); + - @override - String toString() { +@override final String phoneNumber; +@override final String purpose; +@override final Option> failureOrResendOption; +@override@JsonKey() final bool isSubmitting; +@override@JsonKey() final bool showErrorMessages; + +/// Create a copy of ResendFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ResendFormStateCopyWith<_ResendFormState> get copyWith => __$ResendFormStateCopyWithImpl<_ResendFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResendFormState&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.purpose, purpose) || other.purpose == purpose)&&(identical(other.failureOrResendOption, failureOrResendOption) || other.failureOrResendOption == failureOrResendOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.showErrorMessages, showErrorMessages) || other.showErrorMessages == showErrorMessages)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber,purpose,failureOrResendOption,isSubmitting,showErrorMessages); +} + +@override +String toString() { return 'ResendFormState(phoneNumber: $phoneNumber, purpose: $purpose, failureOrResendOption: $failureOrResendOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ResendFormStateImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber) && - (identical(other.purpose, purpose) || other.purpose == purpose) && - (identical(other.failureOrResendOption, failureOrResendOption) || - other.failureOrResendOption == failureOrResendOption) && - (identical(other.isSubmitting, isSubmitting) || - other.isSubmitting == isSubmitting) && - (identical(other.showErrorMessages, showErrorMessages) || - other.showErrorMessages == showErrorMessages)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - phoneNumber, - purpose, - failureOrResendOption, - isSubmitting, - showErrorMessages, - ); - - /// Create a copy of ResendFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ResendFormStateImplCopyWith<_$ResendFormStateImpl> get copyWith => - __$$ResendFormStateImplCopyWithImpl<_$ResendFormStateImpl>( - this, - _$identity, - ); } -abstract class _ResendFormState implements ResendFormState { - const factory _ResendFormState({ - required final String phoneNumber, - required final String purpose, - required final Option> failureOrResendOption, - final bool isSubmitting, - final bool showErrorMessages, - }) = _$ResendFormStateImpl; - @override - String get phoneNumber; - @override - String get purpose; - @override - Option> get failureOrResendOption; - @override - bool get isSubmitting; - @override - bool get showErrorMessages; - - /// Create a copy of ResendFormState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ResendFormStateImplCopyWith<_$ResendFormStateImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$ResendFormStateCopyWith<$Res> implements $ResendFormStateCopyWith<$Res> { + factory _$ResendFormStateCopyWith(_ResendFormState value, $Res Function(_ResendFormState) _then) = __$ResendFormStateCopyWithImpl; +@override @useResult +$Res call({ + String phoneNumber, String purpose, Option> failureOrResendOption, bool isSubmitting, bool showErrorMessages +}); + + + + +} +/// @nodoc +class __$ResendFormStateCopyWithImpl<$Res> + implements _$ResendFormStateCopyWith<$Res> { + __$ResendFormStateCopyWithImpl(this._self, this._then); + + final _ResendFormState _self; + final $Res Function(_ResendFormState) _then; + +/// Create a copy of ResendFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? phoneNumber = null,Object? purpose = null,Object? failureOrResendOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(_ResendFormState( +phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,purpose: null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as String,failureOrResendOption: null == failureOrResendOption ? _self.failureOrResendOption : failureOrResendOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/auth/resend_form/resend_form_event.dart b/lib/application/auth/resend_form/resend_form_event.dart index 0d6267b..7afc261 100644 --- a/lib/application/auth/resend_form/resend_form_event.dart +++ b/lib/application/auth/resend_form/resend_form_event.dart @@ -1,7 +1,7 @@ part of 'resend_form_bloc.dart'; @freezed -class ResendFormEvent with _$ResendFormEvent { +abstract class ResendFormEvent with _$ResendFormEvent { const factory ResendFormEvent.phoneNumberChanged(String phoneNumber) = _PhoneNumberChanged; const factory ResendFormEvent.purposeChanged(String purpose) = diff --git a/lib/application/auth/resend_form/resend_form_state.dart b/lib/application/auth/resend_form/resend_form_state.dart index 92fdfd5..ff80d46 100644 --- a/lib/application/auth/resend_form/resend_form_state.dart +++ b/lib/application/auth/resend_form/resend_form_state.dart @@ -1,7 +1,7 @@ part of 'resend_form_bloc.dart'; @freezed -class ResendFormState with _$ResendFormState { +abstract class ResendFormState with _$ResendFormState { const factory ResendFormState({ required String phoneNumber, required String purpose, diff --git a/lib/application/auth/set_password/set_password_form_bloc.freezed.dart b/lib/application/auth/set_password/set_password_form_bloc.freezed.dart index c83d9c6..002203f 100644 --- a/lib/application/auth/set_password/set_password_form_bloc.freezed.dart +++ b/lib/application/auth/set_password/set_password_form_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'set_password_form_bloc.dart'; @@ -9,972 +9,700 @@ part of 'set_password_form_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$SetPasswordFormEvent { - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String password) passwordChanged, - required TResult Function(String confirmPassword) confirmPasswordChanged, - required TResult Function() submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function(String confirmPassword)? confirmPasswordChanged, - TResult? Function()? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String password)? passwordChanged, - TResult Function(String confirmPassword)? confirmPasswordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_ConfirmPasswordChanged value) - confirmPasswordChanged, - required TResult Function(_Submitted value) submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult? Function(_Submitted value)? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SetPasswordFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'SetPasswordFormEvent()'; +} + + } /// @nodoc -abstract class $SetPasswordFormEventCopyWith<$Res> { - factory $SetPasswordFormEventCopyWith( - SetPasswordFormEvent value, - $Res Function(SetPasswordFormEvent) then, - ) = _$SetPasswordFormEventCopyWithImpl<$Res, SetPasswordFormEvent>; +class $SetPasswordFormEventCopyWith<$Res> { +$SetPasswordFormEventCopyWith(SetPasswordFormEvent _, $Res Function(SetPasswordFormEvent) __); } -/// @nodoc -class _$SetPasswordFormEventCopyWithImpl< - $Res, - $Val extends SetPasswordFormEvent -> - implements $SetPasswordFormEventCopyWith<$Res> { - _$SetPasswordFormEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [SetPasswordFormEvent]. +extension SetPasswordFormEventPatterns on SetPasswordFormEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _RegistrationTokenChanged value)? registrationTokenChanged,TResult Function( _PasswordChanged value)? passwordChanged,TResult Function( _ConfirmPasswordChanged value)? confirmPasswordChanged,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that);case _ConfirmPasswordChanged() when confirmPasswordChanged != null: +return confirmPasswordChanged(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _RegistrationTokenChanged value) registrationTokenChanged,required TResult Function( _PasswordChanged value) passwordChanged,required TResult Function( _ConfirmPasswordChanged value) confirmPasswordChanged,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _RegistrationTokenChanged(): +return registrationTokenChanged(_that);case _PasswordChanged(): +return passwordChanged(_that);case _ConfirmPasswordChanged(): +return confirmPasswordChanged(_that);case _Submitted(): +return submitted(_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( _RegistrationTokenChanged value)? registrationTokenChanged,TResult? Function( _PasswordChanged value)? passwordChanged,TResult? Function( _ConfirmPasswordChanged value)? confirmPasswordChanged,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that);case _ConfirmPasswordChanged() when confirmPasswordChanged != null: +return confirmPasswordChanged(_that);case _Submitted() when submitted != null: +return submitted(_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 registrationToken)? registrationTokenChanged,TResult Function( String password)? passwordChanged,TResult Function( String confirmPassword)? confirmPasswordChanged,TResult Function()? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that.registrationToken);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that.password);case _ConfirmPasswordChanged() when confirmPasswordChanged != null: +return confirmPasswordChanged(_that.confirmPassword);case _Submitted() when submitted != null: +return submitted();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({required TResult Function( String registrationToken) registrationTokenChanged,required TResult Function( String password) passwordChanged,required TResult Function( String confirmPassword) confirmPasswordChanged,required TResult Function() submitted,}) {final _that = this; +switch (_that) { +case _RegistrationTokenChanged(): +return registrationTokenChanged(_that.registrationToken);case _PasswordChanged(): +return passwordChanged(_that.password);case _ConfirmPasswordChanged(): +return confirmPasswordChanged(_that.confirmPassword);case _Submitted(): +return submitted();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 registrationToken)? registrationTokenChanged,TResult? Function( String password)? passwordChanged,TResult? Function( String confirmPassword)? confirmPasswordChanged,TResult? Function()? submitted,}) {final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that.registrationToken);case _PasswordChanged() when passwordChanged != null: +return passwordChanged(_that.password);case _ConfirmPasswordChanged() when confirmPasswordChanged != null: +return confirmPasswordChanged(_that.confirmPassword);case _Submitted() when submitted != null: +return submitted();case _: + return null; + +} } -/// @nodoc -abstract class _$$RegistrationTokenChangedImplCopyWith<$Res> { - factory _$$RegistrationTokenChangedImplCopyWith( - _$RegistrationTokenChangedImpl value, - $Res Function(_$RegistrationTokenChangedImpl) then, - ) = __$$RegistrationTokenChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String registrationToken}); -} - -/// @nodoc -class __$$RegistrationTokenChangedImplCopyWithImpl<$Res> - extends - _$SetPasswordFormEventCopyWithImpl<$Res, _$RegistrationTokenChangedImpl> - implements _$$RegistrationTokenChangedImplCopyWith<$Res> { - __$$RegistrationTokenChangedImplCopyWithImpl( - _$RegistrationTokenChangedImpl _value, - $Res Function(_$RegistrationTokenChangedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? registrationToken = null}) { - return _then( - _$RegistrationTokenChangedImpl( - null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$RegistrationTokenChangedImpl implements _RegistrationTokenChanged { - const _$RegistrationTokenChangedImpl(this.registrationToken); - @override - final String registrationToken; +class _RegistrationTokenChanged implements SetPasswordFormEvent { + const _RegistrationTokenChanged(this.registrationToken); + - @override - String toString() { + final String registrationToken; + +/// Create a copy of SetPasswordFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RegistrationTokenChangedCopyWith<_RegistrationTokenChanged> get copyWith => __$RegistrationTokenChangedCopyWithImpl<_RegistrationTokenChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _RegistrationTokenChanged&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,registrationToken); +} + +@override +String toString() { return 'SetPasswordFormEvent.registrationTokenChanged(registrationToken: $registrationToken)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RegistrationTokenChangedImpl && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken)); - } - - @override - int get hashCode => Object.hash(runtimeType, registrationToken); - - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl> - get copyWith => - __$$RegistrationTokenChangedImplCopyWithImpl< - _$RegistrationTokenChangedImpl - >(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String password) passwordChanged, - required TResult Function(String confirmPassword) confirmPasswordChanged, - required TResult Function() submitted, - }) { - return registrationTokenChanged(registrationToken); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function(String confirmPassword)? confirmPasswordChanged, - TResult? Function()? submitted, - }) { - return registrationTokenChanged?.call(registrationToken); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String password)? passwordChanged, - TResult Function(String confirmPassword)? confirmPasswordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (registrationTokenChanged != null) { - return registrationTokenChanged(registrationToken); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_ConfirmPasswordChanged value) - confirmPasswordChanged, - required TResult Function(_Submitted value) submitted, - }) { - return registrationTokenChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return registrationTokenChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (registrationTokenChanged != null) { - return registrationTokenChanged(this); - } - return orElse(); - } } -abstract class _RegistrationTokenChanged implements SetPasswordFormEvent { - const factory _RegistrationTokenChanged(final String registrationToken) = - _$RegistrationTokenChangedImpl; - String get registrationToken; - - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl> - get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$PasswordChangedImplCopyWith<$Res> { - factory _$$PasswordChangedImplCopyWith( - _$PasswordChangedImpl value, - $Res Function(_$PasswordChangedImpl) then, - ) = __$$PasswordChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String password}); +abstract mixin class _$RegistrationTokenChangedCopyWith<$Res> implements $SetPasswordFormEventCopyWith<$Res> { + factory _$RegistrationTokenChangedCopyWith(_RegistrationTokenChanged value, $Res Function(_RegistrationTokenChanged) _then) = __$RegistrationTokenChangedCopyWithImpl; +@useResult +$Res call({ + String registrationToken +}); + + + + +} +/// @nodoc +class __$RegistrationTokenChangedCopyWithImpl<$Res> + implements _$RegistrationTokenChangedCopyWith<$Res> { + __$RegistrationTokenChangedCopyWithImpl(this._self, this._then); + + final _RegistrationTokenChanged _self; + final $Res Function(_RegistrationTokenChanged) _then; + +/// Create a copy of SetPasswordFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? registrationToken = null,}) { + return _then(_RegistrationTokenChanged( +null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$PasswordChangedImplCopyWithImpl<$Res> - extends _$SetPasswordFormEventCopyWithImpl<$Res, _$PasswordChangedImpl> - implements _$$PasswordChangedImplCopyWith<$Res> { - __$$PasswordChangedImplCopyWithImpl( - _$PasswordChangedImpl _value, - $Res Function(_$PasswordChangedImpl) _then, - ) : super(_value, _then); - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? password = null}) { - return _then( - _$PasswordChangedImpl( - null == password - ? _value.password - : password // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$PasswordChangedImpl implements _PasswordChanged { - const _$PasswordChangedImpl(this.password); - @override - final String password; +class _PasswordChanged implements SetPasswordFormEvent { + const _PasswordChanged(this.password); + - @override - String toString() { + final String password; + +/// Create a copy of SetPasswordFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PasswordChangedCopyWith<_PasswordChanged> get copyWith => __$PasswordChangedCopyWithImpl<_PasswordChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PasswordChanged&&(identical(other.password, password) || other.password == password)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,password); +} + +@override +String toString() { return 'SetPasswordFormEvent.passwordChanged(password: $password)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PasswordChangedImpl && - (identical(other.password, password) || - other.password == password)); - } - - @override - int get hashCode => Object.hash(runtimeType, password); - - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith => - __$$PasswordChangedImplCopyWithImpl<_$PasswordChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String password) passwordChanged, - required TResult Function(String confirmPassword) confirmPasswordChanged, - required TResult Function() submitted, - }) { - return passwordChanged(password); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function(String confirmPassword)? confirmPasswordChanged, - TResult? Function()? submitted, - }) { - return passwordChanged?.call(password); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String password)? passwordChanged, - TResult Function(String confirmPassword)? confirmPasswordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (passwordChanged != null) { - return passwordChanged(password); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_ConfirmPasswordChanged value) - confirmPasswordChanged, - required TResult Function(_Submitted value) submitted, - }) { - return passwordChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return passwordChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (passwordChanged != null) { - return passwordChanged(this); - } - return orElse(); - } } -abstract class _PasswordChanged implements SetPasswordFormEvent { - const factory _PasswordChanged(final String password) = _$PasswordChangedImpl; - String get password; - - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$ConfirmPasswordChangedImplCopyWith<$Res> { - factory _$$ConfirmPasswordChangedImplCopyWith( - _$ConfirmPasswordChangedImpl value, - $Res Function(_$ConfirmPasswordChangedImpl) then, - ) = __$$ConfirmPasswordChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String confirmPassword}); +abstract mixin class _$PasswordChangedCopyWith<$Res> implements $SetPasswordFormEventCopyWith<$Res> { + factory _$PasswordChangedCopyWith(_PasswordChanged value, $Res Function(_PasswordChanged) _then) = __$PasswordChangedCopyWithImpl; +@useResult +$Res call({ + String password +}); + + + + +} +/// @nodoc +class __$PasswordChangedCopyWithImpl<$Res> + implements _$PasswordChangedCopyWith<$Res> { + __$PasswordChangedCopyWithImpl(this._self, this._then); + + final _PasswordChanged _self; + final $Res Function(_PasswordChanged) _then; + +/// Create a copy of SetPasswordFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? password = null,}) { + return _then(_PasswordChanged( +null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$ConfirmPasswordChangedImplCopyWithImpl<$Res> - extends - _$SetPasswordFormEventCopyWithImpl<$Res, _$ConfirmPasswordChangedImpl> - implements _$$ConfirmPasswordChangedImplCopyWith<$Res> { - __$$ConfirmPasswordChangedImplCopyWithImpl( - _$ConfirmPasswordChangedImpl _value, - $Res Function(_$ConfirmPasswordChangedImpl) _then, - ) : super(_value, _then); - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? confirmPassword = null}) { - return _then( - _$ConfirmPasswordChangedImpl( - null == confirmPassword - ? _value.confirmPassword - : confirmPassword // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$ConfirmPasswordChangedImpl implements _ConfirmPasswordChanged { - const _$ConfirmPasswordChangedImpl(this.confirmPassword); - @override - final String confirmPassword; +class _ConfirmPasswordChanged implements SetPasswordFormEvent { + const _ConfirmPasswordChanged(this.confirmPassword); + - @override - String toString() { + final String confirmPassword; + +/// Create a copy of SetPasswordFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ConfirmPasswordChangedCopyWith<_ConfirmPasswordChanged> get copyWith => __$ConfirmPasswordChangedCopyWithImpl<_ConfirmPasswordChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ConfirmPasswordChanged&&(identical(other.confirmPassword, confirmPassword) || other.confirmPassword == confirmPassword)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,confirmPassword); +} + +@override +String toString() { return 'SetPasswordFormEvent.confirmPasswordChanged(confirmPassword: $confirmPassword)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ConfirmPasswordChangedImpl && - (identical(other.confirmPassword, confirmPassword) || - other.confirmPassword == confirmPassword)); - } - - @override - int get hashCode => Object.hash(runtimeType, confirmPassword); - - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ConfirmPasswordChangedImplCopyWith<_$ConfirmPasswordChangedImpl> - get copyWith => - __$$ConfirmPasswordChangedImplCopyWithImpl<_$ConfirmPasswordChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String password) passwordChanged, - required TResult Function(String confirmPassword) confirmPasswordChanged, - required TResult Function() submitted, - }) { - return confirmPasswordChanged(confirmPassword); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function(String confirmPassword)? confirmPasswordChanged, - TResult? Function()? submitted, - }) { - return confirmPasswordChanged?.call(confirmPassword); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String password)? passwordChanged, - TResult Function(String confirmPassword)? confirmPasswordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (confirmPasswordChanged != null) { - return confirmPasswordChanged(confirmPassword); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_ConfirmPasswordChanged value) - confirmPasswordChanged, - required TResult Function(_Submitted value) submitted, - }) { - return confirmPasswordChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return confirmPasswordChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (confirmPasswordChanged != null) { - return confirmPasswordChanged(this); - } - return orElse(); - } } -abstract class _ConfirmPasswordChanged implements SetPasswordFormEvent { - const factory _ConfirmPasswordChanged(final String confirmPassword) = - _$ConfirmPasswordChangedImpl; - String get confirmPassword; - - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ConfirmPasswordChangedImplCopyWith<_$ConfirmPasswordChangedImpl> - get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$SubmittedImplCopyWith<$Res> { - factory _$$SubmittedImplCopyWith( - _$SubmittedImpl value, - $Res Function(_$SubmittedImpl) then, - ) = __$$SubmittedImplCopyWithImpl<$Res>; +abstract mixin class _$ConfirmPasswordChangedCopyWith<$Res> implements $SetPasswordFormEventCopyWith<$Res> { + factory _$ConfirmPasswordChangedCopyWith(_ConfirmPasswordChanged value, $Res Function(_ConfirmPasswordChanged) _then) = __$ConfirmPasswordChangedCopyWithImpl; +@useResult +$Res call({ + String confirmPassword +}); + + + + +} +/// @nodoc +class __$ConfirmPasswordChangedCopyWithImpl<$Res> + implements _$ConfirmPasswordChangedCopyWith<$Res> { + __$ConfirmPasswordChangedCopyWithImpl(this._self, this._then); + + final _ConfirmPasswordChanged _self; + final $Res Function(_ConfirmPasswordChanged) _then; + +/// Create a copy of SetPasswordFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? confirmPassword = null,}) { + return _then(_ConfirmPasswordChanged( +null == confirmPassword ? _self.confirmPassword : confirmPassword // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$SubmittedImplCopyWithImpl<$Res> - extends _$SetPasswordFormEventCopyWithImpl<$Res, _$SubmittedImpl> - implements _$$SubmittedImplCopyWith<$Res> { - __$$SubmittedImplCopyWithImpl( - _$SubmittedImpl _value, - $Res Function(_$SubmittedImpl) _then, - ) : super(_value, _then); - /// Create a copy of SetPasswordFormEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$SubmittedImpl implements _Submitted { - const _$SubmittedImpl(); - @override - String toString() { +class _Submitted implements SetPasswordFormEvent { + const _Submitted(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'SetPasswordFormEvent.submitted()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$SubmittedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String password) passwordChanged, - required TResult Function(String confirmPassword) confirmPasswordChanged, - required TResult Function() submitted, - }) { - return submitted(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String password)? passwordChanged, - TResult? Function(String confirmPassword)? confirmPasswordChanged, - TResult? Function()? submitted, - }) { - return submitted?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String password)? passwordChanged, - TResult Function(String confirmPassword)? confirmPasswordChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_PasswordChanged value) passwordChanged, - required TResult Function(_ConfirmPasswordChanged value) - confirmPasswordChanged, - required TResult Function(_Submitted value) submitted, - }) { - return submitted(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_PasswordChanged value)? passwordChanged, - TResult? Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return submitted?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_PasswordChanged value)? passwordChanged, - TResult Function(_ConfirmPasswordChanged value)? confirmPasswordChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(this); - } - return orElse(); - } } -abstract class _Submitted implements SetPasswordFormEvent { - const factory _Submitted() = _$SubmittedImpl; + } + + + /// @nodoc mixin _$SetPasswordFormState { - String get registrationToken => throw _privateConstructorUsedError; - String get password => throw _privateConstructorUsedError; - String get confirmPassword => throw _privateConstructorUsedError; - Option> get failureOrSetPasswordOption => - throw _privateConstructorUsedError; - bool get isSubmitting => throw _privateConstructorUsedError; - bool get showErrorMessages => throw _privateConstructorUsedError; - /// Create a copy of SetPasswordFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $SetPasswordFormStateCopyWith get copyWith => - throw _privateConstructorUsedError; + String get registrationToken; String get password; String get confirmPassword; Option> get failureOrSetPasswordOption; bool get isSubmitting; bool get showErrorMessages; +/// Create a copy of SetPasswordFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SetPasswordFormStateCopyWith get copyWith => _$SetPasswordFormStateCopyWithImpl(this as SetPasswordFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as SetPasswordFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is SetPasswordFormState&&(identical(other.registrationToken, _this.registrationToken) || other.registrationToken == _this.registrationToken)&&(identical(other.password, _this.password) || other.password == _this.password)&&(identical(other.confirmPassword, _this.confirmPassword) || other.confirmPassword == _this.confirmPassword)&&(identical(other.failureOrSetPasswordOption, _this.failureOrSetPasswordOption) || other.failureOrSetPasswordOption == _this.failureOrSetPasswordOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.showErrorMessages, _this.showErrorMessages) || other.showErrorMessages == _this.showErrorMessages)); +} + + +@override +int get hashCode { + final _this = this as SetPasswordFormState; + return Object.hash(runtimeType,_this.registrationToken,_this.password,_this.confirmPassword,_this.failureOrSetPasswordOption,_this.isSubmitting,_this.showErrorMessages); +} + +@override +String toString() { + final _this = this as SetPasswordFormState; + return 'SetPasswordFormState(registrationToken: ${_this.registrationToken}, password: ${_this.password}, confirmPassword: ${_this.confirmPassword}, failureOrSetPasswordOption: ${_this.failureOrSetPasswordOption}, isSubmitting: ${_this.isSubmitting}, showErrorMessages: ${_this.showErrorMessages})'; +} + + } /// @nodoc -abstract class $SetPasswordFormStateCopyWith<$Res> { - factory $SetPasswordFormStateCopyWith( - SetPasswordFormState value, - $Res Function(SetPasswordFormState) then, - ) = _$SetPasswordFormStateCopyWithImpl<$Res, SetPasswordFormState>; - @useResult - $Res call({ - String registrationToken, - String password, - String confirmPassword, - Option> failureOrSetPasswordOption, - bool isSubmitting, - bool showErrorMessages, - }); -} +abstract mixin class $SetPasswordFormStateCopyWith<$Res> { + factory $SetPasswordFormStateCopyWith(SetPasswordFormState value, $Res Function(SetPasswordFormState) _then) = _$SetPasswordFormStateCopyWithImpl; +@useResult +$Res call({ + String registrationToken, String password, String confirmPassword, Option> failureOrSetPasswordOption, bool isSubmitting, bool showErrorMessages +}); + + + +} /// @nodoc -class _$SetPasswordFormStateCopyWithImpl< - $Res, - $Val extends SetPasswordFormState -> +class _$SetPasswordFormStateCopyWithImpl<$Res> implements $SetPasswordFormStateCopyWith<$Res> { - _$SetPasswordFormStateCopyWithImpl(this._value, this._then); + _$SetPasswordFormStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final SetPasswordFormState _self; + final $Res Function(SetPasswordFormState) _then; - /// Create a copy of SetPasswordFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? registrationToken = null, - Object? password = null, - Object? confirmPassword = null, - Object? failureOrSetPasswordOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _value.copyWith( - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - password: null == password - ? _value.password - : password // ignore: cast_nullable_to_non_nullable - as String, - confirmPassword: null == confirmPassword - ? _value.confirmPassword - : confirmPassword // ignore: cast_nullable_to_non_nullable - as String, - failureOrSetPasswordOption: null == failureOrSetPasswordOption - ? _value.failureOrSetPasswordOption - : failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } +/// Create a copy of SetPasswordFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? registrationToken = null,Object? password = null,Object? confirmPassword = null,Object? failureOrSetPasswordOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(SetPasswordFormState( +registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable +as String,confirmPassword: null == confirmPassword ? _self.confirmPassword : confirmPassword // ignore: cast_nullable_to_non_nullable +as String,failureOrSetPasswordOption: null == failureOrSetPasswordOption ? _self.failureOrSetPasswordOption : failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$SetPasswordFormStateImplCopyWith<$Res> - implements $SetPasswordFormStateCopyWith<$Res> { - factory _$$SetPasswordFormStateImplCopyWith( - _$SetPasswordFormStateImpl value, - $Res Function(_$SetPasswordFormStateImpl) then, - ) = __$$SetPasswordFormStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String registrationToken, - String password, - String confirmPassword, - Option> failureOrSetPasswordOption, - bool isSubmitting, - bool showErrorMessages, - }); } -/// @nodoc -class __$$SetPasswordFormStateImplCopyWithImpl<$Res> - extends _$SetPasswordFormStateCopyWithImpl<$Res, _$SetPasswordFormStateImpl> - implements _$$SetPasswordFormStateImplCopyWith<$Res> { - __$$SetPasswordFormStateImplCopyWithImpl( - _$SetPasswordFormStateImpl _value, - $Res Function(_$SetPasswordFormStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of SetPasswordFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? registrationToken = null, - Object? password = null, - Object? confirmPassword = null, - Object? failureOrSetPasswordOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _$SetPasswordFormStateImpl( - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - password: null == password - ? _value.password - : password // ignore: cast_nullable_to_non_nullable - as String, - confirmPassword: null == confirmPassword - ? _value.confirmPassword - : confirmPassword // ignore: cast_nullable_to_non_nullable - as String, - failureOrSetPasswordOption: null == failureOrSetPasswordOption - ? _value.failureOrSetPasswordOption - : failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [SetPasswordFormState]. +extension SetPasswordFormStatePatterns on SetPasswordFormState { +/// 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( _SetPasswordFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _SetPasswordFormState() 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( _SetPasswordFormState value) $default,){ +final _that = this; +switch (_that) { +case _SetPasswordFormState(): +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( _SetPasswordFormState value)? $default,){ +final _that = this; +switch (_that) { +case _SetPasswordFormState() 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 registrationToken, String password, String confirmPassword, Option> failureOrSetPasswordOption, bool isSubmitting, bool showErrorMessages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _SetPasswordFormState() when $default != null: +return $default(_that.registrationToken,_that.password,_that.confirmPassword,_that.failureOrSetPasswordOption,_that.isSubmitting,_that.showErrorMessages);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 registrationToken, String password, String confirmPassword, Option> failureOrSetPasswordOption, bool isSubmitting, bool showErrorMessages) $default,) {final _that = this; +switch (_that) { +case _SetPasswordFormState(): +return $default(_that.registrationToken,_that.password,_that.confirmPassword,_that.failureOrSetPasswordOption,_that.isSubmitting,_that.showErrorMessages);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 registrationToken, String password, String confirmPassword, Option> failureOrSetPasswordOption, bool isSubmitting, bool showErrorMessages)? $default,) {final _that = this; +switch (_that) { +case _SetPasswordFormState() when $default != null: +return $default(_that.registrationToken,_that.password,_that.confirmPassword,_that.failureOrSetPasswordOption,_that.isSubmitting,_that.showErrorMessages);case _: + return null; + +} +} + } /// @nodoc -class _$SetPasswordFormStateImpl implements _SetPasswordFormState { - const _$SetPasswordFormStateImpl({ - required this.registrationToken, - required this.password, - required this.confirmPassword, - required this.failureOrSetPasswordOption, - this.isSubmitting = false, - this.showErrorMessages = false, - }); - @override - final String registrationToken; - @override - final String password; - @override - final String confirmPassword; - @override - final Option> failureOrSetPasswordOption; - @override - @JsonKey() - final bool isSubmitting; - @override - @JsonKey() - final bool showErrorMessages; +class _SetPasswordFormState implements SetPasswordFormState { + const _SetPasswordFormState({required this.registrationToken, required this.password, required this.confirmPassword, required this.failureOrSetPasswordOption, this.isSubmitting = false, this.showErrorMessages = false}); + - @override - String toString() { +@override final String registrationToken; +@override final String password; +@override final String confirmPassword; +@override final Option> failureOrSetPasswordOption; +@override@JsonKey() final bool isSubmitting; +@override@JsonKey() final bool showErrorMessages; + +/// Create a copy of SetPasswordFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SetPasswordFormStateCopyWith<_SetPasswordFormState> get copyWith => __$SetPasswordFormStateCopyWithImpl<_SetPasswordFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SetPasswordFormState&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)&&(identical(other.password, password) || other.password == password)&&(identical(other.confirmPassword, confirmPassword) || other.confirmPassword == confirmPassword)&&(identical(other.failureOrSetPasswordOption, failureOrSetPasswordOption) || other.failureOrSetPasswordOption == failureOrSetPasswordOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.showErrorMessages, showErrorMessages) || other.showErrorMessages == showErrorMessages)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,registrationToken,password,confirmPassword,failureOrSetPasswordOption,isSubmitting,showErrorMessages); +} + +@override +String toString() { return 'SetPasswordFormState(registrationToken: $registrationToken, password: $password, confirmPassword: $confirmPassword, failureOrSetPasswordOption: $failureOrSetPasswordOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$SetPasswordFormStateImpl && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken) && - (identical(other.password, password) || - other.password == password) && - (identical(other.confirmPassword, confirmPassword) || - other.confirmPassword == confirmPassword) && - (identical( - other.failureOrSetPasswordOption, - failureOrSetPasswordOption, - ) || - other.failureOrSetPasswordOption == - failureOrSetPasswordOption) && - (identical(other.isSubmitting, isSubmitting) || - other.isSubmitting == isSubmitting) && - (identical(other.showErrorMessages, showErrorMessages) || - other.showErrorMessages == showErrorMessages)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - registrationToken, - password, - confirmPassword, - failureOrSetPasswordOption, - isSubmitting, - showErrorMessages, - ); - - /// Create a copy of SetPasswordFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$SetPasswordFormStateImplCopyWith<_$SetPasswordFormStateImpl> - get copyWith => - __$$SetPasswordFormStateImplCopyWithImpl<_$SetPasswordFormStateImpl>( - this, - _$identity, - ); } -abstract class _SetPasswordFormState implements SetPasswordFormState { - const factory _SetPasswordFormState({ - required final String registrationToken, - required final String password, - required final String confirmPassword, - required final Option> - failureOrSetPasswordOption, - final bool isSubmitting, - final bool showErrorMessages, - }) = _$SetPasswordFormStateImpl; - @override - String get registrationToken; - @override - String get password; - @override - String get confirmPassword; - @override - Option> get failureOrSetPasswordOption; - @override - bool get isSubmitting; - @override - bool get showErrorMessages; - - /// Create a copy of SetPasswordFormState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$SetPasswordFormStateImplCopyWith<_$SetPasswordFormStateImpl> - get copyWith => throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$SetPasswordFormStateCopyWith<$Res> implements $SetPasswordFormStateCopyWith<$Res> { + factory _$SetPasswordFormStateCopyWith(_SetPasswordFormState value, $Res Function(_SetPasswordFormState) _then) = __$SetPasswordFormStateCopyWithImpl; +@override @useResult +$Res call({ + String registrationToken, String password, String confirmPassword, Option> failureOrSetPasswordOption, bool isSubmitting, bool showErrorMessages +}); + + + + +} +/// @nodoc +class __$SetPasswordFormStateCopyWithImpl<$Res> + implements _$SetPasswordFormStateCopyWith<$Res> { + __$SetPasswordFormStateCopyWithImpl(this._self, this._then); + + final _SetPasswordFormState _self; + final $Res Function(_SetPasswordFormState) _then; + +/// Create a copy of SetPasswordFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? registrationToken = null,Object? password = null,Object? confirmPassword = null,Object? failureOrSetPasswordOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(_SetPasswordFormState( +registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String,password: null == password ? _self.password : password // ignore: cast_nullable_to_non_nullable +as String,confirmPassword: null == confirmPassword ? _self.confirmPassword : confirmPassword // ignore: cast_nullable_to_non_nullable +as String,failureOrSetPasswordOption: null == failureOrSetPasswordOption ? _self.failureOrSetPasswordOption : failureOrSetPasswordOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/auth/set_password/set_password_form_event.dart b/lib/application/auth/set_password/set_password_form_event.dart index 32dc640..cf4da2b 100644 --- a/lib/application/auth/set_password/set_password_form_event.dart +++ b/lib/application/auth/set_password/set_password_form_event.dart @@ -1,7 +1,7 @@ part of 'set_password_form_bloc.dart'; @freezed -class SetPasswordFormEvent with _$SetPasswordFormEvent { +abstract class SetPasswordFormEvent with _$SetPasswordFormEvent { const factory SetPasswordFormEvent.registrationTokenChanged( String registrationToken, ) = _RegistrationTokenChanged; diff --git a/lib/application/auth/set_password/set_password_form_state.dart b/lib/application/auth/set_password/set_password_form_state.dart index 849755e..e1f3d29 100644 --- a/lib/application/auth/set_password/set_password_form_state.dart +++ b/lib/application/auth/set_password/set_password_form_state.dart @@ -1,7 +1,7 @@ part of 'set_password_form_bloc.dart'; @freezed -class SetPasswordFormState with _$SetPasswordFormState { +abstract class SetPasswordFormState with _$SetPasswordFormState { const factory SetPasswordFormState({ required String registrationToken, required String password, diff --git a/lib/application/auth/verify_form/verify_form_bloc.freezed.dart b/lib/application/auth/verify_form/verify_form_bloc.freezed.dart index 89b0ddd..6b8352f 100644 --- a/lib/application/auth/verify_form/verify_form_bloc.freezed.dart +++ b/lib/application/auth/verify_form/verify_form_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'verify_form_bloc.dart'; @@ -9,742 +9,623 @@ part of 'verify_form_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$VerifyFormEvent { - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String otpCode) otpCodeChanged, - required TResult Function() submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String otpCode)? otpCodeChanged, - TResult? Function()? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String otpCode)? otpCodeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_OtpCodeChanged value) otpCodeChanged, - required TResult Function(_Submitted value) submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_OtpCodeChanged value)? otpCodeChanged, - TResult? Function(_Submitted value)? submitted, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_OtpCodeChanged value)? otpCodeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'VerifyFormEvent()'; +} + + } /// @nodoc -abstract class $VerifyFormEventCopyWith<$Res> { - factory $VerifyFormEventCopyWith( - VerifyFormEvent value, - $Res Function(VerifyFormEvent) then, - ) = _$VerifyFormEventCopyWithImpl<$Res, VerifyFormEvent>; +class $VerifyFormEventCopyWith<$Res> { +$VerifyFormEventCopyWith(VerifyFormEvent _, $Res Function(VerifyFormEvent) __); } -/// @nodoc -class _$VerifyFormEventCopyWithImpl<$Res, $Val extends VerifyFormEvent> - implements $VerifyFormEventCopyWith<$Res> { - _$VerifyFormEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [VerifyFormEvent]. +extension VerifyFormEventPatterns on VerifyFormEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _RegistrationTokenChanged value)? registrationTokenChanged,TResult Function( _OtpCodeChanged value)? otpCodeChanged,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that);case _OtpCodeChanged() when otpCodeChanged != null: +return otpCodeChanged(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _RegistrationTokenChanged value) registrationTokenChanged,required TResult Function( _OtpCodeChanged value) otpCodeChanged,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _RegistrationTokenChanged(): +return registrationTokenChanged(_that);case _OtpCodeChanged(): +return otpCodeChanged(_that);case _Submitted(): +return submitted(_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( _RegistrationTokenChanged value)? registrationTokenChanged,TResult? Function( _OtpCodeChanged value)? otpCodeChanged,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that);case _OtpCodeChanged() when otpCodeChanged != null: +return otpCodeChanged(_that);case _Submitted() when submitted != null: +return submitted(_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 registrationToken)? registrationTokenChanged,TResult Function( String otpCode)? otpCodeChanged,TResult Function()? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that.registrationToken);case _OtpCodeChanged() when otpCodeChanged != null: +return otpCodeChanged(_that.otpCode);case _Submitted() when submitted != null: +return submitted();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({required TResult Function( String registrationToken) registrationTokenChanged,required TResult Function( String otpCode) otpCodeChanged,required TResult Function() submitted,}) {final _that = this; +switch (_that) { +case _RegistrationTokenChanged(): +return registrationTokenChanged(_that.registrationToken);case _OtpCodeChanged(): +return otpCodeChanged(_that.otpCode);case _Submitted(): +return submitted();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 registrationToken)? registrationTokenChanged,TResult? Function( String otpCode)? otpCodeChanged,TResult? Function()? submitted,}) {final _that = this; +switch (_that) { +case _RegistrationTokenChanged() when registrationTokenChanged != null: +return registrationTokenChanged(_that.registrationToken);case _OtpCodeChanged() when otpCodeChanged != null: +return otpCodeChanged(_that.otpCode);case _Submitted() when submitted != null: +return submitted();case _: + return null; + +} } -/// @nodoc -abstract class _$$RegistrationTokenChangedImplCopyWith<$Res> { - factory _$$RegistrationTokenChangedImplCopyWith( - _$RegistrationTokenChangedImpl value, - $Res Function(_$RegistrationTokenChangedImpl) then, - ) = __$$RegistrationTokenChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String registrationToken}); -} - -/// @nodoc -class __$$RegistrationTokenChangedImplCopyWithImpl<$Res> - extends _$VerifyFormEventCopyWithImpl<$Res, _$RegistrationTokenChangedImpl> - implements _$$RegistrationTokenChangedImplCopyWith<$Res> { - __$$RegistrationTokenChangedImplCopyWithImpl( - _$RegistrationTokenChangedImpl _value, - $Res Function(_$RegistrationTokenChangedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? registrationToken = null}) { - return _then( - _$RegistrationTokenChangedImpl( - null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$RegistrationTokenChangedImpl implements _RegistrationTokenChanged { - const _$RegistrationTokenChangedImpl(this.registrationToken); - @override - final String registrationToken; +class _RegistrationTokenChanged implements VerifyFormEvent { + const _RegistrationTokenChanged(this.registrationToken); + - @override - String toString() { + final String registrationToken; + +/// Create a copy of VerifyFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RegistrationTokenChangedCopyWith<_RegistrationTokenChanged> get copyWith => __$RegistrationTokenChangedCopyWithImpl<_RegistrationTokenChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _RegistrationTokenChanged&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,registrationToken); +} + +@override +String toString() { return 'VerifyFormEvent.registrationTokenChanged(registrationToken: $registrationToken)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RegistrationTokenChangedImpl && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken)); - } - - @override - int get hashCode => Object.hash(runtimeType, registrationToken); - - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl> - get copyWith => - __$$RegistrationTokenChangedImplCopyWithImpl< - _$RegistrationTokenChangedImpl - >(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String otpCode) otpCodeChanged, - required TResult Function() submitted, - }) { - return registrationTokenChanged(registrationToken); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String otpCode)? otpCodeChanged, - TResult? Function()? submitted, - }) { - return registrationTokenChanged?.call(registrationToken); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String otpCode)? otpCodeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (registrationTokenChanged != null) { - return registrationTokenChanged(registrationToken); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_OtpCodeChanged value) otpCodeChanged, - required TResult Function(_Submitted value) submitted, - }) { - return registrationTokenChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_OtpCodeChanged value)? otpCodeChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return registrationTokenChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_OtpCodeChanged value)? otpCodeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (registrationTokenChanged != null) { - return registrationTokenChanged(this); - } - return orElse(); - } } -abstract class _RegistrationTokenChanged implements VerifyFormEvent { - const factory _RegistrationTokenChanged(final String registrationToken) = - _$RegistrationTokenChangedImpl; - String get registrationToken; - - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RegistrationTokenChangedImplCopyWith<_$RegistrationTokenChangedImpl> - get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$OtpCodeChangedImplCopyWith<$Res> { - factory _$$OtpCodeChangedImplCopyWith( - _$OtpCodeChangedImpl value, - $Res Function(_$OtpCodeChangedImpl) then, - ) = __$$OtpCodeChangedImplCopyWithImpl<$Res>; - @useResult - $Res call({String otpCode}); +abstract mixin class _$RegistrationTokenChangedCopyWith<$Res> implements $VerifyFormEventCopyWith<$Res> { + factory _$RegistrationTokenChangedCopyWith(_RegistrationTokenChanged value, $Res Function(_RegistrationTokenChanged) _then) = __$RegistrationTokenChangedCopyWithImpl; +@useResult +$Res call({ + String registrationToken +}); + + + + +} +/// @nodoc +class __$RegistrationTokenChangedCopyWithImpl<$Res> + implements _$RegistrationTokenChangedCopyWith<$Res> { + __$RegistrationTokenChangedCopyWithImpl(this._self, this._then); + + final _RegistrationTokenChanged _self; + final $Res Function(_RegistrationTokenChanged) _then; + +/// Create a copy of VerifyFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? registrationToken = null,}) { + return _then(_RegistrationTokenChanged( +null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$OtpCodeChangedImplCopyWithImpl<$Res> - extends _$VerifyFormEventCopyWithImpl<$Res, _$OtpCodeChangedImpl> - implements _$$OtpCodeChangedImplCopyWith<$Res> { - __$$OtpCodeChangedImplCopyWithImpl( - _$OtpCodeChangedImpl _value, - $Res Function(_$OtpCodeChangedImpl) _then, - ) : super(_value, _then); - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? otpCode = null}) { - return _then( - _$OtpCodeChangedImpl( - null == otpCode - ? _value.otpCode - : otpCode // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } } /// @nodoc -class _$OtpCodeChangedImpl implements _OtpCodeChanged { - const _$OtpCodeChangedImpl(this.otpCode); - @override - final String otpCode; +class _OtpCodeChanged implements VerifyFormEvent { + const _OtpCodeChanged(this.otpCode); + - @override - String toString() { + final String otpCode; + +/// Create a copy of VerifyFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OtpCodeChangedCopyWith<_OtpCodeChanged> get copyWith => __$OtpCodeChangedCopyWithImpl<_OtpCodeChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OtpCodeChanged&&(identical(other.otpCode, otpCode) || other.otpCode == otpCode)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,otpCode); +} + +@override +String toString() { return 'VerifyFormEvent.otpCodeChanged(otpCode: $otpCode)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$OtpCodeChangedImpl && - (identical(other.otpCode, otpCode) || other.otpCode == otpCode)); - } - - @override - int get hashCode => Object.hash(runtimeType, otpCode); - - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$OtpCodeChangedImplCopyWith<_$OtpCodeChangedImpl> get copyWith => - __$$OtpCodeChangedImplCopyWithImpl<_$OtpCodeChangedImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String otpCode) otpCodeChanged, - required TResult Function() submitted, - }) { - return otpCodeChanged(otpCode); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String otpCode)? otpCodeChanged, - TResult? Function()? submitted, - }) { - return otpCodeChanged?.call(otpCode); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String otpCode)? otpCodeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (otpCodeChanged != null) { - return otpCodeChanged(otpCode); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_OtpCodeChanged value) otpCodeChanged, - required TResult Function(_Submitted value) submitted, - }) { - return otpCodeChanged(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_OtpCodeChanged value)? otpCodeChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return otpCodeChanged?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_OtpCodeChanged value)? otpCodeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (otpCodeChanged != null) { - return otpCodeChanged(this); - } - return orElse(); - } } -abstract class _OtpCodeChanged implements VerifyFormEvent { - const factory _OtpCodeChanged(final String otpCode) = _$OtpCodeChangedImpl; - String get otpCode; - - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$OtpCodeChangedImplCopyWith<_$OtpCodeChangedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$SubmittedImplCopyWith<$Res> { - factory _$$SubmittedImplCopyWith( - _$SubmittedImpl value, - $Res Function(_$SubmittedImpl) then, - ) = __$$SubmittedImplCopyWithImpl<$Res>; +abstract mixin class _$OtpCodeChangedCopyWith<$Res> implements $VerifyFormEventCopyWith<$Res> { + factory _$OtpCodeChangedCopyWith(_OtpCodeChanged value, $Res Function(_OtpCodeChanged) _then) = __$OtpCodeChangedCopyWithImpl; +@useResult +$Res call({ + String otpCode +}); + + + + +} +/// @nodoc +class __$OtpCodeChangedCopyWithImpl<$Res> + implements _$OtpCodeChangedCopyWith<$Res> { + __$OtpCodeChangedCopyWithImpl(this._self, this._then); + + final _OtpCodeChanged _self; + final $Res Function(_OtpCodeChanged) _then; + +/// Create a copy of VerifyFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? otpCode = null,}) { + return _then(_OtpCodeChanged( +null == otpCode ? _self.otpCode : otpCode // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -class __$$SubmittedImplCopyWithImpl<$Res> - extends _$VerifyFormEventCopyWithImpl<$Res, _$SubmittedImpl> - implements _$$SubmittedImplCopyWith<$Res> { - __$$SubmittedImplCopyWithImpl( - _$SubmittedImpl _value, - $Res Function(_$SubmittedImpl) _then, - ) : super(_value, _then); - /// Create a copy of VerifyFormEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$SubmittedImpl implements _Submitted { - const _$SubmittedImpl(); - @override - String toString() { +class _Submitted implements VerifyFormEvent { + const _Submitted(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'VerifyFormEvent.submitted()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$SubmittedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(String registrationToken) - registrationTokenChanged, - required TResult Function(String otpCode) otpCodeChanged, - required TResult Function() submitted, - }) { - return submitted(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(String registrationToken)? registrationTokenChanged, - TResult? Function(String otpCode)? otpCodeChanged, - TResult? Function()? submitted, - }) { - return submitted?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(String registrationToken)? registrationTokenChanged, - TResult Function(String otpCode)? otpCodeChanged, - TResult Function()? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_RegistrationTokenChanged value) - registrationTokenChanged, - required TResult Function(_OtpCodeChanged value) otpCodeChanged, - required TResult Function(_Submitted value) submitted, - }) { - return submitted(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_RegistrationTokenChanged value)? - registrationTokenChanged, - TResult? Function(_OtpCodeChanged value)? otpCodeChanged, - TResult? Function(_Submitted value)? submitted, - }) { - return submitted?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_RegistrationTokenChanged value)? registrationTokenChanged, - TResult Function(_OtpCodeChanged value)? otpCodeChanged, - TResult Function(_Submitted value)? submitted, - required TResult orElse(), - }) { - if (submitted != null) { - return submitted(this); - } - return orElse(); - } } -abstract class _Submitted implements VerifyFormEvent { - const factory _Submitted() = _$SubmittedImpl; + } + + + /// @nodoc mixin _$VerifyFormState { - String get registrationToken => throw _privateConstructorUsedError; - String get otpCode => throw _privateConstructorUsedError; - Option> get failureOrVerifyOption => - throw _privateConstructorUsedError; - bool get isSubmitting => throw _privateConstructorUsedError; - bool get showErrorMessages => throw _privateConstructorUsedError; - /// Create a copy of VerifyFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $VerifyFormStateCopyWith get copyWith => - throw _privateConstructorUsedError; + String get registrationToken; String get otpCode; Option> get failureOrVerifyOption; bool get isSubmitting; bool get showErrorMessages; +/// Create a copy of VerifyFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$VerifyFormStateCopyWith get copyWith => _$VerifyFormStateCopyWithImpl(this as VerifyFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as VerifyFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyFormState&&(identical(other.registrationToken, _this.registrationToken) || other.registrationToken == _this.registrationToken)&&(identical(other.otpCode, _this.otpCode) || other.otpCode == _this.otpCode)&&(identical(other.failureOrVerifyOption, _this.failureOrVerifyOption) || other.failureOrVerifyOption == _this.failureOrVerifyOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.showErrorMessages, _this.showErrorMessages) || other.showErrorMessages == _this.showErrorMessages)); +} + + +@override +int get hashCode { + final _this = this as VerifyFormState; + return Object.hash(runtimeType,_this.registrationToken,_this.otpCode,_this.failureOrVerifyOption,_this.isSubmitting,_this.showErrorMessages); +} + +@override +String toString() { + final _this = this as VerifyFormState; + return 'VerifyFormState(registrationToken: ${_this.registrationToken}, otpCode: ${_this.otpCode}, failureOrVerifyOption: ${_this.failureOrVerifyOption}, isSubmitting: ${_this.isSubmitting}, showErrorMessages: ${_this.showErrorMessages})'; +} + + } /// @nodoc -abstract class $VerifyFormStateCopyWith<$Res> { - factory $VerifyFormStateCopyWith( - VerifyFormState value, - $Res Function(VerifyFormState) then, - ) = _$VerifyFormStateCopyWithImpl<$Res, VerifyFormState>; - @useResult - $Res call({ - String registrationToken, - String otpCode, - Option> failureOrVerifyOption, - bool isSubmitting, - bool showErrorMessages, - }); -} +abstract mixin class $VerifyFormStateCopyWith<$Res> { + factory $VerifyFormStateCopyWith(VerifyFormState value, $Res Function(VerifyFormState) _then) = _$VerifyFormStateCopyWithImpl; +@useResult +$Res call({ + String registrationToken, String otpCode, Option> failureOrVerifyOption, bool isSubmitting, bool showErrorMessages +}); + + + +} /// @nodoc -class _$VerifyFormStateCopyWithImpl<$Res, $Val extends VerifyFormState> +class _$VerifyFormStateCopyWithImpl<$Res> implements $VerifyFormStateCopyWith<$Res> { - _$VerifyFormStateCopyWithImpl(this._value, this._then); + _$VerifyFormStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final VerifyFormState _self; + final $Res Function(VerifyFormState) _then; - /// Create a copy of VerifyFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? registrationToken = null, - Object? otpCode = null, - Object? failureOrVerifyOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _value.copyWith( - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - otpCode: null == otpCode - ? _value.otpCode - : otpCode // ignore: cast_nullable_to_non_nullable - as String, - failureOrVerifyOption: null == failureOrVerifyOption - ? _value.failureOrVerifyOption - : failureOrVerifyOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } +/// Create a copy of VerifyFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? registrationToken = null,Object? otpCode = null,Object? failureOrVerifyOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(VerifyFormState( +registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String,otpCode: null == otpCode ? _self.otpCode : otpCode // ignore: cast_nullable_to_non_nullable +as String,failureOrVerifyOption: null == failureOrVerifyOption ? _self.failureOrVerifyOption : failureOrVerifyOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); } -/// @nodoc -abstract class _$$VerifyFormStateImplCopyWith<$Res> - implements $VerifyFormStateCopyWith<$Res> { - factory _$$VerifyFormStateImplCopyWith( - _$VerifyFormStateImpl value, - $Res Function(_$VerifyFormStateImpl) then, - ) = __$$VerifyFormStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String registrationToken, - String otpCode, - Option> failureOrVerifyOption, - bool isSubmitting, - bool showErrorMessages, - }); } -/// @nodoc -class __$$VerifyFormStateImplCopyWithImpl<$Res> - extends _$VerifyFormStateCopyWithImpl<$Res, _$VerifyFormStateImpl> - implements _$$VerifyFormStateImplCopyWith<$Res> { - __$$VerifyFormStateImplCopyWithImpl( - _$VerifyFormStateImpl _value, - $Res Function(_$VerifyFormStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of VerifyFormState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? registrationToken = null, - Object? otpCode = null, - Object? failureOrVerifyOption = null, - Object? isSubmitting = null, - Object? showErrorMessages = null, - }) { - return _then( - _$VerifyFormStateImpl( - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - otpCode: null == otpCode - ? _value.otpCode - : otpCode // ignore: cast_nullable_to_non_nullable - as String, - failureOrVerifyOption: null == failureOrVerifyOption - ? _value.failureOrVerifyOption - : failureOrVerifyOption // ignore: cast_nullable_to_non_nullable - as Option>, - isSubmitting: null == isSubmitting - ? _value.isSubmitting - : isSubmitting // ignore: cast_nullable_to_non_nullable - as bool, - showErrorMessages: null == showErrorMessages - ? _value.showErrorMessages - : showErrorMessages // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [VerifyFormState]. +extension VerifyFormStatePatterns on VerifyFormState { +/// 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( _VerifyFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _VerifyFormState() 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( _VerifyFormState value) $default,){ +final _that = this; +switch (_that) { +case _VerifyFormState(): +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( _VerifyFormState value)? $default,){ +final _that = this; +switch (_that) { +case _VerifyFormState() 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 registrationToken, String otpCode, Option> failureOrVerifyOption, bool isSubmitting, bool showErrorMessages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _VerifyFormState() when $default != null: +return $default(_that.registrationToken,_that.otpCode,_that.failureOrVerifyOption,_that.isSubmitting,_that.showErrorMessages);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 registrationToken, String otpCode, Option> failureOrVerifyOption, bool isSubmitting, bool showErrorMessages) $default,) {final _that = this; +switch (_that) { +case _VerifyFormState(): +return $default(_that.registrationToken,_that.otpCode,_that.failureOrVerifyOption,_that.isSubmitting,_that.showErrorMessages);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 registrationToken, String otpCode, Option> failureOrVerifyOption, bool isSubmitting, bool showErrorMessages)? $default,) {final _that = this; +switch (_that) { +case _VerifyFormState() when $default != null: +return $default(_that.registrationToken,_that.otpCode,_that.failureOrVerifyOption,_that.isSubmitting,_that.showErrorMessages);case _: + return null; + +} +} + } /// @nodoc -class _$VerifyFormStateImpl implements _VerifyFormState { - const _$VerifyFormStateImpl({ - required this.registrationToken, - required this.otpCode, - required this.failureOrVerifyOption, - this.isSubmitting = false, - this.showErrorMessages = false, - }); - @override - final String registrationToken; - @override - final String otpCode; - @override - final Option> failureOrVerifyOption; - @override - @JsonKey() - final bool isSubmitting; - @override - @JsonKey() - final bool showErrorMessages; +class _VerifyFormState implements VerifyFormState { + const _VerifyFormState({required this.registrationToken, required this.otpCode, required this.failureOrVerifyOption, this.isSubmitting = false, this.showErrorMessages = false}); + - @override - String toString() { +@override final String registrationToken; +@override final String otpCode; +@override final Option> failureOrVerifyOption; +@override@JsonKey() final bool isSubmitting; +@override@JsonKey() final bool showErrorMessages; + +/// Create a copy of VerifyFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$VerifyFormStateCopyWith<_VerifyFormState> get copyWith => __$VerifyFormStateCopyWithImpl<_VerifyFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyFormState&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)&&(identical(other.otpCode, otpCode) || other.otpCode == otpCode)&&(identical(other.failureOrVerifyOption, failureOrVerifyOption) || other.failureOrVerifyOption == failureOrVerifyOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.showErrorMessages, showErrorMessages) || other.showErrorMessages == showErrorMessages)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,registrationToken,otpCode,failureOrVerifyOption,isSubmitting,showErrorMessages); +} + +@override +String toString() { return 'VerifyFormState(registrationToken: $registrationToken, otpCode: $otpCode, failureOrVerifyOption: $failureOrVerifyOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$VerifyFormStateImpl && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken) && - (identical(other.otpCode, otpCode) || other.otpCode == otpCode) && - (identical(other.failureOrVerifyOption, failureOrVerifyOption) || - other.failureOrVerifyOption == failureOrVerifyOption) && - (identical(other.isSubmitting, isSubmitting) || - other.isSubmitting == isSubmitting) && - (identical(other.showErrorMessages, showErrorMessages) || - other.showErrorMessages == showErrorMessages)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - registrationToken, - otpCode, - failureOrVerifyOption, - isSubmitting, - showErrorMessages, - ); - - /// Create a copy of VerifyFormState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$VerifyFormStateImplCopyWith<_$VerifyFormStateImpl> get copyWith => - __$$VerifyFormStateImplCopyWithImpl<_$VerifyFormStateImpl>( - this, - _$identity, - ); } -abstract class _VerifyFormState implements VerifyFormState { - const factory _VerifyFormState({ - required final String registrationToken, - required final String otpCode, - required final Option> failureOrVerifyOption, - final bool isSubmitting, - final bool showErrorMessages, - }) = _$VerifyFormStateImpl; - @override - String get registrationToken; - @override - String get otpCode; - @override - Option> get failureOrVerifyOption; - @override - bool get isSubmitting; - @override - bool get showErrorMessages; - - /// Create a copy of VerifyFormState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$VerifyFormStateImplCopyWith<_$VerifyFormStateImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$VerifyFormStateCopyWith<$Res> implements $VerifyFormStateCopyWith<$Res> { + factory _$VerifyFormStateCopyWith(_VerifyFormState value, $Res Function(_VerifyFormState) _then) = __$VerifyFormStateCopyWithImpl; +@override @useResult +$Res call({ + String registrationToken, String otpCode, Option> failureOrVerifyOption, bool isSubmitting, bool showErrorMessages +}); + + + + +} +/// @nodoc +class __$VerifyFormStateCopyWithImpl<$Res> + implements _$VerifyFormStateCopyWith<$Res> { + __$VerifyFormStateCopyWithImpl(this._self, this._then); + + final _VerifyFormState _self; + final $Res Function(_VerifyFormState) _then; + +/// Create a copy of VerifyFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? registrationToken = null,Object? otpCode = null,Object? failureOrVerifyOption = null,Object? isSubmitting = null,Object? showErrorMessages = null,}) { + return _then(_VerifyFormState( +registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String,otpCode: null == otpCode ? _self.otpCode : otpCode // ignore: cast_nullable_to_non_nullable +as String,failureOrVerifyOption: null == failureOrVerifyOption ? _self.failureOrVerifyOption : failureOrVerifyOption // ignore: cast_nullable_to_non_nullable +as Option>,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,showErrorMessages: null == showErrorMessages ? _self.showErrorMessages : showErrorMessages // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/auth/verify_form/verify_form_event.dart b/lib/application/auth/verify_form/verify_form_event.dart index d86587a..3b5bb5a 100644 --- a/lib/application/auth/verify_form/verify_form_event.dart +++ b/lib/application/auth/verify_form/verify_form_event.dart @@ -1,7 +1,7 @@ part of 'verify_form_bloc.dart'; @freezed -class VerifyFormEvent with _$VerifyFormEvent { +abstract class VerifyFormEvent with _$VerifyFormEvent { const factory VerifyFormEvent.registrationTokenChanged( String registrationToken, ) = _RegistrationTokenChanged; diff --git a/lib/application/auth/verify_form/verify_form_state.dart b/lib/application/auth/verify_form/verify_form_state.dart index 1955239..a8fded6 100644 --- a/lib/application/auth/verify_form/verify_form_state.dart +++ b/lib/application/auth/verify_form/verify_form_state.dart @@ -1,7 +1,7 @@ part of 'verify_form_bloc.dart'; @freezed -class VerifyFormState with _$VerifyFormState { +abstract class VerifyFormState with _$VerifyFormState { const factory VerifyFormState({ required String registrationToken, required String otpCode, diff --git a/lib/application/customer/customer_point_loader/customer_point_loader_bloc.dart b/lib/application/customer/customer_point_loader/customer_point_loader_bloc.dart deleted file mode 100644 index f64dab9..0000000 --- a/lib/application/customer/customer_point_loader/customer_point_loader_bloc.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'package:bloc/bloc.dart'; -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:injectable/injectable.dart'; - -import '../../../domain/customer/customer.dart'; - -part 'customer_point_loader_event.dart'; -part 'customer_point_loader_state.dart'; -part 'customer_point_loader_bloc.freezed.dart'; - -@injectable -class CustomerPointLoaderBloc - extends Bloc { - final ICustomerRepository _repository; - CustomerPointLoaderBloc(this._repository) - : super(CustomerPointLoaderState.initial()) { - on(_onCustomerPointLoaderEvent); - } - - Future _onCustomerPointLoaderEvent( - CustomerPointLoaderEvent event, - Emitter emit, - ) { - return event.map( - fetched: (e) async { - emit( - state.copyWith(isFetching: true, failureOptionCustomerPoint: none()), - ); - - final result = await _repository.getPoints(); - - var data = result.fold( - (f) => state.copyWith(failureOptionCustomerPoint: optionOf(f)), - (customerPoint) => state.copyWith(customerPoint: customerPoint), - ); - - emit(data.copyWith(isFetching: false)); - }, - ); - } -} diff --git a/lib/application/customer/customer_point_loader/customer_point_loader_bloc.freezed.dart b/lib/application/customer/customer_point_loader/customer_point_loader_bloc.freezed.dart deleted file mode 100644 index 3588ac7..0000000 --- a/lib/application/customer/customer_point_loader/customer_point_loader_bloc.freezed.dart +++ /dev/null @@ -1,391 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'customer_point_loader_bloc.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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 _$CustomerPointLoaderEvent { - @optionalTypeArgs - TResult when({ - required TResult Function() fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? fetched, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_Fetched value) fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Fetched value)? fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Fetched value)? fetched, - required TResult orElse(), - }) => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $CustomerPointLoaderEventCopyWith<$Res> { - factory $CustomerPointLoaderEventCopyWith( - CustomerPointLoaderEvent value, - $Res Function(CustomerPointLoaderEvent) then, - ) = _$CustomerPointLoaderEventCopyWithImpl<$Res, CustomerPointLoaderEvent>; -} - -/// @nodoc -class _$CustomerPointLoaderEventCopyWithImpl< - $Res, - $Val extends CustomerPointLoaderEvent -> - implements $CustomerPointLoaderEventCopyWith<$Res> { - _$CustomerPointLoaderEventCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CustomerPointLoaderEvent - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc -abstract class _$$FetchedImplCopyWith<$Res> { - factory _$$FetchedImplCopyWith( - _$FetchedImpl value, - $Res Function(_$FetchedImpl) then, - ) = __$$FetchedImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$FetchedImplCopyWithImpl<$Res> - extends _$CustomerPointLoaderEventCopyWithImpl<$Res, _$FetchedImpl> - implements _$$FetchedImplCopyWith<$Res> { - __$$FetchedImplCopyWithImpl( - _$FetchedImpl _value, - $Res Function(_$FetchedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerPointLoaderEvent - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc - -class _$FetchedImpl implements _Fetched { - const _$FetchedImpl(); - - @override - String toString() { - return 'CustomerPointLoaderEvent.fetched()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$FetchedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({required TResult Function() fetched}) { - return fetched(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({TResult? Function()? fetched}) { - return fetched?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? fetched, - required TResult orElse(), - }) { - if (fetched != null) { - return fetched(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Fetched value) fetched, - }) { - return fetched(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Fetched value)? fetched, - }) { - return fetched?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Fetched value)? fetched, - required TResult orElse(), - }) { - if (fetched != null) { - return fetched(this); - } - return orElse(); - } -} - -abstract class _Fetched implements CustomerPointLoaderEvent { - const factory _Fetched() = _$FetchedImpl; -} - -/// @nodoc -mixin _$CustomerPointLoaderState { - CustomerPoint get customerPoint => throw _privateConstructorUsedError; - Option get failureOptionCustomerPoint => - throw _privateConstructorUsedError; - bool get isFetching => throw _privateConstructorUsedError; - - /// Create a copy of CustomerPointLoaderState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CustomerPointLoaderStateCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $CustomerPointLoaderStateCopyWith<$Res> { - factory $CustomerPointLoaderStateCopyWith( - CustomerPointLoaderState value, - $Res Function(CustomerPointLoaderState) then, - ) = _$CustomerPointLoaderStateCopyWithImpl<$Res, CustomerPointLoaderState>; - @useResult - $Res call({ - CustomerPoint customerPoint, - Option failureOptionCustomerPoint, - bool isFetching, - }); - - $CustomerPointCopyWith<$Res> get customerPoint; -} - -/// @nodoc -class _$CustomerPointLoaderStateCopyWithImpl< - $Res, - $Val extends CustomerPointLoaderState -> - implements $CustomerPointLoaderStateCopyWith<$Res> { - _$CustomerPointLoaderStateCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CustomerPointLoaderState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? customerPoint = null, - Object? failureOptionCustomerPoint = null, - Object? isFetching = null, - }) { - return _then( - _value.copyWith( - customerPoint: null == customerPoint - ? _value.customerPoint - : customerPoint // ignore: cast_nullable_to_non_nullable - as CustomerPoint, - failureOptionCustomerPoint: null == failureOptionCustomerPoint - ? _value.failureOptionCustomerPoint - : failureOptionCustomerPoint // ignore: cast_nullable_to_non_nullable - as Option, - isFetching: null == isFetching - ? _value.isFetching - : isFetching // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } - - /// Create a copy of CustomerPointLoaderState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $CustomerPointCopyWith<$Res> get customerPoint { - return $CustomerPointCopyWith<$Res>(_value.customerPoint, (value) { - return _then(_value.copyWith(customerPoint: value) as $Val); - }); - } -} - -/// @nodoc -abstract class _$$CustomerPointLoaderStateImplCopyWith<$Res> - implements $CustomerPointLoaderStateCopyWith<$Res> { - factory _$$CustomerPointLoaderStateImplCopyWith( - _$CustomerPointLoaderStateImpl value, - $Res Function(_$CustomerPointLoaderStateImpl) then, - ) = __$$CustomerPointLoaderStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - CustomerPoint customerPoint, - Option failureOptionCustomerPoint, - bool isFetching, - }); - - @override - $CustomerPointCopyWith<$Res> get customerPoint; -} - -/// @nodoc -class __$$CustomerPointLoaderStateImplCopyWithImpl<$Res> - extends - _$CustomerPointLoaderStateCopyWithImpl< - $Res, - _$CustomerPointLoaderStateImpl - > - implements _$$CustomerPointLoaderStateImplCopyWith<$Res> { - __$$CustomerPointLoaderStateImplCopyWithImpl( - _$CustomerPointLoaderStateImpl _value, - $Res Function(_$CustomerPointLoaderStateImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerPointLoaderState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? customerPoint = null, - Object? failureOptionCustomerPoint = null, - Object? isFetching = null, - }) { - return _then( - _$CustomerPointLoaderStateImpl( - customerPoint: null == customerPoint - ? _value.customerPoint - : customerPoint // ignore: cast_nullable_to_non_nullable - as CustomerPoint, - failureOptionCustomerPoint: null == failureOptionCustomerPoint - ? _value.failureOptionCustomerPoint - : failureOptionCustomerPoint // ignore: cast_nullable_to_non_nullable - as Option, - isFetching: null == isFetching - ? _value.isFetching - : isFetching // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } -} - -/// @nodoc - -class _$CustomerPointLoaderStateImpl implements _CustomerPointLoaderState { - const _$CustomerPointLoaderStateImpl({ - required this.customerPoint, - required this.failureOptionCustomerPoint, - this.isFetching = false, - }); - - @override - final CustomerPoint customerPoint; - @override - final Option failureOptionCustomerPoint; - @override - @JsonKey() - final bool isFetching; - - @override - String toString() { - return 'CustomerPointLoaderState(customerPoint: $customerPoint, failureOptionCustomerPoint: $failureOptionCustomerPoint, isFetching: $isFetching)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CustomerPointLoaderStateImpl && - (identical(other.customerPoint, customerPoint) || - other.customerPoint == customerPoint) && - (identical( - other.failureOptionCustomerPoint, - failureOptionCustomerPoint, - ) || - other.failureOptionCustomerPoint == - failureOptionCustomerPoint) && - (identical(other.isFetching, isFetching) || - other.isFetching == isFetching)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - customerPoint, - failureOptionCustomerPoint, - isFetching, - ); - - /// Create a copy of CustomerPointLoaderState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CustomerPointLoaderStateImplCopyWith<_$CustomerPointLoaderStateImpl> - get copyWith => - __$$CustomerPointLoaderStateImplCopyWithImpl< - _$CustomerPointLoaderStateImpl - >(this, _$identity); -} - -abstract class _CustomerPointLoaderState implements CustomerPointLoaderState { - const factory _CustomerPointLoaderState({ - required final CustomerPoint customerPoint, - required final Option failureOptionCustomerPoint, - final bool isFetching, - }) = _$CustomerPointLoaderStateImpl; - - @override - CustomerPoint get customerPoint; - @override - Option get failureOptionCustomerPoint; - @override - bool get isFetching; - - /// Create a copy of CustomerPointLoaderState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CustomerPointLoaderStateImplCopyWith<_$CustomerPointLoaderStateImpl> - get copyWith => throw _privateConstructorUsedError; -} diff --git a/lib/application/customer/customer_point_loader/customer_point_loader_event.dart b/lib/application/customer/customer_point_loader/customer_point_loader_event.dart deleted file mode 100644 index 6e45f9c..0000000 --- a/lib/application/customer/customer_point_loader/customer_point_loader_event.dart +++ /dev/null @@ -1,6 +0,0 @@ -part of 'customer_point_loader_bloc.dart'; - -@freezed -class CustomerPointLoaderEvent with _$CustomerPointLoaderEvent { - const factory CustomerPointLoaderEvent.fetched() = _Fetched; -} diff --git a/lib/application/customer/customer_point_loader/customer_point_loader_state.dart b/lib/application/customer/customer_point_loader/customer_point_loader_state.dart deleted file mode 100644 index b5ab295..0000000 --- a/lib/application/customer/customer_point_loader/customer_point_loader_state.dart +++ /dev/null @@ -1,15 +0,0 @@ -part of 'customer_point_loader_bloc.dart'; - -@freezed -class CustomerPointLoaderState with _$CustomerPointLoaderState { - const factory CustomerPointLoaderState({ - required CustomerPoint customerPoint, - required Option failureOptionCustomerPoint, - @Default(false) bool isFetching, - }) = _CustomerPointLoaderState; - - factory CustomerPointLoaderState.initial() => CustomerPointLoaderState( - customerPoint: CustomerPoint.empty(), - failureOptionCustomerPoint: none(), - ); -} diff --git a/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_bloc.freezed.dart b/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_bloc.freezed.dart index 0979be9..469a6e2 100644 --- a/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_bloc.freezed.dart +++ b/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_bloc.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'ferris_wheel_loader_bloc.dart'; @@ -9,380 +9,487 @@ part of 'ferris_wheel_loader_bloc.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$FerrisWheelLoaderEvent { - @optionalTypeArgs - TResult when({ - required TResult Function() fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function()? fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? fetched, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_Fetched value) fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Fetched value)? fetched, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Fetched value)? fetched, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is FerrisWheelLoaderEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'FerrisWheelLoaderEvent()'; +} + + } /// @nodoc -abstract class $FerrisWheelLoaderEventCopyWith<$Res> { - factory $FerrisWheelLoaderEventCopyWith( - FerrisWheelLoaderEvent value, - $Res Function(FerrisWheelLoaderEvent) then, - ) = _$FerrisWheelLoaderEventCopyWithImpl<$Res, FerrisWheelLoaderEvent>; +class $FerrisWheelLoaderEventCopyWith<$Res> { +$FerrisWheelLoaderEventCopyWith(FerrisWheelLoaderEvent _, $Res Function(FerrisWheelLoaderEvent) __); } -/// @nodoc -class _$FerrisWheelLoaderEventCopyWithImpl< - $Res, - $Val extends FerrisWheelLoaderEvent -> - implements $FerrisWheelLoaderEventCopyWith<$Res> { - _$FerrisWheelLoaderEventCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [FerrisWheelLoaderEvent]. +extension FerrisWheelLoaderEventPatterns on FerrisWheelLoaderEvent { +/// 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(); +/// } +/// ``` - /// Create a copy of FerrisWheelLoaderEvent - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _Fetched value)? fetched,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_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({required TResult Function( _Fetched value) fetched,}){ +final _that = this; +switch (_that) { +case _Fetched(): +return fetched(_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( _Fetched value)? fetched,}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_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()? fetched,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();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({required TResult Function() fetched,}) {final _that = this; +switch (_that) { +case _Fetched(): +return fetched();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()? fetched,}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();case _: + return null; + +} } -/// @nodoc -abstract class _$$FetchedImplCopyWith<$Res> { - factory _$$FetchedImplCopyWith( - _$FetchedImpl value, - $Res Function(_$FetchedImpl) then, - ) = __$$FetchedImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$FetchedImplCopyWithImpl<$Res> - extends _$FerrisWheelLoaderEventCopyWithImpl<$Res, _$FetchedImpl> - implements _$$FetchedImplCopyWith<$Res> { - __$$FetchedImplCopyWithImpl( - _$FetchedImpl _value, - $Res Function(_$FetchedImpl) _then, - ) : super(_value, _then); - - /// Create a copy of FerrisWheelLoaderEvent - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$FetchedImpl implements _Fetched { - const _$FetchedImpl(); - @override - String toString() { +class _Fetched implements FerrisWheelLoaderEvent { + const _Fetched(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Fetched); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'FerrisWheelLoaderEvent.fetched()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$FetchedImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({required TResult Function() fetched}) { - return fetched(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({TResult? Function()? fetched}) { - return fetched?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function()? fetched, - required TResult orElse(), - }) { - if (fetched != null) { - return fetched(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_Fetched value) fetched, - }) { - return fetched(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_Fetched value)? fetched, - }) { - return fetched?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_Fetched value)? fetched, - required TResult orElse(), - }) { - if (fetched != null) { - return fetched(this); - } - return orElse(); - } } -abstract class _Fetched implements FerrisWheelLoaderEvent { - const factory _Fetched() = _$FetchedImpl; + } + + + /// @nodoc mixin _$FerrisWheelLoaderState { - Game get ferrisWheel => throw _privateConstructorUsedError; - Option get failureOptionFerrisWheel => - throw _privateConstructorUsedError; - bool get isFetching => throw _privateConstructorUsedError; - /// Create a copy of FerrisWheelLoaderState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $FerrisWheelLoaderStateCopyWith get copyWith => - throw _privateConstructorUsedError; + Game get ferrisWheel; Option get failureOptionFerrisWheel; bool get isFetching; +/// Create a copy of FerrisWheelLoaderState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$FerrisWheelLoaderStateCopyWith get copyWith => _$FerrisWheelLoaderStateCopyWithImpl(this as FerrisWheelLoaderState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as FerrisWheelLoaderState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is FerrisWheelLoaderState&&(identical(other.ferrisWheel, _this.ferrisWheel) || other.ferrisWheel == _this.ferrisWheel)&&(identical(other.failureOptionFerrisWheel, _this.failureOptionFerrisWheel) || other.failureOptionFerrisWheel == _this.failureOptionFerrisWheel)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)); +} + + +@override +int get hashCode { + final _this = this as FerrisWheelLoaderState; + return Object.hash(runtimeType,_this.ferrisWheel,_this.failureOptionFerrisWheel,_this.isFetching); +} + +@override +String toString() { + final _this = this as FerrisWheelLoaderState; + return 'FerrisWheelLoaderState(ferrisWheel: ${_this.ferrisWheel}, failureOptionFerrisWheel: ${_this.failureOptionFerrisWheel}, isFetching: ${_this.isFetching})'; +} + + } /// @nodoc -abstract class $FerrisWheelLoaderStateCopyWith<$Res> { - factory $FerrisWheelLoaderStateCopyWith( - FerrisWheelLoaderState value, - $Res Function(FerrisWheelLoaderState) then, - ) = _$FerrisWheelLoaderStateCopyWithImpl<$Res, FerrisWheelLoaderState>; - @useResult - $Res call({ - Game ferrisWheel, - Option failureOptionFerrisWheel, - bool isFetching, - }); +abstract mixin class $FerrisWheelLoaderStateCopyWith<$Res> { + factory $FerrisWheelLoaderStateCopyWith(FerrisWheelLoaderState value, $Res Function(FerrisWheelLoaderState) _then) = _$FerrisWheelLoaderStateCopyWithImpl; +@useResult +$Res call({ + Game ferrisWheel, Option failureOptionFerrisWheel, bool isFetching +}); + + +$GameCopyWith<$Res> get ferrisWheel; - $GameCopyWith<$Res> get ferrisWheel; } - /// @nodoc -class _$FerrisWheelLoaderStateCopyWithImpl< - $Res, - $Val extends FerrisWheelLoaderState -> +class _$FerrisWheelLoaderStateCopyWithImpl<$Res> implements $FerrisWheelLoaderStateCopyWith<$Res> { - _$FerrisWheelLoaderStateCopyWithImpl(this._value, this._then); + _$FerrisWheelLoaderStateCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final FerrisWheelLoaderState _self; + final $Res Function(FerrisWheelLoaderState) _then; - /// Create a copy of FerrisWheelLoaderState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? ferrisWheel = null, - Object? failureOptionFerrisWheel = null, - Object? isFetching = null, - }) { - return _then( - _value.copyWith( - ferrisWheel: null == ferrisWheel - ? _value.ferrisWheel - : ferrisWheel // ignore: cast_nullable_to_non_nullable - as Game, - failureOptionFerrisWheel: null == failureOptionFerrisWheel - ? _value.failureOptionFerrisWheel - : failureOptionFerrisWheel // ignore: cast_nullable_to_non_nullable - as Option, - isFetching: null == isFetching - ? _value.isFetching - : isFetching // ignore: cast_nullable_to_non_nullable - as bool, - ) - as $Val, - ); - } - - /// Create a copy of FerrisWheelLoaderState - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $GameCopyWith<$Res> get ferrisWheel { - return $GameCopyWith<$Res>(_value.ferrisWheel, (value) { - return _then(_value.copyWith(ferrisWheel: value) as $Val); - }); - } +/// Create a copy of FerrisWheelLoaderState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? ferrisWheel = null,Object? failureOptionFerrisWheel = null,Object? isFetching = null,}) { + return _then(FerrisWheelLoaderState( +ferrisWheel: null == ferrisWheel ? _self.ferrisWheel : ferrisWheel // ignore: cast_nullable_to_non_nullable +as Game,failureOptionFerrisWheel: null == failureOptionFerrisWheel ? _self.failureOptionFerrisWheel : failureOptionFerrisWheel // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); } - -/// @nodoc -abstract class _$$FerrisWheelLoaderStateImplCopyWith<$Res> - implements $FerrisWheelLoaderStateCopyWith<$Res> { - factory _$$FerrisWheelLoaderStateImplCopyWith( - _$FerrisWheelLoaderStateImpl value, - $Res Function(_$FerrisWheelLoaderStateImpl) then, - ) = __$$FerrisWheelLoaderStateImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - Game ferrisWheel, - Option failureOptionFerrisWheel, - bool isFetching, +/// Create a copy of FerrisWheelLoaderState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$GameCopyWith<$Res> get ferrisWheel { + + return $GameCopyWith<$Res>(_self.ferrisWheel, (value) { + return _then(_self.copyWith(ferrisWheel: value)); }); - - @override - $GameCopyWith<$Res> get ferrisWheel; +} } -/// @nodoc -class __$$FerrisWheelLoaderStateImplCopyWithImpl<$Res> - extends - _$FerrisWheelLoaderStateCopyWithImpl<$Res, _$FerrisWheelLoaderStateImpl> - implements _$$FerrisWheelLoaderStateImplCopyWith<$Res> { - __$$FerrisWheelLoaderStateImplCopyWithImpl( - _$FerrisWheelLoaderStateImpl _value, - $Res Function(_$FerrisWheelLoaderStateImpl) _then, - ) : super(_value, _then); - /// Create a copy of FerrisWheelLoaderState - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? ferrisWheel = null, - Object? failureOptionFerrisWheel = null, - Object? isFetching = null, - }) { - return _then( - _$FerrisWheelLoaderStateImpl( - ferrisWheel: null == ferrisWheel - ? _value.ferrisWheel - : ferrisWheel // ignore: cast_nullable_to_non_nullable - as Game, - failureOptionFerrisWheel: null == failureOptionFerrisWheel - ? _value.failureOptionFerrisWheel - : failureOptionFerrisWheel // ignore: cast_nullable_to_non_nullable - as Option, - isFetching: null == isFetching - ? _value.isFetching - : isFetching // ignore: cast_nullable_to_non_nullable - as bool, - ), - ); - } +/// Adds pattern-matching-related methods to [FerrisWheelLoaderState]. +extension FerrisWheelLoaderStatePatterns on FerrisWheelLoaderState { +/// 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( _FerrisWheelLoaderState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _FerrisWheelLoaderState() 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( _FerrisWheelLoaderState value) $default,){ +final _that = this; +switch (_that) { +case _FerrisWheelLoaderState(): +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( _FerrisWheelLoaderState value)? $default,){ +final _that = this; +switch (_that) { +case _FerrisWheelLoaderState() 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( Game ferrisWheel, Option failureOptionFerrisWheel, bool isFetching)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _FerrisWheelLoaderState() when $default != null: +return $default(_that.ferrisWheel,_that.failureOptionFerrisWheel,_that.isFetching);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( Game ferrisWheel, Option failureOptionFerrisWheel, bool isFetching) $default,) {final _that = this; +switch (_that) { +case _FerrisWheelLoaderState(): +return $default(_that.ferrisWheel,_that.failureOptionFerrisWheel,_that.isFetching);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( Game ferrisWheel, Option failureOptionFerrisWheel, bool isFetching)? $default,) {final _that = this; +switch (_that) { +case _FerrisWheelLoaderState() when $default != null: +return $default(_that.ferrisWheel,_that.failureOptionFerrisWheel,_that.isFetching);case _: + return null; + +} +} + } /// @nodoc -class _$FerrisWheelLoaderStateImpl implements _FerrisWheelLoaderState { - const _$FerrisWheelLoaderStateImpl({ - required this.ferrisWheel, - required this.failureOptionFerrisWheel, - this.isFetching = false, - }); - @override - final Game ferrisWheel; - @override - final Option failureOptionFerrisWheel; - @override - @JsonKey() - final bool isFetching; +class _FerrisWheelLoaderState implements FerrisWheelLoaderState { + const _FerrisWheelLoaderState({required this.ferrisWheel, required this.failureOptionFerrisWheel, this.isFetching = false}); + - @override - String toString() { +@override final Game ferrisWheel; +@override final Option failureOptionFerrisWheel; +@override@JsonKey() final bool isFetching; + +/// Create a copy of FerrisWheelLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$FerrisWheelLoaderStateCopyWith<_FerrisWheelLoaderState> get copyWith => __$FerrisWheelLoaderStateCopyWithImpl<_FerrisWheelLoaderState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _FerrisWheelLoaderState&&(identical(other.ferrisWheel, ferrisWheel) || other.ferrisWheel == ferrisWheel)&&(identical(other.failureOptionFerrisWheel, failureOptionFerrisWheel) || other.failureOptionFerrisWheel == failureOptionFerrisWheel)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,ferrisWheel,failureOptionFerrisWheel,isFetching); +} + +@override +String toString() { return 'FerrisWheelLoaderState(ferrisWheel: $ferrisWheel, failureOptionFerrisWheel: $failureOptionFerrisWheel, isFetching: $isFetching)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$FerrisWheelLoaderStateImpl && - (identical(other.ferrisWheel, ferrisWheel) || - other.ferrisWheel == ferrisWheel) && - (identical( - other.failureOptionFerrisWheel, - failureOptionFerrisWheel, - ) || - other.failureOptionFerrisWheel == failureOptionFerrisWheel) && - (identical(other.isFetching, isFetching) || - other.isFetching == isFetching)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - ferrisWheel, - failureOptionFerrisWheel, - isFetching, - ); - - /// Create a copy of FerrisWheelLoaderState - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$FerrisWheelLoaderStateImplCopyWith<_$FerrisWheelLoaderStateImpl> - get copyWith => - __$$FerrisWheelLoaderStateImplCopyWithImpl<_$FerrisWheelLoaderStateImpl>( - this, - _$identity, - ); } -abstract class _FerrisWheelLoaderState implements FerrisWheelLoaderState { - const factory _FerrisWheelLoaderState({ - required final Game ferrisWheel, - required final Option failureOptionFerrisWheel, - final bool isFetching, - }) = _$FerrisWheelLoaderStateImpl; - @override - Game get ferrisWheel; - @override - Option get failureOptionFerrisWheel; - @override - bool get isFetching; - - /// Create a copy of FerrisWheelLoaderState - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$FerrisWheelLoaderStateImplCopyWith<_$FerrisWheelLoaderStateImpl> - get copyWith => throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$FerrisWheelLoaderStateCopyWith<$Res> implements $FerrisWheelLoaderStateCopyWith<$Res> { + factory _$FerrisWheelLoaderStateCopyWith(_FerrisWheelLoaderState value, $Res Function(_FerrisWheelLoaderState) _then) = __$FerrisWheelLoaderStateCopyWithImpl; +@override @useResult +$Res call({ + Game ferrisWheel, Option failureOptionFerrisWheel, bool isFetching +}); + + +@override $GameCopyWith<$Res> get ferrisWheel; + +} +/// @nodoc +class __$FerrisWheelLoaderStateCopyWithImpl<$Res> + implements _$FerrisWheelLoaderStateCopyWith<$Res> { + __$FerrisWheelLoaderStateCopyWithImpl(this._self, this._then); + + final _FerrisWheelLoaderState _self; + final $Res Function(_FerrisWheelLoaderState) _then; + +/// Create a copy of FerrisWheelLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? ferrisWheel = null,Object? failureOptionFerrisWheel = null,Object? isFetching = null,}) { + return _then(_FerrisWheelLoaderState( +ferrisWheel: null == ferrisWheel ? _self.ferrisWheel : ferrisWheel // ignore: cast_nullable_to_non_nullable +as Game,failureOptionFerrisWheel: null == failureOptionFerrisWheel ? _self.failureOptionFerrisWheel : failureOptionFerrisWheel // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of FerrisWheelLoaderState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$GameCopyWith<$Res> get ferrisWheel { + + return $GameCopyWith<$Res>(_self.ferrisWheel, (value) { + return _then(_self.copyWith(ferrisWheel: value)); + }); +} +} + +// dart format on diff --git a/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_event.dart b/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_event.dart index c250a80..ba96196 100644 --- a/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_event.dart +++ b/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_event.dart @@ -1,6 +1,6 @@ part of 'ferris_wheel_loader_bloc.dart'; @freezed -class FerrisWheelLoaderEvent with _$FerrisWheelLoaderEvent { +abstract class FerrisWheelLoaderEvent with _$FerrisWheelLoaderEvent { const factory FerrisWheelLoaderEvent.fetched() = _Fetched; } diff --git a/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_state.dart b/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_state.dart index 795a34c..49e1a55 100644 --- a/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_state.dart +++ b/lib/application/game/ferris_wheel_loader/ferris_wheel_loader_state.dart @@ -1,7 +1,7 @@ part of 'ferris_wheel_loader_bloc.dart'; @freezed -class FerrisWheelLoaderState with _$FerrisWheelLoaderState { +abstract class FerrisWheelLoaderState with _$FerrisWheelLoaderState { const factory FerrisWheelLoaderState({ required Game ferrisWheel, required Option failureOptionFerrisWheel, diff --git a/lib/application/game/game_spin/game_spin_bloc.dart b/lib/application/game/game_spin/game_spin_bloc.dart new file mode 100644 index 0000000..166d23a --- /dev/null +++ b/lib/application/game/game_spin/game_spin_bloc.dart @@ -0,0 +1,40 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/game/game.dart'; + +part 'game_spin_event.dart'; +part 'game_spin_state.dart'; +part 'game_spin_bloc.freezed.dart'; + +@injectable +class GameSpinBloc extends Bloc { + final IGameRepository _repository; + + GameSpinBloc(this._repository) : super(GameSpinState.initial()) { + on(_onGameSpinEvent); + } + + Future _onGameSpinEvent( + GameSpinEvent event, + Emitter emit, + ) { + return event.map( + spun: (e) async { + if (state.isSpinning) return; + emit(state.copyWith(isSpinning: true, failureOrResultOption: none())); + + final result = await _repository.spin(gameId: e.gameId); + + emit( + state.copyWith( + isSpinning: false, + failureOrResultOption: optionOf(result), + ), + ); + }, + ); + } +} diff --git a/lib/application/game/game_spin/game_spin_bloc.freezed.dart b/lib/application/game/game_spin/game_spin_bloc.freezed.dart new file mode 100644 index 0000000..ba46c5a --- /dev/null +++ b/lib/application/game/game_spin/game_spin_bloc.freezed.dart @@ -0,0 +1,546 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'game_spin_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$GameSpinEvent { + + String get gameId; +/// Create a copy of GameSpinEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GameSpinEventCopyWith get copyWith => _$GameSpinEventCopyWithImpl(this as GameSpinEvent, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as GameSpinEvent; + return identical(this, other) || (other.runtimeType == runtimeType&&other is GameSpinEvent&&(identical(other.gameId, _this.gameId) || other.gameId == _this.gameId)); +} + + +@override +int get hashCode { + final _this = this as GameSpinEvent; + return Object.hash(runtimeType,_this.gameId); +} + +@override +String toString() { + final _this = this as GameSpinEvent; + return 'GameSpinEvent(gameId: ${_this.gameId})'; +} + + +} + +/// @nodoc +abstract mixin class $GameSpinEventCopyWith<$Res> { + factory $GameSpinEventCopyWith(GameSpinEvent value, $Res Function(GameSpinEvent) _then) = _$GameSpinEventCopyWithImpl; +@useResult +$Res call({ + String gameId +}); + + + + +} +/// @nodoc +class _$GameSpinEventCopyWithImpl<$Res> + implements $GameSpinEventCopyWith<$Res> { + _$GameSpinEventCopyWithImpl(this._self, this._then); + + final GameSpinEvent _self; + final $Res Function(GameSpinEvent) _then; + +/// Create a copy of GameSpinEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? gameId = null,}) { + return _then(GameSpinEvent.spun( +null == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [GameSpinEvent]. +extension GameSpinEventPatterns on GameSpinEvent { +/// 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( _Spun value)? spun,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Spun() when spun != null: +return spun(_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({required TResult Function( _Spun value) spun,}){ +final _that = this; +switch (_that) { +case _Spun(): +return spun(_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( _Spun value)? spun,}){ +final _that = this; +switch (_that) { +case _Spun() when spun != null: +return spun(_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 gameId)? spun,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Spun() when spun != null: +return spun(_that.gameId);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({required TResult Function( String gameId) spun,}) {final _that = this; +switch (_that) { +case _Spun(): +return spun(_that.gameId);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 gameId)? spun,}) {final _that = this; +switch (_that) { +case _Spun() when spun != null: +return spun(_that.gameId);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Spun implements GameSpinEvent { + const _Spun(this.gameId); + + +@override final String gameId; + +/// Create a copy of GameSpinEvent +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SpunCopyWith<_Spun> get copyWith => __$SpunCopyWithImpl<_Spun>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Spun&&(identical(other.gameId, gameId) || other.gameId == gameId)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,gameId); +} + +@override +String toString() { + return 'GameSpinEvent.spun(gameId: $gameId)'; +} + + +} + +/// @nodoc +abstract mixin class _$SpunCopyWith<$Res> implements $GameSpinEventCopyWith<$Res> { + factory _$SpunCopyWith(_Spun value, $Res Function(_Spun) _then) = __$SpunCopyWithImpl; +@override @useResult +$Res call({ + String gameId +}); + + + + +} +/// @nodoc +class __$SpunCopyWithImpl<$Res> + implements _$SpunCopyWith<$Res> { + __$SpunCopyWithImpl(this._self, this._then); + + final _Spun _self; + final $Res Function(_Spun) _then; + +/// Create a copy of GameSpinEvent +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? gameId = null,}) { + return _then(_Spun( +null == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$GameSpinState { + + bool get isSpinning; Option> get failureOrResultOption; +/// Create a copy of GameSpinState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GameSpinStateCopyWith get copyWith => _$GameSpinStateCopyWithImpl(this as GameSpinState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as GameSpinState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is GameSpinState&&(identical(other.isSpinning, _this.isSpinning) || other.isSpinning == _this.isSpinning)&&(identical(other.failureOrResultOption, _this.failureOrResultOption) || other.failureOrResultOption == _this.failureOrResultOption)); +} + + +@override +int get hashCode { + final _this = this as GameSpinState; + return Object.hash(runtimeType,_this.isSpinning,_this.failureOrResultOption); +} + +@override +String toString() { + final _this = this as GameSpinState; + return 'GameSpinState(isSpinning: ${_this.isSpinning}, failureOrResultOption: ${_this.failureOrResultOption})'; +} + + +} + +/// @nodoc +abstract mixin class $GameSpinStateCopyWith<$Res> { + factory $GameSpinStateCopyWith(GameSpinState value, $Res Function(GameSpinState) _then) = _$GameSpinStateCopyWithImpl; +@useResult +$Res call({ + bool isSpinning, Option> failureOrResultOption +}); + + + + +} +/// @nodoc +class _$GameSpinStateCopyWithImpl<$Res> + implements $GameSpinStateCopyWith<$Res> { + _$GameSpinStateCopyWithImpl(this._self, this._then); + + final GameSpinState _self; + final $Res Function(GameSpinState) _then; + +/// Create a copy of GameSpinState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? isSpinning = null,Object? failureOrResultOption = null,}) { + return _then(GameSpinState( +isSpinning: null == isSpinning ? _self.isSpinning : isSpinning // ignore: cast_nullable_to_non_nullable +as bool,failureOrResultOption: null == failureOrResultOption ? _self.failureOrResultOption : failureOrResultOption // ignore: cast_nullable_to_non_nullable +as Option>, + )); +} + +} + + +/// Adds pattern-matching-related methods to [GameSpinState]. +extension GameSpinStatePatterns on GameSpinState { +/// 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( _GameSpinState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _GameSpinState() 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( _GameSpinState value) $default,){ +final _that = this; +switch (_that) { +case _GameSpinState(): +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( _GameSpinState value)? $default,){ +final _that = this; +switch (_that) { +case _GameSpinState() 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( bool isSpinning, Option> failureOrResultOption)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _GameSpinState() when $default != null: +return $default(_that.isSpinning,_that.failureOrResultOption);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( bool isSpinning, Option> failureOrResultOption) $default,) {final _that = this; +switch (_that) { +case _GameSpinState(): +return $default(_that.isSpinning,_that.failureOrResultOption);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( bool isSpinning, Option> failureOrResultOption)? $default,) {final _that = this; +switch (_that) { +case _GameSpinState() when $default != null: +return $default(_that.isSpinning,_that.failureOrResultOption);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _GameSpinState implements GameSpinState { + const _GameSpinState({this.isSpinning = false, required this.failureOrResultOption}); + + +@override@JsonKey() final bool isSpinning; +@override final Option> failureOrResultOption; + +/// Create a copy of GameSpinState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$GameSpinStateCopyWith<_GameSpinState> get copyWith => __$GameSpinStateCopyWithImpl<_GameSpinState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _GameSpinState&&(identical(other.isSpinning, isSpinning) || other.isSpinning == isSpinning)&&(identical(other.failureOrResultOption, failureOrResultOption) || other.failureOrResultOption == failureOrResultOption)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,isSpinning,failureOrResultOption); +} + +@override +String toString() { + return 'GameSpinState(isSpinning: $isSpinning, failureOrResultOption: $failureOrResultOption)'; +} + + +} + +/// @nodoc +abstract mixin class _$GameSpinStateCopyWith<$Res> implements $GameSpinStateCopyWith<$Res> { + factory _$GameSpinStateCopyWith(_GameSpinState value, $Res Function(_GameSpinState) _then) = __$GameSpinStateCopyWithImpl; +@override @useResult +$Res call({ + bool isSpinning, Option> failureOrResultOption +}); + + + + +} +/// @nodoc +class __$GameSpinStateCopyWithImpl<$Res> + implements _$GameSpinStateCopyWith<$Res> { + __$GameSpinStateCopyWithImpl(this._self, this._then); + + final _GameSpinState _self; + final $Res Function(_GameSpinState) _then; + +/// Create a copy of GameSpinState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? isSpinning = null,Object? failureOrResultOption = null,}) { + return _then(_GameSpinState( +isSpinning: null == isSpinning ? _self.isSpinning : isSpinning // ignore: cast_nullable_to_non_nullable +as bool,failureOrResultOption: null == failureOrResultOption ? _self.failureOrResultOption : failureOrResultOption // ignore: cast_nullable_to_non_nullable +as Option>, + )); +} + + +} + +// dart format on diff --git a/lib/application/game/game_spin/game_spin_event.dart b/lib/application/game/game_spin/game_spin_event.dart new file mode 100644 index 0000000..3500bbb --- /dev/null +++ b/lib/application/game/game_spin/game_spin_event.dart @@ -0,0 +1,6 @@ +part of 'game_spin_bloc.dart'; + +@freezed +abstract class GameSpinEvent with _$GameSpinEvent { + const factory GameSpinEvent.spun(String gameId) = _Spun; +} diff --git a/lib/application/game/game_spin/game_spin_state.dart b/lib/application/game/game_spin/game_spin_state.dart new file mode 100644 index 0000000..52c97b6 --- /dev/null +++ b/lib/application/game/game_spin/game_spin_state.dart @@ -0,0 +1,12 @@ +part of 'game_spin_bloc.dart'; + +@freezed +abstract class GameSpinState with _$GameSpinState { + const factory GameSpinState({ + @Default(false) bool isSpinning, + required Option> failureOrResultOption, + }) = _GameSpinState; + + factory GameSpinState.initial() => + GameSpinState(failureOrResultOption: none()); +} diff --git a/lib/application/order/order_detail_loader/order_detail_loader_bloc.dart b/lib/application/order/order_detail_loader/order_detail_loader_bloc.dart new file mode 100644 index 0000000..b93fcb2 --- /dev/null +++ b/lib/application/order/order_detail_loader/order_detail_loader_bloc.dart @@ -0,0 +1,43 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'order_detail_loader_event.dart'; +part 'order_detail_loader_state.dart'; +part 'order_detail_loader_bloc.freezed.dart'; + +@injectable +class OrderDetailLoaderBloc + extends Bloc { + final IOrderRepository _repository; + + OrderDetailLoaderBloc(this._repository) + : super(OrderDetailLoaderState.initial()) { + on(_onOrderDetailLoaderEvent); + } + + Future _onOrderDetailLoaderEvent( + OrderDetailLoaderEvent event, + Emitter emit, + ) { + return event.map( + fetched: (e) async { + emit(state.copyWith(isFetching: true, failureOption: none())); + + final result = await _repository.getOrderDetail(e.orderId); + + emit( + result + .fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (detail) => state.copyWith(detailOption: some(detail)), + ) + .copyWith(isFetching: false), + ); + }, + ); + } +} diff --git a/lib/application/order/order_detail_loader/order_detail_loader_bloc.freezed.dart b/lib/application/order/order_detail_loader/order_detail_loader_bloc.freezed.dart new file mode 100644 index 0000000..e461ed4 --- /dev/null +++ b/lib/application/order/order_detail_loader/order_detail_loader_bloc.freezed.dart @@ -0,0 +1,549 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'order_detail_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$OrderDetailLoaderEvent { + + String get orderId; +/// Create a copy of OrderDetailLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OrderDetailLoaderEventCopyWith get copyWith => _$OrderDetailLoaderEventCopyWithImpl(this as OrderDetailLoaderEvent, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as OrderDetailLoaderEvent; + return identical(this, other) || (other.runtimeType == runtimeType&&other is OrderDetailLoaderEvent&&(identical(other.orderId, _this.orderId) || other.orderId == _this.orderId)); +} + + +@override +int get hashCode { + final _this = this as OrderDetailLoaderEvent; + return Object.hash(runtimeType,_this.orderId); +} + +@override +String toString() { + final _this = this as OrderDetailLoaderEvent; + return 'OrderDetailLoaderEvent(orderId: ${_this.orderId})'; +} + + +} + +/// @nodoc +abstract mixin class $OrderDetailLoaderEventCopyWith<$Res> { + factory $OrderDetailLoaderEventCopyWith(OrderDetailLoaderEvent value, $Res Function(OrderDetailLoaderEvent) _then) = _$OrderDetailLoaderEventCopyWithImpl; +@useResult +$Res call({ + String orderId +}); + + + + +} +/// @nodoc +class _$OrderDetailLoaderEventCopyWithImpl<$Res> + implements $OrderDetailLoaderEventCopyWith<$Res> { + _$OrderDetailLoaderEventCopyWithImpl(this._self, this._then); + + final OrderDetailLoaderEvent _self; + final $Res Function(OrderDetailLoaderEvent) _then; + +/// Create a copy of OrderDetailLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? orderId = null,}) { + return _then(OrderDetailLoaderEvent.fetched( +null == orderId ? _self.orderId : orderId // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [OrderDetailLoaderEvent]. +extension OrderDetailLoaderEventPatterns on OrderDetailLoaderEvent { +/// 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( _Fetched value)? fetched,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_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({required TResult Function( _Fetched value) fetched,}){ +final _that = this; +switch (_that) { +case _Fetched(): +return fetched(_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( _Fetched value)? fetched,}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_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 orderId)? fetched,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_that.orderId);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({required TResult Function( String orderId) fetched,}) {final _that = this; +switch (_that) { +case _Fetched(): +return fetched(_that.orderId);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 orderId)? fetched,}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_that.orderId);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Fetched implements OrderDetailLoaderEvent { + const _Fetched(this.orderId); + + +@override final String orderId; + +/// Create a copy of OrderDetailLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$FetchedCopyWith<_Fetched> get copyWith => __$FetchedCopyWithImpl<_Fetched>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Fetched&&(identical(other.orderId, orderId) || other.orderId == orderId)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,orderId); +} + +@override +String toString() { + return 'OrderDetailLoaderEvent.fetched(orderId: $orderId)'; +} + + +} + +/// @nodoc +abstract mixin class _$FetchedCopyWith<$Res> implements $OrderDetailLoaderEventCopyWith<$Res> { + factory _$FetchedCopyWith(_Fetched value, $Res Function(_Fetched) _then) = __$FetchedCopyWithImpl; +@override @useResult +$Res call({ + String orderId +}); + + + + +} +/// @nodoc +class __$FetchedCopyWithImpl<$Res> + implements _$FetchedCopyWith<$Res> { + __$FetchedCopyWithImpl(this._self, this._then); + + final _Fetched _self; + final $Res Function(_Fetched) _then; + +/// Create a copy of OrderDetailLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? orderId = null,}) { + return _then(_Fetched( +null == orderId ? _self.orderId : orderId // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$OrderDetailLoaderState { + + Option get detailOption; Option get failureOption; bool get isFetching; +/// Create a copy of OrderDetailLoaderState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OrderDetailLoaderStateCopyWith get copyWith => _$OrderDetailLoaderStateCopyWithImpl(this as OrderDetailLoaderState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as OrderDetailLoaderState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is OrderDetailLoaderState&&(identical(other.detailOption, _this.detailOption) || other.detailOption == _this.detailOption)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)); +} + + +@override +int get hashCode { + final _this = this as OrderDetailLoaderState; + return Object.hash(runtimeType,_this.detailOption,_this.failureOption,_this.isFetching); +} + +@override +String toString() { + final _this = this as OrderDetailLoaderState; + return 'OrderDetailLoaderState(detailOption: ${_this.detailOption}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching})'; +} + + +} + +/// @nodoc +abstract mixin class $OrderDetailLoaderStateCopyWith<$Res> { + factory $OrderDetailLoaderStateCopyWith(OrderDetailLoaderState value, $Res Function(OrderDetailLoaderState) _then) = _$OrderDetailLoaderStateCopyWithImpl; +@useResult +$Res call({ + Option detailOption, Option failureOption, bool isFetching +}); + + + + +} +/// @nodoc +class _$OrderDetailLoaderStateCopyWithImpl<$Res> + implements $OrderDetailLoaderStateCopyWith<$Res> { + _$OrderDetailLoaderStateCopyWithImpl(this._self, this._then); + + final OrderDetailLoaderState _self; + final $Res Function(OrderDetailLoaderState) _then; + +/// Create a copy of OrderDetailLoaderState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? detailOption = null,Object? failureOption = null,Object? isFetching = null,}) { + return _then(OrderDetailLoaderState( +detailOption: null == detailOption ? _self.detailOption : detailOption // ignore: cast_nullable_to_non_nullable +as Option,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [OrderDetailLoaderState]. +extension OrderDetailLoaderStatePatterns on OrderDetailLoaderState { +/// 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( _OrderDetailLoaderState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _OrderDetailLoaderState() 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( _OrderDetailLoaderState value) $default,){ +final _that = this; +switch (_that) { +case _OrderDetailLoaderState(): +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( _OrderDetailLoaderState value)? $default,){ +final _that = this; +switch (_that) { +case _OrderDetailLoaderState() 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( Option detailOption, Option failureOption, bool isFetching)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _OrderDetailLoaderState() when $default != null: +return $default(_that.detailOption,_that.failureOption,_that.isFetching);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( Option detailOption, Option failureOption, bool isFetching) $default,) {final _that = this; +switch (_that) { +case _OrderDetailLoaderState(): +return $default(_that.detailOption,_that.failureOption,_that.isFetching);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( Option detailOption, Option failureOption, bool isFetching)? $default,) {final _that = this; +switch (_that) { +case _OrderDetailLoaderState() when $default != null: +return $default(_that.detailOption,_that.failureOption,_that.isFetching);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _OrderDetailLoaderState implements OrderDetailLoaderState { + const _OrderDetailLoaderState({required this.detailOption, required this.failureOption, this.isFetching = false}); + + +@override final Option detailOption; +@override final Option failureOption; +@override@JsonKey() final bool isFetching; + +/// Create a copy of OrderDetailLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OrderDetailLoaderStateCopyWith<_OrderDetailLoaderState> get copyWith => __$OrderDetailLoaderStateCopyWithImpl<_OrderDetailLoaderState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OrderDetailLoaderState&&(identical(other.detailOption, detailOption) || other.detailOption == detailOption)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,detailOption,failureOption,isFetching); +} + +@override +String toString() { + return 'OrderDetailLoaderState(detailOption: $detailOption, failureOption: $failureOption, isFetching: $isFetching)'; +} + + +} + +/// @nodoc +abstract mixin class _$OrderDetailLoaderStateCopyWith<$Res> implements $OrderDetailLoaderStateCopyWith<$Res> { + factory _$OrderDetailLoaderStateCopyWith(_OrderDetailLoaderState value, $Res Function(_OrderDetailLoaderState) _then) = __$OrderDetailLoaderStateCopyWithImpl; +@override @useResult +$Res call({ + Option detailOption, Option failureOption, bool isFetching +}); + + + + +} +/// @nodoc +class __$OrderDetailLoaderStateCopyWithImpl<$Res> + implements _$OrderDetailLoaderStateCopyWith<$Res> { + __$OrderDetailLoaderStateCopyWithImpl(this._self, this._then); + + final _OrderDetailLoaderState _self; + final $Res Function(_OrderDetailLoaderState) _then; + +/// Create a copy of OrderDetailLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? detailOption = null,Object? failureOption = null,Object? isFetching = null,}) { + return _then(_OrderDetailLoaderState( +detailOption: null == detailOption ? _self.detailOption : detailOption // ignore: cast_nullable_to_non_nullable +as Option,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/order/order_detail_loader/order_detail_loader_event.dart b/lib/application/order/order_detail_loader/order_detail_loader_event.dart new file mode 100644 index 0000000..15a5d4a --- /dev/null +++ b/lib/application/order/order_detail_loader/order_detail_loader_event.dart @@ -0,0 +1,6 @@ +part of 'order_detail_loader_bloc.dart'; + +@freezed +abstract class OrderDetailLoaderEvent with _$OrderDetailLoaderEvent { + const factory OrderDetailLoaderEvent.fetched(String orderId) = _Fetched; +} diff --git a/lib/application/order/order_detail_loader/order_detail_loader_state.dart b/lib/application/order/order_detail_loader/order_detail_loader_state.dart new file mode 100644 index 0000000..d3d1387 --- /dev/null +++ b/lib/application/order/order_detail_loader/order_detail_loader_state.dart @@ -0,0 +1,13 @@ +part of 'order_detail_loader_bloc.dart'; + +@freezed +abstract class OrderDetailLoaderState with _$OrderDetailLoaderState { + const factory OrderDetailLoaderState({ + required Option detailOption, + required Option failureOption, + @Default(false) bool isFetching, + }) = _OrderDetailLoaderState; + + factory OrderDetailLoaderState.initial() => + OrderDetailLoaderState(detailOption: none(), failureOption: none()); +} diff --git a/lib/application/order/order_loader/order_loader_bloc.dart b/lib/application/order/order_loader/order_loader_bloc.dart new file mode 100644 index 0000000..b221997 --- /dev/null +++ b/lib/application/order/order_loader/order_loader_bloc.dart @@ -0,0 +1,70 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'order_loader_event.dart'; +part 'order_loader_state.dart'; +part 'order_loader_bloc.freezed.dart'; + +@injectable +class OrderLoaderBloc extends Bloc { + final IOrderRepository _repository; + + static const int _limit = 20; + + OrderLoaderBloc(this._repository) : super(OrderLoaderState.initial()) { + on(_onOrderLoaderEvent); + } + + Future _onOrderLoaderEvent( + OrderLoaderEvent event, + Emitter emit, + ) { + return event.map( + refreshed: (e) async { + emit(state.copyWith(isFetching: true, failureOption: none())); + + final result = await _repository.getOrders(page: 1, limit: _limit); + + emit( + result + .fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (page) => state.copyWith( + items: page.items, + page: page.page, + totalPages: page.totalPages, + hasLoaded: true, + ), + ) + .copyWith(isFetching: false), + ); + }, + loadedMore: (e) async { + if (state.isFetching || state.isLoadingMore || !state.hasMore) return; + emit(state.copyWith(isLoadingMore: true, failureOption: none())); + + final result = await _repository.getOrders( + page: state.page + 1, + limit: _limit, + ); + + emit( + result + .fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (page) => state.copyWith( + items: [...state.items, ...page.items], + page: page.page, + totalPages: page.totalPages, + ), + ) + .copyWith(isLoadingMore: false), + ); + }, + ); + } +} diff --git a/lib/application/order/order_loader/order_loader_bloc.freezed.dart b/lib/application/order/order_loader/order_loader_bloc.freezed.dart new file mode 100644 index 0000000..bf6a5cf --- /dev/null +++ b/lib/application/order/order_loader/order_loader_bloc.freezed.dart @@ -0,0 +1,533 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'order_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$OrderLoaderEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is OrderLoaderEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'OrderLoaderEvent()'; +} + + +} + +/// @nodoc +class $OrderLoaderEventCopyWith<$Res> { +$OrderLoaderEventCopyWith(OrderLoaderEvent _, $Res Function(OrderLoaderEvent) __); +} + + +/// Adds pattern-matching-related methods to [OrderLoaderEvent]. +extension OrderLoaderEventPatterns on OrderLoaderEvent { +/// 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( _Refreshed value)? refreshed,TResult Function( _LoadedMore value)? loadedMore,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Refreshed() when refreshed != null: +return refreshed(_that);case _LoadedMore() when loadedMore != null: +return loadedMore(_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({required TResult Function( _Refreshed value) refreshed,required TResult Function( _LoadedMore value) loadedMore,}){ +final _that = this; +switch (_that) { +case _Refreshed(): +return refreshed(_that);case _LoadedMore(): +return loadedMore(_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( _Refreshed value)? refreshed,TResult? Function( _LoadedMore value)? loadedMore,}){ +final _that = this; +switch (_that) { +case _Refreshed() when refreshed != null: +return refreshed(_that);case _LoadedMore() when loadedMore != null: +return loadedMore(_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()? refreshed,TResult Function()? loadedMore,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Refreshed() when refreshed != null: +return refreshed();case _LoadedMore() when loadedMore != null: +return loadedMore();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({required TResult Function() refreshed,required TResult Function() loadedMore,}) {final _that = this; +switch (_that) { +case _Refreshed(): +return refreshed();case _LoadedMore(): +return loadedMore();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()? refreshed,TResult? Function()? loadedMore,}) {final _that = this; +switch (_that) { +case _Refreshed() when refreshed != null: +return refreshed();case _LoadedMore() when loadedMore != null: +return loadedMore();case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Refreshed implements OrderLoaderEvent { + const _Refreshed(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Refreshed); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'OrderLoaderEvent.refreshed()'; +} + + +} + + + + +/// @nodoc + + +class _LoadedMore implements OrderLoaderEvent { + const _LoadedMore(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoadedMore); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'OrderLoaderEvent.loadedMore()'; +} + + +} + + + + +/// @nodoc +mixin _$OrderLoaderState { + + List get items; int get page; int get totalPages; Option get failureOption; bool get isFetching; bool get isLoadingMore; bool get hasLoaded; +/// Create a copy of OrderLoaderState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OrderLoaderStateCopyWith get copyWith => _$OrderLoaderStateCopyWithImpl(this as OrderLoaderState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as OrderLoaderState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is OrderLoaderState&&const DeepCollectionEquality().equals(other.items, _this.items)&&(identical(other.page, _this.page) || other.page == _this.page)&&(identical(other.totalPages, _this.totalPages) || other.totalPages == _this.totalPages)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)&&(identical(other.isLoadingMore, _this.isLoadingMore) || other.isLoadingMore == _this.isLoadingMore)&&(identical(other.hasLoaded, _this.hasLoaded) || other.hasLoaded == _this.hasLoaded)); +} + + +@override +int get hashCode { + final _this = this as OrderLoaderState; + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_this.items),_this.page,_this.totalPages,_this.failureOption,_this.isFetching,_this.isLoadingMore,_this.hasLoaded); +} + +@override +String toString() { + final _this = this as OrderLoaderState; + return 'OrderLoaderState(items: ${_this.items}, page: ${_this.page}, totalPages: ${_this.totalPages}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching}, isLoadingMore: ${_this.isLoadingMore}, hasLoaded: ${_this.hasLoaded})'; +} + + +} + +/// @nodoc +abstract mixin class $OrderLoaderStateCopyWith<$Res> { + factory $OrderLoaderStateCopyWith(OrderLoaderState value, $Res Function(OrderLoaderState) _then) = _$OrderLoaderStateCopyWithImpl; +@useResult +$Res call({ + List items, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded +}); + + + + +} +/// @nodoc +class _$OrderLoaderStateCopyWithImpl<$Res> + implements $OrderLoaderStateCopyWith<$Res> { + _$OrderLoaderStateCopyWithImpl(this._self, this._then); + + final OrderLoaderState _self; + final $Res Function(OrderLoaderState) _then; + +/// Create a copy of OrderLoaderState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? page = null,Object? totalPages = null,Object? failureOption = null,Object? isFetching = null,Object? isLoadingMore = null,Object? hasLoaded = null,}) { + return _then(OrderLoaderState( +items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [OrderLoaderState]. +extension OrderLoaderStatePatterns on OrderLoaderState { +/// 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( _OrderLoaderState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _OrderLoaderState() 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( _OrderLoaderState value) $default,){ +final _that = this; +switch (_that) { +case _OrderLoaderState(): +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( _OrderLoaderState value)? $default,){ +final _that = this; +switch (_that) { +case _OrderLoaderState() 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, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _OrderLoaderState() when $default != null: +return $default(_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_that.isLoadingMore,_that.hasLoaded);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, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded) $default,) {final _that = this; +switch (_that) { +case _OrderLoaderState(): +return $default(_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_that.isLoadingMore,_that.hasLoaded);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, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded)? $default,) {final _that = this; +switch (_that) { +case _OrderLoaderState() when $default != null: +return $default(_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_that.isLoadingMore,_that.hasLoaded);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _OrderLoaderState extends OrderLoaderState { + const _OrderLoaderState({required List items, required this.page, required this.totalPages, required this.failureOption, this.isFetching = false, this.isLoadingMore = false, this.hasLoaded = false}): _items = items,super._(); + + + final List _items; +@override List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); +} + +@override final int page; +@override final int totalPages; +@override final Option failureOption; +@override@JsonKey() final bool isFetching; +@override@JsonKey() final bool isLoadingMore; +@override@JsonKey() final bool hasLoaded; + +/// Create a copy of OrderLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OrderLoaderStateCopyWith<_OrderLoaderState> get copyWith => __$OrderLoaderStateCopyWithImpl<_OrderLoaderState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OrderLoaderState&&const DeepCollectionEquality().equals(other.items, _items)&&(identical(other.page, page) || other.page == page)&&(identical(other.totalPages, totalPages) || other.totalPages == totalPages)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.hasLoaded, hasLoaded) || other.hasLoaded == hasLoaded)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),page,totalPages,failureOption,isFetching,isLoadingMore,hasLoaded); +} + +@override +String toString() { + return 'OrderLoaderState(items: $items, page: $page, totalPages: $totalPages, failureOption: $failureOption, isFetching: $isFetching, isLoadingMore: $isLoadingMore, hasLoaded: $hasLoaded)'; +} + + +} + +/// @nodoc +abstract mixin class _$OrderLoaderStateCopyWith<$Res> implements $OrderLoaderStateCopyWith<$Res> { + factory _$OrderLoaderStateCopyWith(_OrderLoaderState value, $Res Function(_OrderLoaderState) _then) = __$OrderLoaderStateCopyWithImpl; +@override @useResult +$Res call({ + List items, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore, bool hasLoaded +}); + + + + +} +/// @nodoc +class __$OrderLoaderStateCopyWithImpl<$Res> + implements _$OrderLoaderStateCopyWith<$Res> { + __$OrderLoaderStateCopyWithImpl(this._self, this._then); + + final _OrderLoaderState _self; + final $Res Function(_OrderLoaderState) _then; + +/// Create a copy of OrderLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? page = null,Object? totalPages = null,Object? failureOption = null,Object? isFetching = null,Object? isLoadingMore = null,Object? hasLoaded = null,}) { + return _then(_OrderLoaderState( +items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/order/order_loader/order_loader_event.dart b/lib/application/order/order_loader/order_loader_event.dart new file mode 100644 index 0000000..0a0dd9d --- /dev/null +++ b/lib/application/order/order_loader/order_loader_event.dart @@ -0,0 +1,9 @@ +part of 'order_loader_bloc.dart'; + +@freezed +abstract class OrderLoaderEvent with _$OrderLoaderEvent { + /// Muat ulang dari halaman pertama. + const factory OrderLoaderEvent.refreshed() = _Refreshed; + + const factory OrderLoaderEvent.loadedMore() = _LoadedMore; +} diff --git a/lib/application/order/order_loader/order_loader_state.dart b/lib/application/order/order_loader/order_loader_state.dart new file mode 100644 index 0000000..d6a6d8f --- /dev/null +++ b/lib/application/order/order_loader/order_loader_state.dart @@ -0,0 +1,25 @@ +part of 'order_loader_bloc.dart'; + +@freezed +abstract class OrderLoaderState with _$OrderLoaderState { + const OrderLoaderState._(); + + const factory OrderLoaderState({ + required List items, + required int page, + required int totalPages, + required Option failureOption, + @Default(false) bool isFetching, + @Default(false) bool isLoadingMore, + @Default(false) bool hasLoaded, + }) = _OrderLoaderState; + + factory OrderLoaderState.initial() => OrderLoaderState( + items: const [], + page: 0, + totalPages: 0, + failureOption: none(), + ); + + bool get hasMore => page < totalPages; +} diff --git a/lib/application/outlet/outlet_loader/outlet_loader_bloc.dart b/lib/application/outlet/outlet_loader/outlet_loader_bloc.dart new file mode 100644 index 0000000..265679a --- /dev/null +++ b/lib/application/outlet/outlet_loader/outlet_loader_bloc.dart @@ -0,0 +1,40 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'outlet_loader_event.dart'; +part 'outlet_loader_state.dart'; +part 'outlet_loader_bloc.freezed.dart'; + +@injectable +class OutletLoaderBloc extends Bloc { + final IOutletRepository _repository; + + OutletLoaderBloc(this._repository) : super(OutletLoaderState.initial()) { + on(_onOutletLoaderEvent); + } + + Future _onOutletLoaderEvent( + OutletLoaderEvent event, + Emitter emit, + ) { + return event.map( + fetched: (e) async { + emit(state.copyWith(isFetching: true, failureOption: none())); + + final result = await _repository.getOutlets(); + + final data = result.fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (outlets) => state.copyWith(outlets: outlets, hasLoaded: true), + ); + + emit(data.copyWith(isFetching: false)); + }, + cleared: (e) async => emit(OutletLoaderState.initial()), + ); + } +} diff --git a/lib/application/outlet/outlet_loader/outlet_loader_bloc.freezed.dart b/lib/application/outlet/outlet_loader/outlet_loader_bloc.freezed.dart new file mode 100644 index 0000000..d58cb98 --- /dev/null +++ b/lib/application/outlet/outlet_loader/outlet_loader_bloc.freezed.dart @@ -0,0 +1,524 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'outlet_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$OutletLoaderEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is OutletLoaderEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'OutletLoaderEvent()'; +} + + +} + +/// @nodoc +class $OutletLoaderEventCopyWith<$Res> { +$OutletLoaderEventCopyWith(OutletLoaderEvent _, $Res Function(OutletLoaderEvent) __); +} + + +/// Adds pattern-matching-related methods to [OutletLoaderEvent]. +extension OutletLoaderEventPatterns on OutletLoaderEvent { +/// 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( _Fetched value)? fetched,TResult Function( _Cleared value)? cleared,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_that);case _Cleared() when cleared != null: +return cleared(_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({required TResult Function( _Fetched value) fetched,required TResult Function( _Cleared value) cleared,}){ +final _that = this; +switch (_that) { +case _Fetched(): +return fetched(_that);case _Cleared(): +return cleared(_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( _Fetched value)? fetched,TResult? Function( _Cleared value)? cleared,}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_that);case _Cleared() when cleared != null: +return cleared(_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()? fetched,TResult Function()? cleared,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();case _Cleared() when cleared != null: +return cleared();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({required TResult Function() fetched,required TResult Function() cleared,}) {final _that = this; +switch (_that) { +case _Fetched(): +return fetched();case _Cleared(): +return cleared();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()? fetched,TResult? Function()? cleared,}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();case _Cleared() when cleared != null: +return cleared();case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Fetched implements OutletLoaderEvent { + const _Fetched(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Fetched); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'OutletLoaderEvent.fetched()'; +} + + +} + + + + +/// @nodoc + + +class _Cleared implements OutletLoaderEvent { + const _Cleared(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Cleared); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'OutletLoaderEvent.cleared()'; +} + + +} + + + + +/// @nodoc +mixin _$OutletLoaderState { + + List get outlets; Option get failureOption; bool get isFetching; bool get hasLoaded; +/// Create a copy of OutletLoaderState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OutletLoaderStateCopyWith get copyWith => _$OutletLoaderStateCopyWithImpl(this as OutletLoaderState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as OutletLoaderState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is OutletLoaderState&&const DeepCollectionEquality().equals(other.outlets, _this.outlets)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)&&(identical(other.hasLoaded, _this.hasLoaded) || other.hasLoaded == _this.hasLoaded)); +} + + +@override +int get hashCode { + final _this = this as OutletLoaderState; + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_this.outlets),_this.failureOption,_this.isFetching,_this.hasLoaded); +} + +@override +String toString() { + final _this = this as OutletLoaderState; + return 'OutletLoaderState(outlets: ${_this.outlets}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching}, hasLoaded: ${_this.hasLoaded})'; +} + + +} + +/// @nodoc +abstract mixin class $OutletLoaderStateCopyWith<$Res> { + factory $OutletLoaderStateCopyWith(OutletLoaderState value, $Res Function(OutletLoaderState) _then) = _$OutletLoaderStateCopyWithImpl; +@useResult +$Res call({ + List outlets, Option failureOption, bool isFetching, bool hasLoaded +}); + + + + +} +/// @nodoc +class _$OutletLoaderStateCopyWithImpl<$Res> + implements $OutletLoaderStateCopyWith<$Res> { + _$OutletLoaderStateCopyWithImpl(this._self, this._then); + + final OutletLoaderState _self; + final $Res Function(OutletLoaderState) _then; + +/// Create a copy of OutletLoaderState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? outlets = null,Object? failureOption = null,Object? isFetching = null,Object? hasLoaded = null,}) { + return _then(OutletLoaderState( +outlets: null == outlets ? _self.outlets : outlets // ignore: cast_nullable_to_non_nullable +as List,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [OutletLoaderState]. +extension OutletLoaderStatePatterns on OutletLoaderState { +/// 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( _OutletLoaderState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _OutletLoaderState() 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( _OutletLoaderState value) $default,){ +final _that = this; +switch (_that) { +case _OutletLoaderState(): +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( _OutletLoaderState value)? $default,){ +final _that = this; +switch (_that) { +case _OutletLoaderState() 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 outlets, Option failureOption, bool isFetching, bool hasLoaded)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _OutletLoaderState() when $default != null: +return $default(_that.outlets,_that.failureOption,_that.isFetching,_that.hasLoaded);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 outlets, Option failureOption, bool isFetching, bool hasLoaded) $default,) {final _that = this; +switch (_that) { +case _OutletLoaderState(): +return $default(_that.outlets,_that.failureOption,_that.isFetching,_that.hasLoaded);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 outlets, Option failureOption, bool isFetching, bool hasLoaded)? $default,) {final _that = this; +switch (_that) { +case _OutletLoaderState() when $default != null: +return $default(_that.outlets,_that.failureOption,_that.isFetching,_that.hasLoaded);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _OutletLoaderState implements OutletLoaderState { + const _OutletLoaderState({required List outlets, required this.failureOption, this.isFetching = false, this.hasLoaded = false}): _outlets = outlets; + + + final List _outlets; +@override List get outlets { + if (_outlets is EqualUnmodifiableListView) return _outlets; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_outlets); +} + +@override final Option failureOption; +@override@JsonKey() final bool isFetching; +@override@JsonKey() final bool hasLoaded; + +/// Create a copy of OutletLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OutletLoaderStateCopyWith<_OutletLoaderState> get copyWith => __$OutletLoaderStateCopyWithImpl<_OutletLoaderState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OutletLoaderState&&const DeepCollectionEquality().equals(other.outlets, _outlets)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)&&(identical(other.hasLoaded, hasLoaded) || other.hasLoaded == hasLoaded)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_outlets),failureOption,isFetching,hasLoaded); +} + +@override +String toString() { + return 'OutletLoaderState(outlets: $outlets, failureOption: $failureOption, isFetching: $isFetching, hasLoaded: $hasLoaded)'; +} + + +} + +/// @nodoc +abstract mixin class _$OutletLoaderStateCopyWith<$Res> implements $OutletLoaderStateCopyWith<$Res> { + factory _$OutletLoaderStateCopyWith(_OutletLoaderState value, $Res Function(_OutletLoaderState) _then) = __$OutletLoaderStateCopyWithImpl; +@override @useResult +$Res call({ + List outlets, Option failureOption, bool isFetching, bool hasLoaded +}); + + + + +} +/// @nodoc +class __$OutletLoaderStateCopyWithImpl<$Res> + implements _$OutletLoaderStateCopyWith<$Res> { + __$OutletLoaderStateCopyWithImpl(this._self, this._then); + + final _OutletLoaderState _self; + final $Res Function(_OutletLoaderState) _then; + +/// Create a copy of OutletLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? outlets = null,Object? failureOption = null,Object? isFetching = null,Object? hasLoaded = null,}) { + return _then(_OutletLoaderState( +outlets: null == outlets ? _self._outlets : outlets // ignore: cast_nullable_to_non_nullable +as List,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/outlet/outlet_loader/outlet_loader_event.dart b/lib/application/outlet/outlet_loader/outlet_loader_event.dart new file mode 100644 index 0000000..760ef53 --- /dev/null +++ b/lib/application/outlet/outlet_loader/outlet_loader_event.dart @@ -0,0 +1,9 @@ +part of 'outlet_loader_bloc.dart'; + +@freezed +abstract class OutletLoaderEvent with _$OutletLoaderEvent { + const factory OutletLoaderEvent.fetched() = _Fetched; + + /// Dipanggil saat logout supaya outlet organisasi akun sebelumnya hilang. + const factory OutletLoaderEvent.cleared() = _Cleared; +} diff --git a/lib/application/outlet/outlet_loader/outlet_loader_state.dart b/lib/application/outlet/outlet_loader/outlet_loader_state.dart new file mode 100644 index 0000000..e6ab2a6 --- /dev/null +++ b/lib/application/outlet/outlet_loader/outlet_loader_state.dart @@ -0,0 +1,14 @@ +part of 'outlet_loader_bloc.dart'; + +@freezed +abstract class OutletLoaderState with _$OutletLoaderState { + const factory OutletLoaderState({ + required List outlets, + required Option failureOption, + @Default(false) bool isFetching, + @Default(false) bool hasLoaded, + }) = _OutletLoaderState; + + factory OutletLoaderState.initial() => + OutletLoaderState(outlets: const [], failureOption: none()); +} diff --git a/lib/application/pin/pin_change_form/pin_change_form_bloc.dart b/lib/application/pin/pin_change_form/pin_change_form_bloc.dart new file mode 100644 index 0000000..ff9f3e7 --- /dev/null +++ b/lib/application/pin/pin_change_form/pin_change_form_bloc.dart @@ -0,0 +1,45 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'pin_change_form_event.dart'; +part 'pin_change_form_state.dart'; +part 'pin_change_form_bloc.freezed.dart'; + +@injectable +class PinChangeFormBloc extends Bloc { + final IPinRepository _repository; + + PinChangeFormBloc(this._repository) : super(PinChangeFormState.initial()) { + on(_onPinChangeFormEvent); + } + + Future _onPinChangeFormEvent( + PinChangeFormEvent event, + Emitter emit, + ) { + return event.map( + submitted: (e) async { + emit( + state.copyWith(isSubmitting: true, failureOrSuccessOption: none()), + ); + + final result = await _repository.change( + oldPin: e.oldPin, + pin: e.pin, + confirmPin: e.confirmPin, + ); + + emit( + state.copyWith( + isSubmitting: false, + failureOrSuccessOption: optionOf(result), + ), + ); + }, + ); + } +} diff --git a/lib/application/pin/pin_change_form/pin_change_form_bloc.freezed.dart b/lib/application/pin/pin_change_form/pin_change_form_bloc.freezed.dart new file mode 100644 index 0000000..f50f1bf --- /dev/null +++ b/lib/application/pin/pin_change_form/pin_change_form_bloc.freezed.dart @@ -0,0 +1,552 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'pin_change_form_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$PinChangeFormEvent { + + String get oldPin; String get pin; String get confirmPin; +/// Create a copy of PinChangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PinChangeFormEventCopyWith get copyWith => _$PinChangeFormEventCopyWithImpl(this as PinChangeFormEvent, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as PinChangeFormEvent; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinChangeFormEvent&&(identical(other.oldPin, _this.oldPin) || other.oldPin == _this.oldPin)&&(identical(other.pin, _this.pin) || other.pin == _this.pin)&&(identical(other.confirmPin, _this.confirmPin) || other.confirmPin == _this.confirmPin)); +} + + +@override +int get hashCode { + final _this = this as PinChangeFormEvent; + return Object.hash(runtimeType,_this.oldPin,_this.pin,_this.confirmPin); +} + +@override +String toString() { + final _this = this as PinChangeFormEvent; + return 'PinChangeFormEvent(oldPin: ${_this.oldPin}, pin: ${_this.pin}, confirmPin: ${_this.confirmPin})'; +} + + +} + +/// @nodoc +abstract mixin class $PinChangeFormEventCopyWith<$Res> { + factory $PinChangeFormEventCopyWith(PinChangeFormEvent value, $Res Function(PinChangeFormEvent) _then) = _$PinChangeFormEventCopyWithImpl; +@useResult +$Res call({ + String oldPin, String pin, String confirmPin +}); + + + + +} +/// @nodoc +class _$PinChangeFormEventCopyWithImpl<$Res> + implements $PinChangeFormEventCopyWith<$Res> { + _$PinChangeFormEventCopyWithImpl(this._self, this._then); + + final PinChangeFormEvent _self; + final $Res Function(PinChangeFormEvent) _then; + +/// Create a copy of PinChangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? oldPin = null,Object? pin = null,Object? confirmPin = null,}) { + return _then(PinChangeFormEvent.submitted( +oldPin: null == oldPin ? _self.oldPin : oldPin // ignore: cast_nullable_to_non_nullable +as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable +as String,confirmPin: null == confirmPin ? _self.confirmPin : confirmPin // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PinChangeFormEvent]. +extension PinChangeFormEventPatterns on PinChangeFormEvent { +/// 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( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _Submitted(): +return submitted(_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( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_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 oldPin, String pin, String confirmPin)? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_that.oldPin,_that.pin,_that.confirmPin);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({required TResult Function( String oldPin, String pin, String confirmPin) submitted,}) {final _that = this; +switch (_that) { +case _Submitted(): +return submitted(_that.oldPin,_that.pin,_that.confirmPin);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 oldPin, String pin, String confirmPin)? submitted,}) {final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_that.oldPin,_that.pin,_that.confirmPin);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Submitted implements PinChangeFormEvent { + const _Submitted({required this.oldPin, required this.pin, required this.confirmPin}); + + +@override final String oldPin; +@override final String pin; +@override final String confirmPin; + +/// Create a copy of PinChangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SubmittedCopyWith<_Submitted> get copyWith => __$SubmittedCopyWithImpl<_Submitted>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted&&(identical(other.oldPin, oldPin) || other.oldPin == oldPin)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.confirmPin, confirmPin) || other.confirmPin == confirmPin)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,oldPin,pin,confirmPin); +} + +@override +String toString() { + return 'PinChangeFormEvent.submitted(oldPin: $oldPin, pin: $pin, confirmPin: $confirmPin)'; +} + + +} + +/// @nodoc +abstract mixin class _$SubmittedCopyWith<$Res> implements $PinChangeFormEventCopyWith<$Res> { + factory _$SubmittedCopyWith(_Submitted value, $Res Function(_Submitted) _then) = __$SubmittedCopyWithImpl; +@override @useResult +$Res call({ + String oldPin, String pin, String confirmPin +}); + + + + +} +/// @nodoc +class __$SubmittedCopyWithImpl<$Res> + implements _$SubmittedCopyWith<$Res> { + __$SubmittedCopyWithImpl(this._self, this._then); + + final _Submitted _self; + final $Res Function(_Submitted) _then; + +/// Create a copy of PinChangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? oldPin = null,Object? pin = null,Object? confirmPin = null,}) { + return _then(_Submitted( +oldPin: null == oldPin ? _self.oldPin : oldPin // ignore: cast_nullable_to_non_nullable +as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable +as String,confirmPin: null == confirmPin ? _self.confirmPin : confirmPin // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$PinChangeFormState { + + bool get isSubmitting; Option> get failureOrSuccessOption; +/// Create a copy of PinChangeFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PinChangeFormStateCopyWith get copyWith => _$PinChangeFormStateCopyWithImpl(this as PinChangeFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as PinChangeFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinChangeFormState&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.failureOrSuccessOption, _this.failureOrSuccessOption) || other.failureOrSuccessOption == _this.failureOrSuccessOption)); +} + + +@override +int get hashCode { + final _this = this as PinChangeFormState; + return Object.hash(runtimeType,_this.isSubmitting,_this.failureOrSuccessOption); +} + +@override +String toString() { + final _this = this as PinChangeFormState; + return 'PinChangeFormState(isSubmitting: ${_this.isSubmitting}, failureOrSuccessOption: ${_this.failureOrSuccessOption})'; +} + + +} + +/// @nodoc +abstract mixin class $PinChangeFormStateCopyWith<$Res> { + factory $PinChangeFormStateCopyWith(PinChangeFormState value, $Res Function(PinChangeFormState) _then) = _$PinChangeFormStateCopyWithImpl; +@useResult +$Res call({ + bool isSubmitting, Option> failureOrSuccessOption +}); + + + + +} +/// @nodoc +class _$PinChangeFormStateCopyWithImpl<$Res> + implements $PinChangeFormStateCopyWith<$Res> { + _$PinChangeFormStateCopyWithImpl(this._self, this._then); + + final PinChangeFormState _self; + final $Res Function(PinChangeFormState) _then; + +/// Create a copy of PinChangeFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? isSubmitting = null,Object? failureOrSuccessOption = null,}) { + return _then(PinChangeFormState( +isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,failureOrSuccessOption: null == failureOrSuccessOption ? _self.failureOrSuccessOption : failureOrSuccessOption // ignore: cast_nullable_to_non_nullable +as Option>, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PinChangeFormState]. +extension PinChangeFormStatePatterns on PinChangeFormState { +/// 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( _PinChangeFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PinChangeFormState() 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( _PinChangeFormState value) $default,){ +final _that = this; +switch (_that) { +case _PinChangeFormState(): +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( _PinChangeFormState value)? $default,){ +final _that = this; +switch (_that) { +case _PinChangeFormState() 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( bool isSubmitting, Option> failureOrSuccessOption)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PinChangeFormState() when $default != null: +return $default(_that.isSubmitting,_that.failureOrSuccessOption);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( bool isSubmitting, Option> failureOrSuccessOption) $default,) {final _that = this; +switch (_that) { +case _PinChangeFormState(): +return $default(_that.isSubmitting,_that.failureOrSuccessOption);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( bool isSubmitting, Option> failureOrSuccessOption)? $default,) {final _that = this; +switch (_that) { +case _PinChangeFormState() when $default != null: +return $default(_that.isSubmitting,_that.failureOrSuccessOption);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _PinChangeFormState implements PinChangeFormState { + const _PinChangeFormState({this.isSubmitting = false, required this.failureOrSuccessOption}); + + +@override@JsonKey() final bool isSubmitting; +@override final Option> failureOrSuccessOption; + +/// Create a copy of PinChangeFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinChangeFormStateCopyWith<_PinChangeFormState> get copyWith => __$PinChangeFormStateCopyWithImpl<_PinChangeFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinChangeFormState&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.failureOrSuccessOption, failureOrSuccessOption) || other.failureOrSuccessOption == failureOrSuccessOption)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,isSubmitting,failureOrSuccessOption); +} + +@override +String toString() { + return 'PinChangeFormState(isSubmitting: $isSubmitting, failureOrSuccessOption: $failureOrSuccessOption)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinChangeFormStateCopyWith<$Res> implements $PinChangeFormStateCopyWith<$Res> { + factory _$PinChangeFormStateCopyWith(_PinChangeFormState value, $Res Function(_PinChangeFormState) _then) = __$PinChangeFormStateCopyWithImpl; +@override @useResult +$Res call({ + bool isSubmitting, Option> failureOrSuccessOption +}); + + + + +} +/// @nodoc +class __$PinChangeFormStateCopyWithImpl<$Res> + implements _$PinChangeFormStateCopyWith<$Res> { + __$PinChangeFormStateCopyWithImpl(this._self, this._then); + + final _PinChangeFormState _self; + final $Res Function(_PinChangeFormState) _then; + +/// Create a copy of PinChangeFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? isSubmitting = null,Object? failureOrSuccessOption = null,}) { + return _then(_PinChangeFormState( +isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,failureOrSuccessOption: null == failureOrSuccessOption ? _self.failureOrSuccessOption : failureOrSuccessOption // ignore: cast_nullable_to_non_nullable +as Option>, + )); +} + + +} + +// dart format on diff --git a/lib/application/pin/pin_change_form/pin_change_form_event.dart b/lib/application/pin/pin_change_form/pin_change_form_event.dart new file mode 100644 index 0000000..3800171 --- /dev/null +++ b/lib/application/pin/pin_change_form/pin_change_form_event.dart @@ -0,0 +1,11 @@ +part of 'pin_change_form_bloc.dart'; + +@freezed +abstract class PinChangeFormEvent with _$PinChangeFormEvent { + /// PIN hanya diteruskan ke API, tidak disimpan di state. + const factory PinChangeFormEvent.submitted({ + required String oldPin, + required String pin, + required String confirmPin, + }) = _Submitted; +} diff --git a/lib/application/pin/pin_change_form/pin_change_form_state.dart b/lib/application/pin/pin_change_form/pin_change_form_state.dart new file mode 100644 index 0000000..d14b289 --- /dev/null +++ b/lib/application/pin/pin_change_form/pin_change_form_state.dart @@ -0,0 +1,12 @@ +part of 'pin_change_form_bloc.dart'; + +@freezed +abstract class PinChangeFormState with _$PinChangeFormState { + const factory PinChangeFormState({ + @Default(false) bool isSubmitting, + required Option> failureOrSuccessOption, + }) = _PinChangeFormState; + + factory PinChangeFormState.initial() => + PinChangeFormState(failureOrSuccessOption: none()); +} diff --git a/lib/application/pin/pin_setup_form/pin_setup_form_bloc.dart b/lib/application/pin/pin_setup_form/pin_setup_form_bloc.dart new file mode 100644 index 0000000..28e2c44 --- /dev/null +++ b/lib/application/pin/pin_setup_form/pin_setup_form_bloc.dart @@ -0,0 +1,86 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'pin_setup_form_event.dart'; +part 'pin_setup_form_state.dart'; +part 'pin_setup_form_bloc.freezed.dart'; + +/// Alur buat PIN (`pin_setup`) dan lupa PIN (`pin_reset`) lewat OTP WhatsApp. +@injectable +class PinSetupFormBloc extends Bloc { + final IPinRepository _repository; + + PinSetupFormBloc(this._repository) : super(PinSetupFormState.initial()) { + on(_onPinSetupFormEvent); + } + + Future _onPinSetupFormEvent( + PinSetupFormEvent event, + Emitter emit, + ) { + return event.map( + otpRequested: (e) async { + emit( + state.copyWith( + purpose: e.purpose, + isRequestingOtp: true, + otpFailureOption: none(), + ), + ); + + final result = await _repository.requestOtp(e.purpose); + + emit( + result + .fold( + (f) => state.copyWith( + otpFailureOption: optionOf(f), + resendAvailableAt: f.maybeMap( + tooManyRequests: (value) => DateTime.now().add( + Duration(seconds: value.retryAfterSeconds), + ), + orElse: () => state.resendAvailableAt, + ), + ), + (otp) => state.copyWith(otp: otp), + ) + .copyWith(isRequestingOtp: false), + ); + }, + submitted: (e) async { + final otp = state.otp; + if (otp == null) return; + + emit( + state.copyWith(isSubmitting: true, failureOrSuccessOption: none()), + ); + + final Either result = + state.purpose == PinOtpPurpose.setup + ? (await _repository.setup( + otpToken: otp.otpToken, + otpCode: e.otpCode, + pin: e.pin, + confirmPin: e.confirmPin, + )).map((_) => unit) + : await _repository.reset( + otpToken: otp.otpToken, + otpCode: e.otpCode, + pin: e.pin, + confirmPin: e.confirmPin, + ); + + emit( + state.copyWith( + isSubmitting: false, + failureOrSuccessOption: optionOf(result), + ), + ); + }, + ); + } +} diff --git a/lib/application/pin/pin_setup_form/pin_setup_form_bloc.freezed.dart b/lib/application/pin/pin_setup_form/pin_setup_form_bloc.freezed.dart new file mode 100644 index 0000000..4b1b472 --- /dev/null +++ b/lib/application/pin/pin_setup_form/pin_setup_form_bloc.freezed.dart @@ -0,0 +1,631 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'pin_setup_form_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$PinSetupFormEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinSetupFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'PinSetupFormEvent()'; +} + + +} + +/// @nodoc +class $PinSetupFormEventCopyWith<$Res> { +$PinSetupFormEventCopyWith(PinSetupFormEvent _, $Res Function(PinSetupFormEvent) __); +} + + +/// Adds pattern-matching-related methods to [PinSetupFormEvent]. +extension PinSetupFormEventPatterns on PinSetupFormEvent { +/// 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( _OtpRequested value)? otpRequested,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _OtpRequested() when otpRequested != null: +return otpRequested(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _OtpRequested value) otpRequested,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _OtpRequested(): +return otpRequested(_that);case _Submitted(): +return submitted(_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( _OtpRequested value)? otpRequested,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _OtpRequested() when otpRequested != null: +return otpRequested(_that);case _Submitted() when submitted != null: +return submitted(_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( PinOtpPurpose purpose)? otpRequested,TResult Function( String otpCode, String pin, String confirmPin)? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _OtpRequested() when otpRequested != null: +return otpRequested(_that.purpose);case _Submitted() when submitted != null: +return submitted(_that.otpCode,_that.pin,_that.confirmPin);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({required TResult Function( PinOtpPurpose purpose) otpRequested,required TResult Function( String otpCode, String pin, String confirmPin) submitted,}) {final _that = this; +switch (_that) { +case _OtpRequested(): +return otpRequested(_that.purpose);case _Submitted(): +return submitted(_that.otpCode,_that.pin,_that.confirmPin);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( PinOtpPurpose purpose)? otpRequested,TResult? Function( String otpCode, String pin, String confirmPin)? submitted,}) {final _that = this; +switch (_that) { +case _OtpRequested() when otpRequested != null: +return otpRequested(_that.purpose);case _Submitted() when submitted != null: +return submitted(_that.otpCode,_that.pin,_that.confirmPin);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _OtpRequested implements PinSetupFormEvent { + const _OtpRequested(this.purpose); + + + final PinOtpPurpose purpose; + +/// Create a copy of PinSetupFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OtpRequestedCopyWith<_OtpRequested> get copyWith => __$OtpRequestedCopyWithImpl<_OtpRequested>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OtpRequested&&(identical(other.purpose, purpose) || other.purpose == purpose)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,purpose); +} + +@override +String toString() { + return 'PinSetupFormEvent.otpRequested(purpose: $purpose)'; +} + + +} + +/// @nodoc +abstract mixin class _$OtpRequestedCopyWith<$Res> implements $PinSetupFormEventCopyWith<$Res> { + factory _$OtpRequestedCopyWith(_OtpRequested value, $Res Function(_OtpRequested) _then) = __$OtpRequestedCopyWithImpl; +@useResult +$Res call({ + PinOtpPurpose purpose +}); + + + + +} +/// @nodoc +class __$OtpRequestedCopyWithImpl<$Res> + implements _$OtpRequestedCopyWith<$Res> { + __$OtpRequestedCopyWithImpl(this._self, this._then); + + final _OtpRequested _self; + final $Res Function(_OtpRequested) _then; + +/// Create a copy of PinSetupFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? purpose = null,}) { + return _then(_OtpRequested( +null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as PinOtpPurpose, + )); +} + + +} + +/// @nodoc + + +class _Submitted implements PinSetupFormEvent { + const _Submitted({required this.otpCode, required this.pin, required this.confirmPin}); + + + final String otpCode; + final String pin; + final String confirmPin; + +/// Create a copy of PinSetupFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SubmittedCopyWith<_Submitted> get copyWith => __$SubmittedCopyWithImpl<_Submitted>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted&&(identical(other.otpCode, otpCode) || other.otpCode == otpCode)&&(identical(other.pin, pin) || other.pin == pin)&&(identical(other.confirmPin, confirmPin) || other.confirmPin == confirmPin)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,otpCode,pin,confirmPin); +} + +@override +String toString() { + return 'PinSetupFormEvent.submitted(otpCode: $otpCode, pin: $pin, confirmPin: $confirmPin)'; +} + + +} + +/// @nodoc +abstract mixin class _$SubmittedCopyWith<$Res> implements $PinSetupFormEventCopyWith<$Res> { + factory _$SubmittedCopyWith(_Submitted value, $Res Function(_Submitted) _then) = __$SubmittedCopyWithImpl; +@useResult +$Res call({ + String otpCode, String pin, String confirmPin +}); + + + + +} +/// @nodoc +class __$SubmittedCopyWithImpl<$Res> + implements _$SubmittedCopyWith<$Res> { + __$SubmittedCopyWithImpl(this._self, this._then); + + final _Submitted _self; + final $Res Function(_Submitted) _then; + +/// Create a copy of PinSetupFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? otpCode = null,Object? pin = null,Object? confirmPin = null,}) { + return _then(_Submitted( +otpCode: null == otpCode ? _self.otpCode : otpCode // ignore: cast_nullable_to_non_nullable +as String,pin: null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable +as String,confirmPin: null == confirmPin ? _self.confirmPin : confirmPin // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$PinSetupFormState { + + PinOtpPurpose get purpose; PinOtp? get otp; bool get isRequestingOtp; Option get otpFailureOption;/// Diisi saat server menjawab `429`; tombol kirim ulang menunggu sampai +/// waktu ini. + DateTime? get resendAvailableAt; bool get isSubmitting; Option> get failureOrSuccessOption; +/// Create a copy of PinSetupFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PinSetupFormStateCopyWith get copyWith => _$PinSetupFormStateCopyWithImpl(this as PinSetupFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as PinSetupFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinSetupFormState&&(identical(other.purpose, _this.purpose) || other.purpose == _this.purpose)&&(identical(other.otp, _this.otp) || other.otp == _this.otp)&&(identical(other.isRequestingOtp, _this.isRequestingOtp) || other.isRequestingOtp == _this.isRequestingOtp)&&(identical(other.otpFailureOption, _this.otpFailureOption) || other.otpFailureOption == _this.otpFailureOption)&&(identical(other.resendAvailableAt, _this.resendAvailableAt) || other.resendAvailableAt == _this.resendAvailableAt)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.failureOrSuccessOption, _this.failureOrSuccessOption) || other.failureOrSuccessOption == _this.failureOrSuccessOption)); +} + + +@override +int get hashCode { + final _this = this as PinSetupFormState; + return Object.hash(runtimeType,_this.purpose,_this.otp,_this.isRequestingOtp,_this.otpFailureOption,_this.resendAvailableAt,_this.isSubmitting,_this.failureOrSuccessOption); +} + +@override +String toString() { + final _this = this as PinSetupFormState; + return 'PinSetupFormState(purpose: ${_this.purpose}, otp: ${_this.otp}, isRequestingOtp: ${_this.isRequestingOtp}, otpFailureOption: ${_this.otpFailureOption}, resendAvailableAt: ${_this.resendAvailableAt}, isSubmitting: ${_this.isSubmitting}, failureOrSuccessOption: ${_this.failureOrSuccessOption})'; +} + + +} + +/// @nodoc +abstract mixin class $PinSetupFormStateCopyWith<$Res> { + factory $PinSetupFormStateCopyWith(PinSetupFormState value, $Res Function(PinSetupFormState) _then) = _$PinSetupFormStateCopyWithImpl; +@useResult +$Res call({ + PinOtpPurpose purpose, PinOtp? otp, bool isRequestingOtp, Option otpFailureOption, DateTime? resendAvailableAt, bool isSubmitting, Option> failureOrSuccessOption +}); + + +$PinOtpCopyWith<$Res>? get otp; + +} +/// @nodoc +class _$PinSetupFormStateCopyWithImpl<$Res> + implements $PinSetupFormStateCopyWith<$Res> { + _$PinSetupFormStateCopyWithImpl(this._self, this._then); + + final PinSetupFormState _self; + final $Res Function(PinSetupFormState) _then; + +/// Create a copy of PinSetupFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? purpose = null,Object? otp = freezed,Object? isRequestingOtp = null,Object? otpFailureOption = null,Object? resendAvailableAt = freezed,Object? isSubmitting = null,Object? failureOrSuccessOption = null,}) { + return _then(PinSetupFormState( +purpose: null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as PinOtpPurpose,otp: freezed == otp ? _self.otp : otp // ignore: cast_nullable_to_non_nullable +as PinOtp?,isRequestingOtp: null == isRequestingOtp ? _self.isRequestingOtp : isRequestingOtp // ignore: cast_nullable_to_non_nullable +as bool,otpFailureOption: null == otpFailureOption ? _self.otpFailureOption : otpFailureOption // ignore: cast_nullable_to_non_nullable +as Option,resendAvailableAt: freezed == resendAvailableAt ? _self.resendAvailableAt : resendAvailableAt // ignore: cast_nullable_to_non_nullable +as DateTime?,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,failureOrSuccessOption: null == failureOrSuccessOption ? _self.failureOrSuccessOption : failureOrSuccessOption // ignore: cast_nullable_to_non_nullable +as Option>, + )); +} +/// Create a copy of PinSetupFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PinOtpCopyWith<$Res>? get otp { + if (_self.otp == null) { + return null; + } + + return $PinOtpCopyWith<$Res>(_self.otp!, (value) { + return _then(_self.copyWith(otp: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [PinSetupFormState]. +extension PinSetupFormStatePatterns on PinSetupFormState { +/// 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( _PinSetupFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PinSetupFormState() 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( _PinSetupFormState value) $default,){ +final _that = this; +switch (_that) { +case _PinSetupFormState(): +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( _PinSetupFormState value)? $default,){ +final _that = this; +switch (_that) { +case _PinSetupFormState() 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( PinOtpPurpose purpose, PinOtp? otp, bool isRequestingOtp, Option otpFailureOption, DateTime? resendAvailableAt, bool isSubmitting, Option> failureOrSuccessOption)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PinSetupFormState() when $default != null: +return $default(_that.purpose,_that.otp,_that.isRequestingOtp,_that.otpFailureOption,_that.resendAvailableAt,_that.isSubmitting,_that.failureOrSuccessOption);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( PinOtpPurpose purpose, PinOtp? otp, bool isRequestingOtp, Option otpFailureOption, DateTime? resendAvailableAt, bool isSubmitting, Option> failureOrSuccessOption) $default,) {final _that = this; +switch (_that) { +case _PinSetupFormState(): +return $default(_that.purpose,_that.otp,_that.isRequestingOtp,_that.otpFailureOption,_that.resendAvailableAt,_that.isSubmitting,_that.failureOrSuccessOption);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( PinOtpPurpose purpose, PinOtp? otp, bool isRequestingOtp, Option otpFailureOption, DateTime? resendAvailableAt, bool isSubmitting, Option> failureOrSuccessOption)? $default,) {final _that = this; +switch (_that) { +case _PinSetupFormState() when $default != null: +return $default(_that.purpose,_that.otp,_that.isRequestingOtp,_that.otpFailureOption,_that.resendAvailableAt,_that.isSubmitting,_that.failureOrSuccessOption);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _PinSetupFormState implements PinSetupFormState { + const _PinSetupFormState({required this.purpose, this.otp, this.isRequestingOtp = false, required this.otpFailureOption, this.resendAvailableAt, this.isSubmitting = false, required this.failureOrSuccessOption}); + + +@override final PinOtpPurpose purpose; +@override final PinOtp? otp; +@override@JsonKey() final bool isRequestingOtp; +@override final Option otpFailureOption; +/// Diisi saat server menjawab `429`; tombol kirim ulang menunggu sampai +/// waktu ini. +@override final DateTime? resendAvailableAt; +@override@JsonKey() final bool isSubmitting; +@override final Option> failureOrSuccessOption; + +/// Create a copy of PinSetupFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinSetupFormStateCopyWith<_PinSetupFormState> get copyWith => __$PinSetupFormStateCopyWithImpl<_PinSetupFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinSetupFormState&&(identical(other.purpose, purpose) || other.purpose == purpose)&&(identical(other.otp, otp) || other.otp == otp)&&(identical(other.isRequestingOtp, isRequestingOtp) || other.isRequestingOtp == isRequestingOtp)&&(identical(other.otpFailureOption, otpFailureOption) || other.otpFailureOption == otpFailureOption)&&(identical(other.resendAvailableAt, resendAvailableAt) || other.resendAvailableAt == resendAvailableAt)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.failureOrSuccessOption, failureOrSuccessOption) || other.failureOrSuccessOption == failureOrSuccessOption)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,purpose,otp,isRequestingOtp,otpFailureOption,resendAvailableAt,isSubmitting,failureOrSuccessOption); +} + +@override +String toString() { + return 'PinSetupFormState(purpose: $purpose, otp: $otp, isRequestingOtp: $isRequestingOtp, otpFailureOption: $otpFailureOption, resendAvailableAt: $resendAvailableAt, isSubmitting: $isSubmitting, failureOrSuccessOption: $failureOrSuccessOption)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinSetupFormStateCopyWith<$Res> implements $PinSetupFormStateCopyWith<$Res> { + factory _$PinSetupFormStateCopyWith(_PinSetupFormState value, $Res Function(_PinSetupFormState) _then) = __$PinSetupFormStateCopyWithImpl; +@override @useResult +$Res call({ + PinOtpPurpose purpose, PinOtp? otp, bool isRequestingOtp, Option otpFailureOption, DateTime? resendAvailableAt, bool isSubmitting, Option> failureOrSuccessOption +}); + + +@override $PinOtpCopyWith<$Res>? get otp; + +} +/// @nodoc +class __$PinSetupFormStateCopyWithImpl<$Res> + implements _$PinSetupFormStateCopyWith<$Res> { + __$PinSetupFormStateCopyWithImpl(this._self, this._then); + + final _PinSetupFormState _self; + final $Res Function(_PinSetupFormState) _then; + +/// Create a copy of PinSetupFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? purpose = null,Object? otp = freezed,Object? isRequestingOtp = null,Object? otpFailureOption = null,Object? resendAvailableAt = freezed,Object? isSubmitting = null,Object? failureOrSuccessOption = null,}) { + return _then(_PinSetupFormState( +purpose: null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as PinOtpPurpose,otp: freezed == otp ? _self.otp : otp // ignore: cast_nullable_to_non_nullable +as PinOtp?,isRequestingOtp: null == isRequestingOtp ? _self.isRequestingOtp : isRequestingOtp // ignore: cast_nullable_to_non_nullable +as bool,otpFailureOption: null == otpFailureOption ? _self.otpFailureOption : otpFailureOption // ignore: cast_nullable_to_non_nullable +as Option,resendAvailableAt: freezed == resendAvailableAt ? _self.resendAvailableAt : resendAvailableAt // ignore: cast_nullable_to_non_nullable +as DateTime?,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,failureOrSuccessOption: null == failureOrSuccessOption ? _self.failureOrSuccessOption : failureOrSuccessOption // ignore: cast_nullable_to_non_nullable +as Option>, + )); +} + +/// Create a copy of PinSetupFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PinOtpCopyWith<$Res>? get otp { + if (_self.otp == null) { + return null; + } + + return $PinOtpCopyWith<$Res>(_self.otp!, (value) { + return _then(_self.copyWith(otp: value)); + }); +} +} + +// dart format on diff --git a/lib/application/pin/pin_setup_form/pin_setup_form_event.dart b/lib/application/pin/pin_setup_form/pin_setup_form_event.dart new file mode 100644 index 0000000..3053bf0 --- /dev/null +++ b/lib/application/pin/pin_setup_form/pin_setup_form_event.dart @@ -0,0 +1,14 @@ +part of 'pin_setup_form_bloc.dart'; + +@freezed +abstract class PinSetupFormEvent with _$PinSetupFormEvent { + const factory PinSetupFormEvent.otpRequested(PinOtpPurpose purpose) = + _OtpRequested; + + /// PIN hanya diteruskan ke API, tidak disimpan di state. + const factory PinSetupFormEvent.submitted({ + required String otpCode, + required String pin, + required String confirmPin, + }) = _Submitted; +} diff --git a/lib/application/pin/pin_setup_form/pin_setup_form_state.dart b/lib/application/pin/pin_setup_form/pin_setup_form_state.dart new file mode 100644 index 0000000..2fb5903 --- /dev/null +++ b/lib/application/pin/pin_setup_form/pin_setup_form_state.dart @@ -0,0 +1,23 @@ +part of 'pin_setup_form_bloc.dart'; + +@freezed +abstract class PinSetupFormState with _$PinSetupFormState { + const factory PinSetupFormState({ + required PinOtpPurpose purpose, + PinOtp? otp, + @Default(false) bool isRequestingOtp, + required Option otpFailureOption, + + /// Diisi saat server menjawab `429`; tombol kirim ulang menunggu sampai + /// waktu ini. + DateTime? resendAvailableAt, + @Default(false) bool isSubmitting, + required Option> failureOrSuccessOption, + }) = _PinSetupFormState; + + factory PinSetupFormState.initial() => PinSetupFormState( + purpose: PinOtpPurpose.setup, + otpFailureOption: none(), + failureOrSuccessOption: none(), + ); +} diff --git a/lib/application/wallet/exchange_form/exchange_form_bloc.dart b/lib/application/wallet/exchange_form/exchange_form_bloc.dart new file mode 100644 index 0000000..a5fcf67 --- /dev/null +++ b/lib/application/wallet/exchange_form/exchange_form_bloc.dart @@ -0,0 +1,87 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/function/app_function.dart'; +import '../../../domain/wallet/wallet.dart'; + +part 'exchange_form_event.dart'; +part 'exchange_form_state.dart'; +part 'exchange_form_bloc.freezed.dart'; + +@injectable +class ExchangeFormBloc extends Bloc { + final IWalletRepository _repository; + + ExchangeFormBloc(this._repository) : super(ExchangeFormState.initial()) { + on(_onExchangeFormEvent); + } + + Future _onExchangeFormEvent( + ExchangeFormEvent event, + Emitter emit, + ) { + return event.map( + // UI men-debounce ketikan sebelum mengirim event ini. + coinsChanged: (e) async { + emit( + state.copyWith( + coins: e.coins, + preview: null, + previewFailureOption: none(), + idempotencyKey: null, + isPreviewing: e.coins > 0, + ), + ); + if (e.coins <= 0) return; + + final result = await _repository.previewExchange(coins: e.coins); + // Customer sudah mengetik angka lain. + if (state.coins != e.coins) return; + + emit( + result + .fold( + (f) => state.copyWith(previewFailureOption: optionOf(f)), + (preview) => state.copyWith(preview: preview), + ) + .copyWith(isPreviewing: false), + ); + }, + submitted: (e) async { + // Key baru untuk setiap konfirmasi, kecuali mengulang request yang + // sebelumnya gagal karena jaringan. + final key = state.idempotencyKey ?? generateUuidV4(); + emit( + state.copyWith( + isSubmitting: true, + idempotencyKey: key, + failureOption: none(), + ), + ); + + final result = await _repository.exchange( + coins: state.coins, + pin: e.pin, + idempotencyKey: key, + ); + + emit( + result + .fold( + (f) => state.copyWith( + failureOption: optionOf(f), + idempotencyKey: f.isNetworkError ? key : null, + ), + (exchangeResult) => state.copyWith( + result: exchangeResult, + idempotencyKey: null, + ), + ) + .copyWith(isSubmitting: false), + ); + }, + ); + } +} diff --git a/lib/application/wallet/exchange_form/exchange_form_bloc.freezed.dart b/lib/application/wallet/exchange_form/exchange_form_bloc.freezed.dart new file mode 100644 index 0000000..4c3a984 --- /dev/null +++ b/lib/application/wallet/exchange_form/exchange_form_bloc.freezed.dart @@ -0,0 +1,650 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'exchange_form_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$ExchangeFormEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExchangeFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'ExchangeFormEvent()'; +} + + +} + +/// @nodoc +class $ExchangeFormEventCopyWith<$Res> { +$ExchangeFormEventCopyWith(ExchangeFormEvent _, $Res Function(ExchangeFormEvent) __); +} + + +/// Adds pattern-matching-related methods to [ExchangeFormEvent]. +extension ExchangeFormEventPatterns on ExchangeFormEvent { +/// 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( _CoinsChanged value)? coinsChanged,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CoinsChanged() when coinsChanged != null: +return coinsChanged(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _CoinsChanged value) coinsChanged,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _CoinsChanged(): +return coinsChanged(_that);case _Submitted(): +return submitted(_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( _CoinsChanged value)? coinsChanged,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _CoinsChanged() when coinsChanged != null: +return coinsChanged(_that);case _Submitted() when submitted != null: +return submitted(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen({TResult Function( int coins)? coinsChanged,TResult Function( String pin)? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CoinsChanged() when coinsChanged != null: +return coinsChanged(_that.coins);case _Submitted() when submitted != null: +return submitted(_that.pin);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({required TResult Function( int coins) coinsChanged,required TResult Function( String pin) submitted,}) {final _that = this; +switch (_that) { +case _CoinsChanged(): +return coinsChanged(_that.coins);case _Submitted(): +return submitted(_that.pin);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull({TResult? Function( int coins)? coinsChanged,TResult? Function( String pin)? submitted,}) {final _that = this; +switch (_that) { +case _CoinsChanged() when coinsChanged != null: +return coinsChanged(_that.coins);case _Submitted() when submitted != null: +return submitted(_that.pin);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CoinsChanged implements ExchangeFormEvent { + const _CoinsChanged(this.coins); + + + final int coins; + +/// Create a copy of ExchangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CoinsChangedCopyWith<_CoinsChanged> get copyWith => __$CoinsChangedCopyWithImpl<_CoinsChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CoinsChanged&&(identical(other.coins, coins) || other.coins == coins)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,coins); +} + +@override +String toString() { + return 'ExchangeFormEvent.coinsChanged(coins: $coins)'; +} + + +} + +/// @nodoc +abstract mixin class _$CoinsChangedCopyWith<$Res> implements $ExchangeFormEventCopyWith<$Res> { + factory _$CoinsChangedCopyWith(_CoinsChanged value, $Res Function(_CoinsChanged) _then) = __$CoinsChangedCopyWithImpl; +@useResult +$Res call({ + int coins +}); + + + + +} +/// @nodoc +class __$CoinsChangedCopyWithImpl<$Res> + implements _$CoinsChangedCopyWith<$Res> { + __$CoinsChangedCopyWithImpl(this._self, this._then); + + final _CoinsChanged _self; + final $Res Function(_CoinsChanged) _then; + +/// Create a copy of ExchangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? coins = null,}) { + return _then(_CoinsChanged( +null == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class _Submitted implements ExchangeFormEvent { + const _Submitted(this.pin); + + + final String pin; + +/// Create a copy of ExchangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SubmittedCopyWith<_Submitted> get copyWith => __$SubmittedCopyWithImpl<_Submitted>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted&&(identical(other.pin, pin) || other.pin == pin)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,pin); +} + +@override +String toString() { + return 'ExchangeFormEvent.submitted(pin: $pin)'; +} + + +} + +/// @nodoc +abstract mixin class _$SubmittedCopyWith<$Res> implements $ExchangeFormEventCopyWith<$Res> { + factory _$SubmittedCopyWith(_Submitted value, $Res Function(_Submitted) _then) = __$SubmittedCopyWithImpl; +@useResult +$Res call({ + String pin +}); + + + + +} +/// @nodoc +class __$SubmittedCopyWithImpl<$Res> + implements _$SubmittedCopyWith<$Res> { + __$SubmittedCopyWithImpl(this._self, this._then); + + final _Submitted _self; + final $Res Function(_Submitted) _then; + +/// Create a copy of ExchangeFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? pin = null,}) { + return _then(_Submitted( +null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$ExchangeFormState { + + int get coins; ExchangePreview? get preview; Option get previewFailureOption; bool get isPreviewing; ExchangeResult? get result; Option get failureOption; bool get isSubmitting; String? get idempotencyKey; +/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExchangeFormStateCopyWith get copyWith => _$ExchangeFormStateCopyWithImpl(this as ExchangeFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as ExchangeFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExchangeFormState&&(identical(other.coins, _this.coins) || other.coins == _this.coins)&&(identical(other.preview, _this.preview) || other.preview == _this.preview)&&(identical(other.previewFailureOption, _this.previewFailureOption) || other.previewFailureOption == _this.previewFailureOption)&&(identical(other.isPreviewing, _this.isPreviewing) || other.isPreviewing == _this.isPreviewing)&&(identical(other.result, _this.result) || other.result == _this.result)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.idempotencyKey, _this.idempotencyKey) || other.idempotencyKey == _this.idempotencyKey)); +} + + +@override +int get hashCode { + final _this = this as ExchangeFormState; + return Object.hash(runtimeType,_this.coins,_this.preview,_this.previewFailureOption,_this.isPreviewing,_this.result,_this.failureOption,_this.isSubmitting,_this.idempotencyKey); +} + +@override +String toString() { + final _this = this as ExchangeFormState; + return 'ExchangeFormState(coins: ${_this.coins}, preview: ${_this.preview}, previewFailureOption: ${_this.previewFailureOption}, isPreviewing: ${_this.isPreviewing}, result: ${_this.result}, failureOption: ${_this.failureOption}, isSubmitting: ${_this.isSubmitting}, idempotencyKey: ${_this.idempotencyKey})'; +} + + +} + +/// @nodoc +abstract mixin class $ExchangeFormStateCopyWith<$Res> { + factory $ExchangeFormStateCopyWith(ExchangeFormState value, $Res Function(ExchangeFormState) _then) = _$ExchangeFormStateCopyWithImpl; +@useResult +$Res call({ + int coins, ExchangePreview? preview, Option previewFailureOption, bool isPreviewing, ExchangeResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey +}); + + +$ExchangePreviewCopyWith<$Res>? get preview;$ExchangeResultCopyWith<$Res>? get result; + +} +/// @nodoc +class _$ExchangeFormStateCopyWithImpl<$Res> + implements $ExchangeFormStateCopyWith<$Res> { + _$ExchangeFormStateCopyWithImpl(this._self, this._then); + + final ExchangeFormState _self; + final $Res Function(ExchangeFormState) _then; + +/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? coins = null,Object? preview = freezed,Object? previewFailureOption = null,Object? isPreviewing = null,Object? result = freezed,Object? failureOption = null,Object? isSubmitting = null,Object? idempotencyKey = freezed,}) { + return _then(ExchangeFormState( +coins: null == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int,preview: freezed == preview ? _self.preview : preview // ignore: cast_nullable_to_non_nullable +as ExchangePreview?,previewFailureOption: null == previewFailureOption ? _self.previewFailureOption : previewFailureOption // ignore: cast_nullable_to_non_nullable +as Option,isPreviewing: null == isPreviewing ? _self.isPreviewing : isPreviewing // ignore: cast_nullable_to_non_nullable +as bool,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable +as ExchangeResult?,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,idempotencyKey: freezed == idempotencyKey ? _self.idempotencyKey : idempotencyKey // ignore: cast_nullable_to_non_nullable +as String?, + )); +} +/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExchangePreviewCopyWith<$Res>? get preview { + if (_self.preview == null) { + return null; + } + + return $ExchangePreviewCopyWith<$Res>(_self.preview!, (value) { + return _then(_self.copyWith(preview: value)); + }); +}/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExchangeResultCopyWith<$Res>? get result { + if (_self.result == null) { + return null; + } + + return $ExchangeResultCopyWith<$Res>(_self.result!, (value) { + return _then(_self.copyWith(result: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [ExchangeFormState]. +extension ExchangeFormStatePatterns on ExchangeFormState { +/// 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( _ExchangeFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExchangeFormState() 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( _ExchangeFormState value) $default,){ +final _that = this; +switch (_that) { +case _ExchangeFormState(): +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( _ExchangeFormState value)? $default,){ +final _that = this; +switch (_that) { +case _ExchangeFormState() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( int coins, ExchangePreview? preview, Option previewFailureOption, bool isPreviewing, ExchangeResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExchangeFormState() when $default != null: +return $default(_that.coins,_that.preview,_that.previewFailureOption,_that.isPreviewing,_that.result,_that.failureOption,_that.isSubmitting,_that.idempotencyKey);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( int coins, ExchangePreview? preview, Option previewFailureOption, bool isPreviewing, ExchangeResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey) $default,) {final _that = this; +switch (_that) { +case _ExchangeFormState(): +return $default(_that.coins,_that.preview,_that.previewFailureOption,_that.isPreviewing,_that.result,_that.failureOption,_that.isSubmitting,_that.idempotencyKey);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int coins, ExchangePreview? preview, Option previewFailureOption, bool isPreviewing, ExchangeResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey)? $default,) {final _that = this; +switch (_that) { +case _ExchangeFormState() when $default != null: +return $default(_that.coins,_that.preview,_that.previewFailureOption,_that.isPreviewing,_that.result,_that.failureOption,_that.isSubmitting,_that.idempotencyKey);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _ExchangeFormState extends ExchangeFormState { + const _ExchangeFormState({required this.coins, this.preview, required this.previewFailureOption, this.isPreviewing = false, this.result, required this.failureOption, this.isSubmitting = false, this.idempotencyKey}): super._(); + + +@override final int coins; +@override final ExchangePreview? preview; +@override final Option previewFailureOption; +@override@JsonKey() final bool isPreviewing; +@override final ExchangeResult? result; +@override final Option failureOption; +@override@JsonKey() final bool isSubmitting; +@override final String? idempotencyKey; + +/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExchangeFormStateCopyWith<_ExchangeFormState> get copyWith => __$ExchangeFormStateCopyWithImpl<_ExchangeFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExchangeFormState&&(identical(other.coins, coins) || other.coins == coins)&&(identical(other.preview, preview) || other.preview == preview)&&(identical(other.previewFailureOption, previewFailureOption) || other.previewFailureOption == previewFailureOption)&&(identical(other.isPreviewing, isPreviewing) || other.isPreviewing == isPreviewing)&&(identical(other.result, result) || other.result == result)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.idempotencyKey, idempotencyKey) || other.idempotencyKey == idempotencyKey)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,coins,preview,previewFailureOption,isPreviewing,result,failureOption,isSubmitting,idempotencyKey); +} + +@override +String toString() { + return 'ExchangeFormState(coins: $coins, preview: $preview, previewFailureOption: $previewFailureOption, isPreviewing: $isPreviewing, result: $result, failureOption: $failureOption, isSubmitting: $isSubmitting, idempotencyKey: $idempotencyKey)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExchangeFormStateCopyWith<$Res> implements $ExchangeFormStateCopyWith<$Res> { + factory _$ExchangeFormStateCopyWith(_ExchangeFormState value, $Res Function(_ExchangeFormState) _then) = __$ExchangeFormStateCopyWithImpl; +@override @useResult +$Res call({ + int coins, ExchangePreview? preview, Option previewFailureOption, bool isPreviewing, ExchangeResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey +}); + + +@override $ExchangePreviewCopyWith<$Res>? get preview;@override $ExchangeResultCopyWith<$Res>? get result; + +} +/// @nodoc +class __$ExchangeFormStateCopyWithImpl<$Res> + implements _$ExchangeFormStateCopyWith<$Res> { + __$ExchangeFormStateCopyWithImpl(this._self, this._then); + + final _ExchangeFormState _self; + final $Res Function(_ExchangeFormState) _then; + +/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? coins = null,Object? preview = freezed,Object? previewFailureOption = null,Object? isPreviewing = null,Object? result = freezed,Object? failureOption = null,Object? isSubmitting = null,Object? idempotencyKey = freezed,}) { + return _then(_ExchangeFormState( +coins: null == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int,preview: freezed == preview ? _self.preview : preview // ignore: cast_nullable_to_non_nullable +as ExchangePreview?,previewFailureOption: null == previewFailureOption ? _self.previewFailureOption : previewFailureOption // ignore: cast_nullable_to_non_nullable +as Option,isPreviewing: null == isPreviewing ? _self.isPreviewing : isPreviewing // ignore: cast_nullable_to_non_nullable +as bool,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable +as ExchangeResult?,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,idempotencyKey: freezed == idempotencyKey ? _self.idempotencyKey : idempotencyKey // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExchangePreviewCopyWith<$Res>? get preview { + if (_self.preview == null) { + return null; + } + + return $ExchangePreviewCopyWith<$Res>(_self.preview!, (value) { + return _then(_self.copyWith(preview: value)); + }); +}/// Create a copy of ExchangeFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExchangeResultCopyWith<$Res>? get result { + if (_self.result == null) { + return null; + } + + return $ExchangeResultCopyWith<$Res>(_self.result!, (value) { + return _then(_self.copyWith(result: value)); + }); +} +} + +// dart format on diff --git a/lib/application/wallet/exchange_form/exchange_form_event.dart b/lib/application/wallet/exchange_form/exchange_form_event.dart new file mode 100644 index 0000000..03fb955 --- /dev/null +++ b/lib/application/wallet/exchange_form/exchange_form_event.dart @@ -0,0 +1,9 @@ +part of 'exchange_form_bloc.dart'; + +@freezed +abstract class ExchangeFormEvent with _$ExchangeFormEvent { + const factory ExchangeFormEvent.coinsChanged(int coins) = _CoinsChanged; + + /// [pin] hanya diteruskan ke API, tidak disimpan di state. + const factory ExchangeFormEvent.submitted(String pin) = _Submitted; +} diff --git a/lib/application/wallet/exchange_form/exchange_form_state.dart b/lib/application/wallet/exchange_form/exchange_form_state.dart new file mode 100644 index 0000000..e680f3a --- /dev/null +++ b/lib/application/wallet/exchange_form/exchange_form_state.dart @@ -0,0 +1,30 @@ +part of 'exchange_form_bloc.dart'; + +@freezed +abstract class ExchangeFormState with _$ExchangeFormState { + const ExchangeFormState._(); + + const factory ExchangeFormState({ + required int coins, + ExchangePreview? preview, + required Option previewFailureOption, + @Default(false) bool isPreviewing, + ExchangeResult? result, + required Option failureOption, + @Default(false) bool isSubmitting, + String? idempotencyKey, + }) = _ExchangeFormState; + + factory ExchangeFormState.initial() => ExchangeFormState( + coins: 0, + previewFailureOption: none(), + failureOption: none(), + ); + + bool get canSubmit => + !isPreviewing && + !isSubmitting && + preview != null && + preview!.valid && + preview!.coins == coins; +} diff --git a/lib/application/wallet/payment_code_form/payment_code_form_bloc.dart b/lib/application/wallet/payment_code_form/payment_code_form_bloc.dart new file mode 100644 index 0000000..8542c2b --- /dev/null +++ b/lib/application/wallet/payment_code_form/payment_code_form_bloc.dart @@ -0,0 +1,44 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'payment_code_form_event.dart'; +part 'payment_code_form_state.dart'; +part 'payment_code_form_bloc.freezed.dart'; + +@injectable +class PaymentCodeFormBloc + extends Bloc { + final IWalletRepository _repository; + + PaymentCodeFormBloc(this._repository) + : super(PaymentCodeFormState.initial()) { + on(_onPaymentCodeFormEvent); + } + + Future _onPaymentCodeFormEvent( + PaymentCodeFormEvent event, + Emitter emit, + ) { + return event.map( + submitted: (e) async { + emit(state.copyWith(isSubmitting: true, failureOption: none())); + + final result = await _repository.createPaymentCode(pin: e.pin); + + emit( + result + .fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (code) => state.copyWith(paymentCode: code), + ) + .copyWith(isSubmitting: false), + ); + }, + expired: (e) async => emit(state.copyWith(paymentCode: null)), + ); + } +} diff --git a/lib/application/wallet/payment_code_form/payment_code_form_bloc.freezed.dart b/lib/application/wallet/payment_code_form/payment_code_form_bloc.freezed.dart new file mode 100644 index 0000000..48eb1ef --- /dev/null +++ b/lib/application/wallet/payment_code_form/payment_code_form_bloc.freezed.dart @@ -0,0 +1,575 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'payment_code_form_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$PaymentCodeFormEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PaymentCodeFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'PaymentCodeFormEvent()'; +} + + +} + +/// @nodoc +class $PaymentCodeFormEventCopyWith<$Res> { +$PaymentCodeFormEventCopyWith(PaymentCodeFormEvent _, $Res Function(PaymentCodeFormEvent) __); +} + + +/// Adds pattern-matching-related methods to [PaymentCodeFormEvent]. +extension PaymentCodeFormEventPatterns on PaymentCodeFormEvent { +/// 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( _Submitted value)? submitted,TResult Function( _Expired value)? expired,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_that);case _Expired() when expired != null: +return expired(_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({required TResult Function( _Submitted value) submitted,required TResult Function( _Expired value) expired,}){ +final _that = this; +switch (_that) { +case _Submitted(): +return submitted(_that);case _Expired(): +return expired(_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( _Submitted value)? submitted,TResult? Function( _Expired value)? expired,}){ +final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_that);case _Expired() when expired != null: +return expired(_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 pin)? submitted,TResult Function()? expired,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_that.pin);case _Expired() when expired != null: +return expired();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({required TResult Function( String pin) submitted,required TResult Function() expired,}) {final _that = this; +switch (_that) { +case _Submitted(): +return submitted(_that.pin);case _Expired(): +return expired();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 pin)? submitted,TResult? Function()? expired,}) {final _that = this; +switch (_that) { +case _Submitted() when submitted != null: +return submitted(_that.pin);case _Expired() when expired != null: +return expired();case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Submitted implements PaymentCodeFormEvent { + const _Submitted(this.pin); + + + final String pin; + +/// Create a copy of PaymentCodeFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SubmittedCopyWith<_Submitted> get copyWith => __$SubmittedCopyWithImpl<_Submitted>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted&&(identical(other.pin, pin) || other.pin == pin)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,pin); +} + +@override +String toString() { + return 'PaymentCodeFormEvent.submitted(pin: $pin)'; +} + + +} + +/// @nodoc +abstract mixin class _$SubmittedCopyWith<$Res> implements $PaymentCodeFormEventCopyWith<$Res> { + factory _$SubmittedCopyWith(_Submitted value, $Res Function(_Submitted) _then) = __$SubmittedCopyWithImpl; +@useResult +$Res call({ + String pin +}); + + + + +} +/// @nodoc +class __$SubmittedCopyWithImpl<$Res> + implements _$SubmittedCopyWith<$Res> { + __$SubmittedCopyWithImpl(this._self, this._then); + + final _Submitted _self; + final $Res Function(_Submitted) _then; + +/// Create a copy of PaymentCodeFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? pin = null,}) { + return _then(_Submitted( +null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc + + +class _Expired implements PaymentCodeFormEvent { + const _Expired(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Expired); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'PaymentCodeFormEvent.expired()'; +} + + +} + + + + +/// @nodoc +mixin _$PaymentCodeFormState { + + PaymentCode? get paymentCode; Option get failureOption; bool get isSubmitting; +/// Create a copy of PaymentCodeFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PaymentCodeFormStateCopyWith get copyWith => _$PaymentCodeFormStateCopyWithImpl(this as PaymentCodeFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as PaymentCodeFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PaymentCodeFormState&&(identical(other.paymentCode, _this.paymentCode) || other.paymentCode == _this.paymentCode)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)); +} + + +@override +int get hashCode { + final _this = this as PaymentCodeFormState; + return Object.hash(runtimeType,_this.paymentCode,_this.failureOption,_this.isSubmitting); +} + +@override +String toString() { + final _this = this as PaymentCodeFormState; + return 'PaymentCodeFormState(paymentCode: ${_this.paymentCode}, failureOption: ${_this.failureOption}, isSubmitting: ${_this.isSubmitting})'; +} + + +} + +/// @nodoc +abstract mixin class $PaymentCodeFormStateCopyWith<$Res> { + factory $PaymentCodeFormStateCopyWith(PaymentCodeFormState value, $Res Function(PaymentCodeFormState) _then) = _$PaymentCodeFormStateCopyWithImpl; +@useResult +$Res call({ + PaymentCode? paymentCode, Option failureOption, bool isSubmitting +}); + + +$PaymentCodeCopyWith<$Res>? get paymentCode; + +} +/// @nodoc +class _$PaymentCodeFormStateCopyWithImpl<$Res> + implements $PaymentCodeFormStateCopyWith<$Res> { + _$PaymentCodeFormStateCopyWithImpl(this._self, this._then); + + final PaymentCodeFormState _self; + final $Res Function(PaymentCodeFormState) _then; + +/// Create a copy of PaymentCodeFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? paymentCode = freezed,Object? failureOption = null,Object? isSubmitting = null,}) { + return _then(PaymentCodeFormState( +paymentCode: freezed == paymentCode ? _self.paymentCode : paymentCode // ignore: cast_nullable_to_non_nullable +as PaymentCode?,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool, + )); +} +/// Create a copy of PaymentCodeFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PaymentCodeCopyWith<$Res>? get paymentCode { + if (_self.paymentCode == null) { + return null; + } + + return $PaymentCodeCopyWith<$Res>(_self.paymentCode!, (value) { + return _then(_self.copyWith(paymentCode: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [PaymentCodeFormState]. +extension PaymentCodeFormStatePatterns on PaymentCodeFormState { +/// 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( _PaymentCodeFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PaymentCodeFormState() 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( _PaymentCodeFormState value) $default,){ +final _that = this; +switch (_that) { +case _PaymentCodeFormState(): +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( _PaymentCodeFormState value)? $default,){ +final _that = this; +switch (_that) { +case _PaymentCodeFormState() 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( PaymentCode? paymentCode, Option failureOption, bool isSubmitting)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PaymentCodeFormState() when $default != null: +return $default(_that.paymentCode,_that.failureOption,_that.isSubmitting);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( PaymentCode? paymentCode, Option failureOption, bool isSubmitting) $default,) {final _that = this; +switch (_that) { +case _PaymentCodeFormState(): +return $default(_that.paymentCode,_that.failureOption,_that.isSubmitting);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( PaymentCode? paymentCode, Option failureOption, bool isSubmitting)? $default,) {final _that = this; +switch (_that) { +case _PaymentCodeFormState() when $default != null: +return $default(_that.paymentCode,_that.failureOption,_that.isSubmitting);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _PaymentCodeFormState implements PaymentCodeFormState { + const _PaymentCodeFormState({this.paymentCode, required this.failureOption, this.isSubmitting = false}); + + +@override final PaymentCode? paymentCode; +@override final Option failureOption; +@override@JsonKey() final bool isSubmitting; + +/// Create a copy of PaymentCodeFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PaymentCodeFormStateCopyWith<_PaymentCodeFormState> get copyWith => __$PaymentCodeFormStateCopyWithImpl<_PaymentCodeFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentCodeFormState&&(identical(other.paymentCode, paymentCode) || other.paymentCode == paymentCode)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,paymentCode,failureOption,isSubmitting); +} + +@override +String toString() { + return 'PaymentCodeFormState(paymentCode: $paymentCode, failureOption: $failureOption, isSubmitting: $isSubmitting)'; +} + + +} + +/// @nodoc +abstract mixin class _$PaymentCodeFormStateCopyWith<$Res> implements $PaymentCodeFormStateCopyWith<$Res> { + factory _$PaymentCodeFormStateCopyWith(_PaymentCodeFormState value, $Res Function(_PaymentCodeFormState) _then) = __$PaymentCodeFormStateCopyWithImpl; +@override @useResult +$Res call({ + PaymentCode? paymentCode, Option failureOption, bool isSubmitting +}); + + +@override $PaymentCodeCopyWith<$Res>? get paymentCode; + +} +/// @nodoc +class __$PaymentCodeFormStateCopyWithImpl<$Res> + implements _$PaymentCodeFormStateCopyWith<$Res> { + __$PaymentCodeFormStateCopyWithImpl(this._self, this._then); + + final _PaymentCodeFormState _self; + final $Res Function(_PaymentCodeFormState) _then; + +/// Create a copy of PaymentCodeFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? paymentCode = freezed,Object? failureOption = null,Object? isSubmitting = null,}) { + return _then(_PaymentCodeFormState( +paymentCode: freezed == paymentCode ? _self.paymentCode : paymentCode // ignore: cast_nullable_to_non_nullable +as PaymentCode?,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of PaymentCodeFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PaymentCodeCopyWith<$Res>? get paymentCode { + if (_self.paymentCode == null) { + return null; + } + + return $PaymentCodeCopyWith<$Res>(_self.paymentCode!, (value) { + return _then(_self.copyWith(paymentCode: value)); + }); +} +} + +// dart format on diff --git a/lib/application/wallet/payment_code_form/payment_code_form_event.dart b/lib/application/wallet/payment_code_form/payment_code_form_event.dart new file mode 100644 index 0000000..eb056f3 --- /dev/null +++ b/lib/application/wallet/payment_code_form/payment_code_form_event.dart @@ -0,0 +1,9 @@ +part of 'payment_code_form_bloc.dart'; + +@freezed +abstract class PaymentCodeFormEvent with _$PaymentCodeFormEvent { + /// [pin] hanya diteruskan ke API, tidak disimpan di state. + const factory PaymentCodeFormEvent.submitted(String pin) = _Submitted; + + const factory PaymentCodeFormEvent.expired() = _Expired; +} diff --git a/lib/application/wallet/payment_code_form/payment_code_form_state.dart b/lib/application/wallet/payment_code_form/payment_code_form_state.dart new file mode 100644 index 0000000..8414425 --- /dev/null +++ b/lib/application/wallet/payment_code_form/payment_code_form_state.dart @@ -0,0 +1,13 @@ +part of 'payment_code_form_bloc.dart'; + +@freezed +abstract class PaymentCodeFormState with _$PaymentCodeFormState { + const factory PaymentCodeFormState({ + PaymentCode? paymentCode, + required Option failureOption, + @Default(false) bool isSubmitting, + }) = _PaymentCodeFormState; + + factory PaymentCodeFormState.initial() => + PaymentCodeFormState(failureOption: none()); +} diff --git a/lib/application/wallet/transfer_form/transfer_form_bloc.dart b/lib/application/wallet/transfer_form/transfer_form_bloc.dart new file mode 100644 index 0000000..5a88210 --- /dev/null +++ b/lib/application/wallet/transfer_form/transfer_form_bloc.dart @@ -0,0 +1,108 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/function/app_function.dart'; +import '../../../domain/wallet/wallet.dart'; + +part 'transfer_form_event.dart'; +part 'transfer_form_state.dart'; +part 'transfer_form_bloc.freezed.dart'; + +@injectable +class TransferFormBloc extends Bloc { + final IWalletRepository _repository; + + TransferFormBloc(this._repository) : super(TransferFormState.initial()) { + on(_onTransferFormEvent); + } + + Future _onTransferFormEvent( + TransferFormEvent event, + Emitter emit, + ) { + return event.map( + currencyChanged: (e) async => emit( + state.copyWith( + currency: e.currency, + idempotencyKey: null, + failureOption: none(), + ), + ), + phoneChanged: (e) async => emit( + state.copyWith( + phone: e.phone, + recipient: null, + recipientFailureOption: none(), + idempotencyKey: null, + failureOption: none(), + ), + ), + amountChanged: (e) async => emit( + state.copyWith( + amount: e.amount, + idempotencyKey: null, + failureOption: none(), + ), + ), + recipientChecked: (e) async { + final phone = state.phone; + emit( + state.copyWith( + isCheckingRecipient: true, + recipient: null, + recipientFailureOption: none(), + ), + ); + + final result = await _repository.checkRecipient(phone: phone); + if (state.phone != phone) return; + + emit( + result + .fold( + (f) => state.copyWith(recipientFailureOption: optionOf(f)), + (recipient) => state.copyWith(recipient: recipient), + ) + .copyWith(isCheckingRecipient: false), + ); + }, + submitted: (e) async { + // Key baru untuk setiap konfirmasi, kecuali mengulang request yang + // sebelumnya gagal karena jaringan. + final key = state.idempotencyKey ?? generateUuidV4(); + emit( + state.copyWith( + isSubmitting: true, + idempotencyKey: key, + failureOption: none(), + ), + ); + + final result = await _repository.transfer( + currency: state.currency, + amount: state.amount, + recipientPhone: state.phone, + pin: e.pin, + idempotencyKey: key, + ); + + emit( + result + .fold( + (f) => state.copyWith( + failureOption: optionOf(f), + idempotencyKey: f.isNetworkError ? key : null, + ), + (transferResult) => state.copyWith( + result: transferResult, + idempotencyKey: null, + ), + ) + .copyWith(isSubmitting: false), + ); + }, + ); + } +} diff --git a/lib/application/wallet/transfer_form/transfer_form_bloc.freezed.dart b/lib/application/wallet/transfer_form/transfer_form_bloc.freezed.dart new file mode 100644 index 0000000..ab59f12 --- /dev/null +++ b/lib/application/wallet/transfer_form/transfer_form_bloc.freezed.dart @@ -0,0 +1,842 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'transfer_form_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$TransferFormEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is TransferFormEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'TransferFormEvent()'; +} + + +} + +/// @nodoc +class $TransferFormEventCopyWith<$Res> { +$TransferFormEventCopyWith(TransferFormEvent _, $Res Function(TransferFormEvent) __); +} + + +/// Adds pattern-matching-related methods to [TransferFormEvent]. +extension TransferFormEventPatterns on TransferFormEvent { +/// 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( _CurrencyChanged value)? currencyChanged,TResult Function( _PhoneChanged value)? phoneChanged,TResult Function( _AmountChanged value)? amountChanged,TResult Function( _RecipientChecked value)? recipientChecked,TResult Function( _Submitted value)? submitted,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that);case _PhoneChanged() when phoneChanged != null: +return phoneChanged(_that);case _AmountChanged() when amountChanged != null: +return amountChanged(_that);case _RecipientChecked() when recipientChecked != null: +return recipientChecked(_that);case _Submitted() when submitted != null: +return submitted(_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({required TResult Function( _CurrencyChanged value) currencyChanged,required TResult Function( _PhoneChanged value) phoneChanged,required TResult Function( _AmountChanged value) amountChanged,required TResult Function( _RecipientChecked value) recipientChecked,required TResult Function( _Submitted value) submitted,}){ +final _that = this; +switch (_that) { +case _CurrencyChanged(): +return currencyChanged(_that);case _PhoneChanged(): +return phoneChanged(_that);case _AmountChanged(): +return amountChanged(_that);case _RecipientChecked(): +return recipientChecked(_that);case _Submitted(): +return submitted(_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( _CurrencyChanged value)? currencyChanged,TResult? Function( _PhoneChanged value)? phoneChanged,TResult? Function( _AmountChanged value)? amountChanged,TResult? Function( _RecipientChecked value)? recipientChecked,TResult? Function( _Submitted value)? submitted,}){ +final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that);case _PhoneChanged() when phoneChanged != null: +return phoneChanged(_that);case _AmountChanged() when amountChanged != null: +return amountChanged(_that);case _RecipientChecked() when recipientChecked != null: +return recipientChecked(_that);case _Submitted() when submitted != null: +return submitted(_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( WalletCurrency currency)? currencyChanged,TResult Function( String phone)? phoneChanged,TResult Function( int amount)? amountChanged,TResult Function()? recipientChecked,TResult Function( String pin)? submitted,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that.currency);case _PhoneChanged() when phoneChanged != null: +return phoneChanged(_that.phone);case _AmountChanged() when amountChanged != null: +return amountChanged(_that.amount);case _RecipientChecked() when recipientChecked != null: +return recipientChecked();case _Submitted() when submitted != null: +return submitted(_that.pin);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({required TResult Function( WalletCurrency currency) currencyChanged,required TResult Function( String phone) phoneChanged,required TResult Function( int amount) amountChanged,required TResult Function() recipientChecked,required TResult Function( String pin) submitted,}) {final _that = this; +switch (_that) { +case _CurrencyChanged(): +return currencyChanged(_that.currency);case _PhoneChanged(): +return phoneChanged(_that.phone);case _AmountChanged(): +return amountChanged(_that.amount);case _RecipientChecked(): +return recipientChecked();case _Submitted(): +return submitted(_that.pin);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( WalletCurrency currency)? currencyChanged,TResult? Function( String phone)? phoneChanged,TResult? Function( int amount)? amountChanged,TResult? Function()? recipientChecked,TResult? Function( String pin)? submitted,}) {final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that.currency);case _PhoneChanged() when phoneChanged != null: +return phoneChanged(_that.phone);case _AmountChanged() when amountChanged != null: +return amountChanged(_that.amount);case _RecipientChecked() when recipientChecked != null: +return recipientChecked();case _Submitted() when submitted != null: +return submitted(_that.pin);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CurrencyChanged implements TransferFormEvent { + const _CurrencyChanged(this.currency); + + + final WalletCurrency currency; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CurrencyChangedCopyWith<_CurrencyChanged> get copyWith => __$CurrencyChangedCopyWithImpl<_CurrencyChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CurrencyChanged&&(identical(other.currency, currency) || other.currency == currency)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,currency); +} + +@override +String toString() { + return 'TransferFormEvent.currencyChanged(currency: $currency)'; +} + + +} + +/// @nodoc +abstract mixin class _$CurrencyChangedCopyWith<$Res> implements $TransferFormEventCopyWith<$Res> { + factory _$CurrencyChangedCopyWith(_CurrencyChanged value, $Res Function(_CurrencyChanged) _then) = __$CurrencyChangedCopyWithImpl; +@useResult +$Res call({ + WalletCurrency currency +}); + + + + +} +/// @nodoc +class __$CurrencyChangedCopyWithImpl<$Res> + implements _$CurrencyChangedCopyWith<$Res> { + __$CurrencyChangedCopyWithImpl(this._self, this._then); + + final _CurrencyChanged _self; + final $Res Function(_CurrencyChanged) _then; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? currency = null,}) { + return _then(_CurrencyChanged( +null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency, + )); +} + + +} + +/// @nodoc + + +class _PhoneChanged implements TransferFormEvent { + const _PhoneChanged(this.phone); + + + final String phone; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PhoneChangedCopyWith<_PhoneChanged> get copyWith => __$PhoneChangedCopyWithImpl<_PhoneChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PhoneChanged&&(identical(other.phone, phone) || other.phone == phone)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,phone); +} + +@override +String toString() { + return 'TransferFormEvent.phoneChanged(phone: $phone)'; +} + + +} + +/// @nodoc +abstract mixin class _$PhoneChangedCopyWith<$Res> implements $TransferFormEventCopyWith<$Res> { + factory _$PhoneChangedCopyWith(_PhoneChanged value, $Res Function(_PhoneChanged) _then) = __$PhoneChangedCopyWithImpl; +@useResult +$Res call({ + String phone +}); + + + + +} +/// @nodoc +class __$PhoneChangedCopyWithImpl<$Res> + implements _$PhoneChangedCopyWith<$Res> { + __$PhoneChangedCopyWithImpl(this._self, this._then); + + final _PhoneChanged _self; + final $Res Function(_PhoneChanged) _then; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? phone = null,}) { + return _then(_PhoneChanged( +null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc + + +class _AmountChanged implements TransferFormEvent { + const _AmountChanged(this.amount); + + + final int amount; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AmountChangedCopyWith<_AmountChanged> get copyWith => __$AmountChangedCopyWithImpl<_AmountChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AmountChanged&&(identical(other.amount, amount) || other.amount == amount)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,amount); +} + +@override +String toString() { + return 'TransferFormEvent.amountChanged(amount: $amount)'; +} + + +} + +/// @nodoc +abstract mixin class _$AmountChangedCopyWith<$Res> implements $TransferFormEventCopyWith<$Res> { + factory _$AmountChangedCopyWith(_AmountChanged value, $Res Function(_AmountChanged) _then) = __$AmountChangedCopyWithImpl; +@useResult +$Res call({ + int amount +}); + + + + +} +/// @nodoc +class __$AmountChangedCopyWithImpl<$Res> + implements _$AmountChangedCopyWith<$Res> { + __$AmountChangedCopyWithImpl(this._self, this._then); + + final _AmountChanged _self; + final $Res Function(_AmountChanged) _then; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? amount = null,}) { + return _then(_AmountChanged( +null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class _RecipientChecked implements TransferFormEvent { + const _RecipientChecked(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _RecipientChecked); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'TransferFormEvent.recipientChecked()'; +} + + +} + + + + +/// @nodoc + + +class _Submitted implements TransferFormEvent { + const _Submitted(this.pin); + + + final String pin; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SubmittedCopyWith<_Submitted> get copyWith => __$SubmittedCopyWithImpl<_Submitted>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Submitted&&(identical(other.pin, pin) || other.pin == pin)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,pin); +} + +@override +String toString() { + return 'TransferFormEvent.submitted(pin: $pin)'; +} + + +} + +/// @nodoc +abstract mixin class _$SubmittedCopyWith<$Res> implements $TransferFormEventCopyWith<$Res> { + factory _$SubmittedCopyWith(_Submitted value, $Res Function(_Submitted) _then) = __$SubmittedCopyWithImpl; +@useResult +$Res call({ + String pin +}); + + + + +} +/// @nodoc +class __$SubmittedCopyWithImpl<$Res> + implements _$SubmittedCopyWith<$Res> { + __$SubmittedCopyWithImpl(this._self, this._then); + + final _Submitted _self; + final $Res Function(_Submitted) _then; + +/// Create a copy of TransferFormEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? pin = null,}) { + return _then(_Submitted( +null == pin ? _self.pin : pin // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$TransferFormState { + + WalletCurrency get currency; String get phone; int get amount; TransferRecipient? get recipient; Option get recipientFailureOption; bool get isCheckingRecipient; TransferResult? get result; Option get failureOption; bool get isSubmitting; String? get idempotencyKey; +/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TransferFormStateCopyWith get copyWith => _$TransferFormStateCopyWithImpl(this as TransferFormState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as TransferFormState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is TransferFormState&&(identical(other.currency, _this.currency) || other.currency == _this.currency)&&(identical(other.phone, _this.phone) || other.phone == _this.phone)&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.recipient, _this.recipient) || other.recipient == _this.recipient)&&(identical(other.recipientFailureOption, _this.recipientFailureOption) || other.recipientFailureOption == _this.recipientFailureOption)&&(identical(other.isCheckingRecipient, _this.isCheckingRecipient) || other.isCheckingRecipient == _this.isCheckingRecipient)&&(identical(other.result, _this.result) || other.result == _this.result)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isSubmitting, _this.isSubmitting) || other.isSubmitting == _this.isSubmitting)&&(identical(other.idempotencyKey, _this.idempotencyKey) || other.idempotencyKey == _this.idempotencyKey)); +} + + +@override +int get hashCode { + final _this = this as TransferFormState; + return Object.hash(runtimeType,_this.currency,_this.phone,_this.amount,_this.recipient,_this.recipientFailureOption,_this.isCheckingRecipient,_this.result,_this.failureOption,_this.isSubmitting,_this.idempotencyKey); +} + +@override +String toString() { + final _this = this as TransferFormState; + return 'TransferFormState(currency: ${_this.currency}, phone: ${_this.phone}, amount: ${_this.amount}, recipient: ${_this.recipient}, recipientFailureOption: ${_this.recipientFailureOption}, isCheckingRecipient: ${_this.isCheckingRecipient}, result: ${_this.result}, failureOption: ${_this.failureOption}, isSubmitting: ${_this.isSubmitting}, idempotencyKey: ${_this.idempotencyKey})'; +} + + +} + +/// @nodoc +abstract mixin class $TransferFormStateCopyWith<$Res> { + factory $TransferFormStateCopyWith(TransferFormState value, $Res Function(TransferFormState) _then) = _$TransferFormStateCopyWithImpl; +@useResult +$Res call({ + WalletCurrency currency, String phone, int amount, TransferRecipient? recipient, Option recipientFailureOption, bool isCheckingRecipient, TransferResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey +}); + + +$TransferRecipientCopyWith<$Res>? get recipient;$TransferResultCopyWith<$Res>? get result; + +} +/// @nodoc +class _$TransferFormStateCopyWithImpl<$Res> + implements $TransferFormStateCopyWith<$Res> { + _$TransferFormStateCopyWithImpl(this._self, this._then); + + final TransferFormState _self; + final $Res Function(TransferFormState) _then; + +/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? currency = null,Object? phone = null,Object? amount = null,Object? recipient = freezed,Object? recipientFailureOption = null,Object? isCheckingRecipient = null,Object? result = freezed,Object? failureOption = null,Object? isSubmitting = null,Object? idempotencyKey = freezed,}) { + return _then(TransferFormState( +currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as TransferRecipient?,recipientFailureOption: null == recipientFailureOption ? _self.recipientFailureOption : recipientFailureOption // ignore: cast_nullable_to_non_nullable +as Option,isCheckingRecipient: null == isCheckingRecipient ? _self.isCheckingRecipient : isCheckingRecipient // ignore: cast_nullable_to_non_nullable +as bool,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable +as TransferResult?,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,idempotencyKey: freezed == idempotencyKey ? _self.idempotencyKey : idempotencyKey // ignore: cast_nullable_to_non_nullable +as String?, + )); +} +/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferRecipientCopyWith<$Res>? get recipient { + if (_self.recipient == null) { + return null; + } + + return $TransferRecipientCopyWith<$Res>(_self.recipient!, (value) { + return _then(_self.copyWith(recipient: value)); + }); +}/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferResultCopyWith<$Res>? get result { + if (_self.result == null) { + return null; + } + + return $TransferResultCopyWith<$Res>(_self.result!, (value) { + return _then(_self.copyWith(result: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [TransferFormState]. +extension TransferFormStatePatterns on TransferFormState { +/// 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( _TransferFormState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _TransferFormState() 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( _TransferFormState value) $default,){ +final _that = this; +switch (_that) { +case _TransferFormState(): +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( _TransferFormState value)? $default,){ +final _that = this; +switch (_that) { +case _TransferFormState() 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( WalletCurrency currency, String phone, int amount, TransferRecipient? recipient, Option recipientFailureOption, bool isCheckingRecipient, TransferResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _TransferFormState() when $default != null: +return $default(_that.currency,_that.phone,_that.amount,_that.recipient,_that.recipientFailureOption,_that.isCheckingRecipient,_that.result,_that.failureOption,_that.isSubmitting,_that.idempotencyKey);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( WalletCurrency currency, String phone, int amount, TransferRecipient? recipient, Option recipientFailureOption, bool isCheckingRecipient, TransferResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey) $default,) {final _that = this; +switch (_that) { +case _TransferFormState(): +return $default(_that.currency,_that.phone,_that.amount,_that.recipient,_that.recipientFailureOption,_that.isCheckingRecipient,_that.result,_that.failureOption,_that.isSubmitting,_that.idempotencyKey);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( WalletCurrency currency, String phone, int amount, TransferRecipient? recipient, Option recipientFailureOption, bool isCheckingRecipient, TransferResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey)? $default,) {final _that = this; +switch (_that) { +case _TransferFormState() when $default != null: +return $default(_that.currency,_that.phone,_that.amount,_that.recipient,_that.recipientFailureOption,_that.isCheckingRecipient,_that.result,_that.failureOption,_that.isSubmitting,_that.idempotencyKey);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _TransferFormState extends TransferFormState { + const _TransferFormState({required this.currency, required this.phone, required this.amount, this.recipient, required this.recipientFailureOption, this.isCheckingRecipient = false, this.result, required this.failureOption, this.isSubmitting = false, this.idempotencyKey}): super._(); + + +@override final WalletCurrency currency; +@override final String phone; +@override final int amount; +@override final TransferRecipient? recipient; +@override final Option recipientFailureOption; +@override@JsonKey() final bool isCheckingRecipient; +@override final TransferResult? result; +@override final Option failureOption; +@override@JsonKey() final bool isSubmitting; +@override final String? idempotencyKey; + +/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TransferFormStateCopyWith<_TransferFormState> get copyWith => __$TransferFormStateCopyWithImpl<_TransferFormState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TransferFormState&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.recipient, recipient) || other.recipient == recipient)&&(identical(other.recipientFailureOption, recipientFailureOption) || other.recipientFailureOption == recipientFailureOption)&&(identical(other.isCheckingRecipient, isCheckingRecipient) || other.isCheckingRecipient == isCheckingRecipient)&&(identical(other.result, result) || other.result == result)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isSubmitting, isSubmitting) || other.isSubmitting == isSubmitting)&&(identical(other.idempotencyKey, idempotencyKey) || other.idempotencyKey == idempotencyKey)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,currency,phone,amount,recipient,recipientFailureOption,isCheckingRecipient,result,failureOption,isSubmitting,idempotencyKey); +} + +@override +String toString() { + return 'TransferFormState(currency: $currency, phone: $phone, amount: $amount, recipient: $recipient, recipientFailureOption: $recipientFailureOption, isCheckingRecipient: $isCheckingRecipient, result: $result, failureOption: $failureOption, isSubmitting: $isSubmitting, idempotencyKey: $idempotencyKey)'; +} + + +} + +/// @nodoc +abstract mixin class _$TransferFormStateCopyWith<$Res> implements $TransferFormStateCopyWith<$Res> { + factory _$TransferFormStateCopyWith(_TransferFormState value, $Res Function(_TransferFormState) _then) = __$TransferFormStateCopyWithImpl; +@override @useResult +$Res call({ + WalletCurrency currency, String phone, int amount, TransferRecipient? recipient, Option recipientFailureOption, bool isCheckingRecipient, TransferResult? result, Option failureOption, bool isSubmitting, String? idempotencyKey +}); + + +@override $TransferRecipientCopyWith<$Res>? get recipient;@override $TransferResultCopyWith<$Res>? get result; + +} +/// @nodoc +class __$TransferFormStateCopyWithImpl<$Res> + implements _$TransferFormStateCopyWith<$Res> { + __$TransferFormStateCopyWithImpl(this._self, this._then); + + final _TransferFormState _self; + final $Res Function(_TransferFormState) _then; + +/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? currency = null,Object? phone = null,Object? amount = null,Object? recipient = freezed,Object? recipientFailureOption = null,Object? isCheckingRecipient = null,Object? result = freezed,Object? failureOption = null,Object? isSubmitting = null,Object? idempotencyKey = freezed,}) { + return _then(_TransferFormState( +currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable +as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as TransferRecipient?,recipientFailureOption: null == recipientFailureOption ? _self.recipientFailureOption : recipientFailureOption // ignore: cast_nullable_to_non_nullable +as Option,isCheckingRecipient: null == isCheckingRecipient ? _self.isCheckingRecipient : isCheckingRecipient // ignore: cast_nullable_to_non_nullable +as bool,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable +as TransferResult?,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isSubmitting: null == isSubmitting ? _self.isSubmitting : isSubmitting // ignore: cast_nullable_to_non_nullable +as bool,idempotencyKey: freezed == idempotencyKey ? _self.idempotencyKey : idempotencyKey // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferRecipientCopyWith<$Res>? get recipient { + if (_self.recipient == null) { + return null; + } + + return $TransferRecipientCopyWith<$Res>(_self.recipient!, (value) { + return _then(_self.copyWith(recipient: value)); + }); +}/// Create a copy of TransferFormState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferResultCopyWith<$Res>? get result { + if (_self.result == null) { + return null; + } + + return $TransferResultCopyWith<$Res>(_self.result!, (value) { + return _then(_self.copyWith(result: value)); + }); +} +} + +// dart format on diff --git a/lib/application/wallet/transfer_form/transfer_form_event.dart b/lib/application/wallet/transfer_form/transfer_form_event.dart new file mode 100644 index 0000000..245c871 --- /dev/null +++ b/lib/application/wallet/transfer_form/transfer_form_event.dart @@ -0,0 +1,16 @@ +part of 'transfer_form_bloc.dart'; + +@freezed +abstract class TransferFormEvent with _$TransferFormEvent { + const factory TransferFormEvent.currencyChanged(WalletCurrency currency) = + _CurrencyChanged; + + const factory TransferFormEvent.phoneChanged(String phone) = _PhoneChanged; + + const factory TransferFormEvent.amountChanged(int amount) = _AmountChanged; + + const factory TransferFormEvent.recipientChecked() = _RecipientChecked; + + /// [pin] hanya diteruskan ke API, tidak disimpan di state. + const factory TransferFormEvent.submitted(String pin) = _Submitted; +} diff --git a/lib/application/wallet/transfer_form/transfer_form_state.dart b/lib/application/wallet/transfer_form/transfer_form_state.dart new file mode 100644 index 0000000..6904ca7 --- /dev/null +++ b/lib/application/wallet/transfer_form/transfer_form_state.dart @@ -0,0 +1,29 @@ +part of 'transfer_form_bloc.dart'; + +@freezed +abstract class TransferFormState with _$TransferFormState { + const TransferFormState._(); + + const factory TransferFormState({ + required WalletCurrency currency, + required String phone, + required int amount, + TransferRecipient? recipient, + required Option recipientFailureOption, + @Default(false) bool isCheckingRecipient, + TransferResult? result, + required Option failureOption, + @Default(false) bool isSubmitting, + String? idempotencyKey, + }) = _TransferFormState; + + factory TransferFormState.initial() => TransferFormState( + currency: WalletCurrency.point, + phone: '', + amount: 0, + recipientFailureOption: none(), + failureOption: none(), + ); + + bool get isFilled => phone.length >= 9 && amount > 0; +} diff --git a/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.dart b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.dart new file mode 100644 index 0000000..5a6d5c9 --- /dev/null +++ b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.dart @@ -0,0 +1,41 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'wallet_expiring_loader_event.dart'; +part 'wallet_expiring_loader_state.dart'; +part 'wallet_expiring_loader_bloc.freezed.dart'; + +@injectable +class WalletExpiringLoaderBloc + extends Bloc { + final IWalletRepository _repository; + + WalletExpiringLoaderBloc(this._repository) + : super(WalletExpiringLoaderState.initial()) { + on(_onWalletExpiringLoaderEvent); + } + + Future _onWalletExpiringLoaderEvent( + WalletExpiringLoaderEvent event, + Emitter emit, + ) { + return event.map( + fetched: (e) async { + emit(state.copyWith(isFetching: true, failureOption: none())); + + final result = await _repository.getExpiring(); + + final data = result.fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (expiring) => state.copyWith(expiring: expiring), + ); + + emit(data.copyWith(isFetching: false)); + }, + ); + } +} diff --git a/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.freezed.dart b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.freezed.dart new file mode 100644 index 0000000..060a85b --- /dev/null +++ b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.freezed.dart @@ -0,0 +1,495 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'wallet_expiring_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$WalletExpiringLoaderEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletExpiringLoaderEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletExpiringLoaderEvent()'; +} + + +} + +/// @nodoc +class $WalletExpiringLoaderEventCopyWith<$Res> { +$WalletExpiringLoaderEventCopyWith(WalletExpiringLoaderEvent _, $Res Function(WalletExpiringLoaderEvent) __); +} + + +/// Adds pattern-matching-related methods to [WalletExpiringLoaderEvent]. +extension WalletExpiringLoaderEventPatterns on WalletExpiringLoaderEvent { +/// 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( _Fetched value)? fetched,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_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({required TResult Function( _Fetched value) fetched,}){ +final _that = this; +switch (_that) { +case _Fetched(): +return fetched(_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( _Fetched value)? fetched,}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_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()? fetched,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();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({required TResult Function() fetched,}) {final _that = this; +switch (_that) { +case _Fetched(): +return fetched();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()? fetched,}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Fetched implements WalletExpiringLoaderEvent { + const _Fetched(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Fetched); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletExpiringLoaderEvent.fetched()'; +} + + +} + + + + +/// @nodoc +mixin _$WalletExpiringLoaderState { + + WalletExpiring get expiring; Option get failureOption; bool get isFetching; +/// Create a copy of WalletExpiringLoaderState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletExpiringLoaderStateCopyWith get copyWith => _$WalletExpiringLoaderStateCopyWithImpl(this as WalletExpiringLoaderState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletExpiringLoaderState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletExpiringLoaderState&&(identical(other.expiring, _this.expiring) || other.expiring == _this.expiring)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)); +} + + +@override +int get hashCode { + final _this = this as WalletExpiringLoaderState; + return Object.hash(runtimeType,_this.expiring,_this.failureOption,_this.isFetching); +} + +@override +String toString() { + final _this = this as WalletExpiringLoaderState; + return 'WalletExpiringLoaderState(expiring: ${_this.expiring}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletExpiringLoaderStateCopyWith<$Res> { + factory $WalletExpiringLoaderStateCopyWith(WalletExpiringLoaderState value, $Res Function(WalletExpiringLoaderState) _then) = _$WalletExpiringLoaderStateCopyWithImpl; +@useResult +$Res call({ + WalletExpiring expiring, Option failureOption, bool isFetching +}); + + +$WalletExpiringCopyWith<$Res> get expiring; + +} +/// @nodoc +class _$WalletExpiringLoaderStateCopyWithImpl<$Res> + implements $WalletExpiringLoaderStateCopyWith<$Res> { + _$WalletExpiringLoaderStateCopyWithImpl(this._self, this._then); + + final WalletExpiringLoaderState _self; + final $Res Function(WalletExpiringLoaderState) _then; + +/// Create a copy of WalletExpiringLoaderState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? expiring = null,Object? failureOption = null,Object? isFetching = null,}) { + return _then(WalletExpiringLoaderState( +expiring: null == expiring ? _self.expiring : expiring // ignore: cast_nullable_to_non_nullable +as WalletExpiring,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); +} +/// Create a copy of WalletExpiringLoaderState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$WalletExpiringCopyWith<$Res> get expiring { + + return $WalletExpiringCopyWith<$Res>(_self.expiring, (value) { + return _then(_self.copyWith(expiring: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [WalletExpiringLoaderState]. +extension WalletExpiringLoaderStatePatterns on WalletExpiringLoaderState { +/// 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( _WalletExpiringLoaderState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletExpiringLoaderState() 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( _WalletExpiringLoaderState value) $default,){ +final _that = this; +switch (_that) { +case _WalletExpiringLoaderState(): +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( _WalletExpiringLoaderState value)? $default,){ +final _that = this; +switch (_that) { +case _WalletExpiringLoaderState() 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( WalletExpiring expiring, Option failureOption, bool isFetching)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletExpiringLoaderState() when $default != null: +return $default(_that.expiring,_that.failureOption,_that.isFetching);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( WalletExpiring expiring, Option failureOption, bool isFetching) $default,) {final _that = this; +switch (_that) { +case _WalletExpiringLoaderState(): +return $default(_that.expiring,_that.failureOption,_that.isFetching);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( WalletExpiring expiring, Option failureOption, bool isFetching)? $default,) {final _that = this; +switch (_that) { +case _WalletExpiringLoaderState() when $default != null: +return $default(_that.expiring,_that.failureOption,_that.isFetching);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletExpiringLoaderState implements WalletExpiringLoaderState { + const _WalletExpiringLoaderState({required this.expiring, required this.failureOption, this.isFetching = false}); + + +@override final WalletExpiring expiring; +@override final Option failureOption; +@override@JsonKey() final bool isFetching; + +/// Create a copy of WalletExpiringLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletExpiringLoaderStateCopyWith<_WalletExpiringLoaderState> get copyWith => __$WalletExpiringLoaderStateCopyWithImpl<_WalletExpiringLoaderState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletExpiringLoaderState&&(identical(other.expiring, expiring) || other.expiring == expiring)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,expiring,failureOption,isFetching); +} + +@override +String toString() { + return 'WalletExpiringLoaderState(expiring: $expiring, failureOption: $failureOption, isFetching: $isFetching)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletExpiringLoaderStateCopyWith<$Res> implements $WalletExpiringLoaderStateCopyWith<$Res> { + factory _$WalletExpiringLoaderStateCopyWith(_WalletExpiringLoaderState value, $Res Function(_WalletExpiringLoaderState) _then) = __$WalletExpiringLoaderStateCopyWithImpl; +@override @useResult +$Res call({ + WalletExpiring expiring, Option failureOption, bool isFetching +}); + + +@override $WalletExpiringCopyWith<$Res> get expiring; + +} +/// @nodoc +class __$WalletExpiringLoaderStateCopyWithImpl<$Res> + implements _$WalletExpiringLoaderStateCopyWith<$Res> { + __$WalletExpiringLoaderStateCopyWithImpl(this._self, this._then); + + final _WalletExpiringLoaderState _self; + final $Res Function(_WalletExpiringLoaderState) _then; + +/// Create a copy of WalletExpiringLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? expiring = null,Object? failureOption = null,Object? isFetching = null,}) { + return _then(_WalletExpiringLoaderState( +expiring: null == expiring ? _self.expiring : expiring // ignore: cast_nullable_to_non_nullable +as WalletExpiring,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of WalletExpiringLoaderState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$WalletExpiringCopyWith<$Res> get expiring { + + return $WalletExpiringCopyWith<$Res>(_self.expiring, (value) { + return _then(_self.copyWith(expiring: value)); + }); +} +} + +// dart format on diff --git a/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_event.dart b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_event.dart new file mode 100644 index 0000000..624c576 --- /dev/null +++ b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_event.dart @@ -0,0 +1,6 @@ +part of 'wallet_expiring_loader_bloc.dart'; + +@freezed +abstract class WalletExpiringLoaderEvent with _$WalletExpiringLoaderEvent { + const factory WalletExpiringLoaderEvent.fetched() = _Fetched; +} diff --git a/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_state.dart b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_state.dart new file mode 100644 index 0000000..4dfd37b --- /dev/null +++ b/lib/application/wallet/wallet_expiring_loader/wallet_expiring_loader_state.dart @@ -0,0 +1,15 @@ +part of 'wallet_expiring_loader_bloc.dart'; + +@freezed +abstract class WalletExpiringLoaderState with _$WalletExpiringLoaderState { + const factory WalletExpiringLoaderState({ + required WalletExpiring expiring, + required Option failureOption, + @Default(false) bool isFetching, + }) = _WalletExpiringLoaderState; + + factory WalletExpiringLoaderState.initial() => WalletExpiringLoaderState( + expiring: WalletExpiring.empty(), + failureOption: none(), + ); +} diff --git a/lib/application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart b/lib/application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart new file mode 100644 index 0000000..2a04ba3 --- /dev/null +++ b/lib/application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart @@ -0,0 +1,102 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'wallet_history_loader_event.dart'; +part 'wallet_history_loader_state.dart'; +part 'wallet_history_loader_bloc.freezed.dart'; + +@injectable +class WalletHistoryLoaderBloc + extends Bloc { + final IWalletRepository _repository; + + static const int _limit = 20; + + WalletHistoryLoaderBloc(this._repository) + : super(WalletHistoryLoaderState.initial()) { + on(_onWalletHistoryLoaderEvent); + } + + Future _onWalletHistoryLoaderEvent( + WalletHistoryLoaderEvent event, + Emitter emit, + ) { + return event.map( + currencyChanged: (e) async { + emit(state.copyWith(currency: e.currency)); + await _fetchFirstPage(emit); + }, + filterChanged: (e) async { + emit(state.copyWith(types: e.types, from: e.from, to: e.to)); + await _fetchFirstPage(emit); + }, + refreshed: (e) => _fetchFirstPage(emit), + loadedMore: (e) async { + if (state.isFetching || state.isLoadingMore || !state.hasMore) return; + + final query = state.query; + emit(state.copyWith(isLoadingMore: true, failureOption: none())); + + final result = await _fetch(state.page + 1); + if (state.query != query) return; + + emit( + result + .fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (page) => state.copyWith( + items: [...state.items, ...page.items], + page: page.page, + totalPages: page.totalPages, + ), + ) + .copyWith(isLoadingMore: false), + ); + }, + ); + } + + Future _fetchFirstPage(Emitter emit) async { + final query = state.query; + emit( + state.copyWith( + isFetching: true, + items: [], + page: 0, + totalPages: 0, + failureOption: none(), + ), + ); + + final result = await _fetch(1); + // Tab / filter sudah berganti selama request berjalan. + if (state.query != query) return; + + emit( + result + .fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (page) => state.copyWith( + items: page.items, + page: page.page, + totalPages: page.totalPages, + ), + ) + .copyWith(isFetching: false), + ); + } + + Future> _fetch(int page) => + _repository.getTransactions( + page: page, + limit: _limit, + currency: state.currency, + types: state.types, + from: state.from, + to: state.to, + ); +} diff --git a/lib/application/wallet/wallet_history_loader/wallet_history_loader_bloc.freezed.dart b/lib/application/wallet/wallet_history_loader/wallet_history_loader_bloc.freezed.dart new file mode 100644 index 0000000..9b0e934 --- /dev/null +++ b/lib/application/wallet/wallet_history_loader/wallet_history_loader_bloc.freezed.dart @@ -0,0 +1,706 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'wallet_history_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$WalletHistoryLoaderEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletHistoryLoaderEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletHistoryLoaderEvent()'; +} + + +} + +/// @nodoc +class $WalletHistoryLoaderEventCopyWith<$Res> { +$WalletHistoryLoaderEventCopyWith(WalletHistoryLoaderEvent _, $Res Function(WalletHistoryLoaderEvent) __); +} + + +/// Adds pattern-matching-related methods to [WalletHistoryLoaderEvent]. +extension WalletHistoryLoaderEventPatterns on WalletHistoryLoaderEvent { +/// 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( _CurrencyChanged value)? currencyChanged,TResult Function( _FilterChanged value)? filterChanged,TResult Function( _Refreshed value)? refreshed,TResult Function( _LoadedMore value)? loadedMore,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that);case _FilterChanged() when filterChanged != null: +return filterChanged(_that);case _Refreshed() when refreshed != null: +return refreshed(_that);case _LoadedMore() when loadedMore != null: +return loadedMore(_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({required TResult Function( _CurrencyChanged value) currencyChanged,required TResult Function( _FilterChanged value) filterChanged,required TResult Function( _Refreshed value) refreshed,required TResult Function( _LoadedMore value) loadedMore,}){ +final _that = this; +switch (_that) { +case _CurrencyChanged(): +return currencyChanged(_that);case _FilterChanged(): +return filterChanged(_that);case _Refreshed(): +return refreshed(_that);case _LoadedMore(): +return loadedMore(_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( _CurrencyChanged value)? currencyChanged,TResult? Function( _FilterChanged value)? filterChanged,TResult? Function( _Refreshed value)? refreshed,TResult? Function( _LoadedMore value)? loadedMore,}){ +final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that);case _FilterChanged() when filterChanged != null: +return filterChanged(_that);case _Refreshed() when refreshed != null: +return refreshed(_that);case _LoadedMore() when loadedMore != null: +return loadedMore(_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( WalletCurrency currency)? currencyChanged,TResult Function( List types, DateTime? from, DateTime? to)? filterChanged,TResult Function()? refreshed,TResult Function()? loadedMore,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that.currency);case _FilterChanged() when filterChanged != null: +return filterChanged(_that.types,_that.from,_that.to);case _Refreshed() when refreshed != null: +return refreshed();case _LoadedMore() when loadedMore != null: +return loadedMore();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({required TResult Function( WalletCurrency currency) currencyChanged,required TResult Function( List types, DateTime? from, DateTime? to) filterChanged,required TResult Function() refreshed,required TResult Function() loadedMore,}) {final _that = this; +switch (_that) { +case _CurrencyChanged(): +return currencyChanged(_that.currency);case _FilterChanged(): +return filterChanged(_that.types,_that.from,_that.to);case _Refreshed(): +return refreshed();case _LoadedMore(): +return loadedMore();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( WalletCurrency currency)? currencyChanged,TResult? Function( List types, DateTime? from, DateTime? to)? filterChanged,TResult? Function()? refreshed,TResult? Function()? loadedMore,}) {final _that = this; +switch (_that) { +case _CurrencyChanged() when currencyChanged != null: +return currencyChanged(_that.currency);case _FilterChanged() when filterChanged != null: +return filterChanged(_that.types,_that.from,_that.to);case _Refreshed() when refreshed != null: +return refreshed();case _LoadedMore() when loadedMore != null: +return loadedMore();case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CurrencyChanged implements WalletHistoryLoaderEvent { + const _CurrencyChanged(this.currency); + + + final WalletCurrency currency; + +/// Create a copy of WalletHistoryLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CurrencyChangedCopyWith<_CurrencyChanged> get copyWith => __$CurrencyChangedCopyWithImpl<_CurrencyChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CurrencyChanged&&(identical(other.currency, currency) || other.currency == currency)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,currency); +} + +@override +String toString() { + return 'WalletHistoryLoaderEvent.currencyChanged(currency: $currency)'; +} + + +} + +/// @nodoc +abstract mixin class _$CurrencyChangedCopyWith<$Res> implements $WalletHistoryLoaderEventCopyWith<$Res> { + factory _$CurrencyChangedCopyWith(_CurrencyChanged value, $Res Function(_CurrencyChanged) _then) = __$CurrencyChangedCopyWithImpl; +@useResult +$Res call({ + WalletCurrency currency +}); + + + + +} +/// @nodoc +class __$CurrencyChangedCopyWithImpl<$Res> + implements _$CurrencyChangedCopyWith<$Res> { + __$CurrencyChangedCopyWithImpl(this._self, this._then); + + final _CurrencyChanged _self; + final $Res Function(_CurrencyChanged) _then; + +/// Create a copy of WalletHistoryLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? currency = null,}) { + return _then(_CurrencyChanged( +null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency, + )); +} + + +} + +/// @nodoc + + +class _FilterChanged implements WalletHistoryLoaderEvent { + const _FilterChanged({required List types, this.from, this.to}): _types = types; + + + final List _types; + List get types { + if (_types is EqualUnmodifiableListView) return _types; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_types); +} + + final DateTime? from; + final DateTime? to; + +/// Create a copy of WalletHistoryLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$FilterChangedCopyWith<_FilterChanged> get copyWith => __$FilterChangedCopyWithImpl<_FilterChanged>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _FilterChanged&&const DeepCollectionEquality().equals(other.types, _types)&&(identical(other.from, from) || other.from == from)&&(identical(other.to, to) || other.to == to)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_types),from,to); +} + +@override +String toString() { + return 'WalletHistoryLoaderEvent.filterChanged(types: $types, from: $from, to: $to)'; +} + + +} + +/// @nodoc +abstract mixin class _$FilterChangedCopyWith<$Res> implements $WalletHistoryLoaderEventCopyWith<$Res> { + factory _$FilterChangedCopyWith(_FilterChanged value, $Res Function(_FilterChanged) _then) = __$FilterChangedCopyWithImpl; +@useResult +$Res call({ + List types, DateTime? from, DateTime? to +}); + + + + +} +/// @nodoc +class __$FilterChangedCopyWithImpl<$Res> + implements _$FilterChangedCopyWith<$Res> { + __$FilterChangedCopyWithImpl(this._self, this._then); + + final _FilterChanged _self; + final $Res Function(_FilterChanged) _then; + +/// Create a copy of WalletHistoryLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? types = null,Object? from = freezed,Object? to = freezed,}) { + return _then(_FilterChanged( +types: null == types ? _self._types : types // ignore: cast_nullable_to_non_nullable +as List,from: freezed == from ? _self.from : from // ignore: cast_nullable_to_non_nullable +as DateTime?,to: freezed == to ? _self.to : to // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +/// @nodoc + + +class _Refreshed implements WalletHistoryLoaderEvent { + const _Refreshed(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Refreshed); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletHistoryLoaderEvent.refreshed()'; +} + + +} + + + + +/// @nodoc + + +class _LoadedMore implements WalletHistoryLoaderEvent { + const _LoadedMore(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoadedMore); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletHistoryLoaderEvent.loadedMore()'; +} + + +} + + + + +/// @nodoc +mixin _$WalletHistoryLoaderState { + + WalletCurrency get currency; List get types; DateTime? get from; DateTime? get to; List get items; int get page; int get totalPages; Option get failureOption; bool get isFetching; bool get isLoadingMore; +/// Create a copy of WalletHistoryLoaderState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletHistoryLoaderStateCopyWith get copyWith => _$WalletHistoryLoaderStateCopyWithImpl(this as WalletHistoryLoaderState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletHistoryLoaderState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletHistoryLoaderState&&(identical(other.currency, _this.currency) || other.currency == _this.currency)&&const DeepCollectionEquality().equals(other.types, _this.types)&&(identical(other.from, _this.from) || other.from == _this.from)&&(identical(other.to, _this.to) || other.to == _this.to)&&const DeepCollectionEquality().equals(other.items, _this.items)&&(identical(other.page, _this.page) || other.page == _this.page)&&(identical(other.totalPages, _this.totalPages) || other.totalPages == _this.totalPages)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)&&(identical(other.isLoadingMore, _this.isLoadingMore) || other.isLoadingMore == _this.isLoadingMore)); +} + + +@override +int get hashCode { + final _this = this as WalletHistoryLoaderState; + return Object.hash(runtimeType,_this.currency,const DeepCollectionEquality().hash(_this.types),_this.from,_this.to,const DeepCollectionEquality().hash(_this.items),_this.page,_this.totalPages,_this.failureOption,_this.isFetching,_this.isLoadingMore); +} + +@override +String toString() { + final _this = this as WalletHistoryLoaderState; + return 'WalletHistoryLoaderState(currency: ${_this.currency}, types: ${_this.types}, from: ${_this.from}, to: ${_this.to}, items: ${_this.items}, page: ${_this.page}, totalPages: ${_this.totalPages}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching}, isLoadingMore: ${_this.isLoadingMore})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletHistoryLoaderStateCopyWith<$Res> { + factory $WalletHistoryLoaderStateCopyWith(WalletHistoryLoaderState value, $Res Function(WalletHistoryLoaderState) _then) = _$WalletHistoryLoaderStateCopyWithImpl; +@useResult +$Res call({ + WalletCurrency currency, List types, DateTime? from, DateTime? to, List items, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore +}); + + + + +} +/// @nodoc +class _$WalletHistoryLoaderStateCopyWithImpl<$Res> + implements $WalletHistoryLoaderStateCopyWith<$Res> { + _$WalletHistoryLoaderStateCopyWithImpl(this._self, this._then); + + final WalletHistoryLoaderState _self; + final $Res Function(WalletHistoryLoaderState) _then; + +/// Create a copy of WalletHistoryLoaderState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? currency = null,Object? types = null,Object? from = freezed,Object? to = freezed,Object? items = null,Object? page = null,Object? totalPages = null,Object? failureOption = null,Object? isFetching = null,Object? isLoadingMore = null,}) { + return _then(WalletHistoryLoaderState( +currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,types: null == types ? _self.types : types // ignore: cast_nullable_to_non_nullable +as List,from: freezed == from ? _self.from : from // ignore: cast_nullable_to_non_nullable +as DateTime?,to: freezed == to ? _self.to : to // ignore: cast_nullable_to_non_nullable +as DateTime?,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletHistoryLoaderState]. +extension WalletHistoryLoaderStatePatterns on WalletHistoryLoaderState { +/// 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( _WalletHistoryLoaderState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletHistoryLoaderState() 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( _WalletHistoryLoaderState value) $default,){ +final _that = this; +switch (_that) { +case _WalletHistoryLoaderState(): +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( _WalletHistoryLoaderState value)? $default,){ +final _that = this; +switch (_that) { +case _WalletHistoryLoaderState() 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( WalletCurrency currency, List types, DateTime? from, DateTime? to, List items, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletHistoryLoaderState() when $default != null: +return $default(_that.currency,_that.types,_that.from,_that.to,_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_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( WalletCurrency currency, List types, DateTime? from, DateTime? to, List items, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore) $default,) {final _that = this; +switch (_that) { +case _WalletHistoryLoaderState(): +return $default(_that.currency,_that.types,_that.from,_that.to,_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_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( WalletCurrency currency, List types, DateTime? from, DateTime? to, List items, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore)? $default,) {final _that = this; +switch (_that) { +case _WalletHistoryLoaderState() when $default != null: +return $default(_that.currency,_that.types,_that.from,_that.to,_that.items,_that.page,_that.totalPages,_that.failureOption,_that.isFetching,_that.isLoadingMore);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletHistoryLoaderState extends WalletHistoryLoaderState { + const _WalletHistoryLoaderState({required this.currency, required List types, this.from, this.to, required List items, required this.page, required this.totalPages, required this.failureOption, this.isFetching = false, this.isLoadingMore = false}): _types = types,_items = items,super._(); + + +@override final WalletCurrency currency; + final List _types; +@override List get types { + if (_types is EqualUnmodifiableListView) return _types; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_types); +} + +@override final DateTime? from; +@override final DateTime? to; + final List _items; +@override List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); +} + +@override final int page; +@override final int totalPages; +@override final Option failureOption; +@override@JsonKey() final bool isFetching; +@override@JsonKey() final bool isLoadingMore; + +/// Create a copy of WalletHistoryLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletHistoryLoaderStateCopyWith<_WalletHistoryLoaderState> get copyWith => __$WalletHistoryLoaderStateCopyWithImpl<_WalletHistoryLoaderState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletHistoryLoaderState&&(identical(other.currency, currency) || other.currency == currency)&&const DeepCollectionEquality().equals(other.types, _types)&&(identical(other.from, from) || other.from == from)&&(identical(other.to, to) || other.to == to)&&const DeepCollectionEquality().equals(other.items, _items)&&(identical(other.page, page) || other.page == page)&&(identical(other.totalPages, totalPages) || other.totalPages == totalPages)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,currency,const DeepCollectionEquality().hash(_types),from,to,const DeepCollectionEquality().hash(_items),page,totalPages,failureOption,isFetching,isLoadingMore); +} + +@override +String toString() { + return 'WalletHistoryLoaderState(currency: $currency, types: $types, from: $from, to: $to, items: $items, page: $page, totalPages: $totalPages, failureOption: $failureOption, isFetching: $isFetching, isLoadingMore: $isLoadingMore)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletHistoryLoaderStateCopyWith<$Res> implements $WalletHistoryLoaderStateCopyWith<$Res> { + factory _$WalletHistoryLoaderStateCopyWith(_WalletHistoryLoaderState value, $Res Function(_WalletHistoryLoaderState) _then) = __$WalletHistoryLoaderStateCopyWithImpl; +@override @useResult +$Res call({ + WalletCurrency currency, List types, DateTime? from, DateTime? to, List items, int page, int totalPages, Option failureOption, bool isFetching, bool isLoadingMore +}); + + + + +} +/// @nodoc +class __$WalletHistoryLoaderStateCopyWithImpl<$Res> + implements _$WalletHistoryLoaderStateCopyWith<$Res> { + __$WalletHistoryLoaderStateCopyWithImpl(this._self, this._then); + + final _WalletHistoryLoaderState _self; + final $Res Function(_WalletHistoryLoaderState) _then; + +/// Create a copy of WalletHistoryLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? currency = null,Object? types = null,Object? from = freezed,Object? to = freezed,Object? items = null,Object? page = null,Object? totalPages = null,Object? failureOption = null,Object? isFetching = null,Object? isLoadingMore = null,}) { + return _then(_WalletHistoryLoaderState( +currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,types: null == types ? _self._types : types // ignore: cast_nullable_to_non_nullable +as List,from: freezed == from ? _self.from : from // ignore: cast_nullable_to_non_nullable +as DateTime?,to: freezed == to ? _self.to : to // ignore: cast_nullable_to_non_nullable +as DateTime?,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +// dart format on diff --git a/lib/application/wallet/wallet_history_loader/wallet_history_loader_event.dart b/lib/application/wallet/wallet_history_loader/wallet_history_loader_event.dart new file mode 100644 index 0000000..33183d9 --- /dev/null +++ b/lib/application/wallet/wallet_history_loader/wallet_history_loader_event.dart @@ -0,0 +1,18 @@ +part of 'wallet_history_loader_bloc.dart'; + +@freezed +abstract class WalletHistoryLoaderEvent with _$WalletHistoryLoaderEvent { + const factory WalletHistoryLoaderEvent.currencyChanged( + WalletCurrency currency, + ) = _CurrencyChanged; + + const factory WalletHistoryLoaderEvent.filterChanged({ + required List types, + DateTime? from, + DateTime? to, + }) = _FilterChanged; + + const factory WalletHistoryLoaderEvent.refreshed() = _Refreshed; + + const factory WalletHistoryLoaderEvent.loadedMore() = _LoadedMore; +} diff --git a/lib/application/wallet/wallet_history_loader/wallet_history_loader_state.dart b/lib/application/wallet/wallet_history_loader/wallet_history_loader_state.dart new file mode 100644 index 0000000..3da9468 --- /dev/null +++ b/lib/application/wallet/wallet_history_loader/wallet_history_loader_state.dart @@ -0,0 +1,35 @@ +part of 'wallet_history_loader_bloc.dart'; + +@freezed +abstract class WalletHistoryLoaderState with _$WalletHistoryLoaderState { + const WalletHistoryLoaderState._(); + + const factory WalletHistoryLoaderState({ + required WalletCurrency currency, + required List types, + DateTime? from, + DateTime? to, + required List items, + required int page, + required int totalPages, + required Option failureOption, + @Default(false) bool isFetching, + @Default(false) bool isLoadingMore, + }) = _WalletHistoryLoaderState; + + factory WalletHistoryLoaderState.initial() => WalletHistoryLoaderState( + currency: WalletCurrency.point, + types: const [], + items: const [], + page: 0, + totalPages: 0, + failureOption: none(), + ); + + bool get hasMore => page < totalPages; + + bool get hasFilter => types.isNotEmpty || from != null || to != null; + + /// Identitas query aktif, untuk membuang jawaban yang sudah basi. + String get query => '${currency.apiValue}|${types.join(',')}|$from|$to'; +} diff --git a/lib/application/wallet/wallet_loader/wallet_loader_bloc.dart b/lib/application/wallet/wallet_loader/wallet_loader_bloc.dart new file mode 100644 index 0000000..6da764c --- /dev/null +++ b/lib/application/wallet/wallet_loader/wallet_loader_bloc.dart @@ -0,0 +1,47 @@ +import 'package:bloc/bloc.dart'; +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; + +part 'wallet_loader_event.dart'; +part 'wallet_loader_state.dart'; +part 'wallet_loader_bloc.freezed.dart'; + +@injectable +class WalletLoaderBloc extends Bloc { + final IWalletRepository _repository; + + WalletLoaderBloc(this._repository) : super(WalletLoaderState.initial()) { + on(_onWalletLoaderEvent); + } + + Future _onWalletLoaderEvent( + WalletLoaderEvent event, + Emitter emit, + ) { + return event.map( + fetched: (e) async { + emit(state.copyWith(isFetching: true, failureOption: none())); + + final result = await _repository.getWallet(); + + final data = result.fold( + (f) => state.copyWith(failureOption: optionOf(f)), + (summary) => state.copyWith(summary: summary, hasLoaded: true), + ); + + emit(data.copyWith(isFetching: false)); + }, + coinBalanceUpdated: (e) async { + emit( + state.copyWith( + summary: state.summary.copyWith(coinBalance: e.coinBalance), + ), + ); + }, + cleared: (e) async => emit(WalletLoaderState.initial()), + ); + } +} diff --git a/lib/application/wallet/wallet_loader/wallet_loader_bloc.freezed.dart b/lib/application/wallet/wallet_loader/wallet_loader_bloc.freezed.dart new file mode 100644 index 0000000..cdd4410 --- /dev/null +++ b/lib/application/wallet/wallet_loader/wallet_loader_bloc.freezed.dart @@ -0,0 +1,610 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'wallet_loader_bloc.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$WalletLoaderEvent { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletLoaderEvent); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletLoaderEvent()'; +} + + +} + +/// @nodoc +class $WalletLoaderEventCopyWith<$Res> { +$WalletLoaderEventCopyWith(WalletLoaderEvent _, $Res Function(WalletLoaderEvent) __); +} + + +/// Adds pattern-matching-related methods to [WalletLoaderEvent]. +extension WalletLoaderEventPatterns on WalletLoaderEvent { +/// 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( _Fetched value)? fetched,TResult Function( _CoinBalanceUpdated value)? coinBalanceUpdated,TResult Function( _Cleared value)? cleared,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_that);case _CoinBalanceUpdated() when coinBalanceUpdated != null: +return coinBalanceUpdated(_that);case _Cleared() when cleared != null: +return cleared(_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({required TResult Function( _Fetched value) fetched,required TResult Function( _CoinBalanceUpdated value) coinBalanceUpdated,required TResult Function( _Cleared value) cleared,}){ +final _that = this; +switch (_that) { +case _Fetched(): +return fetched(_that);case _CoinBalanceUpdated(): +return coinBalanceUpdated(_that);case _Cleared(): +return cleared(_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( _Fetched value)? fetched,TResult? Function( _CoinBalanceUpdated value)? coinBalanceUpdated,TResult? Function( _Cleared value)? cleared,}){ +final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched(_that);case _CoinBalanceUpdated() when coinBalanceUpdated != null: +return coinBalanceUpdated(_that);case _Cleared() when cleared != null: +return cleared(_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()? fetched,TResult Function( int coinBalance)? coinBalanceUpdated,TResult Function()? cleared,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();case _CoinBalanceUpdated() when coinBalanceUpdated != null: +return coinBalanceUpdated(_that.coinBalance);case _Cleared() when cleared != null: +return cleared();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({required TResult Function() fetched,required TResult Function( int coinBalance) coinBalanceUpdated,required TResult Function() cleared,}) {final _that = this; +switch (_that) { +case _Fetched(): +return fetched();case _CoinBalanceUpdated(): +return coinBalanceUpdated(_that.coinBalance);case _Cleared(): +return cleared();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()? fetched,TResult? Function( int coinBalance)? coinBalanceUpdated,TResult? Function()? cleared,}) {final _that = this; +switch (_that) { +case _Fetched() when fetched != null: +return fetched();case _CoinBalanceUpdated() when coinBalanceUpdated != null: +return coinBalanceUpdated(_that.coinBalance);case _Cleared() when cleared != null: +return cleared();case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Fetched implements WalletLoaderEvent { + const _Fetched(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Fetched); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletLoaderEvent.fetched()'; +} + + +} + + + + +/// @nodoc + + +class _CoinBalanceUpdated implements WalletLoaderEvent { + const _CoinBalanceUpdated(this.coinBalance); + + + final int coinBalance; + +/// Create a copy of WalletLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CoinBalanceUpdatedCopyWith<_CoinBalanceUpdated> get copyWith => __$CoinBalanceUpdatedCopyWithImpl<_CoinBalanceUpdated>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CoinBalanceUpdated&&(identical(other.coinBalance, coinBalance) || other.coinBalance == coinBalance)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,coinBalance); +} + +@override +String toString() { + return 'WalletLoaderEvent.coinBalanceUpdated(coinBalance: $coinBalance)'; +} + + +} + +/// @nodoc +abstract mixin class _$CoinBalanceUpdatedCopyWith<$Res> implements $WalletLoaderEventCopyWith<$Res> { + factory _$CoinBalanceUpdatedCopyWith(_CoinBalanceUpdated value, $Res Function(_CoinBalanceUpdated) _then) = __$CoinBalanceUpdatedCopyWithImpl; +@useResult +$Res call({ + int coinBalance +}); + + + + +} +/// @nodoc +class __$CoinBalanceUpdatedCopyWithImpl<$Res> + implements _$CoinBalanceUpdatedCopyWith<$Res> { + __$CoinBalanceUpdatedCopyWithImpl(this._self, this._then); + + final _CoinBalanceUpdated _self; + final $Res Function(_CoinBalanceUpdated) _then; + +/// Create a copy of WalletLoaderEvent +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? coinBalance = null,}) { + return _then(_CoinBalanceUpdated( +null == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class _Cleared implements WalletLoaderEvent { + const _Cleared(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Cleared); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletLoaderEvent.cleared()'; +} + + +} + + + + +/// @nodoc +mixin _$WalletLoaderState { + + WalletSummary get summary; Option get failureOption; bool get isFetching; bool get hasLoaded; +/// Create a copy of WalletLoaderState +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletLoaderStateCopyWith get copyWith => _$WalletLoaderStateCopyWithImpl(this as WalletLoaderState, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletLoaderState; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletLoaderState&&(identical(other.summary, _this.summary) || other.summary == _this.summary)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching)&&(identical(other.hasLoaded, _this.hasLoaded) || other.hasLoaded == _this.hasLoaded)); +} + + +@override +int get hashCode { + final _this = this as WalletLoaderState; + return Object.hash(runtimeType,_this.summary,_this.failureOption,_this.isFetching,_this.hasLoaded); +} + +@override +String toString() { + final _this = this as WalletLoaderState; + return 'WalletLoaderState(summary: ${_this.summary}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching}, hasLoaded: ${_this.hasLoaded})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletLoaderStateCopyWith<$Res> { + factory $WalletLoaderStateCopyWith(WalletLoaderState value, $Res Function(WalletLoaderState) _then) = _$WalletLoaderStateCopyWithImpl; +@useResult +$Res call({ + WalletSummary summary, Option failureOption, bool isFetching, bool hasLoaded +}); + + +$WalletSummaryCopyWith<$Res> get summary; + +} +/// @nodoc +class _$WalletLoaderStateCopyWithImpl<$Res> + implements $WalletLoaderStateCopyWith<$Res> { + _$WalletLoaderStateCopyWithImpl(this._self, this._then); + + final WalletLoaderState _self; + final $Res Function(WalletLoaderState) _then; + +/// Create a copy of WalletLoaderState +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? summary = null,Object? failureOption = null,Object? isFetching = null,Object? hasLoaded = null,}) { + return _then(WalletLoaderState( +summary: null == summary ? _self.summary : summary // ignore: cast_nullable_to_non_nullable +as WalletSummary,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable +as bool, + )); +} +/// Create a copy of WalletLoaderState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$WalletSummaryCopyWith<$Res> get summary { + + return $WalletSummaryCopyWith<$Res>(_self.summary, (value) { + return _then(_self.copyWith(summary: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [WalletLoaderState]. +extension WalletLoaderStatePatterns on WalletLoaderState { +/// 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( _WalletLoaderState value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletLoaderState() 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( _WalletLoaderState value) $default,){ +final _that = this; +switch (_that) { +case _WalletLoaderState(): +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( _WalletLoaderState value)? $default,){ +final _that = this; +switch (_that) { +case _WalletLoaderState() 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( WalletSummary summary, Option failureOption, bool isFetching, bool hasLoaded)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletLoaderState() when $default != null: +return $default(_that.summary,_that.failureOption,_that.isFetching,_that.hasLoaded);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( WalletSummary summary, Option failureOption, bool isFetching, bool hasLoaded) $default,) {final _that = this; +switch (_that) { +case _WalletLoaderState(): +return $default(_that.summary,_that.failureOption,_that.isFetching,_that.hasLoaded);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( WalletSummary summary, Option failureOption, bool isFetching, bool hasLoaded)? $default,) {final _that = this; +switch (_that) { +case _WalletLoaderState() when $default != null: +return $default(_that.summary,_that.failureOption,_that.isFetching,_that.hasLoaded);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletLoaderState implements WalletLoaderState { + const _WalletLoaderState({required this.summary, required this.failureOption, this.isFetching = false, this.hasLoaded = false}); + + +@override final WalletSummary summary; +@override final Option failureOption; +@override@JsonKey() final bool isFetching; +@override@JsonKey() final bool hasLoaded; + +/// Create a copy of WalletLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletLoaderStateCopyWith<_WalletLoaderState> get copyWith => __$WalletLoaderStateCopyWithImpl<_WalletLoaderState>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletLoaderState&&(identical(other.summary, summary) || other.summary == summary)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching)&&(identical(other.hasLoaded, hasLoaded) || other.hasLoaded == hasLoaded)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,summary,failureOption,isFetching,hasLoaded); +} + +@override +String toString() { + return 'WalletLoaderState(summary: $summary, failureOption: $failureOption, isFetching: $isFetching, hasLoaded: $hasLoaded)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletLoaderStateCopyWith<$Res> implements $WalletLoaderStateCopyWith<$Res> { + factory _$WalletLoaderStateCopyWith(_WalletLoaderState value, $Res Function(_WalletLoaderState) _then) = __$WalletLoaderStateCopyWithImpl; +@override @useResult +$Res call({ + WalletSummary summary, Option failureOption, bool isFetching, bool hasLoaded +}); + + +@override $WalletSummaryCopyWith<$Res> get summary; + +} +/// @nodoc +class __$WalletLoaderStateCopyWithImpl<$Res> + implements _$WalletLoaderStateCopyWith<$Res> { + __$WalletLoaderStateCopyWithImpl(this._self, this._then); + + final _WalletLoaderState _self; + final $Res Function(_WalletLoaderState) _then; + +/// Create a copy of WalletLoaderState +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? summary = null,Object? failureOption = null,Object? isFetching = null,Object? hasLoaded = null,}) { + return _then(_WalletLoaderState( +summary: null == summary ? _self.summary : summary // ignore: cast_nullable_to_non_nullable +as WalletSummary,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable +as Option,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable +as bool,hasLoaded: null == hasLoaded ? _self.hasLoaded : hasLoaded // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of WalletLoaderState +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$WalletSummaryCopyWith<$Res> get summary { + + return $WalletSummaryCopyWith<$Res>(_self.summary, (value) { + return _then(_self.copyWith(summary: value)); + }); +} +} + +// dart format on diff --git a/lib/application/wallet/wallet_loader/wallet_loader_event.dart b/lib/application/wallet/wallet_loader/wallet_loader_event.dart new file mode 100644 index 0000000..ff00d33 --- /dev/null +++ b/lib/application/wallet/wallet_loader/wallet_loader_event.dart @@ -0,0 +1,13 @@ +part of 'wallet_loader_bloc.dart'; + +@freezed +abstract class WalletLoaderEvent with _$WalletLoaderEvent { + const factory WalletLoaderEvent.fetched() = _Fetched; + + /// Saldo EnakCoin terbaru dari hasil main game (`coins_remaining`). + const factory WalletLoaderEvent.coinBalanceUpdated(int coinBalance) = + _CoinBalanceUpdated; + + /// Dipanggil saat logout supaya saldo akun sebelumnya tidak tertampil. + const factory WalletLoaderEvent.cleared() = _Cleared; +} diff --git a/lib/application/wallet/wallet_loader/wallet_loader_state.dart b/lib/application/wallet/wallet_loader/wallet_loader_state.dart new file mode 100644 index 0000000..1cea97f --- /dev/null +++ b/lib/application/wallet/wallet_loader/wallet_loader_state.dart @@ -0,0 +1,14 @@ +part of 'wallet_loader_bloc.dart'; + +@freezed +abstract class WalletLoaderState with _$WalletLoaderState { + const factory WalletLoaderState({ + required WalletSummary summary, + required Option failureOption, + @Default(false) bool isFetching, + @Default(false) bool hasLoaded, + }) = _WalletLoaderState; + + factory WalletLoaderState.initial() => + WalletLoaderState(summary: WalletSummary.empty(), failureOption: none()); +} diff --git a/lib/common/api/api_client.dart b/lib/common/api/api_client.dart index 5e2aafe..0c6554b 100644 --- a/lib/common/api/api_client.dart +++ b/lib/common/api/api_client.dart @@ -17,6 +17,7 @@ import 'interceptors/bad_request_interceptor.dart'; import 'interceptors/connection_timeout_interceptor.dart'; import 'interceptors/internal_server_interceptor.dart'; import 'interceptors/not_found_interceptor.dart'; +import 'interceptors/sensitive_aware_log_interceptor.dart'; import 'interceptors/unauthorized_interceptor.dart'; @lazySingleton @@ -37,10 +38,12 @@ class ApiClient { if (kDebugMode) { _dio.interceptors.add( - AwesomeDioInterceptor( - logResponseHeaders: false, - logRequestTimeout: false, - logRequestHeaders: true, + SensitiveAwareLogInterceptor( + AwesomeDioInterceptor( + logResponseHeaders: false, + logRequestTimeout: false, + logRequestHeaders: true, + ), ), ); } @@ -54,6 +57,7 @@ class ApiClient { bool followRedirects = true, bool Function(int?)? validateStatus, String? contentType, + Map? extra, }) async { try { return await _dio.post( @@ -64,6 +68,7 @@ class ApiClient { followRedirects: followRedirects, validateStatus: validateStatus, contentType: contentType, + extra: extra, ), queryParameters: params, ); @@ -103,6 +108,7 @@ class ApiClient { bool followRedirects = true, bool Function(int?)? validateStatus, String? contentType, + Map? extra, }) async { try { return await _dio.get( @@ -112,6 +118,7 @@ class ApiClient { followRedirects: followRedirects, validateStatus: validateStatus, contentType: contentType, + extra: extra, ), queryParameters: params, ); @@ -153,6 +160,7 @@ class ApiClient { bool Function(int?)? validateStatus, String? contentType, void Function(int count, int total)? onSendProgress, + Map? extra, }) async { try { return await _dio.put( @@ -163,6 +171,7 @@ class ApiClient { followRedirects: followRedirects, validateStatus: validateStatus, contentType: contentType, + extra: extra, ), queryParameters: params, onSendProgress: onSendProgress, @@ -204,6 +213,7 @@ class ApiClient { bool followRedirects = true, bool Function(int?)? validateStatus, String? contentType, + Map? extra, }) async { try { return await _dio.delete( @@ -214,6 +224,7 @@ class ApiClient { followRedirects: followRedirects, validateStatus: validateStatus, contentType: contentType, + extra: extra, ), queryParameters: params, ); diff --git a/lib/common/api/api_failure.freezed.dart b/lib/common/api/api_failure.freezed.dart index aac5bd3..a47fa2b 100644 --- a/lib/common/api/api_failure.freezed.dart +++ b/lib/common/api/api_failure.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'api_failure.dart'; @@ -9,1498 +9,641 @@ part of 'api_failure.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$ApiFailure { - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is ApiFailure); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'ApiFailure()'; +} + + } /// @nodoc -abstract class $ApiFailureCopyWith<$Res> { - factory $ApiFailureCopyWith( - ApiFailure value, - $Res Function(ApiFailure) then, - ) = _$ApiFailureCopyWithImpl<$Res, ApiFailure>; +class $ApiFailureCopyWith<$Res> { +$ApiFailureCopyWith(ApiFailure _, $Res Function(ApiFailure) __); } -/// @nodoc -class _$ApiFailureCopyWithImpl<$Res, $Val extends ApiFailure> - implements $ApiFailureCopyWith<$Res> { - _$ApiFailureCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [ApiFailure]. +extension ApiFailurePatterns on ApiFailure { +/// 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(); +/// } +/// ``` - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _ServerError value)? serverError,TResult Function( _UnexpectedError value)? unexpectedError,TResult Function( _ConnectionError value)? connectionError,TResult Function( _InternalServerError value)? internalServerError,TResult Function( _Unauthorized value)? unauthorized,TResult Function( _BadRequest value)? badRequest,TResult Function( _NotFound value)? notFound,TResult Function( _ConnectionTimeout value)? connectionTimeout,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _ConnectionError() when connectionError != null: +return connectionError(_that);case _InternalServerError() when internalServerError != null: +return internalServerError(_that);case _Unauthorized() when unauthorized != null: +return unauthorized(_that);case _BadRequest() when badRequest != null: +return badRequest(_that);case _NotFound() when notFound != null: +return notFound(_that);case _ConnectionTimeout() when connectionTimeout != null: +return connectionTimeout(_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({required TResult Function( _ServerError value) serverError,required TResult Function( _UnexpectedError value) unexpectedError,required TResult Function( _ConnectionError value) connectionError,required TResult Function( _InternalServerError value) internalServerError,required TResult Function( _Unauthorized value) unauthorized,required TResult Function( _BadRequest value) badRequest,required TResult Function( _NotFound value) notFound,required TResult Function( _ConnectionTimeout value) connectionTimeout,}){ +final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that);case _UnexpectedError(): +return unexpectedError(_that);case _ConnectionError(): +return connectionError(_that);case _InternalServerError(): +return internalServerError(_that);case _Unauthorized(): +return unauthorized(_that);case _BadRequest(): +return badRequest(_that);case _NotFound(): +return notFound(_that);case _ConnectionTimeout(): +return connectionTimeout(_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( _ServerError value)? serverError,TResult? Function( _UnexpectedError value)? unexpectedError,TResult? Function( _ConnectionError value)? connectionError,TResult? Function( _InternalServerError value)? internalServerError,TResult? Function( _Unauthorized value)? unauthorized,TResult? Function( _BadRequest value)? badRequest,TResult? Function( _NotFound value)? notFound,TResult? Function( _ConnectionTimeout value)? connectionTimeout,}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _ConnectionError() when connectionError != null: +return connectionError(_that);case _InternalServerError() when internalServerError != null: +return internalServerError(_that);case _Unauthorized() when unauthorized != null: +return unauthorized(_that);case _BadRequest() when badRequest != null: +return badRequest(_that);case _NotFound() when notFound != null: +return notFound(_that);case _ConnectionTimeout() when connectionTimeout != null: +return connectionTimeout(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen({TResult Function( int statusCode, Object errorMessage)? serverError,TResult Function( Object errorMessage, StackTrace stackTrace)? unexpectedError,TResult Function()? connectionError,TResult Function()? internalServerError,TResult Function( String? message)? unauthorized,TResult Function( String? message)? badRequest,TResult Function( String? message)? notFound,TResult Function()? connectionTimeout,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.statusCode,_that.errorMessage);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that.errorMessage,_that.stackTrace);case _ConnectionError() when connectionError != null: +return connectionError();case _InternalServerError() when internalServerError != null: +return internalServerError();case _Unauthorized() when unauthorized != null: +return unauthorized(_that.message);case _BadRequest() when badRequest != null: +return badRequest(_that.message);case _NotFound() when notFound != null: +return notFound(_that.message);case _ConnectionTimeout() when connectionTimeout != null: +return connectionTimeout();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({required TResult Function( int statusCode, Object errorMessage) serverError,required TResult Function( Object errorMessage, StackTrace stackTrace) unexpectedError,required TResult Function() connectionError,required TResult Function() internalServerError,required TResult Function( String? message) unauthorized,required TResult Function( String? message) badRequest,required TResult Function( String? message) notFound,required TResult Function() connectionTimeout,}) {final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that.statusCode,_that.errorMessage);case _UnexpectedError(): +return unexpectedError(_that.errorMessage,_that.stackTrace);case _ConnectionError(): +return connectionError();case _InternalServerError(): +return internalServerError();case _Unauthorized(): +return unauthorized(_that.message);case _BadRequest(): +return badRequest(_that.message);case _NotFound(): +return notFound(_that.message);case _ConnectionTimeout(): +return connectionTimeout();} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull({TResult? Function( int statusCode, Object errorMessage)? serverError,TResult? Function( Object errorMessage, StackTrace stackTrace)? unexpectedError,TResult? Function()? connectionError,TResult? Function()? internalServerError,TResult? Function( String? message)? unauthorized,TResult? Function( String? message)? badRequest,TResult? Function( String? message)? notFound,TResult? Function()? connectionTimeout,}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.statusCode,_that.errorMessage);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that.errorMessage,_that.stackTrace);case _ConnectionError() when connectionError != null: +return connectionError();case _InternalServerError() when internalServerError != null: +return internalServerError();case _Unauthorized() when unauthorized != null: +return unauthorized(_that.message);case _BadRequest() when badRequest != null: +return badRequest(_that.message);case _NotFound() when notFound != null: +return notFound(_that.message);case _ConnectionTimeout() when connectionTimeout != null: +return connectionTimeout();case _: + return null; + +} } -/// @nodoc -abstract class _$$ServerErrorImplCopyWith<$Res> { - factory _$$ServerErrorImplCopyWith( - _$ServerErrorImpl value, - $Res Function(_$ServerErrorImpl) then, - ) = __$$ServerErrorImplCopyWithImpl<$Res>; - @useResult - $Res call({int statusCode, Object errorMessage}); -} - -/// @nodoc -class __$$ServerErrorImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$ServerErrorImpl> - implements _$$ServerErrorImplCopyWith<$Res> { - __$$ServerErrorImplCopyWithImpl( - _$ServerErrorImpl _value, - $Res Function(_$ServerErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? statusCode = null, Object? errorMessage = null}) { - return _then( - _$ServerErrorImpl( - statusCode: null == statusCode - ? _value.statusCode - : statusCode // ignore: cast_nullable_to_non_nullable - as int, - errorMessage: null == errorMessage ? _value.errorMessage : errorMessage, - ), - ); - } } /// @nodoc -class _$ServerErrorImpl extends _ServerError { - const _$ServerErrorImpl({ - required this.statusCode, - required this.errorMessage, - }) : super._(); - @override - final int statusCode; - @override - final Object errorMessage; +class _ServerError extends ApiFailure { + const _ServerError({required this.statusCode, required this.errorMessage}): super._(); + - @override - String toString() { + final int statusCode; + final Object errorMessage; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ServerErrorCopyWith<_ServerError> get copyWith => __$ServerErrorCopyWithImpl<_ServerError>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServerError&&(identical(other.statusCode, statusCode) || other.statusCode == statusCode)&&const DeepCollectionEquality().equals(other.errorMessage, errorMessage)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,statusCode,const DeepCollectionEquality().hash(errorMessage)); +} + +@override +String toString() { return 'ApiFailure.serverError(statusCode: $statusCode, errorMessage: $errorMessage)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ServerErrorImpl && - (identical(other.statusCode, statusCode) || - other.statusCode == statusCode) && - const DeepCollectionEquality().equals( - other.errorMessage, - errorMessage, - )); - } - - @override - int get hashCode => Object.hash( - runtimeType, - statusCode, - const DeepCollectionEquality().hash(errorMessage), - ); - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - __$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return serverError(statusCode, errorMessage); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return serverError?.call(statusCode, errorMessage); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(statusCode, errorMessage); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return serverError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return serverError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(this); - } - return orElse(); - } } -abstract class _ServerError extends ApiFailure { - const factory _ServerError({ - required final int statusCode, - required final Object errorMessage, - }) = _$ServerErrorImpl; - const _ServerError._() : super._(); - int get statusCode; - Object get errorMessage; - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$UnexpectedErrorImplCopyWith<$Res> { - factory _$$UnexpectedErrorImplCopyWith( - _$UnexpectedErrorImpl value, - $Res Function(_$UnexpectedErrorImpl) then, - ) = __$$UnexpectedErrorImplCopyWithImpl<$Res>; - @useResult - $Res call({Object errorMessage, StackTrace stackTrace}); +abstract mixin class _$ServerErrorCopyWith<$Res> implements $ApiFailureCopyWith<$Res> { + factory _$ServerErrorCopyWith(_ServerError value, $Res Function(_ServerError) _then) = __$ServerErrorCopyWithImpl; +@useResult +$Res call({ + int statusCode, Object errorMessage +}); + + + + +} +/// @nodoc +class __$ServerErrorCopyWithImpl<$Res> + implements _$ServerErrorCopyWith<$Res> { + __$ServerErrorCopyWithImpl(this._self, this._then); + + final _ServerError _self; + final $Res Function(_ServerError) _then; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? statusCode = null,Object? errorMessage = null,}) { + return _then(_ServerError( +statusCode: null == statusCode ? _self.statusCode : statusCode // ignore: cast_nullable_to_non_nullable +as int,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage , + )); } -/// @nodoc -class __$$UnexpectedErrorImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl> - implements _$$UnexpectedErrorImplCopyWith<$Res> { - __$$UnexpectedErrorImplCopyWithImpl( - _$UnexpectedErrorImpl _value, - $Res Function(_$UnexpectedErrorImpl) _then, - ) : super(_value, _then); - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? errorMessage = null, Object? stackTrace = null}) { - return _then( - _$UnexpectedErrorImpl( - errorMessage: null == errorMessage ? _value.errorMessage : errorMessage, - stackTrace: null == stackTrace - ? _value.stackTrace - : stackTrace // ignore: cast_nullable_to_non_nullable - as StackTrace, - ), - ); - } } /// @nodoc -class _$UnexpectedErrorImpl extends _UnexpectedError { - const _$UnexpectedErrorImpl({ - required this.errorMessage, - required this.stackTrace, - }) : super._(); - @override - final Object errorMessage; - @override - final StackTrace stackTrace; +class _UnexpectedError extends ApiFailure { + const _UnexpectedError({required this.errorMessage, required this.stackTrace}): super._(); + - @override - String toString() { + final Object errorMessage; + final StackTrace stackTrace; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$UnexpectedErrorCopyWith<_UnexpectedError> get copyWith => __$UnexpectedErrorCopyWithImpl<_UnexpectedError>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _UnexpectedError&&const DeepCollectionEquality().equals(other.errorMessage, errorMessage)&&(identical(other.stackTrace, stackTrace) || other.stackTrace == stackTrace)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(errorMessage),stackTrace); +} + +@override +String toString() { return 'ApiFailure.unexpectedError(errorMessage: $errorMessage, stackTrace: $stackTrace)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$UnexpectedErrorImpl && - const DeepCollectionEquality().equals( - other.errorMessage, - errorMessage, - ) && - (identical(other.stackTrace, stackTrace) || - other.stackTrace == stackTrace)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(errorMessage), - stackTrace, - ); - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$UnexpectedErrorImplCopyWith<_$UnexpectedErrorImpl> get copyWith => - __$$UnexpectedErrorImplCopyWithImpl<_$UnexpectedErrorImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return unexpectedError(errorMessage, stackTrace); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return unexpectedError?.call(errorMessage, stackTrace); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(errorMessage, stackTrace); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return unexpectedError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return unexpectedError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(this); - } - return orElse(); - } } -abstract class _UnexpectedError extends ApiFailure { - const factory _UnexpectedError({ - required final Object errorMessage, - required final StackTrace stackTrace, - }) = _$UnexpectedErrorImpl; - const _UnexpectedError._() : super._(); - Object get errorMessage; - StackTrace get stackTrace; - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$UnexpectedErrorImplCopyWith<_$UnexpectedErrorImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$ConnectionErrorImplCopyWith<$Res> { - factory _$$ConnectionErrorImplCopyWith( - _$ConnectionErrorImpl value, - $Res Function(_$ConnectionErrorImpl) then, - ) = __$$ConnectionErrorImplCopyWithImpl<$Res>; +abstract mixin class _$UnexpectedErrorCopyWith<$Res> implements $ApiFailureCopyWith<$Res> { + factory _$UnexpectedErrorCopyWith(_UnexpectedError value, $Res Function(_UnexpectedError) _then) = __$UnexpectedErrorCopyWithImpl; +@useResult +$Res call({ + Object errorMessage, StackTrace stackTrace +}); + + + + +} +/// @nodoc +class __$UnexpectedErrorCopyWithImpl<$Res> + implements _$UnexpectedErrorCopyWith<$Res> { + __$UnexpectedErrorCopyWithImpl(this._self, this._then); + + final _UnexpectedError _self; + final $Res Function(_UnexpectedError) _then; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? errorMessage = null,Object? stackTrace = null,}) { + return _then(_UnexpectedError( +errorMessage: null == errorMessage ? _self.errorMessage : errorMessage ,stackTrace: null == stackTrace ? _self.stackTrace : stackTrace // ignore: cast_nullable_to_non_nullable +as StackTrace, + )); } -/// @nodoc -class __$$ConnectionErrorImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$ConnectionErrorImpl> - implements _$$ConnectionErrorImplCopyWith<$Res> { - __$$ConnectionErrorImplCopyWithImpl( - _$ConnectionErrorImpl _value, - $Res Function(_$ConnectionErrorImpl) _then, - ) : super(_value, _then); - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$ConnectionErrorImpl extends _ConnectionError { - const _$ConnectionErrorImpl() : super._(); - @override - String toString() { +class _ConnectionError extends ApiFailure { + const _ConnectionError(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ConnectionError); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'ApiFailure.connectionError()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$ConnectionErrorImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return connectionError(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return connectionError?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (connectionError != null) { - return connectionError(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return connectionError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return connectionError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (connectionError != null) { - return connectionError(this); - } - return orElse(); - } } -abstract class _ConnectionError extends ApiFailure { - const factory _ConnectionError() = _$ConnectionErrorImpl; - const _ConnectionError._() : super._(); + } -/// @nodoc -abstract class _$$InternalServerErrorImplCopyWith<$Res> { - factory _$$InternalServerErrorImplCopyWith( - _$InternalServerErrorImpl value, - $Res Function(_$InternalServerErrorImpl) then, - ) = __$$InternalServerErrorImplCopyWithImpl<$Res>; -} -/// @nodoc -class __$$InternalServerErrorImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$InternalServerErrorImpl> - implements _$$InternalServerErrorImplCopyWith<$Res> { - __$$InternalServerErrorImplCopyWithImpl( - _$InternalServerErrorImpl _value, - $Res Function(_$InternalServerErrorImpl) _then, - ) : super(_value, _then); - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. -} /// @nodoc -class _$InternalServerErrorImpl extends _InternalServerError { - const _$InternalServerErrorImpl() : super._(); - @override - String toString() { +class _InternalServerError extends ApiFailure { + const _InternalServerError(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _InternalServerError); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'ApiFailure.internalServerError()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$InternalServerErrorImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return internalServerError(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return internalServerError?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (internalServerError != null) { - return internalServerError(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return internalServerError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return internalServerError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (internalServerError != null) { - return internalServerError(this); - } - return orElse(); - } } -abstract class _InternalServerError extends ApiFailure { - const factory _InternalServerError() = _$InternalServerErrorImpl; - const _InternalServerError._() : super._(); + } -/// @nodoc -abstract class _$$UnauthorizedImplCopyWith<$Res> { - factory _$$UnauthorizedImplCopyWith( - _$UnauthorizedImpl value, - $Res Function(_$UnauthorizedImpl) then, - ) = __$$UnauthorizedImplCopyWithImpl<$Res>; - @useResult - $Res call({String? message}); -} -/// @nodoc -class __$$UnauthorizedImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$UnauthorizedImpl> - implements _$$UnauthorizedImplCopyWith<$Res> { - __$$UnauthorizedImplCopyWithImpl( - _$UnauthorizedImpl _value, - $Res Function(_$UnauthorizedImpl) _then, - ) : super(_value, _then); - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? message = freezed}) { - return _then( - _$UnauthorizedImpl( - freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } -} /// @nodoc -class _$UnauthorizedImpl extends _Unauthorized { - const _$UnauthorizedImpl(this.message) : super._(); - @override - final String? message; +class _Unauthorized extends ApiFailure { + const _Unauthorized(this.message): super._(); + - @override - String toString() { + final String? message; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$UnauthorizedCopyWith<_Unauthorized> get copyWith => __$UnauthorizedCopyWithImpl<_Unauthorized>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Unauthorized&&(identical(other.message, message) || other.message == message)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,message); +} + +@override +String toString() { return 'ApiFailure.unauthorized(message: $message)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$UnauthorizedImpl && - (identical(other.message, message) || other.message == message)); - } - - @override - int get hashCode => Object.hash(runtimeType, message); - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$UnauthorizedImplCopyWith<_$UnauthorizedImpl> get copyWith => - __$$UnauthorizedImplCopyWithImpl<_$UnauthorizedImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return unauthorized(message); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return unauthorized?.call(message); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (unauthorized != null) { - return unauthorized(message); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return unauthorized(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return unauthorized?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (unauthorized != null) { - return unauthorized(this); - } - return orElse(); - } } -abstract class _Unauthorized extends ApiFailure { - const factory _Unauthorized(final String? message) = _$UnauthorizedImpl; - const _Unauthorized._() : super._(); - String? get message; - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$UnauthorizedImplCopyWith<_$UnauthorizedImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$BadRequestImplCopyWith<$Res> { - factory _$$BadRequestImplCopyWith( - _$BadRequestImpl value, - $Res Function(_$BadRequestImpl) then, - ) = __$$BadRequestImplCopyWithImpl<$Res>; - @useResult - $Res call({String? message}); +abstract mixin class _$UnauthorizedCopyWith<$Res> implements $ApiFailureCopyWith<$Res> { + factory _$UnauthorizedCopyWith(_Unauthorized value, $Res Function(_Unauthorized) _then) = __$UnauthorizedCopyWithImpl; +@useResult +$Res call({ + String? message +}); + + + + +} +/// @nodoc +class __$UnauthorizedCopyWithImpl<$Res> + implements _$UnauthorizedCopyWith<$Res> { + __$UnauthorizedCopyWithImpl(this._self, this._then); + + final _Unauthorized _self; + final $Res Function(_Unauthorized) _then; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? message = freezed,}) { + return _then(_Unauthorized( +freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -class __$$BadRequestImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$BadRequestImpl> - implements _$$BadRequestImplCopyWith<$Res> { - __$$BadRequestImplCopyWithImpl( - _$BadRequestImpl _value, - $Res Function(_$BadRequestImpl) _then, - ) : super(_value, _then); - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? message = freezed}) { - return _then( - _$BadRequestImpl( - freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } } /// @nodoc -class _$BadRequestImpl extends _BadRequest { - const _$BadRequestImpl(this.message) : super._(); - @override - final String? message; +class _BadRequest extends ApiFailure { + const _BadRequest(this.message): super._(); + - @override - String toString() { + final String? message; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$BadRequestCopyWith<_BadRequest> get copyWith => __$BadRequestCopyWithImpl<_BadRequest>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _BadRequest&&(identical(other.message, message) || other.message == message)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,message); +} + +@override +String toString() { return 'ApiFailure.badRequest(message: $message)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$BadRequestImpl && - (identical(other.message, message) || other.message == message)); - } - - @override - int get hashCode => Object.hash(runtimeType, message); - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$BadRequestImplCopyWith<_$BadRequestImpl> get copyWith => - __$$BadRequestImplCopyWithImpl<_$BadRequestImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return badRequest(message); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return badRequest?.call(message); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (badRequest != null) { - return badRequest(message); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return badRequest(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return badRequest?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (badRequest != null) { - return badRequest(this); - } - return orElse(); - } } -abstract class _BadRequest extends ApiFailure { - const factory _BadRequest(final String? message) = _$BadRequestImpl; - const _BadRequest._() : super._(); - String? get message; - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$BadRequestImplCopyWith<_$BadRequestImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$NotFoundImplCopyWith<$Res> { - factory _$$NotFoundImplCopyWith( - _$NotFoundImpl value, - $Res Function(_$NotFoundImpl) then, - ) = __$$NotFoundImplCopyWithImpl<$Res>; - @useResult - $Res call({String? message}); +abstract mixin class _$BadRequestCopyWith<$Res> implements $ApiFailureCopyWith<$Res> { + factory _$BadRequestCopyWith(_BadRequest value, $Res Function(_BadRequest) _then) = __$BadRequestCopyWithImpl; +@useResult +$Res call({ + String? message +}); + + + + +} +/// @nodoc +class __$BadRequestCopyWithImpl<$Res> + implements _$BadRequestCopyWith<$Res> { + __$BadRequestCopyWithImpl(this._self, this._then); + + final _BadRequest _self; + final $Res Function(_BadRequest) _then; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? message = freezed,}) { + return _then(_BadRequest( +freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -class __$$NotFoundImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$NotFoundImpl> - implements _$$NotFoundImplCopyWith<$Res> { - __$$NotFoundImplCopyWithImpl( - _$NotFoundImpl _value, - $Res Function(_$NotFoundImpl) _then, - ) : super(_value, _then); - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? message = freezed}) { - return _then( - _$NotFoundImpl( - freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } } /// @nodoc -class _$NotFoundImpl extends _NotFound { - const _$NotFoundImpl(this.message) : super._(); - @override - final String? message; +class _NotFound extends ApiFailure { + const _NotFound(this.message): super._(); + - @override - String toString() { + final String? message; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NotFoundCopyWith<_NotFound> get copyWith => __$NotFoundCopyWithImpl<_NotFound>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotFound&&(identical(other.message, message) || other.message == message)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,message); +} + +@override +String toString() { return 'ApiFailure.notFound(message: $message)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NotFoundImpl && - (identical(other.message, message) || other.message == message)); - } - - @override - int get hashCode => Object.hash(runtimeType, message); - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NotFoundImplCopyWith<_$NotFoundImpl> get copyWith => - __$$NotFoundImplCopyWithImpl<_$NotFoundImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return notFound(message); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return notFound?.call(message); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (notFound != null) { - return notFound(message); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return notFound(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return notFound?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (notFound != null) { - return notFound(this); - } - return orElse(); - } } -abstract class _NotFound extends ApiFailure { - const factory _NotFound(final String? message) = _$NotFoundImpl; - const _NotFound._() : super._(); - String? get message; - - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NotFoundImplCopyWith<_$NotFoundImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$ConnectionTimeoutImplCopyWith<$Res> { - factory _$$ConnectionTimeoutImplCopyWith( - _$ConnectionTimeoutImpl value, - $Res Function(_$ConnectionTimeoutImpl) then, - ) = __$$ConnectionTimeoutImplCopyWithImpl<$Res>; +abstract mixin class _$NotFoundCopyWith<$Res> implements $ApiFailureCopyWith<$Res> { + factory _$NotFoundCopyWith(_NotFound value, $Res Function(_NotFound) _then) = __$NotFoundCopyWithImpl; +@useResult +$Res call({ + String? message +}); + + + + +} +/// @nodoc +class __$NotFoundCopyWithImpl<$Res> + implements _$NotFoundCopyWith<$Res> { + __$NotFoundCopyWithImpl(this._self, this._then); + + final _NotFound _self; + final $Res Function(_NotFound) _then; + +/// Create a copy of ApiFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? message = freezed,}) { + return _then(_NotFound( +freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -class __$$ConnectionTimeoutImplCopyWithImpl<$Res> - extends _$ApiFailureCopyWithImpl<$Res, _$ConnectionTimeoutImpl> - implements _$$ConnectionTimeoutImplCopyWith<$Res> { - __$$ConnectionTimeoutImplCopyWithImpl( - _$ConnectionTimeoutImpl _value, - $Res Function(_$ConnectionTimeoutImpl) _then, - ) : super(_value, _then); - /// Create a copy of ApiFailure - /// with the given fields replaced by the non-null parameter values. } /// @nodoc -class _$ConnectionTimeoutImpl extends _ConnectionTimeout { - const _$ConnectionTimeoutImpl() : super._(); - @override - String toString() { +class _ConnectionTimeout extends ApiFailure { + const _ConnectionTimeout(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ConnectionTimeout); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'ApiFailure.connectionTimeout()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$ConnectionTimeoutImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(int statusCode, Object errorMessage) serverError, - required TResult Function(Object errorMessage, StackTrace stackTrace) - unexpectedError, - required TResult Function() connectionError, - required TResult Function() internalServerError, - required TResult Function(String? message) unauthorized, - required TResult Function(String? message) badRequest, - required TResult Function(String? message) notFound, - required TResult Function() connectionTimeout, - }) { - return connectionTimeout(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(int statusCode, Object errorMessage)? serverError, - TResult? Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult? Function()? connectionError, - TResult? Function()? internalServerError, - TResult? Function(String? message)? unauthorized, - TResult? Function(String? message)? badRequest, - TResult? Function(String? message)? notFound, - TResult? Function()? connectionTimeout, - }) { - return connectionTimeout?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(int statusCode, Object errorMessage)? serverError, - TResult Function(Object errorMessage, StackTrace stackTrace)? - unexpectedError, - TResult Function()? connectionError, - TResult Function()? internalServerError, - TResult Function(String? message)? unauthorized, - TResult Function(String? message)? badRequest, - TResult Function(String? message)? notFound, - TResult Function()? connectionTimeout, - required TResult orElse(), - }) { - if (connectionTimeout != null) { - return connectionTimeout(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_ConnectionError value) connectionError, - required TResult Function(_InternalServerError value) internalServerError, - required TResult Function(_Unauthorized value) unauthorized, - required TResult Function(_BadRequest value) badRequest, - required TResult Function(_NotFound value) notFound, - required TResult Function(_ConnectionTimeout value) connectionTimeout, - }) { - return connectionTimeout(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_ConnectionError value)? connectionError, - TResult? Function(_InternalServerError value)? internalServerError, - TResult? Function(_Unauthorized value)? unauthorized, - TResult? Function(_BadRequest value)? badRequest, - TResult? Function(_NotFound value)? notFound, - TResult? Function(_ConnectionTimeout value)? connectionTimeout, - }) { - return connectionTimeout?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_ConnectionError value)? connectionError, - TResult Function(_InternalServerError value)? internalServerError, - TResult Function(_Unauthorized value)? unauthorized, - TResult Function(_BadRequest value)? badRequest, - TResult Function(_NotFound value)? notFound, - TResult Function(_ConnectionTimeout value)? connectionTimeout, - required TResult orElse(), - }) { - if (connectionTimeout != null) { - return connectionTimeout(this); - } - return orElse(); - } } -abstract class _ConnectionTimeout extends ApiFailure { - const factory _ConnectionTimeout() = _$ConnectionTimeoutImpl; - const _ConnectionTimeout._() : super._(); + } + + + + +// dart format on diff --git a/lib/common/api/interceptors/sensitive_aware_log_interceptor.dart b/lib/common/api/interceptors/sensitive_aware_log_interceptor.dart new file mode 100644 index 0000000..10ce1bd --- /dev/null +++ b/lib/common/api/interceptors/sensitive_aware_log_interceptor.dart @@ -0,0 +1,32 @@ +import 'package:dio/dio.dart'; + +/// Key untuk `Options.extra` yang menandai request berisi data rahasia +/// (PIN, OTP). Request bertanda ini tidak dicetak ke log sama sekali. +const String kSensitiveRequest = 'sensitive'; + +class SensitiveAwareLogInterceptor extends Interceptor { + final Interceptor _logger; + + SensitiveAwareLogInterceptor(this._logger); + + bool _isSensitive(RequestOptions options) => + options.extra[kSensitiveRequest] == true; + + @override + void onRequest(RequestOptions options, RequestInterceptorHandler handler) { + if (_isSensitive(options)) return handler.next(options); + _logger.onRequest(options, handler); + } + + @override + void onResponse(Response response, ResponseInterceptorHandler handler) { + if (_isSensitive(response.requestOptions)) return handler.next(response); + _logger.onResponse(response, handler); + } + + @override + void onError(DioException err, ErrorInterceptorHandler handler) { + if (_isSensitive(err.requestOptions)) return handler.next(err); + _logger.onError(err, handler); + } +} diff --git a/lib/common/constant/app_constant.dart b/lib/common/constant/app_constant.dart index 8c0a0f3..a53d17d 100644 --- a/lib/common/constant/app_constant.dart +++ b/lib/common/constant/app_constant.dart @@ -1,9 +1,15 @@ +import 'dart:ui'; + import '../../sample/sample_data.dart'; class AppConstant { static const String appName = "Enaklo"; static const String coinName = "EnakCoin"; - static const String poinName = "EnakPoin"; + static const String poinName = "EnakPoint"; + static const String gameUrl = "https://game.enaklo.com/"; + + /// `theme-color` game.enaklo.com. + static const Color gameBackgroundColor = Color(0xFF09090B); } MerchantModel merchant = merchants.first; diff --git a/lib/common/di/di_secure_storage.dart b/lib/common/di/di_secure_storage.dart new file mode 100644 index 0000000..99a9c9d --- /dev/null +++ b/lib/common/di/di_secure_storage.dart @@ -0,0 +1,8 @@ +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:injectable/injectable.dart'; + +@module +abstract class SecureStorageDi { + @lazySingleton + FlutterSecureStorage get secureStorage => const FlutterSecureStorage(); +} diff --git a/lib/common/extension/currency_extension.dart b/lib/common/extension/currency_extension.dart index e53fa46..285a9d4 100644 --- a/lib/common/extension/currency_extension.dart +++ b/lib/common/extension/currency_extension.dart @@ -25,4 +25,7 @@ extension IntegerExt on int { symbol: 'Rp ', decimalDigits: 0, ).format(this); + + /// Format ribuan Indonesia tanpa simbol: 12.500 + String get thousandFormat => NumberFormat.decimalPattern('id').format(this); } diff --git a/lib/common/extension/date_extension.dart b/lib/common/extension/date_extension.dart index 9486843..97af1f3 100644 --- a/lib/common/extension/date_extension.dart +++ b/lib/common/extension/date_extension.dart @@ -30,4 +30,13 @@ extension DateTimeIndonesia on DateTime { String get toHourMinute { return DateFormat('HH:mm', 'id_ID').format(this); } + + /// Waktu dinding WIB (UTC+7), apa pun zona waktu perangkat. + /// Hanya untuk ditampilkan; jangan dipakai untuk membandingkan waktu. + DateTime get toWib => toUtc().add(const Duration(hours: 7)); + + /// Format: 13 Agu 2025 20:00 + String get toShortDatetime { + return DateFormat('d MMM yyyy HH:mm', 'id_ID').format(this); + } } diff --git a/lib/common/function/app_function.dart b/lib/common/function/app_function.dart index d140a91..68277e9 100644 --- a/lib/common/function/app_function.dart +++ b/lib/common/function/app_function.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -18,6 +20,18 @@ String getNormalizePhone(String phoneNumber) { return '62$normalizedPhone'; } +/// UUID v4 acak dari [Random.secure], dipakai sebagai `Idempotency-Key` +/// dan `device_id`. +String generateUuidV4() { + final random = Random.secure(); + final bytes = List.generate(16, (_) => random.nextInt(256)); + bytes[6] = (bytes[6] & 0x0f) | 0x40; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + final hex = bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join(); + return '${hex.substring(0, 8)}-${hex.substring(8, 12)}-' + '${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}'; +} + Map getAuthorizationHeader() { return { 'Authorization': diff --git a/lib/common/url/api_path.dart b/lib/common/url/api_path.dart index 73854c9..d05545f 100644 --- a/lib/common/url/api_path.dart +++ b/lib/common/url/api_path.dart @@ -8,7 +8,30 @@ class ApiPath { // Marketing static String ferrisWheel = '/api/v1/customer/ferris-wheel'; + static String spin = '/api/v1/customer/spin'; - // Customer - static String customerPoint = '/api/v1/customer/points'; + // Wallet + static String wallet = '/api/v1/customer/wallet'; + static String walletTransactions = '/api/v1/customer/wallet/transactions'; + static String walletExpiring = '/api/v1/customer/wallet/expiring'; + static String walletPaymentCode = '/api/v1/customer/wallet/payment-code'; + static String walletExchangePreview = + '/api/v1/customer/wallet/exchange/preview'; + static String walletExchange = '/api/v1/customer/wallet/exchange'; + static String walletTransferRecipient = + '/api/v1/customer/wallet/transfer/recipient'; + static String walletTransfer = '/api/v1/customer/wallet/transfer'; + + // Outlet & order + static String outlets = '/api/v1/customer/outlets'; + static String orders = '/api/v1/customer/orders'; + + // PIN + static String pin = '/api/v1/customer/pin'; + static String pinStatus = '/api/v1/customer/pin/status'; + static String pinOtp = '/api/v1/customer/pin/otp'; + static String pinReset = '/api/v1/customer/pin/reset'; + + // Device (push notification) + static String devices = '/api/v1/customer/devices'; } diff --git a/lib/domain/auth/auth.freezed.dart b/lib/domain/auth/auth.freezed.dart index a9aa594..22af7df 100644 --- a/lib/domain/auth/auth.freezed.dart +++ b/lib/domain/auth/auth.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'auth.dart'; @@ -9,1746 +9,2009 @@ part of 'auth.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$CheckPhone { - CheckPhoneStatus get status => throw _privateConstructorUsedError; - String get message => throw _privateConstructorUsedError; - String get phoneNumber => throw _privateConstructorUsedError; - /// Create a copy of CheckPhone - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CheckPhoneCopyWith get copyWith => - throw _privateConstructorUsedError; + CheckPhoneStatus get status; String get message; String get phoneNumber; +/// Create a copy of CheckPhone +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CheckPhoneCopyWith get copyWith => _$CheckPhoneCopyWithImpl(this as CheckPhone, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as CheckPhone; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CheckPhone&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)); +} + + +@override +int get hashCode { + final _this = this as CheckPhone; + return Object.hash(runtimeType,_this.status,_this.message,_this.phoneNumber); +} + +@override +String toString() { + final _this = this as CheckPhone; + return 'CheckPhone(status: ${_this.status}, message: ${_this.message}, phoneNumber: ${_this.phoneNumber})'; +} + + } /// @nodoc -abstract class $CheckPhoneCopyWith<$Res> { - factory $CheckPhoneCopyWith( - CheckPhone value, - $Res Function(CheckPhone) then, - ) = _$CheckPhoneCopyWithImpl<$Res, CheckPhone>; - @useResult - $Res call({CheckPhoneStatus status, String message, String phoneNumber}); -} +abstract mixin class $CheckPhoneCopyWith<$Res> { + factory $CheckPhoneCopyWith(CheckPhone value, $Res Function(CheckPhone) _then) = _$CheckPhoneCopyWithImpl; +@useResult +$Res call({ + CheckPhoneStatus status, String message, String phoneNumber +}); + + + +} /// @nodoc -class _$CheckPhoneCopyWithImpl<$Res, $Val extends CheckPhone> +class _$CheckPhoneCopyWithImpl<$Res> implements $CheckPhoneCopyWith<$Res> { - _$CheckPhoneCopyWithImpl(this._value, this._then); + _$CheckPhoneCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final CheckPhone _self; + final $Res Function(CheckPhone) _then; - /// Create a copy of CheckPhone - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? phoneNumber = null, - }) { - return _then( - _value.copyWith( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as CheckPhoneStatus, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - ) - as $Val, - ); - } +/// Create a copy of CheckPhone +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? message = null,Object? phoneNumber = null,}) { + return _then(CheckPhone( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as CheckPhoneStatus,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -abstract class _$$CheckPhoneImplCopyWith<$Res> - implements $CheckPhoneCopyWith<$Res> { - factory _$$CheckPhoneImplCopyWith( - _$CheckPhoneImpl value, - $Res Function(_$CheckPhoneImpl) then, - ) = __$$CheckPhoneImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({CheckPhoneStatus status, String message, String phoneNumber}); } -/// @nodoc -class __$$CheckPhoneImplCopyWithImpl<$Res> - extends _$CheckPhoneCopyWithImpl<$Res, _$CheckPhoneImpl> - implements _$$CheckPhoneImplCopyWith<$Res> { - __$$CheckPhoneImplCopyWithImpl( - _$CheckPhoneImpl _value, - $Res Function(_$CheckPhoneImpl) _then, - ) : super(_value, _then); - /// Create a copy of CheckPhone - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? phoneNumber = null, - }) { - return _then( - _$CheckPhoneImpl( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as CheckPhoneStatus, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } +/// Adds pattern-matching-related methods to [CheckPhone]. +extension CheckPhonePatterns on CheckPhone { +/// 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( _CheckPhone value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CheckPhone() 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( _CheckPhone value) $default,){ +final _that = this; +switch (_that) { +case _CheckPhone(): +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( _CheckPhone value)? $default,){ +final _that = this; +switch (_that) { +case _CheckPhone() 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( CheckPhoneStatus status, String message, String phoneNumber)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CheckPhone() when $default != null: +return $default(_that.status,_that.message,_that.phoneNumber);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( CheckPhoneStatus status, String message, String phoneNumber) $default,) {final _that = this; +switch (_that) { +case _CheckPhone(): +return $default(_that.status,_that.message,_that.phoneNumber);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( CheckPhoneStatus status, String message, String phoneNumber)? $default,) {final _that = this; +switch (_that) { +case _CheckPhone() when $default != null: +return $default(_that.status,_that.message,_that.phoneNumber);case _: + return null; + +} +} + } /// @nodoc -class _$CheckPhoneImpl implements _CheckPhone { - const _$CheckPhoneImpl({ - required this.status, - required this.message, - required this.phoneNumber, - }); - @override - final CheckPhoneStatus status; - @override - final String message; - @override - final String phoneNumber; +class _CheckPhone implements CheckPhone { + const _CheckPhone({required this.status, required this.message, required this.phoneNumber}); + - @override - String toString() { +@override final CheckPhoneStatus status; +@override final String message; +@override final String phoneNumber; + +/// Create a copy of CheckPhone +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CheckPhoneCopyWith<_CheckPhone> get copyWith => __$CheckPhoneCopyWithImpl<_CheckPhone>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CheckPhone&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,status,message,phoneNumber); +} + +@override +String toString() { return 'CheckPhone(status: $status, message: $message, phoneNumber: $phoneNumber)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CheckPhoneImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber)); - } - - @override - int get hashCode => Object.hash(runtimeType, status, message, phoneNumber); - - /// Create a copy of CheckPhone - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CheckPhoneImplCopyWith<_$CheckPhoneImpl> get copyWith => - __$$CheckPhoneImplCopyWithImpl<_$CheckPhoneImpl>(this, _$identity); } -abstract class _CheckPhone implements CheckPhone { - const factory _CheckPhone({ - required final CheckPhoneStatus status, - required final String message, - required final String phoneNumber, - }) = _$CheckPhoneImpl; - @override - CheckPhoneStatus get status; - @override - String get message; - @override - String get phoneNumber; +} + +/// @nodoc +abstract mixin class _$CheckPhoneCopyWith<$Res> implements $CheckPhoneCopyWith<$Res> { + factory _$CheckPhoneCopyWith(_CheckPhone value, $Res Function(_CheckPhone) _then) = __$CheckPhoneCopyWithImpl; +@override @useResult +$Res call({ + CheckPhoneStatus status, String message, String phoneNumber +}); + + + + +} +/// @nodoc +class __$CheckPhoneCopyWithImpl<$Res> + implements _$CheckPhoneCopyWith<$Res> { + __$CheckPhoneCopyWithImpl(this._self, this._then); + + final _CheckPhone _self; + final $Res Function(_CheckPhone) _then; + +/// Create a copy of CheckPhone +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? message = null,Object? phoneNumber = null,}) { + return _then(_CheckPhone( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as CheckPhoneStatus,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); +} + - /// Create a copy of CheckPhone - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CheckPhoneImplCopyWith<_$CheckPhoneImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$Register { - String get status => throw _privateConstructorUsedError; - String get message => throw _privateConstructorUsedError; - String get registrationToken => throw _privateConstructorUsedError; - String get otpToken => throw _privateConstructorUsedError; - int get expiresIn => throw _privateConstructorUsedError; - /// Create a copy of Register - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $RegisterCopyWith get copyWith => - throw _privateConstructorUsedError; + String get status; String get message; String get registrationToken; String get otpToken; int get expiresIn; +/// Create a copy of Register +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$RegisterCopyWith get copyWith => _$RegisterCopyWithImpl(this as Register, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as Register; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Register&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.registrationToken, _this.registrationToken) || other.registrationToken == _this.registrationToken)&&(identical(other.otpToken, _this.otpToken) || other.otpToken == _this.otpToken)&&(identical(other.expiresIn, _this.expiresIn) || other.expiresIn == _this.expiresIn)); +} + + +@override +int get hashCode { + final _this = this as Register; + return Object.hash(runtimeType,_this.status,_this.message,_this.registrationToken,_this.otpToken,_this.expiresIn); +} + +@override +String toString() { + final _this = this as Register; + return 'Register(status: ${_this.status}, message: ${_this.message}, registrationToken: ${_this.registrationToken}, otpToken: ${_this.otpToken}, expiresIn: ${_this.expiresIn})'; +} + + } /// @nodoc -abstract class $RegisterCopyWith<$Res> { - factory $RegisterCopyWith(Register value, $Res Function(Register) then) = - _$RegisterCopyWithImpl<$Res, Register>; - @useResult - $Res call({ - String status, - String message, - String registrationToken, - String otpToken, - int expiresIn, - }); -} +abstract mixin class $RegisterCopyWith<$Res> { + factory $RegisterCopyWith(Register value, $Res Function(Register) _then) = _$RegisterCopyWithImpl; +@useResult +$Res call({ + String status, String message, String registrationToken, String otpToken, int expiresIn +}); + + + +} /// @nodoc -class _$RegisterCopyWithImpl<$Res, $Val extends Register> +class _$RegisterCopyWithImpl<$Res> implements $RegisterCopyWith<$Res> { - _$RegisterCopyWithImpl(this._value, this._then); + _$RegisterCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final Register _self; + final $Res Function(Register) _then; - /// Create a copy of Register - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? registrationToken = null, - Object? otpToken = null, - Object? expiresIn = null, - }) { - return _then( - _value.copyWith( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - otpToken: null == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String, - expiresIn: null == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int, - ) - as $Val, - ); - } +/// Create a copy of Register +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? message = null,Object? registrationToken = null,Object? otpToken = null,Object? expiresIn = null,}) { + return _then(Register( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String,otpToken: null == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String,expiresIn: null == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int, + )); } -/// @nodoc -abstract class _$$RegisterImplCopyWith<$Res> - implements $RegisterCopyWith<$Res> { - factory _$$RegisterImplCopyWith( - _$RegisterImpl value, - $Res Function(_$RegisterImpl) then, - ) = __$$RegisterImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String status, - String message, - String registrationToken, - String otpToken, - int expiresIn, - }); } -/// @nodoc -class __$$RegisterImplCopyWithImpl<$Res> - extends _$RegisterCopyWithImpl<$Res, _$RegisterImpl> - implements _$$RegisterImplCopyWith<$Res> { - __$$RegisterImplCopyWithImpl( - _$RegisterImpl _value, - $Res Function(_$RegisterImpl) _then, - ) : super(_value, _then); - /// Create a copy of Register - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? registrationToken = null, - Object? otpToken = null, - Object? expiresIn = null, - }) { - return _then( - _$RegisterImpl( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - otpToken: null == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String, - expiresIn: null == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int, - ), - ); - } +/// Adds pattern-matching-related methods to [Register]. +extension RegisterPatterns on Register { +/// 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( _Register value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Register() 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( _Register value) $default,){ +final _that = this; +switch (_that) { +case _Register(): +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( _Register value)? $default,){ +final _that = this; +switch (_that) { +case _Register() 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 status, String message, String registrationToken, String otpToken, int expiresIn)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Register() when $default != null: +return $default(_that.status,_that.message,_that.registrationToken,_that.otpToken,_that.expiresIn);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 status, String message, String registrationToken, String otpToken, int expiresIn) $default,) {final _that = this; +switch (_that) { +case _Register(): +return $default(_that.status,_that.message,_that.registrationToken,_that.otpToken,_that.expiresIn);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 status, String message, String registrationToken, String otpToken, int expiresIn)? $default,) {final _that = this; +switch (_that) { +case _Register() when $default != null: +return $default(_that.status,_that.message,_that.registrationToken,_that.otpToken,_that.expiresIn);case _: + return null; + +} +} + } /// @nodoc -class _$RegisterImpl implements _Register { - const _$RegisterImpl({ - required this.status, - required this.message, - required this.registrationToken, - required this.otpToken, - required this.expiresIn, - }); - @override - final String status; - @override - final String message; - @override - final String registrationToken; - @override - final String otpToken; - @override - final int expiresIn; +class _Register implements Register { + const _Register({required this.status, required this.message, required this.registrationToken, required this.otpToken, required this.expiresIn}); + - @override - String toString() { +@override final String status; +@override final String message; +@override final String registrationToken; +@override final String otpToken; +@override final int expiresIn; + +/// Create a copy of Register +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RegisterCopyWith<_Register> get copyWith => __$RegisterCopyWithImpl<_Register>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Register&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)&&(identical(other.otpToken, otpToken) || other.otpToken == otpToken)&&(identical(other.expiresIn, expiresIn) || other.expiresIn == expiresIn)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,status,message,registrationToken,otpToken,expiresIn); +} + +@override +String toString() { return 'Register(status: $status, message: $message, registrationToken: $registrationToken, otpToken: $otpToken, expiresIn: $expiresIn)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RegisterImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken) && - (identical(other.otpToken, otpToken) || - other.otpToken == otpToken) && - (identical(other.expiresIn, expiresIn) || - other.expiresIn == expiresIn)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - status, - message, - registrationToken, - otpToken, - expiresIn, - ); - - /// Create a copy of Register - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RegisterImplCopyWith<_$RegisterImpl> get copyWith => - __$$RegisterImplCopyWithImpl<_$RegisterImpl>(this, _$identity); } -abstract class _Register implements Register { - const factory _Register({ - required final String status, - required final String message, - required final String registrationToken, - required final String otpToken, - required final int expiresIn, - }) = _$RegisterImpl; - @override - String get status; - @override - String get message; - @override - String get registrationToken; - @override - String get otpToken; - @override - int get expiresIn; +} + +/// @nodoc +abstract mixin class _$RegisterCopyWith<$Res> implements $RegisterCopyWith<$Res> { + factory _$RegisterCopyWith(_Register value, $Res Function(_Register) _then) = __$RegisterCopyWithImpl; +@override @useResult +$Res call({ + String status, String message, String registrationToken, String otpToken, int expiresIn +}); + + + + +} +/// @nodoc +class __$RegisterCopyWithImpl<$Res> + implements _$RegisterCopyWith<$Res> { + __$RegisterCopyWithImpl(this._self, this._then); + + final _Register _self; + final $Res Function(_Register) _then; + +/// Create a copy of Register +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? message = null,Object? registrationToken = null,Object? otpToken = null,Object? expiresIn = null,}) { + return _then(_Register( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String,otpToken: null == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String,expiresIn: null == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int, + )); +} + - /// Create a copy of Register - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RegisterImplCopyWith<_$RegisterImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$Verify { - String get status => throw _privateConstructorUsedError; - String get message => throw _privateConstructorUsedError; - String get registrationToken => throw _privateConstructorUsedError; - /// Create a copy of Verify - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $VerifyCopyWith get copyWith => throw _privateConstructorUsedError; + String get status; String get message; String get registrationToken; +/// Create a copy of Verify +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$VerifyCopyWith get copyWith => _$VerifyCopyWithImpl(this as Verify, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as Verify; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Verify&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.registrationToken, _this.registrationToken) || other.registrationToken == _this.registrationToken)); +} + + +@override +int get hashCode { + final _this = this as Verify; + return Object.hash(runtimeType,_this.status,_this.message,_this.registrationToken); +} + +@override +String toString() { + final _this = this as Verify; + return 'Verify(status: ${_this.status}, message: ${_this.message}, registrationToken: ${_this.registrationToken})'; +} + + } /// @nodoc -abstract class $VerifyCopyWith<$Res> { - factory $VerifyCopyWith(Verify value, $Res Function(Verify) then) = - _$VerifyCopyWithImpl<$Res, Verify>; - @useResult - $Res call({String status, String message, String registrationToken}); -} +abstract mixin class $VerifyCopyWith<$Res> { + factory $VerifyCopyWith(Verify value, $Res Function(Verify) _then) = _$VerifyCopyWithImpl; +@useResult +$Res call({ + String status, String message, String registrationToken +}); + + + +} /// @nodoc -class _$VerifyCopyWithImpl<$Res, $Val extends Verify> +class _$VerifyCopyWithImpl<$Res> implements $VerifyCopyWith<$Res> { - _$VerifyCopyWithImpl(this._value, this._then); + _$VerifyCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final Verify _self; + final $Res Function(Verify) _then; - /// Create a copy of Verify - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? registrationToken = null, - }) { - return _then( - _value.copyWith( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - ) - as $Val, - ); - } +/// Create a copy of Verify +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? message = null,Object? registrationToken = null,}) { + return _then(Verify( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -abstract class _$$VerifyImplCopyWith<$Res> implements $VerifyCopyWith<$Res> { - factory _$$VerifyImplCopyWith( - _$VerifyImpl value, - $Res Function(_$VerifyImpl) then, - ) = __$$VerifyImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String status, String message, String registrationToken}); } -/// @nodoc -class __$$VerifyImplCopyWithImpl<$Res> - extends _$VerifyCopyWithImpl<$Res, _$VerifyImpl> - implements _$$VerifyImplCopyWith<$Res> { - __$$VerifyImplCopyWithImpl( - _$VerifyImpl _value, - $Res Function(_$VerifyImpl) _then, - ) : super(_value, _then); - /// Create a copy of Verify - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? registrationToken = null, - }) { - return _then( - _$VerifyImpl( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - registrationToken: null == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } +/// Adds pattern-matching-related methods to [Verify]. +extension VerifyPatterns on Verify { +/// 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( _Verify value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Verify() 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( _Verify value) $default,){ +final _that = this; +switch (_that) { +case _Verify(): +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( _Verify value)? $default,){ +final _that = this; +switch (_that) { +case _Verify() 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 status, String message, String registrationToken)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Verify() when $default != null: +return $default(_that.status,_that.message,_that.registrationToken);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 status, String message, String registrationToken) $default,) {final _that = this; +switch (_that) { +case _Verify(): +return $default(_that.status,_that.message,_that.registrationToken);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 status, String message, String registrationToken)? $default,) {final _that = this; +switch (_that) { +case _Verify() when $default != null: +return $default(_that.status,_that.message,_that.registrationToken);case _: + return null; + +} +} + } /// @nodoc -class _$VerifyImpl implements _Verify { - const _$VerifyImpl({ - required this.status, - required this.message, - required this.registrationToken, - }); - @override - final String status; - @override - final String message; - @override - final String registrationToken; +class _Verify implements Verify { + const _Verify({required this.status, required this.message, required this.registrationToken}); + - @override - String toString() { +@override final String status; +@override final String message; +@override final String registrationToken; + +/// Create a copy of Verify +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$VerifyCopyWith<_Verify> get copyWith => __$VerifyCopyWithImpl<_Verify>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Verify&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,status,message,registrationToken); +} + +@override +String toString() { return 'Verify(status: $status, message: $message, registrationToken: $registrationToken)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$VerifyImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken)); - } - - @override - int get hashCode => - Object.hash(runtimeType, status, message, registrationToken); - - /// Create a copy of Verify - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$VerifyImplCopyWith<_$VerifyImpl> get copyWith => - __$$VerifyImplCopyWithImpl<_$VerifyImpl>(this, _$identity); } -abstract class _Verify implements Verify { - const factory _Verify({ - required final String status, - required final String message, - required final String registrationToken, - }) = _$VerifyImpl; - @override - String get status; - @override - String get message; - @override - String get registrationToken; +} + +/// @nodoc +abstract mixin class _$VerifyCopyWith<$Res> implements $VerifyCopyWith<$Res> { + factory _$VerifyCopyWith(_Verify value, $Res Function(_Verify) _then) = __$VerifyCopyWithImpl; +@override @useResult +$Res call({ + String status, String message, String registrationToken +}); + + + + +} +/// @nodoc +class __$VerifyCopyWithImpl<$Res> + implements _$VerifyCopyWith<$Res> { + __$VerifyCopyWithImpl(this._self, this._then); + + final _Verify _self; + final $Res Function(_Verify) _then; + +/// Create a copy of Verify +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? message = null,Object? registrationToken = null,}) { + return _then(_Verify( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,registrationToken: null == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String, + )); +} + - /// Create a copy of Verify - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$VerifyImplCopyWith<_$VerifyImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$Login { - String get status => throw _privateConstructorUsedError; - String get message => throw _privateConstructorUsedError; - String get accessToken => throw _privateConstructorUsedError; - String get refreshToken => throw _privateConstructorUsedError; - User get user => throw _privateConstructorUsedError; - /// Create a copy of Login - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $LoginCopyWith get copyWith => throw _privateConstructorUsedError; + String get status; String get message; String get accessToken; String get refreshToken; User get user; +/// Create a copy of Login +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LoginCopyWith get copyWith => _$LoginCopyWithImpl(this as Login, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as Login; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Login&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.accessToken, _this.accessToken) || other.accessToken == _this.accessToken)&&(identical(other.refreshToken, _this.refreshToken) || other.refreshToken == _this.refreshToken)&&(identical(other.user, _this.user) || other.user == _this.user)); +} + + +@override +int get hashCode { + final _this = this as Login; + return Object.hash(runtimeType,_this.status,_this.message,_this.accessToken,_this.refreshToken,_this.user); +} + +@override +String toString() { + final _this = this as Login; + return 'Login(status: ${_this.status}, message: ${_this.message}, accessToken: ${_this.accessToken}, refreshToken: ${_this.refreshToken}, user: ${_this.user})'; +} + + } /// @nodoc -abstract class $LoginCopyWith<$Res> { - factory $LoginCopyWith(Login value, $Res Function(Login) then) = - _$LoginCopyWithImpl<$Res, Login>; - @useResult - $Res call({ - String status, - String message, - String accessToken, - String refreshToken, - User user, - }); +abstract mixin class $LoginCopyWith<$Res> { + factory $LoginCopyWith(Login value, $Res Function(Login) _then) = _$LoginCopyWithImpl; +@useResult +$Res call({ + String status, String message, String accessToken, String refreshToken, User user +}); + + +$UserCopyWith<$Res> get user; - $UserCopyWith<$Res> get user; } - /// @nodoc -class _$LoginCopyWithImpl<$Res, $Val extends Login> +class _$LoginCopyWithImpl<$Res> implements $LoginCopyWith<$Res> { - _$LoginCopyWithImpl(this._value, this._then); + _$LoginCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final Login _self; + final $Res Function(Login) _then; - /// Create a copy of Login - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? accessToken = null, - Object? refreshToken = null, - Object? user = null, - }) { - return _then( - _value.copyWith( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - 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, - user: null == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as User, - ) - as $Val, - ); - } - - /// Create a copy of Login - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $UserCopyWith<$Res> get user { - return $UserCopyWith<$Res>(_value.user, (value) { - return _then(_value.copyWith(user: value) as $Val); - }); - } +/// Create a copy of Login +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? message = null,Object? accessToken = null,Object? refreshToken = null,Object? user = null,}) { + return _then(Login( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,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,user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as User, + )); } - -/// @nodoc -abstract class _$$LoginImplCopyWith<$Res> implements $LoginCopyWith<$Res> { - factory _$$LoginImplCopyWith( - _$LoginImpl value, - $Res Function(_$LoginImpl) then, - ) = __$$LoginImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String status, - String message, - String accessToken, - String refreshToken, - User user, +/// Create a copy of Login +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserCopyWith<$Res> get user { + + return $UserCopyWith<$Res>(_self.user, (value) { + return _then(_self.copyWith(user: value)); }); - - @override - $UserCopyWith<$Res> get user; +} } -/// @nodoc -class __$$LoginImplCopyWithImpl<$Res> - extends _$LoginCopyWithImpl<$Res, _$LoginImpl> - implements _$$LoginImplCopyWith<$Res> { - __$$LoginImplCopyWithImpl( - _$LoginImpl _value, - $Res Function(_$LoginImpl) _then, - ) : super(_value, _then); - /// Create a copy of Login - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? accessToken = null, - Object? refreshToken = null, - Object? user = null, - }) { - return _then( - _$LoginImpl( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - 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, - user: null == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as User, - ), - ); - } +/// Adds pattern-matching-related methods to [Login]. +extension LoginPatterns on Login { +/// 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( _Login value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Login() 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( _Login value) $default,){ +final _that = this; +switch (_that) { +case _Login(): +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( _Login value)? $default,){ +final _that = this; +switch (_that) { +case _Login() 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 status, String message, String accessToken, String refreshToken, User user)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Login() when $default != null: +return $default(_that.status,_that.message,_that.accessToken,_that.refreshToken,_that.user);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 status, String message, String accessToken, String refreshToken, User user) $default,) {final _that = this; +switch (_that) { +case _Login(): +return $default(_that.status,_that.message,_that.accessToken,_that.refreshToken,_that.user);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 status, String message, String accessToken, String refreshToken, User user)? $default,) {final _that = this; +switch (_that) { +case _Login() when $default != null: +return $default(_that.status,_that.message,_that.accessToken,_that.refreshToken,_that.user);case _: + return null; + +} +} + } /// @nodoc -class _$LoginImpl implements _Login { - const _$LoginImpl({ - required this.status, - required this.message, - required this.accessToken, - required this.refreshToken, - required this.user, - }); - @override - final String status; - @override - final String message; - @override - final String accessToken; - @override - final String refreshToken; - @override - final User user; +class _Login implements Login { + const _Login({required this.status, required this.message, required this.accessToken, required this.refreshToken, required this.user}); + - @override - String toString() { +@override final String status; +@override final String message; +@override final String accessToken; +@override final String refreshToken; +@override final User user; + +/// Create a copy of Login +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LoginCopyWith<_Login> get copyWith => __$LoginCopyWithImpl<_Login>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Login&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.user, user) || other.user == user)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,status,message,accessToken,refreshToken,user); +} + +@override +String toString() { return 'Login(status: $status, message: $message, accessToken: $accessToken, refreshToken: $refreshToken, user: $user)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LoginImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.accessToken, accessToken) || - other.accessToken == accessToken) && - (identical(other.refreshToken, refreshToken) || - other.refreshToken == refreshToken) && - (identical(other.user, user) || other.user == user)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - status, - message, - accessToken, - refreshToken, - user, - ); - - /// Create a copy of Login - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$LoginImplCopyWith<_$LoginImpl> get copyWith => - __$$LoginImplCopyWithImpl<_$LoginImpl>(this, _$identity); } -abstract class _Login implements Login { - const factory _Login({ - required final String status, - required final String message, - required final String accessToken, - required final String refreshToken, - required final User user, - }) = _$LoginImpl; - @override - String get status; - @override - String get message; - @override - String get accessToken; - @override - String get refreshToken; - @override - User get user; +} - /// Create a copy of Login - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$LoginImplCopyWith<_$LoginImpl> get copyWith => - throw _privateConstructorUsedError; +/// @nodoc +abstract mixin class _$LoginCopyWith<$Res> implements $LoginCopyWith<$Res> { + factory _$LoginCopyWith(_Login value, $Res Function(_Login) _then) = __$LoginCopyWithImpl; +@override @useResult +$Res call({ + String status, String message, String accessToken, String refreshToken, User user +}); + + +@override $UserCopyWith<$Res> get user; + +} +/// @nodoc +class __$LoginCopyWithImpl<$Res> + implements _$LoginCopyWith<$Res> { + __$LoginCopyWithImpl(this._self, this._then); + + final _Login _self; + final $Res Function(_Login) _then; + +/// Create a copy of Login +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? message = null,Object? accessToken = null,Object? refreshToken = null,Object? user = null,}) { + return _then(_Login( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,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,user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as User, + )); +} + +/// Create a copy of Login +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserCopyWith<$Res> get user { + + return $UserCopyWith<$Res>(_self.user, (value) { + return _then(_self.copyWith(user: value)); + }); +} } /// @nodoc mixin _$User { - String get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - String get phoneNumber => throw _privateConstructorUsedError; - String get birthDate => throw _privateConstructorUsedError; - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $UserCopyWith get copyWith => throw _privateConstructorUsedError; + String get id; String get name; String get phoneNumber; String get birthDate; +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$UserCopyWith get copyWith => _$UserCopyWithImpl(this as User, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as User; + return identical(this, other) || (other.runtimeType == runtimeType&&other is User&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)&&(identical(other.birthDate, _this.birthDate) || other.birthDate == _this.birthDate)); +} + + +@override +int get hashCode { + final _this = this as User; + return Object.hash(runtimeType,_this.id,_this.name,_this.phoneNumber,_this.birthDate); +} + +@override +String toString() { + final _this = this as User; + return 'User(id: ${_this.id}, name: ${_this.name}, phoneNumber: ${_this.phoneNumber}, birthDate: ${_this.birthDate})'; +} + + } /// @nodoc -abstract class $UserCopyWith<$Res> { - factory $UserCopyWith(User value, $Res Function(User) then) = - _$UserCopyWithImpl<$Res, User>; - @useResult - $Res call({String id, String name, String phoneNumber, String birthDate}); -} +abstract mixin class $UserCopyWith<$Res> { + factory $UserCopyWith(User value, $Res Function(User) _then) = _$UserCopyWithImpl; +@useResult +$Res call({ + String id, String name, String phoneNumber, String birthDate +}); + + + +} /// @nodoc -class _$UserCopyWithImpl<$Res, $Val extends User> +class _$UserCopyWithImpl<$Res> implements $UserCopyWith<$Res> { - _$UserCopyWithImpl(this._value, this._then); + _$UserCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final User _self; + final $Res Function(User) _then; - /// Create a copy of User - /// 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? phoneNumber = null, - Object? birthDate = 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, - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - birthDate: null == birthDate - ? _value.birthDate - : birthDate // ignore: cast_nullable_to_non_nullable - as String, - ) - as $Val, - ); - } +/// Create a copy of User +/// 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? phoneNumber = null,Object? birthDate = null,}) { + return _then(User( +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,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,birthDate: null == birthDate ? _self.birthDate : birthDate // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> { - factory _$$UserImplCopyWith( - _$UserImpl value, - $Res Function(_$UserImpl) then, - ) = __$$UserImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String id, String name, String phoneNumber, String birthDate}); } -/// @nodoc -class __$$UserImplCopyWithImpl<$Res> - extends _$UserCopyWithImpl<$Res, _$UserImpl> - implements _$$UserImplCopyWith<$Res> { - __$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then) - : super(_value, _then); - /// Create a copy of User - /// 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? phoneNumber = null, - Object? birthDate = null, - }) { - return _then( - _$UserImpl( - 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, - phoneNumber: null == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String, - birthDate: null == birthDate - ? _value.birthDate - : birthDate // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } +/// Adds pattern-matching-related methods to [User]. +extension UserPatterns on User { +/// 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( _User value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _User() 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( _User value) $default,){ +final _that = this; +switch (_that) { +case _User(): +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( _User value)? $default,){ +final _that = this; +switch (_that) { +case _User() 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, String phoneNumber, String birthDate)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _User() when $default != null: +return $default(_that.id,_that.name,_that.phoneNumber,_that.birthDate);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, String phoneNumber, String birthDate) $default,) {final _that = this; +switch (_that) { +case _User(): +return $default(_that.id,_that.name,_that.phoneNumber,_that.birthDate);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, String phoneNumber, String birthDate)? $default,) {final _that = this; +switch (_that) { +case _User() when $default != null: +return $default(_that.id,_that.name,_that.phoneNumber,_that.birthDate);case _: + return null; + +} +} + } /// @nodoc -class _$UserImpl implements _User { - const _$UserImpl({ - required this.id, - required this.name, - required this.phoneNumber, - required this.birthDate, - }); - @override - final String id; - @override - final String name; - @override - final String phoneNumber; - @override - final String birthDate; +class _User implements User { + const _User({required this.id, required this.name, required this.phoneNumber, required this.birthDate}); + - @override - String toString() { +@override final String id; +@override final String name; +@override final String phoneNumber; +@override final String birthDate; + +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$UserCopyWith<_User> get copyWith => __$UserCopyWithImpl<_User>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _User&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.birthDate, birthDate) || other.birthDate == birthDate)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,name,phoneNumber,birthDate); +} + +@override +String toString() { return 'User(id: $id, name: $name, phoneNumber: $phoneNumber, birthDate: $birthDate)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$UserImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.name, name) || other.name == name) && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber) && - (identical(other.birthDate, birthDate) || - other.birthDate == birthDate)); - } - - @override - int get hashCode => - Object.hash(runtimeType, id, name, phoneNumber, birthDate); - - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$UserImplCopyWith<_$UserImpl> get copyWith => - __$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity); } -abstract class _User implements User { - const factory _User({ - required final String id, - required final String name, - required final String phoneNumber, - required final String birthDate, - }) = _$UserImpl; - @override - String get id; - @override - String get name; - @override - String get phoneNumber; - @override - String get birthDate; +} + +/// @nodoc +abstract mixin class _$UserCopyWith<$Res> implements $UserCopyWith<$Res> { + factory _$UserCopyWith(_User value, $Res Function(_User) _then) = __$UserCopyWithImpl; +@override @useResult +$Res call({ + String id, String name, String phoneNumber, String birthDate +}); + + + + +} +/// @nodoc +class __$UserCopyWithImpl<$Res> + implements _$UserCopyWith<$Res> { + __$UserCopyWithImpl(this._self, this._then); + + final _User _self; + final $Res Function(_User) _then; + +/// Create a copy of User +/// 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? phoneNumber = null,Object? birthDate = null,}) { + return _then(_User( +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,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String,birthDate: null == birthDate ? _self.birthDate : birthDate // ignore: cast_nullable_to_non_nullable +as String, + )); +} + - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$UserImplCopyWith<_$UserImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$Resend { - ResendStatus get status => throw _privateConstructorUsedError; - String get message => throw _privateConstructorUsedError; - String get otpToken => throw _privateConstructorUsedError; - int get expiresIn => throw _privateConstructorUsedError; - int get nextResendIn => throw _privateConstructorUsedError; - /// Create a copy of Resend - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ResendCopyWith get copyWith => throw _privateConstructorUsedError; + ResendStatus get status; String get message; String get otpToken; int get expiresIn; int get nextResendIn; +/// Create a copy of Resend +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ResendCopyWith get copyWith => _$ResendCopyWithImpl(this as Resend, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as Resend; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Resend&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.otpToken, _this.otpToken) || other.otpToken == _this.otpToken)&&(identical(other.expiresIn, _this.expiresIn) || other.expiresIn == _this.expiresIn)&&(identical(other.nextResendIn, _this.nextResendIn) || other.nextResendIn == _this.nextResendIn)); +} + + +@override +int get hashCode { + final _this = this as Resend; + return Object.hash(runtimeType,_this.status,_this.message,_this.otpToken,_this.expiresIn,_this.nextResendIn); +} + +@override +String toString() { + final _this = this as Resend; + return 'Resend(status: ${_this.status}, message: ${_this.message}, otpToken: ${_this.otpToken}, expiresIn: ${_this.expiresIn}, nextResendIn: ${_this.nextResendIn})'; +} + + } /// @nodoc -abstract class $ResendCopyWith<$Res> { - factory $ResendCopyWith(Resend value, $Res Function(Resend) then) = - _$ResendCopyWithImpl<$Res, Resend>; - @useResult - $Res call({ - ResendStatus status, - String message, - String otpToken, - int expiresIn, - int nextResendIn, - }); -} +abstract mixin class $ResendCopyWith<$Res> { + factory $ResendCopyWith(Resend value, $Res Function(Resend) _then) = _$ResendCopyWithImpl; +@useResult +$Res call({ + ResendStatus status, String message, String otpToken, int expiresIn, int nextResendIn +}); + + + +} /// @nodoc -class _$ResendCopyWithImpl<$Res, $Val extends Resend> +class _$ResendCopyWithImpl<$Res> implements $ResendCopyWith<$Res> { - _$ResendCopyWithImpl(this._value, this._then); + _$ResendCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final Resend _self; + final $Res Function(Resend) _then; - /// Create a copy of Resend - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? otpToken = null, - Object? expiresIn = null, - Object? nextResendIn = null, - }) { - return _then( - _value.copyWith( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as ResendStatus, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - otpToken: null == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String, - expiresIn: null == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int, - nextResendIn: null == nextResendIn - ? _value.nextResendIn - : nextResendIn // ignore: cast_nullable_to_non_nullable - as int, - ) - as $Val, - ); - } +/// Create a copy of Resend +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = null,Object? message = null,Object? otpToken = null,Object? expiresIn = null,Object? nextResendIn = null,}) { + return _then(Resend( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as ResendStatus,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,otpToken: null == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String,expiresIn: null == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int,nextResendIn: null == nextResendIn ? _self.nextResendIn : nextResendIn // ignore: cast_nullable_to_non_nullable +as int, + )); } -/// @nodoc -abstract class _$$ResendImplCopyWith<$Res> implements $ResendCopyWith<$Res> { - factory _$$ResendImplCopyWith( - _$ResendImpl value, - $Res Function(_$ResendImpl) then, - ) = __$$ResendImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - ResendStatus status, - String message, - String otpToken, - int expiresIn, - int nextResendIn, - }); } -/// @nodoc -class __$$ResendImplCopyWithImpl<$Res> - extends _$ResendCopyWithImpl<$Res, _$ResendImpl> - implements _$$ResendImplCopyWith<$Res> { - __$$ResendImplCopyWithImpl( - _$ResendImpl _value, - $Res Function(_$ResendImpl) _then, - ) : super(_value, _then); - /// Create a copy of Resend - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? otpToken = null, - Object? expiresIn = null, - Object? nextResendIn = null, - }) { - return _then( - _$ResendImpl( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as ResendStatus, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - otpToken: null == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String, - expiresIn: null == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int, - nextResendIn: null == nextResendIn - ? _value.nextResendIn - : nextResendIn // ignore: cast_nullable_to_non_nullable - as int, - ), - ); - } +/// Adds pattern-matching-related methods to [Resend]. +extension ResendPatterns on Resend { +/// 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( _Resend value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Resend() 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( _Resend value) $default,){ +final _that = this; +switch (_that) { +case _Resend(): +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( _Resend value)? $default,){ +final _that = this; +switch (_that) { +case _Resend() 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( ResendStatus status, String message, String otpToken, int expiresIn, int nextResendIn)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Resend() when $default != null: +return $default(_that.status,_that.message,_that.otpToken,_that.expiresIn,_that.nextResendIn);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( ResendStatus status, String message, String otpToken, int expiresIn, int nextResendIn) $default,) {final _that = this; +switch (_that) { +case _Resend(): +return $default(_that.status,_that.message,_that.otpToken,_that.expiresIn,_that.nextResendIn);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( ResendStatus status, String message, String otpToken, int expiresIn, int nextResendIn)? $default,) {final _that = this; +switch (_that) { +case _Resend() when $default != null: +return $default(_that.status,_that.message,_that.otpToken,_that.expiresIn,_that.nextResendIn);case _: + return null; + +} +} + } /// @nodoc -class _$ResendImpl implements _Resend { - const _$ResendImpl({ - required this.status, - required this.message, - required this.otpToken, - required this.expiresIn, - required this.nextResendIn, - }); - @override - final ResendStatus status; - @override - final String message; - @override - final String otpToken; - @override - final int expiresIn; - @override - final int nextResendIn; +class _Resend implements Resend { + const _Resend({required this.status, required this.message, required this.otpToken, required this.expiresIn, required this.nextResendIn}); + - @override - String toString() { +@override final ResendStatus status; +@override final String message; +@override final String otpToken; +@override final int expiresIn; +@override final int nextResendIn; + +/// Create a copy of Resend +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ResendCopyWith<_Resend> get copyWith => __$ResendCopyWithImpl<_Resend>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Resend&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.otpToken, otpToken) || other.otpToken == otpToken)&&(identical(other.expiresIn, expiresIn) || other.expiresIn == expiresIn)&&(identical(other.nextResendIn, nextResendIn) || other.nextResendIn == nextResendIn)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,status,message,otpToken,expiresIn,nextResendIn); +} + +@override +String toString() { return 'Resend(status: $status, message: $message, otpToken: $otpToken, expiresIn: $expiresIn, nextResendIn: $nextResendIn)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ResendImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.otpToken, otpToken) || - other.otpToken == otpToken) && - (identical(other.expiresIn, expiresIn) || - other.expiresIn == expiresIn) && - (identical(other.nextResendIn, nextResendIn) || - other.nextResendIn == nextResendIn)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - status, - message, - otpToken, - expiresIn, - nextResendIn, - ); - - /// Create a copy of Resend - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ResendImplCopyWith<_$ResendImpl> get copyWith => - __$$ResendImplCopyWithImpl<_$ResendImpl>(this, _$identity); } -abstract class _Resend implements Resend { - const factory _Resend({ - required final ResendStatus status, - required final String message, - required final String otpToken, - required final int expiresIn, - required final int nextResendIn, - }) = _$ResendImpl; - @override - ResendStatus get status; - @override - String get message; - @override - String get otpToken; - @override - int get expiresIn; - @override - int get nextResendIn; +} + +/// @nodoc +abstract mixin class _$ResendCopyWith<$Res> implements $ResendCopyWith<$Res> { + factory _$ResendCopyWith(_Resend value, $Res Function(_Resend) _then) = __$ResendCopyWithImpl; +@override @useResult +$Res call({ + ResendStatus status, String message, String otpToken, int expiresIn, int nextResendIn +}); + + + + +} +/// @nodoc +class __$ResendCopyWithImpl<$Res> + implements _$ResendCopyWith<$Res> { + __$ResendCopyWithImpl(this._self, this._then); + + final _Resend _self; + final $Res Function(_Resend) _then; + +/// Create a copy of Resend +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = null,Object? message = null,Object? otpToken = null,Object? expiresIn = null,Object? nextResendIn = null,}) { + return _then(_Resend( +status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as ResendStatus,message: null == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String,otpToken: null == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String,expiresIn: null == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int,nextResendIn: null == nextResendIn ? _self.nextResendIn : nextResendIn // ignore: cast_nullable_to_non_nullable +as int, + )); +} + - /// Create a copy of Resend - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ResendImplCopyWith<_$ResendImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$AuthFailure { - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthFailure); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'AuthFailure()'; +} + + } /// @nodoc -abstract class $AuthFailureCopyWith<$Res> { - factory $AuthFailureCopyWith( - AuthFailure value, - $Res Function(AuthFailure) then, - ) = _$AuthFailureCopyWithImpl<$Res, AuthFailure>; +class $AuthFailureCopyWith<$Res> { +$AuthFailureCopyWith(AuthFailure _, $Res Function(AuthFailure) __); } -/// @nodoc -class _$AuthFailureCopyWithImpl<$Res, $Val extends AuthFailure> - implements $AuthFailureCopyWith<$Res> { - _$AuthFailureCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [AuthFailure]. +extension AuthFailurePatterns on AuthFailure { +/// 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(); +/// } +/// ``` - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _ServerError value)? serverError,TResult Function( _UnexpectedError value)? unexpectedError,TResult Function( _DynamicErrorMessage value)? dynamicErrorMessage,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_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({required TResult Function( _ServerError value) serverError,required TResult Function( _UnexpectedError value) unexpectedError,required TResult Function( _DynamicErrorMessage value) dynamicErrorMessage,}){ +final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that);case _UnexpectedError(): +return unexpectedError(_that);case _DynamicErrorMessage(): +return dynamicErrorMessage(_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( _ServerError value)? serverError,TResult? Function( _UnexpectedError value)? unexpectedError,TResult? Function( _DynamicErrorMessage value)? dynamicErrorMessage,}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_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( ApiFailure failure)? serverError,TResult Function()? unexpectedError,TResult Function( String erroMessage)? dynamicErrorMessage,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.failure);case _UnexpectedError() when unexpectedError != null: +return unexpectedError();case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_that.erroMessage);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({required TResult Function( ApiFailure failure) serverError,required TResult Function() unexpectedError,required TResult Function( String erroMessage) dynamicErrorMessage,}) {final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that.failure);case _UnexpectedError(): +return unexpectedError();case _DynamicErrorMessage(): +return dynamicErrorMessage(_that.erroMessage);} +} +/// 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( ApiFailure failure)? serverError,TResult? Function()? unexpectedError,TResult? Function( String erroMessage)? dynamicErrorMessage,}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.failure);case _UnexpectedError() when unexpectedError != null: +return unexpectedError();case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_that.erroMessage);case _: + return null; + +} } -/// @nodoc -abstract class _$$ServerErrorImplCopyWith<$Res> { - factory _$$ServerErrorImplCopyWith( - _$ServerErrorImpl value, - $Res Function(_$ServerErrorImpl) then, - ) = __$$ServerErrorImplCopyWithImpl<$Res>; - @useResult - $Res call({ApiFailure failure}); - - $ApiFailureCopyWith<$Res> get failure; -} - -/// @nodoc -class __$$ServerErrorImplCopyWithImpl<$Res> - extends _$AuthFailureCopyWithImpl<$Res, _$ServerErrorImpl> - implements _$$ServerErrorImplCopyWith<$Res> { - __$$ServerErrorImplCopyWithImpl( - _$ServerErrorImpl _value, - $Res Function(_$ServerErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? failure = null}) { - return _then( - _$ServerErrorImpl( - null == failure - ? _value.failure - : failure // ignore: cast_nullable_to_non_nullable - as ApiFailure, - ), - ); - } - - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ApiFailureCopyWith<$Res> get failure { - return $ApiFailureCopyWith<$Res>(_value.failure, (value) { - return _then(_value.copyWith(failure: value)); - }); - } } /// @nodoc -class _$ServerErrorImpl implements _ServerError { - const _$ServerErrorImpl(this.failure); - @override - final ApiFailure failure; +class _ServerError implements AuthFailure { + const _ServerError(this.failure); + - @override - String toString() { + final ApiFailure failure; + +/// Create a copy of AuthFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ServerErrorCopyWith<_ServerError> get copyWith => __$ServerErrorCopyWithImpl<_ServerError>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServerError&&(identical(other.failure, failure) || other.failure == failure)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,failure); +} + +@override +String toString() { return 'AuthFailure.serverError(failure: $failure)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ServerErrorImpl && - (identical(other.failure, failure) || other.failure == failure)); - } - - @override - int get hashCode => Object.hash(runtimeType, failure); - - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - __$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return serverError(failure); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return serverError?.call(failure); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(failure); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return serverError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return serverError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(this); - } - return orElse(); - } } -abstract class _ServerError implements AuthFailure { - const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl; - ApiFailure get failure; - - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$UnexpectedErrorImplCopyWith<$Res> { - factory _$$UnexpectedErrorImplCopyWith( - _$UnexpectedErrorImpl value, - $Res Function(_$UnexpectedErrorImpl) then, - ) = __$$UnexpectedErrorImplCopyWithImpl<$Res>; +abstract mixin class _$ServerErrorCopyWith<$Res> implements $AuthFailureCopyWith<$Res> { + factory _$ServerErrorCopyWith(_ServerError value, $Res Function(_ServerError) _then) = __$ServerErrorCopyWithImpl; +@useResult +$Res call({ + ApiFailure failure +}); + + +$ApiFailureCopyWith<$Res> get failure; + +} +/// @nodoc +class __$ServerErrorCopyWithImpl<$Res> + implements _$ServerErrorCopyWith<$Res> { + __$ServerErrorCopyWithImpl(this._self, this._then); + + final _ServerError _self; + final $Res Function(_ServerError) _then; + +/// Create a copy of AuthFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? failure = null,}) { + return _then(_ServerError( +null == failure ? _self.failure : failure // ignore: cast_nullable_to_non_nullable +as ApiFailure, + )); } -/// @nodoc -class __$$UnexpectedErrorImplCopyWithImpl<$Res> - extends _$AuthFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl> - implements _$$UnexpectedErrorImplCopyWith<$Res> { - __$$UnexpectedErrorImplCopyWithImpl( - _$UnexpectedErrorImpl _value, - $Res Function(_$UnexpectedErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. +/// Create a copy of AuthFailure +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ApiFailureCopyWith<$Res> get failure { + + return $ApiFailureCopyWith<$Res>(_self.failure, (value) { + return _then(_self.copyWith(failure: value)); + }); +} } /// @nodoc -class _$UnexpectedErrorImpl implements _UnexpectedError { - const _$UnexpectedErrorImpl(); - @override - String toString() { +class _UnexpectedError implements AuthFailure { + const _UnexpectedError(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _UnexpectedError); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'AuthFailure.unexpectedError()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$UnexpectedErrorImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return unexpectedError(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return unexpectedError?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return unexpectedError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return unexpectedError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(this); - } - return orElse(); - } } -abstract class _UnexpectedError implements AuthFailure { - const factory _UnexpectedError() = _$UnexpectedErrorImpl; + } -/// @nodoc -abstract class _$$DynamicErrorMessageImplCopyWith<$Res> { - factory _$$DynamicErrorMessageImplCopyWith( - _$DynamicErrorMessageImpl value, - $Res Function(_$DynamicErrorMessageImpl) then, - ) = __$$DynamicErrorMessageImplCopyWithImpl<$Res>; - @useResult - $Res call({String erroMessage}); -} -/// @nodoc -class __$$DynamicErrorMessageImplCopyWithImpl<$Res> - extends _$AuthFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl> - implements _$$DynamicErrorMessageImplCopyWith<$Res> { - __$$DynamicErrorMessageImplCopyWithImpl( - _$DynamicErrorMessageImpl _value, - $Res Function(_$DynamicErrorMessageImpl) _then, - ) : super(_value, _then); - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? erroMessage = null}) { - return _then( - _$DynamicErrorMessageImpl( - null == erroMessage - ? _value.erroMessage - : erroMessage // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } -} /// @nodoc -class _$DynamicErrorMessageImpl implements _DynamicErrorMessage { - const _$DynamicErrorMessageImpl(this.erroMessage); - @override - final String erroMessage; +class _DynamicErrorMessage implements AuthFailure { + const _DynamicErrorMessage(this.erroMessage); + - @override - String toString() { + final String erroMessage; + +/// Create a copy of AuthFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$DynamicErrorMessageCopyWith<_DynamicErrorMessage> get copyWith => __$DynamicErrorMessageCopyWithImpl<_DynamicErrorMessage>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _DynamicErrorMessage&&(identical(other.erroMessage, erroMessage) || other.erroMessage == erroMessage)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,erroMessage); +} + +@override +String toString() { return 'AuthFailure.dynamicErrorMessage(erroMessage: $erroMessage)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DynamicErrorMessageImpl && - (identical(other.erroMessage, erroMessage) || - other.erroMessage == erroMessage)); - } - - @override - int get hashCode => Object.hash(runtimeType, erroMessage); - - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => - __$$DynamicErrorMessageImplCopyWithImpl<_$DynamicErrorMessageImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return dynamicErrorMessage(erroMessage); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return dynamicErrorMessage?.call(erroMessage); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (dynamicErrorMessage != null) { - return dynamicErrorMessage(erroMessage); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return dynamicErrorMessage(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return dynamicErrorMessage?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (dynamicErrorMessage != null) { - return dynamicErrorMessage(this); - } - return orElse(); - } } -abstract class _DynamicErrorMessage implements AuthFailure { - const factory _DynamicErrorMessage(final String erroMessage) = - _$DynamicErrorMessageImpl; - String get erroMessage; - - /// Create a copy of AuthFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$DynamicErrorMessageCopyWith<$Res> implements $AuthFailureCopyWith<$Res> { + factory _$DynamicErrorMessageCopyWith(_DynamicErrorMessage value, $Res Function(_DynamicErrorMessage) _then) = __$DynamicErrorMessageCopyWithImpl; +@useResult +$Res call({ + String erroMessage +}); + + + + +} +/// @nodoc +class __$DynamicErrorMessageCopyWithImpl<$Res> + implements _$DynamicErrorMessageCopyWith<$Res> { + __$DynamicErrorMessageCopyWithImpl(this._self, this._then); + + final _DynamicErrorMessage _self; + final $Res Function(_DynamicErrorMessage) _then; + +/// Create a copy of AuthFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? erroMessage = null,}) { + return _then(_DynamicErrorMessage( +null == erroMessage ? _self.erroMessage : erroMessage // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +// dart format on diff --git a/lib/domain/auth/entities/check_phone_entity.dart b/lib/domain/auth/entities/check_phone_entity.dart index cfb6509..b0b3ed5 100644 --- a/lib/domain/auth/entities/check_phone_entity.dart +++ b/lib/domain/auth/entities/check_phone_entity.dart @@ -1,7 +1,7 @@ part of '../auth.dart'; @freezed -class CheckPhone with _$CheckPhone { +abstract class CheckPhone with _$CheckPhone { const factory CheckPhone({ required CheckPhoneStatus status, required String message, diff --git a/lib/domain/auth/entities/login_entity.dart b/lib/domain/auth/entities/login_entity.dart index 0d869b1..3a20224 100644 --- a/lib/domain/auth/entities/login_entity.dart +++ b/lib/domain/auth/entities/login_entity.dart @@ -1,7 +1,7 @@ part of '../auth.dart'; @freezed -class Login with _$Login { +abstract class Login with _$Login { const factory Login({ required String status, required String message, @@ -20,7 +20,7 @@ class Login with _$Login { } @freezed -class User with _$User { +abstract class User with _$User { const factory User({ required String id, required String name, diff --git a/lib/domain/auth/entities/register_entity.dart b/lib/domain/auth/entities/register_entity.dart index d441c20..b1df0c2 100644 --- a/lib/domain/auth/entities/register_entity.dart +++ b/lib/domain/auth/entities/register_entity.dart @@ -1,7 +1,7 @@ part of '../auth.dart'; @freezed -class Register with _$Register { +abstract class Register with _$Register { const factory Register({ required String status, required String message, diff --git a/lib/domain/auth/entities/resend_entity.dart b/lib/domain/auth/entities/resend_entity.dart index cd77206..b4d2f37 100644 --- a/lib/domain/auth/entities/resend_entity.dart +++ b/lib/domain/auth/entities/resend_entity.dart @@ -1,7 +1,7 @@ part of '../auth.dart'; @freezed -class Resend with _$Resend { +abstract class Resend with _$Resend { const factory Resend({ required ResendStatus status, required String message, diff --git a/lib/domain/auth/entities/verify_entity.dart b/lib/domain/auth/entities/verify_entity.dart index cef23e8..f8164a3 100644 --- a/lib/domain/auth/entities/verify_entity.dart +++ b/lib/domain/auth/entities/verify_entity.dart @@ -1,7 +1,7 @@ part of '../auth.dart'; @freezed -class Verify with _$Verify { +abstract class Verify with _$Verify { const factory Verify({ required String status, required String message, diff --git a/lib/domain/customer/customer.dart b/lib/domain/customer/customer.dart deleted file mode 100644 index 571a2d6..0000000 --- a/lib/domain/customer/customer.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:dartz/dartz.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -import '../../common/api/api_failure.dart'; - -part 'customer.freezed.dart'; - -part 'entities/customer_point_entity.dart'; -part 'failures/customer_failures.dart'; -part 'repositories/i_customer_repository.dart'; diff --git a/lib/domain/customer/customer.freezed.dart b/lib/domain/customer/customer.freezed.dart deleted file mode 100644 index 6ff1ab3..0000000 --- a/lib/domain/customer/customer.freezed.dart +++ /dev/null @@ -1,713 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'customer.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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 _$CustomerPoint { - String get status => throw _privateConstructorUsedError; - String get message => throw _privateConstructorUsedError; - int get totalPoints => throw _privateConstructorUsedError; - String get lastUpdated => throw _privateConstructorUsedError; - - /// Create a copy of CustomerPoint - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CustomerPointCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $CustomerPointCopyWith<$Res> { - factory $CustomerPointCopyWith( - CustomerPoint value, - $Res Function(CustomerPoint) then, - ) = _$CustomerPointCopyWithImpl<$Res, CustomerPoint>; - @useResult - $Res call({ - String status, - String message, - int totalPoints, - String lastUpdated, - }); -} - -/// @nodoc -class _$CustomerPointCopyWithImpl<$Res, $Val extends CustomerPoint> - implements $CustomerPointCopyWith<$Res> { - _$CustomerPointCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CustomerPoint - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? totalPoints = null, - Object? lastUpdated = null, - }) { - return _then( - _value.copyWith( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - totalPoints: null == totalPoints - ? _value.totalPoints - : totalPoints // ignore: cast_nullable_to_non_nullable - as int, - lastUpdated: null == lastUpdated - ? _value.lastUpdated - : lastUpdated // ignore: cast_nullable_to_non_nullable - as String, - ) - as $Val, - ); - } -} - -/// @nodoc -abstract class _$$CustomerPointImplCopyWith<$Res> - implements $CustomerPointCopyWith<$Res> { - factory _$$CustomerPointImplCopyWith( - _$CustomerPointImpl value, - $Res Function(_$CustomerPointImpl) then, - ) = __$$CustomerPointImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String status, - String message, - int totalPoints, - String lastUpdated, - }); -} - -/// @nodoc -class __$$CustomerPointImplCopyWithImpl<$Res> - extends _$CustomerPointCopyWithImpl<$Res, _$CustomerPointImpl> - implements _$$CustomerPointImplCopyWith<$Res> { - __$$CustomerPointImplCopyWithImpl( - _$CustomerPointImpl _value, - $Res Function(_$CustomerPointImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerPoint - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = null, - Object? message = null, - Object? totalPoints = null, - Object? lastUpdated = null, - }) { - return _then( - _$CustomerPointImpl( - status: null == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String, - message: null == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String, - totalPoints: null == totalPoints - ? _value.totalPoints - : totalPoints // ignore: cast_nullable_to_non_nullable - as int, - lastUpdated: null == lastUpdated - ? _value.lastUpdated - : lastUpdated // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } -} - -/// @nodoc - -class _$CustomerPointImpl implements _CustomerPoint { - const _$CustomerPointImpl({ - required this.status, - required this.message, - required this.totalPoints, - required this.lastUpdated, - }); - - @override - final String status; - @override - final String message; - @override - final int totalPoints; - @override - final String lastUpdated; - - @override - String toString() { - return 'CustomerPoint(status: $status, message: $message, totalPoints: $totalPoints, lastUpdated: $lastUpdated)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CustomerPointImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.totalPoints, totalPoints) || - other.totalPoints == totalPoints) && - (identical(other.lastUpdated, lastUpdated) || - other.lastUpdated == lastUpdated)); - } - - @override - int get hashCode => - Object.hash(runtimeType, status, message, totalPoints, lastUpdated); - - /// Create a copy of CustomerPoint - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CustomerPointImplCopyWith<_$CustomerPointImpl> get copyWith => - __$$CustomerPointImplCopyWithImpl<_$CustomerPointImpl>(this, _$identity); -} - -abstract class _CustomerPoint implements CustomerPoint { - const factory _CustomerPoint({ - required final String status, - required final String message, - required final int totalPoints, - required final String lastUpdated, - }) = _$CustomerPointImpl; - - @override - String get status; - @override - String get message; - @override - int get totalPoints; - @override - String get lastUpdated; - - /// Create a copy of CustomerPoint - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CustomerPointImplCopyWith<_$CustomerPointImpl> get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -mixin _$CustomerFailure { - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $CustomerFailureCopyWith<$Res> { - factory $CustomerFailureCopyWith( - CustomerFailure value, - $Res Function(CustomerFailure) then, - ) = _$CustomerFailureCopyWithImpl<$Res, CustomerFailure>; -} - -/// @nodoc -class _$CustomerFailureCopyWithImpl<$Res, $Val extends CustomerFailure> - implements $CustomerFailureCopyWith<$Res> { - _$CustomerFailureCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc -abstract class _$$ServerErrorImplCopyWith<$Res> { - factory _$$ServerErrorImplCopyWith( - _$ServerErrorImpl value, - $Res Function(_$ServerErrorImpl) then, - ) = __$$ServerErrorImplCopyWithImpl<$Res>; - @useResult - $Res call({ApiFailure failure}); - - $ApiFailureCopyWith<$Res> get failure; -} - -/// @nodoc -class __$$ServerErrorImplCopyWithImpl<$Res> - extends _$CustomerFailureCopyWithImpl<$Res, _$ServerErrorImpl> - implements _$$ServerErrorImplCopyWith<$Res> { - __$$ServerErrorImplCopyWithImpl( - _$ServerErrorImpl _value, - $Res Function(_$ServerErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? failure = null}) { - return _then( - _$ServerErrorImpl( - null == failure - ? _value.failure - : failure // ignore: cast_nullable_to_non_nullable - as ApiFailure, - ), - ); - } - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ApiFailureCopyWith<$Res> get failure { - return $ApiFailureCopyWith<$Res>(_value.failure, (value) { - return _then(_value.copyWith(failure: value)); - }); - } -} - -/// @nodoc - -class _$ServerErrorImpl implements _ServerError { - const _$ServerErrorImpl(this.failure); - - @override - final ApiFailure failure; - - @override - String toString() { - return 'CustomerFailure.serverError(failure: $failure)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ServerErrorImpl && - (identical(other.failure, failure) || other.failure == failure)); - } - - @override - int get hashCode => Object.hash(runtimeType, failure); - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - __$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return serverError(failure); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return serverError?.call(failure); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(failure); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return serverError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return serverError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(this); - } - return orElse(); - } -} - -abstract class _ServerError implements CustomerFailure { - const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl; - - ApiFailure get failure; - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class _$$UnexpectedErrorImplCopyWith<$Res> { - factory _$$UnexpectedErrorImplCopyWith( - _$UnexpectedErrorImpl value, - $Res Function(_$UnexpectedErrorImpl) then, - ) = __$$UnexpectedErrorImplCopyWithImpl<$Res>; -} - -/// @nodoc -class __$$UnexpectedErrorImplCopyWithImpl<$Res> - extends _$CustomerFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl> - implements _$$UnexpectedErrorImplCopyWith<$Res> { - __$$UnexpectedErrorImplCopyWithImpl( - _$UnexpectedErrorImpl _value, - $Res Function(_$UnexpectedErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. -} - -/// @nodoc - -class _$UnexpectedErrorImpl implements _UnexpectedError { - const _$UnexpectedErrorImpl(); - - @override - String toString() { - return 'CustomerFailure.unexpectedError()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$UnexpectedErrorImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return unexpectedError(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return unexpectedError?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return unexpectedError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return unexpectedError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(this); - } - return orElse(); - } -} - -abstract class _UnexpectedError implements CustomerFailure { - const factory _UnexpectedError() = _$UnexpectedErrorImpl; -} - -/// @nodoc -abstract class _$$DynamicErrorMessageImplCopyWith<$Res> { - factory _$$DynamicErrorMessageImplCopyWith( - _$DynamicErrorMessageImpl value, - $Res Function(_$DynamicErrorMessageImpl) then, - ) = __$$DynamicErrorMessageImplCopyWithImpl<$Res>; - @useResult - $Res call({String erroMessage}); -} - -/// @nodoc -class __$$DynamicErrorMessageImplCopyWithImpl<$Res> - extends _$CustomerFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl> - implements _$$DynamicErrorMessageImplCopyWith<$Res> { - __$$DynamicErrorMessageImplCopyWithImpl( - _$DynamicErrorMessageImpl _value, - $Res Function(_$DynamicErrorMessageImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? erroMessage = null}) { - return _then( - _$DynamicErrorMessageImpl( - null == erroMessage - ? _value.erroMessage - : erroMessage // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } -} - -/// @nodoc - -class _$DynamicErrorMessageImpl implements _DynamicErrorMessage { - const _$DynamicErrorMessageImpl(this.erroMessage); - - @override - final String erroMessage; - - @override - String toString() { - return 'CustomerFailure.dynamicErrorMessage(erroMessage: $erroMessage)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DynamicErrorMessageImpl && - (identical(other.erroMessage, erroMessage) || - other.erroMessage == erroMessage)); - } - - @override - int get hashCode => Object.hash(runtimeType, erroMessage); - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => - __$$DynamicErrorMessageImplCopyWithImpl<_$DynamicErrorMessageImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return dynamicErrorMessage(erroMessage); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return dynamicErrorMessage?.call(erroMessage); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (dynamicErrorMessage != null) { - return dynamicErrorMessage(erroMessage); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return dynamicErrorMessage(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return dynamicErrorMessage?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (dynamicErrorMessage != null) { - return dynamicErrorMessage(this); - } - return orElse(); - } -} - -abstract class _DynamicErrorMessage implements CustomerFailure { - const factory _DynamicErrorMessage(final String erroMessage) = - _$DynamicErrorMessageImpl; - - String get erroMessage; - - /// Create a copy of CustomerFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/domain/customer/entities/customer_point_entity.dart b/lib/domain/customer/entities/customer_point_entity.dart deleted file mode 100644 index fc1750e..0000000 --- a/lib/domain/customer/entities/customer_point_entity.dart +++ /dev/null @@ -1,18 +0,0 @@ -part of '../customer.dart'; - -@freezed -class CustomerPoint with _$CustomerPoint { - const factory CustomerPoint({ - required String status, - required String message, - required int totalPoints, - required String lastUpdated, - }) = _CustomerPoint; - - factory CustomerPoint.empty() => const CustomerPoint( - status: '', - message: '', - totalPoints: 0, - lastUpdated: '', - ); -} diff --git a/lib/domain/customer/failures/customer_failures.dart b/lib/domain/customer/failures/customer_failures.dart deleted file mode 100644 index e4459ba..0000000 --- a/lib/domain/customer/failures/customer_failures.dart +++ /dev/null @@ -1,9 +0,0 @@ -part of '../customer.dart'; - -@freezed -sealed class CustomerFailure with _$CustomerFailure { - const factory CustomerFailure.serverError(ApiFailure failure) = _ServerError; - const factory CustomerFailure.unexpectedError() = _UnexpectedError; - const factory CustomerFailure.dynamicErrorMessage(String erroMessage) = - _DynamicErrorMessage; -} diff --git a/lib/domain/customer/repositories/i_customer_repository.dart b/lib/domain/customer/repositories/i_customer_repository.dart deleted file mode 100644 index 618a473..0000000 --- a/lib/domain/customer/repositories/i_customer_repository.dart +++ /dev/null @@ -1,5 +0,0 @@ -part of '../customer.dart'; - -abstract class ICustomerRepository { - Future> getPoints(); -} diff --git a/lib/domain/game/entity/game_entity.dart b/lib/domain/game/entity/game_entity.dart index 5f56b9d..6b93475 100644 --- a/lib/domain/game/entity/game_entity.dart +++ b/lib/domain/game/entity/game_entity.dart @@ -1,7 +1,9 @@ part of '../game.dart'; @freezed -class Game with _$Game { +abstract class Game with _$Game { + const Game._(); + const factory Game({ required String id, required String name, @@ -23,4 +25,11 @@ class Game with _$Game { createdAt: '', updatedAt: '', ); + + /// Biaya sekali main dalam EnakCoin (`metadata.coin_cost`), default 1. + int get coinCost { + final value = metadata['coin_cost']; + final cost = value is num ? value.toInt() : int.tryParse('$value'); + return cost == null || cost <= 0 ? 1 : cost; + } } diff --git a/lib/domain/game/entity/game_prize_entity.dart b/lib/domain/game/entity/game_prize_entity.dart index 1d32834..92d2d97 100644 --- a/lib/domain/game/entity/game_prize_entity.dart +++ b/lib/domain/game/entity/game_prize_entity.dart @@ -1,7 +1,7 @@ part of '../game.dart'; @freezed -class GamePrize with _$GamePrize { +abstract class GamePrize with _$GamePrize { const factory GamePrize({ required String id, required String gameId, diff --git a/lib/domain/game/entity/spin_result_entity.dart b/lib/domain/game/entity/spin_result_entity.dart new file mode 100644 index 0000000..29cc09f --- /dev/null +++ b/lib/domain/game/entity/spin_result_entity.dart @@ -0,0 +1,12 @@ +part of '../game.dart'; + +@freezed +abstract class SpinResult with _$SpinResult { + const factory SpinResult({ + required String gamePlayId, + required int coinsUsed, + required String prizeId, + required String prizeName, + required int coinsRemaining, + }) = _SpinResult; +} diff --git a/lib/domain/game/game.dart b/lib/domain/game/game.dart index af0911b..146ac6d 100644 --- a/lib/domain/game/game.dart +++ b/lib/domain/game/game.dart @@ -7,5 +7,6 @@ part 'game.freezed.dart'; part 'entity/game_entity.dart'; part 'entity/game_prize_entity.dart'; +part 'entity/spin_result_entity.dart'; part 'failures/game_failure.dart'; part 'repositories/i_game_repository.dart'; diff --git a/lib/domain/game/game.freezed.dart b/lib/domain/game/game.freezed.dart index 18c5557..1a478d7 100644 --- a/lib/domain/game/game.freezed.dart +++ b/lib/domain/game/game.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'game.dart'; @@ -9,1060 +9,1208 @@ part of 'game.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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 _$Game { - String get id => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - String get type => throw _privateConstructorUsedError; - bool get isActive => throw _privateConstructorUsedError; - Map get metadata => throw _privateConstructorUsedError; - List get prizes => throw _privateConstructorUsedError; - String get createdAt => throw _privateConstructorUsedError; - String get updatedAt => throw _privateConstructorUsedError; - /// Create a copy of Game - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $GameCopyWith get copyWith => throw _privateConstructorUsedError; + String get id; String get name; String get type; bool get isActive; Map get metadata; List get prizes; String get createdAt; String get updatedAt; +/// Create a copy of Game +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GameCopyWith get copyWith => _$GameCopyWithImpl(this as Game, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as Game; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Game&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.type, _this.type) || other.type == _this.type)&&(identical(other.isActive, _this.isActive) || other.isActive == _this.isActive)&&const DeepCollectionEquality().equals(other.metadata, _this.metadata)&&const DeepCollectionEquality().equals(other.prizes, _this.prizes)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)&&(identical(other.updatedAt, _this.updatedAt) || other.updatedAt == _this.updatedAt)); +} + + +@override +int get hashCode { + final _this = this as Game; + return Object.hash(runtimeType,_this.id,_this.name,_this.type,_this.isActive,const DeepCollectionEquality().hash(_this.metadata),const DeepCollectionEquality().hash(_this.prizes),_this.createdAt,_this.updatedAt); +} + +@override +String toString() { + final _this = this as Game; + return 'Game(id: ${_this.id}, name: ${_this.name}, type: ${_this.type}, isActive: ${_this.isActive}, metadata: ${_this.metadata}, prizes: ${_this.prizes}, createdAt: ${_this.createdAt}, updatedAt: ${_this.updatedAt})'; +} + + } /// @nodoc -abstract class $GameCopyWith<$Res> { - factory $GameCopyWith(Game value, $Res Function(Game) then) = - _$GameCopyWithImpl<$Res, Game>; - @useResult - $Res call({ - String id, - String name, - String type, - bool isActive, - Map metadata, - List prizes, - String createdAt, - String updatedAt, - }); -} +abstract mixin class $GameCopyWith<$Res> { + factory $GameCopyWith(Game value, $Res Function(Game) _then) = _$GameCopyWithImpl; +@useResult +$Res call({ + String id, String name, String type, bool isActive, Map metadata, List prizes, String createdAt, String updatedAt +}); + + + +} /// @nodoc -class _$GameCopyWithImpl<$Res, $Val extends Game> +class _$GameCopyWithImpl<$Res> implements $GameCopyWith<$Res> { - _$GameCopyWithImpl(this._value, this._then); + _$GameCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final Game _self; + final $Res Function(Game) _then; - /// Create a copy of Game - /// 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? type = null, - Object? isActive = null, - Object? metadata = null, - Object? prizes = null, - Object? createdAt = null, - Object? updatedAt = 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, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as String, - isActive: null == isActive - ? _value.isActive - : isActive // ignore: cast_nullable_to_non_nullable - as bool, - metadata: null == metadata - ? _value.metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map, - prizes: null == prizes - ? _value.prizes - : prizes // ignore: cast_nullable_to_non_nullable - as List, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - updatedAt: null == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String, - ) - as $Val, - ); - } +/// Create a copy of Game +/// 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? type = null,Object? isActive = null,Object? metadata = null,Object? prizes = null,Object? createdAt = null,Object? updatedAt = null,}) { + return _then(Game( +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,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String,isActive: null == isActive ? _self.isActive : isActive // ignore: cast_nullable_to_non_nullable +as bool,metadata: null == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map,prizes: null == prizes ? _self.prizes : prizes // ignore: cast_nullable_to_non_nullable +as List,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -abstract class _$$GameImplCopyWith<$Res> implements $GameCopyWith<$Res> { - factory _$$GameImplCopyWith( - _$GameImpl value, - $Res Function(_$GameImpl) then, - ) = __$$GameImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String id, - String name, - String type, - bool isActive, - Map metadata, - List prizes, - String createdAt, - String updatedAt, - }); } -/// @nodoc -class __$$GameImplCopyWithImpl<$Res> - extends _$GameCopyWithImpl<$Res, _$GameImpl> - implements _$$GameImplCopyWith<$Res> { - __$$GameImplCopyWithImpl(_$GameImpl _value, $Res Function(_$GameImpl) _then) - : super(_value, _then); - /// Create a copy of Game - /// 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? type = null, - Object? isActive = null, - Object? metadata = null, - Object? prizes = null, - Object? createdAt = null, - Object? updatedAt = null, - }) { - return _then( - _$GameImpl( - 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, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as String, - isActive: null == isActive - ? _value.isActive - : isActive // ignore: cast_nullable_to_non_nullable - as bool, - metadata: null == metadata - ? _value._metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map, - prizes: null == prizes - ? _value._prizes - : prizes // ignore: cast_nullable_to_non_nullable - as List, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - updatedAt: null == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } +/// Adds pattern-matching-related methods to [Game]. +extension GamePatterns on Game { +/// 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( _Game value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Game() 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( _Game value) $default,){ +final _that = this; +switch (_that) { +case _Game(): +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( _Game value)? $default,){ +final _that = this; +switch (_that) { +case _Game() 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, String type, bool isActive, Map metadata, List prizes, String createdAt, String updatedAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Game() when $default != null: +return $default(_that.id,_that.name,_that.type,_that.isActive,_that.metadata,_that.prizes,_that.createdAt,_that.updatedAt);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, String type, bool isActive, Map metadata, List prizes, String createdAt, String updatedAt) $default,) {final _that = this; +switch (_that) { +case _Game(): +return $default(_that.id,_that.name,_that.type,_that.isActive,_that.metadata,_that.prizes,_that.createdAt,_that.updatedAt);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, String type, bool isActive, Map metadata, List prizes, String createdAt, String updatedAt)? $default,) {final _that = this; +switch (_that) { +case _Game() when $default != null: +return $default(_that.id,_that.name,_that.type,_that.isActive,_that.metadata,_that.prizes,_that.createdAt,_that.updatedAt);case _: + return null; + +} +} + } /// @nodoc -class _$GameImpl implements _Game { - const _$GameImpl({ - required this.id, - required this.name, - required this.type, - required this.isActive, - required final Map metadata, - required final List prizes, - required this.createdAt, - required this.updatedAt, - }) : _metadata = metadata, - _prizes = prizes; - @override - final String id; - @override - final String name; - @override - final String type; - @override - final bool isActive; - final Map _metadata; - @override - Map get metadata { - if (_metadata is EqualUnmodifiableMapView) return _metadata; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_metadata); - } +class _Game extends Game { + const _Game({required this.id, required this.name, required this.type, required this.isActive, required Map metadata, required List prizes, required this.createdAt, required this.updatedAt}): _metadata = metadata,_prizes = prizes,super._(); + - final List _prizes; - @override - List get prizes { - if (_prizes is EqualUnmodifiableListView) return _prizes; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_prizes); - } +@override final String id; +@override final String name; +@override final String type; +@override final bool isActive; + final Map _metadata; +@override Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); +} - @override - final String createdAt; - @override - final String updatedAt; + final List _prizes; +@override List get prizes { + if (_prizes is EqualUnmodifiableListView) return _prizes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_prizes); +} - @override - String toString() { +@override final String createdAt; +@override final String updatedAt; + +/// Create a copy of Game +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$GameCopyWith<_Game> get copyWith => __$GameCopyWithImpl<_Game>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Game&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.type, type) || other.type == type)&&(identical(other.isActive, isActive) || other.isActive == isActive)&&const DeepCollectionEquality().equals(other.metadata, _metadata)&&const DeepCollectionEquality().equals(other.prizes, _prizes)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,name,type,isActive,const DeepCollectionEquality().hash(_metadata),const DeepCollectionEquality().hash(_prizes),createdAt,updatedAt); +} + +@override +String toString() { return 'Game(id: $id, name: $name, type: $type, isActive: $isActive, metadata: $metadata, prizes: $prizes, createdAt: $createdAt, updatedAt: $updatedAt)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$GameImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.name, name) || other.name == name) && - (identical(other.type, type) || other.type == type) && - (identical(other.isActive, isActive) || - other.isActive == isActive) && - const DeepCollectionEquality().equals(other._metadata, _metadata) && - const DeepCollectionEquality().equals(other._prizes, _prizes) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.updatedAt, updatedAt) || - other.updatedAt == updatedAt)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - id, - name, - type, - isActive, - const DeepCollectionEquality().hash(_metadata), - const DeepCollectionEquality().hash(_prizes), - createdAt, - updatedAt, - ); - - /// Create a copy of Game - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$GameImplCopyWith<_$GameImpl> get copyWith => - __$$GameImplCopyWithImpl<_$GameImpl>(this, _$identity); } -abstract class _Game implements Game { - const factory _Game({ - required final String id, - required final String name, - required final String type, - required final bool isActive, - required final Map metadata, - required final List prizes, - required final String createdAt, - required final String updatedAt, - }) = _$GameImpl; - @override - String get id; - @override - String get name; - @override - String get type; - @override - bool get isActive; - @override - Map get metadata; - @override - List get prizes; - @override - String get createdAt; - @override - String get updatedAt; +} + +/// @nodoc +abstract mixin class _$GameCopyWith<$Res> implements $GameCopyWith<$Res> { + factory _$GameCopyWith(_Game value, $Res Function(_Game) _then) = __$GameCopyWithImpl; +@override @useResult +$Res call({ + String id, String name, String type, bool isActive, Map metadata, List prizes, String createdAt, String updatedAt +}); + + + + +} +/// @nodoc +class __$GameCopyWithImpl<$Res> + implements _$GameCopyWith<$Res> { + __$GameCopyWithImpl(this._self, this._then); + + final _Game _self; + final $Res Function(_Game) _then; + +/// Create a copy of Game +/// 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? type = null,Object? isActive = null,Object? metadata = null,Object? prizes = null,Object? createdAt = null,Object? updatedAt = null,}) { + return _then(_Game( +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,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String,isActive: null == isActive ? _self.isActive : isActive // ignore: cast_nullable_to_non_nullable +as bool,metadata: null == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map,prizes: null == prizes ? _self._prizes : prizes // ignore: cast_nullable_to_non_nullable +as List,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String, + )); +} + - /// Create a copy of Game - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$GameImplCopyWith<_$GameImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$GamePrize { - String get id => throw _privateConstructorUsedError; - String get gameId => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - Map get metadata => throw _privateConstructorUsedError; - String get createdAt => throw _privateConstructorUsedError; - String get updatedAt => throw _privateConstructorUsedError; - /// Create a copy of GamePrize - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $GamePrizeCopyWith get copyWith => - throw _privateConstructorUsedError; + String get id; String get gameId; String get name; Map get metadata; String get createdAt; String get updatedAt; +/// Create a copy of GamePrize +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GamePrizeCopyWith get copyWith => _$GamePrizeCopyWithImpl(this as GamePrize, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as GamePrize; + return identical(this, other) || (other.runtimeType == runtimeType&&other is GamePrize&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.gameId, _this.gameId) || other.gameId == _this.gameId)&&(identical(other.name, _this.name) || other.name == _this.name)&&const DeepCollectionEquality().equals(other.metadata, _this.metadata)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)&&(identical(other.updatedAt, _this.updatedAt) || other.updatedAt == _this.updatedAt)); +} + + +@override +int get hashCode { + final _this = this as GamePrize; + return Object.hash(runtimeType,_this.id,_this.gameId,_this.name,const DeepCollectionEquality().hash(_this.metadata),_this.createdAt,_this.updatedAt); +} + +@override +String toString() { + final _this = this as GamePrize; + return 'GamePrize(id: ${_this.id}, gameId: ${_this.gameId}, name: ${_this.name}, metadata: ${_this.metadata}, createdAt: ${_this.createdAt}, updatedAt: ${_this.updatedAt})'; +} + + } /// @nodoc -abstract class $GamePrizeCopyWith<$Res> { - factory $GamePrizeCopyWith(GamePrize value, $Res Function(GamePrize) then) = - _$GamePrizeCopyWithImpl<$Res, GamePrize>; - @useResult - $Res call({ - String id, - String gameId, - String name, - Map metadata, - String createdAt, - String updatedAt, - }); -} +abstract mixin class $GamePrizeCopyWith<$Res> { + factory $GamePrizeCopyWith(GamePrize value, $Res Function(GamePrize) _then) = _$GamePrizeCopyWithImpl; +@useResult +$Res call({ + String id, String gameId, String name, Map metadata, String createdAt, String updatedAt +}); + + + +} /// @nodoc -class _$GamePrizeCopyWithImpl<$Res, $Val extends GamePrize> +class _$GamePrizeCopyWithImpl<$Res> implements $GamePrizeCopyWith<$Res> { - _$GamePrizeCopyWithImpl(this._value, this._then); + _$GamePrizeCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final GamePrize _self; + final $Res Function(GamePrize) _then; - /// Create a copy of GamePrize - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? gameId = null, - Object? name = null, - Object? metadata = null, - Object? createdAt = null, - Object? updatedAt = null, - }) { - return _then( - _value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - gameId: null == gameId - ? _value.gameId - : gameId // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - metadata: null == metadata - ? _value.metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - updatedAt: null == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String, - ) - as $Val, - ); - } +/// Create a copy of GamePrize +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? gameId = null,Object? name = null,Object? metadata = null,Object? createdAt = null,Object? updatedAt = null,}) { + return _then(GamePrize( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,gameId: null == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,metadata: null == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -abstract class _$$GamePrizeImplCopyWith<$Res> - implements $GamePrizeCopyWith<$Res> { - factory _$$GamePrizeImplCopyWith( - _$GamePrizeImpl value, - $Res Function(_$GamePrizeImpl) then, - ) = __$$GamePrizeImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - String id, - String gameId, - String name, - Map metadata, - String createdAt, - String updatedAt, - }); } -/// @nodoc -class __$$GamePrizeImplCopyWithImpl<$Res> - extends _$GamePrizeCopyWithImpl<$Res, _$GamePrizeImpl> - implements _$$GamePrizeImplCopyWith<$Res> { - __$$GamePrizeImplCopyWithImpl( - _$GamePrizeImpl _value, - $Res Function(_$GamePrizeImpl) _then, - ) : super(_value, _then); - /// Create a copy of GamePrize - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? gameId = null, - Object? name = null, - Object? metadata = null, - Object? createdAt = null, - Object? updatedAt = null, - }) { - return _then( - _$GamePrizeImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String, - gameId: null == gameId - ? _value.gameId - : gameId // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - metadata: null == metadata - ? _value._metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map, - createdAt: null == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String, - updatedAt: null == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } +/// Adds pattern-matching-related methods to [GamePrize]. +extension GamePrizePatterns on GamePrize { +/// 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( _GamePrize value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _GamePrize() 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( _GamePrize value) $default,){ +final _that = this; +switch (_that) { +case _GamePrize(): +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( _GamePrize value)? $default,){ +final _that = this; +switch (_that) { +case _GamePrize() 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 gameId, String name, Map metadata, String createdAt, String updatedAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _GamePrize() when $default != null: +return $default(_that.id,_that.gameId,_that.name,_that.metadata,_that.createdAt,_that.updatedAt);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 gameId, String name, Map metadata, String createdAt, String updatedAt) $default,) {final _that = this; +switch (_that) { +case _GamePrize(): +return $default(_that.id,_that.gameId,_that.name,_that.metadata,_that.createdAt,_that.updatedAt);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 gameId, String name, Map metadata, String createdAt, String updatedAt)? $default,) {final _that = this; +switch (_that) { +case _GamePrize() when $default != null: +return $default(_that.id,_that.gameId,_that.name,_that.metadata,_that.createdAt,_that.updatedAt);case _: + return null; + +} +} + } /// @nodoc -class _$GamePrizeImpl implements _GamePrize { - const _$GamePrizeImpl({ - required this.id, - required this.gameId, - required this.name, - required final Map metadata, - required this.createdAt, - required this.updatedAt, - }) : _metadata = metadata; - @override - final String id; - @override - final String gameId; - @override - final String name; - final Map _metadata; - @override - Map get metadata { - if (_metadata is EqualUnmodifiableMapView) return _metadata; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(_metadata); - } +class _GamePrize implements GamePrize { + const _GamePrize({required this.id, required this.gameId, required this.name, required Map metadata, required this.createdAt, required this.updatedAt}): _metadata = metadata; + - @override - final String createdAt; - @override - final String updatedAt; +@override final String id; +@override final String gameId; +@override final String name; + final Map _metadata; +@override Map get metadata { + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(_metadata); +} - @override - String toString() { +@override final String createdAt; +@override final String updatedAt; + +/// Create a copy of GamePrize +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$GamePrizeCopyWith<_GamePrize> get copyWith => __$GamePrizeCopyWithImpl<_GamePrize>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _GamePrize&&(identical(other.id, id) || other.id == id)&&(identical(other.gameId, gameId) || other.gameId == gameId)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other.metadata, _metadata)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,gameId,name,const DeepCollectionEquality().hash(_metadata),createdAt,updatedAt); +} + +@override +String toString() { return 'GamePrize(id: $id, gameId: $gameId, name: $name, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$GamePrizeImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.gameId, gameId) || other.gameId == gameId) && - (identical(other.name, name) || other.name == name) && - const DeepCollectionEquality().equals(other._metadata, _metadata) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.updatedAt, updatedAt) || - other.updatedAt == updatedAt)); - } - - @override - int get hashCode => Object.hash( - runtimeType, - id, - gameId, - name, - const DeepCollectionEquality().hash(_metadata), - createdAt, - updatedAt, - ); - - /// Create a copy of GamePrize - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$GamePrizeImplCopyWith<_$GamePrizeImpl> get copyWith => - __$$GamePrizeImplCopyWithImpl<_$GamePrizeImpl>(this, _$identity); } -abstract class _GamePrize implements GamePrize { - const factory _GamePrize({ - required final String id, - required final String gameId, - required final String name, - required final Map metadata, - required final String createdAt, - required final String updatedAt, - }) = _$GamePrizeImpl; - @override - String get id; - @override - String get gameId; - @override - String get name; - @override - Map get metadata; - @override - String get createdAt; - @override - String get updatedAt; +} + +/// @nodoc +abstract mixin class _$GamePrizeCopyWith<$Res> implements $GamePrizeCopyWith<$Res> { + factory _$GamePrizeCopyWith(_GamePrize value, $Res Function(_GamePrize) _then) = __$GamePrizeCopyWithImpl; +@override @useResult +$Res call({ + String id, String gameId, String name, Map metadata, String createdAt, String updatedAt +}); + + + + +} +/// @nodoc +class __$GamePrizeCopyWithImpl<$Res> + implements _$GamePrizeCopyWith<$Res> { + __$GamePrizeCopyWithImpl(this._self, this._then); + + final _GamePrize _self; + final $Res Function(_GamePrize) _then; + +/// Create a copy of GamePrize +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? gameId = null,Object? name = null,Object? metadata = null,Object? createdAt = null,Object? updatedAt = null,}) { + return _then(_GamePrize( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,gameId: null == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,metadata: null == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String,updatedAt: null == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$SpinResult { + + String get gamePlayId; int get coinsUsed; String get prizeId; String get prizeName; int get coinsRemaining; +/// Create a copy of SpinResult +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SpinResultCopyWith get copyWith => _$SpinResultCopyWithImpl(this as SpinResult, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as SpinResult; + return identical(this, other) || (other.runtimeType == runtimeType&&other is SpinResult&&(identical(other.gamePlayId, _this.gamePlayId) || other.gamePlayId == _this.gamePlayId)&&(identical(other.coinsUsed, _this.coinsUsed) || other.coinsUsed == _this.coinsUsed)&&(identical(other.prizeId, _this.prizeId) || other.prizeId == _this.prizeId)&&(identical(other.prizeName, _this.prizeName) || other.prizeName == _this.prizeName)&&(identical(other.coinsRemaining, _this.coinsRemaining) || other.coinsRemaining == _this.coinsRemaining)); +} + + +@override +int get hashCode { + final _this = this as SpinResult; + return Object.hash(runtimeType,_this.gamePlayId,_this.coinsUsed,_this.prizeId,_this.prizeName,_this.coinsRemaining); +} + +@override +String toString() { + final _this = this as SpinResult; + return 'SpinResult(gamePlayId: ${_this.gamePlayId}, coinsUsed: ${_this.coinsUsed}, prizeId: ${_this.prizeId}, prizeName: ${_this.prizeName}, coinsRemaining: ${_this.coinsRemaining})'; +} + + +} + +/// @nodoc +abstract mixin class $SpinResultCopyWith<$Res> { + factory $SpinResultCopyWith(SpinResult value, $Res Function(SpinResult) _then) = _$SpinResultCopyWithImpl; +@useResult +$Res call({ + String gamePlayId, int coinsUsed, String prizeId, String prizeName, int coinsRemaining +}); + + + + +} +/// @nodoc +class _$SpinResultCopyWithImpl<$Res> + implements $SpinResultCopyWith<$Res> { + _$SpinResultCopyWithImpl(this._self, this._then); + + final SpinResult _self; + final $Res Function(SpinResult) _then; + +/// Create a copy of SpinResult +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? gamePlayId = null,Object? coinsUsed = null,Object? prizeId = null,Object? prizeName = null,Object? coinsRemaining = null,}) { + return _then(SpinResult( +gamePlayId: null == gamePlayId ? _self.gamePlayId : gamePlayId // ignore: cast_nullable_to_non_nullable +as String,coinsUsed: null == coinsUsed ? _self.coinsUsed : coinsUsed // ignore: cast_nullable_to_non_nullable +as int,prizeId: null == prizeId ? _self.prizeId : prizeId // ignore: cast_nullable_to_non_nullable +as String,prizeName: null == prizeName ? _self.prizeName : prizeName // ignore: cast_nullable_to_non_nullable +as String,coinsRemaining: null == coinsRemaining ? _self.coinsRemaining : coinsRemaining // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} + + +/// Adds pattern-matching-related methods to [SpinResult]. +extension SpinResultPatterns on SpinResult { +/// 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( _SpinResult value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _SpinResult() 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( _SpinResult value) $default,){ +final _that = this; +switch (_that) { +case _SpinResult(): +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( _SpinResult value)? $default,){ +final _that = this; +switch (_that) { +case _SpinResult() 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 gamePlayId, int coinsUsed, String prizeId, String prizeName, int coinsRemaining)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _SpinResult() when $default != null: +return $default(_that.gamePlayId,_that.coinsUsed,_that.prizeId,_that.prizeName,_that.coinsRemaining);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 gamePlayId, int coinsUsed, String prizeId, String prizeName, int coinsRemaining) $default,) {final _that = this; +switch (_that) { +case _SpinResult(): +return $default(_that.gamePlayId,_that.coinsUsed,_that.prizeId,_that.prizeName,_that.coinsRemaining);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 gamePlayId, int coinsUsed, String prizeId, String prizeName, int coinsRemaining)? $default,) {final _that = this; +switch (_that) { +case _SpinResult() when $default != null: +return $default(_that.gamePlayId,_that.coinsUsed,_that.prizeId,_that.prizeName,_that.coinsRemaining);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _SpinResult implements SpinResult { + const _SpinResult({required this.gamePlayId, required this.coinsUsed, required this.prizeId, required this.prizeName, required this.coinsRemaining}); + + +@override final String gamePlayId; +@override final int coinsUsed; +@override final String prizeId; +@override final String prizeName; +@override final int coinsRemaining; + +/// Create a copy of SpinResult +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SpinResultCopyWith<_SpinResult> get copyWith => __$SpinResultCopyWithImpl<_SpinResult>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SpinResult&&(identical(other.gamePlayId, gamePlayId) || other.gamePlayId == gamePlayId)&&(identical(other.coinsUsed, coinsUsed) || other.coinsUsed == coinsUsed)&&(identical(other.prizeId, prizeId) || other.prizeId == prizeId)&&(identical(other.prizeName, prizeName) || other.prizeName == prizeName)&&(identical(other.coinsRemaining, coinsRemaining) || other.coinsRemaining == coinsRemaining)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,gamePlayId,coinsUsed,prizeId,prizeName,coinsRemaining); +} + +@override +String toString() { + return 'SpinResult(gamePlayId: $gamePlayId, coinsUsed: $coinsUsed, prizeId: $prizeId, prizeName: $prizeName, coinsRemaining: $coinsRemaining)'; +} + + +} + +/// @nodoc +abstract mixin class _$SpinResultCopyWith<$Res> implements $SpinResultCopyWith<$Res> { + factory _$SpinResultCopyWith(_SpinResult value, $Res Function(_SpinResult) _then) = __$SpinResultCopyWithImpl; +@override @useResult +$Res call({ + String gamePlayId, int coinsUsed, String prizeId, String prizeName, int coinsRemaining +}); + + + + +} +/// @nodoc +class __$SpinResultCopyWithImpl<$Res> + implements _$SpinResultCopyWith<$Res> { + __$SpinResultCopyWithImpl(this._self, this._then); + + final _SpinResult _self; + final $Res Function(_SpinResult) _then; + +/// Create a copy of SpinResult +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? gamePlayId = null,Object? coinsUsed = null,Object? prizeId = null,Object? prizeName = null,Object? coinsRemaining = null,}) { + return _then(_SpinResult( +gamePlayId: null == gamePlayId ? _self.gamePlayId : gamePlayId // ignore: cast_nullable_to_non_nullable +as String,coinsUsed: null == coinsUsed ? _self.coinsUsed : coinsUsed // ignore: cast_nullable_to_non_nullable +as int,prizeId: null == prizeId ? _self.prizeId : prizeId // ignore: cast_nullable_to_non_nullable +as String,prizeName: null == prizeName ? _self.prizeName : prizeName // ignore: cast_nullable_to_non_nullable +as String,coinsRemaining: null == coinsRemaining ? _self.coinsRemaining : coinsRemaining // ignore: cast_nullable_to_non_nullable +as int, + )); +} + - /// Create a copy of GamePrize - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$GamePrizeImplCopyWith<_$GamePrizeImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc mixin _$GameFailure { - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) => throw _privateConstructorUsedError; - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) => throw _privateConstructorUsedError; + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is GameFailure); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'GameFailure()'; +} + + } /// @nodoc -abstract class $GameFailureCopyWith<$Res> { - factory $GameFailureCopyWith( - GameFailure value, - $Res Function(GameFailure) then, - ) = _$GameFailureCopyWithImpl<$Res, GameFailure>; +class $GameFailureCopyWith<$Res> { +$GameFailureCopyWith(GameFailure _, $Res Function(GameFailure) __); } -/// @nodoc -class _$GameFailureCopyWithImpl<$Res, $Val extends GameFailure> - implements $GameFailureCopyWith<$Res> { - _$GameFailureCopyWithImpl(this._value, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; +/// Adds pattern-matching-related methods to [GameFailure]. +extension GameFailurePatterns on GameFailure { +/// 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(); +/// } +/// ``` - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. +@optionalTypeArgs TResult maybeMap({TResult Function( _ServerError value)? serverError,TResult Function( _UnexpectedError value)? unexpectedError,TResult Function( _DynamicErrorMessage value)? dynamicErrorMessage,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_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({required TResult Function( _ServerError value) serverError,required TResult Function( _UnexpectedError value) unexpectedError,required TResult Function( _DynamicErrorMessage value) dynamicErrorMessage,}){ +final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that);case _UnexpectedError(): +return unexpectedError(_that);case _DynamicErrorMessage(): +return dynamicErrorMessage(_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( _ServerError value)? serverError,TResult? Function( _UnexpectedError value)? unexpectedError,TResult? Function( _DynamicErrorMessage value)? dynamicErrorMessage,}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_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( ApiFailure failure)? serverError,TResult Function()? unexpectedError,TResult Function( String erroMessage)? dynamicErrorMessage,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.failure);case _UnexpectedError() when unexpectedError != null: +return unexpectedError();case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_that.erroMessage);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({required TResult Function( ApiFailure failure) serverError,required TResult Function() unexpectedError,required TResult Function( String erroMessage) dynamicErrorMessage,}) {final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that.failure);case _UnexpectedError(): +return unexpectedError();case _DynamicErrorMessage(): +return dynamicErrorMessage(_that.erroMessage);} +} +/// 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( ApiFailure failure)? serverError,TResult? Function()? unexpectedError,TResult? Function( String erroMessage)? dynamicErrorMessage,}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.failure);case _UnexpectedError() when unexpectedError != null: +return unexpectedError();case _DynamicErrorMessage() when dynamicErrorMessage != null: +return dynamicErrorMessage(_that.erroMessage);case _: + return null; + +} } -/// @nodoc -abstract class _$$ServerErrorImplCopyWith<$Res> { - factory _$$ServerErrorImplCopyWith( - _$ServerErrorImpl value, - $Res Function(_$ServerErrorImpl) then, - ) = __$$ServerErrorImplCopyWithImpl<$Res>; - @useResult - $Res call({ApiFailure failure}); - - $ApiFailureCopyWith<$Res> get failure; -} - -/// @nodoc -class __$$ServerErrorImplCopyWithImpl<$Res> - extends _$GameFailureCopyWithImpl<$Res, _$ServerErrorImpl> - implements _$$ServerErrorImplCopyWith<$Res> { - __$$ServerErrorImplCopyWithImpl( - _$ServerErrorImpl _value, - $Res Function(_$ServerErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? failure = null}) { - return _then( - _$ServerErrorImpl( - null == failure - ? _value.failure - : failure // ignore: cast_nullable_to_non_nullable - as ApiFailure, - ), - ); - } - - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ApiFailureCopyWith<$Res> get failure { - return $ApiFailureCopyWith<$Res>(_value.failure, (value) { - return _then(_value.copyWith(failure: value)); - }); - } } /// @nodoc -class _$ServerErrorImpl implements _ServerError { - const _$ServerErrorImpl(this.failure); - @override - final ApiFailure failure; +class _ServerError implements GameFailure { + const _ServerError(this.failure); + - @override - String toString() { + final ApiFailure failure; + +/// Create a copy of GameFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ServerErrorCopyWith<_ServerError> get copyWith => __$ServerErrorCopyWithImpl<_ServerError>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServerError&&(identical(other.failure, failure) || other.failure == failure)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,failure); +} + +@override +String toString() { return 'GameFailure.serverError(failure: $failure)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ServerErrorImpl && - (identical(other.failure, failure) || other.failure == failure)); - } - - @override - int get hashCode => Object.hash(runtimeType, failure); - - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - __$$ServerErrorImplCopyWithImpl<_$ServerErrorImpl>(this, _$identity); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return serverError(failure); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return serverError?.call(failure); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(failure); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return serverError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return serverError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (serverError != null) { - return serverError(this); - } - return orElse(); - } } -abstract class _ServerError implements GameFailure { - const factory _ServerError(final ApiFailure failure) = _$ServerErrorImpl; - ApiFailure get failure; - - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ServerErrorImplCopyWith<_$ServerErrorImpl> get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$UnexpectedErrorImplCopyWith<$Res> { - factory _$$UnexpectedErrorImplCopyWith( - _$UnexpectedErrorImpl value, - $Res Function(_$UnexpectedErrorImpl) then, - ) = __$$UnexpectedErrorImplCopyWithImpl<$Res>; +abstract mixin class _$ServerErrorCopyWith<$Res> implements $GameFailureCopyWith<$Res> { + factory _$ServerErrorCopyWith(_ServerError value, $Res Function(_ServerError) _then) = __$ServerErrorCopyWithImpl; +@useResult +$Res call({ + ApiFailure failure +}); + + +$ApiFailureCopyWith<$Res> get failure; + +} +/// @nodoc +class __$ServerErrorCopyWithImpl<$Res> + implements _$ServerErrorCopyWith<$Res> { + __$ServerErrorCopyWithImpl(this._self, this._then); + + final _ServerError _self; + final $Res Function(_ServerError) _then; + +/// Create a copy of GameFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? failure = null,}) { + return _then(_ServerError( +null == failure ? _self.failure : failure // ignore: cast_nullable_to_non_nullable +as ApiFailure, + )); } -/// @nodoc -class __$$UnexpectedErrorImplCopyWithImpl<$Res> - extends _$GameFailureCopyWithImpl<$Res, _$UnexpectedErrorImpl> - implements _$$UnexpectedErrorImplCopyWith<$Res> { - __$$UnexpectedErrorImplCopyWithImpl( - _$UnexpectedErrorImpl _value, - $Res Function(_$UnexpectedErrorImpl) _then, - ) : super(_value, _then); - - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. +/// Create a copy of GameFailure +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ApiFailureCopyWith<$Res> get failure { + + return $ApiFailureCopyWith<$Res>(_self.failure, (value) { + return _then(_self.copyWith(failure: value)); + }); +} } /// @nodoc -class _$UnexpectedErrorImpl implements _UnexpectedError { - const _$UnexpectedErrorImpl(); - @override - String toString() { +class _UnexpectedError implements GameFailure { + const _UnexpectedError(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _UnexpectedError); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { return 'GameFailure.unexpectedError()'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && other is _$UnexpectedErrorImpl); - } - - @override - int get hashCode => runtimeType.hashCode; - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return unexpectedError(); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return unexpectedError?.call(); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return unexpectedError(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return unexpectedError?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (unexpectedError != null) { - return unexpectedError(this); - } - return orElse(); - } } -abstract class _UnexpectedError implements GameFailure { - const factory _UnexpectedError() = _$UnexpectedErrorImpl; + } -/// @nodoc -abstract class _$$DynamicErrorMessageImplCopyWith<$Res> { - factory _$$DynamicErrorMessageImplCopyWith( - _$DynamicErrorMessageImpl value, - $Res Function(_$DynamicErrorMessageImpl) then, - ) = __$$DynamicErrorMessageImplCopyWithImpl<$Res>; - @useResult - $Res call({String erroMessage}); -} -/// @nodoc -class __$$DynamicErrorMessageImplCopyWithImpl<$Res> - extends _$GameFailureCopyWithImpl<$Res, _$DynamicErrorMessageImpl> - implements _$$DynamicErrorMessageImplCopyWith<$Res> { - __$$DynamicErrorMessageImplCopyWithImpl( - _$DynamicErrorMessageImpl _value, - $Res Function(_$DynamicErrorMessageImpl) _then, - ) : super(_value, _then); - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? erroMessage = null}) { - return _then( - _$DynamicErrorMessageImpl( - null == erroMessage - ? _value.erroMessage - : erroMessage // ignore: cast_nullable_to_non_nullable - as String, - ), - ); - } -} /// @nodoc -class _$DynamicErrorMessageImpl implements _DynamicErrorMessage { - const _$DynamicErrorMessageImpl(this.erroMessage); - @override - final String erroMessage; +class _DynamicErrorMessage implements GameFailure { + const _DynamicErrorMessage(this.erroMessage); + - @override - String toString() { + final String erroMessage; + +/// Create a copy of GameFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$DynamicErrorMessageCopyWith<_DynamicErrorMessage> get copyWith => __$DynamicErrorMessageCopyWithImpl<_DynamicErrorMessage>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _DynamicErrorMessage&&(identical(other.erroMessage, erroMessage) || other.erroMessage == erroMessage)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,erroMessage); +} + +@override +String toString() { return 'GameFailure.dynamicErrorMessage(erroMessage: $erroMessage)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$DynamicErrorMessageImpl && - (identical(other.erroMessage, erroMessage) || - other.erroMessage == erroMessage)); - } - - @override - int get hashCode => Object.hash(runtimeType, erroMessage); - - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => - __$$DynamicErrorMessageImplCopyWithImpl<_$DynamicErrorMessageImpl>( - this, - _$identity, - ); - - @override - @optionalTypeArgs - TResult when({ - required TResult Function(ApiFailure failure) serverError, - required TResult Function() unexpectedError, - required TResult Function(String erroMessage) dynamicErrorMessage, - }) { - return dynamicErrorMessage(erroMessage); - } - - @override - @optionalTypeArgs - TResult? whenOrNull({ - TResult? Function(ApiFailure failure)? serverError, - TResult? Function()? unexpectedError, - TResult? Function(String erroMessage)? dynamicErrorMessage, - }) { - return dynamicErrorMessage?.call(erroMessage); - } - - @override - @optionalTypeArgs - TResult maybeWhen({ - TResult Function(ApiFailure failure)? serverError, - TResult Function()? unexpectedError, - TResult Function(String erroMessage)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (dynamicErrorMessage != null) { - return dynamicErrorMessage(erroMessage); - } - return orElse(); - } - - @override - @optionalTypeArgs - TResult map({ - required TResult Function(_ServerError value) serverError, - required TResult Function(_UnexpectedError value) unexpectedError, - required TResult Function(_DynamicErrorMessage value) dynamicErrorMessage, - }) { - return dynamicErrorMessage(this); - } - - @override - @optionalTypeArgs - TResult? mapOrNull({ - TResult? Function(_ServerError value)? serverError, - TResult? Function(_UnexpectedError value)? unexpectedError, - TResult? Function(_DynamicErrorMessage value)? dynamicErrorMessage, - }) { - return dynamicErrorMessage?.call(this); - } - - @override - @optionalTypeArgs - TResult maybeMap({ - TResult Function(_ServerError value)? serverError, - TResult Function(_UnexpectedError value)? unexpectedError, - TResult Function(_DynamicErrorMessage value)? dynamicErrorMessage, - required TResult orElse(), - }) { - if (dynamicErrorMessage != null) { - return dynamicErrorMessage(this); - } - return orElse(); - } } -abstract class _DynamicErrorMessage implements GameFailure { - const factory _DynamicErrorMessage(final String erroMessage) = - _$DynamicErrorMessageImpl; - String get erroMessage; - - /// Create a copy of GameFailure - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - _$$DynamicErrorMessageImplCopyWith<_$DynamicErrorMessageImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$DynamicErrorMessageCopyWith<$Res> implements $GameFailureCopyWith<$Res> { + factory _$DynamicErrorMessageCopyWith(_DynamicErrorMessage value, $Res Function(_DynamicErrorMessage) _then) = __$DynamicErrorMessageCopyWithImpl; +@useResult +$Res call({ + String erroMessage +}); + + + + +} +/// @nodoc +class __$DynamicErrorMessageCopyWithImpl<$Res> + implements _$DynamicErrorMessageCopyWith<$Res> { + __$DynamicErrorMessageCopyWithImpl(this._self, this._then); + + final _DynamicErrorMessage _self; + final $Res Function(_DynamicErrorMessage) _then; + +/// Create a copy of GameFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? erroMessage = null,}) { + return _then(_DynamicErrorMessage( +null == erroMessage ? _self.erroMessage : erroMessage // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +// dart format on diff --git a/lib/domain/game/repositories/i_game_repository.dart b/lib/domain/game/repositories/i_game_repository.dart index f297b14..c40cba3 100644 --- a/lib/domain/game/repositories/i_game_repository.dart +++ b/lib/domain/game/repositories/i_game_repository.dart @@ -2,4 +2,7 @@ part of '../game.dart'; abstract class IGameRepository { Future> ferrisWheel(); + + /// Main satu kali; memotong EnakCoin sebesar biaya game. Tanpa PIN. + Future> spin({required String gameId}); } diff --git a/lib/domain/wallet/entities/customer_order_entity.dart b/lib/domain/wallet/entities/customer_order_entity.dart new file mode 100644 index 0000000..7901b05 --- /dev/null +++ b/lib/domain/wallet/entities/customer_order_entity.dart @@ -0,0 +1,88 @@ +part of '../wallet.dart'; + +/// Order milik customer di daftar riwayat (§4.5). +@freezed +abstract class CustomerOrder with _$CustomerOrder { + const CustomerOrder._(); + + const factory CustomerOrder({ + required String id, + required String orderNumber, + required String outletName, + required String orderType, + required String status, + required String paymentStatus, + required int totalAmount, + required int itemCount, + required bool isVoid, + required bool isRefund, + required int pointsEarned, + required int coinsEarned, + DateTime? createdAt, + }) = _CustomerOrder; + + bool get isDineIn => orderType == 'dine_in'; +} + +@freezed +abstract class CustomerOrderPage with _$CustomerOrderPage { + const factory CustomerOrderPage({ + required List items, + required int page, + required int totalPages, + }) = _CustomerOrderPage; +} + +/// Detail order: field [order] ditambah rincian item dan pembayaran. +@freezed +abstract class CustomerOrderDetail with _$CustomerOrderDetail { + const factory CustomerOrderDetail({ + required CustomerOrder order, + String? tableNumber, + required int subtotal, + required int discountAmount, + required int taxAmount, + required int refundAmount, + required List items, + required List payments, + }) = _CustomerOrderDetail; +} + +@freezed +abstract class CustomerOrderItem with _$CustomerOrderItem { + const CustomerOrderItem._(); + + const factory CustomerOrderItem({ + required String id, + required String productName, + String? variantName, + required int quantity, + + /// Hanya untuk item timbangan, mis. 4,2 [unitName]. + double? weight, + String? unitName, + required int unitPrice, + required int totalPrice, + required int refundQuantity, + }) = _CustomerOrderItem; + + bool get isWeighted => weight != null; +} + +@freezed +abstract class CustomerOrderPayment with _$CustomerOrderPayment { + const CustomerOrderPayment._(); + + const factory CustomerOrderPayment({ + required String id, + required String methodName, + required String methodType, + required int amount, + required int refundAmount, + + /// Hanya pada pembayaran EnakPoint. + int? pointsUsed, + }) = _CustomerOrderPayment; + + bool get isPoint => methodType == 'point'; +} diff --git a/lib/domain/wallet/entities/exchange_entity.dart b/lib/domain/wallet/entities/exchange_entity.dart new file mode 100644 index 0000000..122e8a2 --- /dev/null +++ b/lib/domain/wallet/entities/exchange_entity.dart @@ -0,0 +1,33 @@ +part of '../wallet.dart'; + +@freezed +abstract class ExchangePreview with _$ExchangePreview { + const factory ExchangePreview({ + required int coinAmount, + required int pointAmount, + required int coinBalance, + required int coins, + required int points, + required bool valid, + String? reason, + }) = _ExchangePreview; +} + +@freezed +abstract class ExchangeResult with _$ExchangeResult { + const factory ExchangeResult({ + required int coins, + required int points, + required int coinBalance, + required int pointBalance, + required List lots, + required bool replayed, + }) = _ExchangeResult; +} + +/// Bagian saldo dengan tanggal kedaluwarsanya sendiri. +@freezed +abstract class WalletLot with _$WalletLot { + const factory WalletLot({required int amount, DateTime? expiresAt}) = + _WalletLot; +} diff --git a/lib/domain/wallet/entities/outlet_entity.dart b/lib/domain/wallet/entities/outlet_entity.dart new file mode 100644 index 0000000..7966ee0 --- /dev/null +++ b/lib/domain/wallet/entities/outlet_entity.dart @@ -0,0 +1,20 @@ +part of '../wallet.dart'; + +/// Outlet aktif di organisasi customer, tempat saldo berlaku (§4.4). +@freezed +abstract class Outlet with _$Outlet { + const factory Outlet({ + required String id, + required String name, + String? address, + + /// Kasir di outlet ini menerima pembayaran EnakPoint. + required bool acceptsPointPayment, + + /// Belanja di outlet ini memberi EnakPoint. + required bool earnsPoints, + + /// Belanja di outlet ini memberi EnakCoin. + required bool earnsCoins, + }) = _Outlet; +} diff --git a/lib/domain/wallet/entities/payment_code_entity.dart b/lib/domain/wallet/entities/payment_code_entity.dart new file mode 100644 index 0000000..b293ed3 --- /dev/null +++ b/lib/domain/wallet/entities/payment_code_entity.dart @@ -0,0 +1,10 @@ +part of '../wallet.dart'; + +@freezed +abstract class PaymentCode with _$PaymentCode { + const factory PaymentCode({ + required String code, + required String qrPayload, + required DateTime expiresAt, + }) = _PaymentCode; +} diff --git a/lib/domain/wallet/entities/pin_entity.dart b/lib/domain/wallet/entities/pin_entity.dart new file mode 100644 index 0000000..815efdb --- /dev/null +++ b/lib/domain/wallet/entities/pin_entity.dart @@ -0,0 +1,24 @@ +part of '../wallet.dart'; + +@freezed +abstract class PinStatus with _$PinStatus { + const PinStatus._(); + + const factory PinStatus({ + required bool hasPin, + DateTime? lockedUntil, + DateTime? transferBlockedUntil, + }) = _PinStatus; + + bool get isLocked => + lockedUntil != null && lockedUntil!.isAfter(DateTime.now()); +} + +@freezed +abstract class PinOtp with _$PinOtp { + const factory PinOtp({ + required PinOtpPurpose purpose, + required String otpToken, + DateTime? expiresAt, + }) = _PinOtp; +} diff --git a/lib/domain/wallet/entities/transfer_entity.dart b/lib/domain/wallet/entities/transfer_entity.dart new file mode 100644 index 0000000..4c99f9b --- /dev/null +++ b/lib/domain/wallet/entities/transfer_entity.dart @@ -0,0 +1,22 @@ +part of '../wallet.dart'; + +/// Penerima transfer; [name] dan [phoneNumber] sudah disamarkan oleh server. +@freezed +abstract class TransferRecipient with _$TransferRecipient { + const factory TransferRecipient({ + required String name, + required String phoneNumber, + }) = _TransferRecipient; +} + +@freezed +abstract class TransferResult with _$TransferResult { + const factory TransferResult({ + required WalletCurrency currency, + required int amount, + required TransferRecipient recipient, + required List lots, + required int balance, + required bool replayed, + }) = _TransferResult; +} diff --git a/lib/domain/wallet/entities/wallet_enum.dart b/lib/domain/wallet/entities/wallet_enum.dart new file mode 100644 index 0000000..cdfbd16 --- /dev/null +++ b/lib/domain/wallet/entities/wallet_enum.dart @@ -0,0 +1,51 @@ +part of '../wallet.dart'; + +enum WalletCurrency { + point('POINT', 'EnakPoint'), + coin('COIN', 'EnakCoin'); + + const WalletCurrency(this.apiValue, this.label); + + final String apiValue; + final String label; + + static WalletCurrency fromApi(String? value) => + value == coin.apiValue ? coin : point; +} + +enum WalletTransactionType { + earn('EARN', 'Dari belanja'), + earnReversal('EARN_REVERSAL', 'Dibatalkan (order di-void/refund)'), + payment('PAYMENT', 'Bayar pesanan'), + paymentRefund('PAYMENT_REFUND', 'Pengembalian pembayaran'), + exchangeOut('EXCHANGE_OUT', 'Ditukar ke EnakPoint'), + exchangeIn('EXCHANGE_IN', 'Hasil tukar EnakCoin'), + transferOut('TRANSFER_OUT', 'Transfer keluar'), + transferIn('TRANSFER_IN', 'Transfer masuk'), + gameSpend('GAME_SPEND', 'Main game'), + expire('EXPIRE', 'Kedaluwarsa'), + adjustment('ADJUSTMENT', 'Koreksi'), + migration('MIGRATION', 'Saldo awal'), + unknown('', 'Transaksi'); + + const WalletTransactionType(this.apiValue, this.label); + + final String apiValue; + final String label; + + /// Tipe yang bisa dipilih di filter riwayat. + static List get filterable => + values.where((e) => e != unknown).toList(); + + static WalletTransactionType fromApi(String? value) => + values.firstWhere((e) => e.apiValue == value, orElse: () => unknown); +} + +enum PinOtpPurpose { + setup('pin_setup'), + reset('pin_reset'); + + const PinOtpPurpose(this.apiValue); + + final String apiValue; +} diff --git a/lib/domain/wallet/entities/wallet_expiring_entity.dart b/lib/domain/wallet/entities/wallet_expiring_entity.dart new file mode 100644 index 0000000..4407af1 --- /dev/null +++ b/lib/domain/wallet/entities/wallet_expiring_entity.dart @@ -0,0 +1,11 @@ +part of '../wallet.dart'; + +@freezed +abstract class WalletExpiring with _$WalletExpiring { + const factory WalletExpiring({ + required List point, + required List coin, + }) = _WalletExpiring; + + factory WalletExpiring.empty() => const WalletExpiring(point: [], coin: []); +} diff --git a/lib/domain/wallet/entities/wallet_summary_entity.dart b/lib/domain/wallet/entities/wallet_summary_entity.dart new file mode 100644 index 0000000..19adc58 --- /dev/null +++ b/lib/domain/wallet/entities/wallet_summary_entity.dart @@ -0,0 +1,30 @@ +part of '../wallet.dart'; + +@freezed +abstract class WalletSummary with _$WalletSummary { + const factory WalletSummary({ + required int pointBalance, + required int coinBalance, + required int pointValue, + required int pointDiscountValue, + ExpiringAmount? nearestExpiringPoint, + ExpiringAmount? nearestExpiringCoin, + required List recentTransactions, + }) = _WalletSummary; + + factory WalletSummary.empty() => const WalletSummary( + pointBalance: 0, + coinBalance: 0, + pointValue: 0, + pointDiscountValue: 0, + recentTransactions: [], + ); +} + +/// Jumlah saldo yang akan hangus pada [date] (tanggal WIB, berlaku sampai +/// 23:59:59 WIB di tanggal itu). +@freezed +abstract class ExpiringAmount with _$ExpiringAmount { + const factory ExpiringAmount({required int amount, required DateTime date}) = + _ExpiringAmount; +} diff --git a/lib/domain/wallet/entities/wallet_transaction_entity.dart b/lib/domain/wallet/entities/wallet_transaction_entity.dart new file mode 100644 index 0000000..2e2d2a9 --- /dev/null +++ b/lib/domain/wallet/entities/wallet_transaction_entity.dart @@ -0,0 +1,30 @@ +part of '../wallet.dart'; + +@freezed +abstract class WalletTransaction with _$WalletTransaction { + const WalletTransaction._(); + + const factory WalletTransaction({ + required String id, + required WalletCurrency currency, + required WalletTransactionType type, + required int amount, + required int balanceAfter, + required String description, + String? groupId, + DateTime? expiresAt, + DateTime? createdAt, + }) = _WalletTransaction; + + bool get isIncoming => amount > 0; +} + +@freezed +abstract class WalletTransactionPage with _$WalletTransactionPage { + const factory WalletTransactionPage({ + required List items, + required int page, + required int totalPages, + required int totalCount, + }) = _WalletTransactionPage; +} diff --git a/lib/domain/wallet/failures/wallet_failure.dart b/lib/domain/wallet/failures/wallet_failure.dart new file mode 100644 index 0000000..92971e4 --- /dev/null +++ b/lib/domain/wallet/failures/wallet_failure.dart @@ -0,0 +1,54 @@ +part of '../wallet.dart'; + +@freezed +sealed class WalletFailure with _$WalletFailure { + const WalletFailure._(); + + /// Gagal di level transport (jaringan, timeout, parsing). + const factory WalletFailure.serverError(ApiFailure failure) = _ServerError; + const factory WalletFailure.unexpectedError() = _UnexpectedError; + const factory WalletFailure.unauthorized() = _Unauthorized; + + /// `303`, `310`: request tidak lengkap / salah format. + const factory WalletFailure.invalidRequest() = _InvalidRequest; + + /// `304`: ditolak aturan bisnis. [cause] berbahasa Inggris, jangan ditampilkan + /// mentah ke customer. + const factory WalletFailure.rejected(String cause) = _Rejected; + + /// `404`. + const factory WalletFailure.notFound() = _NotFound; + + /// `429`: minta OTP terlalu cepat. + const factory WalletFailure.tooManyRequests(int retryAfterSeconds) = + _TooManyRequests; + + /// `900`. + const factory WalletFailure.internalError() = _InternalError; + + const factory WalletFailure.pinNotSet() = _PinNotSet; + const factory WalletFailure.pinInvalid(int? remainingAttempts) = _PinInvalid; + const factory WalletFailure.pinLocked(DateTime? lockedUntil) = _PinLocked; + const factory WalletFailure.transferBlocked(DateTime? transferBlockedUntil) = + _TransferBlocked; + + bool get isPinError => maybeMap( + pinNotSet: (_) => true, + pinInvalid: (_) => true, + pinLocked: (_) => true, + transferBlocked: (_) => true, + orElse: () => false, + ); + + /// Request mungkin tidak sampai / jawaban tidak diterima, sehingga hasilnya + /// tidak diketahui. Hanya pada kondisi ini `Idempotency-Key` dipakai ulang. + bool get isNetworkError => maybeMap( + serverError: (value) => value.failure.maybeMap( + connectionError: (_) => true, + connectionTimeout: (_) => true, + serverError: (e) => e.statusCode == 0, + orElse: () => false, + ), + orElse: () => false, + ); +} diff --git a/lib/domain/wallet/repositories/i_device_repository.dart b/lib/domain/wallet/repositories/i_device_repository.dart new file mode 100644 index 0000000..40a2999 --- /dev/null +++ b/lib/domain/wallet/repositories/i_device_repository.dart @@ -0,0 +1,15 @@ +part of '../wallet.dart'; + +/// Registrasi device untuk push notification (FCM). +abstract class IDeviceRepository { + /// Dipanggil setelah login dan setiap kali FCM memberi token baru. + Future> register({ + required String fcmToken, + required String platform, + required String appVersion, + }); + + /// Dipanggil saat logout, sebelum token login dihapus. Tidak memanggil API + /// bila device ini belum pernah diregistrasi. + Future> unregister(); +} diff --git a/lib/domain/wallet/repositories/i_order_repository.dart b/lib/domain/wallet/repositories/i_order_repository.dart new file mode 100644 index 0000000..0c35814 --- /dev/null +++ b/lib/domain/wallet/repositories/i_order_repository.dart @@ -0,0 +1,12 @@ +part of '../wallet.dart'; + +/// Riwayat order customer. App hanya melihat order; tidak membuat atau +/// membayarnya (§7). +abstract class IOrderRepository { + Future> getOrders({ + required int page, + int limit = 20, + }); + + Future> getOrderDetail(String id); +} diff --git a/lib/domain/wallet/repositories/i_outlet_repository.dart b/lib/domain/wallet/repositories/i_outlet_repository.dart new file mode 100644 index 0000000..9e23f8f --- /dev/null +++ b/lib/domain/wallet/repositories/i_outlet_repository.dart @@ -0,0 +1,6 @@ +part of '../wallet.dart'; + +abstract class IOutletRepository { + /// Outlet aktif di organisasi customer, urut nama. + Future>> getOutlets(); +} diff --git a/lib/domain/wallet/repositories/i_pin_repository.dart b/lib/domain/wallet/repositories/i_pin_repository.dart new file mode 100644 index 0000000..ad0534c --- /dev/null +++ b/lib/domain/wallet/repositories/i_pin_repository.dart @@ -0,0 +1,30 @@ +part of '../wallet.dart'; + +abstract class IPinRepository { + Future> getStatus(); + + /// Mengirim OTP ke WhatsApp customer. + Future> requestOtp(PinOtpPurpose purpose); + + Future> setup({ + required String otpToken, + required String otpCode, + required String pin, + required String confirmPin, + }); + + Future> change({ + required String oldPin, + required String pin, + required String confirmPin, + }); + + /// Reset juga membuka PIN yang terkunci; setelahnya transfer keluar ditahan + /// 24 jam. + Future> reset({ + required String otpToken, + required String otpCode, + required String pin, + required String confirmPin, + }); +} diff --git a/lib/domain/wallet/repositories/i_wallet_repository.dart b/lib/domain/wallet/repositories/i_wallet_repository.dart new file mode 100644 index 0000000..eae6db9 --- /dev/null +++ b/lib/domain/wallet/repositories/i_wallet_repository.dart @@ -0,0 +1,42 @@ +part of '../wallet.dart'; + +abstract class IWalletRepository { + Future> getWallet(); + + Future> getTransactions({ + required int page, + int limit = 20, + WalletCurrency? currency, + List types = const [], + DateTime? from, + DateTime? to, + }); + + Future> getExpiring(); + + Future> createPaymentCode({ + required String pin, + }); + + Future> previewExchange({ + required int coins, + }); + + Future> exchange({ + required int coins, + required String pin, + required String idempotencyKey, + }); + + Future> checkRecipient({ + required String phone, + }); + + Future> transfer({ + required WalletCurrency currency, + required int amount, + required String recipientPhone, + required String pin, + required String idempotencyKey, + }); +} diff --git a/lib/domain/wallet/wallet.dart b/lib/domain/wallet/wallet.dart new file mode 100644 index 0000000..f057f43 --- /dev/null +++ b/lib/domain/wallet/wallet.dart @@ -0,0 +1,23 @@ +import 'package:dartz/dartz.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../common/api/api_failure.dart'; + +part 'wallet.freezed.dart'; + +part 'entities/wallet_enum.dart'; +part 'entities/wallet_summary_entity.dart'; +part 'entities/wallet_transaction_entity.dart'; +part 'entities/wallet_expiring_entity.dart'; +part 'entities/payment_code_entity.dart'; +part 'entities/exchange_entity.dart'; +part 'entities/transfer_entity.dart'; +part 'entities/pin_entity.dart'; +part 'entities/outlet_entity.dart'; +part 'entities/customer_order_entity.dart'; +part 'failures/wallet_failure.dart'; +part 'repositories/i_wallet_repository.dart'; +part 'repositories/i_pin_repository.dart'; +part 'repositories/i_device_repository.dart'; +part 'repositories/i_outlet_repository.dart'; +part 'repositories/i_order_repository.dart'; diff --git a/lib/domain/wallet/wallet.freezed.dart b/lib/domain/wallet/wallet.freezed.dart new file mode 100644 index 0000000..dff592b --- /dev/null +++ b/lib/domain/wallet/wallet.freezed.dart @@ -0,0 +1,6254 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'wallet.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; +/// @nodoc +mixin _$WalletSummary { + + int get pointBalance; int get coinBalance; int get pointValue; int get pointDiscountValue; ExpiringAmount? get nearestExpiringPoint; ExpiringAmount? get nearestExpiringCoin; List get recentTransactions; +/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletSummaryCopyWith get copyWith => _$WalletSummaryCopyWithImpl(this as WalletSummary, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletSummary; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletSummary&&(identical(other.pointBalance, _this.pointBalance) || other.pointBalance == _this.pointBalance)&&(identical(other.coinBalance, _this.coinBalance) || other.coinBalance == _this.coinBalance)&&(identical(other.pointValue, _this.pointValue) || other.pointValue == _this.pointValue)&&(identical(other.pointDiscountValue, _this.pointDiscountValue) || other.pointDiscountValue == _this.pointDiscountValue)&&(identical(other.nearestExpiringPoint, _this.nearestExpiringPoint) || other.nearestExpiringPoint == _this.nearestExpiringPoint)&&(identical(other.nearestExpiringCoin, _this.nearestExpiringCoin) || other.nearestExpiringCoin == _this.nearestExpiringCoin)&&const DeepCollectionEquality().equals(other.recentTransactions, _this.recentTransactions)); +} + + +@override +int get hashCode { + final _this = this as WalletSummary; + return Object.hash(runtimeType,_this.pointBalance,_this.coinBalance,_this.pointValue,_this.pointDiscountValue,_this.nearestExpiringPoint,_this.nearestExpiringCoin,const DeepCollectionEquality().hash(_this.recentTransactions)); +} + +@override +String toString() { + final _this = this as WalletSummary; + return 'WalletSummary(pointBalance: ${_this.pointBalance}, coinBalance: ${_this.coinBalance}, pointValue: ${_this.pointValue}, pointDiscountValue: ${_this.pointDiscountValue}, nearestExpiringPoint: ${_this.nearestExpiringPoint}, nearestExpiringCoin: ${_this.nearestExpiringCoin}, recentTransactions: ${_this.recentTransactions})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletSummaryCopyWith<$Res> { + factory $WalletSummaryCopyWith(WalletSummary value, $Res Function(WalletSummary) _then) = _$WalletSummaryCopyWithImpl; +@useResult +$Res call({ + int pointBalance, int coinBalance, int pointValue, int pointDiscountValue, ExpiringAmount? nearestExpiringPoint, ExpiringAmount? nearestExpiringCoin, List recentTransactions +}); + + +$ExpiringAmountCopyWith<$Res>? get nearestExpiringPoint;$ExpiringAmountCopyWith<$Res>? get nearestExpiringCoin; + +} +/// @nodoc +class _$WalletSummaryCopyWithImpl<$Res> + implements $WalletSummaryCopyWith<$Res> { + _$WalletSummaryCopyWithImpl(this._self, this._then); + + final WalletSummary _self; + final $Res Function(WalletSummary) _then; + +/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? pointBalance = null,Object? coinBalance = null,Object? pointValue = null,Object? pointDiscountValue = null,Object? nearestExpiringPoint = freezed,Object? nearestExpiringCoin = freezed,Object? recentTransactions = null,}) { + return _then(WalletSummary( +pointBalance: null == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int,coinBalance: null == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int,pointValue: null == pointValue ? _self.pointValue : pointValue // ignore: cast_nullable_to_non_nullable +as int,pointDiscountValue: null == pointDiscountValue ? _self.pointDiscountValue : pointDiscountValue // ignore: cast_nullable_to_non_nullable +as int,nearestExpiringPoint: freezed == nearestExpiringPoint ? _self.nearestExpiringPoint : nearestExpiringPoint // ignore: cast_nullable_to_non_nullable +as ExpiringAmount?,nearestExpiringCoin: freezed == nearestExpiringCoin ? _self.nearestExpiringCoin : nearestExpiringCoin // ignore: cast_nullable_to_non_nullable +as ExpiringAmount?,recentTransactions: null == recentTransactions ? _self.recentTransactions : recentTransactions // ignore: cast_nullable_to_non_nullable +as List, + )); +} +/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountCopyWith<$Res>? get nearestExpiringPoint { + if (_self.nearestExpiringPoint == null) { + return null; + } + + return $ExpiringAmountCopyWith<$Res>(_self.nearestExpiringPoint!, (value) { + return _then(_self.copyWith(nearestExpiringPoint: value)); + }); +}/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountCopyWith<$Res>? get nearestExpiringCoin { + if (_self.nearestExpiringCoin == null) { + return null; + } + + return $ExpiringAmountCopyWith<$Res>(_self.nearestExpiringCoin!, (value) { + return _then(_self.copyWith(nearestExpiringCoin: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [WalletSummary]. +extension WalletSummaryPatterns on WalletSummary { +/// 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( _WalletSummary value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletSummary() 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( _WalletSummary value) $default,){ +final _that = this; +switch (_that) { +case _WalletSummary(): +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( _WalletSummary value)? $default,){ +final _that = this; +switch (_that) { +case _WalletSummary() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( int pointBalance, int coinBalance, int pointValue, int pointDiscountValue, ExpiringAmount? nearestExpiringPoint, ExpiringAmount? nearestExpiringCoin, List recentTransactions)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletSummary() when $default != null: +return $default(_that.pointBalance,_that.coinBalance,_that.pointValue,_that.pointDiscountValue,_that.nearestExpiringPoint,_that.nearestExpiringCoin,_that.recentTransactions);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( int pointBalance, int coinBalance, int pointValue, int pointDiscountValue, ExpiringAmount? nearestExpiringPoint, ExpiringAmount? nearestExpiringCoin, List recentTransactions) $default,) {final _that = this; +switch (_that) { +case _WalletSummary(): +return $default(_that.pointBalance,_that.coinBalance,_that.pointValue,_that.pointDiscountValue,_that.nearestExpiringPoint,_that.nearestExpiringCoin,_that.recentTransactions);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int pointBalance, int coinBalance, int pointValue, int pointDiscountValue, ExpiringAmount? nearestExpiringPoint, ExpiringAmount? nearestExpiringCoin, List recentTransactions)? $default,) {final _that = this; +switch (_that) { +case _WalletSummary() when $default != null: +return $default(_that.pointBalance,_that.coinBalance,_that.pointValue,_that.pointDiscountValue,_that.nearestExpiringPoint,_that.nearestExpiringCoin,_that.recentTransactions);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletSummary implements WalletSummary { + const _WalletSummary({required this.pointBalance, required this.coinBalance, required this.pointValue, required this.pointDiscountValue, this.nearestExpiringPoint, this.nearestExpiringCoin, required List recentTransactions}): _recentTransactions = recentTransactions; + + +@override final int pointBalance; +@override final int coinBalance; +@override final int pointValue; +@override final int pointDiscountValue; +@override final ExpiringAmount? nearestExpiringPoint; +@override final ExpiringAmount? nearestExpiringCoin; + final List _recentTransactions; +@override List get recentTransactions { + if (_recentTransactions is EqualUnmodifiableListView) return _recentTransactions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_recentTransactions); +} + + +/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletSummaryCopyWith<_WalletSummary> get copyWith => __$WalletSummaryCopyWithImpl<_WalletSummary>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletSummary&&(identical(other.pointBalance, pointBalance) || other.pointBalance == pointBalance)&&(identical(other.coinBalance, coinBalance) || other.coinBalance == coinBalance)&&(identical(other.pointValue, pointValue) || other.pointValue == pointValue)&&(identical(other.pointDiscountValue, pointDiscountValue) || other.pointDiscountValue == pointDiscountValue)&&(identical(other.nearestExpiringPoint, nearestExpiringPoint) || other.nearestExpiringPoint == nearestExpiringPoint)&&(identical(other.nearestExpiringCoin, nearestExpiringCoin) || other.nearestExpiringCoin == nearestExpiringCoin)&&const DeepCollectionEquality().equals(other.recentTransactions, _recentTransactions)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,pointBalance,coinBalance,pointValue,pointDiscountValue,nearestExpiringPoint,nearestExpiringCoin,const DeepCollectionEquality().hash(_recentTransactions)); +} + +@override +String toString() { + return 'WalletSummary(pointBalance: $pointBalance, coinBalance: $coinBalance, pointValue: $pointValue, pointDiscountValue: $pointDiscountValue, nearestExpiringPoint: $nearestExpiringPoint, nearestExpiringCoin: $nearestExpiringCoin, recentTransactions: $recentTransactions)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletSummaryCopyWith<$Res> implements $WalletSummaryCopyWith<$Res> { + factory _$WalletSummaryCopyWith(_WalletSummary value, $Res Function(_WalletSummary) _then) = __$WalletSummaryCopyWithImpl; +@override @useResult +$Res call({ + int pointBalance, int coinBalance, int pointValue, int pointDiscountValue, ExpiringAmount? nearestExpiringPoint, ExpiringAmount? nearestExpiringCoin, List recentTransactions +}); + + +@override $ExpiringAmountCopyWith<$Res>? get nearestExpiringPoint;@override $ExpiringAmountCopyWith<$Res>? get nearestExpiringCoin; + +} +/// @nodoc +class __$WalletSummaryCopyWithImpl<$Res> + implements _$WalletSummaryCopyWith<$Res> { + __$WalletSummaryCopyWithImpl(this._self, this._then); + + final _WalletSummary _self; + final $Res Function(_WalletSummary) _then; + +/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? pointBalance = null,Object? coinBalance = null,Object? pointValue = null,Object? pointDiscountValue = null,Object? nearestExpiringPoint = freezed,Object? nearestExpiringCoin = freezed,Object? recentTransactions = null,}) { + return _then(_WalletSummary( +pointBalance: null == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int,coinBalance: null == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int,pointValue: null == pointValue ? _self.pointValue : pointValue // ignore: cast_nullable_to_non_nullable +as int,pointDiscountValue: null == pointDiscountValue ? _self.pointDiscountValue : pointDiscountValue // ignore: cast_nullable_to_non_nullable +as int,nearestExpiringPoint: freezed == nearestExpiringPoint ? _self.nearestExpiringPoint : nearestExpiringPoint // ignore: cast_nullable_to_non_nullable +as ExpiringAmount?,nearestExpiringCoin: freezed == nearestExpiringCoin ? _self.nearestExpiringCoin : nearestExpiringCoin // ignore: cast_nullable_to_non_nullable +as ExpiringAmount?,recentTransactions: null == recentTransactions ? _self._recentTransactions : recentTransactions // ignore: cast_nullable_to_non_nullable +as List, + )); +} + +/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountCopyWith<$Res>? get nearestExpiringPoint { + if (_self.nearestExpiringPoint == null) { + return null; + } + + return $ExpiringAmountCopyWith<$Res>(_self.nearestExpiringPoint!, (value) { + return _then(_self.copyWith(nearestExpiringPoint: value)); + }); +}/// Create a copy of WalletSummary +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountCopyWith<$Res>? get nearestExpiringCoin { + if (_self.nearestExpiringCoin == null) { + return null; + } + + return $ExpiringAmountCopyWith<$Res>(_self.nearestExpiringCoin!, (value) { + return _then(_self.copyWith(nearestExpiringCoin: value)); + }); +} +} + +/// @nodoc +mixin _$ExpiringAmount { + + int get amount; DateTime get date; +/// Create a copy of ExpiringAmount +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExpiringAmountCopyWith get copyWith => _$ExpiringAmountCopyWithImpl(this as ExpiringAmount, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as ExpiringAmount; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExpiringAmount&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.date, _this.date) || other.date == _this.date)); +} + + +@override +int get hashCode { + final _this = this as ExpiringAmount; + return Object.hash(runtimeType,_this.amount,_this.date); +} + +@override +String toString() { + final _this = this as ExpiringAmount; + return 'ExpiringAmount(amount: ${_this.amount}, date: ${_this.date})'; +} + + +} + +/// @nodoc +abstract mixin class $ExpiringAmountCopyWith<$Res> { + factory $ExpiringAmountCopyWith(ExpiringAmount value, $Res Function(ExpiringAmount) _then) = _$ExpiringAmountCopyWithImpl; +@useResult +$Res call({ + int amount, DateTime date +}); + + + + +} +/// @nodoc +class _$ExpiringAmountCopyWithImpl<$Res> + implements $ExpiringAmountCopyWith<$Res> { + _$ExpiringAmountCopyWithImpl(this._self, this._then); + + final ExpiringAmount _self; + final $Res Function(ExpiringAmount) _then; + +/// Create a copy of ExpiringAmount +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? amount = null,Object? date = null,}) { + return _then(ExpiringAmount( +amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,date: null == date ? _self.date : date // ignore: cast_nullable_to_non_nullable +as DateTime, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ExpiringAmount]. +extension ExpiringAmountPatterns on ExpiringAmount { +/// 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( _ExpiringAmount value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExpiringAmount() 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( _ExpiringAmount value) $default,){ +final _that = this; +switch (_that) { +case _ExpiringAmount(): +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( _ExpiringAmount value)? $default,){ +final _that = this; +switch (_that) { +case _ExpiringAmount() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( int amount, DateTime date)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExpiringAmount() when $default != null: +return $default(_that.amount,_that.date);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( int amount, DateTime date) $default,) {final _that = this; +switch (_that) { +case _ExpiringAmount(): +return $default(_that.amount,_that.date);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int amount, DateTime date)? $default,) {final _that = this; +switch (_that) { +case _ExpiringAmount() when $default != null: +return $default(_that.amount,_that.date);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _ExpiringAmount implements ExpiringAmount { + const _ExpiringAmount({required this.amount, required this.date}); + + +@override final int amount; +@override final DateTime date; + +/// Create a copy of ExpiringAmount +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExpiringAmountCopyWith<_ExpiringAmount> get copyWith => __$ExpiringAmountCopyWithImpl<_ExpiringAmount>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExpiringAmount&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.date, date) || other.date == date)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,amount,date); +} + +@override +String toString() { + return 'ExpiringAmount(amount: $amount, date: $date)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExpiringAmountCopyWith<$Res> implements $ExpiringAmountCopyWith<$Res> { + factory _$ExpiringAmountCopyWith(_ExpiringAmount value, $Res Function(_ExpiringAmount) _then) = __$ExpiringAmountCopyWithImpl; +@override @useResult +$Res call({ + int amount, DateTime date +}); + + + + +} +/// @nodoc +class __$ExpiringAmountCopyWithImpl<$Res> + implements _$ExpiringAmountCopyWith<$Res> { + __$ExpiringAmountCopyWithImpl(this._self, this._then); + + final _ExpiringAmount _self; + final $Res Function(_ExpiringAmount) _then; + +/// Create a copy of ExpiringAmount +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? amount = null,Object? date = null,}) { + return _then(_ExpiringAmount( +amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,date: null == date ? _self.date : date // ignore: cast_nullable_to_non_nullable +as DateTime, + )); +} + + +} + +/// @nodoc +mixin _$WalletTransaction { + + String get id; WalletCurrency get currency; WalletTransactionType get type; int get amount; int get balanceAfter; String get description; String? get groupId; DateTime? get expiresAt; DateTime? get createdAt; +/// Create a copy of WalletTransaction +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletTransactionCopyWith get copyWith => _$WalletTransactionCopyWithImpl(this as WalletTransaction, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletTransaction; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransaction&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.currency, _this.currency) || other.currency == _this.currency)&&(identical(other.type, _this.type) || other.type == _this.type)&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.balanceAfter, _this.balanceAfter) || other.balanceAfter == _this.balanceAfter)&&(identical(other.description, _this.description) || other.description == _this.description)&&(identical(other.groupId, _this.groupId) || other.groupId == _this.groupId)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)); +} + + +@override +int get hashCode { + final _this = this as WalletTransaction; + return Object.hash(runtimeType,_this.id,_this.currency,_this.type,_this.amount,_this.balanceAfter,_this.description,_this.groupId,_this.expiresAt,_this.createdAt); +} + +@override +String toString() { + final _this = this as WalletTransaction; + return 'WalletTransaction(id: ${_this.id}, currency: ${_this.currency}, type: ${_this.type}, amount: ${_this.amount}, balanceAfter: ${_this.balanceAfter}, description: ${_this.description}, groupId: ${_this.groupId}, expiresAt: ${_this.expiresAt}, createdAt: ${_this.createdAt})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletTransactionCopyWith<$Res> { + factory $WalletTransactionCopyWith(WalletTransaction value, $Res Function(WalletTransaction) _then) = _$WalletTransactionCopyWithImpl; +@useResult +$Res call({ + String id, WalletCurrency currency, WalletTransactionType type, int amount, int balanceAfter, String description, String? groupId, DateTime? expiresAt, DateTime? createdAt +}); + + + + +} +/// @nodoc +class _$WalletTransactionCopyWithImpl<$Res> + implements $WalletTransactionCopyWith<$Res> { + _$WalletTransactionCopyWithImpl(this._self, this._then); + + final WalletTransaction _self; + final $Res Function(WalletTransaction) _then; + +/// Create a copy of WalletTransaction +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? currency = null,Object? type = null,Object? amount = null,Object? balanceAfter = null,Object? description = null,Object? groupId = freezed,Object? expiresAt = freezed,Object? createdAt = freezed,}) { + return _then(WalletTransaction( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as WalletTransactionType,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,balanceAfter: null == balanceAfter ? _self.balanceAfter : balanceAfter // ignore: cast_nullable_to_non_nullable +as int,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,groupId: freezed == groupId ? _self.groupId : groupId // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletTransaction]. +extension WalletTransactionPatterns on WalletTransaction { +/// 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( _WalletTransaction value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletTransaction() 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( _WalletTransaction value) $default,){ +final _that = this; +switch (_that) { +case _WalletTransaction(): +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( _WalletTransaction value)? $default,){ +final _that = this; +switch (_that) { +case _WalletTransaction() 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, WalletCurrency currency, WalletTransactionType type, int amount, int balanceAfter, String description, String? groupId, DateTime? expiresAt, DateTime? createdAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletTransaction() when $default != null: +return $default(_that.id,_that.currency,_that.type,_that.amount,_that.balanceAfter,_that.description,_that.groupId,_that.expiresAt,_that.createdAt);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, WalletCurrency currency, WalletTransactionType type, int amount, int balanceAfter, String description, String? groupId, DateTime? expiresAt, DateTime? createdAt) $default,) {final _that = this; +switch (_that) { +case _WalletTransaction(): +return $default(_that.id,_that.currency,_that.type,_that.amount,_that.balanceAfter,_that.description,_that.groupId,_that.expiresAt,_that.createdAt);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, WalletCurrency currency, WalletTransactionType type, int amount, int balanceAfter, String description, String? groupId, DateTime? expiresAt, DateTime? createdAt)? $default,) {final _that = this; +switch (_that) { +case _WalletTransaction() when $default != null: +return $default(_that.id,_that.currency,_that.type,_that.amount,_that.balanceAfter,_that.description,_that.groupId,_that.expiresAt,_that.createdAt);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletTransaction extends WalletTransaction { + const _WalletTransaction({required this.id, required this.currency, required this.type, required this.amount, required this.balanceAfter, required this.description, this.groupId, this.expiresAt, this.createdAt}): super._(); + + +@override final String id; +@override final WalletCurrency currency; +@override final WalletTransactionType type; +@override final int amount; +@override final int balanceAfter; +@override final String description; +@override final String? groupId; +@override final DateTime? expiresAt; +@override final DateTime? createdAt; + +/// Create a copy of WalletTransaction +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletTransactionCopyWith<_WalletTransaction> get copyWith => __$WalletTransactionCopyWithImpl<_WalletTransaction>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransaction&&(identical(other.id, id) || other.id == id)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.type, type) || other.type == type)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.balanceAfter, balanceAfter) || other.balanceAfter == balanceAfter)&&(identical(other.description, description) || other.description == description)&&(identical(other.groupId, groupId) || other.groupId == groupId)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,currency,type,amount,balanceAfter,description,groupId,expiresAt,createdAt); +} + +@override +String toString() { + return 'WalletTransaction(id: $id, currency: $currency, type: $type, amount: $amount, balanceAfter: $balanceAfter, description: $description, groupId: $groupId, expiresAt: $expiresAt, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletTransactionCopyWith<$Res> implements $WalletTransactionCopyWith<$Res> { + factory _$WalletTransactionCopyWith(_WalletTransaction value, $Res Function(_WalletTransaction) _then) = __$WalletTransactionCopyWithImpl; +@override @useResult +$Res call({ + String id, WalletCurrency currency, WalletTransactionType type, int amount, int balanceAfter, String description, String? groupId, DateTime? expiresAt, DateTime? createdAt +}); + + + + +} +/// @nodoc +class __$WalletTransactionCopyWithImpl<$Res> + implements _$WalletTransactionCopyWith<$Res> { + __$WalletTransactionCopyWithImpl(this._self, this._then); + + final _WalletTransaction _self; + final $Res Function(_WalletTransaction) _then; + +/// Create a copy of WalletTransaction +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? currency = null,Object? type = null,Object? amount = null,Object? balanceAfter = null,Object? description = null,Object? groupId = freezed,Object? expiresAt = freezed,Object? createdAt = freezed,}) { + return _then(_WalletTransaction( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,type: null == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as WalletTransactionType,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,balanceAfter: null == balanceAfter ? _self.balanceAfter : balanceAfter // ignore: cast_nullable_to_non_nullable +as int,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String,groupId: freezed == groupId ? _self.groupId : groupId // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +/// @nodoc +mixin _$WalletTransactionPage { + + List get items; int get page; int get totalPages; int get totalCount; +/// Create a copy of WalletTransactionPage +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletTransactionPageCopyWith get copyWith => _$WalletTransactionPageCopyWithImpl(this as WalletTransactionPage, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletTransactionPage; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionPage&&const DeepCollectionEquality().equals(other.items, _this.items)&&(identical(other.page, _this.page) || other.page == _this.page)&&(identical(other.totalPages, _this.totalPages) || other.totalPages == _this.totalPages)&&(identical(other.totalCount, _this.totalCount) || other.totalCount == _this.totalCount)); +} + + +@override +int get hashCode { + final _this = this as WalletTransactionPage; + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_this.items),_this.page,_this.totalPages,_this.totalCount); +} + +@override +String toString() { + final _this = this as WalletTransactionPage; + return 'WalletTransactionPage(items: ${_this.items}, page: ${_this.page}, totalPages: ${_this.totalPages}, totalCount: ${_this.totalCount})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletTransactionPageCopyWith<$Res> { + factory $WalletTransactionPageCopyWith(WalletTransactionPage value, $Res Function(WalletTransactionPage) _then) = _$WalletTransactionPageCopyWithImpl; +@useResult +$Res call({ + List items, int page, int totalPages, int totalCount +}); + + + + +} +/// @nodoc +class _$WalletTransactionPageCopyWithImpl<$Res> + implements $WalletTransactionPageCopyWith<$Res> { + _$WalletTransactionPageCopyWithImpl(this._self, this._then); + + final WalletTransactionPage _self; + final $Res Function(WalletTransactionPage) _then; + +/// Create a copy of WalletTransactionPage +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? page = null,Object? totalPages = null,Object? totalCount = null,}) { + return _then(WalletTransactionPage( +items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int,totalCount: null == totalCount ? _self.totalCount : totalCount // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletTransactionPage]. +extension WalletTransactionPagePatterns on WalletTransactionPage { +/// 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( _WalletTransactionPage value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletTransactionPage() 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( _WalletTransactionPage value) $default,){ +final _that = this; +switch (_that) { +case _WalletTransactionPage(): +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( _WalletTransactionPage value)? $default,){ +final _that = this; +switch (_that) { +case _WalletTransactionPage() 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, int page, int totalPages, int totalCount)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletTransactionPage() when $default != null: +return $default(_that.items,_that.page,_that.totalPages,_that.totalCount);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, int page, int totalPages, int totalCount) $default,) {final _that = this; +switch (_that) { +case _WalletTransactionPage(): +return $default(_that.items,_that.page,_that.totalPages,_that.totalCount);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, int page, int totalPages, int totalCount)? $default,) {final _that = this; +switch (_that) { +case _WalletTransactionPage() when $default != null: +return $default(_that.items,_that.page,_that.totalPages,_that.totalCount);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletTransactionPage implements WalletTransactionPage { + const _WalletTransactionPage({required List items, required this.page, required this.totalPages, required this.totalCount}): _items = items; + + + final List _items; +@override List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); +} + +@override final int page; +@override final int totalPages; +@override final int totalCount; + +/// Create a copy of WalletTransactionPage +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletTransactionPageCopyWith<_WalletTransactionPage> get copyWith => __$WalletTransactionPageCopyWithImpl<_WalletTransactionPage>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionPage&&const DeepCollectionEquality().equals(other.items, _items)&&(identical(other.page, page) || other.page == page)&&(identical(other.totalPages, totalPages) || other.totalPages == totalPages)&&(identical(other.totalCount, totalCount) || other.totalCount == totalCount)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),page,totalPages,totalCount); +} + +@override +String toString() { + return 'WalletTransactionPage(items: $items, page: $page, totalPages: $totalPages, totalCount: $totalCount)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletTransactionPageCopyWith<$Res> implements $WalletTransactionPageCopyWith<$Res> { + factory _$WalletTransactionPageCopyWith(_WalletTransactionPage value, $Res Function(_WalletTransactionPage) _then) = __$WalletTransactionPageCopyWithImpl; +@override @useResult +$Res call({ + List items, int page, int totalPages, int totalCount +}); + + + + +} +/// @nodoc +class __$WalletTransactionPageCopyWithImpl<$Res> + implements _$WalletTransactionPageCopyWith<$Res> { + __$WalletTransactionPageCopyWithImpl(this._self, this._then); + + final _WalletTransactionPage _self; + final $Res Function(_WalletTransactionPage) _then; + +/// Create a copy of WalletTransactionPage +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? page = null,Object? totalPages = null,Object? totalCount = null,}) { + return _then(_WalletTransactionPage( +items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int,totalCount: null == totalCount ? _self.totalCount : totalCount // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc +mixin _$WalletExpiring { + + List get point; List get coin; +/// Create a copy of WalletExpiring +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletExpiringCopyWith get copyWith => _$WalletExpiringCopyWithImpl(this as WalletExpiring, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletExpiring; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletExpiring&&const DeepCollectionEquality().equals(other.point, _this.point)&&const DeepCollectionEquality().equals(other.coin, _this.coin)); +} + + +@override +int get hashCode { + final _this = this as WalletExpiring; + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_this.point),const DeepCollectionEquality().hash(_this.coin)); +} + +@override +String toString() { + final _this = this as WalletExpiring; + return 'WalletExpiring(point: ${_this.point}, coin: ${_this.coin})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletExpiringCopyWith<$Res> { + factory $WalletExpiringCopyWith(WalletExpiring value, $Res Function(WalletExpiring) _then) = _$WalletExpiringCopyWithImpl; +@useResult +$Res call({ + List point, List coin +}); + + + + +} +/// @nodoc +class _$WalletExpiringCopyWithImpl<$Res> + implements $WalletExpiringCopyWith<$Res> { + _$WalletExpiringCopyWithImpl(this._self, this._then); + + final WalletExpiring _self; + final $Res Function(WalletExpiring) _then; + +/// Create a copy of WalletExpiring +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? point = null,Object? coin = null,}) { + return _then(WalletExpiring( +point: null == point ? _self.point : point // ignore: cast_nullable_to_non_nullable +as List,coin: null == coin ? _self.coin : coin // ignore: cast_nullable_to_non_nullable +as List, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletExpiring]. +extension WalletExpiringPatterns on WalletExpiring { +/// 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( _WalletExpiring value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletExpiring() 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( _WalletExpiring value) $default,){ +final _that = this; +switch (_that) { +case _WalletExpiring(): +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( _WalletExpiring value)? $default,){ +final _that = this; +switch (_that) { +case _WalletExpiring() 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 point, List coin)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletExpiring() when $default != null: +return $default(_that.point,_that.coin);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 point, List coin) $default,) {final _that = this; +switch (_that) { +case _WalletExpiring(): +return $default(_that.point,_that.coin);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 point, List coin)? $default,) {final _that = this; +switch (_that) { +case _WalletExpiring() when $default != null: +return $default(_that.point,_that.coin);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletExpiring implements WalletExpiring { + const _WalletExpiring({required List point, required List coin}): _point = point,_coin = coin; + + + final List _point; +@override List get point { + if (_point is EqualUnmodifiableListView) return _point; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_point); +} + + final List _coin; +@override List get coin { + if (_coin is EqualUnmodifiableListView) return _coin; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_coin); +} + + +/// Create a copy of WalletExpiring +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletExpiringCopyWith<_WalletExpiring> get copyWith => __$WalletExpiringCopyWithImpl<_WalletExpiring>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletExpiring&&const DeepCollectionEquality().equals(other.point, _point)&&const DeepCollectionEquality().equals(other.coin, _coin)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_point),const DeepCollectionEquality().hash(_coin)); +} + +@override +String toString() { + return 'WalletExpiring(point: $point, coin: $coin)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletExpiringCopyWith<$Res> implements $WalletExpiringCopyWith<$Res> { + factory _$WalletExpiringCopyWith(_WalletExpiring value, $Res Function(_WalletExpiring) _then) = __$WalletExpiringCopyWithImpl; +@override @useResult +$Res call({ + List point, List coin +}); + + + + +} +/// @nodoc +class __$WalletExpiringCopyWithImpl<$Res> + implements _$WalletExpiringCopyWith<$Res> { + __$WalletExpiringCopyWithImpl(this._self, this._then); + + final _WalletExpiring _self; + final $Res Function(_WalletExpiring) _then; + +/// Create a copy of WalletExpiring +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? point = null,Object? coin = null,}) { + return _then(_WalletExpiring( +point: null == point ? _self._point : point // ignore: cast_nullable_to_non_nullable +as List,coin: null == coin ? _self._coin : coin // ignore: cast_nullable_to_non_nullable +as List, + )); +} + + +} + +/// @nodoc +mixin _$PaymentCode { + + String get code; String get qrPayload; DateTime get expiresAt; +/// Create a copy of PaymentCode +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PaymentCodeCopyWith get copyWith => _$PaymentCodeCopyWithImpl(this as PaymentCode, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as PaymentCode; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PaymentCode&&(identical(other.code, _this.code) || other.code == _this.code)&&(identical(other.qrPayload, _this.qrPayload) || other.qrPayload == _this.qrPayload)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)); +} + + +@override +int get hashCode { + final _this = this as PaymentCode; + return Object.hash(runtimeType,_this.code,_this.qrPayload,_this.expiresAt); +} + +@override +String toString() { + final _this = this as PaymentCode; + return 'PaymentCode(code: ${_this.code}, qrPayload: ${_this.qrPayload}, expiresAt: ${_this.expiresAt})'; +} + + +} + +/// @nodoc +abstract mixin class $PaymentCodeCopyWith<$Res> { + factory $PaymentCodeCopyWith(PaymentCode value, $Res Function(PaymentCode) _then) = _$PaymentCodeCopyWithImpl; +@useResult +$Res call({ + String code, String qrPayload, DateTime expiresAt +}); + + + + +} +/// @nodoc +class _$PaymentCodeCopyWithImpl<$Res> + implements $PaymentCodeCopyWith<$Res> { + _$PaymentCodeCopyWithImpl(this._self, this._then); + + final PaymentCode _self; + final $Res Function(PaymentCode) _then; + +/// Create a copy of PaymentCode +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? code = null,Object? qrPayload = null,Object? expiresAt = null,}) { + return _then(PaymentCode( +code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable +as String,qrPayload: null == qrPayload ? _self.qrPayload : qrPayload // ignore: cast_nullable_to_non_nullable +as String,expiresAt: null == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PaymentCode]. +extension PaymentCodePatterns on PaymentCode { +/// 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( _PaymentCode value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PaymentCode() 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( _PaymentCode value) $default,){ +final _that = this; +switch (_that) { +case _PaymentCode(): +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( _PaymentCode value)? $default,){ +final _that = this; +switch (_that) { +case _PaymentCode() 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 code, String qrPayload, DateTime expiresAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PaymentCode() when $default != null: +return $default(_that.code,_that.qrPayload,_that.expiresAt);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 code, String qrPayload, DateTime expiresAt) $default,) {final _that = this; +switch (_that) { +case _PaymentCode(): +return $default(_that.code,_that.qrPayload,_that.expiresAt);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 code, String qrPayload, DateTime expiresAt)? $default,) {final _that = this; +switch (_that) { +case _PaymentCode() when $default != null: +return $default(_that.code,_that.qrPayload,_that.expiresAt);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _PaymentCode implements PaymentCode { + const _PaymentCode({required this.code, required this.qrPayload, required this.expiresAt}); + + +@override final String code; +@override final String qrPayload; +@override final DateTime expiresAt; + +/// Create a copy of PaymentCode +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PaymentCodeCopyWith<_PaymentCode> get copyWith => __$PaymentCodeCopyWithImpl<_PaymentCode>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentCode&&(identical(other.code, code) || other.code == code)&&(identical(other.qrPayload, qrPayload) || other.qrPayload == qrPayload)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,code,qrPayload,expiresAt); +} + +@override +String toString() { + return 'PaymentCode(code: $code, qrPayload: $qrPayload, expiresAt: $expiresAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$PaymentCodeCopyWith<$Res> implements $PaymentCodeCopyWith<$Res> { + factory _$PaymentCodeCopyWith(_PaymentCode value, $Res Function(_PaymentCode) _then) = __$PaymentCodeCopyWithImpl; +@override @useResult +$Res call({ + String code, String qrPayload, DateTime expiresAt +}); + + + + +} +/// @nodoc +class __$PaymentCodeCopyWithImpl<$Res> + implements _$PaymentCodeCopyWith<$Res> { + __$PaymentCodeCopyWithImpl(this._self, this._then); + + final _PaymentCode _self; + final $Res Function(_PaymentCode) _then; + +/// Create a copy of PaymentCode +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? code = null,Object? qrPayload = null,Object? expiresAt = null,}) { + return _then(_PaymentCode( +code: null == code ? _self.code : code // ignore: cast_nullable_to_non_nullable +as String,qrPayload: null == qrPayload ? _self.qrPayload : qrPayload // ignore: cast_nullable_to_non_nullable +as String,expiresAt: null == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime, + )); +} + + +} + +/// @nodoc +mixin _$ExchangePreview { + + int get coinAmount; int get pointAmount; int get coinBalance; int get coins; int get points; bool get valid; String? get reason; +/// Create a copy of ExchangePreview +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExchangePreviewCopyWith get copyWith => _$ExchangePreviewCopyWithImpl(this as ExchangePreview, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as ExchangePreview; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExchangePreview&&(identical(other.coinAmount, _this.coinAmount) || other.coinAmount == _this.coinAmount)&&(identical(other.pointAmount, _this.pointAmount) || other.pointAmount == _this.pointAmount)&&(identical(other.coinBalance, _this.coinBalance) || other.coinBalance == _this.coinBalance)&&(identical(other.coins, _this.coins) || other.coins == _this.coins)&&(identical(other.points, _this.points) || other.points == _this.points)&&(identical(other.valid, _this.valid) || other.valid == _this.valid)&&(identical(other.reason, _this.reason) || other.reason == _this.reason)); +} + + +@override +int get hashCode { + final _this = this as ExchangePreview; + return Object.hash(runtimeType,_this.coinAmount,_this.pointAmount,_this.coinBalance,_this.coins,_this.points,_this.valid,_this.reason); +} + +@override +String toString() { + final _this = this as ExchangePreview; + return 'ExchangePreview(coinAmount: ${_this.coinAmount}, pointAmount: ${_this.pointAmount}, coinBalance: ${_this.coinBalance}, coins: ${_this.coins}, points: ${_this.points}, valid: ${_this.valid}, reason: ${_this.reason})'; +} + + +} + +/// @nodoc +abstract mixin class $ExchangePreviewCopyWith<$Res> { + factory $ExchangePreviewCopyWith(ExchangePreview value, $Res Function(ExchangePreview) _then) = _$ExchangePreviewCopyWithImpl; +@useResult +$Res call({ + int coinAmount, int pointAmount, int coinBalance, int coins, int points, bool valid, String? reason +}); + + + + +} +/// @nodoc +class _$ExchangePreviewCopyWithImpl<$Res> + implements $ExchangePreviewCopyWith<$Res> { + _$ExchangePreviewCopyWithImpl(this._self, this._then); + + final ExchangePreview _self; + final $Res Function(ExchangePreview) _then; + +/// Create a copy of ExchangePreview +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? coinAmount = null,Object? pointAmount = null,Object? coinBalance = null,Object? coins = null,Object? points = null,Object? valid = null,Object? reason = freezed,}) { + return _then(ExchangePreview( +coinAmount: null == coinAmount ? _self.coinAmount : coinAmount // ignore: cast_nullable_to_non_nullable +as int,pointAmount: null == pointAmount ? _self.pointAmount : pointAmount // ignore: cast_nullable_to_non_nullable +as int,coinBalance: null == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int,coins: null == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int,points: null == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int,valid: null == valid ? _self.valid : valid // ignore: cast_nullable_to_non_nullable +as bool,reason: freezed == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ExchangePreview]. +extension ExchangePreviewPatterns on ExchangePreview { +/// 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( _ExchangePreview value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExchangePreview() 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( _ExchangePreview value) $default,){ +final _that = this; +switch (_that) { +case _ExchangePreview(): +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( _ExchangePreview value)? $default,){ +final _that = this; +switch (_that) { +case _ExchangePreview() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( int coinAmount, int pointAmount, int coinBalance, int coins, int points, bool valid, String? reason)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExchangePreview() when $default != null: +return $default(_that.coinAmount,_that.pointAmount,_that.coinBalance,_that.coins,_that.points,_that.valid,_that.reason);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( int coinAmount, int pointAmount, int coinBalance, int coins, int points, bool valid, String? reason) $default,) {final _that = this; +switch (_that) { +case _ExchangePreview(): +return $default(_that.coinAmount,_that.pointAmount,_that.coinBalance,_that.coins,_that.points,_that.valid,_that.reason);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int coinAmount, int pointAmount, int coinBalance, int coins, int points, bool valid, String? reason)? $default,) {final _that = this; +switch (_that) { +case _ExchangePreview() when $default != null: +return $default(_that.coinAmount,_that.pointAmount,_that.coinBalance,_that.coins,_that.points,_that.valid,_that.reason);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _ExchangePreview implements ExchangePreview { + const _ExchangePreview({required this.coinAmount, required this.pointAmount, required this.coinBalance, required this.coins, required this.points, required this.valid, this.reason}); + + +@override final int coinAmount; +@override final int pointAmount; +@override final int coinBalance; +@override final int coins; +@override final int points; +@override final bool valid; +@override final String? reason; + +/// Create a copy of ExchangePreview +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExchangePreviewCopyWith<_ExchangePreview> get copyWith => __$ExchangePreviewCopyWithImpl<_ExchangePreview>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExchangePreview&&(identical(other.coinAmount, coinAmount) || other.coinAmount == coinAmount)&&(identical(other.pointAmount, pointAmount) || other.pointAmount == pointAmount)&&(identical(other.coinBalance, coinBalance) || other.coinBalance == coinBalance)&&(identical(other.coins, coins) || other.coins == coins)&&(identical(other.points, points) || other.points == points)&&(identical(other.valid, valid) || other.valid == valid)&&(identical(other.reason, reason) || other.reason == reason)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,coinAmount,pointAmount,coinBalance,coins,points,valid,reason); +} + +@override +String toString() { + return 'ExchangePreview(coinAmount: $coinAmount, pointAmount: $pointAmount, coinBalance: $coinBalance, coins: $coins, points: $points, valid: $valid, reason: $reason)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExchangePreviewCopyWith<$Res> implements $ExchangePreviewCopyWith<$Res> { + factory _$ExchangePreviewCopyWith(_ExchangePreview value, $Res Function(_ExchangePreview) _then) = __$ExchangePreviewCopyWithImpl; +@override @useResult +$Res call({ + int coinAmount, int pointAmount, int coinBalance, int coins, int points, bool valid, String? reason +}); + + + + +} +/// @nodoc +class __$ExchangePreviewCopyWithImpl<$Res> + implements _$ExchangePreviewCopyWith<$Res> { + __$ExchangePreviewCopyWithImpl(this._self, this._then); + + final _ExchangePreview _self; + final $Res Function(_ExchangePreview) _then; + +/// Create a copy of ExchangePreview +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? coinAmount = null,Object? pointAmount = null,Object? coinBalance = null,Object? coins = null,Object? points = null,Object? valid = null,Object? reason = freezed,}) { + return _then(_ExchangePreview( +coinAmount: null == coinAmount ? _self.coinAmount : coinAmount // ignore: cast_nullable_to_non_nullable +as int,pointAmount: null == pointAmount ? _self.pointAmount : pointAmount // ignore: cast_nullable_to_non_nullable +as int,coinBalance: null == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int,coins: null == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int,points: null == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int,valid: null == valid ? _self.valid : valid // ignore: cast_nullable_to_non_nullable +as bool,reason: freezed == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +/// @nodoc +mixin _$ExchangeResult { + + int get coins; int get points; int get coinBalance; int get pointBalance; List get lots; bool get replayed; +/// Create a copy of ExchangeResult +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExchangeResultCopyWith get copyWith => _$ExchangeResultCopyWithImpl(this as ExchangeResult, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as ExchangeResult; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExchangeResult&&(identical(other.coins, _this.coins) || other.coins == _this.coins)&&(identical(other.points, _this.points) || other.points == _this.points)&&(identical(other.coinBalance, _this.coinBalance) || other.coinBalance == _this.coinBalance)&&(identical(other.pointBalance, _this.pointBalance) || other.pointBalance == _this.pointBalance)&&const DeepCollectionEquality().equals(other.lots, _this.lots)&&(identical(other.replayed, _this.replayed) || other.replayed == _this.replayed)); +} + + +@override +int get hashCode { + final _this = this as ExchangeResult; + return Object.hash(runtimeType,_this.coins,_this.points,_this.coinBalance,_this.pointBalance,const DeepCollectionEquality().hash(_this.lots),_this.replayed); +} + +@override +String toString() { + final _this = this as ExchangeResult; + return 'ExchangeResult(coins: ${_this.coins}, points: ${_this.points}, coinBalance: ${_this.coinBalance}, pointBalance: ${_this.pointBalance}, lots: ${_this.lots}, replayed: ${_this.replayed})'; +} + + +} + +/// @nodoc +abstract mixin class $ExchangeResultCopyWith<$Res> { + factory $ExchangeResultCopyWith(ExchangeResult value, $Res Function(ExchangeResult) _then) = _$ExchangeResultCopyWithImpl; +@useResult +$Res call({ + int coins, int points, int coinBalance, int pointBalance, List lots, bool replayed +}); + + + + +} +/// @nodoc +class _$ExchangeResultCopyWithImpl<$Res> + implements $ExchangeResultCopyWith<$Res> { + _$ExchangeResultCopyWithImpl(this._self, this._then); + + final ExchangeResult _self; + final $Res Function(ExchangeResult) _then; + +/// Create a copy of ExchangeResult +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? coins = null,Object? points = null,Object? coinBalance = null,Object? pointBalance = null,Object? lots = null,Object? replayed = null,}) { + return _then(ExchangeResult( +coins: null == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int,points: null == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int,coinBalance: null == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int,pointBalance: null == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int,lots: null == lots ? _self.lots : lots // ignore: cast_nullable_to_non_nullable +as List,replayed: null == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ExchangeResult]. +extension ExchangeResultPatterns on ExchangeResult { +/// 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( _ExchangeResult value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExchangeResult() 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( _ExchangeResult value) $default,){ +final _that = this; +switch (_that) { +case _ExchangeResult(): +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( _ExchangeResult value)? $default,){ +final _that = this; +switch (_that) { +case _ExchangeResult() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( int coins, int points, int coinBalance, int pointBalance, List lots, bool replayed)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExchangeResult() when $default != null: +return $default(_that.coins,_that.points,_that.coinBalance,_that.pointBalance,_that.lots,_that.replayed);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( int coins, int points, int coinBalance, int pointBalance, List lots, bool replayed) $default,) {final _that = this; +switch (_that) { +case _ExchangeResult(): +return $default(_that.coins,_that.points,_that.coinBalance,_that.pointBalance,_that.lots,_that.replayed);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int coins, int points, int coinBalance, int pointBalance, List lots, bool replayed)? $default,) {final _that = this; +switch (_that) { +case _ExchangeResult() when $default != null: +return $default(_that.coins,_that.points,_that.coinBalance,_that.pointBalance,_that.lots,_that.replayed);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _ExchangeResult implements ExchangeResult { + const _ExchangeResult({required this.coins, required this.points, required this.coinBalance, required this.pointBalance, required List lots, required this.replayed}): _lots = lots; + + +@override final int coins; +@override final int points; +@override final int coinBalance; +@override final int pointBalance; + final List _lots; +@override List get lots { + if (_lots is EqualUnmodifiableListView) return _lots; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_lots); +} + +@override final bool replayed; + +/// Create a copy of ExchangeResult +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExchangeResultCopyWith<_ExchangeResult> get copyWith => __$ExchangeResultCopyWithImpl<_ExchangeResult>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExchangeResult&&(identical(other.coins, coins) || other.coins == coins)&&(identical(other.points, points) || other.points == points)&&(identical(other.coinBalance, coinBalance) || other.coinBalance == coinBalance)&&(identical(other.pointBalance, pointBalance) || other.pointBalance == pointBalance)&&const DeepCollectionEquality().equals(other.lots, _lots)&&(identical(other.replayed, replayed) || other.replayed == replayed)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,coins,points,coinBalance,pointBalance,const DeepCollectionEquality().hash(_lots),replayed); +} + +@override +String toString() { + return 'ExchangeResult(coins: $coins, points: $points, coinBalance: $coinBalance, pointBalance: $pointBalance, lots: $lots, replayed: $replayed)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExchangeResultCopyWith<$Res> implements $ExchangeResultCopyWith<$Res> { + factory _$ExchangeResultCopyWith(_ExchangeResult value, $Res Function(_ExchangeResult) _then) = __$ExchangeResultCopyWithImpl; +@override @useResult +$Res call({ + int coins, int points, int coinBalance, int pointBalance, List lots, bool replayed +}); + + + + +} +/// @nodoc +class __$ExchangeResultCopyWithImpl<$Res> + implements _$ExchangeResultCopyWith<$Res> { + __$ExchangeResultCopyWithImpl(this._self, this._then); + + final _ExchangeResult _self; + final $Res Function(_ExchangeResult) _then; + +/// Create a copy of ExchangeResult +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? coins = null,Object? points = null,Object? coinBalance = null,Object? pointBalance = null,Object? lots = null,Object? replayed = null,}) { + return _then(_ExchangeResult( +coins: null == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int,points: null == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int,coinBalance: null == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int,pointBalance: null == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int,lots: null == lots ? _self._lots : lots // ignore: cast_nullable_to_non_nullable +as List,replayed: null == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +/// @nodoc +mixin _$WalletLot { + + int get amount; DateTime? get expiresAt; +/// Create a copy of WalletLot +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletLotCopyWith get copyWith => _$WalletLotCopyWithImpl(this as WalletLot, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as WalletLot; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletLot&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)); +} + + +@override +int get hashCode { + final _this = this as WalletLot; + return Object.hash(runtimeType,_this.amount,_this.expiresAt); +} + +@override +String toString() { + final _this = this as WalletLot; + return 'WalletLot(amount: ${_this.amount}, expiresAt: ${_this.expiresAt})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletLotCopyWith<$Res> { + factory $WalletLotCopyWith(WalletLot value, $Res Function(WalletLot) _then) = _$WalletLotCopyWithImpl; +@useResult +$Res call({ + int amount, DateTime? expiresAt +}); + + + + +} +/// @nodoc +class _$WalletLotCopyWithImpl<$Res> + implements $WalletLotCopyWith<$Res> { + _$WalletLotCopyWithImpl(this._self, this._then); + + final WalletLot _self; + final $Res Function(WalletLot) _then; + +/// Create a copy of WalletLot +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? amount = null,Object? expiresAt = freezed,}) { + return _then(WalletLot( +amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletLot]. +extension WalletLotPatterns on WalletLot { +/// 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( _WalletLot value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletLot() 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( _WalletLot value) $default,){ +final _that = this; +switch (_that) { +case _WalletLot(): +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( _WalletLot value)? $default,){ +final _that = this; +switch (_that) { +case _WalletLot() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( int amount, DateTime? expiresAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletLot() when $default != null: +return $default(_that.amount,_that.expiresAt);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( int amount, DateTime? expiresAt) $default,) {final _that = this; +switch (_that) { +case _WalletLot(): +return $default(_that.amount,_that.expiresAt);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( int amount, DateTime? expiresAt)? $default,) {final _that = this; +switch (_that) { +case _WalletLot() when $default != null: +return $default(_that.amount,_that.expiresAt);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _WalletLot implements WalletLot { + const _WalletLot({required this.amount, this.expiresAt}); + + +@override final int amount; +@override final DateTime? expiresAt; + +/// Create a copy of WalletLot +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletLotCopyWith<_WalletLot> get copyWith => __$WalletLotCopyWithImpl<_WalletLot>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletLot&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,amount,expiresAt); +} + +@override +String toString() { + return 'WalletLot(amount: $amount, expiresAt: $expiresAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletLotCopyWith<$Res> implements $WalletLotCopyWith<$Res> { + factory _$WalletLotCopyWith(_WalletLot value, $Res Function(_WalletLot) _then) = __$WalletLotCopyWithImpl; +@override @useResult +$Res call({ + int amount, DateTime? expiresAt +}); + + + + +} +/// @nodoc +class __$WalletLotCopyWithImpl<$Res> + implements _$WalletLotCopyWith<$Res> { + __$WalletLotCopyWithImpl(this._self, this._then); + + final _WalletLot _self; + final $Res Function(_WalletLot) _then; + +/// Create a copy of WalletLot +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? amount = null,Object? expiresAt = freezed,}) { + return _then(_WalletLot( +amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +/// @nodoc +mixin _$TransferRecipient { + + String get name; String get phoneNumber; +/// Create a copy of TransferRecipient +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TransferRecipientCopyWith get copyWith => _$TransferRecipientCopyWithImpl(this as TransferRecipient, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as TransferRecipient; + return identical(this, other) || (other.runtimeType == runtimeType&&other is TransferRecipient&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)); +} + + +@override +int get hashCode { + final _this = this as TransferRecipient; + return Object.hash(runtimeType,_this.name,_this.phoneNumber); +} + +@override +String toString() { + final _this = this as TransferRecipient; + return 'TransferRecipient(name: ${_this.name}, phoneNumber: ${_this.phoneNumber})'; +} + + +} + +/// @nodoc +abstract mixin class $TransferRecipientCopyWith<$Res> { + factory $TransferRecipientCopyWith(TransferRecipient value, $Res Function(TransferRecipient) _then) = _$TransferRecipientCopyWithImpl; +@useResult +$Res call({ + String name, String phoneNumber +}); + + + + +} +/// @nodoc +class _$TransferRecipientCopyWithImpl<$Res> + implements $TransferRecipientCopyWith<$Res> { + _$TransferRecipientCopyWithImpl(this._self, this._then); + + final TransferRecipient _self; + final $Res Function(TransferRecipient) _then; + +/// Create a copy of TransferRecipient +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = null,Object? phoneNumber = null,}) { + return _then(TransferRecipient( +name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [TransferRecipient]. +extension TransferRecipientPatterns on TransferRecipient { +/// 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( _TransferRecipient value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _TransferRecipient() 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( _TransferRecipient value) $default,){ +final _that = this; +switch (_that) { +case _TransferRecipient(): +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( _TransferRecipient value)? $default,){ +final _that = this; +switch (_that) { +case _TransferRecipient() 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 phoneNumber)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _TransferRecipient() when $default != null: +return $default(_that.name,_that.phoneNumber);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 phoneNumber) $default,) {final _that = this; +switch (_that) { +case _TransferRecipient(): +return $default(_that.name,_that.phoneNumber);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 phoneNumber)? $default,) {final _that = this; +switch (_that) { +case _TransferRecipient() when $default != null: +return $default(_that.name,_that.phoneNumber);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _TransferRecipient implements TransferRecipient { + const _TransferRecipient({required this.name, required this.phoneNumber}); + + +@override final String name; +@override final String phoneNumber; + +/// Create a copy of TransferRecipient +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TransferRecipientCopyWith<_TransferRecipient> get copyWith => __$TransferRecipientCopyWithImpl<_TransferRecipient>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TransferRecipient&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,name,phoneNumber); +} + +@override +String toString() { + return 'TransferRecipient(name: $name, phoneNumber: $phoneNumber)'; +} + + +} + +/// @nodoc +abstract mixin class _$TransferRecipientCopyWith<$Res> implements $TransferRecipientCopyWith<$Res> { + factory _$TransferRecipientCopyWith(_TransferRecipient value, $Res Function(_TransferRecipient) _then) = __$TransferRecipientCopyWithImpl; +@override @useResult +$Res call({ + String name, String phoneNumber +}); + + + + +} +/// @nodoc +class __$TransferRecipientCopyWithImpl<$Res> + implements _$TransferRecipientCopyWith<$Res> { + __$TransferRecipientCopyWithImpl(this._self, this._then); + + final _TransferRecipient _self; + final $Res Function(_TransferRecipient) _then; + +/// Create a copy of TransferRecipient +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = null,Object? phoneNumber = null,}) { + return _then(_TransferRecipient( +name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,phoneNumber: null == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc +mixin _$TransferResult { + + WalletCurrency get currency; int get amount; TransferRecipient get recipient; List get lots; int get balance; bool get replayed; +/// Create a copy of TransferResult +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TransferResultCopyWith get copyWith => _$TransferResultCopyWithImpl(this as TransferResult, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as TransferResult; + return identical(this, other) || (other.runtimeType == runtimeType&&other is TransferResult&&(identical(other.currency, _this.currency) || other.currency == _this.currency)&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.recipient, _this.recipient) || other.recipient == _this.recipient)&&const DeepCollectionEquality().equals(other.lots, _this.lots)&&(identical(other.balance, _this.balance) || other.balance == _this.balance)&&(identical(other.replayed, _this.replayed) || other.replayed == _this.replayed)); +} + + +@override +int get hashCode { + final _this = this as TransferResult; + return Object.hash(runtimeType,_this.currency,_this.amount,_this.recipient,const DeepCollectionEquality().hash(_this.lots),_this.balance,_this.replayed); +} + +@override +String toString() { + final _this = this as TransferResult; + return 'TransferResult(currency: ${_this.currency}, amount: ${_this.amount}, recipient: ${_this.recipient}, lots: ${_this.lots}, balance: ${_this.balance}, replayed: ${_this.replayed})'; +} + + +} + +/// @nodoc +abstract mixin class $TransferResultCopyWith<$Res> { + factory $TransferResultCopyWith(TransferResult value, $Res Function(TransferResult) _then) = _$TransferResultCopyWithImpl; +@useResult +$Res call({ + WalletCurrency currency, int amount, TransferRecipient recipient, List lots, int balance, bool replayed +}); + + +$TransferRecipientCopyWith<$Res> get recipient; + +} +/// @nodoc +class _$TransferResultCopyWithImpl<$Res> + implements $TransferResultCopyWith<$Res> { + _$TransferResultCopyWithImpl(this._self, this._then); + + final TransferResult _self; + final $Res Function(TransferResult) _then; + +/// Create a copy of TransferResult +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? currency = null,Object? amount = null,Object? recipient = null,Object? lots = null,Object? balance = null,Object? replayed = null,}) { + return _then(TransferResult( +currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,recipient: null == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as TransferRecipient,lots: null == lots ? _self.lots : lots // ignore: cast_nullable_to_non_nullable +as List,balance: null == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as int,replayed: null == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool, + )); +} +/// Create a copy of TransferResult +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferRecipientCopyWith<$Res> get recipient { + + return $TransferRecipientCopyWith<$Res>(_self.recipient, (value) { + return _then(_self.copyWith(recipient: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [TransferResult]. +extension TransferResultPatterns on TransferResult { +/// 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( _TransferResult value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _TransferResult() 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( _TransferResult value) $default,){ +final _that = this; +switch (_that) { +case _TransferResult(): +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( _TransferResult value)? $default,){ +final _that = this; +switch (_that) { +case _TransferResult() 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( WalletCurrency currency, int amount, TransferRecipient recipient, List lots, int balance, bool replayed)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _TransferResult() when $default != null: +return $default(_that.currency,_that.amount,_that.recipient,_that.lots,_that.balance,_that.replayed);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( WalletCurrency currency, int amount, TransferRecipient recipient, List lots, int balance, bool replayed) $default,) {final _that = this; +switch (_that) { +case _TransferResult(): +return $default(_that.currency,_that.amount,_that.recipient,_that.lots,_that.balance,_that.replayed);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( WalletCurrency currency, int amount, TransferRecipient recipient, List lots, int balance, bool replayed)? $default,) {final _that = this; +switch (_that) { +case _TransferResult() when $default != null: +return $default(_that.currency,_that.amount,_that.recipient,_that.lots,_that.balance,_that.replayed);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _TransferResult implements TransferResult { + const _TransferResult({required this.currency, required this.amount, required this.recipient, required List lots, required this.balance, required this.replayed}): _lots = lots; + + +@override final WalletCurrency currency; +@override final int amount; +@override final TransferRecipient recipient; + final List _lots; +@override List get lots { + if (_lots is EqualUnmodifiableListView) return _lots; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_lots); +} + +@override final int balance; +@override final bool replayed; + +/// Create a copy of TransferResult +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TransferResultCopyWith<_TransferResult> get copyWith => __$TransferResultCopyWithImpl<_TransferResult>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TransferResult&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.recipient, recipient) || other.recipient == recipient)&&const DeepCollectionEquality().equals(other.lots, _lots)&&(identical(other.balance, balance) || other.balance == balance)&&(identical(other.replayed, replayed) || other.replayed == replayed)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,currency,amount,recipient,const DeepCollectionEquality().hash(_lots),balance,replayed); +} + +@override +String toString() { + return 'TransferResult(currency: $currency, amount: $amount, recipient: $recipient, lots: $lots, balance: $balance, replayed: $replayed)'; +} + + +} + +/// @nodoc +abstract mixin class _$TransferResultCopyWith<$Res> implements $TransferResultCopyWith<$Res> { + factory _$TransferResultCopyWith(_TransferResult value, $Res Function(_TransferResult) _then) = __$TransferResultCopyWithImpl; +@override @useResult +$Res call({ + WalletCurrency currency, int amount, TransferRecipient recipient, List lots, int balance, bool replayed +}); + + +@override $TransferRecipientCopyWith<$Res> get recipient; + +} +/// @nodoc +class __$TransferResultCopyWithImpl<$Res> + implements _$TransferResultCopyWith<$Res> { + __$TransferResultCopyWithImpl(this._self, this._then); + + final _TransferResult _self; + final $Res Function(_TransferResult) _then; + +/// Create a copy of TransferResult +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? currency = null,Object? amount = null,Object? recipient = null,Object? lots = null,Object? balance = null,Object? replayed = null,}) { + return _then(_TransferResult( +currency: null == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as WalletCurrency,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,recipient: null == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as TransferRecipient,lots: null == lots ? _self._lots : lots // ignore: cast_nullable_to_non_nullable +as List,balance: null == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as int,replayed: null == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +/// Create a copy of TransferResult +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferRecipientCopyWith<$Res> get recipient { + + return $TransferRecipientCopyWith<$Res>(_self.recipient, (value) { + return _then(_self.copyWith(recipient: value)); + }); +} +} + +/// @nodoc +mixin _$PinStatus { + + bool get hasPin; DateTime? get lockedUntil; DateTime? get transferBlockedUntil; +/// Create a copy of PinStatus +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PinStatusCopyWith get copyWith => _$PinStatusCopyWithImpl(this as PinStatus, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as PinStatus; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinStatus&&(identical(other.hasPin, _this.hasPin) || other.hasPin == _this.hasPin)&&(identical(other.lockedUntil, _this.lockedUntil) || other.lockedUntil == _this.lockedUntil)&&(identical(other.transferBlockedUntil, _this.transferBlockedUntil) || other.transferBlockedUntil == _this.transferBlockedUntil)); +} + + +@override +int get hashCode { + final _this = this as PinStatus; + return Object.hash(runtimeType,_this.hasPin,_this.lockedUntil,_this.transferBlockedUntil); +} + +@override +String toString() { + final _this = this as PinStatus; + return 'PinStatus(hasPin: ${_this.hasPin}, lockedUntil: ${_this.lockedUntil}, transferBlockedUntil: ${_this.transferBlockedUntil})'; +} + + +} + +/// @nodoc +abstract mixin class $PinStatusCopyWith<$Res> { + factory $PinStatusCopyWith(PinStatus value, $Res Function(PinStatus) _then) = _$PinStatusCopyWithImpl; +@useResult +$Res call({ + bool hasPin, DateTime? lockedUntil, DateTime? transferBlockedUntil +}); + + + + +} +/// @nodoc +class _$PinStatusCopyWithImpl<$Res> + implements $PinStatusCopyWith<$Res> { + _$PinStatusCopyWithImpl(this._self, this._then); + + final PinStatus _self; + final $Res Function(PinStatus) _then; + +/// Create a copy of PinStatus +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? hasPin = null,Object? lockedUntil = freezed,Object? transferBlockedUntil = freezed,}) { + return _then(PinStatus( +hasPin: null == hasPin ? _self.hasPin : hasPin // ignore: cast_nullable_to_non_nullable +as bool,lockedUntil: freezed == lockedUntil ? _self.lockedUntil : lockedUntil // ignore: cast_nullable_to_non_nullable +as DateTime?,transferBlockedUntil: freezed == transferBlockedUntil ? _self.transferBlockedUntil : transferBlockedUntil // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PinStatus]. +extension PinStatusPatterns on PinStatus { +/// 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( _PinStatus value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PinStatus() 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( _PinStatus value) $default,){ +final _that = this; +switch (_that) { +case _PinStatus(): +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( _PinStatus value)? $default,){ +final _that = this; +switch (_that) { +case _PinStatus() 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( bool hasPin, DateTime? lockedUntil, DateTime? transferBlockedUntil)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PinStatus() when $default != null: +return $default(_that.hasPin,_that.lockedUntil,_that.transferBlockedUntil);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( bool hasPin, DateTime? lockedUntil, DateTime? transferBlockedUntil) $default,) {final _that = this; +switch (_that) { +case _PinStatus(): +return $default(_that.hasPin,_that.lockedUntil,_that.transferBlockedUntil);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( bool hasPin, DateTime? lockedUntil, DateTime? transferBlockedUntil)? $default,) {final _that = this; +switch (_that) { +case _PinStatus() when $default != null: +return $default(_that.hasPin,_that.lockedUntil,_that.transferBlockedUntil);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _PinStatus extends PinStatus { + const _PinStatus({required this.hasPin, this.lockedUntil, this.transferBlockedUntil}): super._(); + + +@override final bool hasPin; +@override final DateTime? lockedUntil; +@override final DateTime? transferBlockedUntil; + +/// Create a copy of PinStatus +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinStatusCopyWith<_PinStatus> get copyWith => __$PinStatusCopyWithImpl<_PinStatus>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinStatus&&(identical(other.hasPin, hasPin) || other.hasPin == hasPin)&&(identical(other.lockedUntil, lockedUntil) || other.lockedUntil == lockedUntil)&&(identical(other.transferBlockedUntil, transferBlockedUntil) || other.transferBlockedUntil == transferBlockedUntil)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,hasPin,lockedUntil,transferBlockedUntil); +} + +@override +String toString() { + return 'PinStatus(hasPin: $hasPin, lockedUntil: $lockedUntil, transferBlockedUntil: $transferBlockedUntil)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinStatusCopyWith<$Res> implements $PinStatusCopyWith<$Res> { + factory _$PinStatusCopyWith(_PinStatus value, $Res Function(_PinStatus) _then) = __$PinStatusCopyWithImpl; +@override @useResult +$Res call({ + bool hasPin, DateTime? lockedUntil, DateTime? transferBlockedUntil +}); + + + + +} +/// @nodoc +class __$PinStatusCopyWithImpl<$Res> + implements _$PinStatusCopyWith<$Res> { + __$PinStatusCopyWithImpl(this._self, this._then); + + final _PinStatus _self; + final $Res Function(_PinStatus) _then; + +/// Create a copy of PinStatus +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? hasPin = null,Object? lockedUntil = freezed,Object? transferBlockedUntil = freezed,}) { + return _then(_PinStatus( +hasPin: null == hasPin ? _self.hasPin : hasPin // ignore: cast_nullable_to_non_nullable +as bool,lockedUntil: freezed == lockedUntil ? _self.lockedUntil : lockedUntil // ignore: cast_nullable_to_non_nullable +as DateTime?,transferBlockedUntil: freezed == transferBlockedUntil ? _self.transferBlockedUntil : transferBlockedUntil // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +/// @nodoc +mixin _$PinOtp { + + PinOtpPurpose get purpose; String get otpToken; DateTime? get expiresAt; +/// Create a copy of PinOtp +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PinOtpCopyWith get copyWith => _$PinOtpCopyWithImpl(this as PinOtp, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as PinOtp; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinOtp&&(identical(other.purpose, _this.purpose) || other.purpose == _this.purpose)&&(identical(other.otpToken, _this.otpToken) || other.otpToken == _this.otpToken)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)); +} + + +@override +int get hashCode { + final _this = this as PinOtp; + return Object.hash(runtimeType,_this.purpose,_this.otpToken,_this.expiresAt); +} + +@override +String toString() { + final _this = this as PinOtp; + return 'PinOtp(purpose: ${_this.purpose}, otpToken: ${_this.otpToken}, expiresAt: ${_this.expiresAt})'; +} + + +} + +/// @nodoc +abstract mixin class $PinOtpCopyWith<$Res> { + factory $PinOtpCopyWith(PinOtp value, $Res Function(PinOtp) _then) = _$PinOtpCopyWithImpl; +@useResult +$Res call({ + PinOtpPurpose purpose, String otpToken, DateTime? expiresAt +}); + + + + +} +/// @nodoc +class _$PinOtpCopyWithImpl<$Res> + implements $PinOtpCopyWith<$Res> { + _$PinOtpCopyWithImpl(this._self, this._then); + + final PinOtp _self; + final $Res Function(PinOtp) _then; + +/// Create a copy of PinOtp +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? purpose = null,Object? otpToken = null,Object? expiresAt = freezed,}) { + return _then(PinOtp( +purpose: null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as PinOtpPurpose,otpToken: null == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PinOtp]. +extension PinOtpPatterns on PinOtp { +/// 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( _PinOtp value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PinOtp() 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( _PinOtp value) $default,){ +final _that = this; +switch (_that) { +case _PinOtp(): +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( _PinOtp value)? $default,){ +final _that = this; +switch (_that) { +case _PinOtp() 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( PinOtpPurpose purpose, String otpToken, DateTime? expiresAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PinOtp() when $default != null: +return $default(_that.purpose,_that.otpToken,_that.expiresAt);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( PinOtpPurpose purpose, String otpToken, DateTime? expiresAt) $default,) {final _that = this; +switch (_that) { +case _PinOtp(): +return $default(_that.purpose,_that.otpToken,_that.expiresAt);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( PinOtpPurpose purpose, String otpToken, DateTime? expiresAt)? $default,) {final _that = this; +switch (_that) { +case _PinOtp() when $default != null: +return $default(_that.purpose,_that.otpToken,_that.expiresAt);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _PinOtp implements PinOtp { + const _PinOtp({required this.purpose, required this.otpToken, this.expiresAt}); + + +@override final PinOtpPurpose purpose; +@override final String otpToken; +@override final DateTime? expiresAt; + +/// Create a copy of PinOtp +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinOtpCopyWith<_PinOtp> get copyWith => __$PinOtpCopyWithImpl<_PinOtp>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinOtp&&(identical(other.purpose, purpose) || other.purpose == purpose)&&(identical(other.otpToken, otpToken) || other.otpToken == otpToken)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,purpose,otpToken,expiresAt); +} + +@override +String toString() { + return 'PinOtp(purpose: $purpose, otpToken: $otpToken, expiresAt: $expiresAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinOtpCopyWith<$Res> implements $PinOtpCopyWith<$Res> { + factory _$PinOtpCopyWith(_PinOtp value, $Res Function(_PinOtp) _then) = __$PinOtpCopyWithImpl; +@override @useResult +$Res call({ + PinOtpPurpose purpose, String otpToken, DateTime? expiresAt +}); + + + + +} +/// @nodoc +class __$PinOtpCopyWithImpl<$Res> + implements _$PinOtpCopyWith<$Res> { + __$PinOtpCopyWithImpl(this._self, this._then); + + final _PinOtp _self; + final $Res Function(_PinOtp) _then; + +/// Create a copy of PinOtp +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? purpose = null,Object? otpToken = null,Object? expiresAt = freezed,}) { + return _then(_PinOtp( +purpose: null == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as PinOtpPurpose,otpToken: null == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +/// @nodoc +mixin _$Outlet { + + String get id; String get name; String? get address;/// Kasir di outlet ini menerima pembayaran EnakPoint. + bool get acceptsPointPayment;/// Belanja di outlet ini memberi EnakPoint. + bool get earnsPoints;/// Belanja di outlet ini memberi EnakCoin. + bool get earnsCoins; +/// Create a copy of Outlet +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OutletCopyWith get copyWith => _$OutletCopyWithImpl(this as Outlet, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as Outlet; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Outlet&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.address, _this.address) || other.address == _this.address)&&(identical(other.acceptsPointPayment, _this.acceptsPointPayment) || other.acceptsPointPayment == _this.acceptsPointPayment)&&(identical(other.earnsPoints, _this.earnsPoints) || other.earnsPoints == _this.earnsPoints)&&(identical(other.earnsCoins, _this.earnsCoins) || other.earnsCoins == _this.earnsCoins)); +} + + +@override +int get hashCode { + final _this = this as Outlet; + return Object.hash(runtimeType,_this.id,_this.name,_this.address,_this.acceptsPointPayment,_this.earnsPoints,_this.earnsCoins); +} + +@override +String toString() { + final _this = this as Outlet; + return 'Outlet(id: ${_this.id}, name: ${_this.name}, address: ${_this.address}, acceptsPointPayment: ${_this.acceptsPointPayment}, earnsPoints: ${_this.earnsPoints}, earnsCoins: ${_this.earnsCoins})'; +} + + +} + +/// @nodoc +abstract mixin class $OutletCopyWith<$Res> { + factory $OutletCopyWith(Outlet value, $Res Function(Outlet) _then) = _$OutletCopyWithImpl; +@useResult +$Res call({ + String id, String name, String? address, bool acceptsPointPayment, bool earnsPoints, bool earnsCoins +}); + + + + +} +/// @nodoc +class _$OutletCopyWithImpl<$Res> + implements $OutletCopyWith<$Res> { + _$OutletCopyWithImpl(this._self, this._then); + + final Outlet _self; + final $Res Function(Outlet) _then; + +/// Create a copy of Outlet +/// 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? address = freezed,Object? acceptsPointPayment = null,Object? earnsPoints = null,Object? earnsCoins = null,}) { + return _then(Outlet( +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,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,acceptsPointPayment: null == acceptsPointPayment ? _self.acceptsPointPayment : acceptsPointPayment // ignore: cast_nullable_to_non_nullable +as bool,earnsPoints: null == earnsPoints ? _self.earnsPoints : earnsPoints // ignore: cast_nullable_to_non_nullable +as bool,earnsCoins: null == earnsCoins ? _self.earnsCoins : earnsCoins // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + +} + + +/// Adds pattern-matching-related methods to [Outlet]. +extension OutletPatterns on Outlet { +/// 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( _Outlet value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Outlet() 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( _Outlet value) $default,){ +final _that = this; +switch (_that) { +case _Outlet(): +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( _Outlet value)? $default,){ +final _that = this; +switch (_that) { +case _Outlet() 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, String? address, bool acceptsPointPayment, bool earnsPoints, bool earnsCoins)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Outlet() when $default != null: +return $default(_that.id,_that.name,_that.address,_that.acceptsPointPayment,_that.earnsPoints,_that.earnsCoins);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, String? address, bool acceptsPointPayment, bool earnsPoints, bool earnsCoins) $default,) {final _that = this; +switch (_that) { +case _Outlet(): +return $default(_that.id,_that.name,_that.address,_that.acceptsPointPayment,_that.earnsPoints,_that.earnsCoins);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, String? address, bool acceptsPointPayment, bool earnsPoints, bool earnsCoins)? $default,) {final _that = this; +switch (_that) { +case _Outlet() when $default != null: +return $default(_that.id,_that.name,_that.address,_that.acceptsPointPayment,_that.earnsPoints,_that.earnsCoins);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _Outlet implements Outlet { + const _Outlet({required this.id, required this.name, this.address, required this.acceptsPointPayment, required this.earnsPoints, required this.earnsCoins}); + + +@override final String id; +@override final String name; +@override final String? address; +/// Kasir di outlet ini menerima pembayaran EnakPoint. +@override final bool acceptsPointPayment; +/// Belanja di outlet ini memberi EnakPoint. +@override final bool earnsPoints; +/// Belanja di outlet ini memberi EnakCoin. +@override final bool earnsCoins; + +/// Create a copy of Outlet +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OutletCopyWith<_Outlet> get copyWith => __$OutletCopyWithImpl<_Outlet>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Outlet&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.address, address) || other.address == address)&&(identical(other.acceptsPointPayment, acceptsPointPayment) || other.acceptsPointPayment == acceptsPointPayment)&&(identical(other.earnsPoints, earnsPoints) || other.earnsPoints == earnsPoints)&&(identical(other.earnsCoins, earnsCoins) || other.earnsCoins == earnsCoins)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,name,address,acceptsPointPayment,earnsPoints,earnsCoins); +} + +@override +String toString() { + return 'Outlet(id: $id, name: $name, address: $address, acceptsPointPayment: $acceptsPointPayment, earnsPoints: $earnsPoints, earnsCoins: $earnsCoins)'; +} + + +} + +/// @nodoc +abstract mixin class _$OutletCopyWith<$Res> implements $OutletCopyWith<$Res> { + factory _$OutletCopyWith(_Outlet value, $Res Function(_Outlet) _then) = __$OutletCopyWithImpl; +@override @useResult +$Res call({ + String id, String name, String? address, bool acceptsPointPayment, bool earnsPoints, bool earnsCoins +}); + + + + +} +/// @nodoc +class __$OutletCopyWithImpl<$Res> + implements _$OutletCopyWith<$Res> { + __$OutletCopyWithImpl(this._self, this._then); + + final _Outlet _self; + final $Res Function(_Outlet) _then; + +/// Create a copy of Outlet +/// 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? address = freezed,Object? acceptsPointPayment = null,Object? earnsPoints = null,Object? earnsCoins = null,}) { + return _then(_Outlet( +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,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,acceptsPointPayment: null == acceptsPointPayment ? _self.acceptsPointPayment : acceptsPointPayment // ignore: cast_nullable_to_non_nullable +as bool,earnsPoints: null == earnsPoints ? _self.earnsPoints : earnsPoints // ignore: cast_nullable_to_non_nullable +as bool,earnsCoins: null == earnsCoins ? _self.earnsCoins : earnsCoins // ignore: cast_nullable_to_non_nullable +as bool, + )); +} + + +} + +/// @nodoc +mixin _$CustomerOrder { + + String get id; String get orderNumber; String get outletName; String get orderType; String get status; String get paymentStatus; int get totalAmount; int get itemCount; bool get isVoid; bool get isRefund; int get pointsEarned; int get coinsEarned; DateTime? get createdAt; +/// Create a copy of CustomerOrder +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderCopyWith get copyWith => _$CustomerOrderCopyWithImpl(this as CustomerOrder, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrder; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrder&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.orderNumber, _this.orderNumber) || other.orderNumber == _this.orderNumber)&&(identical(other.outletName, _this.outletName) || other.outletName == _this.outletName)&&(identical(other.orderType, _this.orderType) || other.orderType == _this.orderType)&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.paymentStatus, _this.paymentStatus) || other.paymentStatus == _this.paymentStatus)&&(identical(other.totalAmount, _this.totalAmount) || other.totalAmount == _this.totalAmount)&&(identical(other.itemCount, _this.itemCount) || other.itemCount == _this.itemCount)&&(identical(other.isVoid, _this.isVoid) || other.isVoid == _this.isVoid)&&(identical(other.isRefund, _this.isRefund) || other.isRefund == _this.isRefund)&&(identical(other.pointsEarned, _this.pointsEarned) || other.pointsEarned == _this.pointsEarned)&&(identical(other.coinsEarned, _this.coinsEarned) || other.coinsEarned == _this.coinsEarned)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)); +} + + +@override +int get hashCode { + final _this = this as CustomerOrder; + return Object.hash(runtimeType,_this.id,_this.orderNumber,_this.outletName,_this.orderType,_this.status,_this.paymentStatus,_this.totalAmount,_this.itemCount,_this.isVoid,_this.isRefund,_this.pointsEarned,_this.coinsEarned,_this.createdAt); +} + +@override +String toString() { + final _this = this as CustomerOrder; + return 'CustomerOrder(id: ${_this.id}, orderNumber: ${_this.orderNumber}, outletName: ${_this.outletName}, orderType: ${_this.orderType}, status: ${_this.status}, paymentStatus: ${_this.paymentStatus}, totalAmount: ${_this.totalAmount}, itemCount: ${_this.itemCount}, isVoid: ${_this.isVoid}, isRefund: ${_this.isRefund}, pointsEarned: ${_this.pointsEarned}, coinsEarned: ${_this.coinsEarned}, createdAt: ${_this.createdAt})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderCopyWith<$Res> { + factory $CustomerOrderCopyWith(CustomerOrder value, $Res Function(CustomerOrder) _then) = _$CustomerOrderCopyWithImpl; +@useResult +$Res call({ + String id, String orderNumber, String outletName, String orderType, String status, String paymentStatus, int totalAmount, int itemCount, bool isVoid, bool isRefund, int pointsEarned, int coinsEarned, DateTime? createdAt +}); + + + + +} +/// @nodoc +class _$CustomerOrderCopyWithImpl<$Res> + implements $CustomerOrderCopyWith<$Res> { + _$CustomerOrderCopyWithImpl(this._self, this._then); + + final CustomerOrder _self; + final $Res Function(CustomerOrder) _then; + +/// Create a copy of CustomerOrder +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? orderNumber = null,Object? outletName = null,Object? orderType = null,Object? status = null,Object? paymentStatus = null,Object? totalAmount = null,Object? itemCount = null,Object? isVoid = null,Object? isRefund = null,Object? pointsEarned = null,Object? coinsEarned = null,Object? createdAt = freezed,}) { + return _then(CustomerOrder( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,orderNumber: null == orderNumber ? _self.orderNumber : orderNumber // ignore: cast_nullable_to_non_nullable +as String,outletName: null == outletName ? _self.outletName : outletName // ignore: cast_nullable_to_non_nullable +as String,orderType: null == orderType ? _self.orderType : orderType // ignore: cast_nullable_to_non_nullable +as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,paymentStatus: null == paymentStatus ? _self.paymentStatus : paymentStatus // ignore: cast_nullable_to_non_nullable +as String,totalAmount: null == totalAmount ? _self.totalAmount : totalAmount // ignore: cast_nullable_to_non_nullable +as int,itemCount: null == itemCount ? _self.itemCount : itemCount // ignore: cast_nullable_to_non_nullable +as int,isVoid: null == isVoid ? _self.isVoid : isVoid // ignore: cast_nullable_to_non_nullable +as bool,isRefund: null == isRefund ? _self.isRefund : isRefund // ignore: cast_nullable_to_non_nullable +as bool,pointsEarned: null == pointsEarned ? _self.pointsEarned : pointsEarned // ignore: cast_nullable_to_non_nullable +as int,coinsEarned: null == coinsEarned ? _self.coinsEarned : coinsEarned // ignore: cast_nullable_to_non_nullable +as int,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CustomerOrder]. +extension CustomerOrderPatterns on CustomerOrder { +/// 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( _CustomerOrder value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrder() 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( _CustomerOrder value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrder(): +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( _CustomerOrder value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrder() 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 orderNumber, String outletName, String orderType, String status, String paymentStatus, int totalAmount, int itemCount, bool isVoid, bool isRefund, int pointsEarned, int coinsEarned, DateTime? createdAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrder() when $default != null: +return $default(_that.id,_that.orderNumber,_that.outletName,_that.orderType,_that.status,_that.paymentStatus,_that.totalAmount,_that.itemCount,_that.isVoid,_that.isRefund,_that.pointsEarned,_that.coinsEarned,_that.createdAt);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 orderNumber, String outletName, String orderType, String status, String paymentStatus, int totalAmount, int itemCount, bool isVoid, bool isRefund, int pointsEarned, int coinsEarned, DateTime? createdAt) $default,) {final _that = this; +switch (_that) { +case _CustomerOrder(): +return $default(_that.id,_that.orderNumber,_that.outletName,_that.orderType,_that.status,_that.paymentStatus,_that.totalAmount,_that.itemCount,_that.isVoid,_that.isRefund,_that.pointsEarned,_that.coinsEarned,_that.createdAt);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 orderNumber, String outletName, String orderType, String status, String paymentStatus, int totalAmount, int itemCount, bool isVoid, bool isRefund, int pointsEarned, int coinsEarned, DateTime? createdAt)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrder() when $default != null: +return $default(_that.id,_that.orderNumber,_that.outletName,_that.orderType,_that.status,_that.paymentStatus,_that.totalAmount,_that.itemCount,_that.isVoid,_that.isRefund,_that.pointsEarned,_that.coinsEarned,_that.createdAt);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CustomerOrder extends CustomerOrder { + const _CustomerOrder({required this.id, required this.orderNumber, required this.outletName, required this.orderType, required this.status, required this.paymentStatus, required this.totalAmount, required this.itemCount, required this.isVoid, required this.isRefund, required this.pointsEarned, required this.coinsEarned, this.createdAt}): super._(); + + +@override final String id; +@override final String orderNumber; +@override final String outletName; +@override final String orderType; +@override final String status; +@override final String paymentStatus; +@override final int totalAmount; +@override final int itemCount; +@override final bool isVoid; +@override final bool isRefund; +@override final int pointsEarned; +@override final int coinsEarned; +@override final DateTime? createdAt; + +/// Create a copy of CustomerOrder +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderCopyWith<_CustomerOrder> get copyWith => __$CustomerOrderCopyWithImpl<_CustomerOrder>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrder&&(identical(other.id, id) || other.id == id)&&(identical(other.orderNumber, orderNumber) || other.orderNumber == orderNumber)&&(identical(other.outletName, outletName) || other.outletName == outletName)&&(identical(other.orderType, orderType) || other.orderType == orderType)&&(identical(other.status, status) || other.status == status)&&(identical(other.paymentStatus, paymentStatus) || other.paymentStatus == paymentStatus)&&(identical(other.totalAmount, totalAmount) || other.totalAmount == totalAmount)&&(identical(other.itemCount, itemCount) || other.itemCount == itemCount)&&(identical(other.isVoid, isVoid) || other.isVoid == isVoid)&&(identical(other.isRefund, isRefund) || other.isRefund == isRefund)&&(identical(other.pointsEarned, pointsEarned) || other.pointsEarned == pointsEarned)&&(identical(other.coinsEarned, coinsEarned) || other.coinsEarned == coinsEarned)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,orderNumber,outletName,orderType,status,paymentStatus,totalAmount,itemCount,isVoid,isRefund,pointsEarned,coinsEarned,createdAt); +} + +@override +String toString() { + return 'CustomerOrder(id: $id, orderNumber: $orderNumber, outletName: $outletName, orderType: $orderType, status: $status, paymentStatus: $paymentStatus, totalAmount: $totalAmount, itemCount: $itemCount, isVoid: $isVoid, isRefund: $isRefund, pointsEarned: $pointsEarned, coinsEarned: $coinsEarned, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderCopyWith<$Res> implements $CustomerOrderCopyWith<$Res> { + factory _$CustomerOrderCopyWith(_CustomerOrder value, $Res Function(_CustomerOrder) _then) = __$CustomerOrderCopyWithImpl; +@override @useResult +$Res call({ + String id, String orderNumber, String outletName, String orderType, String status, String paymentStatus, int totalAmount, int itemCount, bool isVoid, bool isRefund, int pointsEarned, int coinsEarned, DateTime? createdAt +}); + + + + +} +/// @nodoc +class __$CustomerOrderCopyWithImpl<$Res> + implements _$CustomerOrderCopyWith<$Res> { + __$CustomerOrderCopyWithImpl(this._self, this._then); + + final _CustomerOrder _self; + final $Res Function(_CustomerOrder) _then; + +/// Create a copy of CustomerOrder +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? orderNumber = null,Object? outletName = null,Object? orderType = null,Object? status = null,Object? paymentStatus = null,Object? totalAmount = null,Object? itemCount = null,Object? isVoid = null,Object? isRefund = null,Object? pointsEarned = null,Object? coinsEarned = null,Object? createdAt = freezed,}) { + return _then(_CustomerOrder( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,orderNumber: null == orderNumber ? _self.orderNumber : orderNumber // ignore: cast_nullable_to_non_nullable +as String,outletName: null == outletName ? _self.outletName : outletName // ignore: cast_nullable_to_non_nullable +as String,orderType: null == orderType ? _self.orderType : orderType // ignore: cast_nullable_to_non_nullable +as String,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String,paymentStatus: null == paymentStatus ? _self.paymentStatus : paymentStatus // ignore: cast_nullable_to_non_nullable +as String,totalAmount: null == totalAmount ? _self.totalAmount : totalAmount // ignore: cast_nullable_to_non_nullable +as int,itemCount: null == itemCount ? _self.itemCount : itemCount // ignore: cast_nullable_to_non_nullable +as int,isVoid: null == isVoid ? _self.isVoid : isVoid // ignore: cast_nullable_to_non_nullable +as bool,isRefund: null == isRefund ? _self.isRefund : isRefund // ignore: cast_nullable_to_non_nullable +as bool,pointsEarned: null == pointsEarned ? _self.pointsEarned : pointsEarned // ignore: cast_nullable_to_non_nullable +as int,coinsEarned: null == coinsEarned ? _self.coinsEarned : coinsEarned // ignore: cast_nullable_to_non_nullable +as int,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +/// @nodoc +mixin _$CustomerOrderPage { + + List get items; int get page; int get totalPages; +/// Create a copy of CustomerOrderPage +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderPageCopyWith get copyWith => _$CustomerOrderPageCopyWithImpl(this as CustomerOrderPage, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrderPage; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrderPage&&const DeepCollectionEquality().equals(other.items, _this.items)&&(identical(other.page, _this.page) || other.page == _this.page)&&(identical(other.totalPages, _this.totalPages) || other.totalPages == _this.totalPages)); +} + + +@override +int get hashCode { + final _this = this as CustomerOrderPage; + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_this.items),_this.page,_this.totalPages); +} + +@override +String toString() { + final _this = this as CustomerOrderPage; + return 'CustomerOrderPage(items: ${_this.items}, page: ${_this.page}, totalPages: ${_this.totalPages})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderPageCopyWith<$Res> { + factory $CustomerOrderPageCopyWith(CustomerOrderPage value, $Res Function(CustomerOrderPage) _then) = _$CustomerOrderPageCopyWithImpl; +@useResult +$Res call({ + List items, int page, int totalPages +}); + + + + +} +/// @nodoc +class _$CustomerOrderPageCopyWithImpl<$Res> + implements $CustomerOrderPageCopyWith<$Res> { + _$CustomerOrderPageCopyWithImpl(this._self, this._then); + + final CustomerOrderPage _self; + final $Res Function(CustomerOrderPage) _then; + +/// Create a copy of CustomerOrderPage +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? page = null,Object? totalPages = null,}) { + return _then(CustomerOrderPage( +items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CustomerOrderPage]. +extension CustomerOrderPagePatterns on CustomerOrderPage { +/// 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( _CustomerOrderPage value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrderPage() 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( _CustomerOrderPage value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderPage(): +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( _CustomerOrderPage value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderPage() 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, int page, int totalPages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrderPage() when $default != null: +return $default(_that.items,_that.page,_that.totalPages);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, int page, int totalPages) $default,) {final _that = this; +switch (_that) { +case _CustomerOrderPage(): +return $default(_that.items,_that.page,_that.totalPages);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, int page, int totalPages)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrderPage() when $default != null: +return $default(_that.items,_that.page,_that.totalPages);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CustomerOrderPage implements CustomerOrderPage { + const _CustomerOrderPage({required List items, required this.page, required this.totalPages}): _items = items; + + + final List _items; +@override List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); +} + +@override final int page; +@override final int totalPages; + +/// Create a copy of CustomerOrderPage +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderPageCopyWith<_CustomerOrderPage> get copyWith => __$CustomerOrderPageCopyWithImpl<_CustomerOrderPage>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrderPage&&const DeepCollectionEquality().equals(other.items, _items)&&(identical(other.page, page) || other.page == page)&&(identical(other.totalPages, totalPages) || other.totalPages == totalPages)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),page,totalPages); +} + +@override +String toString() { + return 'CustomerOrderPage(items: $items, page: $page, totalPages: $totalPages)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderPageCopyWith<$Res> implements $CustomerOrderPageCopyWith<$Res> { + factory _$CustomerOrderPageCopyWith(_CustomerOrderPage value, $Res Function(_CustomerOrderPage) _then) = __$CustomerOrderPageCopyWithImpl; +@override @useResult +$Res call({ + List items, int page, int totalPages +}); + + + + +} +/// @nodoc +class __$CustomerOrderPageCopyWithImpl<$Res> + implements _$CustomerOrderPageCopyWith<$Res> { + __$CustomerOrderPageCopyWithImpl(this._self, this._then); + + final _CustomerOrderPage _self; + final $Res Function(_CustomerOrderPage) _then; + +/// Create a copy of CustomerOrderPage +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? page = null,Object? totalPages = null,}) { + return _then(_CustomerOrderPage( +items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int,totalPages: null == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc +mixin _$CustomerOrderDetail { + + CustomerOrder get order; String? get tableNumber; int get subtotal; int get discountAmount; int get taxAmount; int get refundAmount; List get items; List get payments; +/// Create a copy of CustomerOrderDetail +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderDetailCopyWith get copyWith => _$CustomerOrderDetailCopyWithImpl(this as CustomerOrderDetail, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrderDetail; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrderDetail&&(identical(other.order, _this.order) || other.order == _this.order)&&(identical(other.tableNumber, _this.tableNumber) || other.tableNumber == _this.tableNumber)&&(identical(other.subtotal, _this.subtotal) || other.subtotal == _this.subtotal)&&(identical(other.discountAmount, _this.discountAmount) || other.discountAmount == _this.discountAmount)&&(identical(other.taxAmount, _this.taxAmount) || other.taxAmount == _this.taxAmount)&&(identical(other.refundAmount, _this.refundAmount) || other.refundAmount == _this.refundAmount)&&const DeepCollectionEquality().equals(other.items, _this.items)&&const DeepCollectionEquality().equals(other.payments, _this.payments)); +} + + +@override +int get hashCode { + final _this = this as CustomerOrderDetail; + return Object.hash(runtimeType,_this.order,_this.tableNumber,_this.subtotal,_this.discountAmount,_this.taxAmount,_this.refundAmount,const DeepCollectionEquality().hash(_this.items),const DeepCollectionEquality().hash(_this.payments)); +} + +@override +String toString() { + final _this = this as CustomerOrderDetail; + return 'CustomerOrderDetail(order: ${_this.order}, tableNumber: ${_this.tableNumber}, subtotal: ${_this.subtotal}, discountAmount: ${_this.discountAmount}, taxAmount: ${_this.taxAmount}, refundAmount: ${_this.refundAmount}, items: ${_this.items}, payments: ${_this.payments})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderDetailCopyWith<$Res> { + factory $CustomerOrderDetailCopyWith(CustomerOrderDetail value, $Res Function(CustomerOrderDetail) _then) = _$CustomerOrderDetailCopyWithImpl; +@useResult +$Res call({ + CustomerOrder order, String? tableNumber, int subtotal, int discountAmount, int taxAmount, int refundAmount, List items, List payments +}); + + +$CustomerOrderCopyWith<$Res> get order; + +} +/// @nodoc +class _$CustomerOrderDetailCopyWithImpl<$Res> + implements $CustomerOrderDetailCopyWith<$Res> { + _$CustomerOrderDetailCopyWithImpl(this._self, this._then); + + final CustomerOrderDetail _self; + final $Res Function(CustomerOrderDetail) _then; + +/// Create a copy of CustomerOrderDetail +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? order = null,Object? tableNumber = freezed,Object? subtotal = null,Object? discountAmount = null,Object? taxAmount = null,Object? refundAmount = null,Object? items = null,Object? payments = null,}) { + return _then(CustomerOrderDetail( +order: null == order ? _self.order : order // ignore: cast_nullable_to_non_nullable +as CustomerOrder,tableNumber: freezed == tableNumber ? _self.tableNumber : tableNumber // ignore: cast_nullable_to_non_nullable +as String?,subtotal: null == subtotal ? _self.subtotal : subtotal // ignore: cast_nullable_to_non_nullable +as int,discountAmount: null == discountAmount ? _self.discountAmount : discountAmount // ignore: cast_nullable_to_non_nullable +as int,taxAmount: null == taxAmount ? _self.taxAmount : taxAmount // ignore: cast_nullable_to_non_nullable +as int,refundAmount: null == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List,payments: null == payments ? _self.payments : payments // ignore: cast_nullable_to_non_nullable +as List, + )); +} +/// Create a copy of CustomerOrderDetail +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CustomerOrderCopyWith<$Res> get order { + + return $CustomerOrderCopyWith<$Res>(_self.order, (value) { + return _then(_self.copyWith(order: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [CustomerOrderDetail]. +extension CustomerOrderDetailPatterns on CustomerOrderDetail { +/// 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( _CustomerOrderDetail value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrderDetail() 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( _CustomerOrderDetail value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderDetail(): +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( _CustomerOrderDetail value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderDetail() 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( CustomerOrder order, String? tableNumber, int subtotal, int discountAmount, int taxAmount, int refundAmount, List items, List payments)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrderDetail() when $default != null: +return $default(_that.order,_that.tableNumber,_that.subtotal,_that.discountAmount,_that.taxAmount,_that.refundAmount,_that.items,_that.payments);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( CustomerOrder order, String? tableNumber, int subtotal, int discountAmount, int taxAmount, int refundAmount, List items, List payments) $default,) {final _that = this; +switch (_that) { +case _CustomerOrderDetail(): +return $default(_that.order,_that.tableNumber,_that.subtotal,_that.discountAmount,_that.taxAmount,_that.refundAmount,_that.items,_that.payments);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( CustomerOrder order, String? tableNumber, int subtotal, int discountAmount, int taxAmount, int refundAmount, List items, List payments)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrderDetail() when $default != null: +return $default(_that.order,_that.tableNumber,_that.subtotal,_that.discountAmount,_that.taxAmount,_that.refundAmount,_that.items,_that.payments);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CustomerOrderDetail implements CustomerOrderDetail { + const _CustomerOrderDetail({required this.order, this.tableNumber, required this.subtotal, required this.discountAmount, required this.taxAmount, required this.refundAmount, required List items, required List payments}): _items = items,_payments = payments; + + +@override final CustomerOrder order; +@override final String? tableNumber; +@override final int subtotal; +@override final int discountAmount; +@override final int taxAmount; +@override final int refundAmount; + final List _items; +@override List get items { + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_items); +} + + final List _payments; +@override List get payments { + if (_payments is EqualUnmodifiableListView) return _payments; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_payments); +} + + +/// Create a copy of CustomerOrderDetail +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderDetailCopyWith<_CustomerOrderDetail> get copyWith => __$CustomerOrderDetailCopyWithImpl<_CustomerOrderDetail>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrderDetail&&(identical(other.order, order) || other.order == order)&&(identical(other.tableNumber, tableNumber) || other.tableNumber == tableNumber)&&(identical(other.subtotal, subtotal) || other.subtotal == subtotal)&&(identical(other.discountAmount, discountAmount) || other.discountAmount == discountAmount)&&(identical(other.taxAmount, taxAmount) || other.taxAmount == taxAmount)&&(identical(other.refundAmount, refundAmount) || other.refundAmount == refundAmount)&&const DeepCollectionEquality().equals(other.items, _items)&&const DeepCollectionEquality().equals(other.payments, _payments)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,order,tableNumber,subtotal,discountAmount,taxAmount,refundAmount,const DeepCollectionEquality().hash(_items),const DeepCollectionEquality().hash(_payments)); +} + +@override +String toString() { + return 'CustomerOrderDetail(order: $order, tableNumber: $tableNumber, subtotal: $subtotal, discountAmount: $discountAmount, taxAmount: $taxAmount, refundAmount: $refundAmount, items: $items, payments: $payments)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderDetailCopyWith<$Res> implements $CustomerOrderDetailCopyWith<$Res> { + factory _$CustomerOrderDetailCopyWith(_CustomerOrderDetail value, $Res Function(_CustomerOrderDetail) _then) = __$CustomerOrderDetailCopyWithImpl; +@override @useResult +$Res call({ + CustomerOrder order, String? tableNumber, int subtotal, int discountAmount, int taxAmount, int refundAmount, List items, List payments +}); + + +@override $CustomerOrderCopyWith<$Res> get order; + +} +/// @nodoc +class __$CustomerOrderDetailCopyWithImpl<$Res> + implements _$CustomerOrderDetailCopyWith<$Res> { + __$CustomerOrderDetailCopyWithImpl(this._self, this._then); + + final _CustomerOrderDetail _self; + final $Res Function(_CustomerOrderDetail) _then; + +/// Create a copy of CustomerOrderDetail +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? order = null,Object? tableNumber = freezed,Object? subtotal = null,Object? discountAmount = null,Object? taxAmount = null,Object? refundAmount = null,Object? items = null,Object? payments = null,}) { + return _then(_CustomerOrderDetail( +order: null == order ? _self.order : order // ignore: cast_nullable_to_non_nullable +as CustomerOrder,tableNumber: freezed == tableNumber ? _self.tableNumber : tableNumber // ignore: cast_nullable_to_non_nullable +as String?,subtotal: null == subtotal ? _self.subtotal : subtotal // ignore: cast_nullable_to_non_nullable +as int,discountAmount: null == discountAmount ? _self.discountAmount : discountAmount // ignore: cast_nullable_to_non_nullable +as int,taxAmount: null == taxAmount ? _self.taxAmount : taxAmount // ignore: cast_nullable_to_non_nullable +as int,refundAmount: null == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List,payments: null == payments ? _self._payments : payments // ignore: cast_nullable_to_non_nullable +as List, + )); +} + +/// Create a copy of CustomerOrderDetail +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CustomerOrderCopyWith<$Res> get order { + + return $CustomerOrderCopyWith<$Res>(_self.order, (value) { + return _then(_self.copyWith(order: value)); + }); +} +} + +/// @nodoc +mixin _$CustomerOrderItem { + + String get id; String get productName; String? get variantName; int get quantity;/// Hanya untuk item timbangan, mis. 4,2 [unitName]. + double? get weight; String? get unitName; int get unitPrice; int get totalPrice; int get refundQuantity; +/// Create a copy of CustomerOrderItem +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderItemCopyWith get copyWith => _$CustomerOrderItemCopyWithImpl(this as CustomerOrderItem, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrderItem; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrderItem&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.productName, _this.productName) || other.productName == _this.productName)&&(identical(other.variantName, _this.variantName) || other.variantName == _this.variantName)&&(identical(other.quantity, _this.quantity) || other.quantity == _this.quantity)&&(identical(other.weight, _this.weight) || other.weight == _this.weight)&&(identical(other.unitName, _this.unitName) || other.unitName == _this.unitName)&&(identical(other.unitPrice, _this.unitPrice) || other.unitPrice == _this.unitPrice)&&(identical(other.totalPrice, _this.totalPrice) || other.totalPrice == _this.totalPrice)&&(identical(other.refundQuantity, _this.refundQuantity) || other.refundQuantity == _this.refundQuantity)); +} + + +@override +int get hashCode { + final _this = this as CustomerOrderItem; + return Object.hash(runtimeType,_this.id,_this.productName,_this.variantName,_this.quantity,_this.weight,_this.unitName,_this.unitPrice,_this.totalPrice,_this.refundQuantity); +} + +@override +String toString() { + final _this = this as CustomerOrderItem; + return 'CustomerOrderItem(id: ${_this.id}, productName: ${_this.productName}, variantName: ${_this.variantName}, quantity: ${_this.quantity}, weight: ${_this.weight}, unitName: ${_this.unitName}, unitPrice: ${_this.unitPrice}, totalPrice: ${_this.totalPrice}, refundQuantity: ${_this.refundQuantity})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderItemCopyWith<$Res> { + factory $CustomerOrderItemCopyWith(CustomerOrderItem value, $Res Function(CustomerOrderItem) _then) = _$CustomerOrderItemCopyWithImpl; +@useResult +$Res call({ + String id, String productName, String? variantName, int quantity, double? weight, String? unitName, int unitPrice, int totalPrice, int refundQuantity +}); + + + + +} +/// @nodoc +class _$CustomerOrderItemCopyWithImpl<$Res> + implements $CustomerOrderItemCopyWith<$Res> { + _$CustomerOrderItemCopyWithImpl(this._self, this._then); + + final CustomerOrderItem _self; + final $Res Function(CustomerOrderItem) _then; + +/// Create a copy of CustomerOrderItem +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? productName = null,Object? variantName = freezed,Object? quantity = null,Object? weight = freezed,Object? unitName = freezed,Object? unitPrice = null,Object? totalPrice = null,Object? refundQuantity = null,}) { + return _then(CustomerOrderItem( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,productName: null == productName ? _self.productName : productName // ignore: cast_nullable_to_non_nullable +as String,variantName: freezed == variantName ? _self.variantName : variantName // ignore: cast_nullable_to_non_nullable +as String?,quantity: null == quantity ? _self.quantity : quantity // ignore: cast_nullable_to_non_nullable +as int,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable +as double?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable +as String?,unitPrice: null == unitPrice ? _self.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable +as int,totalPrice: null == totalPrice ? _self.totalPrice : totalPrice // ignore: cast_nullable_to_non_nullable +as int,refundQuantity: null == refundQuantity ? _self.refundQuantity : refundQuantity // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CustomerOrderItem]. +extension CustomerOrderItemPatterns on CustomerOrderItem { +/// 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( _CustomerOrderItem value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrderItem() 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( _CustomerOrderItem value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderItem(): +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( _CustomerOrderItem value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderItem() 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 productName, String? variantName, int quantity, double? weight, String? unitName, int unitPrice, int totalPrice, int refundQuantity)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrderItem() when $default != null: +return $default(_that.id,_that.productName,_that.variantName,_that.quantity,_that.weight,_that.unitName,_that.unitPrice,_that.totalPrice,_that.refundQuantity);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 productName, String? variantName, int quantity, double? weight, String? unitName, int unitPrice, int totalPrice, int refundQuantity) $default,) {final _that = this; +switch (_that) { +case _CustomerOrderItem(): +return $default(_that.id,_that.productName,_that.variantName,_that.quantity,_that.weight,_that.unitName,_that.unitPrice,_that.totalPrice,_that.refundQuantity);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 productName, String? variantName, int quantity, double? weight, String? unitName, int unitPrice, int totalPrice, int refundQuantity)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrderItem() when $default != null: +return $default(_that.id,_that.productName,_that.variantName,_that.quantity,_that.weight,_that.unitName,_that.unitPrice,_that.totalPrice,_that.refundQuantity);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CustomerOrderItem extends CustomerOrderItem { + const _CustomerOrderItem({required this.id, required this.productName, this.variantName, required this.quantity, this.weight, this.unitName, required this.unitPrice, required this.totalPrice, required this.refundQuantity}): super._(); + + +@override final String id; +@override final String productName; +@override final String? variantName; +@override final int quantity; +/// Hanya untuk item timbangan, mis. 4,2 [unitName]. +@override final double? weight; +@override final String? unitName; +@override final int unitPrice; +@override final int totalPrice; +@override final int refundQuantity; + +/// Create a copy of CustomerOrderItem +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderItemCopyWith<_CustomerOrderItem> get copyWith => __$CustomerOrderItemCopyWithImpl<_CustomerOrderItem>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrderItem&&(identical(other.id, id) || other.id == id)&&(identical(other.productName, productName) || other.productName == productName)&&(identical(other.variantName, variantName) || other.variantName == variantName)&&(identical(other.quantity, quantity) || other.quantity == quantity)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.unitName, unitName) || other.unitName == unitName)&&(identical(other.unitPrice, unitPrice) || other.unitPrice == unitPrice)&&(identical(other.totalPrice, totalPrice) || other.totalPrice == totalPrice)&&(identical(other.refundQuantity, refundQuantity) || other.refundQuantity == refundQuantity)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,productName,variantName,quantity,weight,unitName,unitPrice,totalPrice,refundQuantity); +} + +@override +String toString() { + return 'CustomerOrderItem(id: $id, productName: $productName, variantName: $variantName, quantity: $quantity, weight: $weight, unitName: $unitName, unitPrice: $unitPrice, totalPrice: $totalPrice, refundQuantity: $refundQuantity)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderItemCopyWith<$Res> implements $CustomerOrderItemCopyWith<$Res> { + factory _$CustomerOrderItemCopyWith(_CustomerOrderItem value, $Res Function(_CustomerOrderItem) _then) = __$CustomerOrderItemCopyWithImpl; +@override @useResult +$Res call({ + String id, String productName, String? variantName, int quantity, double? weight, String? unitName, int unitPrice, int totalPrice, int refundQuantity +}); + + + + +} +/// @nodoc +class __$CustomerOrderItemCopyWithImpl<$Res> + implements _$CustomerOrderItemCopyWith<$Res> { + __$CustomerOrderItemCopyWithImpl(this._self, this._then); + + final _CustomerOrderItem _self; + final $Res Function(_CustomerOrderItem) _then; + +/// Create a copy of CustomerOrderItem +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? productName = null,Object? variantName = freezed,Object? quantity = null,Object? weight = freezed,Object? unitName = freezed,Object? unitPrice = null,Object? totalPrice = null,Object? refundQuantity = null,}) { + return _then(_CustomerOrderItem( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,productName: null == productName ? _self.productName : productName // ignore: cast_nullable_to_non_nullable +as String,variantName: freezed == variantName ? _self.variantName : variantName // ignore: cast_nullable_to_non_nullable +as String?,quantity: null == quantity ? _self.quantity : quantity // ignore: cast_nullable_to_non_nullable +as int,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable +as double?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable +as String?,unitPrice: null == unitPrice ? _self.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable +as int,totalPrice: null == totalPrice ? _self.totalPrice : totalPrice // ignore: cast_nullable_to_non_nullable +as int,refundQuantity: null == refundQuantity ? _self.refundQuantity : refundQuantity // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc +mixin _$CustomerOrderPayment { + + String get id; String get methodName; String get methodType; int get amount; int get refundAmount;/// Hanya pada pembayaran EnakPoint. + int? get pointsUsed; +/// Create a copy of CustomerOrderPayment +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderPaymentCopyWith get copyWith => _$CustomerOrderPaymentCopyWithImpl(this as CustomerOrderPayment, _$identity); + + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrderPayment; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrderPayment&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.methodName, _this.methodName) || other.methodName == _this.methodName)&&(identical(other.methodType, _this.methodType) || other.methodType == _this.methodType)&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.refundAmount, _this.refundAmount) || other.refundAmount == _this.refundAmount)&&(identical(other.pointsUsed, _this.pointsUsed) || other.pointsUsed == _this.pointsUsed)); +} + + +@override +int get hashCode { + final _this = this as CustomerOrderPayment; + return Object.hash(runtimeType,_this.id,_this.methodName,_this.methodType,_this.amount,_this.refundAmount,_this.pointsUsed); +} + +@override +String toString() { + final _this = this as CustomerOrderPayment; + return 'CustomerOrderPayment(id: ${_this.id}, methodName: ${_this.methodName}, methodType: ${_this.methodType}, amount: ${_this.amount}, refundAmount: ${_this.refundAmount}, pointsUsed: ${_this.pointsUsed})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderPaymentCopyWith<$Res> { + factory $CustomerOrderPaymentCopyWith(CustomerOrderPayment value, $Res Function(CustomerOrderPayment) _then) = _$CustomerOrderPaymentCopyWithImpl; +@useResult +$Res call({ + String id, String methodName, String methodType, int amount, int refundAmount, int? pointsUsed +}); + + + + +} +/// @nodoc +class _$CustomerOrderPaymentCopyWithImpl<$Res> + implements $CustomerOrderPaymentCopyWith<$Res> { + _$CustomerOrderPaymentCopyWithImpl(this._self, this._then); + + final CustomerOrderPayment _self; + final $Res Function(CustomerOrderPayment) _then; + +/// Create a copy of CustomerOrderPayment +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? methodName = null,Object? methodType = null,Object? amount = null,Object? refundAmount = null,Object? pointsUsed = freezed,}) { + return _then(CustomerOrderPayment( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,methodName: null == methodName ? _self.methodName : methodName // ignore: cast_nullable_to_non_nullable +as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable +as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,refundAmount: null == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int,pointsUsed: freezed == pointsUsed ? _self.pointsUsed : pointsUsed // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CustomerOrderPayment]. +extension CustomerOrderPaymentPatterns on CustomerOrderPayment { +/// 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( _CustomerOrderPayment value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrderPayment() 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( _CustomerOrderPayment value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderPayment(): +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( _CustomerOrderPayment value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderPayment() 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 methodName, String methodType, int amount, int refundAmount, int? pointsUsed)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrderPayment() when $default != null: +return $default(_that.id,_that.methodName,_that.methodType,_that.amount,_that.refundAmount,_that.pointsUsed);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 methodName, String methodType, int amount, int refundAmount, int? pointsUsed) $default,) {final _that = this; +switch (_that) { +case _CustomerOrderPayment(): +return $default(_that.id,_that.methodName,_that.methodType,_that.amount,_that.refundAmount,_that.pointsUsed);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 methodName, String methodType, int amount, int refundAmount, int? pointsUsed)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrderPayment() when $default != null: +return $default(_that.id,_that.methodName,_that.methodType,_that.amount,_that.refundAmount,_that.pointsUsed);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _CustomerOrderPayment extends CustomerOrderPayment { + const _CustomerOrderPayment({required this.id, required this.methodName, required this.methodType, required this.amount, required this.refundAmount, this.pointsUsed}): super._(); + + +@override final String id; +@override final String methodName; +@override final String methodType; +@override final int amount; +@override final int refundAmount; +/// Hanya pada pembayaran EnakPoint. +@override final int? pointsUsed; + +/// Create a copy of CustomerOrderPayment +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderPaymentCopyWith<_CustomerOrderPayment> get copyWith => __$CustomerOrderPaymentCopyWithImpl<_CustomerOrderPayment>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrderPayment&&(identical(other.id, id) || other.id == id)&&(identical(other.methodName, methodName) || other.methodName == methodName)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.refundAmount, refundAmount) || other.refundAmount == refundAmount)&&(identical(other.pointsUsed, pointsUsed) || other.pointsUsed == pointsUsed)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,id,methodName,methodType,amount,refundAmount,pointsUsed); +} + +@override +String toString() { + return 'CustomerOrderPayment(id: $id, methodName: $methodName, methodType: $methodType, amount: $amount, refundAmount: $refundAmount, pointsUsed: $pointsUsed)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderPaymentCopyWith<$Res> implements $CustomerOrderPaymentCopyWith<$Res> { + factory _$CustomerOrderPaymentCopyWith(_CustomerOrderPayment value, $Res Function(_CustomerOrderPayment) _then) = __$CustomerOrderPaymentCopyWithImpl; +@override @useResult +$Res call({ + String id, String methodName, String methodType, int amount, int refundAmount, int? pointsUsed +}); + + + + +} +/// @nodoc +class __$CustomerOrderPaymentCopyWithImpl<$Res> + implements _$CustomerOrderPaymentCopyWith<$Res> { + __$CustomerOrderPaymentCopyWithImpl(this._self, this._then); + + final _CustomerOrderPayment _self; + final $Res Function(_CustomerOrderPayment) _then; + +/// Create a copy of CustomerOrderPayment +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? methodName = null,Object? methodType = null,Object? amount = null,Object? refundAmount = null,Object? pointsUsed = freezed,}) { + return _then(_CustomerOrderPayment( +id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String,methodName: null == methodName ? _self.methodName : methodName // ignore: cast_nullable_to_non_nullable +as String,methodType: null == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable +as String,amount: null == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int,refundAmount: null == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int,pointsUsed: freezed == pointsUsed ? _self.pointsUsed : pointsUsed // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +/// @nodoc +mixin _$WalletFailure { + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletFailure); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletFailure()'; +} + + +} + +/// @nodoc +class $WalletFailureCopyWith<$Res> { +$WalletFailureCopyWith(WalletFailure _, $Res Function(WalletFailure) __); +} + + +/// Adds pattern-matching-related methods to [WalletFailure]. +extension WalletFailurePatterns on WalletFailure { +/// 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( _ServerError value)? serverError,TResult Function( _UnexpectedError value)? unexpectedError,TResult Function( _Unauthorized value)? unauthorized,TResult Function( _InvalidRequest value)? invalidRequest,TResult Function( _Rejected value)? rejected,TResult Function( _NotFound value)? notFound,TResult Function( _TooManyRequests value)? tooManyRequests,TResult Function( _InternalError value)? internalError,TResult Function( _PinNotSet value)? pinNotSet,TResult Function( _PinInvalid value)? pinInvalid,TResult Function( _PinLocked value)? pinLocked,TResult Function( _TransferBlocked value)? transferBlocked,required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _Unauthorized() when unauthorized != null: +return unauthorized(_that);case _InvalidRequest() when invalidRequest != null: +return invalidRequest(_that);case _Rejected() when rejected != null: +return rejected(_that);case _NotFound() when notFound != null: +return notFound(_that);case _TooManyRequests() when tooManyRequests != null: +return tooManyRequests(_that);case _InternalError() when internalError != null: +return internalError(_that);case _PinNotSet() when pinNotSet != null: +return pinNotSet(_that);case _PinInvalid() when pinInvalid != null: +return pinInvalid(_that);case _PinLocked() when pinLocked != null: +return pinLocked(_that);case _TransferBlocked() when transferBlocked != null: +return transferBlocked(_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({required TResult Function( _ServerError value) serverError,required TResult Function( _UnexpectedError value) unexpectedError,required TResult Function( _Unauthorized value) unauthorized,required TResult Function( _InvalidRequest value) invalidRequest,required TResult Function( _Rejected value) rejected,required TResult Function( _NotFound value) notFound,required TResult Function( _TooManyRequests value) tooManyRequests,required TResult Function( _InternalError value) internalError,required TResult Function( _PinNotSet value) pinNotSet,required TResult Function( _PinInvalid value) pinInvalid,required TResult Function( _PinLocked value) pinLocked,required TResult Function( _TransferBlocked value) transferBlocked,}){ +final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that);case _UnexpectedError(): +return unexpectedError(_that);case _Unauthorized(): +return unauthorized(_that);case _InvalidRequest(): +return invalidRequest(_that);case _Rejected(): +return rejected(_that);case _NotFound(): +return notFound(_that);case _TooManyRequests(): +return tooManyRequests(_that);case _InternalError(): +return internalError(_that);case _PinNotSet(): +return pinNotSet(_that);case _PinInvalid(): +return pinInvalid(_that);case _PinLocked(): +return pinLocked(_that);case _TransferBlocked(): +return transferBlocked(_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( _ServerError value)? serverError,TResult? Function( _UnexpectedError value)? unexpectedError,TResult? Function( _Unauthorized value)? unauthorized,TResult? Function( _InvalidRequest value)? invalidRequest,TResult? Function( _Rejected value)? rejected,TResult? Function( _NotFound value)? notFound,TResult? Function( _TooManyRequests value)? tooManyRequests,TResult? Function( _InternalError value)? internalError,TResult? Function( _PinNotSet value)? pinNotSet,TResult? Function( _PinInvalid value)? pinInvalid,TResult? Function( _PinLocked value)? pinLocked,TResult? Function( _TransferBlocked value)? transferBlocked,}){ +final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that);case _UnexpectedError() when unexpectedError != null: +return unexpectedError(_that);case _Unauthorized() when unauthorized != null: +return unauthorized(_that);case _InvalidRequest() when invalidRequest != null: +return invalidRequest(_that);case _Rejected() when rejected != null: +return rejected(_that);case _NotFound() when notFound != null: +return notFound(_that);case _TooManyRequests() when tooManyRequests != null: +return tooManyRequests(_that);case _InternalError() when internalError != null: +return internalError(_that);case _PinNotSet() when pinNotSet != null: +return pinNotSet(_that);case _PinInvalid() when pinInvalid != null: +return pinInvalid(_that);case _PinLocked() when pinLocked != null: +return pinLocked(_that);case _TransferBlocked() when transferBlocked != null: +return transferBlocked(_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( ApiFailure failure)? serverError,TResult Function()? unexpectedError,TResult Function()? unauthorized,TResult Function()? invalidRequest,TResult Function( String cause)? rejected,TResult Function()? notFound,TResult Function( int retryAfterSeconds)? tooManyRequests,TResult Function()? internalError,TResult Function()? pinNotSet,TResult Function( int? remainingAttempts)? pinInvalid,TResult Function( DateTime? lockedUntil)? pinLocked,TResult Function( DateTime? transferBlockedUntil)? transferBlocked,required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.failure);case _UnexpectedError() when unexpectedError != null: +return unexpectedError();case _Unauthorized() when unauthorized != null: +return unauthorized();case _InvalidRequest() when invalidRequest != null: +return invalidRequest();case _Rejected() when rejected != null: +return rejected(_that.cause);case _NotFound() when notFound != null: +return notFound();case _TooManyRequests() when tooManyRequests != null: +return tooManyRequests(_that.retryAfterSeconds);case _InternalError() when internalError != null: +return internalError();case _PinNotSet() when pinNotSet != null: +return pinNotSet();case _PinInvalid() when pinInvalid != null: +return pinInvalid(_that.remainingAttempts);case _PinLocked() when pinLocked != null: +return pinLocked(_that.lockedUntil);case _TransferBlocked() when transferBlocked != null: +return transferBlocked(_that.transferBlockedUntil);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({required TResult Function( ApiFailure failure) serverError,required TResult Function() unexpectedError,required TResult Function() unauthorized,required TResult Function() invalidRequest,required TResult Function( String cause) rejected,required TResult Function() notFound,required TResult Function( int retryAfterSeconds) tooManyRequests,required TResult Function() internalError,required TResult Function() pinNotSet,required TResult Function( int? remainingAttempts) pinInvalid,required TResult Function( DateTime? lockedUntil) pinLocked,required TResult Function( DateTime? transferBlockedUntil) transferBlocked,}) {final _that = this; +switch (_that) { +case _ServerError(): +return serverError(_that.failure);case _UnexpectedError(): +return unexpectedError();case _Unauthorized(): +return unauthorized();case _InvalidRequest(): +return invalidRequest();case _Rejected(): +return rejected(_that.cause);case _NotFound(): +return notFound();case _TooManyRequests(): +return tooManyRequests(_that.retryAfterSeconds);case _InternalError(): +return internalError();case _PinNotSet(): +return pinNotSet();case _PinInvalid(): +return pinInvalid(_that.remainingAttempts);case _PinLocked(): +return pinLocked(_that.lockedUntil);case _TransferBlocked(): +return transferBlocked(_that.transferBlockedUntil);} +} +/// 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( ApiFailure failure)? serverError,TResult? Function()? unexpectedError,TResult? Function()? unauthorized,TResult? Function()? invalidRequest,TResult? Function( String cause)? rejected,TResult? Function()? notFound,TResult? Function( int retryAfterSeconds)? tooManyRequests,TResult? Function()? internalError,TResult? Function()? pinNotSet,TResult? Function( int? remainingAttempts)? pinInvalid,TResult? Function( DateTime? lockedUntil)? pinLocked,TResult? Function( DateTime? transferBlockedUntil)? transferBlocked,}) {final _that = this; +switch (_that) { +case _ServerError() when serverError != null: +return serverError(_that.failure);case _UnexpectedError() when unexpectedError != null: +return unexpectedError();case _Unauthorized() when unauthorized != null: +return unauthorized();case _InvalidRequest() when invalidRequest != null: +return invalidRequest();case _Rejected() when rejected != null: +return rejected(_that.cause);case _NotFound() when notFound != null: +return notFound();case _TooManyRequests() when tooManyRequests != null: +return tooManyRequests(_that.retryAfterSeconds);case _InternalError() when internalError != null: +return internalError();case _PinNotSet() when pinNotSet != null: +return pinNotSet();case _PinInvalid() when pinInvalid != null: +return pinInvalid(_that.remainingAttempts);case _PinLocked() when pinLocked != null: +return pinLocked(_that.lockedUntil);case _TransferBlocked() when transferBlocked != null: +return transferBlocked(_that.transferBlockedUntil);case _: + return null; + +} +} + +} + +/// @nodoc + + +class _ServerError extends WalletFailure { + const _ServerError(this.failure): super._(); + + + final ApiFailure failure; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ServerErrorCopyWith<_ServerError> get copyWith => __$ServerErrorCopyWithImpl<_ServerError>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ServerError&&(identical(other.failure, failure) || other.failure == failure)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,failure); +} + +@override +String toString() { + return 'WalletFailure.serverError(failure: $failure)'; +} + + +} + +/// @nodoc +abstract mixin class _$ServerErrorCopyWith<$Res> implements $WalletFailureCopyWith<$Res> { + factory _$ServerErrorCopyWith(_ServerError value, $Res Function(_ServerError) _then) = __$ServerErrorCopyWithImpl; +@useResult +$Res call({ + ApiFailure failure +}); + + +$ApiFailureCopyWith<$Res> get failure; + +} +/// @nodoc +class __$ServerErrorCopyWithImpl<$Res> + implements _$ServerErrorCopyWith<$Res> { + __$ServerErrorCopyWithImpl(this._self, this._then); + + final _ServerError _self; + final $Res Function(_ServerError) _then; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? failure = null,}) { + return _then(_ServerError( +null == failure ? _self.failure : failure // ignore: cast_nullable_to_non_nullable +as ApiFailure, + )); +} + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ApiFailureCopyWith<$Res> get failure { + + return $ApiFailureCopyWith<$Res>(_self.failure, (value) { + return _then(_self.copyWith(failure: value)); + }); +} +} + +/// @nodoc + + +class _UnexpectedError extends WalletFailure { + const _UnexpectedError(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _UnexpectedError); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletFailure.unexpectedError()'; +} + + +} + + + + +/// @nodoc + + +class _Unauthorized extends WalletFailure { + const _Unauthorized(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Unauthorized); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletFailure.unauthorized()'; +} + + +} + + + + +/// @nodoc + + +class _InvalidRequest extends WalletFailure { + const _InvalidRequest(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _InvalidRequest); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletFailure.invalidRequest()'; +} + + +} + + + + +/// @nodoc + + +class _Rejected extends WalletFailure { + const _Rejected(this.cause): super._(); + + + final String cause; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RejectedCopyWith<_Rejected> get copyWith => __$RejectedCopyWithImpl<_Rejected>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Rejected&&(identical(other.cause, cause) || other.cause == cause)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,cause); +} + +@override +String toString() { + return 'WalletFailure.rejected(cause: $cause)'; +} + + +} + +/// @nodoc +abstract mixin class _$RejectedCopyWith<$Res> implements $WalletFailureCopyWith<$Res> { + factory _$RejectedCopyWith(_Rejected value, $Res Function(_Rejected) _then) = __$RejectedCopyWithImpl; +@useResult +$Res call({ + String cause +}); + + + + +} +/// @nodoc +class __$RejectedCopyWithImpl<$Res> + implements _$RejectedCopyWith<$Res> { + __$RejectedCopyWithImpl(this._self, this._then); + + final _Rejected _self; + final $Res Function(_Rejected) _then; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? cause = null,}) { + return _then(_Rejected( +null == cause ? _self.cause : cause // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + +} + +/// @nodoc + + +class _NotFound extends WalletFailure { + const _NotFound(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NotFound); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletFailure.notFound()'; +} + + +} + + + + +/// @nodoc + + +class _TooManyRequests extends WalletFailure { + const _TooManyRequests(this.retryAfterSeconds): super._(); + + + final int retryAfterSeconds; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TooManyRequestsCopyWith<_TooManyRequests> get copyWith => __$TooManyRequestsCopyWithImpl<_TooManyRequests>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TooManyRequests&&(identical(other.retryAfterSeconds, retryAfterSeconds) || other.retryAfterSeconds == retryAfterSeconds)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,retryAfterSeconds); +} + +@override +String toString() { + return 'WalletFailure.tooManyRequests(retryAfterSeconds: $retryAfterSeconds)'; +} + + +} + +/// @nodoc +abstract mixin class _$TooManyRequestsCopyWith<$Res> implements $WalletFailureCopyWith<$Res> { + factory _$TooManyRequestsCopyWith(_TooManyRequests value, $Res Function(_TooManyRequests) _then) = __$TooManyRequestsCopyWithImpl; +@useResult +$Res call({ + int retryAfterSeconds +}); + + + + +} +/// @nodoc +class __$TooManyRequestsCopyWithImpl<$Res> + implements _$TooManyRequestsCopyWith<$Res> { + __$TooManyRequestsCopyWithImpl(this._self, this._then); + + final _TooManyRequests _self; + final $Res Function(_TooManyRequests) _then; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? retryAfterSeconds = null,}) { + return _then(_TooManyRequests( +null == retryAfterSeconds ? _self.retryAfterSeconds : retryAfterSeconds // ignore: cast_nullable_to_non_nullable +as int, + )); +} + + +} + +/// @nodoc + + +class _InternalError extends WalletFailure { + const _InternalError(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _InternalError); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletFailure.internalError()'; +} + + +} + + + + +/// @nodoc + + +class _PinNotSet extends WalletFailure { + const _PinNotSet(): super._(); + + + + + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinNotSet); +} + + +@override +int get hashCode => runtimeType.hashCode; + +@override +String toString() { + return 'WalletFailure.pinNotSet()'; +} + + +} + + + + +/// @nodoc + + +class _PinInvalid extends WalletFailure { + const _PinInvalid(this.remainingAttempts): super._(); + + + final int? remainingAttempts; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinInvalidCopyWith<_PinInvalid> get copyWith => __$PinInvalidCopyWithImpl<_PinInvalid>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinInvalid&&(identical(other.remainingAttempts, remainingAttempts) || other.remainingAttempts == remainingAttempts)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,remainingAttempts); +} + +@override +String toString() { + return 'WalletFailure.pinInvalid(remainingAttempts: $remainingAttempts)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinInvalidCopyWith<$Res> implements $WalletFailureCopyWith<$Res> { + factory _$PinInvalidCopyWith(_PinInvalid value, $Res Function(_PinInvalid) _then) = __$PinInvalidCopyWithImpl; +@useResult +$Res call({ + int? remainingAttempts +}); + + + + +} +/// @nodoc +class __$PinInvalidCopyWithImpl<$Res> + implements _$PinInvalidCopyWith<$Res> { + __$PinInvalidCopyWithImpl(this._self, this._then); + + final _PinInvalid _self; + final $Res Function(_PinInvalid) _then; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? remainingAttempts = freezed,}) { + return _then(_PinInvalid( +freezed == remainingAttempts ? _self.remainingAttempts : remainingAttempts // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +/// @nodoc + + +class _PinLocked extends WalletFailure { + const _PinLocked(this.lockedUntil): super._(); + + + final DateTime? lockedUntil; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinLockedCopyWith<_PinLocked> get copyWith => __$PinLockedCopyWithImpl<_PinLocked>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinLocked&&(identical(other.lockedUntil, lockedUntil) || other.lockedUntil == lockedUntil)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,lockedUntil); +} + +@override +String toString() { + return 'WalletFailure.pinLocked(lockedUntil: $lockedUntil)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinLockedCopyWith<$Res> implements $WalletFailureCopyWith<$Res> { + factory _$PinLockedCopyWith(_PinLocked value, $Res Function(_PinLocked) _then) = __$PinLockedCopyWithImpl; +@useResult +$Res call({ + DateTime? lockedUntil +}); + + + + +} +/// @nodoc +class __$PinLockedCopyWithImpl<$Res> + implements _$PinLockedCopyWith<$Res> { + __$PinLockedCopyWithImpl(this._self, this._then); + + final _PinLocked _self; + final $Res Function(_PinLocked) _then; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? lockedUntil = freezed,}) { + return _then(_PinLocked( +freezed == lockedUntil ? _self.lockedUntil : lockedUntil // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +/// @nodoc + + +class _TransferBlocked extends WalletFailure { + const _TransferBlocked(this.transferBlockedUntil): super._(); + + + final DateTime? transferBlockedUntil; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TransferBlockedCopyWith<_TransferBlocked> get copyWith => __$TransferBlockedCopyWithImpl<_TransferBlocked>(this, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TransferBlocked&&(identical(other.transferBlockedUntil, transferBlockedUntil) || other.transferBlockedUntil == transferBlockedUntil)); +} + + +@override +int get hashCode { + return Object.hash(runtimeType,transferBlockedUntil); +} + +@override +String toString() { + return 'WalletFailure.transferBlocked(transferBlockedUntil: $transferBlockedUntil)'; +} + + +} + +/// @nodoc +abstract mixin class _$TransferBlockedCopyWith<$Res> implements $WalletFailureCopyWith<$Res> { + factory _$TransferBlockedCopyWith(_TransferBlocked value, $Res Function(_TransferBlocked) _then) = __$TransferBlockedCopyWithImpl; +@useResult +$Res call({ + DateTime? transferBlockedUntil +}); + + + + +} +/// @nodoc +class __$TransferBlockedCopyWithImpl<$Res> + implements _$TransferBlockedCopyWith<$Res> { + __$TransferBlockedCopyWithImpl(this._self, this._then); + + final _TransferBlocked _self; + final $Res Function(_TransferBlocked) _then; + +/// Create a copy of WalletFailure +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') $Res call({Object? transferBlockedUntil = freezed,}) { + return _then(_TransferBlocked( +freezed == transferBlockedUntil ? _self.transferBlockedUntil : transferBlockedUntil // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +// dart format on diff --git a/lib/env.dart b/lib/env.dart index d6c9035..813eb6f 100644 --- a/lib/env.dart +++ b/lib/env.dart @@ -9,13 +9,13 @@ abstract class Env { @dev class DevEnv implements Env { @override - // String get baseUrl => 'http://192.168.1.30:4000'; // example value - String get baseUrl => 'https://api-pos.apskel.id'; // example value + // String get baseUrl => 'http://192.168.1.5:4000'; // example value + String get baseUrl => 'https://enaklo-pos-api.altru.id'; // example value } @Injectable(as: Env) @prod class ProdEnv implements Env { @override - String get baseUrl => 'https://api-pos.apskel.id'; + String get baseUrl => 'https://enaklo-pos-api.altru.id'; } diff --git a/lib/infrastructure/auth/auth_dtos.freezed.dart b/lib/infrastructure/auth/auth_dtos.freezed.dart index 98d1193..dd509d9 100644 --- a/lib/infrastructure/auth/auth_dtos.freezed.dart +++ b/lib/infrastructure/auth/auth_dtos.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'auth_dtos.dart'; @@ -9,2385 +9,3178 @@ part of 'auth_dtos.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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', -); - -CheckPhoneDto _$CheckPhoneDtoFromJson(Map json) { - return _CheckPhoneDto.fromJson(json); -} - /// @nodoc mixin _$CheckPhoneDto { - @JsonKey(name: 'status') - String? get status => throw _privateConstructorUsedError; - @JsonKey(name: 'message') - String? get message => throw _privateConstructorUsedError; - @JsonKey(name: 'data') - CheckPhoneDataDto? get data => throw _privateConstructorUsedError; + +@JsonKey(name: 'status') String? get status;@JsonKey(name: 'message') String? get message;@JsonKey(name: 'data') CheckPhoneDataDto? get data; +/// Create a copy of CheckPhoneDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CheckPhoneDtoCopyWith get copyWith => _$CheckPhoneDtoCopyWithImpl(this as CheckPhoneDto, _$identity); /// Serializes this CheckPhoneDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as CheckPhoneDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CheckPhoneDto&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.data, _this.data) || other.data == _this.data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as CheckPhoneDto; + return Object.hash(runtimeType,_this.status,_this.message,_this.data); +} + +@override +String toString() { + final _this = this as CheckPhoneDto; + return 'CheckPhoneDto(status: ${_this.status}, message: ${_this.message}, data: ${_this.data})'; +} + - /// Create a copy of CheckPhoneDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CheckPhoneDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $CheckPhoneDtoCopyWith<$Res> { - factory $CheckPhoneDtoCopyWith( - CheckPhoneDto value, - $Res Function(CheckPhoneDto) then, - ) = _$CheckPhoneDtoCopyWithImpl<$Res, CheckPhoneDto>; - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') CheckPhoneDataDto? data, - }); +abstract mixin class $CheckPhoneDtoCopyWith<$Res> { + factory $CheckPhoneDtoCopyWith(CheckPhoneDto value, $Res Function(CheckPhoneDto) _then) = _$CheckPhoneDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') CheckPhoneDataDto? data +}); + + +$CheckPhoneDataDtoCopyWith<$Res>? get data; - $CheckPhoneDataDtoCopyWith<$Res>? get data; } - /// @nodoc -class _$CheckPhoneDtoCopyWithImpl<$Res, $Val extends CheckPhoneDto> +class _$CheckPhoneDtoCopyWithImpl<$Res> implements $CheckPhoneDtoCopyWith<$Res> { - _$CheckPhoneDtoCopyWithImpl(this._value, this._then); + _$CheckPhoneDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final CheckPhoneDto _self; + final $Res Function(CheckPhoneDto) _then; - /// Create a copy of CheckPhoneDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _value.copyWith( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as CheckPhoneDataDto?, - ) - as $Val, - ); - } - - /// Create a copy of CheckPhoneDto - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $CheckPhoneDataDtoCopyWith<$Res>? get data { - if (_value.data == null) { - return null; - } - - return $CheckPhoneDataDtoCopyWith<$Res>(_value.data!, (value) { - return _then(_value.copyWith(data: value) as $Val); - }); - } +/// Create a copy of CheckPhoneDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(CheckPhoneDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as CheckPhoneDataDto?, + )); } +/// Create a copy of CheckPhoneDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CheckPhoneDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } -/// @nodoc -abstract class _$$CheckPhoneDtoImplCopyWith<$Res> - implements $CheckPhoneDtoCopyWith<$Res> { - factory _$$CheckPhoneDtoImplCopyWith( - _$CheckPhoneDtoImpl value, - $Res Function(_$CheckPhoneDtoImpl) then, - ) = __$$CheckPhoneDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') CheckPhoneDataDto? data, + return $CheckPhoneDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); }); - - @override - $CheckPhoneDataDtoCopyWith<$Res>? get data; +} } -/// @nodoc -class __$$CheckPhoneDtoImplCopyWithImpl<$Res> - extends _$CheckPhoneDtoCopyWithImpl<$Res, _$CheckPhoneDtoImpl> - implements _$$CheckPhoneDtoImplCopyWith<$Res> { - __$$CheckPhoneDtoImplCopyWithImpl( - _$CheckPhoneDtoImpl _value, - $Res Function(_$CheckPhoneDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of CheckPhoneDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _$CheckPhoneDtoImpl( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as CheckPhoneDataDto?, - ), - ); - } +/// Adds pattern-matching-related methods to [CheckPhoneDto]. +extension CheckPhoneDtoPatterns on CheckPhoneDto { +/// 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( _CheckPhoneDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CheckPhoneDto() 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( _CheckPhoneDto value) $default,){ +final _that = this; +switch (_that) { +case _CheckPhoneDto(): +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( _CheckPhoneDto value)? $default,){ +final _that = this; +switch (_that) { +case _CheckPhoneDto() 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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') CheckPhoneDataDto? data)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CheckPhoneDto() when $default != null: +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') CheckPhoneDataDto? data) $default,) {final _that = this; +switch (_that) { +case _CheckPhoneDto(): +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') CheckPhoneDataDto? data)? $default,) {final _that = this; +switch (_that) { +case _CheckPhoneDto() when $default != null: +return $default(_that.status,_that.message,_that.data);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$CheckPhoneDtoImpl extends _CheckPhoneDto { - const _$CheckPhoneDtoImpl({ - @JsonKey(name: 'status') this.status, - @JsonKey(name: 'message') this.message, - @JsonKey(name: 'data') this.data, - }) : super._(); - factory _$CheckPhoneDtoImpl.fromJson(Map json) => - _$$CheckPhoneDtoImplFromJson(json); +class _CheckPhoneDto extends CheckPhoneDto { + const _CheckPhoneDto({@JsonKey(name: 'status') this.status, @JsonKey(name: 'message') this.message, @JsonKey(name: 'data') this.data}): super._(); + factory _CheckPhoneDto.fromJson(Map json) => _$CheckPhoneDtoFromJson(json); - @override - @JsonKey(name: 'status') - final String? status; - @override - @JsonKey(name: 'message') - final String? message; - @override - @JsonKey(name: 'data') - final CheckPhoneDataDto? data; +@override@JsonKey(name: 'status') final String? status; +@override@JsonKey(name: 'message') final String? message; +@override@JsonKey(name: 'data') final CheckPhoneDataDto? data; - @override - String toString() { +/// Create a copy of CheckPhoneDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CheckPhoneDtoCopyWith<_CheckPhoneDto> get copyWith => __$CheckPhoneDtoCopyWithImpl<_CheckPhoneDto>(this, _$identity); + +@override +Map toJson() { + return _$CheckPhoneDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CheckPhoneDto&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,status,message,data); +} + +@override +String toString() { return 'CheckPhoneDto(status: $status, message: $message, data: $data)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CheckPhoneDtoImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.data, data) || other.data == data)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, status, message, data); - - /// Create a copy of CheckPhoneDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CheckPhoneDtoImplCopyWith<_$CheckPhoneDtoImpl> get copyWith => - __$$CheckPhoneDtoImplCopyWithImpl<_$CheckPhoneDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$CheckPhoneDtoImplToJson(this); - } } -abstract class _CheckPhoneDto extends CheckPhoneDto { - const factory _CheckPhoneDto({ - @JsonKey(name: 'status') final String? status, - @JsonKey(name: 'message') final String? message, - @JsonKey(name: 'data') final CheckPhoneDataDto? data, - }) = _$CheckPhoneDtoImpl; - const _CheckPhoneDto._() : super._(); - factory _CheckPhoneDto.fromJson(Map json) = - _$CheckPhoneDtoImpl.fromJson; - - @override - @JsonKey(name: 'status') - String? get status; - @override - @JsonKey(name: 'message') - String? get message; - @override - @JsonKey(name: 'data') - CheckPhoneDataDto? get data; - - /// Create a copy of CheckPhoneDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CheckPhoneDtoImplCopyWith<_$CheckPhoneDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -CheckPhoneDataDto _$CheckPhoneDataDtoFromJson(Map json) { - return _CheckPhoneDataDto.fromJson(json); +/// @nodoc +abstract mixin class _$CheckPhoneDtoCopyWith<$Res> implements $CheckPhoneDtoCopyWith<$Res> { + factory _$CheckPhoneDtoCopyWith(_CheckPhoneDto value, $Res Function(_CheckPhoneDto) _then) = __$CheckPhoneDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') CheckPhoneDataDto? data +}); + + +@override $CheckPhoneDataDtoCopyWith<$Res>? get data; + } +/// @nodoc +class __$CheckPhoneDtoCopyWithImpl<$Res> + implements _$CheckPhoneDtoCopyWith<$Res> { + __$CheckPhoneDtoCopyWithImpl(this._self, this._then); + + final _CheckPhoneDto _self; + final $Res Function(_CheckPhoneDto) _then; + +/// Create a copy of CheckPhoneDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(_CheckPhoneDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as CheckPhoneDataDto?, + )); +} + +/// Create a copy of CheckPhoneDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$CheckPhoneDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + + return $CheckPhoneDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + /// @nodoc mixin _$CheckPhoneDataDto { - @JsonKey(name: 'phone_number') - String? get phoneNumber => throw _privateConstructorUsedError; + +@JsonKey(name: 'phone_number') String? get phoneNumber; +/// Create a copy of CheckPhoneDataDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CheckPhoneDataDtoCopyWith get copyWith => _$CheckPhoneDataDtoCopyWithImpl(this as CheckPhoneDataDto, _$identity); /// Serializes this CheckPhoneDataDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as CheckPhoneDataDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CheckPhoneDataDto&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as CheckPhoneDataDto; + return Object.hash(runtimeType,_this.phoneNumber); +} + +@override +String toString() { + final _this = this as CheckPhoneDataDto; + return 'CheckPhoneDataDto(phoneNumber: ${_this.phoneNumber})'; +} + - /// Create a copy of CheckPhoneDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CheckPhoneDataDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $CheckPhoneDataDtoCopyWith<$Res> { - factory $CheckPhoneDataDtoCopyWith( - CheckPhoneDataDto value, - $Res Function(CheckPhoneDataDto) then, - ) = _$CheckPhoneDataDtoCopyWithImpl<$Res, CheckPhoneDataDto>; - @useResult - $Res call({@JsonKey(name: 'phone_number') String? phoneNumber}); -} +abstract mixin class $CheckPhoneDataDtoCopyWith<$Res> { + factory $CheckPhoneDataDtoCopyWith(CheckPhoneDataDto value, $Res Function(CheckPhoneDataDto) _then) = _$CheckPhoneDataDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'phone_number') String? phoneNumber +}); + + + +} /// @nodoc -class _$CheckPhoneDataDtoCopyWithImpl<$Res, $Val extends CheckPhoneDataDto> +class _$CheckPhoneDataDtoCopyWithImpl<$Res> implements $CheckPhoneDataDtoCopyWith<$Res> { - _$CheckPhoneDataDtoCopyWithImpl(this._value, this._then); + _$CheckPhoneDataDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final CheckPhoneDataDto _self; + final $Res Function(CheckPhoneDataDto) _then; - /// Create a copy of CheckPhoneDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? phoneNumber = freezed}) { - return _then( - _value.copyWith( - phoneNumber: freezed == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } +/// Create a copy of CheckPhoneDataDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? phoneNumber = freezed,}) { + return _then(CheckPhoneDataDto( +phoneNumber: freezed == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$CheckPhoneDataDtoImplCopyWith<$Res> - implements $CheckPhoneDataDtoCopyWith<$Res> { - factory _$$CheckPhoneDataDtoImplCopyWith( - _$CheckPhoneDataDtoImpl value, - $Res Function(_$CheckPhoneDataDtoImpl) then, - ) = __$$CheckPhoneDataDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({@JsonKey(name: 'phone_number') String? phoneNumber}); } -/// @nodoc -class __$$CheckPhoneDataDtoImplCopyWithImpl<$Res> - extends _$CheckPhoneDataDtoCopyWithImpl<$Res, _$CheckPhoneDataDtoImpl> - implements _$$CheckPhoneDataDtoImplCopyWith<$Res> { - __$$CheckPhoneDataDtoImplCopyWithImpl( - _$CheckPhoneDataDtoImpl _value, - $Res Function(_$CheckPhoneDataDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of CheckPhoneDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? phoneNumber = freezed}) { - return _then( - _$CheckPhoneDataDtoImpl( - phoneNumber: freezed == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } +/// Adds pattern-matching-related methods to [CheckPhoneDataDto]. +extension CheckPhoneDataDtoPatterns on CheckPhoneDataDto { +/// 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( _CheckPhoneDataDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CheckPhoneDataDto() 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( _CheckPhoneDataDto value) $default,){ +final _that = this; +switch (_that) { +case _CheckPhoneDataDto(): +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( _CheckPhoneDataDto value)? $default,){ +final _that = this; +switch (_that) { +case _CheckPhoneDataDto() 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(@JsonKey(name: 'phone_number') String? phoneNumber)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CheckPhoneDataDto() when $default != null: +return $default(_that.phoneNumber);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(@JsonKey(name: 'phone_number') String? phoneNumber) $default,) {final _that = this; +switch (_that) { +case _CheckPhoneDataDto(): +return $default(_that.phoneNumber);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(@JsonKey(name: 'phone_number') String? phoneNumber)? $default,) {final _that = this; +switch (_that) { +case _CheckPhoneDataDto() when $default != null: +return $default(_that.phoneNumber);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$CheckPhoneDataDtoImpl implements _CheckPhoneDataDto { - const _$CheckPhoneDataDtoImpl({ - @JsonKey(name: 'phone_number') this.phoneNumber, - }); - factory _$CheckPhoneDataDtoImpl.fromJson(Map json) => - _$$CheckPhoneDataDtoImplFromJson(json); +class _CheckPhoneDataDto implements CheckPhoneDataDto { + const _CheckPhoneDataDto({@JsonKey(name: 'phone_number') this.phoneNumber}); + factory _CheckPhoneDataDto.fromJson(Map json) => _$CheckPhoneDataDtoFromJson(json); - @override - @JsonKey(name: 'phone_number') - final String? phoneNumber; +@override@JsonKey(name: 'phone_number') final String? phoneNumber; - @override - String toString() { +/// Create a copy of CheckPhoneDataDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CheckPhoneDataDtoCopyWith<_CheckPhoneDataDto> get copyWith => __$CheckPhoneDataDtoCopyWithImpl<_CheckPhoneDataDto>(this, _$identity); + +@override +Map toJson() { + return _$CheckPhoneDataDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CheckPhoneDataDto&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,phoneNumber); +} + +@override +String toString() { return 'CheckPhoneDataDto(phoneNumber: $phoneNumber)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CheckPhoneDataDtoImpl && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, phoneNumber); - - /// Create a copy of CheckPhoneDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CheckPhoneDataDtoImplCopyWith<_$CheckPhoneDataDtoImpl> get copyWith => - __$$CheckPhoneDataDtoImplCopyWithImpl<_$CheckPhoneDataDtoImpl>( - this, - _$identity, - ); - - @override - Map toJson() { - return _$$CheckPhoneDataDtoImplToJson(this); - } } -abstract class _CheckPhoneDataDto implements CheckPhoneDataDto { - const factory _CheckPhoneDataDto({ - @JsonKey(name: 'phone_number') final String? phoneNumber, - }) = _$CheckPhoneDataDtoImpl; - factory _CheckPhoneDataDto.fromJson(Map json) = - _$CheckPhoneDataDtoImpl.fromJson; - - @override - @JsonKey(name: 'phone_number') - String? get phoneNumber; - - /// Create a copy of CheckPhoneDataDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CheckPhoneDataDtoImplCopyWith<_$CheckPhoneDataDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -RegisterDto _$RegisterDtoFromJson(Map json) { - return _RegisterDto.fromJson(json); +/// @nodoc +abstract mixin class _$CheckPhoneDataDtoCopyWith<$Res> implements $CheckPhoneDataDtoCopyWith<$Res> { + factory _$CheckPhoneDataDtoCopyWith(_CheckPhoneDataDto value, $Res Function(_CheckPhoneDataDto) _then) = __$CheckPhoneDataDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'phone_number') String? phoneNumber +}); + + + + } +/// @nodoc +class __$CheckPhoneDataDtoCopyWithImpl<$Res> + implements _$CheckPhoneDataDtoCopyWith<$Res> { + __$CheckPhoneDataDtoCopyWithImpl(this._self, this._then); + + final _CheckPhoneDataDto _self; + final $Res Function(_CheckPhoneDataDto) _then; + +/// Create a copy of CheckPhoneDataDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? phoneNumber = freezed,}) { + return _then(_CheckPhoneDataDto( +phoneNumber: freezed == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + /// @nodoc mixin _$RegisterDto { - @JsonKey(name: 'status') - String? get status => throw _privateConstructorUsedError; - @JsonKey(name: 'message') - String? get message => throw _privateConstructorUsedError; - @JsonKey(name: 'data') - RegisterDataDto? get data => throw _privateConstructorUsedError; + +@JsonKey(name: 'status') String? get status;@JsonKey(name: 'message') String? get message;@JsonKey(name: 'data') RegisterDataDto? get data; +/// Create a copy of RegisterDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$RegisterDtoCopyWith get copyWith => _$RegisterDtoCopyWithImpl(this as RegisterDto, _$identity); /// Serializes this RegisterDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as RegisterDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterDto&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.data, _this.data) || other.data == _this.data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as RegisterDto; + return Object.hash(runtimeType,_this.status,_this.message,_this.data); +} + +@override +String toString() { + final _this = this as RegisterDto; + return 'RegisterDto(status: ${_this.status}, message: ${_this.message}, data: ${_this.data})'; +} + - /// Create a copy of RegisterDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $RegisterDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $RegisterDtoCopyWith<$Res> { - factory $RegisterDtoCopyWith( - RegisterDto value, - $Res Function(RegisterDto) then, - ) = _$RegisterDtoCopyWithImpl<$Res, RegisterDto>; - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') RegisterDataDto? data, - }); +abstract mixin class $RegisterDtoCopyWith<$Res> { + factory $RegisterDtoCopyWith(RegisterDto value, $Res Function(RegisterDto) _then) = _$RegisterDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') RegisterDataDto? data +}); + + +$RegisterDataDtoCopyWith<$Res>? get data; - $RegisterDataDtoCopyWith<$Res>? get data; } - /// @nodoc -class _$RegisterDtoCopyWithImpl<$Res, $Val extends RegisterDto> +class _$RegisterDtoCopyWithImpl<$Res> implements $RegisterDtoCopyWith<$Res> { - _$RegisterDtoCopyWithImpl(this._value, this._then); + _$RegisterDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final RegisterDto _self; + final $Res Function(RegisterDto) _then; - /// Create a copy of RegisterDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _value.copyWith( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as RegisterDataDto?, - ) - as $Val, - ); - } - - /// Create a copy of RegisterDto - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $RegisterDataDtoCopyWith<$Res>? get data { - if (_value.data == null) { - return null; - } - - return $RegisterDataDtoCopyWith<$Res>(_value.data!, (value) { - return _then(_value.copyWith(data: value) as $Val); - }); - } +/// Create a copy of RegisterDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(RegisterDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as RegisterDataDto?, + )); } +/// Create a copy of RegisterDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$RegisterDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } -/// @nodoc -abstract class _$$RegisterDtoImplCopyWith<$Res> - implements $RegisterDtoCopyWith<$Res> { - factory _$$RegisterDtoImplCopyWith( - _$RegisterDtoImpl value, - $Res Function(_$RegisterDtoImpl) then, - ) = __$$RegisterDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') RegisterDataDto? data, + return $RegisterDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); }); - - @override - $RegisterDataDtoCopyWith<$Res>? get data; +} } -/// @nodoc -class __$$RegisterDtoImplCopyWithImpl<$Res> - extends _$RegisterDtoCopyWithImpl<$Res, _$RegisterDtoImpl> - implements _$$RegisterDtoImplCopyWith<$Res> { - __$$RegisterDtoImplCopyWithImpl( - _$RegisterDtoImpl _value, - $Res Function(_$RegisterDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of RegisterDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _$RegisterDtoImpl( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as RegisterDataDto?, - ), - ); - } +/// Adds pattern-matching-related methods to [RegisterDto]. +extension RegisterDtoPatterns on RegisterDto { +/// 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( _RegisterDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _RegisterDto() 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( _RegisterDto value) $default,){ +final _that = this; +switch (_that) { +case _RegisterDto(): +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( _RegisterDto value)? $default,){ +final _that = this; +switch (_that) { +case _RegisterDto() 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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') RegisterDataDto? data)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _RegisterDto() when $default != null: +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') RegisterDataDto? data) $default,) {final _that = this; +switch (_that) { +case _RegisterDto(): +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') RegisterDataDto? data)? $default,) {final _that = this; +switch (_that) { +case _RegisterDto() when $default != null: +return $default(_that.status,_that.message,_that.data);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$RegisterDtoImpl extends _RegisterDto { - const _$RegisterDtoImpl({ - @JsonKey(name: 'status') this.status, - @JsonKey(name: 'message') this.message, - @JsonKey(name: 'data') this.data, - }) : super._(); - factory _$RegisterDtoImpl.fromJson(Map json) => - _$$RegisterDtoImplFromJson(json); +class _RegisterDto extends RegisterDto { + const _RegisterDto({@JsonKey(name: 'status') this.status, @JsonKey(name: 'message') this.message, @JsonKey(name: 'data') this.data}): super._(); + factory _RegisterDto.fromJson(Map json) => _$RegisterDtoFromJson(json); - @override - @JsonKey(name: 'status') - final String? status; - @override - @JsonKey(name: 'message') - final String? message; - @override - @JsonKey(name: 'data') - final RegisterDataDto? data; +@override@JsonKey(name: 'status') final String? status; +@override@JsonKey(name: 'message') final String? message; +@override@JsonKey(name: 'data') final RegisterDataDto? data; - @override - String toString() { +/// Create a copy of RegisterDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RegisterDtoCopyWith<_RegisterDto> get copyWith => __$RegisterDtoCopyWithImpl<_RegisterDto>(this, _$identity); + +@override +Map toJson() { + return _$RegisterDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _RegisterDto&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,status,message,data); +} + +@override +String toString() { return 'RegisterDto(status: $status, message: $message, data: $data)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RegisterDtoImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.data, data) || other.data == data)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, status, message, data); - - /// Create a copy of RegisterDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RegisterDtoImplCopyWith<_$RegisterDtoImpl> get copyWith => - __$$RegisterDtoImplCopyWithImpl<_$RegisterDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$RegisterDtoImplToJson(this); - } } -abstract class _RegisterDto extends RegisterDto { - const factory _RegisterDto({ - @JsonKey(name: 'status') final String? status, - @JsonKey(name: 'message') final String? message, - @JsonKey(name: 'data') final RegisterDataDto? data, - }) = _$RegisterDtoImpl; - const _RegisterDto._() : super._(); - factory _RegisterDto.fromJson(Map json) = - _$RegisterDtoImpl.fromJson; - - @override - @JsonKey(name: 'status') - String? get status; - @override - @JsonKey(name: 'message') - String? get message; - @override - @JsonKey(name: 'data') - RegisterDataDto? get data; - - /// Create a copy of RegisterDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RegisterDtoImplCopyWith<_$RegisterDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -RegisterDataDto _$RegisterDataDtoFromJson(Map json) { - return _RegisterDataDto.fromJson(json); +/// @nodoc +abstract mixin class _$RegisterDtoCopyWith<$Res> implements $RegisterDtoCopyWith<$Res> { + factory _$RegisterDtoCopyWith(_RegisterDto value, $Res Function(_RegisterDto) _then) = __$RegisterDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') RegisterDataDto? data +}); + + +@override $RegisterDataDtoCopyWith<$Res>? get data; + } +/// @nodoc +class __$RegisterDtoCopyWithImpl<$Res> + implements _$RegisterDtoCopyWith<$Res> { + __$RegisterDtoCopyWithImpl(this._self, this._then); + + final _RegisterDto _self; + final $Res Function(_RegisterDto) _then; + +/// Create a copy of RegisterDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(_RegisterDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as RegisterDataDto?, + )); +} + +/// Create a copy of RegisterDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$RegisterDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + + return $RegisterDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + /// @nodoc mixin _$RegisterDataDto { - @JsonKey(name: 'registration_token') - String? get registrationToken => throw _privateConstructorUsedError; - @JsonKey(name: 'otp_token') - String? get otpToken => throw _privateConstructorUsedError; - @JsonKey(name: 'expires_in') - int? get expiresIn => throw _privateConstructorUsedError; + +@JsonKey(name: 'registration_token') String? get registrationToken;@JsonKey(name: 'otp_token') String? get otpToken;@JsonKey(name: 'expires_in') int? get expiresIn; +/// Create a copy of RegisterDataDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$RegisterDataDtoCopyWith get copyWith => _$RegisterDataDtoCopyWithImpl(this as RegisterDataDto, _$identity); /// Serializes this RegisterDataDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as RegisterDataDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is RegisterDataDto&&(identical(other.registrationToken, _this.registrationToken) || other.registrationToken == _this.registrationToken)&&(identical(other.otpToken, _this.otpToken) || other.otpToken == _this.otpToken)&&(identical(other.expiresIn, _this.expiresIn) || other.expiresIn == _this.expiresIn)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as RegisterDataDto; + return Object.hash(runtimeType,_this.registrationToken,_this.otpToken,_this.expiresIn); +} + +@override +String toString() { + final _this = this as RegisterDataDto; + return 'RegisterDataDto(registrationToken: ${_this.registrationToken}, otpToken: ${_this.otpToken}, expiresIn: ${_this.expiresIn})'; +} + - /// Create a copy of RegisterDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $RegisterDataDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $RegisterDataDtoCopyWith<$Res> { - factory $RegisterDataDtoCopyWith( - RegisterDataDto value, - $Res Function(RegisterDataDto) then, - ) = _$RegisterDataDtoCopyWithImpl<$Res, RegisterDataDto>; - @useResult - $Res call({ - @JsonKey(name: 'registration_token') String? registrationToken, - @JsonKey(name: 'otp_token') String? otpToken, - @JsonKey(name: 'expires_in') int? expiresIn, - }); -} +abstract mixin class $RegisterDataDtoCopyWith<$Res> { + factory $RegisterDataDtoCopyWith(RegisterDataDto value, $Res Function(RegisterDataDto) _then) = _$RegisterDataDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'registration_token') String? registrationToken,@JsonKey(name: 'otp_token') String? otpToken,@JsonKey(name: 'expires_in') int? expiresIn +}); + + + +} /// @nodoc -class _$RegisterDataDtoCopyWithImpl<$Res, $Val extends RegisterDataDto> +class _$RegisterDataDtoCopyWithImpl<$Res> implements $RegisterDataDtoCopyWith<$Res> { - _$RegisterDataDtoCopyWithImpl(this._value, this._then); + _$RegisterDataDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final RegisterDataDto _self; + final $Res Function(RegisterDataDto) _then; - /// Create a copy of RegisterDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? registrationToken = freezed, - Object? otpToken = freezed, - Object? expiresIn = freezed, - }) { - return _then( - _value.copyWith( - registrationToken: freezed == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String?, - otpToken: freezed == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String?, - expiresIn: freezed == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int?, - ) - as $Val, - ); - } +/// Create a copy of RegisterDataDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? registrationToken = freezed,Object? otpToken = freezed,Object? expiresIn = freezed,}) { + return _then(RegisterDataDto( +registrationToken: freezed == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String?,otpToken: freezed == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String?,expiresIn: freezed == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int?, + )); } -/// @nodoc -abstract class _$$RegisterDataDtoImplCopyWith<$Res> - implements $RegisterDataDtoCopyWith<$Res> { - factory _$$RegisterDataDtoImplCopyWith( - _$RegisterDataDtoImpl value, - $Res Function(_$RegisterDataDtoImpl) then, - ) = __$$RegisterDataDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'registration_token') String? registrationToken, - @JsonKey(name: 'otp_token') String? otpToken, - @JsonKey(name: 'expires_in') int? expiresIn, - }); } -/// @nodoc -class __$$RegisterDataDtoImplCopyWithImpl<$Res> - extends _$RegisterDataDtoCopyWithImpl<$Res, _$RegisterDataDtoImpl> - implements _$$RegisterDataDtoImplCopyWith<$Res> { - __$$RegisterDataDtoImplCopyWithImpl( - _$RegisterDataDtoImpl _value, - $Res Function(_$RegisterDataDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of RegisterDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? registrationToken = freezed, - Object? otpToken = freezed, - Object? expiresIn = freezed, - }) { - return _then( - _$RegisterDataDtoImpl( - registrationToken: freezed == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String?, - otpToken: freezed == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String?, - expiresIn: freezed == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int?, - ), - ); - } +/// Adds pattern-matching-related methods to [RegisterDataDto]. +extension RegisterDataDtoPatterns on RegisterDataDto { +/// 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( _RegisterDataDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _RegisterDataDto() 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( _RegisterDataDto value) $default,){ +final _that = this; +switch (_that) { +case _RegisterDataDto(): +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( _RegisterDataDto value)? $default,){ +final _that = this; +switch (_that) { +case _RegisterDataDto() 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(@JsonKey(name: 'registration_token') String? registrationToken, @JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_in') int? expiresIn)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _RegisterDataDto() when $default != null: +return $default(_that.registrationToken,_that.otpToken,_that.expiresIn);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(@JsonKey(name: 'registration_token') String? registrationToken, @JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_in') int? expiresIn) $default,) {final _that = this; +switch (_that) { +case _RegisterDataDto(): +return $default(_that.registrationToken,_that.otpToken,_that.expiresIn);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(@JsonKey(name: 'registration_token') String? registrationToken, @JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_in') int? expiresIn)? $default,) {final _that = this; +switch (_that) { +case _RegisterDataDto() when $default != null: +return $default(_that.registrationToken,_that.otpToken,_that.expiresIn);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$RegisterDataDtoImpl implements _RegisterDataDto { - const _$RegisterDataDtoImpl({ - @JsonKey(name: 'registration_token') this.registrationToken, - @JsonKey(name: 'otp_token') this.otpToken, - @JsonKey(name: 'expires_in') this.expiresIn, - }); - factory _$RegisterDataDtoImpl.fromJson(Map json) => - _$$RegisterDataDtoImplFromJson(json); +class _RegisterDataDto implements RegisterDataDto { + const _RegisterDataDto({@JsonKey(name: 'registration_token') this.registrationToken, @JsonKey(name: 'otp_token') this.otpToken, @JsonKey(name: 'expires_in') this.expiresIn}); + factory _RegisterDataDto.fromJson(Map json) => _$RegisterDataDtoFromJson(json); - @override - @JsonKey(name: 'registration_token') - final String? registrationToken; - @override - @JsonKey(name: 'otp_token') - final String? otpToken; - @override - @JsonKey(name: 'expires_in') - final int? expiresIn; +@override@JsonKey(name: 'registration_token') final String? registrationToken; +@override@JsonKey(name: 'otp_token') final String? otpToken; +@override@JsonKey(name: 'expires_in') final int? expiresIn; - @override - String toString() { +/// Create a copy of RegisterDataDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$RegisterDataDtoCopyWith<_RegisterDataDto> get copyWith => __$RegisterDataDtoCopyWithImpl<_RegisterDataDto>(this, _$identity); + +@override +Map toJson() { + return _$RegisterDataDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _RegisterDataDto&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)&&(identical(other.otpToken, otpToken) || other.otpToken == otpToken)&&(identical(other.expiresIn, expiresIn) || other.expiresIn == expiresIn)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,registrationToken,otpToken,expiresIn); +} + +@override +String toString() { return 'RegisterDataDto(registrationToken: $registrationToken, otpToken: $otpToken, expiresIn: $expiresIn)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$RegisterDataDtoImpl && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken) && - (identical(other.otpToken, otpToken) || - other.otpToken == otpToken) && - (identical(other.expiresIn, expiresIn) || - other.expiresIn == expiresIn)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, registrationToken, otpToken, expiresIn); - - /// Create a copy of RegisterDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$RegisterDataDtoImplCopyWith<_$RegisterDataDtoImpl> get copyWith => - __$$RegisterDataDtoImplCopyWithImpl<_$RegisterDataDtoImpl>( - this, - _$identity, - ); - - @override - Map toJson() { - return _$$RegisterDataDtoImplToJson(this); - } } -abstract class _RegisterDataDto implements RegisterDataDto { - const factory _RegisterDataDto({ - @JsonKey(name: 'registration_token') final String? registrationToken, - @JsonKey(name: 'otp_token') final String? otpToken, - @JsonKey(name: 'expires_in') final int? expiresIn, - }) = _$RegisterDataDtoImpl; - factory _RegisterDataDto.fromJson(Map json) = - _$RegisterDataDtoImpl.fromJson; - - @override - @JsonKey(name: 'registration_token') - String? get registrationToken; - @override - @JsonKey(name: 'otp_token') - String? get otpToken; - @override - @JsonKey(name: 'expires_in') - int? get expiresIn; - - /// Create a copy of RegisterDataDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$RegisterDataDtoImplCopyWith<_$RegisterDataDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -VerifyDto _$VerifyDtoFromJson(Map json) { - return _VerifyDto.fromJson(json); +/// @nodoc +abstract mixin class _$RegisterDataDtoCopyWith<$Res> implements $RegisterDataDtoCopyWith<$Res> { + factory _$RegisterDataDtoCopyWith(_RegisterDataDto value, $Res Function(_RegisterDataDto) _then) = __$RegisterDataDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'registration_token') String? registrationToken,@JsonKey(name: 'otp_token') String? otpToken,@JsonKey(name: 'expires_in') int? expiresIn +}); + + + + } +/// @nodoc +class __$RegisterDataDtoCopyWithImpl<$Res> + implements _$RegisterDataDtoCopyWith<$Res> { + __$RegisterDataDtoCopyWithImpl(this._self, this._then); + + final _RegisterDataDto _self; + final $Res Function(_RegisterDataDto) _then; + +/// Create a copy of RegisterDataDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? registrationToken = freezed,Object? otpToken = freezed,Object? expiresIn = freezed,}) { + return _then(_RegisterDataDto( +registrationToken: freezed == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String?,otpToken: freezed == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String?,expiresIn: freezed == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + /// @nodoc mixin _$VerifyDto { - @JsonKey(name: 'status') - String? get status => throw _privateConstructorUsedError; - @JsonKey(name: 'message') - String? get message => throw _privateConstructorUsedError; - @JsonKey(name: 'data') - VerifyDataDto? get data => throw _privateConstructorUsedError; + +@JsonKey(name: 'status') String? get status;@JsonKey(name: 'message') String? get message;@JsonKey(name: 'data') VerifyDataDto? get data; +/// Create a copy of VerifyDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$VerifyDtoCopyWith get copyWith => _$VerifyDtoCopyWithImpl(this as VerifyDto, _$identity); /// Serializes this VerifyDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as VerifyDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyDto&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.data, _this.data) || other.data == _this.data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as VerifyDto; + return Object.hash(runtimeType,_this.status,_this.message,_this.data); +} + +@override +String toString() { + final _this = this as VerifyDto; + return 'VerifyDto(status: ${_this.status}, message: ${_this.message}, data: ${_this.data})'; +} + - /// Create a copy of VerifyDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $VerifyDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $VerifyDtoCopyWith<$Res> { - factory $VerifyDtoCopyWith(VerifyDto value, $Res Function(VerifyDto) then) = - _$VerifyDtoCopyWithImpl<$Res, VerifyDto>; - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') VerifyDataDto? data, - }); +abstract mixin class $VerifyDtoCopyWith<$Res> { + factory $VerifyDtoCopyWith(VerifyDto value, $Res Function(VerifyDto) _then) = _$VerifyDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') VerifyDataDto? data +}); + + +$VerifyDataDtoCopyWith<$Res>? get data; - $VerifyDataDtoCopyWith<$Res>? get data; } - /// @nodoc -class _$VerifyDtoCopyWithImpl<$Res, $Val extends VerifyDto> +class _$VerifyDtoCopyWithImpl<$Res> implements $VerifyDtoCopyWith<$Res> { - _$VerifyDtoCopyWithImpl(this._value, this._then); + _$VerifyDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final VerifyDto _self; + final $Res Function(VerifyDto) _then; - /// Create a copy of VerifyDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _value.copyWith( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as VerifyDataDto?, - ) - as $Val, - ); - } - - /// Create a copy of VerifyDto - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $VerifyDataDtoCopyWith<$Res>? get data { - if (_value.data == null) { - return null; - } - - return $VerifyDataDtoCopyWith<$Res>(_value.data!, (value) { - return _then(_value.copyWith(data: value) as $Val); - }); - } +/// Create a copy of VerifyDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(VerifyDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as VerifyDataDto?, + )); } +/// Create a copy of VerifyDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$VerifyDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } -/// @nodoc -abstract class _$$VerifyDtoImplCopyWith<$Res> - implements $VerifyDtoCopyWith<$Res> { - factory _$$VerifyDtoImplCopyWith( - _$VerifyDtoImpl value, - $Res Function(_$VerifyDtoImpl) then, - ) = __$$VerifyDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') VerifyDataDto? data, + return $VerifyDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); }); - - @override - $VerifyDataDtoCopyWith<$Res>? get data; +} } -/// @nodoc -class __$$VerifyDtoImplCopyWithImpl<$Res> - extends _$VerifyDtoCopyWithImpl<$Res, _$VerifyDtoImpl> - implements _$$VerifyDtoImplCopyWith<$Res> { - __$$VerifyDtoImplCopyWithImpl( - _$VerifyDtoImpl _value, - $Res Function(_$VerifyDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of VerifyDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _$VerifyDtoImpl( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as VerifyDataDto?, - ), - ); - } +/// Adds pattern-matching-related methods to [VerifyDto]. +extension VerifyDtoPatterns on VerifyDto { +/// 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( _VerifyDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _VerifyDto() 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( _VerifyDto value) $default,){ +final _that = this; +switch (_that) { +case _VerifyDto(): +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( _VerifyDto value)? $default,){ +final _that = this; +switch (_that) { +case _VerifyDto() 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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') VerifyDataDto? data)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _VerifyDto() when $default != null: +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') VerifyDataDto? data) $default,) {final _that = this; +switch (_that) { +case _VerifyDto(): +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') VerifyDataDto? data)? $default,) {final _that = this; +switch (_that) { +case _VerifyDto() when $default != null: +return $default(_that.status,_that.message,_that.data);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$VerifyDtoImpl extends _VerifyDto { - const _$VerifyDtoImpl({ - @JsonKey(name: 'status') this.status, - @JsonKey(name: 'message') this.message, - @JsonKey(name: 'data') this.data, - }) : super._(); - factory _$VerifyDtoImpl.fromJson(Map json) => - _$$VerifyDtoImplFromJson(json); +class _VerifyDto extends VerifyDto { + const _VerifyDto({@JsonKey(name: 'status') this.status, @JsonKey(name: 'message') this.message, @JsonKey(name: 'data') this.data}): super._(); + factory _VerifyDto.fromJson(Map json) => _$VerifyDtoFromJson(json); - @override - @JsonKey(name: 'status') - final String? status; - @override - @JsonKey(name: 'message') - final String? message; - @override - @JsonKey(name: 'data') - final VerifyDataDto? data; +@override@JsonKey(name: 'status') final String? status; +@override@JsonKey(name: 'message') final String? message; +@override@JsonKey(name: 'data') final VerifyDataDto? data; - @override - String toString() { +/// Create a copy of VerifyDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$VerifyDtoCopyWith<_VerifyDto> get copyWith => __$VerifyDtoCopyWithImpl<_VerifyDto>(this, _$identity); + +@override +Map toJson() { + return _$VerifyDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyDto&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,status,message,data); +} + +@override +String toString() { return 'VerifyDto(status: $status, message: $message, data: $data)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$VerifyDtoImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.data, data) || other.data == data)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, status, message, data); - - /// Create a copy of VerifyDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$VerifyDtoImplCopyWith<_$VerifyDtoImpl> get copyWith => - __$$VerifyDtoImplCopyWithImpl<_$VerifyDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$VerifyDtoImplToJson(this); - } } -abstract class _VerifyDto extends VerifyDto { - const factory _VerifyDto({ - @JsonKey(name: 'status') final String? status, - @JsonKey(name: 'message') final String? message, - @JsonKey(name: 'data') final VerifyDataDto? data, - }) = _$VerifyDtoImpl; - const _VerifyDto._() : super._(); - factory _VerifyDto.fromJson(Map json) = - _$VerifyDtoImpl.fromJson; - - @override - @JsonKey(name: 'status') - String? get status; - @override - @JsonKey(name: 'message') - String? get message; - @override - @JsonKey(name: 'data') - VerifyDataDto? get data; - - /// Create a copy of VerifyDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$VerifyDtoImplCopyWith<_$VerifyDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -VerifyDataDto _$VerifyDataDtoFromJson(Map json) { - return _VerifyDataDto.fromJson(json); +/// @nodoc +abstract mixin class _$VerifyDtoCopyWith<$Res> implements $VerifyDtoCopyWith<$Res> { + factory _$VerifyDtoCopyWith(_VerifyDto value, $Res Function(_VerifyDto) _then) = __$VerifyDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') VerifyDataDto? data +}); + + +@override $VerifyDataDtoCopyWith<$Res>? get data; + } +/// @nodoc +class __$VerifyDtoCopyWithImpl<$Res> + implements _$VerifyDtoCopyWith<$Res> { + __$VerifyDtoCopyWithImpl(this._self, this._then); + + final _VerifyDto _self; + final $Res Function(_VerifyDto) _then; + +/// Create a copy of VerifyDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(_VerifyDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as VerifyDataDto?, + )); +} + +/// Create a copy of VerifyDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$VerifyDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + + return $VerifyDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + /// @nodoc mixin _$VerifyDataDto { - @JsonKey(name: 'registration_token') - String? get registrationToken => throw _privateConstructorUsedError; + +@JsonKey(name: 'registration_token') String? get registrationToken; +/// Create a copy of VerifyDataDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$VerifyDataDtoCopyWith get copyWith => _$VerifyDataDtoCopyWithImpl(this as VerifyDataDto, _$identity); /// Serializes this VerifyDataDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as VerifyDataDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is VerifyDataDto&&(identical(other.registrationToken, _this.registrationToken) || other.registrationToken == _this.registrationToken)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as VerifyDataDto; + return Object.hash(runtimeType,_this.registrationToken); +} + +@override +String toString() { + final _this = this as VerifyDataDto; + return 'VerifyDataDto(registrationToken: ${_this.registrationToken})'; +} + - /// Create a copy of VerifyDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $VerifyDataDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $VerifyDataDtoCopyWith<$Res> { - factory $VerifyDataDtoCopyWith( - VerifyDataDto value, - $Res Function(VerifyDataDto) then, - ) = _$VerifyDataDtoCopyWithImpl<$Res, VerifyDataDto>; - @useResult - $Res call({@JsonKey(name: 'registration_token') String? registrationToken}); -} +abstract mixin class $VerifyDataDtoCopyWith<$Res> { + factory $VerifyDataDtoCopyWith(VerifyDataDto value, $Res Function(VerifyDataDto) _then) = _$VerifyDataDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'registration_token') String? registrationToken +}); + + + +} /// @nodoc -class _$VerifyDataDtoCopyWithImpl<$Res, $Val extends VerifyDataDto> +class _$VerifyDataDtoCopyWithImpl<$Res> implements $VerifyDataDtoCopyWith<$Res> { - _$VerifyDataDtoCopyWithImpl(this._value, this._then); + _$VerifyDataDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final VerifyDataDto _self; + final $Res Function(VerifyDataDto) _then; - /// Create a copy of VerifyDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? registrationToken = freezed}) { - return _then( - _value.copyWith( - registrationToken: freezed == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } +/// Create a copy of VerifyDataDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? registrationToken = freezed,}) { + return _then(VerifyDataDto( +registrationToken: freezed == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$VerifyDataDtoImplCopyWith<$Res> - implements $VerifyDataDtoCopyWith<$Res> { - factory _$$VerifyDataDtoImplCopyWith( - _$VerifyDataDtoImpl value, - $Res Function(_$VerifyDataDtoImpl) then, - ) = __$$VerifyDataDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({@JsonKey(name: 'registration_token') String? registrationToken}); } -/// @nodoc -class __$$VerifyDataDtoImplCopyWithImpl<$Res> - extends _$VerifyDataDtoCopyWithImpl<$Res, _$VerifyDataDtoImpl> - implements _$$VerifyDataDtoImplCopyWith<$Res> { - __$$VerifyDataDtoImplCopyWithImpl( - _$VerifyDataDtoImpl _value, - $Res Function(_$VerifyDataDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of VerifyDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? registrationToken = freezed}) { - return _then( - _$VerifyDataDtoImpl( - registrationToken: freezed == registrationToken - ? _value.registrationToken - : registrationToken // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } +/// Adds pattern-matching-related methods to [VerifyDataDto]. +extension VerifyDataDtoPatterns on VerifyDataDto { +/// 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( _VerifyDataDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _VerifyDataDto() 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( _VerifyDataDto value) $default,){ +final _that = this; +switch (_that) { +case _VerifyDataDto(): +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( _VerifyDataDto value)? $default,){ +final _that = this; +switch (_that) { +case _VerifyDataDto() 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(@JsonKey(name: 'registration_token') String? registrationToken)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _VerifyDataDto() when $default != null: +return $default(_that.registrationToken);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(@JsonKey(name: 'registration_token') String? registrationToken) $default,) {final _that = this; +switch (_that) { +case _VerifyDataDto(): +return $default(_that.registrationToken);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(@JsonKey(name: 'registration_token') String? registrationToken)? $default,) {final _that = this; +switch (_that) { +case _VerifyDataDto() when $default != null: +return $default(_that.registrationToken);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$VerifyDataDtoImpl implements _VerifyDataDto { - const _$VerifyDataDtoImpl({ - @JsonKey(name: 'registration_token') this.registrationToken, - }); - factory _$VerifyDataDtoImpl.fromJson(Map json) => - _$$VerifyDataDtoImplFromJson(json); +class _VerifyDataDto implements VerifyDataDto { + const _VerifyDataDto({@JsonKey(name: 'registration_token') this.registrationToken}); + factory _VerifyDataDto.fromJson(Map json) => _$VerifyDataDtoFromJson(json); - @override - @JsonKey(name: 'registration_token') - final String? registrationToken; +@override@JsonKey(name: 'registration_token') final String? registrationToken; - @override - String toString() { +/// Create a copy of VerifyDataDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$VerifyDataDtoCopyWith<_VerifyDataDto> get copyWith => __$VerifyDataDtoCopyWithImpl<_VerifyDataDto>(this, _$identity); + +@override +Map toJson() { + return _$VerifyDataDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _VerifyDataDto&&(identical(other.registrationToken, registrationToken) || other.registrationToken == registrationToken)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,registrationToken); +} + +@override +String toString() { return 'VerifyDataDto(registrationToken: $registrationToken)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$VerifyDataDtoImpl && - (identical(other.registrationToken, registrationToken) || - other.registrationToken == registrationToken)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, registrationToken); - - /// Create a copy of VerifyDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$VerifyDataDtoImplCopyWith<_$VerifyDataDtoImpl> get copyWith => - __$$VerifyDataDtoImplCopyWithImpl<_$VerifyDataDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$VerifyDataDtoImplToJson(this); - } } -abstract class _VerifyDataDto implements VerifyDataDto { - const factory _VerifyDataDto({ - @JsonKey(name: 'registration_token') final String? registrationToken, - }) = _$VerifyDataDtoImpl; - factory _VerifyDataDto.fromJson(Map json) = - _$VerifyDataDtoImpl.fromJson; - - @override - @JsonKey(name: 'registration_token') - String? get registrationToken; - - /// Create a copy of VerifyDataDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$VerifyDataDtoImplCopyWith<_$VerifyDataDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -LoginDto _$LoginDtoFromJson(Map json) { - return _LoginDto.fromJson(json); +/// @nodoc +abstract mixin class _$VerifyDataDtoCopyWith<$Res> implements $VerifyDataDtoCopyWith<$Res> { + factory _$VerifyDataDtoCopyWith(_VerifyDataDto value, $Res Function(_VerifyDataDto) _then) = __$VerifyDataDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'registration_token') String? registrationToken +}); + + + + } +/// @nodoc +class __$VerifyDataDtoCopyWithImpl<$Res> + implements _$VerifyDataDtoCopyWith<$Res> { + __$VerifyDataDtoCopyWithImpl(this._self, this._then); + + final _VerifyDataDto _self; + final $Res Function(_VerifyDataDto) _then; + +/// Create a copy of VerifyDataDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? registrationToken = freezed,}) { + return _then(_VerifyDataDto( +registrationToken: freezed == registrationToken ? _self.registrationToken : registrationToken // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + /// @nodoc mixin _$LoginDto { - @JsonKey(name: 'status') - String? get status => throw _privateConstructorUsedError; - @JsonKey(name: 'message') - String? get message => throw _privateConstructorUsedError; - @JsonKey(name: 'data') - LoginDataDto? get data => throw _privateConstructorUsedError; + +@JsonKey(name: 'status') String? get status;@JsonKey(name: 'message') String? get message;@JsonKey(name: 'data') LoginDataDto? get data; +/// Create a copy of LoginDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LoginDtoCopyWith get copyWith => _$LoginDtoCopyWithImpl(this as LoginDto, _$identity); /// Serializes this LoginDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as LoginDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginDto&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.data, _this.data) || other.data == _this.data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as LoginDto; + return Object.hash(runtimeType,_this.status,_this.message,_this.data); +} + +@override +String toString() { + final _this = this as LoginDto; + return 'LoginDto(status: ${_this.status}, message: ${_this.message}, data: ${_this.data})'; +} + - /// Create a copy of LoginDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $LoginDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $LoginDtoCopyWith<$Res> { - factory $LoginDtoCopyWith(LoginDto value, $Res Function(LoginDto) then) = - _$LoginDtoCopyWithImpl<$Res, LoginDto>; - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') LoginDataDto? data, - }); +abstract mixin class $LoginDtoCopyWith<$Res> { + factory $LoginDtoCopyWith(LoginDto value, $Res Function(LoginDto) _then) = _$LoginDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') LoginDataDto? data +}); + + +$LoginDataDtoCopyWith<$Res>? get data; - $LoginDataDtoCopyWith<$Res>? get data; } - /// @nodoc -class _$LoginDtoCopyWithImpl<$Res, $Val extends LoginDto> +class _$LoginDtoCopyWithImpl<$Res> implements $LoginDtoCopyWith<$Res> { - _$LoginDtoCopyWithImpl(this._value, this._then); + _$LoginDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final LoginDto _self; + final $Res Function(LoginDto) _then; - /// Create a copy of LoginDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _value.copyWith( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as LoginDataDto?, - ) - as $Val, - ); - } - - /// Create a copy of LoginDto - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $LoginDataDtoCopyWith<$Res>? get data { - if (_value.data == null) { - return null; - } - - return $LoginDataDtoCopyWith<$Res>(_value.data!, (value) { - return _then(_value.copyWith(data: value) as $Val); - }); - } +/// Create a copy of LoginDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(LoginDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as LoginDataDto?, + )); } +/// Create a copy of LoginDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LoginDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } -/// @nodoc -abstract class _$$LoginDtoImplCopyWith<$Res> - implements $LoginDtoCopyWith<$Res> { - factory _$$LoginDtoImplCopyWith( - _$LoginDtoImpl value, - $Res Function(_$LoginDtoImpl) then, - ) = __$$LoginDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') LoginDataDto? data, + return $LoginDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); }); - - @override - $LoginDataDtoCopyWith<$Res>? get data; +} } -/// @nodoc -class __$$LoginDtoImplCopyWithImpl<$Res> - extends _$LoginDtoCopyWithImpl<$Res, _$LoginDtoImpl> - implements _$$LoginDtoImplCopyWith<$Res> { - __$$LoginDtoImplCopyWithImpl( - _$LoginDtoImpl _value, - $Res Function(_$LoginDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of LoginDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _$LoginDtoImpl( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as LoginDataDto?, - ), - ); - } +/// Adds pattern-matching-related methods to [LoginDto]. +extension LoginDtoPatterns on LoginDto { +/// 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( _LoginDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LoginDto() 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( _LoginDto value) $default,){ +final _that = this; +switch (_that) { +case _LoginDto(): +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( _LoginDto value)? $default,){ +final _that = this; +switch (_that) { +case _LoginDto() 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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') LoginDataDto? data)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LoginDto() when $default != null: +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') LoginDataDto? data) $default,) {final _that = this; +switch (_that) { +case _LoginDto(): +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') LoginDataDto? data)? $default,) {final _that = this; +switch (_that) { +case _LoginDto() when $default != null: +return $default(_that.status,_that.message,_that.data);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$LoginDtoImpl extends _LoginDto { - const _$LoginDtoImpl({ - @JsonKey(name: 'status') this.status, - @JsonKey(name: 'message') this.message, - @JsonKey(name: 'data') this.data, - }) : super._(); - factory _$LoginDtoImpl.fromJson(Map json) => - _$$LoginDtoImplFromJson(json); +class _LoginDto extends LoginDto { + const _LoginDto({@JsonKey(name: 'status') this.status, @JsonKey(name: 'message') this.message, @JsonKey(name: 'data') this.data}): super._(); + factory _LoginDto.fromJson(Map json) => _$LoginDtoFromJson(json); - @override - @JsonKey(name: 'status') - final String? status; - @override - @JsonKey(name: 'message') - final String? message; - @override - @JsonKey(name: 'data') - final LoginDataDto? data; +@override@JsonKey(name: 'status') final String? status; +@override@JsonKey(name: 'message') final String? message; +@override@JsonKey(name: 'data') final LoginDataDto? data; - @override - String toString() { +/// Create a copy of LoginDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LoginDtoCopyWith<_LoginDto> get copyWith => __$LoginDtoCopyWithImpl<_LoginDto>(this, _$identity); + +@override +Map toJson() { + return _$LoginDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginDto&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,status,message,data); +} + +@override +String toString() { return 'LoginDto(status: $status, message: $message, data: $data)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LoginDtoImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.data, data) || other.data == data)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, status, message, data); - - /// Create a copy of LoginDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$LoginDtoImplCopyWith<_$LoginDtoImpl> get copyWith => - __$$LoginDtoImplCopyWithImpl<_$LoginDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$LoginDtoImplToJson(this); - } } -abstract class _LoginDto extends LoginDto { - const factory _LoginDto({ - @JsonKey(name: 'status') final String? status, - @JsonKey(name: 'message') final String? message, - @JsonKey(name: 'data') final LoginDataDto? data, - }) = _$LoginDtoImpl; - const _LoginDto._() : super._(); - factory _LoginDto.fromJson(Map json) = - _$LoginDtoImpl.fromJson; - - @override - @JsonKey(name: 'status') - String? get status; - @override - @JsonKey(name: 'message') - String? get message; - @override - @JsonKey(name: 'data') - LoginDataDto? get data; - - /// Create a copy of LoginDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$LoginDtoImplCopyWith<_$LoginDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -LoginDataDto _$LoginDataDtoFromJson(Map json) { - return _LoginDataDto.fromJson(json); +/// @nodoc +abstract mixin class _$LoginDtoCopyWith<$Res> implements $LoginDtoCopyWith<$Res> { + factory _$LoginDtoCopyWith(_LoginDto value, $Res Function(_LoginDto) _then) = __$LoginDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') LoginDataDto? data +}); + + +@override $LoginDataDtoCopyWith<$Res>? get data; + } +/// @nodoc +class __$LoginDtoCopyWithImpl<$Res> + implements _$LoginDtoCopyWith<$Res> { + __$LoginDtoCopyWithImpl(this._self, this._then); + + final _LoginDto _self; + final $Res Function(_LoginDto) _then; + +/// Create a copy of LoginDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(_LoginDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as LoginDataDto?, + )); +} + +/// Create a copy of LoginDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$LoginDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + + return $LoginDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + /// @nodoc mixin _$LoginDataDto { - @JsonKey(name: 'access_token') - String? get accessToken => throw _privateConstructorUsedError; - @JsonKey(name: 'refresh_token') - String? get refreshToken => throw _privateConstructorUsedError; - @JsonKey(name: 'user') - UserDto? get user => throw _privateConstructorUsedError; + +@JsonKey(name: 'access_token') String? get accessToken;@JsonKey(name: 'refresh_token') String? get refreshToken;@JsonKey(name: 'user') UserDto? get user; +/// Create a copy of LoginDataDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$LoginDataDtoCopyWith get copyWith => _$LoginDataDtoCopyWithImpl(this as LoginDataDto, _$identity); /// Serializes this LoginDataDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as LoginDataDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is LoginDataDto&&(identical(other.accessToken, _this.accessToken) || other.accessToken == _this.accessToken)&&(identical(other.refreshToken, _this.refreshToken) || other.refreshToken == _this.refreshToken)&&(identical(other.user, _this.user) || other.user == _this.user)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as LoginDataDto; + return Object.hash(runtimeType,_this.accessToken,_this.refreshToken,_this.user); +} + +@override +String toString() { + final _this = this as LoginDataDto; + return 'LoginDataDto(accessToken: ${_this.accessToken}, refreshToken: ${_this.refreshToken}, user: ${_this.user})'; +} + - /// Create a copy of LoginDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $LoginDataDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $LoginDataDtoCopyWith<$Res> { - factory $LoginDataDtoCopyWith( - LoginDataDto value, - $Res Function(LoginDataDto) then, - ) = _$LoginDataDtoCopyWithImpl<$Res, LoginDataDto>; - @useResult - $Res call({ - @JsonKey(name: 'access_token') String? accessToken, - @JsonKey(name: 'refresh_token') String? refreshToken, - @JsonKey(name: 'user') UserDto? user, - }); +abstract mixin class $LoginDataDtoCopyWith<$Res> { + factory $LoginDataDtoCopyWith(LoginDataDto value, $Res Function(LoginDataDto) _then) = _$LoginDataDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'access_token') String? accessToken,@JsonKey(name: 'refresh_token') String? refreshToken,@JsonKey(name: 'user') UserDto? user +}); + + +$UserDtoCopyWith<$Res>? get user; - $UserDtoCopyWith<$Res>? get user; } - /// @nodoc -class _$LoginDataDtoCopyWithImpl<$Res, $Val extends LoginDataDto> +class _$LoginDataDtoCopyWithImpl<$Res> implements $LoginDataDtoCopyWith<$Res> { - _$LoginDataDtoCopyWithImpl(this._value, this._then); + _$LoginDataDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final LoginDataDto _self; + final $Res Function(LoginDataDto) _then; - /// Create a copy of LoginDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? accessToken = freezed, - Object? refreshToken = freezed, - Object? user = freezed, - }) { - return _then( - _value.copyWith( - accessToken: freezed == accessToken - ? _value.accessToken - : accessToken // ignore: cast_nullable_to_non_nullable - as String?, - refreshToken: freezed == refreshToken - ? _value.refreshToken - : refreshToken // ignore: cast_nullable_to_non_nullable - as String?, - user: freezed == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as UserDto?, - ) - as $Val, - ); - } - - /// Create a copy of LoginDataDto - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $UserDtoCopyWith<$Res>? get user { - if (_value.user == null) { - return null; - } - - return $UserDtoCopyWith<$Res>(_value.user!, (value) { - return _then(_value.copyWith(user: value) as $Val); - }); - } +/// Create a copy of LoginDataDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? accessToken = freezed,Object? refreshToken = freezed,Object? user = freezed,}) { + return _then(LoginDataDto( +accessToken: freezed == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable +as String?,refreshToken: freezed == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable +as String?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as UserDto?, + )); } +/// Create a copy of LoginDataDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserDtoCopyWith<$Res>? get user { + if (_self.user == null) { + return null; + } -/// @nodoc -abstract class _$$LoginDataDtoImplCopyWith<$Res> - implements $LoginDataDtoCopyWith<$Res> { - factory _$$LoginDataDtoImplCopyWith( - _$LoginDataDtoImpl value, - $Res Function(_$LoginDataDtoImpl) then, - ) = __$$LoginDataDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'access_token') String? accessToken, - @JsonKey(name: 'refresh_token') String? refreshToken, - @JsonKey(name: 'user') UserDto? user, + return $UserDtoCopyWith<$Res>(_self.user!, (value) { + return _then(_self.copyWith(user: value)); }); - - @override - $UserDtoCopyWith<$Res>? get user; +} } -/// @nodoc -class __$$LoginDataDtoImplCopyWithImpl<$Res> - extends _$LoginDataDtoCopyWithImpl<$Res, _$LoginDataDtoImpl> - implements _$$LoginDataDtoImplCopyWith<$Res> { - __$$LoginDataDtoImplCopyWithImpl( - _$LoginDataDtoImpl _value, - $Res Function(_$LoginDataDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of LoginDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? accessToken = freezed, - Object? refreshToken = freezed, - Object? user = freezed, - }) { - return _then( - _$LoginDataDtoImpl( - accessToken: freezed == accessToken - ? _value.accessToken - : accessToken // ignore: cast_nullable_to_non_nullable - as String?, - refreshToken: freezed == refreshToken - ? _value.refreshToken - : refreshToken // ignore: cast_nullable_to_non_nullable - as String?, - user: freezed == user - ? _value.user - : user // ignore: cast_nullable_to_non_nullable - as UserDto?, - ), - ); - } +/// Adds pattern-matching-related methods to [LoginDataDto]. +extension LoginDataDtoPatterns on LoginDataDto { +/// 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( _LoginDataDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _LoginDataDto() 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( _LoginDataDto value) $default,){ +final _that = this; +switch (_that) { +case _LoginDataDto(): +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( _LoginDataDto value)? $default,){ +final _that = this; +switch (_that) { +case _LoginDataDto() 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(@JsonKey(name: 'access_token') String? accessToken, @JsonKey(name: 'refresh_token') String? refreshToken, @JsonKey(name: 'user') UserDto? user)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _LoginDataDto() when $default != null: +return $default(_that.accessToken,_that.refreshToken,_that.user);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(@JsonKey(name: 'access_token') String? accessToken, @JsonKey(name: 'refresh_token') String? refreshToken, @JsonKey(name: 'user') UserDto? user) $default,) {final _that = this; +switch (_that) { +case _LoginDataDto(): +return $default(_that.accessToken,_that.refreshToken,_that.user);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(@JsonKey(name: 'access_token') String? accessToken, @JsonKey(name: 'refresh_token') String? refreshToken, @JsonKey(name: 'user') UserDto? user)? $default,) {final _that = this; +switch (_that) { +case _LoginDataDto() when $default != null: +return $default(_that.accessToken,_that.refreshToken,_that.user);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$LoginDataDtoImpl implements _LoginDataDto { - const _$LoginDataDtoImpl({ - @JsonKey(name: 'access_token') this.accessToken, - @JsonKey(name: 'refresh_token') this.refreshToken, - @JsonKey(name: 'user') this.user, - }); - factory _$LoginDataDtoImpl.fromJson(Map json) => - _$$LoginDataDtoImplFromJson(json); +class _LoginDataDto implements LoginDataDto { + const _LoginDataDto({@JsonKey(name: 'access_token') this.accessToken, @JsonKey(name: 'refresh_token') this.refreshToken, @JsonKey(name: 'user') this.user}); + factory _LoginDataDto.fromJson(Map json) => _$LoginDataDtoFromJson(json); - @override - @JsonKey(name: 'access_token') - final String? accessToken; - @override - @JsonKey(name: 'refresh_token') - final String? refreshToken; - @override - @JsonKey(name: 'user') - final UserDto? user; +@override@JsonKey(name: 'access_token') final String? accessToken; +@override@JsonKey(name: 'refresh_token') final String? refreshToken; +@override@JsonKey(name: 'user') final UserDto? user; - @override - String toString() { +/// Create a copy of LoginDataDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$LoginDataDtoCopyWith<_LoginDataDto> get copyWith => __$LoginDataDtoCopyWithImpl<_LoginDataDto>(this, _$identity); + +@override +Map toJson() { + return _$LoginDataDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _LoginDataDto&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.user, user) || other.user == user)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,accessToken,refreshToken,user); +} + +@override +String toString() { return 'LoginDataDto(accessToken: $accessToken, refreshToken: $refreshToken, user: $user)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$LoginDataDtoImpl && - (identical(other.accessToken, accessToken) || - other.accessToken == accessToken) && - (identical(other.refreshToken, refreshToken) || - other.refreshToken == refreshToken) && - (identical(other.user, user) || other.user == user)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, accessToken, refreshToken, user); - - /// Create a copy of LoginDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$LoginDataDtoImplCopyWith<_$LoginDataDtoImpl> get copyWith => - __$$LoginDataDtoImplCopyWithImpl<_$LoginDataDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$LoginDataDtoImplToJson(this); - } } -abstract class _LoginDataDto implements LoginDataDto { - const factory _LoginDataDto({ - @JsonKey(name: 'access_token') final String? accessToken, - @JsonKey(name: 'refresh_token') final String? refreshToken, - @JsonKey(name: 'user') final UserDto? user, - }) = _$LoginDataDtoImpl; - factory _LoginDataDto.fromJson(Map json) = - _$LoginDataDtoImpl.fromJson; - - @override - @JsonKey(name: 'access_token') - String? get accessToken; - @override - @JsonKey(name: 'refresh_token') - String? get refreshToken; - @override - @JsonKey(name: 'user') - UserDto? get user; - - /// Create a copy of LoginDataDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$LoginDataDtoImplCopyWith<_$LoginDataDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -UserDto _$UserDtoFromJson(Map json) { - return _UserDto.fromJson(json); +/// @nodoc +abstract mixin class _$LoginDataDtoCopyWith<$Res> implements $LoginDataDtoCopyWith<$Res> { + factory _$LoginDataDtoCopyWith(_LoginDataDto value, $Res Function(_LoginDataDto) _then) = __$LoginDataDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'access_token') String? accessToken,@JsonKey(name: 'refresh_token') String? refreshToken,@JsonKey(name: 'user') UserDto? user +}); + + +@override $UserDtoCopyWith<$Res>? get user; + } +/// @nodoc +class __$LoginDataDtoCopyWithImpl<$Res> + implements _$LoginDataDtoCopyWith<$Res> { + __$LoginDataDtoCopyWithImpl(this._self, this._then); + + final _LoginDataDto _self; + final $Res Function(_LoginDataDto) _then; + +/// Create a copy of LoginDataDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? accessToken = freezed,Object? refreshToken = freezed,Object? user = freezed,}) { + return _then(_LoginDataDto( +accessToken: freezed == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable +as String?,refreshToken: freezed == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable +as String?,user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable +as UserDto?, + )); +} + +/// Create a copy of LoginDataDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$UserDtoCopyWith<$Res>? get user { + if (_self.user == null) { + return null; + } + + return $UserDtoCopyWith<$Res>(_self.user!, (value) { + return _then(_self.copyWith(user: value)); + }); +} +} + /// @nodoc mixin _$UserDto { - @JsonKey(name: 'id') - String? get id => throw _privateConstructorUsedError; - @JsonKey(name: 'name') - String? get name => throw _privateConstructorUsedError; - @JsonKey(name: 'phone_number') - String? get phoneNumber => throw _privateConstructorUsedError; - @JsonKey(name: 'birth_date') - String? get birthDate => throw _privateConstructorUsedError; + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'name') String? get name;@JsonKey(name: 'phone_number') String? get phoneNumber;@JsonKey(name: 'birth_date') String? get birthDate; +/// Create a copy of UserDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$UserDtoCopyWith get copyWith => _$UserDtoCopyWithImpl(this as UserDto, _$identity); /// Serializes this UserDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as UserDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is UserDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)&&(identical(other.birthDate, _this.birthDate) || other.birthDate == _this.birthDate)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as UserDto; + return Object.hash(runtimeType,_this.id,_this.name,_this.phoneNumber,_this.birthDate); +} + +@override +String toString() { + final _this = this as UserDto; + return 'UserDto(id: ${_this.id}, name: ${_this.name}, phoneNumber: ${_this.phoneNumber}, birthDate: ${_this.birthDate})'; +} + - /// Create a copy of UserDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $UserDtoCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $UserDtoCopyWith<$Res> { - factory $UserDtoCopyWith(UserDto value, $Res Function(UserDto) then) = - _$UserDtoCopyWithImpl<$Res, UserDto>; - @useResult - $Res call({ - @JsonKey(name: 'id') String? id, - @JsonKey(name: 'name') String? name, - @JsonKey(name: 'phone_number') String? phoneNumber, - @JsonKey(name: 'birth_date') String? birthDate, - }); -} +abstract mixin class $UserDtoCopyWith<$Res> { + factory $UserDtoCopyWith(UserDto value, $Res Function(UserDto) _then) = _$UserDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name,@JsonKey(name: 'phone_number') String? phoneNumber,@JsonKey(name: 'birth_date') String? birthDate +}); + + + +} /// @nodoc -class _$UserDtoCopyWithImpl<$Res, $Val extends UserDto> +class _$UserDtoCopyWithImpl<$Res> implements $UserDtoCopyWith<$Res> { - _$UserDtoCopyWithImpl(this._value, this._then); + _$UserDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final UserDto _self; + final $Res Function(UserDto) _then; - /// Create a copy of UserDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = freezed, - Object? phoneNumber = freezed, - Object? birthDate = freezed, - }) { - return _then( - _value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - phoneNumber: freezed == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String?, - birthDate: freezed == birthDate - ? _value.birthDate - : birthDate // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } +/// Create a copy of UserDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? name = freezed,Object? phoneNumber = freezed,Object? birthDate = freezed,}) { + return _then(UserDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,phoneNumber: freezed == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String?,birthDate: freezed == birthDate ? _self.birthDate : birthDate // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$UserDtoImplCopyWith<$Res> implements $UserDtoCopyWith<$Res> { - factory _$$UserDtoImplCopyWith( - _$UserDtoImpl value, - $Res Function(_$UserDtoImpl) then, - ) = __$$UserDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'id') String? id, - @JsonKey(name: 'name') String? name, - @JsonKey(name: 'phone_number') String? phoneNumber, - @JsonKey(name: 'birth_date') String? birthDate, - }); } -/// @nodoc -class __$$UserDtoImplCopyWithImpl<$Res> - extends _$UserDtoCopyWithImpl<$Res, _$UserDtoImpl> - implements _$$UserDtoImplCopyWith<$Res> { - __$$UserDtoImplCopyWithImpl( - _$UserDtoImpl _value, - $Res Function(_$UserDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of UserDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = freezed, - Object? phoneNumber = freezed, - Object? birthDate = freezed, - }) { - return _then( - _$UserDtoImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - phoneNumber: freezed == phoneNumber - ? _value.phoneNumber - : phoneNumber // ignore: cast_nullable_to_non_nullable - as String?, - birthDate: freezed == birthDate - ? _value.birthDate - : birthDate // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } +/// Adds pattern-matching-related methods to [UserDto]. +extension UserDtoPatterns on UserDto { +/// 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( _UserDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _UserDto() 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( _UserDto value) $default,){ +final _that = this; +switch (_that) { +case _UserDto(): +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( _UserDto value)? $default,){ +final _that = this; +switch (_that) { +case _UserDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'phone_number') String? phoneNumber, @JsonKey(name: 'birth_date') String? birthDate)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _UserDto() when $default != null: +return $default(_that.id,_that.name,_that.phoneNumber,_that.birthDate);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'phone_number') String? phoneNumber, @JsonKey(name: 'birth_date') String? birthDate) $default,) {final _that = this; +switch (_that) { +case _UserDto(): +return $default(_that.id,_that.name,_that.phoneNumber,_that.birthDate);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'phone_number') String? phoneNumber, @JsonKey(name: 'birth_date') String? birthDate)? $default,) {final _that = this; +switch (_that) { +case _UserDto() when $default != null: +return $default(_that.id,_that.name,_that.phoneNumber,_that.birthDate);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$UserDtoImpl extends _UserDto { - const _$UserDtoImpl({ - @JsonKey(name: 'id') this.id, - @JsonKey(name: 'name') this.name, - @JsonKey(name: 'phone_number') this.phoneNumber, - @JsonKey(name: 'birth_date') this.birthDate, - }) : super._(); - factory _$UserDtoImpl.fromJson(Map json) => - _$$UserDtoImplFromJson(json); +class _UserDto extends UserDto { + const _UserDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'name') this.name, @JsonKey(name: 'phone_number') this.phoneNumber, @JsonKey(name: 'birth_date') this.birthDate}): super._(); + factory _UserDto.fromJson(Map json) => _$UserDtoFromJson(json); - @override - @JsonKey(name: 'id') - final String? id; - @override - @JsonKey(name: 'name') - final String? name; - @override - @JsonKey(name: 'phone_number') - final String? phoneNumber; - @override - @JsonKey(name: 'birth_date') - final String? birthDate; +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'name') final String? name; +@override@JsonKey(name: 'phone_number') final String? phoneNumber; +@override@JsonKey(name: 'birth_date') final String? birthDate; - @override - String toString() { +/// Create a copy of UserDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$UserDtoCopyWith<_UserDto> get copyWith => __$UserDtoCopyWithImpl<_UserDto>(this, _$identity); + +@override +Map toJson() { + return _$UserDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _UserDto&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)&&(identical(other.birthDate, birthDate) || other.birthDate == birthDate)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,name,phoneNumber,birthDate); +} + +@override +String toString() { return 'UserDto(id: $id, name: $name, phoneNumber: $phoneNumber, birthDate: $birthDate)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$UserDtoImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.name, name) || other.name == name) && - (identical(other.phoneNumber, phoneNumber) || - other.phoneNumber == phoneNumber) && - (identical(other.birthDate, birthDate) || - other.birthDate == birthDate)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, id, name, phoneNumber, birthDate); - - /// Create a copy of UserDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith => - __$$UserDtoImplCopyWithImpl<_$UserDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$UserDtoImplToJson(this); - } } -abstract class _UserDto extends UserDto { - const factory _UserDto({ - @JsonKey(name: 'id') final String? id, - @JsonKey(name: 'name') final String? name, - @JsonKey(name: 'phone_number') final String? phoneNumber, - @JsonKey(name: 'birth_date') final String? birthDate, - }) = _$UserDtoImpl; - const _UserDto._() : super._(); - factory _UserDto.fromJson(Map json) = _$UserDtoImpl.fromJson; - - @override - @JsonKey(name: 'id') - String? get id; - @override - @JsonKey(name: 'name') - String? get name; - @override - @JsonKey(name: 'phone_number') - String? get phoneNumber; - @override - @JsonKey(name: 'birth_date') - String? get birthDate; - - /// Create a copy of UserDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$UserDtoImplCopyWith<_$UserDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -ResendDto _$ResendDtoFromJson(Map json) { - return _ResendDto.fromJson(json); +/// @nodoc +abstract mixin class _$UserDtoCopyWith<$Res> implements $UserDtoCopyWith<$Res> { + factory _$UserDtoCopyWith(_UserDto value, $Res Function(_UserDto) _then) = __$UserDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name,@JsonKey(name: 'phone_number') String? phoneNumber,@JsonKey(name: 'birth_date') String? birthDate +}); + + + + } +/// @nodoc +class __$UserDtoCopyWithImpl<$Res> + implements _$UserDtoCopyWith<$Res> { + __$UserDtoCopyWithImpl(this._self, this._then); + + final _UserDto _self; + final $Res Function(_UserDto) _then; + +/// Create a copy of UserDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? name = freezed,Object? phoneNumber = freezed,Object? birthDate = freezed,}) { + return _then(_UserDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,phoneNumber: freezed == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String?,birthDate: freezed == birthDate ? _self.birthDate : birthDate // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + /// @nodoc mixin _$ResendDto { - @JsonKey(name: 'status') - String? get status => throw _privateConstructorUsedError; - @JsonKey(name: 'message') - String? get message => throw _privateConstructorUsedError; - @JsonKey(name: 'data') - ResendDataDto? get data => throw _privateConstructorUsedError; + +@JsonKey(name: 'status') String? get status;@JsonKey(name: 'message') String? get message;@JsonKey(name: 'data') ResendDataDto? get data; +/// Create a copy of ResendDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ResendDtoCopyWith get copyWith => _$ResendDtoCopyWithImpl(this as ResendDto, _$identity); /// Serializes this ResendDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as ResendDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ResendDto&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.message, _this.message) || other.message == _this.message)&&(identical(other.data, _this.data) || other.data == _this.data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as ResendDto; + return Object.hash(runtimeType,_this.status,_this.message,_this.data); +} + +@override +String toString() { + final _this = this as ResendDto; + return 'ResendDto(status: ${_this.status}, message: ${_this.message}, data: ${_this.data})'; +} + - /// Create a copy of ResendDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ResendDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $ResendDtoCopyWith<$Res> { - factory $ResendDtoCopyWith(ResendDto value, $Res Function(ResendDto) then) = - _$ResendDtoCopyWithImpl<$Res, ResendDto>; - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') ResendDataDto? data, - }); +abstract mixin class $ResendDtoCopyWith<$Res> { + factory $ResendDtoCopyWith(ResendDto value, $Res Function(ResendDto) _then) = _$ResendDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') ResendDataDto? data +}); + + +$ResendDataDtoCopyWith<$Res>? get data; - $ResendDataDtoCopyWith<$Res>? get data; } - /// @nodoc -class _$ResendDtoCopyWithImpl<$Res, $Val extends ResendDto> +class _$ResendDtoCopyWithImpl<$Res> implements $ResendDtoCopyWith<$Res> { - _$ResendDtoCopyWithImpl(this._value, this._then); + _$ResendDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final ResendDto _self; + final $Res Function(ResendDto) _then; - /// Create a copy of ResendDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _value.copyWith( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as ResendDataDto?, - ) - as $Val, - ); - } - - /// Create a copy of ResendDto - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $ResendDataDtoCopyWith<$Res>? get data { - if (_value.data == null) { - return null; - } - - return $ResendDataDtoCopyWith<$Res>(_value.data!, (value) { - return _then(_value.copyWith(data: value) as $Val); - }); - } +/// Create a copy of ResendDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(ResendDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as ResendDataDto?, + )); } +/// Create a copy of ResendDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ResendDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } -/// @nodoc -abstract class _$$ResendDtoImplCopyWith<$Res> - implements $ResendDtoCopyWith<$Res> { - factory _$$ResendDtoImplCopyWith( - _$ResendDtoImpl value, - $Res Function(_$ResendDtoImpl) then, - ) = __$$ResendDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') ResendDataDto? data, + return $ResendDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); }); - - @override - $ResendDataDtoCopyWith<$Res>? get data; +} } -/// @nodoc -class __$$ResendDtoImplCopyWithImpl<$Res> - extends _$ResendDtoCopyWithImpl<$Res, _$ResendDtoImpl> - implements _$$ResendDtoImplCopyWith<$Res> { - __$$ResendDtoImplCopyWithImpl( - _$ResendDtoImpl _value, - $Res Function(_$ResendDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of ResendDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _$ResendDtoImpl( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as ResendDataDto?, - ), - ); - } +/// Adds pattern-matching-related methods to [ResendDto]. +extension ResendDtoPatterns on ResendDto { +/// 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( _ResendDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ResendDto() 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( _ResendDto value) $default,){ +final _that = this; +switch (_that) { +case _ResendDto(): +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( _ResendDto value)? $default,){ +final _that = this; +switch (_that) { +case _ResendDto() 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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') ResendDataDto? data)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ResendDto() when $default != null: +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') ResendDataDto? data) $default,) {final _that = this; +switch (_that) { +case _ResendDto(): +return $default(_that.status,_that.message,_that.data);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(@JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @JsonKey(name: 'data') ResendDataDto? data)? $default,) {final _that = this; +switch (_that) { +case _ResendDto() when $default != null: +return $default(_that.status,_that.message,_that.data);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$ResendDtoImpl extends _ResendDto { - const _$ResendDtoImpl({ - @JsonKey(name: 'status') this.status, - @JsonKey(name: 'message') this.message, - @JsonKey(name: 'data') this.data, - }) : super._(); - factory _$ResendDtoImpl.fromJson(Map json) => - _$$ResendDtoImplFromJson(json); +class _ResendDto extends ResendDto { + const _ResendDto({@JsonKey(name: 'status') this.status, @JsonKey(name: 'message') this.message, @JsonKey(name: 'data') this.data}): super._(); + factory _ResendDto.fromJson(Map json) => _$ResendDtoFromJson(json); - @override - @JsonKey(name: 'status') - final String? status; - @override - @JsonKey(name: 'message') - final String? message; - @override - @JsonKey(name: 'data') - final ResendDataDto? data; +@override@JsonKey(name: 'status') final String? status; +@override@JsonKey(name: 'message') final String? message; +@override@JsonKey(name: 'data') final ResendDataDto? data; - @override - String toString() { +/// Create a copy of ResendDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ResendDtoCopyWith<_ResendDto> get copyWith => __$ResendDtoCopyWithImpl<_ResendDto>(this, _$identity); + +@override +Map toJson() { + return _$ResendDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResendDto&&(identical(other.status, status) || other.status == status)&&(identical(other.message, message) || other.message == message)&&(identical(other.data, data) || other.data == data)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,status,message,data); +} + +@override +String toString() { return 'ResendDto(status: $status, message: $message, data: $data)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ResendDtoImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.data, data) || other.data == data)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, status, message, data); - - /// Create a copy of ResendDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ResendDtoImplCopyWith<_$ResendDtoImpl> get copyWith => - __$$ResendDtoImplCopyWithImpl<_$ResendDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$ResendDtoImplToJson(this); - } } -abstract class _ResendDto extends ResendDto { - const factory _ResendDto({ - @JsonKey(name: 'status') final String? status, - @JsonKey(name: 'message') final String? message, - @JsonKey(name: 'data') final ResendDataDto? data, - }) = _$ResendDtoImpl; - const _ResendDto._() : super._(); - factory _ResendDto.fromJson(Map json) = - _$ResendDtoImpl.fromJson; - - @override - @JsonKey(name: 'status') - String? get status; - @override - @JsonKey(name: 'message') - String? get message; - @override - @JsonKey(name: 'data') - ResendDataDto? get data; - - /// Create a copy of ResendDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ResendDtoImplCopyWith<_$ResendDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -ResendDataDto _$ResendDataDtoFromJson(Map json) { - return _ResendDataDto.fromJson(json); +/// @nodoc +abstract mixin class _$ResendDtoCopyWith<$Res> implements $ResendDtoCopyWith<$Res> { + factory _$ResendDtoCopyWith(_ResendDto value, $Res Function(_ResendDto) _then) = __$ResendDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'status') String? status,@JsonKey(name: 'message') String? message,@JsonKey(name: 'data') ResendDataDto? data +}); + + +@override $ResendDataDtoCopyWith<$Res>? get data; + } +/// @nodoc +class __$ResendDtoCopyWithImpl<$Res> + implements _$ResendDtoCopyWith<$Res> { + __$ResendDtoCopyWithImpl(this._self, this._then); + + final _ResendDto _self; + final $Res Function(_ResendDto) _then; + +/// Create a copy of ResendDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? status = freezed,Object? message = freezed,Object? data = freezed,}) { + return _then(_ResendDto( +status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,message: freezed == message ? _self.message : message // ignore: cast_nullable_to_non_nullable +as String?,data: freezed == data ? _self.data : data // ignore: cast_nullable_to_non_nullable +as ResendDataDto?, + )); +} + +/// Create a copy of ResendDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ResendDataDtoCopyWith<$Res>? get data { + if (_self.data == null) { + return null; + } + + return $ResendDataDtoCopyWith<$Res>(_self.data!, (value) { + return _then(_self.copyWith(data: value)); + }); +} +} + /// @nodoc mixin _$ResendDataDto { - @JsonKey(name: 'otp_token') - String? get otpToken => throw _privateConstructorUsedError; - @JsonKey(name: 'expires_in') - int? get expiresIn => throw _privateConstructorUsedError; - @JsonKey(name: 'next_resend_in') - int? get nextResendIn => throw _privateConstructorUsedError; + +@JsonKey(name: 'otp_token') String? get otpToken;@JsonKey(name: 'expires_in') int? get expiresIn;@JsonKey(name: 'next_resend_in') int? get nextResendIn; +/// Create a copy of ResendDataDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ResendDataDtoCopyWith get copyWith => _$ResendDataDtoCopyWithImpl(this as ResendDataDto, _$identity); /// Serializes this ResendDataDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as ResendDataDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ResendDataDto&&(identical(other.otpToken, _this.otpToken) || other.otpToken == _this.otpToken)&&(identical(other.expiresIn, _this.expiresIn) || other.expiresIn == _this.expiresIn)&&(identical(other.nextResendIn, _this.nextResendIn) || other.nextResendIn == _this.nextResendIn)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as ResendDataDto; + return Object.hash(runtimeType,_this.otpToken,_this.expiresIn,_this.nextResendIn); +} + +@override +String toString() { + final _this = this as ResendDataDto; + return 'ResendDataDto(otpToken: ${_this.otpToken}, expiresIn: ${_this.expiresIn}, nextResendIn: ${_this.nextResendIn})'; +} + - /// Create a copy of ResendDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $ResendDataDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $ResendDataDtoCopyWith<$Res> { - factory $ResendDataDtoCopyWith( - ResendDataDto value, - $Res Function(ResendDataDto) then, - ) = _$ResendDataDtoCopyWithImpl<$Res, ResendDataDto>; - @useResult - $Res call({ - @JsonKey(name: 'otp_token') String? otpToken, - @JsonKey(name: 'expires_in') int? expiresIn, - @JsonKey(name: 'next_resend_in') int? nextResendIn, - }); -} +abstract mixin class $ResendDataDtoCopyWith<$Res> { + factory $ResendDataDtoCopyWith(ResendDataDto value, $Res Function(ResendDataDto) _then) = _$ResendDataDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'otp_token') String? otpToken,@JsonKey(name: 'expires_in') int? expiresIn,@JsonKey(name: 'next_resend_in') int? nextResendIn +}); + + + +} /// @nodoc -class _$ResendDataDtoCopyWithImpl<$Res, $Val extends ResendDataDto> +class _$ResendDataDtoCopyWithImpl<$Res> implements $ResendDataDtoCopyWith<$Res> { - _$ResendDataDtoCopyWithImpl(this._value, this._then); + _$ResendDataDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final ResendDataDto _self; + final $Res Function(ResendDataDto) _then; - /// Create a copy of ResendDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? otpToken = freezed, - Object? expiresIn = freezed, - Object? nextResendIn = freezed, - }) { - return _then( - _value.copyWith( - otpToken: freezed == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String?, - expiresIn: freezed == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int?, - nextResendIn: freezed == nextResendIn - ? _value.nextResendIn - : nextResendIn // ignore: cast_nullable_to_non_nullable - as int?, - ) - as $Val, - ); - } +/// Create a copy of ResendDataDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? otpToken = freezed,Object? expiresIn = freezed,Object? nextResendIn = freezed,}) { + return _then(ResendDataDto( +otpToken: freezed == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String?,expiresIn: freezed == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int?,nextResendIn: freezed == nextResendIn ? _self.nextResendIn : nextResendIn // ignore: cast_nullable_to_non_nullable +as int?, + )); } -/// @nodoc -abstract class _$$ResendDataDtoImplCopyWith<$Res> - implements $ResendDataDtoCopyWith<$Res> { - factory _$$ResendDataDtoImplCopyWith( - _$ResendDataDtoImpl value, - $Res Function(_$ResendDataDtoImpl) then, - ) = __$$ResendDataDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'otp_token') String? otpToken, - @JsonKey(name: 'expires_in') int? expiresIn, - @JsonKey(name: 'next_resend_in') int? nextResendIn, - }); } -/// @nodoc -class __$$ResendDataDtoImplCopyWithImpl<$Res> - extends _$ResendDataDtoCopyWithImpl<$Res, _$ResendDataDtoImpl> - implements _$$ResendDataDtoImplCopyWith<$Res> { - __$$ResendDataDtoImplCopyWithImpl( - _$ResendDataDtoImpl _value, - $Res Function(_$ResendDataDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of ResendDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? otpToken = freezed, - Object? expiresIn = freezed, - Object? nextResendIn = freezed, - }) { - return _then( - _$ResendDataDtoImpl( - otpToken: freezed == otpToken - ? _value.otpToken - : otpToken // ignore: cast_nullable_to_non_nullable - as String?, - expiresIn: freezed == expiresIn - ? _value.expiresIn - : expiresIn // ignore: cast_nullable_to_non_nullable - as int?, - nextResendIn: freezed == nextResendIn - ? _value.nextResendIn - : nextResendIn // ignore: cast_nullable_to_non_nullable - as int?, - ), - ); - } +/// Adds pattern-matching-related methods to [ResendDataDto]. +extension ResendDataDtoPatterns on ResendDataDto { +/// 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( _ResendDataDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ResendDataDto() 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( _ResendDataDto value) $default,){ +final _that = this; +switch (_that) { +case _ResendDataDto(): +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( _ResendDataDto value)? $default,){ +final _that = this; +switch (_that) { +case _ResendDataDto() 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(@JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_in') int? expiresIn, @JsonKey(name: 'next_resend_in') int? nextResendIn)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ResendDataDto() when $default != null: +return $default(_that.otpToken,_that.expiresIn,_that.nextResendIn);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(@JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_in') int? expiresIn, @JsonKey(name: 'next_resend_in') int? nextResendIn) $default,) {final _that = this; +switch (_that) { +case _ResendDataDto(): +return $default(_that.otpToken,_that.expiresIn,_that.nextResendIn);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(@JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_in') int? expiresIn, @JsonKey(name: 'next_resend_in') int? nextResendIn)? $default,) {final _that = this; +switch (_that) { +case _ResendDataDto() when $default != null: +return $default(_that.otpToken,_that.expiresIn,_that.nextResendIn);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$ResendDataDtoImpl implements _ResendDataDto { - const _$ResendDataDtoImpl({ - @JsonKey(name: 'otp_token') this.otpToken, - @JsonKey(name: 'expires_in') this.expiresIn, - @JsonKey(name: 'next_resend_in') this.nextResendIn, - }); - factory _$ResendDataDtoImpl.fromJson(Map json) => - _$$ResendDataDtoImplFromJson(json); +class _ResendDataDto implements ResendDataDto { + const _ResendDataDto({@JsonKey(name: 'otp_token') this.otpToken, @JsonKey(name: 'expires_in') this.expiresIn, @JsonKey(name: 'next_resend_in') this.nextResendIn}); + factory _ResendDataDto.fromJson(Map json) => _$ResendDataDtoFromJson(json); - @override - @JsonKey(name: 'otp_token') - final String? otpToken; - @override - @JsonKey(name: 'expires_in') - final int? expiresIn; - @override - @JsonKey(name: 'next_resend_in') - final int? nextResendIn; +@override@JsonKey(name: 'otp_token') final String? otpToken; +@override@JsonKey(name: 'expires_in') final int? expiresIn; +@override@JsonKey(name: 'next_resend_in') final int? nextResendIn; - @override - String toString() { +/// Create a copy of ResendDataDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ResendDataDtoCopyWith<_ResendDataDto> get copyWith => __$ResendDataDtoCopyWithImpl<_ResendDataDto>(this, _$identity); + +@override +Map toJson() { + return _$ResendDataDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ResendDataDto&&(identical(other.otpToken, otpToken) || other.otpToken == otpToken)&&(identical(other.expiresIn, expiresIn) || other.expiresIn == expiresIn)&&(identical(other.nextResendIn, nextResendIn) || other.nextResendIn == nextResendIn)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,otpToken,expiresIn,nextResendIn); +} + +@override +String toString() { return 'ResendDataDto(otpToken: $otpToken, expiresIn: $expiresIn, nextResendIn: $nextResendIn)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$ResendDataDtoImpl && - (identical(other.otpToken, otpToken) || - other.otpToken == otpToken) && - (identical(other.expiresIn, expiresIn) || - other.expiresIn == expiresIn) && - (identical(other.nextResendIn, nextResendIn) || - other.nextResendIn == nextResendIn)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, otpToken, expiresIn, nextResendIn); - - /// Create a copy of ResendDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$ResendDataDtoImplCopyWith<_$ResendDataDtoImpl> get copyWith => - __$$ResendDataDtoImplCopyWithImpl<_$ResendDataDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$ResendDataDtoImplToJson(this); - } } -abstract class _ResendDataDto implements ResendDataDto { - const factory _ResendDataDto({ - @JsonKey(name: 'otp_token') final String? otpToken, - @JsonKey(name: 'expires_in') final int? expiresIn, - @JsonKey(name: 'next_resend_in') final int? nextResendIn, - }) = _$ResendDataDtoImpl; - factory _ResendDataDto.fromJson(Map json) = - _$ResendDataDtoImpl.fromJson; - - @override - @JsonKey(name: 'otp_token') - String? get otpToken; - @override - @JsonKey(name: 'expires_in') - int? get expiresIn; - @override - @JsonKey(name: 'next_resend_in') - int? get nextResendIn; - - /// Create a copy of ResendDataDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$ResendDataDtoImplCopyWith<_$ResendDataDtoImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$ResendDataDtoCopyWith<$Res> implements $ResendDataDtoCopyWith<$Res> { + factory _$ResendDataDtoCopyWith(_ResendDataDto value, $Res Function(_ResendDataDto) _then) = __$ResendDataDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'otp_token') String? otpToken,@JsonKey(name: 'expires_in') int? expiresIn,@JsonKey(name: 'next_resend_in') int? nextResendIn +}); + + + + +} +/// @nodoc +class __$ResendDataDtoCopyWithImpl<$Res> + implements _$ResendDataDtoCopyWith<$Res> { + __$ResendDataDtoCopyWithImpl(this._self, this._then); + + final _ResendDataDto _self; + final $Res Function(_ResendDataDto) _then; + +/// Create a copy of ResendDataDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? otpToken = freezed,Object? expiresIn = freezed,Object? nextResendIn = freezed,}) { + return _then(_ResendDataDto( +otpToken: freezed == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String?,expiresIn: freezed == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable +as int?,nextResendIn: freezed == nextResendIn ? _self.nextResendIn : nextResendIn // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/lib/infrastructure/auth/auth_dtos.g.dart b/lib/infrastructure/auth/auth_dtos.g.dart index 6569175..4215b84 100644 --- a/lib/infrastructure/auth/auth_dtos.g.dart +++ b/lib/infrastructure/auth/auth_dtos.g.dart @@ -6,8 +6,8 @@ part of 'auth_dtos.dart'; // JsonSerializableGenerator // ************************************************************************** -_$CheckPhoneDtoImpl _$$CheckPhoneDtoImplFromJson(Map json) => - _$CheckPhoneDtoImpl( +_CheckPhoneDto _$CheckPhoneDtoFromJson(Map json) => + _CheckPhoneDto( status: json['status'] as String?, message: json['message'] as String?, data: json['data'] == null @@ -15,95 +15,85 @@ _$CheckPhoneDtoImpl _$$CheckPhoneDtoImplFromJson(Map json) => : CheckPhoneDataDto.fromJson(json['data'] as Map), ); -Map _$$CheckPhoneDtoImplToJson(_$CheckPhoneDtoImpl instance) => +Map _$CheckPhoneDtoToJson(_CheckPhoneDto instance) => { 'status': instance.status, 'message': instance.message, 'data': instance.data, }; -_$CheckPhoneDataDtoImpl _$$CheckPhoneDataDtoImplFromJson( - Map json, -) => _$CheckPhoneDataDtoImpl(phoneNumber: json['phone_number'] as String?); +_CheckPhoneDataDto _$CheckPhoneDataDtoFromJson(Map json) => + _CheckPhoneDataDto(phoneNumber: json['phone_number'] as String?); -Map _$$CheckPhoneDataDtoImplToJson( - _$CheckPhoneDataDtoImpl instance, -) => {'phone_number': instance.phoneNumber}; +Map _$CheckPhoneDataDtoToJson(_CheckPhoneDataDto instance) => + {'phone_number': instance.phoneNumber}; -_$RegisterDtoImpl _$$RegisterDtoImplFromJson(Map json) => - _$RegisterDtoImpl( - status: json['status'] as String?, - message: json['message'] as String?, - data: json['data'] == null - ? null - : RegisterDataDto.fromJson(json['data'] as Map), - ); - -Map _$$RegisterDtoImplToJson(_$RegisterDtoImpl instance) => - { - 'status': instance.status, - 'message': instance.message, - 'data': instance.data, - }; - -_$RegisterDataDtoImpl _$$RegisterDataDtoImplFromJson( - Map json, -) => _$RegisterDataDtoImpl( - registrationToken: json['registration_token'] as String?, - otpToken: json['otp_token'] as String?, - expiresIn: (json['expires_in'] as num?)?.toInt(), +_RegisterDto _$RegisterDtoFromJson(Map json) => _RegisterDto( + status: json['status'] as String?, + message: json['message'] as String?, + data: json['data'] == null + ? null + : RegisterDataDto.fromJson(json['data'] as Map), ); -Map _$$RegisterDataDtoImplToJson( - _$RegisterDataDtoImpl instance, -) => { - 'registration_token': instance.registrationToken, - 'otp_token': instance.otpToken, - 'expires_in': instance.expiresIn, -}; - -_$VerifyDtoImpl _$$VerifyDtoImplFromJson(Map json) => - _$VerifyDtoImpl( - status: json['status'] as String?, - message: json['message'] as String?, - data: json['data'] == null - ? null - : VerifyDataDto.fromJson(json['data'] as Map), - ); - -Map _$$VerifyDtoImplToJson(_$VerifyDtoImpl instance) => +Map _$RegisterDtoToJson(_RegisterDto instance) => { 'status': instance.status, 'message': instance.message, 'data': instance.data, }; -_$VerifyDataDtoImpl _$$VerifyDataDtoImplFromJson(Map json) => - _$VerifyDataDtoImpl( +_RegisterDataDto _$RegisterDataDtoFromJson(Map json) => + _RegisterDataDto( registrationToken: json['registration_token'] as String?, + otpToken: json['otp_token'] as String?, + expiresIn: (json['expires_in'] as num?)?.toInt(), ); -Map _$$VerifyDataDtoImplToJson(_$VerifyDataDtoImpl instance) => +Map _$RegisterDataDtoToJson(_RegisterDataDto instance) => + { + 'registration_token': instance.registrationToken, + 'otp_token': instance.otpToken, + 'expires_in': instance.expiresIn, + }; + +_VerifyDto _$VerifyDtoFromJson(Map json) => _VerifyDto( + status: json['status'] as String?, + message: json['message'] as String?, + data: json['data'] == null + ? null + : VerifyDataDto.fromJson(json['data'] as Map), +); + +Map _$VerifyDtoToJson(_VerifyDto instance) => + { + 'status': instance.status, + 'message': instance.message, + 'data': instance.data, + }; + +_VerifyDataDto _$VerifyDataDtoFromJson(Map json) => + _VerifyDataDto(registrationToken: json['registration_token'] as String?); + +Map _$VerifyDataDtoToJson(_VerifyDataDto instance) => {'registration_token': instance.registrationToken}; -_$LoginDtoImpl _$$LoginDtoImplFromJson(Map json) => - _$LoginDtoImpl( - status: json['status'] as String?, - message: json['message'] as String?, - data: json['data'] == null - ? null - : LoginDataDto.fromJson(json['data'] as Map), - ); +_LoginDto _$LoginDtoFromJson(Map json) => _LoginDto( + status: json['status'] as String?, + message: json['message'] as String?, + data: json['data'] == null + ? null + : LoginDataDto.fromJson(json['data'] as Map), +); -Map _$$LoginDtoImplToJson(_$LoginDtoImpl instance) => - { - 'status': instance.status, - 'message': instance.message, - 'data': instance.data, - }; +Map _$LoginDtoToJson(_LoginDto instance) => { + 'status': instance.status, + 'message': instance.message, + 'data': instance.data, +}; -_$LoginDataDtoImpl _$$LoginDataDtoImplFromJson(Map json) => - _$LoginDataDtoImpl( +_LoginDataDto _$LoginDataDtoFromJson(Map json) => + _LoginDataDto( accessToken: json['access_token'] as String?, refreshToken: json['refresh_token'] as String?, user: json['user'] == null @@ -111,53 +101,50 @@ _$LoginDataDtoImpl _$$LoginDataDtoImplFromJson(Map json) => : UserDto.fromJson(json['user'] as Map), ); -Map _$$LoginDataDtoImplToJson(_$LoginDataDtoImpl instance) => +Map _$LoginDataDtoToJson(_LoginDataDto instance) => { 'access_token': instance.accessToken, 'refresh_token': instance.refreshToken, 'user': instance.user, }; -_$UserDtoImpl _$$UserDtoImplFromJson(Map json) => - _$UserDtoImpl( - id: json['id'] as String?, - name: json['name'] as String?, - phoneNumber: json['phone_number'] as String?, - birthDate: json['birth_date'] as String?, - ); +_UserDto _$UserDtoFromJson(Map json) => _UserDto( + id: json['id'] as String?, + name: json['name'] as String?, + phoneNumber: json['phone_number'] as String?, + birthDate: json['birth_date'] as String?, +); -Map _$$UserDtoImplToJson(_$UserDtoImpl instance) => - { - 'id': instance.id, - 'name': instance.name, - 'phone_number': instance.phoneNumber, - 'birth_date': instance.birthDate, - }; +Map _$UserDtoToJson(_UserDto instance) => { + 'id': instance.id, + 'name': instance.name, + 'phone_number': instance.phoneNumber, + 'birth_date': instance.birthDate, +}; -_$ResendDtoImpl _$$ResendDtoImplFromJson(Map json) => - _$ResendDtoImpl( - status: json['status'] as String?, - message: json['message'] as String?, - data: json['data'] == null - ? null - : ResendDataDto.fromJson(json['data'] as Map), - ); +_ResendDto _$ResendDtoFromJson(Map json) => _ResendDto( + status: json['status'] as String?, + message: json['message'] as String?, + data: json['data'] == null + ? null + : ResendDataDto.fromJson(json['data'] as Map), +); -Map _$$ResendDtoImplToJson(_$ResendDtoImpl instance) => +Map _$ResendDtoToJson(_ResendDto instance) => { 'status': instance.status, 'message': instance.message, 'data': instance.data, }; -_$ResendDataDtoImpl _$$ResendDataDtoImplFromJson(Map json) => - _$ResendDataDtoImpl( +_ResendDataDto _$ResendDataDtoFromJson(Map json) => + _ResendDataDto( otpToken: json['otp_token'] as String?, expiresIn: (json['expires_in'] as num?)?.toInt(), nextResendIn: (json['next_resend_in'] as num?)?.toInt(), ); -Map _$$ResendDataDtoImplToJson(_$ResendDataDtoImpl instance) => +Map _$ResendDataDtoToJson(_ResendDataDto instance) => { 'otp_token': instance.otpToken, 'expires_in': instance.expiresIn, diff --git a/lib/infrastructure/auth/datasources/remote_data_provider.dart b/lib/infrastructure/auth/datasources/remote_data_provider.dart index f8e7256..86c2dad 100644 --- a/lib/infrastructure/auth/datasources/remote_data_provider.dart +++ b/lib/infrastructure/auth/datasources/remote_data_provider.dart @@ -17,6 +17,42 @@ class AuthRemoteDataProvider { AuthRemoteDataProvider(this._apiClient); + static const _defaultErrorMessage = 'Terjadi kesalahan coba lagi nanti'; + + Map? _firstError(dynamic body) { + final errors = body is Map ? body['errors'] : null; + if (errors is! List || errors.isEmpty || errors.first is! Map) return null; + return errors.first as Map; + } + + /// Kode bisa dikirim sebagai string ("304") maupun int (304). + String? _errorCode(dynamic body) => _firstError(body)?['code']?.toString(); + + /// Pesan untuk error validasi (`303`/`310`) dan aturan bisnis (`304`). + String _errorMessage(dynamic body) { + final error = _firstError(body); + final code = error?['code']?.toString(); + final cause = error?['cause']?.toString() ?? ''; + final lower = cause.toLowerCase(); + + if (lower.contains('password') && + (lower.contains('min') || + lower.contains('least') || + lower.contains('short'))) { + final length = RegExp(r'\d+').firstMatch(cause)?.group(0); + return length == null + ? 'Kata sandi terlalu pendek' + : 'Kata sandi minimal $length karakter'; + } + + if ((code == '303' || code == '304' || code == '310') && + cause.isNotEmpty) { + return cause; + } + + return _defaultErrorMessage; + } + Future> checkPhone({ required String phoneNumber, }) async { @@ -160,33 +196,14 @@ class AuthRemoteDataProvider { ); if (response.data['success'] == false) { - if ((response.data['errors'] as List).isNotEmpty) { - if (response.data['errors'][0]['code'] == 900) { - return DC.error( - AuthFailure.dynamicErrorMessage( - 'Invalid Registration, Lakukan kembali dari awal', - ), - ); - } else if (response.data['errors'][0]['code'] == "304") { - return DC.error( - AuthFailure.dynamicErrorMessage( - response.data['errors'][0]['cause'], - ), - ); - } else { - return DC.error( - AuthFailure.dynamicErrorMessage( - 'Terjadi kesalahan coba lagi nanti', - ), - ); - } - } else { - return DC.error( - AuthFailure.dynamicErrorMessage( - 'Terjadi kesalahan coba lagi nanti', - ), - ); - } + final code = _errorCode(response.data); + return DC.error( + AuthFailure.dynamicErrorMessage( + code == '900' + ? 'Invalid Registration, Lakukan kembali dari awal' + : _errorMessage(response.data), + ), + ); } final dto = LoginDto.fromJson(response.data['data']); diff --git a/lib/infrastructure/auth/dto/check_phone_dto.dart b/lib/infrastructure/auth/dto/check_phone_dto.dart index 50bfc3d..ade4e6f 100644 --- a/lib/infrastructure/auth/dto/check_phone_dto.dart +++ b/lib/infrastructure/auth/dto/check_phone_dto.dart @@ -1,7 +1,7 @@ part of '../auth_dtos.dart'; @freezed -class CheckPhoneDto with _$CheckPhoneDto { +abstract class CheckPhoneDto with _$CheckPhoneDto { const CheckPhoneDto._(); const factory CheckPhoneDto({ @@ -20,7 +20,7 @@ class CheckPhoneDto with _$CheckPhoneDto { } @freezed -class CheckPhoneDataDto with _$CheckPhoneDataDto { +abstract class CheckPhoneDataDto with _$CheckPhoneDataDto { const factory CheckPhoneDataDto({ @JsonKey(name: 'phone_number') String? phoneNumber, }) = _CheckPhoneDataDto; diff --git a/lib/infrastructure/auth/dto/login_dto.dart b/lib/infrastructure/auth/dto/login_dto.dart index a3aba23..37e1724 100644 --- a/lib/infrastructure/auth/dto/login_dto.dart +++ b/lib/infrastructure/auth/dto/login_dto.dart @@ -1,7 +1,7 @@ part of '../auth_dtos.dart'; @freezed -class LoginDto with _$LoginDto { +abstract class LoginDto with _$LoginDto { const factory LoginDto({ @JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @@ -24,7 +24,7 @@ class LoginDto with _$LoginDto { } @freezed -class LoginDataDto with _$LoginDataDto { +abstract class LoginDataDto with _$LoginDataDto { const factory LoginDataDto({ @JsonKey(name: 'access_token') String? accessToken, @JsonKey(name: 'refresh_token') String? refreshToken, @@ -36,7 +36,7 @@ class LoginDataDto with _$LoginDataDto { } @freezed -class UserDto with _$UserDto { +abstract class UserDto with _$UserDto { const factory UserDto({ @JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, diff --git a/lib/infrastructure/auth/dto/register_dto.dart b/lib/infrastructure/auth/dto/register_dto.dart index 4cadceb..1ebdc72 100644 --- a/lib/infrastructure/auth/dto/register_dto.dart +++ b/lib/infrastructure/auth/dto/register_dto.dart @@ -1,7 +1,7 @@ part of '../auth_dtos.dart'; @freezed -class RegisterDto with _$RegisterDto { +abstract class RegisterDto with _$RegisterDto { const RegisterDto._(); const factory RegisterDto({ @@ -24,7 +24,7 @@ class RegisterDto with _$RegisterDto { } @freezed -class RegisterDataDto with _$RegisterDataDto { +abstract class RegisterDataDto with _$RegisterDataDto { const factory RegisterDataDto({ @JsonKey(name: 'registration_token') String? registrationToken, @JsonKey(name: 'otp_token') String? otpToken, diff --git a/lib/infrastructure/auth/dto/resend_dto.dart b/lib/infrastructure/auth/dto/resend_dto.dart index 863df73..e78e445 100644 --- a/lib/infrastructure/auth/dto/resend_dto.dart +++ b/lib/infrastructure/auth/dto/resend_dto.dart @@ -1,7 +1,7 @@ part of '../auth_dtos.dart'; @freezed -class ResendDto with _$ResendDto { +abstract class ResendDto with _$ResendDto { const factory ResendDto({ @JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @@ -24,7 +24,7 @@ class ResendDto with _$ResendDto { } @freezed -class ResendDataDto with _$ResendDataDto { +abstract class ResendDataDto with _$ResendDataDto { const factory ResendDataDto({ @JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_in') int? expiresIn, diff --git a/lib/infrastructure/auth/dto/verify_dto.dart b/lib/infrastructure/auth/dto/verify_dto.dart index bb9769d..5bcbfe1 100644 --- a/lib/infrastructure/auth/dto/verify_dto.dart +++ b/lib/infrastructure/auth/dto/verify_dto.dart @@ -1,7 +1,7 @@ part of '../auth_dtos.dart'; @freezed -class VerifyDto with _$VerifyDto { +abstract class VerifyDto with _$VerifyDto { const factory VerifyDto({ @JsonKey(name: 'status') String? status, @JsonKey(name: 'message') String? message, @@ -22,7 +22,7 @@ class VerifyDto with _$VerifyDto { } @freezed -class VerifyDataDto with _$VerifyDataDto { +abstract class VerifyDataDto with _$VerifyDataDto { const factory VerifyDataDto({ @JsonKey(name: 'registration_token') String? registrationToken, }) = _VerifyDataDto; diff --git a/lib/infrastructure/customer/customer_dtos.dart b/lib/infrastructure/customer/customer_dtos.dart deleted file mode 100644 index c53f3ec..0000000 --- a/lib/infrastructure/customer/customer_dtos.dart +++ /dev/null @@ -1,8 +0,0 @@ -import 'package:freezed_annotation/freezed_annotation.dart'; - -import '../../domain/customer/customer.dart'; - -part 'customer_dtos.freezed.dart'; -part 'customer_dtos.g.dart'; - -part 'dtos/customer_point_dto.dart'; diff --git a/lib/infrastructure/customer/customer_dtos.freezed.dart b/lib/infrastructure/customer/customer_dtos.freezed.dart deleted file mode 100644 index 86a7403..0000000 --- a/lib/infrastructure/customer/customer_dtos.freezed.dart +++ /dev/null @@ -1,443 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'customer_dtos.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -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', -); - -CustomerPointDto _$CustomerPointDtoFromJson(Map json) { - return _CustomerPointDto.fromJson(json); -} - -/// @nodoc -mixin _$CustomerPointDto { - @JsonKey(name: 'status') - String? get status => throw _privateConstructorUsedError; - @JsonKey(name: 'message') - String? get message => throw _privateConstructorUsedError; - @JsonKey(name: 'data') - CustomerPointDataDto? get data => throw _privateConstructorUsedError; - - /// Serializes this CustomerPointDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of CustomerPointDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CustomerPointDtoCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $CustomerPointDtoCopyWith<$Res> { - factory $CustomerPointDtoCopyWith( - CustomerPointDto value, - $Res Function(CustomerPointDto) then, - ) = _$CustomerPointDtoCopyWithImpl<$Res, CustomerPointDto>; - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') CustomerPointDataDto? data, - }); - - $CustomerPointDataDtoCopyWith<$Res>? get data; -} - -/// @nodoc -class _$CustomerPointDtoCopyWithImpl<$Res, $Val extends CustomerPointDto> - implements $CustomerPointDtoCopyWith<$Res> { - _$CustomerPointDtoCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CustomerPointDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _value.copyWith( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as CustomerPointDataDto?, - ) - as $Val, - ); - } - - /// Create a copy of CustomerPointDto - /// with the given fields replaced by the non-null parameter values. - @override - @pragma('vm:prefer-inline') - $CustomerPointDataDtoCopyWith<$Res>? get data { - if (_value.data == null) { - return null; - } - - return $CustomerPointDataDtoCopyWith<$Res>(_value.data!, (value) { - return _then(_value.copyWith(data: value) as $Val); - }); - } -} - -/// @nodoc -abstract class _$$CustomerPointDtoImplCopyWith<$Res> - implements $CustomerPointDtoCopyWith<$Res> { - factory _$$CustomerPointDtoImplCopyWith( - _$CustomerPointDtoImpl value, - $Res Function(_$CustomerPointDtoImpl) then, - ) = __$$CustomerPointDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') CustomerPointDataDto? data, - }); - - @override - $CustomerPointDataDtoCopyWith<$Res>? get data; -} - -/// @nodoc -class __$$CustomerPointDtoImplCopyWithImpl<$Res> - extends _$CustomerPointDtoCopyWithImpl<$Res, _$CustomerPointDtoImpl> - implements _$$CustomerPointDtoImplCopyWith<$Res> { - __$$CustomerPointDtoImplCopyWithImpl( - _$CustomerPointDtoImpl _value, - $Res Function(_$CustomerPointDtoImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerPointDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? status = freezed, - Object? message = freezed, - Object? data = freezed, - }) { - return _then( - _$CustomerPointDtoImpl( - status: freezed == status - ? _value.status - : status // ignore: cast_nullable_to_non_nullable - as String?, - message: freezed == message - ? _value.message - : message // ignore: cast_nullable_to_non_nullable - as String?, - data: freezed == data - ? _value.data - : data // ignore: cast_nullable_to_non_nullable - as CustomerPointDataDto?, - ), - ); - } -} - -/// @nodoc -@JsonSerializable() -class _$CustomerPointDtoImpl extends _CustomerPointDto { - const _$CustomerPointDtoImpl({ - @JsonKey(name: 'status') this.status, - @JsonKey(name: 'message') this.message, - @JsonKey(name: 'data') this.data, - }) : super._(); - - factory _$CustomerPointDtoImpl.fromJson(Map json) => - _$$CustomerPointDtoImplFromJson(json); - - @override - @JsonKey(name: 'status') - final String? status; - @override - @JsonKey(name: 'message') - final String? message; - @override - @JsonKey(name: 'data') - final CustomerPointDataDto? data; - - @override - String toString() { - return 'CustomerPointDto(status: $status, message: $message, data: $data)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CustomerPointDtoImpl && - (identical(other.status, status) || other.status == status) && - (identical(other.message, message) || other.message == message) && - (identical(other.data, data) || other.data == data)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, status, message, data); - - /// Create a copy of CustomerPointDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CustomerPointDtoImplCopyWith<_$CustomerPointDtoImpl> get copyWith => - __$$CustomerPointDtoImplCopyWithImpl<_$CustomerPointDtoImpl>( - this, - _$identity, - ); - - @override - Map toJson() { - return _$$CustomerPointDtoImplToJson(this); - } -} - -abstract class _CustomerPointDto extends CustomerPointDto { - const factory _CustomerPointDto({ - @JsonKey(name: 'status') final String? status, - @JsonKey(name: 'message') final String? message, - @JsonKey(name: 'data') final CustomerPointDataDto? data, - }) = _$CustomerPointDtoImpl; - const _CustomerPointDto._() : super._(); - - factory _CustomerPointDto.fromJson(Map json) = - _$CustomerPointDtoImpl.fromJson; - - @override - @JsonKey(name: 'status') - String? get status; - @override - @JsonKey(name: 'message') - String? get message; - @override - @JsonKey(name: 'data') - CustomerPointDataDto? get data; - - /// Create a copy of CustomerPointDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CustomerPointDtoImplCopyWith<_$CustomerPointDtoImpl> get copyWith => - throw _privateConstructorUsedError; -} - -CustomerPointDataDto _$CustomerPointDataDtoFromJson(Map json) { - return _CustomerPointDataDto.fromJson(json); -} - -/// @nodoc -mixin _$CustomerPointDataDto { - @JsonKey(name: 'total_points') - int? get totalPoints => throw _privateConstructorUsedError; - @JsonKey(name: 'last_updated') - String? get lastUpdated => throw _privateConstructorUsedError; - - /// Serializes this CustomerPointDataDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; - - /// Create a copy of CustomerPointDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CustomerPointDataDtoCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $CustomerPointDataDtoCopyWith<$Res> { - factory $CustomerPointDataDtoCopyWith( - CustomerPointDataDto value, - $Res Function(CustomerPointDataDto) then, - ) = _$CustomerPointDataDtoCopyWithImpl<$Res, CustomerPointDataDto>; - @useResult - $Res call({ - @JsonKey(name: 'total_points') int? totalPoints, - @JsonKey(name: 'last_updated') String? lastUpdated, - }); -} - -/// @nodoc -class _$CustomerPointDataDtoCopyWithImpl< - $Res, - $Val extends CustomerPointDataDto -> - implements $CustomerPointDataDtoCopyWith<$Res> { - _$CustomerPointDataDtoCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of CustomerPointDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? totalPoints = freezed, Object? lastUpdated = freezed}) { - return _then( - _value.copyWith( - totalPoints: freezed == totalPoints - ? _value.totalPoints - : totalPoints // ignore: cast_nullable_to_non_nullable - as int?, - lastUpdated: freezed == lastUpdated - ? _value.lastUpdated - : lastUpdated // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } -} - -/// @nodoc -abstract class _$$CustomerPointDataDtoImplCopyWith<$Res> - implements $CustomerPointDataDtoCopyWith<$Res> { - factory _$$CustomerPointDataDtoImplCopyWith( - _$CustomerPointDataDtoImpl value, - $Res Function(_$CustomerPointDataDtoImpl) then, - ) = __$$CustomerPointDataDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'total_points') int? totalPoints, - @JsonKey(name: 'last_updated') String? lastUpdated, - }); -} - -/// @nodoc -class __$$CustomerPointDataDtoImplCopyWithImpl<$Res> - extends _$CustomerPointDataDtoCopyWithImpl<$Res, _$CustomerPointDataDtoImpl> - implements _$$CustomerPointDataDtoImplCopyWith<$Res> { - __$$CustomerPointDataDtoImplCopyWithImpl( - _$CustomerPointDataDtoImpl _value, - $Res Function(_$CustomerPointDataDtoImpl) _then, - ) : super(_value, _then); - - /// Create a copy of CustomerPointDataDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({Object? totalPoints = freezed, Object? lastUpdated = freezed}) { - return _then( - _$CustomerPointDataDtoImpl( - totalPoints: freezed == totalPoints - ? _value.totalPoints - : totalPoints // ignore: cast_nullable_to_non_nullable - as int?, - lastUpdated: freezed == lastUpdated - ? _value.lastUpdated - : lastUpdated // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } -} - -/// @nodoc -@JsonSerializable() -class _$CustomerPointDataDtoImpl implements _CustomerPointDataDto { - const _$CustomerPointDataDtoImpl({ - @JsonKey(name: 'total_points') this.totalPoints, - @JsonKey(name: 'last_updated') this.lastUpdated, - }); - - factory _$CustomerPointDataDtoImpl.fromJson(Map json) => - _$$CustomerPointDataDtoImplFromJson(json); - - @override - @JsonKey(name: 'total_points') - final int? totalPoints; - @override - @JsonKey(name: 'last_updated') - final String? lastUpdated; - - @override - String toString() { - return 'CustomerPointDataDto(totalPoints: $totalPoints, lastUpdated: $lastUpdated)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CustomerPointDataDtoImpl && - (identical(other.totalPoints, totalPoints) || - other.totalPoints == totalPoints) && - (identical(other.lastUpdated, lastUpdated) || - other.lastUpdated == lastUpdated)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, totalPoints, lastUpdated); - - /// Create a copy of CustomerPointDataDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CustomerPointDataDtoImplCopyWith<_$CustomerPointDataDtoImpl> - get copyWith => - __$$CustomerPointDataDtoImplCopyWithImpl<_$CustomerPointDataDtoImpl>( - this, - _$identity, - ); - - @override - Map toJson() { - return _$$CustomerPointDataDtoImplToJson(this); - } -} - -abstract class _CustomerPointDataDto implements CustomerPointDataDto { - const factory _CustomerPointDataDto({ - @JsonKey(name: 'total_points') final int? totalPoints, - @JsonKey(name: 'last_updated') final String? lastUpdated, - }) = _$CustomerPointDataDtoImpl; - - factory _CustomerPointDataDto.fromJson(Map json) = - _$CustomerPointDataDtoImpl.fromJson; - - @override - @JsonKey(name: 'total_points') - int? get totalPoints; - @override - @JsonKey(name: 'last_updated') - String? get lastUpdated; - - /// Create a copy of CustomerPointDataDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CustomerPointDataDtoImplCopyWith<_$CustomerPointDataDtoImpl> - get copyWith => throw _privateConstructorUsedError; -} diff --git a/lib/infrastructure/customer/customer_dtos.g.dart b/lib/infrastructure/customer/customer_dtos.g.dart deleted file mode 100644 index 2a573d1..0000000 --- a/lib/infrastructure/customer/customer_dtos.g.dart +++ /dev/null @@ -1,39 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'customer_dtos.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$CustomerPointDtoImpl _$$CustomerPointDtoImplFromJson( - Map json, -) => _$CustomerPointDtoImpl( - status: json['status'] as String?, - message: json['message'] as String?, - data: json['data'] == null - ? null - : CustomerPointDataDto.fromJson(json['data'] as Map), -); - -Map _$$CustomerPointDtoImplToJson( - _$CustomerPointDtoImpl instance, -) => { - 'status': instance.status, - 'message': instance.message, - 'data': instance.data, -}; - -_$CustomerPointDataDtoImpl _$$CustomerPointDataDtoImplFromJson( - Map json, -) => _$CustomerPointDataDtoImpl( - totalPoints: (json['total_points'] as num?)?.toInt(), - lastUpdated: json['last_updated'] as String?, -); - -Map _$$CustomerPointDataDtoImplToJson( - _$CustomerPointDataDtoImpl instance, -) => { - 'total_points': instance.totalPoints, - 'last_updated': instance.lastUpdated, -}; diff --git a/lib/infrastructure/customer/datasources/remote_data_provider.dart b/lib/infrastructure/customer/datasources/remote_data_provider.dart deleted file mode 100644 index 1af9a17..0000000 --- a/lib/infrastructure/customer/datasources/remote_data_provider.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'dart:developer'; - -import 'package:data_channel/data_channel.dart'; -import 'package:injectable/injectable.dart'; - -import '../../../common/api/api_client.dart'; -import '../../../common/api/api_failure.dart'; -import '../../../common/function/app_function.dart'; -import '../../../common/url/api_path.dart'; -import '../../../domain/customer/customer.dart'; -import '../customer_dtos.dart'; - -@injectable -class CustomerRemoteDataProvider { - final ApiClient _apiClient; - final String _logName = "CustomerRemoteDataProvider"; - - CustomerRemoteDataProvider(this._apiClient); - - Future> fetchCustomerPoint() async { - try { - final response = await _apiClient.get( - ApiPath.customerPoint, - headers: getAuthorizationHeader(), - ); - - if (response.data['code'] == 401) { - return DC.error( - CustomerFailure.serverError( - ApiFailure.unauthorized('Session Expired'), - ), - ); - } - - if (response.data['status'] == false) { - return DC.error( - CustomerFailure.dynamicErrorMessage( - 'Terjadi kesalahan coba lagi nanti', - ), - ); - } - - final dto = CustomerPointDto.fromJson(response.data['data']); - return DC.data(dto); - } on ApiFailure catch (e, s) { - log('fetchCustomerPoint', name: _logName, error: e, stackTrace: s); - return DC.error(CustomerFailure.serverError(e)); - } - } -} diff --git a/lib/infrastructure/customer/dtos/customer_point_dto.dart b/lib/infrastructure/customer/dtos/customer_point_dto.dart deleted file mode 100644 index 9d9515e..0000000 --- a/lib/infrastructure/customer/dtos/customer_point_dto.dart +++ /dev/null @@ -1,34 +0,0 @@ -part of '../customer_dtos.dart'; - -@freezed -class CustomerPointDto with _$CustomerPointDto { - const factory CustomerPointDto({ - @JsonKey(name: 'status') String? status, - @JsonKey(name: 'message') String? message, - @JsonKey(name: 'data') CustomerPointDataDto? data, - }) = _CustomerPointDto; - - factory CustomerPointDto.fromJson(Map json) => - _$CustomerPointDtoFromJson(json); - - const CustomerPointDto._(); - - /// mapping ke domain - CustomerPoint toDomain() => CustomerPoint( - status: status ?? '', - message: message ?? '', - totalPoints: data?.totalPoints ?? 0, - lastUpdated: data?.lastUpdated ?? '', - ); -} - -@freezed -class CustomerPointDataDto with _$CustomerPointDataDto { - const factory CustomerPointDataDto({ - @JsonKey(name: 'total_points') int? totalPoints, - @JsonKey(name: 'last_updated') String? lastUpdated, - }) = _CustomerPointDataDto; - - factory CustomerPointDataDto.fromJson(Map json) => - _$CustomerPointDataDtoFromJson(json); -} diff --git a/lib/infrastructure/customer/repositories/customer_repository.dart b/lib/infrastructure/customer/repositories/customer_repository.dart deleted file mode 100644 index 18cebfe..0000000 --- a/lib/infrastructure/customer/repositories/customer_repository.dart +++ /dev/null @@ -1,33 +0,0 @@ -import 'dart:developer'; - -import 'package:dartz/dartz.dart'; -import 'package:injectable/injectable.dart'; - -import '../../../domain/customer/customer.dart'; -import '../datasources/remote_data_provider.dart'; - -@Injectable(as: ICustomerRepository) -class CustomerRepository implements ICustomerRepository { - final CustomerRemoteDataProvider _remoteDataProvider; - - final String _logName = 'CustomerRepository'; - - CustomerRepository(this._remoteDataProvider); - - @override - Future> getPoints() async { - try { - final result = await _remoteDataProvider.fetchCustomerPoint(); - - if (result.hasError) { - return left(result.error!); - } - - final data = result.data!.toDomain(); - return right(data); - } catch (e, s) { - log('getPoints', name: _logName, error: e, stackTrace: s); - return left(const CustomerFailure.unexpectedError()); - } - } -} diff --git a/lib/infrastructure/game/datasources/remote_data_provider.dart b/lib/infrastructure/game/datasources/remote_data_provider.dart index 8df1131..2178867 100644 --- a/lib/infrastructure/game/datasources/remote_data_provider.dart +++ b/lib/infrastructure/game/datasources/remote_data_provider.dart @@ -44,4 +44,38 @@ class GameRemoteDataProvider { return DC.error(GameFailure.serverError(e)); } } + + Future> spin({required String gameId}) async { + try { + final response = await _apiClient.post( + ApiPath.spin, + headers: getAuthorizationHeader(), + data: {'spin_id': gameId}, + ); + + if (response.data is! Map || response.data['success'] != true) { + final errors = response.data is Map ? response.data['errors'] : null; + final code = errors is List && errors.isNotEmpty && errors.first is Map + ? errors.first['code']?.toString() + : null; + + return DC.error( + GameFailure.dynamicErrorMessage( + code == '304' + ? 'EnakCoin kurang, game sedang tidak aktif, atau hadiah baru ' + 'saja habis. EnakCoin kamu tidak terpotong, silakan coba lagi.' + : 'Terjadi kesalahan, coba lagi', + ), + ); + } + + final dto = SpinResultDto.fromJson( + Map.from(response.data['data'] as Map), + ); + return DC.data(dto); + } on ApiFailure catch (e, s) { + log('spin', name: _logName, error: e, stackTrace: s); + return DC.error(GameFailure.serverError(e)); + } + } } diff --git a/lib/infrastructure/game/dto/game_dto.dart b/lib/infrastructure/game/dto/game_dto.dart index f366d86..6fef223 100644 --- a/lib/infrastructure/game/dto/game_dto.dart +++ b/lib/infrastructure/game/dto/game_dto.dart @@ -1,7 +1,7 @@ part of '../game_dtos.dart'; @freezed -class GameDto with _$GameDto { +abstract class GameDto with _$GameDto { const factory GameDto({ @JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, diff --git a/lib/infrastructure/game/dto/game_prize_dto.dart b/lib/infrastructure/game/dto/game_prize_dto.dart index 6ff0a5d..c5ba716 100644 --- a/lib/infrastructure/game/dto/game_prize_dto.dart +++ b/lib/infrastructure/game/dto/game_prize_dto.dart @@ -1,7 +1,7 @@ part of '../game_dtos.dart'; @freezed -class GamePrizeDto with _$GamePrizeDto { +abstract class GamePrizeDto with _$GamePrizeDto { const factory GamePrizeDto({ @JsonKey(name: 'id') String? id, @JsonKey(name: 'game_id') String? gameId, diff --git a/lib/infrastructure/game/dto/spin_result_dto.dart b/lib/infrastructure/game/dto/spin_result_dto.dart new file mode 100644 index 0000000..73c72c5 --- /dev/null +++ b/lib/infrastructure/game/dto/spin_result_dto.dart @@ -0,0 +1,47 @@ +part of '../game_dtos.dart'; + +@freezed +abstract class SpinResultDto with _$SpinResultDto { + const factory SpinResultDto({ + @JsonKey(name: 'game_play') GamePlayDto? gamePlay, + @JsonKey(name: 'prize_won') PrizeWonDto? prizeWon, + @JsonKey(name: 'coins_remaining') int? coinsRemaining, + }) = _SpinResultDto; + + factory SpinResultDto.fromJson(Map json) => + _$SpinResultDtoFromJson(json); + + const SpinResultDto._(); + + SpinResult toDomain() => SpinResult( + gamePlayId: gamePlay?.id ?? '', + coinsUsed: gamePlay?.coinsUsed ?? 0, + prizeId: prizeWon?.id ?? '', + prizeName: prizeWon?.name ?? '', + coinsRemaining: coinsRemaining ?? 0, + ); +} + +@freezed +abstract class GamePlayDto with _$GamePlayDto { + const factory GamePlayDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'game_id') String? gameId, + @JsonKey(name: 'coins_used') int? coinsUsed, + @JsonKey(name: 'created_at') String? createdAt, + }) = _GamePlayDto; + + factory GamePlayDto.fromJson(Map json) => + _$GamePlayDtoFromJson(json); +} + +@freezed +abstract class PrizeWonDto with _$PrizeWonDto { + const factory PrizeWonDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'name') String? name, + }) = _PrizeWonDto; + + factory PrizeWonDto.fromJson(Map json) => + _$PrizeWonDtoFromJson(json); +} diff --git a/lib/infrastructure/game/game_dtos.dart b/lib/infrastructure/game/game_dtos.dart index 899b9fa..58e7404 100644 --- a/lib/infrastructure/game/game_dtos.dart +++ b/lib/infrastructure/game/game_dtos.dart @@ -7,3 +7,4 @@ part 'game_dtos.g.dart'; part 'dto/game_dto.dart'; part 'dto/game_prize_dto.dart'; +part 'dto/spin_result_dto.dart'; diff --git a/lib/infrastructure/game/game_dtos.freezed.dart b/lib/infrastructure/game/game_dtos.freezed.dart index 3774c5f..aeff44f 100644 --- a/lib/infrastructure/game/game_dtos.freezed.dart +++ b/lib/infrastructure/game/game_dtos.freezed.dart @@ -1,6 +1,6 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'game_dtos.dart'; @@ -9,663 +9,1483 @@ part of 'game_dtos.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND +// 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', -); - -GameDto _$GameDtoFromJson(Map json) { - return _GameDto.fromJson(json); -} - /// @nodoc mixin _$GameDto { - @JsonKey(name: 'id') - String? get id => throw _privateConstructorUsedError; - @JsonKey(name: 'name') - String? get name => throw _privateConstructorUsedError; - @JsonKey(name: 'type') - String? get type => throw _privateConstructorUsedError; - @JsonKey(name: 'is_active') - bool? get isActive => throw _privateConstructorUsedError; - @JsonKey(name: 'metadata') - Map? get metadata => throw _privateConstructorUsedError; - @JsonKey(name: 'prizes') - List? get prizes => throw _privateConstructorUsedError; - @JsonKey(name: 'created_at') - String? get createdAt => throw _privateConstructorUsedError; - @JsonKey(name: 'updated_at') - String? get updatedAt => throw _privateConstructorUsedError; + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'name') String? get name;@JsonKey(name: 'type') String? get type;@JsonKey(name: 'is_active') bool? get isActive;@JsonKey(name: 'metadata') Map? get metadata;@JsonKey(name: 'prizes') List? get prizes;@JsonKey(name: 'created_at') String? get createdAt;@JsonKey(name: 'updated_at') String? get updatedAt; +/// Create a copy of GameDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GameDtoCopyWith get copyWith => _$GameDtoCopyWithImpl(this as GameDto, _$identity); /// Serializes this GameDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as GameDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is GameDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.type, _this.type) || other.type == _this.type)&&(identical(other.isActive, _this.isActive) || other.isActive == _this.isActive)&&const DeepCollectionEquality().equals(other.metadata, _this.metadata)&&const DeepCollectionEquality().equals(other.prizes, _this.prizes)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)&&(identical(other.updatedAt, _this.updatedAt) || other.updatedAt == _this.updatedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as GameDto; + return Object.hash(runtimeType,_this.id,_this.name,_this.type,_this.isActive,const DeepCollectionEquality().hash(_this.metadata),const DeepCollectionEquality().hash(_this.prizes),_this.createdAt,_this.updatedAt); +} + +@override +String toString() { + final _this = this as GameDto; + return 'GameDto(id: ${_this.id}, name: ${_this.name}, type: ${_this.type}, isActive: ${_this.isActive}, metadata: ${_this.metadata}, prizes: ${_this.prizes}, createdAt: ${_this.createdAt}, updatedAt: ${_this.updatedAt})'; +} + - /// Create a copy of GameDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $GameDtoCopyWith get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class $GameDtoCopyWith<$Res> { - factory $GameDtoCopyWith(GameDto value, $Res Function(GameDto) then) = - _$GameDtoCopyWithImpl<$Res, GameDto>; - @useResult - $Res call({ - @JsonKey(name: 'id') String? id, - @JsonKey(name: 'name') String? name, - @JsonKey(name: 'type') String? type, - @JsonKey(name: 'is_active') bool? isActive, - @JsonKey(name: 'metadata') Map? metadata, - @JsonKey(name: 'prizes') List? prizes, - @JsonKey(name: 'created_at') String? createdAt, - @JsonKey(name: 'updated_at') String? updatedAt, - }); -} +abstract mixin class $GameDtoCopyWith<$Res> { + factory $GameDtoCopyWith(GameDto value, $Res Function(GameDto) _then) = _$GameDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name,@JsonKey(name: 'type') String? type,@JsonKey(name: 'is_active') bool? isActive,@JsonKey(name: 'metadata') Map? metadata,@JsonKey(name: 'prizes') List? prizes,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt +}); + + + +} /// @nodoc -class _$GameDtoCopyWithImpl<$Res, $Val extends GameDto> +class _$GameDtoCopyWithImpl<$Res> implements $GameDtoCopyWith<$Res> { - _$GameDtoCopyWithImpl(this._value, this._then); + _$GameDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final GameDto _self; + final $Res Function(GameDto) _then; - /// Create a copy of GameDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = freezed, - Object? type = freezed, - Object? isActive = freezed, - Object? metadata = freezed, - Object? prizes = freezed, - Object? createdAt = freezed, - Object? updatedAt = freezed, - }) { - return _then( - _value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - type: freezed == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as String?, - isActive: freezed == isActive - ? _value.isActive - : isActive // ignore: cast_nullable_to_non_nullable - as bool?, - metadata: freezed == metadata - ? _value.metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map?, - prizes: freezed == prizes - ? _value.prizes - : prizes // ignore: cast_nullable_to_non_nullable - as List?, - createdAt: freezed == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String?, - updatedAt: freezed == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } +/// Create a copy of GameDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? name = freezed,Object? type = freezed,Object? isActive = freezed,Object? metadata = freezed,Object? prizes = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,}) { + return _then(GameDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,isActive: freezed == isActive ? _self.isActive : isActive // ignore: cast_nullable_to_non_nullable +as bool?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map?,prizes: freezed == prizes ? _self.prizes : prizes // ignore: cast_nullable_to_non_nullable +as List?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$GameDtoImplCopyWith<$Res> implements $GameDtoCopyWith<$Res> { - factory _$$GameDtoImplCopyWith( - _$GameDtoImpl value, - $Res Function(_$GameDtoImpl) then, - ) = __$$GameDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'id') String? id, - @JsonKey(name: 'name') String? name, - @JsonKey(name: 'type') String? type, - @JsonKey(name: 'is_active') bool? isActive, - @JsonKey(name: 'metadata') Map? metadata, - @JsonKey(name: 'prizes') List? prizes, - @JsonKey(name: 'created_at') String? createdAt, - @JsonKey(name: 'updated_at') String? updatedAt, - }); } -/// @nodoc -class __$$GameDtoImplCopyWithImpl<$Res> - extends _$GameDtoCopyWithImpl<$Res, _$GameDtoImpl> - implements _$$GameDtoImplCopyWith<$Res> { - __$$GameDtoImplCopyWithImpl( - _$GameDtoImpl _value, - $Res Function(_$GameDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of GameDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? name = freezed, - Object? type = freezed, - Object? isActive = freezed, - Object? metadata = freezed, - Object? prizes = freezed, - Object? createdAt = freezed, - Object? updatedAt = freezed, - }) { - return _then( - _$GameDtoImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - type: freezed == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as String?, - isActive: freezed == isActive - ? _value.isActive - : isActive // ignore: cast_nullable_to_non_nullable - as bool?, - metadata: freezed == metadata - ? _value._metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map?, - prizes: freezed == prizes - ? _value._prizes - : prizes // ignore: cast_nullable_to_non_nullable - as List?, - createdAt: freezed == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String?, - updatedAt: freezed == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } +/// Adds pattern-matching-related methods to [GameDto]. +extension GameDtoPatterns on GameDto { +/// 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( _GameDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _GameDto() 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( _GameDto value) $default,){ +final _that = this; +switch (_that) { +case _GameDto(): +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( _GameDto value)? $default,){ +final _that = this; +switch (_that) { +case _GameDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'type') String? type, @JsonKey(name: 'is_active') bool? isActive, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'prizes') List? prizes, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _GameDto() when $default != null: +return $default(_that.id,_that.name,_that.type,_that.isActive,_that.metadata,_that.prizes,_that.createdAt,_that.updatedAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'type') String? type, @JsonKey(name: 'is_active') bool? isActive, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'prizes') List? prizes, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt) $default,) {final _that = this; +switch (_that) { +case _GameDto(): +return $default(_that.id,_that.name,_that.type,_that.isActive,_that.metadata,_that.prizes,_that.createdAt,_that.updatedAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'type') String? type, @JsonKey(name: 'is_active') bool? isActive, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'prizes') List? prizes, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt)? $default,) {final _that = this; +switch (_that) { +case _GameDto() when $default != null: +return $default(_that.id,_that.name,_that.type,_that.isActive,_that.metadata,_that.prizes,_that.createdAt,_that.updatedAt);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$GameDtoImpl extends _GameDto { - const _$GameDtoImpl({ - @JsonKey(name: 'id') this.id, - @JsonKey(name: 'name') this.name, - @JsonKey(name: 'type') this.type, - @JsonKey(name: 'is_active') this.isActive, - @JsonKey(name: 'metadata') final Map? metadata, - @JsonKey(name: 'prizes') final List? prizes, - @JsonKey(name: 'created_at') this.createdAt, - @JsonKey(name: 'updated_at') this.updatedAt, - }) : _metadata = metadata, - _prizes = prizes, - super._(); - factory _$GameDtoImpl.fromJson(Map json) => - _$$GameDtoImplFromJson(json); +class _GameDto extends GameDto { + const _GameDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'name') this.name, @JsonKey(name: 'type') this.type, @JsonKey(name: 'is_active') this.isActive, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'prizes') List? prizes, @JsonKey(name: 'created_at') this.createdAt, @JsonKey(name: 'updated_at') this.updatedAt}): _metadata = metadata,_prizes = prizes,super._(); + factory _GameDto.fromJson(Map json) => _$GameDtoFromJson(json); - @override - @JsonKey(name: 'id') - final String? id; - @override - @JsonKey(name: 'name') - final String? name; - @override - @JsonKey(name: 'type') - final String? type; - @override - @JsonKey(name: 'is_active') - final bool? isActive; - final Map? _metadata; - @override - @JsonKey(name: 'metadata') - Map? get metadata { - final value = _metadata; - if (value == null) return null; - if (_metadata is EqualUnmodifiableMapView) return _metadata; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'name') final String? name; +@override@JsonKey(name: 'type') final String? type; +@override@JsonKey(name: 'is_active') final bool? isActive; + final Map? _metadata; +@override@JsonKey(name: 'metadata') Map? get metadata { + final value = _metadata; + if (value == null) return null; + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); +} - final List? _prizes; - @override - @JsonKey(name: 'prizes') - List? get prizes { - final value = _prizes; - if (value == null) return null; - if (_prizes is EqualUnmodifiableListView) return _prizes; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } + final List? _prizes; +@override@JsonKey(name: 'prizes') List? get prizes { + final value = _prizes; + if (value == null) return null; + if (_prizes is EqualUnmodifiableListView) return _prizes; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} - @override - @JsonKey(name: 'created_at') - final String? createdAt; - @override - @JsonKey(name: 'updated_at') - final String? updatedAt; +@override@JsonKey(name: 'created_at') final String? createdAt; +@override@JsonKey(name: 'updated_at') final String? updatedAt; - @override - String toString() { +/// Create a copy of GameDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$GameDtoCopyWith<_GameDto> get copyWith => __$GameDtoCopyWithImpl<_GameDto>(this, _$identity); + +@override +Map toJson() { + return _$GameDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _GameDto&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.type, type) || other.type == type)&&(identical(other.isActive, isActive) || other.isActive == isActive)&&const DeepCollectionEquality().equals(other.metadata, _metadata)&&const DeepCollectionEquality().equals(other.prizes, _prizes)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,name,type,isActive,const DeepCollectionEquality().hash(_metadata),const DeepCollectionEquality().hash(_prizes),createdAt,updatedAt); +} + +@override +String toString() { return 'GameDto(id: $id, name: $name, type: $type, isActive: $isActive, metadata: $metadata, prizes: $prizes, createdAt: $createdAt, updatedAt: $updatedAt)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$GameDtoImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.name, name) || other.name == name) && - (identical(other.type, type) || other.type == type) && - (identical(other.isActive, isActive) || - other.isActive == isActive) && - const DeepCollectionEquality().equals(other._metadata, _metadata) && - const DeepCollectionEquality().equals(other._prizes, _prizes) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.updatedAt, updatedAt) || - other.updatedAt == updatedAt)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - name, - type, - isActive, - const DeepCollectionEquality().hash(_metadata), - const DeepCollectionEquality().hash(_prizes), - createdAt, - updatedAt, - ); - - /// Create a copy of GameDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$GameDtoImplCopyWith<_$GameDtoImpl> get copyWith => - __$$GameDtoImplCopyWithImpl<_$GameDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$GameDtoImplToJson(this); - } } -abstract class _GameDto extends GameDto { - const factory _GameDto({ - @JsonKey(name: 'id') final String? id, - @JsonKey(name: 'name') final String? name, - @JsonKey(name: 'type') final String? type, - @JsonKey(name: 'is_active') final bool? isActive, - @JsonKey(name: 'metadata') final Map? metadata, - @JsonKey(name: 'prizes') final List? prizes, - @JsonKey(name: 'created_at') final String? createdAt, - @JsonKey(name: 'updated_at') final String? updatedAt, - }) = _$GameDtoImpl; - const _GameDto._() : super._(); - factory _GameDto.fromJson(Map json) = _$GameDtoImpl.fromJson; - - @override - @JsonKey(name: 'id') - String? get id; - @override - @JsonKey(name: 'name') - String? get name; - @override - @JsonKey(name: 'type') - String? get type; - @override - @JsonKey(name: 'is_active') - bool? get isActive; - @override - @JsonKey(name: 'metadata') - Map? get metadata; - @override - @JsonKey(name: 'prizes') - List? get prizes; - @override - @JsonKey(name: 'created_at') - String? get createdAt; - @override - @JsonKey(name: 'updated_at') - String? get updatedAt; - - /// Create a copy of GameDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$GameDtoImplCopyWith<_$GameDtoImpl> get copyWith => - throw _privateConstructorUsedError; } -GamePrizeDto _$GamePrizeDtoFromJson(Map json) { - return _GamePrizeDto.fromJson(json); +/// @nodoc +abstract mixin class _$GameDtoCopyWith<$Res> implements $GameDtoCopyWith<$Res> { + factory _$GameDtoCopyWith(_GameDto value, $Res Function(_GameDto) _then) = __$GameDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name,@JsonKey(name: 'type') String? type,@JsonKey(name: 'is_active') bool? isActive,@JsonKey(name: 'metadata') Map? metadata,@JsonKey(name: 'prizes') List? prizes,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt +}); + + + + } +/// @nodoc +class __$GameDtoCopyWithImpl<$Res> + implements _$GameDtoCopyWith<$Res> { + __$GameDtoCopyWithImpl(this._self, this._then); + + final _GameDto _self; + final $Res Function(_GameDto) _then; + +/// Create a copy of GameDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? name = freezed,Object? type = freezed,Object? isActive = freezed,Object? metadata = freezed,Object? prizes = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,}) { + return _then(_GameDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,isActive: freezed == isActive ? _self.isActive : isActive // ignore: cast_nullable_to_non_nullable +as bool?,metadata: freezed == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map?,prizes: freezed == prizes ? _self._prizes : prizes // ignore: cast_nullable_to_non_nullable +as List?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + /// @nodoc mixin _$GamePrizeDto { - @JsonKey(name: 'id') - String? get id => throw _privateConstructorUsedError; - @JsonKey(name: 'game_id') - String? get gameId => throw _privateConstructorUsedError; - @JsonKey(name: 'name') - String? get name => throw _privateConstructorUsedError; - @JsonKey(name: 'metadata') - Map? get metadata => throw _privateConstructorUsedError; - @JsonKey(name: 'created_at') - String? get createdAt => throw _privateConstructorUsedError; - @JsonKey(name: 'updated_at') - String? get updatedAt => throw _privateConstructorUsedError; + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'game_id') String? get gameId;@JsonKey(name: 'name') String? get name;@JsonKey(name: 'metadata') Map? get metadata;@JsonKey(name: 'created_at') String? get createdAt;@JsonKey(name: 'updated_at') String? get updatedAt; +/// Create a copy of GamePrizeDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GamePrizeDtoCopyWith get copyWith => _$GamePrizeDtoCopyWithImpl(this as GamePrizeDto, _$identity); /// Serializes this GamePrizeDto to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as GamePrizeDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is GamePrizeDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.gameId, _this.gameId) || other.gameId == _this.gameId)&&(identical(other.name, _this.name) || other.name == _this.name)&&const DeepCollectionEquality().equals(other.metadata, _this.metadata)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)&&(identical(other.updatedAt, _this.updatedAt) || other.updatedAt == _this.updatedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as GamePrizeDto; + return Object.hash(runtimeType,_this.id,_this.gameId,_this.name,const DeepCollectionEquality().hash(_this.metadata),_this.createdAt,_this.updatedAt); +} + +@override +String toString() { + final _this = this as GamePrizeDto; + return 'GamePrizeDto(id: ${_this.id}, gameId: ${_this.gameId}, name: ${_this.name}, metadata: ${_this.metadata}, createdAt: ${_this.createdAt}, updatedAt: ${_this.updatedAt})'; +} + - /// Create a copy of GamePrizeDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $GamePrizeDtoCopyWith get copyWith => - throw _privateConstructorUsedError; } /// @nodoc -abstract class $GamePrizeDtoCopyWith<$Res> { - factory $GamePrizeDtoCopyWith( - GamePrizeDto value, - $Res Function(GamePrizeDto) then, - ) = _$GamePrizeDtoCopyWithImpl<$Res, GamePrizeDto>; - @useResult - $Res call({ - @JsonKey(name: 'id') String? id, - @JsonKey(name: 'game_id') String? gameId, - @JsonKey(name: 'name') String? name, - @JsonKey(name: 'metadata') Map? metadata, - @JsonKey(name: 'created_at') String? createdAt, - @JsonKey(name: 'updated_at') String? updatedAt, - }); -} +abstract mixin class $GamePrizeDtoCopyWith<$Res> { + factory $GamePrizeDtoCopyWith(GamePrizeDto value, $Res Function(GamePrizeDto) _then) = _$GamePrizeDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'game_id') String? gameId,@JsonKey(name: 'name') String? name,@JsonKey(name: 'metadata') Map? metadata,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt +}); + + + +} /// @nodoc -class _$GamePrizeDtoCopyWithImpl<$Res, $Val extends GamePrizeDto> +class _$GamePrizeDtoCopyWithImpl<$Res> implements $GamePrizeDtoCopyWith<$Res> { - _$GamePrizeDtoCopyWithImpl(this._value, this._then); + _$GamePrizeDtoCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + final GamePrizeDto _self; + final $Res Function(GamePrizeDto) _then; - /// Create a copy of GamePrizeDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? gameId = freezed, - Object? name = freezed, - Object? metadata = freezed, - Object? createdAt = freezed, - Object? updatedAt = freezed, - }) { - return _then( - _value.copyWith( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - gameId: freezed == gameId - ? _value.gameId - : gameId // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - metadata: freezed == metadata - ? _value.metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map?, - createdAt: freezed == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String?, - updatedAt: freezed == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String?, - ) - as $Val, - ); - } +/// Create a copy of GamePrizeDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? gameId = freezed,Object? name = freezed,Object? metadata = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,}) { + return _then(GamePrizeDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,gameId: freezed == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,metadata: freezed == metadata ? _self.metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$GamePrizeDtoImplCopyWith<$Res> - implements $GamePrizeDtoCopyWith<$Res> { - factory _$$GamePrizeDtoImplCopyWith( - _$GamePrizeDtoImpl value, - $Res Function(_$GamePrizeDtoImpl) then, - ) = __$$GamePrizeDtoImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({ - @JsonKey(name: 'id') String? id, - @JsonKey(name: 'game_id') String? gameId, - @JsonKey(name: 'name') String? name, - @JsonKey(name: 'metadata') Map? metadata, - @JsonKey(name: 'created_at') String? createdAt, - @JsonKey(name: 'updated_at') String? updatedAt, - }); } -/// @nodoc -class __$$GamePrizeDtoImplCopyWithImpl<$Res> - extends _$GamePrizeDtoCopyWithImpl<$Res, _$GamePrizeDtoImpl> - implements _$$GamePrizeDtoImplCopyWith<$Res> { - __$$GamePrizeDtoImplCopyWithImpl( - _$GamePrizeDtoImpl _value, - $Res Function(_$GamePrizeDtoImpl) _then, - ) : super(_value, _then); - /// Create a copy of GamePrizeDto - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = freezed, - Object? gameId = freezed, - Object? name = freezed, - Object? metadata = freezed, - Object? createdAt = freezed, - Object? updatedAt = freezed, - }) { - return _then( - _$GamePrizeDtoImpl( - id: freezed == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as String?, - gameId: freezed == gameId - ? _value.gameId - : gameId // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - metadata: freezed == metadata - ? _value._metadata - : metadata // ignore: cast_nullable_to_non_nullable - as Map?, - createdAt: freezed == createdAt - ? _value.createdAt - : createdAt // ignore: cast_nullable_to_non_nullable - as String?, - updatedAt: freezed == updatedAt - ? _value.updatedAt - : updatedAt // ignore: cast_nullable_to_non_nullable - as String?, - ), - ); - } +/// Adds pattern-matching-related methods to [GamePrizeDto]. +extension GamePrizeDtoPatterns on GamePrizeDto { +/// 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( _GamePrizeDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _GamePrizeDto() 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( _GamePrizeDto value) $default,){ +final _that = this; +switch (_that) { +case _GamePrizeDto(): +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( _GamePrizeDto value)? $default,){ +final _that = this; +switch (_that) { +case _GamePrizeDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'game_id') String? gameId, @JsonKey(name: 'name') String? name, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _GamePrizeDto() when $default != null: +return $default(_that.id,_that.gameId,_that.name,_that.metadata,_that.createdAt,_that.updatedAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'game_id') String? gameId, @JsonKey(name: 'name') String? name, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt) $default,) {final _that = this; +switch (_that) { +case _GamePrizeDto(): +return $default(_that.id,_that.gameId,_that.name,_that.metadata,_that.createdAt,_that.updatedAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'game_id') String? gameId, @JsonKey(name: 'name') String? name, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'updated_at') String? updatedAt)? $default,) {final _that = this; +switch (_that) { +case _GamePrizeDto() when $default != null: +return $default(_that.id,_that.gameId,_that.name,_that.metadata,_that.createdAt,_that.updatedAt);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$GamePrizeDtoImpl extends _GamePrizeDto { - const _$GamePrizeDtoImpl({ - @JsonKey(name: 'id') this.id, - @JsonKey(name: 'game_id') this.gameId, - @JsonKey(name: 'name') this.name, - @JsonKey(name: 'metadata') final Map? metadata, - @JsonKey(name: 'created_at') this.createdAt, - @JsonKey(name: 'updated_at') this.updatedAt, - }) : _metadata = metadata, - super._(); - factory _$GamePrizeDtoImpl.fromJson(Map json) => - _$$GamePrizeDtoImplFromJson(json); +class _GamePrizeDto extends GamePrizeDto { + const _GamePrizeDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'game_id') this.gameId, @JsonKey(name: 'name') this.name, @JsonKey(name: 'metadata') Map? metadata, @JsonKey(name: 'created_at') this.createdAt, @JsonKey(name: 'updated_at') this.updatedAt}): _metadata = metadata,super._(); + factory _GamePrizeDto.fromJson(Map json) => _$GamePrizeDtoFromJson(json); - @override - @JsonKey(name: 'id') - final String? id; - @override - @JsonKey(name: 'game_id') - final String? gameId; - @override - @JsonKey(name: 'name') - final String? name; - final Map? _metadata; - @override - @JsonKey(name: 'metadata') - Map? get metadata { - final value = _metadata; - if (value == null) return null; - if (_metadata is EqualUnmodifiableMapView) return _metadata; - // ignore: implicit_dynamic_type - return EqualUnmodifiableMapView(value); - } +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'game_id') final String? gameId; +@override@JsonKey(name: 'name') final String? name; + final Map? _metadata; +@override@JsonKey(name: 'metadata') Map? get metadata { + final value = _metadata; + if (value == null) return null; + if (_metadata is EqualUnmodifiableMapView) return _metadata; + // ignore: implicit_dynamic_type + return EqualUnmodifiableMapView(value); +} - @override - @JsonKey(name: 'created_at') - final String? createdAt; - @override - @JsonKey(name: 'updated_at') - final String? updatedAt; +@override@JsonKey(name: 'created_at') final String? createdAt; +@override@JsonKey(name: 'updated_at') final String? updatedAt; - @override - String toString() { +/// Create a copy of GamePrizeDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$GamePrizeDtoCopyWith<_GamePrizeDto> get copyWith => __$GamePrizeDtoCopyWithImpl<_GamePrizeDto>(this, _$identity); + +@override +Map toJson() { + return _$GamePrizeDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _GamePrizeDto&&(identical(other.id, id) || other.id == id)&&(identical(other.gameId, gameId) || other.gameId == gameId)&&(identical(other.name, name) || other.name == name)&&const DeepCollectionEquality().equals(other.metadata, _metadata)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.updatedAt, updatedAt) || other.updatedAt == updatedAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,gameId,name,const DeepCollectionEquality().hash(_metadata),createdAt,updatedAt); +} + +@override +String toString() { return 'GamePrizeDto(id: $id, gameId: $gameId, name: $name, metadata: $metadata, createdAt: $createdAt, updatedAt: $updatedAt)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$GamePrizeDtoImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.gameId, gameId) || other.gameId == gameId) && - (identical(other.name, name) || other.name == name) && - const DeepCollectionEquality().equals(other._metadata, _metadata) && - (identical(other.createdAt, createdAt) || - other.createdAt == createdAt) && - (identical(other.updatedAt, updatedAt) || - other.updatedAt == updatedAt)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - id, - gameId, - name, - const DeepCollectionEquality().hash(_metadata), - createdAt, - updatedAt, - ); - - /// Create a copy of GamePrizeDto - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$GamePrizeDtoImplCopyWith<_$GamePrizeDtoImpl> get copyWith => - __$$GamePrizeDtoImplCopyWithImpl<_$GamePrizeDtoImpl>(this, _$identity); - - @override - Map toJson() { - return _$$GamePrizeDtoImplToJson(this); - } } -abstract class _GamePrizeDto extends GamePrizeDto { - const factory _GamePrizeDto({ - @JsonKey(name: 'id') final String? id, - @JsonKey(name: 'game_id') final String? gameId, - @JsonKey(name: 'name') final String? name, - @JsonKey(name: 'metadata') final Map? metadata, - @JsonKey(name: 'created_at') final String? createdAt, - @JsonKey(name: 'updated_at') final String? updatedAt, - }) = _$GamePrizeDtoImpl; - const _GamePrizeDto._() : super._(); - factory _GamePrizeDto.fromJson(Map json) = - _$GamePrizeDtoImpl.fromJson; - - @override - @JsonKey(name: 'id') - String? get id; - @override - @JsonKey(name: 'game_id') - String? get gameId; - @override - @JsonKey(name: 'name') - String? get name; - @override - @JsonKey(name: 'metadata') - Map? get metadata; - @override - @JsonKey(name: 'created_at') - String? get createdAt; - @override - @JsonKey(name: 'updated_at') - String? get updatedAt; - - /// Create a copy of GamePrizeDto - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$GamePrizeDtoImplCopyWith<_$GamePrizeDtoImpl> get copyWith => - throw _privateConstructorUsedError; } + +/// @nodoc +abstract mixin class _$GamePrizeDtoCopyWith<$Res> implements $GamePrizeDtoCopyWith<$Res> { + factory _$GamePrizeDtoCopyWith(_GamePrizeDto value, $Res Function(_GamePrizeDto) _then) = __$GamePrizeDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'game_id') String? gameId,@JsonKey(name: 'name') String? name,@JsonKey(name: 'metadata') Map? metadata,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'updated_at') String? updatedAt +}); + + + + +} +/// @nodoc +class __$GamePrizeDtoCopyWithImpl<$Res> + implements _$GamePrizeDtoCopyWith<$Res> { + __$GamePrizeDtoCopyWithImpl(this._self, this._then); + + final _GamePrizeDto _self; + final $Res Function(_GamePrizeDto) _then; + +/// Create a copy of GamePrizeDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? gameId = freezed,Object? name = freezed,Object? metadata = freezed,Object? createdAt = freezed,Object? updatedAt = freezed,}) { + return _then(_GamePrizeDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,gameId: freezed == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,metadata: freezed == metadata ? _self._metadata : metadata // ignore: cast_nullable_to_non_nullable +as Map?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?,updatedAt: freezed == updatedAt ? _self.updatedAt : updatedAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$SpinResultDto { + +@JsonKey(name: 'game_play') GamePlayDto? get gamePlay;@JsonKey(name: 'prize_won') PrizeWonDto? get prizeWon;@JsonKey(name: 'coins_remaining') int? get coinsRemaining; +/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SpinResultDtoCopyWith get copyWith => _$SpinResultDtoCopyWithImpl(this as SpinResultDto, _$identity); + + /// Serializes this SpinResultDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as SpinResultDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is SpinResultDto&&(identical(other.gamePlay, _this.gamePlay) || other.gamePlay == _this.gamePlay)&&(identical(other.prizeWon, _this.prizeWon) || other.prizeWon == _this.prizeWon)&&(identical(other.coinsRemaining, _this.coinsRemaining) || other.coinsRemaining == _this.coinsRemaining)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as SpinResultDto; + return Object.hash(runtimeType,_this.gamePlay,_this.prizeWon,_this.coinsRemaining); +} + +@override +String toString() { + final _this = this as SpinResultDto; + return 'SpinResultDto(gamePlay: ${_this.gamePlay}, prizeWon: ${_this.prizeWon}, coinsRemaining: ${_this.coinsRemaining})'; +} + + +} + +/// @nodoc +abstract mixin class $SpinResultDtoCopyWith<$Res> { + factory $SpinResultDtoCopyWith(SpinResultDto value, $Res Function(SpinResultDto) _then) = _$SpinResultDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'game_play') GamePlayDto? gamePlay,@JsonKey(name: 'prize_won') PrizeWonDto? prizeWon,@JsonKey(name: 'coins_remaining') int? coinsRemaining +}); + + +$GamePlayDtoCopyWith<$Res>? get gamePlay;$PrizeWonDtoCopyWith<$Res>? get prizeWon; + +} +/// @nodoc +class _$SpinResultDtoCopyWithImpl<$Res> + implements $SpinResultDtoCopyWith<$Res> { + _$SpinResultDtoCopyWithImpl(this._self, this._then); + + final SpinResultDto _self; + final $Res Function(SpinResultDto) _then; + +/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? gamePlay = freezed,Object? prizeWon = freezed,Object? coinsRemaining = freezed,}) { + return _then(SpinResultDto( +gamePlay: freezed == gamePlay ? _self.gamePlay : gamePlay // ignore: cast_nullable_to_non_nullable +as GamePlayDto?,prizeWon: freezed == prizeWon ? _self.prizeWon : prizeWon // ignore: cast_nullable_to_non_nullable +as PrizeWonDto?,coinsRemaining: freezed == coinsRemaining ? _self.coinsRemaining : coinsRemaining // ignore: cast_nullable_to_non_nullable +as int?, + )); +} +/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$GamePlayDtoCopyWith<$Res>? get gamePlay { + if (_self.gamePlay == null) { + return null; + } + + return $GamePlayDtoCopyWith<$Res>(_self.gamePlay!, (value) { + return _then(_self.copyWith(gamePlay: value)); + }); +}/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PrizeWonDtoCopyWith<$Res>? get prizeWon { + if (_self.prizeWon == null) { + return null; + } + + return $PrizeWonDtoCopyWith<$Res>(_self.prizeWon!, (value) { + return _then(_self.copyWith(prizeWon: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [SpinResultDto]. +extension SpinResultDtoPatterns on SpinResultDto { +/// 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( _SpinResultDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _SpinResultDto() 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( _SpinResultDto value) $default,){ +final _that = this; +switch (_that) { +case _SpinResultDto(): +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( _SpinResultDto value)? $default,){ +final _that = this; +switch (_that) { +case _SpinResultDto() 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(@JsonKey(name: 'game_play') GamePlayDto? gamePlay, @JsonKey(name: 'prize_won') PrizeWonDto? prizeWon, @JsonKey(name: 'coins_remaining') int? coinsRemaining)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _SpinResultDto() when $default != null: +return $default(_that.gamePlay,_that.prizeWon,_that.coinsRemaining);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(@JsonKey(name: 'game_play') GamePlayDto? gamePlay, @JsonKey(name: 'prize_won') PrizeWonDto? prizeWon, @JsonKey(name: 'coins_remaining') int? coinsRemaining) $default,) {final _that = this; +switch (_that) { +case _SpinResultDto(): +return $default(_that.gamePlay,_that.prizeWon,_that.coinsRemaining);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(@JsonKey(name: 'game_play') GamePlayDto? gamePlay, @JsonKey(name: 'prize_won') PrizeWonDto? prizeWon, @JsonKey(name: 'coins_remaining') int? coinsRemaining)? $default,) {final _that = this; +switch (_that) { +case _SpinResultDto() when $default != null: +return $default(_that.gamePlay,_that.prizeWon,_that.coinsRemaining);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _SpinResultDto extends SpinResultDto { + const _SpinResultDto({@JsonKey(name: 'game_play') this.gamePlay, @JsonKey(name: 'prize_won') this.prizeWon, @JsonKey(name: 'coins_remaining') this.coinsRemaining}): super._(); + factory _SpinResultDto.fromJson(Map json) => _$SpinResultDtoFromJson(json); + +@override@JsonKey(name: 'game_play') final GamePlayDto? gamePlay; +@override@JsonKey(name: 'prize_won') final PrizeWonDto? prizeWon; +@override@JsonKey(name: 'coins_remaining') final int? coinsRemaining; + +/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SpinResultDtoCopyWith<_SpinResultDto> get copyWith => __$SpinResultDtoCopyWithImpl<_SpinResultDto>(this, _$identity); + +@override +Map toJson() { + return _$SpinResultDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SpinResultDto&&(identical(other.gamePlay, gamePlay) || other.gamePlay == gamePlay)&&(identical(other.prizeWon, prizeWon) || other.prizeWon == prizeWon)&&(identical(other.coinsRemaining, coinsRemaining) || other.coinsRemaining == coinsRemaining)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,gamePlay,prizeWon,coinsRemaining); +} + +@override +String toString() { + return 'SpinResultDto(gamePlay: $gamePlay, prizeWon: $prizeWon, coinsRemaining: $coinsRemaining)'; +} + + +} + +/// @nodoc +abstract mixin class _$SpinResultDtoCopyWith<$Res> implements $SpinResultDtoCopyWith<$Res> { + factory _$SpinResultDtoCopyWith(_SpinResultDto value, $Res Function(_SpinResultDto) _then) = __$SpinResultDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'game_play') GamePlayDto? gamePlay,@JsonKey(name: 'prize_won') PrizeWonDto? prizeWon,@JsonKey(name: 'coins_remaining') int? coinsRemaining +}); + + +@override $GamePlayDtoCopyWith<$Res>? get gamePlay;@override $PrizeWonDtoCopyWith<$Res>? get prizeWon; + +} +/// @nodoc +class __$SpinResultDtoCopyWithImpl<$Res> + implements _$SpinResultDtoCopyWith<$Res> { + __$SpinResultDtoCopyWithImpl(this._self, this._then); + + final _SpinResultDto _self; + final $Res Function(_SpinResultDto) _then; + +/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? gamePlay = freezed,Object? prizeWon = freezed,Object? coinsRemaining = freezed,}) { + return _then(_SpinResultDto( +gamePlay: freezed == gamePlay ? _self.gamePlay : gamePlay // ignore: cast_nullable_to_non_nullable +as GamePlayDto?,prizeWon: freezed == prizeWon ? _self.prizeWon : prizeWon // ignore: cast_nullable_to_non_nullable +as PrizeWonDto?,coinsRemaining: freezed == coinsRemaining ? _self.coinsRemaining : coinsRemaining // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$GamePlayDtoCopyWith<$Res>? get gamePlay { + if (_self.gamePlay == null) { + return null; + } + + return $GamePlayDtoCopyWith<$Res>(_self.gamePlay!, (value) { + return _then(_self.copyWith(gamePlay: value)); + }); +}/// Create a copy of SpinResultDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$PrizeWonDtoCopyWith<$Res>? get prizeWon { + if (_self.prizeWon == null) { + return null; + } + + return $PrizeWonDtoCopyWith<$Res>(_self.prizeWon!, (value) { + return _then(_self.copyWith(prizeWon: value)); + }); +} +} + + +/// @nodoc +mixin _$GamePlayDto { + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'game_id') String? get gameId;@JsonKey(name: 'coins_used') int? get coinsUsed;@JsonKey(name: 'created_at') String? get createdAt; +/// Create a copy of GamePlayDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$GamePlayDtoCopyWith get copyWith => _$GamePlayDtoCopyWithImpl(this as GamePlayDto, _$identity); + + /// Serializes this GamePlayDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as GamePlayDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is GamePlayDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.gameId, _this.gameId) || other.gameId == _this.gameId)&&(identical(other.coinsUsed, _this.coinsUsed) || other.coinsUsed == _this.coinsUsed)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as GamePlayDto; + return Object.hash(runtimeType,_this.id,_this.gameId,_this.coinsUsed,_this.createdAt); +} + +@override +String toString() { + final _this = this as GamePlayDto; + return 'GamePlayDto(id: ${_this.id}, gameId: ${_this.gameId}, coinsUsed: ${_this.coinsUsed}, createdAt: ${_this.createdAt})'; +} + + +} + +/// @nodoc +abstract mixin class $GamePlayDtoCopyWith<$Res> { + factory $GamePlayDtoCopyWith(GamePlayDto value, $Res Function(GamePlayDto) _then) = _$GamePlayDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'game_id') String? gameId,@JsonKey(name: 'coins_used') int? coinsUsed,@JsonKey(name: 'created_at') String? createdAt +}); + + + + +} +/// @nodoc +class _$GamePlayDtoCopyWithImpl<$Res> + implements $GamePlayDtoCopyWith<$Res> { + _$GamePlayDtoCopyWithImpl(this._self, this._then); + + final GamePlayDto _self; + final $Res Function(GamePlayDto) _then; + +/// Create a copy of GamePlayDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? gameId = freezed,Object? coinsUsed = freezed,Object? createdAt = freezed,}) { + return _then(GamePlayDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,gameId: freezed == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String?,coinsUsed: freezed == coinsUsed ? _self.coinsUsed : coinsUsed // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [GamePlayDto]. +extension GamePlayDtoPatterns on GamePlayDto { +/// 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( _GamePlayDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _GamePlayDto() 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( _GamePlayDto value) $default,){ +final _that = this; +switch (_that) { +case _GamePlayDto(): +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( _GamePlayDto value)? $default,){ +final _that = this; +switch (_that) { +case _GamePlayDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'game_id') String? gameId, @JsonKey(name: 'coins_used') int? coinsUsed, @JsonKey(name: 'created_at') String? createdAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _GamePlayDto() when $default != null: +return $default(_that.id,_that.gameId,_that.coinsUsed,_that.createdAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'game_id') String? gameId, @JsonKey(name: 'coins_used') int? coinsUsed, @JsonKey(name: 'created_at') String? createdAt) $default,) {final _that = this; +switch (_that) { +case _GamePlayDto(): +return $default(_that.id,_that.gameId,_that.coinsUsed,_that.createdAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'game_id') String? gameId, @JsonKey(name: 'coins_used') int? coinsUsed, @JsonKey(name: 'created_at') String? createdAt)? $default,) {final _that = this; +switch (_that) { +case _GamePlayDto() when $default != null: +return $default(_that.id,_that.gameId,_that.coinsUsed,_that.createdAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _GamePlayDto implements GamePlayDto { + const _GamePlayDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'game_id') this.gameId, @JsonKey(name: 'coins_used') this.coinsUsed, @JsonKey(name: 'created_at') this.createdAt}); + factory _GamePlayDto.fromJson(Map json) => _$GamePlayDtoFromJson(json); + +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'game_id') final String? gameId; +@override@JsonKey(name: 'coins_used') final int? coinsUsed; +@override@JsonKey(name: 'created_at') final String? createdAt; + +/// Create a copy of GamePlayDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$GamePlayDtoCopyWith<_GamePlayDto> get copyWith => __$GamePlayDtoCopyWithImpl<_GamePlayDto>(this, _$identity); + +@override +Map toJson() { + return _$GamePlayDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _GamePlayDto&&(identical(other.id, id) || other.id == id)&&(identical(other.gameId, gameId) || other.gameId == gameId)&&(identical(other.coinsUsed, coinsUsed) || other.coinsUsed == coinsUsed)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,gameId,coinsUsed,createdAt); +} + +@override +String toString() { + return 'GamePlayDto(id: $id, gameId: $gameId, coinsUsed: $coinsUsed, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$GamePlayDtoCopyWith<$Res> implements $GamePlayDtoCopyWith<$Res> { + factory _$GamePlayDtoCopyWith(_GamePlayDto value, $Res Function(_GamePlayDto) _then) = __$GamePlayDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'game_id') String? gameId,@JsonKey(name: 'coins_used') int? coinsUsed,@JsonKey(name: 'created_at') String? createdAt +}); + + + + +} +/// @nodoc +class __$GamePlayDtoCopyWithImpl<$Res> + implements _$GamePlayDtoCopyWith<$Res> { + __$GamePlayDtoCopyWithImpl(this._self, this._then); + + final _GamePlayDto _self; + final $Res Function(_GamePlayDto) _then; + +/// Create a copy of GamePlayDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? gameId = freezed,Object? coinsUsed = freezed,Object? createdAt = freezed,}) { + return _then(_GamePlayDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,gameId: freezed == gameId ? _self.gameId : gameId // ignore: cast_nullable_to_non_nullable +as String?,coinsUsed: freezed == coinsUsed ? _self.coinsUsed : coinsUsed // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$PrizeWonDto { + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'name') String? get name; +/// Create a copy of PrizeWonDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PrizeWonDtoCopyWith get copyWith => _$PrizeWonDtoCopyWithImpl(this as PrizeWonDto, _$identity); + + /// Serializes this PrizeWonDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as PrizeWonDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PrizeWonDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as PrizeWonDto; + return Object.hash(runtimeType,_this.id,_this.name); +} + +@override +String toString() { + final _this = this as PrizeWonDto; + return 'PrizeWonDto(id: ${_this.id}, name: ${_this.name})'; +} + + +} + +/// @nodoc +abstract mixin class $PrizeWonDtoCopyWith<$Res> { + factory $PrizeWonDtoCopyWith(PrizeWonDto value, $Res Function(PrizeWonDto) _then) = _$PrizeWonDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name +}); + + + + +} +/// @nodoc +class _$PrizeWonDtoCopyWithImpl<$Res> + implements $PrizeWonDtoCopyWith<$Res> { + _$PrizeWonDtoCopyWithImpl(this._self, this._then); + + final PrizeWonDto _self; + final $Res Function(PrizeWonDto) _then; + +/// Create a copy of PrizeWonDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? name = freezed,}) { + return _then(PrizeWonDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PrizeWonDto]. +extension PrizeWonDtoPatterns on PrizeWonDto { +/// 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( _PrizeWonDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PrizeWonDto() 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( _PrizeWonDto value) $default,){ +final _that = this; +switch (_that) { +case _PrizeWonDto(): +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( _PrizeWonDto value)? $default,){ +final _that = this; +switch (_that) { +case _PrizeWonDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PrizeWonDto() when $default != null: +return $default(_that.id,_that.name);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name) $default,) {final _that = this; +switch (_that) { +case _PrizeWonDto(): +return $default(_that.id,_that.name);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name)? $default,) {final _that = this; +switch (_that) { +case _PrizeWonDto() when $default != null: +return $default(_that.id,_that.name);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _PrizeWonDto implements PrizeWonDto { + const _PrizeWonDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'name') this.name}); + factory _PrizeWonDto.fromJson(Map json) => _$PrizeWonDtoFromJson(json); + +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'name') final String? name; + +/// Create a copy of PrizeWonDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PrizeWonDtoCopyWith<_PrizeWonDto> get copyWith => __$PrizeWonDtoCopyWithImpl<_PrizeWonDto>(this, _$identity); + +@override +Map toJson() { + return _$PrizeWonDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PrizeWonDto&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,name); +} + +@override +String toString() { + return 'PrizeWonDto(id: $id, name: $name)'; +} + + +} + +/// @nodoc +abstract mixin class _$PrizeWonDtoCopyWith<$Res> implements $PrizeWonDtoCopyWith<$Res> { + factory _$PrizeWonDtoCopyWith(_PrizeWonDto value, $Res Function(_PrizeWonDto) _then) = __$PrizeWonDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name +}); + + + + +} +/// @nodoc +class __$PrizeWonDtoCopyWithImpl<$Res> + implements _$PrizeWonDtoCopyWith<$Res> { + __$PrizeWonDtoCopyWithImpl(this._self, this._then); + + final _PrizeWonDto _self; + final $Res Function(_PrizeWonDto) _then; + +/// Create a copy of PrizeWonDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? name = freezed,}) { + return _then(_PrizeWonDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/lib/infrastructure/game/game_dtos.g.dart b/lib/infrastructure/game/game_dtos.g.dart index e159635..c86b986 100644 --- a/lib/infrastructure/game/game_dtos.g.dart +++ b/lib/infrastructure/game/game_dtos.g.dart @@ -6,34 +6,32 @@ part of 'game_dtos.dart'; // JsonSerializableGenerator // ************************************************************************** -_$GameDtoImpl _$$GameDtoImplFromJson(Map json) => - _$GameDtoImpl( - id: json['id'] as String?, - name: json['name'] as String?, - type: json['type'] as String?, - isActive: json['is_active'] as bool?, - metadata: json['metadata'] as Map?, - prizes: (json['prizes'] as List?) - ?.map((e) => GamePrizeDto.fromJson(e as Map)) - .toList(), - createdAt: json['created_at'] as String?, - updatedAt: json['updated_at'] as String?, - ); +_GameDto _$GameDtoFromJson(Map json) => _GameDto( + id: json['id'] as String?, + name: json['name'] as String?, + type: json['type'] as String?, + isActive: json['is_active'] as bool?, + metadata: json['metadata'] as Map?, + prizes: (json['prizes'] as List?) + ?.map((e) => GamePrizeDto.fromJson(e as Map)) + .toList(), + createdAt: json['created_at'] as String?, + updatedAt: json['updated_at'] as String?, +); -Map _$$GameDtoImplToJson(_$GameDtoImpl instance) => - { - 'id': instance.id, - 'name': instance.name, - 'type': instance.type, - 'is_active': instance.isActive, - 'metadata': instance.metadata, - 'prizes': instance.prizes, - 'created_at': instance.createdAt, - 'updated_at': instance.updatedAt, - }; +Map _$GameDtoToJson(_GameDto instance) => { + 'id': instance.id, + 'name': instance.name, + 'type': instance.type, + 'is_active': instance.isActive, + 'metadata': instance.metadata, + 'prizes': instance.prizes, + 'created_at': instance.createdAt, + 'updated_at': instance.updatedAt, +}; -_$GamePrizeDtoImpl _$$GamePrizeDtoImplFromJson(Map json) => - _$GamePrizeDtoImpl( +_GamePrizeDto _$GamePrizeDtoFromJson(Map json) => + _GamePrizeDto( id: json['id'] as String?, gameId: json['game_id'] as String?, name: json['name'] as String?, @@ -42,7 +40,7 @@ _$GamePrizeDtoImpl _$$GamePrizeDtoImplFromJson(Map json) => updatedAt: json['updated_at'] as String?, ); -Map _$$GamePrizeDtoImplToJson(_$GamePrizeDtoImpl instance) => +Map _$GamePrizeDtoToJson(_GamePrizeDto instance) => { 'id': instance.id, 'game_id': instance.gameId, @@ -51,3 +49,42 @@ Map _$$GamePrizeDtoImplToJson(_$GamePrizeDtoImpl instance) => 'created_at': instance.createdAt, 'updated_at': instance.updatedAt, }; + +_SpinResultDto _$SpinResultDtoFromJson(Map json) => + _SpinResultDto( + gamePlay: json['game_play'] == null + ? null + : GamePlayDto.fromJson(json['game_play'] as Map), + prizeWon: json['prize_won'] == null + ? null + : PrizeWonDto.fromJson(json['prize_won'] as Map), + coinsRemaining: (json['coins_remaining'] as num?)?.toInt(), + ); + +Map _$SpinResultDtoToJson(_SpinResultDto instance) => + { + 'game_play': instance.gamePlay, + 'prize_won': instance.prizeWon, + 'coins_remaining': instance.coinsRemaining, + }; + +_GamePlayDto _$GamePlayDtoFromJson(Map json) => _GamePlayDto( + id: json['id'] as String?, + gameId: json['game_id'] as String?, + coinsUsed: (json['coins_used'] as num?)?.toInt(), + createdAt: json['created_at'] as String?, +); + +Map _$GamePlayDtoToJson(_GamePlayDto instance) => + { + 'id': instance.id, + 'game_id': instance.gameId, + 'coins_used': instance.coinsUsed, + 'created_at': instance.createdAt, + }; + +_PrizeWonDto _$PrizeWonDtoFromJson(Map json) => + _PrizeWonDto(id: json['id'] as String?, name: json['name'] as String?); + +Map _$PrizeWonDtoToJson(_PrizeWonDto instance) => + {'id': instance.id, 'name': instance.name}; diff --git a/lib/infrastructure/game/repositories/game_repository.dart b/lib/infrastructure/game/repositories/game_repository.dart index b038d26..89a50d9 100644 --- a/lib/infrastructure/game/repositories/game_repository.dart +++ b/lib/infrastructure/game/repositories/game_repository.dart @@ -31,4 +31,20 @@ class GameRepository implements IGameRepository { return left(const GameFailure.unexpectedError()); } } + + @override + Future> spin({required String gameId}) async { + try { + final result = await _remoteDataProvider.spin(gameId: gameId); + + if (result.hasError) { + return left(result.error!); + } + + return right(result.data!.toDomain()); + } catch (e, s) { + log('spin', name: _logName, error: e, stackTrace: s); + return left(const GameFailure.unexpectedError()); + } + } } diff --git a/lib/infrastructure/wallet/datasources/customer_remote_data_provider.dart b/lib/infrastructure/wallet/datasources/customer_remote_data_provider.dart new file mode 100644 index 0000000..bb02e20 --- /dev/null +++ b/lib/infrastructure/wallet/datasources/customer_remote_data_provider.dart @@ -0,0 +1,94 @@ +import 'dart:developer'; + +import 'package:data_channel/data_channel.dart'; +import 'package:dio/dio.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/api/api_client.dart'; +import '../../../common/api/api_failure.dart'; +import '../../../common/function/app_function.dart'; +import '../../../common/url/api_path.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../wallet_dtos.dart'; +import '../wallet_response.dart'; + +/// Outlet (§4.4) dan riwayat order (§4.5). +@injectable +class CustomerRemoteDataProvider { + final ApiClient _apiClient; + final String _logName = 'CustomerRemoteDataProvider'; + + CustomerRemoteDataProvider(this._apiClient); + + Future>> fetchOutlets() => _request( + 'fetchOutlets', + () => _apiClient.get(ApiPath.outlets, headers: getAuthorizationHeader()), + (response) => ((response.data as Map)['data'] as List? ?? []) + .map((e) => OutletDto.fromJson(Map.from(e as Map))) + .toList(), + ); + + Future> fetchOrders({ + required int page, + required int limit, + }) => _request( + 'fetchOrders', + () => _apiClient.get( + ApiPath.orders, + headers: getAuthorizationHeader(), + params: {'page': page, 'limit': limit}, + ), + _parseOrderPage, + ); + + Future> fetchOrderDetail(String id) => + _request( + 'fetchOrderDetail', + () => _apiClient.get( + '${ApiPath.orders}/$id', + headers: getAuthorizationHeader(), + ), + (response) => CustomerOrderDto.fromJson(walletDataOf(response)), + ); + + /// `data` bisa berupa list langsung dengan `pagination` di envelope, atau + /// objek `{ data, pagination }`. + CustomerOrderPageDto _parseOrderPage(Response response) { + final body = response.data as Map; + final payload = body['data']; + final rawItems = payload is Map ? payload['data'] : payload; + final rawPagination = payload is Map + ? payload['pagination'] + : body['pagination']; + + return CustomerOrderPageDto( + items: (rawItems as List? ?? []) + .map( + (e) => + CustomerOrderDto.fromJson(Map.from(e as Map)), + ) + .toList(), + pagination: rawPagination is Map + ? WalletPaginationDto.fromJson( + Map.from(rawPagination), + ) + : const WalletPaginationDto(), + ); + } + + Future> _request( + String name, + Future Function() call, + T Function(Response response) parse, + ) async { + try { + final response = await call(); + final failure = parseWalletFailure(response); + if (failure != null) return DC.error(failure); + return DC.data(parse(response)); + } on ApiFailure catch (e, s) { + log(name, name: _logName, error: e, stackTrace: s); + return DC.error(WalletFailure.serverError(e)); + } + } +} diff --git a/lib/infrastructure/wallet/datasources/device_data_provider.dart b/lib/infrastructure/wallet/datasources/device_data_provider.dart new file mode 100644 index 0000000..79fa98f --- /dev/null +++ b/lib/infrastructure/wallet/datasources/device_data_provider.dart @@ -0,0 +1,88 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:data_channel/data_channel.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/api/api_client.dart'; +import '../../../common/api/api_failure.dart'; +import '../../../common/function/app_function.dart'; +import '../../../common/url/api_path.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../wallet_response.dart'; + +@injectable +class DeviceLocalDataProvider { + final FlutterSecureStorage _storage; + + static const _deviceIdKey = 'device_id'; + static const _registeredKey = 'device_registered'; + + DeviceLocalDataProvider(this._storage); + + /// ID unik & stabil per instalasi; dibuat sekali lalu disimpan. + Future deviceId() async { + final saved = await _storage.read(key: _deviceIdKey); + if (saved != null && saved.isNotEmpty) return saved; + + final created = generateUuidV4(); + await _storage.write(key: _deviceIdKey, value: created); + return created; + } + + Future isRegistered() async => + await _storage.read(key: _registeredKey) == 'true'; + + Future setRegistered(bool value) => + _storage.write(key: _registeredKey, value: value.toString()); +} + +@injectable +class DeviceRemoteDataProvider { + final ApiClient _apiClient; + final String _logName = 'DeviceRemoteDataProvider'; + + DeviceRemoteDataProvider(this._apiClient); + + Future> register({ + required String deviceId, + required String fcmToken, + required String platform, + required String appVersion, + }) async { + try { + final response = await _apiClient.put( + ApiPath.devices, + headers: getAuthorizationHeader(), + data: { + 'device_id': deviceId, + 'fcm_token': fcmToken, + 'platform': platform, + 'app_version': appVersion, + }, + ); + final failure = parseWalletFailure(response); + if (failure != null) return DC.error(failure); + return DC.data(unit); + } on ApiFailure catch (e, s) { + log('register', name: _logName, error: e, stackTrace: s); + return DC.error(WalletFailure.serverError(e)); + } + } + + Future> unregister({required String deviceId}) async { + try { + final response = await _apiClient.delete( + '${ApiPath.devices}/$deviceId', + headers: getAuthorizationHeader(), + ); + final failure = parseWalletFailure(response); + if (failure != null) return DC.error(failure); + return DC.data(unit); + } on ApiFailure catch (e, s) { + log('unregister', name: _logName, error: e, stackTrace: s); + return DC.error(WalletFailure.serverError(e)); + } + } +} diff --git a/lib/infrastructure/wallet/datasources/pin_remote_data_provider.dart b/lib/infrastructure/wallet/datasources/pin_remote_data_provider.dart new file mode 100644 index 0000000..de56b02 --- /dev/null +++ b/lib/infrastructure/wallet/datasources/pin_remote_data_provider.dart @@ -0,0 +1,113 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:data_channel/data_channel.dart'; +import 'package:dio/dio.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/api/api_client.dart'; +import '../../../common/api/api_failure.dart'; +import '../../../common/api/interceptors/sensitive_aware_log_interceptor.dart'; +import '../../../common/function/app_function.dart'; +import '../../../common/url/api_path.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../wallet_dtos.dart'; +import '../wallet_response.dart'; + +@injectable +class PinRemoteDataProvider { + final ApiClient _apiClient; + final String _logName = 'PinRemoteDataProvider'; + + PinRemoteDataProvider(this._apiClient); + + Future> fetchStatus() => _request( + 'fetchStatus', + () => _apiClient.get(ApiPath.pinStatus, headers: getAuthorizationHeader()), + (response) => PinStatusDto.fromJson(walletDataOf(response)), + ); + + Future> requestOtp(PinOtpPurpose purpose) => + _request( + 'requestOtp', + () => _apiClient.post( + ApiPath.pinOtp, + headers: getAuthorizationHeader(), + data: {'purpose': purpose.apiValue}, + ), + (response) => PinOtpDto.fromJson(walletDataOf(response)), + ); + + Future> setup({ + required String otpToken, + required String otpCode, + required String pin, + required String confirmPin, + }) => _request( + 'setup', + () => _apiClient.post( + ApiPath.pin, + headers: getAuthorizationHeader(), + data: { + 'otp_token': otpToken, + 'otp_code': otpCode, + 'pin': pin, + 'confirm_pin': confirmPin, + }, + extra: {kSensitiveRequest: true}, + ), + (response) => PinStatusDto.fromJson(walletDataOf(response)), + ); + + Future> change({ + required String oldPin, + required String pin, + required String confirmPin, + }) => _request( + 'change', + () => _apiClient.put( + ApiPath.pin, + headers: getAuthorizationHeader(), + data: {'old_pin': oldPin, 'pin': pin, 'confirm_pin': confirmPin}, + extra: {kSensitiveRequest: true}, + ), + (_) => unit, + ); + + Future> reset({ + required String otpToken, + required String otpCode, + required String pin, + required String confirmPin, + }) => _request( + 'reset', + () => _apiClient.post( + ApiPath.pinReset, + headers: getAuthorizationHeader(), + data: { + 'otp_token': otpToken, + 'otp_code': otpCode, + 'pin': pin, + 'confirm_pin': confirmPin, + }, + extra: {kSensitiveRequest: true}, + ), + (_) => unit, + ); + + Future> _request( + String name, + Future Function() call, + T Function(Response response) parse, + ) async { + try { + final response = await call(); + final failure = parseWalletFailure(response); + if (failure != null) return DC.error(failure); + return DC.data(parse(response)); + } on ApiFailure catch (e, s) { + log(name, name: _logName, error: e, stackTrace: s); + return DC.error(WalletFailure.serverError(e)); + } + } +} diff --git a/lib/infrastructure/wallet/datasources/wallet_remote_data_provider.dart b/lib/infrastructure/wallet/datasources/wallet_remote_data_provider.dart new file mode 100644 index 0000000..1359bd7 --- /dev/null +++ b/lib/infrastructure/wallet/datasources/wallet_remote_data_provider.dart @@ -0,0 +1,178 @@ +import 'dart:developer'; + +import 'package:data_channel/data_channel.dart'; +import 'package:dio/dio.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../common/api/api_client.dart'; +import '../../../common/api/api_failure.dart'; +import '../../../common/api/interceptors/sensitive_aware_log_interceptor.dart'; +import '../../../common/extension/extension.dart'; +import '../../../common/function/app_function.dart'; +import '../../../common/url/api_path.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../wallet_dtos.dart'; +import '../wallet_response.dart'; + +@injectable +class WalletRemoteDataProvider { + final ApiClient _apiClient; + final String _logName = 'WalletRemoteDataProvider'; + + WalletRemoteDataProvider(this._apiClient); + + Future> fetchWallet() => _request( + 'fetchWallet', + () => _apiClient.get(ApiPath.wallet, headers: getAuthorizationHeader()), + (response) => WalletSummaryDto.fromJson(walletDataOf(response)), + ); + + Future> fetchTransactions({ + required int page, + required int limit, + WalletCurrency? currency, + List types = const [], + DateTime? from, + DateTime? to, + }) => _request( + 'fetchTransactions', + () => _apiClient.get( + ApiPath.walletTransactions, + headers: getAuthorizationHeader(), + params: { + 'page': page, + 'limit': limit, + if (currency != null) 'currency': currency.apiValue, + if (types.isNotEmpty) 'type': types.map((e) => e.apiValue).join(','), + if (from != null) 'from': from.toServerDate, + if (to != null) 'to': to.toServerDate, + }, + ), + _parseTransactionPage, + ); + + Future> fetchExpiring() => _request( + 'fetchExpiring', + () => _apiClient.get( + ApiPath.walletExpiring, + headers: getAuthorizationHeader(), + ), + (response) => WalletExpiringDto.fromJson(walletDataOf(response)), + ); + + Future> createPaymentCode({ + required String pin, + }) => _request( + 'createPaymentCode', + () => _apiClient.post( + ApiPath.walletPaymentCode, + headers: getAuthorizationHeader(), + data: {'pin': pin}, + extra: {kSensitiveRequest: true}, + ), + (response) => PaymentCodeDto.fromJson(walletDataOf(response)), + ); + + Future> previewExchange({ + required int coins, + }) => _request( + 'previewExchange', + () => _apiClient.get( + ApiPath.walletExchangePreview, + headers: getAuthorizationHeader(), + params: {'coins': coins}, + ), + (response) => ExchangePreviewDto.fromJson(walletDataOf(response)), + ); + + Future> exchange({ + required int coins, + required String pin, + required String idempotencyKey, + }) => _request( + 'exchange', + () => _apiClient.post( + ApiPath.walletExchange, + headers: {...getAuthorizationHeader(), 'Idempotency-Key': idempotencyKey}, + data: {'coins': coins, 'pin': pin}, + extra: {kSensitiveRequest: true}, + ), + (response) => ExchangeResultDto.fromJson(walletDataOf(response)), + ); + + Future> checkRecipient({ + required String phone, + }) => _request( + 'checkRecipient', + () => _apiClient.get( + ApiPath.walletTransferRecipient, + headers: getAuthorizationHeader(), + params: {'phone': phone}, + ), + (response) => TransferRecipientDto.fromJson(walletDataOf(response)), + ); + + Future> transfer({ + required WalletCurrency currency, + required int amount, + required String recipientPhone, + required String pin, + required String idempotencyKey, + }) => _request( + 'transfer', + () => _apiClient.post( + ApiPath.walletTransfer, + headers: {...getAuthorizationHeader(), 'Idempotency-Key': idempotencyKey}, + data: { + 'currency': currency.apiValue, + 'amount': amount, + 'recipient_phone': recipientPhone, + 'pin': pin, + }, + extra: {kSensitiveRequest: true}, + ), + (response) => TransferResultDto.fromJson(walletDataOf(response)), + ); + + /// `data` bisa berupa list langsung dengan `pagination` di envelope, atau + /// objek `{ data, pagination }`. + WalletTransactionPageDto _parseTransactionPage(Response response) { + final body = response.data as Map; + final payload = body['data']; + final rawItems = payload is Map ? payload['data'] : payload; + final rawPagination = payload is Map + ? payload['pagination'] + : body['pagination']; + + return WalletTransactionPageDto( + items: (rawItems as List? ?? []) + .map( + (e) => WalletTransactionDto.fromJson( + Map.from(e as Map), + ), + ) + .toList(), + pagination: rawPagination is Map + ? WalletPaginationDto.fromJson( + Map.from(rawPagination), + ) + : const WalletPaginationDto(), + ); + } + + Future> _request( + String name, + Future Function() call, + T Function(Response response) parse, + ) async { + try { + final response = await call(); + final failure = parseWalletFailure(response); + if (failure != null) return DC.error(failure); + return DC.data(parse(response)); + } on ApiFailure catch (e, s) { + log(name, name: _logName, error: e, stackTrace: s); + return DC.error(WalletFailure.serverError(e)); + } + } +} diff --git a/lib/infrastructure/wallet/dto/customer_order_dto.dart b/lib/infrastructure/wallet/dto/customer_order_dto.dart new file mode 100644 index 0000000..af44210 --- /dev/null +++ b/lib/infrastructure/wallet/dto/customer_order_dto.dart @@ -0,0 +1,132 @@ +part of '../wallet_dtos.dart'; + +/// Satu DTO untuk daftar dan detail order; field detail kosong di daftar. +@freezed +abstract class CustomerOrderDto with _$CustomerOrderDto { + const factory CustomerOrderDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'order_number') String? orderNumber, + @JsonKey(name: 'outlet_name') String? outletName, + @JsonKey(name: 'order_type') String? orderType, + @JsonKey(name: 'status') String? status, + @JsonKey(name: 'payment_status') String? paymentStatus, + @JsonKey(name: 'total_amount') int? totalAmount, + @JsonKey(name: 'item_count') int? itemCount, + @JsonKey(name: 'is_void') bool? isVoid, + @JsonKey(name: 'is_refund') bool? isRefund, + @JsonKey(name: 'points_earned') int? pointsEarned, + @JsonKey(name: 'coins_earned') int? coinsEarned, + @JsonKey(name: 'created_at') String? createdAt, + // Detail + @JsonKey(name: 'table_number') String? tableNumber, + @JsonKey(name: 'subtotal') int? subtotal, + @JsonKey(name: 'discount_amount') int? discountAmount, + @JsonKey(name: 'tax_amount') int? taxAmount, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'items') List? items, + @JsonKey(name: 'payments') List? payments, + }) = _CustomerOrderDto; + + factory CustomerOrderDto.fromJson(Map json) => + _$CustomerOrderDtoFromJson(json); + + const CustomerOrderDto._(); + + CustomerOrder toDomain() => CustomerOrder( + id: id ?? '', + orderNumber: orderNumber ?? '', + outletName: outletName ?? '', + orderType: orderType ?? '', + status: status ?? '', + paymentStatus: paymentStatus ?? '', + totalAmount: totalAmount ?? 0, + itemCount: itemCount ?? 0, + isVoid: isVoid ?? false, + isRefund: isRefund ?? false, + pointsEarned: pointsEarned ?? 0, + coinsEarned: coinsEarned ?? 0, + createdAt: _parseDateTime(createdAt), + ); + + CustomerOrderDetail toDetailDomain() => CustomerOrderDetail( + order: toDomain(), + tableNumber: (tableNumber?.isEmpty ?? true) ? null : tableNumber, + subtotal: subtotal ?? 0, + discountAmount: discountAmount ?? 0, + taxAmount: taxAmount ?? 0, + refundAmount: refundAmount ?? 0, + items: items?.map((e) => e.toDomain()).toList() ?? [], + payments: payments?.map((e) => e.toDomain()).toList() ?? [], + ); +} + +@freezed +abstract class CustomerOrderItemDto with _$CustomerOrderItemDto { + const factory CustomerOrderItemDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'product_name') String? productName, + @JsonKey(name: 'variant_name') String? variantName, + @JsonKey(name: 'quantity') int? quantity, + @JsonKey(name: 'weight') double? weight, + @JsonKey(name: 'unit_name') String? unitName, + @JsonKey(name: 'unit_price') int? unitPrice, + @JsonKey(name: 'total_price') int? totalPrice, + @JsonKey(name: 'refund_quantity') int? refundQuantity, + }) = _CustomerOrderItemDto; + + factory CustomerOrderItemDto.fromJson(Map json) => + _$CustomerOrderItemDtoFromJson(json); + + const CustomerOrderItemDto._(); + + CustomerOrderItem toDomain() => CustomerOrderItem( + id: id ?? '', + productName: productName ?? '', + variantName: (variantName?.isEmpty ?? true) ? null : variantName, + quantity: quantity ?? 0, + weight: weight, + unitName: unitName, + unitPrice: unitPrice ?? 0, + totalPrice: totalPrice ?? 0, + refundQuantity: refundQuantity ?? 0, + ); +} + +@freezed +abstract class CustomerOrderPaymentDto with _$CustomerOrderPaymentDto { + const factory CustomerOrderPaymentDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'method_name') String? methodName, + @JsonKey(name: 'method_type') String? methodType, + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'refund_amount') int? refundAmount, + @JsonKey(name: 'points_used') int? pointsUsed, + }) = _CustomerOrderPaymentDto; + + factory CustomerOrderPaymentDto.fromJson(Map json) => + _$CustomerOrderPaymentDtoFromJson(json); + + const CustomerOrderPaymentDto._(); + + CustomerOrderPayment toDomain() => CustomerOrderPayment( + id: id ?? '', + methodName: methodName ?? '', + methodType: methodType ?? '', + amount: amount ?? 0, + refundAmount: refundAmount ?? 0, + pointsUsed: pointsUsed, + ); +} + +class CustomerOrderPageDto { + final List items; + final WalletPaginationDto pagination; + + const CustomerOrderPageDto({required this.items, required this.pagination}); + + CustomerOrderPage toDomain() => CustomerOrderPage( + items: items.map((e) => e.toDomain()).toList(), + page: pagination.page ?? 1, + totalPages: pagination.totalPages ?? 1, + ); +} diff --git a/lib/infrastructure/wallet/dto/exchange_dto.dart b/lib/infrastructure/wallet/dto/exchange_dto.dart new file mode 100644 index 0000000..47e6ce2 --- /dev/null +++ b/lib/infrastructure/wallet/dto/exchange_dto.dart @@ -0,0 +1,71 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class ExchangePreviewDto with _$ExchangePreviewDto { + const factory ExchangePreviewDto({ + @JsonKey(name: 'coin_amount') int? coinAmount, + @JsonKey(name: 'point_amount') int? pointAmount, + @JsonKey(name: 'coin_balance') int? coinBalance, + @JsonKey(name: 'coins') int? coins, + @JsonKey(name: 'points') int? points, + @JsonKey(name: 'valid') bool? valid, + @JsonKey(name: 'reason') String? reason, + }) = _ExchangePreviewDto; + + factory ExchangePreviewDto.fromJson(Map json) => + _$ExchangePreviewDtoFromJson(json); + + const ExchangePreviewDto._(); + + ExchangePreview toDomain() => ExchangePreview( + coinAmount: coinAmount ?? 0, + pointAmount: pointAmount ?? 0, + coinBalance: coinBalance ?? 0, + coins: coins ?? 0, + points: points ?? 0, + valid: valid ?? false, + reason: reason, + ); +} + +@freezed +abstract class ExchangeResultDto with _$ExchangeResultDto { + const factory ExchangeResultDto({ + @JsonKey(name: 'coins') int? coins, + @JsonKey(name: 'points') int? points, + @JsonKey(name: 'coin_balance') int? coinBalance, + @JsonKey(name: 'point_balance') int? pointBalance, + @JsonKey(name: 'lots') List? lots, + @JsonKey(name: 'replayed') bool? replayed, + }) = _ExchangeResultDto; + + factory ExchangeResultDto.fromJson(Map json) => + _$ExchangeResultDtoFromJson(json); + + const ExchangeResultDto._(); + + ExchangeResult toDomain() => ExchangeResult( + coins: coins ?? 0, + points: points ?? 0, + coinBalance: coinBalance ?? 0, + pointBalance: pointBalance ?? 0, + lots: lots?.map((e) => e.toDomain()).toList() ?? [], + replayed: replayed ?? false, + ); +} + +@freezed +abstract class WalletLotDto with _$WalletLotDto { + const factory WalletLotDto({ + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'expires_at') String? expiresAt, + }) = _WalletLotDto; + + factory WalletLotDto.fromJson(Map json) => + _$WalletLotDtoFromJson(json); + + const WalletLotDto._(); + + WalletLot toDomain() => + WalletLot(amount: amount ?? 0, expiresAt: _parseDateTime(expiresAt)); +} diff --git a/lib/infrastructure/wallet/dto/outlet_dto.dart b/lib/infrastructure/wallet/dto/outlet_dto.dart new file mode 100644 index 0000000..d79b5eb --- /dev/null +++ b/lib/infrastructure/wallet/dto/outlet_dto.dart @@ -0,0 +1,27 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class OutletDto with _$OutletDto { + const factory OutletDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'name') String? name, + @JsonKey(name: 'address') String? address, + @JsonKey(name: 'accepts_point_payment') bool? acceptsPointPayment, + @JsonKey(name: 'earns_points') bool? earnsPoints, + @JsonKey(name: 'earns_coins') bool? earnsCoins, + }) = _OutletDto; + + factory OutletDto.fromJson(Map json) => + _$OutletDtoFromJson(json); + + const OutletDto._(); + + Outlet toDomain() => Outlet( + id: id ?? '', + name: name ?? '', + address: (address?.trim().isEmpty ?? true) ? null : address!.trim(), + acceptsPointPayment: acceptsPointPayment ?? false, + earnsPoints: earnsPoints ?? false, + earnsCoins: earnsCoins ?? false, + ); +} diff --git a/lib/infrastructure/wallet/dto/payment_code_dto.dart b/lib/infrastructure/wallet/dto/payment_code_dto.dart new file mode 100644 index 0000000..80c19f6 --- /dev/null +++ b/lib/infrastructure/wallet/dto/payment_code_dto.dart @@ -0,0 +1,24 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class PaymentCodeDto with _$PaymentCodeDto { + const factory PaymentCodeDto({ + @JsonKey(name: 'code') String? code, + @JsonKey(name: 'qr_payload') String? qrPayload, + @JsonKey(name: 'expires_at') String? expiresAt, + }) = _PaymentCodeDto; + + factory PaymentCodeDto.fromJson(Map json) => + _$PaymentCodeDtoFromJson(json); + + const PaymentCodeDto._(); + + PaymentCode toDomain() => PaymentCode( + code: code ?? '', + qrPayload: qrPayload ?? '', + // Kode berlaku 2 menit; dipakai hanya bila server tidak mengirim expires_at. + expiresAt: + _parseDateTime(expiresAt) ?? + DateTime.now().add(const Duration(minutes: 2)), + ); +} diff --git a/lib/infrastructure/wallet/dto/pin_dto.dart b/lib/infrastructure/wallet/dto/pin_dto.dart new file mode 100644 index 0000000..7a275b6 --- /dev/null +++ b/lib/infrastructure/wallet/dto/pin_dto.dart @@ -0,0 +1,43 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class PinStatusDto with _$PinStatusDto { + const factory PinStatusDto({ + @JsonKey(name: 'has_pin') bool? hasPin, + @JsonKey(name: 'locked_until') String? lockedUntil, + @JsonKey(name: 'transfer_blocked_until') String? transferBlockedUntil, + }) = _PinStatusDto; + + factory PinStatusDto.fromJson(Map json) => + _$PinStatusDtoFromJson(json); + + const PinStatusDto._(); + + PinStatus toDomain() => PinStatus( + hasPin: hasPin ?? false, + lockedUntil: _parseDateTime(lockedUntil), + transferBlockedUntil: _parseDateTime(transferBlockedUntil), + ); +} + +@freezed +abstract class PinOtpDto with _$PinOtpDto { + const factory PinOtpDto({ + @JsonKey(name: 'purpose') String? purpose, + @JsonKey(name: 'otp_token') String? otpToken, + @JsonKey(name: 'expires_at') String? expiresAt, + }) = _PinOtpDto; + + factory PinOtpDto.fromJson(Map json) => + _$PinOtpDtoFromJson(json); + + const PinOtpDto._(); + + PinOtp toDomain() => PinOtp( + purpose: purpose == PinOtpPurpose.reset.apiValue + ? PinOtpPurpose.reset + : PinOtpPurpose.setup, + otpToken: otpToken ?? '', + expiresAt: _parseDateTime(expiresAt), + ); +} diff --git a/lib/infrastructure/wallet/dto/transfer_dto.dart b/lib/infrastructure/wallet/dto/transfer_dto.dart new file mode 100644 index 0000000..0d2aa55 --- /dev/null +++ b/lib/infrastructure/wallet/dto/transfer_dto.dart @@ -0,0 +1,45 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class TransferRecipientDto with _$TransferRecipientDto { + const factory TransferRecipientDto({ + @JsonKey(name: 'name') String? name, + @JsonKey(name: 'phone_number') String? phoneNumber, + }) = _TransferRecipientDto; + + factory TransferRecipientDto.fromJson(Map json) => + _$TransferRecipientDtoFromJson(json); + + const TransferRecipientDto._(); + + TransferRecipient toDomain() => + TransferRecipient(name: name ?? '', phoneNumber: phoneNumber ?? ''); +} + +@freezed +abstract class TransferResultDto with _$TransferResultDto { + const factory TransferResultDto({ + @JsonKey(name: 'currency') String? currency, + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'recipient') TransferRecipientDto? recipient, + @JsonKey(name: 'lots') List? lots, + @JsonKey(name: 'balance') int? balance, + @JsonKey(name: 'replayed') bool? replayed, + }) = _TransferResultDto; + + factory TransferResultDto.fromJson(Map json) => + _$TransferResultDtoFromJson(json); + + const TransferResultDto._(); + + TransferResult toDomain() => TransferResult( + currency: WalletCurrency.fromApi(currency), + amount: amount ?? 0, + recipient: + recipient?.toDomain() ?? + const TransferRecipient(name: '', phoneNumber: ''), + lots: lots?.map((e) => e.toDomain()).toList() ?? [], + balance: balance ?? 0, + replayed: replayed ?? false, + ); +} diff --git a/lib/infrastructure/wallet/dto/wallet_expiring_dto.dart b/lib/infrastructure/wallet/dto/wallet_expiring_dto.dart new file mode 100644 index 0000000..daf0d4f --- /dev/null +++ b/lib/infrastructure/wallet/dto/wallet_expiring_dto.dart @@ -0,0 +1,22 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class WalletExpiringDto with _$WalletExpiringDto { + const factory WalletExpiringDto({ + @JsonKey(name: 'point') List? point, + @JsonKey(name: 'coin') List? coin, + }) = _WalletExpiringDto; + + factory WalletExpiringDto.fromJson(Map json) => + _$WalletExpiringDtoFromJson(json); + + const WalletExpiringDto._(); + + WalletExpiring toDomain() => + WalletExpiring(point: _sorted(point), coin: _sorted(coin)); + + /// Paling dekat di atas. + List _sorted(List? list) => + (list ?? []).map((e) => e.toDomain()).whereType().toList() + ..sort((a, b) => a.date.compareTo(b.date)); +} diff --git a/lib/infrastructure/wallet/dto/wallet_summary_dto.dart b/lib/infrastructure/wallet/dto/wallet_summary_dto.dart new file mode 100644 index 0000000..188ba38 --- /dev/null +++ b/lib/infrastructure/wallet/dto/wallet_summary_dto.dart @@ -0,0 +1,60 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class WalletSummaryDto with _$WalletSummaryDto { + const factory WalletSummaryDto({ + @JsonKey(name: 'point_balance') int? pointBalance, + @JsonKey(name: 'coin_balance') int? coinBalance, + @JsonKey(name: 'point_value') int? pointValue, + @JsonKey(name: 'point_discount_value') int? pointDiscountValue, + @JsonKey(name: 'nearest_expiring') NearestExpiringDto? nearestExpiring, + @JsonKey(name: 'recent_transactions') + List? recentTransactions, + }) = _WalletSummaryDto; + + factory WalletSummaryDto.fromJson(Map json) => + _$WalletSummaryDtoFromJson(json); + + const WalletSummaryDto._(); + + WalletSummary toDomain() => WalletSummary( + pointBalance: pointBalance ?? 0, + coinBalance: coinBalance ?? 0, + pointValue: pointValue ?? 0, + pointDiscountValue: pointDiscountValue ?? 0, + nearestExpiringPoint: nearestExpiring?.point?.toDomain(), + nearestExpiringCoin: nearestExpiring?.coin?.toDomain(), + recentTransactions: + recentTransactions?.map((e) => e.toDomain()).toList() ?? [], + ); +} + +@freezed +abstract class NearestExpiringDto with _$NearestExpiringDto { + const factory NearestExpiringDto({ + @JsonKey(name: 'point') ExpiringAmountDto? point, + @JsonKey(name: 'coin') ExpiringAmountDto? coin, + }) = _NearestExpiringDto; + + factory NearestExpiringDto.fromJson(Map json) => + _$NearestExpiringDtoFromJson(json); +} + +@freezed +abstract class ExpiringAmountDto with _$ExpiringAmountDto { + const factory ExpiringAmountDto({ + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'date') String? date, + }) = _ExpiringAmountDto; + + factory ExpiringAmountDto.fromJson(Map json) => + _$ExpiringAmountDtoFromJson(json); + + const ExpiringAmountDto._(); + + ExpiringAmount? toDomain() { + final parsed = _parseDate(date); + if (parsed == null) return null; + return ExpiringAmount(amount: amount ?? 0, date: parsed); + } +} diff --git a/lib/infrastructure/wallet/dto/wallet_transaction_dto.dart b/lib/infrastructure/wallet/dto/wallet_transaction_dto.dart new file mode 100644 index 0000000..13f2c5c --- /dev/null +++ b/lib/infrastructure/wallet/dto/wallet_transaction_dto.dart @@ -0,0 +1,63 @@ +part of '../wallet_dtos.dart'; + +@freezed +abstract class WalletTransactionDto with _$WalletTransactionDto { + const factory WalletTransactionDto({ + @JsonKey(name: 'id') String? id, + @JsonKey(name: 'currency') String? currency, + @JsonKey(name: 'type') String? type, + @JsonKey(name: 'amount') int? amount, + @JsonKey(name: 'balance_after') int? balanceAfter, + @JsonKey(name: 'description') String? description, + @JsonKey(name: 'group_id') String? groupId, + @JsonKey(name: 'expires_at') String? expiresAt, + @JsonKey(name: 'created_at') String? createdAt, + }) = _WalletTransactionDto; + + factory WalletTransactionDto.fromJson(Map json) => + _$WalletTransactionDtoFromJson(json); + + const WalletTransactionDto._(); + + WalletTransaction toDomain() => WalletTransaction( + id: id ?? '', + currency: WalletCurrency.fromApi(currency), + type: WalletTransactionType.fromApi(type), + amount: amount ?? 0, + balanceAfter: balanceAfter ?? 0, + description: description ?? '', + groupId: groupId, + expiresAt: _parseDateTime(expiresAt), + createdAt: _parseDateTime(createdAt), + ); +} + +@freezed +abstract class WalletPaginationDto with _$WalletPaginationDto { + const factory WalletPaginationDto({ + @JsonKey(name: 'page') int? page, + @JsonKey(name: 'limit') int? limit, + @JsonKey(name: 'total_count') int? totalCount, + @JsonKey(name: 'total_pages') int? totalPages, + }) = _WalletPaginationDto; + + factory WalletPaginationDto.fromJson(Map json) => + _$WalletPaginationDtoFromJson(json); +} + +class WalletTransactionPageDto { + final List items; + final WalletPaginationDto pagination; + + const WalletTransactionPageDto({ + required this.items, + required this.pagination, + }); + + WalletTransactionPage toDomain() => WalletTransactionPage( + items: items.map((e) => e.toDomain()).toList(), + page: pagination.page ?? 1, + totalPages: pagination.totalPages ?? 1, + totalCount: pagination.totalCount ?? items.length, + ); +} diff --git a/lib/infrastructure/wallet/repositories/device_repository.dart b/lib/infrastructure/wallet/repositories/device_repository.dart new file mode 100644 index 0000000..1d0bc5e --- /dev/null +++ b/lib/infrastructure/wallet/repositories/device_repository.dart @@ -0,0 +1,58 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; +import '../datasources/device_data_provider.dart'; + +@Injectable(as: IDeviceRepository) +class DeviceRepository implements IDeviceRepository { + final DeviceLocalDataProvider _localDataProvider; + final DeviceRemoteDataProvider _remoteDataProvider; + + final String _logName = 'DeviceRepository'; + + DeviceRepository(this._localDataProvider, this._remoteDataProvider); + + @override + Future> register({ + required String fcmToken, + required String platform, + required String appVersion, + }) async { + try { + final result = await _remoteDataProvider.register( + deviceId: await _localDataProvider.deviceId(), + fcmToken: fcmToken, + platform: platform, + appVersion: appVersion, + ); + if (result.hasError) return left(result.error!); + + await _localDataProvider.setRegistered(true); + return right(unit); + } catch (e, s) { + log('register', name: _logName, error: e, stackTrace: s); + return left(const WalletFailure.unexpectedError()); + } + } + + @override + Future> unregister() async { + try { + if (!await _localDataProvider.isRegistered()) return right(unit); + + final result = await _remoteDataProvider.unregister( + deviceId: await _localDataProvider.deviceId(), + ); + if (result.hasError) return left(result.error!); + + await _localDataProvider.setRegistered(false); + return right(unit); + } catch (e, s) { + log('unregister', name: _logName, error: e, stackTrace: s); + return left(const WalletFailure.unexpectedError()); + } + } +} diff --git a/lib/infrastructure/wallet/repositories/order_repository.dart b/lib/infrastructure/wallet/repositories/order_repository.dart new file mode 100644 index 0000000..ff6351d --- /dev/null +++ b/lib/infrastructure/wallet/repositories/order_repository.dart @@ -0,0 +1,51 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:data_channel/data_channel.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; +import '../datasources/customer_remote_data_provider.dart'; + +@Injectable(as: IOrderRepository) +class OrderRepository implements IOrderRepository { + final CustomerRemoteDataProvider _remoteDataProvider; + + final String _logName = 'OrderRepository'; + + OrderRepository(this._remoteDataProvider); + + @override + Future> getOrders({ + required int page, + int limit = 20, + }) => _run( + 'getOrders', + () => _remoteDataProvider.fetchOrders(page: page, limit: limit), + (dto) => dto.toDomain(), + ); + + @override + Future> getOrderDetail( + String id, + ) => _run( + 'getOrderDetail', + () => _remoteDataProvider.fetchOrderDetail(id), + (dto) => dto.toDetailDomain(), + ); + + Future> _run( + String name, + Future> Function() call, + R Function(D dto) toDomain, + ) async { + try { + final result = await call(); + if (result.hasError) return left(result.error!); + return right(toDomain(result.data as D)); + } catch (e, s) { + log(name, name: _logName, error: e, stackTrace: s); + return left(const WalletFailure.unexpectedError()); + } + } +} diff --git a/lib/infrastructure/wallet/repositories/outlet_repository.dart b/lib/infrastructure/wallet/repositories/outlet_repository.dart new file mode 100644 index 0000000..68a0cfe --- /dev/null +++ b/lib/infrastructure/wallet/repositories/outlet_repository.dart @@ -0,0 +1,28 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; +import '../datasources/customer_remote_data_provider.dart'; + +@Injectable(as: IOutletRepository) +class OutletRepository implements IOutletRepository { + final CustomerRemoteDataProvider _remoteDataProvider; + + final String _logName = 'OutletRepository'; + + OutletRepository(this._remoteDataProvider); + + @override + Future>> getOutlets() async { + try { + final result = await _remoteDataProvider.fetchOutlets(); + if (result.hasError) return left(result.error!); + return right(result.data!.map((e) => e.toDomain()).toList()); + } catch (e, s) { + log('getOutlets', name: _logName, error: e, stackTrace: s); + return left(const WalletFailure.unexpectedError()); + } + } +} diff --git a/lib/infrastructure/wallet/repositories/pin_repository.dart b/lib/infrastructure/wallet/repositories/pin_repository.dart new file mode 100644 index 0000000..8a7852c --- /dev/null +++ b/lib/infrastructure/wallet/repositories/pin_repository.dart @@ -0,0 +1,96 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:data_channel/data_channel.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; +import '../datasources/pin_remote_data_provider.dart'; + +@Injectable(as: IPinRepository) +class PinRepository implements IPinRepository { + final PinRemoteDataProvider _remoteDataProvider; + + final String _logName = 'PinRepository'; + + PinRepository(this._remoteDataProvider); + + @override + Future> getStatus() => _run( + 'getStatus', + _remoteDataProvider.fetchStatus, + (dto) => dto.toDomain(), + ); + + @override + Future> requestOtp(PinOtpPurpose purpose) => + _run( + 'requestOtp', + () => _remoteDataProvider.requestOtp(purpose), + (dto) => dto.toDomain(), + ); + + @override + Future> setup({ + required String otpToken, + required String otpCode, + required String pin, + required String confirmPin, + }) => _run( + 'setup', + () => _remoteDataProvider.setup( + otpToken: otpToken, + otpCode: otpCode, + pin: pin, + confirmPin: confirmPin, + ), + (dto) => dto.toDomain(), + ); + + @override + Future> change({ + required String oldPin, + required String pin, + required String confirmPin, + }) => _run( + 'change', + () => _remoteDataProvider.change( + oldPin: oldPin, + pin: pin, + confirmPin: confirmPin, + ), + (value) => value, + ); + + @override + Future> reset({ + required String otpToken, + required String otpCode, + required String pin, + required String confirmPin, + }) => _run( + 'reset', + () => _remoteDataProvider.reset( + otpToken: otpToken, + otpCode: otpCode, + pin: pin, + confirmPin: confirmPin, + ), + (value) => value, + ); + + Future> _run( + String name, + Future> Function() call, + R Function(D dto) toDomain, + ) async { + try { + final result = await call(); + if (result.hasError) return left(result.error!); + return right(toDomain(result.data as D)); + } catch (e, s) { + log(name, name: _logName, error: e, stackTrace: s); + return left(const WalletFailure.unexpectedError()); + } + } +} diff --git a/lib/infrastructure/wallet/repositories/wallet_repository.dart b/lib/infrastructure/wallet/repositories/wallet_repository.dart new file mode 100644 index 0000000..58c2ae1 --- /dev/null +++ b/lib/infrastructure/wallet/repositories/wallet_repository.dart @@ -0,0 +1,128 @@ +import 'dart:developer'; + +import 'package:dartz/dartz.dart'; +import 'package:data_channel/data_channel.dart'; +import 'package:injectable/injectable.dart'; + +import '../../../domain/wallet/wallet.dart'; +import '../datasources/wallet_remote_data_provider.dart'; + +@Injectable(as: IWalletRepository) +class WalletRepository implements IWalletRepository { + final WalletRemoteDataProvider _remoteDataProvider; + + final String _logName = 'WalletRepository'; + + WalletRepository(this._remoteDataProvider); + + @override + Future> getWallet() => _run( + 'getWallet', + _remoteDataProvider.fetchWallet, + (dto) => dto.toDomain(), + ); + + @override + Future> getTransactions({ + required int page, + int limit = 20, + WalletCurrency? currency, + List types = const [], + DateTime? from, + DateTime? to, + }) => _run( + 'getTransactions', + () => _remoteDataProvider.fetchTransactions( + page: page, + limit: limit, + currency: currency, + types: types, + from: from, + to: to, + ), + (dto) => dto.toDomain(), + ); + + @override + Future> getExpiring() => _run( + 'getExpiring', + _remoteDataProvider.fetchExpiring, + (dto) => dto.toDomain(), + ); + + @override + Future> createPaymentCode({ + required String pin, + }) => _run( + 'createPaymentCode', + () => _remoteDataProvider.createPaymentCode(pin: pin), + (dto) => dto.toDomain(), + ); + + @override + Future> previewExchange({ + required int coins, + }) => _run( + 'previewExchange', + () => _remoteDataProvider.previewExchange(coins: coins), + (dto) => dto.toDomain(), + ); + + @override + Future> exchange({ + required int coins, + required String pin, + required String idempotencyKey, + }) => _run( + 'exchange', + () => _remoteDataProvider.exchange( + coins: coins, + pin: pin, + idempotencyKey: idempotencyKey, + ), + (dto) => dto.toDomain(), + ); + + @override + Future> checkRecipient({ + required String phone, + }) => _run( + 'checkRecipient', + () => _remoteDataProvider.checkRecipient(phone: phone), + (dto) => dto.toDomain(), + ); + + @override + Future> transfer({ + required WalletCurrency currency, + required int amount, + required String recipientPhone, + required String pin, + required String idempotencyKey, + }) => _run( + 'transfer', + () => _remoteDataProvider.transfer( + currency: currency, + amount: amount, + recipientPhone: recipientPhone, + pin: pin, + idempotencyKey: idempotencyKey, + ), + (dto) => dto.toDomain(), + ); + + Future> _run( + String name, + Future> Function() call, + R Function(D dto) toDomain, + ) async { + try { + final result = await call(); + if (result.hasError) return left(result.error!); + return right(toDomain(result.data as D)); + } catch (e, s) { + log(name, name: _logName, error: e, stackTrace: s); + return left(const WalletFailure.unexpectedError()); + } + } +} diff --git a/lib/infrastructure/wallet/wallet_dtos.dart b/lib/infrastructure/wallet/wallet_dtos.dart new file mode 100644 index 0000000..148a541 --- /dev/null +++ b/lib/infrastructure/wallet/wallet_dtos.dart @@ -0,0 +1,27 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +import '../../domain/wallet/wallet.dart'; + +part 'wallet_dtos.freezed.dart'; +part 'wallet_dtos.g.dart'; + +part 'dto/wallet_summary_dto.dart'; +part 'dto/wallet_transaction_dto.dart'; +part 'dto/wallet_expiring_dto.dart'; +part 'dto/payment_code_dto.dart'; +part 'dto/exchange_dto.dart'; +part 'dto/transfer_dto.dart'; +part 'dto/pin_dto.dart'; +part 'dto/outlet_dto.dart'; +part 'dto/customer_order_dto.dart'; + +DateTime? _parseDateTime(String? value) => + value == null ? null : DateTime.tryParse(value); + +/// Tanggal `yyyy-MM-dd` (WIB) sebagai tanggal kalender, tanpa konversi zona. +DateTime? _parseDate(String? value) { + if (value == null) return null; + final parsed = DateTime.tryParse(value); + if (parsed == null) return null; + return DateTime(parsed.year, parsed.month, parsed.day); +} diff --git a/lib/infrastructure/wallet/wallet_dtos.freezed.dart b/lib/infrastructure/wallet/wallet_dtos.freezed.dart new file mode 100644 index 0000000..8940fe3 --- /dev/null +++ b/lib/infrastructure/wallet/wallet_dtos.freezed.dart @@ -0,0 +1,5267 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'wallet_dtos.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$WalletSummaryDto { + +@JsonKey(name: 'point_balance') int? get pointBalance;@JsonKey(name: 'coin_balance') int? get coinBalance;@JsonKey(name: 'point_value') int? get pointValue;@JsonKey(name: 'point_discount_value') int? get pointDiscountValue;@JsonKey(name: 'nearest_expiring') NearestExpiringDto? get nearestExpiring;@JsonKey(name: 'recent_transactions') List? get recentTransactions; +/// Create a copy of WalletSummaryDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletSummaryDtoCopyWith get copyWith => _$WalletSummaryDtoCopyWithImpl(this as WalletSummaryDto, _$identity); + + /// Serializes this WalletSummaryDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as WalletSummaryDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletSummaryDto&&(identical(other.pointBalance, _this.pointBalance) || other.pointBalance == _this.pointBalance)&&(identical(other.coinBalance, _this.coinBalance) || other.coinBalance == _this.coinBalance)&&(identical(other.pointValue, _this.pointValue) || other.pointValue == _this.pointValue)&&(identical(other.pointDiscountValue, _this.pointDiscountValue) || other.pointDiscountValue == _this.pointDiscountValue)&&(identical(other.nearestExpiring, _this.nearestExpiring) || other.nearestExpiring == _this.nearestExpiring)&&const DeepCollectionEquality().equals(other.recentTransactions, _this.recentTransactions)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as WalletSummaryDto; + return Object.hash(runtimeType,_this.pointBalance,_this.coinBalance,_this.pointValue,_this.pointDiscountValue,_this.nearestExpiring,const DeepCollectionEquality().hash(_this.recentTransactions)); +} + +@override +String toString() { + final _this = this as WalletSummaryDto; + return 'WalletSummaryDto(pointBalance: ${_this.pointBalance}, coinBalance: ${_this.coinBalance}, pointValue: ${_this.pointValue}, pointDiscountValue: ${_this.pointDiscountValue}, nearestExpiring: ${_this.nearestExpiring}, recentTransactions: ${_this.recentTransactions})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletSummaryDtoCopyWith<$Res> { + factory $WalletSummaryDtoCopyWith(WalletSummaryDto value, $Res Function(WalletSummaryDto) _then) = _$WalletSummaryDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'point_balance') int? pointBalance,@JsonKey(name: 'coin_balance') int? coinBalance,@JsonKey(name: 'point_value') int? pointValue,@JsonKey(name: 'point_discount_value') int? pointDiscountValue,@JsonKey(name: 'nearest_expiring') NearestExpiringDto? nearestExpiring,@JsonKey(name: 'recent_transactions') List? recentTransactions +}); + + +$NearestExpiringDtoCopyWith<$Res>? get nearestExpiring; + +} +/// @nodoc +class _$WalletSummaryDtoCopyWithImpl<$Res> + implements $WalletSummaryDtoCopyWith<$Res> { + _$WalletSummaryDtoCopyWithImpl(this._self, this._then); + + final WalletSummaryDto _self; + final $Res Function(WalletSummaryDto) _then; + +/// Create a copy of WalletSummaryDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? pointBalance = freezed,Object? coinBalance = freezed,Object? pointValue = freezed,Object? pointDiscountValue = freezed,Object? nearestExpiring = freezed,Object? recentTransactions = freezed,}) { + return _then(WalletSummaryDto( +pointBalance: freezed == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int?,coinBalance: freezed == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int?,pointValue: freezed == pointValue ? _self.pointValue : pointValue // ignore: cast_nullable_to_non_nullable +as int?,pointDiscountValue: freezed == pointDiscountValue ? _self.pointDiscountValue : pointDiscountValue // ignore: cast_nullable_to_non_nullable +as int?,nearestExpiring: freezed == nearestExpiring ? _self.nearestExpiring : nearestExpiring // ignore: cast_nullable_to_non_nullable +as NearestExpiringDto?,recentTransactions: freezed == recentTransactions ? _self.recentTransactions : recentTransactions // ignore: cast_nullable_to_non_nullable +as List?, + )); +} +/// Create a copy of WalletSummaryDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$NearestExpiringDtoCopyWith<$Res>? get nearestExpiring { + if (_self.nearestExpiring == null) { + return null; + } + + return $NearestExpiringDtoCopyWith<$Res>(_self.nearestExpiring!, (value) { + return _then(_self.copyWith(nearestExpiring: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [WalletSummaryDto]. +extension WalletSummaryDtoPatterns on WalletSummaryDto { +/// 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( _WalletSummaryDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletSummaryDto() 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( _WalletSummaryDto value) $default,){ +final _that = this; +switch (_that) { +case _WalletSummaryDto(): +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( _WalletSummaryDto value)? $default,){ +final _that = this; +switch (_that) { +case _WalletSummaryDto() 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(@JsonKey(name: 'point_balance') int? pointBalance, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'point_value') int? pointValue, @JsonKey(name: 'point_discount_value') int? pointDiscountValue, @JsonKey(name: 'nearest_expiring') NearestExpiringDto? nearestExpiring, @JsonKey(name: 'recent_transactions') List? recentTransactions)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletSummaryDto() when $default != null: +return $default(_that.pointBalance,_that.coinBalance,_that.pointValue,_that.pointDiscountValue,_that.nearestExpiring,_that.recentTransactions);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(@JsonKey(name: 'point_balance') int? pointBalance, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'point_value') int? pointValue, @JsonKey(name: 'point_discount_value') int? pointDiscountValue, @JsonKey(name: 'nearest_expiring') NearestExpiringDto? nearestExpiring, @JsonKey(name: 'recent_transactions') List? recentTransactions) $default,) {final _that = this; +switch (_that) { +case _WalletSummaryDto(): +return $default(_that.pointBalance,_that.coinBalance,_that.pointValue,_that.pointDiscountValue,_that.nearestExpiring,_that.recentTransactions);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(@JsonKey(name: 'point_balance') int? pointBalance, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'point_value') int? pointValue, @JsonKey(name: 'point_discount_value') int? pointDiscountValue, @JsonKey(name: 'nearest_expiring') NearestExpiringDto? nearestExpiring, @JsonKey(name: 'recent_transactions') List? recentTransactions)? $default,) {final _that = this; +switch (_that) { +case _WalletSummaryDto() when $default != null: +return $default(_that.pointBalance,_that.coinBalance,_that.pointValue,_that.pointDiscountValue,_that.nearestExpiring,_that.recentTransactions);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _WalletSummaryDto extends WalletSummaryDto { + const _WalletSummaryDto({@JsonKey(name: 'point_balance') this.pointBalance, @JsonKey(name: 'coin_balance') this.coinBalance, @JsonKey(name: 'point_value') this.pointValue, @JsonKey(name: 'point_discount_value') this.pointDiscountValue, @JsonKey(name: 'nearest_expiring') this.nearestExpiring, @JsonKey(name: 'recent_transactions') List? recentTransactions}): _recentTransactions = recentTransactions,super._(); + factory _WalletSummaryDto.fromJson(Map json) => _$WalletSummaryDtoFromJson(json); + +@override@JsonKey(name: 'point_balance') final int? pointBalance; +@override@JsonKey(name: 'coin_balance') final int? coinBalance; +@override@JsonKey(name: 'point_value') final int? pointValue; +@override@JsonKey(name: 'point_discount_value') final int? pointDiscountValue; +@override@JsonKey(name: 'nearest_expiring') final NearestExpiringDto? nearestExpiring; + final List? _recentTransactions; +@override@JsonKey(name: 'recent_transactions') List? get recentTransactions { + final value = _recentTransactions; + if (value == null) return null; + if (_recentTransactions is EqualUnmodifiableListView) return _recentTransactions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + + +/// Create a copy of WalletSummaryDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletSummaryDtoCopyWith<_WalletSummaryDto> get copyWith => __$WalletSummaryDtoCopyWithImpl<_WalletSummaryDto>(this, _$identity); + +@override +Map toJson() { + return _$WalletSummaryDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletSummaryDto&&(identical(other.pointBalance, pointBalance) || other.pointBalance == pointBalance)&&(identical(other.coinBalance, coinBalance) || other.coinBalance == coinBalance)&&(identical(other.pointValue, pointValue) || other.pointValue == pointValue)&&(identical(other.pointDiscountValue, pointDiscountValue) || other.pointDiscountValue == pointDiscountValue)&&(identical(other.nearestExpiring, nearestExpiring) || other.nearestExpiring == nearestExpiring)&&const DeepCollectionEquality().equals(other.recentTransactions, _recentTransactions)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,pointBalance,coinBalance,pointValue,pointDiscountValue,nearestExpiring,const DeepCollectionEquality().hash(_recentTransactions)); +} + +@override +String toString() { + return 'WalletSummaryDto(pointBalance: $pointBalance, coinBalance: $coinBalance, pointValue: $pointValue, pointDiscountValue: $pointDiscountValue, nearestExpiring: $nearestExpiring, recentTransactions: $recentTransactions)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletSummaryDtoCopyWith<$Res> implements $WalletSummaryDtoCopyWith<$Res> { + factory _$WalletSummaryDtoCopyWith(_WalletSummaryDto value, $Res Function(_WalletSummaryDto) _then) = __$WalletSummaryDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'point_balance') int? pointBalance,@JsonKey(name: 'coin_balance') int? coinBalance,@JsonKey(name: 'point_value') int? pointValue,@JsonKey(name: 'point_discount_value') int? pointDiscountValue,@JsonKey(name: 'nearest_expiring') NearestExpiringDto? nearestExpiring,@JsonKey(name: 'recent_transactions') List? recentTransactions +}); + + +@override $NearestExpiringDtoCopyWith<$Res>? get nearestExpiring; + +} +/// @nodoc +class __$WalletSummaryDtoCopyWithImpl<$Res> + implements _$WalletSummaryDtoCopyWith<$Res> { + __$WalletSummaryDtoCopyWithImpl(this._self, this._then); + + final _WalletSummaryDto _self; + final $Res Function(_WalletSummaryDto) _then; + +/// Create a copy of WalletSummaryDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? pointBalance = freezed,Object? coinBalance = freezed,Object? pointValue = freezed,Object? pointDiscountValue = freezed,Object? nearestExpiring = freezed,Object? recentTransactions = freezed,}) { + return _then(_WalletSummaryDto( +pointBalance: freezed == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int?,coinBalance: freezed == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int?,pointValue: freezed == pointValue ? _self.pointValue : pointValue // ignore: cast_nullable_to_non_nullable +as int?,pointDiscountValue: freezed == pointDiscountValue ? _self.pointDiscountValue : pointDiscountValue // ignore: cast_nullable_to_non_nullable +as int?,nearestExpiring: freezed == nearestExpiring ? _self.nearestExpiring : nearestExpiring // ignore: cast_nullable_to_non_nullable +as NearestExpiringDto?,recentTransactions: freezed == recentTransactions ? _self._recentTransactions : recentTransactions // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + +/// Create a copy of WalletSummaryDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$NearestExpiringDtoCopyWith<$Res>? get nearestExpiring { + if (_self.nearestExpiring == null) { + return null; + } + + return $NearestExpiringDtoCopyWith<$Res>(_self.nearestExpiring!, (value) { + return _then(_self.copyWith(nearestExpiring: value)); + }); +} +} + + +/// @nodoc +mixin _$NearestExpiringDto { + +@JsonKey(name: 'point') ExpiringAmountDto? get point;@JsonKey(name: 'coin') ExpiringAmountDto? get coin; +/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$NearestExpiringDtoCopyWith get copyWith => _$NearestExpiringDtoCopyWithImpl(this as NearestExpiringDto, _$identity); + + /// Serializes this NearestExpiringDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as NearestExpiringDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is NearestExpiringDto&&(identical(other.point, _this.point) || other.point == _this.point)&&(identical(other.coin, _this.coin) || other.coin == _this.coin)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as NearestExpiringDto; + return Object.hash(runtimeType,_this.point,_this.coin); +} + +@override +String toString() { + final _this = this as NearestExpiringDto; + return 'NearestExpiringDto(point: ${_this.point}, coin: ${_this.coin})'; +} + + +} + +/// @nodoc +abstract mixin class $NearestExpiringDtoCopyWith<$Res> { + factory $NearestExpiringDtoCopyWith(NearestExpiringDto value, $Res Function(NearestExpiringDto) _then) = _$NearestExpiringDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'point') ExpiringAmountDto? point,@JsonKey(name: 'coin') ExpiringAmountDto? coin +}); + + +$ExpiringAmountDtoCopyWith<$Res>? get point;$ExpiringAmountDtoCopyWith<$Res>? get coin; + +} +/// @nodoc +class _$NearestExpiringDtoCopyWithImpl<$Res> + implements $NearestExpiringDtoCopyWith<$Res> { + _$NearestExpiringDtoCopyWithImpl(this._self, this._then); + + final NearestExpiringDto _self; + final $Res Function(NearestExpiringDto) _then; + +/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? point = freezed,Object? coin = freezed,}) { + return _then(NearestExpiringDto( +point: freezed == point ? _self.point : point // ignore: cast_nullable_to_non_nullable +as ExpiringAmountDto?,coin: freezed == coin ? _self.coin : coin // ignore: cast_nullable_to_non_nullable +as ExpiringAmountDto?, + )); +} +/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountDtoCopyWith<$Res>? get point { + if (_self.point == null) { + return null; + } + + return $ExpiringAmountDtoCopyWith<$Res>(_self.point!, (value) { + return _then(_self.copyWith(point: value)); + }); +}/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountDtoCopyWith<$Res>? get coin { + if (_self.coin == null) { + return null; + } + + return $ExpiringAmountDtoCopyWith<$Res>(_self.coin!, (value) { + return _then(_self.copyWith(coin: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [NearestExpiringDto]. +extension NearestExpiringDtoPatterns on NearestExpiringDto { +/// 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( _NearestExpiringDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _NearestExpiringDto() 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( _NearestExpiringDto value) $default,){ +final _that = this; +switch (_that) { +case _NearestExpiringDto(): +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( _NearestExpiringDto value)? $default,){ +final _that = this; +switch (_that) { +case _NearestExpiringDto() 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(@JsonKey(name: 'point') ExpiringAmountDto? point, @JsonKey(name: 'coin') ExpiringAmountDto? coin)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _NearestExpiringDto() when $default != null: +return $default(_that.point,_that.coin);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(@JsonKey(name: 'point') ExpiringAmountDto? point, @JsonKey(name: 'coin') ExpiringAmountDto? coin) $default,) {final _that = this; +switch (_that) { +case _NearestExpiringDto(): +return $default(_that.point,_that.coin);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(@JsonKey(name: 'point') ExpiringAmountDto? point, @JsonKey(name: 'coin') ExpiringAmountDto? coin)? $default,) {final _that = this; +switch (_that) { +case _NearestExpiringDto() when $default != null: +return $default(_that.point,_that.coin);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _NearestExpiringDto implements NearestExpiringDto { + const _NearestExpiringDto({@JsonKey(name: 'point') this.point, @JsonKey(name: 'coin') this.coin}); + factory _NearestExpiringDto.fromJson(Map json) => _$NearestExpiringDtoFromJson(json); + +@override@JsonKey(name: 'point') final ExpiringAmountDto? point; +@override@JsonKey(name: 'coin') final ExpiringAmountDto? coin; + +/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NearestExpiringDtoCopyWith<_NearestExpiringDto> get copyWith => __$NearestExpiringDtoCopyWithImpl<_NearestExpiringDto>(this, _$identity); + +@override +Map toJson() { + return _$NearestExpiringDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _NearestExpiringDto&&(identical(other.point, point) || other.point == point)&&(identical(other.coin, coin) || other.coin == coin)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,point,coin); +} + +@override +String toString() { + return 'NearestExpiringDto(point: $point, coin: $coin)'; +} + + +} + +/// @nodoc +abstract mixin class _$NearestExpiringDtoCopyWith<$Res> implements $NearestExpiringDtoCopyWith<$Res> { + factory _$NearestExpiringDtoCopyWith(_NearestExpiringDto value, $Res Function(_NearestExpiringDto) _then) = __$NearestExpiringDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'point') ExpiringAmountDto? point,@JsonKey(name: 'coin') ExpiringAmountDto? coin +}); + + +@override $ExpiringAmountDtoCopyWith<$Res>? get point;@override $ExpiringAmountDtoCopyWith<$Res>? get coin; + +} +/// @nodoc +class __$NearestExpiringDtoCopyWithImpl<$Res> + implements _$NearestExpiringDtoCopyWith<$Res> { + __$NearestExpiringDtoCopyWithImpl(this._self, this._then); + + final _NearestExpiringDto _self; + final $Res Function(_NearestExpiringDto) _then; + +/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? point = freezed,Object? coin = freezed,}) { + return _then(_NearestExpiringDto( +point: freezed == point ? _self.point : point // ignore: cast_nullable_to_non_nullable +as ExpiringAmountDto?,coin: freezed == coin ? _self.coin : coin // ignore: cast_nullable_to_non_nullable +as ExpiringAmountDto?, + )); +} + +/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountDtoCopyWith<$Res>? get point { + if (_self.point == null) { + return null; + } + + return $ExpiringAmountDtoCopyWith<$Res>(_self.point!, (value) { + return _then(_self.copyWith(point: value)); + }); +}/// Create a copy of NearestExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$ExpiringAmountDtoCopyWith<$Res>? get coin { + if (_self.coin == null) { + return null; + } + + return $ExpiringAmountDtoCopyWith<$Res>(_self.coin!, (value) { + return _then(_self.copyWith(coin: value)); + }); +} +} + + +/// @nodoc +mixin _$ExpiringAmountDto { + +@JsonKey(name: 'amount') int? get amount;@JsonKey(name: 'date') String? get date; +/// Create a copy of ExpiringAmountDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExpiringAmountDtoCopyWith get copyWith => _$ExpiringAmountDtoCopyWithImpl(this as ExpiringAmountDto, _$identity); + + /// Serializes this ExpiringAmountDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as ExpiringAmountDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExpiringAmountDto&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.date, _this.date) || other.date == _this.date)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as ExpiringAmountDto; + return Object.hash(runtimeType,_this.amount,_this.date); +} + +@override +String toString() { + final _this = this as ExpiringAmountDto; + return 'ExpiringAmountDto(amount: ${_this.amount}, date: ${_this.date})'; +} + + +} + +/// @nodoc +abstract mixin class $ExpiringAmountDtoCopyWith<$Res> { + factory $ExpiringAmountDtoCopyWith(ExpiringAmountDto value, $Res Function(ExpiringAmountDto) _then) = _$ExpiringAmountDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'date') String? date +}); + + + + +} +/// @nodoc +class _$ExpiringAmountDtoCopyWithImpl<$Res> + implements $ExpiringAmountDtoCopyWith<$Res> { + _$ExpiringAmountDtoCopyWithImpl(this._self, this._then); + + final ExpiringAmountDto _self; + final $Res Function(ExpiringAmountDto) _then; + +/// Create a copy of ExpiringAmountDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? amount = freezed,Object? date = freezed,}) { + return _then(ExpiringAmountDto( +amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ExpiringAmountDto]. +extension ExpiringAmountDtoPatterns on ExpiringAmountDto { +/// 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( _ExpiringAmountDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExpiringAmountDto() 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( _ExpiringAmountDto value) $default,){ +final _that = this; +switch (_that) { +case _ExpiringAmountDto(): +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( _ExpiringAmountDto value)? $default,){ +final _that = this; +switch (_that) { +case _ExpiringAmountDto() 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(@JsonKey(name: 'amount') int? amount, @JsonKey(name: 'date') String? date)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExpiringAmountDto() when $default != null: +return $default(_that.amount,_that.date);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(@JsonKey(name: 'amount') int? amount, @JsonKey(name: 'date') String? date) $default,) {final _that = this; +switch (_that) { +case _ExpiringAmountDto(): +return $default(_that.amount,_that.date);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(@JsonKey(name: 'amount') int? amount, @JsonKey(name: 'date') String? date)? $default,) {final _that = this; +switch (_that) { +case _ExpiringAmountDto() when $default != null: +return $default(_that.amount,_that.date);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _ExpiringAmountDto extends ExpiringAmountDto { + const _ExpiringAmountDto({@JsonKey(name: 'amount') this.amount, @JsonKey(name: 'date') this.date}): super._(); + factory _ExpiringAmountDto.fromJson(Map json) => _$ExpiringAmountDtoFromJson(json); + +@override@JsonKey(name: 'amount') final int? amount; +@override@JsonKey(name: 'date') final String? date; + +/// Create a copy of ExpiringAmountDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExpiringAmountDtoCopyWith<_ExpiringAmountDto> get copyWith => __$ExpiringAmountDtoCopyWithImpl<_ExpiringAmountDto>(this, _$identity); + +@override +Map toJson() { + return _$ExpiringAmountDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExpiringAmountDto&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.date, date) || other.date == date)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,amount,date); +} + +@override +String toString() { + return 'ExpiringAmountDto(amount: $amount, date: $date)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExpiringAmountDtoCopyWith<$Res> implements $ExpiringAmountDtoCopyWith<$Res> { + factory _$ExpiringAmountDtoCopyWith(_ExpiringAmountDto value, $Res Function(_ExpiringAmountDto) _then) = __$ExpiringAmountDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'date') String? date +}); + + + + +} +/// @nodoc +class __$ExpiringAmountDtoCopyWithImpl<$Res> + implements _$ExpiringAmountDtoCopyWith<$Res> { + __$ExpiringAmountDtoCopyWithImpl(this._self, this._then); + + final _ExpiringAmountDto _self; + final $Res Function(_ExpiringAmountDto) _then; + +/// Create a copy of ExpiringAmountDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? amount = freezed,Object? date = freezed,}) { + return _then(_ExpiringAmountDto( +amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$WalletTransactionDto { + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'currency') String? get currency;@JsonKey(name: 'type') String? get type;@JsonKey(name: 'amount') int? get amount;@JsonKey(name: 'balance_after') int? get balanceAfter;@JsonKey(name: 'description') String? get description;@JsonKey(name: 'group_id') String? get groupId;@JsonKey(name: 'expires_at') String? get expiresAt;@JsonKey(name: 'created_at') String? get createdAt; +/// Create a copy of WalletTransactionDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletTransactionDtoCopyWith get copyWith => _$WalletTransactionDtoCopyWithImpl(this as WalletTransactionDto, _$identity); + + /// Serializes this WalletTransactionDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as WalletTransactionDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletTransactionDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.currency, _this.currency) || other.currency == _this.currency)&&(identical(other.type, _this.type) || other.type == _this.type)&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.balanceAfter, _this.balanceAfter) || other.balanceAfter == _this.balanceAfter)&&(identical(other.description, _this.description) || other.description == _this.description)&&(identical(other.groupId, _this.groupId) || other.groupId == _this.groupId)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as WalletTransactionDto; + return Object.hash(runtimeType,_this.id,_this.currency,_this.type,_this.amount,_this.balanceAfter,_this.description,_this.groupId,_this.expiresAt,_this.createdAt); +} + +@override +String toString() { + final _this = this as WalletTransactionDto; + return 'WalletTransactionDto(id: ${_this.id}, currency: ${_this.currency}, type: ${_this.type}, amount: ${_this.amount}, balanceAfter: ${_this.balanceAfter}, description: ${_this.description}, groupId: ${_this.groupId}, expiresAt: ${_this.expiresAt}, createdAt: ${_this.createdAt})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletTransactionDtoCopyWith<$Res> { + factory $WalletTransactionDtoCopyWith(WalletTransactionDto value, $Res Function(WalletTransactionDto) _then) = _$WalletTransactionDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'currency') String? currency,@JsonKey(name: 'type') String? type,@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'balance_after') int? balanceAfter,@JsonKey(name: 'description') String? description,@JsonKey(name: 'group_id') String? groupId,@JsonKey(name: 'expires_at') String? expiresAt,@JsonKey(name: 'created_at') String? createdAt +}); + + + + +} +/// @nodoc +class _$WalletTransactionDtoCopyWithImpl<$Res> + implements $WalletTransactionDtoCopyWith<$Res> { + _$WalletTransactionDtoCopyWithImpl(this._self, this._then); + + final WalletTransactionDto _self; + final $Res Function(WalletTransactionDto) _then; + +/// Create a copy of WalletTransactionDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? currency = freezed,Object? type = freezed,Object? amount = freezed,Object? balanceAfter = freezed,Object? description = freezed,Object? groupId = freezed,Object? expiresAt = freezed,Object? createdAt = freezed,}) { + return _then(WalletTransactionDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,currency: freezed == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,balanceAfter: freezed == balanceAfter ? _self.balanceAfter : balanceAfter // ignore: cast_nullable_to_non_nullable +as int?,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String?,groupId: freezed == groupId ? _self.groupId : groupId // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletTransactionDto]. +extension WalletTransactionDtoPatterns on WalletTransactionDto { +/// 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( _WalletTransactionDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletTransactionDto() 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( _WalletTransactionDto value) $default,){ +final _that = this; +switch (_that) { +case _WalletTransactionDto(): +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( _WalletTransactionDto value)? $default,){ +final _that = this; +switch (_that) { +case _WalletTransactionDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'currency') String? currency, @JsonKey(name: 'type') String? type, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'balance_after') int? balanceAfter, @JsonKey(name: 'description') String? description, @JsonKey(name: 'group_id') String? groupId, @JsonKey(name: 'expires_at') String? expiresAt, @JsonKey(name: 'created_at') String? createdAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletTransactionDto() when $default != null: +return $default(_that.id,_that.currency,_that.type,_that.amount,_that.balanceAfter,_that.description,_that.groupId,_that.expiresAt,_that.createdAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'currency') String? currency, @JsonKey(name: 'type') String? type, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'balance_after') int? balanceAfter, @JsonKey(name: 'description') String? description, @JsonKey(name: 'group_id') String? groupId, @JsonKey(name: 'expires_at') String? expiresAt, @JsonKey(name: 'created_at') String? createdAt) $default,) {final _that = this; +switch (_that) { +case _WalletTransactionDto(): +return $default(_that.id,_that.currency,_that.type,_that.amount,_that.balanceAfter,_that.description,_that.groupId,_that.expiresAt,_that.createdAt);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'currency') String? currency, @JsonKey(name: 'type') String? type, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'balance_after') int? balanceAfter, @JsonKey(name: 'description') String? description, @JsonKey(name: 'group_id') String? groupId, @JsonKey(name: 'expires_at') String? expiresAt, @JsonKey(name: 'created_at') String? createdAt)? $default,) {final _that = this; +switch (_that) { +case _WalletTransactionDto() when $default != null: +return $default(_that.id,_that.currency,_that.type,_that.amount,_that.balanceAfter,_that.description,_that.groupId,_that.expiresAt,_that.createdAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _WalletTransactionDto extends WalletTransactionDto { + const _WalletTransactionDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'currency') this.currency, @JsonKey(name: 'type') this.type, @JsonKey(name: 'amount') this.amount, @JsonKey(name: 'balance_after') this.balanceAfter, @JsonKey(name: 'description') this.description, @JsonKey(name: 'group_id') this.groupId, @JsonKey(name: 'expires_at') this.expiresAt, @JsonKey(name: 'created_at') this.createdAt}): super._(); + factory _WalletTransactionDto.fromJson(Map json) => _$WalletTransactionDtoFromJson(json); + +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'currency') final String? currency; +@override@JsonKey(name: 'type') final String? type; +@override@JsonKey(name: 'amount') final int? amount; +@override@JsonKey(name: 'balance_after') final int? balanceAfter; +@override@JsonKey(name: 'description') final String? description; +@override@JsonKey(name: 'group_id') final String? groupId; +@override@JsonKey(name: 'expires_at') final String? expiresAt; +@override@JsonKey(name: 'created_at') final String? createdAt; + +/// Create a copy of WalletTransactionDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletTransactionDtoCopyWith<_WalletTransactionDto> get copyWith => __$WalletTransactionDtoCopyWithImpl<_WalletTransactionDto>(this, _$identity); + +@override +Map toJson() { + return _$WalletTransactionDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletTransactionDto&&(identical(other.id, id) || other.id == id)&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.type, type) || other.type == type)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.balanceAfter, balanceAfter) || other.balanceAfter == balanceAfter)&&(identical(other.description, description) || other.description == description)&&(identical(other.groupId, groupId) || other.groupId == groupId)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,currency,type,amount,balanceAfter,description,groupId,expiresAt,createdAt); +} + +@override +String toString() { + return 'WalletTransactionDto(id: $id, currency: $currency, type: $type, amount: $amount, balanceAfter: $balanceAfter, description: $description, groupId: $groupId, expiresAt: $expiresAt, createdAt: $createdAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletTransactionDtoCopyWith<$Res> implements $WalletTransactionDtoCopyWith<$Res> { + factory _$WalletTransactionDtoCopyWith(_WalletTransactionDto value, $Res Function(_WalletTransactionDto) _then) = __$WalletTransactionDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'currency') String? currency,@JsonKey(name: 'type') String? type,@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'balance_after') int? balanceAfter,@JsonKey(name: 'description') String? description,@JsonKey(name: 'group_id') String? groupId,@JsonKey(name: 'expires_at') String? expiresAt,@JsonKey(name: 'created_at') String? createdAt +}); + + + + +} +/// @nodoc +class __$WalletTransactionDtoCopyWithImpl<$Res> + implements _$WalletTransactionDtoCopyWith<$Res> { + __$WalletTransactionDtoCopyWithImpl(this._self, this._then); + + final _WalletTransactionDto _self; + final $Res Function(_WalletTransactionDto) _then; + +/// Create a copy of WalletTransactionDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? currency = freezed,Object? type = freezed,Object? amount = freezed,Object? balanceAfter = freezed,Object? description = freezed,Object? groupId = freezed,Object? expiresAt = freezed,Object? createdAt = freezed,}) { + return _then(_WalletTransactionDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,currency: freezed == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String?,type: freezed == type ? _self.type : type // ignore: cast_nullable_to_non_nullable +as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,balanceAfter: freezed == balanceAfter ? _self.balanceAfter : balanceAfter // ignore: cast_nullable_to_non_nullable +as int?,description: freezed == description ? _self.description : description // ignore: cast_nullable_to_non_nullable +as String?,groupId: freezed == groupId ? _self.groupId : groupId // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$WalletPaginationDto { + +@JsonKey(name: 'page') int? get page;@JsonKey(name: 'limit') int? get limit;@JsonKey(name: 'total_count') int? get totalCount;@JsonKey(name: 'total_pages') int? get totalPages; +/// Create a copy of WalletPaginationDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletPaginationDtoCopyWith get copyWith => _$WalletPaginationDtoCopyWithImpl(this as WalletPaginationDto, _$identity); + + /// Serializes this WalletPaginationDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as WalletPaginationDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletPaginationDto&&(identical(other.page, _this.page) || other.page == _this.page)&&(identical(other.limit, _this.limit) || other.limit == _this.limit)&&(identical(other.totalCount, _this.totalCount) || other.totalCount == _this.totalCount)&&(identical(other.totalPages, _this.totalPages) || other.totalPages == _this.totalPages)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as WalletPaginationDto; + return Object.hash(runtimeType,_this.page,_this.limit,_this.totalCount,_this.totalPages); +} + +@override +String toString() { + final _this = this as WalletPaginationDto; + return 'WalletPaginationDto(page: ${_this.page}, limit: ${_this.limit}, totalCount: ${_this.totalCount}, totalPages: ${_this.totalPages})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletPaginationDtoCopyWith<$Res> { + factory $WalletPaginationDtoCopyWith(WalletPaginationDto value, $Res Function(WalletPaginationDto) _then) = _$WalletPaginationDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'page') int? page,@JsonKey(name: 'limit') int? limit,@JsonKey(name: 'total_count') int? totalCount,@JsonKey(name: 'total_pages') int? totalPages +}); + + + + +} +/// @nodoc +class _$WalletPaginationDtoCopyWithImpl<$Res> + implements $WalletPaginationDtoCopyWith<$Res> { + _$WalletPaginationDtoCopyWithImpl(this._self, this._then); + + final WalletPaginationDto _self; + final $Res Function(WalletPaginationDto) _then; + +/// Create a copy of WalletPaginationDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? page = freezed,Object? limit = freezed,Object? totalCount = freezed,Object? totalPages = freezed,}) { + return _then(WalletPaginationDto( +page: freezed == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int?,limit: freezed == limit ? _self.limit : limit // ignore: cast_nullable_to_non_nullable +as int?,totalCount: freezed == totalCount ? _self.totalCount : totalCount // ignore: cast_nullable_to_non_nullable +as int?,totalPages: freezed == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletPaginationDto]. +extension WalletPaginationDtoPatterns on WalletPaginationDto { +/// 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( _WalletPaginationDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletPaginationDto() 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( _WalletPaginationDto value) $default,){ +final _that = this; +switch (_that) { +case _WalletPaginationDto(): +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( _WalletPaginationDto value)? $default,){ +final _that = this; +switch (_that) { +case _WalletPaginationDto() 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(@JsonKey(name: 'page') int? page, @JsonKey(name: 'limit') int? limit, @JsonKey(name: 'total_count') int? totalCount, @JsonKey(name: 'total_pages') int? totalPages)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletPaginationDto() when $default != null: +return $default(_that.page,_that.limit,_that.totalCount,_that.totalPages);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(@JsonKey(name: 'page') int? page, @JsonKey(name: 'limit') int? limit, @JsonKey(name: 'total_count') int? totalCount, @JsonKey(name: 'total_pages') int? totalPages) $default,) {final _that = this; +switch (_that) { +case _WalletPaginationDto(): +return $default(_that.page,_that.limit,_that.totalCount,_that.totalPages);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(@JsonKey(name: 'page') int? page, @JsonKey(name: 'limit') int? limit, @JsonKey(name: 'total_count') int? totalCount, @JsonKey(name: 'total_pages') int? totalPages)? $default,) {final _that = this; +switch (_that) { +case _WalletPaginationDto() when $default != null: +return $default(_that.page,_that.limit,_that.totalCount,_that.totalPages);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _WalletPaginationDto implements WalletPaginationDto { + const _WalletPaginationDto({@JsonKey(name: 'page') this.page, @JsonKey(name: 'limit') this.limit, @JsonKey(name: 'total_count') this.totalCount, @JsonKey(name: 'total_pages') this.totalPages}); + factory _WalletPaginationDto.fromJson(Map json) => _$WalletPaginationDtoFromJson(json); + +@override@JsonKey(name: 'page') final int? page; +@override@JsonKey(name: 'limit') final int? limit; +@override@JsonKey(name: 'total_count') final int? totalCount; +@override@JsonKey(name: 'total_pages') final int? totalPages; + +/// Create a copy of WalletPaginationDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletPaginationDtoCopyWith<_WalletPaginationDto> get copyWith => __$WalletPaginationDtoCopyWithImpl<_WalletPaginationDto>(this, _$identity); + +@override +Map toJson() { + return _$WalletPaginationDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletPaginationDto&&(identical(other.page, page) || other.page == page)&&(identical(other.limit, limit) || other.limit == limit)&&(identical(other.totalCount, totalCount) || other.totalCount == totalCount)&&(identical(other.totalPages, totalPages) || other.totalPages == totalPages)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,page,limit,totalCount,totalPages); +} + +@override +String toString() { + return 'WalletPaginationDto(page: $page, limit: $limit, totalCount: $totalCount, totalPages: $totalPages)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletPaginationDtoCopyWith<$Res> implements $WalletPaginationDtoCopyWith<$Res> { + factory _$WalletPaginationDtoCopyWith(_WalletPaginationDto value, $Res Function(_WalletPaginationDto) _then) = __$WalletPaginationDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'page') int? page,@JsonKey(name: 'limit') int? limit,@JsonKey(name: 'total_count') int? totalCount,@JsonKey(name: 'total_pages') int? totalPages +}); + + + + +} +/// @nodoc +class __$WalletPaginationDtoCopyWithImpl<$Res> + implements _$WalletPaginationDtoCopyWith<$Res> { + __$WalletPaginationDtoCopyWithImpl(this._self, this._then); + + final _WalletPaginationDto _self; + final $Res Function(_WalletPaginationDto) _then; + +/// Create a copy of WalletPaginationDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? page = freezed,Object? limit = freezed,Object? totalCount = freezed,Object? totalPages = freezed,}) { + return _then(_WalletPaginationDto( +page: freezed == page ? _self.page : page // ignore: cast_nullable_to_non_nullable +as int?,limit: freezed == limit ? _self.limit : limit // ignore: cast_nullable_to_non_nullable +as int?,totalCount: freezed == totalCount ? _self.totalCount : totalCount // ignore: cast_nullable_to_non_nullable +as int?,totalPages: freezed == totalPages ? _self.totalPages : totalPages // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + + +/// @nodoc +mixin _$WalletExpiringDto { + +@JsonKey(name: 'point') List? get point;@JsonKey(name: 'coin') List? get coin; +/// Create a copy of WalletExpiringDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletExpiringDtoCopyWith get copyWith => _$WalletExpiringDtoCopyWithImpl(this as WalletExpiringDto, _$identity); + + /// Serializes this WalletExpiringDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as WalletExpiringDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletExpiringDto&&const DeepCollectionEquality().equals(other.point, _this.point)&&const DeepCollectionEquality().equals(other.coin, _this.coin)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as WalletExpiringDto; + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_this.point),const DeepCollectionEquality().hash(_this.coin)); +} + +@override +String toString() { + final _this = this as WalletExpiringDto; + return 'WalletExpiringDto(point: ${_this.point}, coin: ${_this.coin})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletExpiringDtoCopyWith<$Res> { + factory $WalletExpiringDtoCopyWith(WalletExpiringDto value, $Res Function(WalletExpiringDto) _then) = _$WalletExpiringDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'point') List? point,@JsonKey(name: 'coin') List? coin +}); + + + + +} +/// @nodoc +class _$WalletExpiringDtoCopyWithImpl<$Res> + implements $WalletExpiringDtoCopyWith<$Res> { + _$WalletExpiringDtoCopyWithImpl(this._self, this._then); + + final WalletExpiringDto _self; + final $Res Function(WalletExpiringDto) _then; + +/// Create a copy of WalletExpiringDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? point = freezed,Object? coin = freezed,}) { + return _then(WalletExpiringDto( +point: freezed == point ? _self.point : point // ignore: cast_nullable_to_non_nullable +as List?,coin: freezed == coin ? _self.coin : coin // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletExpiringDto]. +extension WalletExpiringDtoPatterns on WalletExpiringDto { +/// 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( _WalletExpiringDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletExpiringDto() 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( _WalletExpiringDto value) $default,){ +final _that = this; +switch (_that) { +case _WalletExpiringDto(): +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( _WalletExpiringDto value)? $default,){ +final _that = this; +switch (_that) { +case _WalletExpiringDto() 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(@JsonKey(name: 'point') List? point, @JsonKey(name: 'coin') List? coin)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletExpiringDto() when $default != null: +return $default(_that.point,_that.coin);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(@JsonKey(name: 'point') List? point, @JsonKey(name: 'coin') List? coin) $default,) {final _that = this; +switch (_that) { +case _WalletExpiringDto(): +return $default(_that.point,_that.coin);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(@JsonKey(name: 'point') List? point, @JsonKey(name: 'coin') List? coin)? $default,) {final _that = this; +switch (_that) { +case _WalletExpiringDto() when $default != null: +return $default(_that.point,_that.coin);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _WalletExpiringDto extends WalletExpiringDto { + const _WalletExpiringDto({@JsonKey(name: 'point') List? point, @JsonKey(name: 'coin') List? coin}): _point = point,_coin = coin,super._(); + factory _WalletExpiringDto.fromJson(Map json) => _$WalletExpiringDtoFromJson(json); + + final List? _point; +@override@JsonKey(name: 'point') List? get point { + final value = _point; + if (value == null) return null; + if (_point is EqualUnmodifiableListView) return _point; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + + final List? _coin; +@override@JsonKey(name: 'coin') List? get coin { + final value = _coin; + if (value == null) return null; + if (_coin is EqualUnmodifiableListView) return _coin; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + + +/// Create a copy of WalletExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletExpiringDtoCopyWith<_WalletExpiringDto> get copyWith => __$WalletExpiringDtoCopyWithImpl<_WalletExpiringDto>(this, _$identity); + +@override +Map toJson() { + return _$WalletExpiringDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletExpiringDto&&const DeepCollectionEquality().equals(other.point, _point)&&const DeepCollectionEquality().equals(other.coin, _coin)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,const DeepCollectionEquality().hash(_point),const DeepCollectionEquality().hash(_coin)); +} + +@override +String toString() { + return 'WalletExpiringDto(point: $point, coin: $coin)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletExpiringDtoCopyWith<$Res> implements $WalletExpiringDtoCopyWith<$Res> { + factory _$WalletExpiringDtoCopyWith(_WalletExpiringDto value, $Res Function(_WalletExpiringDto) _then) = __$WalletExpiringDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'point') List? point,@JsonKey(name: 'coin') List? coin +}); + + + + +} +/// @nodoc +class __$WalletExpiringDtoCopyWithImpl<$Res> + implements _$WalletExpiringDtoCopyWith<$Res> { + __$WalletExpiringDtoCopyWithImpl(this._self, this._then); + + final _WalletExpiringDto _self; + final $Res Function(_WalletExpiringDto) _then; + +/// Create a copy of WalletExpiringDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? point = freezed,Object? coin = freezed,}) { + return _then(_WalletExpiringDto( +point: freezed == point ? _self._point : point // ignore: cast_nullable_to_non_nullable +as List?,coin: freezed == coin ? _self._coin : coin // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + + +} + + +/// @nodoc +mixin _$PaymentCodeDto { + +@JsonKey(name: 'code') String? get code;@JsonKey(name: 'qr_payload') String? get qrPayload;@JsonKey(name: 'expires_at') String? get expiresAt; +/// Create a copy of PaymentCodeDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PaymentCodeDtoCopyWith get copyWith => _$PaymentCodeDtoCopyWithImpl(this as PaymentCodeDto, _$identity); + + /// Serializes this PaymentCodeDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as PaymentCodeDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PaymentCodeDto&&(identical(other.code, _this.code) || other.code == _this.code)&&(identical(other.qrPayload, _this.qrPayload) || other.qrPayload == _this.qrPayload)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as PaymentCodeDto; + return Object.hash(runtimeType,_this.code,_this.qrPayload,_this.expiresAt); +} + +@override +String toString() { + final _this = this as PaymentCodeDto; + return 'PaymentCodeDto(code: ${_this.code}, qrPayload: ${_this.qrPayload}, expiresAt: ${_this.expiresAt})'; +} + + +} + +/// @nodoc +abstract mixin class $PaymentCodeDtoCopyWith<$Res> { + factory $PaymentCodeDtoCopyWith(PaymentCodeDto value, $Res Function(PaymentCodeDto) _then) = _$PaymentCodeDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'code') String? code,@JsonKey(name: 'qr_payload') String? qrPayload,@JsonKey(name: 'expires_at') String? expiresAt +}); + + + + +} +/// @nodoc +class _$PaymentCodeDtoCopyWithImpl<$Res> + implements $PaymentCodeDtoCopyWith<$Res> { + _$PaymentCodeDtoCopyWithImpl(this._self, this._then); + + final PaymentCodeDto _self; + final $Res Function(PaymentCodeDto) _then; + +/// Create a copy of PaymentCodeDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? code = freezed,Object? qrPayload = freezed,Object? expiresAt = freezed,}) { + return _then(PaymentCodeDto( +code: freezed == code ? _self.code : code // ignore: cast_nullable_to_non_nullable +as String?,qrPayload: freezed == qrPayload ? _self.qrPayload : qrPayload // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PaymentCodeDto]. +extension PaymentCodeDtoPatterns on PaymentCodeDto { +/// 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( _PaymentCodeDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PaymentCodeDto() 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( _PaymentCodeDto value) $default,){ +final _that = this; +switch (_that) { +case _PaymentCodeDto(): +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( _PaymentCodeDto value)? $default,){ +final _that = this; +switch (_that) { +case _PaymentCodeDto() 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(@JsonKey(name: 'code') String? code, @JsonKey(name: 'qr_payload') String? qrPayload, @JsonKey(name: 'expires_at') String? expiresAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PaymentCodeDto() when $default != null: +return $default(_that.code,_that.qrPayload,_that.expiresAt);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(@JsonKey(name: 'code') String? code, @JsonKey(name: 'qr_payload') String? qrPayload, @JsonKey(name: 'expires_at') String? expiresAt) $default,) {final _that = this; +switch (_that) { +case _PaymentCodeDto(): +return $default(_that.code,_that.qrPayload,_that.expiresAt);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(@JsonKey(name: 'code') String? code, @JsonKey(name: 'qr_payload') String? qrPayload, @JsonKey(name: 'expires_at') String? expiresAt)? $default,) {final _that = this; +switch (_that) { +case _PaymentCodeDto() when $default != null: +return $default(_that.code,_that.qrPayload,_that.expiresAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _PaymentCodeDto extends PaymentCodeDto { + const _PaymentCodeDto({@JsonKey(name: 'code') this.code, @JsonKey(name: 'qr_payload') this.qrPayload, @JsonKey(name: 'expires_at') this.expiresAt}): super._(); + factory _PaymentCodeDto.fromJson(Map json) => _$PaymentCodeDtoFromJson(json); + +@override@JsonKey(name: 'code') final String? code; +@override@JsonKey(name: 'qr_payload') final String? qrPayload; +@override@JsonKey(name: 'expires_at') final String? expiresAt; + +/// Create a copy of PaymentCodeDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PaymentCodeDtoCopyWith<_PaymentCodeDto> get copyWith => __$PaymentCodeDtoCopyWithImpl<_PaymentCodeDto>(this, _$identity); + +@override +Map toJson() { + return _$PaymentCodeDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PaymentCodeDto&&(identical(other.code, code) || other.code == code)&&(identical(other.qrPayload, qrPayload) || other.qrPayload == qrPayload)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,code,qrPayload,expiresAt); +} + +@override +String toString() { + return 'PaymentCodeDto(code: $code, qrPayload: $qrPayload, expiresAt: $expiresAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$PaymentCodeDtoCopyWith<$Res> implements $PaymentCodeDtoCopyWith<$Res> { + factory _$PaymentCodeDtoCopyWith(_PaymentCodeDto value, $Res Function(_PaymentCodeDto) _then) = __$PaymentCodeDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'code') String? code,@JsonKey(name: 'qr_payload') String? qrPayload,@JsonKey(name: 'expires_at') String? expiresAt +}); + + + + +} +/// @nodoc +class __$PaymentCodeDtoCopyWithImpl<$Res> + implements _$PaymentCodeDtoCopyWith<$Res> { + __$PaymentCodeDtoCopyWithImpl(this._self, this._then); + + final _PaymentCodeDto _self; + final $Res Function(_PaymentCodeDto) _then; + +/// Create a copy of PaymentCodeDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? code = freezed,Object? qrPayload = freezed,Object? expiresAt = freezed,}) { + return _then(_PaymentCodeDto( +code: freezed == code ? _self.code : code // ignore: cast_nullable_to_non_nullable +as String?,qrPayload: freezed == qrPayload ? _self.qrPayload : qrPayload // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$ExchangePreviewDto { + +@JsonKey(name: 'coin_amount') int? get coinAmount;@JsonKey(name: 'point_amount') int? get pointAmount;@JsonKey(name: 'coin_balance') int? get coinBalance;@JsonKey(name: 'coins') int? get coins;@JsonKey(name: 'points') int? get points;@JsonKey(name: 'valid') bool? get valid;@JsonKey(name: 'reason') String? get reason; +/// Create a copy of ExchangePreviewDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExchangePreviewDtoCopyWith get copyWith => _$ExchangePreviewDtoCopyWithImpl(this as ExchangePreviewDto, _$identity); + + /// Serializes this ExchangePreviewDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as ExchangePreviewDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExchangePreviewDto&&(identical(other.coinAmount, _this.coinAmount) || other.coinAmount == _this.coinAmount)&&(identical(other.pointAmount, _this.pointAmount) || other.pointAmount == _this.pointAmount)&&(identical(other.coinBalance, _this.coinBalance) || other.coinBalance == _this.coinBalance)&&(identical(other.coins, _this.coins) || other.coins == _this.coins)&&(identical(other.points, _this.points) || other.points == _this.points)&&(identical(other.valid, _this.valid) || other.valid == _this.valid)&&(identical(other.reason, _this.reason) || other.reason == _this.reason)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as ExchangePreviewDto; + return Object.hash(runtimeType,_this.coinAmount,_this.pointAmount,_this.coinBalance,_this.coins,_this.points,_this.valid,_this.reason); +} + +@override +String toString() { + final _this = this as ExchangePreviewDto; + return 'ExchangePreviewDto(coinAmount: ${_this.coinAmount}, pointAmount: ${_this.pointAmount}, coinBalance: ${_this.coinBalance}, coins: ${_this.coins}, points: ${_this.points}, valid: ${_this.valid}, reason: ${_this.reason})'; +} + + +} + +/// @nodoc +abstract mixin class $ExchangePreviewDtoCopyWith<$Res> { + factory $ExchangePreviewDtoCopyWith(ExchangePreviewDto value, $Res Function(ExchangePreviewDto) _then) = _$ExchangePreviewDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'coin_amount') int? coinAmount,@JsonKey(name: 'point_amount') int? pointAmount,@JsonKey(name: 'coin_balance') int? coinBalance,@JsonKey(name: 'coins') int? coins,@JsonKey(name: 'points') int? points,@JsonKey(name: 'valid') bool? valid,@JsonKey(name: 'reason') String? reason +}); + + + + +} +/// @nodoc +class _$ExchangePreviewDtoCopyWithImpl<$Res> + implements $ExchangePreviewDtoCopyWith<$Res> { + _$ExchangePreviewDtoCopyWithImpl(this._self, this._then); + + final ExchangePreviewDto _self; + final $Res Function(ExchangePreviewDto) _then; + +/// Create a copy of ExchangePreviewDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? coinAmount = freezed,Object? pointAmount = freezed,Object? coinBalance = freezed,Object? coins = freezed,Object? points = freezed,Object? valid = freezed,Object? reason = freezed,}) { + return _then(ExchangePreviewDto( +coinAmount: freezed == coinAmount ? _self.coinAmount : coinAmount // ignore: cast_nullable_to_non_nullable +as int?,pointAmount: freezed == pointAmount ? _self.pointAmount : pointAmount // ignore: cast_nullable_to_non_nullable +as int?,coinBalance: freezed == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int?,coins: freezed == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int?,points: freezed == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int?,valid: freezed == valid ? _self.valid : valid // ignore: cast_nullable_to_non_nullable +as bool?,reason: freezed == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ExchangePreviewDto]. +extension ExchangePreviewDtoPatterns on ExchangePreviewDto { +/// 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( _ExchangePreviewDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExchangePreviewDto() 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( _ExchangePreviewDto value) $default,){ +final _that = this; +switch (_that) { +case _ExchangePreviewDto(): +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( _ExchangePreviewDto value)? $default,){ +final _that = this; +switch (_that) { +case _ExchangePreviewDto() 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(@JsonKey(name: 'coin_amount') int? coinAmount, @JsonKey(name: 'point_amount') int? pointAmount, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'valid') bool? valid, @JsonKey(name: 'reason') String? reason)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExchangePreviewDto() when $default != null: +return $default(_that.coinAmount,_that.pointAmount,_that.coinBalance,_that.coins,_that.points,_that.valid,_that.reason);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(@JsonKey(name: 'coin_amount') int? coinAmount, @JsonKey(name: 'point_amount') int? pointAmount, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'valid') bool? valid, @JsonKey(name: 'reason') String? reason) $default,) {final _that = this; +switch (_that) { +case _ExchangePreviewDto(): +return $default(_that.coinAmount,_that.pointAmount,_that.coinBalance,_that.coins,_that.points,_that.valid,_that.reason);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(@JsonKey(name: 'coin_amount') int? coinAmount, @JsonKey(name: 'point_amount') int? pointAmount, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'valid') bool? valid, @JsonKey(name: 'reason') String? reason)? $default,) {final _that = this; +switch (_that) { +case _ExchangePreviewDto() when $default != null: +return $default(_that.coinAmount,_that.pointAmount,_that.coinBalance,_that.coins,_that.points,_that.valid,_that.reason);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _ExchangePreviewDto extends ExchangePreviewDto { + const _ExchangePreviewDto({@JsonKey(name: 'coin_amount') this.coinAmount, @JsonKey(name: 'point_amount') this.pointAmount, @JsonKey(name: 'coin_balance') this.coinBalance, @JsonKey(name: 'coins') this.coins, @JsonKey(name: 'points') this.points, @JsonKey(name: 'valid') this.valid, @JsonKey(name: 'reason') this.reason}): super._(); + factory _ExchangePreviewDto.fromJson(Map json) => _$ExchangePreviewDtoFromJson(json); + +@override@JsonKey(name: 'coin_amount') final int? coinAmount; +@override@JsonKey(name: 'point_amount') final int? pointAmount; +@override@JsonKey(name: 'coin_balance') final int? coinBalance; +@override@JsonKey(name: 'coins') final int? coins; +@override@JsonKey(name: 'points') final int? points; +@override@JsonKey(name: 'valid') final bool? valid; +@override@JsonKey(name: 'reason') final String? reason; + +/// Create a copy of ExchangePreviewDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExchangePreviewDtoCopyWith<_ExchangePreviewDto> get copyWith => __$ExchangePreviewDtoCopyWithImpl<_ExchangePreviewDto>(this, _$identity); + +@override +Map toJson() { + return _$ExchangePreviewDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExchangePreviewDto&&(identical(other.coinAmount, coinAmount) || other.coinAmount == coinAmount)&&(identical(other.pointAmount, pointAmount) || other.pointAmount == pointAmount)&&(identical(other.coinBalance, coinBalance) || other.coinBalance == coinBalance)&&(identical(other.coins, coins) || other.coins == coins)&&(identical(other.points, points) || other.points == points)&&(identical(other.valid, valid) || other.valid == valid)&&(identical(other.reason, reason) || other.reason == reason)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,coinAmount,pointAmount,coinBalance,coins,points,valid,reason); +} + +@override +String toString() { + return 'ExchangePreviewDto(coinAmount: $coinAmount, pointAmount: $pointAmount, coinBalance: $coinBalance, coins: $coins, points: $points, valid: $valid, reason: $reason)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExchangePreviewDtoCopyWith<$Res> implements $ExchangePreviewDtoCopyWith<$Res> { + factory _$ExchangePreviewDtoCopyWith(_ExchangePreviewDto value, $Res Function(_ExchangePreviewDto) _then) = __$ExchangePreviewDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'coin_amount') int? coinAmount,@JsonKey(name: 'point_amount') int? pointAmount,@JsonKey(name: 'coin_balance') int? coinBalance,@JsonKey(name: 'coins') int? coins,@JsonKey(name: 'points') int? points,@JsonKey(name: 'valid') bool? valid,@JsonKey(name: 'reason') String? reason +}); + + + + +} +/// @nodoc +class __$ExchangePreviewDtoCopyWithImpl<$Res> + implements _$ExchangePreviewDtoCopyWith<$Res> { + __$ExchangePreviewDtoCopyWithImpl(this._self, this._then); + + final _ExchangePreviewDto _self; + final $Res Function(_ExchangePreviewDto) _then; + +/// Create a copy of ExchangePreviewDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? coinAmount = freezed,Object? pointAmount = freezed,Object? coinBalance = freezed,Object? coins = freezed,Object? points = freezed,Object? valid = freezed,Object? reason = freezed,}) { + return _then(_ExchangePreviewDto( +coinAmount: freezed == coinAmount ? _self.coinAmount : coinAmount // ignore: cast_nullable_to_non_nullable +as int?,pointAmount: freezed == pointAmount ? _self.pointAmount : pointAmount // ignore: cast_nullable_to_non_nullable +as int?,coinBalance: freezed == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int?,coins: freezed == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int?,points: freezed == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int?,valid: freezed == valid ? _self.valid : valid // ignore: cast_nullable_to_non_nullable +as bool?,reason: freezed == reason ? _self.reason : reason // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$ExchangeResultDto { + +@JsonKey(name: 'coins') int? get coins;@JsonKey(name: 'points') int? get points;@JsonKey(name: 'coin_balance') int? get coinBalance;@JsonKey(name: 'point_balance') int? get pointBalance;@JsonKey(name: 'lots') List? get lots;@JsonKey(name: 'replayed') bool? get replayed; +/// Create a copy of ExchangeResultDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$ExchangeResultDtoCopyWith get copyWith => _$ExchangeResultDtoCopyWithImpl(this as ExchangeResultDto, _$identity); + + /// Serializes this ExchangeResultDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as ExchangeResultDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is ExchangeResultDto&&(identical(other.coins, _this.coins) || other.coins == _this.coins)&&(identical(other.points, _this.points) || other.points == _this.points)&&(identical(other.coinBalance, _this.coinBalance) || other.coinBalance == _this.coinBalance)&&(identical(other.pointBalance, _this.pointBalance) || other.pointBalance == _this.pointBalance)&&const DeepCollectionEquality().equals(other.lots, _this.lots)&&(identical(other.replayed, _this.replayed) || other.replayed == _this.replayed)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as ExchangeResultDto; + return Object.hash(runtimeType,_this.coins,_this.points,_this.coinBalance,_this.pointBalance,const DeepCollectionEquality().hash(_this.lots),_this.replayed); +} + +@override +String toString() { + final _this = this as ExchangeResultDto; + return 'ExchangeResultDto(coins: ${_this.coins}, points: ${_this.points}, coinBalance: ${_this.coinBalance}, pointBalance: ${_this.pointBalance}, lots: ${_this.lots}, replayed: ${_this.replayed})'; +} + + +} + +/// @nodoc +abstract mixin class $ExchangeResultDtoCopyWith<$Res> { + factory $ExchangeResultDtoCopyWith(ExchangeResultDto value, $Res Function(ExchangeResultDto) _then) = _$ExchangeResultDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'coins') int? coins,@JsonKey(name: 'points') int? points,@JsonKey(name: 'coin_balance') int? coinBalance,@JsonKey(name: 'point_balance') int? pointBalance,@JsonKey(name: 'lots') List? lots,@JsonKey(name: 'replayed') bool? replayed +}); + + + + +} +/// @nodoc +class _$ExchangeResultDtoCopyWithImpl<$Res> + implements $ExchangeResultDtoCopyWith<$Res> { + _$ExchangeResultDtoCopyWithImpl(this._self, this._then); + + final ExchangeResultDto _self; + final $Res Function(ExchangeResultDto) _then; + +/// Create a copy of ExchangeResultDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? coins = freezed,Object? points = freezed,Object? coinBalance = freezed,Object? pointBalance = freezed,Object? lots = freezed,Object? replayed = freezed,}) { + return _then(ExchangeResultDto( +coins: freezed == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int?,points: freezed == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int?,coinBalance: freezed == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int?,pointBalance: freezed == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int?,lots: freezed == lots ? _self.lots : lots // ignore: cast_nullable_to_non_nullable +as List?,replayed: freezed == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [ExchangeResultDto]. +extension ExchangeResultDtoPatterns on ExchangeResultDto { +/// 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( _ExchangeResultDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _ExchangeResultDto() 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( _ExchangeResultDto value) $default,){ +final _that = this; +switch (_that) { +case _ExchangeResultDto(): +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( _ExchangeResultDto value)? $default,){ +final _that = this; +switch (_that) { +case _ExchangeResultDto() 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(@JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'point_balance') int? pointBalance, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'replayed') bool? replayed)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _ExchangeResultDto() when $default != null: +return $default(_that.coins,_that.points,_that.coinBalance,_that.pointBalance,_that.lots,_that.replayed);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(@JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'point_balance') int? pointBalance, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'replayed') bool? replayed) $default,) {final _that = this; +switch (_that) { +case _ExchangeResultDto(): +return $default(_that.coins,_that.points,_that.coinBalance,_that.pointBalance,_that.lots,_that.replayed);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(@JsonKey(name: 'coins') int? coins, @JsonKey(name: 'points') int? points, @JsonKey(name: 'coin_balance') int? coinBalance, @JsonKey(name: 'point_balance') int? pointBalance, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'replayed') bool? replayed)? $default,) {final _that = this; +switch (_that) { +case _ExchangeResultDto() when $default != null: +return $default(_that.coins,_that.points,_that.coinBalance,_that.pointBalance,_that.lots,_that.replayed);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _ExchangeResultDto extends ExchangeResultDto { + const _ExchangeResultDto({@JsonKey(name: 'coins') this.coins, @JsonKey(name: 'points') this.points, @JsonKey(name: 'coin_balance') this.coinBalance, @JsonKey(name: 'point_balance') this.pointBalance, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'replayed') this.replayed}): _lots = lots,super._(); + factory _ExchangeResultDto.fromJson(Map json) => _$ExchangeResultDtoFromJson(json); + +@override@JsonKey(name: 'coins') final int? coins; +@override@JsonKey(name: 'points') final int? points; +@override@JsonKey(name: 'coin_balance') final int? coinBalance; +@override@JsonKey(name: 'point_balance') final int? pointBalance; + final List? _lots; +@override@JsonKey(name: 'lots') List? get lots { + final value = _lots; + if (value == null) return null; + if (_lots is EqualUnmodifiableListView) return _lots; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + +@override@JsonKey(name: 'replayed') final bool? replayed; + +/// Create a copy of ExchangeResultDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$ExchangeResultDtoCopyWith<_ExchangeResultDto> get copyWith => __$ExchangeResultDtoCopyWithImpl<_ExchangeResultDto>(this, _$identity); + +@override +Map toJson() { + return _$ExchangeResultDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _ExchangeResultDto&&(identical(other.coins, coins) || other.coins == coins)&&(identical(other.points, points) || other.points == points)&&(identical(other.coinBalance, coinBalance) || other.coinBalance == coinBalance)&&(identical(other.pointBalance, pointBalance) || other.pointBalance == pointBalance)&&const DeepCollectionEquality().equals(other.lots, _lots)&&(identical(other.replayed, replayed) || other.replayed == replayed)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,coins,points,coinBalance,pointBalance,const DeepCollectionEquality().hash(_lots),replayed); +} + +@override +String toString() { + return 'ExchangeResultDto(coins: $coins, points: $points, coinBalance: $coinBalance, pointBalance: $pointBalance, lots: $lots, replayed: $replayed)'; +} + + +} + +/// @nodoc +abstract mixin class _$ExchangeResultDtoCopyWith<$Res> implements $ExchangeResultDtoCopyWith<$Res> { + factory _$ExchangeResultDtoCopyWith(_ExchangeResultDto value, $Res Function(_ExchangeResultDto) _then) = __$ExchangeResultDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'coins') int? coins,@JsonKey(name: 'points') int? points,@JsonKey(name: 'coin_balance') int? coinBalance,@JsonKey(name: 'point_balance') int? pointBalance,@JsonKey(name: 'lots') List? lots,@JsonKey(name: 'replayed') bool? replayed +}); + + + + +} +/// @nodoc +class __$ExchangeResultDtoCopyWithImpl<$Res> + implements _$ExchangeResultDtoCopyWith<$Res> { + __$ExchangeResultDtoCopyWithImpl(this._self, this._then); + + final _ExchangeResultDto _self; + final $Res Function(_ExchangeResultDto) _then; + +/// Create a copy of ExchangeResultDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? coins = freezed,Object? points = freezed,Object? coinBalance = freezed,Object? pointBalance = freezed,Object? lots = freezed,Object? replayed = freezed,}) { + return _then(_ExchangeResultDto( +coins: freezed == coins ? _self.coins : coins // ignore: cast_nullable_to_non_nullable +as int?,points: freezed == points ? _self.points : points // ignore: cast_nullable_to_non_nullable +as int?,coinBalance: freezed == coinBalance ? _self.coinBalance : coinBalance // ignore: cast_nullable_to_non_nullable +as int?,pointBalance: freezed == pointBalance ? _self.pointBalance : pointBalance // ignore: cast_nullable_to_non_nullable +as int?,lots: freezed == lots ? _self._lots : lots // ignore: cast_nullable_to_non_nullable +as List?,replayed: freezed == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + + +} + + +/// @nodoc +mixin _$WalletLotDto { + +@JsonKey(name: 'amount') int? get amount;@JsonKey(name: 'expires_at') String? get expiresAt; +/// Create a copy of WalletLotDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletLotDtoCopyWith get copyWith => _$WalletLotDtoCopyWithImpl(this as WalletLotDto, _$identity); + + /// Serializes this WalletLotDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as WalletLotDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is WalletLotDto&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as WalletLotDto; + return Object.hash(runtimeType,_this.amount,_this.expiresAt); +} + +@override +String toString() { + final _this = this as WalletLotDto; + return 'WalletLotDto(amount: ${_this.amount}, expiresAt: ${_this.expiresAt})'; +} + + +} + +/// @nodoc +abstract mixin class $WalletLotDtoCopyWith<$Res> { + factory $WalletLotDtoCopyWith(WalletLotDto value, $Res Function(WalletLotDto) _then) = _$WalletLotDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'expires_at') String? expiresAt +}); + + + + +} +/// @nodoc +class _$WalletLotDtoCopyWithImpl<$Res> + implements $WalletLotDtoCopyWith<$Res> { + _$WalletLotDtoCopyWithImpl(this._self, this._then); + + final WalletLotDto _self; + final $Res Function(WalletLotDto) _then; + +/// Create a copy of WalletLotDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? amount = freezed,Object? expiresAt = freezed,}) { + return _then(WalletLotDto( +amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [WalletLotDto]. +extension WalletLotDtoPatterns on WalletLotDto { +/// 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( _WalletLotDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _WalletLotDto() 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( _WalletLotDto value) $default,){ +final _that = this; +switch (_that) { +case _WalletLotDto(): +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( _WalletLotDto value)? $default,){ +final _that = this; +switch (_that) { +case _WalletLotDto() 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(@JsonKey(name: 'amount') int? amount, @JsonKey(name: 'expires_at') String? expiresAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _WalletLotDto() when $default != null: +return $default(_that.amount,_that.expiresAt);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(@JsonKey(name: 'amount') int? amount, @JsonKey(name: 'expires_at') String? expiresAt) $default,) {final _that = this; +switch (_that) { +case _WalletLotDto(): +return $default(_that.amount,_that.expiresAt);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(@JsonKey(name: 'amount') int? amount, @JsonKey(name: 'expires_at') String? expiresAt)? $default,) {final _that = this; +switch (_that) { +case _WalletLotDto() when $default != null: +return $default(_that.amount,_that.expiresAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _WalletLotDto extends WalletLotDto { + const _WalletLotDto({@JsonKey(name: 'amount') this.amount, @JsonKey(name: 'expires_at') this.expiresAt}): super._(); + factory _WalletLotDto.fromJson(Map json) => _$WalletLotDtoFromJson(json); + +@override@JsonKey(name: 'amount') final int? amount; +@override@JsonKey(name: 'expires_at') final String? expiresAt; + +/// Create a copy of WalletLotDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletLotDtoCopyWith<_WalletLotDto> get copyWith => __$WalletLotDtoCopyWithImpl<_WalletLotDto>(this, _$identity); + +@override +Map toJson() { + return _$WalletLotDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _WalletLotDto&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,amount,expiresAt); +} + +@override +String toString() { + return 'WalletLotDto(amount: $amount, expiresAt: $expiresAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletLotDtoCopyWith<$Res> implements $WalletLotDtoCopyWith<$Res> { + factory _$WalletLotDtoCopyWith(_WalletLotDto value, $Res Function(_WalletLotDto) _then) = __$WalletLotDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'expires_at') String? expiresAt +}); + + + + +} +/// @nodoc +class __$WalletLotDtoCopyWithImpl<$Res> + implements _$WalletLotDtoCopyWith<$Res> { + __$WalletLotDtoCopyWithImpl(this._self, this._then); + + final _WalletLotDto _self; + final $Res Function(_WalletLotDto) _then; + +/// Create a copy of WalletLotDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? amount = freezed,Object? expiresAt = freezed,}) { + return _then(_WalletLotDto( +amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$TransferRecipientDto { + +@JsonKey(name: 'name') String? get name;@JsonKey(name: 'phone_number') String? get phoneNumber; +/// Create a copy of TransferRecipientDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TransferRecipientDtoCopyWith get copyWith => _$TransferRecipientDtoCopyWithImpl(this as TransferRecipientDto, _$identity); + + /// Serializes this TransferRecipientDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as TransferRecipientDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is TransferRecipientDto&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.phoneNumber, _this.phoneNumber) || other.phoneNumber == _this.phoneNumber)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as TransferRecipientDto; + return Object.hash(runtimeType,_this.name,_this.phoneNumber); +} + +@override +String toString() { + final _this = this as TransferRecipientDto; + return 'TransferRecipientDto(name: ${_this.name}, phoneNumber: ${_this.phoneNumber})'; +} + + +} + +/// @nodoc +abstract mixin class $TransferRecipientDtoCopyWith<$Res> { + factory $TransferRecipientDtoCopyWith(TransferRecipientDto value, $Res Function(TransferRecipientDto) _then) = _$TransferRecipientDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'name') String? name,@JsonKey(name: 'phone_number') String? phoneNumber +}); + + + + +} +/// @nodoc +class _$TransferRecipientDtoCopyWithImpl<$Res> + implements $TransferRecipientDtoCopyWith<$Res> { + _$TransferRecipientDtoCopyWithImpl(this._self, this._then); + + final TransferRecipientDto _self; + final $Res Function(TransferRecipientDto) _then; + +/// Create a copy of TransferRecipientDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,Object? phoneNumber = freezed,}) { + return _then(TransferRecipientDto( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,phoneNumber: freezed == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [TransferRecipientDto]. +extension TransferRecipientDtoPatterns on TransferRecipientDto { +/// 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( _TransferRecipientDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _TransferRecipientDto() 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( _TransferRecipientDto value) $default,){ +final _that = this; +switch (_that) { +case _TransferRecipientDto(): +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( _TransferRecipientDto value)? $default,){ +final _that = this; +switch (_that) { +case _TransferRecipientDto() 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(@JsonKey(name: 'name') String? name, @JsonKey(name: 'phone_number') String? phoneNumber)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _TransferRecipientDto() when $default != null: +return $default(_that.name,_that.phoneNumber);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(@JsonKey(name: 'name') String? name, @JsonKey(name: 'phone_number') String? phoneNumber) $default,) {final _that = this; +switch (_that) { +case _TransferRecipientDto(): +return $default(_that.name,_that.phoneNumber);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(@JsonKey(name: 'name') String? name, @JsonKey(name: 'phone_number') String? phoneNumber)? $default,) {final _that = this; +switch (_that) { +case _TransferRecipientDto() when $default != null: +return $default(_that.name,_that.phoneNumber);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _TransferRecipientDto extends TransferRecipientDto { + const _TransferRecipientDto({@JsonKey(name: 'name') this.name, @JsonKey(name: 'phone_number') this.phoneNumber}): super._(); + factory _TransferRecipientDto.fromJson(Map json) => _$TransferRecipientDtoFromJson(json); + +@override@JsonKey(name: 'name') final String? name; +@override@JsonKey(name: 'phone_number') final String? phoneNumber; + +/// Create a copy of TransferRecipientDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TransferRecipientDtoCopyWith<_TransferRecipientDto> get copyWith => __$TransferRecipientDtoCopyWithImpl<_TransferRecipientDto>(this, _$identity); + +@override +Map toJson() { + return _$TransferRecipientDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TransferRecipientDto&&(identical(other.name, name) || other.name == name)&&(identical(other.phoneNumber, phoneNumber) || other.phoneNumber == phoneNumber)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,name,phoneNumber); +} + +@override +String toString() { + return 'TransferRecipientDto(name: $name, phoneNumber: $phoneNumber)'; +} + + +} + +/// @nodoc +abstract mixin class _$TransferRecipientDtoCopyWith<$Res> implements $TransferRecipientDtoCopyWith<$Res> { + factory _$TransferRecipientDtoCopyWith(_TransferRecipientDto value, $Res Function(_TransferRecipientDto) _then) = __$TransferRecipientDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'name') String? name,@JsonKey(name: 'phone_number') String? phoneNumber +}); + + + + +} +/// @nodoc +class __$TransferRecipientDtoCopyWithImpl<$Res> + implements _$TransferRecipientDtoCopyWith<$Res> { + __$TransferRecipientDtoCopyWithImpl(this._self, this._then); + + final _TransferRecipientDto _self; + final $Res Function(_TransferRecipientDto) _then; + +/// Create a copy of TransferRecipientDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? phoneNumber = freezed,}) { + return _then(_TransferRecipientDto( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,phoneNumber: freezed == phoneNumber ? _self.phoneNumber : phoneNumber // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$TransferResultDto { + +@JsonKey(name: 'currency') String? get currency;@JsonKey(name: 'amount') int? get amount;@JsonKey(name: 'recipient') TransferRecipientDto? get recipient;@JsonKey(name: 'lots') List? get lots;@JsonKey(name: 'balance') int? get balance;@JsonKey(name: 'replayed') bool? get replayed; +/// Create a copy of TransferResultDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TransferResultDtoCopyWith get copyWith => _$TransferResultDtoCopyWithImpl(this as TransferResultDto, _$identity); + + /// Serializes this TransferResultDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as TransferResultDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is TransferResultDto&&(identical(other.currency, _this.currency) || other.currency == _this.currency)&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.recipient, _this.recipient) || other.recipient == _this.recipient)&&const DeepCollectionEquality().equals(other.lots, _this.lots)&&(identical(other.balance, _this.balance) || other.balance == _this.balance)&&(identical(other.replayed, _this.replayed) || other.replayed == _this.replayed)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as TransferResultDto; + return Object.hash(runtimeType,_this.currency,_this.amount,_this.recipient,const DeepCollectionEquality().hash(_this.lots),_this.balance,_this.replayed); +} + +@override +String toString() { + final _this = this as TransferResultDto; + return 'TransferResultDto(currency: ${_this.currency}, amount: ${_this.amount}, recipient: ${_this.recipient}, lots: ${_this.lots}, balance: ${_this.balance}, replayed: ${_this.replayed})'; +} + + +} + +/// @nodoc +abstract mixin class $TransferResultDtoCopyWith<$Res> { + factory $TransferResultDtoCopyWith(TransferResultDto value, $Res Function(TransferResultDto) _then) = _$TransferResultDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'currency') String? currency,@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'recipient') TransferRecipientDto? recipient,@JsonKey(name: 'lots') List? lots,@JsonKey(name: 'balance') int? balance,@JsonKey(name: 'replayed') bool? replayed +}); + + +$TransferRecipientDtoCopyWith<$Res>? get recipient; + +} +/// @nodoc +class _$TransferResultDtoCopyWithImpl<$Res> + implements $TransferResultDtoCopyWith<$Res> { + _$TransferResultDtoCopyWithImpl(this._self, this._then); + + final TransferResultDto _self; + final $Res Function(TransferResultDto) _then; + +/// Create a copy of TransferResultDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? currency = freezed,Object? amount = freezed,Object? recipient = freezed,Object? lots = freezed,Object? balance = freezed,Object? replayed = freezed,}) { + return _then(TransferResultDto( +currency: freezed == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as TransferRecipientDto?,lots: freezed == lots ? _self.lots : lots // ignore: cast_nullable_to_non_nullable +as List?,balance: freezed == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as int?,replayed: freezed == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} +/// Create a copy of TransferResultDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferRecipientDtoCopyWith<$Res>? get recipient { + if (_self.recipient == null) { + return null; + } + + return $TransferRecipientDtoCopyWith<$Res>(_self.recipient!, (value) { + return _then(_self.copyWith(recipient: value)); + }); +} +} + + +/// Adds pattern-matching-related methods to [TransferResultDto]. +extension TransferResultDtoPatterns on TransferResultDto { +/// 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( _TransferResultDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _TransferResultDto() 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( _TransferResultDto value) $default,){ +final _that = this; +switch (_that) { +case _TransferResultDto(): +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( _TransferResultDto value)? $default,){ +final _that = this; +switch (_that) { +case _TransferResultDto() 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(@JsonKey(name: 'currency') String? currency, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'recipient') TransferRecipientDto? recipient, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'balance') int? balance, @JsonKey(name: 'replayed') bool? replayed)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _TransferResultDto() when $default != null: +return $default(_that.currency,_that.amount,_that.recipient,_that.lots,_that.balance,_that.replayed);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(@JsonKey(name: 'currency') String? currency, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'recipient') TransferRecipientDto? recipient, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'balance') int? balance, @JsonKey(name: 'replayed') bool? replayed) $default,) {final _that = this; +switch (_that) { +case _TransferResultDto(): +return $default(_that.currency,_that.amount,_that.recipient,_that.lots,_that.balance,_that.replayed);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(@JsonKey(name: 'currency') String? currency, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'recipient') TransferRecipientDto? recipient, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'balance') int? balance, @JsonKey(name: 'replayed') bool? replayed)? $default,) {final _that = this; +switch (_that) { +case _TransferResultDto() when $default != null: +return $default(_that.currency,_that.amount,_that.recipient,_that.lots,_that.balance,_that.replayed);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _TransferResultDto extends TransferResultDto { + const _TransferResultDto({@JsonKey(name: 'currency') this.currency, @JsonKey(name: 'amount') this.amount, @JsonKey(name: 'recipient') this.recipient, @JsonKey(name: 'lots') List? lots, @JsonKey(name: 'balance') this.balance, @JsonKey(name: 'replayed') this.replayed}): _lots = lots,super._(); + factory _TransferResultDto.fromJson(Map json) => _$TransferResultDtoFromJson(json); + +@override@JsonKey(name: 'currency') final String? currency; +@override@JsonKey(name: 'amount') final int? amount; +@override@JsonKey(name: 'recipient') final TransferRecipientDto? recipient; + final List? _lots; +@override@JsonKey(name: 'lots') List? get lots { + final value = _lots; + if (value == null) return null; + if (_lots is EqualUnmodifiableListView) return _lots; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + +@override@JsonKey(name: 'balance') final int? balance; +@override@JsonKey(name: 'replayed') final bool? replayed; + +/// Create a copy of TransferResultDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TransferResultDtoCopyWith<_TransferResultDto> get copyWith => __$TransferResultDtoCopyWithImpl<_TransferResultDto>(this, _$identity); + +@override +Map toJson() { + return _$TransferResultDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _TransferResultDto&&(identical(other.currency, currency) || other.currency == currency)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.recipient, recipient) || other.recipient == recipient)&&const DeepCollectionEquality().equals(other.lots, _lots)&&(identical(other.balance, balance) || other.balance == balance)&&(identical(other.replayed, replayed) || other.replayed == replayed)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,currency,amount,recipient,const DeepCollectionEquality().hash(_lots),balance,replayed); +} + +@override +String toString() { + return 'TransferResultDto(currency: $currency, amount: $amount, recipient: $recipient, lots: $lots, balance: $balance, replayed: $replayed)'; +} + + +} + +/// @nodoc +abstract mixin class _$TransferResultDtoCopyWith<$Res> implements $TransferResultDtoCopyWith<$Res> { + factory _$TransferResultDtoCopyWith(_TransferResultDto value, $Res Function(_TransferResultDto) _then) = __$TransferResultDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'currency') String? currency,@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'recipient') TransferRecipientDto? recipient,@JsonKey(name: 'lots') List? lots,@JsonKey(name: 'balance') int? balance,@JsonKey(name: 'replayed') bool? replayed +}); + + +@override $TransferRecipientDtoCopyWith<$Res>? get recipient; + +} +/// @nodoc +class __$TransferResultDtoCopyWithImpl<$Res> + implements _$TransferResultDtoCopyWith<$Res> { + __$TransferResultDtoCopyWithImpl(this._self, this._then); + + final _TransferResultDto _self; + final $Res Function(_TransferResultDto) _then; + +/// Create a copy of TransferResultDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? currency = freezed,Object? amount = freezed,Object? recipient = freezed,Object? lots = freezed,Object? balance = freezed,Object? replayed = freezed,}) { + return _then(_TransferResultDto( +currency: freezed == currency ? _self.currency : currency // ignore: cast_nullable_to_non_nullable +as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,recipient: freezed == recipient ? _self.recipient : recipient // ignore: cast_nullable_to_non_nullable +as TransferRecipientDto?,lots: freezed == lots ? _self._lots : lots // ignore: cast_nullable_to_non_nullable +as List?,balance: freezed == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as int?,replayed: freezed == replayed ? _self.replayed : replayed // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + +/// Create a copy of TransferResultDto +/// with the given fields replaced by the non-null parameter values. +@override +@pragma('vm:prefer-inline') +$TransferRecipientDtoCopyWith<$Res>? get recipient { + if (_self.recipient == null) { + return null; + } + + return $TransferRecipientDtoCopyWith<$Res>(_self.recipient!, (value) { + return _then(_self.copyWith(recipient: value)); + }); +} +} + + +/// @nodoc +mixin _$PinStatusDto { + +@JsonKey(name: 'has_pin') bool? get hasPin;@JsonKey(name: 'locked_until') String? get lockedUntil;@JsonKey(name: 'transfer_blocked_until') String? get transferBlockedUntil; +/// Create a copy of PinStatusDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PinStatusDtoCopyWith get copyWith => _$PinStatusDtoCopyWithImpl(this as PinStatusDto, _$identity); + + /// Serializes this PinStatusDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as PinStatusDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinStatusDto&&(identical(other.hasPin, _this.hasPin) || other.hasPin == _this.hasPin)&&(identical(other.lockedUntil, _this.lockedUntil) || other.lockedUntil == _this.lockedUntil)&&(identical(other.transferBlockedUntil, _this.transferBlockedUntil) || other.transferBlockedUntil == _this.transferBlockedUntil)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as PinStatusDto; + return Object.hash(runtimeType,_this.hasPin,_this.lockedUntil,_this.transferBlockedUntil); +} + +@override +String toString() { + final _this = this as PinStatusDto; + return 'PinStatusDto(hasPin: ${_this.hasPin}, lockedUntil: ${_this.lockedUntil}, transferBlockedUntil: ${_this.transferBlockedUntil})'; +} + + +} + +/// @nodoc +abstract mixin class $PinStatusDtoCopyWith<$Res> { + factory $PinStatusDtoCopyWith(PinStatusDto value, $Res Function(PinStatusDto) _then) = _$PinStatusDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'has_pin') bool? hasPin,@JsonKey(name: 'locked_until') String? lockedUntil,@JsonKey(name: 'transfer_blocked_until') String? transferBlockedUntil +}); + + + + +} +/// @nodoc +class _$PinStatusDtoCopyWithImpl<$Res> + implements $PinStatusDtoCopyWith<$Res> { + _$PinStatusDtoCopyWithImpl(this._self, this._then); + + final PinStatusDto _self; + final $Res Function(PinStatusDto) _then; + +/// Create a copy of PinStatusDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? hasPin = freezed,Object? lockedUntil = freezed,Object? transferBlockedUntil = freezed,}) { + return _then(PinStatusDto( +hasPin: freezed == hasPin ? _self.hasPin : hasPin // ignore: cast_nullable_to_non_nullable +as bool?,lockedUntil: freezed == lockedUntil ? _self.lockedUntil : lockedUntil // ignore: cast_nullable_to_non_nullable +as String?,transferBlockedUntil: freezed == transferBlockedUntil ? _self.transferBlockedUntil : transferBlockedUntil // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PinStatusDto]. +extension PinStatusDtoPatterns on PinStatusDto { +/// 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( _PinStatusDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PinStatusDto() 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( _PinStatusDto value) $default,){ +final _that = this; +switch (_that) { +case _PinStatusDto(): +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( _PinStatusDto value)? $default,){ +final _that = this; +switch (_that) { +case _PinStatusDto() 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(@JsonKey(name: 'has_pin') bool? hasPin, @JsonKey(name: 'locked_until') String? lockedUntil, @JsonKey(name: 'transfer_blocked_until') String? transferBlockedUntil)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PinStatusDto() when $default != null: +return $default(_that.hasPin,_that.lockedUntil,_that.transferBlockedUntil);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(@JsonKey(name: 'has_pin') bool? hasPin, @JsonKey(name: 'locked_until') String? lockedUntil, @JsonKey(name: 'transfer_blocked_until') String? transferBlockedUntil) $default,) {final _that = this; +switch (_that) { +case _PinStatusDto(): +return $default(_that.hasPin,_that.lockedUntil,_that.transferBlockedUntil);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(@JsonKey(name: 'has_pin') bool? hasPin, @JsonKey(name: 'locked_until') String? lockedUntil, @JsonKey(name: 'transfer_blocked_until') String? transferBlockedUntil)? $default,) {final _that = this; +switch (_that) { +case _PinStatusDto() when $default != null: +return $default(_that.hasPin,_that.lockedUntil,_that.transferBlockedUntil);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _PinStatusDto extends PinStatusDto { + const _PinStatusDto({@JsonKey(name: 'has_pin') this.hasPin, @JsonKey(name: 'locked_until') this.lockedUntil, @JsonKey(name: 'transfer_blocked_until') this.transferBlockedUntil}): super._(); + factory _PinStatusDto.fromJson(Map json) => _$PinStatusDtoFromJson(json); + +@override@JsonKey(name: 'has_pin') final bool? hasPin; +@override@JsonKey(name: 'locked_until') final String? lockedUntil; +@override@JsonKey(name: 'transfer_blocked_until') final String? transferBlockedUntil; + +/// Create a copy of PinStatusDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinStatusDtoCopyWith<_PinStatusDto> get copyWith => __$PinStatusDtoCopyWithImpl<_PinStatusDto>(this, _$identity); + +@override +Map toJson() { + return _$PinStatusDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinStatusDto&&(identical(other.hasPin, hasPin) || other.hasPin == hasPin)&&(identical(other.lockedUntil, lockedUntil) || other.lockedUntil == lockedUntil)&&(identical(other.transferBlockedUntil, transferBlockedUntil) || other.transferBlockedUntil == transferBlockedUntil)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,hasPin,lockedUntil,transferBlockedUntil); +} + +@override +String toString() { + return 'PinStatusDto(hasPin: $hasPin, lockedUntil: $lockedUntil, transferBlockedUntil: $transferBlockedUntil)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinStatusDtoCopyWith<$Res> implements $PinStatusDtoCopyWith<$Res> { + factory _$PinStatusDtoCopyWith(_PinStatusDto value, $Res Function(_PinStatusDto) _then) = __$PinStatusDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'has_pin') bool? hasPin,@JsonKey(name: 'locked_until') String? lockedUntil,@JsonKey(name: 'transfer_blocked_until') String? transferBlockedUntil +}); + + + + +} +/// @nodoc +class __$PinStatusDtoCopyWithImpl<$Res> + implements _$PinStatusDtoCopyWith<$Res> { + __$PinStatusDtoCopyWithImpl(this._self, this._then); + + final _PinStatusDto _self; + final $Res Function(_PinStatusDto) _then; + +/// Create a copy of PinStatusDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? hasPin = freezed,Object? lockedUntil = freezed,Object? transferBlockedUntil = freezed,}) { + return _then(_PinStatusDto( +hasPin: freezed == hasPin ? _self.hasPin : hasPin // ignore: cast_nullable_to_non_nullable +as bool?,lockedUntil: freezed == lockedUntil ? _self.lockedUntil : lockedUntil // ignore: cast_nullable_to_non_nullable +as String?,transferBlockedUntil: freezed == transferBlockedUntil ? _self.transferBlockedUntil : transferBlockedUntil // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$PinOtpDto { + +@JsonKey(name: 'purpose') String? get purpose;@JsonKey(name: 'otp_token') String? get otpToken;@JsonKey(name: 'expires_at') String? get expiresAt; +/// Create a copy of PinOtpDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PinOtpDtoCopyWith get copyWith => _$PinOtpDtoCopyWithImpl(this as PinOtpDto, _$identity); + + /// Serializes this PinOtpDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as PinOtpDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is PinOtpDto&&(identical(other.purpose, _this.purpose) || other.purpose == _this.purpose)&&(identical(other.otpToken, _this.otpToken) || other.otpToken == _this.otpToken)&&(identical(other.expiresAt, _this.expiresAt) || other.expiresAt == _this.expiresAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as PinOtpDto; + return Object.hash(runtimeType,_this.purpose,_this.otpToken,_this.expiresAt); +} + +@override +String toString() { + final _this = this as PinOtpDto; + return 'PinOtpDto(purpose: ${_this.purpose}, otpToken: ${_this.otpToken}, expiresAt: ${_this.expiresAt})'; +} + + +} + +/// @nodoc +abstract mixin class $PinOtpDtoCopyWith<$Res> { + factory $PinOtpDtoCopyWith(PinOtpDto value, $Res Function(PinOtpDto) _then) = _$PinOtpDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'purpose') String? purpose,@JsonKey(name: 'otp_token') String? otpToken,@JsonKey(name: 'expires_at') String? expiresAt +}); + + + + +} +/// @nodoc +class _$PinOtpDtoCopyWithImpl<$Res> + implements $PinOtpDtoCopyWith<$Res> { + _$PinOtpDtoCopyWithImpl(this._self, this._then); + + final PinOtpDto _self; + final $Res Function(PinOtpDto) _then; + +/// Create a copy of PinOtpDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? purpose = freezed,Object? otpToken = freezed,Object? expiresAt = freezed,}) { + return _then(PinOtpDto( +purpose: freezed == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as String?,otpToken: freezed == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PinOtpDto]. +extension PinOtpDtoPatterns on PinOtpDto { +/// 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( _PinOtpDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _PinOtpDto() 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( _PinOtpDto value) $default,){ +final _that = this; +switch (_that) { +case _PinOtpDto(): +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( _PinOtpDto value)? $default,){ +final _that = this; +switch (_that) { +case _PinOtpDto() 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(@JsonKey(name: 'purpose') String? purpose, @JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_at') String? expiresAt)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _PinOtpDto() when $default != null: +return $default(_that.purpose,_that.otpToken,_that.expiresAt);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(@JsonKey(name: 'purpose') String? purpose, @JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_at') String? expiresAt) $default,) {final _that = this; +switch (_that) { +case _PinOtpDto(): +return $default(_that.purpose,_that.otpToken,_that.expiresAt);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(@JsonKey(name: 'purpose') String? purpose, @JsonKey(name: 'otp_token') String? otpToken, @JsonKey(name: 'expires_at') String? expiresAt)? $default,) {final _that = this; +switch (_that) { +case _PinOtpDto() when $default != null: +return $default(_that.purpose,_that.otpToken,_that.expiresAt);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _PinOtpDto extends PinOtpDto { + const _PinOtpDto({@JsonKey(name: 'purpose') this.purpose, @JsonKey(name: 'otp_token') this.otpToken, @JsonKey(name: 'expires_at') this.expiresAt}): super._(); + factory _PinOtpDto.fromJson(Map json) => _$PinOtpDtoFromJson(json); + +@override@JsonKey(name: 'purpose') final String? purpose; +@override@JsonKey(name: 'otp_token') final String? otpToken; +@override@JsonKey(name: 'expires_at') final String? expiresAt; + +/// Create a copy of PinOtpDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PinOtpDtoCopyWith<_PinOtpDto> get copyWith => __$PinOtpDtoCopyWithImpl<_PinOtpDto>(this, _$identity); + +@override +Map toJson() { + return _$PinOtpDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _PinOtpDto&&(identical(other.purpose, purpose) || other.purpose == purpose)&&(identical(other.otpToken, otpToken) || other.otpToken == otpToken)&&(identical(other.expiresAt, expiresAt) || other.expiresAt == expiresAt)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,purpose,otpToken,expiresAt); +} + +@override +String toString() { + return 'PinOtpDto(purpose: $purpose, otpToken: $otpToken, expiresAt: $expiresAt)'; +} + + +} + +/// @nodoc +abstract mixin class _$PinOtpDtoCopyWith<$Res> implements $PinOtpDtoCopyWith<$Res> { + factory _$PinOtpDtoCopyWith(_PinOtpDto value, $Res Function(_PinOtpDto) _then) = __$PinOtpDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'purpose') String? purpose,@JsonKey(name: 'otp_token') String? otpToken,@JsonKey(name: 'expires_at') String? expiresAt +}); + + + + +} +/// @nodoc +class __$PinOtpDtoCopyWithImpl<$Res> + implements _$PinOtpDtoCopyWith<$Res> { + __$PinOtpDtoCopyWithImpl(this._self, this._then); + + final _PinOtpDto _self; + final $Res Function(_PinOtpDto) _then; + +/// Create a copy of PinOtpDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? purpose = freezed,Object? otpToken = freezed,Object? expiresAt = freezed,}) { + return _then(_PinOtpDto( +purpose: freezed == purpose ? _self.purpose : purpose // ignore: cast_nullable_to_non_nullable +as String?,otpToken: freezed == otpToken ? _self.otpToken : otpToken // ignore: cast_nullable_to_non_nullable +as String?,expiresAt: freezed == expiresAt ? _self.expiresAt : expiresAt // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + + +/// @nodoc +mixin _$OutletDto { + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'name') String? get name;@JsonKey(name: 'address') String? get address;@JsonKey(name: 'accepts_point_payment') bool? get acceptsPointPayment;@JsonKey(name: 'earns_points') bool? get earnsPoints;@JsonKey(name: 'earns_coins') bool? get earnsCoins; +/// Create a copy of OutletDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$OutletDtoCopyWith get copyWith => _$OutletDtoCopyWithImpl(this as OutletDto, _$identity); + + /// Serializes this OutletDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as OutletDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is OutletDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.address, _this.address) || other.address == _this.address)&&(identical(other.acceptsPointPayment, _this.acceptsPointPayment) || other.acceptsPointPayment == _this.acceptsPointPayment)&&(identical(other.earnsPoints, _this.earnsPoints) || other.earnsPoints == _this.earnsPoints)&&(identical(other.earnsCoins, _this.earnsCoins) || other.earnsCoins == _this.earnsCoins)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as OutletDto; + return Object.hash(runtimeType,_this.id,_this.name,_this.address,_this.acceptsPointPayment,_this.earnsPoints,_this.earnsCoins); +} + +@override +String toString() { + final _this = this as OutletDto; + return 'OutletDto(id: ${_this.id}, name: ${_this.name}, address: ${_this.address}, acceptsPointPayment: ${_this.acceptsPointPayment}, earnsPoints: ${_this.earnsPoints}, earnsCoins: ${_this.earnsCoins})'; +} + + +} + +/// @nodoc +abstract mixin class $OutletDtoCopyWith<$Res> { + factory $OutletDtoCopyWith(OutletDto value, $Res Function(OutletDto) _then) = _$OutletDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name,@JsonKey(name: 'address') String? address,@JsonKey(name: 'accepts_point_payment') bool? acceptsPointPayment,@JsonKey(name: 'earns_points') bool? earnsPoints,@JsonKey(name: 'earns_coins') bool? earnsCoins +}); + + + + +} +/// @nodoc +class _$OutletDtoCopyWithImpl<$Res> + implements $OutletDtoCopyWith<$Res> { + _$OutletDtoCopyWithImpl(this._self, this._then); + + final OutletDto _self; + final $Res Function(OutletDto) _then; + +/// Create a copy of OutletDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? name = freezed,Object? address = freezed,Object? acceptsPointPayment = freezed,Object? earnsPoints = freezed,Object? earnsCoins = freezed,}) { + return _then(OutletDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,acceptsPointPayment: freezed == acceptsPointPayment ? _self.acceptsPointPayment : acceptsPointPayment // ignore: cast_nullable_to_non_nullable +as bool?,earnsPoints: freezed == earnsPoints ? _self.earnsPoints : earnsPoints // ignore: cast_nullable_to_non_nullable +as bool?,earnsCoins: freezed == earnsCoins ? _self.earnsCoins : earnsCoins // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [OutletDto]. +extension OutletDtoPatterns on OutletDto { +/// 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( _OutletDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _OutletDto() 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( _OutletDto value) $default,){ +final _that = this; +switch (_that) { +case _OutletDto(): +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( _OutletDto value)? $default,){ +final _that = this; +switch (_that) { +case _OutletDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'address') String? address, @JsonKey(name: 'accepts_point_payment') bool? acceptsPointPayment, @JsonKey(name: 'earns_points') bool? earnsPoints, @JsonKey(name: 'earns_coins') bool? earnsCoins)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _OutletDto() when $default != null: +return $default(_that.id,_that.name,_that.address,_that.acceptsPointPayment,_that.earnsPoints,_that.earnsCoins);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'address') String? address, @JsonKey(name: 'accepts_point_payment') bool? acceptsPointPayment, @JsonKey(name: 'earns_points') bool? earnsPoints, @JsonKey(name: 'earns_coins') bool? earnsCoins) $default,) {final _that = this; +switch (_that) { +case _OutletDto(): +return $default(_that.id,_that.name,_that.address,_that.acceptsPointPayment,_that.earnsPoints,_that.earnsCoins);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'name') String? name, @JsonKey(name: 'address') String? address, @JsonKey(name: 'accepts_point_payment') bool? acceptsPointPayment, @JsonKey(name: 'earns_points') bool? earnsPoints, @JsonKey(name: 'earns_coins') bool? earnsCoins)? $default,) {final _that = this; +switch (_that) { +case _OutletDto() when $default != null: +return $default(_that.id,_that.name,_that.address,_that.acceptsPointPayment,_that.earnsPoints,_that.earnsCoins);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _OutletDto extends OutletDto { + const _OutletDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'name') this.name, @JsonKey(name: 'address') this.address, @JsonKey(name: 'accepts_point_payment') this.acceptsPointPayment, @JsonKey(name: 'earns_points') this.earnsPoints, @JsonKey(name: 'earns_coins') this.earnsCoins}): super._(); + factory _OutletDto.fromJson(Map json) => _$OutletDtoFromJson(json); + +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'name') final String? name; +@override@JsonKey(name: 'address') final String? address; +@override@JsonKey(name: 'accepts_point_payment') final bool? acceptsPointPayment; +@override@JsonKey(name: 'earns_points') final bool? earnsPoints; +@override@JsonKey(name: 'earns_coins') final bool? earnsCoins; + +/// Create a copy of OutletDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$OutletDtoCopyWith<_OutletDto> get copyWith => __$OutletDtoCopyWithImpl<_OutletDto>(this, _$identity); + +@override +Map toJson() { + return _$OutletDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _OutletDto&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.address, address) || other.address == address)&&(identical(other.acceptsPointPayment, acceptsPointPayment) || other.acceptsPointPayment == acceptsPointPayment)&&(identical(other.earnsPoints, earnsPoints) || other.earnsPoints == earnsPoints)&&(identical(other.earnsCoins, earnsCoins) || other.earnsCoins == earnsCoins)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,name,address,acceptsPointPayment,earnsPoints,earnsCoins); +} + +@override +String toString() { + return 'OutletDto(id: $id, name: $name, address: $address, acceptsPointPayment: $acceptsPointPayment, earnsPoints: $earnsPoints, earnsCoins: $earnsCoins)'; +} + + +} + +/// @nodoc +abstract mixin class _$OutletDtoCopyWith<$Res> implements $OutletDtoCopyWith<$Res> { + factory _$OutletDtoCopyWith(_OutletDto value, $Res Function(_OutletDto) _then) = __$OutletDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'name') String? name,@JsonKey(name: 'address') String? address,@JsonKey(name: 'accepts_point_payment') bool? acceptsPointPayment,@JsonKey(name: 'earns_points') bool? earnsPoints,@JsonKey(name: 'earns_coins') bool? earnsCoins +}); + + + + +} +/// @nodoc +class __$OutletDtoCopyWithImpl<$Res> + implements _$OutletDtoCopyWith<$Res> { + __$OutletDtoCopyWithImpl(this._self, this._then); + + final _OutletDto _self; + final $Res Function(_OutletDto) _then; + +/// Create a copy of OutletDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? name = freezed,Object? address = freezed,Object? acceptsPointPayment = freezed,Object? earnsPoints = freezed,Object? earnsCoins = freezed,}) { + return _then(_OutletDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,acceptsPointPayment: freezed == acceptsPointPayment ? _self.acceptsPointPayment : acceptsPointPayment // ignore: cast_nullable_to_non_nullable +as bool?,earnsPoints: freezed == earnsPoints ? _self.earnsPoints : earnsPoints // ignore: cast_nullable_to_non_nullable +as bool?,earnsCoins: freezed == earnsCoins ? _self.earnsCoins : earnsCoins // ignore: cast_nullable_to_non_nullable +as bool?, + )); +} + + +} + + +/// @nodoc +mixin _$CustomerOrderDto { + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'order_number') String? get orderNumber;@JsonKey(name: 'outlet_name') String? get outletName;@JsonKey(name: 'order_type') String? get orderType;@JsonKey(name: 'status') String? get status;@JsonKey(name: 'payment_status') String? get paymentStatus;@JsonKey(name: 'total_amount') int? get totalAmount;@JsonKey(name: 'item_count') int? get itemCount;@JsonKey(name: 'is_void') bool? get isVoid;@JsonKey(name: 'is_refund') bool? get isRefund;@JsonKey(name: 'points_earned') int? get pointsEarned;@JsonKey(name: 'coins_earned') int? get coinsEarned;@JsonKey(name: 'created_at') String? get createdAt;@JsonKey(name: 'table_number') String? get tableNumber;@JsonKey(name: 'subtotal') int? get subtotal;@JsonKey(name: 'discount_amount') int? get discountAmount;@JsonKey(name: 'tax_amount') int? get taxAmount;@JsonKey(name: 'refund_amount') int? get refundAmount;@JsonKey(name: 'items') List? get items;@JsonKey(name: 'payments') List? get payments; +/// Create a copy of CustomerOrderDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderDtoCopyWith get copyWith => _$CustomerOrderDtoCopyWithImpl(this as CustomerOrderDto, _$identity); + + /// Serializes this CustomerOrderDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrderDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrderDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.orderNumber, _this.orderNumber) || other.orderNumber == _this.orderNumber)&&(identical(other.outletName, _this.outletName) || other.outletName == _this.outletName)&&(identical(other.orderType, _this.orderType) || other.orderType == _this.orderType)&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.paymentStatus, _this.paymentStatus) || other.paymentStatus == _this.paymentStatus)&&(identical(other.totalAmount, _this.totalAmount) || other.totalAmount == _this.totalAmount)&&(identical(other.itemCount, _this.itemCount) || other.itemCount == _this.itemCount)&&(identical(other.isVoid, _this.isVoid) || other.isVoid == _this.isVoid)&&(identical(other.isRefund, _this.isRefund) || other.isRefund == _this.isRefund)&&(identical(other.pointsEarned, _this.pointsEarned) || other.pointsEarned == _this.pointsEarned)&&(identical(other.coinsEarned, _this.coinsEarned) || other.coinsEarned == _this.coinsEarned)&&(identical(other.createdAt, _this.createdAt) || other.createdAt == _this.createdAt)&&(identical(other.tableNumber, _this.tableNumber) || other.tableNumber == _this.tableNumber)&&(identical(other.subtotal, _this.subtotal) || other.subtotal == _this.subtotal)&&(identical(other.discountAmount, _this.discountAmount) || other.discountAmount == _this.discountAmount)&&(identical(other.taxAmount, _this.taxAmount) || other.taxAmount == _this.taxAmount)&&(identical(other.refundAmount, _this.refundAmount) || other.refundAmount == _this.refundAmount)&&const DeepCollectionEquality().equals(other.items, _this.items)&&const DeepCollectionEquality().equals(other.payments, _this.payments)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as CustomerOrderDto; + return Object.hashAll([runtimeType,_this.id,_this.orderNumber,_this.outletName,_this.orderType,_this.status,_this.paymentStatus,_this.totalAmount,_this.itemCount,_this.isVoid,_this.isRefund,_this.pointsEarned,_this.coinsEarned,_this.createdAt,_this.tableNumber,_this.subtotal,_this.discountAmount,_this.taxAmount,_this.refundAmount,const DeepCollectionEquality().hash(_this.items),const DeepCollectionEquality().hash(_this.payments)]); +} + +@override +String toString() { + final _this = this as CustomerOrderDto; + return 'CustomerOrderDto(id: ${_this.id}, orderNumber: ${_this.orderNumber}, outletName: ${_this.outletName}, orderType: ${_this.orderType}, status: ${_this.status}, paymentStatus: ${_this.paymentStatus}, totalAmount: ${_this.totalAmount}, itemCount: ${_this.itemCount}, isVoid: ${_this.isVoid}, isRefund: ${_this.isRefund}, pointsEarned: ${_this.pointsEarned}, coinsEarned: ${_this.coinsEarned}, createdAt: ${_this.createdAt}, tableNumber: ${_this.tableNumber}, subtotal: ${_this.subtotal}, discountAmount: ${_this.discountAmount}, taxAmount: ${_this.taxAmount}, refundAmount: ${_this.refundAmount}, items: ${_this.items}, payments: ${_this.payments})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderDtoCopyWith<$Res> { + factory $CustomerOrderDtoCopyWith(CustomerOrderDto value, $Res Function(CustomerOrderDto) _then) = _$CustomerOrderDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'order_number') String? orderNumber,@JsonKey(name: 'outlet_name') String? outletName,@JsonKey(name: 'order_type') String? orderType,@JsonKey(name: 'status') String? status,@JsonKey(name: 'payment_status') String? paymentStatus,@JsonKey(name: 'total_amount') int? totalAmount,@JsonKey(name: 'item_count') int? itemCount,@JsonKey(name: 'is_void') bool? isVoid,@JsonKey(name: 'is_refund') bool? isRefund,@JsonKey(name: 'points_earned') int? pointsEarned,@JsonKey(name: 'coins_earned') int? coinsEarned,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'table_number') String? tableNumber,@JsonKey(name: 'subtotal') int? subtotal,@JsonKey(name: 'discount_amount') int? discountAmount,@JsonKey(name: 'tax_amount') int? taxAmount,@JsonKey(name: 'refund_amount') int? refundAmount,@JsonKey(name: 'items') List? items,@JsonKey(name: 'payments') List? payments +}); + + + + +} +/// @nodoc +class _$CustomerOrderDtoCopyWithImpl<$Res> + implements $CustomerOrderDtoCopyWith<$Res> { + _$CustomerOrderDtoCopyWithImpl(this._self, this._then); + + final CustomerOrderDto _self; + final $Res Function(CustomerOrderDto) _then; + +/// Create a copy of CustomerOrderDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? orderNumber = freezed,Object? outletName = freezed,Object? orderType = freezed,Object? status = freezed,Object? paymentStatus = freezed,Object? totalAmount = freezed,Object? itemCount = freezed,Object? isVoid = freezed,Object? isRefund = freezed,Object? pointsEarned = freezed,Object? coinsEarned = freezed,Object? createdAt = freezed,Object? tableNumber = freezed,Object? subtotal = freezed,Object? discountAmount = freezed,Object? taxAmount = freezed,Object? refundAmount = freezed,Object? items = freezed,Object? payments = freezed,}) { + return _then(CustomerOrderDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,orderNumber: freezed == orderNumber ? _self.orderNumber : orderNumber // ignore: cast_nullable_to_non_nullable +as String?,outletName: freezed == outletName ? _self.outletName : outletName // ignore: cast_nullable_to_non_nullable +as String?,orderType: freezed == orderType ? _self.orderType : orderType // ignore: cast_nullable_to_non_nullable +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,paymentStatus: freezed == paymentStatus ? _self.paymentStatus : paymentStatus // ignore: cast_nullable_to_non_nullable +as String?,totalAmount: freezed == totalAmount ? _self.totalAmount : totalAmount // ignore: cast_nullable_to_non_nullable +as int?,itemCount: freezed == itemCount ? _self.itemCount : itemCount // ignore: cast_nullable_to_non_nullable +as int?,isVoid: freezed == isVoid ? _self.isVoid : isVoid // ignore: cast_nullable_to_non_nullable +as bool?,isRefund: freezed == isRefund ? _self.isRefund : isRefund // ignore: cast_nullable_to_non_nullable +as bool?,pointsEarned: freezed == pointsEarned ? _self.pointsEarned : pointsEarned // ignore: cast_nullable_to_non_nullable +as int?,coinsEarned: freezed == coinsEarned ? _self.coinsEarned : coinsEarned // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?,tableNumber: freezed == tableNumber ? _self.tableNumber : tableNumber // ignore: cast_nullable_to_non_nullable +as String?,subtotal: freezed == subtotal ? _self.subtotal : subtotal // ignore: cast_nullable_to_non_nullable +as int?,discountAmount: freezed == discountAmount ? _self.discountAmount : discountAmount // ignore: cast_nullable_to_non_nullable +as int?,taxAmount: freezed == taxAmount ? _self.taxAmount : taxAmount // ignore: cast_nullable_to_non_nullable +as int?,refundAmount: freezed == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int?,items: freezed == items ? _self.items : items // ignore: cast_nullable_to_non_nullable +as List?,payments: freezed == payments ? _self.payments : payments // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CustomerOrderDto]. +extension CustomerOrderDtoPatterns on CustomerOrderDto { +/// 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( _CustomerOrderDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrderDto() 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( _CustomerOrderDto value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderDto(): +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( _CustomerOrderDto value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'order_number') String? orderNumber, @JsonKey(name: 'outlet_name') String? outletName, @JsonKey(name: 'order_type') String? orderType, @JsonKey(name: 'status') String? status, @JsonKey(name: 'payment_status') String? paymentStatus, @JsonKey(name: 'total_amount') int? totalAmount, @JsonKey(name: 'item_count') int? itemCount, @JsonKey(name: 'is_void') bool? isVoid, @JsonKey(name: 'is_refund') bool? isRefund, @JsonKey(name: 'points_earned') int? pointsEarned, @JsonKey(name: 'coins_earned') int? coinsEarned, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'table_number') String? tableNumber, @JsonKey(name: 'subtotal') int? subtotal, @JsonKey(name: 'discount_amount') int? discountAmount, @JsonKey(name: 'tax_amount') int? taxAmount, @JsonKey(name: 'refund_amount') int? refundAmount, @JsonKey(name: 'items') List? items, @JsonKey(name: 'payments') List? payments)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrderDto() when $default != null: +return $default(_that.id,_that.orderNumber,_that.outletName,_that.orderType,_that.status,_that.paymentStatus,_that.totalAmount,_that.itemCount,_that.isVoid,_that.isRefund,_that.pointsEarned,_that.coinsEarned,_that.createdAt,_that.tableNumber,_that.subtotal,_that.discountAmount,_that.taxAmount,_that.refundAmount,_that.items,_that.payments);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'order_number') String? orderNumber, @JsonKey(name: 'outlet_name') String? outletName, @JsonKey(name: 'order_type') String? orderType, @JsonKey(name: 'status') String? status, @JsonKey(name: 'payment_status') String? paymentStatus, @JsonKey(name: 'total_amount') int? totalAmount, @JsonKey(name: 'item_count') int? itemCount, @JsonKey(name: 'is_void') bool? isVoid, @JsonKey(name: 'is_refund') bool? isRefund, @JsonKey(name: 'points_earned') int? pointsEarned, @JsonKey(name: 'coins_earned') int? coinsEarned, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'table_number') String? tableNumber, @JsonKey(name: 'subtotal') int? subtotal, @JsonKey(name: 'discount_amount') int? discountAmount, @JsonKey(name: 'tax_amount') int? taxAmount, @JsonKey(name: 'refund_amount') int? refundAmount, @JsonKey(name: 'items') List? items, @JsonKey(name: 'payments') List? payments) $default,) {final _that = this; +switch (_that) { +case _CustomerOrderDto(): +return $default(_that.id,_that.orderNumber,_that.outletName,_that.orderType,_that.status,_that.paymentStatus,_that.totalAmount,_that.itemCount,_that.isVoid,_that.isRefund,_that.pointsEarned,_that.coinsEarned,_that.createdAt,_that.tableNumber,_that.subtotal,_that.discountAmount,_that.taxAmount,_that.refundAmount,_that.items,_that.payments);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'order_number') String? orderNumber, @JsonKey(name: 'outlet_name') String? outletName, @JsonKey(name: 'order_type') String? orderType, @JsonKey(name: 'status') String? status, @JsonKey(name: 'payment_status') String? paymentStatus, @JsonKey(name: 'total_amount') int? totalAmount, @JsonKey(name: 'item_count') int? itemCount, @JsonKey(name: 'is_void') bool? isVoid, @JsonKey(name: 'is_refund') bool? isRefund, @JsonKey(name: 'points_earned') int? pointsEarned, @JsonKey(name: 'coins_earned') int? coinsEarned, @JsonKey(name: 'created_at') String? createdAt, @JsonKey(name: 'table_number') String? tableNumber, @JsonKey(name: 'subtotal') int? subtotal, @JsonKey(name: 'discount_amount') int? discountAmount, @JsonKey(name: 'tax_amount') int? taxAmount, @JsonKey(name: 'refund_amount') int? refundAmount, @JsonKey(name: 'items') List? items, @JsonKey(name: 'payments') List? payments)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrderDto() when $default != null: +return $default(_that.id,_that.orderNumber,_that.outletName,_that.orderType,_that.status,_that.paymentStatus,_that.totalAmount,_that.itemCount,_that.isVoid,_that.isRefund,_that.pointsEarned,_that.coinsEarned,_that.createdAt,_that.tableNumber,_that.subtotal,_that.discountAmount,_that.taxAmount,_that.refundAmount,_that.items,_that.payments);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _CustomerOrderDto extends CustomerOrderDto { + const _CustomerOrderDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'order_number') this.orderNumber, @JsonKey(name: 'outlet_name') this.outletName, @JsonKey(name: 'order_type') this.orderType, @JsonKey(name: 'status') this.status, @JsonKey(name: 'payment_status') this.paymentStatus, @JsonKey(name: 'total_amount') this.totalAmount, @JsonKey(name: 'item_count') this.itemCount, @JsonKey(name: 'is_void') this.isVoid, @JsonKey(name: 'is_refund') this.isRefund, @JsonKey(name: 'points_earned') this.pointsEarned, @JsonKey(name: 'coins_earned') this.coinsEarned, @JsonKey(name: 'created_at') this.createdAt, @JsonKey(name: 'table_number') this.tableNumber, @JsonKey(name: 'subtotal') this.subtotal, @JsonKey(name: 'discount_amount') this.discountAmount, @JsonKey(name: 'tax_amount') this.taxAmount, @JsonKey(name: 'refund_amount') this.refundAmount, @JsonKey(name: 'items') List? items, @JsonKey(name: 'payments') List? payments}): _items = items,_payments = payments,super._(); + factory _CustomerOrderDto.fromJson(Map json) => _$CustomerOrderDtoFromJson(json); + +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'order_number') final String? orderNumber; +@override@JsonKey(name: 'outlet_name') final String? outletName; +@override@JsonKey(name: 'order_type') final String? orderType; +@override@JsonKey(name: 'status') final String? status; +@override@JsonKey(name: 'payment_status') final String? paymentStatus; +@override@JsonKey(name: 'total_amount') final int? totalAmount; +@override@JsonKey(name: 'item_count') final int? itemCount; +@override@JsonKey(name: 'is_void') final bool? isVoid; +@override@JsonKey(name: 'is_refund') final bool? isRefund; +@override@JsonKey(name: 'points_earned') final int? pointsEarned; +@override@JsonKey(name: 'coins_earned') final int? coinsEarned; +@override@JsonKey(name: 'created_at') final String? createdAt; +@override@JsonKey(name: 'table_number') final String? tableNumber; +@override@JsonKey(name: 'subtotal') final int? subtotal; +@override@JsonKey(name: 'discount_amount') final int? discountAmount; +@override@JsonKey(name: 'tax_amount') final int? taxAmount; +@override@JsonKey(name: 'refund_amount') final int? refundAmount; + final List? _items; +@override@JsonKey(name: 'items') List? get items { + final value = _items; + if (value == null) return null; + if (_items is EqualUnmodifiableListView) return _items; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + + final List? _payments; +@override@JsonKey(name: 'payments') List? get payments { + final value = _payments; + if (value == null) return null; + if (_payments is EqualUnmodifiableListView) return _payments; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); +} + + +/// Create a copy of CustomerOrderDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderDtoCopyWith<_CustomerOrderDto> get copyWith => __$CustomerOrderDtoCopyWithImpl<_CustomerOrderDto>(this, _$identity); + +@override +Map toJson() { + return _$CustomerOrderDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrderDto&&(identical(other.id, id) || other.id == id)&&(identical(other.orderNumber, orderNumber) || other.orderNumber == orderNumber)&&(identical(other.outletName, outletName) || other.outletName == outletName)&&(identical(other.orderType, orderType) || other.orderType == orderType)&&(identical(other.status, status) || other.status == status)&&(identical(other.paymentStatus, paymentStatus) || other.paymentStatus == paymentStatus)&&(identical(other.totalAmount, totalAmount) || other.totalAmount == totalAmount)&&(identical(other.itemCount, itemCount) || other.itemCount == itemCount)&&(identical(other.isVoid, isVoid) || other.isVoid == isVoid)&&(identical(other.isRefund, isRefund) || other.isRefund == isRefund)&&(identical(other.pointsEarned, pointsEarned) || other.pointsEarned == pointsEarned)&&(identical(other.coinsEarned, coinsEarned) || other.coinsEarned == coinsEarned)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.tableNumber, tableNumber) || other.tableNumber == tableNumber)&&(identical(other.subtotal, subtotal) || other.subtotal == subtotal)&&(identical(other.discountAmount, discountAmount) || other.discountAmount == discountAmount)&&(identical(other.taxAmount, taxAmount) || other.taxAmount == taxAmount)&&(identical(other.refundAmount, refundAmount) || other.refundAmount == refundAmount)&&const DeepCollectionEquality().equals(other.items, _items)&&const DeepCollectionEquality().equals(other.payments, _payments)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hashAll([runtimeType,id,orderNumber,outletName,orderType,status,paymentStatus,totalAmount,itemCount,isVoid,isRefund,pointsEarned,coinsEarned,createdAt,tableNumber,subtotal,discountAmount,taxAmount,refundAmount,const DeepCollectionEquality().hash(_items),const DeepCollectionEquality().hash(_payments)]); +} + +@override +String toString() { + return 'CustomerOrderDto(id: $id, orderNumber: $orderNumber, outletName: $outletName, orderType: $orderType, status: $status, paymentStatus: $paymentStatus, totalAmount: $totalAmount, itemCount: $itemCount, isVoid: $isVoid, isRefund: $isRefund, pointsEarned: $pointsEarned, coinsEarned: $coinsEarned, createdAt: $createdAt, tableNumber: $tableNumber, subtotal: $subtotal, discountAmount: $discountAmount, taxAmount: $taxAmount, refundAmount: $refundAmount, items: $items, payments: $payments)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderDtoCopyWith<$Res> implements $CustomerOrderDtoCopyWith<$Res> { + factory _$CustomerOrderDtoCopyWith(_CustomerOrderDto value, $Res Function(_CustomerOrderDto) _then) = __$CustomerOrderDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'order_number') String? orderNumber,@JsonKey(name: 'outlet_name') String? outletName,@JsonKey(name: 'order_type') String? orderType,@JsonKey(name: 'status') String? status,@JsonKey(name: 'payment_status') String? paymentStatus,@JsonKey(name: 'total_amount') int? totalAmount,@JsonKey(name: 'item_count') int? itemCount,@JsonKey(name: 'is_void') bool? isVoid,@JsonKey(name: 'is_refund') bool? isRefund,@JsonKey(name: 'points_earned') int? pointsEarned,@JsonKey(name: 'coins_earned') int? coinsEarned,@JsonKey(name: 'created_at') String? createdAt,@JsonKey(name: 'table_number') String? tableNumber,@JsonKey(name: 'subtotal') int? subtotal,@JsonKey(name: 'discount_amount') int? discountAmount,@JsonKey(name: 'tax_amount') int? taxAmount,@JsonKey(name: 'refund_amount') int? refundAmount,@JsonKey(name: 'items') List? items,@JsonKey(name: 'payments') List? payments +}); + + + + +} +/// @nodoc +class __$CustomerOrderDtoCopyWithImpl<$Res> + implements _$CustomerOrderDtoCopyWith<$Res> { + __$CustomerOrderDtoCopyWithImpl(this._self, this._then); + + final _CustomerOrderDto _self; + final $Res Function(_CustomerOrderDto) _then; + +/// Create a copy of CustomerOrderDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? orderNumber = freezed,Object? outletName = freezed,Object? orderType = freezed,Object? status = freezed,Object? paymentStatus = freezed,Object? totalAmount = freezed,Object? itemCount = freezed,Object? isVoid = freezed,Object? isRefund = freezed,Object? pointsEarned = freezed,Object? coinsEarned = freezed,Object? createdAt = freezed,Object? tableNumber = freezed,Object? subtotal = freezed,Object? discountAmount = freezed,Object? taxAmount = freezed,Object? refundAmount = freezed,Object? items = freezed,Object? payments = freezed,}) { + return _then(_CustomerOrderDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,orderNumber: freezed == orderNumber ? _self.orderNumber : orderNumber // ignore: cast_nullable_to_non_nullable +as String?,outletName: freezed == outletName ? _self.outletName : outletName // ignore: cast_nullable_to_non_nullable +as String?,orderType: freezed == orderType ? _self.orderType : orderType // ignore: cast_nullable_to_non_nullable +as String?,status: freezed == status ? _self.status : status // ignore: cast_nullable_to_non_nullable +as String?,paymentStatus: freezed == paymentStatus ? _self.paymentStatus : paymentStatus // ignore: cast_nullable_to_non_nullable +as String?,totalAmount: freezed == totalAmount ? _self.totalAmount : totalAmount // ignore: cast_nullable_to_non_nullable +as int?,itemCount: freezed == itemCount ? _self.itemCount : itemCount // ignore: cast_nullable_to_non_nullable +as int?,isVoid: freezed == isVoid ? _self.isVoid : isVoid // ignore: cast_nullable_to_non_nullable +as bool?,isRefund: freezed == isRefund ? _self.isRefund : isRefund // ignore: cast_nullable_to_non_nullable +as bool?,pointsEarned: freezed == pointsEarned ? _self.pointsEarned : pointsEarned // ignore: cast_nullable_to_non_nullable +as int?,coinsEarned: freezed == coinsEarned ? _self.coinsEarned : coinsEarned // ignore: cast_nullable_to_non_nullable +as int?,createdAt: freezed == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable +as String?,tableNumber: freezed == tableNumber ? _self.tableNumber : tableNumber // ignore: cast_nullable_to_non_nullable +as String?,subtotal: freezed == subtotal ? _self.subtotal : subtotal // ignore: cast_nullable_to_non_nullable +as int?,discountAmount: freezed == discountAmount ? _self.discountAmount : discountAmount // ignore: cast_nullable_to_non_nullable +as int?,taxAmount: freezed == taxAmount ? _self.taxAmount : taxAmount // ignore: cast_nullable_to_non_nullable +as int?,refundAmount: freezed == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int?,items: freezed == items ? _self._items : items // ignore: cast_nullable_to_non_nullable +as List?,payments: freezed == payments ? _self._payments : payments // ignore: cast_nullable_to_non_nullable +as List?, + )); +} + + +} + + +/// @nodoc +mixin _$CustomerOrderItemDto { + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'product_name') String? get productName;@JsonKey(name: 'variant_name') String? get variantName;@JsonKey(name: 'quantity') int? get quantity;@JsonKey(name: 'weight') double? get weight;@JsonKey(name: 'unit_name') String? get unitName;@JsonKey(name: 'unit_price') int? get unitPrice;@JsonKey(name: 'total_price') int? get totalPrice;@JsonKey(name: 'refund_quantity') int? get refundQuantity; +/// Create a copy of CustomerOrderItemDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderItemDtoCopyWith get copyWith => _$CustomerOrderItemDtoCopyWithImpl(this as CustomerOrderItemDto, _$identity); + + /// Serializes this CustomerOrderItemDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrderItemDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrderItemDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.productName, _this.productName) || other.productName == _this.productName)&&(identical(other.variantName, _this.variantName) || other.variantName == _this.variantName)&&(identical(other.quantity, _this.quantity) || other.quantity == _this.quantity)&&(identical(other.weight, _this.weight) || other.weight == _this.weight)&&(identical(other.unitName, _this.unitName) || other.unitName == _this.unitName)&&(identical(other.unitPrice, _this.unitPrice) || other.unitPrice == _this.unitPrice)&&(identical(other.totalPrice, _this.totalPrice) || other.totalPrice == _this.totalPrice)&&(identical(other.refundQuantity, _this.refundQuantity) || other.refundQuantity == _this.refundQuantity)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as CustomerOrderItemDto; + return Object.hash(runtimeType,_this.id,_this.productName,_this.variantName,_this.quantity,_this.weight,_this.unitName,_this.unitPrice,_this.totalPrice,_this.refundQuantity); +} + +@override +String toString() { + final _this = this as CustomerOrderItemDto; + return 'CustomerOrderItemDto(id: ${_this.id}, productName: ${_this.productName}, variantName: ${_this.variantName}, quantity: ${_this.quantity}, weight: ${_this.weight}, unitName: ${_this.unitName}, unitPrice: ${_this.unitPrice}, totalPrice: ${_this.totalPrice}, refundQuantity: ${_this.refundQuantity})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderItemDtoCopyWith<$Res> { + factory $CustomerOrderItemDtoCopyWith(CustomerOrderItemDto value, $Res Function(CustomerOrderItemDto) _then) = _$CustomerOrderItemDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'product_name') String? productName,@JsonKey(name: 'variant_name') String? variantName,@JsonKey(name: 'quantity') int? quantity,@JsonKey(name: 'weight') double? weight,@JsonKey(name: 'unit_name') String? unitName,@JsonKey(name: 'unit_price') int? unitPrice,@JsonKey(name: 'total_price') int? totalPrice,@JsonKey(name: 'refund_quantity') int? refundQuantity +}); + + + + +} +/// @nodoc +class _$CustomerOrderItemDtoCopyWithImpl<$Res> + implements $CustomerOrderItemDtoCopyWith<$Res> { + _$CustomerOrderItemDtoCopyWithImpl(this._self, this._then); + + final CustomerOrderItemDto _self; + final $Res Function(CustomerOrderItemDto) _then; + +/// Create a copy of CustomerOrderItemDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? productName = freezed,Object? variantName = freezed,Object? quantity = freezed,Object? weight = freezed,Object? unitName = freezed,Object? unitPrice = freezed,Object? totalPrice = freezed,Object? refundQuantity = freezed,}) { + return _then(CustomerOrderItemDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,productName: freezed == productName ? _self.productName : productName // ignore: cast_nullable_to_non_nullable +as String?,variantName: freezed == variantName ? _self.variantName : variantName // ignore: cast_nullable_to_non_nullable +as String?,quantity: freezed == quantity ? _self.quantity : quantity // ignore: cast_nullable_to_non_nullable +as int?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable +as double?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable +as String?,unitPrice: freezed == unitPrice ? _self.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable +as int?,totalPrice: freezed == totalPrice ? _self.totalPrice : totalPrice // ignore: cast_nullable_to_non_nullable +as int?,refundQuantity: freezed == refundQuantity ? _self.refundQuantity : refundQuantity // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CustomerOrderItemDto]. +extension CustomerOrderItemDtoPatterns on CustomerOrderItemDto { +/// 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( _CustomerOrderItemDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrderItemDto() 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( _CustomerOrderItemDto value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderItemDto(): +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( _CustomerOrderItemDto value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderItemDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'product_name') String? productName, @JsonKey(name: 'variant_name') String? variantName, @JsonKey(name: 'quantity') int? quantity, @JsonKey(name: 'weight') double? weight, @JsonKey(name: 'unit_name') String? unitName, @JsonKey(name: 'unit_price') int? unitPrice, @JsonKey(name: 'total_price') int? totalPrice, @JsonKey(name: 'refund_quantity') int? refundQuantity)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrderItemDto() when $default != null: +return $default(_that.id,_that.productName,_that.variantName,_that.quantity,_that.weight,_that.unitName,_that.unitPrice,_that.totalPrice,_that.refundQuantity);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'product_name') String? productName, @JsonKey(name: 'variant_name') String? variantName, @JsonKey(name: 'quantity') int? quantity, @JsonKey(name: 'weight') double? weight, @JsonKey(name: 'unit_name') String? unitName, @JsonKey(name: 'unit_price') int? unitPrice, @JsonKey(name: 'total_price') int? totalPrice, @JsonKey(name: 'refund_quantity') int? refundQuantity) $default,) {final _that = this; +switch (_that) { +case _CustomerOrderItemDto(): +return $default(_that.id,_that.productName,_that.variantName,_that.quantity,_that.weight,_that.unitName,_that.unitPrice,_that.totalPrice,_that.refundQuantity);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'product_name') String? productName, @JsonKey(name: 'variant_name') String? variantName, @JsonKey(name: 'quantity') int? quantity, @JsonKey(name: 'weight') double? weight, @JsonKey(name: 'unit_name') String? unitName, @JsonKey(name: 'unit_price') int? unitPrice, @JsonKey(name: 'total_price') int? totalPrice, @JsonKey(name: 'refund_quantity') int? refundQuantity)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrderItemDto() when $default != null: +return $default(_that.id,_that.productName,_that.variantName,_that.quantity,_that.weight,_that.unitName,_that.unitPrice,_that.totalPrice,_that.refundQuantity);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _CustomerOrderItemDto extends CustomerOrderItemDto { + const _CustomerOrderItemDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'product_name') this.productName, @JsonKey(name: 'variant_name') this.variantName, @JsonKey(name: 'quantity') this.quantity, @JsonKey(name: 'weight') this.weight, @JsonKey(name: 'unit_name') this.unitName, @JsonKey(name: 'unit_price') this.unitPrice, @JsonKey(name: 'total_price') this.totalPrice, @JsonKey(name: 'refund_quantity') this.refundQuantity}): super._(); + factory _CustomerOrderItemDto.fromJson(Map json) => _$CustomerOrderItemDtoFromJson(json); + +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'product_name') final String? productName; +@override@JsonKey(name: 'variant_name') final String? variantName; +@override@JsonKey(name: 'quantity') final int? quantity; +@override@JsonKey(name: 'weight') final double? weight; +@override@JsonKey(name: 'unit_name') final String? unitName; +@override@JsonKey(name: 'unit_price') final int? unitPrice; +@override@JsonKey(name: 'total_price') final int? totalPrice; +@override@JsonKey(name: 'refund_quantity') final int? refundQuantity; + +/// Create a copy of CustomerOrderItemDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderItemDtoCopyWith<_CustomerOrderItemDto> get copyWith => __$CustomerOrderItemDtoCopyWithImpl<_CustomerOrderItemDto>(this, _$identity); + +@override +Map toJson() { + return _$CustomerOrderItemDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrderItemDto&&(identical(other.id, id) || other.id == id)&&(identical(other.productName, productName) || other.productName == productName)&&(identical(other.variantName, variantName) || other.variantName == variantName)&&(identical(other.quantity, quantity) || other.quantity == quantity)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.unitName, unitName) || other.unitName == unitName)&&(identical(other.unitPrice, unitPrice) || other.unitPrice == unitPrice)&&(identical(other.totalPrice, totalPrice) || other.totalPrice == totalPrice)&&(identical(other.refundQuantity, refundQuantity) || other.refundQuantity == refundQuantity)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,productName,variantName,quantity,weight,unitName,unitPrice,totalPrice,refundQuantity); +} + +@override +String toString() { + return 'CustomerOrderItemDto(id: $id, productName: $productName, variantName: $variantName, quantity: $quantity, weight: $weight, unitName: $unitName, unitPrice: $unitPrice, totalPrice: $totalPrice, refundQuantity: $refundQuantity)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderItemDtoCopyWith<$Res> implements $CustomerOrderItemDtoCopyWith<$Res> { + factory _$CustomerOrderItemDtoCopyWith(_CustomerOrderItemDto value, $Res Function(_CustomerOrderItemDto) _then) = __$CustomerOrderItemDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'product_name') String? productName,@JsonKey(name: 'variant_name') String? variantName,@JsonKey(name: 'quantity') int? quantity,@JsonKey(name: 'weight') double? weight,@JsonKey(name: 'unit_name') String? unitName,@JsonKey(name: 'unit_price') int? unitPrice,@JsonKey(name: 'total_price') int? totalPrice,@JsonKey(name: 'refund_quantity') int? refundQuantity +}); + + + + +} +/// @nodoc +class __$CustomerOrderItemDtoCopyWithImpl<$Res> + implements _$CustomerOrderItemDtoCopyWith<$Res> { + __$CustomerOrderItemDtoCopyWithImpl(this._self, this._then); + + final _CustomerOrderItemDto _self; + final $Res Function(_CustomerOrderItemDto) _then; + +/// Create a copy of CustomerOrderItemDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? productName = freezed,Object? variantName = freezed,Object? quantity = freezed,Object? weight = freezed,Object? unitName = freezed,Object? unitPrice = freezed,Object? totalPrice = freezed,Object? refundQuantity = freezed,}) { + return _then(_CustomerOrderItemDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,productName: freezed == productName ? _self.productName : productName // ignore: cast_nullable_to_non_nullable +as String?,variantName: freezed == variantName ? _self.variantName : variantName // ignore: cast_nullable_to_non_nullable +as String?,quantity: freezed == quantity ? _self.quantity : quantity // ignore: cast_nullable_to_non_nullable +as int?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable +as double?,unitName: freezed == unitName ? _self.unitName : unitName // ignore: cast_nullable_to_non_nullable +as String?,unitPrice: freezed == unitPrice ? _self.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable +as int?,totalPrice: freezed == totalPrice ? _self.totalPrice : totalPrice // ignore: cast_nullable_to_non_nullable +as int?,refundQuantity: freezed == refundQuantity ? _self.refundQuantity : refundQuantity // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + + +/// @nodoc +mixin _$CustomerOrderPaymentDto { + +@JsonKey(name: 'id') String? get id;@JsonKey(name: 'method_name') String? get methodName;@JsonKey(name: 'method_type') String? get methodType;@JsonKey(name: 'amount') int? get amount;@JsonKey(name: 'refund_amount') int? get refundAmount;@JsonKey(name: 'points_used') int? get pointsUsed; +/// Create a copy of CustomerOrderPaymentDto +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CustomerOrderPaymentDtoCopyWith get copyWith => _$CustomerOrderPaymentDtoCopyWithImpl(this as CustomerOrderPaymentDto, _$identity); + + /// Serializes this CustomerOrderPaymentDto to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + final _this = this as CustomerOrderPaymentDto; + return identical(this, other) || (other.runtimeType == runtimeType&&other is CustomerOrderPaymentDto&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.methodName, _this.methodName) || other.methodName == _this.methodName)&&(identical(other.methodType, _this.methodType) || other.methodType == _this.methodType)&&(identical(other.amount, _this.amount) || other.amount == _this.amount)&&(identical(other.refundAmount, _this.refundAmount) || other.refundAmount == _this.refundAmount)&&(identical(other.pointsUsed, _this.pointsUsed) || other.pointsUsed == _this.pointsUsed)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + final _this = this as CustomerOrderPaymentDto; + return Object.hash(runtimeType,_this.id,_this.methodName,_this.methodType,_this.amount,_this.refundAmount,_this.pointsUsed); +} + +@override +String toString() { + final _this = this as CustomerOrderPaymentDto; + return 'CustomerOrderPaymentDto(id: ${_this.id}, methodName: ${_this.methodName}, methodType: ${_this.methodType}, amount: ${_this.amount}, refundAmount: ${_this.refundAmount}, pointsUsed: ${_this.pointsUsed})'; +} + + +} + +/// @nodoc +abstract mixin class $CustomerOrderPaymentDtoCopyWith<$Res> { + factory $CustomerOrderPaymentDtoCopyWith(CustomerOrderPaymentDto value, $Res Function(CustomerOrderPaymentDto) _then) = _$CustomerOrderPaymentDtoCopyWithImpl; +@useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'method_name') String? methodName,@JsonKey(name: 'method_type') String? methodType,@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'refund_amount') int? refundAmount,@JsonKey(name: 'points_used') int? pointsUsed +}); + + + + +} +/// @nodoc +class _$CustomerOrderPaymentDtoCopyWithImpl<$Res> + implements $CustomerOrderPaymentDtoCopyWith<$Res> { + _$CustomerOrderPaymentDtoCopyWithImpl(this._self, this._then); + + final CustomerOrderPaymentDto _self; + final $Res Function(CustomerOrderPaymentDto) _then; + +/// Create a copy of CustomerOrderPaymentDto +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? id = freezed,Object? methodName = freezed,Object? methodType = freezed,Object? amount = freezed,Object? refundAmount = freezed,Object? pointsUsed = freezed,}) { + return _then(CustomerOrderPaymentDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,methodName: freezed == methodName ? _self.methodName : methodName // ignore: cast_nullable_to_non_nullable +as String?,methodType: freezed == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable +as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,refundAmount: freezed == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int?,pointsUsed: freezed == pointsUsed ? _self.pointsUsed : pointsUsed // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [CustomerOrderPaymentDto]. +extension CustomerOrderPaymentDtoPatterns on CustomerOrderPaymentDto { +/// 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( _CustomerOrderPaymentDto value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _CustomerOrderPaymentDto() 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( _CustomerOrderPaymentDto value) $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderPaymentDto(): +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( _CustomerOrderPaymentDto value)? $default,){ +final _that = this; +switch (_that) { +case _CustomerOrderPaymentDto() 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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'method_name') String? methodName, @JsonKey(name: 'method_type') String? methodType, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'refund_amount') int? refundAmount, @JsonKey(name: 'points_used') int? pointsUsed)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _CustomerOrderPaymentDto() when $default != null: +return $default(_that.id,_that.methodName,_that.methodType,_that.amount,_that.refundAmount,_that.pointsUsed);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'method_name') String? methodName, @JsonKey(name: 'method_type') String? methodType, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'refund_amount') int? refundAmount, @JsonKey(name: 'points_used') int? pointsUsed) $default,) {final _that = this; +switch (_that) { +case _CustomerOrderPaymentDto(): +return $default(_that.id,_that.methodName,_that.methodType,_that.amount,_that.refundAmount,_that.pointsUsed);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(@JsonKey(name: 'id') String? id, @JsonKey(name: 'method_name') String? methodName, @JsonKey(name: 'method_type') String? methodType, @JsonKey(name: 'amount') int? amount, @JsonKey(name: 'refund_amount') int? refundAmount, @JsonKey(name: 'points_used') int? pointsUsed)? $default,) {final _that = this; +switch (_that) { +case _CustomerOrderPaymentDto() when $default != null: +return $default(_that.id,_that.methodName,_that.methodType,_that.amount,_that.refundAmount,_that.pointsUsed);case _: + return null; + +} +} + +} + +/// @nodoc +@JsonSerializable() + +class _CustomerOrderPaymentDto extends CustomerOrderPaymentDto { + const _CustomerOrderPaymentDto({@JsonKey(name: 'id') this.id, @JsonKey(name: 'method_name') this.methodName, @JsonKey(name: 'method_type') this.methodType, @JsonKey(name: 'amount') this.amount, @JsonKey(name: 'refund_amount') this.refundAmount, @JsonKey(name: 'points_used') this.pointsUsed}): super._(); + factory _CustomerOrderPaymentDto.fromJson(Map json) => _$CustomerOrderPaymentDtoFromJson(json); + +@override@JsonKey(name: 'id') final String? id; +@override@JsonKey(name: 'method_name') final String? methodName; +@override@JsonKey(name: 'method_type') final String? methodType; +@override@JsonKey(name: 'amount') final int? amount; +@override@JsonKey(name: 'refund_amount') final int? refundAmount; +@override@JsonKey(name: 'points_used') final int? pointsUsed; + +/// Create a copy of CustomerOrderPaymentDto +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CustomerOrderPaymentDtoCopyWith<_CustomerOrderPaymentDto> get copyWith => __$CustomerOrderPaymentDtoCopyWithImpl<_CustomerOrderPaymentDto>(this, _$identity); + +@override +Map toJson() { + return _$CustomerOrderPaymentDtoToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _CustomerOrderPaymentDto&&(identical(other.id, id) || other.id == id)&&(identical(other.methodName, methodName) || other.methodName == methodName)&&(identical(other.methodType, methodType) || other.methodType == methodType)&&(identical(other.amount, amount) || other.amount == amount)&&(identical(other.refundAmount, refundAmount) || other.refundAmount == refundAmount)&&(identical(other.pointsUsed, pointsUsed) || other.pointsUsed == pointsUsed)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode { + return Object.hash(runtimeType,id,methodName,methodType,amount,refundAmount,pointsUsed); +} + +@override +String toString() { + return 'CustomerOrderPaymentDto(id: $id, methodName: $methodName, methodType: $methodType, amount: $amount, refundAmount: $refundAmount, pointsUsed: $pointsUsed)'; +} + + +} + +/// @nodoc +abstract mixin class _$CustomerOrderPaymentDtoCopyWith<$Res> implements $CustomerOrderPaymentDtoCopyWith<$Res> { + factory _$CustomerOrderPaymentDtoCopyWith(_CustomerOrderPaymentDto value, $Res Function(_CustomerOrderPaymentDto) _then) = __$CustomerOrderPaymentDtoCopyWithImpl; +@override @useResult +$Res call({ +@JsonKey(name: 'id') String? id,@JsonKey(name: 'method_name') String? methodName,@JsonKey(name: 'method_type') String? methodType,@JsonKey(name: 'amount') int? amount,@JsonKey(name: 'refund_amount') int? refundAmount,@JsonKey(name: 'points_used') int? pointsUsed +}); + + + + +} +/// @nodoc +class __$CustomerOrderPaymentDtoCopyWithImpl<$Res> + implements _$CustomerOrderPaymentDtoCopyWith<$Res> { + __$CustomerOrderPaymentDtoCopyWithImpl(this._self, this._then); + + final _CustomerOrderPaymentDto _self; + final $Res Function(_CustomerOrderPaymentDto) _then; + +/// Create a copy of CustomerOrderPaymentDto +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? id = freezed,Object? methodName = freezed,Object? methodType = freezed,Object? amount = freezed,Object? refundAmount = freezed,Object? pointsUsed = freezed,}) { + return _then(_CustomerOrderPaymentDto( +id: freezed == id ? _self.id : id // ignore: cast_nullable_to_non_nullable +as String?,methodName: freezed == methodName ? _self.methodName : methodName // ignore: cast_nullable_to_non_nullable +as String?,methodType: freezed == methodType ? _self.methodType : methodType // ignore: cast_nullable_to_non_nullable +as String?,amount: freezed == amount ? _self.amount : amount // ignore: cast_nullable_to_non_nullable +as int?,refundAmount: freezed == refundAmount ? _self.refundAmount : refundAmount // ignore: cast_nullable_to_non_nullable +as int?,pointsUsed: freezed == pointsUsed ? _self.pointsUsed : pointsUsed // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/lib/infrastructure/wallet/wallet_dtos.g.dart b/lib/infrastructure/wallet/wallet_dtos.g.dart new file mode 100644 index 0000000..baeb8be --- /dev/null +++ b/lib/infrastructure/wallet/wallet_dtos.g.dart @@ -0,0 +1,373 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'wallet_dtos.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_WalletSummaryDto _$WalletSummaryDtoFromJson(Map json) => + _WalletSummaryDto( + pointBalance: (json['point_balance'] as num?)?.toInt(), + coinBalance: (json['coin_balance'] as num?)?.toInt(), + pointValue: (json['point_value'] as num?)?.toInt(), + pointDiscountValue: (json['point_discount_value'] as num?)?.toInt(), + nearestExpiring: json['nearest_expiring'] == null + ? null + : NearestExpiringDto.fromJson( + json['nearest_expiring'] as Map, + ), + recentTransactions: (json['recent_transactions'] as List?) + ?.map((e) => WalletTransactionDto.fromJson(e as Map)) + .toList(), + ); + +Map _$WalletSummaryDtoToJson(_WalletSummaryDto instance) => + { + 'point_balance': instance.pointBalance, + 'coin_balance': instance.coinBalance, + 'point_value': instance.pointValue, + 'point_discount_value': instance.pointDiscountValue, + 'nearest_expiring': instance.nearestExpiring, + 'recent_transactions': instance.recentTransactions, + }; + +_NearestExpiringDto _$NearestExpiringDtoFromJson(Map json) => + _NearestExpiringDto( + point: json['point'] == null + ? null + : ExpiringAmountDto.fromJson(json['point'] as Map), + coin: json['coin'] == null + ? null + : ExpiringAmountDto.fromJson(json['coin'] as Map), + ); + +Map _$NearestExpiringDtoToJson(_NearestExpiringDto instance) => + {'point': instance.point, 'coin': instance.coin}; + +_ExpiringAmountDto _$ExpiringAmountDtoFromJson(Map json) => + _ExpiringAmountDto( + amount: (json['amount'] as num?)?.toInt(), + date: json['date'] as String?, + ); + +Map _$ExpiringAmountDtoToJson(_ExpiringAmountDto instance) => + {'amount': instance.amount, 'date': instance.date}; + +_WalletTransactionDto _$WalletTransactionDtoFromJson( + Map json, +) => _WalletTransactionDto( + id: json['id'] as String?, + currency: json['currency'] as String?, + type: json['type'] as String?, + amount: (json['amount'] as num?)?.toInt(), + balanceAfter: (json['balance_after'] as num?)?.toInt(), + description: json['description'] as String?, + groupId: json['group_id'] as String?, + expiresAt: json['expires_at'] as String?, + createdAt: json['created_at'] as String?, +); + +Map _$WalletTransactionDtoToJson( + _WalletTransactionDto instance, +) => { + 'id': instance.id, + 'currency': instance.currency, + 'type': instance.type, + 'amount': instance.amount, + 'balance_after': instance.balanceAfter, + 'description': instance.description, + 'group_id': instance.groupId, + 'expires_at': instance.expiresAt, + 'created_at': instance.createdAt, +}; + +_WalletPaginationDto _$WalletPaginationDtoFromJson(Map json) => + _WalletPaginationDto( + page: (json['page'] as num?)?.toInt(), + limit: (json['limit'] as num?)?.toInt(), + totalCount: (json['total_count'] as num?)?.toInt(), + totalPages: (json['total_pages'] as num?)?.toInt(), + ); + +Map _$WalletPaginationDtoToJson( + _WalletPaginationDto instance, +) => { + 'page': instance.page, + 'limit': instance.limit, + 'total_count': instance.totalCount, + 'total_pages': instance.totalPages, +}; + +_WalletExpiringDto _$WalletExpiringDtoFromJson(Map json) => + _WalletExpiringDto( + point: (json['point'] as List?) + ?.map((e) => ExpiringAmountDto.fromJson(e as Map)) + .toList(), + coin: (json['coin'] as List?) + ?.map((e) => ExpiringAmountDto.fromJson(e as Map)) + .toList(), + ); + +Map _$WalletExpiringDtoToJson(_WalletExpiringDto instance) => + {'point': instance.point, 'coin': instance.coin}; + +_PaymentCodeDto _$PaymentCodeDtoFromJson(Map json) => + _PaymentCodeDto( + code: json['code'] as String?, + qrPayload: json['qr_payload'] as String?, + expiresAt: json['expires_at'] as String?, + ); + +Map _$PaymentCodeDtoToJson(_PaymentCodeDto instance) => + { + 'code': instance.code, + 'qr_payload': instance.qrPayload, + 'expires_at': instance.expiresAt, + }; + +_ExchangePreviewDto _$ExchangePreviewDtoFromJson(Map json) => + _ExchangePreviewDto( + coinAmount: (json['coin_amount'] as num?)?.toInt(), + pointAmount: (json['point_amount'] as num?)?.toInt(), + coinBalance: (json['coin_balance'] as num?)?.toInt(), + coins: (json['coins'] as num?)?.toInt(), + points: (json['points'] as num?)?.toInt(), + valid: json['valid'] as bool?, + reason: json['reason'] as String?, + ); + +Map _$ExchangePreviewDtoToJson(_ExchangePreviewDto instance) => + { + 'coin_amount': instance.coinAmount, + 'point_amount': instance.pointAmount, + 'coin_balance': instance.coinBalance, + 'coins': instance.coins, + 'points': instance.points, + 'valid': instance.valid, + 'reason': instance.reason, + }; + +_ExchangeResultDto _$ExchangeResultDtoFromJson(Map json) => + _ExchangeResultDto( + coins: (json['coins'] as num?)?.toInt(), + points: (json['points'] as num?)?.toInt(), + coinBalance: (json['coin_balance'] as num?)?.toInt(), + pointBalance: (json['point_balance'] as num?)?.toInt(), + lots: (json['lots'] as List?) + ?.map((e) => WalletLotDto.fromJson(e as Map)) + .toList(), + replayed: json['replayed'] as bool?, + ); + +Map _$ExchangeResultDtoToJson(_ExchangeResultDto instance) => + { + 'coins': instance.coins, + 'points': instance.points, + 'coin_balance': instance.coinBalance, + 'point_balance': instance.pointBalance, + 'lots': instance.lots, + 'replayed': instance.replayed, + }; + +_WalletLotDto _$WalletLotDtoFromJson(Map json) => + _WalletLotDto( + amount: (json['amount'] as num?)?.toInt(), + expiresAt: json['expires_at'] as String?, + ); + +Map _$WalletLotDtoToJson(_WalletLotDto instance) => + { + 'amount': instance.amount, + 'expires_at': instance.expiresAt, + }; + +_TransferRecipientDto _$TransferRecipientDtoFromJson( + Map json, +) => _TransferRecipientDto( + name: json['name'] as String?, + phoneNumber: json['phone_number'] as String?, +); + +Map _$TransferRecipientDtoToJson( + _TransferRecipientDto instance, +) => { + 'name': instance.name, + 'phone_number': instance.phoneNumber, +}; + +_TransferResultDto _$TransferResultDtoFromJson(Map json) => + _TransferResultDto( + currency: json['currency'] as String?, + amount: (json['amount'] as num?)?.toInt(), + recipient: json['recipient'] == null + ? null + : TransferRecipientDto.fromJson( + json['recipient'] as Map, + ), + lots: (json['lots'] as List?) + ?.map((e) => WalletLotDto.fromJson(e as Map)) + .toList(), + balance: (json['balance'] as num?)?.toInt(), + replayed: json['replayed'] as bool?, + ); + +Map _$TransferResultDtoToJson(_TransferResultDto instance) => + { + 'currency': instance.currency, + 'amount': instance.amount, + 'recipient': instance.recipient, + 'lots': instance.lots, + 'balance': instance.balance, + 'replayed': instance.replayed, + }; + +_PinStatusDto _$PinStatusDtoFromJson(Map json) => + _PinStatusDto( + hasPin: json['has_pin'] as bool?, + lockedUntil: json['locked_until'] as String?, + transferBlockedUntil: json['transfer_blocked_until'] as String?, + ); + +Map _$PinStatusDtoToJson(_PinStatusDto instance) => + { + 'has_pin': instance.hasPin, + 'locked_until': instance.lockedUntil, + 'transfer_blocked_until': instance.transferBlockedUntil, + }; + +_PinOtpDto _$PinOtpDtoFromJson(Map json) => _PinOtpDto( + purpose: json['purpose'] as String?, + otpToken: json['otp_token'] as String?, + expiresAt: json['expires_at'] as String?, +); + +Map _$PinOtpDtoToJson(_PinOtpDto instance) => + { + 'purpose': instance.purpose, + 'otp_token': instance.otpToken, + 'expires_at': instance.expiresAt, + }; + +_OutletDto _$OutletDtoFromJson(Map json) => _OutletDto( + id: json['id'] as String?, + name: json['name'] as String?, + address: json['address'] as String?, + acceptsPointPayment: json['accepts_point_payment'] as bool?, + earnsPoints: json['earns_points'] as bool?, + earnsCoins: json['earns_coins'] as bool?, +); + +Map _$OutletDtoToJson(_OutletDto instance) => + { + 'id': instance.id, + 'name': instance.name, + 'address': instance.address, + 'accepts_point_payment': instance.acceptsPointPayment, + 'earns_points': instance.earnsPoints, + 'earns_coins': instance.earnsCoins, + }; + +_CustomerOrderDto _$CustomerOrderDtoFromJson(Map json) => + _CustomerOrderDto( + id: json['id'] as String?, + orderNumber: json['order_number'] as String?, + outletName: json['outlet_name'] as String?, + orderType: json['order_type'] as String?, + status: json['status'] as String?, + paymentStatus: json['payment_status'] as String?, + totalAmount: (json['total_amount'] as num?)?.toInt(), + itemCount: (json['item_count'] as num?)?.toInt(), + isVoid: json['is_void'] as bool?, + isRefund: json['is_refund'] as bool?, + pointsEarned: (json['points_earned'] as num?)?.toInt(), + coinsEarned: (json['coins_earned'] as num?)?.toInt(), + createdAt: json['created_at'] as String?, + tableNumber: json['table_number'] as String?, + subtotal: (json['subtotal'] as num?)?.toInt(), + discountAmount: (json['discount_amount'] as num?)?.toInt(), + taxAmount: (json['tax_amount'] as num?)?.toInt(), + refundAmount: (json['refund_amount'] as num?)?.toInt(), + items: (json['items'] as List?) + ?.map((e) => CustomerOrderItemDto.fromJson(e as Map)) + .toList(), + payments: (json['payments'] as List?) + ?.map( + (e) => CustomerOrderPaymentDto.fromJson(e as Map), + ) + .toList(), + ); + +Map _$CustomerOrderDtoToJson(_CustomerOrderDto instance) => + { + 'id': instance.id, + 'order_number': instance.orderNumber, + 'outlet_name': instance.outletName, + 'order_type': instance.orderType, + 'status': instance.status, + 'payment_status': instance.paymentStatus, + 'total_amount': instance.totalAmount, + 'item_count': instance.itemCount, + 'is_void': instance.isVoid, + 'is_refund': instance.isRefund, + 'points_earned': instance.pointsEarned, + 'coins_earned': instance.coinsEarned, + 'created_at': instance.createdAt, + 'table_number': instance.tableNumber, + 'subtotal': instance.subtotal, + 'discount_amount': instance.discountAmount, + 'tax_amount': instance.taxAmount, + 'refund_amount': instance.refundAmount, + 'items': instance.items, + 'payments': instance.payments, + }; + +_CustomerOrderItemDto _$CustomerOrderItemDtoFromJson( + Map json, +) => _CustomerOrderItemDto( + id: json['id'] as String?, + productName: json['product_name'] as String?, + variantName: json['variant_name'] as String?, + quantity: (json['quantity'] as num?)?.toInt(), + weight: (json['weight'] as num?)?.toDouble(), + unitName: json['unit_name'] as String?, + unitPrice: (json['unit_price'] as num?)?.toInt(), + totalPrice: (json['total_price'] as num?)?.toInt(), + refundQuantity: (json['refund_quantity'] as num?)?.toInt(), +); + +Map _$CustomerOrderItemDtoToJson( + _CustomerOrderItemDto instance, +) => { + 'id': instance.id, + 'product_name': instance.productName, + 'variant_name': instance.variantName, + 'quantity': instance.quantity, + 'weight': instance.weight, + 'unit_name': instance.unitName, + 'unit_price': instance.unitPrice, + 'total_price': instance.totalPrice, + 'refund_quantity': instance.refundQuantity, +}; + +_CustomerOrderPaymentDto _$CustomerOrderPaymentDtoFromJson( + Map json, +) => _CustomerOrderPaymentDto( + id: json['id'] as String?, + methodName: json['method_name'] as String?, + methodType: json['method_type'] as String?, + amount: (json['amount'] as num?)?.toInt(), + refundAmount: (json['refund_amount'] as num?)?.toInt(), + pointsUsed: (json['points_used'] as num?)?.toInt(), +); + +Map _$CustomerOrderPaymentDtoToJson( + _CustomerOrderPaymentDto instance, +) => { + 'id': instance.id, + 'method_name': instance.methodName, + 'method_type': instance.methodType, + 'amount': instance.amount, + 'refund_amount': instance.refundAmount, + 'points_used': instance.pointsUsed, +}; diff --git a/lib/infrastructure/wallet/wallet_response.dart b/lib/infrastructure/wallet/wallet_response.dart new file mode 100644 index 0000000..09dee00 --- /dev/null +++ b/lib/infrastructure/wallet/wallet_response.dart @@ -0,0 +1,93 @@ +import 'package:dio/dio.dart'; + +import '../../domain/wallet/wallet.dart'; + +/// Hitung mundur bawaan bila server menjawab `429` tanpa header `Retry-After`. +const int kDefaultOtpRetrySeconds = 60; + +/// Membaca envelope `{ success, data, errors }`. Mengembalikan `null` bila +/// sukses, atau [WalletFailure] yang sesuai bila gagal. +WalletFailure? parseWalletFailure(Response response) { + if (response.statusCode == 401) return const WalletFailure.unauthorized(); + + final body = response.data; + if (body is! Map) return _failureFromStatus(response); + if (body['success'] == true) return null; + + // Error PIN: `data` berisi `code` dan field tambahan. + final data = body['data']; + if (data is Map) { + final pinFailure = _pinFailure(data['code']?.toString(), data); + if (pinFailure != null) return pinFailure; + } + + final errors = body['errors']; + final first = errors is List && errors.isNotEmpty && errors.first is Map + ? errors.first as Map + : null; + final code = first?['code']?.toString(); + + switch (code) { + case '303': + case '310': + return const WalletFailure.invalidRequest(); + case '304': + return WalletFailure.rejected(first?['cause']?.toString() ?? ''); + case '404': + return const WalletFailure.notFound(); + case '429': + return WalletFailure.tooManyRequests(_retryAfterSeconds(response)); + case '900': + return const WalletFailure.internalError(); + } + + return _pinFailure(code, const {}) ?? _failureFromStatus(response); +} + +/// Isi `data` dari envelope sukses. Beberapa endpoint (mis. `/wallet`) +/// membungkus lagi payload-nya dalam `{ status, message, data }`, jadi lapisan +/// itu ikut dikupas. +Map walletDataOf(Response response) { + final data = response.data['data'] as Map; + final isInnerEnvelope = + data.containsKey('status') && + data.containsKey('message') && + data['data'] is Map; + return Map.from(isInnerEnvelope ? data['data'] : data); +} + +WalletFailure? _pinFailure(String? code, Map data) { + switch (code) { + case 'PIN_NOT_SET': + return const WalletFailure.pinNotSet(); + case 'PIN_INVALID': + return WalletFailure.pinInvalid(_toInt(data['remaining_attempts'])); + case 'PIN_LOCKED': + return WalletFailure.pinLocked(_toDateTime(data['locked_until'])); + case 'TRANSFER_BLOCKED': + return WalletFailure.transferBlocked( + _toDateTime(data['transfer_blocked_until']), + ); + } + return null; +} + +WalletFailure _failureFromStatus(Response response) { + final status = response.statusCode ?? 0; + if (status == 404) return const WalletFailure.notFound(); + if (status == 429) { + return WalletFailure.tooManyRequests(_retryAfterSeconds(response)); + } + if (status >= 500) return const WalletFailure.internalError(); + return const WalletFailure.unexpectedError(); +} + +int _retryAfterSeconds(Response response) => + int.tryParse(response.headers.value('retry-after') ?? '') ?? + kDefaultOtpRetrySeconds; + +int? _toInt(Object? value) => + value is int ? value : int.tryParse(value?.toString() ?? ''); + +DateTime? _toDateTime(Object? value) => + value == null ? null : DateTime.tryParse(value.toString()); diff --git a/lib/injection.config.dart b/lib/injection.config.dart index 858c417..00d4a2c 100644 --- a/lib/injection.config.dart +++ b/lib/injection.config.dart @@ -1,5 +1,5 @@ -// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 // ************************************************************************** // InjectableConfigGenerator @@ -9,6 +9,7 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes + import 'package:connectivity_plus/connectivity_plus.dart' as _i895; import 'package:dio/dio.dart' as _i361; import 'package:enaklo/application/auth/auth_bloc.dart' as _i771; @@ -23,22 +24,44 @@ import 'package:enaklo/application/auth/register_form/register_form_bloc.dart' import 'package:enaklo/application/auth/resend_form/resend_form_bloc.dart' as _i627; import 'package:enaklo/application/auth/set_password/set_password_form_bloc.dart' - as _i174; + as _i175; import 'package:enaklo/application/auth/verify_form/verify_form_bloc.dart' as _i521; -import 'package:enaklo/application/customer/customer_point_loader/customer_point_loader_bloc.dart' - as _i497; import 'package:enaklo/application/game/ferris_wheel_loader/ferris_wheel_loader_bloc.dart' as _i1013; +import 'package:enaklo/application/game/game_spin/game_spin_bloc.dart' as _i744; +import 'package:enaklo/application/order/order_detail_loader/order_detail_loader_bloc.dart' + as _i342; +import 'package:enaklo/application/order/order_loader/order_loader_bloc.dart' + as _i554; +import 'package:enaklo/application/outlet/outlet_loader/outlet_loader_bloc.dart' + as _i957; +import 'package:enaklo/application/pin/pin_change_form/pin_change_form_bloc.dart' + as _i538; +import 'package:enaklo/application/pin/pin_setup_form/pin_setup_form_bloc.dart' + as _i390; +import 'package:enaklo/application/wallet/exchange_form/exchange_form_bloc.dart' + as _i691; +import 'package:enaklo/application/wallet/payment_code_form/payment_code_form_bloc.dart' + as _i847; +import 'package:enaklo/application/wallet/transfer_form/transfer_form_bloc.dart' + as _i277; +import 'package:enaklo/application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.dart' + as _i916; +import 'package:enaklo/application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart' + as _i383; +import 'package:enaklo/application/wallet/wallet_loader/wallet_loader_bloc.dart' + as _i40; import 'package:enaklo/common/api/api_client.dart' as _i842; import 'package:enaklo/common/di/di_auto_route.dart' as _i619; import 'package:enaklo/common/di/di_connectivity.dart' as _i644; -import 'package:enaklo/common/di/di_dio.dart' as _i842; +import 'package:enaklo/common/di/di_dio.dart' as _i843; +import 'package:enaklo/common/di/di_secure_storage.dart' as _i525; import 'package:enaklo/common/di/di_shared_preferences.dart' as _i672; import 'package:enaklo/common/network/network_client.dart' as _i109; import 'package:enaklo/domain/auth/auth.dart' as _i995; -import 'package:enaklo/domain/customer/customer.dart' as _i898; import 'package:enaklo/domain/game/game.dart' as _i96; +import 'package:enaklo/domain/wallet/wallet.dart' as _i66; import 'package:enaklo/env.dart' as _i372; import 'package:enaklo/infrastructure/auth/datasources/local_data_provider.dart' as _i1003; @@ -46,15 +69,30 @@ import 'package:enaklo/infrastructure/auth/datasources/remote_data_provider.dart as _i818; import 'package:enaklo/infrastructure/auth/repositories/auth_repository.dart' as _i879; -import 'package:enaklo/infrastructure/customer/datasources/remote_data_provider.dart' - as _i89; -import 'package:enaklo/infrastructure/customer/repositories/customer_repository.dart' - as _i118; import 'package:enaklo/infrastructure/game/datasources/remote_data_provider.dart' as _i143; import 'package:enaklo/infrastructure/game/repositories/game_repository.dart' as _i547; +import 'package:enaklo/infrastructure/wallet/datasources/customer_remote_data_provider.dart' + as _i852; +import 'package:enaklo/infrastructure/wallet/datasources/device_data_provider.dart' + as _i489; +import 'package:enaklo/infrastructure/wallet/datasources/pin_remote_data_provider.dart' + as _i507; +import 'package:enaklo/infrastructure/wallet/datasources/wallet_remote_data_provider.dart' + as _i152; +import 'package:enaklo/infrastructure/wallet/repositories/device_repository.dart' + as _i1022; +import 'package:enaklo/infrastructure/wallet/repositories/order_repository.dart' + as _i453; +import 'package:enaklo/infrastructure/wallet/repositories/outlet_repository.dart' + as _i369; +import 'package:enaklo/infrastructure/wallet/repositories/pin_repository.dart' + as _i846; +import 'package:enaklo/infrastructure/wallet/repositories/wallet_repository.dart' + as _i189; import 'package:enaklo/presentation/router/app_router.dart' as _i698; +import 'package:flutter_secure_storage/flutter_secure_storage.dart' as _i558; import 'package:get_it/get_it.dart' as _i174; import 'package:injectable/injectable.dart' as _i526; import 'package:shared_preferences/shared_preferences.dart' as _i460; @@ -70,41 +108,84 @@ extension GetItInjectableX on _i174.GetIt { }) async { final gh = _i526.GetItHelper(this, environment, environmentFilter); final sharedPreferencesDi = _$SharedPreferencesDi(); - final dioDi = _$DioDi(); final autoRouteDi = _$AutoRouteDi(); final connectivityDi = _$ConnectivityDi(); + final dioDi = _$DioDi(); + final secureStorageDi = _$SecureStorageDi(); await gh.factoryAsync<_i460.SharedPreferences>( () => sharedPreferencesDi.prefs, preResolve: true, ); - gh.lazySingleton<_i361.Dio>(() => dioDi.dio); gh.lazySingleton<_i698.AppRouter>(() => autoRouteDi.appRouter); gh.lazySingleton<_i895.Connectivity>(() => connectivityDi.connectivity); + gh.lazySingleton<_i361.Dio>(() => dioDi.dio); + gh.lazySingleton<_i558.FlutterSecureStorage>( + () => secureStorageDi.secureStorage, + ); + gh.factory<_i372.Env>(() => _i372.DevEnv(), registerFor: {_dev}); gh.lazySingleton<_i109.NetworkClient>( () => _i109.NetworkClient(gh<_i895.Connectivity>()), ); - gh.factory<_i372.Env>(() => _i372.DevEnv(), registerFor: {_dev}); - gh.factory<_i1003.AuthLocalDataProvider>( - () => _i1003.AuthLocalDataProvider(gh<_i460.SharedPreferences>()), + gh.factory<_i489.DeviceLocalDataProvider>( + () => _i489.DeviceLocalDataProvider(gh<_i558.FlutterSecureStorage>()), ); gh.factory<_i372.Env>(() => _i372.ProdEnv(), registerFor: {_prod}); gh.lazySingleton<_i842.ApiClient>( () => _i842.ApiClient(gh<_i361.Dio>(), gh<_i372.Env>()), ); + gh.factory<_i1003.AuthLocalDataProvider>( + () => _i1003.AuthLocalDataProvider(gh<_i460.SharedPreferences>()), + ); gh.factory<_i818.AuthRemoteDataProvider>( () => _i818.AuthRemoteDataProvider(gh<_i842.ApiClient>()), ); gh.factory<_i143.GameRemoteDataProvider>( () => _i143.GameRemoteDataProvider(gh<_i842.ApiClient>()), ); - gh.factory<_i89.CustomerRemoteDataProvider>( - () => _i89.CustomerRemoteDataProvider(gh<_i842.ApiClient>()), + gh.factory<_i852.CustomerRemoteDataProvider>( + () => _i852.CustomerRemoteDataProvider(gh<_i842.ApiClient>()), ); - gh.factory<_i96.IGameRepository>( - () => _i547.GameRepository(gh<_i143.GameRemoteDataProvider>()), + gh.factory<_i489.DeviceRemoteDataProvider>( + () => _i489.DeviceRemoteDataProvider(gh<_i842.ApiClient>()), ); - gh.factory<_i1013.FerrisWheelLoaderBloc>( - () => _i1013.FerrisWheelLoaderBloc(gh<_i96.IGameRepository>()), + gh.factory<_i507.PinRemoteDataProvider>( + () => _i507.PinRemoteDataProvider(gh<_i842.ApiClient>()), + ); + gh.factory<_i152.WalletRemoteDataProvider>( + () => _i152.WalletRemoteDataProvider(gh<_i842.ApiClient>()), + ); + gh.factory<_i66.IPinRepository>( + () => _i846.PinRepository(gh<_i507.PinRemoteDataProvider>()), + ); + gh.factory<_i66.IOutletRepository>( + () => _i369.OutletRepository(gh<_i852.CustomerRemoteDataProvider>()), + ); + gh.factory<_i957.OutletLoaderBloc>( + () => _i957.OutletLoaderBloc(gh<_i66.IOutletRepository>()), + ); + gh.factory<_i66.IWalletRepository>( + () => _i189.WalletRepository(gh<_i152.WalletRemoteDataProvider>()), + ); + gh.factory<_i691.ExchangeFormBloc>( + () => _i691.ExchangeFormBloc(gh<_i66.IWalletRepository>()), + ); + gh.factory<_i847.PaymentCodeFormBloc>( + () => _i847.PaymentCodeFormBloc(gh<_i66.IWalletRepository>()), + ); + gh.factory<_i277.TransferFormBloc>( + () => _i277.TransferFormBloc(gh<_i66.IWalletRepository>()), + ); + gh.factory<_i916.WalletExpiringLoaderBloc>( + () => _i916.WalletExpiringLoaderBloc(gh<_i66.IWalletRepository>()), + ); + gh.factory<_i383.WalletHistoryLoaderBloc>( + () => _i383.WalletHistoryLoaderBloc(gh<_i66.IWalletRepository>()), + ); + gh.factory<_i40.WalletLoaderBloc>( + () => _i40.WalletLoaderBloc(gh<_i66.IWalletRepository>()), + ); + gh.factory<_i66.IOrderRepository>( + () => _i453.OrderRepository(gh<_i852.CustomerRemoteDataProvider>()), ); gh.factory<_i995.IAuthRepository>( () => _i879.AuthRepository( @@ -112,35 +193,59 @@ extension GetItInjectableX on _i174.GetIt { gh<_i1003.AuthLocalDataProvider>(), ), ); - gh.factory<_i627.ResendFormBloc>( - () => _i627.ResendFormBloc(gh<_i995.IAuthRepository>()), - ); - gh.factory<_i174.SetPasswordFormBloc>( - () => _i174.SetPasswordFormBloc(gh<_i995.IAuthRepository>()), - ); - gh.factory<_i260.RegisterFormBloc>( - () => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()), - ); - gh.factory<_i869.CheckPhoneFormBloc>( - () => _i869.CheckPhoneFormBloc(gh<_i995.IAuthRepository>()), - ); - gh.factory<_i771.AuthBloc>( - () => _i771.AuthBloc(gh<_i995.IAuthRepository>()), - ); - gh.factory<_i521.VerifyFormBloc>( - () => _i521.VerifyFormBloc(gh<_i995.IAuthRepository>()), - ); - gh.factory<_i216.LogoutFormBloc>( - () => _i216.LogoutFormBloc(gh<_i995.IAuthRepository>()), - ); - gh.factory<_i898.ICustomerRepository>( - () => _i118.CustomerRepository(gh<_i89.CustomerRemoteDataProvider>()), + gh.factory<_i66.IDeviceRepository>( + () => _i1022.DeviceRepository( + gh<_i489.DeviceLocalDataProvider>(), + gh<_i489.DeviceRemoteDataProvider>(), + ), ); gh.factory<_i510.LoginFormBloc>( () => _i510.LoginFormBloc(gh<_i995.IAuthRepository>()), ); - gh.factory<_i497.CustomerPointLoaderBloc>( - () => _i497.CustomerPointLoaderBloc(gh<_i898.ICustomerRepository>()), + gh.factory<_i96.IGameRepository>( + () => _i547.GameRepository(gh<_i143.GameRemoteDataProvider>()), + ); + gh.factory<_i771.AuthBloc>( + () => _i771.AuthBloc(gh<_i995.IAuthRepository>()), + ); + gh.factory<_i869.CheckPhoneFormBloc>( + () => _i869.CheckPhoneFormBloc(gh<_i995.IAuthRepository>()), + ); + gh.factory<_i260.RegisterFormBloc>( + () => _i260.RegisterFormBloc(gh<_i995.IAuthRepository>()), + ); + gh.factory<_i627.ResendFormBloc>( + () => _i627.ResendFormBloc(gh<_i995.IAuthRepository>()), + ); + gh.factory<_i175.SetPasswordFormBloc>( + () => _i175.SetPasswordFormBloc(gh<_i995.IAuthRepository>()), + ); + gh.factory<_i521.VerifyFormBloc>( + () => _i521.VerifyFormBloc(gh<_i995.IAuthRepository>()), + ); + gh.factory<_i538.PinChangeFormBloc>( + () => _i538.PinChangeFormBloc(gh<_i66.IPinRepository>()), + ); + gh.factory<_i390.PinSetupFormBloc>( + () => _i390.PinSetupFormBloc(gh<_i66.IPinRepository>()), + ); + gh.factory<_i216.LogoutFormBloc>( + () => _i216.LogoutFormBloc( + gh<_i995.IAuthRepository>(), + gh<_i66.IDeviceRepository>(), + ), + ); + gh.factory<_i342.OrderDetailLoaderBloc>( + () => _i342.OrderDetailLoaderBloc(gh<_i66.IOrderRepository>()), + ); + gh.factory<_i554.OrderLoaderBloc>( + () => _i554.OrderLoaderBloc(gh<_i66.IOrderRepository>()), + ); + gh.factory<_i1013.FerrisWheelLoaderBloc>( + () => _i1013.FerrisWheelLoaderBloc(gh<_i96.IGameRepository>()), + ); + gh.factory<_i744.GameSpinBloc>( + () => _i744.GameSpinBloc(gh<_i96.IGameRepository>()), ); return this; } @@ -148,8 +253,10 @@ extension GetItInjectableX on _i174.GetIt { class _$SharedPreferencesDi extends _i672.SharedPreferencesDi {} -class _$DioDi extends _i842.DioDi {} - class _$AutoRouteDi extends _i619.AutoRouteDi {} class _$ConnectivityDi extends _i644.ConnectivityDi {} + +class _$DioDi extends _i843.DioDi {} + +class _$SecureStorageDi extends _i525.SecureStorageDi {} diff --git a/lib/presentation/app_widget.dart b/lib/presentation/app_widget.dart index 049e39a..e9723bf 100644 --- a/lib/presentation/app_widget.dart +++ b/lib/presentation/app_widget.dart @@ -3,7 +3,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../application/auth/auth_bloc.dart'; import '../application/auth/logout_form/logout_form_bloc.dart'; -import '../application/customer/customer_point_loader/customer_point_loader_bloc.dart'; +import '../application/outlet/outlet_loader/outlet_loader_bloc.dart'; +import '../application/wallet/wallet_loader/wallet_loader_bloc.dart'; import '../common/theme/theme.dart'; import '../common/constant/app_constant.dart'; import '../injection.dart'; @@ -26,7 +27,8 @@ class _AppWidgetState extends State { providers: [ BlocProvider(create: (context) => getIt()), BlocProvider(create: (context) => getIt()), - BlocProvider(create: (context) => getIt()), + BlocProvider(create: (context) => getIt()), + BlocProvider(create: (context) => getIt()), ], child: MaterialApp.router( debugShowCheckedModeBanner: false, diff --git a/lib/presentation/components/assets/assets.gen.dart b/lib/presentation/components/assets/assets.gen.dart index 79306ec..e7925b1 100644 --- a/lib/presentation/components/assets/assets.gen.dart +++ b/lib/presentation/components/assets/assets.gen.dart @@ -49,12 +49,60 @@ class $AssetsIconsGen { /// File path: assets/icons/dine_in.png AssetGenImage get dineIn => const AssetGenImage('assets/icons/dine_in.png'); + /// File path: assets/icons/enakcoin_icon.png + AssetGenImage get enakcoinIcon => + const AssetGenImage('assets/icons/enakcoin_icon.png'); + + /// File path: assets/icons/enakcommunity_icon.png + AssetGenImage get enakcommunityIcon => + const AssetGenImage('assets/icons/enakcommunity_icon.png'); + + /// File path: assets/icons/enakgame_icon.png + AssetGenImage get enakgameIcon => + const AssetGenImage('assets/icons/enakgame_icon.png'); + + /// File path: assets/icons/enaknews_icon.png + AssetGenImage get enaknewsIcon => + const AssetGenImage('assets/icons/enaknews_icon.png'); + + /// File path: assets/icons/enakpoint_icon.png + AssetGenImage get enakpointIcon => + const AssetGenImage('assets/icons/enakpoint_icon.png'); + + /// File path: assets/icons/enakpromo_icon.png + AssetGenImage get enakpromoIcon => + const AssetGenImage('assets/icons/enakpromo_icon.png'); + + /// File path: assets/icons/enakreward_icon.png + AssetGenImage get enakrewardIcon => + const AssetGenImage('assets/icons/enakreward_icon.png'); + + /// File path: assets/icons/enakshop_icon.png + AssetGenImage get enakshopIcon => + const AssetGenImage('assets/icons/enakshop_icon.png'); + + /// File path: assets/icons/enaktransfer_icon.png + AssetGenImage get enaktransferIcon => + const AssetGenImage('assets/icons/enaktransfer_icon.png'); + /// File path: assets/icons/takeaway.png AssetGenImage get takeaway => const AssetGenImage('assets/icons/takeaway.png'); /// List of all assets - List get values => [dineIn, takeaway]; + List get values => [ + dineIn, + enakcoinIcon, + enakcommunityIcon, + enakgameIcon, + enaknewsIcon, + enakpointIcon, + enakpromoIcon, + enakrewardIcon, + enakshopIcon, + enaktransferIcon, + takeaway, + ]; } class $AssetsImagesGen { @@ -107,9 +155,7 @@ class $AssetsImagesGen { ]; } -class Assets { - const Assets._(); - +abstract final class Assets { static const $AssetsAudioGen audio = $AssetsAudioGen(); static const $AssetsIconsGen icons = $AssetsIconsGen(); static const $AssetsImagesGen images = $AssetsImagesGen(); diff --git a/lib/presentation/components/assets/fonts.gen.dart b/lib/presentation/components/assets/fonts.gen.dart index 6b60f37..5659b66 100644 --- a/lib/presentation/components/assets/fonts.gen.dart +++ b/lib/presentation/components/assets/fonts.gen.dart @@ -8,9 +8,7 @@ // ignore_for_file: type=lint // ignore_for_file: deprecated_member_use,directives_ordering,implicit_dynamic_list_literal,unnecessary_import -class FontFamily { - FontFamily._(); - +abstract final class FontFamily { /// Font family: Quicksand static const String quicksand = 'Quicksand'; } diff --git a/lib/presentation/components/card/detail_section.dart b/lib/presentation/components/card/detail_section.dart new file mode 100644 index 0000000..b59958f --- /dev/null +++ b/lib/presentation/components/card/detail_section.dart @@ -0,0 +1,74 @@ +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; + +/// Kotak putih berjudul untuk mengelompokkan isi halaman detail. +class DetailSection extends StatelessWidget { + const DetailSection({super.key, this.title, required this.child}); + + final String? title; + final Widget child; + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (title != null) ...[ + Text( + title!, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 12), + ], + child, + ], + ), + ); + } +} + +/// Satu langkah bernomor, mis. untuk "Cara dapat" atau "Cara beli". +class NumberedStep extends StatelessWidget { + const NumberedStep({super.key, required this.number, required this.text}); + + final int number; + final String text; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 22, + height: 22, + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.1), + shape: BoxShape.circle, + ), + child: Text( + '$number', + style: AppStyle.xs.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w800, + ), + ), + ), + const SizedBox(width: 10), + Expanded(child: Text(text, style: AppStyle.md.copyWith(height: 1.4))), + ], + ), + ); + } +} diff --git a/lib/presentation/components/chip/app_filter_chip.dart b/lib/presentation/components/chip/app_filter_chip.dart new file mode 100644 index 0000000..f3ac1a0 --- /dev/null +++ b/lib/presentation/components/chip/app_filter_chip.dart @@ -0,0 +1,75 @@ +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; + +/// Chip filter berbentuk pil, dengan jumlah item di sebelah label bila +/// [count] diisi. +class AppFilterChip extends StatelessWidget { + const AppFilterChip({ + super.key, + required this.label, + this.count, + required this.isSelected, + required this.onTap, + }); + + final String label; + final int? count; + final bool isSelected; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + final foreground = isSelected ? AppColor.textWhite : AppColor.textPrimary; + + return Material( + color: isSelected ? AppColor.primary : AppColor.white, + shape: StadiumBorder( + side: BorderSide( + color: isSelected ? AppColor.primary : AppColor.border, + ), + ), + child: InkWell( + customBorder: const StadiumBorder(), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 14), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + label, + style: AppStyle.sm.copyWith( + color: foreground, + fontWeight: FontWeight.w600, + ), + ), + if (count != null) ...[ + const SizedBox(width: 6), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 6, + vertical: 1, + ), + decoration: BoxDecoration( + color: isSelected + ? AppColor.white.withOpacity(0.2) + : AppColor.primary.withOpacity(0.08), + borderRadius: BorderRadius.circular(10), + ), + child: Text( + '$count', + style: AppStyle.xs.copyWith( + color: isSelected ? AppColor.textWhite : AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ], + ), + ), + ), + ); + } +} diff --git a/lib/presentation/components/delegate/filter_bar_delegate.dart b/lib/presentation/components/delegate/filter_bar_delegate.dart new file mode 100644 index 0000000..8df9dfb --- /dev/null +++ b/lib/presentation/components/delegate/filter_bar_delegate.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; +import '../chip/app_filter_chip.dart'; + +/// Baris [AppFilterChip] yang bisa di-scroll menyamping, untuk +/// [SliverPersistentHeader] yang menempel di atas daftar. +class FilterBarDelegate extends SliverPersistentHeaderDelegate { + FilterBarDelegate({ + required this.values, + required this.selected, + required this.labelOf, + this.countOf, + required this.onSelected, + this.backgroundColor = AppColor.background, + }); + + final List values; + final T selected; + final String Function(T value) labelOf; + + /// Kosongkan bila chip tidak perlu menampilkan jumlah. + final int Function(T value)? countOf; + final ValueChanged onSelected; + final Color backgroundColor; + + static const double _height = 56; + + @override + double get minExtent => _height; + + @override + double get maxExtent => _height; + + @override + Widget build( + BuildContext context, + double shrinkOffset, + bool overlapsContent, + ) { + return Container( + color: backgroundColor, + child: ListView.separated( + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + itemCount: values.length, + separatorBuilder: (_, _) => const SizedBox(width: 8), + itemBuilder: (context, index) { + final value = values[index]; + return AppFilterChip( + label: labelOf(value), + count: countOf?.call(value), + isSelected: value == selected, + onTap: () => onSelected(value), + ); + }, + ), + ); + } + + @override + bool shouldRebuild(covariant FilterBarDelegate oldDelegate) => + oldDelegate.selected != selected || oldDelegate.values != values; +} diff --git a/lib/presentation/components/image/image.dart b/lib/presentation/components/image/image.dart index c61ef77..1c74ffd 100644 --- a/lib/presentation/components/image/image.dart +++ b/lib/presentation/components/image/image.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; import 'dart:math' as math; -import '../../../common/theme/theme.dart'; import '../assets/assets.gen.dart'; part 'image_placeholder.dart'; diff --git a/lib/presentation/components/image/image_placeholder.dart b/lib/presentation/components/image/image_placeholder.dart index ff567ec..5ee3f49 100644 --- a/lib/presentation/components/image/image_placeholder.dart +++ b/lib/presentation/components/image/image_placeholder.dart @@ -22,7 +22,7 @@ class ImagePlaceholder extends StatelessWidget { final containerWidth = width ?? constraints.maxWidth; final containerHeight = height ?? constraints.maxHeight; - // Calculate the minimum dimension to determine if we should show simple or detailed version + // Logo mengikuti sisi terpendek placeholder final minDimension = math.min( containerWidth == double.infinity ? containerHeight : containerWidth, containerHeight == double.infinity ? containerWidth : containerHeight, @@ -42,129 +42,44 @@ class ImagePlaceholder extends StatelessWidget { ) : null, ), - child: Center( - child: minDimension < 150 - ? _buildSimpleVersion(minDimension) - : _buildDetailedVersion(minDimension), - ), + child: Center(child: _buildLogo(context, minDimension)), ); }, ); } - // Simple version for small sizes (< 100px) - Widget _buildSimpleVersion(double size) { - final iconSize = (size * 0.4).clamp(16.0, 32.0); - final fontSize = (size * 0.12).clamp(8.0, 12.0); - - return Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Container( - width: iconSize * 1.5, - height: iconSize * 1.5, - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(iconSize * 0.75), - ), - child: Center( - child: Assets.images.logo.image( - width: iconSize, - height: iconSize, - fit: BoxFit.contain, - ), - ), - ), - if (size > 50) ...[ - SizedBox(height: size * 0.05), - Text( - 'Enaklo', - style: TextStyle( - color: AppColor.primary, - fontSize: fontSize, - fontWeight: FontWeight.bold, - ), - ), - ], - ], - ); - } - - // Detailed version for larger sizes (>= 100px) - Widget _buildDetailedVersion(double minDimension) { - final scaleFactor = minDimension / 200; // Base scale factor - - // Proportional sizes - final illustrationSize = (120 * scaleFactor).clamp(80.0, 120.0); - final illustrationHeight = (160 * scaleFactor).clamp(100.0, 160.0); - final handWidth = (60 * scaleFactor).clamp(30.0, 60.0); - final handHeight = (80 * scaleFactor).clamp(40.0, 80.0); - final cupWidth = (70 * scaleFactor).clamp(35.0, 70.0); - final cupHeight = (90 * scaleFactor).clamp(45.0, 90.0); - final logoSize = (40 * scaleFactor).clamp(20.0, 40.0); - final fontSize = (12 * scaleFactor).clamp(8.0, 12.0); + Widget _buildLogo(BuildContext context, double minDimension) { + final size = (minDimension * 0.6).clamp(28.0, 140.0); + // Aset logo 1024px; decode seukuran tampilan saja. + final cacheSize = (size * 1.2 * MediaQuery.devicePixelRatioOf(context)) + .round(); return Container( - width: illustrationSize, - height: illustrationHeight, + width: size, + height: size, + padding: EdgeInsets.all(size * 0.04), decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.circular(illustrationSize / 2), - ), - child: Stack( - children: [ - // Hand - Positioned( - bottom: illustrationHeight * 0.125, // 20/160 ratio - left: illustrationSize * 0.25, // 30/120 ratio - child: Container( - width: handWidth, - height: handHeight, - decoration: BoxDecoration( - color: const Color(0xFFFFDBB3), - borderRadius: BorderRadius.circular(handWidth / 2), - ), - ), - ), - // Coffee cup - Positioned( - top: illustrationHeight * 0.1875, // 30/160 ratio - left: illustrationSize * 0.208, // 25/120 ratio - child: Container( - width: cupWidth, - height: cupHeight, - decoration: BoxDecoration( - color: const Color(0xFFF4E4BC), - borderRadius: BorderRadius.circular( - math.max(8.0, 10 * scaleFactor), - ), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // Logo - Assets.images.logo.image( - width: logoSize, - height: logoSize, - fit: BoxFit.contain, - ), - SizedBox(height: math.max(4.0, 8 * scaleFactor)), - if (cupHeight > 50) // Only show text if cup is big enough - Text( - 'Enaklo', - style: TextStyle( - color: AppColor.primary, - fontSize: fontSize, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), + shape: BoxShape.circle, + boxShadow: [ + BoxShadow( + color: Colors.black.withOpacity(0.08), + blurRadius: size * 0.1, + offset: Offset(0, size * 0.03), ), ], ), + child: ClipOval( + // Sudut aset logo berlatar gelap; diperbesar sedikit supaya yang + // terlihat hanya lingkaran merahnya. + child: Transform.scale( + scale: 1.2, + child: Assets.images.logo.image( + fit: BoxFit.cover, + cacheWidth: cacheSize, + ), + ), + ), ); } } diff --git a/lib/presentation/pages/auth/pin/pin_page.dart b/lib/presentation/pages/auth/pin/pin_page.dart index c759315..b8d419d 100644 --- a/lib/presentation/pages/auth/pin/pin_page.dart +++ b/lib/presentation/pages/auth/pin/pin_page.dart @@ -106,13 +106,11 @@ class _PinPageState extends State { void _createPin(String pin) { // Add your PIN creation logic here - print('Creating PIN: $pin'); // Navigate to next screen or show success message } void _verifyPin(String pin) { // Add your PIN verification logic here - print('Verifying PIN: $pin'); // Navigate to next screen or show error } diff --git a/lib/presentation/pages/checkout/checkout_page.dart b/lib/presentation/pages/checkout/checkout_page.dart deleted file mode 100644 index 0a274fa..0000000 --- a/lib/presentation/pages/checkout/checkout_page.dart +++ /dev/null @@ -1,225 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:flutter/material.dart'; - -import '../../../common/data/service_data.dart'; -import '../../../common/extension/extension.dart'; -import '../../../common/theme/theme.dart'; -import '../../../sample/product_sample_data.dart'; -import '../../components/border/dashed_border.dart'; -import '../../components/button/button.dart'; -import '../../components/card/service_card.dart'; -import 'widgets/checkout_item.dart'; -import 'widgets/merchant.dart'; - -@RoutePage() -class CheckoutPage extends StatelessWidget { - const CheckoutPage({super.key}); - - @override - Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar(title: Text('Checkout')), - bottomNavigationBar: Container( - padding: EdgeInsets.all(AppValue.padding).copyWith(bottom: 24), - decoration: BoxDecoration( - color: AppColor.white, - boxShadow: [ - BoxShadow( - color: AppColor.black.withOpacity(0.1), - offset: Offset(2, 0), - blurRadius: 10, - ), - ], - ), - child: AppElevatedButton(onPressed: () {}, title: 'Pesan Sekarang'), - ), - body: ListView( - children: [ - Container( - padding: EdgeInsets.all(AppValue.padding), - child: Column( - children: [ - ServiceCard(service: services.first), - SizedBox(height: 16), - CheckoutMerchant(), - ], - ), - ), - Divider(thickness: 4, color: AppColor.borderLight), - Container( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _sectionTitle('Pesananmu'), - SizedBox(height: 16), - CheckoutItem(product: products.first), - CheckoutItem(product: products.first), - Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Ada Tambah lagi?', - style: AppStyle.md.copyWith( - fontWeight: FontWeight.w600, - ), - ), - SizedBox(height: 4), - Text( - 'Kakmu bisa menambah menu lainnya, ya.', - style: AppStyle.md, - ), - ], - ), - ), - SizedBox(width: 12), - AppOutlineButton( - width: 100, - onPressed: () {}, - title: '+ Tambah', - ), - ], - ), - ], - ), - ), - Divider(thickness: 4, color: AppColor.borderLight), - Container( - padding: EdgeInsets.all(AppValue.padding), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _sectionTitle('Voucher'), - SizedBox(height: 16), - Row( - children: [ - Container( - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: AppColor.primary.withOpacity(0.1), - ), - child: Icon( - Icons.confirmation_number, - color: AppColor.primary, - ), - ), - SizedBox(width: 12), - Expanded( - child: Text( - 'Kamu bisa menggunakan voucher mu disini.', - style: AppStyle.md, - ), - ), - Icon(Icons.chevron_right, color: AppColor.textSecondary), - ], - ), - ], - ), - ), - Divider(thickness: 4, color: AppColor.borderLight), - Container( - padding: EdgeInsets.all(AppValue.padding), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _sectionTitle('Metode Pembayaran'), - SizedBox(height: 16), - Row( - children: [ - Container( - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: AppColor.primary.withOpacity(0.1), - ), - child: Icon(Icons.wallet, color: AppColor.primary), - ), - SizedBox(width: 12), - Expanded( - child: Text( - 'Pilih metode pembayaran disini.', - style: AppStyle.md, - ), - ), - Icon(Icons.chevron_right, color: AppColor.textSecondary), - ], - ), - ], - ), - ), - Divider(thickness: 4, color: AppColor.borderLight), - Container( - padding: EdgeInsets.all(AppValue.padding), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _sectionTitle('Rincian Pembayaran'), - SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Harga', - style: AppStyle.md.copyWith(fontWeight: FontWeight.w500), - ), - Text( - "40000".currencyFormatRp, - style: AppStyle.md.copyWith(fontWeight: FontWeight.w500), - ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 12), - child: DashedDivider(), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Total Pembayaran', - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - Text( - "40000".currencyFormatRp, - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - ], - ), - ], - ), - ), - Divider(thickness: 4, color: AppColor.borderLight), - Container( - padding: EdgeInsets.all(AppValue.padding), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Kebijakan Pembatalan", - style: AppStyle.md.copyWith(fontWeight: FontWeight.bold), - ), - SizedBox(height: 4), - Text( - 'Kamu tidak dapat melakukan pembatalan atau perubahan apapun pada pesanan setelah melakukan pembayaran.', - style: AppStyle.sm, - ), - ], - ), - ), - SizedBox(height: 40), - ], - ), - ); - } - - Text _sectionTitle(String title) { - return Text( - title, - style: AppStyle.xl.copyWith(fontWeight: FontWeight.bold), - ); - } -} diff --git a/lib/presentation/pages/checkout/widgets/checkout_item.dart b/lib/presentation/pages/checkout/widgets/checkout_item.dart deleted file mode 100644 index be3dbab..0000000 --- a/lib/presentation/pages/checkout/widgets/checkout_item.dart +++ /dev/null @@ -1,68 +0,0 @@ -import 'package:flutter/material.dart'; - -import '../../../../common/extension/extension.dart'; -import '../../../../common/theme/theme.dart'; -import '../../../../sample/product_sample_data.dart'; -import '../../../components/button/button.dart'; -import '../../../components/image/image.dart'; - -class CheckoutItem extends StatelessWidget { - final Product product; - const CheckoutItem({super.key, required this.product}); - - @override - Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(bottom: 16), - decoration: BoxDecoration(), - child: Column( - children: [ - Row( - children: [ - AppNetworkImage(url: product.imageUrl, width: 60, height: 60), - SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - product.name, - style: AppStyle.md.copyWith(fontWeight: FontWeight.bold), - ), - SizedBox(height: 4), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "1x ${product.price.currencyFormatRp}", - style: AppStyle.md, - ), - Text("27000".currencyFormatRp, style: AppStyle.md), - ], - ), - ], - ), - ), - ], - ), - SizedBox(height: 8), - Row( - children: [ - Expanded( - child: Text( - 'Catatan', - style: AppStyle.md.copyWith( - color: AppColor.textSecondary, - fontWeight: FontWeight.w600, - ), - ), - ), - SizedBox(width: 12), - QtyButton(), - ], - ), - ], - ), - ); - } -} diff --git a/lib/presentation/pages/checkout/widgets/merchant.dart b/lib/presentation/pages/checkout/widgets/merchant.dart deleted file mode 100644 index 0da9195..0000000 --- a/lib/presentation/pages/checkout/widgets/merchant.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:flutter/material.dart'; - -import '../../../../common/constant/app_constant.dart'; -import '../../../../common/theme/theme.dart'; - -class CheckoutMerchant extends StatelessWidget { - const CheckoutMerchant({super.key}); - - @override - Widget build(BuildContext context) { - return Row( - children: [ - Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: AppColor.surface, - borderRadius: BorderRadius.circular(12), - ), - child: Center( - child: ClipRRect( - borderRadius: BorderRadius.circular(12), - child: Image.asset(merchant.imageUrl), - ), - ), - ), - SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - merchant.name, - style: AppStyle.h6.copyWith(fontWeight: FontWeight.bold), - ), - Text(merchant.category, style: AppStyle.md.copyWith()), - Row(children: [SizedBox(width: 12)]), - ], - ), - ), - ], - ); - } -} diff --git a/lib/presentation/pages/coin/coin_page.dart b/lib/presentation/pages/coin/coin_page.dart index c725073..07e1642 100644 --- a/lib/presentation/pages/coin/coin_page.dart +++ b/lib/presentation/pages/coin/coin_page.dart @@ -2,7 +2,7 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import '../../../application/customer/customer_point_loader/customer_point_loader_bloc.dart'; +import '../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; import '../../../common/theme/theme.dart'; import '../../router/app_router.gr.dart'; @@ -203,9 +203,7 @@ class _CoinPageState extends State { super.initState(); activeCategoryId = categories.first.id; // Set first category as active _initializeCategoryKeys(); - context.read().add( - CustomerPointLoaderEvent.fetched(), - ); + context.read().add(const WalletLoaderEvent.fetched()); } void _initializeCategoryKeys() { @@ -309,7 +307,7 @@ class _CoinPageState extends State { } Widget _buildPointCard() { - return BlocBuilder( + return BlocBuilder( builder: (context, state) { return Container( margin: EdgeInsets.all(16), @@ -347,14 +345,14 @@ class _CoinPageState extends State { // ), // SizedBox(height: 4), Text( - "${state.customerPoint.totalPoints}", + "${state.summary.pointBalance}", style: AppStyle.h2.copyWith( color: AppColor.textWhite, fontWeight: FontWeight.w700, ), ), Text( - "Poin Tersedia", + "EnakPoint Tersedia", style: AppStyle.sm.copyWith( color: AppColor.textWhite.withOpacity(0.9), ), diff --git a/lib/presentation/pages/coming_soon/coming_soon_page.dart b/lib/presentation/pages/coming_soon/coming_soon_page.dart new file mode 100644 index 0000000..61b5af6 --- /dev/null +++ b/lib/presentation/pages/coming_soon/coming_soon_page.dart @@ -0,0 +1,58 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; +import '../../components/button/button.dart'; + +/// Halaman sementara untuk fitur yang belum tersedia. +@RoutePage() +class ComingSoonPage extends StatelessWidget { + const ComingSoonPage({super.key, required this.title, this.iconPath}); + + final String title; + + /// Path aset ikon fitur, mis. `Assets.icons.enakshopIcon.path`. + final String? iconPath; + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(title: Text(title)), + body: SafeArea( + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + children: [ + const Spacer(), + if (iconPath != null) + Image.asset(iconPath!, width: 160, height: 160) + else + const Icon( + Icons.hourglass_empty, + size: 96, + color: AppColor.primary, + ), + const SizedBox(height: 24), + Text( + 'Segera Hadir', + style: AppStyle.h5.copyWith(fontWeight: FontWeight.w700), + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Text( + '$title sedang kami siapkan. Nantikan kehadirannya, ya!', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + textAlign: TextAlign.center, + ), + const Spacer(), + AppElevatedButton( + title: 'Kembali', + onPressed: () => context.router.maybePop(), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/community/community_page.dart b/lib/presentation/pages/community/community_page.dart new file mode 100644 index 0000000..e9d92b9 --- /dev/null +++ b/lib/presentation/pages/community/community_page.dart @@ -0,0 +1,510 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../sample/community_sample_data.dart'; +import '../../components/assets/assets.gen.dart'; +import '../../components/toast/flushbar.dart'; +import '../../router/app_router.gr.dart'; +import 'community_ui.dart'; +import 'widgets/community_compose_sheet.dart'; +import 'widgets/community_event_card.dart'; +import 'widgets/community_group_card.dart'; +import 'widgets/community_post_card.dart'; + +enum _CommunityTab { forYou, groups, events } + +@RoutePage() +class CommunityPage extends StatefulWidget { + const CommunityPage({super.key}); + + @override + State createState() => _CommunityPageState(); +} + +class _CommunityPageState extends State { + final List _posts = [...communityPosts]; + final Set _goingEventIds = {}; + _CommunityTab _tab = _CommunityTab.forYou; + + void _openGroup(CommunityGroup group) => + context.router.push(CommunityDetailRoute(group: group)); + + void _openPost(CommunityPost post) => + context.router.push(CommunityPostDetailRoute(post: post)); + + Future _compose() async { + final joined = communityGroups + .where((g) => joinedCommunityIds.value.contains(g.id)) + .toList(); + if (joined.isEmpty) { + AppFlushbar.showError(context, 'Gabung komunitas dulu untuk posting'); + setState(() => _tab = _CommunityTab.groups); + return; + } + + final post = await CommunityComposeSheet.show(context, groups: joined); + if (post == null || !mounted) return; + + setState(() { + _posts.insert(0, post); + _tab = _CommunityTab.forYou; + }); + AppFlushbar.showSuccess(context, 'Postingan kamu sudah terbit'); + } + + void _toggleEvent(CommunityEvent event) { + final going = !_goingEventIds.contains(event.id); + setState(() { + going ? _goingEventIds.add(event.id) : _goingEventIds.remove(event.id); + }); + if (going) { + AppFlushbar.showSuccess(context, 'Kamu terdaftar di ${event.title}'); + } + } + + @override + Widget build(BuildContext context) { + return ValueListenableBuilder>( + valueListenable: joinedCommunityIds, + builder: (context, joinedIds, _) { + return Scaffold( + backgroundColor: CommunityColor.background, + floatingActionButton: AnimatedScale( + scale: _tab == _CommunityTab.events ? 0 : 1, + duration: const Duration(milliseconds: 200), + child: FloatingActionButton.extended( + onPressed: _compose, + elevation: 2, + backgroundColor: AppColor.primary, + foregroundColor: AppColor.white, + shape: const StadiumBorder(), + icon: const Icon(Icons.edit_rounded, size: 20), + label: Text( + 'Tulis', + style: AppStyle.md.copyWith( + color: AppColor.white, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + body: CustomScrollView( + slivers: [ + SliverAppBar( + pinned: true, + automaticallyImplyLeading: false, + backgroundColor: CommunityColor.background, + title: const Text('EnakCommunity'), + actions: [ + IconButton( + onPressed: () => + context.router.push(const NotificationRoute()), + icon: const Icon( + Icons.notifications_none_rounded, + color: AppColor.textPrimary, + ), + ), + const SizedBox(width: 4), + ], + ), + SliverToBoxAdapter(child: _buildHero(joinedIds.length)), + SliverPersistentHeader( + pinned: true, + delegate: _TabHeaderDelegate( + selected: _tab, + onChanged: (tab) => setState(() => _tab = tab), + ), + ), + ...switch (_tab) { + _CommunityTab.forYou => _buildForYou(joinedIds), + _CommunityTab.groups => _buildGroups(joinedIds), + _CommunityTab.events => _buildEvents(), + }, + const SliverToBoxAdapter(child: SizedBox(height: 96)), + ], + ), + ); + }, + ); + } + + Widget _buildHero(int joinedCount) { + final myPostCount = _posts + .where((p) => p.author.id == currentMember.id) + .length; + + return Container( + margin: const EdgeInsets.fromLTRB(16, 4, 16, 8), + padding: const EdgeInsets.fromLTRB(20, 20, 16, 16), + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: [CommunityColor.blush, Color(0xFFFFF6EE)], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(28), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Halo, Foodie! 👋', + style: AppStyle.xxl.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text( + 'Berbagi cerita kuliner, ikut event seru, dan temukan ' + 'teman makan baru.', + style: AppStyle.sm.copyWith( + height: 1.45, + color: AppColor.textSecondary, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + const SizedBox(width: 8), + Assets.icons.enakcommunityIcon.image(width: 72, height: 72), + ], + ), + const SizedBox(height: 14), + Row( + children: [ + _HeroStat(value: '$joinedCount', label: 'Komunitas'), + const SizedBox(width: 8), + _HeroStat(value: '$myPostCount', label: 'Postingan'), + const SizedBox(width: 8), + _HeroStat(value: '${_goingEventIds.length}', label: 'Event'), + ], + ), + const SizedBox(height: 14), + Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(999), + child: InkWell( + borderRadius: BorderRadius.circular(999), + onTap: _compose, + child: Padding( + padding: const EdgeInsets.fromLTRB(6, 6, 16, 6), + child: Row( + children: [ + const CommunityAvatar(member: currentMember, size: 32), + const SizedBox(width: 10), + Expanded( + child: Text( + 'Apa yang kamu makan hari ini?', + style: AppStyle.sm.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w600, + ), + ), + ), + const Icon( + Icons.edit_note_rounded, + color: AppColor.primary, + ), + ], + ), + ), + ), + ), + ], + ), + ); + } + + List _buildForYou(Set joinedIds) { + return [ + SliverToBoxAdapter( + child: CommunitySectionTitle( + title: 'Komunitas Populer', + actionLabel: 'Lihat semua', + onAction: () => setState(() => _tab = _CommunityTab.groups), + ), + ), + SliverToBoxAdapter( + child: SizedBox( + height: 176, + child: ListView.separated( + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.symmetric(horizontal: 16), + itemCount: communityGroups.length, + separatorBuilder: (_, _) => const SizedBox(width: 12), + itemBuilder: (context, index) { + final group = communityGroups[index]; + return CommunityGroupCard( + group: group, + isJoined: joinedIds.contains(group.id), + onTap: () => _openGroup(group), + onJoin: () => toggleJoinCommunity(group.id), + ); + }, + ), + ), + ), + const SliverToBoxAdapter( + child: CommunitySectionTitle(title: 'Obrolan Terbaru'), + ), + SliverList.builder( + itemCount: _posts.length, + itemBuilder: (context, index) { + final post = _posts[index]; + return CommunityPostCard( + key: ValueKey(post.id), + post: post, + onTap: () => _openPost(post), + onGroupTap: () => _openGroup(post.group), + ); + }, + ), + ]; + } + + List _buildGroups(Set joinedIds) { + final joined = communityGroups + .where((g) => joinedIds.contains(g.id)) + .toList(); + final discover = communityGroups + .where((g) => !joinedIds.contains(g.id)) + .toList(); + + Widget tile(CommunityGroup group) => CommunityGroupTile( + key: ValueKey(group.id), + group: group, + isJoined: joinedIds.contains(group.id), + onTap: () => _openGroup(group), + onJoin: () => toggleJoinCommunity(group.id), + ); + + return [ + const SliverToBoxAdapter( + child: CommunitySectionTitle(title: 'Komunitas Saya'), + ), + if (joined.isEmpty) + const SliverToBoxAdapter( + child: _SoftEmpty( + emoji: '🤝', + title: 'Belum gabung komunitas', + message: 'Pilih komunitas di bawah yang sesuai seleramu.', + ), + ) + else + SliverList.list(children: joined.map(tile).toList()), + if (discover.isNotEmpty) ...[ + const SliverToBoxAdapter( + child: CommunitySectionTitle(title: 'Jelajahi Komunitas'), + ), + SliverList.list(children: discover.map(tile).toList()), + ], + ]; + } + + List _buildEvents() { + return [ + SliverToBoxAdapter( + child: Container( + margin: const EdgeInsets.fromLTRB(16, 16, 16, 16), + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: const Color(0xFFFFF8E1), + borderRadius: BorderRadius.circular(18), + ), + child: Row( + children: [ + const Text('🎁', style: TextStyle(fontSize: 24)), + const SizedBox(width: 12), + Expanded( + child: Text( + 'Hadiri event komunitas dan kumpulkan EnakPoint & EnakCoin ' + 'tambahan!', + style: AppStyle.sm.copyWith( + height: 1.4, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ), + ), + SliverList.builder( + itemCount: communityEvents.length, + itemBuilder: (context, index) { + final event = communityEvents[index]; + return CommunityEventCard( + event: event, + isGoing: _goingEventIds.contains(event.id), + onToggle: () => _toggleEvent(event), + ); + }, + ), + ]; + } +} + +class _HeroStat extends StatelessWidget { + const _HeroStat({required this.value, required this.label}); + + final String value; + final String label; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + decoration: BoxDecoration( + color: AppColor.white.withOpacity(0.7), + borderRadius: BorderRadius.circular(999), + ), + child: Text.rich( + TextSpan( + children: [ + TextSpan( + text: '$value ', + style: const TextStyle( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + TextSpan(text: label), + ], + ), + style: AppStyle.xs.copyWith(fontWeight: FontWeight.w600), + ), + ); + } +} + +class _SoftEmpty extends StatelessWidget { + const _SoftEmpty({ + required this.emoji, + required this.title, + required this.message, + }); + + final String emoji; + final String title; + final String message; + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 24), + decoration: communityCardDecoration(), + child: Column( + children: [ + Text(emoji, style: const TextStyle(fontSize: 32)), + const SizedBox(height: 8), + Text(title, style: AppStyle.md.copyWith(fontWeight: FontWeight.w700)), + const SizedBox(height: 4), + Text( + message, + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: CommunityColor.muted), + ), + ], + ), + ); + } +} + +/// Tab bergaya pil lembut yang menempel saat di-scroll. +class _TabHeaderDelegate extends SliverPersistentHeaderDelegate { + _TabHeaderDelegate({required this.selected, required this.onChanged}); + + final _CommunityTab selected; + final ValueChanged<_CommunityTab> onChanged; + + static const double _height = 64; + static const _labels = { + _CommunityTab.forYou: 'Untukmu', + _CommunityTab.groups: 'Komunitas', + _CommunityTab.events: 'Event', + }; + + @override + double get minExtent => _height; + + @override + double get maxExtent => _height; + + @override + Widget build( + BuildContext context, + double shrinkOffset, + bool overlapsContent, + ) { + const tabs = _CommunityTab.values; + final index = tabs.indexOf(selected); + + return Container( + color: CommunityColor.background, + padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), + child: Container( + padding: const EdgeInsets.all(4), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(999), + boxShadow: communitySoftShadow, + ), + child: Stack( + children: [ + AnimatedAlign( + duration: const Duration(milliseconds: 250), + curve: Curves.easeOutCubic, + alignment: Alignment(-1 + 2 * index / (tabs.length - 1), 0), + child: FractionallySizedBox( + widthFactor: 1 / tabs.length, + heightFactor: 1, + child: Container( + decoration: BoxDecoration( + color: CommunityColor.blush, + borderRadius: BorderRadius.circular(999), + ), + ), + ), + ), + Row( + children: tabs.map((tab) { + final isSelected = tab == selected; + return Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () => onChanged(tab), + child: Center( + child: Text( + _labels[tab]!, + style: AppStyle.sm.copyWith( + color: isSelected + ? AppColor.primary + : CommunityColor.muted, + fontWeight: isSelected + ? FontWeight.w700 + : FontWeight.w600, + ), + ), + ), + ), + ); + }).toList(), + ), + ], + ), + ), + ); + } + + @override + bool shouldRebuild(_TabHeaderDelegate oldDelegate) => + oldDelegate.selected != selected; +} diff --git a/lib/presentation/pages/community/community_ui.dart b/lib/presentation/pages/community/community_ui.dart new file mode 100644 index 0000000..efe383b --- /dev/null +++ b/lib/presentation/pages/community/community_ui.dart @@ -0,0 +1,262 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../sample/community_sample_data.dart'; + +/// Palet lembut khusus EnakCommunity. +class CommunityColor { + static const Color background = Color(0xFFFAF7F5); + static const Color blush = Color(0xFFFFEEEC); + static const Color blushDeep = Color(0xFFFFDCD7); + static const Color divider = Color(0xFFF1ECE9); + static const Color muted = Color(0xFF9A918D); + + /// Pasangan (latar, aksen) untuk komunitas & avatar. + static const List<(Color, Color)> tints = [ + (Color(0xFFFFF1E6), Color(0xFFE07A3F)), // peach + (Color(0xFFF1ECE4), Color(0xFF8A6A4F)), // latte + (Color(0xFFEAF3FC), Color(0xFF4A86C5)), // sky + (Color(0xFFFFEEEC), Color(0xFFD14B4B)), // blush + (Color(0xFFE9F7EF), Color(0xFF3F9A67)), // mint + (Color(0xFFF1EDFB), Color(0xFF7D63C9)), // lavender + ]; + + static (Color, Color) tintOf(int index) => tints[index % tints.length]; +} + +/// Komunitas yang diikuti, dibagi antar layar. Sementara di memori sampai +/// API komunitas tersedia. +final ValueNotifier> joinedCommunityIds = ValueNotifier({ + for (final group in communityGroups) + if (group.isJoined) group.id, +}); + +void toggleJoinCommunity(String groupId) { + final ids = {...joinedCommunityIds.value}; + if (!ids.remove(groupId)) ids.add(groupId); + joinedCommunityIds.value = ids; +} + +/// Bayangan tipis agar kartu tampak "mengambang" tanpa garis tepi. +const List communitySoftShadow = [ + BoxShadow(color: Color(0x0D3B2A24), blurRadius: 24, offset: Offset(0, 8)), +]; + +BoxDecoration communityCardDecoration({double radius = 20}) => BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(radius), + boxShadow: communitySoftShadow, +); + +/// "Baru saja", "5 mnt", "3 jam", "2 hari", lalu tanggal pendek. +String formatTimeAgo(DateTime time) { + final diff = DateTime.now().difference(time); + if (diff.inMinutes < 1) return 'Baru saja'; + if (diff.inHours < 1) return '${diff.inMinutes} mnt'; + if (diff.inDays < 1) return '${diff.inHours} jam'; + if (diff.inDays < 7) return '${diff.inDays} hari'; + return DateFormat('d MMM', 'id_ID').format(time); +} + +/// 950 → "950", 12480 → "12,4rb". +String formatCompact(int value) { + if (value < 1000) return '$value'; + if (value < 1000000) { + return '${NumberFormat('0.#', 'id_ID').format(value / 1000)}rb'; + } + return '${NumberFormat('0.#', 'id_ID').format(value / 1000000)}jt'; +} + +/// Avatar inisial dengan warna lembut yang konsisten per anggota. +class CommunityAvatar extends StatelessWidget { + const CommunityAvatar({super.key, required this.member, this.size = 40}); + + final CommunityMember member; + final double size; + + @override + Widget build(BuildContext context) { + final (background, accent) = CommunityColor.tintOf( + member.id.codeUnits.fold(0, (sum, c) => sum + c), + ); + + return Container( + width: size, + height: size, + alignment: Alignment.center, + decoration: BoxDecoration(color: background, shape: BoxShape.circle), + child: Text( + member.initials, + style: AppStyle.md.copyWith( + fontSize: size * 0.36, + color: accent, + fontWeight: FontWeight.w700, + ), + ), + ); + } +} + +/// Deretan avatar bertumpuk, mis. peserta event. +class CommunityAvatarStack extends StatelessWidget { + const CommunityAvatarStack({ + super.key, + required this.members, + this.size = 26, + this.max = 3, + }); + + final List members; + final double size; + final int max; + + @override + Widget build(BuildContext context) { + final shown = members.take(max).toList(); + final overlap = size * 0.65; + + return SizedBox( + width: size + overlap * (shown.length - 1), + height: size, + child: Stack( + children: [ + for (var i = 0; i < shown.length; i++) + Positioned( + left: overlap * i, + child: Container( + padding: const EdgeInsets.all(1.5), + decoration: const BoxDecoration( + color: AppColor.white, + shape: BoxShape.circle, + ), + child: CommunityAvatar(member: shown[i], size: size - 3), + ), + ), + ], + ), + ); + } +} + +/// Emoji komunitas di atas kotak berwarna lembut. +class CommunityEmojiBadge extends StatelessWidget { + const CommunityEmojiBadge({super.key, required this.group, this.size = 44}); + + final CommunityGroup group; + final double size; + + @override + Widget build(BuildContext context) { + final (background, _) = CommunityColor.tintOf(group.tint); + + return Container( + width: size, + height: size, + alignment: Alignment.center, + decoration: BoxDecoration( + color: background, + borderRadius: BorderRadius.circular(size * 0.32), + ), + child: Text(group.emoji, style: TextStyle(fontSize: size * 0.48)), + ); + } +} + +/// Tombol pil "Gabung" / "Tergabung". +class CommunityJoinButton extends StatelessWidget { + const CommunityJoinButton({ + super.key, + required this.isJoined, + required this.onPressed, + this.compact = false, + }); + + final bool isJoined; + final VoidCallback onPressed; + final bool compact; + + @override + Widget build(BuildContext context) { + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + decoration: BoxDecoration( + color: isJoined ? CommunityColor.blush : AppColor.primary, + borderRadius: BorderRadius.circular(999), + ), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(999), + onTap: onPressed, + child: Padding( + padding: EdgeInsets.symmetric( + horizontal: compact ? 12 : 16, + vertical: compact ? 6 : 8, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + isJoined ? Icons.check_rounded : Icons.add_rounded, + size: compact ? 14 : 16, + color: isJoined ? AppColor.primary : AppColor.white, + ), + const SizedBox(width: 4), + Text( + isJoined ? 'Tergabung' : 'Gabung', + style: (compact ? AppStyle.xs : AppStyle.sm).copyWith( + color: isJoined ? AppColor.primary : AppColor.white, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +/// Judul seksi dengan aksi opsional di kanan. +class CommunitySectionTitle extends StatelessWidget { + const CommunitySectionTitle({ + super.key, + required this.title, + this.actionLabel, + this.onAction, + }); + + final String title; + final String? actionLabel; + final VoidCallback? onAction; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.fromLTRB(20, 20, 12, 10), + child: Row( + children: [ + Expanded( + child: Text( + title, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + if (actionLabel != null) + TextButton( + onPressed: onAction, + child: Text( + actionLabel!, + style: AppStyle.sm.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/community/pages/community_detail/community_detail_page.dart b/lib/presentation/pages/community/pages/community_detail/community_detail_page.dart new file mode 100644 index 0000000..0f2d9d0 --- /dev/null +++ b/lib/presentation/pages/community/pages/community_detail/community_detail_page.dart @@ -0,0 +1,424 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../../../common/theme/theme.dart'; +import '../../../../../sample/community_sample_data.dart'; +import '../../../../components/toast/flushbar.dart'; +import '../../../../router/app_router.gr.dart'; +import '../../community_ui.dart'; +import '../../widgets/community_compose_sheet.dart'; +import '../../widgets/community_post_card.dart'; + +@RoutePage() +class CommunityDetailPage extends StatefulWidget { + const CommunityDetailPage({super.key, required this.group}); + + final CommunityGroup group; + + @override + State createState() => _CommunityDetailPageState(); +} + +class _CommunityDetailPageState extends State { + static const double _expandedHeight = 220; + + final _scrollController = ScrollController(); + late final List _posts = communityPosts + .where((post) => post.group.id == widget.group.id) + .toList(); + bool _isCollapsed = false; + bool _isNotifyOn = true; + + @override + void initState() { + super.initState(); + _scrollController.addListener(() { + final collapsed = + _scrollController.offset > _expandedHeight - kToolbarHeight - 20; + if (collapsed != _isCollapsed) setState(() => _isCollapsed = collapsed); + }); + } + + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + + bool get _isJoined => joinedCommunityIds.value.contains(widget.group.id); + + Future _compose() async { + if (!_isJoined) { + AppFlushbar.showError(context, 'Gabung komunitas dulu untuk posting'); + return; + } + + final post = await CommunityComposeSheet.show( + context, + groups: [widget.group], + ); + if (post == null || !mounted) return; + + setState(() => _posts.insert(0, post)); + AppFlushbar.showSuccess(context, 'Postingan kamu sudah terbit'); + } + + @override + Widget build(BuildContext context) { + final group = widget.group; + + return ValueListenableBuilder>( + valueListenable: joinedCommunityIds, + builder: (context, joinedIds, _) { + final isJoined = joinedIds.contains(group.id); + + return Scaffold( + backgroundColor: CommunityColor.background, + floatingActionButton: isJoined + ? FloatingActionButton.extended( + onPressed: _compose, + elevation: 2, + backgroundColor: AppColor.primary, + foregroundColor: AppColor.white, + shape: const StadiumBorder(), + icon: const Icon(Icons.edit_rounded, size: 20), + label: Text( + 'Tulis', + style: AppStyle.md.copyWith( + color: AppColor.white, + fontWeight: FontWeight.w700, + ), + ), + ) + : null, + body: CustomScrollView( + controller: _scrollController, + slivers: [ + _buildAppBar(group), + SliverToBoxAdapter(child: _buildInfo(group, isJoined)), + SliverToBoxAdapter(child: _buildStats(group)), + const SliverToBoxAdapter( + child: CommunitySectionTitle(title: 'Postingan Terbaru'), + ), + if (_posts.isEmpty) + SliverToBoxAdapter(child: _buildEmpty()) + else + SliverList.builder( + itemCount: _posts.length, + itemBuilder: (context, index) { + final post = _posts[index]; + return CommunityPostCard( + key: ValueKey(post.id), + post: post, + onTap: () => context.router.push( + CommunityPostDetailRoute(post: post), + ), + ); + }, + ), + const SliverToBoxAdapter(child: SizedBox(height: 96)), + ], + ), + ); + }, + ); + } + + Widget _buildAppBar(CommunityGroup group) { + return SliverAppBar( + pinned: true, + expandedHeight: _expandedHeight, + backgroundColor: CommunityColor.background, + automaticallyImplyLeading: false, + leading: Padding( + padding: const EdgeInsets.only(left: 12), + child: _CircleButton( + icon: Icons.arrow_back_rounded, + onTap: () => context.router.maybePop(), + ), + ), + leadingWidth: 60, + title: AnimatedOpacity( + opacity: _isCollapsed ? 1 : 0, + duration: const Duration(milliseconds: 200), + child: Text(group.name), + ), + actions: [ + _CircleButton(icon: Icons.ios_share_rounded, onTap: () {}), + const SizedBox(width: 12), + ], + flexibleSpace: FlexibleSpaceBar( + background: Stack( + fit: StackFit.expand, + children: [ + Image.asset(group.coverImage, fit: BoxFit.cover), + DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + AppColor.black.withOpacity(0.25), + Colors.transparent, + ], + ), + ), + ), + ], + ), + ), + // Lengkungan "sheet" di atas foto sampul. + bottom: PreferredSize( + preferredSize: const Size.fromHeight(24), + child: Container( + height: 24, + decoration: const BoxDecoration( + color: CommunityColor.background, + borderRadius: BorderRadius.vertical(top: Radius.circular(28)), + ), + ), + ), + ); + } + + Widget _buildInfo(CommunityGroup group, bool isJoined) { + return Padding( + padding: const EdgeInsets.fromLTRB(20, 0, 20, 0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + CommunityEmojiBadge(group: group, size: 60), + const SizedBox(width: 14), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + group.name, + style: AppStyle.xxl.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 2), + Text( + 'Komunitas publik · ${formatCompact(group.memberCount)} anggota', + style: AppStyle.sm.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 14), + Text( + group.description, + style: AppStyle.md.copyWith( + height: 1.5, + color: AppColor.textSecondary, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 12), + Wrap( + spacing: 8, + runSpacing: 8, + children: group.tags.map((tag) { + final (background, accent) = CommunityColor.tintOf(group.tint); + return Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 6, + ), + decoration: BoxDecoration( + color: background, + borderRadius: BorderRadius.circular(999), + ), + child: Text( + '#$tag', + style: AppStyle.xs.copyWith( + color: accent, + fontWeight: FontWeight.w700, + ), + ), + ); + }).toList(), + ), + const SizedBox(height: 18), + Row( + children: [ + Expanded( + child: SizedBox( + height: 48, + child: _JoinBlockButton( + isJoined: isJoined, + onTap: () => toggleJoinCommunity(group.id), + ), + ), + ), + const SizedBox(width: 10), + Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + child: InkWell( + borderRadius: BorderRadius.circular(16), + onTap: () => setState(() => _isNotifyOn = !_isNotifyOn), + child: SizedBox( + width: 48, + height: 48, + child: Icon( + _isNotifyOn + ? Icons.notifications_active_rounded + : Icons.notifications_off_outlined, + color: _isNotifyOn + ? AppColor.primary + : CommunityColor.muted, + ), + ), + ), + ), + ], + ), + ], + ), + ); + } + + Widget _buildStats(CommunityGroup group) { + final stats = [ + (formatCompact(group.memberCount), 'Anggota'), + ('${group.postPerDay}', 'Post/hari'), + ( + '${communityEvents.where((e) => e.groupId == group.id).length}', + 'Event', + ), + ]; + + return Container( + margin: const EdgeInsets.fromLTRB(16, 20, 16, 0), + padding: const EdgeInsets.symmetric(vertical: 16), + decoration: communityCardDecoration(), + child: Row( + children: [ + for (var i = 0; i < stats.length; i++) ...[ + if (i > 0) + Container(width: 1, height: 28, color: CommunityColor.divider), + Expanded( + child: Column( + children: [ + Text( + stats[i].$1, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 2), + Text( + stats[i].$2, + style: AppStyle.xs.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ], + ], + ), + ); + } + + Widget _buildEmpty() { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32), + decoration: communityCardDecoration(), + child: Column( + children: [ + const Text('📝', style: TextStyle(fontSize: 36)), + const SizedBox(height: 10), + Text( + 'Belum ada postingan', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 4), + Text( + 'Jadi yang pertama berbagi cerita di komunitas ini.', + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: CommunityColor.muted), + ), + ], + ), + ); + } +} + +class _CircleButton extends StatelessWidget { + const _CircleButton({required this.icon, required this.onTap}); + + final IconData icon; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Center( + child: Material( + color: AppColor.white.withOpacity(0.92), + shape: const CircleBorder(), + child: InkWell( + customBorder: const CircleBorder(), + onTap: onTap, + child: SizedBox( + width: 40, + height: 40, + child: Icon(icon, size: 20, color: AppColor.textPrimary), + ), + ), + ), + ); + } +} + +class _JoinBlockButton extends StatelessWidget { + const _JoinBlockButton({required this.isJoined, required this.onTap}); + + final bool isJoined; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + decoration: BoxDecoration( + color: isJoined ? CommunityColor.blush : AppColor.primary, + borderRadius: BorderRadius.circular(16), + ), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(16), + onTap: onTap, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Icon( + isJoined ? Icons.check_circle_rounded : Icons.group_add_rounded, + size: 20, + color: isJoined ? AppColor.primary : AppColor.white, + ), + const SizedBox(width: 8), + Text( + isJoined ? 'Sudah Bergabung' : 'Gabung Komunitas', + style: AppStyle.md.copyWith( + color: isJoined ? AppColor.primary : AppColor.white, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/community/pages/post_detail/community_post_detail_page.dart b/lib/presentation/pages/community/pages/post_detail/community_post_detail_page.dart new file mode 100644 index 0000000..ad3c473 --- /dev/null +++ b/lib/presentation/pages/community/pages/post_detail/community_post_detail_page.dart @@ -0,0 +1,277 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../../../common/theme/theme.dart'; +import '../../../../../sample/community_sample_data.dart'; +import '../../../../router/app_router.gr.dart'; +import '../../community_ui.dart'; +import '../../widgets/community_post_card.dart'; + +@RoutePage() +class CommunityPostDetailPage extends StatefulWidget { + const CommunityPostDetailPage({super.key, required this.post}); + + final CommunityPost post; + + @override + State createState() => + _CommunityPostDetailPageState(); +} + +class _CommunityPostDetailPageState extends State { + final _controller = TextEditingController(); + final _scrollController = ScrollController(); + late final List _comments = [...communityComments]; + + @override + void initState() { + super.initState(); + _controller.addListener(() => setState(() {})); + } + + @override + void dispose() { + _controller.dispose(); + _scrollController.dispose(); + super.dispose(); + } + + void _send() { + final text = _controller.text.trim(); + if (text.isEmpty) return; + + setState(() { + _comments.add( + CommunityComment( + id: 'local-${DateTime.now().millisecondsSinceEpoch}', + author: currentMember, + content: text, + createdAt: DateTime.now(), + ), + ); + }); + _controller.clear(); + FocusScope.of(context).unfocus(); + + WidgetsBinding.instance.addPostFrameCallback((_) { + if (!_scrollController.hasClients) return; + _scrollController.animateTo( + _scrollController.position.maxScrollExtent, + duration: const Duration(milliseconds: 300), + curve: Curves.easeOut, + ); + }); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: CommunityColor.background, + appBar: AppBar( + backgroundColor: CommunityColor.background, + title: const Text('Postingan'), + ), + body: Column( + children: [ + Expanded( + child: ListView( + controller: _scrollController, + padding: const EdgeInsets.only(top: 8, bottom: 24), + children: [ + CommunityPostCard( + post: widget.post, + expanded: true, + onGroupTap: () => context.router.push( + CommunityDetailRoute(group: widget.post.group), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(20, 6, 20, 12), + child: Text( + 'Komentar (${_comments.length})', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + ..._comments.map((comment) => _CommentTile(comment: comment)), + ], + ), + ), + _buildInputBar(), + ], + ), + ); + } + + Widget _buildInputBar() { + final canSend = _controller.text.trim().isNotEmpty; + + return Container( + padding: const EdgeInsets.fromLTRB(16, 10, 12, 10), + decoration: const BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(24)), + boxShadow: communitySoftShadow, + ), + child: SafeArea( + top: false, + child: Row( + children: [ + const CommunityAvatar(member: currentMember, size: 36), + const SizedBox(width: 10), + Expanded( + child: TextField( + controller: _controller, + minLines: 1, + maxLines: 4, + textCapitalization: TextCapitalization.sentences, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w500), + decoration: InputDecoration( + hintText: 'Tulis komentar...', + isDense: true, + filled: true, + fillColor: CommunityColor.background, + contentPadding: const EdgeInsets.symmetric( + horizontal: 16, + vertical: 12, + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(22), + borderSide: BorderSide.none, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(22), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(22), + borderSide: BorderSide.none, + ), + ), + ), + ), + const SizedBox(width: 8), + AnimatedContainer( + duration: const Duration(milliseconds: 200), + decoration: BoxDecoration( + color: canSend ? AppColor.primary : CommunityColor.blush, + shape: BoxShape.circle, + ), + child: IconButton( + onPressed: canSend ? _send : null, + icon: Icon( + Icons.send_rounded, + size: 20, + color: canSend ? AppColor.white : CommunityColor.blushDeep, + ), + ), + ), + ], + ), + ), + ); + } +} + +class _CommentTile extends StatefulWidget { + const _CommentTile({required this.comment}); + + final CommunityComment comment; + + @override + State<_CommentTile> createState() => _CommentTileState(); +} + +class _CommentTileState extends State<_CommentTile> { + bool _isLiked = false; + + @override + Widget build(BuildContext context) { + final comment = widget.comment; + final likeCount = comment.likeCount + (_isLiked ? 1 : 0); + + return Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 14), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CommunityAvatar(member: comment.author, size: 34), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + padding: const EdgeInsets.fromLTRB(14, 10, 14, 12), + decoration: const BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(4), + topRight: Radius.circular(18), + bottomLeft: Radius.circular(18), + bottomRight: Radius.circular(18), + ), + boxShadow: communitySoftShadow, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + comment.author.name, + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 4), + Text( + comment.content, + style: AppStyle.md.copyWith( + height: 1.45, + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + Padding( + padding: const EdgeInsets.only(left: 6, top: 4), + child: Row( + children: [ + Text( + formatTimeAgo(comment.createdAt), + style: AppStyle.xs.copyWith( + color: CommunityColor.muted, + ), + ), + const SizedBox(width: 16), + GestureDetector( + onTap: () => setState(() => _isLiked = !_isLiked), + child: Text( + likeCount > 0 ? 'Suka · $likeCount' : 'Suka', + style: AppStyle.xs.copyWith( + color: _isLiked + ? AppColor.primary + : CommunityColor.muted, + fontWeight: FontWeight.w700, + ), + ), + ), + const SizedBox(width: 16), + Text( + 'Balas', + style: AppStyle.xs.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + ], + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/community/widgets/community_compose_sheet.dart b/lib/presentation/pages/community/widgets/community_compose_sheet.dart new file mode 100644 index 0000000..5dae6e4 --- /dev/null +++ b/lib/presentation/pages/community/widgets/community_compose_sheet.dart @@ -0,0 +1,314 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/community_sample_data.dart'; +import '../../../../sample/sample_data.dart'; +import '../../../components/button/button.dart'; +import '../../../components/toast/flushbar.dart'; +import '../community_ui.dart'; + +/// Bottom sheet untuk menulis postingan baru. Mengembalikan [CommunityPost] +/// bila dikirim, `null` bila dibatalkan. +class CommunityComposeSheet extends StatefulWidget { + const CommunityComposeSheet({super.key, required this.groups}); + + /// Komunitas tujuan; hanya yang sudah diikuti. + final List groups; + + static Future show( + BuildContext context, { + required List groups, + }) { + return showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: Colors.transparent, + builder: (_) => CommunityComposeSheet(groups: groups), + ); + } + + @override + State createState() => _CommunityComposeSheetState(); +} + +class _CommunityComposeSheetState extends State { + final _controller = TextEditingController(); + late CommunityGroup _group = widget.groups.first; + String? _merchantName; + + @override + void initState() { + super.initState(); + _controller.addListener(() => setState(() {})); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + void _submit() { + Navigator.of(context).pop( + CommunityPost( + id: 'local-${DateTime.now().millisecondsSinceEpoch}', + author: currentMember, + group: _group, + content: _controller.text.trim(), + merchantName: _merchantName, + createdAt: DateTime.now(), + ), + ); + } + + @override + Widget build(BuildContext context) { + final canSubmit = _controller.text.trim().isNotEmpty; + + return Padding( + padding: EdgeInsets.only(bottom: MediaQuery.viewInsetsOf(context).bottom), + child: Container( + decoration: const BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(28)), + ), + child: SafeArea( + top: false, + child: SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(20, 12, 20, 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Center( + child: Container( + width: 40, + height: 4, + decoration: BoxDecoration( + color: CommunityColor.divider, + borderRadius: BorderRadius.circular(999), + ), + ), + ), + const SizedBox(height: 16), + Row( + children: [ + Expanded( + child: Text( + 'Tulis Postingan', + style: AppStyle.xl.copyWith( + fontWeight: FontWeight.w700, + ), + ), + ), + IconButton( + onPressed: () => Navigator.of(context).pop(), + style: IconButton.styleFrom( + backgroundColor: CommunityColor.background, + ), + icon: const Icon( + Icons.close_rounded, + size: 20, + color: CommunityColor.muted, + ), + ), + ], + ), + const SizedBox(height: 12), + _Label('Posting ke'), + SizedBox( + height: 38, + child: ListView.separated( + scrollDirection: Axis.horizontal, + itemCount: widget.groups.length, + separatorBuilder: (_, _) => const SizedBox(width: 8), + itemBuilder: (context, index) { + final group = widget.groups[index]; + return _Chip( + label: '${group.emoji} ${group.name}', + selected: group.id == _group.id, + onTap: () => setState(() => _group = group), + ); + }, + ), + ), + const SizedBox(height: 16), + TextField( + controller: _controller, + autofocus: true, + minLines: 5, + maxLines: 8, + maxLength: 500, + textCapitalization: TextCapitalization.sentences, + style: AppStyle.md.copyWith( + height: 1.5, + fontWeight: FontWeight.w500, + ), + decoration: InputDecoration( + hintText: 'Ceritakan pengalaman kulinermu hari ini...', + filled: true, + fillColor: CommunityColor.background, + contentPadding: const EdgeInsets.all(16), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(18), + borderSide: BorderSide.none, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(18), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(18), + borderSide: const BorderSide( + color: CommunityColor.blushDeep, + width: 1.5, + ), + ), + ), + ), + const SizedBox(height: 8), + _Label('Tandai merchant'), + Wrap( + spacing: 8, + runSpacing: 8, + children: merchants.map((merchant) { + final selected = merchant.name == _merchantName; + return _Chip( + label: merchant.name, + icon: Icons.storefront_rounded, + selected: selected, + onTap: () => setState( + () => _merchantName = selected ? null : merchant.name, + ), + ); + }).toList(), + ), + const SizedBox(height: 20), + Row( + children: [ + _AttachButton( + icon: Icons.photo_library_outlined, + onTap: () => AppFlushbar.showSuccess( + context, + 'Unggah foto segera hadir', + ), + ), + const SizedBox(width: 8), + _AttachButton( + icon: Icons.emoji_emotions_outlined, + onTap: () { + _controller.text = '${_controller.text}😋'; + }, + ), + const SizedBox(width: 12), + Expanded( + child: AppElevatedButton( + title: 'Posting', + height: 48, + onPressed: canSubmit ? _submit : null, + ), + ), + ], + ), + ], + ), + ), + ), + ), + ); + } +} + +class _Label extends StatelessWidget { + const _Label(this.text); + + final String text; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: Text( + text, + style: AppStyle.sm.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w600, + ), + ), + ); + } +} + +class _Chip extends StatelessWidget { + const _Chip({ + required this.label, + required this.selected, + required this.onTap, + this.icon, + }); + + final String label; + final bool selected; + final VoidCallback onTap; + final IconData? icon; + + @override + Widget build(BuildContext context) { + final color = selected ? AppColor.primary : AppColor.textPrimary; + + return GestureDetector( + onTap: onTap, + child: AnimatedContainer( + duration: const Duration(milliseconds: 200), + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), + decoration: BoxDecoration( + color: selected ? CommunityColor.blush : CommunityColor.background, + borderRadius: BorderRadius.circular(999), + border: Border.all( + color: selected ? CommunityColor.blushDeep : Colors.transparent, + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + if (icon != null) ...[ + Icon(icon, size: 14, color: color), + const SizedBox(width: 6), + ], + Text( + label, + style: AppStyle.sm.copyWith( + color: color, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ); + } +} + +class _AttachButton extends StatelessWidget { + const _AttachButton({required this.icon, required this.onTap}); + + final IconData icon; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Material( + color: CommunityColor.background, + borderRadius: BorderRadius.circular(14), + child: InkWell( + borderRadius: BorderRadius.circular(14), + onTap: onTap, + child: SizedBox( + width: 48, + height: 48, + child: Icon(icon, color: CommunityColor.muted), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/community/widgets/community_event_card.dart b/lib/presentation/pages/community/widgets/community_event_card.dart new file mode 100644 index 0000000..3a02d37 --- /dev/null +++ b/lib/presentation/pages/community/widgets/community_event_card.dart @@ -0,0 +1,226 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/community_sample_data.dart'; +import '../community_ui.dart'; + +class CommunityEventCard extends StatelessWidget { + const CommunityEventCard({ + super.key, + required this.event, + required this.isGoing, + required this.onToggle, + }); + + final CommunityEvent event; + final bool isGoing; + final VoidCallback onToggle; + + @override + Widget build(BuildContext context) { + final attendeeCount = event.attendeeCount + (isGoing ? 1 : 0); + final remaining = event.quota - attendeeCount; + + return Container( + margin: const EdgeInsets.fromLTRB(16, 0, 16, 16), + decoration: communityCardDecoration(radius: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Stack( + children: [ + ClipRRect( + borderRadius: const BorderRadius.vertical( + top: Radius.circular(24), + ), + child: AspectRatio( + aspectRatio: 2.2, + child: Image.asset(event.image, fit: BoxFit.cover), + ), + ), + Positioned( + left: 12, + top: 12, + child: _DateBadge(date: event.startAt), + ), + if (event.reward != null) + Positioned( + right: 12, + top: 12, + child: Container( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), + decoration: BoxDecoration( + color: AppColor.white.withOpacity(0.92), + borderRadius: BorderRadius.circular(999), + ), + child: Text( + '🎁 ${event.reward}', + style: AppStyle.xs.copyWith(fontWeight: FontWeight.w700), + ), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.fromLTRB(16, 14, 16, 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + event.title, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 8), + _InfoRow( + icon: Icons.schedule_rounded, + text: + '${DateFormat('EEEE, d MMM', 'id_ID').format(event.startAt)}' + ' · ${DateFormat('HH:mm', 'id_ID').format(event.startAt)}', + ), + const SizedBox(height: 4), + _InfoRow(icon: Icons.place_outlined, text: event.location), + const SizedBox(height: 14), + Row( + children: [ + CommunityAvatarStack(members: event.attendees), + const SizedBox(width: 8), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '$attendeeCount akan hadir', + style: AppStyle.xs.copyWith( + fontWeight: FontWeight.w700, + ), + ), + Text( + remaining > 0 + ? 'Sisa $remaining kursi' + : 'Kuota penuh', + style: AppStyle.xs.copyWith( + fontSize: 10, + color: remaining <= 5 + ? AppColor.primary + : CommunityColor.muted, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + _GoingButton(isGoing: isGoing, onTap: onToggle), + ], + ), + ], + ), + ), + ], + ), + ); + } +} + +class _DateBadge extends StatelessWidget { + const _DateBadge({required this.date}); + + final DateTime date; + + @override + Widget build(BuildContext context) { + return Container( + width: 48, + padding: const EdgeInsets.symmetric(vertical: 6), + decoration: BoxDecoration( + color: AppColor.white.withOpacity(0.95), + borderRadius: BorderRadius.circular(14), + ), + child: Column( + children: [ + Text( + DateFormat('d', 'id_ID').format(date), + style: AppStyle.xl.copyWith( + height: 1.1, + fontWeight: FontWeight.w700, + ), + ), + Text( + DateFormat('MMM', 'id_ID').format(date).toUpperCase(), + style: AppStyle.xs.copyWith( + fontSize: 10, + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ); + } +} + +class _InfoRow extends StatelessWidget { + const _InfoRow({required this.icon, required this.text}); + + final IconData icon; + final String text; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Icon(icon, size: 15, color: CommunityColor.muted), + const SizedBox(width: 6), + Expanded( + child: Text( + text, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w500, + ), + ), + ), + ], + ); + } +} + +class _GoingButton extends StatelessWidget { + const _GoingButton({required this.isGoing, required this.onTap}); + + final bool isGoing; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + decoration: BoxDecoration( + color: isGoing ? CommunityColor.blush : AppColor.primary, + borderRadius: BorderRadius.circular(14), + ), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(14), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10), + child: Text( + isGoing ? 'Terdaftar ✓' : 'Ikut', + style: AppStyle.sm.copyWith( + color: isGoing ? AppColor.primary : AppColor.white, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/community/widgets/community_group_card.dart b/lib/presentation/pages/community/widgets/community_group_card.dart new file mode 100644 index 0000000..73b8d31 --- /dev/null +++ b/lib/presentation/pages/community/widgets/community_group_card.dart @@ -0,0 +1,212 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/community_sample_data.dart'; +import '../community_ui.dart'; + +/// Kartu kecil untuk carousel "Komunitas Populer". +class CommunityGroupCard extends StatelessWidget { + const CommunityGroupCard({ + super.key, + required this.group, + required this.isJoined, + required this.onTap, + required this.onJoin, + }); + + final CommunityGroup group; + final bool isJoined; + final VoidCallback onTap; + final VoidCallback onJoin; + + @override + Widget build(BuildContext context) { + final (background, _) = CommunityColor.tintOf(group.tint); + + return Container( + width: 156, + decoration: BoxDecoration( + color: background, + borderRadius: BorderRadius.circular(22), + ), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(22), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(14), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 44, + height: 44, + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColor.white.withOpacity(0.8), + borderRadius: BorderRadius.circular(14), + ), + child: Text( + group.emoji, + style: const TextStyle(fontSize: 22), + ), + ), + const Spacer(), + Text( + group.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 2), + Text( + '${formatCompact(group.memberCount)} anggota', + style: AppStyle.xs.copyWith(color: CommunityColor.muted), + ), + const SizedBox(height: 10), + CommunityJoinButton( + isJoined: isJoined, + onPressed: onJoin, + compact: true, + ), + ], + ), + ), + ), + ), + ); + } +} + +/// Baris komunitas untuk tab "Komunitas". +class CommunityGroupTile extends StatelessWidget { + const CommunityGroupTile({ + super.key, + required this.group, + required this.isJoined, + required this.onTap, + required this.onJoin, + }); + + final CommunityGroup group; + final bool isJoined; + final VoidCallback onTap; + final VoidCallback onJoin; + + @override + Widget build(BuildContext context) { + return Container( + margin: const EdgeInsets.fromLTRB(16, 0, 16, 12), + decoration: communityCardDecoration(), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(20), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(12), + child: Row( + children: [ + Stack( + clipBehavior: Clip.none, + children: [ + ClipRRect( + borderRadius: BorderRadius.circular(16), + child: Image.asset( + group.coverImage, + width: 64, + height: 64, + fit: BoxFit.cover, + ), + ), + Positioned( + right: -4, + bottom: -4, + child: Container( + padding: const EdgeInsets.all(2), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(10), + ), + child: CommunityEmojiBadge(group: group, size: 24), + ), + ), + ], + ), + const SizedBox(width: 14), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + group.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.md.copyWith( + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 2), + Text( + group.description, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w500, + ), + ), + const SizedBox(height: 6), + Row( + children: [ + const Icon( + Icons.people_alt_rounded, + size: 14, + color: CommunityColor.muted, + ), + const SizedBox(width: 4), + Text( + formatCompact(group.memberCount), + style: AppStyle.xs.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(width: 10), + const Icon( + Icons.local_fire_department_rounded, + size: 14, + color: CommunityColor.muted, + ), + const SizedBox(width: 2), + Flexible( + child: Text( + '${group.postPerDay} post/hari', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith( + color: CommunityColor.muted, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ], + ), + ), + const SizedBox(width: 8), + CommunityJoinButton( + isJoined: isJoined, + onPressed: onJoin, + compact: true, + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/community/widgets/community_post_card.dart b/lib/presentation/pages/community/widgets/community_post_card.dart new file mode 100644 index 0000000..6905759 --- /dev/null +++ b/lib/presentation/pages/community/widgets/community_post_card.dart @@ -0,0 +1,284 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/community_sample_data.dart'; +import '../community_ui.dart'; + +/// Kartu postingan. [expanded] menampilkan teks penuh (halaman detail). +class CommunityPostCard extends StatefulWidget { + const CommunityPostCard({ + super.key, + required this.post, + this.onTap, + this.onGroupTap, + this.expanded = false, + }); + + final CommunityPost post; + final VoidCallback? onTap; + final VoidCallback? onGroupTap; + final bool expanded; + + @override + State createState() => _CommunityPostCardState(); +} + +class _CommunityPostCardState extends State { + late bool _isLiked = widget.post.isLiked; + late int _likeCount = widget.post.likeCount; + bool _isSaved = false; + + void _toggleLike() { + setState(() { + _isLiked = !_isLiked; + _likeCount += _isLiked ? 1 : -1; + }); + } + + @override + Widget build(BuildContext context) { + final post = widget.post; + + return Container( + margin: const EdgeInsets.fromLTRB(16, 0, 16, 14), + decoration: communityCardDecoration(), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(20), + onTap: widget.onTap, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildHeader(post), + const SizedBox(height: 12), + Text( + post.content, + maxLines: widget.expanded ? null : 4, + overflow: widget.expanded ? null : TextOverflow.ellipsis, + style: AppStyle.md.copyWith( + height: 1.5, + fontWeight: FontWeight.w500, + ), + ), + if (post.image != null) ...[ + const SizedBox(height: 12), + ClipRRect( + borderRadius: BorderRadius.circular(16), + child: AspectRatio( + aspectRatio: 16 / 10, + child: Image.asset(post.image!, fit: BoxFit.cover), + ), + ), + ], + if (post.merchantName != null) ...[ + const SizedBox(height: 10), + _MerchantTag(name: post.merchantName!), + ], + const SizedBox(height: 6), + _buildActions(post), + ], + ), + ), + ), + ), + ); + } + + Widget _buildHeader(CommunityPost post) { + return Row( + children: [ + CommunityAvatar(member: post.author, size: 42), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Flexible( + child: Text( + post.author.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + ), + if (post.author.badge != null) ...[ + const SizedBox(width: 6), + _AuthorBadge(label: post.author.badge!), + ], + ], + ), + const SizedBox(height: 2), + GestureDetector( + onTap: widget.onGroupTap, + child: Text.rich( + TextSpan( + children: [ + TextSpan( + text: '${post.group.emoji} ${post.group.name}', + style: const TextStyle( + color: AppColor.textPrimary, + fontWeight: FontWeight.w600, + ), + ), + TextSpan(text: ' · ${formatTimeAgo(post.createdAt)}'), + ], + ), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith(color: CommunityColor.muted), + ), + ), + ], + ), + ), + IconButton( + onPressed: () {}, + visualDensity: VisualDensity.compact, + icon: const Icon( + Icons.more_horiz_rounded, + color: CommunityColor.muted, + ), + ), + ], + ); + } + + Widget _buildActions(CommunityPost post) { + return Row( + children: [ + _ActionButton( + icon: _isLiked + ? Icons.favorite_rounded + : Icons.favorite_border_rounded, + label: formatCompact(_likeCount), + color: _isLiked ? AppColor.primary : CommunityColor.muted, + onTap: _toggleLike, + ), + _ActionButton( + icon: Icons.chat_bubble_outline_rounded, + label: formatCompact(post.commentCount), + color: CommunityColor.muted, + onTap: widget.onTap, + ), + _ActionButton( + icon: Icons.ios_share_rounded, + label: 'Bagikan', + color: CommunityColor.muted, + onTap: () {}, + ), + const Spacer(), + IconButton( + onPressed: () => setState(() => _isSaved = !_isSaved), + visualDensity: VisualDensity.compact, + icon: Icon( + _isSaved ? Icons.bookmark_rounded : Icons.bookmark_border_rounded, + size: 22, + color: _isSaved ? AppColor.primary : CommunityColor.muted, + ), + ), + ], + ); + } +} + +class _AuthorBadge extends StatelessWidget { + const _AuthorBadge({required this.label}); + + final String label; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), + decoration: BoxDecoration( + color: CommunityColor.blush, + borderRadius: BorderRadius.circular(999), + ), + child: Text( + label, + style: AppStyle.xs.copyWith( + fontSize: 10, + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ); + } +} + +class _MerchantTag extends StatelessWidget { + const _MerchantTag({required this.name}); + + final String name; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), + decoration: BoxDecoration( + color: CommunityColor.background, + borderRadius: BorderRadius.circular(999), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.storefront_rounded, + size: 14, + color: AppColor.primary, + ), + const SizedBox(width: 6), + Text(name, style: AppStyle.xs.copyWith(fontWeight: FontWeight.w700)), + ], + ), + ); + } +} + +class _ActionButton extends StatelessWidget { + const _ActionButton({ + required this.icon, + required this.label, + required this.color, + this.onTap, + }); + + final IconData icon; + final String label; + final Color color; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(999), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8), + child: Row( + children: [ + AnimatedSwitcher( + duration: const Duration(milliseconds: 200), + transitionBuilder: (child, animation) => + ScaleTransition(scale: animation, child: child), + child: Icon(icon, key: ValueKey(icon), size: 20, color: color), + ), + const SizedBox(width: 6), + Text( + label, + style: AppStyle.sm.copyWith( + color: color, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/main/main_page.dart b/lib/presentation/pages/main/main_page.dart index 41ef4e8..cf04a2b 100644 --- a/lib/presentation/pages/main/main_page.dart +++ b/lib/presentation/pages/main/main_page.dart @@ -21,6 +21,14 @@ class _MainPageState extends State { context.read().add(const AuthEvent.fetchCurrentUser()); } + /// Kode bayar di kasir; PIN diminta di halamannya sendiri. + void _openPay() { + final isAuthenticated = context.read().state.isAuthenticated; + context.router.push( + isAuthenticated ? const PaymentCodeRoute() : const OnboardingRoute(), + ); + } + @override Widget build(BuildContext context) { return AutoTabsRouter.pageView( @@ -28,15 +36,26 @@ class _MainPageState extends State { HomeRoute(), // VoucherRoute(), OrderRoute(), + CommunityRoute(), ProfileRoute(), ], physics: const NeverScrollableScrollPhysics(), - builder: (context, child, pageController) => Scaffold( - body: child, - bottomNavigationBar: MainBottomNavbar( - tabsRouter: AutoTabsRouter.of(context), - ), - ), + builder: (context, child, pageController) { + // Docked FAB ikut naik ke atas keyboard; sembunyikan saat mengetik. + final isKeyboardOpen = MediaQuery.viewInsetsOf(context).bottom > 0; + + return Scaffold( + body: child, + floatingActionButton: isKeyboardOpen + ? null + : MainPayButton(onPressed: _openPay), + floatingActionButtonLocation: const MainPayButtonLocation(), + bottomNavigationBar: MainBottomNavbar( + tabsRouter: AutoTabsRouter.of(context), + onPayTap: _openPay, + ), + ); + }, ); } } diff --git a/lib/presentation/pages/main/pages/home/home_page.dart b/lib/presentation/pages/main/pages/home/home_page.dart index ded7289..4dcb1a9 100644 --- a/lib/presentation/pages/main/pages/home/home_page.dart +++ b/lib/presentation/pages/main/pages/home/home_page.dart @@ -4,12 +4,14 @@ import 'package:carousel_slider/carousel_slider.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../../application/auth/auth_bloc.dart'; -import '../../../../../application/customer/customer_point_loader/customer_point_loader_bloc.dart'; -import '../../../../../common/constant/app_constant.dart'; +import '../../../../../application/outlet/outlet_loader/outlet_loader_bloc.dart'; +import '../../../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; +// import '../../../../../common/constant/app_constant.dart'; import '../../../../../common/theme/theme.dart'; import '../../../../components/image/image.dart'; import '../../../../router/app_router.gr.dart'; -import 'widgets/banner_card.dart'; +// import 'widgets/banner_card.dart'; +import 'widgets/outlet_section.dart'; import 'widgets/point_card.dart'; import 'widgets/popular_merchant_section.dart'; import 'widgets/service_section.dart'; @@ -38,9 +40,8 @@ class _HomePageState extends State { void initState() { super.initState(); if (context.read().state.isAuthenticated) { - context.read().add( - CustomerPointLoaderEvent.fetched(), - ); + context.read().add(const WalletLoaderEvent.fetched()); + context.read().add(const OutletLoaderEvent.fetched()); } } @@ -52,16 +53,17 @@ class _HomePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ _buildHeaderSection(), - const SizedBox(height: 70), + const SizedBox(height: 8), HomeServiceSection(), - HomeBanner( - title: '🎰 My Rewards', - subtitle: - 'Main dan tepat menangkan produk gratis dari ${AppConstant.appName}.', - actionText: 'Mainkan Sekarang', - onTap: () => context.router.push(DrawRoute()), - ), + // HomeBanner( + // title: '🎰 My Rewards', + // subtitle: + // 'Main dan tepat menangkan produk gratis dari ${AppConstant.appName}.', + // actionText: 'Mainkan Sekarang', + // onTap: () => context.router.push(DrawRoute()), + // ), HomePopularMerchantSection(), + const HomeOutletSection(), ], ), ), @@ -81,18 +83,11 @@ class _HomePageState extends State { top: 225, child: _buildCarouselIndicators(), ), - Positioned( - left: 16, - right: 16, - top: 240, - child: HomePointCard( - point: context - .read() - .state - .customerPoint - .totalPoints - .toString(), - ), + // Tidak di-Positioned supaya tinggi kartu ikut dihitung, sehingga jarak + // ke menu di bawahnya tetap walau isi kartu bertambah. + const Padding( + padding: EdgeInsets.fromLTRB(16, 240, 16, 0), + child: HomePointCard(), ), ], ); diff --git a/lib/presentation/pages/main/pages/home/widgets/outlet_section.dart b/lib/presentation/pages/main/pages/home/widgets/outlet_section.dart new file mode 100644 index 0000000..1642d0c --- /dev/null +++ b/lib/presentation/pages/main/pages/home/widgets/outlet_section.dart @@ -0,0 +1,54 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../../../../application/auth/auth_bloc.dart'; +import '../../../../../../application/outlet/outlet_loader/outlet_loader_bloc.dart'; +import '../../../../../router/app_router.gr.dart'; +import '../../../../outlet/widgets/outlet_tile.dart'; +import 'section_header.dart'; + +/// Seksi "Outlet Kami" (§4.4). Hanya untuk customer yang sudah masuk, karena +/// daftar outlet mengikuti organisasi akunnya. +class HomeOutletSection extends StatelessWidget { + const HomeOutletSection({super.key}); + + static const int _maxShown = 3; + + @override + Widget build(BuildContext context) { + final isAuthenticated = context.select( + (bloc) => bloc.state.isAuthenticated, + ); + if (!isAuthenticated) return const SizedBox.shrink(); + + return BlocBuilder( + buildWhen: (p, c) => p.outlets != c.outlets, + builder: (context, state) { + if (state.outlets.isEmpty) return const SizedBox.shrink(); + + return Padding( + padding: const EdgeInsets.only(bottom: 24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + HomeSectionHeader( + eyebrow: 'Outlet', + title: 'Outlet Kami', + onSeeAll: state.outlets.length > _maxShown + ? () => context.router.push(const OutletRoute()) + : null, + ), + const SizedBox(height: 12), + for (final outlet in state.outlets.take(_maxShown)) + Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 10), + child: OutletTile(outlet: outlet), + ), + ], + ), + ); + }, + ); + } +} diff --git a/lib/presentation/pages/main/pages/home/widgets/point_card.dart b/lib/presentation/pages/main/pages/home/widgets/point_card.dart index bea986b..94e2289 100644 --- a/lib/presentation/pages/main/pages/home/widgets/point_card.dart +++ b/lib/presentation/pages/main/pages/home/widgets/point_card.dart @@ -3,165 +3,64 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../../../application/auth/auth_bloc.dart'; +import '../../../../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; +import '../../../../../../common/extension/extension.dart'; import '../../../../../../common/theme/theme.dart'; +import '../../../../../../domain/wallet/wallet.dart'; import '../../../../../router/app_router.gr.dart'; +import '../../../../wallet/wallet_ui.dart'; class HomePointCard extends StatelessWidget { - final String point; - const HomePointCard({super.key, required this.point}); + const HomePointCard({super.key}); @override Widget build(BuildContext context) { + final summary = context.watch().state.summary; + return BlocBuilder( builder: (context, state) { - return GestureDetector( - onTap: () => state.isAuthenticated - ? context.router.push(CoinRoute()) - : context.router.push(OnboardingRoute()), - child: Container( - decoration: BoxDecoration( - color: AppColor.white, - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: AppColor.textLight.withOpacity(0.15), - spreadRadius: 0, - blurRadius: 20, - offset: const Offset(0, 8), - ), - ], - ), - child: Stack( - children: [ - _buildCoinPattern(), - Padding( - padding: const EdgeInsets.all(16), - child: Column( - children: [ - Row( - children: [ - !state.isAuthenticated - ? Expanded( - child: Text( - 'Hi, Selamat Datang Di Enaklo', - style: AppStyle.md.copyWith( - color: AppColor.primary, - fontWeight: FontWeight.w600, - ), - ), - ) - : Expanded( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: const EdgeInsets.symmetric( - horizontal: 16, - vertical: 10, - ), - decoration: BoxDecoration( - color: AppColor.primary, - borderRadius: BorderRadius.circular( - 25, - ), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - Icons.stars, - color: AppColor.white, - size: 18, - ), - SizedBox(width: 8), - Text( - '$point Poin', - style: AppStyle.md.copyWith( - color: AppColor.white, - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), - const SizedBox(height: 4), - Text( - 'Kamu punya $point poin', - style: AppStyle.sm.copyWith( - color: AppColor.textSecondary, - fontSize: 11, - ), - ), - ], - ), - ), + final isAuthenticated = state.isAuthenticated; - SizedBox( - width: 120, - height: 40, - child: Stack( - children: [ - _buildCoin( - right: 0, - top: 0, - size: 24, - color: Colors.amber, - ), - _buildCoin( - right: 20, - top: 8, - size: 20, - color: Colors.orange, - ), - _buildCoin( - right: 40, - top: 4, - size: 18, - color: Colors.amber, - ), - _buildCoin( - right: 60, - top: 12, - size: 16, - color: Colors.orange, - ), - _buildCoin( - right: 80, - top: 8, - size: 14, - color: Colors.amber, - ), - ], - ), - ), - ], - ), - const SizedBox(height: 12), - Row( - children: [ - Text( - state.isAuthenticated - ? 'Tukarkan poinmu dengan hadiah menarik' - : 'Silahkan login untuk tukarkan poinmu', - style: AppStyle.sm.copyWith( - color: AppColor.textPrimary, - fontSize: 13, - fontWeight: FontWeight.w500, - ), - ), - const Spacer(), - Icon( - Icons.arrow_forward_ios, + return Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + shadowColor: AppColor.textLight.withOpacity(0.3), + elevation: 6, + child: InkWell( + borderRadius: BorderRadius.circular(16), + onTap: () => isAuthenticated + ? context.router.push(WalletRoute()) + : context.router.push(OnboardingRoute()), + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 12), + child: Column( + children: [ + isAuthenticated ? _buildBalances(summary) : _buildGuest(), + const SizedBox(height: 12), + const Divider(height: 1, color: AppColor.borderLight), + const SizedBox(height: 10), + Row( + children: [ + Expanded( + child: Text( + isAuthenticated + ? 'Bayar di kasir, tukar, transfer & main game' + : 'Silahkan login untuk melihat EnakPoint kamu', + style: AppStyle.sm.copyWith( color: AppColor.textSecondary, - size: 16, + fontWeight: FontWeight.w500, ), - ], + ), + ), + const Icon( + Icons.arrow_forward_ios_rounded, + color: AppColor.textSecondary, + size: 14, ), ], ), - ), - ], + ], + ), ), ), ); @@ -169,90 +68,129 @@ class HomePointCard extends StatelessWidget { ); } - Widget _buildCoinPattern() { - return Positioned.fill( - child: ClipRRect( - borderRadius: BorderRadius.circular(16), - child: Stack( - children: [ - Positioned( - right: -20, - top: -10, - child: Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.1), - shape: BoxShape.circle, - ), - ), + Widget _buildBalances(WalletSummary summary) { + return IntrinsicHeight( + child: Row( + children: [ + Expanded( + child: _BalanceTile( + currency: WalletCurrency.point, + balance: summary.pointBalance, + caption: pointDiscountLabel(summary.pointDiscountValue), ), - Positioned( - right: 40, - top: 30, - child: Container( - width: 20, - height: 20, - decoration: BoxDecoration( - color: Colors.orange.withOpacity(0.15), - shape: BoxShape.circle, - ), - ), + ), + const VerticalDivider( + width: 24, + thickness: 1, + color: AppColor.borderLight, + ), + Expanded( + child: _BalanceTile( + currency: WalletCurrency.coin, + balance: summary.coinBalance, ), - Positioned( - left: -15, - bottom: -20, - child: Container( - width: 40, - height: 40, - decoration: BoxDecoration( - color: Colors.amber.withOpacity(0.08), - shape: BoxShape.circle, - ), - ), - ), - Positioned( - left: 60, - bottom: 10, - child: Container( - width: 15, - height: 15, - decoration: BoxDecoration( - color: Colors.orange.withOpacity(0.12), - shape: BoxShape.circle, - ), - ), - ), - ], - ), + ), + ], ), ); } - Widget _buildCoin({ - required double right, - required double top, - required double size, - required Color color, - }) { - return Positioned( - right: right, - top: top, - child: Container( - width: size, - height: size, - decoration: BoxDecoration(color: color, shape: BoxShape.circle), - child: Center( + Widget _buildGuest() { + return Row( + children: [ + Expanded( child: Text( - '\$', - style: TextStyle( - color: Colors.white, - fontSize: size * 0.5, - fontWeight: FontWeight.bold, + 'Hi, Selamat Datang Di Enaklo', + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, ), ), ), - ), + const SizedBox(width: 12), + const SizedBox( + width: 64, + height: 40, + child: Stack( + children: [ + Positioned( + left: 0, + top: 4, + child: WalletCurrencyIcon( + currency: WalletCurrency.coin, + size: 32, + ), + ), + Positioned( + right: 0, + top: 0, + child: WalletCurrencyIcon( + currency: WalletCurrency.point, + size: 36, + ), + ), + ], + ), + ), + ], + ); + } +} + +/// Satu kolom saldo: ikon, nama mata uang, dan jumlahnya. +class _BalanceTile extends StatelessWidget { + const _BalanceTile({ + required this.currency, + required this.balance, + this.caption, + }); + + final WalletCurrency currency; + final int balance; + final String? caption; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + WalletCurrencyIcon(currency: currency, size: 36), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + currency.label, + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 2), + FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Text( + balance.thousandFormat, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + ), + if (caption != null) + FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Text( + caption!, + style: AppStyle.xs.copyWith( + fontSize: 10, + color: AppColor.textSecondary, + ), + ), + ), + ], + ), + ), + ], ); } } diff --git a/lib/presentation/pages/main/pages/home/widgets/popular_merchant_card.dart b/lib/presentation/pages/main/pages/home/widgets/popular_merchant_card.dart index b038e07..5cec59f 100644 --- a/lib/presentation/pages/main/pages/home/widgets/popular_merchant_card.dart +++ b/lib/presentation/pages/main/pages/home/widgets/popular_merchant_card.dart @@ -1,156 +1,82 @@ +import 'dart:ui'; + import 'package:flutter/material.dart'; import '../../../../../../common/theme/theme.dart'; import '../../../../../../sample/sample_data.dart'; import '../../../../../components/image/image.dart'; +/// Banner brand partner di seksi "Brand Kami". class HomePopularMerchantCard extends StatelessWidget { final MerchantModel merchant; + final double width; + final double height; final VoidCallback? onTap; const HomePopularMerchantCard({ super.key, - this.onTap, required this.merchant, + required this.width, + required this.height, + this.onTap, }); + static const double _radius = 12; + + Widget _image(BoxFit fit) => merchant.imageUrl.startsWith('http') + ? Image.network( + merchant.imageUrl, + fit: fit, + errorBuilder: (_, _, _) => const ImagePlaceholder(), + ) + : Image.asset( + merchant.imageUrl, + fit: fit, + errorBuilder: (_, _, _) => const ImagePlaceholder(), + ); + @override Widget build(BuildContext context) { - return GestureDetector( - onTap: onTap, + return Semantics( + button: true, + label: merchant.name, child: Container( - margin: const EdgeInsets.only(bottom: 12), - padding: const EdgeInsets.all(12), + width: width, + height: height, decoration: BoxDecoration( color: AppColor.surface, - borderRadius: BorderRadius.circular(12), + borderRadius: BorderRadius.circular(_radius), + border: Border.all(color: AppColor.borderLight), boxShadow: [ BoxShadow( - color: AppColor.black.withOpacity(0.06), - blurRadius: 8, - offset: const Offset(0, 2), + color: AppColor.black.withOpacity(0.08), + blurRadius: 10, + offset: const Offset(0, 4), ), ], ), - child: Row( - children: [ - // Image Container - Container( - width: 60, - height: 60, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - color: AppColor.border, - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(8), - child: merchant.imageUrl.startsWith('http') - ? Image.network( - merchant.imageUrl, - width: 60, - height: 60, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) { - return ImagePlaceholder(width: 60, height: 60); - }, - ) - : Image.asset( - merchant.imageUrl, - width: 60, - height: 60, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) { - return ImagePlaceholder(width: 60, height: 60); - }, - ), - ), - ), - - const SizedBox(width: 12), - - // Title and Category - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - merchant.name, - style: AppStyle.md.copyWith( - fontWeight: FontWeight.w600, - height: 1.2, - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - - const SizedBox(height: 4), - - Text( - merchant.category, - style: AppStyle.sm.copyWith(color: AppColor.textSecondary), - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - ], - ), - ), - - const SizedBox(width: 8), - - // Rating and Status - Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - // Status Badge - Container( - padding: const EdgeInsets.symmetric( - horizontal: 6, - vertical: 2, - ), - decoration: BoxDecoration( - color: merchant.isOpen ? AppColor.success : AppColor.error, - borderRadius: BorderRadius.circular(6), - ), - child: Text( - merchant.isOpen ? 'OPEN' : 'CLOSED', - style: AppStyle.xs.copyWith( - color: AppColor.textWhite, - fontWeight: FontWeight.w600, - fontSize: 10, - ), - ), + child: ClipRRect( + borderRadius: BorderRadius.circular(_radius), + child: Stack( + fit: StackFit.expand, + children: [ + // Logo brand ada yang persegi: tampilkan utuh, sisa ruangnya + // diisi versi blur dari gambar yang sama agar tidak terpotong. + ImageFiltered( + imageFilter: ImageFilter.blur( + sigmaX: 18, + sigmaY: 18, + tileMode: TileMode.clamp, ), - - const SizedBox(height: 8), - - // Rating - Container( - padding: const EdgeInsets.symmetric( - horizontal: 6, - vertical: 3, - ), - decoration: BoxDecoration( - color: AppColor.primary.withOpacity(0.1), - borderRadius: BorderRadius.circular(6), - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Icon(Icons.star, size: 12, color: AppColor.warning), - const SizedBox(width: 2), - Text( - merchant.rating.toString(), - style: AppStyle.xs.copyWith( - fontWeight: FontWeight.w600, - color: AppColor.primary, - ), - ), - ], - ), - ), - ], - ), - ], + child: _image(BoxFit.cover), + ), + _image(BoxFit.contain), + Material( + type: MaterialType.transparency, + child: InkWell(onTap: onTap), + ), + ], + ), ), ), ); diff --git a/lib/presentation/pages/main/pages/home/widgets/popular_merchant_section.dart b/lib/presentation/pages/main/pages/home/widgets/popular_merchant_section.dart index 4b154e4..0f0812c 100644 --- a/lib/presentation/pages/main/pages/home/widgets/popular_merchant_section.dart +++ b/lib/presentation/pages/main/pages/home/widgets/popular_merchant_section.dart @@ -1,53 +1,51 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import '../../../../../../common/theme/theme.dart'; import '../../../../../../sample/sample_data.dart'; import '../../../../../router/app_router.gr.dart'; import 'popular_merchant_card.dart'; +import 'section_header.dart'; +/// Seksi "Brand Kami": banner brand partner yang bisa digeser. class HomePopularMerchantSection extends StatelessWidget { const HomePopularMerchantSection({super.key}); + static const double _cardWidth = 240; + static const double _cardHeight = 136; + @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 24), + padding: const EdgeInsets.only(top: 8, bottom: 16), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Text( - 'Popular Merchants', - style: AppStyle.xl.copyWith(fontWeight: FontWeight.bold), - ), - Spacer(), - InkWell( - onTap: () => context.router.push(MerchantRoute()), - child: Row( - children: [ - Text( - 'Lihat Semua', - style: AppStyle.sm.copyWith( - fontWeight: FontWeight.w500, - color: AppColor.primary, - ), - ), - SizedBox(width: 4), - Icon( - Icons.arrow_forward_ios, - size: 12, - color: AppColor.primary, - ), - ], - ), - ), - ], + HomeSectionHeader( + eyebrow: 'Partner', + title: 'Brand Kami', + onSeeAll: () => context.router.push(MerchantRoute()), ), - SizedBox(height: 16), - ...List.generate( - merchants.length, - (index) => HomePopularMerchantCard(merchant: merchants[index]), + const SizedBox(height: 12), + SizedBox( + // Ruang ekstra agar bayangan kartu tidak terpotong. + height: _cardHeight + 16, + child: ListView.separated( + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.fromLTRB(16, 4, 16, 12), + itemCount: merchants.length, + separatorBuilder: (_, _) => const SizedBox(width: 12), + itemBuilder: (context, index) { + final merchant = merchants[index]; + return HomePopularMerchantCard( + merchant: merchant, + width: _cardWidth, + height: _cardHeight, + onTap: () => context.router.push( + MerchantDetailRoute(merchant: merchant), + ), + ); + }, + ), ), ], ), diff --git a/lib/presentation/pages/main/pages/home/widgets/section_header.dart b/lib/presentation/pages/main/pages/home/widgets/section_header.dart new file mode 100644 index 0000000..c4d4607 --- /dev/null +++ b/lib/presentation/pages/main/pages/home/widgets/section_header.dart @@ -0,0 +1,90 @@ +import 'package:flutter/material.dart'; + +import '../../../../../../common/theme/theme.dart'; + +/// Judul seksi Home: pemisah abu-abu, label kecil merah, judul, dan +/// "Lihat Semua" opsional. +class HomeSectionHeader extends StatelessWidget { + const HomeSectionHeader({ + super.key, + required this.eyebrow, + required this.title, + this.onSeeAll, + }); + + final String eyebrow; + final String title; + final VoidCallback? onSeeAll; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container(height: 6, color: AppColor.borderLight), + const SizedBox(height: 20), + Padding( + padding: const EdgeInsets.only(left: 16, right: 8), + child: Row( + children: [ + Container( + width: 3, + height: 36, + decoration: BoxDecoration( + color: AppColor.primary, + borderRadius: BorderRadius.circular(2), + ), + ), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + eyebrow.toUpperCase(), + style: AppStyle.xs.copyWith( + fontSize: 10, + color: AppColor.primary, + fontWeight: FontWeight.w700, + letterSpacing: 1.5, + ), + ), + Text( + title, + style: AppStyle.xl.copyWith( + height: 1.2, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ), + if (onSeeAll != null) + TextButton( + onPressed: onSeeAll, + style: TextButton.styleFrom( + foregroundColor: AppColor.primaryDark, + padding: const EdgeInsets.symmetric(horizontal: 8), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + 'Lihat Semua', + style: AppStyle.sm.copyWith( + color: AppColor.primaryDark, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(width: 4), + const Icon(Icons.arrow_right_alt_rounded, size: 20), + ], + ), + ), + ], + ), + ), + ], + ); + } +} diff --git a/lib/presentation/pages/main/pages/home/widgets/service_section.dart b/lib/presentation/pages/main/pages/home/widgets/service_section.dart index c974de1..cac3d6c 100644 --- a/lib/presentation/pages/main/pages/home/widgets/service_section.dart +++ b/lib/presentation/pages/main/pages/home/widgets/service_section.dart @@ -1,71 +1,184 @@ +import 'dart:math' as math; + import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; -import '../../../../../../common/data/service_data.dart'; +import '../../../../../../application/auth/auth_bloc.dart'; +import '../../../../../../common/constant/app_constant.dart'; import '../../../../../../common/theme/theme.dart'; -import '../../../../../components/card/gradient_card.dart'; +import '../../../../../components/assets/assets.gen.dart'; +import '../../../../../components/toast/flushbar.dart'; import '../../../../../router/app_router.gr.dart'; +class _HomeMenu { + const _HomeMenu({ + required this.label, + required this.icon, + this.route, + this.requiresLogin = false, + this.opensTab = false, + }); + + final String label; + final AssetGenImage icon; + + /// `null` berarti fitur belum tersedia. + final PageRouteInfo? route; + final bool requiresLogin; + + /// [route] adalah tab di bottom navbar; dibuka dengan pindah tab, bukan push. + final bool opensTab; +} + class HomeServiceSection extends StatelessWidget { const HomeServiceSection({super.key}); - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.all(16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: List.generate(services.length, (index) { - return Expanded( - child: Padding( - padding: EdgeInsets.only(right: index == 0 ? 12 : 0), - child: InkWell( - onTap: () => - context.router.push(MenuRoute(service: services[index])), - child: GradientCard( - padding: EdgeInsets.zero, - child: _content(services[index]), - ), - ), - ), - ); - }), + static final List<_HomeMenu> _menus = [ + _HomeMenu( + label: 'EnakGame', + icon: Assets.icons.enakgameIcon, + route: WebViewRoute( + title: 'EnakGame', + url: AppConstant.gameUrl, + fullscreen: true, + backgroundColor: AppConstant.gameBackgroundColor, ), - ); + ), + _HomeMenu( + label: 'EnakTransfer', + icon: Assets.icons.enaktransferIcon, + route: const TransferRoute(), + requiresLogin: true, + ), + _HomeMenu( + label: 'EnakReward', + icon: Assets.icons.enakrewardIcon, + route: const RewardRoute(), + ), + _HomeMenu( + label: 'EnakPromo', + icon: Assets.icons.enakpromoIcon, + route: const PromoRoute(), + ), + _HomeMenu( + label: 'EnakShop', + icon: Assets.icons.enakshopIcon, + route: const ShopRoute(), + ), + _HomeMenu( + label: 'EnakNews', + icon: Assets.icons.enaknewsIcon, + route: const NewsRoute(), + ), + _HomeMenu( + label: 'EnakCommunity', + icon: Assets.icons.enakcommunityIcon, + route: const CommunityRoute(), + opensTab: true, + ), + ]; + + void _open(BuildContext context, _HomeMenu menu) { + final route = menu.route; + if (route == null) { + AppFlushbar.showSuccess(context, '${menu.label} segera hadir'); + return; + } + + final isAuthenticated = context.read().state.isAuthenticated; + if (menu.requiresLogin && !isAuthenticated) { + context.router.push(OnboardingRoute()); + return; + } + + if (menu.opensTab) { + context.tabsRouter.navigate(route); + return; + } + + context.router.push(route); } - Stack _content(Service service) { - return Stack( - children: [ - Positioned( - right: 4, - top: 4, - child: Image.asset(service.imagePath, width: 60, height: 60), - ), - Padding( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - service.name, - style: AppStyle.lg.copyWith( - color: AppColor.white, - fontWeight: FontWeight.bold, - ), - ), - SizedBox(height: 8), - Text( - service.description, - style: AppStyle.md.copyWith( - color: AppColor.white, - fontWeight: FontWeight.w500, - ), - ), - ], + static const double _horizontalPadding = 16; + static const int _crossAxisCount = 4; + static const double _crossAxisSpacing = 8; + + /// Semua label memakai ukuran font yang sama: kalau label terpanjang tidak + /// muat di lebar sel, semuanya diperkecil bersama supaya tidak ada yang + /// kecil sendiri. + TextStyle _labelStyle(BuildContext context, double maxWidth) { + final style = DefaultTextStyle.of( + context, + ).style.merge(AppStyle.xs.copyWith(fontWeight: FontWeight.w600)); + final textScaler = MediaQuery.textScalerOf(context); + final textDirection = Directionality.of(context); + + final widest = _menus + .map((menu) { + final painter = TextPainter( + text: TextSpan(text: menu.label, style: style), + textDirection: textDirection, + textScaler: textScaler, + maxLines: 1, + )..layout(); + final width = painter.width; + painter.dispose(); + return width; + }) + .reduce(math.max); + + if (widest <= maxWidth) return style; + return style.copyWith(fontSize: style.fontSize! * maxWidth / widest); + } + + @override + Widget build(BuildContext context) { + return LayoutBuilder( + builder: (context, constraints) { + final itemWidth = + (constraints.maxWidth - + _horizontalPadding * 2 - + _crossAxisSpacing * (_crossAxisCount - 1)) / + _crossAxisCount; + final labelStyle = _labelStyle(context, itemWidth); + + return GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.fromLTRB( + _horizontalPadding, + 32, + _horizontalPadding, + 16, ), - ), - ], + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: _crossAxisCount, + mainAxisSpacing: 12, + crossAxisSpacing: _crossAxisSpacing, + mainAxisExtent: 76, + ), + itemCount: _menus.length, + itemBuilder: (context, index) { + final menu = _menus[index]; + return InkWell( + borderRadius: BorderRadius.circular(AppValue.borderRadius), + onTap: () => _open(context, menu), + child: Column( + children: [ + const SizedBox(height: 4), + menu.icon.image(width: 44, height: 44, fit: BoxFit.contain), + const SizedBox(height: 6), + FittedBox( + fit: BoxFit.scaleDown, + child: Text(menu.label, maxLines: 1, style: labelStyle), + ), + ], + ), + ); + }, + ); + }, ); } } diff --git a/lib/presentation/pages/main/pages/order/order_page.dart b/lib/presentation/pages/main/pages/order/order_page.dart index 33b0a8a..006a78e 100644 --- a/lib/presentation/pages/main/pages/order/order_page.dart +++ b/lib/presentation/pages/main/pages/order/order_page.dart @@ -1,355 +1,215 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import '../../../../../application/auth/auth_bloc.dart'; +import '../../../../../application/order/order_loader/order_loader_bloc.dart'; import '../../../../../common/theme/theme.dart'; +import '../../../../../injection.dart'; +import '../../../../components/button/button.dart'; +import '../../../../components/toast/flushbar.dart'; +import '../../../../router/app_router.gr.dart'; +import '../../../wallet/wallet_ui.dart'; import 'widgets/order_card.dart'; -// Model untuk Order -class Order { - final String id; - final String customerName; - final DateTime orderDate; - final List items; - final double totalAmount; - final OrderStatus status; - final String? notes; - final String? phoneNumber; - final String? address; - - Order({ - required this.id, - required this.customerName, - required this.orderDate, - required this.items, - required this.totalAmount, - required this.status, - this.notes, - this.phoneNumber, - this.address, - }); -} - -class OrderItem { - final String name; - final int quantity; - final double price; - final String? imageUrl; - final String? notes; - - OrderItem({ - required this.name, - required this.quantity, - required this.price, - this.imageUrl, - this.notes, - }); -} - -enum OrderStatus { pending, processing, completed, cancelled } - +/// Riwayat order customer (§4.5). Order hanya bisa dilihat; app tidak membuat +/// atau membayar order. @RoutePage() -class OrderPage extends StatefulWidget { +class OrderPage extends StatefulWidget implements AutoRouteWrapper { const OrderPage({super.key}); @override State createState() => _OrderPageState(); + + @override + Widget wrappedRoute(BuildContext context) => + BlocProvider(create: (_) => getIt(), child: this); } -class _OrderPageState extends State with TickerProviderStateMixin { - late TabController _tabController; - bool _isLoading = true; - List _orders = []; - - // Filter states +class _OrderPageState extends State { + final ScrollController _scrollController = ScrollController(); @override void initState() { super.initState(); - _tabController = TabController(length: 5, vsync: this); - _loadOrders(); + if (context.read().state.isAuthenticated) _refresh(); + _scrollController.addListener(_onScroll); } @override void dispose() { - _tabController.dispose(); + _scrollController.dispose(); super.dispose(); } - void _loadOrders() { - // Simulate loading - Future.delayed(const Duration(seconds: 2), () { - setState(() { - _isLoading = false; - // Uncomment untuk testing dengan data - _orders = _generateSampleOrders(); - }); - }); + void _refresh() { + context.read().add(const OrderLoaderEvent.refreshed()); } - List _generateSampleOrders() { - return [ - Order( - id: "ORD-001", - customerName: "John Doe", - orderDate: DateTime.now().subtract(const Duration(hours: 2)), - address: "Jl. Malioboro No. 123, Yogyakarta", - items: [ - OrderItem( - name: "Nasi Gudeg", - quantity: 2, - price: 25000, - notes: "Pedas sedang", - ), - OrderItem(name: "Es Teh Manis", quantity: 2, price: 8000), - OrderItem(name: "Kerupuk", quantity: 1, price: 5000), - ], - totalAmount: 71000, - status: OrderStatus.pending, - notes: "Tolong diantar sebelum jam 2 siang", - ), - Order( - id: "ORD-002", - customerName: "Jane Smith", - orderDate: DateTime.now().subtract(const Duration(hours: 1)), - address: "Jl. Sultan Agung No. 45, Yogyakarta", - items: [ - OrderItem( - name: "Ayam Bakar", - quantity: 1, - price: 35000, - notes: "Tidak pedas", - ), - OrderItem(name: "Nasi Putih", quantity: 1, price: 5000), - OrderItem(name: "Lalapan", quantity: 1, price: 8000), - ], - totalAmount: 48000, - status: OrderStatus.processing, - ), - Order( - id: "ORD-003", - customerName: "Bob Wilson", - orderDate: DateTime.now().subtract(const Duration(minutes: 30)), - phoneNumber: "+62 811-2345-6789", - items: [ - OrderItem(name: "Gado-gado", quantity: 2, price: 20000), - OrderItem(name: "Lontong", quantity: 2, price: 3000), - OrderItem(name: "Es Jeruk", quantity: 2, price: 10000), - ], - totalAmount: 66000, - status: OrderStatus.completed, - ), - ]; + void _onScroll() { + final position = _scrollController.position; + if (position.pixels >= position.maxScrollExtent - 200) { + context.read().add(const OrderLoaderEvent.loadedMore()); + } } @override Widget build(BuildContext context) { + final isAuthenticated = context.select( + (bloc) => bloc.state.isAuthenticated, + ); + return Scaffold( - appBar: _buildAppBar(), - body: Column( - children: [ - _buildTabBar(), - Expanded( - child: _isLoading ? _buildLoadingState() : _buildOrderContent(), - ), - ], + backgroundColor: AppColor.background, + appBar: AppBar( + title: const Text('Pesanan'), + automaticallyImplyLeading: false, ), + body: isAuthenticated ? _buildOrders() : _buildGuest(), ); } - PreferredSizeWidget _buildAppBar() { - return AppBar( - elevation: 0, - backgroundColor: AppColor.white, - automaticallyImplyLeading: false, - title: Text('Pesanan'), - actions: [ - IconButton( - onPressed: _showFilterDialog, - icon: const Icon(Icons.filter_list, color: AppColor.textSecondary), - ), - IconButton( - onPressed: _refreshOrders, - icon: const Icon(Icons.refresh, color: AppColor.textSecondary), - ), - ], - ); - } - - Widget _buildTabBar() { - return Container( - color: AppColor.white, - child: TabBar( - controller: _tabController, - isScrollable: true, - labelColor: AppColor.primary, - unselectedLabelColor: AppColor.textSecondary, - indicatorColor: AppColor.primary, - indicatorWeight: 3, - labelStyle: AppStyle.md.copyWith(fontWeight: FontWeight.w600), - tabAlignment: TabAlignment.start, - unselectedLabelStyle: AppStyle.md, - tabs: const [ - Tab(text: 'Semua'), - Tab(text: 'Menunggu'), - Tab(text: 'Diproses'), - Tab(text: 'Selesai'), - Tab(text: 'Dibatalkan'), - ], + Widget _buildOrders() { + return BlocConsumer( + listenWhen: (p, c) => + p.failureOption != c.failureOption && c.items.isNotEmpty, + listener: (context, state) => state.failureOption.fold( + () {}, + (f) => AppFlushbar.showError(context, walletFailureMessage(f)), ), - ); - } - - Widget _buildOrderContent() { - if (_orders.isEmpty) { - return _buildEmptyState(); - } - - return TabBarView( - controller: _tabController, - children: [ - _buildOrderList(_orders), - _buildOrderList( - _orders.where((o) => o.status == OrderStatus.pending).toList(), - ), - _buildOrderList( - _orders.where((o) => o.status == OrderStatus.processing).toList(), - ), - _buildOrderList( - _orders.where((o) => o.status == OrderStatus.completed).toList(), - ), - _buildOrderList( - _orders.where((o) => o.status == OrderStatus.cancelled).toList(), - ), - ], - ); - } - - Widget _buildOrderList(List orders) { - if (orders.isEmpty) { - return _buildEmptyState(); - } - - return RefreshIndicator( - onRefresh: _refreshOrders, - color: AppColor.primary, - child: ListView.builder( - padding: const EdgeInsets.all(16), - itemCount: orders.length, - itemBuilder: (context, index) { - return OrderCard(order: orders[index]); - }, - ), - ); - } - - Widget _buildEmptyState() { - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: 120, - height: 120, - decoration: BoxDecoration( - color: AppColor.primary.withOpacity(0.1), - borderRadius: BorderRadius.circular(60), + builder: (context, state) { + if (!state.hasLoaded) { + return state.failureOption.fold( + () => const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 36), ), - child: Icon( - Icons.receipt_long, - size: 60, - color: AppColor.primary.withOpacity(0.5), + (f) => _Message( + icon: Icons.wifi_off_rounded, + title: 'Gagal memuat pesanan', + message: walletFailureMessage(f), + actionLabel: 'Coba lagi', + onAction: _refresh, ), - ), - const SizedBox(height: 24), - Text( - 'Belum Ada Pesanan', - style: AppStyle.h6.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - const SizedBox(height: 8), - Text( - 'Pesanan akan muncul di sini setelah\npelanggan mulai memesan.', - style: AppStyle.md.copyWith(color: AppColor.textSecondary), - textAlign: TextAlign.center, - ), - const SizedBox(height: 32), - ElevatedButton.icon( - onPressed: _refreshOrders, - icon: const Icon(Icons.refresh, size: 20), - label: const Text('Muat Ulang'), - style: ElevatedButton.styleFrom( - backgroundColor: AppColor.primary, - foregroundColor: AppColor.white, - padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - ), - ], - ), - ); - } + ); + } - Widget _buildLoadingState() { - return Center( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation(AppColor.primary), - ), - const SizedBox(height: 16), - Text( - 'Memuat pesanan...', - style: AppStyle.md.copyWith(color: AppColor.textSecondary), - ), - ], - ), - ); - } - - void _showFilterDialog() { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text( - 'Filter Pesanan', - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - content: Column( - mainAxisSize: MainAxisSize.min, - children: [ - // Add filter options here - Text('Opsi filter akan segera hadir...', style: AppStyle.md), - ], - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: Text( - 'Tutup', - style: AppStyle.md.copyWith(color: AppColor.primary), - ), - ), - ], + return RefreshIndicator( + color: AppColor.primary, + onRefresh: () async { + _refresh(); + await context.read().stream.firstWhere( + (s) => !s.isFetching, + ); + }, + child: state.items.isEmpty + ? ListView( + children: const [ + SizedBox(height: 80), + _Message( + icon: Icons.receipt_long_rounded, + title: 'Belum ada pesanan', + message: + 'Pesanan akan muncul di sini setelah kasir ' + 'mengaitkannya ke akunmu.', + ), + ], + ) + : ListView.builder( + controller: _scrollController, + physics: const AlwaysScrollableScrollPhysics(), + padding: const EdgeInsets.fromLTRB(16, 12, 16, 24), + itemCount: state.items.length + (state.hasMore ? 1 : 0), + itemBuilder: (context, index) { + if (index >= state.items.length) { + return const Padding( + padding: EdgeInsets.symmetric(vertical: 16), + child: SpinKitThreeBounce( + color: AppColor.primary, + size: 18, + ), + ); + } + return OrderCard(order: state.items[index]); + }, + ), ); }, ); } - Future _refreshOrders() async { - setState(() { - _isLoading = true; - }); - await Future.delayed(const Duration(seconds: 1)); - setState(() { - _isLoading = false; - // Uncomment untuk testing dengan data - _orders = _generateSampleOrders(); - }); + Widget _buildGuest() { + return _Message( + icon: Icons.receipt_long_rounded, + title: 'Lihat pesananmu', + message: + 'Masuk untuk melihat riwayat pesanan dan EnakPoint yang kamu ' + 'dapat dari setiap belanja.', + actionLabel: 'Masuk', + onAction: () => context.router.push(OnboardingRoute()), + ); + } +} + +class _Message extends StatelessWidget { + const _Message({ + required this.icon, + required this.title, + required this.message, + this.actionLabel, + this.onAction, + }); + + final IconData icon; + final String title; + final String message; + final String? actionLabel; + final VoidCallback? onAction; + + @override + Widget build(BuildContext context) { + return Center( + child: Padding( + padding: const EdgeInsets.all(32), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 96, + height: 96, + decoration: BoxDecoration( + color: AppColor.primaryWithOpacity(0.08), + shape: BoxShape.circle, + ), + child: Icon( + icon, + size: 44, + color: AppColor.primaryWithOpacity(0.6), + ), + ), + const SizedBox(height: 20), + Text( + title, + textAlign: TextAlign.center, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 8), + Text( + message, + textAlign: TextAlign.center, + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + if (actionLabel != null) ...[ + const SizedBox(height: 24), + AppElevatedButton( + title: actionLabel!, + width: 180, + onPressed: onAction, + ), + ], + ], + ), + ), + ); } } diff --git a/lib/presentation/pages/main/pages/order/widgets/order_card.dart b/lib/presentation/pages/main/pages/order/widgets/order_card.dart index 0b14936..a900e5c 100644 --- a/lib/presentation/pages/main/pages/order/widgets/order_card.dart +++ b/lib/presentation/pages/main/pages/order/widgets/order_card.dart @@ -1,125 +1,140 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; +import '../../../../../../common/extension/extension.dart'; import '../../../../../../common/theme/theme.dart'; +import '../../../../../../domain/wallet/wallet.dart'; import '../../../../../router/app_router.gr.dart'; -import '../order_page.dart'; +import '../../../../order/order_ui.dart'; +import '../../../../wallet/wallet_ui.dart'; class OrderCard extends StatelessWidget { - final Order order; + final CustomerOrder order; const OrderCard({super.key, required this.order}); @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => context.router.push(OrderDetailRoute(order: order)), - child: Container( - padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 0), - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: AppColor.border.withOpacity(0.3), - width: 1, - ), - ), - ), - child: Row( - children: [ - // Left side - Order info - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Order ID - Text( - order.id, - style: AppStyle.md.copyWith( - fontWeight: FontWeight.w600, - color: AppColor.textPrimary, - ), - ), - const SizedBox(height: 4), - // Order Date - Text( - DateFormat('dd MMM yyyy • HH:mm').format(order.orderDate), - style: AppStyle.sm.copyWith(color: AppColor.textSecondary), - ), - ], - ), - ), - - // Right side - Status and Total - Column( - crossAxisAlignment: CrossAxisAlignment.end, + return Container( + margin: const EdgeInsets.only(bottom: 12), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(AppValue.borderRadius), + onTap: () => context.router.push(OrderDetailRoute(order: order)), + child: Padding( + padding: const EdgeInsets.all(14), + child: Column( children: [ - // Status - Container( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - decoration: BoxDecoration( - color: _getStatusColor().withOpacity(0.1), - borderRadius: BorderRadius.circular(12), - border: Border.all( - color: _getStatusColor().withOpacity(0.2), - width: 1, + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 44, + height: 44, + padding: const EdgeInsets.all(8), + decoration: BoxDecoration( + color: AppColor.primaryWithOpacity(0.08), + borderRadius: BorderRadius.circular(12), + ), + child: orderTypeIcon(order).image(fit: BoxFit.contain), ), - ), - child: Text( - _getStatusText(), - style: AppStyle.xs.copyWith( - color: _getStatusColor(), - fontWeight: FontWeight.w600, + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + order.outletName, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.md.copyWith( + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 2), + Text( + '${order.orderNumber} · ' + '${formatOrderTime(order.createdAt)}', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + ), + ), + const SizedBox(height: 2), + Text( + '${order.itemCount} item · ' + '${orderTypeLabel(order.orderType)}', + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + ), + ), + ], + ), ), - ), + const SizedBox(width: 8), + OrderStatusBadge(order: order), + ], ), - const SizedBox(height: 6), - // Total Amount - Text( - 'Rp ${_formatCurrency(order.totalAmount)}', - style: AppStyle.md.copyWith( - fontWeight: FontWeight.w700, - color: AppColor.textPrimary, - ), + const SizedBox(height: 12), + const Divider(height: 1, color: AppColor.borderLight), + const SizedBox(height: 10), + Row( + children: [ + Text( + order.totalAmount.currencyFormatRp, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + const Spacer(), + if (order.pointsEarned > 0) + _Earned( + currency: WalletCurrency.point, + amount: order.pointsEarned, + ), + if (order.pointsEarned > 0 && order.coinsEarned > 0) + const SizedBox(width: 10), + if (order.coinsEarned > 0) + _Earned( + currency: WalletCurrency.coin, + amount: order.coinsEarned, + ), + ], ), ], ), - ], + ), ), ), ); } +} - Color _getStatusColor() { - switch (order.status) { - case OrderStatus.pending: - return AppColor.warning; - case OrderStatus.processing: - return AppColor.info; - case OrderStatus.completed: - return AppColor.success; - case OrderStatus.cancelled: - return AppColor.error; - } - } +/// "+865" dengan ikon mata uang: saldo yang didapat dari order. +class _Earned extends StatelessWidget { + const _Earned({required this.currency, required this.amount}); - String _getStatusText() { - switch (order.status) { - case OrderStatus.pending: - return 'Menunggu'; - case OrderStatus.processing: - return 'Diproses'; - case OrderStatus.completed: - return 'Selesai'; - case OrderStatus.cancelled: - return 'Dibatalkan'; - } - } + final WalletCurrency currency; + final int amount; - String _formatCurrency(double amount) { - final formatter = NumberFormat('#,###'); - return formatter.format(amount); + @override + Widget build(BuildContext context) { + return Row( + mainAxisSize: MainAxisSize.min, + children: [ + WalletCurrencyIcon(currency: currency, size: 16), + const SizedBox(width: 4), + Text( + '+${amount.thousandFormat}', + style: AppStyle.sm.copyWith( + color: AppColor.success, + fontWeight: FontWeight.w700, + ), + ), + ], + ); } } diff --git a/lib/presentation/pages/main/pages/profile/profile_page.dart b/lib/presentation/pages/main/pages/profile/profile_page.dart index 98b3140..5a5a277 100644 --- a/lib/presentation/pages/main/pages/profile/profile_page.dart +++ b/lib/presentation/pages/main/pages/profile/profile_page.dart @@ -4,6 +4,8 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import '../../../../../application/auth/auth_bloc.dart'; import '../../../../../application/auth/logout_form/logout_form_bloc.dart'; +import '../../../../../application/outlet/outlet_loader/outlet_loader_bloc.dart'; +import '../../../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; import '../../../../../common/theme/theme.dart'; import '../../../../../injection.dart'; import '../../../../components/card/gradient_card.dart'; @@ -22,7 +24,15 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper { () => null, (either) => either.fold( (f) => AppFlushbar.showAuthFailureToast(context, f), - (_) => context.router.replaceAll([OnboardingRoute()]), + (_) { + context.read().add( + const WalletLoaderEvent.cleared(), + ); + context.read().add( + const OutletLoaderEvent.cleared(), + ); + context.router.replaceAll([OnboardingRoute()]); + }, ), ); }, @@ -146,6 +156,12 @@ class ProfilePage extends StatelessWidget implements AutoRouteWrapper { title: 'Pembayaran', onTap: () => context.router.push(PaymentRoute()), ), + _buildMenuItem( + icon: Icons.lock_outline, + title: 'PIN', + onTap: () => + context.router.push(const PinSettingsRoute()), + ), _buildMenuItem( icon: Icons.help_outline, title: 'Pusat Bantuan', diff --git a/lib/presentation/pages/main/widgets/bottom_navbar.dart b/lib/presentation/pages/main/widgets/bottom_navbar.dart index 49dd7c4..f54a262 100644 --- a/lib/presentation/pages/main/widgets/bottom_navbar.dart +++ b/lib/presentation/pages/main/widgets/bottom_navbar.dart @@ -1,16 +1,33 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import '../../../../common/theme/theme.dart'; + class MainBottomNavbar extends StatelessWidget { final TabsRouter tabsRouter; - const MainBottomNavbar({super.key, required this.tabsRouter}); + final VoidCallback onPayTap; + const MainBottomNavbar({ + super.key, + required this.tabsRouter, + required this.onPayTap, + }); + + /// Slot tengah hanya tempat label tombol Bayar; lingkarannya + /// [MainPayButton] yang menempel di atas navbar. + static const int _payIndex = 2; @override Widget build(BuildContext context) { + final activeIndex = tabsRouter.activeIndex; + return BottomNavigationBar( - currentIndex: tabsRouter.activeIndex, + currentIndex: activeIndex >= _payIndex ? activeIndex + 1 : activeIndex, onTap: (index) { - tabsRouter.setActiveIndex(index); + if (index == _payIndex) { + onPayTap(); + return; + } + tabsRouter.setActiveIndex(index > _payIndex ? index - 1 : index); }, items: const [ BottomNavigationBarItem( @@ -28,6 +45,16 @@ class MainBottomNavbar extends StatelessWidget { label: 'Pesanan', tooltip: 'Pesanan', ), + BottomNavigationBarItem( + icon: SizedBox(height: 24), + label: 'Bayar', + tooltip: 'Bayar di kasir', + ), + BottomNavigationBarItem( + icon: Icon(Icons.groups), + label: 'Community', + tooltip: 'Community', + ), BottomNavigationBarItem( icon: Icon(Icons.person), label: 'Profil', @@ -37,3 +64,40 @@ class MainBottomNavbar extends StatelessWidget { ); } } + +/// Seperti [FloatingActionButtonLocation.centerDocked], tapi tombolnya lebih +/// menonjol ke atas supaya tidak menempel ke label "Bayar". +class MainPayButtonLocation extends StandardFabLocation + with FabCenterOffsetX, FabDockedOffsetY { + const MainPayButtonLocation(); + + static const double _raise = 10; + + @override + double getOffsetY( + ScaffoldPrelayoutGeometry scaffoldGeometry, + double adjustment, + ) => super.getOffsetY(scaffoldGeometry, adjustment) - _raise; +} + +/// Tombol bulat di tengah navbar, dipasang di [MainPayButtonLocation]. +class MainPayButton extends StatelessWidget { + final VoidCallback onPressed; + const MainPayButton({super.key, required this.onPressed}); + + @override + Widget build(BuildContext context) { + return FloatingActionButton( + onPressed: onPressed, + // Halaman tab (mis. Community) juga punya FAB; tanpa hero supaya tag + // default tidak bentrok saat pindah halaman. + heroTag: null, + tooltip: 'Bayar di kasir', + elevation: 4, + backgroundColor: AppColor.primary, + foregroundColor: AppColor.white, + shape: const CircleBorder(), + child: const Icon(Icons.qr_code_scanner_rounded, size: 28), + ); + } +} diff --git a/lib/presentation/pages/menu/menu_page.dart b/lib/presentation/pages/menu/menu_page.dart deleted file mode 100644 index f906711..0000000 --- a/lib/presentation/pages/menu/menu_page.dart +++ /dev/null @@ -1,132 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:flutter/material.dart'; - -import '../../../common/data/service_data.dart'; -import '../../../common/theme/theme.dart'; -import '../../../sample/product_sample_data.dart'; -import '../../components/delegate/category_delegate.dart'; -import 'widgets/header.dart'; -import 'widgets/product_section.dart'; - -@RoutePage() -class MenuPage extends StatefulWidget { - final Service service; - const MenuPage({super.key, required this.service}); - - @override - State createState() => _MenuPageState(); -} - -class _MenuPageState extends State { - final ScrollController _scrollController = ScrollController(); - final List _productSectionKeys = []; - - String _selectedCategoryId = ""; - - @override - void initState() { - super.initState(); - _selectedCategoryId = categories.isNotEmpty ? categories.first.id : ""; - - // Initialize keys for each category - for (int i = 0; i < categories.length; i++) { - _productSectionKeys.add(GlobalKey()); - } - } - - void _scrollToCategory(String categoryId) { - setState(() { - _selectedCategoryId = categoryId; - }); - - final categoryIndex = categories.indexWhere((cat) => cat.id == categoryId); - if (categoryIndex >= 0 && categoryIndex < _productSectionKeys.length) { - final key = _productSectionKeys[categoryIndex]; - final context = key.currentContext; - - if (context != null) { - Future.delayed(Duration(milliseconds: 100), () { - if (mounted) { - Scrollable.ensureVisible( - context, - duration: Duration(milliseconds: 500), - curve: Curves.easeInOut, - alignment: 0.1, - ); - } - }); - } - } - } - - List _getProductsByCategory(String categoryId) { - return products - .where((product) => product.categoryId == categoryId) - .toList(); - } - - @override - void dispose() { - _scrollController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: AppColor.background, - body: CustomScrollView( - controller: _scrollController, - slivers: [ - // App Bar with merchant info - SliverAppBar( - expandedHeight: 200, - pinned: true, - backgroundColor: AppColor.primary, - leading: IconButton( - icon: Icon(Icons.arrow_back, color: AppColor.textWhite), - onPressed: () => Navigator.of(context).pop(), - ), - actions: [ - IconButton( - icon: Icon(Icons.share, color: AppColor.textWhite), - onPressed: () {}, - ), - IconButton( - icon: Icon(Icons.favorite_border, color: AppColor.textWhite), - onPressed: () {}, - ), - ], - flexibleSpace: FlexibleSpaceBar( - background: MenuHeader(service: widget.service), - ), - ), - - // Categories (will be pinned) - SliverPersistentHeader( - pinned: true, - delegate: SliverCategoryDelegate( - categories: categories, - selectedCategoryId: _selectedCategoryId, - onCategoryTap: _scrollToCategory, - ), - ), - - // Product sections by category - ...categories.map((category) { - final categoryProducts = _getProductsByCategory(category.id); - final categoryIndex = categories.indexOf(category); - - return SliverToBoxAdapter( - key: _productSectionKeys[categoryIndex], - child: MenuProductSection( - category: category, - categoryProducts: categoryProducts, - ), - ); - }), - ], - ), - ); - } -} diff --git a/lib/presentation/pages/menu/pages/menu_detail/menu_detail_page.dart b/lib/presentation/pages/menu/pages/menu_detail/menu_detail_page.dart deleted file mode 100644 index f1cf4e9..0000000 --- a/lib/presentation/pages/menu/pages/menu_detail/menu_detail_page.dart +++ /dev/null @@ -1,166 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:flutter/material.dart'; - -import '../../../../../common/extension/extension.dart'; -import '../../../../../common/theme/theme.dart'; -import '../../../../../sample/product_sample_data.dart'; -import '../../../../components/button/button.dart'; -import '../../../../components/card/variant_card.dart'; -import '../../../../components/image/image.dart'; -import '../../../../router/app_router.gr.dart'; - -@RoutePage() -class MenuDetailPage extends StatefulWidget { - final Product product; - const MenuDetailPage({super.key, required this.product}); - - @override - State createState() => _MenuDetailPageState(); -} - -class _MenuDetailPageState extends State { - final ScrollController _scrollController = ScrollController(); - double _titleOpacity = 0.0; - - @override - void initState() { - super.initState(); - _scrollController.addListener(_onScroll); - } - - void _onScroll() { - // Hitung opacity berdasarkan scroll offset - // Mulai muncul dari offset 150, full opacity di offset 220 - double offset = _scrollController.offset; - double newOpacity = ((offset - 150) / 70).clamp(0.0, 1.0); - - if (newOpacity != _titleOpacity) { - setState(() => _titleOpacity = newOpacity); - } - } - - @override - void dispose() { - _scrollController.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Scaffold( - bottomNavigationBar: Container( - padding: EdgeInsets.all(AppValue.padding).copyWith(bottom: 24), - decoration: BoxDecoration( - color: AppColor.white, - boxShadow: [ - BoxShadow( - color: AppColor.black.withOpacity(0.1), - offset: Offset(2, 0), - blurRadius: 10, - ), - ], - ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - Expanded(flex: 1, child: QtyButton()), - SizedBox(width: 16), - Expanded( - flex: 2, - child: AppElevatedButton( - onPressed: () => context.router.push(CheckoutRoute()), - title: '+ Keranjang ${"27000".currencyFormatRp}', - ), - ), - ], - ), - ), - body: CustomScrollView( - controller: _scrollController, - slivers: [ - SliverAppBar( - expandedHeight: 240, - pinned: true, - backgroundColor: Colors.white, - title: AnimatedOpacity( - opacity: _titleOpacity, - duration: Duration(milliseconds: 200), - child: Text( - widget.product.name, - style: TextStyle( - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ), - ), - flexibleSpace: FlexibleSpaceBar( - background: Stack( - children: [ - ImagePlaceholder(width: double.infinity, height: 240), - ], - ), - ), - ), - SliverToBoxAdapter( - child: Container( - padding: EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.product.name, - style: AppStyle.xl.copyWith(fontWeight: FontWeight.bold), - ), - SizedBox(height: 4), - Text( - widget.product.description, - style: AppStyle.md.copyWith(fontWeight: FontWeight.w500), - ), - SizedBox(height: 8), - Align( - alignment: Alignment.centerRight, - child: Text( - widget.product.price.currencyFormatRp, - style: AppStyle.xxl.copyWith( - color: AppColor.primary, - fontWeight: FontWeight.w700, - ), - ), - ), - ], - ), - ), - ), - SliverToBoxAdapter( - child: Container( - width: double.infinity, - height: 6, - decoration: BoxDecoration(color: AppColor.borderLight), - ), - ), - SliverToBoxAdapter( - child: Container( - padding: EdgeInsets.all(16), - decoration: BoxDecoration(), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Pilih Varian', - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - SizedBox(height: 12), - VariantCard(name: 'Small'), - SizedBox(height: 8), - VariantCard(name: 'Normal', isSelected: true), - SizedBox(height: 8), - VariantCard(name: 'Large'), - ], - ), - ), - ), - ], - ), - ); - } -} diff --git a/lib/presentation/pages/menu/widgets/header.dart b/lib/presentation/pages/menu/widgets/header.dart deleted file mode 100644 index 3fb076c..0000000 --- a/lib/presentation/pages/menu/widgets/header.dart +++ /dev/null @@ -1,142 +0,0 @@ -import 'package:flutter/material.dart'; - -import '../../../../common/constant/app_constant.dart'; -import '../../../../common/data/service_data.dart'; -import '../../../../common/theme/theme.dart'; - -class MenuHeader extends StatelessWidget { - final Service service; - const MenuHeader({super.key, required this.service}); - - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [AppColor.primary, AppColor.primary.withOpacity(0.8)], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - ), - ), - child: Stack( - children: [ - // Background decoration - Positioned( - right: 20, - top: 60, - child: Opacity( - opacity: 0.1, - child: Icon(Icons.store, size: 100, color: AppColor.textWhite), - ), - ), - - // Content - Positioned( - left: 20, - right: 20, - bottom: 20, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Service - Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - service.name, - style: AppStyle.lg.copyWith( - color: AppColor.white, - fontWeight: FontWeight.bold, - ), - ), - Text( - service.description, - style: AppStyle.md.copyWith( - color: AppColor.white, - fontWeight: FontWeight.w500, - ), - ), - ], - ), - ), - SizedBox(width: 12), - Image.asset(service.imagePath, width: 60, height: 60), - ], - ), - - SizedBox(height: 16), - // Merchant - Row( - children: [ - Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: AppColor.surface, - borderRadius: BorderRadius.circular(12), - boxShadow: [ - BoxShadow( - color: AppColor.black.withOpacity(0.2), - blurRadius: 8, - offset: Offset(0, 4), - ), - ], - ), - child: Center( - child: ClipRRect( - borderRadius: BorderRadius.circular(12), - child: Image.asset(merchant.imageUrl), - ), - ), - ), - SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - merchant.name, - style: AppStyle.h6.copyWith( - color: AppColor.textWhite, - fontWeight: FontWeight.bold, - ), - ), - Text( - merchant.category, - style: AppStyle.md.copyWith( - color: AppColor.textWhite.withOpacity(0.9), - ), - ), - Row(children: [SizedBox(width: 12)]), - ], - ), - ), - Container( - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), - decoration: BoxDecoration( - color: merchant.isOpen - ? AppColor.success - : AppColor.error, - borderRadius: BorderRadius.circular(6), - ), - child: Text( - merchant.isOpen ? "BUKA" : "TUTUP", - style: AppStyle.xs.copyWith( - color: AppColor.textWhite, - fontWeight: FontWeight.bold, - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - ); - } -} diff --git a/lib/presentation/pages/menu/widgets/product_section.dart b/lib/presentation/pages/menu/widgets/product_section.dart deleted file mode 100644 index 14b687d..0000000 --- a/lib/presentation/pages/menu/widgets/product_section.dart +++ /dev/null @@ -1,77 +0,0 @@ -import 'package:auto_route/auto_route.dart'; -import 'package:flutter/material.dart'; - -import '../../../../common/theme/theme.dart'; -import '../../../../sample/product_sample_data.dart'; -import '../../../components/card/product_card.dart'; -import '../../../components/card/product_empty_card.dart'; -import '../../../router/app_router.gr.dart'; - -class MenuProductSection extends StatelessWidget { - final ProductCategory category; - final List categoryProducts; - const MenuProductSection({ - super.key, - required this.category, - required this.categoryProducts, - }); - - @override - Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(bottom: 24), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Section header - Padding( - padding: EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: Row( - children: [ - Text(category.icon, style: AppStyle.h5), - SizedBox(width: 8), - Text( - category.name, - style: AppStyle.lg.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - SizedBox(width: 8), - Text( - "(${categoryProducts.length})", - style: AppStyle.md.copyWith(color: AppColor.textSecondary), - ), - ], - ), - ), - - // Products grid - if (categoryProducts.isEmpty) - ProductEmptyCard() - else - GridView.builder( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.symmetric(horizontal: 16), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 2, - crossAxisSpacing: 12, - mainAxisSpacing: 12, - childAspectRatio: 0.75, - ), - itemCount: categoryProducts.length, - itemBuilder: (context, index) { - return ProductCard( - product: categoryProducts[index], - onTap: () => context.router.push( - MenuDetailRoute(product: categoryProducts[index]), - ), - ); - }, - ), - ], - ), - ); - } -} diff --git a/lib/presentation/pages/mini_games/ferris_wheel/ferris_wheel_page.dart b/lib/presentation/pages/mini_games/ferris_wheel/ferris_wheel_page.dart index 605a945..3439011 100644 --- a/lib/presentation/pages/mini_games/ferris_wheel/ferris_wheel_page.dart +++ b/lib/presentation/pages/mini_games/ferris_wheel/ferris_wheel_page.dart @@ -5,12 +5,20 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'dart:math' as math; +import 'package:dartz/dartz.dart' hide State; + import '../../../../application/auth/auth_bloc.dart'; import '../../../../application/game/ferris_wheel_loader/ferris_wheel_loader_bloc.dart'; +import '../../../../application/game/game_spin/game_spin_bloc.dart'; +import '../../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; +import '../../../../common/extension/extension.dart'; import '../../../../common/theme/theme.dart'; import '../../../../common/painter/wheel_painter.dart'; import '../../../../injection.dart'; import '../../../../domain/game/game.dart'; +import '../../../../domain/wallet/wallet.dart'; +import '../../../components/toast/flushbar.dart'; +import '../../wallet/wallet_ui.dart'; // Simple models for UI state class PrizeHistory { @@ -39,10 +47,15 @@ class FerrisWheelPage extends StatefulWidget implements AutoRouteWrapper { State createState() => _FerrisWheelPageState(); @override - Widget wrappedRoute(BuildContext context) => BlocProvider( - create: (context) => - getIt() - ..add(const FerrisWheelLoaderEvent.fetched()), + Widget wrappedRoute(BuildContext context) => MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => + getIt() + ..add(const FerrisWheelLoaderEvent.fetched()), + ), + BlocProvider(create: (context) => getIt()), + ], child: this, ); } @@ -69,7 +82,6 @@ class _FerrisWheelPageState extends State bool _isMusicEnabled = true; // Game State - int tokens = 3; bool isSpinning = false; String resultText = 'Belum pernah spin'; double currentRotation = 0.0; @@ -84,6 +96,7 @@ class _FerrisWheelPageState extends State super.initState(); _initializeAudio(); _initializeAnimations(); + context.read().add(const WalletLoaderEvent.fetched()); } @override @@ -167,39 +180,11 @@ class _FerrisWheelPageState extends State _idleRotationController.repeat(); } - int _selectPrizeWithWeight() { - if (gamePrizes.isEmpty) return 0; + int get _coinBalance => + context.read().state.summary.coinBalance; - // Jika GamePrize memiliki properti weight, gunakan ini: - // List weights = gamePrizes.map((prize) => prize.weight ?? 1).toList(); - - // Untuk sementara, gunakan bobot default yang berbeda - // Hadiah langka (index awal) memiliki bobot lebih kecil - List weights = []; - for (int i = 0; i < gamePrizes.length; i++) { - // Bobot menurun: hadiah pertama langka, hadiah terakhir mudah didapat - int weight = gamePrizes.length - i; - weights.add(weight); - } - - // Hitung total bobot - int totalWeight = weights.reduce((a, b) => a + b); - - // Generate random number - int randomNum = math.Random().nextInt(totalWeight); - - // Tentukan hadiah berdasarkan bobot - int currentWeight = 0; - for (int i = 0; i < gamePrizes.length; i++) { - currentWeight += weights[i]; - if (randomNum < currentWeight) { - return i; - } - } - - // Fallback (seharusnya tidak pernah terjadi) - return gamePrizes.length - 1; - } + int get _coinCost => + context.read().state.ferrisWheel.coinCost; Color _getPrizeColor(GamePrize prize, int index) { final colors = [ @@ -214,22 +199,70 @@ class _FerrisWheelPageState extends State return colors[index % colors.length]; } + /// Hadiah ditentukan server; roda hanya dianimasikan ke hadiah itu. void _spinWheel() { - if (isSpinning || tokens <= 0 || gamePrizes.isEmpty) return; + if (isSpinning || gamePrizes.isEmpty) return; + + final game = context.read().state.ferrisWheel; + if (_coinBalance < _coinCost) { + AppFlushbar.showError( + context, + 'EnakCoin kamu kurang. Butuh $_coinCost EnakCoin untuk main.', + ); + return; + } - _playWheelSpin(); _playTokenSound(); - setState(() { isSpinning = true; - tokens--; resultText = 'Sedang berputar...'; }); + context.read().add(GameSpinEvent.spun(game.id)); + } + + void _onSpinResult(Either either) { + either.fold( + (f) { + final message = f.map( + serverError: (value) => value.failure.toStringFormatted(context), + unexpectedError: (_) => 'Terjadi kesalahan, coba lagi', + dynamicErrorMessage: (value) => value.erroMessage, + ); + setState(() { + isSpinning = false; + resultText = 'Belum berhasil, silakan coba lagi'; + }); + AppFlushbar.showError(context, message); + }, + (result) { + context.read().add( + WalletLoaderEvent.coinBalanceUpdated(result.coinsRemaining), + ); + + var index = gamePrizes.indexWhere((p) => p.id == result.prizeId); + if (index < 0) { + index = gamePrizes.indexWhere((p) => p.name == result.prizeName); + } + _animateToPrize( + index < 0 ? 0 : index, + index < 0 + ? GamePrize.empty().copyWith( + id: result.prizeId, + name: result.prizeName, + ) + : gamePrizes[index], + ); + }, + ); + } + + void _animateToPrize(int selectedPrizeIndex, GamePrize wonPrize) { + _playWheelSpin(); + _idleRotationController.stop(); _idleRotationController.reset(); - int selectedPrizeIndex = _selectPrizeWithWeight(); double sectionAngle = (2 * math.pi) / gamePrizes.length; double currentPos = currentRotation; @@ -254,7 +287,7 @@ class _FerrisWheelPageState extends State _rotationController.reset(); _rotationController.animateTo(1.0).then((_) { - final wonPrize = gamePrizes[selectedPrizeIndex]; + if (!mounted) return; _playWinSound(); setState(() { @@ -373,6 +406,15 @@ class _FerrisWheelPageState extends State @override Widget build(BuildContext context) { + return BlocListener( + listenWhen: (p, c) => p.failureOrResultOption != c.failureOrResultOption, + listener: (context, state) => + state.failureOrResultOption.fold(() {}, _onSpinResult), + child: _buildPage(), + ); + } + + Widget _buildPage() { return BlocBuilder( builder: (context, state) { if (state.isFetching) { @@ -599,21 +641,15 @@ class _FerrisWheelPageState extends State ), Row( children: [ - Container( - width: 20, - height: 20, - decoration: BoxDecoration( - color: AppColor.warning, - shape: BoxShape.circle, - ), - child: Icon(Icons.circle, size: 12, color: AppColor.textWhite), - ), + const WalletCurrencyIcon(currency: WalletCurrency.coin, size: 20), const SizedBox(width: 8), - Text( - 'Token: $tokens', - style: AppStyle.lg.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, + BlocBuilder( + builder: (context, wallet) => Text( + '${wallet.summary.coinBalance.thousandFormat} EnakCoin', + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.bold, + color: AppColor.textPrimary, + ), ), ), ], @@ -689,6 +725,16 @@ class _FerrisWheelPageState extends State } Widget _buildSpinButton() { + return BlocSelector( + selector: (state) => state.summary.coinBalance, + builder: (context, coinBalance) => Opacity( + opacity: coinBalance >= _coinCost ? 1 : 0.5, + child: _buildSpinButtonBody(), + ), + ); + } + + Widget _buildSpinButtonBody() { return AnimatedBuilder( animation: _pulseAnimation ?? const AlwaysStoppedAnimation(1.0), builder: (context, child) => Transform.scale( @@ -737,21 +783,31 @@ class _FerrisWheelPageState extends State } Widget _buildBottomBanner() { - return Container( - margin: const EdgeInsets.all(20), - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - gradient: LinearGradient(colors: [AppColor.warning, AppColor.warning]), - borderRadius: BorderRadius.circular(15), - ), - child: Text( - 'Spin 30x lagi buat mainin spesial spin', - textAlign: TextAlign.center, - style: AppStyle.lg.copyWith( - color: AppColor.textWhite, - fontWeight: FontWeight.bold, - ), - ), + return BlocSelector( + selector: (state) => state.summary.coinBalance, + builder: (context, coinBalance) { + final cost = _coinCost; + return Container( + margin: const EdgeInsets.all(20), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [AppColor.warning, AppColor.warning], + ), + borderRadius: BorderRadius.circular(15), + ), + child: Text( + coinBalance >= cost + ? 'Sekali main: $cost EnakCoin' + : 'Sekali main: $cost EnakCoin. EnakCoin kamu belum cukup.', + textAlign: TextAlign.center, + style: AppStyle.lg.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.bold, + ), + ), + ); + }, ); } diff --git a/lib/presentation/pages/news/news_page.dart b/lib/presentation/pages/news/news_page.dart new file mode 100644 index 0000000..3b9e505 --- /dev/null +++ b/lib/presentation/pages/news/news_page.dart @@ -0,0 +1,135 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../sample/news_sample_data.dart'; +import '../../components/delegate/filter_bar_delegate.dart'; +import '../../router/app_router.gr.dart'; +import 'widgets/news_headline_card.dart'; +import 'widgets/news_list_tile.dart'; + +@RoutePage() +class NewsPage extends StatefulWidget { + const NewsPage({super.key}); + + @override + State createState() => _NewsPageState(); +} + +class _NewsPageState extends State { + /// `null` berarti semua kategori. + static const List _filters = [null, ...NewsCategory.values]; + + NewsCategory? _category; + + /// Terbaru di atas. + final List _articles = newsSamples + ..sort((a, b) => b.publishedAt.compareTo(a.publishedAt)); + + void _open(NewsArticle article) => + context.router.push(NewsDetailRoute(article: article)); + + @override + Widget build(BuildContext context) { + final visible = _articles + .where((a) => _category == null || a.category == _category) + .toList(); + // Berita utama hanya di "Semua"; di kategori lain semua jadi daftar. + final headline = _category == null + ? visible.where((a) => a.isHeadline).firstOrNull + : null; + final rest = visible.where((a) => a != headline).toList(); + + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('EnakNews')), + body: CustomScrollView( + slivers: [ + SliverPersistentHeader( + pinned: true, + delegate: FilterBarDelegate( + values: _filters, + selected: _category, + labelOf: (category) => category?.label ?? 'Semua', + onSelected: (category) => setState(() => _category = category), + ), + ), + if (headline != null) + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 20), + sliver: SliverToBoxAdapter( + child: NewsHeadlineCard( + article: headline, + onTap: () => _open(headline), + ), + ), + ), + if (visible.isEmpty) + SliverFillRemaining(hasScrollBody: false, child: _buildEmpty()) + else if (rest.isNotEmpty) ...[ + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 10), + sliver: SliverToBoxAdapter( + child: Text( + _category?.label ?? 'Terbaru', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + ), + ), + SliverPadding( + padding: const EdgeInsets.symmetric(horizontal: 16), + sliver: SliverToBoxAdapter(child: _buildList(rest)), + ), + ], + const SliverToBoxAdapter(child: SizedBox(height: 24)), + ], + ), + ); + } + + Widget _buildList(List articles) { + return Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + clipBehavior: Clip.antiAlias, + child: Column( + children: [ + for (var i = 0; i < articles.length; i++) ...[ + if (i > 0) + const Divider( + height: 1, + indent: 16, + endIndent: 16, + color: AppColor.borderLight, + ), + NewsListTile(article: articles[i], onTap: () => _open(articles[i])), + ], + ], + ), + ); + } + + Widget _buildEmpty() { + return Padding( + padding: const EdgeInsets.fromLTRB(32, 32, 32, 64), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('📰', style: TextStyle(fontSize: 44)), + const SizedBox(height: 16), + Text( + 'Belum ada berita', + textAlign: TextAlign.center, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text( + 'Berita terbaru dari outlet akan muncul di sini.', + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/news/news_ui.dart b/lib/presentation/pages/news/news_ui.dart new file mode 100644 index 0000000..6d11991 --- /dev/null +++ b/lib/presentation/pages/news/news_ui.dart @@ -0,0 +1,111 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../sample/news_sample_data.dart'; + +extension NewsCategoryUi on NewsCategory { + Color get color => switch (this) { + NewsCategory.menu => const Color(0xFFD9642A), + NewsCategory.promo => AppColor.primary, + NewsCategory.event => const Color(0xFF7D63C9), + NewsCategory.info => const Color(0xFF3B7BBF), + NewsCategory.tips => const Color(0xFF2F8A5B), + }; + + IconData get icon => switch (this) { + NewsCategory.menu => Icons.restaurant_menu_rounded, + NewsCategory.promo => Icons.local_offer_rounded, + NewsCategory.event => Icons.celebration_rounded, + NewsCategory.info => Icons.campaign_rounded, + NewsCategory.tips => Icons.lightbulb_rounded, + }; +} + +/// "Baru saja" / "5 menit lalu" / "3 jam lalu" / "Kemarin" / "2 hari lalu", +/// lalu tanggal pendek. +String formatNewsTime(DateTime time) { + final diff = DateTime.now().difference(time); + if (diff.inMinutes < 1) return 'Baru saja'; + if (diff.inHours < 1) return '${diff.inMinutes} menit lalu'; + if (diff.inDays < 1) return '${diff.inHours} jam lalu'; + if (diff.inDays == 1) return 'Kemarin'; + if (diff.inDays < 7) return '${diff.inDays} hari lalu'; + return DateFormat('d MMM yyyy', 'id_ID').format(time); +} + +/// "3 jam lalu · 2 menit baca". +String newsMetaLabel(NewsArticle article) => + '${formatNewsTime(article.publishedAt)} · ' + '${article.readMinutes} menit baca'; + +/// Sampul artikel: foto, atau warna kategori dengan ikon bila tidak ada foto. +class NewsCover extends StatelessWidget { + const NewsCover({super.key, required this.article, this.iconSize = 40}); + + final NewsArticle article; + final double iconSize; + + @override + Widget build(BuildContext context) { + final image = article.coverImage; + if (image != null) { + return Image.asset( + image, + fit: BoxFit.cover, + errorBuilder: (_, _, _) => _buildFallback(), + ); + } + return _buildFallback(); + } + + Widget _buildFallback() { + final color = article.category.color; + return DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [color.withOpacity(0.75), color], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + ), + child: Center( + child: Icon( + article.category.icon, + size: iconSize, + color: AppColor.white.withOpacity(0.9), + ), + ), + ); + } +} + +/// Label kategori berwarna; [onImage] untuk di atas foto sampul. +class NewsCategoryPill extends StatelessWidget { + const NewsCategoryPill({ + super.key, + required this.category, + this.onImage = false, + }); + + final NewsCategory category; + final bool onImage; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + decoration: BoxDecoration( + color: onImage ? AppColor.white : category.color.withOpacity(0.1), + borderRadius: BorderRadius.circular(20), + ), + child: Text( + category.label, + style: AppStyle.xs.copyWith( + color: category.color, + fontWeight: FontWeight.w800, + ), + ), + ); + } +} diff --git a/lib/presentation/pages/news/pages/news_detail/news_detail_page.dart b/lib/presentation/pages/news/pages/news_detail/news_detail_page.dart new file mode 100644 index 0000000..8ae419e --- /dev/null +++ b/lib/presentation/pages/news/pages/news_detail/news_detail_page.dart @@ -0,0 +1,269 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../../../../../common/theme/theme.dart'; +import '../../../../../sample/news_sample_data.dart'; +import '../../../../components/assets/assets.gen.dart'; +import '../../../../router/app_router.gr.dart'; +import '../../news_ui.dart'; +import '../../widgets/news_list_tile.dart'; + +@RoutePage() +class NewsDetailPage extends StatefulWidget { + const NewsDetailPage({super.key, required this.article}); + + final NewsArticle article; + + @override + State createState() => _NewsDetailPageState(); +} + +class _NewsDetailPageState extends State { + static const double _expandedHeight = 260; + static const int _relatedCount = 3; + + final _scrollController = ScrollController(); + bool _isCollapsed = false; + + late final List _related = _findRelated(); + + /// Kategori yang sama lebih dulu, lalu yang terbaru. + List _findRelated() { + final current = widget.article; + final others = newsSamples.where((a) => a.id != current.id).toList() + ..sort((a, b) { + final aSame = a.category == current.category; + final bSame = b.category == current.category; + if (aSame != bSame) return aSame ? -1 : 1; + return b.publishedAt.compareTo(a.publishedAt); + }); + return others.take(_relatedCount).toList(); + } + + @override + void initState() { + super.initState(); + _scrollController.addListener(() { + final collapsed = + _scrollController.offset > _expandedHeight - kToolbarHeight - 20; + if (collapsed != _isCollapsed) setState(() => _isCollapsed = collapsed); + }); + } + + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final article = widget.article; + + return Scaffold( + backgroundColor: AppColor.white, + body: CustomScrollView( + controller: _scrollController, + slivers: [ + _buildAppBar(article), + SliverToBoxAdapter(child: _buildBody(article)), + if (_related.isNotEmpty) ...[ + SliverToBoxAdapter( + child: Container( + height: 8, + margin: const EdgeInsets.only(top: 8), + color: AppColor.background, + ), + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 20, 16, 4), + child: Text( + 'Baca juga', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + ), + SliverList.separated( + itemCount: _related.length, + separatorBuilder: (_, _) => const Divider( + height: 1, + indent: 16, + endIndent: 16, + color: AppColor.borderLight, + ), + itemBuilder: (context, index) { + final related = _related[index]; + return NewsListTile( + article: related, + onTap: () => + context.router.push(NewsDetailRoute(article: related)), + ); + }, + ), + ], + SliverToBoxAdapter( + child: SizedBox(height: 24 + MediaQuery.paddingOf(context).bottom), + ), + ], + ), + ); + } + + Widget _buildAppBar(NewsArticle article) { + return SliverAppBar( + pinned: true, + expandedHeight: _expandedHeight, + backgroundColor: AppColor.white, + automaticallyImplyLeading: false, + leading: Padding( + padding: const EdgeInsets.only(left: 12), + child: _CircleButton( + icon: Icons.arrow_back_rounded, + onTap: () => context.router.maybePop(), + ), + ), + leadingWidth: 60, + title: AnimatedOpacity( + opacity: _isCollapsed ? 1 : 0, + duration: const Duration(milliseconds: 200), + child: Text(article.category.label), + ), + flexibleSpace: FlexibleSpaceBar( + background: Stack( + fit: StackFit.expand, + children: [ + NewsCover(article: article, iconSize: 72), + DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [AppColor.black.withOpacity(0.3), Colors.transparent], + ), + ), + ), + ], + ), + ), + // Lengkungan "sheet" di atas foto sampul. + bottom: PreferredSize( + preferredSize: const Size.fromHeight(24), + child: Container( + height: 24, + decoration: const BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.vertical(top: Radius.circular(28)), + ), + ), + ), + ); + } + + Widget _buildBody(NewsArticle article) { + return Padding( + padding: const EdgeInsets.fromLTRB(20, 0, 20, 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + NewsCategoryPill(category: article.category), + const SizedBox(height: 10), + Text( + article.title, + style: AppStyle.h5.copyWith( + fontWeight: FontWeight.w800, + height: 1.25, + ), + ), + const SizedBox(height: 14), + Row( + children: [ + ClipOval( + child: SizedBox( + width: 32, + height: 32, + // Sudut aset logo berlatar gelap; perbesar supaya yang + // terlihat hanya lingkaran merahnya. + child: Transform.scale( + scale: 1.2, + child: Assets.images.logo.image( + fit: BoxFit.cover, + cacheWidth: (40 * MediaQuery.devicePixelRatioOf(context)) + .round(), + ), + ), + ), + ), + const SizedBox(width: 10), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + article.author, + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w700), + ), + Text( + '${DateFormat('d MMMM yyyy', 'id_ID').format(article.publishedAt)}' + ' · ${article.readMinutes} menit baca', + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + ), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 16), + const Divider(height: 1, color: AppColor.borderLight), + const SizedBox(height: 16), + Text( + article.summary, + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.w600, + height: 1.5, + ), + ), + for (final paragraph in article.paragraphs) ...[ + const SizedBox(height: 14), + Text( + paragraph, + style: AppStyle.md.copyWith( + color: AppColor.textPrimary.withOpacity(0.85), + height: 1.7, + ), + ), + ], + ], + ), + ); + } +} + +class _CircleButton extends StatelessWidget { + const _CircleButton({required this.icon, required this.onTap}); + + final IconData icon; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Center( + child: Material( + color: AppColor.white.withOpacity(0.92), + shape: const CircleBorder(), + child: InkWell( + customBorder: const CircleBorder(), + onTap: onTap, + child: SizedBox( + width: 40, + height: 40, + child: Icon(icon, size: 20, color: AppColor.textPrimary), + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/news/widgets/news_headline_card.dart b/lib/presentation/pages/news/widgets/news_headline_card.dart new file mode 100644 index 0000000..940f346 --- /dev/null +++ b/lib/presentation/pages/news/widgets/news_headline_card.dart @@ -0,0 +1,78 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/news_sample_data.dart'; +import '../news_ui.dart'; + +/// Berita utama: sampul lebar di atas, judul dan ringkasan di bawahnya. +/// +/// Teks tidak ditumpuk di atas foto karena sampul outlet sering berupa +/// banner bertulisan. +class NewsHeadlineCard extends StatelessWidget { + const NewsHeadlineCard({ + super.key, + required this.article, + required this.onTap, + }); + + final NewsArticle article; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(20), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: onTap, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AspectRatio( + aspectRatio: 16 / 9, + child: NewsCover(article: article, iconSize: 64), + ), + Padding( + padding: const EdgeInsets.fromLTRB(16, 14, 16, 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + NewsCategoryPill(category: article.category), + const SizedBox(height: 8), + Text( + article.title, + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: AppStyle.xl.copyWith( + fontWeight: FontWeight.w800, + height: 1.25, + ), + ), + const SizedBox(height: 6), + Text( + article.summary, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + height: 1.4, + ), + ), + const SizedBox(height: 10), + Text( + newsMetaLabel(article), + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/news/widgets/news_list_tile.dart b/lib/presentation/pages/news/widgets/news_list_tile.dart new file mode 100644 index 0000000..45b840a --- /dev/null +++ b/lib/presentation/pages/news/widgets/news_list_tile.dart @@ -0,0 +1,69 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/news_sample_data.dart'; +import '../news_ui.dart'; + +/// Baris artikel: kategori, judul, dan waktu di kiri, sampul kecil di kanan. +class NewsListTile extends StatelessWidget { + const NewsListTile({super.key, required this.article, required this.onTap}); + + final NewsArticle article; + final VoidCallback onTap; + + static const double _thumbSize = 88; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + article.category.label.toUpperCase(), + style: AppStyle.xs.copyWith( + color: article.category.color, + fontWeight: FontWeight.w800, + letterSpacing: 0.4, + ), + ), + const SizedBox(height: 4), + Text( + article.title, + maxLines: 3, + overflow: TextOverflow.ellipsis, + style: AppStyle.md.copyWith( + fontWeight: FontWeight.w700, + height: 1.3, + ), + ), + const SizedBox(height: 6), + Text( + newsMetaLabel(article), + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ), + const SizedBox(width: 12), + ClipRRect( + borderRadius: BorderRadius.circular(12), + child: SizedBox( + width: _thumbSize, + height: _thumbSize, + child: NewsCover(article: article, iconSize: 32), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/order/order_detail/order_detail_page.dart b/lib/presentation/pages/order/order_detail/order_detail_page.dart index 7016635..1488647 100644 --- a/lib/presentation/pages/order/order_detail/order_detail_page.dart +++ b/lib/presentation/pages/order/order_detail/order_detail_page.dart @@ -1,892 +1,479 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; -import '../../../../../common/theme/theme.dart'; -import '../../main/pages/order/order_page.dart'; +import '../../../../application/order/order_detail_loader/order_detail_loader_bloc.dart'; +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../domain/wallet/wallet.dart'; +import '../../../../injection.dart'; +import '../../../components/button/button.dart'; +import '../../wallet/wallet_ui.dart'; +import '../order_ui.dart'; +/// Detail order (§4.5). Ringkasan dari daftar tampil lebih dulu selagi +/// rincian item dan pembayaran dimuat. @RoutePage() -class OrderDetailPage extends StatefulWidget { - final Order order; +class OrderDetailPage extends StatelessWidget implements AutoRouteWrapper { + final CustomerOrder order; const OrderDetailPage({super.key, required this.order}); @override - State createState() => _OrderDetailPageState(); -} + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (_) => + getIt() + ..add(OrderDetailLoaderEvent.fetched(order.id)), + child: this, + ); -class _OrderDetailPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: AppColor.white, - appBar: _buildAppBar(), - body: SingleChildScrollView( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildOrderHeader(), - const SizedBox(height: 24), - _buildCustomerInfo(), - const SizedBox(height: 24), - _buildOrderItems(), - const SizedBox(height: 24), - _buildOrderSummary(), - if (widget.order.notes != null) ...[ - const SizedBox(height: 24), - _buildOrderNotes(), - ], - const SizedBox(height: 32), - _buildActionButtons(), - const SizedBox(height: 16), - ], - ), - ), - ); - } + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Detail Pesanan')), + body: BlocBuilder( + builder: (context, state) { + final detail = state.detailOption.toNullable(); + // Data terbaru dari detail, bila sudah ada. + final current = detail?.order ?? order; - PreferredSizeWidget _buildAppBar() { - return AppBar( - title: Text('Detail Pesanan'), - actions: [ - IconButton( - onPressed: _shareOrder, - icon: const Icon(Icons.share, color: AppColor.textSecondary), - ), - PopupMenuButton( - onSelected: _handleMenuAction, - icon: const Icon(Icons.more_vert, color: AppColor.textSecondary), - itemBuilder: (context) => [ - const PopupMenuItem( - value: 'edit', - child: Row( - children: [ - Icon(Icons.edit, size: 20), - SizedBox(width: 12), - Text('Edit Pesanan'), - ], - ), - ), - const PopupMenuItem( - value: 'duplicate', - child: Row( - children: [ - Icon(Icons.content_copy, size: 20), - SizedBox(width: 12), - Text('Duplikat Pesanan'), - ], - ), - ), - const PopupMenuItem( - value: 'delete', - child: Row( - children: [ - Icon(Icons.delete, size: 20, color: Colors.red), - SizedBox(width: 12), - Text('Hapus Pesanan', style: TextStyle(color: Colors.red)), - ], - ), - ), - ], - ), - ], - ); - } - - Widget _buildOrderHeader() { - return Container( - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - color: AppColor.background, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: AppColor.border), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + return ListView( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 32), children: [ - Text( - widget.order.id, - style: AppStyle.lg.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - _buildStatusBadge(widget.order.status), - ], - ), - const SizedBox(height: 12), - Row( - children: [ - Icon(Icons.access_time, size: 16, color: AppColor.textSecondary), - const SizedBox(width: 8), - Text( - _formatDateTime(widget.order.orderDate), - style: AppStyle.sm.copyWith(color: AppColor.textSecondary), - ), - ], - ), - ], - ), - ); - } - - Widget _buildStatusBadge(OrderStatus status) { - Color backgroundColor; - Color textColor; - String text; - - switch (status) { - case OrderStatus.pending: - backgroundColor = Colors.orange.withOpacity(0.1); - textColor = Colors.orange; - text = 'Menunggu'; - break; - case OrderStatus.processing: - backgroundColor = Colors.blue.withOpacity(0.1); - textColor = Colors.blue; - text = 'Diproses'; - break; - case OrderStatus.completed: - backgroundColor = Colors.green.withOpacity(0.1); - textColor = Colors.green; - text = 'Selesai'; - break; - case OrderStatus.cancelled: - backgroundColor = Colors.red.withOpacity(0.1); - textColor = Colors.red; - text = 'Dibatalkan'; - break; - } - - return Container( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), - decoration: BoxDecoration( - color: backgroundColor, - borderRadius: BorderRadius.circular(20), - ), - child: Text( - text, - style: AppStyle.sm.copyWith( - fontWeight: FontWeight.w600, - color: textColor, - ), - ), - ); - } - - Widget _buildCustomerInfo() { - return Container( - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - color: AppColor.background, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: AppColor.border), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Informasi Pelanggan', - style: AppStyle.md.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - const SizedBox(height: 16), - _buildInfoRow( - icon: Icons.person, - label: 'Nama', - value: widget.order.customerName, - ), - if (widget.order.phoneNumber != null) ...[ - const SizedBox(height: 12), - _buildInfoRow( - icon: Icons.phone, - label: 'Telepon', - value: widget.order.phoneNumber!, - isClickable: true, - ), - ], - if (widget.order.address != null) ...[ - const SizedBox(height: 12), - _buildInfoRow( - icon: Icons.location_on, - label: 'Alamat', - value: widget.order.address!, - isMultiline: true, - ), - ], - ], - ), - ); - } - - Widget _buildInfoRow({ - required IconData icon, - required String label, - required String value, - bool isClickable = false, - bool isMultiline = false, - }) { - return Row( - crossAxisAlignment: isMultiline - ? CrossAxisAlignment.start - : CrossAxisAlignment.center, - children: [ - Container( - padding: const EdgeInsets.all(8), - decoration: BoxDecoration( - color: AppColor.primary.withOpacity(0.1), - borderRadius: BorderRadius.circular(8), - ), - child: Icon(icon, size: 18, color: AppColor.primary), - ), - const SizedBox(width: 12), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - label, - style: AppStyle.xs.copyWith( - color: AppColor.textSecondary, - fontWeight: FontWeight.w500, - ), - ), - const SizedBox(height: 2), - GestureDetector( - onTap: isClickable ? () => _callCustomer(value) : null, - child: Text( - value, - style: AppStyle.sm.copyWith( - color: isClickable - ? AppColor.primary - : AppColor.textPrimary, - fontWeight: FontWeight.w500, - decoration: isClickable ? TextDecoration.underline : null, - ), - ), - ), - ], - ), - ), - ], - ); - } - - Widget _buildOrderItems() { - return Container( - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - color: AppColor.background, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: AppColor.border), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Item Pesanan', - style: AppStyle.md.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - const SizedBox(height: 16), - ...widget.order.items.asMap().entries.map((entry) { - final index = entry.key; - final item = entry.value; - return Column( - children: [ - if (index > 0) - Padding( - padding: const EdgeInsets.symmetric(vertical: 12), - child: Divider(color: AppColor.border, height: 1), - ), - _buildOrderItem(item), + if (current.isVoid || current.isRefund) ...[ + _CancelledBanner(order: current), + const SizedBox(height: 12), ], - ); - }).toList(), - ], - ), - ); - } - - Widget _buildOrderItem(OrderItem item) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: 60, - height: 60, - decoration: BoxDecoration( - color: AppColor.primary.withOpacity(0.1), - borderRadius: BorderRadius.circular(8), - ), - child: item.imageUrl != null - ? ClipRRect( - borderRadius: BorderRadius.circular(8), - child: Image.network( - item.imageUrl!, - fit: BoxFit.cover, - errorBuilder: (context, error, stackTrace) { - return Icon( - Icons.restaurant, - color: AppColor.primary, - size: 24, - ); - }, - ), - ) - : Icon(Icons.restaurant, color: AppColor.primary, size: 24), - ), - const SizedBox(width: 16), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - item.name, - style: AppStyle.md.copyWith( - fontWeight: FontWeight.w600, - color: AppColor.textPrimary, - ), - ), - const SizedBox(height: 4), - Text( - 'Rp ${_formatCurrency(item.price)} x ${item.quantity}', - style: AppStyle.sm.copyWith(color: AppColor.textSecondary), - ), - if (item.notes != null) ...[ - const SizedBox(height: 4), - Text( - 'Catatan: ${item.notes}', - style: AppStyle.xs.copyWith( - color: AppColor.textSecondary, - fontStyle: FontStyle.italic, - ), - ), + _Header(order: current, tableNumber: detail?.tableNumber), + if (current.pointsEarned > 0 || current.coinsEarned > 0) ...[ + const SizedBox(height: 12), + _EarnedCard(order: current), ], - ], - ), - ), - Text( - 'Rp ${_formatCurrency(item.price * item.quantity)}', - style: AppStyle.md.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - ], - ); - } - - Widget _buildOrderSummary() { - final subtotal = widget.order.items.fold( - 0, - (sum, item) => sum + (item.price * item.quantity), - ); - - return Container( - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - color: AppColor.background, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: AppColor.border), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 'Ringkasan Pesanan', - style: AppStyle.md.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - const SizedBox(height: 16), - _buildSummaryRow('Subtotal', subtotal), - const SizedBox(height: 8), - _buildSummaryRow('Ongkos Kirim', 10000), - const SizedBox(height: 8), - _buildSummaryRow('Pajak', subtotal * 0.1), - const SizedBox(height: 12), - Divider(color: AppColor.border, height: 1), - const SizedBox(height: 12), - _buildSummaryRow('Total', widget.order.totalAmount, isBold: true), - ], - ), - ); - } - - Widget _buildSummaryRow(String label, double amount, {bool isBold = false}) { - return Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - label, - style: AppStyle.sm.copyWith( - color: AppColor.textSecondary, - fontWeight: isBold ? FontWeight.bold : FontWeight.normal, - ), - ), - Text( - 'Rp ${_formatCurrency(amount)}', - style: AppStyle.sm.copyWith( - color: isBold ? AppColor.textPrimary : AppColor.textSecondary, - fontWeight: isBold ? FontWeight.bold : FontWeight.w500, - ), - ), - ], - ); - } - - Widget _buildOrderNotes() { - return Container( - padding: const EdgeInsets.all(20), - decoration: BoxDecoration( - color: AppColor.background, - borderRadius: BorderRadius.circular(12), - border: Border.all(color: AppColor.border), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Icon(Icons.note, size: 18, color: AppColor.primary), - const SizedBox(width: 8), - Text( - 'Catatan Pesanan', - style: AppStyle.md.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, - ), - ), - ], - ), - const SizedBox(height: 12), - Container( - width: double.infinity, - padding: const EdgeInsets.all(16), - decoration: BoxDecoration( - color: AppColor.white, - borderRadius: BorderRadius.circular(8), - border: Border.all(color: AppColor.border), - ), - child: Text( - widget.order.notes!, - style: AppStyle.sm.copyWith( - color: AppColor.textPrimary, - height: 1.5, - ), - ), - ), - ], - ), - ); - } - - Widget _buildActionButtons() { - return Column( - children: [ - if (widget.order.status == OrderStatus.pending) ...[ - Row( - children: [ - Expanded( - child: OutlinedButton.icon( - onPressed: _cancelOrder, - icon: const Icon(Icons.cancel, size: 20), - label: const Text('Batalkan'), - style: OutlinedButton.styleFrom( - foregroundColor: Colors.red, - side: const BorderSide(color: Colors.red), - padding: const EdgeInsets.symmetric(vertical: 16), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), + const SizedBox(height: 12), + if (detail != null) + OrderDetailBody(detail: detail) + else + state.failureOption.fold( + () => const Padding( + padding: EdgeInsets.symmetric(vertical: 48), + child: SpinKitFadingCircle( + color: AppColor.primary, + size: 32, + ), + ), + (f) => _Section( + child: Column( + children: [ + Text( + walletFailureMessage(f), + textAlign: TextAlign.center, + style: AppStyle.md, + ), + const SizedBox(height: 12), + AppOutlineButton( + title: 'Coba lagi', + width: 160, + onPressed: () => context + .read() + .add(OrderDetailLoaderEvent.fetched(order.id)), + ), + ], ), ), ), - ), - const SizedBox(width: 12), - Expanded( - child: ElevatedButton.icon( - onPressed: _processOrder, - icon: const Icon(Icons.check, size: 20), - label: const Text('Proses'), - style: ElevatedButton.styleFrom( - backgroundColor: AppColor.primary, - foregroundColor: AppColor.white, - padding: const EdgeInsets.symmetric(vertical: 16), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - ), - ), ], + ); + }, + ), + ); + } +} + +/// Rincian item, ringkasan harga, dan pembayaran. +class OrderDetailBody extends StatelessWidget { + const OrderDetailBody({super.key, required this.detail}); + + final CustomerOrderDetail detail; + + @override + Widget build(BuildContext context) { + return Column( + children: [ + _Section( + title: 'Item Pesanan', + child: Column( + children: [ + for (var i = 0; i < detail.items.length; i++) ...[ + if (i > 0) + const Padding( + padding: EdgeInsets.symmetric(vertical: 10), + child: Divider(height: 1, color: AppColor.borderLight), + ), + _ItemRow(item: detail.items[i]), + ], + ], ), - ] else if (widget.order.status == OrderStatus.processing) ...[ - SizedBox( - width: double.infinity, - child: ElevatedButton.icon( - onPressed: _completeOrder, - icon: const Icon(Icons.check_circle, size: 20), - label: const Text('Selesaikan Pesanan'), - style: ElevatedButton.styleFrom( - backgroundColor: Colors.green, - foregroundColor: AppColor.white, - padding: const EdgeInsets.symmetric(vertical: 16), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), + ), + const SizedBox(height: 12), + _Section( + title: 'Ringkasan', + child: Column( + children: [ + _AmountRow(label: 'Subtotal', amount: detail.subtotal), + if (detail.discountAmount > 0) + _AmountRow( + label: 'Diskon', + amount: -detail.discountAmount, + color: AppColor.success, ), + if (detail.taxAmount > 0) + _AmountRow(label: 'Pajak', amount: detail.taxAmount), + const Padding( + padding: EdgeInsets.symmetric(vertical: 8), + child: Divider(height: 1, color: AppColor.borderLight), + ), + _AmountRow( + label: 'Total', + amount: detail.order.totalAmount, + isBold: true, ), + if (detail.refundAmount > 0) + _AmountRow( + label: 'Dikembalikan', + amount: detail.refundAmount, + color: AppColor.warning, + ), + ], + ), + ), + if (detail.payments.isNotEmpty) ...[ + const SizedBox(height: 12), + _Section( + title: 'Pembayaran', + child: Column( + children: [ + for (final payment in detail.payments) + _PaymentRow(payment: payment), + ], ), ), ], - const SizedBox(height: 12), - SizedBox( - width: double.infinity, - child: OutlinedButton.icon( - onPressed: _contactCustomer, - icon: const Icon(Icons.chat, size: 20), - label: const Text('Hubungi Pelanggan'), - style: OutlinedButton.styleFrom( - foregroundColor: AppColor.primary, - side: BorderSide(color: AppColor.primary), - padding: const EdgeInsets.symmetric(vertical: 16), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - ), - ), - ), - ), ], ); } +} - String _formatDateTime(DateTime dateTime) { - final months = [ - 'Jan', - 'Feb', - 'Mar', - 'Apr', - 'Mei', - 'Jun', - 'Jul', - 'Ags', - 'Sep', - 'Okt', - 'Nov', - 'Des', - ]; +class _Section extends StatelessWidget { + const _Section({this.title, required this.child}); - final day = dateTime.day; - final month = months[dateTime.month - 1]; - final year = dateTime.year; - final hour = dateTime.hour.toString().padLeft(2, '0'); - final minute = dateTime.minute.toString().padLeft(2, '0'); + final String? title; + final Widget child; - return '$day $month $year, $hour:$minute WIB'; - } - - String _formatCurrency(double amount) { - return amount - .toStringAsFixed(0) - .replaceAllMapped( - RegExp(r'(\d)(?=(\d{3})+(?!\d))'), - (Match m) => '${m[1]}.', - ); - } - - void _shareOrder() { - // Implement share functionality - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Fitur berbagi akan segera hadir'), - backgroundColor: AppColor.primary, + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (title != null) ...[ + Text( + title!, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 12), + ], + child, + ], ), ); } +} - void _handleMenuAction(String action) { - switch (action) { - case 'edit': - _editOrder(); - break; - case 'duplicate': - _duplicateOrder(); - break; - case 'delete': - _deleteOrder(); - break; - } - } +class _CancelledBanner extends StatelessWidget { + const _CancelledBanner({required this.order}); + + final CustomerOrder order; - void _editOrder() { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Fitur edit pesanan akan segera hadir'), - backgroundColor: AppColor.primary, - ), - ); - } + @override + Widget build(BuildContext context) { + final (label, color) = orderStatusOf(order); - void _duplicateOrder() { - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Pesanan berhasil diduplikat'), - backgroundColor: Colors.green, + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: color.withOpacity(0.08), + borderRadius: BorderRadius.circular(AppValue.borderRadius), ), - ); - } - - void _deleteOrder() { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text( - 'Hapus Pesanan', - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - content: Text( - 'Apakah Anda yakin ingin menghapus pesanan ${widget.order.id}? Tindakan ini tidak dapat dibatalkan.', - style: AppStyle.md, - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), + child: Row( + children: [ + Icon(Icons.info_outline_rounded, color: color, size: 20), + const SizedBox(width: 10), + Expanded( child: Text( - 'Batal', - style: AppStyle.md.copyWith(color: AppColor.textSecondary), + 'Pesanan ini ${label.toLowerCase()}.', + style: AppStyle.sm.copyWith( + color: color, + fontWeight: FontWeight.w600, + ), ), ), - ElevatedButton( - onPressed: () { - context.router.back(); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Pesanan berhasil dihapus'), - backgroundColor: Colors.red, - ), - ); - }, - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - foregroundColor: Colors.white, - ), - child: const Text('Hapus'), - ), ], ), ); } +} + +class _Header extends StatelessWidget { + const _Header({required this.order, this.tableNumber}); - void _processOrder() { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text( - 'Proses Pesanan', - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - content: Text( - 'Apakah Anda yakin ingin memproses pesanan ${widget.order.id}?', - style: AppStyle.md, - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: Text( - 'Batal', - style: AppStyle.md.copyWith(color: AppColor.textSecondary), - ), + final CustomerOrder order; + final String? tableNumber; + + @override + Widget build(BuildContext context) { + return _Section( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + order.outletName, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + const SizedBox(width: 8), + OrderStatusBadge(order: order), + ], + ), + const SizedBox(height: 12), + _InfoRow(icon: Icons.tag_rounded, text: order.orderNumber), + _InfoRow( + icon: Icons.schedule_rounded, + text: formatOrderTime(order.createdAt), ), - ElevatedButton( - onPressed: () { - Navigator.pop(context); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Pesanan sedang diproses'), - backgroundColor: Colors.blue, - ), - ); - }, - style: ElevatedButton.styleFrom( - backgroundColor: AppColor.primary, - foregroundColor: Colors.white, - ), - child: const Text('Proses'), + _InfoRow( + icon: Icons.restaurant_rounded, + text: [ + orderTypeLabel(order.orderType), + if (tableNumber != null) 'Meja $tableNumber', + ].join(' · '), ), ], ), ); } +} + +class _InfoRow extends StatelessWidget { + const _InfoRow({required this.icon, required this.text}); - void _completeOrder() { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text( - 'Selesaikan Pesanan', - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - content: Text( - 'Apakah pesanan ${widget.order.id} sudah selesai dan siap dikirim?', - style: AppStyle.md, - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), + final IconData icon; + final String text; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 4), + child: Row( + children: [ + Icon(icon, size: 16, color: AppColor.textSecondary), + const SizedBox(width: 8), + Expanded( child: Text( - 'Belum', - style: AppStyle.md.copyWith(color: AppColor.textSecondary), + text, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), ), ), - ElevatedButton( - onPressed: () { - Navigator.pop(context); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Pesanan berhasil diselesaikan'), - backgroundColor: Colors.green, - ), - ); - }, - style: ElevatedButton.styleFrom( - backgroundColor: Colors.green, - foregroundColor: Colors.white, - ), - child: const Text('Selesai'), - ), ], ), ); } +} + +class _EarnedCard extends StatelessWidget { + const _EarnedCard({required this.order}); + + final CustomerOrder order; - void _cancelOrder() { - showDialog( - context: context, - builder: (context) => AlertDialog( - title: Text( - 'Batalkan Pesanan', - style: AppStyle.lg.copyWith(fontWeight: FontWeight.bold), - ), - content: Text( - 'Apakah Anda yakin ingin membatalkan pesanan ${widget.order.id}?', - style: AppStyle.md, - ), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), + @override + Widget build(BuildContext context) { + final earned = [ + if (order.pointsEarned > 0) (WalletCurrency.point, order.pointsEarned), + if (order.coinsEarned > 0) (WalletCurrency.coin, order.coinsEarned), + ]; + + return Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: AppColor.successWithOpacity(0.08), + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Row( + children: [ + Expanded( child: Text( - 'Tidak', - style: AppStyle.md.copyWith(color: AppColor.textSecondary), + 'Didapat dari pesanan ini', + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w600), ), ), - ElevatedButton( - onPressed: () { - Navigator.pop(context); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Pesanan berhasil dibatalkan'), - backgroundColor: Colors.red, - ), - ); - }, - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red, - foregroundColor: Colors.white, + for (final (currency, amount) in earned) ...[ + const SizedBox(width: 12), + WalletCurrencyIcon(currency: currency, size: 20), + const SizedBox(width: 4), + Text( + '+${amount.thousandFormat}', + style: AppStyle.md.copyWith( + color: AppColor.success, + fontWeight: FontWeight.w700, + ), ), - child: const Text('Batalkan'), - ), + ], ], ), ); } +} - void _contactCustomer() { - showModalBottomSheet( - context: context, - backgroundColor: AppColor.white, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(16)), - ), - builder: (context) => Container( - padding: const EdgeInsets.all(24), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Container( - width: 40, - height: 4, - decoration: BoxDecoration( - color: AppColor.border, - borderRadius: BorderRadius.circular(2), +class _ItemRow extends StatelessWidget { + const _ItemRow({required this.item}); + + final CustomerOrderItem item; + + @override + Widget build(BuildContext context) { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + item.productName, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), ), - ), - const SizedBox(height: 20), - Text( - 'Hubungi ${widget.order.customerName}', - style: AppStyle.lg.copyWith( - fontWeight: FontWeight.bold, - color: AppColor.textPrimary, + if (item.variantName != null) + Text( + item.variantName!, + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 2), + Text( + formatItemQuantity(item), + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), ), - ), - const SizedBox(height: 24), - if (widget.order.phoneNumber != null) - ListTile( - leading: Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.green.withOpacity(0.1), - borderRadius: BorderRadius.circular(8), + if (item.refundQuantity > 0) + Text( + '${item.refundQuantity} direfund', + style: AppStyle.xs.copyWith( + color: AppColor.warning, + fontWeight: FontWeight.w600, ), - child: const Icon(Icons.phone, color: Colors.green), ), - title: const Text('Telepon'), - subtitle: Text(widget.order.phoneNumber!), - onTap: () => _callCustomer(widget.order.phoneNumber!), - ), - ListTile( - leading: Container( - padding: const EdgeInsets.all(12), - decoration: BoxDecoration( - color: Colors.blue.withOpacity(0.1), - borderRadius: BorderRadius.circular(8), - ), - child: const Icon(Icons.chat, color: Colors.blue), - ), - title: const Text('Kirim Pesan'), - subtitle: const Text('Via WhatsApp'), - onTap: () => _sendMessage(), - ), - const SizedBox(height: 16), - ], + ], + ), + ), + const SizedBox(width: 12), + Text( + item.totalPrice.currencyFormatRp, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), ), - ), + ], ); } +} + +class _AmountRow extends StatelessWidget { + const _AmountRow({ + required this.label, + required this.amount, + this.isBold = false, + this.color, + }); + + final String label; + + /// Negatif ditampilkan sebagai potongan: "−Rp 5.000". + final int amount; + final bool isBold; + final Color? color; - void _callCustomer(String phoneNumber) { - Navigator.pop(context); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Menghubungi $phoneNumber...'), - backgroundColor: Colors.green, + @override + Widget build(BuildContext context) { + final style = (isBold ? AppStyle.md : AppStyle.sm).copyWith( + color: color ?? (isBold ? AppColor.textPrimary : AppColor.textSecondary), + fontWeight: isBold ? FontWeight.w700 : FontWeight.w500, + ); + final text = amount < 0 + ? '−${(-amount).currencyFormatRp}' + : amount.currencyFormatRp; + + return Padding( + padding: const EdgeInsets.symmetric(vertical: 3), + child: Row( + children: [ + Expanded(child: Text(label, style: style)), + Text(text, style: style), + ], ), ); } +} + +class _PaymentRow extends StatelessWidget { + const _PaymentRow({required this.payment}); - void _sendMessage() { - Navigator.pop(context); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: Text('Membuka WhatsApp...'), - backgroundColor: Colors.blue, + final CustomerOrderPayment payment; + + @override + Widget build(BuildContext context) { + // Pembayaran EnakPoint: "EnakPoint 12.500 (Rp 12.500)". + final title = payment.isPoint && payment.pointsUsed != null + ? '${WalletCurrency.point.label} ${payment.pointsUsed!.thousandFormat}' + : payment.methodName; + + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (payment.isPoint) ...[ + const WalletCurrencyIcon(currency: WalletCurrency.point, size: 20), + const SizedBox(width: 8), + ], + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w600), + ), + if (payment.refundAmount > 0) + Text( + 'Dikembalikan ${payment.refundAmount.currencyFormatRp}', + style: AppStyle.xs.copyWith(color: AppColor.warning), + ), + ], + ), + ), + Text( + payment.isPoint + ? '(${payment.amount.currencyFormatRp})' + : payment.amount.currencyFormatRp, + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w600), + ), + ], ), ); } diff --git a/lib/presentation/pages/order/order_ui.dart b/lib/presentation/pages/order/order_ui.dart new file mode 100644 index 0000000..941bbd6 --- /dev/null +++ b/lib/presentation/pages/order/order_ui.dart @@ -0,0 +1,68 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../../../common/extension/extension.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../components/assets/assets.gen.dart'; + +/// Label & warna status order. Void/refund didahulukan (§4.5). +(String, Color) orderStatusOf(CustomerOrder order) { + if (order.isVoid) return ('Dibatalkan', AppColor.error); + if (order.isRefund) return ('Direfund', AppColor.warning); + return switch (order.status) { + 'completed' => ('Selesai', AppColor.success), + 'pending' => ('Menunggu', AppColor.warning), + 'cancelled' => ('Dibatalkan', AppColor.error), + _ => ('Diproses', AppColor.info), + }; +} + +String orderTypeLabel(String orderType) => switch (orderType) { + 'dine_in' => 'Makan di tempat', + 'take_away' || 'takeaway' => 'Bawa pulang', + 'delivery' => 'Diantar', + '' => '-', + _ => orderType.replaceAll('_', ' '), +}; + +AssetGenImage orderTypeIcon(CustomerOrder order) => + order.isDineIn ? Assets.icons.dineIn : Assets.icons.takeaway; + +/// "30 Sep 2026, 19:01 WIB". +String formatOrderTime(DateTime? time) { + if (time == null) return '-'; + return '${DateFormat('d MMM yyyy, HH:mm', 'id_ID').format(time.toWib)} WIB'; +} + +/// Kuantitas item: "2 × Rp 25.000", atau "1 × 4,2 ons" untuk item timbangan. +String formatItemQuantity(CustomerOrderItem item) { + if (item.isWeighted) { + final weight = NumberFormat('0.###', 'id_ID').format(item.weight); + return '${item.quantity} × $weight ${item.unitName ?? ''}'.trim(); + } + return '${item.quantity} × ${item.unitPrice.currencyFormatRp}'; +} + +class OrderStatusBadge extends StatelessWidget { + const OrderStatusBadge({super.key, required this.order}); + + final CustomerOrder order; + + @override + Widget build(BuildContext context) { + final (label, color) = orderStatusOf(order); + + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + decoration: BoxDecoration( + color: color.withOpacity(0.1), + borderRadius: BorderRadius.circular(999), + ), + child: Text( + label, + style: AppStyle.xs.copyWith(color: color, fontWeight: FontWeight.w700), + ), + ); + } +} diff --git a/lib/presentation/pages/outlet/outlet_page.dart b/lib/presentation/pages/outlet/outlet_page.dart new file mode 100644 index 0000000..38e5e31 --- /dev/null +++ b/lib/presentation/pages/outlet/outlet_page.dart @@ -0,0 +1,84 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../application/outlet/outlet_loader/outlet_loader_bloc.dart'; +import '../../../common/theme/theme.dart'; +import '../../components/button/button.dart'; +import '../wallet/wallet_ui.dart'; +import 'widgets/outlet_tile.dart'; + +/// Semua outlet tempat EnakPoint & EnakCoin berlaku (§4.4). +@RoutePage() +class OutletPage extends StatelessWidget { + const OutletPage({super.key}); + + void _refresh(BuildContext context) => + context.read().add(const OutletLoaderEvent.fetched()); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Outlet')), + body: BlocBuilder( + builder: (context, state) { + if (!state.hasLoaded) { + return state.failureOption.fold( + () => const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 36), + ), + (f) => Center( + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + walletFailureMessage(f), + textAlign: TextAlign.center, + style: AppStyle.md, + ), + const SizedBox(height: 16), + AppOutlineButton( + title: 'Coba lagi', + width: 160, + onPressed: () => _refresh(context), + ), + ], + ), + ), + ), + ); + } + + return RefreshIndicator( + color: AppColor.primary, + onRefresh: () async { + _refresh(context); + await context.read().stream.firstWhere( + (s) => !s.isFetching, + ); + }, + child: ListView.separated( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 24), + itemCount: state.outlets.length + 1, + separatorBuilder: (_, _) => const SizedBox(height: 10), + itemBuilder: (context, index) { + if (index == 0) { + return Text( + 'EnakPoint & EnakCoin kamu berlaku di ' + '${state.outlets.length} outlet berikut.', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ); + } + return OutletTile(outlet: state.outlets[index - 1]); + }, + ), + ); + }, + ), + ); + } +} diff --git a/lib/presentation/pages/outlet/widgets/outlet_tile.dart b/lib/presentation/pages/outlet/widgets/outlet_tile.dart new file mode 100644 index 0000000..ff9049f --- /dev/null +++ b/lib/presentation/pages/outlet/widgets/outlet_tile.dart @@ -0,0 +1,140 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../domain/wallet/wallet.dart'; +import '../../wallet/wallet_ui.dart'; + +/// Satu outlet: nama, alamat, dan di mana EnakPoint/EnakCoin berlaku. +class OutletTile extends StatelessWidget { + const OutletTile({super.key, required this.outlet}); + + final Outlet outlet; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + border: Border.all(color: AppColor.borderLight), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: AppColor.primaryWithOpacity(0.08), + borderRadius: BorderRadius.circular(12), + ), + child: const Icon( + Icons.storefront_rounded, + color: AppColor.primary, + size: 22, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + outlet.name, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + if (outlet.address != null) ...[ + const SizedBox(height: 2), + Text( + outlet.address!, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + ], + if (outlet.acceptsPointPayment || + outlet.earnsPoints || + outlet.earnsCoins) ...[ + const SizedBox(height: 8), + Wrap( + spacing: 6, + runSpacing: 6, + children: [ + if (outlet.acceptsPointPayment) + const _Chip( + label: 'Bisa bayar pakai EnakPoint', + icon: Icon( + Icons.check_circle_rounded, + size: 14, + color: AppColor.primary, + ), + highlighted: true, + ), + if (outlet.earnsPoints) + const _Chip( + label: 'Dapat EnakPoint', + icon: WalletCurrencyIcon( + currency: WalletCurrency.point, + size: 14, + ), + ), + if (outlet.earnsCoins) + const _Chip( + label: 'Dapat EnakCoin', + icon: WalletCurrencyIcon( + currency: WalletCurrency.coin, + size: 14, + ), + ), + ], + ), + ], + ], + ), + ), + ], + ), + ); + } +} + +class _Chip extends StatelessWidget { + const _Chip({ + required this.label, + required this.icon, + this.highlighted = false, + }); + + final String label; + final Widget icon; + final bool highlighted; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration( + color: highlighted + ? AppColor.primaryWithOpacity(0.08) + : AppColor.background, + borderRadius: BorderRadius.circular(999), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + icon, + const SizedBox(width: 4), + Text( + label, + style: AppStyle.xs.copyWith( + fontSize: 10, + color: highlighted ? AppColor.primary : AppColor.textPrimary, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/pin/pin_change_page.dart b/lib/presentation/pages/pin/pin_change_page.dart new file mode 100644 index 0000000..1032dbf --- /dev/null +++ b/lib/presentation/pages/pin/pin_change_page.dart @@ -0,0 +1,203 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../application/auth/auth_bloc.dart'; +import '../../../application/pin/pin_change_form/pin_change_form_bloc.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/toast/flushbar.dart'; +import '../../router/app_router.gr.dart'; +import '../wallet/wallet_ui.dart'; +import 'pin_rules.dart'; +import 'widgets/pin_code_field.dart'; + +enum _Step { oldPin, newPin, confirm } + +/// Ganti PIN (§6.3). +@RoutePage() +class PinChangePage extends StatefulWidget implements AutoRouteWrapper { + const PinChangePage({super.key}); + + @override + State createState() => _PinChangePageState(); + + @override + Widget wrappedRoute(BuildContext context) => + BlocProvider(create: (_) => getIt(), child: this); +} + +class _PinChangePageState extends State { + final TextEditingController _controller = TextEditingController(); + + _Step _step = _Step.oldPin; + String _oldPin = ''; + String _newPin = ''; + String? _errorText; + bool _isLocked = false; + + @override + void dispose() { + _controller.dispose(); + _oldPin = ''; + _newPin = ''; + super.dispose(); + } + + void _goTo(_Step step, {String? error}) { + setState(() { + _step = step; + _errorText = error; + }); + _controller.clear(); + } + + void _onCompleted(String value) { + switch (_step) { + case _Step.oldPin: + _oldPin = value; + _goTo(_Step.newPin); + case _Step.newPin: + final error = value == _oldPin + ? 'PIN baru harus berbeda dari PIN lama.' + : validateNewPin( + value, + birthDate: context.read().state.user.birthDate, + ); + if (error != null) { + _goTo(_Step.newPin, error: error); + return; + } + _newPin = value; + _goTo(_Step.confirm); + case _Step.confirm: + if (value != _newPin) { + _newPin = ''; + _goTo(_Step.newPin, error: 'PIN tidak sama. Silakan ulangi.'); + return; + } + context.read().add( + PinChangeFormEvent.submitted( + oldPin: _oldPin, + pin: _newPin, + confirmPin: value, + ), + ); + _controller.clear(); + } + } + + void _onFailure(WalletFailure failure) { + _oldPin = ''; + _newPin = ''; + failure.maybeMap( + pinInvalid: (_) => + _goTo(_Step.oldPin, error: walletFailureMessage(failure)), + pinLocked: (_) { + _goTo(_Step.oldPin, error: walletFailureMessage(failure)); + setState(() => _isLocked = true); + }, + pinNotSet: (_) => + context.router.replace(PinSetupRoute(purpose: PinOtpPurpose.setup)), + rejected: (_) => _goTo( + _Step.newPin, + error: 'PIN baru tidak memenuhi syarat. Coba PIN lain.', + ), + orElse: () { + _goTo(_Step.oldPin); + AppFlushbar.showError(context, walletFailureMessage(failure)); + }, + ); + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listenWhen: (p, c) => + p.failureOrSuccessOption != c.failureOrSuccessOption, + listener: (context, state) { + state.failureOrSuccessOption.fold( + () {}, + (either) => either.fold(_onFailure, (_) { + _oldPin = ''; + _newPin = ''; + AppFlushbar.showSuccess(context, 'PIN berhasil diganti'); + context.router.maybePop(); + }), + ); + }, + builder: (context, state) { + final title = switch (_step) { + _Step.oldPin => 'Masukkan PIN lama', + _Step.newPin => 'Masukkan PIN baru', + _Step.confirm => 'Konfirmasi PIN baru', + }; + + return Scaffold( + appBar: AppBar(title: const Text('Ganti PIN')), + body: Padding( + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 8), + Text( + 'PIN 6 digit, bukan angka berulang, berurutan, atau tanggal ' + 'lahir.', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 28), + PinCodeField( + key: ValueKey(_step), + controller: _controller, + enabled: !state.isSubmitting && !_isLocked, + hasError: _errorText != null, + onCompleted: _onCompleted, + ), + const SizedBox(height: 16), + if (state.isSubmitting) + const Center( + child: SpinKitFadingCircle( + color: AppColor.primary, + size: 28, + ), + ) + else if (_errorText != null) + Text( + _errorText!, + style: AppStyle.md.copyWith( + color: AppColor.error, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 8), + if (_step == _Step.oldPin) + Align( + alignment: Alignment.centerRight, + child: TextButton( + onPressed: () => context.router.replace( + PinSetupRoute(purpose: PinOtpPurpose.reset), + ), + child: Text( + 'Lupa PIN', + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ], + ), + ), + ); + }, + ); + } +} diff --git a/lib/presentation/pages/pin/pin_guard.dart b/lib/presentation/pages/pin/pin_guard.dart new file mode 100644 index 0000000..d420ba4 --- /dev/null +++ b/lib/presentation/pages/pin/pin_guard.dart @@ -0,0 +1,96 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/toast/flushbar.dart'; +import '../../router/app_router.gr.dart'; +import '../wallet/wallet_ui.dart'; + +/// Memastikan customer siap memasukkan PIN (§6.1) sebelum aksi yang butuh PIN. +/// +/// - Belum punya PIN: buka alur buat PIN, lalu lanjut bila berhasil dibuat. +/// - PIN terkunci: tampilkan jam buka kunci dan tawarkan "Lupa PIN". +/// +/// Mengembalikan `true` bila aksi boleh dilanjutkan ke input PIN. +Future ensurePinReady(BuildContext context) async { + showDialog( + context: context, + barrierDismissible: false, + builder: (_) => const Center( + child: SpinKitFadingCircle(color: AppColor.white, size: 40), + ), + ); + + final result = await getIt().getStatus(); + + if (!context.mounted) return false; + Navigator.of(context, rootNavigator: true).pop(); + + final failure = result.fold((f) => f, (_) => null); + if (failure != null) { + AppFlushbar.showError(context, walletFailureMessage(failure)); + return false; + } + + final status = result.getOrElse(() => const PinStatus(hasPin: false)); + + if (!status.hasPin) { + final created = await context.router.push( + PinSetupRoute(purpose: PinOtpPurpose.setup), + ); + return created == true; + } + + if (status.isLocked) { + await showPinLockedDialog(context, status.lockedUntil!); + return false; + } + + return true; +} + +Future showPinLockedDialog( + BuildContext context, + DateTime lockedUntil, +) async { + final forgot = await showDialog( + context: context, + builder: (dialogContext) => AlertDialog( + backgroundColor: AppColor.white, + title: Text( + 'PIN terkunci', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + content: Text( + 'PIN terkunci sampai ${formatWibTime(lockedUntil)}.', + style: AppStyle.md, + ), + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: Text( + 'Tutup', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + ), + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(true), + child: Text( + 'Lupa PIN', + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ), + ); + + if (forgot == true && context.mounted) { + context.router.push(PinSetupRoute(purpose: PinOtpPurpose.reset)); + } +} diff --git a/lib/presentation/pages/pin/pin_rules.dart b/lib/presentation/pages/pin/pin_rules.dart new file mode 100644 index 0000000..1bdbc50 --- /dev/null +++ b/lib/presentation/pages/pin/pin_rules.dart @@ -0,0 +1,33 @@ +/// Validasi PIN baru di app sebelum dikirim (server juga memeriksa). +/// Mengembalikan pesan error, atau `null` bila PIN boleh dipakai. +String? validateNewPin(String pin, {String? birthDate}) { + if (!RegExp(r'^\d{6}$').hasMatch(pin)) return 'PIN harus 6 digit angka.'; + + final digits = pin.split('').map(int.parse).toList(); + + if (digits.every((d) => d == digits.first)) { + return 'PIN tidak boleh satu angka berulang.'; + } + + bool stepsBy(int step) { + for (var i = 1; i < digits.length; i++) { + if (digits[i] - digits[i - 1] != step) return false; + } + return true; + } + + if (stepsBy(1) || stepsBy(-1)) { + return 'PIN tidak boleh angka berurutan.'; + } + + final birth = birthDate == null ? null : DateTime.tryParse(birthDate); + if (birth != null) { + String two(int v) => (v % 100).toString().padLeft(2, '0'); + final dd = two(birth.day), mm = two(birth.month), yy = two(birth.year); + if (pin == '$dd$mm$yy' || pin == '$yy$mm$dd') { + return 'PIN tidak boleh tanggal lahir kamu.'; + } + } + + return null; +} diff --git a/lib/presentation/pages/pin/pin_settings_page.dart b/lib/presentation/pages/pin/pin_settings_page.dart new file mode 100644 index 0000000..baa29d6 --- /dev/null +++ b/lib/presentation/pages/pin/pin_settings_page.dart @@ -0,0 +1,166 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:dartz/dartz.dart' hide State; +import 'package:flutter/material.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/button/button.dart'; +import '../../router/app_router.gr.dart'; +import '../wallet/wallet_ui.dart'; + +/// Menu PIN di profil: buat, ganti, dan lupa PIN. +@RoutePage() +class PinSettingsPage extends StatefulWidget { + const PinSettingsPage({super.key}); + + @override + State createState() => _PinSettingsPageState(); +} + +class _PinSettingsPageState extends State { + late Future> _status; + + @override + void initState() { + super.initState(); + _load(); + } + + void _load() { + setState(() => _status = getIt().getStatus()); + } + + Future _open(PageRouteInfo route) async { + await context.router.push(route); + if (mounted) _load(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('PIN')), + body: FutureBuilder>( + future: _status, + builder: (context, snapshot) { + if (!snapshot.hasData) { + return const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 32), + ); + } + + return snapshot.data!.fold( + (f) => Center( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(walletFailureMessage(f), textAlign: TextAlign.center), + const SizedBox(height: 16), + AppOutlineButton( + title: 'Coba lagi', + width: 160, + onPressed: _load, + ), + ], + ), + ), + ), + (status) => ListView( + children: [ + Container( + margin: const EdgeInsets.all(16), + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Text( + 'PIN 6 digit dipakai untuk membuat kode bayar, tukar ' + 'EnakCoin, dan transfer. PIN berbeda dengan password ' + 'login dan jangan diberitahukan kepada siapa pun.', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + ), + if (status.isLocked) + _buildNotice( + 'PIN terkunci sampai ${formatWibTime(status.lockedUntil!)}. ' + 'Gunakan Lupa PIN untuk membukanya.', + ), + if (status.transferBlockedUntil != null && + status.transferBlockedUntil!.isAfter(DateTime.now())) + _buildNotice( + 'Transfer bisa dilakukan lagi pada ' + '${formatWibDateTime(status.transferBlockedUntil!)}.', + ), + Container( + color: AppColor.white, + child: Column( + children: status.hasPin + ? [ + _buildTile( + icon: Icons.lock_reset, + title: 'Ganti PIN', + onTap: () => _open(const PinChangeRoute()), + ), + const Divider(height: 1, indent: 60), + _buildTile( + icon: Icons.help_outline, + title: 'Lupa PIN', + onTap: () => _open( + PinSetupRoute(purpose: PinOtpPurpose.reset), + ), + ), + ] + : [ + _buildTile( + icon: Icons.lock_outline, + title: 'Buat PIN', + onTap: () => _open( + PinSetupRoute(purpose: PinOtpPurpose.setup), + ), + ), + ], + ), + ), + ], + ), + ); + }, + ), + ); + } + + Widget _buildNotice(String text) { + return Container( + margin: const EdgeInsets.fromLTRB(16, 0, 16, 16), + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColor.warningWithOpacity(0.1), + borderRadius: BorderRadius.circular(AppValue.borderRadius), + border: Border.all(color: AppColor.warning), + ), + child: Text(text, style: AppStyle.md), + ); + } + + Widget _buildTile({ + required IconData icon, + required String title, + required VoidCallback onTap, + }) { + return ListTile( + leading: Icon(icon, color: AppColor.textSecondary), + title: Text(title, style: AppStyle.md), + trailing: const Icon( + Icons.arrow_forward_ios, + size: 16, + color: AppColor.textSecondary, + ), + onTap: onTap, + ); + } +} diff --git a/lib/presentation/pages/pin/pin_setup_page.dart b/lib/presentation/pages/pin/pin_setup_page.dart new file mode 100644 index 0000000..ae77280 --- /dev/null +++ b/lib/presentation/pages/pin/pin_setup_page.dart @@ -0,0 +1,335 @@ +import 'dart:async'; + +import 'package:auto_route/auto_route.dart'; +import 'package:dartz/dartz.dart' hide State; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../application/auth/auth_bloc.dart'; +import '../../../application/pin/pin_setup_form/pin_setup_form_bloc.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/button/button.dart'; +import '../../components/toast/flushbar.dart'; +import '../wallet/wallet_ui.dart'; +import 'pin_rules.dart'; +import 'widgets/pin_code_field.dart'; + +enum _Step { otp, pin, confirm, done } + +/// Buat PIN (§6.2) atau lupa PIN (§6.4). Pop dengan `true` bila berhasil. +@RoutePage() +class PinSetupPage extends StatefulWidget implements AutoRouteWrapper { + const PinSetupPage({super.key, required this.purpose}); + + final PinOtpPurpose purpose; + + @override + State createState() => _PinSetupPageState(); + + @override + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (_) => + getIt()..add(PinSetupFormEvent.otpRequested(purpose)), + child: this, + ); +} + +class _PinSetupPageState extends State { + final TextEditingController _otpController = TextEditingController(); + final TextEditingController _pinController = TextEditingController(); + + _Step _step = _Step.otp; + String _otpCode = ''; + String _pin = ''; + String? _errorText; + Timer? _ticker; + + bool get _isReset => widget.purpose == PinOtpPurpose.reset; + + @override + void initState() { + super.initState(); + _ticker = Timer.periodic(const Duration(seconds: 1), (_) { + if (mounted) setState(() {}); + }); + } + + @override + void dispose() { + _ticker?.cancel(); + _otpController.dispose(); + _pinController.dispose(); + _pin = ''; + super.dispose(); + } + + void _goTo(_Step step, {String? error}) { + setState(() { + _step = step; + _errorText = error; + }); + _pinController.clear(); + } + + void _onOtpCompleted(String code) { + _otpCode = code; + _goTo(_Step.pin); + } + + void _onPinCompleted(String value) { + if (_step == _Step.pin) { + final error = validateNewPin( + value, + birthDate: context.read().state.user.birthDate, + ); + if (error != null) { + _goTo(_Step.pin, error: error); + return; + } + _pin = value; + _goTo(_Step.confirm); + return; + } + + if (value != _pin) { + _pin = ''; + _goTo(_Step.pin, error: 'PIN tidak sama. Silakan ulangi.'); + return; + } + + context.read().add( + PinSetupFormEvent.submitted( + otpCode: _otpCode, + pin: _pin, + confirmPin: value, + ), + ); + _pinController.clear(); + } + + void _onSubmitResult(Either either) { + either.fold( + (f) { + _pin = ''; + f.maybeMap( + rejected: (_) { + _otpController.clear(); + _goTo( + _Step.otp, + error: + 'Kode OTP salah atau sudah kedaluwarsa, atau PIN tidak ' + 'memenuhi syarat. Silakan ulangi.', + ); + }, + orElse: () { + _goTo(_Step.pin); + AppFlushbar.showError(context, walletFailureMessage(f)); + }, + ); + }, + (_) { + _pin = ''; + _goTo(_Step.done); + }, + ); + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listenWhen: (p, c) => + p.failureOrSuccessOption != c.failureOrSuccessOption || + p.otpFailureOption != c.otpFailureOption, + listener: (context, state) { + state.failureOrSuccessOption.fold(() {}, _onSubmitResult); + state.otpFailureOption.fold(() {}, (f) { + final isRateLimited = f.maybeMap( + tooManyRequests: (_) => true, + orElse: () => false, + ); + if (!isRateLimited) { + AppFlushbar.showError(context, walletFailureMessage(f)); + } + }); + }, + builder: (context, state) { + return PopScope( + canPop: _step != _Step.done, + onPopInvokedWithResult: (didPop, _) { + if (!didPop && _step == _Step.done) Navigator.of(context).pop(true); + }, + child: Scaffold( + appBar: AppBar(title: Text(_isReset ? 'Lupa PIN' : 'Buat PIN')), + body: SafeArea( + child: Padding( + padding: const EdgeInsets.all(20), + child: _step == _Step.done ? _buildDone() : _buildForm(state), + ), + ), + ), + ); + }, + ); + } + + Widget _buildForm(PinSetupFormState state) { + final isOtp = _step == _Step.otp; + + final title = switch (_step) { + _Step.otp => 'Masukkan kode verifikasi', + _Step.pin => _isReset ? 'Buat PIN baru' : 'Buat PIN', + _Step.confirm => 'Konfirmasi PIN', + _Step.done => '', + }; + + final description = switch (_step) { + _Step.otp => + 'Kami mengirim kode 6 digit ke WhatsApp nomor kamu yang terdaftar.', + _Step.pin => + 'PIN 6 digit dipakai untuk membuat kode bayar, tukar EnakCoin, dan ' + 'transfer. PIN berbeda dengan password login.', + _Step.confirm => 'Masukkan kembali PIN yang sama.', + _Step.done => '', + }; + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildStepIndicator(), + const SizedBox(height: 20), + Text(title, style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700)), + const SizedBox(height: 8), + Text( + description, + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 28), + if (isOtp && state.otp == null) + Center( + child: state.isRequestingOtp + ? const SpinKitFadingCircle(color: AppColor.primary, size: 32) + : AppOutlineButton( + title: 'Kirim kode', + onPressed: _canResend(state) ? _requestOtp : null, + ), + ) + else + PinCodeField( + key: ValueKey(_step), + controller: isOtp ? _otpController : _pinController, + obscure: !isOtp, + enabled: !state.isSubmitting, + hasError: _errorText != null, + onCompleted: isOtp ? _onOtpCompleted : _onPinCompleted, + ), + const SizedBox(height: 16), + if (state.isSubmitting) + const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 28), + ) + else if (_errorText != null) + Text( + _errorText!, + style: AppStyle.md.copyWith( + color: AppColor.error, + fontWeight: FontWeight.w600, + ), + ), + if (isOtp && state.otp != null) ...[ + const SizedBox(height: 16), + _buildResend(state), + ], + ], + ); + } + + bool _canResend(PinSetupFormState state) => + !state.isRequestingOtp && + (state.resendAvailableAt == null || + DateTime.now().isAfter(state.resendAvailableAt!)); + + void _requestOtp() { + _otpController.clear(); + setState(() => _errorText = null); + context.read().add( + PinSetupFormEvent.otpRequested(widget.purpose), + ); + } + + Widget _buildResend(PinSetupFormState state) { + final availableAt = state.resendAvailableAt; + if (availableAt != null && DateTime.now().isBefore(availableAt)) { + return Center( + child: Text( + 'Kirim ulang kode dalam ' + '${formatCountdown(availableAt.difference(DateTime.now()))}', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ); + } + + return Center( + child: TextButton( + onPressed: _canResend(state) ? _requestOtp : null, + child: Text( + state.isRequestingOtp ? 'Mengirim...' : 'Kirim ulang kode', + style: AppStyle.md.copyWith( + color: AppColor.success, + fontWeight: FontWeight.w600, + ), + ), + ), + ); + } + + Widget _buildStepIndicator() { + final index = _Step.values.indexOf(_step); + return Row( + children: List.generate(3, (i) { + return Expanded( + child: Container( + height: 4, + margin: EdgeInsets.only(right: i == 2 ? 0 : 6), + decoration: BoxDecoration( + color: i <= index ? AppColor.primary : AppColor.border, + borderRadius: BorderRadius.circular(2), + ), + ), + ); + }), + ); + } + + Widget _buildDone() { + return Column( + children: [ + const Spacer(), + const Icon(Icons.verified_user, color: AppColor.success, size: 72), + const SizedBox(height: 16), + Text( + _isReset ? 'PIN berhasil direset' : 'PIN berhasil dibuat', + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Text( + _isReset + ? 'Demi keamanan, transfer keluar ditahan selama 24 jam. ' + 'Kode bayar dan tukar EnakCoin tetap bisa dipakai.' + : 'Gunakan PIN ini untuk membuat kode bayar, tukar EnakCoin, ' + 'dan transfer. Jangan beritahu PIN kepada siapa pun.', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + textAlign: TextAlign.center, + ), + const Spacer(), + AppElevatedButton( + title: 'Selesai', + onPressed: () => Navigator.of(context).pop(true), + ), + ], + ); + } +} diff --git a/lib/presentation/pages/pin/widgets/pin_code_field.dart b/lib/presentation/pages/pin/widgets/pin_code_field.dart new file mode 100644 index 0000000..8b92c78 --- /dev/null +++ b/lib/presentation/pages/pin/widgets/pin_code_field.dart @@ -0,0 +1,147 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +import '../../../../common/theme/theme.dart'; + +/// Input 6 digit dengan tampilan kotak. Nilainya tidak pernah disimpan di luar +/// [controller]; pemanggil wajib mengosongkannya setelah dipakai. +class PinCodeField extends StatefulWidget { + const PinCodeField({ + super.key, + required this.controller, + this.onCompleted, + this.obscure = true, + this.hasError = false, + this.enabled = true, + this.autofocus = true, + }); + + final TextEditingController controller; + final ValueChanged? onCompleted; + final bool obscure; + final bool hasError; + final bool enabled; + final bool autofocus; + + static const int length = 6; + + @override + State createState() => _PinCodeFieldState(); +} + +class _PinCodeFieldState extends State { + final FocusNode _focusNode = FocusNode(); + + @override + void initState() { + super.initState(); + widget.controller.addListener(_onChanged); + _focusNode.addListener(() => setState(() {})); + } + + @override + void didUpdateWidget(covariant PinCodeField oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.controller != widget.controller) { + oldWidget.controller.removeListener(_onChanged); + widget.controller.addListener(_onChanged); + } + } + + @override + void dispose() { + widget.controller.removeListener(_onChanged); + _focusNode.dispose(); + super.dispose(); + } + + void _onChanged() { + setState(() {}); + final value = widget.controller.text; + if (value.length == PinCodeField.length) { + widget.onCompleted?.call(value); + } + } + + @override + Widget build(BuildContext context) { + final value = widget.controller.text; + + return GestureDetector( + onTap: () => _focusNode.requestFocus(), + child: Stack( + children: [ + // Field asli tak terlihat yang menerima input keyboard. + Opacity( + opacity: 0, + child: SizedBox( + height: 52, + child: TextField( + controller: widget.controller, + focusNode: _focusNode, + enabled: widget.enabled, + autofocus: widget.autofocus, + keyboardType: TextInputType.number, + maxLength: PinCodeField.length, + enableSuggestions: false, + autocorrect: false, + enableInteractiveSelection: false, + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + decoration: const InputDecoration(counterText: ''), + ), + ), + ), + IgnorePointer( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: List.generate(PinCodeField.length, (index) { + final filled = index < value.length; + final active = + widget.enabled && + _focusNode.hasFocus && + index == value.length; + + return Container( + width: 44, + height: 52, + alignment: Alignment.center, + decoration: BoxDecoration( + color: widget.enabled + ? AppColor.white + : AppColor.backgroundGradient.first, + borderRadius: BorderRadius.circular(10), + border: Border.all( + width: active || widget.hasError ? 2 : 1, + color: widget.hasError + ? AppColor.error + : active + ? AppColor.primary + : AppColor.border, + ), + ), + child: filled + ? widget.obscure + ? Container( + width: 12, + height: 12, + decoration: const BoxDecoration( + color: AppColor.textPrimary, + shape: BoxShape.circle, + ), + ) + : Text( + value[index], + style: AppStyle.xl.copyWith( + fontWeight: FontWeight.w700, + ), + ) + : null, + ); + }), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/pin/widgets/pin_sheet.dart b/lib/presentation/pages/pin/widgets/pin_sheet.dart new file mode 100644 index 0000000..54d5d82 --- /dev/null +++ b/lib/presentation/pages/pin/widgets/pin_sheet.dart @@ -0,0 +1,217 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../domain/wallet/wallet.dart'; +import '../../../router/app_router.gr.dart'; +import '../../wallet/wallet_ui.dart'; +import 'pin_code_field.dart'; + +/// Mengirim PIN ke server. Kembalikan `null` bila sukses, atau failure-nya. +typedef PinSubmitCallback = Future Function(String pin); + +enum _PinSheetResult { success, failed, forgotPin, pinNotSet } + +/// Meminta PIN lalu menjalankan [onSubmit]. Error PIN (§6.5) ditangani di dalam +/// sheet; failure lain menutup sheet lalu diteruskan ke [onFailure]. +/// Mengembalikan `true` bila [onSubmit] sukses. +/// +/// Tampilkan failure lewat [onFailure], jangan dari listener bloc: flushbar juga +/// berupa route, jadi bila muncul selagi sheet masih terbuka, pop milik sheet +/// justru menutup flushbar dan Navigator gagal assertion. +Future showPinSheet( + BuildContext context, { + required String title, + String? subtitle, + required PinSubmitCallback onSubmit, + ValueChanged? onFailure, +}) async { + WalletFailure? lastFailure; + + final result = await showModalBottomSheet<_PinSheetResult>( + context: context, + isScrollControlled: true, + isDismissible: false, + backgroundColor: AppColor.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + builder: (_) => _PinSheet( + title: title, + subtitle: subtitle, + onSubmit: (pin) async => lastFailure = await onSubmit(pin), + ), + ); + + if (!context.mounted) return false; + + switch (result) { + case _PinSheetResult.success: + return true; + case _PinSheetResult.forgotPin: + context.router.push(PinSetupRoute(purpose: PinOtpPurpose.reset)); + return false; + case _PinSheetResult.pinNotSet: + context.router.push(PinSetupRoute(purpose: PinOtpPurpose.setup)); + return false; + case _PinSheetResult.failed: + if (lastFailure != null) onFailure?.call(lastFailure!); + return false; + case null: + return false; + } +} + +class _PinSheet extends StatefulWidget { + const _PinSheet({required this.title, this.subtitle, required this.onSubmit}); + + final String title; + final String? subtitle; + final PinSubmitCallback onSubmit; + + @override + State<_PinSheet> createState() => _PinSheetState(); +} + +class _PinSheetState extends State<_PinSheet> { + final TextEditingController _controller = TextEditingController(); + + bool _isSubmitting = false; + String? _errorText; + + /// PIN terkunci atau transfer ditahan: input tidak berguna lagi. + bool _isBlocked = false; + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + Future _submit(String pin) async { + if (_isSubmitting || _isBlocked) return; + setState(() { + _isSubmitting = true; + _errorText = null; + }); + + final failure = await widget.onSubmit(pin); + if (!mounted) return; + + // PIN tidak disimpan lebih lama dari yang diperlukan. + _controller.clear(); + + if (failure == null) { + Navigator.of(context).pop(_PinSheetResult.success); + return; + } + + final handled = failure.maybeMap( + pinNotSet: (_) { + Navigator.of(context).pop(_PinSheetResult.pinNotSet); + return true; + }, + pinInvalid: (_) { + setState(() => _errorText = walletFailureMessage(failure)); + return true; + }, + pinLocked: (_) { + setState(() { + _errorText = walletFailureMessage(failure); + _isBlocked = true; + }); + return true; + }, + transferBlocked: (_) { + setState(() { + _errorText = walletFailureMessage(failure); + _isBlocked = true; + }); + return true; + }, + orElse: () => false, + ); + + if (!handled) { + Navigator.of(context).pop(_PinSheetResult.failed); + return; + } + + setState(() => _isSubmitting = false); + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.only( + left: 20, + right: 20, + top: 12, + bottom: MediaQuery.of(context).viewInsets.bottom + 24, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + widget.title, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + ), + IconButton( + onPressed: _isSubmitting + ? null + : () => Navigator.of(context).pop(), + icon: const Icon(Icons.close, color: AppColor.textSecondary), + ), + ], + ), + Text( + widget.subtitle ?? 'Masukkan PIN 6 digit kamu', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 24), + PinCodeField( + controller: _controller, + enabled: !_isSubmitting && !_isBlocked, + hasError: _errorText != null, + onCompleted: _submit, + ), + const SizedBox(height: 16), + if (_isSubmitting) + const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 28), + ) + else if (_errorText != null) + Text( + _errorText!, + style: AppStyle.md.copyWith( + color: AppColor.error, + fontWeight: FontWeight.w600, + ), + ), + const SizedBox(height: 8), + Align( + alignment: Alignment.centerRight, + child: TextButton( + onPressed: _isSubmitting + ? null + : () => Navigator.of(context).pop(_PinSheetResult.forgotPin), + child: Text( + 'Lupa PIN', + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/promo/pages/promo_detail/promo_detail_page.dart b/lib/presentation/pages/promo/pages/promo_detail/promo_detail_page.dart new file mode 100644 index 0000000..52c8f2e --- /dev/null +++ b/lib/presentation/pages/promo/pages/promo_detail/promo_detail_page.dart @@ -0,0 +1,291 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../../../common/theme/theme.dart'; +import '../../../../../sample/promo_sample_data.dart'; +import '../../../../components/button/button.dart'; +import '../../../../components/card/detail_section.dart'; +import '../../../../router/app_router.gr.dart'; +import '../../promo_ui.dart'; + +@RoutePage() +class PromoDetailPage extends StatelessWidget { + const PromoDetailPage({super.key, required this.promo}); + + final Promo promo; + + @override + Widget build(BuildContext context) { + final isReward = promo.type == PromoType.reward; + + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Detail Promo')), + body: ListView( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 24), + children: [ + _buildHero(), + if (isPromoUpcoming(promo)) ...[ + const SizedBox(height: 12), + _buildUpcomingNote(), + ], + const SizedBox(height: 12), + DetailSection( + child: Column( + children: [ + _InfoRow( + icon: Icons.card_giftcard_rounded, + label: 'Hadiah', + value: promo.rewardLabel, + ), + const Divider(height: 20, color: AppColor.borderLight), + _InfoRow( + icon: Icons.calendar_month_rounded, + label: 'Periode', + value: promoPeriodLabel(promo), + trailing: PromoTimeBadge(promo: promo), + ), + const Divider(height: 20, color: AppColor.borderLight), + _InfoRow( + icon: Icons.storefront_outlined, + label: 'Berlaku di', + value: promoOutletLabel(promo), + ), + ], + ), + ), + const SizedBox(height: 12), + DetailSection( + title: 'Tentang promo', + child: Text( + promo.description, + style: AppStyle.md.copyWith( + color: AppColor.textSecondary, + height: 1.5, + ), + ), + ), + const SizedBox(height: 12), + DetailSection( + title: 'Cara dapat', + child: Column( + children: [ + for (var i = 0; i < promo.steps.length; i++) + NumberedStep(number: i + 1, text: promo.steps[i]), + ], + ), + ), + if (promo.terms.isNotEmpty) ...[ + const SizedBox(height: 12), + DetailSection( + title: 'Syarat & Ketentuan', + child: Column( + children: [ + for (final term in promo.terms) _BulletRow(text: term), + ], + ), + ), + ], + ], + ), + bottomNavigationBar: Container( + decoration: const BoxDecoration( + color: AppColor.white, + border: Border(top: BorderSide(color: AppColor.borderLight)), + ), + child: SafeArea( + top: false, + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 12), + child: AppElevatedButton( + title: isReward ? 'Lihat Reward Saya' : 'Cari Outlet', + onPressed: () => context.router.push( + isReward ? const RewardRoute() : const OutletRoute(), + ), + ), + ), + ), + ), + ); + } + + Widget _buildHero() { + final gradient = promo.type.gradient; + + return Container( + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + gradient: LinearGradient( + colors: gradient, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + boxShadow: [ + BoxShadow( + color: gradient.last.withOpacity(0.3), + blurRadius: 12, + offset: const Offset(0, 6), + ), + ], + ), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 4, + ), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(20), + ), + child: Text( + promo.rewardLabel, + style: AppStyle.xs.copyWith( + color: promo.type.color, + fontWeight: FontWeight.w800, + ), + ), + ), + const SizedBox(height: 10), + Text( + promo.title, + style: AppStyle.h6.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w800, + height: 1.2, + ), + ), + const SizedBox(height: 6), + Text( + promo.subtitle, + style: AppStyle.sm.copyWith( + color: AppColor.textWhite.withOpacity(0.9), + ), + ), + ], + ), + ), + const SizedBox(width: 12), + PromoTypeIcon(type: promo.type, size: 80), + ], + ), + ); + } + + Widget _buildUpcomingNote() { + return Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColor.info.withOpacity(0.08), + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Row( + children: [ + const Icon(Icons.info_outline, size: 20, color: AppColor.info), + const SizedBox(width: 10), + Expanded( + child: Text( + 'Promo ini mulai ${formatPromoDate(promo.startDate)}. Belanja ' + 'sebelum tanggal itu belum mendapat bonus.', + style: AppStyle.sm.copyWith(color: AppColor.textPrimary), + ), + ), + ], + ), + ); + } +} + +class _InfoRow extends StatelessWidget { + const _InfoRow({ + required this.icon, + required this.label, + required this.value, + this.trailing, + }); + + final IconData icon; + final String label; + final String value; + final Widget? trailing; + + @override + Widget build(BuildContext context) { + return Row( + children: [ + Container( + width: 36, + height: 36, + decoration: BoxDecoration( + color: AppColor.background, + borderRadius: BorderRadius.circular(10), + ), + child: Icon(icon, size: 18, color: AppColor.textSecondary), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + label, + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 2), + Text( + value, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), + ), + ], + ), + ), + if (trailing != null) ...[const SizedBox(width: 8), trailing!], + ], + ); + } +} + +class _BulletRow extends StatelessWidget { + const _BulletRow({required this.text}); + + final String text; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(bottom: 8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(top: 7), + child: Container( + width: 5, + height: 5, + decoration: const BoxDecoration( + color: AppColor.textSecondary, + shape: BoxShape.circle, + ), + ), + ), + const SizedBox(width: 10), + Expanded( + child: Text( + text, + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + height: 1.5, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/promo/promo_page.dart b/lib/presentation/pages/promo/promo_page.dart new file mode 100644 index 0000000..ecd55dc --- /dev/null +++ b/lib/presentation/pages/promo/promo_page.dart @@ -0,0 +1,251 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../sample/promo_sample_data.dart'; +import '../../components/delegate/filter_bar_delegate.dart'; +import '../../router/app_router.gr.dart'; +import 'promo_ui.dart'; +import 'widgets/promo_banner.dart'; +import 'widgets/promo_card.dart'; + +enum _PromoFilter { + all('Semua'), + point('EnakPoint'), + coin('EnakCoin'), + reward('Hadiah'); + + const _PromoFilter(this.label); + + final String label; + + bool matches(Promo promo) => switch (this) { + _PromoFilter.all => true, + _PromoFilter.point => promo.type == PromoType.point, + _PromoFilter.coin => promo.type == PromoType.coin, + _PromoFilter.reward => promo.type == PromoType.reward, + }; +} + +@RoutePage() +class PromoPage extends StatefulWidget { + const PromoPage({super.key}); + + @override + State createState() => _PromoPageState(); +} + +class _PromoPageState extends State { + final PageController _bannerController = PageController( + viewportFraction: 0.9, + ); + int _bannerIndex = 0; + _PromoFilter _filter = _PromoFilter.all; + + /// Promo yang belum berakhir, paling cepat berakhir di atas. + final List _promos = + promoSamples.where((p) => p.endDate.isAfter(DateTime.now())).toList() + ..sort((a, b) => a.endDate.compareTo(b.endDate)); + + List get _featured => + _promos.where((p) => p.isFeatured && !isPromoUpcoming(p)).toList(); + + int _countOf(_PromoFilter filter) => _promos.where(filter.matches).length; + + void _open(Promo promo) => + context.router.push(PromoDetailRoute(promo: promo)); + + @override + void dispose() { + _bannerController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final visible = _promos.where(_filter.matches).toList(); + final ongoing = visible.where((p) => !isPromoUpcoming(p)).toList(); + final upcoming = visible.where(isPromoUpcoming).toList(); + final featured = _featured; + + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('EnakPromo')), + body: CustomScrollView( + slivers: [ + if (featured.isNotEmpty) + SliverToBoxAdapter(child: _buildBanners(featured)), + SliverToBoxAdapter(child: _buildHowItWorks()), + SliverPersistentHeader( + pinned: true, + delegate: FilterBarDelegate<_PromoFilter>( + values: _PromoFilter.values, + selected: _filter, + labelOf: (filter) => filter.label, + countOf: _countOf, + onSelected: (filter) => setState(() => _filter = filter), + ), + ), + if (visible.isEmpty) + SliverFillRemaining(hasScrollBody: false, child: _buildEmpty()) + else ...[ + if (ongoing.isNotEmpty) + ..._buildSection('Sedang berlangsung', ongoing), + if (upcoming.isNotEmpty) ..._buildSection('Segera hadir', upcoming), + const SliverToBoxAdapter(child: SizedBox(height: 24)), + ], + ], + ), + ); + } + + Widget _buildBanners(List featured) { + return Column( + children: [ + const SizedBox(height: 16), + SizedBox( + // Ikut skala font sistem supaya teks banner tidak terpotong. + height: MediaQuery.textScalerOf(context).scale(168), + child: PageView.builder( + controller: _bannerController, + itemCount: featured.length, + onPageChanged: (index) => setState(() => _bannerIndex = index), + itemBuilder: (context, index) { + final promo = featured[index]; + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 6), + child: PromoBanner(promo: promo, onTap: () => _open(promo)), + ); + }, + ), + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate(featured.length, (index) { + final isActive = index == _bannerIndex; + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + margin: const EdgeInsets.symmetric(horizontal: 3), + width: isActive ? 18 : 6, + height: 6, + decoration: BoxDecoration( + color: isActive ? AppColor.primary : AppColor.border, + borderRadius: BorderRadius.circular(3), + ), + ); + }), + ), + ], + ); + } + + Widget _buildHowItWorks() { + return Container( + margin: const EdgeInsets.fromLTRB(16, 16, 16, 4), + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + border: Border.all(color: AppColor.borderLight), + ), + child: Row( + children: [ + Container( + width: 36, + height: 36, + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.08), + shape: BoxShape.circle, + ), + child: const Icon( + Icons.phone_iphone_rounded, + size: 18, + color: AppColor.primary, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Text.rich( + TextSpan( + children: [ + TextSpan( + text: 'Tanpa klaim. ', + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w700), + ), + const TextSpan( + text: + 'Sebutkan nomor HP akunmu ke kasir saat bayar, bonus ' + 'promo masuk otomatis.', + ), + ], + ), + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ), + ], + ), + ); + } + + List _buildSection(String title, List promos) { + return [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 10), + sliver: SliverToBoxAdapter( + child: Text( + title, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + ), + ), + SliverPadding( + padding: const EdgeInsets.symmetric(horizontal: 16), + sliver: SliverList.separated( + itemCount: promos.length, + separatorBuilder: (_, _) => const SizedBox(height: 12), + itemBuilder: (context, index) { + final promo = promos[index]; + return PromoCard(promo: promo, onTap: () => _open(promo)); + }, + ), + ), + const SliverToBoxAdapter(child: SizedBox(height: 16)), + ]; + } + + Widget _buildEmpty() { + return Padding( + padding: const EdgeInsets.fromLTRB(32, 32, 32, 64), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 96, + height: 96, + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.06), + shape: BoxShape.circle, + ), + child: const Text('🏷️', style: TextStyle(fontSize: 44)), + ), + const SizedBox(height: 16), + Text( + _filter == _PromoFilter.all + ? 'Belum ada promo' + : 'Belum ada promo ${_filter.label}', + textAlign: TextAlign.center, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text( + 'Promo baru akan muncul di sini.', + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/promo/promo_ui.dart b/lib/presentation/pages/promo/promo_ui.dart new file mode 100644 index 0000000..e63a93f --- /dev/null +++ b/lib/presentation/pages/promo/promo_ui.dart @@ -0,0 +1,140 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../sample/promo_sample_data.dart'; +import '../../components/assets/assets.gen.dart'; +import '../wallet/wallet_ui.dart'; + +/// Promo aktif dengan sisa hari segini dianggap segera berakhir. +const int promoEndingSoonDays = 3; + +extension PromoTypeUi on PromoType { + String get label => switch (this) { + PromoType.point => 'EnakPoint', + PromoType.coin => 'EnakCoin', + PromoType.reward => 'Hadiah', + }; + + /// Warna aksen untuk teks dan latar tipis; cukup gelap di atas putih. + Color get color => switch (this) { + PromoType.point => AppColor.primary, + PromoType.coin => const Color(0xFFC26A00), + PromoType.reward => AppColor.secondaryDark, + }; + + /// Latar banner; teks putih di atasnya. + List get gradient => switch (this) { + PromoType.point => AppColor.primaryGradient, + PromoType.coin => const [Color(0xFFF59E0B), Color(0xFFC2410C)], + PromoType.reward => const [Color(0xFF43A047), Color(0xFF1B5E20)], + }; +} + +bool isPromoUpcoming(Promo promo) => promo.startDate.isAfter(DateTime.now()); + +/// Sisa hari kalender sampai [Promo.endDate]; 0 berarti berakhir hari ini. +int promoDaysLeft(Promo promo) { + final now = DateTime.now(); + final today = DateTime(now.year, now.month, now.day); + final end = DateTime( + promo.endDate.year, + promo.endDate.month, + promo.endDate.day, + ); + return end.difference(today).inDays; +} + +bool isPromoEndingSoon(Promo promo) => + !isPromoUpcoming(promo) && promoDaysLeft(promo) <= promoEndingSoonDays; + +/// "12 Okt". +String formatPromoDate(DateTime date) => + DateFormat('d MMM', 'id_ID').format(date); + +/// "1 Okt – 25 Okt 2026". +String promoPeriodLabel(Promo promo) => + '${formatPromoDate(promo.startDate)} – ' + '${DateFormat('d MMM yyyy', 'id_ID').format(promo.endDate)}'; + +String promoOutletLabel(Promo promo) => + promo.outlets.isEmpty ? 'Semua outlet' : promo.outlets.join(', '); + +/// "Mulai 4 Okt" / "Berakhir 2 hari lagi" / "s/d 25 Okt". +String promoTimeLabel(Promo promo) { + if (isPromoUpcoming(promo)) { + return 'Mulai ${formatPromoDate(promo.startDate)}'; + } + final daysLeft = promoDaysLeft(promo); + if (daysLeft <= 0) return 'Berakhir hari ini'; + if (daysLeft <= promoEndingSoonDays) return 'Berakhir $daysLeft hari lagi'; + return 's/d ${formatPromoDate(promo.endDate)}'; +} + +/// Ikon 3D sesuai hadiah promo. +class PromoTypeIcon extends StatelessWidget { + const PromoTypeIcon({super.key, required this.type, this.size = 32}); + + final PromoType type; + final double size; + + @override + Widget build(BuildContext context) { + return switch (type) { + PromoType.point => WalletCurrencyIcon( + currency: WalletCurrency.point, + size: size, + ), + PromoType.coin => WalletCurrencyIcon( + currency: WalletCurrency.coin, + size: size, + ), + PromoType.reward => Assets.icons.enakrewardIcon.image( + width: size, + height: size, + fit: BoxFit.contain, + // Aset aslinya besar; decode seukuran tampilan saja. + cacheWidth: (size * MediaQuery.devicePixelRatioOf(context)).round(), + ), + }; + } +} + +/// Label waktu promo: biru bila belum mulai, oranye bila segera berakhir. +class PromoTimeBadge extends StatelessWidget { + const PromoTimeBadge({super.key, required this.promo}); + + final Promo promo; + + @override + Widget build(BuildContext context) { + final color = isPromoUpcoming(promo) + ? AppColor.info + : isPromoEndingSoon(promo) + ? AppColor.warning + : AppColor.textSecondary; + + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3), + decoration: BoxDecoration( + color: color.withOpacity(0.1), + borderRadius: BorderRadius.circular(20), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.schedule, size: 12, color: color), + const SizedBox(width: 4), + Text( + promoTimeLabel(promo), + style: AppStyle.xs.copyWith( + color: color, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/promo/widgets/promo_banner.dart b/lib/presentation/pages/promo/widgets/promo_banner.dart new file mode 100644 index 0000000..b638a98 --- /dev/null +++ b/lib/presentation/pages/promo/widgets/promo_banner.dart @@ -0,0 +1,161 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/promo_sample_data.dart'; +import '../promo_ui.dart'; + +/// Kartu besar untuk promo unggulan di bagian atas EnakPromo. +class PromoBanner extends StatelessWidget { + const PromoBanner({super.key, required this.promo, required this.onTap}); + + final Promo promo; + final VoidCallback onTap; + + static const double _iconSize = 96; + + @override + Widget build(BuildContext context) { + final gradient = promo.type.gradient; + + return DecoratedBox( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + gradient: LinearGradient( + colors: gradient, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + boxShadow: [ + BoxShadow( + color: gradient.last.withOpacity(0.3), + blurRadius: 12, + offset: const Offset(0, 6), + ), + ], + ), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(20), + onTap: onTap, + child: ClipRRect( + borderRadius: BorderRadius.circular(20), + child: Stack( + children: [ + // Lingkaran dekoratif di belakang ikon. + Positioned( + right: -36, + top: -36, + child: _Circle(size: 150, opacity: 0.1), + ), + Positioned( + right: 40, + bottom: -48, + child: _Circle(size: 100, opacity: 0.08), + ), + Positioned( + right: 14, + bottom: 14, + child: PromoTypeIcon(type: promo.type, size: _iconSize), + ), + Padding( + padding: const EdgeInsets.fromLTRB( + 18, + 16, + _iconSize + 20, + 16, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _Pill(text: promo.rewardLabel, color: promo.type.color), + const SizedBox(height: 8), + Text( + promo.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.xl.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w800, + height: 1.2, + ), + ), + const SizedBox(height: 4), + Text( + promo.subtitle, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith( + color: AppColor.textWhite.withOpacity(0.9), + ), + ), + const Spacer(), + Row( + children: [ + Icon( + Icons.schedule, + size: 14, + color: AppColor.textWhite.withOpacity(0.9), + ), + const SizedBox(width: 4), + Text( + promoTimeLabel(promo), + style: AppStyle.xs.copyWith( + color: AppColor.textWhite.withOpacity(0.9), + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ], + ), + ), + ], + ), + ), + ), + ), + ); + } +} + +class _Pill extends StatelessWidget { + const _Pill({required this.text, required this.color}); + + final String text; + final Color color; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(20), + ), + child: Text( + text, + style: AppStyle.xs.copyWith(color: color, fontWeight: FontWeight.w800), + ), + ); + } +} + +class _Circle extends StatelessWidget { + const _Circle({required this.size, required this.opacity}); + + final double size; + final double opacity; + + @override + Widget build(BuildContext context) { + return Container( + width: size, + height: size, + decoration: BoxDecoration( + color: AppColor.white.withOpacity(opacity), + shape: BoxShape.circle, + ), + ); + } +} diff --git a/lib/presentation/pages/promo/widgets/promo_card.dart b/lib/presentation/pages/promo/widgets/promo_card.dart new file mode 100644 index 0000000..e6e8fc5 --- /dev/null +++ b/lib/presentation/pages/promo/widgets/promo_card.dart @@ -0,0 +1,120 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/promo_sample_data.dart'; +import '../promo_ui.dart'; + +class PromoCard extends StatelessWidget { + const PromoCard({super.key, required this.promo, required this.onTap}); + + final Promo promo; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + final color = promo.type.color; + + return Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + shadowColor: Colors.black.withOpacity(0.25), + elevation: 1, + child: InkWell( + borderRadius: BorderRadius.circular(16), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(14), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 56, + height: 56, + alignment: Alignment.center, + decoration: BoxDecoration( + color: color.withOpacity(0.08), + borderRadius: BorderRadius.circular(14), + ), + child: PromoTypeIcon(type: promo.type, size: 34), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: const EdgeInsets.symmetric( + horizontal: 8, + vertical: 3, + ), + decoration: BoxDecoration( + color: color.withOpacity(0.1), + borderRadius: BorderRadius.circular(6), + ), + child: Text( + promo.rewardLabel, + style: AppStyle.xs.copyWith( + color: color, + fontWeight: FontWeight.w800, + ), + ), + ), + const SizedBox(height: 6), + Text( + promo.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 2), + Text( + promo.subtitle, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + ), + ), + const SizedBox(height: 10), + // Wrap: di layar sempit label waktu turun ke baris baru + // supaya nama outlet tidak terpotong. + Wrap( + spacing: 8, + runSpacing: 6, + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.storefront_outlined, + size: 14, + color: AppColor.textSecondary, + ), + const SizedBox(width: 4), + Flexible( + child: Text( + promoOutletLabel(promo), + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + PromoTimeBadge(promo: promo), + ], + ), + ], + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/reward/reward_page.dart b/lib/presentation/pages/reward/reward_page.dart index 1e0952d..c7c4c02 100644 --- a/lib/presentation/pages/reward/reward_page.dart +++ b/lib/presentation/pages/reward/reward_page.dart @@ -2,62 +2,32 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import '../../../common/theme/theme.dart'; +import '../../../sample/reward_sample_data.dart'; +import '../../components/assets/assets.gen.dart'; +import '../../components/delegate/filter_bar_delegate.dart'; +import '../../router/app_router.gr.dart'; +import 'reward_ui.dart'; +import 'widgets/reward_card.dart'; +import 'widgets/reward_detail_sheet.dart'; -// Models -class Reward { - final String id; - final String name; - final String image; - final int pointsUsed; - final String description; - final DateTime redeemedAt; - final RewardStatus status; - final String? couponCode; - final String? validUntil; - final String? termsAndConditions; - final String categoryName; - final String categoryIcon; +enum _RewardFilter { + all('Semua'), + active('Aktif'), + used('Terpakai'), + expired('Kedaluwarsa'); - Reward({ - required this.id, - required this.name, - required this.image, - required this.pointsUsed, - required this.description, - required this.redeemedAt, - required this.status, - required this.categoryName, - required this.categoryIcon, - this.couponCode, - this.validUntil, - this.termsAndConditions, - }); + const _RewardFilter(this.label); - String get statusText { - switch (status) { - case RewardStatus.active: - return "Aktif"; - case RewardStatus.used: - return "Sudah Digunakan"; - case RewardStatus.expired: - return "Kadaluarsa"; - } - } + final String label; - Color get statusColor { - switch (status) { - case RewardStatus.active: - return AppColor.success; - case RewardStatus.used: - return AppColor.textSecondary; - case RewardStatus.expired: - return AppColor.error; - } - } + bool matches(Reward reward) => switch (this) { + _RewardFilter.all => true, + _RewardFilter.active => reward.status == RewardStatus.active, + _RewardFilter.used => reward.status == RewardStatus.used, + _RewardFilter.expired => reward.status == RewardStatus.expired, + }; } -enum RewardStatus { active, used, expired } - @RoutePage() class RewardPage extends StatefulWidget { const RewardPage({super.key}); @@ -66,413 +36,262 @@ class RewardPage extends StatefulWidget { State createState() => _RewardPageState(); } -class _RewardPageState extends State - with SingleTickerProviderStateMixin { - late TabController _tabController; +class _RewardPageState extends State { + _RewardFilter _filter = _RewardFilter.all; - // Sample reward data - final List rewards = [ - Reward( - id: "r1", - name: "Es Teh Manis", - image: "🧊", - pointsUsed: 1500, - description: "Teh manis dingin segar", - redeemedAt: DateTime.now().subtract(Duration(hours: 2)), - status: RewardStatus.active, - categoryName: "Minuman", - categoryIcon: "🥤", - couponCode: "ETM123456", - validUntil: "31 Des 2025", - termsAndConditions: - "Berlaku untuk dine-in dan take away. Tidak dapat digabung dengan promo lain.", - ), - Reward( - id: "r2", - name: "Diskon 50%", - image: "🏷️", - pointsUsed: 5000, - description: "Potongan harga 50% untuk semua menu", - redeemedAt: DateTime.now().subtract(Duration(days: 1)), - status: RewardStatus.used, - categoryName: "Voucher", - categoryIcon: "🎟️", - couponCode: "DISC50789", - validUntil: "15 Des 2025", - termsAndConditions: - "Berlaku untuk pembelian minimum Rp 50.000. Tidak berlaku untuk menu promo.", - ), - Reward( - id: "r3", - name: "Nasi Gudeg", - image: "🍛", - pointsUsed: 4000, - description: "Gudeg Jogja autentik", - redeemedAt: DateTime.now().subtract(Duration(days: 3)), - status: RewardStatus.active, - categoryName: "Makanan", - categoryIcon: "🍽️", - couponCode: "GUDEG456", - validUntil: "25 Des 2025", - termsAndConditions: - "Berlaku untuk 1 porsi. Dapat dimakan di tempat atau dibawa pulang.", - ), - Reward( - id: "r4", - name: "Gratis Ongkir", - image: "🚚", - pointsUsed: 2000, - description: "Bebas ongkos kirim untuk pesanan apapun", - redeemedAt: DateTime.now().subtract(Duration(days: 15)), - status: RewardStatus.expired, - categoryName: "Voucher", - categoryIcon: "🎟️", - validUntil: "20 Agu 2025", - termsAndConditions: - "Berlaku untuk area Jabodetabek. Minimum pembelian Rp 25.000.", - ), - Reward( - id: "r5", - name: "Kopi Susu", - image: "☕", - pointsUsed: 2000, - description: "Kopi dengan susu creamy", - redeemedAt: DateTime.now().subtract(Duration(days: 7)), - status: RewardStatus.used, - categoryName: "Minuman", - categoryIcon: "🥤", - couponCode: "KOPI987654", - validUntil: "30 Nov 2025", - termsAndConditions: - "Berlaku untuk size regular. Dapat request level manis.", - ), - ]; + /// Aktif lebih dulu, urut yang paling cepat berakhir; sisanya terbaru dulu. + final List _rewards = [...rewardSamples] + ..sort((a, b) { + final aActive = a.status == RewardStatus.active; + final bActive = b.status == RewardStatus.active; + if (aActive != bActive) return aActive ? -1 : 1; + if (aActive) return a.validUntil.compareTo(b.validUntil); + return b.redeemedAt.compareTo(a.redeemedAt); + }); - @override - void initState() { - super.initState(); - _tabController = TabController(length: 4, vsync: this); - } + List get _activeRewards => + _rewards.where(_RewardFilter.active.matches).toList(); - List get filteredRewards { - switch (_tabController.index) { - case 0: - return rewards; // Semua - case 1: - return rewards.where((r) => r.status == RewardStatus.active).toList(); - case 2: - return rewards.where((r) => r.status == RewardStatus.used).toList(); - case 3: - return rewards.where((r) => r.status == RewardStatus.expired).toList(); - default: - return rewards; - } - } + int _countOf(_RewardFilter filter) => _rewards.where(filter.matches).length; @override Widget build(BuildContext context) { + final visible = _rewards.where(_filter.matches).toList(); + return Scaffold( - backgroundColor: AppColor.backgroundLight, - appBar: AppBar(title: Text("Reward Saya"), centerTitle: true), - body: Column( - children: [ - _buildCleanTabBar(), - Expanded( - child: TabBarView( - controller: _tabController, - children: [ - _buildRewardList(), // Semua - _buildRewardList(), // Aktif - _buildRewardList(), // Digunakan - _buildRewardList(), // Kadaluarsa - ], + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Reward Saya')), + body: CustomScrollView( + slivers: [ + SliverToBoxAdapter(child: _buildSummary()), + SliverPersistentHeader( + pinned: true, + delegate: FilterBarDelegate<_RewardFilter>( + values: _RewardFilter.values, + selected: _filter, + labelOf: (filter) => filter.label, + countOf: _countOf, + onSelected: (filter) => setState(() => _filter = filter), ), ), + if (visible.isEmpty) + SliverFillRemaining(hasScrollBody: false, child: _buildEmpty()) + else + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 4, 16, 32), + sliver: SliverList.separated( + itemCount: visible.length, + separatorBuilder: (_, _) => const SizedBox(height: 12), + itemBuilder: (context, index) { + final reward = visible[index]; + return RewardCard( + reward: reward, + onTap: () => RewardDetailSheet.show(context, reward), + ); + }, + ), + ), ], ), ); } - Widget _buildCleanTabBar() { - final activeCount = rewards - .where((r) => r.status == RewardStatus.active) - .length; - final usedCount = rewards - .where((r) => r.status == RewardStatus.used) - .length; - final expiredCount = rewards - .where((r) => r.status == RewardStatus.expired) - .length; + Widget _buildSummary() { + final active = _activeRewards; + // Sudah terurut: yang pertama adalah yang paling cepat berakhir. + final expiringSoon = active.where(isRewardExpiringSoon).firstOrNull; return Container( - margin: EdgeInsets.symmetric(horizontal: 20, vertical: 12), + margin: const EdgeInsets.fromLTRB(16, 16, 16, 4), + padding: const EdgeInsets.all(16), decoration: BoxDecoration( - color: AppColor.white, + gradient: const LinearGradient( + colors: AppColor.primaryGradient, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), borderRadius: BorderRadius.circular(16), boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.04), - blurRadius: 20, - offset: Offset(0, 4), + color: AppColor.primary.withOpacity(0.3), + blurRadius: 12, + offset: const Offset(0, 6), ), ], ), - child: TabBar( - controller: _tabController, - indicatorSize: TabBarIndicatorSize.tab, - isScrollable: true, - tabAlignment: TabAlignment.start, - dividerColor: Colors.transparent, - onTap: (index) => setState(() {}), - tabs: [ - _buildCleanTab("Semua", rewards.length), - _buildCleanTab("Aktif", activeCount), - _buildCleanTab("Terpakai", usedCount), - _buildCleanTab("Expired", expiredCount), - ], - ), - ); - } - - Widget _buildCleanTab(String label, int count) { - return Container(height: 44, child: Center(child: Text("$label ($count)"))); - } - - Widget _buildRewardList() { - final filteredData = filteredRewards; - - if (filteredData.isEmpty) { - return _buildEmptyState(); - } - - return ListView.builder( - padding: EdgeInsets.symmetric(horizontal: 20, vertical: 8), - itemCount: filteredData.length, - itemBuilder: (context, index) { - final reward = filteredData[index]; - return _buildCleanRewardCard(reward); - }, - ); - } - - Widget _buildEmptyState() { - String message; - String icon; - - switch (_tabController.index) { - case 1: - message = "Belum ada reward aktif"; - icon = "🎯"; - break; - case 2: - message = "Belum ada reward yang digunakan"; - icon = "✅"; - break; - case 3: - message = "Tidak ada reward yang kadaluarsa"; - icon = "⏰"; - break; - default: - message = "Belum ada reward"; - icon = "🎁"; - } - - return Center( child: Column( - mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(icon, style: TextStyle(fontSize: 64)), - SizedBox(height: 16), - Text( - message, - style: AppStyle.lg.copyWith( - color: AppColor.textSecondary, - fontWeight: FontWeight.w600, - ), - ), - SizedBox(height: 8), - Text( - "Tukar poin Anda untuk mendapatkan reward menarik", - style: AppStyle.sm.copyWith(color: AppColor.textLight), - textAlign: TextAlign.center, - ), - SizedBox(height: 24), - ElevatedButton( - onPressed: () => context.router.back(), - style: ElevatedButton.styleFrom( - backgroundColor: AppColor.primary, - foregroundColor: AppColor.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(12), - ), - padding: EdgeInsets.symmetric(horizontal: 24, vertical: 12), - elevation: 0, - ), - child: Text( - "Tukar Poin Sekarang", - style: AppStyle.sm.copyWith( - fontWeight: FontWeight.w600, - color: AppColor.white, - ), - ), - ), - ], - ), - ); - } - - Widget _buildCleanRewardCard(Reward reward) { - return Container( - margin: EdgeInsets.only(bottom: 12), - decoration: BoxDecoration( - color: AppColor.white, - borderRadius: BorderRadius.circular(16), - boxShadow: [ - BoxShadow( - color: Colors.black.withOpacity(0.04), - blurRadius: 20, - offset: Offset(0, 4), - ), - ], - ), - child: InkWell( - onTap: () {}, - borderRadius: BorderRadius.circular(16), - child: Padding( - padding: EdgeInsets.all(20), - child: Row( + Row( children: [ - // Product Image - Simplified Container( - width: 56, - height: 56, - decoration: BoxDecoration( - color: AppColor.backgroundLight, - borderRadius: BorderRadius.circular(14), + width: 48, + height: 48, + padding: const EdgeInsets.all(8), + decoration: const BoxDecoration( + color: AppColor.white, + shape: BoxShape.circle, ), - child: Center( - child: Text(reward.image, style: TextStyle(fontSize: 24)), + child: Assets.icons.enakrewardIcon.image( + fit: BoxFit.contain, + // Aset aslinya besar; decode seukuran tampilan saja. + cacheWidth: (32 * MediaQuery.devicePixelRatioOf(context)) + .round(), ), ), - SizedBox(width: 16), - - // Reward Info - Cleaner layout + const SizedBox(width: 12), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Expanded( - child: Text( - reward.name, - style: AppStyle.md.copyWith( - fontWeight: FontWeight.w600, - color: AppColor.textPrimary, - ), - ), - ), - _buildStatusBadge(reward), - ], - ), - SizedBox(height: 4), Text( - reward.description, + 'Siap dipakai', style: AppStyle.sm.copyWith( - color: AppColor.textSecondary, + color: AppColor.textWhite.withOpacity(0.9), ), ), - SizedBox(height: 8), - Row( - children: [ - Icon( - Icons.access_time, - size: 12, - color: AppColor.textLight, + FittedBox( + fit: BoxFit.scaleDown, + alignment: Alignment.centerLeft, + child: Text( + '${active.length} reward', + style: AppStyle.h5.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w700, ), - SizedBox(width: 4), - Text( - _formatDate(reward.redeemedAt), - style: AppStyle.xs.copyWith( - color: AppColor.textLight, - ), - ), - Spacer(), - Icon(Icons.stars, size: 14, color: AppColor.warning), - SizedBox(width: 4), - Text( - "${reward.pointsUsed}", - style: AppStyle.xs.copyWith( - color: AppColor.textSecondary, - fontWeight: FontWeight.w600, - ), - ), - ], + ), ), ], ), ), + Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(20), + child: InkWell( + borderRadius: BorderRadius.circular(20), + onTap: () => context.router.push(const CoinRoute()), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 14, + vertical: 8, + ), + child: Text( + 'Tukar Poin', + style: AppStyle.sm.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ), ], ), - ), + if (expiringSoon != null) ...[ + const SizedBox(height: 14), + Material( + color: AppColor.white.withOpacity(0.15), + borderRadius: BorderRadius.circular(10), + child: InkWell( + borderRadius: BorderRadius.circular(10), + onTap: () => RewardDetailSheet.show(context, expiringSoon), + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 10, + ), + child: Row( + children: [ + const Icon( + Icons.schedule, + size: 16, + color: AppColor.textWhite, + ), + const SizedBox(width: 8), + Expanded( + child: Text( + '${expiringSoon.name} · ' + '${rewardValidityLabel(expiringSoon).toLowerCase()}', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w600, + ), + ), + ), + const Icon( + Icons.chevron_right, + size: 18, + color: AppColor.textWhite, + ), + ], + ), + ), + ), + ), + ], + ], ), ); } - Widget _buildStatusBadge(Reward reward) { - return Container( - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4), - decoration: BoxDecoration( - color: reward.statusColor.withOpacity(0.1), - borderRadius: BorderRadius.circular(6), - ), - child: Text( - reward.statusText, - style: AppStyle.xs.copyWith( - color: reward.statusColor, - fontWeight: FontWeight.w600, - ), + Widget _buildEmpty() { + final (String emoji, String message) = switch (_filter) { + _RewardFilter.all => ('🎁', 'Belum ada reward'), + _RewardFilter.active => ('🎯', 'Belum ada reward aktif'), + _RewardFilter.used => ('✅', 'Belum ada reward yang dipakai'), + _RewardFilter.expired => ('⏰', 'Tidak ada reward yang kedaluwarsa'), + }; + + return Padding( + padding: const EdgeInsets.fromLTRB(32, 32, 32, 64), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 96, + height: 96, + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.06), + shape: BoxShape.circle, + ), + child: Text(emoji, style: const TextStyle(fontSize: 44)), + ), + const SizedBox(height: 16), + Text( + message, + textAlign: TextAlign.center, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text( + 'Tukar poin kamu untuk mendapatkan reward menarik', + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + if (_filter == _RewardFilter.all || + _filter == _RewardFilter.active) ...[ + const SizedBox(height: 20), + ElevatedButton( + onPressed: () => context.router.push(const CoinRoute()), + style: ElevatedButton.styleFrom( + padding: const EdgeInsets.symmetric( + horizontal: 24, + vertical: 12, + ), + ), + child: Text( + 'Tukar Poin Sekarang', + style: AppStyle.sm.copyWith( + color: AppColor.white, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ], ), ); } - - String _formatDate(DateTime date) { - final months = [ - '', - 'Jan', - 'Feb', - 'Mar', - 'Apr', - 'Mei', - 'Jun', - 'Jul', - 'Agu', - 'Sep', - 'Okt', - 'Nov', - 'Des', - ]; - - final now = DateTime.now(); - final difference = now.difference(date); - - if (difference.inDays == 0) { - if (difference.inHours == 0) { - return "${difference.inMinutes} menit lalu"; - } - return "${difference.inHours} jam lalu"; - } else if (difference.inDays == 1) { - return "Kemarin"; - } else if (difference.inDays < 7) { - return "${difference.inDays} hari lalu"; - } else { - return "${date.day} ${months[date.month]} ${date.year}"; - } - } - - @override - void dispose() { - _tabController.dispose(); - super.dispose(); - } } diff --git a/lib/presentation/pages/reward/reward_ui.dart b/lib/presentation/pages/reward/reward_ui.dart new file mode 100644 index 0000000..08ab35e --- /dev/null +++ b/lib/presentation/pages/reward/reward_ui.dart @@ -0,0 +1,98 @@ +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../sample/reward_sample_data.dart'; + +/// Reward aktif dengan sisa masa berlaku segini dianggap segera berakhir. +const int rewardExpiringSoonDays = 7; + +extension RewardStatusUi on RewardStatus { + String get label => switch (this) { + RewardStatus.active => 'Aktif', + RewardStatus.used => 'Terpakai', + RewardStatus.expired => 'Kedaluwarsa', + }; + + Color get color => switch (this) { + RewardStatus.active => AppColor.success, + RewardStatus.used => AppColor.textSecondary, + RewardStatus.expired => AppColor.error, + }; +} + +/// Tanggal pendek: "1 Okt 2026". +String formatRewardDate(DateTime date) => + DateFormat('d MMM yyyy', 'id_ID').format(date); + +/// Sisa hari kalender sampai [Reward.validUntil]; 0 berarti berakhir hari ini. +int rewardDaysLeft(Reward reward) { + final now = DateTime.now(); + final today = DateTime(now.year, now.month, now.day); + final end = DateTime( + reward.validUntil.year, + reward.validUntil.month, + reward.validUntil.day, + ); + return end.difference(today).inDays; +} + +bool isRewardExpiringSoon(Reward reward) => + reward.status == RewardStatus.active && + rewardDaysLeft(reward) <= rewardExpiringSoonDays; + +/// "Berakhir hari ini" / "Berakhir 3 hari lagi" / "Berlaku s/d 25 Okt 2026". +String rewardValidityLabel(Reward reward) { + final daysLeft = rewardDaysLeft(reward); + if (daysLeft <= 0) return 'Berakhir hari ini'; + if (daysLeft <= rewardExpiringSoonDays) { + return 'Berakhir $daysLeft hari lagi'; + } + return 'Berlaku s/d ${formatRewardDate(reward.validUntil)}'; +} + +class RewardStatusBadge extends StatelessWidget { + const RewardStatusBadge({super.key, required this.status}); + + final RewardStatus status; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3), + decoration: BoxDecoration( + color: status.color.withOpacity(0.1), + borderRadius: BorderRadius.circular(20), + ), + child: Text( + status.label, + style: AppStyle.xs.copyWith( + color: status.color, + fontWeight: FontWeight.w700, + ), + ), + ); + } +} + +/// Emoji reward; abu-abu untuk reward yang sudah tidak bisa dipakai. +class RewardEmoji extends StatelessWidget { + const RewardEmoji({super.key, required this.reward, required this.size}); + + final Reward reward; + final double size; + + static const ColorFilter _greyscale = ColorFilter.matrix([ + 0.2126, 0.7152, 0.0722, 0, 0, // + 0.2126, 0.7152, 0.0722, 0, 0, // + 0.2126, 0.7152, 0.0722, 0, 0, // + 0, 0, 0, 0.5, 0, // + ]); + + @override + Widget build(BuildContext context) { + final emoji = Text(reward.emoji, style: TextStyle(fontSize: size)); + if (reward.status == RewardStatus.active) return emoji; + return ColorFiltered(colorFilter: _greyscale, child: emoji); + } +} diff --git a/lib/presentation/pages/reward/widgets/reward_card.dart b/lib/presentation/pages/reward/widgets/reward_card.dart new file mode 100644 index 0000000..4b436c3 --- /dev/null +++ b/lib/presentation/pages/reward/widgets/reward_card.dart @@ -0,0 +1,249 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../sample/reward_sample_data.dart'; +import '../reward_ui.dart'; + +/// Kartu reward berbentuk tiket: sobekan kiri (emoji + poin) dan isi kanan. +class RewardCard extends StatelessWidget { + const RewardCard({super.key, required this.reward, required this.onTap}); + + final Reward reward; + final VoidCallback onTap; + + static const double _stubWidth = 84; + + bool get _isActive => reward.status == RewardStatus.active; + + @override + Widget build(BuildContext context) { + return PhysicalShape( + clipper: const _TicketClipper(notchX: _stubWidth + 0.5), + color: AppColor.white, + elevation: 2, + shadowColor: Colors.black.withOpacity(0.25), + child: Material( + type: MaterialType.transparency, + child: InkWell( + onTap: onTap, + child: IntrinsicHeight( + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _buildStub(), + const Padding( + padding: EdgeInsets.symmetric(vertical: 14), + child: CustomPaint( + size: Size(1, double.infinity), + painter: _VerticalDashPainter(), + ), + ), + Expanded(child: _buildBody()), + ], + ), + ), + ), + ), + ); + } + + Widget _buildStub() { + return Container( + width: _stubWidth, + color: _isActive + ? AppColor.primary.withOpacity(0.06) + : AppColor.background, + padding: const EdgeInsets.symmetric(vertical: 16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + RewardEmoji(reward: reward, size: 34), + const SizedBox(height: 8), + Text( + reward.pointsUsed.thousandFormat, + style: AppStyle.md.copyWith( + color: _isActive ? AppColor.primary : AppColor.textSecondary, + fontWeight: FontWeight.w700, + ), + ), + Text( + 'poin', + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ); + } + + Widget _buildBody() { + return Padding( + padding: const EdgeInsets.fromLTRB(14, 12, 14, 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + reward.categoryName.toUpperCase(), + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w700, + letterSpacing: 0.6, + ), + ), + ), + RewardStatusBadge(status: reward.status), + ], + ), + const SizedBox(height: 4), + Text( + reward.name, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.lg.copyWith( + color: _isActive ? AppColor.textPrimary : AppColor.textSecondary, + fontWeight: FontWeight.w700, + ), + ), + const SizedBox(height: 2), + Text( + reward.description, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 10), + Row( + children: [ + Expanded(child: _buildFootnote()), + if (_isActive) ...[ + const SizedBox(width: 8), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 14, + vertical: 6, + ), + decoration: BoxDecoration( + color: AppColor.primary, + borderRadius: BorderRadius.circular(20), + ), + child: Text( + 'Pakai', + style: AppStyle.sm.copyWith( + color: AppColor.white, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ], + ), + ], + ), + ); + } + + Widget _buildFootnote() { + final (IconData icon, String text, Color color) = switch (reward.status) { + RewardStatus.active => ( + Icons.schedule, + rewardValidityLabel(reward), + isRewardExpiringSoon(reward) + ? AppColor.warning + : AppColor.textSecondary, + ), + RewardStatus.used => ( + Icons.check_circle_outline, + reward.usedAt == null + ? 'Sudah dipakai' + : 'Dipakai ${formatRewardDate(reward.usedAt!)}', + AppColor.textSecondary, + ), + RewardStatus.expired => ( + Icons.event_busy_outlined, + 'Berakhir ${formatRewardDate(reward.validUntil)}', + AppColor.textSecondary, + ), + }; + + return Row( + children: [ + Icon(icon, size: 14, color: color), + const SizedBox(width: 4), + Expanded( + child: Text( + text, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith( + color: color, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ); + } +} + +/// Persegi panjang membulat dengan lekuk setengah lingkaran di atas dan +/// bawah pada posisi [notchX], tempat garis sobekan tiket. +class _TicketClipper extends CustomClipper { + const _TicketClipper({required this.notchX}); + + final double notchX; + + static const double _radius = 16; + static const double _notchRadius = 8; + + @override + Path getClip(Size size) { + final card = Path() + ..addRRect( + RRect.fromRectAndRadius( + Offset.zero & size, + const Radius.circular(_radius), + ), + ); + final notches = Path() + ..addOval( + Rect.fromCircle(center: Offset(notchX, 0), radius: _notchRadius), + ) + ..addOval( + Rect.fromCircle( + center: Offset(notchX, size.height), + radius: _notchRadius, + ), + ); + return Path.combine(PathOperation.difference, card, notches); + } + + @override + bool shouldReclip(covariant _TicketClipper oldClipper) => + oldClipper.notchX != notchX; +} + +class _VerticalDashPainter extends CustomPainter { + const _VerticalDashPainter(); + + static const double _dash = 5; + static const double _gap = 4; + + @override + void paint(Canvas canvas, Size size) { + final paint = Paint() + ..color = AppColor.border + ..strokeWidth = size.width; + final x = size.width / 2; + + for (double y = 0; y < size.height; y += _dash + _gap) { + final end = (y + _dash).clamp(0, size.height).toDouble(); + canvas.drawLine(Offset(x, y), Offset(x, end), paint); + } + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) => false; +} diff --git a/lib/presentation/pages/reward/widgets/reward_detail_sheet.dart b/lib/presentation/pages/reward/widgets/reward_detail_sheet.dart new file mode 100644 index 0000000..0a5430e --- /dev/null +++ b/lib/presentation/pages/reward/widgets/reward_detail_sheet.dart @@ -0,0 +1,280 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../common/ui/painter/dashed_line_painter.dart'; +import '../../../../sample/reward_sample_data.dart'; +import '../../../components/toast/flushbar.dart'; +import '../reward_ui.dart'; + +class RewardDetailSheet extends StatelessWidget { + const RewardDetailSheet({super.key, required this.reward}); + + final Reward reward; + + static Future show(BuildContext context, Reward reward) { + return showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: AppColor.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + builder: (_) => RewardDetailSheet(reward: reward), + ); + } + + bool get _isActive => reward.status == RewardStatus.active; + + @override + Widget build(BuildContext context) { + return ConstrainedBox( + constraints: BoxConstraints( + maxHeight: MediaQuery.sizeOf(context).height * 0.85, + ), + child: SafeArea( + top: false, + child: SingleChildScrollView( + padding: const EdgeInsets.fromLTRB(20, 12, 20, 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Center( + child: Container( + width: 40, + height: 4, + decoration: BoxDecoration( + color: AppColor.border, + borderRadius: BorderRadius.circular(2), + ), + ), + ), + const SizedBox(height: 20), + _buildHeader(), + const SizedBox(height: 20), + if (_isActive && reward.couponCode != null) + _CouponBox(code: reward.couponCode!) + else + _buildInactiveNote(), + const SizedBox(height: 20), + _InfoRow( + label: 'Ditukar pada', + value: formatRewardDate(reward.redeemedAt), + ), + _InfoRow( + label: 'Berlaku sampai', + value: formatRewardDate(reward.validUntil), + valueColor: isRewardExpiringSoon(reward) + ? AppColor.warning + : null, + ), + if (reward.usedAt != null) + _InfoRow( + label: 'Dipakai pada', + value: formatRewardDate(reward.usedAt!), + ), + _InfoRow( + label: 'Poin ditukar', + value: '${reward.pointsUsed.thousandFormat} poin', + ), + if (reward.termsAndConditions != null) ...[ + const SizedBox(height: 16), + Text( + 'Syarat & Ketentuan', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text( + reward.termsAndConditions!, + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + height: 1.5, + ), + ), + ], + ], + ), + ), + ), + ); + } + + Widget _buildHeader() { + return Row( + children: [ + Container( + width: 56, + height: 56, + alignment: Alignment.center, + decoration: BoxDecoration( + color: _isActive + ? AppColor.primary.withOpacity(0.06) + : AppColor.background, + borderRadius: BorderRadius.circular(14), + ), + child: RewardEmoji(reward: reward, size: 28), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + reward.categoryName.toUpperCase(), + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w700, + letterSpacing: 0.6, + ), + ), + const SizedBox(height: 2), + Text( + reward.name, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + Text( + reward.description, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ), + const SizedBox(width: 8), + RewardStatusBadge(status: reward.status), + ], + ); + } + + Widget _buildInactiveNote() { + final message = switch (reward.status) { + RewardStatus.used => + reward.usedAt == null + ? 'Reward ini sudah dipakai.' + : 'Reward ini sudah dipakai pada ' + '${formatRewardDate(reward.usedAt!)}.', + _ => + 'Masa berlaku reward ini sudah habis pada ' + '${formatRewardDate(reward.validUntil)}.', + }; + + return Container( + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: AppColor.background, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Row( + children: [ + Icon(Icons.info_outline, size: 20, color: reward.status.color), + const SizedBox(width: 10), + Expanded( + child: Text( + message, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ), + ], + ), + ); + } +} + +class _CouponBox extends StatelessWidget { + const _CouponBox({required this.code}); + + final String code; + + Future _copy(BuildContext context) async { + await Clipboard.setData(ClipboardData(text: code)); + if (!context.mounted) return; + AppFlushbar.showSuccess(context, 'Kode reward disalin'); + } + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + border: Border.all(color: AppColor.border), + borderRadius: BorderRadius.circular(16), + ), + child: Column( + children: [ + QrImageView( + data: code, + size: 168, + padding: EdgeInsets.zero, + backgroundColor: AppColor.white, + ), + const SizedBox(height: 12), + Text( + 'Tunjukkan QR atau kode ini ke kasir', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 14), + CustomPaint( + size: const Size(double.infinity, 1), + painter: DashedLinePainter(), + ), + const SizedBox(height: 6), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Flexible( + child: Text( + code, + style: AppStyle.xl.copyWith( + fontWeight: FontWeight.w700, + letterSpacing: 2, + ), + ), + ), + IconButton( + onPressed: () => _copy(context), + tooltip: 'Salin kode', + icon: const Icon( + Icons.copy_rounded, + size: 20, + color: AppColor.primary, + ), + ), + ], + ), + ], + ), + ); + } +} + +class _InfoRow extends StatelessWidget { + const _InfoRow({required this.label, required this.value, this.valueColor}); + + final String label; + final String value; + final Color? valueColor; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6), + child: Row( + children: [ + Text( + label, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + const Spacer(), + Text( + value, + style: AppStyle.sm.copyWith( + color: valueColor ?? AppColor.textPrimary, + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/shop/pages/shop_category/shop_category_page.dart b/lib/presentation/pages/shop/pages/shop_category/shop_category_page.dart new file mode 100644 index 0000000..7162bef --- /dev/null +++ b/lib/presentation/pages/shop/pages/shop_category/shop_category_page.dart @@ -0,0 +1,135 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../../../common/theme/theme.dart'; +import '../../../../../sample/shop_sample_data.dart'; +import '../../../../components/delegate/filter_bar_delegate.dart'; +import '../../../../router/app_router.gr.dart'; +import '../../shop_ui.dart'; +import '../../widgets/shop_product_card.dart'; + +enum _ShopSort { + popular('Terlaris'), + newest('Terbaru'), + cheapest('Termurah'), + priciest('Termahal'); + + const _ShopSort(this.label); + + final String label; + + int compare(ShopProduct a, ShopProduct b) => switch (this) { + _ShopSort.popular => b.soldCount.compareTo(a.soldCount), + _ShopSort.newest => b.addedAt.compareTo(a.addedAt), + _ShopSort.cheapest => a.finalPrice.compareTo(b.finalPrice), + _ShopSort.priciest => b.finalPrice.compareTo(a.finalPrice), + }; +} + +/// Daftar produk satu kategori, semua produk (`category` kosong), atau hanya +/// yang sedang diskon ([promoOnly]). +@RoutePage() +class ShopCategoryPage extends StatefulWidget { + const ShopCategoryPage({super.key, this.category, this.promoOnly = false}); + + final ShopCategory? category; + final bool promoOnly; + + @override + State createState() => _ShopCategoryPageState(); +} + +class _ShopCategoryPageState extends State { + _ShopSort _sort = _ShopSort.popular; + + late final List _products = shopSamples + .where( + (p) => + (widget.category == null || p.category == widget.category) && + (!widget.promoOnly || p.isDiscounted), + ) + .toList(); + + String get _title { + if (widget.promoOnly) return 'Lagi Promo'; + return widget.category?.label ?? 'Semua Produk'; + } + + @override + Widget build(BuildContext context) { + final sorted = [..._products]..sort(_sort.compare); + + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: Text(_title)), + body: CustomScrollView( + slivers: [ + SliverPersistentHeader( + pinned: true, + delegate: FilterBarDelegate<_ShopSort>( + values: _ShopSort.values, + selected: _sort, + labelOf: (sort) => sort.label, + onSelected: (sort) => setState(() => _sort = sort), + ), + ), + if (sorted.isEmpty) + SliverFillRemaining(hasScrollBody: false, child: _buildEmpty()) + else ...[ + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 10), + child: Text( + '${sorted.length} produk', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ), + ), + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 24), + sliver: SliverGrid.builder( + gridDelegate: shopProductGridDelegate(context), + itemCount: sorted.length, + itemBuilder: (context, index) { + final product = sorted[index]; + return ShopProductCard( + product: product, + onTap: () => context.router.push( + ShopProductDetailRoute(product: product), + ), + ); + }, + ), + ), + ], + ], + ), + ); + } + + Widget _buildEmpty() { + return Padding( + padding: const EdgeInsets.fromLTRB(32, 32, 32, 64), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + widget.category?.emoji ?? '🛍️', + style: const TextStyle(fontSize: 44), + ), + const SizedBox(height: 16), + Text( + 'Belum ada produk', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text( + 'Produk baru akan muncul di sini.', + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/shop/pages/shop_product_detail/shop_product_detail_page.dart b/lib/presentation/pages/shop/pages/shop_product_detail/shop_product_detail_page.dart new file mode 100644 index 0000000..67a7b5b --- /dev/null +++ b/lib/presentation/pages/shop/pages/shop_product_detail/shop_product_detail_page.dart @@ -0,0 +1,265 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../../../common/theme/theme.dart'; +import '../../../../../sample/shop_sample_data.dart'; +import '../../../../components/card/detail_section.dart'; +import '../../../../router/app_router.gr.dart'; +import '../../shop_ui.dart'; +import '../../widgets/shop_product_card.dart'; + +@RoutePage() +class ShopProductDetailPage extends StatefulWidget { + const ShopProductDetailPage({super.key, required this.product}); + + final ShopProduct product; + + @override + State createState() => _ShopProductDetailPageState(); +} + +class _ShopProductDetailPageState extends State { + static const double _relatedCardWidth = 150; + static const int _relatedCount = 6; + static const int _lowStock = 5; + + late String? _variant = widget.product.variants.firstOrNull; + + late final List _related = _findRelated(); + + /// Kategori yang sama lebih dulu, lalu yang terlaris. + List _findRelated() { + final current = widget.product; + final others = shopSamples.where((p) => p.id != current.id).toList() + ..sort((a, b) { + final aSame = a.category == current.category; + final bSame = b.category == current.category; + if (aSame != bSame) return aSame ? -1 : 1; + return b.soldCount.compareTo(a.soldCount); + }); + return others.take(_relatedCount).toList(); + } + + @override + Widget build(BuildContext context) { + final product = widget.product; + + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Detail Produk')), + body: ListView( + padding: const EdgeInsets.only(bottom: 24), + children: [ + AspectRatio( + aspectRatio: 1.2, + child: Stack( + fit: StackFit.expand, + children: [ + ShopProductImage(product: product, emojiSize: 120), + if (product.tag != null) + Positioned( + top: 16, + left: 16, + child: ShopTagBadge(tag: product.tag!), + ), + ], + ), + ), + _buildSummary(product), + Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 0), + child: Column( + children: [ + if (product.variants.isNotEmpty) ...[ + DetailSection( + title: '${product.variantLabel}: $_variant', + child: Wrap( + spacing: 8, + runSpacing: 8, + children: [ + for (final variant in product.variants) + _VariantOption( + label: variant, + isSelected: variant == _variant, + onTap: () => setState(() => _variant = variant), + ), + ], + ), + ), + const SizedBox(height: 12), + ], + DetailSection( + title: 'Info produk', + child: Column( + children: [ + _InfoRow( + label: 'Kategori', + value: product.category.label, + ), + _InfoRow(label: 'Berat / isi', value: product.unit), + ], + ), + ), + const SizedBox(height: 12), + DetailSection( + title: 'Deskripsi', + child: Text( + product.description, + style: AppStyle.md.copyWith( + color: AppColor.textSecondary, + height: 1.5, + ), + ), + ), + ], + ), + ), + if (_related.isNotEmpty) ...[ + Padding( + padding: const EdgeInsets.fromLTRB(16, 20, 16, 10), + child: Text( + 'Produk serupa', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + SizedBox( + height: _relatedCardWidth + shopCardInfoHeight(context), + child: ListView.separated( + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.symmetric(horizontal: 16), + itemCount: _related.length, + separatorBuilder: (_, _) => const SizedBox(width: 12), + itemBuilder: (context, index) { + final related = _related[index]; + return SizedBox( + width: _relatedCardWidth, + child: ShopProductCard( + product: related, + onTap: () => context.router.push( + ShopProductDetailRoute(product: related), + ), + ), + ); + }, + ), + ), + ], + ], + ), + ); + } + + Widget _buildSummary(ShopProduct product) { + final isLowStock = product.stock <= _lowStock; + + return Container( + width: double.infinity, + color: AppColor.white, + padding: const EdgeInsets.fromLTRB(16, 16, 16, 18), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ShopPrice(product: product, large: true), + const SizedBox(height: 10), + Text( + product.name, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text.rich( + TextSpan( + children: [ + TextSpan(text: formatSoldCount(product.soldCount)), + const TextSpan(text: ' · '), + TextSpan( + text: isLowStock + ? 'Sisa ${product.stock}' + : 'Stok ${product.stock}', + style: isLowStock + ? const TextStyle( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ) + : null, + ), + ], + ), + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ); + } +} + +class _VariantOption extends StatelessWidget { + const _VariantOption({ + required this.label, + required this.isSelected, + required this.onTap, + }); + + final String label; + final bool isSelected; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Material( + color: isSelected ? AppColor.primary.withOpacity(0.06) : AppColor.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + side: BorderSide( + color: isSelected ? AppColor.primary : AppColor.border, + width: isSelected ? 1.5 : 1, + ), + ), + child: InkWell( + borderRadius: BorderRadius.circular(10), + onTap: onTap, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8), + child: Text( + label, + style: AppStyle.sm.copyWith( + color: isSelected ? AppColor.primary : AppColor.textPrimary, + fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500, + ), + ), + ), + ), + ); + } +} + +class _InfoRow extends StatelessWidget { + const _InfoRow({required this.label, required this.value}); + + final String label; + final String value; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 5), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + width: 110, + child: Text( + label, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ), + Expanded( + child: Text( + value, + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w600), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/shop/shop_page.dart b/lib/presentation/pages/shop/shop_page.dart new file mode 100644 index 0000000..4283d22 --- /dev/null +++ b/lib/presentation/pages/shop/shop_page.dart @@ -0,0 +1,273 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; + +import '../../../common/theme/theme.dart'; +import '../../../sample/shop_sample_data.dart'; +import '../../components/field/field.dart'; +import '../../router/app_router.gr.dart'; +import 'shop_ui.dart'; +import 'widgets/shop_category_grid.dart'; +import 'widgets/shop_product_card.dart'; +import 'widgets/shop_promo_banner.dart'; + +@RoutePage() +class ShopPage extends StatefulWidget { + const ShopPage({super.key}); + + @override + State createState() => _ShopPageState(); +} + +class _ShopPageState extends State { + static const double _rowCardWidth = 150; + + final _searchController = TextEditingController(); + final _bannerController = PageController(viewportFraction: 0.9); + int _bannerIndex = 0; + + final List _promos = shopPromoSamples; + + /// Terlaris di atas. + final List _products = shopSamples + ..sort((a, b) => b.soldCount.compareTo(a.soldCount)); + + @override + void initState() { + super.initState(); + _searchController.addListener(() => setState(() {})); + } + + @override + void dispose() { + _searchController.dispose(); + _bannerController.dispose(); + super.dispose(); + } + + void _openProduct(ShopProduct product) => + context.router.push(ShopProductDetailRoute(product: product)); + + void _openCategory({ShopCategory? category, bool promoOnly = false}) => + context.router.push( + ShopCategoryRoute(category: category, promoOnly: promoOnly), + ); + + @override + Widget build(BuildContext context) { + final query = _searchController.text.trim().toLowerCase(); + + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('EnakShop')), + body: CustomScrollView( + slivers: [ + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.only(top: 12), + child: SearchTextField( + hintText: 'Cari di EnakShop', + prefixIcon: Icons.search, + controller: _searchController, + ), + ), + ), + if (query.isNotEmpty) + ..._buildSearchResults(query) + else ...[ + SliverToBoxAdapter(child: _buildBanners()), + const SliverToBoxAdapter(child: _SectionTitle(title: 'Kategori')), + SliverToBoxAdapter( + child: ShopCategoryGrid( + onTap: (category) => _openCategory(category: category), + ), + ), + SliverToBoxAdapter( + child: _SectionTitle( + title: 'Lagi Promo', + onSeeAll: () => _openCategory(promoOnly: true), + ), + ), + SliverToBoxAdapter( + child: _buildProductRow( + _products.where((p) => p.isDiscounted).toList(), + ), + ), + const SliverToBoxAdapter( + child: _SectionTitle(title: 'Rekomendasi'), + ), + _buildGrid(_products), + ], + const SliverToBoxAdapter(child: SizedBox(height: 24)), + ], + ), + ); + } + + List _buildSearchResults(String query) { + final results = _products + .where( + (p) => + p.name.toLowerCase().contains(query) || + p.category.label.toLowerCase().contains(query), + ) + .toList(); + + if (results.isEmpty) { + return [ + SliverFillRemaining( + hasScrollBody: false, + child: Padding( + padding: const EdgeInsets.fromLTRB(32, 32, 32, 64), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('🔍', style: TextStyle(fontSize: 44)), + const SizedBox(height: 16), + Text( + 'Produk tidak ditemukan', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 6), + Text( + 'Coba kata kunci lain, mis. "sambal" atau "kopi".', + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + ), + ), + ), + ]; + } + + return [ + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 12), + child: Text( + '${results.length} produk ditemukan', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ), + ), + _buildGrid(results), + ]; + } + + Widget _buildBanners() { + return Column( + children: [ + SizedBox( + // Ikut skala font sistem supaya teks banner tidak terpotong. + height: MediaQuery.textScalerOf(context).scale(150), + child: PageView.builder( + controller: _bannerController, + itemCount: _promos.length, + onPageChanged: (index) => setState(() => _bannerIndex = index), + itemBuilder: (context, index) { + final promo = _promos[index]; + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 6), + child: ShopPromoBanner( + promo: promo, + onTap: () => _openCategory(category: promo.category), + ), + ); + }, + ), + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: List.generate(_promos.length, (index) { + final isActive = index == _bannerIndex; + return AnimatedContainer( + duration: const Duration(milliseconds: 200), + margin: const EdgeInsets.symmetric(horizontal: 3), + width: isActive ? 18 : 6, + height: 6, + decoration: BoxDecoration( + color: isActive ? AppColor.primary : AppColor.border, + borderRadius: BorderRadius.circular(3), + ), + ); + }), + ), + ], + ); + } + + Widget _buildProductRow(List products) { + return SizedBox( + height: _rowCardWidth + shopCardInfoHeight(context), + child: ListView.separated( + scrollDirection: Axis.horizontal, + padding: const EdgeInsets.symmetric(horizontal: 16), + itemCount: products.length, + separatorBuilder: (_, _) => const SizedBox(width: 12), + itemBuilder: (context, index) { + final product = products[index]; + return SizedBox( + width: _rowCardWidth, + child: ShopProductCard( + product: product, + onTap: () => _openProduct(product), + ), + ); + }, + ), + ); + } + + Widget _buildGrid(List products) { + return SliverPadding( + padding: const EdgeInsets.symmetric(horizontal: 16), + sliver: SliverGrid.builder( + gridDelegate: shopProductGridDelegate(context), + itemCount: products.length, + itemBuilder: (context, index) { + final product = products[index]; + return ShopProductCard( + product: product, + onTap: () => _openProduct(product), + ); + }, + ), + ); + } +} + +class _SectionTitle extends StatelessWidget { + const _SectionTitle({required this.title, this.onSeeAll}); + + final String title; + final VoidCallback? onSeeAll; + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.fromLTRB(16, 20, onSeeAll == null ? 16 : 4, 10), + child: Row( + children: [ + Expanded( + child: Text( + title, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + if (onSeeAll != null) + TextButton( + onPressed: onSeeAll, + child: Text( + 'Lihat semua', + style: AppStyle.sm.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/shop/shop_ui.dart b/lib/presentation/pages/shop/shop_ui.dart new file mode 100644 index 0000000..28d0503 --- /dev/null +++ b/lib/presentation/pages/shop/shop_ui.dart @@ -0,0 +1,139 @@ +import 'package:flutter/material.dart'; + +import '../../../common/extension/extension.dart'; +import '../../../common/theme/theme.dart'; +import '../../../sample/shop_sample_data.dart'; + +/// "320 terjual" / "1,2rb terjual". +String formatSoldCount(int count) { + if (count < 1000) return '$count terjual'; + final thousands = (count / 100).floor() / 10; + final text = thousands == thousands.roundToDouble() + ? thousands.toInt().toString() + : thousands.toString().replaceAll('.', ','); + return '${text}rb terjual'; +} + +/// Grid 2 kolom produk; tinggi kartu = lebar gambar + bagian teks. +SliverGridDelegate shopProductGridDelegate(BuildContext context) { + final itemWidth = (MediaQuery.sizeOf(context).width - 32 - 12) / 2; + return SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 2, + mainAxisSpacing: 12, + crossAxisSpacing: 12, + mainAxisExtent: itemWidth + shopCardInfoHeight(context), + ); +} + +/// Tinggi bagian teks kartu produk, ikut skala font sistem supaya tidak +/// terpotong. +double shopCardInfoHeight(BuildContext context) => + MediaQuery.textScalerOf(context).scale(118); + +/// Gambar produk: emoji di atas latar warna produk. +class ShopProductImage extends StatelessWidget { + const ShopProductImage({ + super.key, + required this.product, + this.emojiSize = 56, + }); + + final ShopProduct product; + final double emojiSize; + + @override + Widget build(BuildContext context) { + return ColoredBox( + color: Color(product.tint), + child: Center( + child: Text(product.emoji, style: TextStyle(fontSize: emojiSize)), + ), + ); + } +} + +/// Label pojok kartu seperti "Terlaris" atau "Baru". +class ShopTagBadge extends StatelessWidget { + const ShopTagBadge({super.key, required this.tag}); + + final ShopTag tag; + + @override + Widget build(BuildContext context) { + return Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3), + decoration: BoxDecoration( + color: switch (tag) { + ShopTag.bestSeller => AppColor.primary, + ShopTag.newArrival => AppColor.info, + }, + borderRadius: BorderRadius.circular(6), + ), + child: Text( + tag.label, + style: AppStyle.xs.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w800, + ), + ), + ); + } +} + +/// Harga akhir, dengan harga coret dan persen potongan bila diskon. +class ShopPrice extends StatelessWidget { + const ShopPrice({super.key, required this.product, this.large = false}); + + final ShopProduct product; + final bool large; + + @override + Widget build(BuildContext context) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + product.finalPrice.currencyFormatRp, + style: (large ? AppStyle.h5 : AppStyle.md).copyWith( + fontWeight: FontWeight.w800, + ), + ), + if (product.isDiscounted) ...[ + SizedBox(height: large ? 4 : 2), + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1), + decoration: BoxDecoration( + color: AppColor.primary.withOpacity(0.1), + borderRadius: BorderRadius.circular(4), + ), + child: Text( + '${product.discountPercent}%', + style: (large ? AppStyle.sm : AppStyle.xs).copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w800, + ), + ), + ), + const SizedBox(width: 6), + Flexible( + child: Text( + product.price.currencyFormatRp, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: (large ? AppStyle.sm : AppStyle.xs).copyWith( + color: AppColor.textSecondary, + decoration: TextDecoration.lineThrough, + ), + ), + ), + ], + ), + ], + ], + ); + } +} diff --git a/lib/presentation/pages/shop/widgets/shop_category_grid.dart b/lib/presentation/pages/shop/widgets/shop_category_grid.dart new file mode 100644 index 0000000..7db7e0a --- /dev/null +++ b/lib/presentation/pages/shop/widgets/shop_category_grid.dart @@ -0,0 +1,66 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/shop_sample_data.dart'; + +/// Grid kategori toko, 4 kolom, diakhiri tile "Semua" (`null`). +class ShopCategoryGrid extends StatelessWidget { + const ShopCategoryGrid({super.key, required this.onTap}); + + final ValueChanged onTap; + + @override + Widget build(BuildContext context) { + return GridView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + padding: const EdgeInsets.symmetric(horizontal: 12), + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisCount: 4, + mainAxisSpacing: 8, + crossAxisSpacing: 4, + mainAxisExtent: MediaQuery.textScalerOf(context).scale(92), + ), + itemCount: ShopCategory.values.length + 1, + itemBuilder: (context, index) { + final category = index < ShopCategory.values.length + ? ShopCategory.values[index] + : null; + return InkWell( + borderRadius: BorderRadius.circular(AppValue.borderRadius), + onTap: () => onTap(category), + child: Column( + children: [ + const SizedBox(height: 4), + Container( + width: 52, + height: 52, + alignment: Alignment.center, + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + border: Border.all(color: AppColor.borderLight), + ), + child: Text( + category?.emoji ?? '🏪', + style: const TextStyle(fontSize: 26), + ), + ), + const SizedBox(height: 6), + Text( + category?.label ?? 'Semua', + maxLines: 2, + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + style: AppStyle.xs.copyWith( + fontWeight: FontWeight.w600, + height: 1.2, + ), + ), + ], + ), + ); + }, + ); + } +} diff --git a/lib/presentation/pages/shop/widgets/shop_product_card.dart b/lib/presentation/pages/shop/widgets/shop_product_card.dart new file mode 100644 index 0000000..1478997 --- /dev/null +++ b/lib/presentation/pages/shop/widgets/shop_product_card.dart @@ -0,0 +1,79 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/shop_sample_data.dart'; +import '../shop_ui.dart'; + +/// Kartu produk untuk grid dan daftar geser. Tinggi bagian teks mengikuti +/// [shopCardInfoHeight]. +class ShopProductCard extends StatelessWidget { + const ShopProductCard({ + super.key, + required this.product, + required this.onTap, + }); + + final ShopProduct product; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Material( + color: AppColor.white, + borderRadius: BorderRadius.circular(16), + clipBehavior: Clip.antiAlias, + child: InkWell( + onTap: onTap, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AspectRatio( + aspectRatio: 1, + child: Stack( + fit: StackFit.expand, + children: [ + ShopProductImage(product: product), + if (product.tag != null) + Positioned( + top: 10, + left: 10, + child: ShopTagBadge(tag: product.tag!), + ), + ], + ), + ), + SizedBox( + height: shopCardInfoHeight(context), + child: Padding( + padding: const EdgeInsets.fromLTRB(10, 8, 10, 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + product.name, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith( + fontWeight: FontWeight.w600, + height: 1.3, + ), + ), + const Spacer(), + ShopPrice(product: product), + const SizedBox(height: 4), + Text( + formatSoldCount(product.soldCount), + style: AppStyle.xs.copyWith( + color: AppColor.textSecondary, + ), + ), + ], + ), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/shop/widgets/shop_promo_banner.dart b/lib/presentation/pages/shop/widgets/shop_promo_banner.dart new file mode 100644 index 0000000..54157a6 --- /dev/null +++ b/lib/presentation/pages/shop/widgets/shop_promo_banner.dart @@ -0,0 +1,107 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../sample/shop_sample_data.dart'; + +/// Banner promo toko; mengarah ke kategori promo. +class ShopPromoBanner extends StatelessWidget { + const ShopPromoBanner({super.key, required this.promo, required this.onTap}); + + final ShopPromo promo; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + final colors = promo.gradient.map(Color.new).toList(); + + return DecoratedBox( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(18), + gradient: LinearGradient( + colors: colors, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + ), + child: Material( + type: MaterialType.transparency, + child: InkWell( + borderRadius: BorderRadius.circular(18), + onTap: onTap, + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + child: Stack( + children: [ + Positioned( + right: -20, + bottom: -24, + child: Container( + width: 130, + height: 130, + decoration: BoxDecoration( + color: AppColor.white.withOpacity(0.12), + shape: BoxShape.circle, + ), + ), + ), + Positioned( + right: 18, + bottom: 14, + child: Text( + promo.category.emoji, + style: const TextStyle(fontSize: 64), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(18, 16, 110, 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + promo.title, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.xl.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w800, + height: 1.2, + ), + ), + const SizedBox(height: 4), + Text( + promo.subtitle, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: AppStyle.sm.copyWith( + color: AppColor.textWhite.withOpacity(0.9), + ), + ), + const Spacer(), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 5, + ), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(20), + ), + child: Text( + 'Lihat produk', + style: AppStyle.xs.copyWith( + color: colors.last, + fontWeight: FontWeight.w800, + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/exchange_page.dart b/lib/presentation/pages/wallet/exchange_page.dart new file mode 100644 index 0000000..504839e --- /dev/null +++ b/lib/presentation/pages/wallet/exchange_page.dart @@ -0,0 +1,647 @@ +import 'dart:async'; + +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../application/wallet/exchange_form/exchange_form_bloc.dart'; +import '../../../application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart'; +import '../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; +import '../../../common/extension/extension.dart'; +import '../../../common/function/app_function.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/button/button.dart'; +import '../../components/toast/flushbar.dart'; +import '../pin/pin_guard.dart'; +import '../pin/widgets/pin_sheet.dart'; +import 'wallet_ui.dart'; +import 'widgets/wallet_confirm_dialog.dart'; +import 'widgets/wallet_history_section.dart'; +import 'widgets/wallet_result_view.dart'; + +/// Tukar EnakCoin → EnakPoint (§8.1). +@RoutePage() +class ExchangePage extends StatefulWidget implements AutoRouteWrapper { + const ExchangePage({super.key}); + + @override + State createState() => _ExchangePageState(); + + @override + Widget wrappedRoute(BuildContext context) => MultiBlocProvider( + providers: [ + BlocProvider(create: (_) => getIt()), + // Riwayat dilihat dari sisi EnakPoint: berapa poin yang didapat. + BlocProvider( + create: (_) => getIt() + ..add( + const WalletHistoryLoaderEvent.filterChanged( + types: [WalletTransactionType.exchangeIn], + ), + ), + ), + ], + child: this, + ); +} + +class _ExchangePageState extends State { + final TextEditingController _coinsController = TextEditingController(); + final ScrollController _scrollController = ScrollController(); + Timer? _debounce; + + /// Kurs terakhir yang diketahui, tetap ditampilkan selama preview baru + /// sedang dihitung. + ExchangePreview? _rate; + + @override + void initState() { + super.initState(); + context.read().add(const WalletLoaderEvent.fetched()); + _scrollController.addListener(_onScroll); + } + + @override + void dispose() { + _debounce?.cancel(); + _coinsController.dispose(); + _scrollController.dispose(); + super.dispose(); + } + + void _onScroll() { + final position = _scrollController.position; + if (position.pixels >= position.maxScrollExtent - 200) { + context.read().add( + const WalletHistoryLoaderEvent.loadedMore(), + ); + } + } + + Future _onRefresh() async { + context.read().add(const WalletLoaderEvent.fetched()); + final history = context.read(); + history.add(const WalletHistoryLoaderEvent.refreshed()); + await history.stream.firstWhere((s) => !s.isFetching); + } + + void _onCoinsChanged(String value) { + _debounce?.cancel(); + _debounce = Timer(const Duration(milliseconds: 500), () { + if (!mounted) return; + context.read().add( + ExchangeFormEvent.coinsChanged(int.tryParse(digitsOnly(value)) ?? 0), + ); + }); + } + + /// Isi jumlah langsung tanpa debounce, mis. dari tombol "Tukar semua". + void _fillCoins(int coins) { + _debounce?.cancel(); + final text = coins.thousandFormat; + _coinsController.value = TextEditingValue( + text: text, + selection: TextSelection.collapsed(offset: text.length), + ); + context.read().add(ExchangeFormEvent.coinsChanged(coins)); + } + + /// Bulatkan ke bawah ke kelipatan kurs bila kursnya sudah diketahui. + int _roundToRate(int coins) { + final step = _rate?.coinAmount ?? 0; + return step > 0 ? coins - coins % step : coins; + } + + Future _confirm(ExchangeFormState state) async { + dismissKeyboard(context); + final preview = state.preview!; + final confirmed = await showWalletConfirmDialog( + context, + title: 'Tukar EnakCoin?', + message: + 'Tukar ${preview.coins.thousandFormat} EnakCoin menjadi ' + '${preview.points.thousandFormat} EnakPoint. Penukaran tidak bisa ' + 'dibatalkan.', + confirmLabel: 'Tukar', + ); + if (!confirmed || !mounted) return; + if (!await ensurePinReady(context) || !mounted) return; + + final success = await showPinSheet( + context, + title: 'Tukar EnakCoin', + onSubmit: (pin) async { + final bloc = context.read(); + bloc.add(ExchangeFormEvent.submitted(pin)); + final result = await bloc.stream.firstWhere((s) => !s.isSubmitting); + return result.failureOption.toNullable(); + }, + onFailure: _showFailure, + ); + + if (success && mounted) { + context.read().add(const WalletLoaderEvent.fetched()); + } + } + + void _showFailure(WalletFailure failure) { + if (failure.isPinError) return; + + if (failure.isNetworkError) { + AppFlushbar.showError( + context, + 'Koneksi terputus, status penukaran belum diketahui. Tekan Tukar lagi ' + 'untuk mengulang. Saldo tidak akan terpotong dua kali.', + ); + return; + } + + AppFlushbar.showError( + context, + walletFailureMessage( + failure, + rejectedMessage: + 'Penukaran tidak bisa diproses. Periksa jumlah dan saldo ' + 'EnakCoin kamu.', + ), + ); + } + + @override + Widget build(BuildContext context) { + return MultiBlocListener( + listeners: [ + BlocListener( + listenWhen: (p, c) => p.preview != c.preview && c.preview != null, + listener: (context, state) => setState(() => _rate = state.preview), + ), + ], + child: BlocBuilder( + builder: (context, state) { + final result = state.result; + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Tukar EnakCoin')), + body: AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: result != null + ? KeyedSubtree( + key: const ValueKey('success'), + child: _buildSuccess(result), + ) + : KeyedSubtree( + key: const ValueKey('form'), + child: _buildForm(state), + ), + ), + ); + }, + ), + ); + } + + Widget _buildForm(ExchangeFormState state) { + return RefreshIndicator( + color: AppColor.primary, + onRefresh: _onRefresh, + child: CustomScrollView( + controller: _scrollController, + physics: const AlwaysScrollableScrollPhysics(), + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + slivers: [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 28), + sliver: SliverToBoxAdapter( + child: BlocBuilder( + buildWhen: (p, c) => + p.summary != c.summary || p.hasLoaded != c.hasLoaded, + builder: (context, walletState) => + _buildFormContent(state, walletState), + ), + ), + ), + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 32), + sliver: WalletHistorySection( + title: 'Riwayat penukaran', + emptyIcon: Icons.currency_exchange_rounded, + emptyTitle: 'Belum ada penukaran', + emptySubtitle: (_) => + 'EnakPoint yang kamu dapat dari tukar EnakCoin akan ' + 'muncul di sini.', + ), + ), + ], + ), + ); + } + + Widget _buildFormContent( + ExchangeFormState state, + WalletLoaderState walletState, + ) { + final summary = walletState.summary; + final coinBalance = summary.coinBalance; + final exceedsBalance = walletState.hasLoaded && state.coins > coinBalance; + final preview = state.preview; + final points = preview != null && preview.valid && !exceedsBalance + ? preview.points + : 0; + final maxCoins = _roundToRate(coinBalance); + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _ExchangeCard( + label: 'Kamu tukar', + currency: WalletCurrency.coin, + trailing: Text( + walletState.hasLoaded + ? 'Saldo ${coinBalance.thousandFormat}' + : 'Memuat saldo…', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: _coinsController, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + enabled: !state.isSubmitting, + cursorColor: AppColor.primary, + inputFormatters: [ThousandsInputFormatter()], + onChanged: _onCoinsChanged, + style: AppStyle.h4.copyWith(fontWeight: FontWeight.w700), + decoration: InputDecoration( + hintText: '0', + hintStyle: AppStyle.h4.copyWith( + color: AppColor.textLight, + fontWeight: FontWeight.w700, + ), + border: InputBorder.none, + enabledBorder: InputBorder.none, + focusedBorder: InputBorder.none, + disabledBorder: InputBorder.none, + isDense: true, + contentPadding: const EdgeInsets.symmetric(vertical: 8), + ), + ), + Align( + alignment: Alignment.centerLeft, + child: _QuickChip( + label: 'Tukar semua', + onTap: + walletState.hasLoaded && + maxCoins > 0 && + !state.isSubmitting + ? () => _fillCoins(maxCoins) + : null, + ), + ), + ], + ), + ), + const SizedBox(height: 8), + Stack( + clipBehavior: Clip.none, + children: [ + _ExchangeCard( + label: 'Kamu dapat', + currency: WalletCurrency.point, + highlighted: points > 0, + trailing: Text( + walletState.hasLoaded + ? 'Saldo ${summary.pointBalance.thousandFormat}' + : '', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: AnimatedOpacity( + duration: const Duration(milliseconds: 200), + opacity: state.isPreviewing ? 0.35 : 1, + child: TweenAnimationBuilder( + tween: IntTween(begin: 0, end: points), + duration: const Duration(milliseconds: 450), + curve: Curves.easeOutCubic, + builder: (context, value, _) => Text( + value.thousandFormat, + style: AppStyle.h4.copyWith( + fontWeight: FontWeight.w700, + color: points > 0 + ? AppColor.success + : AppColor.textLight, + ), + ), + ), + ), + ), + ), + const Positioned( + top: -24, + left: 0, + right: 0, + child: Center(child: _SwapBadge()), + ), + ], + ), + const SizedBox(height: 12), + AnimatedSize( + duration: const Duration(milliseconds: 200), + curve: Curves.easeOut, + alignment: Alignment.topCenter, + child: AnimatedSwitcher( + duration: const Duration(milliseconds: 200), + child: _buildStatus(state, exceedsBalance), + ), + ), + const SizedBox(height: 20), + AppElevatedButton( + title: 'Tukar', + height: 48, + isLoading: state.isSubmitting, + onPressed: state.canSubmit && !exceedsBalance + ? () => _confirm(state) + : null, + ), + ], + ); + } + + /// Satu baris keterangan di bawah kartu: kurs, proses hitung, atau error. + Widget _buildStatus(ExchangeFormState state, bool exceedsBalance) { + if (state.isPreviewing) { + return const _StatusLine( + key: ValueKey('previewing'), + icon: SpinKitThreeBounce(color: AppColor.primary, size: 14), + text: 'Menghitung…', + ); + } + + if (exceedsBalance) { + return const _StatusLine( + key: ValueKey('exceeds'), + icon: Icon( + Icons.error_outline_rounded, + size: 16, + color: AppColor.error, + ), + text: 'Melebihi saldo EnakCoin kamu', + color: AppColor.error, + ); + } + + final previewFailure = state.previewFailureOption.toNullable(); + if (previewFailure != null) { + return _StatusLine( + key: const ValueKey('failure'), + icon: const Icon( + Icons.error_outline_rounded, + size: 16, + color: AppColor.error, + ), + text: walletFailureMessage( + previewFailure, + rejectedMessage: 'Jumlah EnakCoin tidak valid.', + ), + color: AppColor.error, + ); + } + + final preview = state.preview; + if (preview != null && !preview.valid) { + final rounded = _roundToRate(state.coins); + return _StatusLine( + key: const ValueKey('invalid'), + icon: const Icon( + Icons.error_outline_rounded, + size: 16, + color: AppColor.error, + ), + text: + preview.reason ?? + 'Jumlah harus kelipatan ${preview.coinAmount.thousandFormat} ' + 'EnakCoin.', + color: AppColor.error, + action: rounded > 0 && rounded != state.coins + ? _QuickChip( + label: 'Pakai ${rounded.thousandFormat}', + onTap: () => _fillCoins(rounded), + ) + : null, + ); + } + + final rate = _rate; + if (rate == null) { + return const _StatusLine( + key: ValueKey('hint'), + icon: Icon( + Icons.info_outline_rounded, + size: 16, + color: AppColor.textSecondary, + ), + text: 'Masukkan jumlah EnakCoin untuk melihat kurs penukaran.', + ); + } + + return _StatusLine( + key: const ValueKey('rate'), + icon: const Icon( + Icons.currency_exchange_rounded, + size: 16, + color: AppColor.textSecondary, + ), + text: + 'Kurs ${rate.coinAmount.thousandFormat} EnakCoin = ' + '${rate.pointAmount.thousandFormat} EnakPoint · penukaran tidak ' + 'bisa dibatalkan', + ); + } + + Widget _buildSuccess(ExchangeResult result) { + return WalletResultView( + title: 'Penukaran berhasil', + amountText: '+${result.points.thousandFormat} EnakPoint', + lines: [ + 'Ditukar dari ${result.coins.thousandFormat} EnakCoin', + 'Saldo sekarang: ${result.pointBalance.thousandFormat} EnakPoint · ' + '${result.coinBalance.thousandFormat} EnakCoin', + ...result.lots + .where((lot) => lot.expiresAt != null) + .map( + (lot) => + '${lot.amount.thousandFormat} EnakPoint ini berlaku sampai ' + '${formatWibDate(lot.expiresAt!)}', + ), + ], + onDone: () => context.router.maybePop(), + ); + } +} + +/// Kartu satu sisi penukaran (asal atau tujuan). +class _ExchangeCard extends StatelessWidget { + const _ExchangeCard({ + required this.label, + required this.currency, + required this.trailing, + required this.child, + this.highlighted = false, + }); + + final String label; + final WalletCurrency currency; + final Widget trailing; + final Widget child; + final bool highlighted; + + @override + Widget build(BuildContext context) { + return AnimatedContainer( + duration: const Duration(milliseconds: 250), + padding: const EdgeInsets.fromLTRB(16, 14, 16, 14), + decoration: BoxDecoration( + color: highlighted ? AppColor.successWithOpacity(0.06) : AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + border: Border.all( + color: highlighted + ? AppColor.successWithOpacity(0.4) + : AppColor.white, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Text( + label, + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + ), + ), + const Spacer(), + trailing, + ], + ), + const SizedBox(height: 4), + Row( + children: [ + Expanded(child: child), + const SizedBox(width: 12), + Container( + padding: const EdgeInsets.fromLTRB(6, 6, 12, 6), + decoration: BoxDecoration( + color: AppColor.background, + borderRadius: BorderRadius.circular(20), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + WalletCurrencyIcon(currency: currency, size: 24), + const SizedBox(width: 6), + Text( + currency.label, + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w700), + ), + ], + ), + ), + ], + ), + ], + ), + ); + } +} + +/// Lingkaran panah di antara dua kartu. +class _SwapBadge extends StatelessWidget { + const _SwapBadge(); + + @override + Widget build(BuildContext context) { + return Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: AppColor.primary, + shape: BoxShape.circle, + border: Border.all(color: AppColor.background, width: 4), + ), + child: const Icon( + Icons.arrow_downward_rounded, + size: 18, + color: AppColor.white, + ), + ); + } +} + +class _QuickChip extends StatelessWidget { + const _QuickChip({required this.label, required this.onTap}); + + final String label; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + final enabled = onTap != null; + return Material( + color: enabled ? AppColor.primaryWithOpacity(0.08) : AppColor.background, + borderRadius: BorderRadius.circular(20), + child: InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(20), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), + child: Text( + label, + style: AppStyle.xs.copyWith( + color: enabled ? AppColor.primary : AppColor.textLight, + fontWeight: FontWeight.w700, + ), + ), + ), + ), + ); + } +} + +class _StatusLine extends StatelessWidget { + const _StatusLine({ + super.key, + required this.icon, + required this.text, + this.color = AppColor.textSecondary, + this.action, + }); + + final Widget icon; + final String text; + final Color color; + final Widget? action; + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: Row( + children: [ + SizedBox(width: 20, child: Center(child: icon)), + const SizedBox(width: 6), + Expanded( + child: Text(text, style: AppStyle.xs.copyWith(color: color)), + ), + if (action != null) ...[const SizedBox(width: 8), action!], + ], + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/payment_code_page.dart b/lib/presentation/pages/wallet/payment_code_page.dart new file mode 100644 index 0000000..63ae7c8 --- /dev/null +++ b/lib/presentation/pages/wallet/payment_code_page.dart @@ -0,0 +1,226 @@ +import 'dart:async'; + +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:qr_flutter/qr_flutter.dart'; + +import '../../../application/wallet/payment_code_form/payment_code_form_bloc.dart'; +import '../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; +import '../../../common/extension/extension.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/button/button.dart'; +import '../../components/toast/flushbar.dart'; +import '../pin/pin_guard.dart'; +import '../pin/widgets/pin_sheet.dart'; +import 'wallet_ui.dart'; + +/// Bayar di kasir dengan kode bayar (§7.1). +@RoutePage() +class PaymentCodePage extends StatefulWidget implements AutoRouteWrapper { + const PaymentCodePage({super.key}); + + @override + State createState() => _PaymentCodePageState(); + + @override + Widget wrappedRoute(BuildContext context) => + BlocProvider(create: (_) => getIt(), child: this); +} + +class _PaymentCodePageState extends State { + Timer? _ticker; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) => _generate()); + _ticker = Timer.periodic(const Duration(seconds: 1), (_) => _tick()); + } + + @override + void dispose() { + _ticker?.cancel(); + super.dispose(); + } + + void _tick() { + if (!mounted) return; + final code = context.read().state.paymentCode; + if (code == null) return; + + if (!DateTime.now().isBefore(code.expiresAt)) { + context.read().add( + const PaymentCodeFormEvent.expired(), + ); + } else { + setState(() {}); + } + } + + Future _generate() async { + if (!await ensurePinReady(context) || !mounted) return; + + await showPinSheet( + context, + title: 'Bayar di kasir', + subtitle: 'Masukkan PIN untuk menampilkan kode bayar', + onSubmit: (pin) async { + final bloc = context.read(); + bloc.add(PaymentCodeFormEvent.submitted(pin)); + final state = await bloc.stream.firstWhere((s) => !s.isSubmitting); + return state.failureOption.toNullable(); + }, + onFailure: (f) => AppFlushbar.showError(context, walletFailureMessage(f)), + ); + } + + @override + Widget build(BuildContext context) { + return BlocBuilder( + builder: (context, state) { + final code = state.paymentCode; + + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Bayar di Kasir')), + body: ListView( + padding: const EdgeInsets.all(16), + children: [ + _buildBalance(), + const SizedBox(height: 16), + code == null ? _buildEmpty(state.isSubmitting) : _buildCode(code), + const SizedBox(height: 16), + Text( + 'Tunjukkan kode ini ke kasir. Kasir yang memilih jumlah ' + 'EnakPoint yang dipakai. Kode hanya bisa dipakai sekali, dan ' + 'membuat kode baru membatalkan kode sebelumnya.', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + textAlign: TextAlign.center, + ), + ], + ), + ); + }, + ); + } + + Widget _buildBalance() { + return BlocBuilder( + builder: (context, state) { + final summary = state.summary; + return Container( + padding: const EdgeInsets.all(16), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Row( + children: [ + const WalletCurrencyIcon( + currency: WalletCurrency.point, + size: 28, + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '${summary.pointBalance.thousandFormat} EnakPoint', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + Text( + pointDiscountLabel(summary.pointDiscountValue), + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + ), + ), + ], + ), + ), + ], + ), + ); + }, + ); + } + + Widget _buildEmpty(bool isSubmitting) { + return Container( + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Column( + children: [ + const Icon(Icons.qr_code_2, size: 72, color: AppColor.textLight), + const SizedBox(height: 12), + Text( + 'Kode bayar belum dibuat atau sudah kedaluwarsa', + textAlign: TextAlign.center, + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 16), + AppElevatedButton( + title: 'Buat kode baru', + isLoading: isSubmitting, + onPressed: isSubmitting ? null : _generate, + ), + ], + ), + ); + } + + Widget _buildCode(PaymentCode code) { + final remaining = code.expiresAt.difference(DateTime.now()); + final spacedCode = code.code.split('').join(' '); + + return Container( + padding: const EdgeInsets.all(24), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Column( + children: [ + Text( + spacedCode, + style: AppStyle.h1.copyWith( + fontWeight: FontWeight.w700, + letterSpacing: 2, + ), + ), + const SizedBox(height: 16), + QrImageView( + data: code.qrPayload, + size: 220, + backgroundColor: AppColor.white, + ), + const SizedBox(height: 16), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon( + Icons.timer_outlined, + size: 18, + color: AppColor.warning, + ), + const SizedBox(width: 6), + Text( + 'Berlaku ${formatCountdown(remaining)}', + style: AppStyle.md.copyWith( + color: AppColor.warning, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/transfer_page.dart b/lib/presentation/pages/wallet/transfer_page.dart new file mode 100644 index 0000000..f96482b --- /dev/null +++ b/lib/presentation/pages/wallet/transfer_page.dart @@ -0,0 +1,564 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; + +import '../../../application/wallet/transfer_form/transfer_form_bloc.dart'; +import '../../../application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart'; +import '../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; +import '../../../common/extension/extension.dart'; +import '../../../common/function/app_function.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/button/button.dart'; +import '../../components/toast/flushbar.dart'; +import '../pin/pin_guard.dart'; +import '../pin/widgets/pin_sheet.dart'; +import 'wallet_ui.dart'; +import 'widgets/wallet_history_section.dart'; +import 'widgets/wallet_confirm_dialog.dart'; +import 'widgets/wallet_result_view.dart'; + +/// Transfer EnakPoint / EnakCoin ke customer lain (§8.2). +@RoutePage() +class TransferPage extends StatefulWidget implements AutoRouteWrapper { + const TransferPage({super.key}); + + @override + State createState() => _TransferPageState(); + + @override + Widget wrappedRoute(BuildContext context) => MultiBlocProvider( + providers: [ + BlocProvider(create: (_) => getIt()), + BlocProvider( + create: (_) => getIt() + ..add( + const WalletHistoryLoaderEvent.filterChanged( + types: [ + WalletTransactionType.transferOut, + WalletTransactionType.transferIn, + ], + ), + ), + ), + ], + child: this, + ); +} + +class _TransferPageState extends State { + final TextEditingController _phoneController = TextEditingController(); + final TextEditingController _amountController = TextEditingController(); + final ScrollController _scrollController = ScrollController(); + + @override + void initState() { + super.initState(); + // Halaman ini juga dibuka dari beranda, saldo belum tentu sudah dimuat. + context.read().add(const WalletLoaderEvent.fetched()); + _scrollController.addListener(_onScroll); + } + + @override + void dispose() { + _phoneController.dispose(); + _amountController.dispose(); + _scrollController.dispose(); + super.dispose(); + } + + void _onScroll() { + final position = _scrollController.position; + if (position.pixels >= position.maxScrollExtent - 200) { + context.read().add( + const WalletHistoryLoaderEvent.loadedMore(), + ); + } + } + + Future _onRefresh() async { + context.read().add(const WalletLoaderEvent.fetched()); + final history = context.read(); + history.add(const WalletHistoryLoaderEvent.refreshed()); + await history.stream.firstWhere((s) => !s.isFetching); + } + + void _onCurrencyChanged(WalletCurrency currency) { + if (context.read().state.currency == currency) return; + HapticFeedback.selectionClick(); + context.read().add( + TransferFormEvent.currencyChanged(currency), + ); + context.read().add( + WalletHistoryLoaderEvent.currencyChanged(currency), + ); + } + + void _fillAmount(int amount) { + final text = amount.thousandFormat; + _amountController.value = TextEditingValue( + text: text, + selection: TextSelection.collapsed(offset: text.length), + ); + context.read().add( + TransferFormEvent.amountChanged(amount), + ); + } + + Future _onRecipientFound(TransferFormState state) async { + final recipient = state.recipient!; + final confirmed = await showWalletConfirmDialog( + context, + title: 'Kirim ke ${recipient.name} (${recipient.phoneNumber})?', + message: + 'Kamu akan mengirim ${state.amount.thousandFormat} ' + '${state.currency.label}. Transfer bersifat final dan tidak bisa ' + 'dibatalkan.', + confirmLabel: 'Kirim', + ); + if (!confirmed || !mounted) return; + if (!await ensurePinReady(context) || !mounted) return; + + final success = await showPinSheet( + context, + title: 'Transfer ${state.currency.label}', + onSubmit: (pin) async { + final bloc = context.read(); + bloc.add(TransferFormEvent.submitted(pin)); + final result = await bloc.stream.firstWhere((s) => !s.isSubmitting); + return result.failureOption.toNullable(); + }, + onFailure: _showFailure, + ); + + if (success && mounted) { + context.read().add(const WalletLoaderEvent.fetched()); + } + } + + void _showFailure(WalletFailure failure) { + if (failure.isPinError) return; + + if (failure.isNetworkError) { + AppFlushbar.showError( + context, + 'Koneksi terputus, status transfer belum diketahui. Tekan Lanjut lagi ' + 'untuk mengulang. Saldo tidak akan terpotong dua kali.', + ); + return; + } + + final reason = failure.maybeMap( + rejected: (value) => _transferRejectReason(value.cause), + orElse: () => null, + ); + + AppFlushbar.showError( + context, + walletFailureMessage( + failure, + rejectedMessage: reason == null + ? 'Transfer tidak bisa diproses.' + : 'Transfer tidak bisa diproses. $reason', + ), + ); + } + + /// Mengenali alasan penolakan `304` dari `cause` (bahasa Inggris) tanpa + /// menampilkannya mentah. + String? _transferRejectReason(String cause) { + final text = cause.toLowerCase(); + if (text.contains('daily')) return 'Melewati batas transfer harian.'; + if (text.contains('not enough') || text.contains('insufficient')) { + return 'Saldo tidak cukup.'; + } + if (text.contains('minimum') || text.contains('below')) { + return 'Jumlah di bawah minimal transfer.'; + } + if (text.contains('maximum') || + text.contains('exceed') || + text.contains('above')) { + return 'Jumlah melebihi maksimal per transaksi.'; + } + if (text.contains('disabled') || text.contains('not enabled')) { + return 'Fitur transfer sedang tidak tersedia.'; + } + return null; + } + + String? _recipientError(TransferFormState state) { + final failure = state.recipientFailureOption.toNullable(); + if (failure == null) return null; + return failure.maybeMap( + notFound: (_) => 'Nomor ini tidak terdaftar', + rejected: (_) => 'Tidak bisa mengirim ke nomor ini', + orElse: () => walletFailureMessage(failure), + ); + } + + @override + Widget build(BuildContext context) { + return MultiBlocListener( + listeners: [ + BlocListener( + listenWhen: (p, c) => + p.recipient != c.recipient && c.recipient != null, + listener: (context, state) => _onRecipientFound(state), + ), + ], + child: BlocBuilder( + builder: (context, state) { + final result = state.result; + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Transfer')), + body: AnimatedSwitcher( + duration: const Duration(milliseconds: 300), + child: result != null + ? KeyedSubtree( + key: const ValueKey('success'), + child: _buildSuccess(result), + ) + : KeyedSubtree( + key: const ValueKey('form'), + child: _buildForm(state), + ), + ), + ); + }, + ), + ); + } + + Widget _buildForm(TransferFormState state) { + return RefreshIndicator( + color: AppColor.primary, + onRefresh: _onRefresh, + child: CustomScrollView( + controller: _scrollController, + physics: const AlwaysScrollableScrollPhysics(), + keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag, + slivers: [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 28), + sliver: SliverToBoxAdapter( + child: BlocBuilder( + buildWhen: (p, c) => + p.summary != c.summary || p.hasLoaded != c.hasLoaded, + builder: (context, walletState) => + _buildFormContent(state, walletState), + ), + ), + ), + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 32), + sliver: WalletHistorySection( + title: 'Riwayat transfer', + emptyIcon: Icons.swap_horiz_rounded, + emptyTitle: 'Belum ada transfer', + emptySubtitle: (currency) => + 'Transfer ${currency.label} yang kamu kirim atau terima ' + 'akan muncul di sini.', + ), + ), + ], + ), + ); + } + + Widget _buildFormContent( + TransferFormState state, + WalletLoaderState walletState, + ) { + final summary = walletState.summary; + final balance = _balanceOf(summary, state.currency); + final exceedsBalance = walletState.hasLoaded && state.amount > balance; + final isBusy = state.isCheckingRecipient || state.isSubmitting; + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + _buildSectionLabel('Kirim dari'), + Row( + children: [ + for (final currency in WalletCurrency.values) ...[ + if (currency != WalletCurrency.values.first) + const SizedBox(width: 12), + Expanded( + child: _CurrencyOption( + currency: currency, + balance: _balanceOf(summary, currency), + isLoaded: walletState.hasLoaded, + selected: state.currency == currency, + onTap: isBusy ? null : () => _onCurrencyChanged(currency), + ), + ), + ], + ], + ), + const SizedBox(height: 20), + Container( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 12), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildSectionLabel('Nomor HP penerima', inCard: true), + TextField( + controller: _phoneController, + keyboardType: TextInputType.phone, + textInputAction: TextInputAction.next, + enabled: !isBusy, + cursorColor: AppColor.primary, + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly, + LengthLimitingTextInputFormatter(15), + ], + style: AppStyle.lg.copyWith( + fontWeight: FontWeight.w600, + letterSpacing: 0.5, + ), + onChanged: (value) => context.read().add( + TransferFormEvent.phoneChanged(value), + ), + decoration: InputDecoration( + hintText: '08xxxxxxxxxx', + errorText: _recipientError(state), + prefixIcon: const Padding( + padding: EdgeInsets.only(right: 10), + child: Icon( + Icons.person_outline_rounded, + color: AppColor.textSecondary, + size: 22, + ), + ), + prefixIconConstraints: const BoxConstraints(), + ), + ), + const SizedBox(height: 24), + _buildSectionLabel('Jumlah', inCard: true), + TextField( + controller: _amountController, + keyboardType: TextInputType.number, + textInputAction: TextInputAction.done, + enabled: !isBusy, + cursorColor: AppColor.primary, + inputFormatters: [ThousandsInputFormatter()], + style: AppStyle.h4.copyWith(fontWeight: FontWeight.w700), + onChanged: (value) => context.read().add( + TransferFormEvent.amountChanged( + int.tryParse(digitsOnly(value)) ?? 0, + ), + ), + decoration: InputDecoration( + hintText: '0', + hintStyle: AppStyle.h4.copyWith( + color: AppColor.textLight, + fontWeight: FontWeight.w700, + ), + errorText: exceedsBalance ? 'Melebihi saldo kamu' : null, + suffixText: state.currency.label, + suffixStyle: AppStyle.md.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + ), + ), + ), + const SizedBox(height: 4), + Row( + children: [ + Expanded( + child: Text( + walletState.hasLoaded + ? 'Saldo tersedia ${balance.thousandFormat}' + : 'Memuat saldo…', + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + ), + ), + ), + TextButton( + onPressed: walletState.hasLoaded && balance > 0 && !isBusy + ? () => _fillAmount(balance) + : null, + style: TextButton.styleFrom( + foregroundColor: AppColor.primary, + padding: const EdgeInsets.symmetric(horizontal: 8), + minimumSize: const Size(0, 32), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), + child: Text( + 'Kirim semua', + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w700), + ), + ), + ], + ), + ], + ), + ), + const SizedBox(height: 12), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Icon( + Icons.info_outline_rounded, + size: 16, + color: AppColor.textSecondary, + ), + const SizedBox(width: 6), + Expanded( + child: Text( + 'Transfer bersifat final dan tidak bisa dibatalkan. Pastikan ' + 'nomor penerima sudah benar.', + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + ), + ], + ), + const SizedBox(height: 20), + AppElevatedButton( + title: 'Lanjut', + height: 48, + isLoading: isBusy, + onPressed: state.isFilled && !exceedsBalance && !isBusy + ? () { + dismissKeyboard(context); + context.read().add( + const TransferFormEvent.recipientChecked(), + ); + } + : null, + ), + ], + ); + } + + Widget _buildSectionLabel(String text, {bool inCard = false}) { + return Padding( + padding: EdgeInsets.only(left: inCard ? 0 : 4, bottom: inCard ? 4 : 10), + child: Text( + text, + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + ), + ), + ); + } + + int _balanceOf(WalletSummary summary, WalletCurrency currency) => + currency == WalletCurrency.point + ? summary.pointBalance + : summary.coinBalance; + + Widget _buildSuccess(TransferResult result) { + return WalletResultView( + title: 'Transfer berhasil', + amountText: + '${result.amount.thousandFormat} ${result.currency.label} terkirim', + lines: [ + 'Ke ${result.recipient.name} (${result.recipient.phoneNumber})', + 'Saldo tersisa: ${result.balance.thousandFormat} ' + '${result.currency.label}', + ...result.lots + .where((lot) => lot.expiresAt != null) + .map( + (lot) => + '${lot.amount.thousandFormat} ${result.currency.label} yang ' + 'dikirim berlaku sampai ${formatWibDate(lot.expiresAt!)}', + ), + ], + onDone: () => context.router.maybePop(), + ); + } +} + +/// Kartu pilihan mata uang beserta saldonya. +class _CurrencyOption extends StatelessWidget { + const _CurrencyOption({ + required this.currency, + required this.balance, + required this.isLoaded, + required this.selected, + required this.onTap, + }); + + final WalletCurrency currency; + final int balance; + final bool isLoaded; + final bool selected; + final VoidCallback? onTap; + + @override + Widget build(BuildContext context) { + final radius = BorderRadius.circular(AppValue.borderRadius); + + return Material( + color: Colors.transparent, + child: InkWell( + onTap: onTap, + borderRadius: radius, + child: AnimatedContainer( + duration: const Duration(milliseconds: 220), + curve: Curves.easeOut, + padding: const EdgeInsets.all(14), + decoration: BoxDecoration( + color: selected + ? AppColor.primaryWithOpacity(0.06) + : AppColor.white, + borderRadius: radius, + border: Border.all( + color: selected ? AppColor.primary : AppColor.white, + width: 1.5, + ), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + AnimatedScale( + scale: selected ? 1 : 0.85, + duration: const Duration(milliseconds: 220), + curve: Curves.easeOut, + alignment: Alignment.centerLeft, + child: WalletCurrencyIcon(currency: currency, size: 36), + ), + const Spacer(), + AnimatedScale( + scale: selected ? 1 : 0, + duration: const Duration(milliseconds: 220), + curve: Curves.easeOutBack, + child: const Icon( + Icons.check_circle_rounded, + size: 20, + color: AppColor.primary, + ), + ), + ], + ), + const SizedBox(height: 12), + Text( + currency.label, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 2), + Text( + isLoaded ? balance.thousandFormat : '–', + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/wallet_expiring_page.dart b/lib/presentation/pages/wallet/wallet_expiring_page.dart new file mode 100644 index 0000000..dcd118b --- /dev/null +++ b/lib/presentation/pages/wallet/wallet_expiring_page.dart @@ -0,0 +1,131 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../application/wallet/wallet_expiring_loader/wallet_expiring_loader_bloc.dart'; +import '../../../common/extension/extension.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/button/button.dart'; +import 'wallet_ui.dart'; + +/// Saldo yang akan kedaluwarsa (§4.3). +@RoutePage() +class WalletExpiringPage extends StatelessWidget implements AutoRouteWrapper { + const WalletExpiringPage({super.key}); + + @override + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (_) => + getIt() + ..add(const WalletExpiringLoaderEvent.fetched()), + child: this, + ); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('Akan Kedaluwarsa')), + body: BlocBuilder( + builder: (context, state) { + if (state.isFetching) { + return const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 36), + ); + } + + final failure = state.failureOption.toNullable(); + if (failure != null) { + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(walletFailureMessage(failure), style: AppStyle.md), + const SizedBox(height: 16), + AppOutlineButton( + title: 'Coba lagi', + width: 160, + onPressed: () => context + .read() + .add(const WalletExpiringLoaderEvent.fetched()), + ), + ], + ), + ); + } + + final expiring = state.expiring; + + return ListView( + padding: const EdgeInsets.all(16), + children: [ + Text( + 'Saldo bisa dipakai sampai pukul 23:59 WIB pada tanggal ' + 'kedaluwarsa. Saldo yang kedaluwarsa hangus tanpa kompensasi.', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + const SizedBox(height: 16), + _Section(currency: WalletCurrency.point, items: expiring.point), + const SizedBox(height: 16), + _Section(currency: WalletCurrency.coin, items: expiring.coin), + ], + ); + }, + ), + ); + } +} + +class _Section extends StatelessWidget { + const _Section({required this.currency, required this.items}); + + final WalletCurrency currency; + final List items; + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 8), + child: Text( + currency.label, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + if (items.isEmpty) + Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 16, 20), + child: Text( + 'Tidak ada saldo yang akan kedaluwarsa', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + ) + else + ...items.map( + (item) => ListTile( + leading: const Icon(Icons.schedule, color: AppColor.warning), + title: Text( + '${item.amount.thousandFormat} ${currency.label}', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + subtitle: Text( + 'Berlaku sampai ${item.date.toDate}, 23:59 WIB', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/wallet_history_page.dart b/lib/presentation/pages/wallet/wallet_history_page.dart new file mode 100644 index 0000000..6fef883 --- /dev/null +++ b/lib/presentation/pages/wallet/wallet_history_page.dart @@ -0,0 +1,380 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../../injection.dart'; +import '../../components/button/button.dart'; +import '../../components/toast/flushbar.dart'; +import 'wallet_ui.dart'; +import 'widgets/wallet_transaction_tile.dart'; + +/// Riwayat mutasi (§4.2). +@RoutePage() +class WalletHistoryPage extends StatefulWidget implements AutoRouteWrapper { + const WalletHistoryPage({ + super.key, + this.initialCurrency = WalletCurrency.point, + }); + + final WalletCurrency initialCurrency; + + @override + State createState() => _WalletHistoryPageState(); + + @override + Widget wrappedRoute(BuildContext context) => BlocProvider( + create: (_) => + getIt() + ..add(WalletHistoryLoaderEvent.currencyChanged(initialCurrency)), + child: this, + ); +} + +class _WalletHistoryPageState extends State + with SingleTickerProviderStateMixin { + late final TabController _tabController; + final ScrollController _scrollController = ScrollController(); + + @override + void initState() { + super.initState(); + _tabController = TabController( + length: WalletCurrency.values.length, + vsync: this, + initialIndex: WalletCurrency.values.indexOf(widget.initialCurrency), + ); + _tabController.addListener(() { + if (_tabController.indexIsChanging) return; + context.read().add( + WalletHistoryLoaderEvent.currencyChanged( + WalletCurrency.values[_tabController.index], + ), + ); + }); + _scrollController.addListener(_onScroll); + } + + @override + void dispose() { + _tabController.dispose(); + _scrollController.dispose(); + super.dispose(); + } + + void _onScroll() { + final position = _scrollController.position; + if (position.pixels >= position.maxScrollExtent - 200) { + context.read().add( + const WalletHistoryLoaderEvent.loadedMore(), + ); + } + } + + Future _openFilter(WalletHistoryLoaderState state) async { + final result = await showModalBottomSheet<_HistoryFilter>( + context: context, + isScrollControlled: true, + backgroundColor: AppColor.white, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + builder: (_) => _FilterSheet( + initial: _HistoryFilter( + types: state.types, + from: state.from, + to: state.to, + ), + ), + ); + + if (result == null || !mounted) return; + context.read().add( + WalletHistoryLoaderEvent.filterChanged( + types: result.types, + from: result.from, + to: result.to, + ), + ); + } + + @override + Widget build(BuildContext context) { + return BlocConsumer( + listenWhen: (p, c) => + p.failureOption != c.failureOption && c.items.isNotEmpty, + listener: (context, state) => state.failureOption.fold( + () {}, + (f) => AppFlushbar.showError(context, walletFailureMessage(f)), + ), + builder: (context, state) { + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar( + title: const Text('Riwayat'), + actions: [ + IconButton( + onPressed: () => _openFilter(state), + icon: Badge( + isLabelVisible: state.hasFilter, + backgroundColor: AppColor.primary, + smallSize: 8, + child: const Icon(Icons.filter_list), + ), + ), + ], + bottom: TabBar( + controller: _tabController, + tabs: WalletCurrency.values + .map((currency) => Tab(text: currency.label)) + .toList(), + ), + ), + body: Column( + children: [ + if (state.hasFilter) _buildActiveFilter(state), + Expanded(child: _buildList(state)), + ], + ), + ); + }, + ); + } + + Widget _buildActiveFilter(WalletHistoryLoaderState state) { + final parts = [ + if (state.types.isNotEmpty) '${state.types.length} tipe', + if (state.from != null || state.to != null) + '${state.from == null ? '…' : formatShortDate(state.from!)} – ' + '${state.to == null ? '…' : formatShortDate(state.to!)}', + ]; + + return Container( + color: AppColor.white, + padding: const EdgeInsets.fromLTRB(16, 4, 4, 4), + child: Row( + children: [ + Expanded( + child: Text( + 'Filter: ${parts.join(' · ')}', + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ), + TextButton( + onPressed: () => context.read().add( + const WalletHistoryLoaderEvent.filterChanged(types: []), + ), + child: Text( + 'Hapus filter', + style: AppStyle.sm.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ); + } + + Widget _buildList(WalletHistoryLoaderState state) { + if (state.isFetching && state.items.isEmpty) { + return const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 36), + ); + } + + final failure = state.failureOption.toNullable(); + if (failure != null && state.items.isEmpty) { + return Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(walletFailureMessage(failure), style: AppStyle.md), + const SizedBox(height: 16), + AppOutlineButton( + title: 'Coba lagi', + width: 160, + onPressed: () => context.read().add( + const WalletHistoryLoaderEvent.refreshed(), + ), + ), + ], + ), + ); + } + + return RefreshIndicator( + color: AppColor.primary, + onRefresh: () async { + final bloc = context.read(); + bloc.add(const WalletHistoryLoaderEvent.refreshed()); + await bloc.stream.firstWhere((s) => !s.isFetching); + }, + child: state.items.isEmpty + ? ListView( + children: [ + const SizedBox(height: 120), + Text( + state.hasFilter + ? 'Tidak ada transaksi yang cocok dengan filter' + : 'Belum ada transaksi', + textAlign: TextAlign.center, + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + ], + ) + : ListView.separated( + controller: _scrollController, + physics: const AlwaysScrollableScrollPhysics(), + itemCount: state.items.length + (state.hasMore ? 1 : 0), + separatorBuilder: (_, __) => + const Divider(height: 1, color: AppColor.borderLight), + itemBuilder: (context, index) { + if (index >= state.items.length) { + return const Padding( + padding: EdgeInsets.all(16), + child: Center( + child: SpinKitFadingCircle( + color: AppColor.primary, + size: 24, + ), + ), + ); + } + return Container( + color: AppColor.white, + child: WalletTransactionTile(transaction: state.items[index]), + ); + }, + ), + ); + } +} + +class _HistoryFilter { + const _HistoryFilter({required this.types, this.from, this.to}); + + final List types; + final DateTime? from; + final DateTime? to; +} + +class _FilterSheet extends StatefulWidget { + const _FilterSheet({required this.initial}); + + final _HistoryFilter initial; + + @override + State<_FilterSheet> createState() => _FilterSheetState(); +} + +class _FilterSheetState extends State<_FilterSheet> { + late final Set _types = {...widget.initial.types}; + late DateTime? _from = widget.initial.from; + late DateTime? _to = widget.initial.to; + + Future _pickRange() async { + final now = DateTime.now(); + final picked = await showDateRangePicker( + context: context, + firstDate: DateTime(now.year - 5), + lastDate: now, + initialDateRange: _from != null && _to != null + ? DateTimeRange(start: _from!, end: _to!) + : null, + ); + if (picked == null) return; + setState(() { + _from = picked.start; + _to = picked.end; + }); + } + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Filter riwayat', + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + ), + const SizedBox(height: 16), + Text( + 'Tipe', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), + ), + const SizedBox(height: 8), + Wrap( + spacing: 8, + runSpacing: 8, + children: WalletTransactionType.filterable.map((type) { + final selected = _types.contains(type); + return FilterChip( + label: Text(type.label, style: AppStyle.sm), + selected: selected, + selectedColor: AppColor.primaryWithOpacity(0.15), + checkmarkColor: AppColor.primary, + onSelected: (value) => setState( + () => value ? _types.add(type) : _types.remove(type), + ), + ); + }).toList(), + ), + const SizedBox(height: 16), + Text( + 'Tanggal', + style: AppStyle.md.copyWith(fontWeight: FontWeight.w600), + ), + const SizedBox(height: 8), + OutlinedButton.icon( + onPressed: _pickRange, + icon: const Icon(Icons.date_range), + label: Text( + _from == null + ? 'Pilih rentang tanggal' + : '${formatShortDate(_from!)} – ${formatShortDate(_to!)}', + ), + ), + const SizedBox(height: 24), + Row( + children: [ + Expanded( + child: AppOutlineButton( + title: 'Reset', + onPressed: () => Navigator.of( + context, + ).pop(const _HistoryFilter(types: [])), + ), + ), + const SizedBox(width: 12), + Expanded( + child: AppElevatedButton( + title: 'Terapkan', + onPressed: () => Navigator.of(context).pop( + _HistoryFilter( + types: WalletTransactionType.filterable + .where(_types.contains) + .toList(), + from: _from, + to: _to, + ), + ), + ), + ), + ], + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/wallet_page.dart b/lib/presentation/pages/wallet/wallet_page.dart new file mode 100644 index 0000000..38dee04 --- /dev/null +++ b/lib/presentation/pages/wallet/wallet_page.dart @@ -0,0 +1,337 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; + +import '../../../application/wallet/wallet_loader/wallet_loader_bloc.dart'; +import '../../../common/extension/extension.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../components/button/button.dart'; +import '../../router/app_router.gr.dart'; +import 'wallet_ui.dart'; +import 'widgets/wallet_expiring_banner.dart'; +import 'widgets/wallet_transaction_tile.dart'; + +/// Beranda wallet (§4.1). +@RoutePage() +class WalletPage extends StatefulWidget { + const WalletPage({super.key}); + + @override + State createState() => _WalletPageState(); +} + +class _WalletPageState extends State { + @override + void initState() { + super.initState(); + _refresh(); + } + + void _refresh() { + context.read().add(const WalletLoaderEvent.fetched()); + } + + /// Saldo dimuat ulang setiap kembali dari layar transaksi. + Future _open(PageRouteInfo route) async { + await context.router.push(route); + if (mounted) _refresh(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: AppColor.background, + appBar: AppBar(title: const Text('EnakPoint & EnakCoin')), + body: BlocBuilder( + builder: (context, state) { + if (!state.hasLoaded) { + return state.failureOption.fold( + () => const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 36), + ), + (f) => _buildError(walletFailureMessage(f)), + ); + } + + final summary = state.summary; + + return RefreshIndicator( + color: AppColor.primary, + onRefresh: () async { + _refresh(); + await context.read().stream.firstWhere( + (s) => !s.isFetching, + ); + }, + child: ListView( + padding: const EdgeInsets.only(bottom: 32), + children: [ + _buildBalanceCard(summary), + ..._buildExpiringBanners(summary), + _buildActions(summary), + const SizedBox(height: 8), + _buildRecent(summary), + ], + ), + ); + }, + ), + ); + } + + Widget _buildError(String message) { + return Center( + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text(message, style: AppStyle.md, textAlign: TextAlign.center), + const SizedBox(height: 16), + AppOutlineButton( + title: 'Coba lagi', + width: 160, + onPressed: _refresh, + ), + ], + ), + ), + ); + } + + Widget _buildBalanceCard(WalletSummary summary) { + return Container( + margin: const EdgeInsets.all(16), + padding: const EdgeInsets.all(20), + decoration: BoxDecoration( + gradient: const LinearGradient( + colors: AppColor.primaryGradient, + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: AppColor.primary.withOpacity(0.3), + blurRadius: 12, + offset: const Offset(0, 6), + ), + ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + const _CurrencyBadge(currency: WalletCurrency.point, size: 44), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'EnakPoint', + style: AppStyle.sm.copyWith( + color: AppColor.textWhite.withOpacity(0.9), + ), + ), + Text( + summary.pointBalance.thousandFormat, + style: AppStyle.h2.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w700, + ), + ), + Text( + pointDiscountLabel(summary.pointDiscountValue), + style: AppStyle.sm.copyWith( + color: AppColor.textWhite.withOpacity(0.9), + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ], + ), + const SizedBox(height: 16), + Divider(color: AppColor.white.withOpacity(0.3), height: 1), + const SizedBox(height: 12), + Row( + children: [ + const _CurrencyBadge(currency: WalletCurrency.coin, size: 28), + const SizedBox(width: 8), + Text( + 'EnakCoin', + style: AppStyle.md.copyWith( + color: AppColor.textWhite.withOpacity(0.9), + ), + ), + const Spacer(), + Text( + summary.coinBalance.thousandFormat, + style: AppStyle.xl.copyWith( + color: AppColor.textWhite, + fontWeight: FontWeight.w700, + ), + ), + ], + ), + ], + ), + ); + } + + List _buildExpiringBanners(WalletSummary summary) { + final banners = [ + if (summary.nearestExpiringPoint != null) + WalletExpiringBanner( + currency: WalletCurrency.point, + expiring: summary.nearestExpiringPoint!, + onTap: () => _open(const WalletExpiringRoute()), + ), + if (summary.nearestExpiringCoin != null) + WalletExpiringBanner( + currency: WalletCurrency.coin, + expiring: summary.nearestExpiringCoin!, + onTap: () => _open(const WalletExpiringRoute()), + ), + ]; + + return banners + .map( + (banner) => Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 12), + child: banner, + ), + ) + .toList(); + } + + Widget _buildActions(WalletSummary summary) { + final actions = [ + (Icons.qr_code_2, 'Bayar di kasir', const PaymentCodeRoute()), + (Icons.swap_horiz, 'Tukar EnakCoin', const ExchangeRoute()), + (Icons.send_outlined, 'Transfer', const TransferRoute()), + (Icons.casino_outlined, 'Main game', const FerrisWheelRoute()), + ]; + + return Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(vertical: 16), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Row( + children: actions.map((action) { + final (icon, label, route) = action; + return Expanded( + child: InkWell( + onTap: () => _open(route), + child: Column( + children: [ + Container( + width: 48, + height: 48, + decoration: BoxDecoration( + color: AppColor.primaryWithOpacity(0.1), + shape: BoxShape.circle, + ), + child: Icon(icon, color: AppColor.primary), + ), + const SizedBox(height: 8), + Text( + label, + textAlign: TextAlign.center, + style: AppStyle.xs.copyWith(fontWeight: FontWeight.w600), + ), + ], + ), + ), + ); + }).toList(), + ), + ); + } + + Widget _buildRecent(WalletSummary summary) { + return Container( + margin: const EdgeInsets.symmetric(horizontal: 16), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(16, 8, 4, 0), + child: Row( + children: [ + Expanded( + child: Text( + 'Riwayat terbaru', + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + TextButton( + onPressed: () => _open(WalletHistoryRoute()), + child: Text( + 'Lihat semua', + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ), + if (summary.recentTransactions.isEmpty) + Padding( + padding: const EdgeInsets.all(24), + child: Text( + 'Belum ada transaksi', + textAlign: TextAlign.center, + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + ) + else + ...summary.recentTransactions + .take(5) + .map( + (tx) => WalletTransactionTile( + transaction: tx, + showCurrency: true, + ), + ), + ], + ), + ); + } +} + +/// Ikon mata uang di atas lingkaran putih, agar kontras di kartu merah. +class _CurrencyBadge extends StatelessWidget { + const _CurrencyBadge({required this.currency, required this.size}); + + final WalletCurrency currency; + final double size; + + @override + Widget build(BuildContext context) { + return Container( + width: size, + height: size, + padding: EdgeInsets.all(size * 0.14), + decoration: const BoxDecoration( + color: AppColor.white, + shape: BoxShape.circle, + ), + child: WalletCurrencyIcon(currency: currency, size: size * 0.72), + ); + } +} diff --git a/lib/presentation/pages/wallet/wallet_ui.dart b/lib/presentation/pages/wallet/wallet_ui.dart new file mode 100644 index 0000000..5c8d07d --- /dev/null +++ b/lib/presentation/pages/wallet/wallet_ui.dart @@ -0,0 +1,131 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:intl/intl.dart'; + +import '../../../common/api/api_failure.dart'; +import '../../../common/extension/extension.dart'; +import '../../../common/theme/theme.dart'; +import '../../../domain/wallet/wallet.dart'; +import '../../components/assets/assets.gen.dart'; + +/// Pesan ramah untuk customer. [rejectedMessage] dipakai untuk penolakan +/// aturan bisnis (`304`), karena `cause` dari server tidak boleh tampil mentah. +String walletFailureMessage(WalletFailure failure, {String? rejectedMessage}) { + return failure.map( + serverError: (value) => value.failure.maybeMap( + connectionError: (_) => 'Tidak ada koneksi internet. Coba lagi.', + connectionTimeout: (_) => 'Koneksi lambat. Coba lagi.', + orElse: () => 'Terjadi kesalahan, coba lagi', + ), + unexpectedError: (_) => 'Terjadi kesalahan, coba lagi', + unauthorized: (_) => 'Sesi kamu sudah berakhir. Silakan masuk lagi.', + invalidRequest: (_) => 'Permintaan tidak dapat diproses. Coba lagi.', + rejected: (_) => rejectedMessage ?? 'Permintaan tidak dapat diproses.', + notFound: (_) => 'Data tidak ditemukan', + tooManyRequests: (value) => + 'Terlalu sering meminta kode. Coba lagi dalam ' + '${value.retryAfterSeconds} detik.', + internalError: (_) => 'Terjadi kesalahan, coba lagi', + pinNotSet: (_) => 'Kamu belum membuat PIN.', + pinInvalid: (value) => value.remainingAttempts == null + ? 'PIN salah.' + : 'PIN salah, sisa ${value.remainingAttempts} percobaan.', + pinLocked: (value) => value.lockedUntil == null + ? 'PIN terkunci. Silakan gunakan Lupa PIN.' + : 'PIN terkunci sampai ${formatWibTime(value.lockedUntil!)}.', + transferBlocked: (value) => value.transferBlockedUntil == null + ? 'Transfer sementara ditahan karena PIN baru direset.' + : 'Transfer bisa dilakukan lagi pada ' + '${formatWibDateTime(value.transferBlockedUntil!)}.', + ); +} + +/// Jam WIB, dengan tanggal bila bukan hari ini: "14:30 WIB" / +/// "1 Okt 2026 14:30 WIB". +String formatWibTime(DateTime time) { + final wib = time.toWib; + final today = DateTime.now().toWib; + final sameDay = + wib.year == today.year && + wib.month == today.month && + wib.day == today.day; + return sameDay ? '${wib.toHourMinute} WIB' : formatWibDateTime(time); +} + +String formatWibDateTime(DateTime time) => '${time.toWib.toShortDatetime} WIB'; + +/// Tanggal kalender WIB dari timestamp, mis. `expires_at`. +String formatWibDate(DateTime time) => time.toWib.toDate; + +/// Nilai rupiah EnakPoint selalu "setara potongan", tidak pernah saldo atau +/// uang (§1 aturan 2). +String pointDiscountLabel(int discountValue) => + 'setara potongan ${discountValue.currencyFormatRp}'; + +/// Jumlah bertanda: "+875" / "−120" (tanda minus U+2212). +String formatSignedAmount(int amount) => amount >= 0 + ? '+${amount.thousandFormat}' + : '−${amount.abs().thousandFormat}'; + +Color signedAmountColor(int amount) => + amount >= 0 ? AppColor.success : AppColor.error; + +String formatCountdown(Duration duration) { + final seconds = duration.inSeconds < 0 ? 0 : duration.inSeconds; + final m = (seconds ~/ 60).toString().padLeft(2, '0'); + final s = (seconds % 60).toString().padLeft(2, '0'); + return '$m:$s'; +} + +/// Hanya digit, untuk nomor HP dan jumlah. +String digitsOnly(String value) => value.replaceAll(RegExp(r'[^0-9]'), ''); + +/// Tanggal pendek untuk chip filter: "1 Sep 2026". +String formatShortDate(DateTime date) => + DateFormat('d MMM yyyy', 'id_ID').format(date); + +/// Menampilkan jumlah dengan pemisah ribuan saat diketik: "10000" → "10.000". +/// Baca nilainya dengan [digitsOnly]. +class ThousandsInputFormatter extends TextInputFormatter { + static const int _maxDigits = 12; + + @override + TextEditingValue formatEditUpdate( + TextEditingValue oldValue, + TextEditingValue newValue, + ) { + final digits = digitsOnly(newValue.text); + if (digits.isEmpty) return const TextEditingValue(); + if (digits.length > _maxDigits) return oldValue; + + final text = int.parse(digits).thousandFormat; + return TextEditingValue( + text: text, + selection: TextSelection.collapsed(offset: text.length), + ); + } +} + +/// Ikon 3D EnakPoint / EnakCoin. +class WalletCurrencyIcon extends StatelessWidget { + const WalletCurrencyIcon({super.key, required this.currency, this.size = 24}); + + final WalletCurrency currency; + final double size; + + @override + Widget build(BuildContext context) { + final asset = currency == WalletCurrency.point + ? Assets.icons.enakpointIcon + : Assets.icons.enakcoinIcon; + // Aset aslinya 512–1024px; decode seukuran tampilan saja. + final cacheSize = (size * MediaQuery.devicePixelRatioOf(context)).round(); + + return asset.image( + width: size, + height: size, + fit: BoxFit.contain, + cacheWidth: cacheSize, + ); + } +} diff --git a/lib/presentation/pages/wallet/widgets/wallet_confirm_dialog.dart b/lib/presentation/pages/wallet/widgets/wallet_confirm_dialog.dart new file mode 100644 index 0000000..a1a88c9 --- /dev/null +++ b/lib/presentation/pages/wallet/widgets/wallet_confirm_dialog.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; + +/// Konfirmasi sebelum transaksi yang tidak bisa dibatalkan. +Future showWalletConfirmDialog( + BuildContext context, { + required String title, + required String message, + required String confirmLabel, +}) async { + final confirmed = await showDialog( + context: context, + builder: (dialogContext) => AlertDialog( + backgroundColor: AppColor.white, + title: Text( + title, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + content: Text(message, style: AppStyle.md), + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(false), + child: Text( + 'Batal', + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + ), + ), + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(true), + child: Text( + confirmLabel, + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ], + ), + ); + return confirmed == true; +} diff --git a/lib/presentation/pages/wallet/widgets/wallet_expiring_banner.dart b/lib/presentation/pages/wallet/widgets/wallet_expiring_banner.dart new file mode 100644 index 0000000..66f8180 --- /dev/null +++ b/lib/presentation/pages/wallet/widgets/wallet_expiring_banner.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/extension/extension.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../domain/wallet/wallet.dart'; + +class WalletExpiringBanner extends StatelessWidget { + const WalletExpiringBanner({ + super.key, + required this.currency, + required this.expiring, + required this.onTap, + }); + + final WalletCurrency currency; + final ExpiringAmount expiring; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + child: Container( + padding: const EdgeInsets.all(12), + decoration: BoxDecoration( + color: AppColor.warningWithOpacity(0.1), + borderRadius: BorderRadius.circular(AppValue.borderRadius), + border: Border.all(color: AppColor.warning), + ), + child: Row( + children: [ + const Icon(Icons.schedule, color: AppColor.warning, size: 20), + const SizedBox(width: 10), + Expanded( + child: Text( + '${expiring.amount.thousandFormat} ${currency.label} akan ' + 'kedaluwarsa pada ${expiring.date.toDate}', + style: AppStyle.sm.copyWith(fontWeight: FontWeight.w600), + ), + ), + const Icon( + Icons.arrow_forward_ios, + size: 14, + color: AppColor.textSecondary, + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/widgets/wallet_history_section.dart b/lib/presentation/pages/wallet/widgets/wallet_history_section.dart new file mode 100644 index 0000000..87bc3b3 --- /dev/null +++ b/lib/presentation/pages/wallet/widgets/wallet_history_section.dart @@ -0,0 +1,361 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; +import 'package:shimmer/shimmer.dart'; + +import '../../../../application/wallet/wallet_history_loader/wallet_history_loader_bloc.dart'; +import '../../../../common/theme/theme.dart'; +import '../../../../domain/wallet/wallet.dart'; +import '../wallet_ui.dart'; +import 'wallet_transaction_tile.dart'; + +/// Riwayat dari [WalletHistoryLoaderBloc] terdekat, sebagai sliver di dalam +/// [CustomScrollView]. Filter tipe/mata uang diatur oleh halaman pemakainya. +class WalletHistorySection extends StatefulWidget { + const WalletHistorySection({ + super.key, + required this.title, + required this.emptyIcon, + required this.emptyTitle, + required this.emptySubtitle, + }); + + final String title; + final IconData emptyIcon; + final String emptyTitle; + final String Function(WalletCurrency currency) emptySubtitle; + + @override + State createState() => _WalletHistorySectionState(); +} + +class _WalletHistorySectionState extends State { + static const _radius = Radius.circular(AppValue.borderRadius); + + /// Item yang sudah pernah dianimasikan, supaya tidak berkedip ulang saat + /// di-scroll keluar lalu masuk lagi. + final Set _animatedIds = {}; + + /// Sebelum request pertama selesai, tampilkan skeleton, bukan "kosong". + bool _hasFetched = false; + + @override + Widget build(BuildContext context) { + return BlocConsumer( + // Awal fetch halaman pertama (ganti tab / refresh) mengosongkan list, + // jadi item yang datang berikutnya boleh dianimasikan lagi. + listenWhen: (p, c) => p.isFetching != c.isFetching, + listener: (context, state) { + if (state.isFetching) { + _animatedIds.clear(); + } else { + _hasFetched = true; + } + }, + builder: (context, state) { + final showList = state.items.isNotEmpty; + + return SliverMainAxisGroup( + slivers: [ + SliverToBoxAdapter(child: _buildHeader(state)), + if (showList) + SliverList.builder( + itemCount: state.items.length + (state.hasMore ? 1 : 0), + itemBuilder: (context, index) { + if (index >= state.items.length) return _buildLoadingMore(); + return _buildItem(state, index); + }, + ) + else + SliverToBoxAdapter( + child: AnimatedSwitcher( + duration: const Duration(milliseconds: 250), + child: _buildPlaceholder(state), + ), + ), + ], + ); + }, + ); + } + + Widget _buildHeader(WalletHistoryLoaderState state) { + return Padding( + padding: const EdgeInsets.fromLTRB(4, 0, 4, 12), + child: Row( + children: [ + Expanded( + child: Text( + widget.title, + style: AppStyle.lg.copyWith(fontWeight: FontWeight.w700), + ), + ), + AnimatedSwitcher( + duration: const Duration(milliseconds: 200), + child: Text( + state.currency.label, + key: ValueKey(state.currency), + style: AppStyle.sm.copyWith( + color: AppColor.textSecondary, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ); + } + + Widget _buildItem(WalletHistoryLoaderState state, int index) { + final tx = state.items[index]; + final isFirst = index == 0; + final isLast = index == state.items.length - 1 && !state.hasMore; + final animate = _animatedIds.add(tx.id); + + final tile = Container( + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.vertical( + top: isFirst ? _radius : Radius.zero, + bottom: isLast ? _radius : Radius.zero, + ), + ), + child: Column( + children: [ + if (!isFirst) + const Divider( + height: 1, + indent: 68, + endIndent: 16, + color: AppColor.borderLight, + ), + WalletTransactionTile(transaction: tx), + ], + ), + ); + + if (!animate) return tile; + return _FadeSlideIn( + key: ValueKey(tx.id), + // Hanya item awal yang bertahap; item hasil scroll langsung muncul. + delay: Duration(milliseconds: index < 8 ? index * 50 : 0), + child: tile, + ); + } + + Widget _buildLoadingMore() { + return Container( + padding: const EdgeInsets.symmetric(vertical: 16), + decoration: const BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.vertical(bottom: _radius), + ), + child: const Center( + child: SpinKitFadingCircle(color: AppColor.primary, size: 24), + ), + ); + } + + Widget _buildPlaceholder(WalletHistoryLoaderState state) { + if (state.isFetching || !_hasFetched) { + return const _HistorySkeleton(key: ValueKey('skeleton')); + } + + final failure = state.failureOption.toNullable(); + if (failure != null) { + return _MessageCard( + key: const ValueKey('error'), + icon: Icons.wifi_off_rounded, + title: walletFailureMessage(failure), + action: TextButton( + onPressed: () => context.read().add( + const WalletHistoryLoaderEvent.refreshed(), + ), + child: Text( + 'Coba lagi', + style: AppStyle.md.copyWith( + color: AppColor.primary, + fontWeight: FontWeight.w700, + ), + ), + ), + ); + } + + return _MessageCard( + key: ValueKey('empty-${state.currency}'), + icon: widget.emptyIcon, + title: widget.emptyTitle, + subtitle: widget.emptySubtitle(state.currency), + ); + } +} + +class _MessageCard extends StatelessWidget { + const _MessageCard({ + super.key, + required this.icon, + required this.title, + this.subtitle, + this.action, + }); + + final IconData icon; + final String title; + final String? subtitle; + final Widget? action; + + @override + Widget build(BuildContext context) { + return Container( + width: double.infinity, + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 28), + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Column( + children: [ + Container( + width: 52, + height: 52, + decoration: BoxDecoration( + color: AppColor.primaryWithOpacity(0.08), + shape: BoxShape.circle, + ), + child: Icon(icon, color: AppColor.primary, size: 26), + ), + const SizedBox(height: 12), + Text( + title, + textAlign: TextAlign.center, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + if (subtitle != null) ...[ + const SizedBox(height: 4), + Text( + subtitle!, + textAlign: TextAlign.center, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + if (action != null) ...[const SizedBox(height: 4), action!], + ], + ), + ); + } +} + +class _HistorySkeleton extends StatelessWidget { + const _HistorySkeleton({super.key}); + + @override + Widget build(BuildContext context) { + Widget bar(double width, double height) => Container( + width: width, + height: height, + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(4), + ), + ); + + return Container( + decoration: BoxDecoration( + color: AppColor.white, + borderRadius: BorderRadius.circular(AppValue.borderRadius), + ), + child: Shimmer.fromColors( + baseColor: AppColor.borderLight, + highlightColor: AppColor.white, + child: Column( + children: List.generate( + 3, + (_) => Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + child: Row( + children: [ + Container( + width: 40, + height: 40, + decoration: const BoxDecoration( + color: AppColor.white, + shape: BoxShape.circle, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + bar(120, 12), + const SizedBox(height: 8), + bar(80, 10), + ], + ), + ), + bar(56, 14), + ], + ), + ), + ), + ), + ), + ); + } +} + +/// Fade + geser naik sekali saat pertama kali muncul. +class _FadeSlideIn extends StatefulWidget { + const _FadeSlideIn({ + super.key, + required this.child, + this.delay = Duration.zero, + }); + + final Widget child; + final Duration delay; + + @override + State<_FadeSlideIn> createState() => _FadeSlideInState(); +} + +class _FadeSlideInState extends State<_FadeSlideIn> + with SingleTickerProviderStateMixin { + late final AnimationController _controller = AnimationController( + vsync: this, + duration: const Duration(milliseconds: 350), + ); + late final Animation _curve = CurvedAnimation( + parent: _controller, + curve: Curves.easeOutCubic, + ); + + @override + void initState() { + super.initState(); + Future.delayed(widget.delay, () { + if (mounted) _controller.forward(); + }); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return FadeTransition( + opacity: _curve, + child: SlideTransition( + position: Tween( + begin: const Offset(0, 0.15), + end: Offset.zero, + ).animate(_curve), + child: widget.child, + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/widgets/wallet_result_view.dart b/lib/presentation/pages/wallet/widgets/wallet_result_view.dart new file mode 100644 index 0000000..7116249 --- /dev/null +++ b/lib/presentation/pages/wallet/widgets/wallet_result_view.dart @@ -0,0 +1,60 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../components/button/button.dart'; + +/// Layar sukses untuk tukar dan transfer. +class WalletResultView extends StatelessWidget { + const WalletResultView({ + super.key, + required this.title, + required this.amountText, + required this.lines, + required this.onDone, + }); + + final String title; + final String amountText; + final List lines; + final VoidCallback onDone; + + @override + Widget build(BuildContext context) { + return SafeArea( + child: Padding( + padding: const EdgeInsets.all(20), + child: Column( + children: [ + const Spacer(), + const Icon(Icons.check_circle, color: AppColor.success, size: 72), + const SizedBox(height: 16), + Text( + title, + style: AppStyle.xl.copyWith(fontWeight: FontWeight.w700), + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Text( + amountText, + style: AppStyle.h4.copyWith(fontWeight: FontWeight.w700), + textAlign: TextAlign.center, + ), + const SizedBox(height: 16), + ...lines.map( + (line) => Padding( + padding: const EdgeInsets.only(bottom: 6), + child: Text( + line, + style: AppStyle.md.copyWith(color: AppColor.textSecondary), + textAlign: TextAlign.center, + ), + ), + ), + const Spacer(), + AppElevatedButton(title: 'Selesai', onPressed: onDone), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/pages/wallet/widgets/wallet_transaction_tile.dart b/lib/presentation/pages/wallet/widgets/wallet_transaction_tile.dart new file mode 100644 index 0000000..2c5f537 --- /dev/null +++ b/lib/presentation/pages/wallet/widgets/wallet_transaction_tile.dart @@ -0,0 +1,113 @@ +import 'package:flutter/material.dart'; + +import '../../../../common/theme/theme.dart'; +import '../../../../domain/wallet/wallet.dart'; +import '../wallet_ui.dart'; + +class WalletTransactionTile extends StatelessWidget { + const WalletTransactionTile({ + super.key, + required this.transaction, + this.showCurrency = false, + }); + + final WalletTransaction transaction; + + /// Tampilkan mata uang di samping jumlah, untuk list yang mencampur + /// EnakPoint & EnakCoin. Satu order menghasilkan dua transaksi (POINT dan + /// COIN) dengan deskripsi dan jumlah yang sama. + final bool showCurrency; + + @override + Widget build(BuildContext context) { + final tx = transaction; + final color = signedAmountColor(tx.amount); + + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: 40, + height: 40, + decoration: BoxDecoration( + color: color.withOpacity(0.1), + shape: BoxShape.circle, + ), + child: Icon( + tx.isIncoming ? Icons.south_west : Icons.north_east, + color: color, + size: 20, + ), + ), + const SizedBox(width: 12), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + tx.type.label, + style: AppStyle.md.copyWith(fontWeight: FontWeight.w700), + ), + if (tx.description.isNotEmpty) ...[ + const SizedBox(height: 2), + Text( + tx.description, + style: AppStyle.sm.copyWith(color: AppColor.textSecondary), + ), + ], + if (tx.createdAt != null) ...[ + const SizedBox(height: 2), + Text( + formatWibDateTime(tx.createdAt!), + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + ], + if (tx.isIncoming && tx.expiresAt != null) ...[ + const SizedBox(height: 4), + Text( + 'Berlaku sampai ${formatWibDate(tx.expiresAt!)}', + style: AppStyle.xs.copyWith( + color: AppColor.warning, + fontWeight: FontWeight.w600, + ), + ), + ], + ], + ), + ), + const SizedBox(width: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + formatSignedAmount(tx.amount), + style: AppStyle.md.copyWith( + color: color, + fontWeight: FontWeight.w700, + ), + ), + if (showCurrency) ...[ + const SizedBox(width: 4), + WalletCurrencyIcon(currency: tx.currency, size: 16), + ], + ], + ), + if (showCurrency) ...[ + const SizedBox(height: 2), + Text( + tx.currency.label, + style: AppStyle.xs.copyWith(color: AppColor.textSecondary), + ), + ], + ], + ), + ], + ), + ); + } +} diff --git a/lib/presentation/pages/webview/webview_page.dart b/lib/presentation/pages/webview/webview_page.dart new file mode 100644 index 0000000..dbf2262 --- /dev/null +++ b/lib/presentation/pages/webview/webview_page.dart @@ -0,0 +1,283 @@ +import 'dart:developer'; + +import 'package:auto_route/auto_route.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:url_launcher/url_launcher.dart'; +import 'package:webview_flutter/webview_flutter.dart'; +import 'package:webview_flutter_android/webview_flutter_android.dart'; +import 'package:webview_flutter_wkwebview/webview_flutter_wkwebview.dart'; + +import '../../../common/theme/theme.dart'; +import '../../components/button/button.dart'; + +/// Membuka halaman web di dalam aplikasi, mis. EnakGame. +@RoutePage() +class WebViewPage extends StatefulWidget { + const WebViewPage({ + super.key, + required this.title, + required this.url, + this.fullscreen = false, + this.backgroundColor, + }); + + final String title; + final String url; + + /// Tanpa AppBar: web digambar sampai ke belakang status bar. Untuk web yang + /// punya header sendiri dan memakai `viewport-fit=cover`. Kalau WebView + /// diletakkan di bawah AppBar, Android WebView tetap melaporkan + /// `env(safe-area-inset-top)` setinggi status bar, sehingga header web + /// turun dan menyisakan celah kosong. + final bool fullscreen; + + /// Samakan dengan warna latar web, supaya tidak berkedip saat dimuat dan + /// warna ikon status bar pas. Bawaan putih. + final Color? backgroundColor; + + @override + State createState() => _WebViewPageState(); +} + +class _WebViewPageState extends State { + static const _nativeChannel = MethodChannel('com.apskel.enaklocustomer/webview'); + + late final WebViewController _controller; + + /// Lewat notifier, bukan setState, supaya WebView tidak ikut di-rebuild + /// setiap progres berubah. + final ValueNotifier _progress = ValueNotifier(0); + bool _hasError = false; + + /// Selama web masih punya riwayat, back (tombol Android / swipe iOS) + /// mundur di web. Di halaman pertama, back langsung menutup halaman ini. + bool _canGoBack = false; + + Color get _backgroundColor => widget.backgroundColor ?? AppColor.white; + + @override + void initState() { + super.initState(); + _controller = WebViewController() + ..setJavaScriptMode(JavaScriptMode.unrestricted) + ..setBackgroundColor(_backgroundColor) + ..setNavigationDelegate( + NavigationDelegate( + onProgress: (progress) => _progress.value = progress, + onPageStarted: (_) { + if (mounted && _hasError) setState(() => _hasError = false); + }, + onPageFinished: (_) => _syncCanGoBack(), + onUrlChange: (_) => _syncCanGoBack(), + onWebResourceError: (error) { + // Error sub-resource (gambar, script pihak ketiga) diabaikan. + if (error.isForMainFrame == false) return; + if (mounted) setState(() => _hasError = true); + }, + onNavigationRequest: _onNavigationRequest, + ), + ) + ..loadRequest(Uri.parse(widget.url)); + + final platform = _controller.platform; + if (platform is AndroidWebViewController) { + _enableOffscreenPreRaster(platform); + } + // Swipe dari tepi kiri di iOS untuk mundur di riwayat web. + if (platform is WebKitWebViewController) { + platform.setAllowsBackForwardNavigationGestures(true); + } + } + + /// Bawaannya Android WebView hanya menyimpan tile yang sedang terlihat: + /// bagian yang di-scroll keluar layar dibuang, lalu digambar ulang saat + /// di-scroll kembali. Pre-raster membuat tile di sekitar layar ikut + /// disimpan (memakai memori lebih besar). Lihat `MainActivity.kt`. + Future _enableOffscreenPreRaster( + AndroidWebViewController platform, + ) async { + try { + await _nativeChannel.invokeMethod('enableOffscreenPreRaster', { + 'webViewId': platform.webViewIdentifier, + }); + } on PlatformException catch (e, s) { + log('enableOffscreenPreRaster', error: e, stackTrace: s); + } + } + + Future _syncCanGoBack() async { + final canGoBack = await _controller.canGoBack(); + if (mounted && canGoBack != _canGoBack) { + setState(() => _canGoBack = canGoBack); + } + } + + /// Skema selain http/https (tel:, mailto:, whatsapp:, intent:) diserahkan + /// ke aplikasi luar karena WebView tidak bisa membukanya. + Future _onNavigationRequest( + NavigationRequest request, + ) async { + final uri = Uri.tryParse(request.url); + if (uri == null || uri.scheme == 'http' || uri.scheme == 'https') { + return NavigationDecision.navigate; + } + + await launchUrl(uri, mode: LaunchMode.externalApplication); + return NavigationDecision.prevent; + } + + Future _onPopInvoked(bool didPop, Object? result) async { + if (didPop) return; + if (await _controller.canGoBack()) { + await _controller.goBack(); + } else if (mounted) { + context.router.pop(); + } + } + + void _reload() { + setState(() => _hasError = false); + _controller.reload(); + } + + @override + void dispose() { + _progress.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final surface = _hasError ? AppColor.white : _backgroundColor; + final overlayStyle = + ThemeData.estimateBrightnessForColor(surface) == Brightness.dark + ? SystemUiOverlayStyle.light + : SystemUiOverlayStyle.dark; + + return AnnotatedRegion( + value: overlayStyle.copyWith(statusBarColor: Colors.transparent), + child: PopScope( + canPop: !_canGoBack, + onPopInvokedWithResult: _onPopInvoked, + child: Scaffold( + backgroundColor: _backgroundColor, + appBar: widget.fullscreen ? null : _buildAppBar(), + // WebView tetap terpasang saat error, supaya "Coba lagi" tidak + // membuat ulang native view-nya. + body: Stack( + children: [ + _buildWebView(), + if (widget.fullscreen) + Positioned( + top: MediaQuery.paddingOf(context).top, + left: 0, + right: 0, + child: _buildProgress(), + ), + if (_hasError) Positioned.fill(child: _buildError()), + ], + ), + ), + ), + ); + } + + PreferredSizeWidget _buildAppBar() { + return AppBar( + title: Text(widget.title), + actions: [ + IconButton( + icon: const Icon(Icons.refresh), + tooltip: 'Muat ulang', + onPressed: _reload, + ), + ], + // Tinggi tetap: kalau bar ini muncul-hilang, WebView ikut di-resize + // dan halamannya di-layout ulang. + bottom: PreferredSize( + preferredSize: const Size.fromHeight(2), + child: _buildProgress(), + ), + ); + } + + Widget _buildProgress() { + return ValueListenableBuilder( + valueListenable: _progress, + builder: (context, progress, _) => progress < 100 && !_hasError + ? LinearProgressIndicator( + value: progress / 100, + minHeight: 2, + color: AppColor.primary, + backgroundColor: AppColor.primaryWithOpacity(0.1), + ) + : const SizedBox(height: 2), + ); + } + + /// Android memakai Hybrid Composition: WebView digambar langsung oleh + /// Android, bukan disalin ke texture Flutter setiap frame (mode default). + /// Jauh lebih lancar untuk halaman yang terus beranimasi seperti EnakGame. + Widget _buildWebView() { + final platform = _controller.platform; + return WebViewWidget.fromPlatformCreationParams( + params: platform is AndroidWebViewController + ? AndroidWebViewWidgetCreationParams( + controller: platform, + displayWithHybridComposition: true, + ) + : PlatformWebViewWidgetCreationParams(controller: platform), + ); + } + + Widget _buildError() { + return ColoredBox( + color: AppColor.white, + child: SafeArea( + child: Stack( + children: [ + Center( + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.wifi_off, + size: 56, + color: AppColor.textSecondary, + ), + const SizedBox(height: 16), + Text( + 'Halaman tidak bisa dimuat. Periksa koneksi internet kamu.', + style: AppStyle.md, + textAlign: TextAlign.center, + ), + const SizedBox(height: 16), + AppOutlineButton( + title: 'Coba lagi', + width: 160, + onPressed: _reload, + ), + ], + ), + ), + ), + // Tanpa AppBar, ini satu-satunya tombol keluar yang terlihat. + if (widget.fullscreen) + Positioned( + top: 4, + left: 4, + child: IconButton( + icon: const Icon(Icons.close), + tooltip: 'Tutup', + onPressed: () => context.router.pop(), + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/presentation/router/app_router.dart b/lib/presentation/router/app_router.dart index 001111b..808da99 100644 --- a/lib/presentation/router/app_router.dart +++ b/lib/presentation/router/app_router.dart @@ -26,6 +26,7 @@ class AppRouter extends RootStackRouter { AutoRoute(page: HomeRoute.page), AutoRoute(page: VoucherRoute.page), AutoRoute(page: OrderRoute.page), + AutoRoute(page: CommunityRoute.page), AutoRoute(page: ProfileRoute.page), ], ), @@ -42,6 +43,19 @@ class AppRouter extends RootStackRouter { AutoRoute(page: CoinHistoryRoute.page), AutoRoute(page: ProductRedeemRoute.page), + // Wallet (EnakPoint & EnakCoin) + AutoRoute(page: WalletRoute.page), + AutoRoute(page: WalletHistoryRoute.page), + AutoRoute(page: WalletExpiringRoute.page), + AutoRoute(page: PaymentCodeRoute.page), + AutoRoute(page: ExchangeRoute.page), + AutoRoute(page: TransferRoute.page), + + // PIN + AutoRoute(page: PinSettingsRoute.page), + AutoRoute(page: PinSetupRoute.page), + AutoRoute(page: PinChangeRoute.page), + // Draw AutoRoute(page: DrawRoute.page), AutoRoute( @@ -63,9 +77,25 @@ class AppRouter extends RootStackRouter { // Order AutoRoute(page: OrderDetailRoute.page), + // Outlet + AutoRoute(page: OutletRoute.page), + // Reward AutoRoute(page: RewardRoute.page), + // Promo + AutoRoute(page: PromoRoute.page), + AutoRoute(page: PromoDetailRoute.page), + + // News + AutoRoute(page: NewsRoute.page), + AutoRoute(page: NewsDetailRoute.page), + + // Shop + AutoRoute(page: ShopRoute.page), + AutoRoute(page: ShopCategoryRoute.page), + AutoRoute(page: ShopProductDetailRoute.page), + // Account AutoRoute(page: AccountMyRoute.page), AutoRoute(page: AddressRoute.page), @@ -75,11 +105,14 @@ class AppRouter extends RootStackRouter { AutoRoute(page: FerrisWheelRoute.page), AutoRoute(page: MisteryBoxRoute.page), - // Menu - AutoRoute(page: MenuRoute.page), - AutoRoute(page: MenuDetailRoute.page), + // Community (halaman utamanya tab di Main) + AutoRoute(page: CommunityDetailRoute.page), + AutoRoute(page: CommunityPostDetailRoute.page), - // Checkout - AutoRoute(page: CheckoutRoute.page), + // Coming Soon + AutoRoute(page: ComingSoonRoute.page), + + // WebView + AutoRoute(page: WebViewRoute.page), ]; } diff --git a/lib/presentation/router/app_router.gr.dart b/lib/presentation/router/app_router.gr.dart index 79ddcf8..0fd7d77 100644 --- a/lib/presentation/router/app_router.gr.dart +++ b/lib/presentation/router/app_router.gr.dart @@ -9,83 +9,115 @@ // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes -import 'package:auto_route/auto_route.dart' as _i38; -import 'package:enaklo/common/data/service_data.dart' as _i41; + +import 'package:auto_route/auto_route.dart' as _i57; +import 'package:enaklo/domain/wallet/wallet.dart' as _i62; import 'package:enaklo/presentation/pages/account/account_my/account_my_page.dart' as _i1; import 'package:enaklo/presentation/pages/account/address/address_page.dart' as _i2; import 'package:enaklo/presentation/pages/account/payment/payment_page.dart' - as _i28; + as _i34; import 'package:enaklo/presentation/pages/auth/create_password/create_password_page.dart' - as _i6; -import 'package:enaklo/presentation/pages/auth/login/login_page.dart' as _i15; -import 'package:enaklo/presentation/pages/auth/otp/otp_page.dart' as _i26; -import 'package:enaklo/presentation/pages/auth/password/password_page.dart' - as _i27; -import 'package:enaklo/presentation/pages/auth/pin/pin_page.dart' as _i29; -import 'package:enaklo/presentation/pages/auth/register/register_page.dart' - as _i33; -import 'package:enaklo/presentation/pages/checkout/checkout_page.dart' as _i3; -import 'package:enaklo/presentation/pages/coin/coin_page.dart' as _i5; -import 'package:enaklo/presentation/pages/coin/pages/coin_history_page.dart' - as _i4; -import 'package:enaklo/presentation/pages/coin/pages/product_redeem/product_redeem_page.dart' - as _i31; -import 'package:enaklo/presentation/pages/draw/draw_page.dart' as _i10; -import 'package:enaklo/presentation/pages/draw/pages/draw_detail/draw_detail_page.dart' - as _i7; -import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_info_page.dart' - as _i8; -import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_my_number_page.dart' as _i9; -import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_today_page.dart' - as _i11; -import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_winner_page.dart' - as _i12; -import 'package:enaklo/presentation/pages/main/main_page.dart' as _i16; -import 'package:enaklo/presentation/pages/main/pages/home/home_page.dart' - as _i14; -import 'package:enaklo/presentation/pages/main/pages/order/order_page.dart' - as _i25; -import 'package:enaklo/presentation/pages/main/pages/profile/profile_page.dart' +import 'package:enaklo/presentation/pages/auth/login/login_page.dart' as _i19; +import 'package:enaklo/presentation/pages/auth/otp/otp_page.dart' as _i30; +import 'package:enaklo/presentation/pages/auth/password/password_page.dart' as _i32; +import 'package:enaklo/presentation/pages/auth/pin/pin_page.dart' as _i36; +import 'package:enaklo/presentation/pages/auth/register/register_page.dart' + as _i44; +import 'package:enaklo/presentation/pages/coin/coin_page.dart' as _i4; +import 'package:enaklo/presentation/pages/coin/pages/coin_history_page.dart' + as _i3; +import 'package:enaklo/presentation/pages/coin/pages/product_redeem/product_redeem_page.dart' + as _i40; +import 'package:enaklo/presentation/pages/coming_soon/coming_soon_page.dart' + as _i5; +import 'package:enaklo/presentation/pages/community/community_page.dart' as _i7; +import 'package:enaklo/presentation/pages/community/pages/community_detail/community_detail_page.dart' + as _i6; +import 'package:enaklo/presentation/pages/community/pages/post_detail/community_post_detail_page.dart' + as _i8; +import 'package:enaklo/presentation/pages/draw/draw_page.dart' as _i13; +import 'package:enaklo/presentation/pages/draw/pages/draw_detail/draw_detail_page.dart' + as _i10; +import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_info_page.dart' + as _i11; +import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_my_number_page.dart' + as _i12; +import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_today_page.dart' + as _i14; +import 'package:enaklo/presentation/pages/draw/pages/draw_detail/pages/draw_winner_page.dart' + as _i15; +import 'package:enaklo/presentation/pages/main/main_page.dart' as _i20; +import 'package:enaklo/presentation/pages/main/pages/home/home_page.dart' + as _i18; +import 'package:enaklo/presentation/pages/main/pages/order/order_page.dart' + as _i29; +import 'package:enaklo/presentation/pages/main/pages/profile/profile_page.dart' + as _i41; import 'package:enaklo/presentation/pages/main/pages/voucher/voucher_page.dart' - as _i37; -import 'package:enaklo/presentation/pages/menu/menu_page.dart' as _i18; -import 'package:enaklo/presentation/pages/menu/pages/menu_detail/menu_detail_page.dart' - as _i17; -import 'package:enaklo/presentation/pages/merchant/merchant_page.dart' as _i20; + as _i52; +import 'package:enaklo/presentation/pages/merchant/merchant_page.dart' as _i22; import 'package:enaklo/presentation/pages/merchant/pages/merchant_detail/merchant_detail_page.dart' - as _i19; -import 'package:enaklo/presentation/pages/mini_games/ferris_wheel/ferris_wheel_page.dart' - as _i13; -import 'package:enaklo/presentation/pages/mini_games/mistery_box/mistery_box_page.dart' as _i21; -import 'package:enaklo/presentation/pages/notification/notification_page.dart' - as _i22; -import 'package:enaklo/presentation/pages/onboarding/onboarding_page.dart' +import 'package:enaklo/presentation/pages/mini_games/ferris_wheel/ferris_wheel_page.dart' + as _i17; +import 'package:enaklo/presentation/pages/mini_games/mistery_box/mistery_box_page.dart' as _i23; -import 'package:enaklo/presentation/pages/order/order_detail/order_detail_page.dart' +import 'package:enaklo/presentation/pages/news/news_page.dart' as _i25; +import 'package:enaklo/presentation/pages/news/pages/news_detail/news_detail_page.dart' as _i24; -import 'package:enaklo/presentation/pages/point/point_page.dart' as _i30; -import 'package:enaklo/presentation/pages/reward/reward_page.dart' as _i34; -import 'package:enaklo/presentation/pages/splash/splash_page.dart' as _i35; +import 'package:enaklo/presentation/pages/notification/notification_page.dart' + as _i26; +import 'package:enaklo/presentation/pages/onboarding/onboarding_page.dart' + as _i27; +import 'package:enaklo/presentation/pages/order/order_detail/order_detail_page.dart' + as _i28; +import 'package:enaklo/presentation/pages/outlet/outlet_page.dart' as _i31; +import 'package:enaklo/presentation/pages/pin/pin_change_page.dart' as _i35; +import 'package:enaklo/presentation/pages/pin/pin_settings_page.dart' as _i37; +import 'package:enaklo/presentation/pages/pin/pin_setup_page.dart' as _i38; +import 'package:enaklo/presentation/pages/point/point_page.dart' as _i39; +import 'package:enaklo/presentation/pages/promo/pages/promo_detail/promo_detail_page.dart' + as _i42; +import 'package:enaklo/presentation/pages/promo/promo_page.dart' as _i43; +import 'package:enaklo/presentation/pages/reward/reward_page.dart' as _i45; +import 'package:enaklo/presentation/pages/shop/pages/shop_category/shop_category_page.dart' + as _i46; +import 'package:enaklo/presentation/pages/shop/pages/shop_product_detail/shop_product_detail_page.dart' + as _i48; +import 'package:enaklo/presentation/pages/shop/shop_page.dart' as _i47; +import 'package:enaklo/presentation/pages/splash/splash_page.dart' as _i49; import 'package:enaklo/presentation/pages/voucher/voucher_detail/voucher_detail_page.dart' - as _i36; -import 'package:enaklo/sample/product_sample_data.dart' as _i40; -import 'package:enaklo/sample/sample_data.dart' as _i42; -import 'package:flutter/material.dart' as _i39; + as _i51; +import 'package:enaklo/presentation/pages/wallet/exchange_page.dart' as _i16; +import 'package:enaklo/presentation/pages/wallet/payment_code_page.dart' + as _i33; +import 'package:enaklo/presentation/pages/wallet/transfer_page.dart' as _i50; +import 'package:enaklo/presentation/pages/wallet/wallet_expiring_page.dart' + as _i53; +import 'package:enaklo/presentation/pages/wallet/wallet_history_page.dart' + as _i54; +import 'package:enaklo/presentation/pages/wallet/wallet_page.dart' as _i55; +import 'package:enaklo/presentation/pages/webview/webview_page.dart' as _i56; +import 'package:enaklo/sample/community_sample_data.dart' as _i59; +import 'package:enaklo/sample/news_sample_data.dart' as _i61; +import 'package:enaklo/sample/promo_sample_data.dart' as _i63; +import 'package:enaklo/sample/sample_data.dart' as _i60; +import 'package:enaklo/sample/shop_sample_data.dart' as _i64; +import 'package:flutter/material.dart' as _i58; /// generated route for /// [_i1.AccountMyPage] -class AccountMyRoute extends _i38.PageRouteInfo { - const AccountMyRoute({List<_i38.PageRouteInfo>? children}) +class AccountMyRoute extends _i57.PageRouteInfo { + const AccountMyRoute({List<_i57.PageRouteInfo>? children}) : super(AccountMyRoute.name, initialChildren: children); static const String name = 'AccountMyRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { return const _i1.AccountMyPage(); @@ -95,13 +127,13 @@ class AccountMyRoute extends _i38.PageRouteInfo { /// generated route for /// [_i2.AddressPage] -class AddressRoute extends _i38.PageRouteInfo { - const AddressRoute({List<_i38.PageRouteInfo>? children}) +class AddressRoute extends _i57.PageRouteInfo { + const AddressRoute({List<_i57.PageRouteInfo>? children}) : super(AddressRoute.name, initialChildren: children); static const String name = 'AddressRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { return const _i2.AddressPage(); @@ -110,60 +142,212 @@ class AddressRoute extends _i38.PageRouteInfo { } /// generated route for -/// [_i3.CheckoutPage] -class CheckoutRoute extends _i38.PageRouteInfo { - const CheckoutRoute({List<_i38.PageRouteInfo>? children}) - : super(CheckoutRoute.name, initialChildren: children); - - static const String name = 'CheckoutRoute'; - - static _i38.PageInfo page = _i38.PageInfo( - name, - builder: (data) { - return const _i3.CheckoutPage(); - }, - ); -} - -/// generated route for -/// [_i4.CoinHistoryPage] -class CoinHistoryRoute extends _i38.PageRouteInfo { - const CoinHistoryRoute({List<_i38.PageRouteInfo>? children}) +/// [_i3.CoinHistoryPage] +class CoinHistoryRoute extends _i57.PageRouteInfo { + const CoinHistoryRoute({List<_i57.PageRouteInfo>? children}) : super(CoinHistoryRoute.name, initialChildren: children); static const String name = 'CoinHistoryRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i4.CoinHistoryPage(); + return const _i3.CoinHistoryPage(); }, ); } /// generated route for -/// [_i5.CoinPage] -class CoinRoute extends _i38.PageRouteInfo { - const CoinRoute({List<_i38.PageRouteInfo>? children}) +/// [_i4.CoinPage] +class CoinRoute extends _i57.PageRouteInfo { + const CoinRoute({List<_i57.PageRouteInfo>? children}) : super(CoinRoute.name, initialChildren: children); static const String name = 'CoinRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i5.CoinPage(); + return const _i4.CoinPage(); }, ); } /// generated route for -/// [_i6.CreatePasswordPage] -class CreatePasswordRoute extends _i38.PageRouteInfo { +/// [_i5.ComingSoonPage] +class ComingSoonRoute extends _i57.PageRouteInfo { + ComingSoonRoute({ + _i58.Key? key, + required String title, + String? iconPath, + List<_i57.PageRouteInfo>? children, + }) : super( + ComingSoonRoute.name, + args: ComingSoonRouteArgs(key: key, title: title, iconPath: iconPath), + initialChildren: children, + ); + + static const String name = 'ComingSoonRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i5.ComingSoonPage( + key: args.key, + title: args.title, + iconPath: args.iconPath, + ); + }, + ); +} + +class ComingSoonRouteArgs { + const ComingSoonRouteArgs({this.key, required this.title, this.iconPath}); + + final _i58.Key? key; + + final String title; + + final String? iconPath; + + @override + String toString() { + return 'ComingSoonRouteArgs{key: $key, title: $title, iconPath: $iconPath}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! ComingSoonRouteArgs) return false; + return key == other.key && + title == other.title && + iconPath == other.iconPath; + } + + @override + int get hashCode => key.hashCode ^ title.hashCode ^ iconPath.hashCode; +} + +/// generated route for +/// [_i6.CommunityDetailPage] +class CommunityDetailRoute + extends _i57.PageRouteInfo { + CommunityDetailRoute({ + _i58.Key? key, + required _i59.CommunityGroup group, + List<_i57.PageRouteInfo>? children, + }) : super( + CommunityDetailRoute.name, + args: CommunityDetailRouteArgs(key: key, group: group), + initialChildren: children, + ); + + static const String name = 'CommunityDetailRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i6.CommunityDetailPage(key: args.key, group: args.group); + }, + ); +} + +class CommunityDetailRouteArgs { + const CommunityDetailRouteArgs({this.key, required this.group}); + + final _i58.Key? key; + + final _i59.CommunityGroup group; + + @override + String toString() { + return 'CommunityDetailRouteArgs{key: $key, group: $group}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! CommunityDetailRouteArgs) return false; + return key == other.key && group == other.group; + } + + @override + int get hashCode => key.hashCode ^ group.hashCode; +} + +/// generated route for +/// [_i7.CommunityPage] +class CommunityRoute extends _i57.PageRouteInfo { + const CommunityRoute({List<_i57.PageRouteInfo>? children}) + : super(CommunityRoute.name, initialChildren: children); + + static const String name = 'CommunityRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i7.CommunityPage(); + }, + ); +} + +/// generated route for +/// [_i8.CommunityPostDetailPage] +class CommunityPostDetailRoute + extends _i57.PageRouteInfo { + CommunityPostDetailRoute({ + _i58.Key? key, + required _i59.CommunityPost post, + List<_i57.PageRouteInfo>? children, + }) : super( + CommunityPostDetailRoute.name, + args: CommunityPostDetailRouteArgs(key: key, post: post), + initialChildren: children, + ); + + static const String name = 'CommunityPostDetailRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i8.CommunityPostDetailPage(key: args.key, post: args.post); + }, + ); +} + +class CommunityPostDetailRouteArgs { + const CommunityPostDetailRouteArgs({this.key, required this.post}); + + final _i58.Key? key; + + final _i59.CommunityPost post; + + @override + String toString() { + return 'CommunityPostDetailRouteArgs{key: $key, post: $post}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! CommunityPostDetailRouteArgs) return false; + return key == other.key && post == other.post; + } + + @override + int get hashCode => key.hashCode ^ post.hashCode; +} + +/// generated route for +/// [_i9.CreatePasswordPage] +class CreatePasswordRoute extends _i57.PageRouteInfo { CreatePasswordRoute({ - _i39.Key? key, + _i58.Key? key, required String registrationToken, - List<_i38.PageRouteInfo>? children, + List<_i57.PageRouteInfo>? children, }) : super( CreatePasswordRoute.name, args: CreatePasswordRouteArgs( @@ -175,12 +359,12 @@ class CreatePasswordRoute extends _i38.PageRouteInfo { static const String name = 'CreatePasswordRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i38.WrappedRoute( - child: _i6.CreatePasswordPage( + return _i57.WrappedRoute( + child: _i9.CreatePasswordPage( key: args.key, registrationToken: args.registrationToken, ), @@ -192,7 +376,7 @@ class CreatePasswordRoute extends _i38.PageRouteInfo { class CreatePasswordRouteArgs { const CreatePasswordRouteArgs({this.key, required this.registrationToken}); - final _i39.Key? key; + final _i58.Key? key; final String registrationToken; @@ -200,249 +384,201 @@ class CreatePasswordRouteArgs { String toString() { return 'CreatePasswordRouteArgs{key: $key, registrationToken: $registrationToken}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! CreatePasswordRouteArgs) return false; + return key == other.key && registrationToken == other.registrationToken; + } + + @override + int get hashCode => key.hashCode ^ registrationToken.hashCode; } /// generated route for -/// [_i7.DrawDetailPage] -class DrawDetailRoute extends _i38.PageRouteInfo { - const DrawDetailRoute({List<_i38.PageRouteInfo>? children}) +/// [_i10.DrawDetailPage] +class DrawDetailRoute extends _i57.PageRouteInfo { + const DrawDetailRoute({List<_i57.PageRouteInfo>? children}) : super(DrawDetailRoute.name, initialChildren: children); static const String name = 'DrawDetailRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i7.DrawDetailPage(); + return const _i10.DrawDetailPage(); }, ); } /// generated route for -/// [_i8.DrawInfoPage] -class DrawInfoRoute extends _i38.PageRouteInfo { - const DrawInfoRoute({List<_i38.PageRouteInfo>? children}) +/// [_i11.DrawInfoPage] +class DrawInfoRoute extends _i57.PageRouteInfo { + const DrawInfoRoute({List<_i57.PageRouteInfo>? children}) : super(DrawInfoRoute.name, initialChildren: children); static const String name = 'DrawInfoRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i8.DrawInfoPage(); + return const _i11.DrawInfoPage(); }, ); } /// generated route for -/// [_i9.DrawMyNumberPage] -class DrawMyNumberRoute extends _i38.PageRouteInfo { - const DrawMyNumberRoute({List<_i38.PageRouteInfo>? children}) +/// [_i12.DrawMyNumberPage] +class DrawMyNumberRoute extends _i57.PageRouteInfo { + const DrawMyNumberRoute({List<_i57.PageRouteInfo>? children}) : super(DrawMyNumberRoute.name, initialChildren: children); static const String name = 'DrawMyNumberRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i9.DrawMyNumberPage(); + return const _i12.DrawMyNumberPage(); }, ); } /// generated route for -/// [_i10.DrawPage] -class DrawRoute extends _i38.PageRouteInfo { - const DrawRoute({List<_i38.PageRouteInfo>? children}) +/// [_i13.DrawPage] +class DrawRoute extends _i57.PageRouteInfo { + const DrawRoute({List<_i57.PageRouteInfo>? children}) : super(DrawRoute.name, initialChildren: children); static const String name = 'DrawRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i10.DrawPage(); + return const _i13.DrawPage(); }, ); } /// generated route for -/// [_i11.DrawTodayPage] -class DrawTodayRoute extends _i38.PageRouteInfo { - const DrawTodayRoute({List<_i38.PageRouteInfo>? children}) +/// [_i14.DrawTodayPage] +class DrawTodayRoute extends _i57.PageRouteInfo { + const DrawTodayRoute({List<_i57.PageRouteInfo>? children}) : super(DrawTodayRoute.name, initialChildren: children); static const String name = 'DrawTodayRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i11.DrawTodayPage(); + return const _i14.DrawTodayPage(); }, ); } /// generated route for -/// [_i12.DrawWinnerPage] -class DrawWinnerRoute extends _i38.PageRouteInfo { - const DrawWinnerRoute({List<_i38.PageRouteInfo>? children}) +/// [_i15.DrawWinnerPage] +class DrawWinnerRoute extends _i57.PageRouteInfo { + const DrawWinnerRoute({List<_i57.PageRouteInfo>? children}) : super(DrawWinnerRoute.name, initialChildren: children); static const String name = 'DrawWinnerRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i12.DrawWinnerPage(); + return const _i15.DrawWinnerPage(); }, ); } /// generated route for -/// [_i13.FerrisWheelPage] -class FerrisWheelRoute extends _i38.PageRouteInfo { - const FerrisWheelRoute({List<_i38.PageRouteInfo>? children}) +/// [_i16.ExchangePage] +class ExchangeRoute extends _i57.PageRouteInfo { + const ExchangeRoute({List<_i57.PageRouteInfo>? children}) + : super(ExchangeRoute.name, initialChildren: children); + + static const String name = 'ExchangeRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return _i57.WrappedRoute(child: const _i16.ExchangePage()); + }, + ); +} + +/// generated route for +/// [_i17.FerrisWheelPage] +class FerrisWheelRoute extends _i57.PageRouteInfo { + const FerrisWheelRoute({List<_i57.PageRouteInfo>? children}) : super(FerrisWheelRoute.name, initialChildren: children); static const String name = 'FerrisWheelRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return _i38.WrappedRoute(child: const _i13.FerrisWheelPage()); + return _i57.WrappedRoute(child: const _i17.FerrisWheelPage()); }, ); } /// generated route for -/// [_i14.HomePage] -class HomeRoute extends _i38.PageRouteInfo { - const HomeRoute({List<_i38.PageRouteInfo>? children}) +/// [_i18.HomePage] +class HomeRoute extends _i57.PageRouteInfo { + const HomeRoute({List<_i57.PageRouteInfo>? children}) : super(HomeRoute.name, initialChildren: children); static const String name = 'HomeRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i14.HomePage(); + return const _i18.HomePage(); }, ); } /// generated route for -/// [_i15.LoginPage] -class LoginRoute extends _i38.PageRouteInfo { - const LoginRoute({List<_i38.PageRouteInfo>? children}) +/// [_i19.LoginPage] +class LoginRoute extends _i57.PageRouteInfo { + const LoginRoute({List<_i57.PageRouteInfo>? children}) : super(LoginRoute.name, initialChildren: children); static const String name = 'LoginRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return _i38.WrappedRoute(child: const _i15.LoginPage()); + return _i57.WrappedRoute(child: const _i19.LoginPage()); }, ); } /// generated route for -/// [_i16.MainPage] -class MainRoute extends _i38.PageRouteInfo { - const MainRoute({List<_i38.PageRouteInfo>? children}) +/// [_i20.MainPage] +class MainRoute extends _i57.PageRouteInfo { + const MainRoute({List<_i57.PageRouteInfo>? children}) : super(MainRoute.name, initialChildren: children); static const String name = 'MainRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i16.MainPage(); + return const _i20.MainPage(); }, ); } /// generated route for -/// [_i17.MenuDetailPage] -class MenuDetailRoute extends _i38.PageRouteInfo { - MenuDetailRoute({ - _i39.Key? key, - required _i40.Product product, - List<_i38.PageRouteInfo>? children, - }) : super( - MenuDetailRoute.name, - args: MenuDetailRouteArgs(key: key, product: product), - initialChildren: children, - ); - - static const String name = 'MenuDetailRoute'; - - static _i38.PageInfo page = _i38.PageInfo( - name, - builder: (data) { - final args = data.argsAs(); - return _i17.MenuDetailPage(key: args.key, product: args.product); - }, - ); -} - -class MenuDetailRouteArgs { - const MenuDetailRouteArgs({this.key, required this.product}); - - final _i39.Key? key; - - final _i40.Product product; - - @override - String toString() { - return 'MenuDetailRouteArgs{key: $key, product: $product}'; - } -} - -/// generated route for -/// [_i18.MenuPage] -class MenuRoute extends _i38.PageRouteInfo { - MenuRoute({ - _i39.Key? key, - required _i41.Service service, - List<_i38.PageRouteInfo>? children, - }) : super( - MenuRoute.name, - args: MenuRouteArgs(key: key, service: service), - initialChildren: children, - ); - - static const String name = 'MenuRoute'; - - static _i38.PageInfo page = _i38.PageInfo( - name, - builder: (data) { - final args = data.argsAs(); - return _i18.MenuPage(key: args.key, service: args.service); - }, - ); -} - -class MenuRouteArgs { - const MenuRouteArgs({this.key, required this.service}); - - final _i39.Key? key; - - final _i41.Service service; - - @override - String toString() { - return 'MenuRouteArgs{key: $key, service: $service}'; - } -} - -/// generated route for -/// [_i19.MerchantDetailPage] -class MerchantDetailRoute extends _i38.PageRouteInfo { +/// [_i21.MerchantDetailPage] +class MerchantDetailRoute extends _i57.PageRouteInfo { MerchantDetailRoute({ - _i39.Key? key, - required _i42.MerchantModel merchant, - List<_i38.PageRouteInfo>? children, + _i58.Key? key, + required _i60.MerchantModel merchant, + List<_i57.PageRouteInfo>? children, }) : super( MerchantDetailRoute.name, args: MerchantDetailRouteArgs(key: key, merchant: merchant), @@ -451,11 +587,11 @@ class MerchantDetailRoute extends _i38.PageRouteInfo { static const String name = 'MerchantDetailRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i19.MerchantDetailPage(key: args.key, merchant: args.merchant); + return _i21.MerchantDetailPage(key: args.key, merchant: args.merchant); }, ); } @@ -463,87 +599,160 @@ class MerchantDetailRoute extends _i38.PageRouteInfo { class MerchantDetailRouteArgs { const MerchantDetailRouteArgs({this.key, required this.merchant}); - final _i39.Key? key; + final _i58.Key? key; - final _i42.MerchantModel merchant; + final _i60.MerchantModel merchant; @override String toString() { return 'MerchantDetailRouteArgs{key: $key, merchant: $merchant}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! MerchantDetailRouteArgs) return false; + return key == other.key && merchant == other.merchant; + } + + @override + int get hashCode => key.hashCode ^ merchant.hashCode; } /// generated route for -/// [_i20.MerchantPage] -class MerchantRoute extends _i38.PageRouteInfo { - const MerchantRoute({List<_i38.PageRouteInfo>? children}) +/// [_i22.MerchantPage] +class MerchantRoute extends _i57.PageRouteInfo { + const MerchantRoute({List<_i57.PageRouteInfo>? children}) : super(MerchantRoute.name, initialChildren: children); static const String name = 'MerchantRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i20.MerchantPage(); + return const _i22.MerchantPage(); }, ); } /// generated route for -/// [_i21.MisteryBoxPage] -class MisteryBoxRoute extends _i38.PageRouteInfo { - const MisteryBoxRoute({List<_i38.PageRouteInfo>? children}) +/// [_i23.MisteryBoxPage] +class MisteryBoxRoute extends _i57.PageRouteInfo { + const MisteryBoxRoute({List<_i57.PageRouteInfo>? children}) : super(MisteryBoxRoute.name, initialChildren: children); static const String name = 'MisteryBoxRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i21.MisteryBoxPage(); + return const _i23.MisteryBoxPage(); }, ); } /// generated route for -/// [_i22.NotificationPage] -class NotificationRoute extends _i38.PageRouteInfo { - const NotificationRoute({List<_i38.PageRouteInfo>? children}) +/// [_i24.NewsDetailPage] +class NewsDetailRoute extends _i57.PageRouteInfo { + NewsDetailRoute({ + _i58.Key? key, + required _i61.NewsArticle article, + List<_i57.PageRouteInfo>? children, + }) : super( + NewsDetailRoute.name, + args: NewsDetailRouteArgs(key: key, article: article), + initialChildren: children, + ); + + static const String name = 'NewsDetailRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i24.NewsDetailPage(key: args.key, article: args.article); + }, + ); +} + +class NewsDetailRouteArgs { + const NewsDetailRouteArgs({this.key, required this.article}); + + final _i58.Key? key; + + final _i61.NewsArticle article; + + @override + String toString() { + return 'NewsDetailRouteArgs{key: $key, article: $article}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! NewsDetailRouteArgs) return false; + return key == other.key && article == other.article; + } + + @override + int get hashCode => key.hashCode ^ article.hashCode; +} + +/// generated route for +/// [_i25.NewsPage] +class NewsRoute extends _i57.PageRouteInfo { + const NewsRoute({List<_i57.PageRouteInfo>? children}) + : super(NewsRoute.name, initialChildren: children); + + static const String name = 'NewsRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i25.NewsPage(); + }, + ); +} + +/// generated route for +/// [_i26.NotificationPage] +class NotificationRoute extends _i57.PageRouteInfo { + const NotificationRoute({List<_i57.PageRouteInfo>? children}) : super(NotificationRoute.name, initialChildren: children); static const String name = 'NotificationRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i22.NotificationPage(); + return const _i26.NotificationPage(); }, ); } /// generated route for -/// [_i23.OnboardingPage] -class OnboardingRoute extends _i38.PageRouteInfo { - const OnboardingRoute({List<_i38.PageRouteInfo>? children}) +/// [_i27.OnboardingPage] +class OnboardingRoute extends _i57.PageRouteInfo { + const OnboardingRoute({List<_i57.PageRouteInfo>? children}) : super(OnboardingRoute.name, initialChildren: children); static const String name = 'OnboardingRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i23.OnboardingPage(); + return const _i27.OnboardingPage(); }, ); } /// generated route for -/// [_i24.OrderDetailPage] -class OrderDetailRoute extends _i38.PageRouteInfo { +/// [_i28.OrderDetailPage] +class OrderDetailRoute extends _i57.PageRouteInfo { OrderDetailRoute({ - _i39.Key? key, - required _i25.Order order, - List<_i38.PageRouteInfo>? children, + _i58.Key? key, + required _i62.CustomerOrder order, + List<_i57.PageRouteInfo>? children, }) : super( OrderDetailRoute.name, args: OrderDetailRouteArgs(key: key, order: order), @@ -552,11 +761,13 @@ class OrderDetailRoute extends _i38.PageRouteInfo { static const String name = 'OrderDetailRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i24.OrderDetailPage(key: args.key, order: args.order); + return _i57.WrappedRoute( + child: _i28.OrderDetailPage(key: args.key, order: args.order), + ); }, ); } @@ -564,40 +775,50 @@ class OrderDetailRoute extends _i38.PageRouteInfo { class OrderDetailRouteArgs { const OrderDetailRouteArgs({this.key, required this.order}); - final _i39.Key? key; + final _i58.Key? key; - final _i25.Order order; + final _i62.CustomerOrder order; @override String toString() { return 'OrderDetailRouteArgs{key: $key, order: $order}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! OrderDetailRouteArgs) return false; + return key == other.key && order == other.order; + } + + @override + int get hashCode => key.hashCode ^ order.hashCode; } /// generated route for -/// [_i25.OrderPage] -class OrderRoute extends _i38.PageRouteInfo { - const OrderRoute({List<_i38.PageRouteInfo>? children}) +/// [_i29.OrderPage] +class OrderRoute extends _i57.PageRouteInfo { + const OrderRoute({List<_i57.PageRouteInfo>? children}) : super(OrderRoute.name, initialChildren: children); static const String name = 'OrderRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i25.OrderPage(); + return _i57.WrappedRoute(child: const _i29.OrderPage()); }, ); } /// generated route for -/// [_i26.OtpPage] -class OtpRoute extends _i38.PageRouteInfo { +/// [_i30.OtpPage] +class OtpRoute extends _i57.PageRouteInfo { OtpRoute({ - _i39.Key? key, + _i58.Key? key, required String registrationToken, required String phoneNumber, - List<_i38.PageRouteInfo>? children, + List<_i57.PageRouteInfo>? children, }) : super( OtpRoute.name, args: OtpRouteArgs( @@ -610,12 +831,12 @@ class OtpRoute extends _i38.PageRouteInfo { static const String name = 'OtpRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i38.WrappedRoute( - child: _i26.OtpPage( + return _i57.WrappedRoute( + child: _i30.OtpPage( key: args.key, registrationToken: args.registrationToken, phoneNumber: args.phoneNumber, @@ -632,7 +853,7 @@ class OtpRouteArgs { required this.phoneNumber, }); - final _i39.Key? key; + final _i58.Key? key; final String registrationToken; @@ -642,15 +863,44 @@ class OtpRouteArgs { String toString() { return 'OtpRouteArgs{key: $key, registrationToken: $registrationToken, phoneNumber: $phoneNumber}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! OtpRouteArgs) return false; + return key == other.key && + registrationToken == other.registrationToken && + phoneNumber == other.phoneNumber; + } + + @override + int get hashCode => + key.hashCode ^ registrationToken.hashCode ^ phoneNumber.hashCode; } /// generated route for -/// [_i27.PasswordPage] -class PasswordRoute extends _i38.PageRouteInfo { +/// [_i31.OutletPage] +class OutletRoute extends _i57.PageRouteInfo { + const OutletRoute({List<_i57.PageRouteInfo>? children}) + : super(OutletRoute.name, initialChildren: children); + + static const String name = 'OutletRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i31.OutletPage(); + }, + ); +} + +/// generated route for +/// [_i32.PasswordPage] +class PasswordRoute extends _i57.PageRouteInfo { PasswordRoute({ - _i39.Key? key, + _i58.Key? key, required String phoneNumber, - List<_i38.PageRouteInfo>? children, + List<_i57.PageRouteInfo>? children, }) : super( PasswordRoute.name, args: PasswordRouteArgs(key: key, phoneNumber: phoneNumber), @@ -659,12 +909,12 @@ class PasswordRoute extends _i38.PageRouteInfo { static const String name = 'PasswordRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i38.WrappedRoute( - child: _i27.PasswordPage(key: args.key, phoneNumber: args.phoneNumber), + return _i57.WrappedRoute( + child: _i32.PasswordPage(key: args.key, phoneNumber: args.phoneNumber), ); }, ); @@ -673,7 +923,7 @@ class PasswordRoute extends _i38.PageRouteInfo { class PasswordRouteArgs { const PasswordRouteArgs({this.key, required this.phoneNumber}); - final _i39.Key? key; + final _i58.Key? key; final String phoneNumber; @@ -681,32 +931,74 @@ class PasswordRouteArgs { String toString() { return 'PasswordRouteArgs{key: $key, phoneNumber: $phoneNumber}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! PasswordRouteArgs) return false; + return key == other.key && phoneNumber == other.phoneNumber; + } + + @override + int get hashCode => key.hashCode ^ phoneNumber.hashCode; } /// generated route for -/// [_i28.PaymentPage] -class PaymentRoute extends _i38.PageRouteInfo { - const PaymentRoute({List<_i38.PageRouteInfo>? children}) - : super(PaymentRoute.name, initialChildren: children); +/// [_i33.PaymentCodePage] +class PaymentCodeRoute extends _i57.PageRouteInfo { + const PaymentCodeRoute({List<_i57.PageRouteInfo>? children}) + : super(PaymentCodeRoute.name, initialChildren: children); - static const String name = 'PaymentRoute'; + static const String name = 'PaymentCodeRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i28.PaymentPage(); + return _i57.WrappedRoute(child: const _i33.PaymentCodePage()); }, ); } /// generated route for -/// [_i29.PinPage] -class PinRoute extends _i38.PageRouteInfo { +/// [_i34.PaymentPage] +class PaymentRoute extends _i57.PageRouteInfo { + const PaymentRoute({List<_i57.PageRouteInfo>? children}) + : super(PaymentRoute.name, initialChildren: children); + + static const String name = 'PaymentRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i34.PaymentPage(); + }, + ); +} + +/// generated route for +/// [_i35.PinChangePage] +class PinChangeRoute extends _i57.PageRouteInfo { + const PinChangeRoute({List<_i57.PageRouteInfo>? children}) + : super(PinChangeRoute.name, initialChildren: children); + + static const String name = 'PinChangeRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return _i57.WrappedRoute(child: const _i35.PinChangePage()); + }, + ); +} + +/// generated route for +/// [_i36.PinPage] +class PinRoute extends _i57.PageRouteInfo { PinRoute({ - _i39.Key? key, + _i58.Key? key, bool isCreatePin = true, String? title, - List<_i38.PageRouteInfo>? children, + List<_i57.PageRouteInfo>? children, }) : super( PinRoute.name, args: PinRouteArgs(key: key, isCreatePin: isCreatePin, title: title), @@ -715,13 +1007,13 @@ class PinRoute extends _i38.PageRouteInfo { static const String name = 'PinRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs( orElse: () => const PinRouteArgs(), ); - return _i29.PinPage( + return _i36.PinPage( key: args.key, isCreatePin: args.isCreatePin, title: args.title, @@ -733,7 +1025,7 @@ class PinRoute extends _i38.PageRouteInfo { class PinRouteArgs { const PinRouteArgs({this.key, this.isCreatePin = true, this.title}); - final _i39.Key? key; + final _i58.Key? key; final bool isCreatePin; @@ -743,32 +1035,109 @@ class PinRouteArgs { String toString() { return 'PinRouteArgs{key: $key, isCreatePin: $isCreatePin, title: $title}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! PinRouteArgs) return false; + return key == other.key && + isCreatePin == other.isCreatePin && + title == other.title; + } + + @override + int get hashCode => key.hashCode ^ isCreatePin.hashCode ^ title.hashCode; } /// generated route for -/// [_i30.PointPage] -class PointRoute extends _i38.PageRouteInfo { - const PointRoute({List<_i38.PageRouteInfo>? children}) - : super(PointRoute.name, initialChildren: children); +/// [_i37.PinSettingsPage] +class PinSettingsRoute extends _i57.PageRouteInfo { + const PinSettingsRoute({List<_i57.PageRouteInfo>? children}) + : super(PinSettingsRoute.name, initialChildren: children); - static const String name = 'PointRoute'; + static const String name = 'PinSettingsRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i30.PointPage(); + return const _i37.PinSettingsPage(); }, ); } /// generated route for -/// [_i31.ProductRedeemPage] -class ProductRedeemRoute extends _i38.PageRouteInfo { +/// [_i38.PinSetupPage] +class PinSetupRoute extends _i57.PageRouteInfo { + PinSetupRoute({ + _i58.Key? key, + required _i62.PinOtpPurpose purpose, + List<_i57.PageRouteInfo>? children, + }) : super( + PinSetupRoute.name, + args: PinSetupRouteArgs(key: key, purpose: purpose), + initialChildren: children, + ); + + static const String name = 'PinSetupRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i57.WrappedRoute( + child: _i38.PinSetupPage(key: args.key, purpose: args.purpose), + ); + }, + ); +} + +class PinSetupRouteArgs { + const PinSetupRouteArgs({this.key, required this.purpose}); + + final _i58.Key? key; + + final _i62.PinOtpPurpose purpose; + + @override + String toString() { + return 'PinSetupRouteArgs{key: $key, purpose: $purpose}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! PinSetupRouteArgs) return false; + return key == other.key && purpose == other.purpose; + } + + @override + int get hashCode => key.hashCode ^ purpose.hashCode; +} + +/// generated route for +/// [_i39.PointPage] +class PointRoute extends _i57.PageRouteInfo { + const PointRoute({List<_i57.PageRouteInfo>? children}) + : super(PointRoute.name, initialChildren: children); + + static const String name = 'PointRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i39.PointPage(); + }, + ); +} + +/// generated route for +/// [_i40.ProductRedeemPage] +class ProductRedeemRoute extends _i57.PageRouteInfo { ProductRedeemRoute({ - _i39.Key? key, - required _i5.Product product, - required _i5.PointCard pointCard, - List<_i38.PageRouteInfo>? children, + _i58.Key? key, + required _i4.Product product, + required _i4.PointCard pointCard, + List<_i57.PageRouteInfo>? children, }) : super( ProductRedeemRoute.name, args: ProductRedeemRouteArgs( @@ -781,11 +1150,11 @@ class ProductRedeemRoute extends _i38.PageRouteInfo { static const String name = 'ProductRedeemRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i31.ProductRedeemPage( + return _i40.ProductRedeemPage( key: args.key, product: args.product, pointCard: args.pointCard, @@ -801,41 +1170,116 @@ class ProductRedeemRouteArgs { required this.pointCard, }); - final _i39.Key? key; + final _i58.Key? key; - final _i5.Product product; + final _i4.Product product; - final _i5.PointCard pointCard; + final _i4.PointCard pointCard; @override String toString() { return 'ProductRedeemRouteArgs{key: $key, product: $product, pointCard: $pointCard}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! ProductRedeemRouteArgs) return false; + return key == other.key && + product == other.product && + pointCard == other.pointCard; + } + + @override + int get hashCode => key.hashCode ^ product.hashCode ^ pointCard.hashCode; } /// generated route for -/// [_i32.ProfilePage] -class ProfileRoute extends _i38.PageRouteInfo { - const ProfileRoute({List<_i38.PageRouteInfo>? children}) +/// [_i41.ProfilePage] +class ProfileRoute extends _i57.PageRouteInfo { + const ProfileRoute({List<_i57.PageRouteInfo>? children}) : super(ProfileRoute.name, initialChildren: children); static const String name = 'ProfileRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return _i38.WrappedRoute(child: const _i32.ProfilePage()); + return _i57.WrappedRoute(child: const _i41.ProfilePage()); }, ); } /// generated route for -/// [_i33.RegisterPage] -class RegisterRoute extends _i38.PageRouteInfo { +/// [_i42.PromoDetailPage] +class PromoDetailRoute extends _i57.PageRouteInfo { + PromoDetailRoute({ + _i58.Key? key, + required _i63.Promo promo, + List<_i57.PageRouteInfo>? children, + }) : super( + PromoDetailRoute.name, + args: PromoDetailRouteArgs(key: key, promo: promo), + initialChildren: children, + ); + + static const String name = 'PromoDetailRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i42.PromoDetailPage(key: args.key, promo: args.promo); + }, + ); +} + +class PromoDetailRouteArgs { + const PromoDetailRouteArgs({this.key, required this.promo}); + + final _i58.Key? key; + + final _i63.Promo promo; + + @override + String toString() { + return 'PromoDetailRouteArgs{key: $key, promo: $promo}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! PromoDetailRouteArgs) return false; + return key == other.key && promo == other.promo; + } + + @override + int get hashCode => key.hashCode ^ promo.hashCode; +} + +/// generated route for +/// [_i43.PromoPage] +class PromoRoute extends _i57.PageRouteInfo { + const PromoRoute({List<_i57.PageRouteInfo>? children}) + : super(PromoRoute.name, initialChildren: children); + + static const String name = 'PromoRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i43.PromoPage(); + }, + ); +} + +/// generated route for +/// [_i44.RegisterPage] +class RegisterRoute extends _i57.PageRouteInfo { RegisterRoute({ - _i39.Key? key, + _i58.Key? key, required String phoneNumber, - List<_i38.PageRouteInfo>? children, + List<_i57.PageRouteInfo>? children, }) : super( RegisterRoute.name, args: RegisterRouteArgs(key: key, phoneNumber: phoneNumber), @@ -844,12 +1288,12 @@ class RegisterRoute extends _i38.PageRouteInfo { static const String name = 'RegisterRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { final args = data.argsAs(); - return _i38.WrappedRoute( - child: _i33.RegisterPage(key: args.key, phoneNumber: args.phoneNumber), + return _i57.WrappedRoute( + child: _i44.RegisterPage(key: args.key, phoneNumber: args.phoneNumber), ); }, ); @@ -858,7 +1302,7 @@ class RegisterRoute extends _i38.PageRouteInfo { class RegisterRouteArgs { const RegisterRouteArgs({this.key, required this.phoneNumber}); - final _i39.Key? key; + final _i58.Key? key; final String phoneNumber; @@ -866,68 +1310,399 @@ class RegisterRouteArgs { String toString() { return 'RegisterRouteArgs{key: $key, phoneNumber: $phoneNumber}'; } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! RegisterRouteArgs) return false; + return key == other.key && phoneNumber == other.phoneNumber; + } + + @override + int get hashCode => key.hashCode ^ phoneNumber.hashCode; } /// generated route for -/// [_i34.RewardPage] -class RewardRoute extends _i38.PageRouteInfo { - const RewardRoute({List<_i38.PageRouteInfo>? children}) +/// [_i45.RewardPage] +class RewardRoute extends _i57.PageRouteInfo { + const RewardRoute({List<_i57.PageRouteInfo>? children}) : super(RewardRoute.name, initialChildren: children); static const String name = 'RewardRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i34.RewardPage(); + return const _i45.RewardPage(); }, ); } /// generated route for -/// [_i35.SplashPage] -class SplashRoute extends _i38.PageRouteInfo { - const SplashRoute({List<_i38.PageRouteInfo>? children}) +/// [_i46.ShopCategoryPage] +class ShopCategoryRoute extends _i57.PageRouteInfo { + ShopCategoryRoute({ + _i58.Key? key, + _i64.ShopCategory? category, + bool promoOnly = false, + List<_i57.PageRouteInfo>? children, + }) : super( + ShopCategoryRoute.name, + args: ShopCategoryRouteArgs( + key: key, + category: category, + promoOnly: promoOnly, + ), + initialChildren: children, + ); + + static const String name = 'ShopCategoryRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs( + orElse: () => const ShopCategoryRouteArgs(), + ); + return _i46.ShopCategoryPage( + key: args.key, + category: args.category, + promoOnly: args.promoOnly, + ); + }, + ); +} + +class ShopCategoryRouteArgs { + const ShopCategoryRouteArgs({ + this.key, + this.category, + this.promoOnly = false, + }); + + final _i58.Key? key; + + final _i64.ShopCategory? category; + + final bool promoOnly; + + @override + String toString() { + return 'ShopCategoryRouteArgs{key: $key, category: $category, promoOnly: $promoOnly}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! ShopCategoryRouteArgs) return false; + return key == other.key && + category == other.category && + promoOnly == other.promoOnly; + } + + @override + int get hashCode => key.hashCode ^ category.hashCode ^ promoOnly.hashCode; +} + +/// generated route for +/// [_i47.ShopPage] +class ShopRoute extends _i57.PageRouteInfo { + const ShopRoute({List<_i57.PageRouteInfo>? children}) + : super(ShopRoute.name, initialChildren: children); + + static const String name = 'ShopRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i47.ShopPage(); + }, + ); +} + +/// generated route for +/// [_i48.ShopProductDetailPage] +class ShopProductDetailRoute + extends _i57.PageRouteInfo { + ShopProductDetailRoute({ + _i58.Key? key, + required _i64.ShopProduct product, + List<_i57.PageRouteInfo>? children, + }) : super( + ShopProductDetailRoute.name, + args: ShopProductDetailRouteArgs(key: key, product: product), + initialChildren: children, + ); + + static const String name = 'ShopProductDetailRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i48.ShopProductDetailPage(key: args.key, product: args.product); + }, + ); +} + +class ShopProductDetailRouteArgs { + const ShopProductDetailRouteArgs({this.key, required this.product}); + + final _i58.Key? key; + + final _i64.ShopProduct product; + + @override + String toString() { + return 'ShopProductDetailRouteArgs{key: $key, product: $product}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! ShopProductDetailRouteArgs) return false; + return key == other.key && product == other.product; + } + + @override + int get hashCode => key.hashCode ^ product.hashCode; +} + +/// generated route for +/// [_i49.SplashPage] +class SplashRoute extends _i57.PageRouteInfo { + const SplashRoute({List<_i57.PageRouteInfo>? children}) : super(SplashRoute.name, initialChildren: children); static const String name = 'SplashRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i35.SplashPage(); + return const _i49.SplashPage(); }, ); } /// generated route for -/// [_i36.VoucherDetailPage] -class VoucherDetailRoute extends _i38.PageRouteInfo { - const VoucherDetailRoute({List<_i38.PageRouteInfo>? children}) +/// [_i50.TransferPage] +class TransferRoute extends _i57.PageRouteInfo { + const TransferRoute({List<_i57.PageRouteInfo>? children}) + : super(TransferRoute.name, initialChildren: children); + + static const String name = 'TransferRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return _i57.WrappedRoute(child: const _i50.TransferPage()); + }, + ); +} + +/// generated route for +/// [_i51.VoucherDetailPage] +class VoucherDetailRoute extends _i57.PageRouteInfo { + const VoucherDetailRoute({List<_i57.PageRouteInfo>? children}) : super(VoucherDetailRoute.name, initialChildren: children); static const String name = 'VoucherDetailRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i36.VoucherDetailPage(); + return const _i51.VoucherDetailPage(); }, ); } /// generated route for -/// [_i37.VoucherPage] -class VoucherRoute extends _i38.PageRouteInfo { - const VoucherRoute({List<_i38.PageRouteInfo>? children}) +/// [_i52.VoucherPage] +class VoucherRoute extends _i57.PageRouteInfo { + const VoucherRoute({List<_i57.PageRouteInfo>? children}) : super(VoucherRoute.name, initialChildren: children); static const String name = 'VoucherRoute'; - static _i38.PageInfo page = _i38.PageInfo( + static _i57.PageInfo page = _i57.PageInfo( name, builder: (data) { - return const _i37.VoucherPage(); + return const _i52.VoucherPage(); }, ); } + +/// generated route for +/// [_i53.WalletExpiringPage] +class WalletExpiringRoute extends _i57.PageRouteInfo { + const WalletExpiringRoute({List<_i57.PageRouteInfo>? children}) + : super(WalletExpiringRoute.name, initialChildren: children); + + static const String name = 'WalletExpiringRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return _i57.WrappedRoute(child: const _i53.WalletExpiringPage()); + }, + ); +} + +/// generated route for +/// [_i54.WalletHistoryPage] +class WalletHistoryRoute extends _i57.PageRouteInfo { + WalletHistoryRoute({ + _i58.Key? key, + _i62.WalletCurrency initialCurrency = _i62.WalletCurrency.point, + List<_i57.PageRouteInfo>? children, + }) : super( + WalletHistoryRoute.name, + args: WalletHistoryRouteArgs( + key: key, + initialCurrency: initialCurrency, + ), + initialChildren: children, + ); + + static const String name = 'WalletHistoryRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs( + orElse: () => const WalletHistoryRouteArgs(), + ); + return _i57.WrappedRoute( + child: _i54.WalletHistoryPage( + key: args.key, + initialCurrency: args.initialCurrency, + ), + ); + }, + ); +} + +class WalletHistoryRouteArgs { + const WalletHistoryRouteArgs({ + this.key, + this.initialCurrency = _i62.WalletCurrency.point, + }); + + final _i58.Key? key; + + final _i62.WalletCurrency initialCurrency; + + @override + String toString() { + return 'WalletHistoryRouteArgs{key: $key, initialCurrency: $initialCurrency}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! WalletHistoryRouteArgs) return false; + return key == other.key && initialCurrency == other.initialCurrency; + } + + @override + int get hashCode => key.hashCode ^ initialCurrency.hashCode; +} + +/// generated route for +/// [_i55.WalletPage] +class WalletRoute extends _i57.PageRouteInfo { + const WalletRoute({List<_i57.PageRouteInfo>? children}) + : super(WalletRoute.name, initialChildren: children); + + static const String name = 'WalletRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + return const _i55.WalletPage(); + }, + ); +} + +/// generated route for +/// [_i56.WebViewPage] +class WebViewRoute extends _i57.PageRouteInfo { + WebViewRoute({ + _i58.Key? key, + required String title, + required String url, + bool fullscreen = false, + _i58.Color? backgroundColor, + List<_i57.PageRouteInfo>? children, + }) : super( + WebViewRoute.name, + args: WebViewRouteArgs( + key: key, + title: title, + url: url, + fullscreen: fullscreen, + backgroundColor: backgroundColor, + ), + initialChildren: children, + ); + + static const String name = 'WebViewRoute'; + + static _i57.PageInfo page = _i57.PageInfo( + name, + builder: (data) { + final args = data.argsAs(); + return _i56.WebViewPage( + key: args.key, + title: args.title, + url: args.url, + fullscreen: args.fullscreen, + backgroundColor: args.backgroundColor, + ); + }, + ); +} + +class WebViewRouteArgs { + const WebViewRouteArgs({ + this.key, + required this.title, + required this.url, + this.fullscreen = false, + this.backgroundColor, + }); + + final _i58.Key? key; + + final String title; + + final String url; + + final bool fullscreen; + + final _i58.Color? backgroundColor; + + @override + String toString() { + return 'WebViewRouteArgs{key: $key, title: $title, url: $url, fullscreen: $fullscreen, backgroundColor: $backgroundColor}'; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! WebViewRouteArgs) return false; + return key == other.key && + title == other.title && + url == other.url && + fullscreen == other.fullscreen && + backgroundColor == other.backgroundColor; + } + + @override + int get hashCode => + key.hashCode ^ + title.hashCode ^ + url.hashCode ^ + fullscreen.hashCode ^ + backgroundColor.hashCode; +} diff --git a/lib/sample/community_sample_data.dart b/lib/sample/community_sample_data.dart new file mode 100644 index 0000000..5ea689a --- /dev/null +++ b/lib/sample/community_sample_data.dart @@ -0,0 +1,298 @@ +import '../presentation/components/assets/assets.gen.dart'; + +// Models +class CommunityMember { + final String id; + final String name; + final String? badge; + + const CommunityMember({required this.id, required this.name, this.badge}); + + String get initials { + final parts = name.trim().split(RegExp(r'\s+')); + if (parts.length == 1) return parts.first.substring(0, 1).toUpperCase(); + return (parts[0][0] + parts[1][0]).toUpperCase(); + } +} + +class CommunityGroup { + final String id; + final String name; + final String emoji; + final String description; + final String coverImage; + final int memberCount; + final int postPerDay; + final List tags; + final bool isJoined; + + /// Indeks warna lembut di [CommunityColor.tints]. + final int tint; + + const CommunityGroup({ + required this.id, + required this.name, + required this.emoji, + required this.description, + required this.coverImage, + required this.memberCount, + required this.postPerDay, + required this.tags, + required this.tint, + this.isJoined = false, + }); +} + +class CommunityPost { + final String id; + final CommunityMember author; + final CommunityGroup group; + final String content; + final String? image; + final String? merchantName; + final DateTime createdAt; + final int likeCount; + final int commentCount; + final bool isLiked; + + const CommunityPost({ + required this.id, + required this.author, + required this.group, + required this.content, + required this.createdAt, + this.image, + this.merchantName, + this.likeCount = 0, + this.commentCount = 0, + this.isLiked = false, + }); +} + +class CommunityComment { + final String id; + final CommunityMember author; + final String content; + final DateTime createdAt; + final int likeCount; + + const CommunityComment({ + required this.id, + required this.author, + required this.content, + required this.createdAt, + this.likeCount = 0, + }); +} + +class CommunityEvent { + final String id; + final String groupId; + final String title; + final String location; + final String image; + final DateTime startAt; + final int attendeeCount; + final int quota; + final String? reward; + final List attendees; + + const CommunityEvent({ + required this.id, + required this.groupId, + required this.title, + required this.location, + required this.image, + required this.startAt, + required this.attendeeCount, + required this.quota, + required this.attendees, + this.reward, + }); +} + +// Sample data +const currentMember = CommunityMember(id: 'me', name: 'Kamu'); + +const _members = [ + CommunityMember(id: 'm1', name: 'Nadia Putri', badge: 'Top Foodie'), + CommunityMember(id: 'm2', name: 'Raka Pratama'), + CommunityMember(id: 'm3', name: 'Salsa Amelia', badge: 'Kopi Lover'), + CommunityMember(id: 'm4', name: 'Dimas Haryo'), + CommunityMember(id: 'm5', name: 'Intan Lestari'), + CommunityMember(id: 'm6', name: 'Bayu Saputra', badge: 'Pedas Master'), +]; + +final List communityGroups = [ + CommunityGroup( + id: 'g1', + name: 'Pecinta Bakso', + emoji: '🍜', + description: + 'Tempat berbagi rekomendasi bakso terenak, dari urat sampai mercon. ' + 'Yuk kulineran bareng!', + coverImage: Assets.images.bakso343.path, + memberCount: 12480, + postPerDay: 86, + tags: ['Bakso', 'Kuliner Lokal', 'Review'], + tint: 0, + isJoined: true, + ), + CommunityGroup( + id: 'g2', + name: 'Ngopi Santai', + emoji: '☕', + description: + 'Obrolan santai soal kopi, manual brew, dan coffee shop nyaman ' + 'buat kerja atau nongkrong.', + coverImage: Assets.images.tumulu.path, + memberCount: 8920, + postPerDay: 54, + tags: ['Kopi', 'Nongkrong', 'WFC'], + tint: 1, + isJoined: true, + ), + CommunityGroup( + id: 'g3', + name: 'Ramen Hunter', + emoji: '🍥', + description: + 'Berburu semangkuk ramen terbaik. Bagikan kuah favoritmu dan ' + 'temukan kedai baru.', + coverImage: Assets.images.ramenmulu.path, + memberCount: 5310, + postPerDay: 31, + tags: ['Ramen', 'Jepang'], + tint: 2, + ), + CommunityGroup( + id: 'g4', + name: 'Tim Pedas', + emoji: '🌶️', + description: + 'Buat kamu yang nggak kenyang kalau belum kepedesan. Tantangan ' + 'level pedas tiap minggu!', + coverImage: Assets.images.woku.path, + memberCount: 7640, + postPerDay: 47, + tags: ['Pedas', 'Challenge'], + tint: 3, + ), +]; + +final List communityPosts = [ + CommunityPost( + id: 'p1', + author: _members[0], + group: communityGroups[0], + content: + 'Akhirnya nyobain bakso urat di Bakso 343 🤤 Kuahnya bening tapi ' + 'kaldunya kerasa banget, uratnya juga kenyal pas. Porsi besar, ' + 'harga masih ramah dompet. Wajib coba sambal ijonya!', + image: Assets.images.bakso343.path, + merchantName: 'Bakso 343', + createdAt: DateTime.now().subtract(const Duration(minutes: 25)), + likeCount: 128, + commentCount: 24, + isLiked: true, + ), + CommunityPost( + id: 'p2', + author: _members[2], + group: communityGroups[1], + content: + 'Rekomendasi tempat WFC yang colokannya banyak dan wifi kencang? ' + 'Aku biasanya di Tumulu Coffee, tapi pengen coba suasana baru ☕', + createdAt: DateTime.now().subtract(const Duration(hours: 2)), + likeCount: 42, + commentCount: 31, + ), + CommunityPost( + id: 'p3', + author: _members[5], + group: communityGroups[3], + content: + 'Level 5 Woku Pedas sukses kutaklukkan 🔥 Yang berani ikut challenge ' + 'minggu depan, kumpul di komen ya!', + image: Assets.images.woku.path, + merchantName: 'Woku Pedas', + createdAt: DateTime.now().subtract(const Duration(hours: 5)), + likeCount: 256, + commentCount: 58, + ), + CommunityPost( + id: 'p4', + author: _members[1], + group: communityGroups[2], + content: + 'Shoyu ramen di Ramenmulu ternyata enak banget, chashu-nya lumer. ' + 'Next mau coba yang tantan.', + image: Assets.images.ramenmulu.path, + merchantName: 'Ramenmulu', + createdAt: DateTime.now().subtract(const Duration(days: 1, hours: 3)), + likeCount: 87, + commentCount: 12, + ), +]; + +final List communityComments = [ + CommunityComment( + id: 'c1', + author: _members[3], + content: 'Setuju! Sambal ijonya juara, aku sampai nambah dua kali 😆', + createdAt: DateTime.now().subtract(const Duration(minutes: 12)), + likeCount: 8, + ), + CommunityComment( + id: 'c2', + author: _members[4], + content: 'Buka sampai jam berapa ya kak? Mau mampir pulang kerja.', + createdAt: DateTime.now().subtract(const Duration(minutes: 8)), + likeCount: 2, + ), + CommunityComment( + id: 'c3', + author: _members[0], + content: '@Intan sampai jam 10 malam kok, aman 👍', + createdAt: DateTime.now().subtract(const Duration(minutes: 3)), + likeCount: 1, + ), +]; + +final List communityEvents = [ + CommunityEvent( + id: 'e1', + groupId: 'g1', + title: 'Kopdar Pecinta Bakso', + location: 'Bakso 343, Jakarta Selatan', + image: Assets.images.bakso343.path, + startAt: DateTime.now().add(const Duration(days: 4, hours: 2)), + attendeeCount: 38, + quota: 50, + reward: '+500 EnakPoint', + attendees: _members.sublist(0, 4), + ), + CommunityEvent( + id: 'e2', + groupId: 'g2', + title: 'Cupping Session Bareng Barista', + location: 'Tumulu Coffee, Bandung', + image: Assets.images.tumulu.path, + startAt: DateTime.now().add(const Duration(days: 9)), + attendeeCount: 18, + quota: 20, + attendees: _members.sublist(2, 5), + ), + CommunityEvent( + id: 'e3', + groupId: 'g4', + title: 'Spicy Challenge Level 10', + location: 'Woku Pedas, Surabaya', + image: Assets.images.woku.path, + startAt: DateTime.now().add(const Duration(days: 15)), + attendeeCount: 64, + quota: 100, + reward: '+1.000 EnakCoin', + attendees: _members.sublist(3), + ), +]; diff --git a/lib/sample/news_sample_data.dart b/lib/sample/news_sample_data.dart new file mode 100644 index 0000000..a744cc0 --- /dev/null +++ b/lib/sample/news_sample_data.dart @@ -0,0 +1,187 @@ +import '../presentation/components/assets/assets.gen.dart'; + +// Models +enum NewsCategory { + menu('Menu Baru'), + promo('Promo'), + event('Event'), + info('Info'), + tips('Tips'); + + const NewsCategory(this.label); + + final String label; +} + +class NewsArticle { + final String id; + final String title; + final String summary; + final NewsCategory category; + + /// Path aset sampul; `null` memakai sampul warna kategori. + final String? coverImage; + final DateTime publishedAt; + final int readMinutes; + final String author; + final List paragraphs; + final bool isHeadline; + + const NewsArticle({ + required this.id, + required this.title, + required this.summary, + required this.category, + required this.publishedAt, + required this.readMinutes, + required this.paragraphs, + this.coverImage, + this.author = 'Tim Enaklo', + this.isHeadline = false, + }); +} + +// Sample Data +DateTime _hoursAgo(int hours) => + DateTime.now().subtract(Duration(hours: hours)); +DateTime _daysAgo(int days) => DateTime.now().subtract(Duration(days: days)); + +/// Getter, bukan `final`, supaya perubahan data langsung terbaca saat hot +/// reload (variabel global yang sudah terisi tidak diisi ulang). +List get newsSamples => [ + NewsArticle( + id: 'n1', + title: 'Sup Ikan Woku Kemangi, Menu Baru Andalan Woku Pedas', + summary: + 'Kuah woku khas Manado dengan kemangi segar, hadir mulai minggu ini.', + category: NewsCategory.menu, + coverImage: Assets.images.woku.path, + publishedAt: _hoursAgo(3), + readMinutes: 3, + isHeadline: true, + paragraphs: [ + 'Woku Pedas menambah menu andalan baru: Sup Ikan Woku Kemangi. Ikan ' + 'segar dimasak dalam kuah bumbu woku, lalu ditaburi daun kemangi ' + 'tepat sebelum disajikan.', + 'Level pedasnya bisa dipilih dari 1 sampai 5. Untuk yang baru pertama ' + 'mencoba, tim dapur menyarankan level 2 supaya aroma rempahnya tetap ' + 'terasa.', + 'Menu ini tersedia untuk dine-in dan take away. Jangan lupa sebutkan ' + 'nomor HP akunmu ke kasir supaya EnakPoint dari pembelian ini masuk.', + ], + ), + NewsArticle( + id: 'n2', + title: 'Double EnakPoint Tiap Akhir Pekan, Begini Cara Dapatnya', + summary: 'Belanja Sabtu dan Minggu di outlet mana pun dapat EnakPoint 2x.', + category: NewsCategory.promo, + publishedAt: _hoursAgo(20), + readMinutes: 2, + paragraphs: [ + 'Selama bulan ini, setiap belanja pada hari Sabtu dan Minggu mendapat ' + 'EnakPoint dua kali lipat dari biasanya, di semua outlet.', + 'Tidak perlu klaim. Cukup sebutkan nomor HP akunmu ke kasir sebelum ' + 'membayar, dan EnakPoint 2x masuk otomatis setelah pesanan lunas.', + 'Bonus maksimal 5.000 EnakPoint per transaksi. Detail lengkap dan promo ' + 'lainnya bisa kamu cek di EnakPromo.', + ], + ), + NewsArticle( + id: 'n3', + title: 'Tumulu Coffee Kini Buka Lebih Pagi, Mulai Pukul 07.00', + summary: 'Ngopi sebelum berangkat kerja sekarang bisa langsung di Tumulu.', + category: NewsCategory.info, + coverImage: Assets.images.tumulu.path, + publishedAt: _daysAgo(1), + readMinutes: 2, + paragraphs: [ + 'Mulai minggu ini Tumulu Coffee buka pukul 07.00, satu jam lebih pagi ' + 'dari sebelumnya. Jam tutup tetap pukul 22.00.', + 'Selama jam 07.00 sampai 09.00, tersedia paket sarapan kopi susu dan ' + 'roti bakar untuk kamu yang terburu-buru.', + ], + ), + NewsArticle( + id: 'n4', + title: 'Ramen Night di Ramenmulu, Sabtu Ini', + summary: 'Nonton bareng, live akustik, dan ramen edisi terbatas.', + category: NewsCategory.event, + coverImage: Assets.images.ramenmulu.path, + publishedAt: _daysAgo(2), + readMinutes: 3, + paragraphs: [ + 'Ramenmulu menggelar Ramen Night hari Sabtu mulai pukul 18.00. Ada ' + 'nonton bareng, live musik akustik, dan ramen kuah miso edisi ' + 'terbatas.', + 'Tempat duduk terbatas dan tidak bisa dipesan lebih dulu, jadi datang ' + 'lebih awal supaya kebagian meja.', + 'Anggota komunitas Ramen Lovers di EnakCommunity sudah ramai membahas ' + 'acara ini. Yuk ikut gabung obrolannya.', + ], + ), + NewsArticle( + id: 'n5', + title: 'Cheesecake Karamel Jadi Dessert Baru di Tumulu Coffee', + summary: 'Lembut, tidak terlalu manis, dan pas ditemani kopi hitam.', + category: NewsCategory.menu, + coverImage: Assets.images.onboarding2.path, + publishedAt: _daysAgo(4), + readMinutes: 2, + paragraphs: [ + 'Tumulu Coffee menghadirkan dessert baru: Cheesecake Karamel. Lapisan ' + 'keju yang lembut dipadukan dengan saus karamel dan remahan biskuit ' + 'cokelat.', + 'Rasa manisnya dibuat ringan supaya cocok dinikmati bersama kopi hitam ' + 'atau americano.', + ], + ), + NewsArticle( + id: 'n6', + title: 'Cara Bayar Pakai EnakPoint di Kasir', + summary: 'Cukup tunjukkan kode bayar. PIN tidak pernah diketik di kasir.', + category: NewsCategory.tips, + publishedAt: _daysAgo(5), + readMinutes: 3, + paragraphs: [ + 'EnakPoint bisa langsung dipakai untuk membayar di kasir. Setiap 1 ' + 'EnakPoint setara potongan Rp 1.', + 'Tekan tombol Bayar di tengah menu bawah, lalu masukkan PIN kamu. ' + 'Aplikasi akan menampilkan kode angka dan QR.', + 'Tunjukkan kode itu ke kasir. Kasir yang memilih berapa EnakPoint yang ' + 'dipakai. Kode berlaku 2 menit dan hanya bisa dipakai sekali.', + 'PIN hanya dimasukkan di aplikasi, tidak pernah di mesin kasir. Jangan ' + 'berikan PIN kamu kepada siapa pun, termasuk petugas outlet.', + ], + ), + NewsArticle( + id: 'n7', + title: 'EnakPoint Bisa Kedaluwarsa, Begini Cara Mengeceknya', + summary: 'Pakai saldo sebelum hangus. Cek tanggalnya di halaman EnakPoint.', + category: NewsCategory.tips, + publishedAt: _daysAgo(6), + readMinutes: 2, + paragraphs: [ + 'Outlet bisa mengatur masa berlaku untuk EnakPoint dan EnakCoin. Saldo ' + 'yang sudah lewat masa berlakunya akan hangus.', + 'Buka halaman EnakPoint & EnakCoin untuk melihat saldo terdekat yang ' + 'akan kedaluwarsa, lengkap dengan tanggalnya.', + 'Tanggal kedaluwarsa berarti saldo masih bisa dipakai sampai pukul ' + '23.59 WIB pada tanggal tersebut.', + ], + ), + NewsArticle( + id: 'n8', + title: 'Bakso 343 Rayakan Ulang Tahun ke-5', + summary: 'Lima tahun menemani makan siang, ada kejutan untuk pelanggan.', + category: NewsCategory.event, + coverImage: Assets.images.bakso343.path, + publishedAt: _daysAgo(9), + readMinutes: 2, + paragraphs: [ + 'Bakso 343 genap berusia lima tahun. Berawal dari satu gerobak, kini ' + 'jadi salah satu tenant favorit di Enaklo.', + 'Selama pekan ulang tahun, setiap pelanggan yang makan di tempat ' + 'mendapat es teh gratis selama persediaan masih ada.', + ], + ), +]; diff --git a/lib/sample/promo_sample_data.dart b/lib/sample/promo_sample_data.dart new file mode 100644 index 0000000..3840f5c --- /dev/null +++ b/lib/sample/promo_sample_data.dart @@ -0,0 +1,209 @@ +// Models +// +// Mengikuti bentuk campaign di backend: tipe hadiah (POINTS / COINS / REWARD) +// dengan satu aturan (min. belanja, menu, hari, atau outlet) dan periode. + +/// Hadiah yang didapat customer dari promo. +enum PromoType { point, coin, reward } + +class Promo { + final String id; + final String title; + + /// Satu kalimat pendek untuk kartu. + final String subtitle; + final PromoType type; + + /// Hadiah dalam bentuk ringkas, mis. "2x EnakPoint" atau "+3 EnakCoin". + final String rewardLabel; + final String description; + final List steps; + final List terms; + + /// Kosong berarti berlaku di semua outlet. + final List outlets; + final DateTime startDate; + final DateTime endDate; + final bool isFeatured; + + const Promo({ + required this.id, + required this.title, + required this.subtitle, + required this.type, + required this.rewardLabel, + required this.description, + required this.steps, + required this.terms, + required this.startDate, + required this.endDate, + this.outlets = const [], + this.isFeatured = false, + }); +} + +// Sample Data +// +// 1 EnakPoint = potongan Rp 1. Belanja biasa memberi sekitar 1% EnakPoint. +DateTime _daysAgo(int days) => DateTime.now().subtract(Duration(days: days)); +DateTime _daysFromNow(int days) => DateTime.now().add(Duration(days: days)); + +const String _stepLinkPhone = + 'Sebutkan nomor HP akunmu ke kasir sebelum membayar.'; + +/// Getter, bukan `final`, supaya perubahan data langsung terbaca saat hot +/// reload (variabel global yang sudah terisi tidak diisi ulang). +List get promoSamples => [ + Promo( + id: 'p1', + title: 'Double EnakPoint Akhir Pekan', + subtitle: 'Semua belanja Sabtu & Minggu dapat EnakPoint 2x lipat', + type: PromoType.point, + rewardLabel: '2x EnakPoint', + description: + 'Belanja di akhir pekan jadi lebih untung. Setiap transaksi pada hari ' + 'Sabtu dan Minggu mendapat EnakPoint dua kali lipat dari biasanya.', + steps: [ + 'Belanja di outlet mana pun pada hari Sabtu atau Minggu.', + _stepLinkPhone, + 'EnakPoint 2x otomatis masuk setelah pesanan lunas.', + ], + terms: [ + 'Berlaku untuk semua menu, kecuali pembelian EnakCoin.', + 'Bonus dihitung dari total belanja setelah diskon.', + 'Maksimal bonus 5.000 EnakPoint per transaksi.', + ], + startDate: _daysAgo(6), + endDate: _daysFromNow(24), + isFeatured: true, + ), + Promo( + id: 'p2', + title: 'Ngopi Dapat EnakCoin', + subtitle: 'Setiap Kopi Susu di Tumulu Coffee dapat +3 EnakCoin', + type: PromoType.coin, + rewardLabel: '+3 EnakCoin', + description: + 'Kopi pagi sekaligus modal main EnakGame. Setiap pembelian Kopi Susu ' + 'di Tumulu Coffee memberi 3 EnakCoin tambahan.', + steps: [ + 'Pesan Kopi Susu ukuran apa pun di Tumulu Coffee.', + _stepLinkPhone, + 'EnakCoin masuk otomatis setelah pesanan lunas.', + ], + terms: [ + 'Berlaku kelipatan: 2 Kopi Susu = +6 EnakCoin.', + 'Maksimal 15 EnakCoin per hari.', + ], + outlets: ['Tumulu Coffee'], + startDate: _daysAgo(4), + endDate: _daysFromNow(10), + isFeatured: true, + ), + Promo( + id: 'p3', + title: 'Belanja Rp 100 Ribu, Bonus 2.000 EnakPoint', + subtitle: 'Bonus langsung untuk belanja minimal Rp 100.000', + type: PromoType.point, + rewardLabel: '+2.000 EnakPoint', + description: + 'Dapatkan bonus 2.000 EnakPoint, setara potongan Rp 2.000 di belanja ' + 'berikutnya, untuk setiap transaksi minimal Rp 100.000.', + steps: [ + 'Belanja minimal Rp 100.000 dalam satu transaksi.', + _stepLinkPhone, + 'Bonus masuk otomatis, di luar EnakPoint belanja biasa.', + ], + terms: [ + 'Minimum belanja dihitung sebelum pajak.', + 'Berlaku 1 kali per customer per hari.', + ], + startDate: _daysAgo(12), + endDate: _daysFromNow(2), + ), + Promo( + id: 'p4', + title: 'Gratis Es Teh Manis', + subtitle: 'Belanja Rp 50.000 di Bakso 343, dapat reward Es Teh Manis', + type: PromoType.reward, + rewardLabel: 'Gratis Es Teh', + description: + 'Makan bakso makin segar. Belanja minimal Rp 50.000 di Bakso 343 dan ' + 'dapatkan reward 1 Es Teh Manis untuk kunjungan berikutnya.', + steps: [ + 'Belanja minimal Rp 50.000 di Bakso 343.', + _stepLinkPhone, + 'Reward masuk ke Reward Saya dan berlaku 14 hari.', + ], + terms: [ + 'Reward hanya bisa dipakai di Bakso 343.', + 'Maksimal 1 reward per customer per hari.', + ], + outlets: ['Bakso 343'], + startDate: _daysAgo(2), + endDate: _daysFromNow(14), + isFeatured: true, + ), + Promo( + id: 'p5', + title: 'Rabu Ramen', + subtitle: 'Setiap Rabu, tiap porsi ramen dapat +1.500 EnakPoint', + type: PromoType.point, + rewardLabel: '+1.500 EnakPoint', + description: + 'Hari Rabu jadi hari ramen. Setiap porsi ramen di Ramenmulu pada hari ' + 'Rabu memberi bonus 1.500 EnakPoint.', + steps: [ + 'Pesan ramen di Ramenmulu pada hari Rabu.', + _stepLinkPhone, + 'Bonus masuk otomatis setelah pesanan lunas.', + ], + terms: [ + 'Berlaku untuk semua varian ramen, tidak termasuk topping.', + 'Maksimal 3 porsi per transaksi.', + ], + outlets: ['Ramenmulu'], + startDate: _daysAgo(20), + endDate: _daysFromNow(21), + ), + Promo( + id: 'p6', + title: 'Modal Main EnakGame', + subtitle: 'Belanja Rp 75.000 dapat +5 EnakCoin', + type: PromoType.coin, + rewardLabel: '+5 EnakCoin', + description: + 'Tambah kesempatan menang hadiah di EnakGame. Setiap belanja minimal ' + 'Rp 75.000 memberi 5 EnakCoin tambahan.', + steps: [ + 'Belanja minimal Rp 75.000 di outlet mana pun.', + _stepLinkPhone, + 'Pakai EnakCoin untuk main EnakGame.', + ], + terms: [ + 'Berlaku 1 kali per customer per hari.', + 'EnakCoin mengikuti masa berlaku yang diatur outlet.', + ], + startDate: _daysAgo(1), + endDate: _daysFromNow(7), + ), + Promo( + id: 'p7', + title: 'Pekan Woku Pedas', + subtitle: 'Menu apa pun di Woku Pedas dapat EnakPoint 3x lipat', + type: PromoType.point, + rewardLabel: '3x EnakPoint', + description: + 'Rayakan pembukaan menu baru Woku Pedas. Selama sepekan, semua ' + 'belanja di Woku Pedas mendapat EnakPoint tiga kali lipat.', + steps: [ + 'Belanja di Woku Pedas selama periode promo.', + _stepLinkPhone, + 'EnakPoint 3x otomatis masuk setelah pesanan lunas.', + ], + terms: ['Maksimal bonus 10.000 EnakPoint per transaksi.'], + outlets: ['Woku Pedas'], + startDate: _daysFromNow(3), + endDate: _daysFromNow(10), + ), +]; diff --git a/lib/sample/reward_sample_data.dart b/lib/sample/reward_sample_data.dart new file mode 100644 index 0000000..6888443 --- /dev/null +++ b/lib/sample/reward_sample_data.dart @@ -0,0 +1,139 @@ +// Models +enum RewardStatus { active, used, expired } + +class Reward { + final String id; + final String name; + final String emoji; + final String description; + final String categoryName; + final int pointsUsed; + final DateTime redeemedAt; + final DateTime validUntil; + final RewardStatus status; + final String? couponCode; + final DateTime? usedAt; + final String? termsAndConditions; + + const Reward({ + required this.id, + required this.name, + required this.emoji, + required this.description, + required this.categoryName, + required this.pointsUsed, + required this.redeemedAt, + required this.validUntil, + required this.status, + this.couponCode, + this.usedAt, + this.termsAndConditions, + }); +} + +// Sample Data +// +// 1 EnakPoint = potongan Rp 1, jadi harga reward dibuat sedikit di bawah harga +// menunya supaya menukar lebih untung daripada bayar langsung pakai poin. +// Menu gratis berlaku 14 hari dan voucher potongan 30 hari sejak ditukar. +DateTime _daysAgo(int days) => DateTime.now().subtract(Duration(days: days)); +DateTime _daysFromNow(int days) => DateTime.now().add(Duration(days: days)); + +/// Getter, bukan `final`, supaya perubahan data langsung terbaca saat hot +/// reload (variabel global yang sudah terisi tidak diisi ulang). +List get rewardSamples => [ + Reward( + id: 'r1', + name: 'Kopi Susu', + emoji: '☕', + description: '1 Kopi Susu regular di Tumulu Coffee', + categoryName: 'Minuman', + pointsUsed: 20000, + redeemedAt: _daysAgo(11), + validUntil: _daysFromNow(3), + status: RewardStatus.active, + couponCode: 'ENK-7QM2PX', + termsAndConditions: + 'Berlaku untuk 1 Kopi Susu ukuran regular di Tumulu Coffee, dine-in ' + 'atau take away. Upsize dan tambahan topping dibayar terpisah. ' + 'Tunjukkan kode ke kasir sebelum membayar.', + ), + Reward( + id: 'r2', + name: 'Bakso Urat', + emoji: '🍲', + description: '1 porsi Bakso Urat di Bakso 343', + categoryName: 'Makanan', + pointsUsed: 18000, + redeemedAt: DateTime.now().subtract(const Duration(hours: 5)), + validUntil: _daysFromNow(14), + status: RewardStatus.active, + couponCode: 'ENK-B3HW8N', + termsAndConditions: + 'Berlaku untuk 1 porsi Bakso Urat di Bakso 343, dine-in atau take ' + 'away. Tunjukkan kode ke kasir sebelum membayar.', + ), + Reward( + id: 'r3', + name: 'Potongan Rp 10.000', + emoji: '🎟️', + description: 'Min. belanja Rp 50.000 di semua outlet', + categoryName: 'Voucher', + pointsUsed: 8000, + redeemedAt: _daysAgo(2), + validUntil: _daysFromNow(28), + status: RewardStatus.active, + couponCode: 'ENK-K9D4TR', + termsAndConditions: + 'Berlaku untuk 1 transaksi dengan minimum belanja Rp 50.000 di semua ' + 'outlet. Tidak dapat digabung dengan voucher lain dan tidak dapat ' + 'diuangkan.', + ), + Reward( + id: 'r4', + name: 'Es Teh Manis', + emoji: '🥤', + description: '1 gelas Es Teh Manis di semua outlet', + categoryName: 'Minuman', + pointsUsed: 4000, + redeemedAt: _daysAgo(9), + validUntil: _daysFromNow(5), + usedAt: _daysAgo(8), + status: RewardStatus.used, + couponCode: 'ENK-5TRJ6C', + termsAndConditions: + 'Berlaku untuk 1 gelas Es Teh Manis ukuran regular di semua outlet.', + ), + Reward( + id: 'r5', + name: 'Gyoza Goreng', + emoji: '🥟', + description: '5 pcs Gyoza goreng di Ramenmulu', + categoryName: 'Cemilan', + pointsUsed: 16000, + redeemedAt: _daysAgo(20), + validUntil: _daysAgo(6), + usedAt: _daysAgo(16), + status: RewardStatus.used, + couponCode: 'ENK-G8VL2F', + termsAndConditions: + 'Berlaku untuk 1 porsi Gyoza goreng isi 5 di Ramenmulu. Tidak berlaku ' + 'untuk menu paket.', + ), + Reward( + id: 'r6', + name: 'Potongan Rp 5.000', + emoji: '🎟️', + description: 'Min. belanja Rp 30.000 di semua outlet', + categoryName: 'Voucher', + pointsUsed: 4000, + redeemedAt: _daysAgo(50), + validUntil: _daysAgo(20), + status: RewardStatus.expired, + couponCode: 'ENK-P2XN7D', + termsAndConditions: + 'Berlaku untuk 1 transaksi dengan minimum belanja Rp 30.000 di semua ' + 'outlet. Tidak dapat digabung dengan voucher lain dan tidak dapat ' + 'diuangkan.', + ), +]; diff --git a/lib/sample/shop_sample_data.dart b/lib/sample/shop_sample_data.dart new file mode 100644 index 0000000..555061d --- /dev/null +++ b/lib/sample/shop_sample_data.dart @@ -0,0 +1,368 @@ +// Models +// +// EnakShop adalah toko online. Tahap ini baru katalog; keranjang dan checkout +// menyusul setelah API toko tersedia. +enum ShopCategory { + frozen('Makanan Beku', '🥟'), + sauce('Sambal & Bumbu', '🌶️'), + coffee('Kopi & Minuman', '☕'), + noodle('Mie & Ramen', '🍜'), + snack('Camilan', '🍪'), + merch('Merchandise', '🛍️'), + hampers('Hampers', '🎁'); + + const ShopCategory(this.label, this.emoji); + + final String label; + final String emoji; +} + +/// Label pojok kartu produk. +enum ShopTag { + bestSeller('Terlaris'), + newArrival('Baru'); + + const ShopTag(this.label); + + final String label; +} + +class ShopProduct { + final String id; + final String name; + final ShopCategory category; + final int price; + + /// Harga setelah diskon; `null` bila tidak sedang diskon. + final int? discountPrice; + final String emoji; + + /// Warna latar gambar produk, ARGB. + final int tint; + + /// Berat atau isi, mis. "500 g" atau "Isi 25 butir". + final String unit; + final String description; + + /// Judul pilihan varian, mis. "Ukuran" atau "Level pedas". + final String variantLabel; + final List variants; + final int soldCount; + final int stock; + final ShopTag? tag; + final DateTime addedAt; + + const ShopProduct({ + required this.id, + required this.name, + required this.category, + required this.price, + required this.emoji, + required this.tint, + required this.unit, + required this.description, + required this.soldCount, + required this.stock, + required this.addedAt, + this.discountPrice, + this.variantLabel = 'Varian', + this.variants = const [], + this.tag, + }); + + bool get isDiscounted => discountPrice != null; + + int get finalPrice => discountPrice ?? price; + + /// Persen potongan, dibulatkan. + int get discountPercent => + isDiscounted ? ((price - discountPrice!) * 100 / price).round() : 0; +} + +/// Banner promo di beranda toko; mengarah ke satu kategori. +class ShopPromo { + final String id; + final String title; + final String subtitle; + final ShopCategory category; + + /// Warna gradasi banner, ARGB. + final List gradient; + + const ShopPromo({ + required this.id, + required this.title, + required this.subtitle, + required this.category, + required this.gradient, + }); +} + +// Sample Data +DateTime _daysAgo(int days) => DateTime.now().subtract(Duration(days: days)); + +/// Getter, bukan `final`, supaya perubahan data langsung terbaca saat hot +/// reload (variabel global yang sudah terisi tidak diisi ulang). +List get shopPromoSamples => const [ + ShopPromo( + id: 'sp1', + title: 'Diskon s.d. 20% Makanan Beku', + subtitle: 'Stok bakso & dimsum di rumah', + category: ShopCategory.frozen, + gradient: [0xFFD90000, 0xFF990000], + ), + ShopPromo( + id: 'sp2', + title: 'Hampers Mulai Rp 299 Ribu', + subtitle: 'Kirim rasa Nusantara untuk orang tersayang', + category: ShopCategory.hampers, + gradient: [0xFF43A047, 0xFF1B5E20], + ), + ShopPromo( + id: 'sp3', + title: 'Merchandise Diskon s.d. 15%', + subtitle: 'Tumbler, kaos, dan tote bag Enaklo', + category: ShopCategory.merch, + gradient: [0xFFF59E0B, 0xFFC2410C], + ), +]; + +List get shopSamples => [ + ShopProduct( + id: 's1', + name: 'Bakso Sapi Frozen Bakso 343', + category: ShopCategory.frozen, + price: 65000, + discountPrice: 52000, + emoji: '🍲', + tint: 0xFFF6D5D0, + unit: 'Isi 25 butir', + variantLabel: 'Ukuran', + variants: ['Isi 25 butir', 'Isi 50 butir'], + description: + 'Bakso sapi resep Bakso 343, dibekukan segera setelah dibuat. Cukup ' + 'rebus 5 menit. Tahan 3 bulan di freezer.', + soldCount: 320, + stock: 48, + tag: ShopTag.bestSeller, + addedAt: _daysAgo(60), + ), + ShopProduct( + id: 's2', + name: 'Dimsum Ayam Frozen', + category: ShopCategory.frozen, + price: 48000, + emoji: '🥟', + tint: 0xFFF3E6CF, + unit: 'Isi 20 pcs', + description: + 'Dimsum ayam udang dengan kulit tipis. Kukus 10 menit dari beku, ' + 'sajikan dengan sambal.', + soldCount: 85, + stock: 30, + tag: ShopTag.newArrival, + addedAt: _daysAgo(5), + ), + ShopProduct( + id: 's3', + name: 'Sambal Woku Pedas', + category: ShopCategory.sauce, + price: 35000, + discountPrice: 29000, + emoji: '🌶️', + tint: 0xFFFBDCC8, + unit: '200 g', + variantLabel: 'Level pedas', + variants: ['Level 2', 'Level 3', 'Level 5'], + description: + 'Sambal khas Woku Pedas dengan cabai, kemangi, dan rempah Manado. ' + 'Tanpa pengawet, simpan di kulkas setelah dibuka.', + soldCount: 540, + stock: 120, + tag: ShopTag.bestSeller, + addedAt: _daysAgo(90), + ), + ShopProduct( + id: 's4', + name: 'Bumbu Rica-Rica Instan', + category: ShopCategory.sauce, + price: 18000, + emoji: '🧂', + tint: 0xFFF7E2C8, + unit: '100 g', + description: + 'Bumbu rica-rica siap pakai untuk 1 kg ayam atau ikan. Tinggal tumis ' + 'dan masak bersama bahan utama.', + soldCount: 140, + stock: 75, + addedAt: _daysAgo(40), + ), + ShopProduct( + id: 's5', + name: 'Kopi Tumulu House Blend', + category: ShopCategory.coffee, + price: 85000, + emoji: '☕', + tint: 0xFFE8DCCF, + unit: '250 g', + variantLabel: 'Gilingan', + variants: ['Biji utuh', 'Bubuk halus', 'Bubuk kasar'], + description: + 'Campuran arabika Gayo dan robusta Temanggung yang dipakai di Tumulu ' + 'Coffee. Cocok untuk kopi susu maupun kopi tubruk.', + soldCount: 410, + stock: 64, + tag: ShopTag.bestSeller, + addedAt: _daysAgo(120), + ), + ShopProduct( + id: 's6', + name: 'Cold Brew Tumulu 1 Liter', + category: ShopCategory.coffee, + price: 75000, + discountPrice: 65000, + emoji: '🧋', + tint: 0xFFE2D6CC, + unit: '1 liter', + description: + 'Kopi seduh dingin 18 jam, tinggal tuang ke es dan susu. Simpan di ' + 'kulkas, habiskan dalam 7 hari.', + soldCount: 95, + stock: 20, + addedAt: _daysAgo(20), + ), + ShopProduct( + id: 's7', + name: 'Ramen Kit Shoyu Ramenmulu', + category: ShopCategory.noodle, + price: 79000, + discountPrice: 69000, + emoji: '🍜', + tint: 0xFFF5E1C8, + unit: '2 porsi', + description: + 'Mie ramen segar, kuah shoyu pekat, chashu, dan telur ajitama untuk ' + '2 porsi. Siap dalam 10 menit.', + soldCount: 150, + stock: 18, + tag: ShopTag.newArrival, + addedAt: _daysAgo(3), + ), + ShopProduct( + id: 's8', + name: 'Mie Ramen Kering', + category: ShopCategory.noodle, + price: 32000, + emoji: '🍝', + tint: 0xFFF4EBD3, + unit: '500 g', + description: + 'Mie ramen kering untuk 5 porsi, kenyal seperti mie segar. Rebus ' + '3 menit.', + soldCount: 60, + stock: 90, + addedAt: _daysAgo(30), + ), + ShopProduct( + id: 's9', + name: 'Keripik Kulit Ikan Pedas', + category: ShopCategory.snack, + price: 28000, + emoji: '🍘', + tint: 0xFFF6E7C1, + unit: '100 g', + description: + 'Keripik kulit ikan renyah dengan bumbu woku pedas. Camilan pas ' + 'teman nonton.', + soldCount: 210, + stock: 55, + addedAt: _daysAgo(50), + ), + ShopProduct( + id: 's10', + name: 'Nastar Keju Premium', + category: ShopCategory.snack, + price: 95000, + discountPrice: 85000, + emoji: '🍪', + tint: 0xFFF7E4B5, + unit: 'Toples 500 g', + description: + 'Nastar selai nanas homemade dengan taburan keju edam. Tahan 1 bulan ' + 'dalam toples tertutup.', + soldCount: 130, + stock: 25, + addedAt: _daysAgo(15), + ), + ShopProduct( + id: 's11', + name: 'Tumbler Enaklo 500 ml', + category: ShopCategory.merch, + price: 129000, + emoji: '🥤', + tint: 0xFFF3D3D3, + unit: '500 ml', + variantLabel: 'Warna', + variants: ['Merah', 'Hitam', 'Krem'], + description: + 'Tumbler stainless dua lapis yang menjaga minuman tetap dingin sampai ' + '12 jam. Tutup anti tumpah.', + soldCount: 75, + stock: 40, + tag: ShopTag.bestSeller, + addedAt: _daysAgo(70), + ), + ShopProduct( + id: 's12', + name: 'Kaos "Enak Lho!"', + category: ShopCategory.merch, + price: 119000, + emoji: '👕', + tint: 0xFFE9E9E9, + unit: 'Katun combed 30s', + variantLabel: 'Ukuran', + variants: ['S', 'M', 'L', 'XL'], + description: + 'Kaos katun yang adem dipakai seharian, dengan sablon "Enak Lho!" di ' + 'bagian depan.', + soldCount: 48, + stock: 32, + addedAt: _daysAgo(35), + ), + ShopProduct( + id: 's13', + name: 'Tote Bag Kanvas Enaklo', + category: ShopCategory.merch, + price: 90000, + discountPrice: 76500, + emoji: '🛍️', + tint: 0xFFEDE3CF, + unit: '38 × 42 cm', + variantLabel: 'Warna', + variants: ['Natural', 'Hitam'], + description: + 'Tote bag kanvas tebal dengan kantong dalam. Cukup untuk laptop 14 ' + 'inci.', + soldCount: 66, + stock: 3, + tag: ShopTag.newArrival, + addedAt: _daysAgo(8), + ), + ShopProduct( + id: 's14', + name: 'Hampers Rasa Nusantara', + category: ShopCategory.hampers, + price: 350000, + discountPrice: 299000, + emoji: '🎁', + tint: 0xFFDCEBD6, + unit: 'Isi 5 produk', + description: + 'Sambal Woku Pedas, Kopi Tumulu House Blend, Nastar Keju Premium, ' + 'Keripik Kulit Ikan Pedas, dan kartu ucapan dalam kotak kayu.', + soldCount: 34, + stock: 12, + tag: ShopTag.newArrival, + addedAt: _daysAgo(6), + ), +]; diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 1b34b4c..c1e0f28 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -7,7 +7,7 @@ project(runner LANGUAGES CXX) set(BINARY_NAME "enaklo") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID -set(APPLICATION_ID "com.appskel.enaklo") +set(APPLICATION_ID "com.apskel.enaklocustomer") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index cc10c4d..ef9ba8a 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,12 +7,16 @@ #include "generated_plugin_registrant.h" #include +#include #include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin"); audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar); + g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin"); + flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar); g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index 8e2a190..0044ef2 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST audioplayers_linux + flutter_secure_storage_linux url_launcher_linux ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index cd7dfe0..5739c53 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,16 +7,20 @@ import Foundation import audioplayers_darwin import connectivity_plus +import flutter_secure_storage_darwin import path_provider_foundation import shared_preferences_foundation import sqflite_darwin import url_launcher_macos +import webview_flutter_wkwebview func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin")) ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) + FlutterSecureStorageDarwinPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageDarwinPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) + WebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "WebViewFlutterPlugin")) } diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index ee2d4d6..8b0e276 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -385,7 +385,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/enaklo.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/enaklo"; @@ -399,7 +399,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/enaklo.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/enaklo"; @@ -413,7 +413,7 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/enaklo.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/enaklo"; diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/macos/Runner/Configs/AppInfo.xcconfig index 40318f8..188704b 100644 --- a/macos/Runner/Configs/AppInfo.xcconfig +++ b/macos/Runner/Configs/AppInfo.xcconfig @@ -8,7 +8,7 @@ PRODUCT_NAME = enaklo // The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.appskel.enaklo +PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklocustomer // The copyright displayed in application information PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. diff --git a/pubspec.lock b/pubspec.lock index eeccb95..e9356df 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,18 +5,26 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: da0d9209ca76bde579f2da330aeb9df62b6319c834fa7baae052021b0462401f + sha256: "1b0e6a07425a3e460666e88bf1c949ccc7bb0116ad562ce94a1eca60fe820725" url: "https://pub.dev" source: hosted - version: "85.0.0" + version: "103.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "974859dc0ff5f37bc4313244b3218c791810d03ab3470a579580279ba971a48d" + sha256: "61c04d0c1bfed555c681ea079519933f071a5a026578ff73c4ff0df2d3462e5e" url: "https://pub.dev" source: hosted - version: "7.7.1" + version: "13.3.0" + analyzer_buffer: + dependency: transitive + description: + name: analyzer_buffer + sha256: f890a2e708e38fbf4238ad2f9fd3d506538acdddb0cd8eb2c3e8c7bd17784b57 + url: "https://pub.dev" + source: hosted + version: "0.3.4" another_flushbar: dependency: "direct main" description: @@ -25,6 +33,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.12.32" + ansicolor: + dependency: transitive + description: + name: ansicolor + sha256: "50e982d500bc863e1d703448afdbf9e5a72eb48840a4f766fa361ffd6877055f" + url: "https://pub.dev" + source: hosted + version: "2.0.3" archive: dependency: transitive description: @@ -109,18 +125,18 @@ packages: dependency: "direct main" description: name: auto_route - sha256: "1d1bd908a1fec327719326d5d0791edd37f16caff6493c01003689fb03315ad7" + sha256: "538d8eb2ffc48de30abb30d4545a90405b5f8a29248b82d5e4b2977a79bfd229" url: "https://pub.dev" source: hosted - version: "9.3.0+1" + version: "11.2.0" auto_route_generator: dependency: "direct dev" description: name: auto_route_generator - sha256: c2e359d8932986d4d1bcad7a428143f81384ce10fef8d4aa5bc29e1f83766a46 + sha256: f58fdb20c51b36afe7bf8a162aea3b22dff580a8a0b5c35e8e3a91367121c8f1 url: "https://pub.dev" source: hosted - version: "9.3.1" + version: "10.6.0" awesome_dio_interceptor: dependency: "direct dev" description: @@ -149,18 +165,18 @@ packages: dependency: transitive description: name: build - sha256: "51dc711996cbf609b90cbe5b335bbce83143875a9d58e4b5c6d3c4f684d3dda7" + sha256: "8a5c5761af8e31748bba3c82f68925ace40f3225c3eea25be9beb57eca7cd7a8" url: "https://pub.dev" source: hosted - version: "2.5.4" + version: "4.0.11" build_config: dependency: transitive description: name: build_config - sha256: "4ae2de3e1e67ea270081eaee972e1bd8f027d459f249e0f1186730784c2e7e33" + sha256: d466ed2dc9c6cd1d169948879b84ee061eb5e22c64a7c6089879c6296d272a8d url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "1.3.3" build_daemon: dependency: transitive description: @@ -169,30 +185,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.4" - build_resolvers: - dependency: transitive - description: - name: build_resolvers - sha256: ee4257b3f20c0c90e72ed2b57ad637f694ccba48839a821e87db762548c22a62 - url: "https://pub.dev" - source: hosted - version: "2.5.4" build_runner: dependency: "direct dev" description: name: build_runner - sha256: "382a4d649addbfb7ba71a3631df0ec6a45d5ab9b098638144faf27f02778eb53" + sha256: "894c243f6bc32015fec466ce30a6925bd537a77a426ee5bf481120477eb3de67" url: "https://pub.dev" source: hosted - version: "2.5.4" - build_runner_core: - dependency: transitive - description: - name: build_runner_core - sha256: "85fbbb1036d576d966332a3f5ce83f2ce66a40bea1a94ad2d5fc29a19a0d3792" - url: "https://pub.dev" - source: hosted - version: "9.1.2" + version: "2.16.1" built_collection: dependency: transitive description: @@ -245,10 +245,10 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" checked_yaml: dependency: transitive description: @@ -277,10 +277,10 @@ packages: dependency: transitive description: name: code_builder - sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" + sha256: aa5932e94c6c39c2f9ec4e5e06dfdd11a9430a61f6c41b6ba75b28ce0c481baf url: "https://pub.dev" source: hosted - version: "4.10.1" + version: "4.12.0" collection: dependency: transitive description: @@ -345,14 +345,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.8" + cupertino_ui: + dependency: transitive + description: + name: cupertino_ui + sha256: "1fa3c6bf0925e96c7235ab4f1a6c701cc07e3c7abe13aa4e3d1219e651586615" + url: "https://pub.dev" + source: hosted + version: "0.0.1" dart_style: dependency: transitive description: name: dart_style - sha256: "8a0e5fba27e8ee025d2ffb4ee820b4e6e2cf5e4246a6b1a477eb66866947e0bb" + sha256: "82ade9fc4273f29ed673e33166944465225b4f7fc5d4aaef48605cc751c18fc1" url: "https://pub.dev" source: hosted - version: "3.1.1" + version: "3.1.13" dartx: dependency: transitive description: @@ -413,10 +421,18 @@ packages: dependency: transitive description: name: ffi - sha256: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418" + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.2.0" + ffi_leak_tracker: + dependency: transitive + description: + name: ffi_leak_tracker + sha256: "4093d4ef9ca06ffe2786e73bfb25e22aa92112b9bb4ec941f11e3e6b61489a97" + url: "https://pub.dev" + source: hosted + version: "0.1.2" file: dependency: transitive description: @@ -458,18 +474,18 @@ packages: dependency: transitive description: name: flutter_gen_core - sha256: eda54fdc5de08e7eeea663eb8442aafc8660b5a13fda4e0c9e572c64e50195fb + sha256: "8ccb1f809642b34eb4857d8d7c4e5b41430a8cba8206177aae2ffe9d72b5eef3" url: "https://pub.dev" source: hosted - version: "5.11.0" + version: "5.15.0" flutter_gen_runner: dependency: "direct dev" description: name: flutter_gen_runner - sha256: "669bf8b7a9b4acbdcb7fcc5e12bf638aca19acedf43341714cbca3bf3a219521" + sha256: "2b0fff517a75a14ed2eff749c1da2d6b8b568e542ad2b1c967356669a4c29bb2" url: "https://pub.dev" source: hosted - version: "5.11.0" + version: "5.15.0" flutter_launcher_icons: dependency: "direct dev" description: @@ -486,6 +502,54 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + sha256: d4e1fb6b2cb524868929e78dc0282fa000554b22060fb53789dc481c9fc95bb8 + url: "https://pub.dev" + source: hosted + version: "11.2.0" + flutter_secure_storage_darwin: + dependency: transitive + description: + name: flutter_secure_storage_darwin + sha256: a031ceac9b070e62ef183cd7f7d1a8798ebde402d5049f0fe6eb3a51bd797a21 + url: "https://pub.dev" + source: hosted + version: "0.4.3" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + sha256: caa75bd78f017422912e3a904933113b2428eb79f981ac37acd2dd2a700458ea + url: "https://pub.dev" + source: hosted + version: "3.0.3" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + sha256: "64951127f001f546891c86f414972bf49ef2c4c8a4c92c65f5790cc0c9100045" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + sha256: "073a62b3aeb866ab4ce795f960413948e51e5a42a9b0c8333b6daf5bb3208a1c" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + sha256: "471951813a97006d899db4948acc654a4f28c440083ea08178935ce20b173ec1" + url: "https://pub.dev" + source: hosted + version: "4.2.2" flutter_spinkit: dependency: "direct main" description: @@ -516,18 +580,18 @@ packages: dependency: "direct dev" description: name: freezed - sha256: "59a584c24b3acdc5250bb856d0d3e9c0b798ed14a4af1ddb7dc1c7b41df91c9c" + sha256: "541a82723c84298f3ca46a6c2186935aa21ad529ad1f1423d67af18040494f51" url: "https://pub.dev" source: hosted - version: "2.5.8" + version: "4.0.1" freezed_annotation: dependency: "direct main" description: name: freezed_annotation - sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8" url: "https://pub.dev" source: hosted - version: "2.4.4" + version: "3.1.0" frontend_server_client: dependency: transitive description: @@ -540,10 +604,10 @@ packages: dependency: "direct main" description: name: get_it - sha256: a4292e7cf67193f8e7c1258203104eb2a51ec8b3a04baa14695f4064c144297b + sha256: ae78de7c3f2304b8d81f2bb6e320833e5e81de942188542328f074978cc0efa9 url: "https://pub.dev" source: hosted - version: "8.2.0" + version: "8.3.0" glob: dependency: transitive description: @@ -568,6 +632,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" + hotreloader: + dependency: transitive + description: + name: hotreloader + sha256: "66871df468fc24eee81f1a0a7cb98acc104716f9b7376d355437b48d633c4ebf" + url: "https://pub.dev" + source: hosted + version: "4.4.0" http: dependency: transitive description: @@ -612,18 +684,18 @@ packages: dependency: "direct main" description: name: injectable - sha256: "1b86fab6a98c11a97e5c718afb00e628d47d183c2a2256392e995a4c561141c1" + sha256: "1da6399509e44ddb0d8a4a35291d7122c4efb5c625a9d733bf5e48d4a72e379e" url: "https://pub.dev" source: hosted - version: "2.5.1" + version: "3.0.0" injectable_generator: dependency: "direct dev" description: name: injectable_generator - sha256: b04673a4c88b3a848c0c77bf58b8309f9b9e064d9fe1df5450c8ee1675eaea1a + sha256: "24d525c60ed9abf345c8749c3291ca1b3f1d21fd53344c0c644da820a92049df" url: "https://pub.dev" source: hosted - version: "2.7.0" + version: "3.1.3" intl: dependency: "direct main" description: @@ -640,30 +712,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" - js: - dependency: transitive - description: - name: js - sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" - url: "https://pub.dev" - source: hosted - version: "0.7.2" json_annotation: dependency: "direct main" description: name: json_annotation - sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80" url: "https://pub.dev" source: hosted - version: "4.9.0" + version: "4.12.0" json_serializable: dependency: "direct dev" description: name: json_serializable - sha256: c50ef5fc083d5b5e12eef489503ba3bf5ccc899e487d691584699b4bdefeea8c + sha256: e45aefa0324f08c683caafbb94b72837aa6193c61822799c916e45f4a263113d url: "https://pub.dev" source: hosted - version: "6.9.5" + version: "6.14.1" leak_tracker: dependency: transitive description: @@ -688,6 +752,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + lean_builder: + dependency: transitive + description: + name: lean_builder + sha256: "5acef0857ec7163da8e6e5c86a9d7df87ce2487c8e866eb24c60508b82e67917" + url: "https://pub.dev" + source: hosted + version: "1.2.2" lints: dependency: transitive description: @@ -708,26 +780,34 @@ packages: dependency: transitive description: name: matcher - sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + sha256: "31bd099b47c10cd1aeb55146a2d46ce0277630ecef3f7dae54ad7873f36696cd" url: "https://pub.dev" source: hosted - version: "0.12.17" + version: "0.12.20" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" + material_ui: + dependency: transitive + description: + name: material_ui + sha256: "47b4acbb50683230000996cedd2a5ea511c2106c818db8ee28155ba0f0e26063" + url: "https://pub.dev" + source: hosted + version: "0.0.1" meta: dependency: transitive description: name: meta - sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9" url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.19.0" mime: dependency: transitive description: @@ -896,6 +976,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.0" + qr: + dependency: transitive + description: + name: qr + sha256: "5a1d2586170e172b8a8c8470bbbffd5eb0cd38a66c0d77155ea138d3af3a4445" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + qr_flutter: + dependency: "direct main" + description: + name: qr_flutter + sha256: "5095f0fc6e3f71d08adef8feccc8cea4f12eec18a2e31c2e8d82cb6019f4b097" + url: "https://pub.dev" + source: hosted + version: "4.1.0" recase: dependency: transitive description: @@ -1001,26 +1097,26 @@ packages: dependency: transitive description: name: source_gen - sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" + sha256: a603f1fb984a7391ae5978d1b92bfaaa08b350dca5c825256f925818f7943bf5 url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "4.2.4" source_helper: dependency: transitive description: name: source_helper - sha256: a447acb083d3a5ef17f983dd36201aeea33fedadb3228fa831f2f0c92f0f3aca + sha256: "5e6f216fdf6376c9f3852381ae037499797a3385377d388b011dac98d303c67c" url: "https://pub.dev" source: hosted - version: "1.3.7" + version: "1.3.13" source_span: dependency: transitive description: name: source_span - sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" url: "https://pub.dev" source: hosted - version: "1.10.1" + version: "1.10.2" sprintf: dependency: transitive description: @@ -1121,10 +1217,10 @@ packages: dependency: transitive description: name: test_api - sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + sha256: "2a122cbe059f8b610d3a5415f42e255b6c17b1f21eee1d960f31080237fb4f11" url: "https://pub.dev" source: hosted - version: "0.7.7" + version: "0.7.12" time: dependency: transitive description: @@ -1133,14 +1229,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.5" - timing: - dependency: transitive - description: - name: timing - sha256: "62ee18aca144e4a9f29d212f5a4c6a053be252b895ab14b5821996cff4ed90fe" - url: "https://pub.dev" - source: hosted - version: "1.0.2" typed_data: dependency: transitive description: @@ -1249,10 +1337,10 @@ packages: dependency: transitive description: name: vector_math - sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + sha256: "92b9910f66ed1057fd4da7b040ae7c74cafacf885bdc81be496928d5049b032d" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.4.3" vm_service: dependency: transitive description: @@ -1265,10 +1353,10 @@ packages: dependency: transitive description: name: watcher - sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c" + sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635" url: "https://pub.dev" source: hosted - version: "1.1.3" + version: "1.2.1" web: dependency: transitive description: @@ -1293,6 +1381,46 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + webview_flutter: + dependency: "direct main" + description: + name: webview_flutter + sha256: d53e1ccf5516f25017e3c9d44c39034db352d20fa34fe200674270242c2c5111 + url: "https://pub.dev" + source: hosted + version: "4.14.1" + webview_flutter_android: + dependency: "direct main" + description: + name: webview_flutter_android + sha256: "4de8b3d1ff4ebe1bdb42e68a5e4f809194a3cb0117a8f495f590004f00da3964" + url: "https://pub.dev" + source: hosted + version: "4.14.1" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + sha256: "1221c1b12f5278791042f2ec2841743784cf25c5a644e23d6680e5d718824f04" + url: "https://pub.dev" + source: hosted + version: "2.15.1" + webview_flutter_wkwebview: + dependency: "direct main" + description: + name: webview_flutter_wkwebview + sha256: "0f784be1b080e5b918ef7c2c070c1f4616899fd23f1d001feb74b4978f92bdbc" + url: "https://pub.dev" + source: hosted + version: "3.26.2" + win32: + dependency: transitive + description: + name: win32 + sha256: a0b93865d5644f11cf6a8c3f6db909f1ec168958b5805f6cc684adea957cd63d + url: "https://pub.dev" + source: hosted + version: "6.4.0" xdg_directories: dependency: transitive description: @@ -1309,6 +1437,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.6.1" + xxh3: + dependency: transitive + description: + name: xxh3 + sha256: "399a0438f5d426785723c99da6b16e136f4953fb1e9db0bf270bd41dd4619916" + url: "https://pub.dev" + source: hosted + version: "1.2.0" yaml: dependency: transitive description: @@ -1318,5 +1454,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.8.1 <4.0.0" - flutter: ">=3.29.0" + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.44.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7afb99d..01052ad 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,9 +13,9 @@ dependencies: sdk: flutter cupertino_icons: ^1.0.8 - auto_route: ^9.3.0 + auto_route: ^11.2.0 get_it: ^8.0.3 - injectable: ^2.5.0 + injectable: ^3.0.0 dio: ^5.8.0+1 connectivity_plus: ^6.1.4 data_channel: ^2.0.0+1 @@ -24,8 +24,8 @@ dependencies: dartz: ^0.10.1 intl: ^0.20.2 flutter_svg: ^2.2.0 - freezed_annotation: ^2.4.1 - json_annotation: ^4.9.0 + freezed_annotation: ^3.1.0 + json_annotation: ^4.12.0 shared_preferences: ^2.5.3 carousel_slider: ^5.1.1 url_launcher: ^6.3.2 @@ -36,17 +36,22 @@ dependencies: bloc: ^9.0.0 another_flushbar: ^1.12.32 flutter_spinkit: ^5.2.2 + qr_flutter: ^4.1.0 + flutter_secure_storage: ^11.2.0 + webview_flutter: ^4.14.1 + webview_flutter_android: ^4.14.1 + webview_flutter_wkwebview: ^3.26.2 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^5.0.0 - auto_route_generator: ^9.3.0 + auto_route_generator: ^10.6.0 build_runner: ^2.4.6 - freezed: ^2.4.5 + freezed: ^4.0.1 awesome_dio_interceptor: ^1.3.0 - injectable_generator: ^2.5.0 + injectable_generator: ^3.1.3 flutter_gen_runner: ^5.11.0 flutter_launcher_icons: ^0.14.4 json_serializable: ^6.9.5 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index d836cf4..e7fbed7 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -8,6 +8,7 @@ #include #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { @@ -15,6 +16,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); ConnectivityPlusWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); + FlutterSecureStorageWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 5ac8838..2ed3463 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -5,6 +5,7 @@ list(APPEND FLUTTER_PLUGIN_LIST audioplayers_windows connectivity_plus + flutter_secure_storage_windows url_launcher_windows )