Compare commits
84
Commits
7961c9d8c5
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5b0e66706 | ||
|
|
1ff144a1a2 | ||
|
|
eb031d4c2a | ||
|
|
7161f523c2 | ||
|
|
d097df1592 | ||
|
|
e8bbef03b0 | ||
|
|
b228538725 | ||
|
|
2ab20a1150 | ||
|
|
b9fcd79962 | ||
|
|
9a5f0c7415 | ||
|
|
d345294a2f | ||
|
|
beb86f6259 | ||
|
|
ea29c62af1 | ||
|
|
c8a84ffe5f | ||
|
|
539c70be17 | ||
|
|
c45848bcf2 | ||
|
|
6d9377f4ab | ||
|
|
56e720e253 | ||
|
|
c7ed45a374 | ||
|
|
a0610459bf | ||
|
|
842b7a5041 | ||
|
|
dc09aabbe8 | ||
|
|
cdc65f8f8f | ||
|
|
e7260ea0e2 | ||
|
|
b173654a9c | ||
|
|
699ca4cfb7 | ||
|
|
d790262fd4 | ||
|
|
60fec68a92 | ||
|
|
ab2d7d7be5 | ||
|
|
6ac88b92ae | ||
|
|
9e4e2ebbd1 | ||
|
|
3513c63259 | ||
|
|
46dfb7e44e | ||
|
|
a0db13feb4 | ||
|
|
f626b18d31 | ||
|
|
200f996d3e | ||
|
|
a739e1c29e | ||
|
|
4481d24375 | ||
|
|
59d8f06d75 | ||
|
|
e625bd3d2a | ||
|
|
5058f99fe0 | ||
|
|
f7cafeb583 | ||
|
|
37d747c0ba | ||
|
|
e3b9444a08 | ||
|
|
d8a28c084d | ||
|
|
d3974b8eda | ||
|
|
97313371c3 | ||
|
|
6fa45c8ac0 | ||
|
|
b2b2e2b111 | ||
|
|
0a8f8d93bb | ||
|
|
f5256fb33d | ||
|
|
c5673a147c | ||
|
|
af182b6f5a | ||
|
|
d78b6165c2 | ||
|
|
0886e8c912 | ||
|
|
93560b85cb | ||
|
|
4eece81eb1 | ||
|
|
873dd7e224 | ||
|
|
3e6dce93fb | ||
|
|
8923ce737d | ||
|
|
c0cf63a176 | ||
|
|
bf7a5708f5 | ||
|
|
896ea6c28c | ||
|
|
4ed7721bbe | ||
|
|
f12614cec9 | ||
|
|
98b152cbc2 | ||
|
|
1b24bae23a | ||
|
|
a87b62ca9f | ||
|
|
dca0f546f9 | ||
|
|
2a44ce023e | ||
|
|
13941d4881 | ||
|
|
07932d688f | ||
|
|
5a7892aa99 | ||
|
|
14c3c69ad6 | ||
|
|
3bb6bd653e | ||
|
|
b4a9cf31fc | ||
|
|
069c2296de | ||
|
|
ef23839761 | ||
|
|
d37a4993df | ||
|
|
2f155a2f8d | ||
|
|
d111025aa6 | ||
|
|
fecb4fb5c1 | ||
|
|
35f02e6b76 | ||
|
|
6b42cd86ff |
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Dev",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"args": ["--dart-define=ENV=dev"]
|
||||
},
|
||||
{
|
||||
"name": "Prod",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"args": ["--dart-define=ENV=prod"]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,16 +1,215 @@
|
||||
# apskel_pos_flutter_v2
|
||||
# Apskel POS Flutter
|
||||
|
||||
A new Flutter project.
|
||||
Aplikasi Point of Sale (POS) berbasis Flutter untuk manajemen kasir restoran. Mendukung manajemen order, produk, meja, pelanggan, pembayaran, printer bluetooth/network, analitik, dan push notification via FCM.
|
||||
|
||||
## Getting Started
|
||||
---
|
||||
|
||||
This project is a starting point for a Flutter application.
|
||||
## Fitur Utama
|
||||
|
||||
A few resources to get you started if this is your first Flutter project:
|
||||
- **Autentikasi** — Login dengan email & password, logout, session management
|
||||
- **Order Management** — Buat, kelola, dan proses order
|
||||
- **Produk & Kategori** — Manajemen menu dan kategori produk
|
||||
- **Meja** — Manajemen meja restoran
|
||||
- **Pelanggan** — Data pelanggan dan riwayat transaksi
|
||||
- **Checkout & Pembayaran** — Proses checkout dengan berbagai metode pembayaran
|
||||
- **Split Bill** — Pembagian tagihan
|
||||
- **Void & Refund** — Pembatalan dan pengembalian transaksi
|
||||
- **Printer** — Cetak struk via Bluetooth dan Network printer
|
||||
- **Analitik** — Dashboard, laporan penjualan, produk, kategori, payment method, profit/loss, inventory
|
||||
- **Sinkronisasi** — Sinkronisasi data offline/online
|
||||
- **Push Notification (FCM)** — Notifikasi real-time via Firebase Cloud Messaging
|
||||
|
||||
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
|
||||
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
|
||||
---
|
||||
|
||||
For help getting started with Flutter development, view the
|
||||
[online documentation](https://docs.flutter.dev/), which offers tutorials,
|
||||
samples, guidance on mobile development, and a full API reference.
|
||||
## Tech Stack
|
||||
|
||||
| Kategori | Library |
|
||||
|---|---|
|
||||
| State Management | `flutter_bloc` + `bloc` |
|
||||
| Dependency Injection | `get_it` + `injectable` |
|
||||
| Navigation | `auto_route` |
|
||||
| HTTP Client | `dio` |
|
||||
| Local Database | `sqflite` |
|
||||
| Local Storage | `shared_preferences` |
|
||||
| Firebase | `firebase_core`, `firebase_crashlytics`, `firebase_messaging` |
|
||||
| Push Notification | `flutter_local_notifications` |
|
||||
| Device Info | `device_info_plus`, `package_info_plus` |
|
||||
| Code Generation | `freezed`, `json_serializable` |
|
||||
| Printer | `print_bluetooth_thermal`, `flutter_esc_pos_network` |
|
||||
| Chart | `fl_chart` |
|
||||
| Connectivity | `connectivity_plus` |
|
||||
|
||||
---
|
||||
|
||||
## Arsitektur
|
||||
|
||||
Project menggunakan **Clean Architecture** dengan 4 layer:
|
||||
|
||||
```
|
||||
lib/
|
||||
├── application/ # BLoC — state management per fitur
|
||||
├── domain/ # Entity, repository interface, failure
|
||||
├── infrastructure/ # Implementasi repository, DTO, datasource
|
||||
├── presentation/ # UI — pages, components, router
|
||||
└── common/ # Shared utilities, DI modules, service, theme
|
||||
```
|
||||
|
||||
### Struktur per Fitur
|
||||
|
||||
```
|
||||
feature/
|
||||
├── application/
|
||||
│ └── feature_bloc.dart # BLoC
|
||||
├── domain/
|
||||
│ ├── entities/ # Domain model (freezed)
|
||||
│ ├── repositories/ # Interface repository
|
||||
│ └── failures/ # Failure types
|
||||
└── infrastructure/
|
||||
├── datasources/
|
||||
│ ├── remote_data_provider.dart
|
||||
│ └── local_data_provider.dart
|
||||
├── dtos/ # Data Transfer Object (json_serializable)
|
||||
└── repositories/ # Implementasi repository
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Setup & Menjalankan
|
||||
|
||||
### Prasyarat
|
||||
|
||||
- Flutter SDK `^3.8.1`
|
||||
- Dart SDK `^3.8.1`
|
||||
- Android SDK / Xcode (untuk iOS)
|
||||
- Firebase project yang sudah dikonfigurasi
|
||||
|
||||
### Instalasi
|
||||
|
||||
```bash
|
||||
# Clone repository
|
||||
git clone <repo-url>
|
||||
cd apskel-pos-flutter-v2
|
||||
|
||||
# Install dependencies
|
||||
flutter pub get
|
||||
|
||||
# Generate kode (freezed, injectable, auto_route, json_serializable)
|
||||
dart run build_runner build --delete-conflicting-outputs
|
||||
```
|
||||
|
||||
### Menjalankan App
|
||||
|
||||
```bash
|
||||
# Development
|
||||
flutter run
|
||||
|
||||
# Release
|
||||
flutter run --release
|
||||
```
|
||||
|
||||
App otomatis menggunakan environment `dev` saat debug dan `prod` saat release.
|
||||
|
||||
---
|
||||
|
||||
## Environment
|
||||
|
||||
Konfigurasi environment ada di `lib/env.dart`:
|
||||
|
||||
| Environment | Base URL | Database |
|
||||
|---|---|---|
|
||||
| `dev` | `https://api-pos.apskel.id` | `apskel_pos_dev.db` |
|
||||
| `prod` | `https://api-pos.apskel.id` | `apskel_pos_dev.db` |
|
||||
|
||||
Environment dipilih otomatis di `main.dart`:
|
||||
|
||||
```dart
|
||||
await configureDependencies(
|
||||
kReleaseMode ? Environment.prod : Environment.dev,
|
||||
);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Dependency Injection
|
||||
|
||||
DI menggunakan `get_it` + `injectable`. Semua service, repository, dan BLoC didaftarkan via annotation.
|
||||
|
||||
### Modul DI
|
||||
|
||||
| File | Isi |
|
||||
|---|---|
|
||||
| `di_firebase.dart` | `FirebaseMessaging`, `FlutterLocalNotificationsPlugin`, `DeviceInfoPlugin`, `PackageInfo` |
|
||||
| `di_dio.dart` | `Dio` HTTP client |
|
||||
| `di_shared_preferences.dart` | `SharedPreferences` |
|
||||
| `di_database.dart` | `DatabaseHelper` (SQLite) |
|
||||
| `di_auto_route.dart` | `AppRouter` |
|
||||
| `di_connectivity.dart` | `Connectivity` |
|
||||
|
||||
Setelah menambah atau mengubah class yang menggunakan annotation injectable, jalankan:
|
||||
|
||||
```bash
|
||||
dart run build_runner build --delete-conflicting-outputs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Firebase & FCM
|
||||
|
||||
### Setup
|
||||
|
||||
Firebase sudah dikonfigurasi di `android/app/google-services.json`. Inisialisasi dilakukan di `main.dart` sebelum app berjalan.
|
||||
|
||||
### FCM Service
|
||||
|
||||
`FcmService` (`lib/common/service/fcm_service.dart`) menangani:
|
||||
|
||||
- Request permission notifikasi (Android 13+ / iOS)
|
||||
- Ambil dan log FCM token
|
||||
- Foreground notification via `flutter_local_notifications`
|
||||
- Background & terminated message handler
|
||||
- Subscribe/unsubscribe topic
|
||||
|
||||
FCM token dikirim ke server saat login bersama device info.
|
||||
|
||||
### Login Payload
|
||||
|
||||
Saat login, app mengirim data berikut ke API:
|
||||
|
||||
```json
|
||||
{
|
||||
"email": "user@example.com",
|
||||
"password": "secret",
|
||||
"fcm_token": "dXj3k9...",
|
||||
"device_id": "abc123",
|
||||
"device_name": "Samsung Galaxy Tab S8",
|
||||
"device_type": "tablet",
|
||||
"platform": "android",
|
||||
"app_version": "1.0.4+9",
|
||||
"os_version": "Android 13 (SDK 33)"
|
||||
}
|
||||
```
|
||||
|
||||
Nilai valid: `device_type` → `mobile | tablet | desktop`, `platform` → `android | ios | web`
|
||||
|
||||
---
|
||||
|
||||
## Printer
|
||||
|
||||
Mendukung dua jenis printer:
|
||||
|
||||
- **Bluetooth** — via `print_bluetooth_thermal`
|
||||
- **Network (LAN)** — via `flutter_esc_pos_network`
|
||||
|
||||
---
|
||||
|
||||
## Orientasi Layar
|
||||
|
||||
App dikunci ke mode **landscape** (kiri & kanan) karena didesain untuk tablet POS.
|
||||
|
||||
---
|
||||
|
||||
## Catatan Development
|
||||
|
||||
- Jangan edit `injection.config.dart` dan file `*.freezed.dart` / `*.g.dart` secara manual — file tersebut di-generate otomatis
|
||||
- Gunakan `log()` dari `dart:developer` untuk logging, bukan `print()`
|
||||
- `print()` dinonaktifkan di release mode
|
||||
|
||||
@@ -4,6 +4,9 @@ linter:
|
||||
rules:
|
||||
sort_pub_dependencies: false
|
||||
prefer_relative_imports: true
|
||||
prefer_const_constructors: true
|
||||
prefer_const_literals_to_create_immutables: true
|
||||
prefer_const_declarations: true
|
||||
|
||||
analyzer:
|
||||
errors:
|
||||
|
||||
@@ -14,6 +14,7 @@ android {
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
isCoreLibraryDesugaringEnabled = true
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
@@ -45,6 +46,8 @@ flutter {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
|
||||
|
||||
// Import the Firebase BoM
|
||||
implementation(platform("com.google.firebase:firebase-bom:34.4.0"))
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||
<!-- Izin khusus untuk akses foto (media images) di Android 33 ke atas -->
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<!-- Izin notifikasi untuk Android 13+ -->
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<application
|
||||
android:label="Apskel POS"
|
||||
android:name="${applicationName}"
|
||||
@@ -41,6 +43,13 @@
|
||||
<meta-data
|
||||
android:name="flutterEmbedding"
|
||||
android:value="2" />
|
||||
<!-- FCM: default notification icon dan channel -->
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
android:resource="@drawable/ic_notification" />
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_channel_id"
|
||||
android:value="high_importance_channel" />
|
||||
</application>
|
||||
<!-- Required to query activities that can process text, see:
|
||||
https://developer.android.com/training/package-visibility and
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 846 B |
Binary file not shown.
|
After Width: | Height: | Size: 431 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
@@ -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
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
||||
@@ -0,0 +1,52 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/analytic/analytic.dart';
|
||||
|
||||
part 'category_analytic_loader_event.dart';
|
||||
part 'category_analytic_loader_state.dart';
|
||||
part 'category_analytic_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class CategoryAnalyticLoaderBloc
|
||||
extends Bloc<CategoryAnalyticLoaderEvent, CategoryAnalyticLoaderState> {
|
||||
final IAnalyticRepository _analyticRepository;
|
||||
CategoryAnalyticLoaderBloc(this._analyticRepository)
|
||||
: super(CategoryAnalyticLoaderState.initial()) {
|
||||
on<CategoryAnalyticLoaderEvent>(_onCategoryAnalyticLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onCategoryAnalyticLoaderEvent(
|
||||
CategoryAnalyticLoaderEvent event,
|
||||
Emitter<CategoryAnalyticLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _analyticRepository.getCategories(
|
||||
dateFrom: e.startDate,
|
||||
dateTo: e.endDate,
|
||||
);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(categories) async {
|
||||
emit(
|
||||
state.copyWith(isFetching: false, categoryAnalytic: categories),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+476
@@ -0,0 +1,476 @@
|
||||
// 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 'category_analytic_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$CategoryAnalyticLoaderEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$CategoryAnalyticLoaderEventCopyWith<CategoryAnalyticLoaderEvent>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CategoryAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory $CategoryAnalyticLoaderEventCopyWith(
|
||||
CategoryAnalyticLoaderEvent value,
|
||||
$Res Function(CategoryAnalyticLoaderEvent) then,
|
||||
) =
|
||||
_$CategoryAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
CategoryAnalyticLoaderEvent
|
||||
>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CategoryAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends CategoryAnalyticLoaderEvent
|
||||
>
|
||||
implements $CategoryAnalyticLoaderEventCopyWith<$Res> {
|
||||
_$CategoryAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $CategoryAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$CategoryAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CategoryAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) {
|
||||
return fetched?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements CategoryAnalyticLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CategoryAnalyticLoaderState {
|
||||
CategoryAnalytic get categoryAnalytic => throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$CategoryAnalyticLoaderStateCopyWith<CategoryAnalyticLoaderState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CategoryAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory $CategoryAnalyticLoaderStateCopyWith(
|
||||
CategoryAnalyticLoaderState value,
|
||||
$Res Function(CategoryAnalyticLoaderState) then,
|
||||
) =
|
||||
_$CategoryAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
CategoryAnalyticLoaderState
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
CategoryAnalytic categoryAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CategoryAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends CategoryAnalyticLoaderState
|
||||
>
|
||||
implements $CategoryAnalyticLoaderStateCopyWith<$Res> {
|
||||
_$CategoryAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? categoryAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
categoryAnalytic: null == categoryAnalytic
|
||||
? _value.categoryAnalytic
|
||||
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as CategoryAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic {
|
||||
return $CategoryAnalyticCopyWith<$Res>(_value.categoryAnalytic, (value) {
|
||||
return _then(_value.copyWith(categoryAnalytic: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CategoryAnalyticLoaderStateImplCopyWith<$Res>
|
||||
implements $CategoryAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory _$$CategoryAnalyticLoaderStateImplCopyWith(
|
||||
_$CategoryAnalyticLoaderStateImpl value,
|
||||
$Res Function(_$CategoryAnalyticLoaderStateImpl) then,
|
||||
) = __$$CategoryAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
CategoryAnalytic categoryAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CategoryAnalyticLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$CategoryAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$CategoryAnalyticLoaderStateImpl
|
||||
>
|
||||
implements _$$CategoryAnalyticLoaderStateImplCopyWith<$Res> {
|
||||
__$$CategoryAnalyticLoaderStateImplCopyWithImpl(
|
||||
_$CategoryAnalyticLoaderStateImpl _value,
|
||||
$Res Function(_$CategoryAnalyticLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? categoryAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$CategoryAnalyticLoaderStateImpl(
|
||||
categoryAnalytic: null == categoryAnalytic
|
||||
? _value.categoryAnalytic
|
||||
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as CategoryAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CategoryAnalyticLoaderStateImpl
|
||||
implements _CategoryAnalyticLoaderState {
|
||||
_$CategoryAnalyticLoaderStateImpl({
|
||||
required this.categoryAnalytic,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final CategoryAnalytic categoryAnalytic;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CategoryAnalyticLoaderState(categoryAnalytic: $categoryAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CategoryAnalyticLoaderStateImpl &&
|
||||
(identical(other.categoryAnalytic, categoryAnalytic) ||
|
||||
other.categoryAnalytic == categoryAnalytic) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, categoryAnalytic, failureOption, isFetching);
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CategoryAnalyticLoaderStateImplCopyWith<_$CategoryAnalyticLoaderStateImpl>
|
||||
get copyWith =>
|
||||
__$$CategoryAnalyticLoaderStateImplCopyWithImpl<
|
||||
_$CategoryAnalyticLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _CategoryAnalyticLoaderState
|
||||
implements CategoryAnalyticLoaderState {
|
||||
factory _CategoryAnalyticLoaderState({
|
||||
required final CategoryAnalytic categoryAnalytic,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$CategoryAnalyticLoaderStateImpl;
|
||||
|
||||
@override
|
||||
CategoryAnalytic get categoryAnalytic;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of CategoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CategoryAnalyticLoaderStateImplCopyWith<_$CategoryAnalyticLoaderStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
part of 'category_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class CategoryAnalyticLoaderEvent with _$CategoryAnalyticLoaderEvent {
|
||||
const factory CategoryAnalyticLoaderEvent.fetched({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _Fetched;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
part of 'category_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class CategoryAnalyticLoaderState with _$CategoryAnalyticLoaderState {
|
||||
factory CategoryAnalyticLoaderState({
|
||||
required CategoryAnalytic categoryAnalytic,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _CategoryAnalyticLoaderState;
|
||||
|
||||
factory CategoryAnalyticLoaderState.initial() => CategoryAnalyticLoaderState(
|
||||
categoryAnalytic: CategoryAnalytic.empty(),
|
||||
failureOption: none(),
|
||||
);
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/analytic/analytic.dart';
|
||||
|
||||
part 'dashboard_analytic_loader_event.dart';
|
||||
part 'dashboard_analytic_loader_state.dart';
|
||||
part 'dashboard_analytic_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class DashboardAnalyticLoaderBloc
|
||||
extends Bloc<DashboardAnalyticLoaderEvent, DashboardAnalyticLoaderState> {
|
||||
final IAnalyticRepository _analyticRepository;
|
||||
|
||||
DashboardAnalyticLoaderBloc(this._analyticRepository)
|
||||
: super(DashboardAnalyticLoaderState.initial()) {
|
||||
on<DashboardAnalyticLoaderEvent>(_onDashboardAnalyticLoader);
|
||||
}
|
||||
|
||||
Future<void> _onDashboardAnalyticLoader(
|
||||
DashboardAnalyticLoaderEvent event,
|
||||
Emitter<DashboardAnalyticLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _analyticRepository.getDashboard(
|
||||
dateFrom: e.startDate,
|
||||
dateTo: e.endDate,
|
||||
);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(dashboard) async {
|
||||
emit(
|
||||
state.copyWith(isFetching: false, dashboardAnalytic: dashboard),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+480
@@ -0,0 +1,480 @@
|
||||
// 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 'dashboard_analytic_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$DashboardAnalyticLoaderEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$DashboardAnalyticLoaderEventCopyWith<DashboardAnalyticLoaderEvent>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $DashboardAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory $DashboardAnalyticLoaderEventCopyWith(
|
||||
DashboardAnalyticLoaderEvent value,
|
||||
$Res Function(DashboardAnalyticLoaderEvent) then,
|
||||
) =
|
||||
_$DashboardAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
DashboardAnalyticLoaderEvent
|
||||
>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$DashboardAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends DashboardAnalyticLoaderEvent
|
||||
>
|
||||
implements $DashboardAnalyticLoaderEventCopyWith<$Res> {
|
||||
_$DashboardAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $DashboardAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$DashboardAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DashboardAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) {
|
||||
return fetched?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements DashboardAnalyticLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$DashboardAnalyticLoaderState {
|
||||
DashboardAnalytic get dashboardAnalytic => throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$DashboardAnalyticLoaderStateCopyWith<DashboardAnalyticLoaderState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $DashboardAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory $DashboardAnalyticLoaderStateCopyWith(
|
||||
DashboardAnalyticLoaderState value,
|
||||
$Res Function(DashboardAnalyticLoaderState) then,
|
||||
) =
|
||||
_$DashboardAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
DashboardAnalyticLoaderState
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
DashboardAnalytic dashboardAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$DashboardAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends DashboardAnalyticLoaderState
|
||||
>
|
||||
implements $DashboardAnalyticLoaderStateCopyWith<$Res> {
|
||||
_$DashboardAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? dashboardAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
dashboardAnalytic: null == dashboardAnalytic
|
||||
? _value.dashboardAnalytic
|
||||
: dashboardAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as DashboardAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic {
|
||||
return $DashboardAnalyticCopyWith<$Res>(_value.dashboardAnalytic, (value) {
|
||||
return _then(_value.copyWith(dashboardAnalytic: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$DashboardAnalyticLoaderStateImplCopyWith<$Res>
|
||||
implements $DashboardAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory _$$DashboardAnalyticLoaderStateImplCopyWith(
|
||||
_$DashboardAnalyticLoaderStateImpl value,
|
||||
$Res Function(_$DashboardAnalyticLoaderStateImpl) then,
|
||||
) = __$$DashboardAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
DashboardAnalytic dashboardAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$DashboardAnalyticLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$DashboardAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$DashboardAnalyticLoaderStateImpl
|
||||
>
|
||||
implements _$$DashboardAnalyticLoaderStateImplCopyWith<$Res> {
|
||||
__$$DashboardAnalyticLoaderStateImplCopyWithImpl(
|
||||
_$DashboardAnalyticLoaderStateImpl _value,
|
||||
$Res Function(_$DashboardAnalyticLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? dashboardAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$DashboardAnalyticLoaderStateImpl(
|
||||
dashboardAnalytic: null == dashboardAnalytic
|
||||
? _value.dashboardAnalytic
|
||||
: dashboardAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as DashboardAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$DashboardAnalyticLoaderStateImpl
|
||||
implements _DashboardAnalyticLoaderState {
|
||||
_$DashboardAnalyticLoaderStateImpl({
|
||||
required this.dashboardAnalytic,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final DashboardAnalytic dashboardAnalytic;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'DashboardAnalyticLoaderState(dashboardAnalytic: $dashboardAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$DashboardAnalyticLoaderStateImpl &&
|
||||
(identical(other.dashboardAnalytic, dashboardAnalytic) ||
|
||||
other.dashboardAnalytic == dashboardAnalytic) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, dashboardAnalytic, failureOption, isFetching);
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$DashboardAnalyticLoaderStateImplCopyWith<
|
||||
_$DashboardAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith =>
|
||||
__$$DashboardAnalyticLoaderStateImplCopyWithImpl<
|
||||
_$DashboardAnalyticLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _DashboardAnalyticLoaderState
|
||||
implements DashboardAnalyticLoaderState {
|
||||
factory _DashboardAnalyticLoaderState({
|
||||
required final DashboardAnalytic dashboardAnalytic,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$DashboardAnalyticLoaderStateImpl;
|
||||
|
||||
@override
|
||||
DashboardAnalytic get dashboardAnalytic;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of DashboardAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$DashboardAnalyticLoaderStateImplCopyWith<
|
||||
_$DashboardAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
part of 'dashboard_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class DashboardAnalyticLoaderEvent with _$DashboardAnalyticLoaderEvent {
|
||||
const factory DashboardAnalyticLoaderEvent.fetched({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _Fetched;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
part of 'dashboard_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class DashboardAnalyticLoaderState with _$DashboardAnalyticLoaderState {
|
||||
factory DashboardAnalyticLoaderState({
|
||||
required DashboardAnalytic dashboardAnalytic,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _DashboardAnalyticLoaderState;
|
||||
|
||||
factory DashboardAnalyticLoaderState.initial() =>
|
||||
DashboardAnalyticLoaderState(
|
||||
dashboardAnalytic: DashboardAnalytic.empty(),
|
||||
failureOption: none(),
|
||||
);
|
||||
}
|
||||
+47
@@ -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/analytic/analytic.dart';
|
||||
|
||||
part 'inventory_analytic_loader_event.dart';
|
||||
part 'inventory_analytic_loader_state.dart';
|
||||
part 'inventory_analytic_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class InventoryAnalyticLoaderBloc
|
||||
extends Bloc<InventoryAnalyticLoaderEvent, InventoryAnalyticLoaderState> {
|
||||
final IAnalyticRepository _analyticRepository;
|
||||
InventoryAnalyticLoaderBloc(this._analyticRepository)
|
||||
: super(InventoryAnalyticLoaderState.initial()) {
|
||||
on<InventoryAnalyticLoaderEvent>(_onInventoryAnalyticLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onInventoryAnalyticLoaderEvent(
|
||||
InventoryAnalyticLoaderEvent event,
|
||||
Emitter<InventoryAnalyticLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _analyticRepository.getInventory(
|
||||
dateFrom: e.startDate,
|
||||
dateTo: e.endDate,
|
||||
);
|
||||
|
||||
emit(
|
||||
result.fold(
|
||||
(l) => state.copyWith(isFetching: false, failureOption: some(l)),
|
||||
(r) => state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: none(),
|
||||
inventoryAnalytic: r,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+480
@@ -0,0 +1,480 @@
|
||||
// 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 'inventory_analytic_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$InventoryAnalyticLoaderEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$InventoryAnalyticLoaderEventCopyWith<InventoryAnalyticLoaderEvent>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $InventoryAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory $InventoryAnalyticLoaderEventCopyWith(
|
||||
InventoryAnalyticLoaderEvent value,
|
||||
$Res Function(InventoryAnalyticLoaderEvent) then,
|
||||
) =
|
||||
_$InventoryAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
InventoryAnalyticLoaderEvent
|
||||
>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$InventoryAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends InventoryAnalyticLoaderEvent
|
||||
>
|
||||
implements $InventoryAnalyticLoaderEventCopyWith<$Res> {
|
||||
_$InventoryAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $InventoryAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$InventoryAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InventoryAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) {
|
||||
return fetched?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements InventoryAnalyticLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$InventoryAnalyticLoaderState {
|
||||
InventoryAnalytic get inventoryAnalytic => throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$InventoryAnalyticLoaderStateCopyWith<InventoryAnalyticLoaderState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $InventoryAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory $InventoryAnalyticLoaderStateCopyWith(
|
||||
InventoryAnalyticLoaderState value,
|
||||
$Res Function(InventoryAnalyticLoaderState) then,
|
||||
) =
|
||||
_$InventoryAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
InventoryAnalyticLoaderState
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
InventoryAnalytic inventoryAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$InventoryAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends InventoryAnalyticLoaderState
|
||||
>
|
||||
implements $InventoryAnalyticLoaderStateCopyWith<$Res> {
|
||||
_$InventoryAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? inventoryAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
inventoryAnalytic: null == inventoryAnalytic
|
||||
? _value.inventoryAnalytic
|
||||
: inventoryAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as InventoryAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic {
|
||||
return $InventoryAnalyticCopyWith<$Res>(_value.inventoryAnalytic, (value) {
|
||||
return _then(_value.copyWith(inventoryAnalytic: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$InventoryAnalyticLoaderStateImplCopyWith<$Res>
|
||||
implements $InventoryAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory _$$InventoryAnalyticLoaderStateImplCopyWith(
|
||||
_$InventoryAnalyticLoaderStateImpl value,
|
||||
$Res Function(_$InventoryAnalyticLoaderStateImpl) then,
|
||||
) = __$$InventoryAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
InventoryAnalytic inventoryAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$InventoryAnalyticLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$InventoryAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$InventoryAnalyticLoaderStateImpl
|
||||
>
|
||||
implements _$$InventoryAnalyticLoaderStateImplCopyWith<$Res> {
|
||||
__$$InventoryAnalyticLoaderStateImplCopyWithImpl(
|
||||
_$InventoryAnalyticLoaderStateImpl _value,
|
||||
$Res Function(_$InventoryAnalyticLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? inventoryAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$InventoryAnalyticLoaderStateImpl(
|
||||
inventoryAnalytic: null == inventoryAnalytic
|
||||
? _value.inventoryAnalytic
|
||||
: inventoryAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as InventoryAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$InventoryAnalyticLoaderStateImpl
|
||||
implements _InventoryAnalyticLoaderState {
|
||||
_$InventoryAnalyticLoaderStateImpl({
|
||||
required this.inventoryAnalytic,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final InventoryAnalytic inventoryAnalytic;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InventoryAnalyticLoaderState(inventoryAnalytic: $inventoryAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$InventoryAnalyticLoaderStateImpl &&
|
||||
(identical(other.inventoryAnalytic, inventoryAnalytic) ||
|
||||
other.inventoryAnalytic == inventoryAnalytic) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, inventoryAnalytic, failureOption, isFetching);
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$InventoryAnalyticLoaderStateImplCopyWith<
|
||||
_$InventoryAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith =>
|
||||
__$$InventoryAnalyticLoaderStateImplCopyWithImpl<
|
||||
_$InventoryAnalyticLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _InventoryAnalyticLoaderState
|
||||
implements InventoryAnalyticLoaderState {
|
||||
factory _InventoryAnalyticLoaderState({
|
||||
required final InventoryAnalytic inventoryAnalytic,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$InventoryAnalyticLoaderStateImpl;
|
||||
|
||||
@override
|
||||
InventoryAnalytic get inventoryAnalytic;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of InventoryAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$InventoryAnalyticLoaderStateImplCopyWith<
|
||||
_$InventoryAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
part of 'inventory_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class InventoryAnalyticLoaderEvent with _$InventoryAnalyticLoaderEvent {
|
||||
const factory InventoryAnalyticLoaderEvent.fetched({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _Fetched;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
part of 'inventory_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class InventoryAnalyticLoaderState with _$InventoryAnalyticLoaderState {
|
||||
factory InventoryAnalyticLoaderState({
|
||||
required InventoryAnalytic inventoryAnalytic,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _InventoryAnalyticLoaderState;
|
||||
|
||||
factory InventoryAnalyticLoaderState.initial() =>
|
||||
InventoryAnalyticLoaderState(
|
||||
inventoryAnalytic: InventoryAnalytic.empty(),
|
||||
failureOption: none(),
|
||||
);
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/analytic/analytic.dart';
|
||||
|
||||
part 'payment_method_analytic_loader_event.dart';
|
||||
part 'payment_method_analytic_loader_state.dart';
|
||||
part 'payment_method_analytic_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class PaymentMethodAnalyticLoaderBloc
|
||||
extends
|
||||
Bloc<
|
||||
PaymentMethodAnalyticLoaderEvent,
|
||||
PaymentMethodAnalyticLoaderState
|
||||
> {
|
||||
final IAnalyticRepository _analyticRepository;
|
||||
PaymentMethodAnalyticLoaderBloc(this._analyticRepository)
|
||||
: super(PaymentMethodAnalyticLoaderState.initial()) {
|
||||
on<PaymentMethodAnalyticLoaderEvent>(_onPaymentMethodAnalyticLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onPaymentMethodAnalyticLoaderEvent(
|
||||
PaymentMethodAnalyticLoaderEvent event,
|
||||
Emitter<PaymentMethodAnalyticLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _analyticRepository.getPaymentMethod(
|
||||
dateFrom: e.startDate,
|
||||
dateTo: e.endDate,
|
||||
);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(paymentMethod) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
paymentMethodAnalytic: paymentMethod,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+487
@@ -0,0 +1,487 @@
|
||||
// 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 'payment_method_analytic_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$PaymentMethodAnalyticLoaderEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentMethodAnalyticLoaderEventCopyWith<PaymentMethodAnalyticLoaderEvent>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentMethodAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory $PaymentMethodAnalyticLoaderEventCopyWith(
|
||||
PaymentMethodAnalyticLoaderEvent value,
|
||||
$Res Function(PaymentMethodAnalyticLoaderEvent) then,
|
||||
) =
|
||||
_$PaymentMethodAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
PaymentMethodAnalyticLoaderEvent
|
||||
>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentMethodAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends PaymentMethodAnalyticLoaderEvent
|
||||
>
|
||||
implements $PaymentMethodAnalyticLoaderEventCopyWith<$Res> {
|
||||
_$PaymentMethodAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $PaymentMethodAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$PaymentMethodAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentMethodAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) {
|
||||
return fetched?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements PaymentMethodAnalyticLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentMethodAnalyticLoaderState {
|
||||
PaymentMethodAnalytic get paymentMethodAnalytic =>
|
||||
throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentMethodAnalyticLoaderStateCopyWith<PaymentMethodAnalyticLoaderState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentMethodAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory $PaymentMethodAnalyticLoaderStateCopyWith(
|
||||
PaymentMethodAnalyticLoaderState value,
|
||||
$Res Function(PaymentMethodAnalyticLoaderState) then,
|
||||
) =
|
||||
_$PaymentMethodAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
PaymentMethodAnalyticLoaderState
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
PaymentMethodAnalytic paymentMethodAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentMethodAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends PaymentMethodAnalyticLoaderState
|
||||
>
|
||||
implements $PaymentMethodAnalyticLoaderStateCopyWith<$Res> {
|
||||
_$PaymentMethodAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? paymentMethodAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
paymentMethodAnalytic: null == paymentMethodAnalytic
|
||||
? _value.paymentMethodAnalytic
|
||||
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as PaymentMethodAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic {
|
||||
return $PaymentMethodAnalyticCopyWith<$Res>(_value.paymentMethodAnalytic, (
|
||||
value,
|
||||
) {
|
||||
return _then(_value.copyWith(paymentMethodAnalytic: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaymentMethodAnalyticLoaderStateImplCopyWith<$Res>
|
||||
implements $PaymentMethodAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory _$$PaymentMethodAnalyticLoaderStateImplCopyWith(
|
||||
_$PaymentMethodAnalyticLoaderStateImpl value,
|
||||
$Res Function(_$PaymentMethodAnalyticLoaderStateImpl) then,
|
||||
) = __$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
PaymentMethodAnalytic paymentMethodAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$PaymentMethodAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$PaymentMethodAnalyticLoaderStateImpl
|
||||
>
|
||||
implements _$$PaymentMethodAnalyticLoaderStateImplCopyWith<$Res> {
|
||||
__$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl(
|
||||
_$PaymentMethodAnalyticLoaderStateImpl _value,
|
||||
$Res Function(_$PaymentMethodAnalyticLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? paymentMethodAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$PaymentMethodAnalyticLoaderStateImpl(
|
||||
paymentMethodAnalytic: null == paymentMethodAnalytic
|
||||
? _value.paymentMethodAnalytic
|
||||
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as PaymentMethodAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$PaymentMethodAnalyticLoaderStateImpl
|
||||
implements _PaymentMethodAnalyticLoaderState {
|
||||
_$PaymentMethodAnalyticLoaderStateImpl({
|
||||
required this.paymentMethodAnalytic,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final PaymentMethodAnalytic paymentMethodAnalytic;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentMethodAnalyticLoaderState(paymentMethodAnalytic: $paymentMethodAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaymentMethodAnalyticLoaderStateImpl &&
|
||||
(identical(other.paymentMethodAnalytic, paymentMethodAnalytic) ||
|
||||
other.paymentMethodAnalytic == paymentMethodAnalytic) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
paymentMethodAnalytic,
|
||||
failureOption,
|
||||
isFetching,
|
||||
);
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaymentMethodAnalyticLoaderStateImplCopyWith<
|
||||
_$PaymentMethodAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith =>
|
||||
__$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl<
|
||||
_$PaymentMethodAnalyticLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _PaymentMethodAnalyticLoaderState
|
||||
implements PaymentMethodAnalyticLoaderState {
|
||||
factory _PaymentMethodAnalyticLoaderState({
|
||||
required final PaymentMethodAnalytic paymentMethodAnalytic,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$PaymentMethodAnalyticLoaderStateImpl;
|
||||
|
||||
@override
|
||||
PaymentMethodAnalytic get paymentMethodAnalytic;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaymentMethodAnalyticLoaderStateImplCopyWith<
|
||||
_$PaymentMethodAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
part of 'payment_method_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PaymentMethodAnalyticLoaderEvent with _$PaymentMethodAnalyticLoaderEvent {
|
||||
const factory PaymentMethodAnalyticLoaderEvent.fetched({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _Fetched;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
part of 'payment_method_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PaymentMethodAnalyticLoaderState with _$PaymentMethodAnalyticLoaderState {
|
||||
factory PaymentMethodAnalyticLoaderState({
|
||||
required PaymentMethodAnalytic paymentMethodAnalytic,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _PaymentMethodAnalyticLoaderState;
|
||||
|
||||
factory PaymentMethodAnalyticLoaderState.initial() =>
|
||||
PaymentMethodAnalyticLoaderState(
|
||||
paymentMethodAnalytic: PaymentMethodAnalytic.empty(),
|
||||
failureOption: none(),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/analytic/analytic.dart';
|
||||
|
||||
part 'product_analytic_loader_event.dart';
|
||||
part 'product_analytic_loader_state.dart';
|
||||
part 'product_analytic_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class ProductAnalyticLoaderBloc
|
||||
extends Bloc<ProductAnalyticLoaderEvent, ProductAnalyticLoaderState> {
|
||||
final IAnalyticRepository _analyticRepository;
|
||||
ProductAnalyticLoaderBloc(this._analyticRepository)
|
||||
: super(ProductAnalyticLoaderState.initial()) {
|
||||
on<ProductAnalyticLoaderEvent>(_onProductAnalyticLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onProductAnalyticLoaderEvent(
|
||||
ProductAnalyticLoaderEvent event,
|
||||
Emitter<ProductAnalyticLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _analyticRepository.getProducts(
|
||||
dateFrom: e.startDate,
|
||||
dateTo: e.endDate,
|
||||
);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(products) async {
|
||||
emit(state.copyWith(isFetching: false, productAnalytic: products));
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+475
@@ -0,0 +1,475 @@
|
||||
// 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 'product_analytic_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$ProductAnalyticLoaderEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProductAnalyticLoaderEventCopyWith<ProductAnalyticLoaderEvent>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProductAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory $ProductAnalyticLoaderEventCopyWith(
|
||||
ProductAnalyticLoaderEvent value,
|
||||
$Res Function(ProductAnalyticLoaderEvent) then,
|
||||
) =
|
||||
_$ProductAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
ProductAnalyticLoaderEvent
|
||||
>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProductAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProductAnalyticLoaderEvent
|
||||
>
|
||||
implements $ProductAnalyticLoaderEventCopyWith<$Res> {
|
||||
_$ProductAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $ProductAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$ProductAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProductAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) {
|
||||
return fetched?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements ProductAnalyticLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProductAnalyticLoaderState {
|
||||
ProductAnalytic get productAnalytic => throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProductAnalyticLoaderStateCopyWith<ProductAnalyticLoaderState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProductAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory $ProductAnalyticLoaderStateCopyWith(
|
||||
ProductAnalyticLoaderState value,
|
||||
$Res Function(ProductAnalyticLoaderState) then,
|
||||
) =
|
||||
_$ProductAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
ProductAnalyticLoaderState
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
ProductAnalytic productAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$ProductAnalyticCopyWith<$Res> get productAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProductAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProductAnalyticLoaderState
|
||||
>
|
||||
implements $ProductAnalyticLoaderStateCopyWith<$Res> {
|
||||
_$ProductAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? productAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
productAnalytic: null == productAnalytic
|
||||
? _value.productAnalytic
|
||||
: productAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as ProductAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ProductAnalyticCopyWith<$Res> get productAnalytic {
|
||||
return $ProductAnalyticCopyWith<$Res>(_value.productAnalytic, (value) {
|
||||
return _then(_value.copyWith(productAnalytic: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProductAnalyticLoaderStateImplCopyWith<$Res>
|
||||
implements $ProductAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory _$$ProductAnalyticLoaderStateImplCopyWith(
|
||||
_$ProductAnalyticLoaderStateImpl value,
|
||||
$Res Function(_$ProductAnalyticLoaderStateImpl) then,
|
||||
) = __$$ProductAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
ProductAnalytic productAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$ProductAnalyticCopyWith<$Res> get productAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProductAnalyticLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$ProductAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$ProductAnalyticLoaderStateImpl
|
||||
>
|
||||
implements _$$ProductAnalyticLoaderStateImplCopyWith<$Res> {
|
||||
__$$ProductAnalyticLoaderStateImplCopyWithImpl(
|
||||
_$ProductAnalyticLoaderStateImpl _value,
|
||||
$Res Function(_$ProductAnalyticLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? productAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$ProductAnalyticLoaderStateImpl(
|
||||
productAnalytic: null == productAnalytic
|
||||
? _value.productAnalytic
|
||||
: productAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as ProductAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProductAnalyticLoaderStateImpl implements _ProductAnalyticLoaderState {
|
||||
_$ProductAnalyticLoaderStateImpl({
|
||||
required this.productAnalytic,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final ProductAnalytic productAnalytic;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProductAnalyticLoaderState(productAnalytic: $productAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProductAnalyticLoaderStateImpl &&
|
||||
(identical(other.productAnalytic, productAnalytic) ||
|
||||
other.productAnalytic == productAnalytic) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, productAnalytic, failureOption, isFetching);
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProductAnalyticLoaderStateImplCopyWith<_$ProductAnalyticLoaderStateImpl>
|
||||
get copyWith =>
|
||||
__$$ProductAnalyticLoaderStateImplCopyWithImpl<
|
||||
_$ProductAnalyticLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ProductAnalyticLoaderState
|
||||
implements ProductAnalyticLoaderState {
|
||||
factory _ProductAnalyticLoaderState({
|
||||
required final ProductAnalytic productAnalytic,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$ProductAnalyticLoaderStateImpl;
|
||||
|
||||
@override
|
||||
ProductAnalytic get productAnalytic;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of ProductAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ProductAnalyticLoaderStateImplCopyWith<_$ProductAnalyticLoaderStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
part of 'product_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProductAnalyticLoaderEvent with _$ProductAnalyticLoaderEvent {
|
||||
const factory ProductAnalyticLoaderEvent.fetched({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _Fetched;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
part of 'product_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProductAnalyticLoaderState with _$ProductAnalyticLoaderState {
|
||||
factory ProductAnalyticLoaderState({
|
||||
required ProductAnalytic productAnalytic,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _ProductAnalyticLoaderState;
|
||||
|
||||
factory ProductAnalyticLoaderState.initial() => ProductAnalyticLoaderState(
|
||||
productAnalytic: ProductAnalytic.empty(),
|
||||
failureOption: none(),
|
||||
);
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/analytic/analytic.dart';
|
||||
|
||||
part 'profit_loss_analytic_loader_event.dart';
|
||||
part 'profit_loss_analytic_loader_state.dart';
|
||||
part 'profit_loss_analytic_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class ProfitLossAnalyticLoaderBloc
|
||||
extends Bloc<ProfitLossAnalyticLoaderEvent, ProfitLossAnalyticLoaderState> {
|
||||
final IAnalyticRepository _analyticRepository;
|
||||
ProfitLossAnalyticLoaderBloc(this._analyticRepository)
|
||||
: super(ProfitLossAnalyticLoaderState.initial()) {
|
||||
on<ProfitLossAnalyticLoaderEvent>(_onProfitLossAnalyticLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onProfitLossAnalyticLoaderEvent(
|
||||
ProfitLossAnalyticLoaderEvent event,
|
||||
Emitter<ProfitLossAnalyticLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _analyticRepository.getProfitLoss(
|
||||
dateFrom: e.startDate,
|
||||
dateTo: e.endDate,
|
||||
);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(profitLoss) async {
|
||||
emit(
|
||||
state.copyWith(isFetching: false, profitLossAnalytic: profitLoss),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+483
@@ -0,0 +1,483 @@
|
||||
// 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 'profit_loss_analytic_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$ProfitLossAnalyticLoaderEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProfitLossAnalyticLoaderEventCopyWith<ProfitLossAnalyticLoaderEvent>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitLossAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory $ProfitLossAnalyticLoaderEventCopyWith(
|
||||
ProfitLossAnalyticLoaderEvent value,
|
||||
$Res Function(ProfitLossAnalyticLoaderEvent) then,
|
||||
) =
|
||||
_$ProfitLossAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
ProfitLossAnalyticLoaderEvent
|
||||
>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitLossAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProfitLossAnalyticLoaderEvent
|
||||
>
|
||||
implements $ProfitLossAnalyticLoaderEventCopyWith<$Res> {
|
||||
_$ProfitLossAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $ProfitLossAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$ProfitLossAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitLossAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) {
|
||||
return fetched?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements ProfitLossAnalyticLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ProfitLossAnalyticLoaderState {
|
||||
ProfitLossAnalytic get profitLossAnalytic =>
|
||||
throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ProfitLossAnalyticLoaderStateCopyWith<ProfitLossAnalyticLoaderState>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ProfitLossAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory $ProfitLossAnalyticLoaderStateCopyWith(
|
||||
ProfitLossAnalyticLoaderState value,
|
||||
$Res Function(ProfitLossAnalyticLoaderState) then,
|
||||
) =
|
||||
_$ProfitLossAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
ProfitLossAnalyticLoaderState
|
||||
>;
|
||||
@useResult
|
||||
$Res call({
|
||||
ProfitLossAnalytic profitLossAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ProfitLossAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends ProfitLossAnalyticLoaderState
|
||||
>
|
||||
implements $ProfitLossAnalyticLoaderStateCopyWith<$Res> {
|
||||
_$ProfitLossAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? profitLossAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
profitLossAnalytic: null == profitLossAnalytic
|
||||
? _value.profitLossAnalytic
|
||||
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitLossAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic {
|
||||
return $ProfitLossAnalyticCopyWith<$Res>(_value.profitLossAnalytic, (
|
||||
value,
|
||||
) {
|
||||
return _then(_value.copyWith(profitLossAnalytic: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ProfitLossAnalyticLoaderStateImplCopyWith<$Res>
|
||||
implements $ProfitLossAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory _$$ProfitLossAnalyticLoaderStateImplCopyWith(
|
||||
_$ProfitLossAnalyticLoaderStateImpl value,
|
||||
$Res Function(_$ProfitLossAnalyticLoaderStateImpl) then,
|
||||
) = __$$ProfitLossAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
ProfitLossAnalytic profitLossAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ProfitLossAnalyticLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$ProfitLossAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$ProfitLossAnalyticLoaderStateImpl
|
||||
>
|
||||
implements _$$ProfitLossAnalyticLoaderStateImplCopyWith<$Res> {
|
||||
__$$ProfitLossAnalyticLoaderStateImplCopyWithImpl(
|
||||
_$ProfitLossAnalyticLoaderStateImpl _value,
|
||||
$Res Function(_$ProfitLossAnalyticLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? profitLossAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$ProfitLossAnalyticLoaderStateImpl(
|
||||
profitLossAnalytic: null == profitLossAnalytic
|
||||
? _value.profitLossAnalytic
|
||||
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as ProfitLossAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ProfitLossAnalyticLoaderStateImpl
|
||||
implements _ProfitLossAnalyticLoaderState {
|
||||
_$ProfitLossAnalyticLoaderStateImpl({
|
||||
required this.profitLossAnalytic,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final ProfitLossAnalytic profitLossAnalytic;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProfitLossAnalyticLoaderState(profitLossAnalytic: $profitLossAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ProfitLossAnalyticLoaderStateImpl &&
|
||||
(identical(other.profitLossAnalytic, profitLossAnalytic) ||
|
||||
other.profitLossAnalytic == profitLossAnalytic) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, profitLossAnalytic, failureOption, isFetching);
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ProfitLossAnalyticLoaderStateImplCopyWith<
|
||||
_$ProfitLossAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith =>
|
||||
__$$ProfitLossAnalyticLoaderStateImplCopyWithImpl<
|
||||
_$ProfitLossAnalyticLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ProfitLossAnalyticLoaderState
|
||||
implements ProfitLossAnalyticLoaderState {
|
||||
factory _ProfitLossAnalyticLoaderState({
|
||||
required final ProfitLossAnalytic profitLossAnalytic,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$ProfitLossAnalyticLoaderStateImpl;
|
||||
|
||||
@override
|
||||
ProfitLossAnalytic get profitLossAnalytic;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ProfitLossAnalyticLoaderStateImplCopyWith<
|
||||
_$ProfitLossAnalyticLoaderStateImpl
|
||||
>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
part of 'profit_loss_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProfitLossAnalyticLoaderEvent with _$ProfitLossAnalyticLoaderEvent {
|
||||
const factory ProfitLossAnalyticLoaderEvent.fetched({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _Fetched;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
part of 'profit_loss_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ProfitLossAnalyticLoaderState with _$ProfitLossAnalyticLoaderState {
|
||||
factory ProfitLossAnalyticLoaderState({
|
||||
required ProfitLossAnalytic profitLossAnalytic,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _ProfitLossAnalyticLoaderState;
|
||||
|
||||
factory ProfitLossAnalyticLoaderState.initial() =>
|
||||
ProfitLossAnalyticLoaderState(
|
||||
profitLossAnalytic: ProfitLossAnalytic.empty(),
|
||||
failureOption: none(),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/analytic/analytic.dart';
|
||||
|
||||
part 'sales_analytic_loader_event.dart';
|
||||
part 'sales_analytic_loader_state.dart';
|
||||
part 'sales_analytic_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class SalesAnalyticLoaderBloc
|
||||
extends Bloc<SalesAnalyticLoaderEvent, SalesAnalyticLoaderState> {
|
||||
final IAnalyticRepository _analyticRepository;
|
||||
SalesAnalyticLoaderBloc(this._analyticRepository)
|
||||
: super(SalesAnalyticLoaderState.initial()) {
|
||||
on<SalesAnalyticLoaderEvent>(_onSalesAnalyticLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onSalesAnalyticLoaderEvent(
|
||||
SalesAnalyticLoaderEvent event,
|
||||
Emitter<SalesAnalyticLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _analyticRepository.getSales(
|
||||
dateFrom: e.startDate,
|
||||
dateTo: e.endDate,
|
||||
);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(sales) async {
|
||||
emit(state.copyWith(isFetching: false, salesAnalytic: sales));
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+466
@@ -0,0 +1,466 @@
|
||||
// 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 'sales_analytic_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$SalesAnalyticLoaderEvent {
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$SalesAnalyticLoaderEventCopyWith<SalesAnalyticLoaderEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $SalesAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory $SalesAnalyticLoaderEventCopyWith(
|
||||
SalesAnalyticLoaderEvent value,
|
||||
$Res Function(SalesAnalyticLoaderEvent) then,
|
||||
) = _$SalesAnalyticLoaderEventCopyWithImpl<$Res, SalesAnalyticLoaderEvent>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$SalesAnalyticLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends SalesAnalyticLoaderEvent
|
||||
>
|
||||
implements $SalesAnalyticLoaderEventCopyWith<$Res> {
|
||||
_$SalesAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$FetchedImplCopyWith<$Res>
|
||||
implements $SalesAnalyticLoaderEventCopyWith<$Res> {
|
||||
factory _$$FetchedImplCopyWith(
|
||||
_$FetchedImpl value,
|
||||
$Res Function(_$FetchedImpl) then,
|
||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$FetchedImplCopyWithImpl<$Res>
|
||||
extends _$SalesAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$FetchedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SalesAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$FetchedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
||||
}) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
}) {
|
||||
return fetched?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements SalesAnalyticLoaderEvent {
|
||||
const factory _Fetched({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$FetchedImpl;
|
||||
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$SalesAnalyticLoaderState {
|
||||
SalesAnalytic get salesAnalytic => throw _privateConstructorUsedError;
|
||||
Option<AnalyticFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$SalesAnalyticLoaderStateCopyWith<SalesAnalyticLoaderState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $SalesAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory $SalesAnalyticLoaderStateCopyWith(
|
||||
SalesAnalyticLoaderState value,
|
||||
$Res Function(SalesAnalyticLoaderState) then,
|
||||
) = _$SalesAnalyticLoaderStateCopyWithImpl<$Res, SalesAnalyticLoaderState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
SalesAnalytic salesAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$SalesAnalyticCopyWith<$Res> get salesAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$SalesAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends SalesAnalyticLoaderState
|
||||
>
|
||||
implements $SalesAnalyticLoaderStateCopyWith<$Res> {
|
||||
_$SalesAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? salesAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
salesAnalytic: null == salesAnalytic
|
||||
? _value.salesAnalytic
|
||||
: salesAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as SalesAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$SalesAnalyticCopyWith<$Res> get salesAnalytic {
|
||||
return $SalesAnalyticCopyWith<$Res>(_value.salesAnalytic, (value) {
|
||||
return _then(_value.copyWith(salesAnalytic: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SalesAnalyticLoaderStateImplCopyWith<$Res>
|
||||
implements $SalesAnalyticLoaderStateCopyWith<$Res> {
|
||||
factory _$$SalesAnalyticLoaderStateImplCopyWith(
|
||||
_$SalesAnalyticLoaderStateImpl value,
|
||||
$Res Function(_$SalesAnalyticLoaderStateImpl) then,
|
||||
) = __$$SalesAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
SalesAnalytic salesAnalytic,
|
||||
Option<AnalyticFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$SalesAnalyticCopyWith<$Res> get salesAnalytic;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SalesAnalyticLoaderStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$SalesAnalyticLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
_$SalesAnalyticLoaderStateImpl
|
||||
>
|
||||
implements _$$SalesAnalyticLoaderStateImplCopyWith<$Res> {
|
||||
__$$SalesAnalyticLoaderStateImplCopyWithImpl(
|
||||
_$SalesAnalyticLoaderStateImpl _value,
|
||||
$Res Function(_$SalesAnalyticLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? salesAnalytic = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$SalesAnalyticLoaderStateImpl(
|
||||
salesAnalytic: null == salesAnalytic
|
||||
? _value.salesAnalytic
|
||||
: salesAnalytic // ignore: cast_nullable_to_non_nullable
|
||||
as SalesAnalytic,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<AnalyticFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SalesAnalyticLoaderStateImpl implements _SalesAnalyticLoaderState {
|
||||
_$SalesAnalyticLoaderStateImpl({
|
||||
required this.salesAnalytic,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final SalesAnalytic salesAnalytic;
|
||||
@override
|
||||
final Option<AnalyticFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SalesAnalyticLoaderState(salesAnalytic: $salesAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SalesAnalyticLoaderStateImpl &&
|
||||
(identical(other.salesAnalytic, salesAnalytic) ||
|
||||
other.salesAnalytic == salesAnalytic) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, salesAnalytic, failureOption, isFetching);
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SalesAnalyticLoaderStateImplCopyWith<_$SalesAnalyticLoaderStateImpl>
|
||||
get copyWith =>
|
||||
__$$SalesAnalyticLoaderStateImplCopyWithImpl<
|
||||
_$SalesAnalyticLoaderStateImpl
|
||||
>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _SalesAnalyticLoaderState implements SalesAnalyticLoaderState {
|
||||
factory _SalesAnalyticLoaderState({
|
||||
required final SalesAnalytic salesAnalytic,
|
||||
required final Option<AnalyticFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$SalesAnalyticLoaderStateImpl;
|
||||
|
||||
@override
|
||||
SalesAnalytic get salesAnalytic;
|
||||
@override
|
||||
Option<AnalyticFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of SalesAnalyticLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SalesAnalyticLoaderStateImplCopyWith<_$SalesAnalyticLoaderStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
part of 'sales_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SalesAnalyticLoaderEvent with _$SalesAnalyticLoaderEvent {
|
||||
const factory SalesAnalyticLoaderEvent.fetched({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _Fetched;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
part of 'sales_analytic_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SalesAnalyticLoaderState with _$SalesAnalyticLoaderState {
|
||||
factory SalesAnalyticLoaderState({
|
||||
required SalesAnalytic salesAnalytic,
|
||||
required Option<AnalyticFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _SalesAnalyticLoaderState;
|
||||
|
||||
factory SalesAnalyticLoaderState.initial() => SalesAnalyticLoaderState(
|
||||
failureOption: none(),
|
||||
salesAnalytic: SalesAnalytic.empty(),
|
||||
);
|
||||
}
|
||||
@@ -33,16 +33,16 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
state.copyWith(
|
||||
failureOption: optionOf(f),
|
||||
status: token
|
||||
? AuthStatus.authenticated()
|
||||
: AuthStatus.unauthenticated(),
|
||||
? const AuthStatus.authenticated()
|
||||
: const AuthStatus.unauthenticated(),
|
||||
),
|
||||
),
|
||||
(user) => emit(
|
||||
state.copyWith(
|
||||
user: user,
|
||||
status: token
|
||||
? AuthStatus.authenticated()
|
||||
: AuthStatus.unauthenticated(),
|
||||
? const AuthStatus.authenticated()
|
||||
: const AuthStatus.unauthenticated(),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,6 +5,8 @@ import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../common/service/device_info_service.dart';
|
||||
import '../../../common/service/fcm_service.dart';
|
||||
import '../../../domain/auth/auth.dart';
|
||||
|
||||
part 'login_form_event.dart';
|
||||
@@ -14,7 +16,14 @@ part 'login_form_bloc.freezed.dart';
|
||||
@injectable
|
||||
class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
|
||||
final IAuthRepository _authRepository;
|
||||
LoginFormBloc(this._authRepository) : super(LoginFormState.initial()) {
|
||||
final FcmService _fcmService;
|
||||
final DeviceInfoService _deviceInfoService;
|
||||
|
||||
LoginFormBloc(
|
||||
this._authRepository,
|
||||
this._fcmService,
|
||||
this._deviceInfoService,
|
||||
) : super(LoginFormState.initial()) {
|
||||
on<LoginFormEvent>(_onLoginFormEvent);
|
||||
}
|
||||
|
||||
@@ -43,9 +52,14 @@ class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
|
||||
);
|
||||
|
||||
if (emailValid && passwordValid) {
|
||||
final fcmToken = await _fcmService.getToken() ?? '';
|
||||
final devicePayload = await _deviceInfoService.getDevicePayload();
|
||||
|
||||
failureOrLogin = await _authRepository.login(
|
||||
email: state.email,
|
||||
password: state.password,
|
||||
fcmToken: fcmToken,
|
||||
devicePayload: devicePayload,
|
||||
);
|
||||
|
||||
emit(
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/auth/auth.dart';
|
||||
|
||||
part 'logout_event.dart';
|
||||
part 'logout_state.dart';
|
||||
part 'logout_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class LogoutBloc extends Bloc<LogoutEvent, LogoutState> {
|
||||
final IAuthRepository _authRepository;
|
||||
LogoutBloc(this._authRepository) : super(LogoutState.initial()) {
|
||||
on<LogoutEvent>(_onLogoutEvent);
|
||||
}
|
||||
|
||||
Future<void> _onLogoutEvent(LogoutEvent event, Emitter<LogoutState> emit) {
|
||||
return event.map(
|
||||
logout: (e) async {
|
||||
Either<AuthFailure, Unit>? failureOrSuccess;
|
||||
emit(
|
||||
state.copyWith(isLoggingOut: true, logoutFailureOrSuccess: none()),
|
||||
);
|
||||
|
||||
failureOrSuccess = await _authRepository.logout();
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoggingOut: false,
|
||||
logoutFailureOrSuccess: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
// 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 'logout_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$LogoutEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({required TResult Function() logout}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({TResult? Function()? logout}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? logout,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Logout value) logout,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Logout value)? logout,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Logout value)? logout,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $LogoutEventCopyWith<$Res> {
|
||||
factory $LogoutEventCopyWith(
|
||||
LogoutEvent value,
|
||||
$Res Function(LogoutEvent) then,
|
||||
) = _$LogoutEventCopyWithImpl<$Res, LogoutEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$LogoutEventCopyWithImpl<$Res, $Val extends LogoutEvent>
|
||||
implements $LogoutEventCopyWith<$Res> {
|
||||
_$LogoutEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of LogoutEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LogoutImplCopyWith<$Res> {
|
||||
factory _$$LogoutImplCopyWith(
|
||||
_$LogoutImpl value,
|
||||
$Res Function(_$LogoutImpl) then,
|
||||
) = __$$LogoutImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LogoutImplCopyWithImpl<$Res>
|
||||
extends _$LogoutEventCopyWithImpl<$Res, _$LogoutImpl>
|
||||
implements _$$LogoutImplCopyWith<$Res> {
|
||||
__$$LogoutImplCopyWithImpl(
|
||||
_$LogoutImpl _value,
|
||||
$Res Function(_$LogoutImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of LogoutEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LogoutImpl implements _Logout {
|
||||
const _$LogoutImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LogoutEvent.logout()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$LogoutImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({required TResult Function() logout}) {
|
||||
return logout();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({TResult? Function()? logout}) {
|
||||
return logout?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? logout,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (logout != null) {
|
||||
return logout();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Logout value) logout,
|
||||
}) {
|
||||
return logout(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Logout value)? logout,
|
||||
}) {
|
||||
return logout?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Logout value)? logout,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (logout != null) {
|
||||
return logout(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Logout implements LogoutEvent {
|
||||
const factory _Logout() = _$LogoutImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$LogoutState {
|
||||
Option<Either<AuthFailure, Unit>> get logoutFailureOrSuccess =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isLoggingOut => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of LogoutState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$LogoutStateCopyWith<LogoutState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $LogoutStateCopyWith<$Res> {
|
||||
factory $LogoutStateCopyWith(
|
||||
LogoutState value,
|
||||
$Res Function(LogoutState) then,
|
||||
) = _$LogoutStateCopyWithImpl<$Res, LogoutState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
Option<Either<AuthFailure, Unit>> logoutFailureOrSuccess,
|
||||
bool isLoggingOut,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$LogoutStateCopyWithImpl<$Res, $Val extends LogoutState>
|
||||
implements $LogoutStateCopyWith<$Res> {
|
||||
_$LogoutStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of LogoutState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? logoutFailureOrSuccess = null,
|
||||
Object? isLoggingOut = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
logoutFailureOrSuccess: null == logoutFailureOrSuccess
|
||||
? _value.logoutFailureOrSuccess
|
||||
: logoutFailureOrSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<AuthFailure, Unit>>,
|
||||
isLoggingOut: null == isLoggingOut
|
||||
? _value.isLoggingOut
|
||||
: isLoggingOut // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$LogoutStateImplCopyWith<$Res>
|
||||
implements $LogoutStateCopyWith<$Res> {
|
||||
factory _$$LogoutStateImplCopyWith(
|
||||
_$LogoutStateImpl value,
|
||||
$Res Function(_$LogoutStateImpl) then,
|
||||
) = __$$LogoutStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
Option<Either<AuthFailure, Unit>> logoutFailureOrSuccess,
|
||||
bool isLoggingOut,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$LogoutStateImplCopyWithImpl<$Res>
|
||||
extends _$LogoutStateCopyWithImpl<$Res, _$LogoutStateImpl>
|
||||
implements _$$LogoutStateImplCopyWith<$Res> {
|
||||
__$$LogoutStateImplCopyWithImpl(
|
||||
_$LogoutStateImpl _value,
|
||||
$Res Function(_$LogoutStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of LogoutState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? logoutFailureOrSuccess = null,
|
||||
Object? isLoggingOut = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$LogoutStateImpl(
|
||||
logoutFailureOrSuccess: null == logoutFailureOrSuccess
|
||||
? _value.logoutFailureOrSuccess
|
||||
: logoutFailureOrSuccess // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<AuthFailure, Unit>>,
|
||||
isLoggingOut: null == isLoggingOut
|
||||
? _value.isLoggingOut
|
||||
: isLoggingOut // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$LogoutStateImpl implements _LogoutState {
|
||||
_$LogoutStateImpl({
|
||||
required this.logoutFailureOrSuccess,
|
||||
this.isLoggingOut = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final Option<Either<AuthFailure, Unit>> logoutFailureOrSuccess;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isLoggingOut;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'LogoutState(logoutFailureOrSuccess: $logoutFailureOrSuccess, isLoggingOut: $isLoggingOut)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$LogoutStateImpl &&
|
||||
(identical(other.logoutFailureOrSuccess, logoutFailureOrSuccess) ||
|
||||
other.logoutFailureOrSuccess == logoutFailureOrSuccess) &&
|
||||
(identical(other.isLoggingOut, isLoggingOut) ||
|
||||
other.isLoggingOut == isLoggingOut));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, logoutFailureOrSuccess, isLoggingOut);
|
||||
|
||||
/// Create a copy of LogoutState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$LogoutStateImplCopyWith<_$LogoutStateImpl> get copyWith =>
|
||||
__$$LogoutStateImplCopyWithImpl<_$LogoutStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _LogoutState implements LogoutState {
|
||||
factory _LogoutState({
|
||||
required final Option<Either<AuthFailure, Unit>> logoutFailureOrSuccess,
|
||||
final bool isLoggingOut,
|
||||
}) = _$LogoutStateImpl;
|
||||
|
||||
@override
|
||||
Option<Either<AuthFailure, Unit>> get logoutFailureOrSuccess;
|
||||
@override
|
||||
bool get isLoggingOut;
|
||||
|
||||
/// Create a copy of LogoutState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$LogoutStateImplCopyWith<_$LogoutStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'logout_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class LogoutEvent with _$LogoutEvent {
|
||||
const factory LogoutEvent.logout() = _Logout;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
part of 'logout_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class LogoutState with _$LogoutState {
|
||||
factory LogoutState({
|
||||
required Option<Either<AuthFailure, Unit>> logoutFailureOrSuccess,
|
||||
@Default(false) bool isLoggingOut,
|
||||
}) = _LogoutState;
|
||||
|
||||
factory LogoutState.initial() => LogoutState(logoutFailureOrSuccess: none());
|
||||
}
|
||||
@@ -175,7 +175,7 @@ class CategoryLoaderBloc
|
||||
_searchDebounce?.cancel();
|
||||
|
||||
// Debounce search for better UX
|
||||
_searchDebounce = Timer(Duration(milliseconds: 300), () async {
|
||||
_searchDebounce = Timer(const Duration(milliseconds: 300), () async {
|
||||
emit(state.copyWith(isLoadingMore: true));
|
||||
_isLoadingMore = false;
|
||||
|
||||
@@ -237,7 +237,7 @@ class CategoryLoaderBloc
|
||||
);
|
||||
|
||||
// After sync error, try to load local data
|
||||
Timer(Duration(seconds: 2), () {
|
||||
Timer(const Duration(seconds: 2), () {
|
||||
add(const CategoryLoaderEvent.getCategories());
|
||||
});
|
||||
},
|
||||
@@ -251,7 +251,7 @@ class CategoryLoaderBloc
|
||||
);
|
||||
|
||||
// After successful sync, load the updated data
|
||||
Timer(Duration(seconds: 1), () {
|
||||
Timer(const Duration(seconds: 1), () {
|
||||
add(const CategoryLoaderEvent.getCategories());
|
||||
});
|
||||
},
|
||||
|
||||
@@ -180,6 +180,9 @@ class CheckoutFormBloc extends Bloc<CheckoutFormEvent, CheckoutFormState> {
|
||||
orderAddedItems: (e) async {
|
||||
emit(state.copyWith(orderAdded: e.order));
|
||||
},
|
||||
customerNameChanged: (e) async {
|
||||
emit(state.copyWith(customerName: e.name,));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ mixin _$CheckoutFormEvent {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
@@ -39,6 +40,7 @@ mixin _$CheckoutFormEvent {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
@@ -50,6 +52,7 @@ mixin _$CheckoutFormEvent {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@@ -62,6 +65,7 @@ mixin _$CheckoutFormEvent {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
@@ -73,6 +77,7 @@ mixin _$CheckoutFormEvent {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
@@ -84,6 +89,7 @@ mixin _$CheckoutFormEvent {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -195,6 +201,7 @@ class _$StartedImpl implements _Started {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return started(items);
|
||||
}
|
||||
@@ -210,6 +217,7 @@ class _$StartedImpl implements _Started {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return started?.call(items);
|
||||
}
|
||||
@@ -225,6 +233,7 @@ class _$StartedImpl implements _Started {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (started != null) {
|
||||
@@ -244,6 +253,7 @@ class _$StartedImpl implements _Started {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return started(this);
|
||||
}
|
||||
@@ -259,6 +269,7 @@ class _$StartedImpl implements _Started {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return started?.call(this);
|
||||
}
|
||||
@@ -274,6 +285,7 @@ class _$StartedImpl implements _Started {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (started != null) {
|
||||
@@ -408,6 +420,7 @@ class _$AddItemImpl implements _AddItem {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return addItem(product, variant);
|
||||
}
|
||||
@@ -423,6 +436,7 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return addItem?.call(product, variant);
|
||||
}
|
||||
@@ -438,6 +452,7 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (addItem != null) {
|
||||
@@ -457,6 +472,7 @@ class _$AddItemImpl implements _AddItem {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return addItem(this);
|
||||
}
|
||||
@@ -472,6 +488,7 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return addItem?.call(this);
|
||||
}
|
||||
@@ -487,6 +504,7 @@ class _$AddItemImpl implements _AddItem {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (addItem != null) {
|
||||
@@ -623,6 +641,7 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return removeItem(product, variant);
|
||||
}
|
||||
@@ -638,6 +657,7 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return removeItem?.call(product, variant);
|
||||
}
|
||||
@@ -653,6 +673,7 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (removeItem != null) {
|
||||
@@ -672,6 +693,7 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return removeItem(this);
|
||||
}
|
||||
@@ -687,6 +709,7 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return removeItem?.call(this);
|
||||
}
|
||||
@@ -702,6 +725,7 @@ class _$RemoveItemImpl implements _RemoveItem {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (removeItem != null) {
|
||||
@@ -828,6 +852,7 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return updateItemNotes(product, notes);
|
||||
}
|
||||
@@ -843,6 +868,7 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return updateItemNotes?.call(product, notes);
|
||||
}
|
||||
@@ -858,6 +884,7 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateItemNotes != null) {
|
||||
@@ -877,6 +904,7 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return updateItemNotes(this);
|
||||
}
|
||||
@@ -892,6 +920,7 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return updateItemNotes?.call(this);
|
||||
}
|
||||
@@ -907,6 +936,7 @@ class _$UpdateItemNotesImpl implements _UpdateItemNotes {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateItemNotes != null) {
|
||||
@@ -1013,6 +1043,7 @@ class _$UpdateOrderTypeImpl implements _UpdateOrderType {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return updateOrderType(orderType);
|
||||
}
|
||||
@@ -1028,6 +1059,7 @@ class _$UpdateOrderTypeImpl implements _UpdateOrderType {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return updateOrderType?.call(orderType);
|
||||
}
|
||||
@@ -1043,6 +1075,7 @@ class _$UpdateOrderTypeImpl implements _UpdateOrderType {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateOrderType != null) {
|
||||
@@ -1062,6 +1095,7 @@ class _$UpdateOrderTypeImpl implements _UpdateOrderType {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return updateOrderType(this);
|
||||
}
|
||||
@@ -1077,6 +1111,7 @@ class _$UpdateOrderTypeImpl implements _UpdateOrderType {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return updateOrderType?.call(this);
|
||||
}
|
||||
@@ -1092,6 +1127,7 @@ class _$UpdateOrderTypeImpl implements _UpdateOrderType {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateOrderType != null) {
|
||||
@@ -1197,6 +1233,7 @@ class _$UpdateDeliveryImpl implements _UpdateDelivery {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return updateDelivery(delivery);
|
||||
}
|
||||
@@ -1212,6 +1249,7 @@ class _$UpdateDeliveryImpl implements _UpdateDelivery {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return updateDelivery?.call(delivery);
|
||||
}
|
||||
@@ -1227,6 +1265,7 @@ class _$UpdateDeliveryImpl implements _UpdateDelivery {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateDelivery != null) {
|
||||
@@ -1246,6 +1285,7 @@ class _$UpdateDeliveryImpl implements _UpdateDelivery {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return updateDelivery(this);
|
||||
}
|
||||
@@ -1261,6 +1301,7 @@ class _$UpdateDeliveryImpl implements _UpdateDelivery {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return updateDelivery?.call(this);
|
||||
}
|
||||
@@ -1276,6 +1317,7 @@ class _$UpdateDeliveryImpl implements _UpdateDelivery {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateDelivery != null) {
|
||||
@@ -1392,6 +1434,7 @@ class _$UpdateTableImpl implements _UpdateTable {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return updateTable(table);
|
||||
}
|
||||
@@ -1407,6 +1450,7 @@ class _$UpdateTableImpl implements _UpdateTable {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return updateTable?.call(table);
|
||||
}
|
||||
@@ -1422,6 +1466,7 @@ class _$UpdateTableImpl implements _UpdateTable {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateTable != null) {
|
||||
@@ -1441,6 +1486,7 @@ class _$UpdateTableImpl implements _UpdateTable {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return updateTable(this);
|
||||
}
|
||||
@@ -1456,6 +1502,7 @@ class _$UpdateTableImpl implements _UpdateTable {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return updateTable?.call(this);
|
||||
}
|
||||
@@ -1471,6 +1518,7 @@ class _$UpdateTableImpl implements _UpdateTable {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (updateTable != null) {
|
||||
@@ -1590,6 +1638,7 @@ class _$OrderAddedItemsImpl implements _OrderAddedItems {
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return orderAddedItems(order);
|
||||
}
|
||||
@@ -1605,6 +1654,7 @@ class _$OrderAddedItemsImpl implements _OrderAddedItems {
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return orderAddedItems?.call(order);
|
||||
}
|
||||
@@ -1620,6 +1670,7 @@ class _$OrderAddedItemsImpl implements _OrderAddedItems {
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (orderAddedItems != null) {
|
||||
@@ -1639,6 +1690,7 @@ class _$OrderAddedItemsImpl implements _OrderAddedItems {
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return orderAddedItems(this);
|
||||
}
|
||||
@@ -1654,6 +1706,7 @@ class _$OrderAddedItemsImpl implements _OrderAddedItems {
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return orderAddedItems?.call(this);
|
||||
}
|
||||
@@ -1669,6 +1722,7 @@ class _$OrderAddedItemsImpl implements _OrderAddedItems {
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (orderAddedItems != null) {
|
||||
@@ -1690,6 +1744,195 @@ abstract class _OrderAddedItems implements CheckoutFormEvent {
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CustomerNameChangedImplCopyWith<$Res> {
|
||||
factory _$$CustomerNameChangedImplCopyWith(
|
||||
_$CustomerNameChangedImpl value,
|
||||
$Res Function(_$CustomerNameChangedImpl) then,
|
||||
) = __$$CustomerNameChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String name});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CustomerNameChangedImplCopyWithImpl<$Res>
|
||||
extends _$CheckoutFormEventCopyWithImpl<$Res, _$CustomerNameChangedImpl>
|
||||
implements _$$CustomerNameChangedImplCopyWith<$Res> {
|
||||
__$$CustomerNameChangedImplCopyWithImpl(
|
||||
_$CustomerNameChangedImpl _value,
|
||||
$Res Function(_$CustomerNameChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CheckoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? name = null}) {
|
||||
return _then(
|
||||
_$CustomerNameChangedImpl(
|
||||
null == name
|
||||
? _value.name
|
||||
: name // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$CustomerNameChangedImpl implements _CustomerNameChanged {
|
||||
const _$CustomerNameChangedImpl(this.name);
|
||||
|
||||
@override
|
||||
final String name;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CheckoutFormEvent.customerNameChanged(name: $name)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CustomerNameChangedImpl &&
|
||||
(identical(other.name, name) || other.name == name));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, name);
|
||||
|
||||
/// Create a copy of CheckoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CustomerNameChangedImplCopyWith<_$CustomerNameChangedImpl> get copyWith =>
|
||||
__$$CustomerNameChangedImplCopyWithImpl<_$CustomerNameChangedImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(List<ProductQuantity> items) started,
|
||||
required TResult Function(Product product, ProductVariant? variant) addItem,
|
||||
required TResult Function(Product product, ProductVariant? variant)
|
||||
removeItem,
|
||||
required TResult Function(Product product, String notes) updateItemNotes,
|
||||
required TResult Function(OrderType orderType) updateOrderType,
|
||||
required TResult Function(Delivery delivery) updateDelivery,
|
||||
required TResult Function(Table? table) updateTable,
|
||||
required TResult Function(Order? order) orderAddedItems,
|
||||
required TResult Function(String name) customerNameChanged,
|
||||
}) {
|
||||
return customerNameChanged(name);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(List<ProductQuantity> items)? started,
|
||||
TResult? Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult? Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult? Function(Product product, String notes)? updateItemNotes,
|
||||
TResult? Function(OrderType orderType)? updateOrderType,
|
||||
TResult? Function(Delivery delivery)? updateDelivery,
|
||||
TResult? Function(Table? table)? updateTable,
|
||||
TResult? Function(Order? order)? orderAddedItems,
|
||||
TResult? Function(String name)? customerNameChanged,
|
||||
}) {
|
||||
return customerNameChanged?.call(name);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(List<ProductQuantity> items)? started,
|
||||
TResult Function(Product product, ProductVariant? variant)? addItem,
|
||||
TResult Function(Product product, ProductVariant? variant)? removeItem,
|
||||
TResult Function(Product product, String notes)? updateItemNotes,
|
||||
TResult Function(OrderType orderType)? updateOrderType,
|
||||
TResult Function(Delivery delivery)? updateDelivery,
|
||||
TResult Function(Table? table)? updateTable,
|
||||
TResult Function(Order? order)? orderAddedItems,
|
||||
TResult Function(String name)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (customerNameChanged != null) {
|
||||
return customerNameChanged(name);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Started value) started,
|
||||
required TResult Function(_AddItem value) addItem,
|
||||
required TResult Function(_RemoveItem value) removeItem,
|
||||
required TResult Function(_UpdateItemNotes value) updateItemNotes,
|
||||
required TResult Function(_UpdateOrderType value) updateOrderType,
|
||||
required TResult Function(_UpdateDelivery value) updateDelivery,
|
||||
required TResult Function(_UpdateTable value) updateTable,
|
||||
required TResult Function(_OrderAddedItems value) orderAddedItems,
|
||||
required TResult Function(_CustomerNameChanged value) customerNameChanged,
|
||||
}) {
|
||||
return customerNameChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Started value)? started,
|
||||
TResult? Function(_AddItem value)? addItem,
|
||||
TResult? Function(_RemoveItem value)? removeItem,
|
||||
TResult? Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult? Function(_UpdateOrderType value)? updateOrderType,
|
||||
TResult? Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult? Function(_UpdateTable value)? updateTable,
|
||||
TResult? Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult? Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
}) {
|
||||
return customerNameChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Started value)? started,
|
||||
TResult Function(_AddItem value)? addItem,
|
||||
TResult Function(_RemoveItem value)? removeItem,
|
||||
TResult Function(_UpdateItemNotes value)? updateItemNotes,
|
||||
TResult Function(_UpdateOrderType value)? updateOrderType,
|
||||
TResult Function(_UpdateDelivery value)? updateDelivery,
|
||||
TResult Function(_UpdateTable value)? updateTable,
|
||||
TResult Function(_OrderAddedItems value)? orderAddedItems,
|
||||
TResult Function(_CustomerNameChanged value)? customerNameChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (customerNameChanged != null) {
|
||||
return customerNameChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CustomerNameChanged implements CheckoutFormEvent {
|
||||
const factory _CustomerNameChanged(final String name) =
|
||||
_$CustomerNameChangedImpl;
|
||||
|
||||
String get name;
|
||||
|
||||
/// Create a copy of CheckoutFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CustomerNameChangedImplCopyWith<_$CustomerNameChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CheckoutFormState {
|
||||
Order? get orderAdded => throw _privateConstructorUsedError;
|
||||
@@ -1702,6 +1945,7 @@ mixin _$CheckoutFormState {
|
||||
int get totalPrice => throw _privateConstructorUsedError;
|
||||
String get draftName => throw _privateConstructorUsedError;
|
||||
OrderType get orderType => throw _privateConstructorUsedError;
|
||||
String get customerName => throw _privateConstructorUsedError;
|
||||
Delivery? get delivery => throw _privateConstructorUsedError;
|
||||
Table? get table => throw _privateConstructorUsedError;
|
||||
bool get isLoading => throw _privateConstructorUsedError;
|
||||
@@ -1731,6 +1975,7 @@ abstract class $CheckoutFormStateCopyWith<$Res> {
|
||||
int totalPrice,
|
||||
String draftName,
|
||||
OrderType orderType,
|
||||
String customerName,
|
||||
Delivery? delivery,
|
||||
Table? table,
|
||||
bool isLoading,
|
||||
@@ -1765,6 +2010,7 @@ class _$CheckoutFormStateCopyWithImpl<$Res, $Val extends CheckoutFormState>
|
||||
Object? totalPrice = null,
|
||||
Object? draftName = null,
|
||||
Object? orderType = null,
|
||||
Object? customerName = null,
|
||||
Object? delivery = freezed,
|
||||
Object? table = freezed,
|
||||
Object? isLoading = null,
|
||||
@@ -1811,6 +2057,10 @@ class _$CheckoutFormStateCopyWithImpl<$Res, $Val extends CheckoutFormState>
|
||||
? _value.orderType
|
||||
: orderType // ignore: cast_nullable_to_non_nullable
|
||||
as OrderType,
|
||||
customerName: null == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
delivery: freezed == delivery
|
||||
? _value.delivery
|
||||
: delivery // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1877,6 +2127,7 @@ abstract class _$$CheckoutFormStateImplCopyWith<$Res>
|
||||
int totalPrice,
|
||||
String draftName,
|
||||
OrderType orderType,
|
||||
String customerName,
|
||||
Delivery? delivery,
|
||||
Table? table,
|
||||
bool isLoading,
|
||||
@@ -1912,6 +2163,7 @@ class __$$CheckoutFormStateImplCopyWithImpl<$Res>
|
||||
Object? totalPrice = null,
|
||||
Object? draftName = null,
|
||||
Object? orderType = null,
|
||||
Object? customerName = null,
|
||||
Object? delivery = freezed,
|
||||
Object? table = freezed,
|
||||
Object? isLoading = null,
|
||||
@@ -1958,6 +2210,10 @@ class __$$CheckoutFormStateImplCopyWithImpl<$Res>
|
||||
? _value.orderType
|
||||
: orderType // ignore: cast_nullable_to_non_nullable
|
||||
as OrderType,
|
||||
customerName: null == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
delivery: freezed == delivery
|
||||
? _value.delivery
|
||||
: delivery // ignore: cast_nullable_to_non_nullable
|
||||
@@ -1989,6 +2245,7 @@ class _$CheckoutFormStateImpl implements _CheckoutFormState {
|
||||
required this.totalPrice,
|
||||
required this.draftName,
|
||||
required this.orderType,
|
||||
required this.customerName,
|
||||
this.delivery,
|
||||
this.table,
|
||||
this.isLoading = false,
|
||||
@@ -2021,6 +2278,8 @@ class _$CheckoutFormStateImpl implements _CheckoutFormState {
|
||||
@override
|
||||
final OrderType orderType;
|
||||
@override
|
||||
final String customerName;
|
||||
@override
|
||||
final Delivery? delivery;
|
||||
@override
|
||||
final Table? table;
|
||||
@@ -2030,7 +2289,7 @@ class _$CheckoutFormStateImpl implements _CheckoutFormState {
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CheckoutFormState(orderAdded: $orderAdded, items: $items, discount: $discount, discountAmount: $discountAmount, tax: $tax, serviceCharge: $serviceCharge, totalQuantity: $totalQuantity, totalPrice: $totalPrice, draftName: $draftName, orderType: $orderType, delivery: $delivery, table: $table, isLoading: $isLoading)';
|
||||
return 'CheckoutFormState(orderAdded: $orderAdded, items: $items, discount: $discount, discountAmount: $discountAmount, tax: $tax, serviceCharge: $serviceCharge, totalQuantity: $totalQuantity, totalPrice: $totalPrice, draftName: $draftName, orderType: $orderType, customerName: $customerName, delivery: $delivery, table: $table, isLoading: $isLoading)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -2056,6 +2315,8 @@ class _$CheckoutFormStateImpl implements _CheckoutFormState {
|
||||
other.draftName == draftName) &&
|
||||
(identical(other.orderType, orderType) ||
|
||||
other.orderType == orderType) &&
|
||||
(identical(other.customerName, customerName) ||
|
||||
other.customerName == customerName) &&
|
||||
(identical(other.delivery, delivery) ||
|
||||
other.delivery == delivery) &&
|
||||
(identical(other.table, table) || other.table == table) &&
|
||||
@@ -2076,6 +2337,7 @@ class _$CheckoutFormStateImpl implements _CheckoutFormState {
|
||||
totalPrice,
|
||||
draftName,
|
||||
orderType,
|
||||
customerName,
|
||||
delivery,
|
||||
table,
|
||||
isLoading,
|
||||
@@ -2105,6 +2367,7 @@ abstract class _CheckoutFormState implements CheckoutFormState {
|
||||
required final int totalPrice,
|
||||
required final String draftName,
|
||||
required final OrderType orderType,
|
||||
required final String customerName,
|
||||
final Delivery? delivery,
|
||||
final Table? table,
|
||||
final bool isLoading,
|
||||
@@ -2131,6 +2394,8 @@ abstract class _CheckoutFormState implements CheckoutFormState {
|
||||
@override
|
||||
OrderType get orderType;
|
||||
@override
|
||||
String get customerName;
|
||||
@override
|
||||
Delivery? get delivery;
|
||||
@override
|
||||
Table? get table;
|
||||
|
||||
@@ -30,4 +30,6 @@ class CheckoutFormEvent with _$CheckoutFormEvent {
|
||||
|
||||
const factory CheckoutFormEvent.orderAddedItems(Order? order) =
|
||||
_OrderAddedItems;
|
||||
const factory CheckoutFormEvent.customerNameChanged(String name) =
|
||||
_CustomerNameChanged;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class CheckoutFormState with _$CheckoutFormState {
|
||||
required int totalPrice,
|
||||
required String draftName,
|
||||
required OrderType orderType,
|
||||
required String customerName,
|
||||
Delivery? delivery,
|
||||
Table? table,
|
||||
@Default(false) bool isLoading,
|
||||
@@ -27,6 +28,7 @@ class CheckoutFormState with _$CheckoutFormState {
|
||||
totalQuantity: 0,
|
||||
totalPrice: 0,
|
||||
draftName: '',
|
||||
customerName: '',
|
||||
orderType: OrderType.dineIn,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:dartz/dartz.dart' hide Order;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../../../common/types/order_type.dart';
|
||||
import '../../../domain/customer/customer.dart';
|
||||
@@ -123,10 +124,15 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
||||
addItemOrder: (e) async {
|
||||
Either<OrderFailure, Order> failureOrAddItemOrder;
|
||||
|
||||
// Generate new idempotency key saat user intent (tap Add Items)
|
||||
// Kalau sedang retry, pakai key yang sama
|
||||
final idempotencyKey = state.addItemIdempotencyKey ?? const Uuid().v4();
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isAddingItemOrder: true,
|
||||
failureOrAddItemOrder: none(),
|
||||
addItemIdempotencyKey: idempotencyKey,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -145,12 +151,16 @@ class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
||||
failureOrAddItemOrder = await _repository.addItemOrder(
|
||||
id: e.orderId,
|
||||
request: request,
|
||||
idempotencyKey: idempotencyKey,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isAddingItemOrder: false,
|
||||
failureOrAddItemOrder: optionOf(failureOrAddItemOrder),
|
||||
// Clear key on success, keep on failure for retry
|
||||
addItemIdempotencyKey:
|
||||
failureOrAddItemOrder.isRight() ? null : idempotencyKey,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -1584,6 +1584,11 @@ mixin _$OrderFormState {
|
||||
bool get isCreatingWithPayment => throw _privateConstructorUsedError;
|
||||
bool get isAddingItemOrder => throw _privateConstructorUsedError;
|
||||
|
||||
/// Idempotency key untuk add item order.
|
||||
/// Di-generate saat user tap "Add Items", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
String? get addItemIdempotencyKey => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -1608,6 +1613,7 @@ abstract class $OrderFormStateCopyWith<$Res> {
|
||||
bool isCreating,
|
||||
bool isCreatingWithPayment,
|
||||
bool isAddingItemOrder,
|
||||
String? addItemIdempotencyKey,
|
||||
});
|
||||
|
||||
$PaymentMethodCopyWith<$Res>? get paymentMethod;
|
||||
@@ -1638,6 +1644,7 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
|
||||
Object? isCreating = null,
|
||||
Object? isCreatingWithPayment = null,
|
||||
Object? isAddingItemOrder = null,
|
||||
Object? addItemIdempotencyKey = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
@@ -1678,6 +1685,10 @@ class _$OrderFormStateCopyWithImpl<$Res, $Val extends OrderFormState>
|
||||
? _value.isAddingItemOrder
|
||||
: isAddingItemOrder // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
addItemIdempotencyKey: freezed == addItemIdempotencyKey
|
||||
? _value.addItemIdempotencyKey
|
||||
: addItemIdempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
@@ -1731,6 +1742,7 @@ abstract class _$$OrderFormStateImplCopyWith<$Res>
|
||||
bool isCreating,
|
||||
bool isCreatingWithPayment,
|
||||
bool isAddingItemOrder,
|
||||
String? addItemIdempotencyKey,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -1762,6 +1774,7 @@ class __$$OrderFormStateImplCopyWithImpl<$Res>
|
||||
Object? isCreating = null,
|
||||
Object? isCreatingWithPayment = null,
|
||||
Object? isAddingItemOrder = null,
|
||||
Object? addItemIdempotencyKey = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$OrderFormStateImpl(
|
||||
@@ -1801,6 +1814,10 @@ class __$$OrderFormStateImplCopyWithImpl<$Res>
|
||||
? _value.isAddingItemOrder
|
||||
: isAddingItemOrder // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
addItemIdempotencyKey: freezed == addItemIdempotencyKey
|
||||
? _value.addItemIdempotencyKey
|
||||
: addItemIdempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1821,6 +1838,7 @@ class _$OrderFormStateImpl
|
||||
this.isCreating = false,
|
||||
this.isCreatingWithPayment = false,
|
||||
this.isAddingItemOrder = false,
|
||||
this.addItemIdempotencyKey,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -1845,9 +1863,15 @@ class _$OrderFormStateImpl
|
||||
@JsonKey()
|
||||
final bool isAddingItemOrder;
|
||||
|
||||
/// Idempotency key untuk add item order.
|
||||
/// Di-generate saat user tap "Add Items", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
@override
|
||||
final String? addItemIdempotencyKey;
|
||||
|
||||
@override
|
||||
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||
return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer, failureOrCreateOrder: $failureOrCreateOrder, failureOrCreateOrderWithPayment: $failureOrCreateOrderWithPayment, failureOrAddItemOrder: $failureOrAddItemOrder, isCreating: $isCreating, isCreatingWithPayment: $isCreatingWithPayment, isAddingItemOrder: $isAddingItemOrder)';
|
||||
return 'OrderFormState(paymentMethod: $paymentMethod, customerName: $customerName, customer: $customer, failureOrCreateOrder: $failureOrCreateOrder, failureOrCreateOrderWithPayment: $failureOrCreateOrderWithPayment, failureOrAddItemOrder: $failureOrAddItemOrder, isCreating: $isCreating, isCreatingWithPayment: $isCreatingWithPayment, isAddingItemOrder: $isAddingItemOrder, addItemIdempotencyKey: $addItemIdempotencyKey)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1868,7 +1892,10 @@ class _$OrderFormStateImpl
|
||||
..add(DiagnosticsProperty('failureOrAddItemOrder', failureOrAddItemOrder))
|
||||
..add(DiagnosticsProperty('isCreating', isCreating))
|
||||
..add(DiagnosticsProperty('isCreatingWithPayment', isCreatingWithPayment))
|
||||
..add(DiagnosticsProperty('isAddingItemOrder', isAddingItemOrder));
|
||||
..add(DiagnosticsProperty('isAddingItemOrder', isAddingItemOrder))
|
||||
..add(
|
||||
DiagnosticsProperty('addItemIdempotencyKey', addItemIdempotencyKey),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1897,7 +1924,9 @@ class _$OrderFormStateImpl
|
||||
(identical(other.isCreatingWithPayment, isCreatingWithPayment) ||
|
||||
other.isCreatingWithPayment == isCreatingWithPayment) &&
|
||||
(identical(other.isAddingItemOrder, isAddingItemOrder) ||
|
||||
other.isAddingItemOrder == isAddingItemOrder));
|
||||
other.isAddingItemOrder == isAddingItemOrder) &&
|
||||
(identical(other.addItemIdempotencyKey, addItemIdempotencyKey) ||
|
||||
other.addItemIdempotencyKey == addItemIdempotencyKey));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1912,6 +1941,7 @@ class _$OrderFormStateImpl
|
||||
isCreating,
|
||||
isCreatingWithPayment,
|
||||
isAddingItemOrder,
|
||||
addItemIdempotencyKey,
|
||||
);
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
@@ -1938,6 +1968,7 @@ abstract class _OrderFormState implements OrderFormState {
|
||||
final bool isCreating,
|
||||
final bool isCreatingWithPayment,
|
||||
final bool isAddingItemOrder,
|
||||
final String? addItemIdempotencyKey,
|
||||
}) = _$OrderFormStateImpl;
|
||||
|
||||
@override
|
||||
@@ -1959,6 +1990,12 @@ abstract class _OrderFormState implements OrderFormState {
|
||||
@override
|
||||
bool get isAddingItemOrder;
|
||||
|
||||
/// Idempotency key untuk add item order.
|
||||
/// Di-generate saat user tap "Add Items", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
@override
|
||||
String? get addItemIdempotencyKey;
|
||||
|
||||
/// Create a copy of OrderFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
|
||||
@@ -13,6 +13,10 @@ class OrderFormState with _$OrderFormState {
|
||||
@Default(false) bool isCreating,
|
||||
@Default(false) bool isCreatingWithPayment,
|
||||
@Default(false) bool isAddingItemOrder,
|
||||
/// Idempotency key untuk add item order.
|
||||
/// Di-generate saat user tap "Add Items", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
String? addItemIdempotencyKey,
|
||||
}) = _OrderFormState;
|
||||
|
||||
factory OrderFormState.initial() => OrderFormState(
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart' hide Order;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../../../common/types/split_type.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../domain/payment_method/payment_method.dart';
|
||||
|
||||
@@ -35,7 +39,15 @@ class PaymentFormBloc extends Bloc<PaymentFormEvent, PaymentFormState> {
|
||||
submitted: (e) async {
|
||||
Either<OrderFailure, Payment> failureOrPayment;
|
||||
|
||||
emit(state.copyWith(isSubmitting: true, failureOrPayment: none()));
|
||||
// Generate new idempotency key saat user intent (tap Bayar)
|
||||
// Kalau sedang retry (isSubmitting sebelumnya gagal), pakai key yang sama
|
||||
final idempotencyKey = state.idempotencyKey ?? const Uuid().v4();
|
||||
|
||||
emit(state.copyWith(
|
||||
isSubmitting: true,
|
||||
failureOrPayment: none(),
|
||||
idempotencyKey: idempotencyKey,
|
||||
));
|
||||
|
||||
final request = PaymentRequest(
|
||||
orderId: state.order.id,
|
||||
@@ -55,12 +67,65 @@ class PaymentFormBloc extends Bloc<PaymentFormEvent, PaymentFormState> {
|
||||
.toList(),
|
||||
);
|
||||
|
||||
failureOrPayment = await _repository.createPayment(request: request);
|
||||
failureOrPayment = await _repository.createPayment(
|
||||
request: request,
|
||||
idempotencyKey: idempotencyKey,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: false,
|
||||
failureOrPayment: optionOf(failureOrPayment),
|
||||
// Clear key on success, keep on failure for retry
|
||||
idempotencyKey: failureOrPayment.isRight() ? null : idempotencyKey,
|
||||
),
|
||||
);
|
||||
},
|
||||
submittedSplitBill: (e) async {
|
||||
Either<OrderFailure, Payment> failureOrPayment;
|
||||
|
||||
// Generate new idempotency key untuk split bill
|
||||
final idempotencyKey = state.splitBillIdempotencyKey ?? const Uuid().v4();
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: true,
|
||||
failureOrPaymentSplitBill: none(),
|
||||
splitBillIdempotencyKey: idempotencyKey,
|
||||
),
|
||||
);
|
||||
|
||||
final request = PaymentSplitBillRequest(
|
||||
orderId: state.order.id,
|
||||
paymentMethodId: state.paymentMethod?.id ?? '',
|
||||
amount: state.order.totalAmount,
|
||||
customerId: e.customerId ?? '',
|
||||
type: e.splitType ?? SplitType.unknown,
|
||||
customerName: e.customerName ?? '',
|
||||
items: state.pendingItems
|
||||
.map(
|
||||
(item) => PaymentItemSplitBillRequest(
|
||||
orderItemId: item.id,
|
||||
quantity: item.quantity,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
log(request.toString());
|
||||
|
||||
failureOrPayment = await _repository.createSplitBill(
|
||||
request,
|
||||
idempotencyKey: idempotencyKey,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: false,
|
||||
failureOrPaymentSplitBill: optionOf(failureOrPayment),
|
||||
// Clear key on success, keep on failure for retry
|
||||
splitBillIdempotencyKey:
|
||||
failureOrPayment.isRight() ? null : idempotencyKey,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -22,18 +22,36 @@ mixin _$PaymentFormEvent {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
@@ -41,18 +59,21 @@ mixin _$PaymentFormEvent {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -164,6 +185,12 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setOrder(order);
|
||||
}
|
||||
@@ -174,6 +201,12 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setOrder?.call(order);
|
||||
}
|
||||
@@ -184,6 +217,12 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
@@ -198,6 +237,7 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return setOrder(this);
|
||||
}
|
||||
@@ -208,6 +248,7 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return setOrder?.call(this);
|
||||
}
|
||||
@@ -218,6 +259,7 @@ class _$SetOrderImpl implements _SetOrder {
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
@@ -325,6 +367,12 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod(paymentMethod);
|
||||
}
|
||||
@@ -335,6 +383,12 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod?.call(paymentMethod);
|
||||
}
|
||||
@@ -345,6 +399,12 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setPaymentMethod != null) {
|
||||
@@ -359,6 +419,7 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod(this);
|
||||
}
|
||||
@@ -369,6 +430,7 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return setPaymentMethod?.call(this);
|
||||
}
|
||||
@@ -379,6 +441,7 @@ class _$SetPaymentImpl implements _SetPayment {
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setPaymentMethod != null) {
|
||||
@@ -447,6 +510,12 @@ class _$SubmittedImpl implements _Submitted {
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submitted();
|
||||
}
|
||||
@@ -457,6 +526,12 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submitted?.call();
|
||||
}
|
||||
@@ -467,6 +542,12 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
@@ -481,6 +562,7 @@ class _$SubmittedImpl implements _Submitted {
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return submitted(this);
|
||||
}
|
||||
@@ -491,6 +573,7 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return submitted?.call(this);
|
||||
}
|
||||
@@ -501,6 +584,7 @@ class _$SubmittedImpl implements _Submitted {
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
@@ -514,15 +598,229 @@ abstract class _Submitted implements PaymentFormEvent {
|
||||
const factory _Submitted() = _$SubmittedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SubmittedSplitBillImplCopyWith<$Res> {
|
||||
factory _$$SubmittedSplitBillImplCopyWith(
|
||||
_$SubmittedSplitBillImpl value,
|
||||
$Res Function(_$SubmittedSplitBillImpl) then,
|
||||
) = __$$SubmittedSplitBillImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({SplitType? splitType, String? customerId, String? customerName});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SubmittedSplitBillImplCopyWithImpl<$Res>
|
||||
extends _$PaymentFormEventCopyWithImpl<$Res, _$SubmittedSplitBillImpl>
|
||||
implements _$$SubmittedSplitBillImplCopyWith<$Res> {
|
||||
__$$SubmittedSplitBillImplCopyWithImpl(
|
||||
_$SubmittedSplitBillImpl _value,
|
||||
$Res Function(_$SubmittedSplitBillImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? splitType = freezed,
|
||||
Object? customerId = freezed,
|
||||
Object? customerName = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$SubmittedSplitBillImpl(
|
||||
splitType: freezed == splitType
|
||||
? _value.splitType
|
||||
: splitType // ignore: cast_nullable_to_non_nullable
|
||||
as SplitType?,
|
||||
customerId: freezed == customerId
|
||||
? _value.customerId
|
||||
: customerId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
customerName: freezed == customerName
|
||||
? _value.customerName
|
||||
: customerName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SubmittedSplitBillImpl implements _SubmittedSplitBill {
|
||||
const _$SubmittedSplitBillImpl({
|
||||
this.splitType,
|
||||
this.customerId,
|
||||
this.customerName,
|
||||
});
|
||||
|
||||
@override
|
||||
final SplitType? splitType;
|
||||
@override
|
||||
final String? customerId;
|
||||
@override
|
||||
final String? customerName;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormEvent.submittedSplitBill(splitType: $splitType, customerId: $customerId, customerName: $customerName)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SubmittedSplitBillImpl &&
|
||||
(identical(other.splitType, splitType) ||
|
||||
other.splitType == splitType) &&
|
||||
(identical(other.customerId, customerId) ||
|
||||
other.customerId == customerId) &&
|
||||
(identical(other.customerName, customerName) ||
|
||||
other.customerName == customerName));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, splitType, customerId, customerName);
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SubmittedSplitBillImplCopyWith<_$SubmittedSplitBillImpl> get copyWith =>
|
||||
__$$SubmittedSplitBillImplCopyWithImpl<_$SubmittedSplitBillImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(PaymentMethod paymentMethod) setPaymentMethod,
|
||||
required TResult Function() submitted,
|
||||
required TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill(splitType, customerId, customerName);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult? Function()? submitted,
|
||||
TResult? Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill?.call(splitType, customerId, customerName);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(PaymentMethod paymentMethod)? setPaymentMethod,
|
||||
TResult Function()? submitted,
|
||||
TResult Function(
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
)?
|
||||
submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submittedSplitBill != null) {
|
||||
return submittedSplitBill(splitType, customerId, customerName);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_SetPayment value) setPaymentMethod,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
required TResult Function(_SubmittedSplitBill value) submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
TResult? Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
}) {
|
||||
return submittedSplitBill?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_SetPayment value)? setPaymentMethod,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
TResult Function(_SubmittedSplitBill value)? submittedSplitBill,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submittedSplitBill != null) {
|
||||
return submittedSplitBill(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SubmittedSplitBill implements PaymentFormEvent {
|
||||
const factory _SubmittedSplitBill({
|
||||
final SplitType? splitType,
|
||||
final String? customerId,
|
||||
final String? customerName,
|
||||
}) = _$SubmittedSplitBillImpl;
|
||||
|
||||
SplitType? get splitType;
|
||||
String? get customerId;
|
||||
String? get customerName;
|
||||
|
||||
/// Create a copy of PaymentFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SubmittedSplitBillImplCopyWith<_$SubmittedSplitBillImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentFormState {
|
||||
Order get order => throw _privateConstructorUsedError;
|
||||
List<OrderItem> get pendingItems => throw _privateConstructorUsedError;
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPayment =>
|
||||
throw _privateConstructorUsedError;
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPaymentSplitBill =>
|
||||
throw _privateConstructorUsedError;
|
||||
PaymentMethod? get paymentMethod => throw _privateConstructorUsedError;
|
||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||
|
||||
/// Idempotency key untuk payment submission.
|
||||
/// Di-generate saat user tap "Bayar", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
String? get idempotencyKey => throw _privateConstructorUsedError;
|
||||
|
||||
/// Idempotency key untuk split bill submission.
|
||||
String? get splitBillIdempotencyKey => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -541,8 +839,11 @@ abstract class $PaymentFormStateCopyWith<$Res> {
|
||||
Order order,
|
||||
List<OrderItem> pendingItems,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill,
|
||||
PaymentMethod? paymentMethod,
|
||||
bool isSubmitting,
|
||||
String? idempotencyKey,
|
||||
String? splitBillIdempotencyKey,
|
||||
});
|
||||
|
||||
$OrderCopyWith<$Res> get order;
|
||||
@@ -567,8 +868,11 @@ class _$PaymentFormStateCopyWithImpl<$Res, $Val extends PaymentFormState>
|
||||
Object? order = null,
|
||||
Object? pendingItems = null,
|
||||
Object? failureOrPayment = null,
|
||||
Object? failureOrPaymentSplitBill = null,
|
||||
Object? paymentMethod = freezed,
|
||||
Object? isSubmitting = null,
|
||||
Object? idempotencyKey = freezed,
|
||||
Object? splitBillIdempotencyKey = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
@@ -584,6 +888,10 @@ class _$PaymentFormStateCopyWithImpl<$Res, $Val extends PaymentFormState>
|
||||
? _value.failureOrPayment
|
||||
: failureOrPayment // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
failureOrPaymentSplitBill: null == failureOrPaymentSplitBill
|
||||
? _value.failureOrPaymentSplitBill
|
||||
: failureOrPaymentSplitBill // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
paymentMethod: freezed == paymentMethod
|
||||
? _value.paymentMethod
|
||||
: paymentMethod // ignore: cast_nullable_to_non_nullable
|
||||
@@ -592,6 +900,14 @@ class _$PaymentFormStateCopyWithImpl<$Res, $Val extends PaymentFormState>
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
idempotencyKey: freezed == idempotencyKey
|
||||
? _value.idempotencyKey
|
||||
: idempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
splitBillIdempotencyKey: freezed == splitBillIdempotencyKey
|
||||
? _value.splitBillIdempotencyKey
|
||||
: splitBillIdempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
@@ -635,8 +951,11 @@ abstract class _$$PaymentFormStateImplCopyWith<$Res>
|
||||
Order order,
|
||||
List<OrderItem> pendingItems,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill,
|
||||
PaymentMethod? paymentMethod,
|
||||
bool isSubmitting,
|
||||
String? idempotencyKey,
|
||||
String? splitBillIdempotencyKey,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -662,8 +981,11 @@ class __$$PaymentFormStateImplCopyWithImpl<$Res>
|
||||
Object? order = null,
|
||||
Object? pendingItems = null,
|
||||
Object? failureOrPayment = null,
|
||||
Object? failureOrPaymentSplitBill = null,
|
||||
Object? paymentMethod = freezed,
|
||||
Object? isSubmitting = null,
|
||||
Object? idempotencyKey = freezed,
|
||||
Object? splitBillIdempotencyKey = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$PaymentFormStateImpl(
|
||||
@@ -679,6 +1001,10 @@ class __$$PaymentFormStateImplCopyWithImpl<$Res>
|
||||
? _value.failureOrPayment
|
||||
: failureOrPayment // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
failureOrPaymentSplitBill: null == failureOrPaymentSplitBill
|
||||
? _value.failureOrPaymentSplitBill
|
||||
: failureOrPaymentSplitBill // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Payment>>,
|
||||
paymentMethod: freezed == paymentMethod
|
||||
? _value.paymentMethod
|
||||
: paymentMethod // ignore: cast_nullable_to_non_nullable
|
||||
@@ -687,6 +1013,14 @@ class __$$PaymentFormStateImplCopyWithImpl<$Res>
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
idempotencyKey: freezed == idempotencyKey
|
||||
? _value.idempotencyKey
|
||||
: idempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
splitBillIdempotencyKey: freezed == splitBillIdempotencyKey
|
||||
? _value.splitBillIdempotencyKey
|
||||
: splitBillIdempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -699,8 +1033,11 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
required this.order,
|
||||
required final List<OrderItem> pendingItems,
|
||||
required this.failureOrPayment,
|
||||
required this.failureOrPaymentSplitBill,
|
||||
this.paymentMethod,
|
||||
this.isSubmitting = false,
|
||||
this.idempotencyKey,
|
||||
this.splitBillIdempotencyKey,
|
||||
}) : _pendingItems = pendingItems;
|
||||
|
||||
@override
|
||||
@@ -716,14 +1053,26 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
@override
|
||||
final Option<Either<OrderFailure, Payment>> failureOrPayment;
|
||||
@override
|
||||
final Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill;
|
||||
@override
|
||||
final PaymentMethod? paymentMethod;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isSubmitting;
|
||||
|
||||
/// Idempotency key untuk payment submission.
|
||||
/// Di-generate saat user tap "Bayar", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
@override
|
||||
final String? idempotencyKey;
|
||||
|
||||
/// Idempotency key untuk split bill submission.
|
||||
@override
|
||||
final String? splitBillIdempotencyKey;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentFormState(order: $order, pendingItems: $pendingItems, failureOrPayment: $failureOrPayment, paymentMethod: $paymentMethod, isSubmitting: $isSubmitting)';
|
||||
return 'PaymentFormState(order: $order, pendingItems: $pendingItems, failureOrPayment: $failureOrPayment, failureOrPaymentSplitBill: $failureOrPaymentSplitBill, paymentMethod: $paymentMethod, isSubmitting: $isSubmitting, idempotencyKey: $idempotencyKey, splitBillIdempotencyKey: $splitBillIdempotencyKey)';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -738,10 +1087,22 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
) &&
|
||||
(identical(other.failureOrPayment, failureOrPayment) ||
|
||||
other.failureOrPayment == failureOrPayment) &&
|
||||
(identical(
|
||||
other.failureOrPaymentSplitBill,
|
||||
failureOrPaymentSplitBill,
|
||||
) ||
|
||||
other.failureOrPaymentSplitBill == failureOrPaymentSplitBill) &&
|
||||
(identical(other.paymentMethod, paymentMethod) ||
|
||||
other.paymentMethod == paymentMethod) &&
|
||||
(identical(other.isSubmitting, isSubmitting) ||
|
||||
other.isSubmitting == isSubmitting));
|
||||
other.isSubmitting == isSubmitting) &&
|
||||
(identical(other.idempotencyKey, idempotencyKey) ||
|
||||
other.idempotencyKey == idempotencyKey) &&
|
||||
(identical(
|
||||
other.splitBillIdempotencyKey,
|
||||
splitBillIdempotencyKey,
|
||||
) ||
|
||||
other.splitBillIdempotencyKey == splitBillIdempotencyKey));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -750,8 +1111,11 @@ class _$PaymentFormStateImpl implements _PaymentFormState {
|
||||
order,
|
||||
const DeepCollectionEquality().hash(_pendingItems),
|
||||
failureOrPayment,
|
||||
failureOrPaymentSplitBill,
|
||||
paymentMethod,
|
||||
isSubmitting,
|
||||
idempotencyKey,
|
||||
splitBillIdempotencyKey,
|
||||
);
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
@@ -771,8 +1135,12 @@ abstract class _PaymentFormState implements PaymentFormState {
|
||||
required final Order order,
|
||||
required final List<OrderItem> pendingItems,
|
||||
required final Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
required final Option<Either<OrderFailure, Payment>>
|
||||
failureOrPaymentSplitBill,
|
||||
final PaymentMethod? paymentMethod,
|
||||
final bool isSubmitting,
|
||||
final String? idempotencyKey,
|
||||
final String? splitBillIdempotencyKey,
|
||||
}) = _$PaymentFormStateImpl;
|
||||
|
||||
@override
|
||||
@@ -782,10 +1150,22 @@ abstract class _PaymentFormState implements PaymentFormState {
|
||||
@override
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPayment;
|
||||
@override
|
||||
Option<Either<OrderFailure, Payment>> get failureOrPaymentSplitBill;
|
||||
@override
|
||||
PaymentMethod? get paymentMethod;
|
||||
@override
|
||||
bool get isSubmitting;
|
||||
|
||||
/// Idempotency key untuk payment submission.
|
||||
/// Di-generate saat user tap "Bayar", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
@override
|
||||
String? get idempotencyKey;
|
||||
|
||||
/// Idempotency key untuk split bill submission.
|
||||
@override
|
||||
String? get splitBillIdempotencyKey;
|
||||
|
||||
/// Create a copy of PaymentFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
|
||||
@@ -6,4 +6,9 @@ class PaymentFormEvent with _$PaymentFormEvent {
|
||||
const factory PaymentFormEvent.setPaymentMethod(PaymentMethod paymentMethod) =
|
||||
_SetPayment;
|
||||
const factory PaymentFormEvent.submitted() = _Submitted;
|
||||
const factory PaymentFormEvent.submittedSplitBill({
|
||||
SplitType? splitType,
|
||||
String? customerId,
|
||||
String? customerName,
|
||||
}) = _SubmittedSplitBill;
|
||||
}
|
||||
|
||||
@@ -6,13 +6,21 @@ class PaymentFormState with _$PaymentFormState {
|
||||
required Order order,
|
||||
required List<OrderItem> pendingItems,
|
||||
required Option<Either<OrderFailure, Payment>> failureOrPayment,
|
||||
required Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill,
|
||||
PaymentMethod? paymentMethod,
|
||||
@Default(false) bool isSubmitting,
|
||||
/// Idempotency key untuk payment submission.
|
||||
/// Di-generate saat user tap "Bayar", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
String? idempotencyKey,
|
||||
/// Idempotency key untuk split bill submission.
|
||||
String? splitBillIdempotencyKey,
|
||||
}) = _PaymentFormState;
|
||||
|
||||
factory PaymentFormState.initial() => PaymentFormState(
|
||||
order: Order.empty(),
|
||||
pendingItems: [],
|
||||
failureOrPayment: none(),
|
||||
failureOrPaymentSplitBill: none(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../../domain/printer/printer.dart';
|
||||
|
||||
part 'bluetooth_connect_event.dart';
|
||||
part 'bluetooth_connect_state.dart';
|
||||
part 'bluetooth_connect_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class BluetoothConnectBloc
|
||||
extends Bloc<BluetoothConnectEvent, BluetoothConnectState> {
|
||||
final IPrinterRepository _printerRepository;
|
||||
BluetoothConnectBloc(this._printerRepository)
|
||||
: super(BluetoothConnectState.initial()) {
|
||||
on<BluetoothConnectEvent>(_onBluetoothConnectEvent);
|
||||
}
|
||||
|
||||
Future<void> _onBluetoothConnectEvent(
|
||||
BluetoothConnectEvent event,
|
||||
Emitter<BluetoothConnectState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
connect: (e) async {
|
||||
emit(state.copyWith(isConnecting: true, failureOrSuccee: none()));
|
||||
|
||||
final result = await _printerRepository.connectBluetooth(e.macAddress);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(state.copyWith(isConnecting: false)),
|
||||
(success) => emit(state.copyWith(isConnecting: false)),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+404
@@ -0,0 +1,404 @@
|
||||
// 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 'bluetooth_connect_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$BluetoothConnectEvent {
|
||||
String get macAddress => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String macAddress) connect,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String macAddress)? connect,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String macAddress)? connect,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Connect value) connect,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Connect value)? connect,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Connect value)? connect,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of BluetoothConnectEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$BluetoothConnectEventCopyWith<BluetoothConnectEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $BluetoothConnectEventCopyWith<$Res> {
|
||||
factory $BluetoothConnectEventCopyWith(
|
||||
BluetoothConnectEvent value,
|
||||
$Res Function(BluetoothConnectEvent) then,
|
||||
) = _$BluetoothConnectEventCopyWithImpl<$Res, BluetoothConnectEvent>;
|
||||
@useResult
|
||||
$Res call({String macAddress});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$BluetoothConnectEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends BluetoothConnectEvent
|
||||
>
|
||||
implements $BluetoothConnectEventCopyWith<$Res> {
|
||||
_$BluetoothConnectEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of BluetoothConnectEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? macAddress = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
macAddress: null == macAddress
|
||||
? _value.macAddress
|
||||
: macAddress // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ConnectImplCopyWith<$Res>
|
||||
implements $BluetoothConnectEventCopyWith<$Res> {
|
||||
factory _$$ConnectImplCopyWith(
|
||||
_$ConnectImpl value,
|
||||
$Res Function(_$ConnectImpl) then,
|
||||
) = __$$ConnectImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String macAddress});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ConnectImplCopyWithImpl<$Res>
|
||||
extends _$BluetoothConnectEventCopyWithImpl<$Res, _$ConnectImpl>
|
||||
implements _$$ConnectImplCopyWith<$Res> {
|
||||
__$$ConnectImplCopyWithImpl(
|
||||
_$ConnectImpl _value,
|
||||
$Res Function(_$ConnectImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of BluetoothConnectEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? macAddress = null}) {
|
||||
return _then(
|
||||
_$ConnectImpl(
|
||||
null == macAddress
|
||||
? _value.macAddress
|
||||
: macAddress // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ConnectImpl implements _Connect {
|
||||
const _$ConnectImpl(this.macAddress);
|
||||
|
||||
@override
|
||||
final String macAddress;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BluetoothConnectEvent.connect(macAddress: $macAddress)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ConnectImpl &&
|
||||
(identical(other.macAddress, macAddress) ||
|
||||
other.macAddress == macAddress));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, macAddress);
|
||||
|
||||
/// Create a copy of BluetoothConnectEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ConnectImplCopyWith<_$ConnectImpl> get copyWith =>
|
||||
__$$ConnectImplCopyWithImpl<_$ConnectImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String macAddress) connect,
|
||||
}) {
|
||||
return connect(macAddress);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String macAddress)? connect,
|
||||
}) {
|
||||
return connect?.call(macAddress);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String macAddress)? connect,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (connect != null) {
|
||||
return connect(macAddress);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Connect value) connect,
|
||||
}) {
|
||||
return connect(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Connect value)? connect,
|
||||
}) {
|
||||
return connect?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Connect value)? connect,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (connect != null) {
|
||||
return connect(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Connect implements BluetoothConnectEvent {
|
||||
const factory _Connect(final String macAddress) = _$ConnectImpl;
|
||||
|
||||
@override
|
||||
String get macAddress;
|
||||
|
||||
/// Create a copy of BluetoothConnectEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ConnectImplCopyWith<_$ConnectImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$BluetoothConnectState {
|
||||
Option<Either<PrinterFailure, bool>> get failureOrSuccee =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isConnecting => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of BluetoothConnectState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$BluetoothConnectStateCopyWith<BluetoothConnectState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $BluetoothConnectStateCopyWith<$Res> {
|
||||
factory $BluetoothConnectStateCopyWith(
|
||||
BluetoothConnectState value,
|
||||
$Res Function(BluetoothConnectState) then,
|
||||
) = _$BluetoothConnectStateCopyWithImpl<$Res, BluetoothConnectState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
Option<Either<PrinterFailure, bool>> failureOrSuccee,
|
||||
bool isConnecting,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$BluetoothConnectStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends BluetoothConnectState
|
||||
>
|
||||
implements $BluetoothConnectStateCopyWith<$Res> {
|
||||
_$BluetoothConnectStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of BluetoothConnectState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? failureOrSuccee = null, Object? isConnecting = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
failureOrSuccee: null == failureOrSuccee
|
||||
? _value.failureOrSuccee
|
||||
: failureOrSuccee // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<PrinterFailure, bool>>,
|
||||
isConnecting: null == isConnecting
|
||||
? _value.isConnecting
|
||||
: isConnecting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BluetoothConnectStateImplCopyWith<$Res>
|
||||
implements $BluetoothConnectStateCopyWith<$Res> {
|
||||
factory _$$BluetoothConnectStateImplCopyWith(
|
||||
_$BluetoothConnectStateImpl value,
|
||||
$Res Function(_$BluetoothConnectStateImpl) then,
|
||||
) = __$$BluetoothConnectStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
Option<Either<PrinterFailure, bool>> failureOrSuccee,
|
||||
bool isConnecting,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BluetoothConnectStateImplCopyWithImpl<$Res>
|
||||
extends
|
||||
_$BluetoothConnectStateCopyWithImpl<$Res, _$BluetoothConnectStateImpl>
|
||||
implements _$$BluetoothConnectStateImplCopyWith<$Res> {
|
||||
__$$BluetoothConnectStateImplCopyWithImpl(
|
||||
_$BluetoothConnectStateImpl _value,
|
||||
$Res Function(_$BluetoothConnectStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of BluetoothConnectState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? failureOrSuccee = null, Object? isConnecting = null}) {
|
||||
return _then(
|
||||
_$BluetoothConnectStateImpl(
|
||||
failureOrSuccee: null == failureOrSuccee
|
||||
? _value.failureOrSuccee
|
||||
: failureOrSuccee // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<PrinterFailure, bool>>,
|
||||
isConnecting: null == isConnecting
|
||||
? _value.isConnecting
|
||||
: isConnecting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$BluetoothConnectStateImpl implements _BluetoothConnectState {
|
||||
_$BluetoothConnectStateImpl({
|
||||
required this.failureOrSuccee,
|
||||
this.isConnecting = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final Option<Either<PrinterFailure, bool>> failureOrSuccee;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isConnecting;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BluetoothConnectState(failureOrSuccee: $failureOrSuccee, isConnecting: $isConnecting)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$BluetoothConnectStateImpl &&
|
||||
(identical(other.failureOrSuccee, failureOrSuccee) ||
|
||||
other.failureOrSuccee == failureOrSuccee) &&
|
||||
(identical(other.isConnecting, isConnecting) ||
|
||||
other.isConnecting == isConnecting));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, failureOrSuccee, isConnecting);
|
||||
|
||||
/// Create a copy of BluetoothConnectState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$BluetoothConnectStateImplCopyWith<_$BluetoothConnectStateImpl>
|
||||
get copyWith =>
|
||||
__$$BluetoothConnectStateImplCopyWithImpl<_$BluetoothConnectStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _BluetoothConnectState implements BluetoothConnectState {
|
||||
factory _BluetoothConnectState({
|
||||
required final Option<Either<PrinterFailure, bool>> failureOrSuccee,
|
||||
final bool isConnecting,
|
||||
}) = _$BluetoothConnectStateImpl;
|
||||
|
||||
@override
|
||||
Option<Either<PrinterFailure, bool>> get failureOrSuccee;
|
||||
@override
|
||||
bool get isConnecting;
|
||||
|
||||
/// Create a copy of BluetoothConnectState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$BluetoothConnectStateImplCopyWith<_$BluetoothConnectStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'bluetooth_connect_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class BluetoothConnectEvent with _$BluetoothConnectEvent {
|
||||
const factory BluetoothConnectEvent.connect(String macAddress) = _Connect;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
part of 'bluetooth_connect_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class BluetoothConnectState with _$BluetoothConnectState {
|
||||
factory BluetoothConnectState({
|
||||
required Option<Either<PrinterFailure, bool>> failureOrSuccee,
|
||||
@Default(false) bool isConnecting,
|
||||
}) = _BluetoothConnectState;
|
||||
|
||||
factory BluetoothConnectState.initial() =>
|
||||
BluetoothConnectState(failureOrSuccee: none());
|
||||
}
|
||||
@@ -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 'package:print_bluetooth_thermal/print_bluetooth_thermal.dart';
|
||||
|
||||
import '../../../../domain/printer/printer.dart';
|
||||
|
||||
part 'bluetooth_loader_event.dart';
|
||||
part 'bluetooth_loader_state.dart';
|
||||
part 'bluetooth_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class BluetoothLoaderBloc
|
||||
extends Bloc<BluetoothLoaderEvent, BluetoothLoaderState> {
|
||||
final IPrinterRepository _printerRepository;
|
||||
BluetoothLoaderBloc(this._printerRepository)
|
||||
: super(BluetoothLoaderState.initial()) {
|
||||
on<BluetoothLoaderEvent>(_onBluetoothLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onBluetoothLoaderEvent(
|
||||
BluetoothLoaderEvent event,
|
||||
Emitter<BluetoothLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
fetched: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _printerRepository.getPairedBluetoothDevices();
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(
|
||||
state.copyWith(failureOption: optionOf(failure), isFetching: false),
|
||||
),
|
||||
(devices) => emit(
|
||||
state.copyWith(
|
||||
bluetoothDevices: devices,
|
||||
failureOption: none(),
|
||||
isFetching: false,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
// 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 'bluetooth_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$BluetoothLoaderEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $BluetoothLoaderEventCopyWith<$Res> {
|
||||
factory $BluetoothLoaderEventCopyWith(
|
||||
BluetoothLoaderEvent value,
|
||||
$Res Function(BluetoothLoaderEvent) then,
|
||||
) = _$BluetoothLoaderEventCopyWithImpl<$Res, BluetoothLoaderEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$BluetoothLoaderEventCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends BluetoothLoaderEvent
|
||||
>
|
||||
implements $BluetoothLoaderEventCopyWith<$Res> {
|
||||
_$BluetoothLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of BluetoothLoaderEvent
|
||||
/// 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 _$BluetoothLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
||||
implements _$$FetchedImplCopyWith<$Res> {
|
||||
__$$FetchedImplCopyWithImpl(
|
||||
_$FetchedImpl _value,
|
||||
$Res Function(_$FetchedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of BluetoothLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$FetchedImpl implements _Fetched {
|
||||
const _$FetchedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BluetoothLoaderEvent.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<TResult extends Object?>({required TResult Function() fetched}) {
|
||||
return fetched();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({TResult? Function()? fetched}) {
|
||||
return fetched?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_Fetched value) fetched,
|
||||
}) {
|
||||
return fetched(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_Fetched value)? fetched,
|
||||
}) {
|
||||
return fetched?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_Fetched value)? fetched,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (fetched != null) {
|
||||
return fetched(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Fetched implements BluetoothLoaderEvent {
|
||||
const factory _Fetched() = _$FetchedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$BluetoothLoaderState {
|
||||
List<BluetoothInfo> get bluetoothDevices =>
|
||||
throw _privateConstructorUsedError;
|
||||
Option<PrinterFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of BluetoothLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$BluetoothLoaderStateCopyWith<BluetoothLoaderState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $BluetoothLoaderStateCopyWith<$Res> {
|
||||
factory $BluetoothLoaderStateCopyWith(
|
||||
BluetoothLoaderState value,
|
||||
$Res Function(BluetoothLoaderState) then,
|
||||
) = _$BluetoothLoaderStateCopyWithImpl<$Res, BluetoothLoaderState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<BluetoothInfo> bluetoothDevices,
|
||||
Option<PrinterFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$BluetoothLoaderStateCopyWithImpl<
|
||||
$Res,
|
||||
$Val extends BluetoothLoaderState
|
||||
>
|
||||
implements $BluetoothLoaderStateCopyWith<$Res> {
|
||||
_$BluetoothLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of BluetoothLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? bluetoothDevices = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
bluetoothDevices: null == bluetoothDevices
|
||||
? _value.bluetoothDevices
|
||||
: bluetoothDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<BluetoothInfo>,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<PrinterFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$BluetoothLoaderStateImplCopyWith<$Res>
|
||||
implements $BluetoothLoaderStateCopyWith<$Res> {
|
||||
factory _$$BluetoothLoaderStateImplCopyWith(
|
||||
_$BluetoothLoaderStateImpl value,
|
||||
$Res Function(_$BluetoothLoaderStateImpl) then,
|
||||
) = __$$BluetoothLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
List<BluetoothInfo> bluetoothDevices,
|
||||
Option<PrinterFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$BluetoothLoaderStateImplCopyWithImpl<$Res>
|
||||
extends _$BluetoothLoaderStateCopyWithImpl<$Res, _$BluetoothLoaderStateImpl>
|
||||
implements _$$BluetoothLoaderStateImplCopyWith<$Res> {
|
||||
__$$BluetoothLoaderStateImplCopyWithImpl(
|
||||
_$BluetoothLoaderStateImpl _value,
|
||||
$Res Function(_$BluetoothLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of BluetoothLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? bluetoothDevices = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$BluetoothLoaderStateImpl(
|
||||
bluetoothDevices: null == bluetoothDevices
|
||||
? _value._bluetoothDevices
|
||||
: bluetoothDevices // ignore: cast_nullable_to_non_nullable
|
||||
as List<BluetoothInfo>,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<PrinterFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$BluetoothLoaderStateImpl implements _BluetoothLoaderState {
|
||||
_$BluetoothLoaderStateImpl({
|
||||
required final List<BluetoothInfo> bluetoothDevices,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
}) : _bluetoothDevices = bluetoothDevices;
|
||||
|
||||
final List<BluetoothInfo> _bluetoothDevices;
|
||||
@override
|
||||
List<BluetoothInfo> get bluetoothDevices {
|
||||
if (_bluetoothDevices is EqualUnmodifiableListView)
|
||||
return _bluetoothDevices;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_bluetoothDevices);
|
||||
}
|
||||
|
||||
@override
|
||||
final Option<PrinterFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BluetoothLoaderState(bluetoothDevices: $bluetoothDevices, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$BluetoothLoaderStateImpl &&
|
||||
const DeepCollectionEquality().equals(
|
||||
other._bluetoothDevices,
|
||||
_bluetoothDevices,
|
||||
) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
const DeepCollectionEquality().hash(_bluetoothDevices),
|
||||
failureOption,
|
||||
isFetching,
|
||||
);
|
||||
|
||||
/// Create a copy of BluetoothLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$BluetoothLoaderStateImplCopyWith<_$BluetoothLoaderStateImpl>
|
||||
get copyWith =>
|
||||
__$$BluetoothLoaderStateImplCopyWithImpl<_$BluetoothLoaderStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _BluetoothLoaderState implements BluetoothLoaderState {
|
||||
factory _BluetoothLoaderState({
|
||||
required final List<BluetoothInfo> bluetoothDevices,
|
||||
required final Option<PrinterFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$BluetoothLoaderStateImpl;
|
||||
|
||||
@override
|
||||
List<BluetoothInfo> get bluetoothDevices;
|
||||
@override
|
||||
Option<PrinterFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of BluetoothLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$BluetoothLoaderStateImplCopyWith<_$BluetoothLoaderStateImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'bluetooth_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class BluetoothLoaderEvent with _$BluetoothLoaderEvent {
|
||||
const factory BluetoothLoaderEvent.fetched() = _Fetched;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
part of 'bluetooth_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class BluetoothLoaderState with _$BluetoothLoaderState {
|
||||
factory BluetoothLoaderState({
|
||||
required List<BluetoothInfo> bluetoothDevices,
|
||||
required Option<PrinterFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _BluetoothLoaderState;
|
||||
|
||||
factory BluetoothLoaderState.initial() =>
|
||||
BluetoothLoaderState(bluetoothDevices: [], failureOption: none());
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart' hide Order;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../domain/printer/printer.dart';
|
||||
|
||||
part 'print_struck_event.dart';
|
||||
part 'print_struck_state.dart';
|
||||
part 'print_struck_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class PrintStruckBloc extends Bloc<PrintStruckEvent, PrintStruckState> {
|
||||
final IPrinterRepository _printerRepository;
|
||||
|
||||
PrintStruckBloc(this._printerRepository) : super(PrintStruckState.initial()) {
|
||||
on<PrintStruckEvent>(_onPrintStruckEvent);
|
||||
}
|
||||
|
||||
Future<void> _onPrintStruckEvent(
|
||||
PrintStruckEvent event,
|
||||
Emitter<PrintStruckState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
order: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckOrder(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
cashier: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckCashier(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
payment: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckPayment(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
voided: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckVoid(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
splitBill: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckSplitBill(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
kitchen: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckKitchen(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
bar: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckBar(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
checker: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrSuccess;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintStruck: none()));
|
||||
|
||||
failureOrSuccess = await _printerRepository.printStruckChecker(
|
||||
order: e.order,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintStruck: optionOf(failureOrSuccess),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,13 @@
|
||||
part of 'print_struck_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrintStruckEvent with _$PrintStruckEvent {
|
||||
const factory PrintStruckEvent.order(Order order) = _Order;
|
||||
const factory PrintStruckEvent.cashier(Order order) = _Cashier;
|
||||
const factory PrintStruckEvent.payment(Order order) = _Payment;
|
||||
const factory PrintStruckEvent.voided(Order order) = _Voided;
|
||||
const factory PrintStruckEvent.checker(Order order) = _Checker;
|
||||
const factory PrintStruckEvent.kitchen(Order order) = _Kitchen;
|
||||
const factory PrintStruckEvent.bar(Order order) = _Bar;
|
||||
const factory PrintStruckEvent.splitBill(Order order) = _SplitBill;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
part of 'print_struck_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrintStruckState with _$PrintStruckState {
|
||||
factory PrintStruckState({
|
||||
required Option<Either<PrinterFailure, Unit>> failureOrPrintStruck,
|
||||
@Default(false) bool isPrinting,
|
||||
}) = _PrintStruckState;
|
||||
|
||||
factory PrintStruckState.initial() =>
|
||||
PrintStruckState(failureOrPrintStruck: none());
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
part 'printer_event.dart';
|
||||
part 'printer_state.dart';
|
||||
part 'printer_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class PrinterBloc extends Bloc<PrinterEvent, PrinterState> {
|
||||
PrinterBloc() : super(PrinterState.initial()) {
|
||||
on<PrinterEvent>(_onPrinterEvent);
|
||||
}
|
||||
|
||||
Future<void> _onPrinterEvent(PrinterEvent event, Emitter<PrinterState> emit) {
|
||||
return event.map(
|
||||
indexChanged: (e) async {
|
||||
emit(state.copyWith(index: e.index));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
// 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 'printer_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$PrinterEvent {
|
||||
int get index => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(int index) indexChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(int index)? indexChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(int index)? indexChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_IndexChanged value) indexChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_IndexChanged value)? indexChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_IndexChanged value)? indexChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PrinterEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PrinterEventCopyWith<PrinterEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PrinterEventCopyWith<$Res> {
|
||||
factory $PrinterEventCopyWith(
|
||||
PrinterEvent value,
|
||||
$Res Function(PrinterEvent) then,
|
||||
) = _$PrinterEventCopyWithImpl<$Res, PrinterEvent>;
|
||||
@useResult
|
||||
$Res call({int index});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PrinterEventCopyWithImpl<$Res, $Val extends PrinterEvent>
|
||||
implements $PrinterEventCopyWith<$Res> {
|
||||
_$PrinterEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PrinterEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? index = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
index: null == index
|
||||
? _value.index
|
||||
: index // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$IndexChangedImplCopyWith<$Res>
|
||||
implements $PrinterEventCopyWith<$Res> {
|
||||
factory _$$IndexChangedImplCopyWith(
|
||||
_$IndexChangedImpl value,
|
||||
$Res Function(_$IndexChangedImpl) then,
|
||||
) = __$$IndexChangedImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int index});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$IndexChangedImplCopyWithImpl<$Res>
|
||||
extends _$PrinterEventCopyWithImpl<$Res, _$IndexChangedImpl>
|
||||
implements _$$IndexChangedImplCopyWith<$Res> {
|
||||
__$$IndexChangedImplCopyWithImpl(
|
||||
_$IndexChangedImpl _value,
|
||||
$Res Function(_$IndexChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PrinterEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? index = null}) {
|
||||
return _then(
|
||||
_$IndexChangedImpl(
|
||||
null == index
|
||||
? _value.index
|
||||
: index // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$IndexChangedImpl implements _IndexChanged {
|
||||
const _$IndexChangedImpl(this.index);
|
||||
|
||||
@override
|
||||
final int index;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrinterEvent.indexChanged(index: $index)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$IndexChangedImpl &&
|
||||
(identical(other.index, index) || other.index == index));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, index);
|
||||
|
||||
/// Create a copy of PrinterEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$IndexChangedImplCopyWith<_$IndexChangedImpl> get copyWith =>
|
||||
__$$IndexChangedImplCopyWithImpl<_$IndexChangedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(int index) indexChanged,
|
||||
}) {
|
||||
return indexChanged(index);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(int index)? indexChanged,
|
||||
}) {
|
||||
return indexChanged?.call(index);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(int index)? indexChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (indexChanged != null) {
|
||||
return indexChanged(index);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_IndexChanged value) indexChanged,
|
||||
}) {
|
||||
return indexChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_IndexChanged value)? indexChanged,
|
||||
}) {
|
||||
return indexChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_IndexChanged value)? indexChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (indexChanged != null) {
|
||||
return indexChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _IndexChanged implements PrinterEvent {
|
||||
const factory _IndexChanged(final int index) = _$IndexChangedImpl;
|
||||
|
||||
@override
|
||||
int get index;
|
||||
|
||||
/// Create a copy of PrinterEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$IndexChangedImplCopyWith<_$IndexChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PrinterState {
|
||||
int get index => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PrinterState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PrinterStateCopyWith<PrinterState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PrinterStateCopyWith<$Res> {
|
||||
factory $PrinterStateCopyWith(
|
||||
PrinterState value,
|
||||
$Res Function(PrinterState) then,
|
||||
) = _$PrinterStateCopyWithImpl<$Res, PrinterState>;
|
||||
@useResult
|
||||
$Res call({int index});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PrinterStateCopyWithImpl<$Res, $Val extends PrinterState>
|
||||
implements $PrinterStateCopyWith<$Res> {
|
||||
_$PrinterStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PrinterState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? index = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
index: null == index
|
||||
? _value.index
|
||||
: index // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PrinterStateImplCopyWith<$Res>
|
||||
implements $PrinterStateCopyWith<$Res> {
|
||||
factory _$$PrinterStateImplCopyWith(
|
||||
_$PrinterStateImpl value,
|
||||
$Res Function(_$PrinterStateImpl) then,
|
||||
) = __$$PrinterStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({int index});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PrinterStateImplCopyWithImpl<$Res>
|
||||
extends _$PrinterStateCopyWithImpl<$Res, _$PrinterStateImpl>
|
||||
implements _$$PrinterStateImplCopyWith<$Res> {
|
||||
__$$PrinterStateImplCopyWithImpl(
|
||||
_$PrinterStateImpl _value,
|
||||
$Res Function(_$PrinterStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PrinterState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? index = null}) {
|
||||
return _then(
|
||||
_$PrinterStateImpl(
|
||||
index: null == index
|
||||
? _value.index
|
||||
: index // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$PrinterStateImpl implements _PrinterState {
|
||||
_$PrinterStateImpl({this.index = 0});
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final int index;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrinterState(index: $index)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PrinterStateImpl &&
|
||||
(identical(other.index, index) || other.index == index));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, index);
|
||||
|
||||
/// Create a copy of PrinterState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PrinterStateImplCopyWith<_$PrinterStateImpl> get copyWith =>
|
||||
__$$PrinterStateImplCopyWithImpl<_$PrinterStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _PrinterState implements PrinterState {
|
||||
factory _PrinterState({final int index}) = _$PrinterStateImpl;
|
||||
|
||||
@override
|
||||
int get index;
|
||||
|
||||
/// Create a copy of PrinterState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PrinterStateImplCopyWith<_$PrinterStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'printer_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrinterEvent with _$PrinterEvent {
|
||||
const factory PrinterEvent.indexChanged(int index) = _IndexChanged;
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart' hide Order;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
|
||||
import '../../../common/function/app_function.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
import '../../../domain/outlet/outlet.dart';
|
||||
import '../../../domain/printer/printer.dart';
|
||||
import '../../../presentation/components/print/print_ui.dart';
|
||||
|
||||
part 'printer_form_event.dart';
|
||||
part 'printer_form_state.dart';
|
||||
part 'printer_form_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class PrinterFormBloc extends Bloc<PrinterFormEvent, PrinterFormState> {
|
||||
final IPrinterRepository _printerRepository;
|
||||
final IOutletRepository _outletRepository;
|
||||
|
||||
PrinterFormBloc(this._printerRepository, this._outletRepository)
|
||||
: super(PrinterFormState.initial()) {
|
||||
on<PrinterFormEvent>(_onPrinterFormEvent);
|
||||
}
|
||||
|
||||
Future<void> _onPrinterFormEvent(
|
||||
PrinterFormEvent event,
|
||||
Emitter<PrinterFormState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
codeChanged: (e) async {
|
||||
emit(state.copyWith(code: e.code));
|
||||
},
|
||||
nameChanged: (e) async {
|
||||
emit(state.copyWith(name: e.name));
|
||||
},
|
||||
addressChanged: (e) async {
|
||||
emit(state.copyWith(address: e.address));
|
||||
},
|
||||
typeChanged: (e) async {
|
||||
emit(state.copyWith(type: e.type));
|
||||
},
|
||||
paperChanged: (e) async {
|
||||
emit(state.copyWith(paper: e.paper));
|
||||
},
|
||||
created: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrPrinter;
|
||||
|
||||
emit(state.copyWith(isCreating: true, failureOrCreateSuccess: none()));
|
||||
|
||||
final request = Printer(
|
||||
id: generateRandomNumber(),
|
||||
code: state.code,
|
||||
name: state.name,
|
||||
address: state.address,
|
||||
paper: state.paper,
|
||||
type: state.type,
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
);
|
||||
|
||||
failureOrPrinter = await _printerRepository.createPrinter(request);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isCreating: false,
|
||||
failureOrCreateSuccess: optionOf(failureOrPrinter),
|
||||
),
|
||||
);
|
||||
},
|
||||
updated: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrPrinter;
|
||||
|
||||
emit(state.copyWith(isUpdate: true, failureOrUpdateSuccess: none()));
|
||||
|
||||
final request = Printer(
|
||||
id: generateRandomNumber(),
|
||||
code: state.code,
|
||||
name: state.name,
|
||||
address: state.address,
|
||||
paper: state.paper,
|
||||
type: state.type,
|
||||
createdAt: DateTime.now(),
|
||||
updatedAt: DateTime.now(),
|
||||
);
|
||||
|
||||
failureOrPrinter = await _printerRepository.updatePrinter(
|
||||
request,
|
||||
e.id,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isUpdate: false,
|
||||
failureOrUpdateSuccess: optionOf(failureOrPrinter),
|
||||
),
|
||||
);
|
||||
},
|
||||
deleted: (e) async {
|
||||
Either<PrinterFailure, Unit> failureOrPrinter;
|
||||
|
||||
emit(state.copyWith(isDeleting: true, failureOrDeleteSuccess: none()));
|
||||
|
||||
failureOrPrinter = await _printerRepository.deletePrinter(e.id);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isDeleting: false,
|
||||
failureOrDeleteSuccess: optionOf(failureOrPrinter),
|
||||
),
|
||||
);
|
||||
},
|
||||
printTest: (e) async {
|
||||
Either<PrinterFailure, bool> failureOrPrinter;
|
||||
|
||||
emit(state.copyWith(isPrinting: true, failureOrPrintTest: none()));
|
||||
|
||||
final currentOutlet = await _outletRepository.currentOutlet();
|
||||
|
||||
// Ambil paper size dari DB, fallback ke state.paper jika belum tersimpan
|
||||
final savedPrinter = await _printerRepository.getPrinterByCode(e.code);
|
||||
final paper = savedPrinter.fold(
|
||||
(_) => int.tryParse(state.paper) ?? 58,
|
||||
(p) => int.tryParse(p.paper) ?? 58,
|
||||
);
|
||||
|
||||
List<int> printValue = [];
|
||||
|
||||
if (e.code == "receipt") {
|
||||
printValue = await PrintUi().printOrder(
|
||||
order: Order.mockOrder(),
|
||||
outlet: currentOutlet,
|
||||
cashierName: 'Kasir Test',
|
||||
paper: paper,
|
||||
);
|
||||
} else if (e.code == "checker") {
|
||||
printValue = await PrintUi().printChecker(
|
||||
order: Order.mockOrder(),
|
||||
outlet: currentOutlet,
|
||||
cashierName: 'Kasir Test',
|
||||
paper: paper,
|
||||
);
|
||||
} else if (e.code == 'kitchen') {
|
||||
printValue = await PrintUi().printKitchen(
|
||||
order: Order.mockOrder(),
|
||||
outlet: currentOutlet,
|
||||
cashierName: 'Kasir Test',
|
||||
paper: paper,
|
||||
);
|
||||
} else if (e.code == 'bar') {
|
||||
printValue = await PrintUi().printBar(
|
||||
order: Order.mockOrder(),
|
||||
outlet: currentOutlet,
|
||||
cashierName: 'Kasir Test',
|
||||
paper: paper,
|
||||
);
|
||||
} else if (e.code == 'ticket') {
|
||||
printValue = await PrintUi().printTicket(
|
||||
order: Order.mockOrder(),
|
||||
outlet: currentOutlet,
|
||||
paper: paper,
|
||||
);
|
||||
}
|
||||
|
||||
final printer = Printer.fromTest(
|
||||
code: e.code,
|
||||
name: state.name,
|
||||
address: e.macAccdress,
|
||||
paper: paper.toString(),
|
||||
type: state.type,
|
||||
);
|
||||
|
||||
failureOrPrinter = await _printerRepository.printStruct(
|
||||
printer,
|
||||
printValue,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPrinting: false,
|
||||
failureOrPrintTest: optionOf(failureOrPrinter),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
part of 'printer_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrinterFormEvent with _$PrinterFormEvent {
|
||||
const factory PrinterFormEvent.codeChanged(String code) = _CodeChanged;
|
||||
const factory PrinterFormEvent.nameChanged(String name) = _NameChanged;
|
||||
const factory PrinterFormEvent.addressChanged(String address) =
|
||||
_AddressChanged;
|
||||
const factory PrinterFormEvent.typeChanged(String type) = _TypeChanged;
|
||||
const factory PrinterFormEvent.paperChanged(String paper) = _PaperChanged;
|
||||
const factory PrinterFormEvent.created() = _Created;
|
||||
const factory PrinterFormEvent.updated(int id) = _Updated;
|
||||
const factory PrinterFormEvent.deleted(int id) = _Deleted;
|
||||
const factory PrinterFormEvent.printTest({
|
||||
required String code,
|
||||
required String macAccdress,
|
||||
}) = _PrintTest;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
part of 'printer_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrinterFormState with _$PrinterFormState {
|
||||
factory PrinterFormState({
|
||||
required String code,
|
||||
required String name,
|
||||
required String address,
|
||||
required String paper,
|
||||
required String type,
|
||||
required Option<Either<PrinterFailure, Unit>> failureOrCreateSuccess,
|
||||
required Option<Either<PrinterFailure, Unit>> failureOrUpdateSuccess,
|
||||
required Option<Either<PrinterFailure, Unit>> failureOrDeleteSuccess,
|
||||
required Option<Either<PrinterFailure, bool>> failureOrPrintTest,
|
||||
@Default(false) isCreating,
|
||||
@Default(false) isUpdate,
|
||||
@Default(false) isDeleting,
|
||||
@Default(false) isPrinting,
|
||||
}) = _PrinterFormState;
|
||||
|
||||
factory PrinterFormState.initial() => PrinterFormState(
|
||||
code: '',
|
||||
name: '',
|
||||
address: '',
|
||||
paper: '58',
|
||||
type: 'Bluetooth',
|
||||
failureOrCreateSuccess: none(),
|
||||
failureOrUpdateSuccess: none(),
|
||||
failureOrDeleteSuccess: none(),
|
||||
failureOrPrintTest: none(),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/printer/printer.dart';
|
||||
|
||||
part 'printer_loader_event.dart';
|
||||
part 'printer_loader_state.dart';
|
||||
part 'printer_loader_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class PrinterLoaderBloc extends Bloc<PrinterLoaderEvent, PrinterLoaderState> {
|
||||
final IPrinterRepository _printerRepository;
|
||||
PrinterLoaderBloc(this._printerRepository)
|
||||
: super(PrinterLoaderState.initial()) {
|
||||
on<PrinterLoaderEvent>(_onPrinterLoaderEvent);
|
||||
}
|
||||
|
||||
Future<void> _onPrinterLoaderEvent(
|
||||
PrinterLoaderEvent event,
|
||||
Emitter<PrinterLoaderState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
getByCode: (e) async {
|
||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
||||
|
||||
final result = await _printerRepository.getPrinterByCode(e.code);
|
||||
|
||||
await result.fold(
|
||||
(failure) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isFetching: false,
|
||||
failureOption: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(printer) async {
|
||||
emit(state.copyWith(isFetching: false, printer: printer));
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,437 @@
|
||||
// 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 'printer_loader_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$PrinterLoaderEvent {
|
||||
String get code => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String code) getByCode,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String code)? getByCode,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String code)? getByCode,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetByCode value) getByCode,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetByCode value)? getByCode,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetByCode value)? getByCode,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PrinterLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PrinterLoaderEventCopyWith<PrinterLoaderEvent> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PrinterLoaderEventCopyWith<$Res> {
|
||||
factory $PrinterLoaderEventCopyWith(
|
||||
PrinterLoaderEvent value,
|
||||
$Res Function(PrinterLoaderEvent) then,
|
||||
) = _$PrinterLoaderEventCopyWithImpl<$Res, PrinterLoaderEvent>;
|
||||
@useResult
|
||||
$Res call({String code});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PrinterLoaderEventCopyWithImpl<$Res, $Val extends PrinterLoaderEvent>
|
||||
implements $PrinterLoaderEventCopyWith<$Res> {
|
||||
_$PrinterLoaderEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PrinterLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? code = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
code: null == code
|
||||
? _value.code
|
||||
: code // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$GetByCodeImplCopyWith<$Res>
|
||||
implements $PrinterLoaderEventCopyWith<$Res> {
|
||||
factory _$$GetByCodeImplCopyWith(
|
||||
_$GetByCodeImpl value,
|
||||
$Res Function(_$GetByCodeImpl) then,
|
||||
) = __$$GetByCodeImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String code});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$GetByCodeImplCopyWithImpl<$Res>
|
||||
extends _$PrinterLoaderEventCopyWithImpl<$Res, _$GetByCodeImpl>
|
||||
implements _$$GetByCodeImplCopyWith<$Res> {
|
||||
__$$GetByCodeImplCopyWithImpl(
|
||||
_$GetByCodeImpl _value,
|
||||
$Res Function(_$GetByCodeImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PrinterLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? code = null}) {
|
||||
return _then(
|
||||
_$GetByCodeImpl(
|
||||
null == code
|
||||
? _value.code
|
||||
: code // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$GetByCodeImpl implements _GetByCode {
|
||||
const _$GetByCodeImpl(this.code);
|
||||
|
||||
@override
|
||||
final String code;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrinterLoaderEvent.getByCode(code: $code)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$GetByCodeImpl &&
|
||||
(identical(other.code, code) || other.code == code));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, code);
|
||||
|
||||
/// Create a copy of PrinterLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$GetByCodeImplCopyWith<_$GetByCodeImpl> get copyWith =>
|
||||
__$$GetByCodeImplCopyWithImpl<_$GetByCodeImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(String code) getByCode,
|
||||
}) {
|
||||
return getByCode(code);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(String code)? getByCode,
|
||||
}) {
|
||||
return getByCode?.call(code);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(String code)? getByCode,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getByCode != null) {
|
||||
return getByCode(code);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_GetByCode value) getByCode,
|
||||
}) {
|
||||
return getByCode(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_GetByCode value)? getByCode,
|
||||
}) {
|
||||
return getByCode?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_GetByCode value)? getByCode,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (getByCode != null) {
|
||||
return getByCode(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _GetByCode implements PrinterLoaderEvent {
|
||||
const factory _GetByCode(final String code) = _$GetByCodeImpl;
|
||||
|
||||
@override
|
||||
String get code;
|
||||
|
||||
/// Create a copy of PrinterLoaderEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$GetByCodeImplCopyWith<_$GetByCodeImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PrinterLoaderState {
|
||||
Printer get printer => throw _privateConstructorUsedError;
|
||||
Option<PrinterFailure> get failureOption =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isFetching => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PrinterLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PrinterLoaderStateCopyWith<PrinterLoaderState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PrinterLoaderStateCopyWith<$Res> {
|
||||
factory $PrinterLoaderStateCopyWith(
|
||||
PrinterLoaderState value,
|
||||
$Res Function(PrinterLoaderState) then,
|
||||
) = _$PrinterLoaderStateCopyWithImpl<$Res, PrinterLoaderState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
Printer printer,
|
||||
Option<PrinterFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
$PrinterCopyWith<$Res> get printer;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PrinterLoaderStateCopyWithImpl<$Res, $Val extends PrinterLoaderState>
|
||||
implements $PrinterLoaderStateCopyWith<$Res> {
|
||||
_$PrinterLoaderStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PrinterLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? printer = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
printer: null == printer
|
||||
? _value.printer
|
||||
: printer // ignore: cast_nullable_to_non_nullable
|
||||
as Printer,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<PrinterFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of PrinterLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$PrinterCopyWith<$Res> get printer {
|
||||
return $PrinterCopyWith<$Res>(_value.printer, (value) {
|
||||
return _then(_value.copyWith(printer: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PrinterLoaderStateImplCopyWith<$Res>
|
||||
implements $PrinterLoaderStateCopyWith<$Res> {
|
||||
factory _$$PrinterLoaderStateImplCopyWith(
|
||||
_$PrinterLoaderStateImpl value,
|
||||
$Res Function(_$PrinterLoaderStateImpl) then,
|
||||
) = __$$PrinterLoaderStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
Printer printer,
|
||||
Option<PrinterFailure> failureOption,
|
||||
bool isFetching,
|
||||
});
|
||||
|
||||
@override
|
||||
$PrinterCopyWith<$Res> get printer;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PrinterLoaderStateImplCopyWithImpl<$Res>
|
||||
extends _$PrinterLoaderStateCopyWithImpl<$Res, _$PrinterLoaderStateImpl>
|
||||
implements _$$PrinterLoaderStateImplCopyWith<$Res> {
|
||||
__$$PrinterLoaderStateImplCopyWithImpl(
|
||||
_$PrinterLoaderStateImpl _value,
|
||||
$Res Function(_$PrinterLoaderStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PrinterLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? printer = null,
|
||||
Object? failureOption = null,
|
||||
Object? isFetching = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$PrinterLoaderStateImpl(
|
||||
printer: null == printer
|
||||
? _value.printer
|
||||
: printer // ignore: cast_nullable_to_non_nullable
|
||||
as Printer,
|
||||
failureOption: null == failureOption
|
||||
? _value.failureOption
|
||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
||||
as Option<PrinterFailure>,
|
||||
isFetching: null == isFetching
|
||||
? _value.isFetching
|
||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$PrinterLoaderStateImpl implements _PrinterLoaderState {
|
||||
_$PrinterLoaderStateImpl({
|
||||
required this.printer,
|
||||
required this.failureOption,
|
||||
this.isFetching = false,
|
||||
});
|
||||
|
||||
@override
|
||||
final Printer printer;
|
||||
@override
|
||||
final Option<PrinterFailure> failureOption;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isFetching;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PrinterLoaderState(printer: $printer, failureOption: $failureOption, isFetching: $isFetching)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PrinterLoaderStateImpl &&
|
||||
(identical(other.printer, printer) || other.printer == printer) &&
|
||||
(identical(other.failureOption, failureOption) ||
|
||||
other.failureOption == failureOption) &&
|
||||
(identical(other.isFetching, isFetching) ||
|
||||
other.isFetching == isFetching));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, printer, failureOption, isFetching);
|
||||
|
||||
/// Create a copy of PrinterLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PrinterLoaderStateImplCopyWith<_$PrinterLoaderStateImpl> get copyWith =>
|
||||
__$$PrinterLoaderStateImplCopyWithImpl<_$PrinterLoaderStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _PrinterLoaderState implements PrinterLoaderState {
|
||||
factory _PrinterLoaderState({
|
||||
required final Printer printer,
|
||||
required final Option<PrinterFailure> failureOption,
|
||||
final bool isFetching,
|
||||
}) = _$PrinterLoaderStateImpl;
|
||||
|
||||
@override
|
||||
Printer get printer;
|
||||
@override
|
||||
Option<PrinterFailure> get failureOption;
|
||||
@override
|
||||
bool get isFetching;
|
||||
|
||||
/// Create a copy of PrinterLoaderState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PrinterLoaderStateImplCopyWith<_$PrinterLoaderStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
part of 'printer_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrinterLoaderEvent with _$PrinterLoaderEvent {
|
||||
const factory PrinterLoaderEvent.getByCode(String code) = _GetByCode;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
part of 'printer_loader_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrinterLoaderState with _$PrinterLoaderState {
|
||||
factory PrinterLoaderState({
|
||||
required Printer printer,
|
||||
required Option<PrinterFailure> failureOption,
|
||||
@Default(false) bool isFetching,
|
||||
}) = _PrinterLoaderState;
|
||||
|
||||
factory PrinterLoaderState.initial() =>
|
||||
PrinterLoaderState(printer: Printer.empty(), failureOption: none());
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
part of 'printer_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class PrinterState with _$PrinterState {
|
||||
factory PrinterState({@Default(0) int index}) = _PrinterState;
|
||||
factory PrinterState.initial() => PrinterState();
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class ProductLoaderBloc extends Bloc<ProductLoaderEvent, ProductLoaderState> {
|
||||
state.copyWith(
|
||||
isLoadingMore: false,
|
||||
failureOptionProduct: optionOf(
|
||||
ProductFailure.dynamicErrorMessage(
|
||||
const ProductFailure.dynamicErrorMessage(
|
||||
'Database lokal belum siap. Silakan lakukan sinkronisasi data terlebih dahulu.',
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart' hide Order;
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
import '../../../common/data/refund_data.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
|
||||
part 'refund_form_event.dart';
|
||||
part 'refund_form_state.dart';
|
||||
part 'refund_form_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class RefundFormBloc extends Bloc<RefundFormEvent, RefundFormState> {
|
||||
final IOrderRepository _repository;
|
||||
RefundFormBloc(this._repository) : super(RefundFormState.initial()) {
|
||||
on<RefundFormEvent>(_onRefundFormEvent);
|
||||
}
|
||||
|
||||
Future<void> _onRefundFormEvent(
|
||||
RefundFormEvent event,
|
||||
Emitter<RefundFormState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
setOrder: (e) async {
|
||||
emit(state.copyWith(order: e.order));
|
||||
},
|
||||
reasonChanged: (e) async {
|
||||
emit(state.copyWith(reason: e.reason));
|
||||
},
|
||||
refundReasonChanged: (e) async {
|
||||
emit(state.copyWith(refundReason: e.refundReason));
|
||||
},
|
||||
submitted: (e) async {
|
||||
Either<OrderFailure, Unit>? failureOrRefund;
|
||||
|
||||
// Generate new idempotency key saat user intent (tap Refund)
|
||||
// Kalau sedang retry, pakai key yang sama
|
||||
final idempotencyKey = state.idempotencyKey ?? const Uuid().v4();
|
||||
|
||||
emit(state.copyWith(
|
||||
isSubmitting: true,
|
||||
failureOrRefund: none(),
|
||||
idempotencyKey: idempotencyKey,
|
||||
));
|
||||
|
||||
failureOrRefund = await _repository.refundOrder(
|
||||
id: state.order.id,
|
||||
reason: state.refundReason?.value == 'Lainnya'
|
||||
? state.reason
|
||||
: state.refundReason?.value ?? '',
|
||||
refundAmount: state.order.totalAmount,
|
||||
idempotencyKey: idempotencyKey,
|
||||
);
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSubmitting: false,
|
||||
failureOrRefund: optionOf(failureOrRefund),
|
||||
// Clear key on success, keep on failure for retry
|
||||
idempotencyKey: failureOrRefund.isRight() ? null : idempotencyKey,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,972 @@
|
||||
// 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 'refund_form_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$RefundFormEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $RefundFormEventCopyWith<$Res> {
|
||||
factory $RefundFormEventCopyWith(
|
||||
RefundFormEvent value,
|
||||
$Res Function(RefundFormEvent) then,
|
||||
) = _$RefundFormEventCopyWithImpl<$Res, RefundFormEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$RefundFormEventCopyWithImpl<$Res, $Val extends RefundFormEvent>
|
||||
implements $RefundFormEventCopyWith<$Res> {
|
||||
_$RefundFormEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SetOrderImplCopyWith<$Res> {
|
||||
factory _$$SetOrderImplCopyWith(
|
||||
_$SetOrderImpl value,
|
||||
$Res Function(_$SetOrderImpl) then,
|
||||
) = __$$SetOrderImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({Order order});
|
||||
|
||||
$OrderCopyWith<$Res> get order;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SetOrderImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormEventCopyWithImpl<$Res, _$SetOrderImpl>
|
||||
implements _$$SetOrderImplCopyWith<$Res> {
|
||||
__$$SetOrderImplCopyWithImpl(
|
||||
_$SetOrderImpl _value,
|
||||
$Res Function(_$SetOrderImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? order = null}) {
|
||||
return _then(
|
||||
_$SetOrderImpl(
|
||||
null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OrderCopyWith<$Res> get order {
|
||||
return $OrderCopyWith<$Res>(_value.order, (value) {
|
||||
return _then(_value.copyWith(order: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SetOrderImpl implements _SetOrder {
|
||||
const _$SetOrderImpl(this.order);
|
||||
|
||||
@override
|
||||
final Order order;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormEvent.setOrder(order: $order)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$SetOrderImpl &&
|
||||
(identical(other.order, order) || other.order == order));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, order);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$SetOrderImplCopyWith<_$SetOrderImpl> get copyWith =>
|
||||
__$$SetOrderImplCopyWithImpl<_$SetOrderImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return setOrder(order);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return setOrder?.call(order);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
return setOrder(order);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return setOrder(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return setOrder?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (setOrder != null) {
|
||||
return setOrder(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _SetOrder implements RefundFormEvent {
|
||||
const factory _SetOrder(final Order order) = _$SetOrderImpl;
|
||||
|
||||
Order get order;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$SetOrderImplCopyWith<_$SetOrderImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ReasonChangedImplCopyWith<$Res> {
|
||||
factory _$$ReasonChangedImplCopyWith(
|
||||
_$ReasonChangedImpl value,
|
||||
$Res Function(_$ReasonChangedImpl) then,
|
||||
) = __$$ReasonChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String reason});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ReasonChangedImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormEventCopyWithImpl<$Res, _$ReasonChangedImpl>
|
||||
implements _$$ReasonChangedImplCopyWith<$Res> {
|
||||
__$$ReasonChangedImplCopyWithImpl(
|
||||
_$ReasonChangedImpl _value,
|
||||
$Res Function(_$ReasonChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? reason = null}) {
|
||||
return _then(
|
||||
_$ReasonChangedImpl(
|
||||
null == reason
|
||||
? _value.reason
|
||||
: reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ReasonChangedImpl implements _ReasonChanged {
|
||||
const _$ReasonChangedImpl(this.reason);
|
||||
|
||||
@override
|
||||
final String reason;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormEvent.reasonChanged(reason: $reason)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ReasonChangedImpl &&
|
||||
(identical(other.reason, reason) || other.reason == reason));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, reason);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ReasonChangedImplCopyWith<_$ReasonChangedImpl> get copyWith =>
|
||||
__$$ReasonChangedImplCopyWithImpl<_$ReasonChangedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return reasonChanged(reason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return reasonChanged?.call(reason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (reasonChanged != null) {
|
||||
return reasonChanged(reason);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return reasonChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return reasonChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (reasonChanged != null) {
|
||||
return reasonChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _ReasonChanged implements RefundFormEvent {
|
||||
const factory _ReasonChanged(final String reason) = _$ReasonChangedImpl;
|
||||
|
||||
String get reason;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ReasonChangedImplCopyWith<_$ReasonChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$RefundReasonChangedImplCopyWith<$Res> {
|
||||
factory _$$RefundReasonChangedImplCopyWith(
|
||||
_$RefundReasonChangedImpl value,
|
||||
$Res Function(_$RefundReasonChangedImpl) then,
|
||||
) = __$$RefundReasonChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({RefundReason refundReason});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$RefundReasonChangedImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormEventCopyWithImpl<$Res, _$RefundReasonChangedImpl>
|
||||
implements _$$RefundReasonChangedImplCopyWith<$Res> {
|
||||
__$$RefundReasonChangedImplCopyWithImpl(
|
||||
_$RefundReasonChangedImpl _value,
|
||||
$Res Function(_$RefundReasonChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? refundReason = null}) {
|
||||
return _then(
|
||||
_$RefundReasonChangedImpl(
|
||||
null == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as RefundReason,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$RefundReasonChangedImpl implements _RefundReasonChanged {
|
||||
const _$RefundReasonChangedImpl(this.refundReason);
|
||||
|
||||
@override
|
||||
final RefundReason refundReason;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormEvent.refundReasonChanged(refundReason: $refundReason)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RefundReasonChangedImpl &&
|
||||
(identical(other.refundReason, refundReason) ||
|
||||
other.refundReason == refundReason));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, refundReason);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RefundReasonChangedImplCopyWith<_$RefundReasonChangedImpl> get copyWith =>
|
||||
__$$RefundReasonChangedImplCopyWithImpl<_$RefundReasonChangedImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return refundReasonChanged(refundReason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return refundReasonChanged?.call(refundReason);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (refundReasonChanged != null) {
|
||||
return refundReasonChanged(refundReason);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return refundReasonChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return refundReasonChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (refundReasonChanged != null) {
|
||||
return refundReasonChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _RefundReasonChanged implements RefundFormEvent {
|
||||
const factory _RefundReasonChanged(final RefundReason refundReason) =
|
||||
_$RefundReasonChangedImpl;
|
||||
|
||||
RefundReason get refundReason;
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$RefundReasonChangedImplCopyWith<_$RefundReasonChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$SubmittedImplCopyWith<$Res> {
|
||||
factory _$$SubmittedImplCopyWith(
|
||||
_$SubmittedImpl value,
|
||||
$Res Function(_$SubmittedImpl) then,
|
||||
) = __$$SubmittedImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$SubmittedImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormEventCopyWithImpl<$Res, _$SubmittedImpl>
|
||||
implements _$$SubmittedImplCopyWith<$Res> {
|
||||
__$$SubmittedImplCopyWithImpl(
|
||||
_$SubmittedImpl _value,
|
||||
$Res Function(_$SubmittedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$SubmittedImpl implements _Submitted {
|
||||
const _$SubmittedImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormEvent.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<TResult extends Object?>({
|
||||
required TResult Function(Order order) setOrder,
|
||||
required TResult Function(String reason) reasonChanged,
|
||||
required TResult Function(RefundReason refundReason) refundReasonChanged,
|
||||
required TResult Function() submitted,
|
||||
}) {
|
||||
return submitted();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(Order order)? setOrder,
|
||||
TResult? Function(String reason)? reasonChanged,
|
||||
TResult? Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult? Function()? submitted,
|
||||
}) {
|
||||
return submitted?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(Order order)? setOrder,
|
||||
TResult Function(String reason)? reasonChanged,
|
||||
TResult Function(RefundReason refundReason)? refundReasonChanged,
|
||||
TResult Function()? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_SetOrder value) setOrder,
|
||||
required TResult Function(_ReasonChanged value) reasonChanged,
|
||||
required TResult Function(_RefundReasonChanged value) refundReasonChanged,
|
||||
required TResult Function(_Submitted value) submitted,
|
||||
}) {
|
||||
return submitted(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_SetOrder value)? setOrder,
|
||||
TResult? Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult? Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult? Function(_Submitted value)? submitted,
|
||||
}) {
|
||||
return submitted?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_SetOrder value)? setOrder,
|
||||
TResult Function(_ReasonChanged value)? reasonChanged,
|
||||
TResult Function(_RefundReasonChanged value)? refundReasonChanged,
|
||||
TResult Function(_Submitted value)? submitted,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (submitted != null) {
|
||||
return submitted(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Submitted implements RefundFormEvent {
|
||||
const factory _Submitted() = _$SubmittedImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$RefundFormState {
|
||||
Order get order => throw _privateConstructorUsedError;
|
||||
String get reason => throw _privateConstructorUsedError;
|
||||
RefundReason? get refundReason => throw _privateConstructorUsedError;
|
||||
Option<Either<OrderFailure, Unit>> get failureOrRefund =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
||||
|
||||
/// Idempotency key untuk refund submission.
|
||||
/// Di-generate saat user tap "Refund", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
String? get idempotencyKey => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$RefundFormStateCopyWith<RefundFormState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $RefundFormStateCopyWith<$Res> {
|
||||
factory $RefundFormStateCopyWith(
|
||||
RefundFormState value,
|
||||
$Res Function(RefundFormState) then,
|
||||
) = _$RefundFormStateCopyWithImpl<$Res, RefundFormState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
Order order,
|
||||
String reason,
|
||||
RefundReason? refundReason,
|
||||
Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
bool isSubmitting,
|
||||
String? idempotencyKey,
|
||||
});
|
||||
|
||||
$OrderCopyWith<$Res> get order;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$RefundFormStateCopyWithImpl<$Res, $Val extends RefundFormState>
|
||||
implements $RefundFormStateCopyWith<$Res> {
|
||||
_$RefundFormStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? order = null,
|
||||
Object? reason = null,
|
||||
Object? refundReason = freezed,
|
||||
Object? failureOrRefund = null,
|
||||
Object? isSubmitting = null,
|
||||
Object? idempotencyKey = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
reason: null == reason
|
||||
? _value.reason
|
||||
: reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
refundReason: freezed == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as RefundReason?,
|
||||
failureOrRefund: null == failureOrRefund
|
||||
? _value.failureOrRefund
|
||||
: failureOrRefund // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Unit>>,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
idempotencyKey: freezed == idempotencyKey
|
||||
? _value.idempotencyKey
|
||||
: idempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$OrderCopyWith<$Res> get order {
|
||||
return $OrderCopyWith<$Res>(_value.order, (value) {
|
||||
return _then(_value.copyWith(order: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$RefundFormStateImplCopyWith<$Res>
|
||||
implements $RefundFormStateCopyWith<$Res> {
|
||||
factory _$$RefundFormStateImplCopyWith(
|
||||
_$RefundFormStateImpl value,
|
||||
$Res Function(_$RefundFormStateImpl) then,
|
||||
) = __$$RefundFormStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
Order order,
|
||||
String reason,
|
||||
RefundReason? refundReason,
|
||||
Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
bool isSubmitting,
|
||||
String? idempotencyKey,
|
||||
});
|
||||
|
||||
@override
|
||||
$OrderCopyWith<$Res> get order;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$RefundFormStateImplCopyWithImpl<$Res>
|
||||
extends _$RefundFormStateCopyWithImpl<$Res, _$RefundFormStateImpl>
|
||||
implements _$$RefundFormStateImplCopyWith<$Res> {
|
||||
__$$RefundFormStateImplCopyWithImpl(
|
||||
_$RefundFormStateImpl _value,
|
||||
$Res Function(_$RefundFormStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? order = null,
|
||||
Object? reason = null,
|
||||
Object? refundReason = freezed,
|
||||
Object? failureOrRefund = null,
|
||||
Object? isSubmitting = null,
|
||||
Object? idempotencyKey = freezed,
|
||||
}) {
|
||||
return _then(
|
||||
_$RefundFormStateImpl(
|
||||
order: null == order
|
||||
? _value.order
|
||||
: order // ignore: cast_nullable_to_non_nullable
|
||||
as Order,
|
||||
reason: null == reason
|
||||
? _value.reason
|
||||
: reason // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
refundReason: freezed == refundReason
|
||||
? _value.refundReason
|
||||
: refundReason // ignore: cast_nullable_to_non_nullable
|
||||
as RefundReason?,
|
||||
failureOrRefund: null == failureOrRefund
|
||||
? _value.failureOrRefund
|
||||
: failureOrRefund // ignore: cast_nullable_to_non_nullable
|
||||
as Option<Either<OrderFailure, Unit>>,
|
||||
isSubmitting: null == isSubmitting
|
||||
? _value.isSubmitting
|
||||
: isSubmitting // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
idempotencyKey: freezed == idempotencyKey
|
||||
? _value.idempotencyKey
|
||||
: idempotencyKey // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$RefundFormStateImpl implements _RefundFormState {
|
||||
_$RefundFormStateImpl({
|
||||
required this.order,
|
||||
required this.reason,
|
||||
this.refundReason,
|
||||
required this.failureOrRefund,
|
||||
this.isSubmitting = false,
|
||||
this.idempotencyKey,
|
||||
});
|
||||
|
||||
@override
|
||||
final Order order;
|
||||
@override
|
||||
final String reason;
|
||||
@override
|
||||
final RefundReason? refundReason;
|
||||
@override
|
||||
final Option<Either<OrderFailure, Unit>> failureOrRefund;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool isSubmitting;
|
||||
|
||||
/// Idempotency key untuk refund submission.
|
||||
/// Di-generate saat user tap "Refund", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
@override
|
||||
final String? idempotencyKey;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'RefundFormState(order: $order, reason: $reason, refundReason: $refundReason, failureOrRefund: $failureOrRefund, isSubmitting: $isSubmitting, idempotencyKey: $idempotencyKey)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$RefundFormStateImpl &&
|
||||
(identical(other.order, order) || other.order == order) &&
|
||||
(identical(other.reason, reason) || other.reason == reason) &&
|
||||
(identical(other.refundReason, refundReason) ||
|
||||
other.refundReason == refundReason) &&
|
||||
(identical(other.failureOrRefund, failureOrRefund) ||
|
||||
other.failureOrRefund == failureOrRefund) &&
|
||||
(identical(other.isSubmitting, isSubmitting) ||
|
||||
other.isSubmitting == isSubmitting) &&
|
||||
(identical(other.idempotencyKey, idempotencyKey) ||
|
||||
other.idempotencyKey == idempotencyKey));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
order,
|
||||
reason,
|
||||
refundReason,
|
||||
failureOrRefund,
|
||||
isSubmitting,
|
||||
idempotencyKey,
|
||||
);
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$RefundFormStateImplCopyWith<_$RefundFormStateImpl> get copyWith =>
|
||||
__$$RefundFormStateImplCopyWithImpl<_$RefundFormStateImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
}
|
||||
|
||||
abstract class _RefundFormState implements RefundFormState {
|
||||
factory _RefundFormState({
|
||||
required final Order order,
|
||||
required final String reason,
|
||||
final RefundReason? refundReason,
|
||||
required final Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
final bool isSubmitting,
|
||||
final String? idempotencyKey,
|
||||
}) = _$RefundFormStateImpl;
|
||||
|
||||
@override
|
||||
Order get order;
|
||||
@override
|
||||
String get reason;
|
||||
@override
|
||||
RefundReason? get refundReason;
|
||||
@override
|
||||
Option<Either<OrderFailure, Unit>> get failureOrRefund;
|
||||
@override
|
||||
bool get isSubmitting;
|
||||
|
||||
/// Idempotency key untuk refund submission.
|
||||
/// Di-generate saat user tap "Refund", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
@override
|
||||
String? get idempotencyKey;
|
||||
|
||||
/// Create a copy of RefundFormState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$RefundFormStateImplCopyWith<_$RefundFormStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
part of 'refund_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class RefundFormEvent with _$RefundFormEvent {
|
||||
const factory RefundFormEvent.setOrder(Order order) = _SetOrder;
|
||||
const factory RefundFormEvent.reasonChanged(String reason) = _ReasonChanged;
|
||||
const factory RefundFormEvent.refundReasonChanged(RefundReason refundReason) =
|
||||
_RefundReasonChanged;
|
||||
const factory RefundFormEvent.submitted() = _Submitted;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
part of 'refund_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class RefundFormState with _$RefundFormState {
|
||||
factory RefundFormState({
|
||||
required Order order,
|
||||
required String reason,
|
||||
RefundReason? refundReason,
|
||||
required Option<Either<OrderFailure, Unit>> failureOrRefund,
|
||||
@Default(false) bool isSubmitting,
|
||||
/// Idempotency key untuk refund submission.
|
||||
/// Di-generate saat user tap "Refund", dipakai ulang saat retry,
|
||||
/// di-clear setelah sukses.
|
||||
String? idempotencyKey,
|
||||
}) = _RefundFormState;
|
||||
|
||||
factory RefundFormState.initial() => RefundFormState(
|
||||
order: Order.empty(),
|
||||
reason: '',
|
||||
failureOrRefund: none(),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../common/extension/extension.dart';
|
||||
|
||||
part 'report_event.dart';
|
||||
part 'report_state.dart';
|
||||
part 'report_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class ReportBloc extends Bloc<ReportEvent, ReportState> {
|
||||
ReportBloc() : super(ReportState.initial()) {
|
||||
on<ReportEvent>(_onReportEvent);
|
||||
}
|
||||
|
||||
Future<void> _onReportEvent(ReportEvent event, Emitter<ReportState> emit) {
|
||||
return event.map(
|
||||
dateChanged: (e) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
startDate: e.startDate,
|
||||
endDate: e.endDate,
|
||||
rangeDateFormatted:
|
||||
'${e.startDate.toFormattedDate()} - ${e.endDate.toFormattedDate()}',
|
||||
),
|
||||
);
|
||||
},
|
||||
menuChanged: (e) async {
|
||||
emit(state.copyWith(selectedMenu: e.index, title: e.title));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,616 @@
|
||||
// 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 'report_bloc.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(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 _$ReportEvent {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(int index, String title) menuChanged,
|
||||
required TResult Function(DateTime startDate, DateTime endDate) dateChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(int index, String title)? menuChanged,
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? dateChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(int index, String title)? menuChanged,
|
||||
TResult Function(DateTime startDate, DateTime endDate)? dateChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_MenuChanged value) menuChanged,
|
||||
required TResult Function(_DateChanged value) dateChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_MenuChanged value)? menuChanged,
|
||||
TResult? Function(_DateChanged value)? dateChanged,
|
||||
}) => throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_MenuChanged value)? menuChanged,
|
||||
TResult Function(_DateChanged value)? dateChanged,
|
||||
required TResult orElse(),
|
||||
}) => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ReportEventCopyWith<$Res> {
|
||||
factory $ReportEventCopyWith(
|
||||
ReportEvent value,
|
||||
$Res Function(ReportEvent) then,
|
||||
) = _$ReportEventCopyWithImpl<$Res, ReportEvent>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ReportEventCopyWithImpl<$Res, $Val extends ReportEvent>
|
||||
implements $ReportEventCopyWith<$Res> {
|
||||
_$ReportEventCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ReportEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$MenuChangedImplCopyWith<$Res> {
|
||||
factory _$$MenuChangedImplCopyWith(
|
||||
_$MenuChangedImpl value,
|
||||
$Res Function(_$MenuChangedImpl) then,
|
||||
) = __$$MenuChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({int index, String title});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$MenuChangedImplCopyWithImpl<$Res>
|
||||
extends _$ReportEventCopyWithImpl<$Res, _$MenuChangedImpl>
|
||||
implements _$$MenuChangedImplCopyWith<$Res> {
|
||||
__$$MenuChangedImplCopyWithImpl(
|
||||
_$MenuChangedImpl _value,
|
||||
$Res Function(_$MenuChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ReportEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? index = null, Object? title = null}) {
|
||||
return _then(
|
||||
_$MenuChangedImpl(
|
||||
index: null == index
|
||||
? _value.index
|
||||
: index // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$MenuChangedImpl implements _MenuChanged {
|
||||
const _$MenuChangedImpl({required this.index, required this.title});
|
||||
|
||||
@override
|
||||
final int index;
|
||||
@override
|
||||
final String title;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReportEvent.menuChanged(index: $index, title: $title)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$MenuChangedImpl &&
|
||||
(identical(other.index, index) || other.index == index) &&
|
||||
(identical(other.title, title) || other.title == title));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, index, title);
|
||||
|
||||
/// Create a copy of ReportEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$MenuChangedImplCopyWith<_$MenuChangedImpl> get copyWith =>
|
||||
__$$MenuChangedImplCopyWithImpl<_$MenuChangedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(int index, String title) menuChanged,
|
||||
required TResult Function(DateTime startDate, DateTime endDate) dateChanged,
|
||||
}) {
|
||||
return menuChanged(index, title);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(int index, String title)? menuChanged,
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? dateChanged,
|
||||
}) {
|
||||
return menuChanged?.call(index, title);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(int index, String title)? menuChanged,
|
||||
TResult Function(DateTime startDate, DateTime endDate)? dateChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (menuChanged != null) {
|
||||
return menuChanged(index, title);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_MenuChanged value) menuChanged,
|
||||
required TResult Function(_DateChanged value) dateChanged,
|
||||
}) {
|
||||
return menuChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_MenuChanged value)? menuChanged,
|
||||
TResult? Function(_DateChanged value)? dateChanged,
|
||||
}) {
|
||||
return menuChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_MenuChanged value)? menuChanged,
|
||||
TResult Function(_DateChanged value)? dateChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (menuChanged != null) {
|
||||
return menuChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _MenuChanged implements ReportEvent {
|
||||
const factory _MenuChanged({
|
||||
required final int index,
|
||||
required final String title,
|
||||
}) = _$MenuChangedImpl;
|
||||
|
||||
int get index;
|
||||
String get title;
|
||||
|
||||
/// Create a copy of ReportEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$MenuChangedImplCopyWith<_$MenuChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$DateChangedImplCopyWith<$Res> {
|
||||
factory _$$DateChangedImplCopyWith(
|
||||
_$DateChangedImpl value,
|
||||
$Res Function(_$DateChangedImpl) then,
|
||||
) = __$$DateChangedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({DateTime startDate, DateTime endDate});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$DateChangedImplCopyWithImpl<$Res>
|
||||
extends _$ReportEventCopyWithImpl<$Res, _$DateChangedImpl>
|
||||
implements _$$DateChangedImplCopyWith<$Res> {
|
||||
__$$DateChangedImplCopyWithImpl(
|
||||
_$DateChangedImpl _value,
|
||||
$Res Function(_$DateChangedImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ReportEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
||||
return _then(
|
||||
_$DateChangedImpl(
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$DateChangedImpl implements _DateChanged {
|
||||
const _$DateChangedImpl({required this.startDate, required this.endDate});
|
||||
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReportEvent.dateChanged(startDate: $startDate, endDate: $endDate)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$DateChangedImpl &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
||||
|
||||
/// Create a copy of ReportEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$DateChangedImplCopyWith<_$DateChangedImpl> get copyWith =>
|
||||
__$$DateChangedImplCopyWithImpl<_$DateChangedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function(int index, String title) menuChanged,
|
||||
required TResult Function(DateTime startDate, DateTime endDate) dateChanged,
|
||||
}) {
|
||||
return dateChanged(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function(int index, String title)? menuChanged,
|
||||
TResult? Function(DateTime startDate, DateTime endDate)? dateChanged,
|
||||
}) {
|
||||
return dateChanged?.call(startDate, endDate);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function(int index, String title)? menuChanged,
|
||||
TResult Function(DateTime startDate, DateTime endDate)? dateChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (dateChanged != null) {
|
||||
return dateChanged(startDate, endDate);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(_MenuChanged value) menuChanged,
|
||||
required TResult Function(_DateChanged value) dateChanged,
|
||||
}) {
|
||||
return dateChanged(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(_MenuChanged value)? menuChanged,
|
||||
TResult? Function(_DateChanged value)? dateChanged,
|
||||
}) {
|
||||
return dateChanged?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(_MenuChanged value)? menuChanged,
|
||||
TResult Function(_DateChanged value)? dateChanged,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (dateChanged != null) {
|
||||
return dateChanged(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _DateChanged implements ReportEvent {
|
||||
const factory _DateChanged({
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
}) = _$DateChangedImpl;
|
||||
|
||||
DateTime get startDate;
|
||||
DateTime get endDate;
|
||||
|
||||
/// Create a copy of ReportEvent
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$DateChangedImplCopyWith<_$DateChangedImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$ReportState {
|
||||
String get title => throw _privateConstructorUsedError;
|
||||
DateTime get startDate => throw _privateConstructorUsedError;
|
||||
DateTime get endDate => throw _privateConstructorUsedError;
|
||||
String get rangeDateFormatted => throw _privateConstructorUsedError;
|
||||
int get selectedMenu => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of ReportState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$ReportStateCopyWith<ReportState> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $ReportStateCopyWith<$Res> {
|
||||
factory $ReportStateCopyWith(
|
||||
ReportState value,
|
||||
$Res Function(ReportState) then,
|
||||
) = _$ReportStateCopyWithImpl<$Res, ReportState>;
|
||||
@useResult
|
||||
$Res call({
|
||||
String title,
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
String rangeDateFormatted,
|
||||
int selectedMenu,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$ReportStateCopyWithImpl<$Res, $Val extends ReportState>
|
||||
implements $ReportStateCopyWith<$Res> {
|
||||
_$ReportStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of ReportState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? title = null,
|
||||
Object? startDate = null,
|
||||
Object? endDate = null,
|
||||
Object? rangeDateFormatted = null,
|
||||
Object? selectedMenu = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
rangeDateFormatted: null == rangeDateFormatted
|
||||
? _value.rangeDateFormatted
|
||||
: rangeDateFormatted // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
selectedMenu: null == selectedMenu
|
||||
? _value.selectedMenu
|
||||
: selectedMenu // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$ReportStateImplCopyWith<$Res>
|
||||
implements $ReportStateCopyWith<$Res> {
|
||||
factory _$$ReportStateImplCopyWith(
|
||||
_$ReportStateImpl value,
|
||||
$Res Function(_$ReportStateImpl) then,
|
||||
) = __$$ReportStateImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
String title,
|
||||
DateTime startDate,
|
||||
DateTime endDate,
|
||||
String rangeDateFormatted,
|
||||
int selectedMenu,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$ReportStateImplCopyWithImpl<$Res>
|
||||
extends _$ReportStateCopyWithImpl<$Res, _$ReportStateImpl>
|
||||
implements _$$ReportStateImplCopyWith<$Res> {
|
||||
__$$ReportStateImplCopyWithImpl(
|
||||
_$ReportStateImpl _value,
|
||||
$Res Function(_$ReportStateImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of ReportState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? title = null,
|
||||
Object? startDate = null,
|
||||
Object? endDate = null,
|
||||
Object? rangeDateFormatted = null,
|
||||
Object? selectedMenu = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$ReportStateImpl(
|
||||
title: null == title
|
||||
? _value.title
|
||||
: title // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
startDate: null == startDate
|
||||
? _value.startDate
|
||||
: startDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
endDate: null == endDate
|
||||
? _value.endDate
|
||||
: endDate // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime,
|
||||
rangeDateFormatted: null == rangeDateFormatted
|
||||
? _value.rangeDateFormatted
|
||||
: rangeDateFormatted // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
selectedMenu: null == selectedMenu
|
||||
? _value.selectedMenu
|
||||
: selectedMenu // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$ReportStateImpl implements _ReportState {
|
||||
_$ReportStateImpl({
|
||||
required this.title,
|
||||
required this.startDate,
|
||||
required this.endDate,
|
||||
required this.rangeDateFormatted,
|
||||
this.selectedMenu = 0,
|
||||
});
|
||||
|
||||
@override
|
||||
final String title;
|
||||
@override
|
||||
final DateTime startDate;
|
||||
@override
|
||||
final DateTime endDate;
|
||||
@override
|
||||
final String rangeDateFormatted;
|
||||
@override
|
||||
@JsonKey()
|
||||
final int selectedMenu;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ReportState(title: $title, startDate: $startDate, endDate: $endDate, rangeDateFormatted: $rangeDateFormatted, selectedMenu: $selectedMenu)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$ReportStateImpl &&
|
||||
(identical(other.title, title) || other.title == title) &&
|
||||
(identical(other.startDate, startDate) ||
|
||||
other.startDate == startDate) &&
|
||||
(identical(other.endDate, endDate) || other.endDate == endDate) &&
|
||||
(identical(other.rangeDateFormatted, rangeDateFormatted) ||
|
||||
other.rangeDateFormatted == rangeDateFormatted) &&
|
||||
(identical(other.selectedMenu, selectedMenu) ||
|
||||
other.selectedMenu == selectedMenu));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType,
|
||||
title,
|
||||
startDate,
|
||||
endDate,
|
||||
rangeDateFormatted,
|
||||
selectedMenu,
|
||||
);
|
||||
|
||||
/// Create a copy of ReportState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$ReportStateImplCopyWith<_$ReportStateImpl> get copyWith =>
|
||||
__$$ReportStateImplCopyWithImpl<_$ReportStateImpl>(this, _$identity);
|
||||
}
|
||||
|
||||
abstract class _ReportState implements ReportState {
|
||||
factory _ReportState({
|
||||
required final String title,
|
||||
required final DateTime startDate,
|
||||
required final DateTime endDate,
|
||||
required final String rangeDateFormatted,
|
||||
final int selectedMenu,
|
||||
}) = _$ReportStateImpl;
|
||||
|
||||
@override
|
||||
String get title;
|
||||
@override
|
||||
DateTime get startDate;
|
||||
@override
|
||||
DateTime get endDate;
|
||||
@override
|
||||
String get rangeDateFormatted;
|
||||
@override
|
||||
int get selectedMenu;
|
||||
|
||||
/// Create a copy of ReportState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$ReportStateImplCopyWith<_$ReportStateImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
part of 'report_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ReportEvent with _$ReportEvent {
|
||||
const factory ReportEvent.menuChanged({
|
||||
required int index,
|
||||
required String title,
|
||||
}) = _MenuChanged;
|
||||
const factory ReportEvent.dateChanged({
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
}) = _DateChanged;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
part of 'report_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class ReportState with _$ReportState {
|
||||
factory ReportState({
|
||||
required String title,
|
||||
required DateTime startDate,
|
||||
required DateTime endDate,
|
||||
required String rangeDateFormatted,
|
||||
@Default(0) int selectedMenu,
|
||||
}) = _ReportState;
|
||||
|
||||
factory ReportState.initial() => ReportState(
|
||||
title: 'Ringkasan Laporan Penjualan',
|
||||
startDate: DateTime.now().subtract(const Duration(days: 30)),
|
||||
endDate: DateTime.now(),
|
||||
rangeDateFormatted:
|
||||
'${DateTime.now().subtract(const Duration(days: 30)).toFormattedDate()} - ${DateTime.now().toFormattedDate()}',
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart' hide Order;
|
||||
|
||||
import '../../../common/extension/extension.dart';
|
||||
import '../../../common/types/split_type.dart';
|
||||
import '../../../domain/customer/customer.dart';
|
||||
import '../../../domain/order/order.dart';
|
||||
|
||||
part 'split_bill_form_event.dart';
|
||||
part 'split_bill_form_state.dart';
|
||||
part 'split_bill_form_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class SplitBillFormBloc extends Bloc<SplitBillFormEvent, SplitBillFormState> {
|
||||
SplitBillFormBloc() : super(SplitBillFormState.initial()) {
|
||||
on<SplitBillFormEvent>(_onSplitBillFormEvent);
|
||||
}
|
||||
|
||||
Future<void> _onSplitBillFormEvent(
|
||||
SplitBillFormEvent event,
|
||||
Emitter<SplitBillFormState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
setOrder: (e) async {
|
||||
List<OrderItem> pendingItems = e.order.orderItems
|
||||
.where((item) => item.status == 'pending')
|
||||
.toList();
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
order: e.order,
|
||||
pendingItems: pendingItems,
|
||||
splitType: e.order.splitType.isEmpty
|
||||
? SplitType.amount
|
||||
: e.order.splitType.toSplitType(),
|
||||
),
|
||||
);
|
||||
},
|
||||
customerChanged: (e) async {
|
||||
emit(state.copyWith(customer: e.customer));
|
||||
},
|
||||
customerNameChanged: (e) async {
|
||||
emit(state.copyWith(customerName: e.customerName));
|
||||
},
|
||||
splitTypeChanged: (e) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
splitType: e.splitType,
|
||||
totalAmount: 0,
|
||||
selectedProducts: {},
|
||||
),
|
||||
);
|
||||
},
|
||||
itemQuantityChanged: (e) async {
|
||||
final newQuantities = Map<String, int>.from(state.selectedProducts);
|
||||
|
||||
if (e.quantity > 0) {
|
||||
newQuantities[e.itemId] = e.quantity;
|
||||
} else {
|
||||
newQuantities.remove(e.itemId);
|
||||
}
|
||||
|
||||
// Recalculate total price
|
||||
int newTotal = 0;
|
||||
for (var entry in newQuantities.entries) {
|
||||
final item = state.pendingItems.firstWhere(
|
||||
(item) => item.id == entry.key,
|
||||
);
|
||||
newTotal += item.unitPrice.toInt() * entry.value;
|
||||
}
|
||||
|
||||
emit(
|
||||
state.copyWith(
|
||||
selectedProducts: newQuantities,
|
||||
totalAmount: newTotal,
|
||||
),
|
||||
);
|
||||
},
|
||||
amountChanged: (e) async {
|
||||
emit(state.copyWith(totalAmount: e.amount));
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,17 @@
|
||||
part of 'split_bill_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SplitBillFormEvent with _$SplitBillFormEvent {
|
||||
const factory SplitBillFormEvent.setOrder(Order order) = _SetOrder;
|
||||
const factory SplitBillFormEvent.customerChanged(Customer? customer) =
|
||||
_CustomerChanged;
|
||||
const factory SplitBillFormEvent.customerNameChanged(String customerName) =
|
||||
_CustomerNameChanged;
|
||||
const factory SplitBillFormEvent.splitTypeChanged(SplitType splitType) =
|
||||
_SplitTypeChanged;
|
||||
const factory SplitBillFormEvent.itemQuantityChanged({
|
||||
required String itemId,
|
||||
required int quantity,
|
||||
}) = _ItemQuantityChanged;
|
||||
const factory SplitBillFormEvent.amountChanged(int amount) = _AmountChanged;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
part of 'split_bill_form_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SplitBillFormState with _$SplitBillFormState {
|
||||
factory SplitBillFormState({
|
||||
required Order order,
|
||||
required List<OrderItem> pendingItems,
|
||||
Customer? customer,
|
||||
required String customerName,
|
||||
required SplitType splitType,
|
||||
required Map<String, int> selectedProducts,
|
||||
@Default(0) int totalAmount,
|
||||
@Default(false) bool isConfirming,
|
||||
}) = _SplitBillFormState;
|
||||
|
||||
factory SplitBillFormState.initial() => SplitBillFormState(
|
||||
order: Order.empty(),
|
||||
pendingItems: [],
|
||||
customerName: '',
|
||||
splitType: SplitType.amount,
|
||||
selectedProducts: {},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../../domain/category/category.dart';
|
||||
import '../../../domain/product/product.dart';
|
||||
|
||||
part 'sync_setting_event.dart';
|
||||
part 'sync_setting_state.dart';
|
||||
part 'sync_setting_bloc.freezed.dart';
|
||||
|
||||
@injectable
|
||||
class SyncSettingBloc extends Bloc<SyncSettingEvent, SyncSettingState> {
|
||||
final IProductRepository _productRepository;
|
||||
final ICategoryRepository _categoryRepository;
|
||||
|
||||
SyncSettingBloc(this._productRepository, this._categoryRepository)
|
||||
: super(SyncSettingState.initial()) {
|
||||
on<SyncSettingEvent>(_onSyncSettingEvent);
|
||||
}
|
||||
|
||||
Future<void> _onSyncSettingEvent(
|
||||
SyncSettingEvent event,
|
||||
Emitter<SyncSettingState> emit,
|
||||
) {
|
||||
return event.map(
|
||||
loadStats: (e) => _onLoadStats(emit),
|
||||
syncAllData: (e) => _onSyncAllData(emit),
|
||||
clearAllData: (e) => _onClearAllData(emit),
|
||||
syncProducts: (e) => _onSyncProducts(emit),
|
||||
syncCategories: (e) => _onSyncCategories(emit),
|
||||
clearCategories: (e) => _onClearCategories(emit),
|
||||
clearProducts: (e) => _onClearProducts(emit),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onLoadStats(Emitter<SyncSettingState> emit) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: true,
|
||||
failureOptionProduct: none(),
|
||||
failureOptionCategory: none(),
|
||||
),
|
||||
);
|
||||
|
||||
final productStats = await _productRepository.getDatabaseStats();
|
||||
final categoryStats = await _categoryRepository.getDatabaseStats();
|
||||
|
||||
productStats.fold(
|
||||
(failure) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
failureOptionProduct: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(data) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
productStats: data,
|
||||
failureOptionProduct: none(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
categoryStats.fold(
|
||||
(failure) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
failureOptionCategory: optionOf(failure),
|
||||
),
|
||||
);
|
||||
},
|
||||
(data) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
categoryStats: data,
|
||||
failureOptionCategory: none(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onSyncAllData(Emitter<SyncSettingState> emit) async {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSyncing: true,
|
||||
failureOptionSyncCategory: none(),
|
||||
failureOptionSyncProduct: none(),
|
||||
),
|
||||
);
|
||||
|
||||
// Sync categories first
|
||||
final categoryResult = await _categoryRepository.syncAllCategories();
|
||||
|
||||
bool categorySuccess = false;
|
||||
categoryResult.fold(
|
||||
(failure) {
|
||||
emit(
|
||||
state.copyWith(failureOptionSyncCategory: optionOf(left(failure))),
|
||||
);
|
||||
},
|
||||
(success) {
|
||||
categorySuccess = true;
|
||||
emit(
|
||||
state.copyWith(failureOptionSyncCategory: optionOf(right(success))),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// Only sync products if categories synced successfully
|
||||
if (categorySuccess) {
|
||||
final productResult = await _productRepository.syncAllProducts();
|
||||
|
||||
productResult.fold(
|
||||
(failure) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSyncing: false,
|
||||
failureOptionSyncProduct: optionOf(left(failure)),
|
||||
),
|
||||
);
|
||||
},
|
||||
(success) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isSyncing: false,
|
||||
failureOptionSyncProduct: optionOf(right(success)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
} else {
|
||||
emit(state.copyWith(isSyncing: false));
|
||||
}
|
||||
|
||||
// Reload stats after sync
|
||||
add(const SyncSettingEvent.loadStats());
|
||||
}
|
||||
|
||||
Future<void> _onClearAllData(Emitter<SyncSettingState> emit) async {
|
||||
emit(state.copyWith(isLoading: true));
|
||||
|
||||
try {
|
||||
// Clear products and categories
|
||||
await _productRepository.clearAllProducts();
|
||||
await _categoryRepository.clearAllCategories();
|
||||
|
||||
// Clear caches
|
||||
_productRepository.clearCache();
|
||||
_categoryRepository.clearCache();
|
||||
|
||||
emit(state.copyWith(isLoading: false));
|
||||
|
||||
// Reload stats after clearing
|
||||
add(const SyncSettingEvent.loadStats());
|
||||
} catch (e) {
|
||||
emit(state.copyWith(isLoading: false));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onSyncProducts(Emitter<SyncSettingState> emit) async {
|
||||
emit(state.copyWith(isLoading: true, failureOptionSyncProduct: none()));
|
||||
|
||||
final result = await _productRepository.syncAllProducts();
|
||||
|
||||
result.fold(
|
||||
(failure) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
failureOptionSyncProduct: optionOf(left(failure)),
|
||||
),
|
||||
);
|
||||
},
|
||||
(success) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
failureOptionSyncProduct: optionOf(right(success)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// Reload stats after sync
|
||||
add(const SyncSettingEvent.loadStats());
|
||||
}
|
||||
|
||||
Future<void> _onSyncCategories(Emitter<SyncSettingState> emit) async {
|
||||
emit(state.copyWith(isLoading: true, failureOptionSyncCategory: none()));
|
||||
|
||||
final result = await _categoryRepository.syncAllCategories();
|
||||
|
||||
result.fold(
|
||||
(failure) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
failureOptionSyncCategory: optionOf(left(failure)),
|
||||
),
|
||||
);
|
||||
},
|
||||
(success) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
isLoading: false,
|
||||
failureOptionSyncCategory: optionOf(right(success)),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
// Reload stats after sync
|
||||
add(const SyncSettingEvent.loadStats());
|
||||
}
|
||||
|
||||
Future<void> _onClearCategories(Emitter<SyncSettingState> emit) async {
|
||||
await _categoryRepository.clearAllCategories();
|
||||
_categoryRepository.clearCache();
|
||||
}
|
||||
|
||||
Future<void> _onClearProducts(Emitter<SyncSettingState> emit) async {
|
||||
await _productRepository.clearAllProducts();
|
||||
_productRepository.clearCache();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
part of 'sync_setting_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SyncSettingEvent with _$SyncSettingEvent {
|
||||
const factory SyncSettingEvent.loadStats() = _LoadStats;
|
||||
const factory SyncSettingEvent.syncAllData() = _SyncAllData;
|
||||
const factory SyncSettingEvent.clearAllData() = _ClearAllData;
|
||||
const factory SyncSettingEvent.syncProducts() = _SyncProducts;
|
||||
const factory SyncSettingEvent.syncCategories() = _SyncCategories;
|
||||
const factory SyncSettingEvent.clearCategories() = _ClearCategories;
|
||||
const factory SyncSettingEvent.clearProducts() = _ClearProducts;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
part of 'sync_setting_bloc.dart';
|
||||
|
||||
@freezed
|
||||
class SyncSettingState with _$SyncSettingState {
|
||||
factory SyncSettingState({
|
||||
required Map<String, dynamic> productStats,
|
||||
required Map<String, dynamic> categoryStats,
|
||||
required Option<CategoryFailure> failureOptionCategory,
|
||||
required Option<ProductFailure> failureOptionProduct,
|
||||
required Option<Either<ProductFailure, String>> failureOptionSyncProduct,
|
||||
required Option<Either<CategoryFailure, String>> failureOptionSyncCategory,
|
||||
@Default(false) bool isSyncing,
|
||||
@Default(false) bool isLoading,
|
||||
}) = _SyncSettingState;
|
||||
|
||||
factory SyncSettingState.initial() => SyncSettingState(
|
||||
productStats: {},
|
||||
categoryStats: {},
|
||||
failureOptionCategory: none(),
|
||||
failureOptionProduct: none(),
|
||||
failureOptionSyncProduct: none(),
|
||||
failureOptionSyncCategory: none(),
|
||||
);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user