Compare commits

...
35 Commits
Author SHA1 Message Date
efrilm 0c8ca3c51b git push 2026-05-15 12:53:04 +07:00
Efril 96526c1972 update 2026-05-14 15:05:04 +07:00
Efril c4618bbc1b update pesanan 2026-05-14 14:55:49 +07:00
Efril 9f2097a268 add all outlet 2026-05-14 14:11:42 +07:00
efrilm 6fda0f5636 fix home 2026-05-13 15:31:14 +07:00
efrilm d7cd84e130 fix ios 2026-05-13 13:22:06 +07:00
efrilm ba2f0cd265 selected outlet 2026-05-12 17:09:50 +07:00
efrilm 3541fc725c outlet list 2026-05-12 16:47:36 +07:00
efrilm c2727a0995 update outlet card 2026-05-12 16:31:00 +07:00
efrilm 6e4b09f15e update home ui 2026-05-12 15:50:02 +07:00
efrilm 9076c9c66e update home ui 2026-05-12 15:47:38 +07:00
efrilm 86d581f5ea update remove animation 2026-05-12 14:48:53 +07:00
efrilm 411d1274bd add files ios 2026-05-12 02:01:15 +07:00
Efril a4a12c6763 add device info at login 2026-05-12 02:00:38 +07:00
Efril 9b6e9c591d update notification 2026-05-12 01:54:24 +07:00
Efril 3985611a0e update ios 2026-05-12 00:59:56 +07:00
Efril 61dd2bbb2c update api 2026-05-12 00:55:15 +07:00
Efril 91965667ec setup fcm 2026-05-12 00:52:14 +07:00
efrilm 9775e09659 feat: readme 2025-08-22 15:26:16 +07:00
efrilm 3f75bffd09 feat: pull to refresh on home 2025-08-20 13:57:00 +07:00
efrilm 5a83bc4049 feat: lang 2025-08-20 13:52:49 +07:00
efrilm f07d07b3a8 feat: transaction report 2025-08-19 17:39:00 +07:00
efrilm 1aa65d1732 feat: inventory report 2025-08-19 17:05:55 +07:00
efrilm 50934bfed9 feat: about app 2025-08-19 16:05:42 +07:00
efrilm 838707becf fix: bloc 2025-08-19 15:36:34 +07:00
efrilm 1b1e8c5bb4 feat: change password 2025-08-19 15:35:18 +07:00
efrilm 7919825955 feat: update user 2025-08-19 15:05:08 +07:00
efrilm bfd4604897 feat: update download report 2025-08-19 13:09:00 +07:00
efrilm 60f43f6df7 feat: download report page 2025-08-19 13:01:29 +07:00
efrilm 811ac4b202 feat: comming page 2025-08-19 12:48:06 +07:00
efrilm b731704a3d feat: home bloc 2025-08-19 12:23:53 +07:00
efrilm 9b51bf2bee feat: order shimmer 2025-08-19 11:44:50 +07:00
efrilm 5b91b5978f feat: order range date filter 2025-08-19 11:42:26 +07:00
efrilm 590bb3329c feat: outlet information page 2025-08-19 11:08:33 +07:00
efrilm de11c1243c feat: update profile page 2025-08-19 10:10:12 +07:00
231 changed files with 20930 additions and 3109 deletions
+541 -15
View File
@@ -1,39 +1,565 @@
# Apskel Owner App
## Apskel Owner Flutter
A Flutter-based Point of Sale (POS) application designed specifically for business owners.
Helps manage sales, products, inventory, and business reports in real-time with a simple, easy-to-use interface.
A POS (Point of Sale) application for business owners, built with Flutter. The project follows a layered architecture (presentation → application → domain → infrastructure) with dependency injection, state management, automated routing, internationalization, and code generation.
## 🚀 Getting Started
---
### âś… Prerequisites
### Contents
- [Flutter](https://flutter.dev/docs/get-started/install) 3.32.8 or newer
- Dart 3.8.1 or newer
- Technical Summary
- Requirements & Setup
- Running the App
- Architecture Overview
- Project Structure
- Key Dependencies & Purpose
- Code Generation
- Internationalization (i18n)
- Theming & Assets
- Environment Configuration (`env.dart`)
- Development Practices
### đź›  Installation
---
```bash
git clone https://github.com/efrilm/frl-movie.git
```
## Technical Summary
```bash
cd app-path
```
- SDK: Flutter (Material) with Dart ^3.8.1
- Targets: Android, iOS, Web, Desktop (Windows, macOS, Linux)
- State management: `flutter_bloc`
- Routing: `auto_route`
- Dependency Injection: `get_it` + `injectable`
- HTTP Client: `dio` (+ `awesome_dio_interceptor`)
- Data class & serialization: `freezed` + `json_serializable`
- Localization: `flutter_localizations`, `l10n/*.arb`
- Assets generation: `flutter_gen`
---
## Requirements & Setup
### Prerequisites
- Flutter SDK installed as per the official guide (`https://flutter.dev/docs/get-started/install`)
- Dart version per constraint: ^3.8.1
### Installation
```bash
git clone <your-repo-url>
cd apskel_owner_flutter
flutter pub get
```
### Code generation (required after clone or when annotations change)
```bash
flutter pub run build_runner build --delete-conflicting-outputs
```
> Re-run whenever you change files using `@RoutePage()`, `@injectable`, `@freezed`, or `@JsonSerializable`.
---
## đź§Ş Running
## Running the App
```bash
flutter run
```
Select a specific device/platform:
```bash
flutter run -d chrome
flutter run -d ios
flutter run -d android
```
Example release builds:
```bash
flutter build apk --release
flutter build ios --release
flutter build web --release
```
---
## Architecture Overview
The codebase follows a clean, layered approach that separates concerns and keeps features modular and testable:
- Presentation (`lib/presentation`): Widgets, pages/screens, and the `AutoRoute` router. Contains only UI code and wiring to BLoC/Cubit.
- Application (`lib/application`): BLoC/Cubit and application-level orchestration. Holds input validation, state transitions, and calls into the Domain layer.
- Domain (`lib/domain`): Pure business logic. Entities, value objects, repository interfaces, and (optional) use-cases. No framework dependencies.
- Infrastructure (`lib/infrastructure`): Repository implementations, DTOs, and data sources (HTTP/DB). Performs `dio` calls and mappings between DTOs and Domain entities.
- Common (`lib/common`): Cross-cutting helpers such as API base, DI setup, constants, extensions, theme, validators, and utilities.
Data flow in a feature:
1. UI triggers an intent/event in Presentation →
2. Application layer BLoC/Cubit handles the event and calls a repository/use-case from Domain →
3. Infrastructure implements the repository, performs network calls via `dio`, and maps results →
4. Data is converted to Domain entities and returned to Application →
5. Application updates state, Presentation rebuilds UI accordingly.
Cross-cutting concerns:
- Dependency Injection: `get_it` + `injectable` auto-register services/repositories (`injection.dart`, `injection.config.dart`).
- Routing: `auto_route` defines typed routes, generated into router files in `presentation/router`.
- State: `flutter_bloc` models states/events and isolates side-effects in BLoCs/Cubits.
- Networking: `dio` with interceptors for logging and error handling.
- Error handling: functional style with `dartz` (`Either`, `Option`) or well-defined BLoC states.
- i18n: ARB files in `lib/l10n/` and generated localization delegates.
- Theming: centralized theme under `lib/common/theme/` with shared design tokens.
- Assets: managed under `assets/` and referenced via FlutterGen outputs at `lib/presentation/components/assets/`.
---
## Project Structure
```
lib/
application/ # BLoC/cubit per feature (analytic, auth, product, etc.)
common/
api/ # Base API client, endpoint helper
constant/ # Application constants
di/ # Dependency injection setup (get_it, injectable)
extension/ # Extensions
function/ # General utility functions
network/ # Connectivity checks, handlers
painter/ # Custom painters
theme/ # Colors, text styles, theming
url/ # Base URL/endpoints
utils/ # Other helpers
validator/ # Input validators
domain/
<feature>/ # Entities, repo interfaces, (use-cases if present)
infrastructure/
<feature>/ # Repo implementations, DTOs, API calls
l10n/ # ARB sources for i18n + generated localizations
presentation/
components/ # Reusable widgets
pages/ # Feature pages/screens
router/ # AutoRoute definitions
env.dart # Environment configuration (BASE_URL, etc.)
injection.dart # DI entry point
injection.config.dart # DI generated
main.dart # Application entry point
assets/
images/, icons/, json/, fonts/
```
---
## Key Dependencies & Purpose
Runtime:
- `auto_route`: Automated, typed routing based on annotations.
- `flutter_bloc`: State management with BLoC/Cubit.
- `get_it`, `injectable`: Service locator + codegen for DI.
- `dio`, `awesome_dio_interceptor`: HTTP client + logging interceptor.
- `freezed_annotation`, `json_annotation`: Annotations for immutable data classes & JSON.
- `dartz`: Functional types (Either, Option) for explicit error handling.
- `connectivity_plus`, `device_info_plus`, `package_info_plus`: Device and connectivity info.
- `shared_preferences`: Local key-value storage.
- `image_picker`, `permission_handler`, `open_file`, `url_launcher`: OS/device integrations.
- UI: `flutter_svg`, `line_icons`, `flutter_spinkit`, `fl_chart`, `another_flushbar`, `table_calendar`, `shimmer`, `cached_network_image`, `syncfusion_flutter_datepicker`, `pdf`.
Dev:
- `build_runner`: Code generation orchestration.
- `auto_route_generator`, `injectable_generator`, `freezed`, `json_serializable`: Related generators.
- `flutter_gen_runner`: Typed asset access generator.
- `flutter_lints`: Recommended Flutter lints.
- `flutter_launcher_icons`: Launcher icon generation.
Refer to `pubspec.yaml` for full version constraints.
---
## Code Generation
Common commands:
```bash
flutter pub run build_runner build --delete-conflicting-outputs
# or watch
flutter pub run build_runner watch --delete-conflicting-outputs
```
### Asset generation (flutter_gen_runner)
`flutter_gen_runner` is integrated with `build_runner`. Running the commands above will also generate typed accessors for assets based on the `flutter_gen` section in `pubspec.yaml`:
- Output path: `lib/presentation/components/assets/`
- SVG integration: enabled (`flutter_svg: true`)
Usage in code example (after generation):
```dart
// Example usage
// import 'presentation/components/assets/assets.gen.dart';
// Image.asset(Assets.images.logo.path);
```
Generators used:
- AutoRoute: Generates router and typed routes.
- Injectable: Generates DI registrations (`injection.config.dart`).
- Freezed: Generates immutable data classes, copyWith, unions, etc.
- Json Serializable: Generates toJson/fromJson for DTOs.
- FlutterGen: Generates static asset access under `lib/presentation/components/assets/`.
---
## Internationalization (i18n)
- Source files live in `lib/l10n/app_*.arb` (e.g., `app_en.arb`, `app_id.arb`).
- To add a language: create `app_<code>.arb`, then run code generation.
- Ensure `MaterialApp` is wired with `localizationsDelegates` and `supportedLocales` (already prepared).
---
## Theming & Assets
- Theme files live under `lib/common/theme/`.
- Fonts: `Quicksand` family is declared in `pubspec.yaml`.
- Assets: `assets/images/`, `assets/icons/`, `assets/json/` – referenced via FlutterGen outputs at `lib/presentation/components/assets/`.
---
## Environment Configuration (`env.dart`)
The `lib/env.dart` file stores configuration values such as base URLs and debug flags. Adjust per environment (development/production) using flavors, environment variables, or branching as preferred by the team.
---
## Development Practices
- Routing: Define routes in `presentation/router`, then run code generation.
- DI: Annotate services/repositories with `@injectable`/`@LazySingleton`, generate code, and call `configureDependencies()` early in app startup.
- BLoC: Keep UI logic in the `application` layer and use `BlocBuilder`/`BlocListener` in the `presentation` layer.
- DTO ↔ Entity: Mapping resides in the `infrastructure` layer to keep domain pure.
- Error handling: Prefer `Either`/`Option` (`dartz`) or well-structured BLoC states.
- Linting: Follow `analysis_options.yaml`.
---
## Useful Commands
```bash
# Install dependencies
flutter pub get
# Format & Analyze
flutter format .
flutter analyze
# Code generation (single run / watch)
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run build_runner watch --delete-conflicting-outputs
# Run by device
flutter devices
flutter run -d <device-id>
```
---
## Additional Notes
- Launcher icons configured via `launcher_icon.yaml`.
- Platform-specific configuration (Android/iOS/Web/Desktop) resides in respective platform folders.
- Review `analysis_options.yaml` for code style and lint rules.
---
## Launcher Icons
Configured via `launcher_icon.yaml` at the repository root. To (re)generate launcher icons, run:
```bash
dart run flutter_launcher_icons -f launcher_icon.yaml
```
If you prefer the Flutter shim:
```bash
flutter pub run flutter_launcher_icons -f launcher_icon.yaml
```
Ensure you have the package in `dev_dependencies` (`flutter_launcher_icons`).
## Contributing
1. Branch off `main`.
2. Make focused changes and provide a clear PR description.
3. Ensure build, lints, and codegen are clean before opening the PR.
---
## License
This project is private/internal. Contact the repository owner for usage permissions.
## Apskel Owner Flutter
Aplikasi Point of Sale (POS) untuk pemilik usaha, dibangun dengan Flutter. Proyek ini menerapkan arsitektur berlapis (presentation → application → domain → infrastructure) dengan dependency injection, state management, routing terotomasi, internationalization, dan code generation.
---
### Isi Dokumen
- Ringkasan Teknis
- Persyaratan & Setup
- Menjalankan Aplikasi
- Arsitektur & Alur
- Struktur Proyek
- Dependensi Utama & Fungsinya
- Code Generation
- Internationalization (i18n)
- Theming & Assets
- Konfigurasi Lingkungan (`env.dart`)
- Praktik Pengembangan
---
## Ringkasan Teknis
- SDK: Flutter (Material) dengan Dart ^3.8.1
- Target platform: Android, iOS, Web, Desktop (Windows, macOS, Linux)
- State management: `flutter_bloc`
- Routing: `auto_route`
- Dependency Injection: `get_it` + `injectable`
- HTTP Client: `dio` (+ `awesome_dio_interceptor`)
- Data class & serialization: `freezed` + `json_serializable`
- Localization: `flutter_localizations`, `l10n/*.arb`
- Assets generation: `flutter_gen`
---
## Persyaratan & Setup
### Prasyarat
- Flutter SDK terpasang sesuai panduan resmi (`https://flutter.dev/docs/get-started/install`)
- Versi Dart sesuai constraint: ^3.8.1
### Instalasi
```bash
git clone <repo-url-anda>
cd apskel_owner_flutter
flutter pub get
```
### Generate kode (wajib setelah clone atau mengubah anotasi)
```bash
flutter pub run build_runner build --delete-conflicting-outputs
```
> Jalankan ulang perintah di atas setiap kali Anda mengubah file yang menggunakan anotasi `@RoutePage()`, `@injectable`, `@freezed`, atau `@JsonSerializable`.
---
## Menjalankan Aplikasi
```bash
flutter run
```
Menentukan platform/target tertentu:
```bash
flutter run -d chrome
flutter run -d ios
flutter run -d android
```
Build release contoh:
```bash
flutter build apk --release
flutter build ios --release
flutter build web --release
```
---
## Arsitektur & Alur
Proyek mengikuti layering yang jelas:
- Presentation (`lib/presentation`): UI, widget, halaman, router.
- Application (`lib/application`): BLoC/cubit, use-case orkestra ringan, validasi input UI.
- Domain (`lib/domain`): Entitas, value object, repository interface, use-case (jika ada).
- Infrastructure (`lib/infrastructure`): Implementasi repository, data source (API/DB), mapping DTO.
- Common (`lib/common`): Utilitas umum, konstanta, theme, API base, DI bootstrap, extension, dll.
Alur umum:
1. UI memicu event →
2. BLoC di layer Application memanggil use-case/repo (Domain) →
3. Implementasi repo (Infrastructure) melakukan HTTP via `dio` →
4. Response dipetakan menjadi entity/domain →
5. State di-update kembali ke UI.
---
## Struktur Proyek
```
lib/
application/ # BLoC/cubit per fitur (analytic, auth, product, dst.)
common/
api/ # Base API client, endpoint helper
constant/ # Konstanta aplikasi
di/ # Setup dependency injection (get_it, injectable)
extension/ # Extension util
function/ # Fungsi util umum
network/ # Cek konektivitas, handler
painter/ # Custom painter
theme/ # Warna, text styles, theming
url/ # Base URL/endpoint
utils/ # Helper lain
validator/ # Validator input
domain/
<feature>/ # Entity, repo interface, (use-case bila ada)
infrastructure/
<feature>/ # Repo implementation, DTO, pemanggilan API
l10n/ # Berkas ARB untuk i18n + generated localizations
presentation/
components/ # Widget reusable
pages/ # Halaman/layar fitur
router/ # Definisi AutoRoute
env.dart # Konfigurasi environment (BASE_URL, dsb)
injection.dart # Entry point DI
injection.config.dart # DI generated
main.dart # Entrypoint aplikasi
assets/
images/, icons/, json/, fonts/
```
---
## Dependensi Utama & Fungsinya
Runtime:
- `auto_route`: Routing terotomasi berbasis anotasi.
- `flutter_bloc`: State management dengan BLoC/Cubit.
- `get_it`, `injectable`: Service locator + codegen untuk DI.
- `dio`, `awesome_dio_interceptor`: HTTP client + logging interceptor.
- `freezed_annotation`, `json_annotation`: Anotasi untuk data class immutable & JSON.
- `dartz`: Functional types (Either, Option) untuk error handling yang eksplisit.
- `connectivity_plus`, `device_info_plus`, `package_info_plus`: Info perangkat & konektivitas.
- `shared_preferences`: Penyimpanan key-value lokal.
- `image_picker`, `permission_handler`, `open_file`, `url_launcher`: Integrasi perangkat/OS.
- UI: `flutter_svg`, `line_icons`, `flutter_spinkit`, `fl_chart`, `another_flushbar`, `table_calendar`, `shimmer`, `cached_network_image`, `syncfusion_flutter_datepicker`, `pdf`.
Dev:
- `build_runner`: Orkestrasi code generation.
- `auto_route_generator`, `injectable_generator`, `freezed`, `json_serializable`: Generator terkait.
- `flutter_gen_runner`: Generator akses asset terketik.
- `flutter_lints`: Linter rekomendasi Flutter.
- `flutter_launcher_icons`: Generate icon launcher.
Catatan versi lengkap tersedia di `pubspec.yaml`.
---
## Code Generation
Perintah umum:
```bash
flutter pub run build_runner build --delete-conflicting-outputs
# atau untuk watch
flutter pub run build_runner watch --delete-conflicting-outputs
```
Generator yang digunakan:
- AutoRoute: menghasilkan deklarasi router & route.
- Injectable: menghasilkan registrasi DI (`injection.config.dart`).
- Freezed: menghasilkan data class immutable, copyWith, union, dsb.
- Json Serializable: menghasilkan toJson/fromJson untuk DTO.
- FlutterGen: menghasilkan akses asset statis di `lib/presentation/components/assets/`.
---
## Internationalization (i18n)
- Berkas sumber ada di `lib/l10n/app_*.arb` (contoh: `app_en.arb`, `app_id.arb`).
- Bahasa baru: tambahkan `app_<kode>.arb`, jalankan code generation.
- Pastikan `MaterialApp` menggunakan `localizationsDelegates` dan `supportedLocales` (sudah disiapkan).
---
## Theming & Assets
- Theme ada di `lib/common/theme/`.
- Font: keluarga `Quicksand` dideklarasikan di `pubspec.yaml`.
- Assets: `assets/images/`, `assets/icons/`, `assets/json/` – akses via FlutterGen yang dihasilkan ke `lib/presentation/components/assets/`.
---
## Konfigurasi Lingkungan (`env.dart`)
File `lib/env.dart` menyimpan nilai konfigurasi seperti base URL, flag debug, dll. Sesuaikan untuk development/production (bisa dengan flavor, env var, atau branch khusus sesuai kebutuhan tim).
---
## Praktik Pengembangan
- Routing: definisikan route di `presentation/router`, jalankan codegen.
- DI: daftarkan service/repository dengan anotasi `@injectable`/`@LazySingleton`, lalu generate, dan panggil `configureDependencies()` di awal aplikasi.
- BLoC: simpan logic UI di layer `application` dan gunakan `BlocBuilder`/`BlocListener` di layer `presentation`.
- DTO ↔ Entity: mapping berada di layer `infrastructure` untuk menjaga domain tetap bersih.
- Error handling: gunakan `Either`/`Option` (`dartz`) atau state terstruktur di BLoC.
- Lint: patuhi aturan `analysis_options.yaml`.
---
## Perintah Berguna
```bash
# Install dependencies
flutter pub get
# Format & Analyze
flutter format .
flutter analyze
# Code generation (sekali jalan / watch)
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run build_runner watch --delete-conflicting-outputs
# Run by device
flutter devices
flutter run -d <device-id>
```
---
## Catatan Tambahan
- Icon launcher dikonfigurasi di `launcher_icon.yaml` (gunakan `flutter pub run flutter_launcher_icons` bila diperlukan).
- Konfigurasi platform (Android/iOS/Web/Desktop) berada pada folder platform terkait.
- Pastikan meninjau `analysis_options.yaml` untuk standar code style dan lints.
---
## Kontribusi
1. Buat branch dari `main`.
2. Lakukan perubahan terfokus dan sertakan deskripsi yang jelas pada PR.
3. Pastikan build, lints, dan codegen bersih sebelum mengajukan PR.
---
## Lisensi
Proyek ini bersifat privat/internal. Hubungi pemilik repositori untuk detail izin penggunaan.
+1
View File
@@ -14,6 +14,7 @@ analyzer:
invalid_annotation_target: ignore
use_build_context_synchronously: ignore
deprecated_member_use: ignore
depend_on_referenced_packages: ignore
exclude:
- test/generated/**
- "**/**.g.dart"
+8 -2
View File
@@ -3,14 +3,16 @@ plugins {
id("kotlin-android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
id("com.google.gms.google-services")
}
android {
namespace = "com.apskel.apskel_owner"
namespace = "com.apskel.enaklo_owner"
compileSdk = flutter.compileSdkVersion
ndkVersion = "27.0.12077973"
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
@@ -21,7 +23,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.apskel.apskel_owner"
applicationId = "com.apskel.enaklo_owner"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
@@ -42,3 +44,7 @@ android {
flutter {
source = "../.."
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}
+48
View File
@@ -0,0 +1,48 @@
{
"project_info": {
"project_number": "765730035527",
"project_id": "apskel-pos-v2",
"storage_bucket": "apskel-pos-v2.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:765730035527:android:beffb797b781e715241e62",
"android_client_info": {
"package_name": "com.apskel.enaklo_owner"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAOZwVSQwUeeM9BjcyTOK9GUh8AmTWucuc"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:765730035527:android:498defd7071336dd241e62",
"android_client_info": {
"package_name": "com.apskel.pos"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyAOZwVSQwUeeM9BjcyTOK9GUh8AmTWucuc"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
+36 -1
View File
@@ -1,8 +1,19 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<!-- FCM: required for POST_NOTIFICATIONS on Android 13+ -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<!-- FCM: allow background processing after device reboot -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<!-- FCM: allow wake lock for background message processing -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<application
android:label="Apskel Owner"
android:label="Enaklo Owner"
android:name="${applicationName}"
android:icon="@mipmap/launcher_icon">
<activity
@@ -32,6 +43,30 @@
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<!-- FCM: default notification channel for Android 8+ -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="high_importance_channel" />
<!-- FCM: default notification icon -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notification" />
<!-- FCM: default notification color -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/notification_color" />
<!-- FCM: background message handler service -->
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:exported="false">
<intent-filter android:priority="-500">
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
@@ -1,4 +1,4 @@
package com.apskel.apskel_owner
package com.apskel.enaklo_owner
import io.flutter.embedding.android.FlutterActivity
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 37 KiB

@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#ffffff</color>
<!-- FCM: notification accent color -->
<color name="notification_color">#FF6B35</color>
</resources>
+1
View File
@@ -20,6 +20,7 @@ plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.3" apply false
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
id("com.google.gms.google-services") version "4.4.2" apply false
}
include(":app")
Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 1.4 MiB

+1 -1
View File
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
platform :ios, '14.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
+181
View File
@@ -0,0 +1,181 @@
PODS:
- connectivity_plus (0.0.1):
- Flutter
- device_info_plus (0.0.1):
- Flutter
- Firebase/CoreOnly (10.25.0):
- FirebaseCore (= 10.25.0)
- Firebase/Messaging (10.25.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 10.25.0)
- firebase_core (2.32.0):
- Firebase/CoreOnly (= 10.25.0)
- Flutter
- firebase_messaging (14.7.10):
- Firebase/Messaging (= 10.25.0)
- firebase_core
- Flutter
- FirebaseCore (10.25.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.12)
- GoogleUtilities/Logger (~> 7.12)
- FirebaseCoreInternal (10.29.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseInstallations (10.29.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseMessaging (10.25.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleDataTransport (~> 9.3)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Reachability (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- nanopb (< 2.30911.0, >= 2.30908.0)
- Flutter (1.0.0)
- flutter_local_notifications (0.0.1):
- Flutter
- GoogleDataTransport (9.4.1):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30911.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/AppDelegateSwizzler (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Privacy
- GoogleUtilities/Environment (7.13.3):
- GoogleUtilities/Privacy
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.13.3):
- GoogleUtilities/Environment
- GoogleUtilities/Privacy
- GoogleUtilities/Network (7.13.3):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Privacy
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.13.3)":
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (7.13.3)
- GoogleUtilities/Reachability (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- GoogleUtilities/UserDefaults (7.13.3):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- image_picker_ios (0.0.1):
- Flutter
- nanopb (2.30910.0):
- nanopb/decode (= 2.30910.0)
- nanopb/encode (= 2.30910.0)
- nanopb/decode (2.30910.0)
- nanopb/encode (2.30910.0)
- open_file_ios (0.0.1):
- Flutter
- package_info_plus (0.4.5):
- Flutter
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.3.0):
- Flutter
- PromisesObjC (2.4.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqflite_darwin (0.0.4):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter
DEPENDENCIES:
- connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`)
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- Flutter (from `Flutter`)
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- open_file_ios (from `.symlinks/plugins/open_file_ios/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
SPEC REPOS:
trunk:
- Firebase
- FirebaseCore
- FirebaseCoreInternal
- FirebaseInstallations
- FirebaseMessaging
- GoogleDataTransport
- GoogleUtilities
- nanopb
- PromisesObjC
EXTERNAL SOURCES:
connectivity_plus:
:path: ".symlinks/plugins/connectivity_plus/ios"
device_info_plus:
:path: ".symlinks/plugins/device_info_plus/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
firebase_messaging:
:path: ".symlinks/plugins/firebase_messaging/ios"
Flutter:
:path: Flutter
flutter_local_notifications:
:path: ".symlinks/plugins/flutter_local_notifications/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
open_file_ios:
:path: ".symlinks/plugins/open_file_ios/ios"
package_info_plus:
:path: ".symlinks/plugins/package_info_plus/ios"
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite_darwin:
:path: ".symlinks/plugins/sqflite_darwin/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
SPEC CHECKSUMS:
connectivity_plus: 2a701ffec2c0ae28a48cf7540e279787e77c447d
device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342
Firebase: 0312a2352584f782ea56f66d91606891d4607f06
firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197
firebase_messaging: 1541105e2a2a6ef8bd869bcc44157d31e82f3a50
FirebaseCore: 7ec4d0484817f12c3373955bc87762d96842d483
FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934
FirebaseInstallations: 913cf60d0400ebd5d6b63a28b290372ab44590dd
FirebaseMessaging: 88950ba9485052891ebe26f6c43a52bb62248952
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_local_notifications: df98d66e515e1ca797af436137b4459b160ad8c9
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
nanopb: 438bc412db1928dac798aa6fd75726007be04262
open_file_ios: 461db5853723763573e140de3193656f91990d9e
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
PODFILE CHECKSUM: e30f02f9d1c72c47bb6344a0a748c9d268180865
COCOAPODS: 1.16.2
+145 -6
View File
@@ -8,12 +8,15 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
227E95452FB25185003AAE6C /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 227E95442FB25185003AAE6C /* GoogleService-Info.plist */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
989F8AA016A730C566E93749 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3A6F295F1D6E4BB0819A8681 /* Pods_RunnerTests.framework */; };
F18848A41F5DE1108211F920 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B7ABC3D9AD3883EDD2E44FB /* Pods_Runner.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -40,14 +43,22 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
0B9C91DAD8EC48930CF79A70 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
159A415F4811E2794AA4092B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
1CE6759F37E82B0362B2E241 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
227E95442FB25185003AAE6C /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3A6F295F1D6E4BB0819A8681 /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B7ABC3D9AD3883EDD2E44FB /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3C70A9D33D5F6D7EAE05A508 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
7F8F2B65C01EDDD64346C756 /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = "<group>"; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -55,13 +66,23 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E6E423C7625C032FDEFB6799 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
6BBDF52C0DFCF2DFA69EB9C3 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
989F8AA016A730C566E93749 /* Pods_RunnerTests.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F18848A41F5DE1108211F920 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -76,6 +97,15 @@
path = RunnerTests;
sourceTree = "<group>";
};
4DBA9259FD070A034AF146BB /* Frameworks */ = {
isa = PBXGroup;
children = (
3B7ABC3D9AD3883EDD2E44FB /* Pods_Runner.framework */,
3A6F295F1D6E4BB0819A8681 /* Pods_RunnerTests.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
@@ -94,6 +124,8 @@
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
331C8082294A63A400263BE5 /* RunnerTests */,
F771B77E516695BE7A4B0AEA /* Pods */,
4DBA9259FD070A034AF146BB /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -109,6 +141,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
227E95442FB25185003AAE6C /* GoogleService-Info.plist */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
@@ -121,6 +154,19 @@
path = Runner;
sourceTree = "<group>";
};
F771B77E516695BE7A4B0AEA /* Pods */ = {
isa = PBXGroup;
children = (
3C70A9D33D5F6D7EAE05A508 /* Pods-Runner.debug.xcconfig */,
1CE6759F37E82B0362B2E241 /* Pods-Runner.release.xcconfig */,
159A415F4811E2794AA4092B /* Pods-Runner.profile.xcconfig */,
E6E423C7625C032FDEFB6799 /* Pods-RunnerTests.debug.xcconfig */,
7F8F2B65C01EDDD64346C756 /* Pods-RunnerTests.release.xcconfig */,
0B9C91DAD8EC48930CF79A70 /* Pods-RunnerTests.profile.xcconfig */,
);
path = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -128,8 +174,10 @@
isa = PBXNativeTarget;
buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */;
buildPhases = (
81D20024DBE321C19417AE73 /* [CP] Check Pods Manifest.lock */,
331C807D294A63A400263BE5 /* Sources */,
331C807F294A63A400263BE5 /* Resources */,
6BBDF52C0DFCF2DFA69EB9C3 /* Frameworks */,
);
buildRules = (
);
@@ -145,12 +193,15 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
ACC8E6F2D63F11FFC05DF00A /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
77740562F72074B1BD58B4C5 /* [CP] Embed Pods Frameworks */,
E2768009FD8B9B6235B4E16A /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -214,6 +265,7 @@
files = (
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
227E95452FB25185003AAE6C /* GoogleService-Info.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
@@ -238,6 +290,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
77740562F72074B1BD58B4C5 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
81D20024DBE321C19417AE73 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-RunnerTests-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
@@ -253,6 +344,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
ACC8E6F2D63F11FFC05DF00A /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
E2768009FD8B9B6235B4E16A /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Copy Pods Resources";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -362,13 +492,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 5TRC3M8UZG;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.apskelOwnerFlutter;
PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
@@ -378,13 +510,14 @@
};
331C8088294A63A400263BE5 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = E6E423C7625C032FDEFB6799 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.apskelOwnerFlutter.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklo.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -395,13 +528,14 @@
};
331C8089294A63A400263BE5 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7F8F2B65C01EDDD64346C756 /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.apskelOwnerFlutter.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklo.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
@@ -410,13 +544,14 @@
};
331C808A294A63A400263BE5 /* Profile */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0B9C91DAD8EC48930CF79A70 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.example.apskelOwnerFlutter.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklo.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner";
@@ -541,13 +676,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 5TRC3M8UZG;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.apskelOwnerFlutter;
PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -563,13 +700,15 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = 5TRC3M8UZG;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.apskelOwnerFlutter;
PRODUCT_BUNDLE_IDENTIFIER = com.apskel.enaklo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
+3
View File
@@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
+22
View File
@@ -1,5 +1,6 @@
import Flutter
import UIKit
import UserNotifications
@main
@objc class AppDelegate: FlutterAppDelegate {
@@ -7,7 +8,28 @@ import UIKit
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
// Set notification delegate so notifications show in foreground & background
UNUserNotificationCenter.current().delegate = self
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// Called when a notification is delivered while app is in foreground
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void
) {
completionHandler([.banner, .badge, .sound])
}
// Called when user taps a notification (foreground or background)
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
completionHandler()
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 654 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 14 KiB

+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyCb6teTjGKytZmAZc2aMJrpaW484tm93jY</string>
<key>GCM_SENDER_ID</key>
<string>765730035527</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.apskel.enaklo</string>
<key>PROJECT_ID</key>
<string>apskel-pos-v2</string>
<key>STORAGE_BUCKET</key>
<string>apskel-pos-v2.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:765730035527:ios:c87f91e28b33766e241e62</string>
</dict>
</plist>
+7 -1
View File
@@ -5,7 +5,7 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Apskel Owner</string>
<string>Enaklo Owner</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
@@ -45,5 +45,11 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<!-- FCM: enable background fetch & remote notifications -->
<key>UIBackgroundModes</key>
<array>
<string>fetch</string>
<string>remote-notification</string>
</array>
</dict>
</plist>
@@ -14,7 +14,7 @@ class DashboardAnalyticLoaderState with _$DashboardAnalyticLoaderState {
DashboardAnalyticLoaderState(
dashboardAnalytic: DashboardAnalytic.empty(),
failureOptionDashboardAnalytic: none(),
dateFrom: DateTime.now().subtract(const Duration(days: 30)),
dateFrom: DateTime.now(),
dateTo: DateTime.now(),
);
}
+2 -1
View File
@@ -1,9 +1,10 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../domain/auth/auth.dart';
import '../../domain/user/user.dart';
part 'auth_event.dart';
part 'auth_state.dart';
@@ -4,6 +4,8 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../common/utils/device_info_service.dart';
import '../../../common/utils/fcm_service.dart';
import '../../../domain/auth/auth.dart';
part 'login_form_event.dart';
@@ -13,7 +15,11 @@ part 'login_form_bloc.freezed.dart';
@injectable
class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
final IAuthRepository _repository;
LoginFormBloc(this._repository) : super(LoginFormState.initial()) {
final DeviceInfoService _deviceInfoService;
final FcmService _fcmService;
LoginFormBloc(this._repository, this._deviceInfoService, this._fcmService)
: super(LoginFormState.initial()) {
on<LoginFormEvent>(_onLoginFormEvent);
}
@@ -23,10 +29,10 @@ class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
) {
return event.map(
emailChanged: (e) async {
emit(state.copyWith(email: e.email));
emit(state.copyWith(email: e.email, failureOrAuthOption: none()));
},
passwordChanged: (e) async {
emit(state.copyWith(password: e.password));
emit(state.copyWith(password: e.password, failureOrAuthOption: none()));
},
submitted: (e) async {
Either<AuthFailure, Auth>? failureOrAuth;
@@ -36,9 +42,25 @@ class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
final passwordValid = state.password.isNotEmpty;
if (emailValid && passwordValid) {
// Ambil device info dan FCM token secara paralel
final results = await Future.wait([
_deviceInfoService.getDeviceInfo(),
_fcmService.getToken(),
]);
final deviceInfo = results[0] as DeviceInfo;
final fcmToken = results[1] as String?;
failureOrAuth = await _repository.login(
email: state.email,
password: state.password,
deviceId: deviceInfo.deviceId,
deviceName: deviceInfo.deviceName,
deviceType: deviceInfo.deviceType,
platform: deviceInfo.platform,
osVersion: deviceInfo.osVersion,
appVersion: deviceInfo.appVersion,
fcmToken: fcmToken,
);
emit(
state.copyWith(
+38
View File
@@ -0,0 +1,38 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../domain/analytic/analytic.dart';
import '../../domain/analytic/repositories/i_analytic_repository.dart';
part 'home_event.dart';
part 'home_state.dart';
part 'home_bloc.freezed.dart';
@injectable
class HomeBloc extends Bloc<HomeEvent, HomeState> {
final IAnalyticRepository _analyticRepository;
HomeBloc(this._analyticRepository) : super(HomeState.initial()) {
on<HomeEvent>(_onHomeEvent);
}
Future<void> _onHomeEvent(HomeEvent event, Emitter<HomeState> emit) {
return event.map(
fetchedDashboard: (e) async {
emit(state.copyWith(isFetching: true, failureOptionDashboard: none()));
final result = await _analyticRepository.getDashboard(
dateFrom: DateTime.now(),
dateTo: DateTime.now(),
);
var data = result.fold(
(f) => state.copyWith(failureOptionDashboard: optionOf(f)),
(dashboard) => state.copyWith(dashboard: dashboard),
);
emit(data.copyWith(isFetching: false));
},
);
}
}
+370
View File
@@ -0,0 +1,370 @@
// 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 'home_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 _$HomeEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedDashboard,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedDashboard,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedDashboard,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedDashboard value) fetchedDashboard,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedDashboard value)? fetchedDashboard,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedDashboard value)? fetchedDashboard,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $HomeEventCopyWith<$Res> {
factory $HomeEventCopyWith(HomeEvent value, $Res Function(HomeEvent) then) =
_$HomeEventCopyWithImpl<$Res, HomeEvent>;
}
/// @nodoc
class _$HomeEventCopyWithImpl<$Res, $Val extends HomeEvent>
implements $HomeEventCopyWith<$Res> {
_$HomeEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of HomeEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedDashboardImplCopyWith<$Res> {
factory _$$FetchedDashboardImplCopyWith(
_$FetchedDashboardImpl value,
$Res Function(_$FetchedDashboardImpl) then,
) = __$$FetchedDashboardImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchedDashboardImplCopyWithImpl<$Res>
extends _$HomeEventCopyWithImpl<$Res, _$FetchedDashboardImpl>
implements _$$FetchedDashboardImplCopyWith<$Res> {
__$$FetchedDashboardImplCopyWithImpl(
_$FetchedDashboardImpl _value,
$Res Function(_$FetchedDashboardImpl) _then,
) : super(_value, _then);
/// Create a copy of HomeEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedDashboardImpl implements _FetchedDashboard {
const _$FetchedDashboardImpl();
@override
String toString() {
return 'HomeEvent.fetchedDashboard()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchedDashboardImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedDashboard,
}) {
return fetchedDashboard();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedDashboard,
}) {
return fetchedDashboard?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedDashboard,
required TResult orElse(),
}) {
if (fetchedDashboard != null) {
return fetchedDashboard();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedDashboard value) fetchedDashboard,
}) {
return fetchedDashboard(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedDashboard value)? fetchedDashboard,
}) {
return fetchedDashboard?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedDashboard value)? fetchedDashboard,
required TResult orElse(),
}) {
if (fetchedDashboard != null) {
return fetchedDashboard(this);
}
return orElse();
}
}
abstract class _FetchedDashboard implements HomeEvent {
const factory _FetchedDashboard() = _$FetchedDashboardImpl;
}
/// @nodoc
mixin _$HomeState {
DashboardAnalytic get dashboard => throw _privateConstructorUsedError;
Option<AnalyticFailure> get failureOptionDashboard =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of HomeState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$HomeStateCopyWith<HomeState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $HomeStateCopyWith<$Res> {
factory $HomeStateCopyWith(HomeState value, $Res Function(HomeState) then) =
_$HomeStateCopyWithImpl<$Res, HomeState>;
@useResult
$Res call({
DashboardAnalytic dashboard,
Option<AnalyticFailure> failureOptionDashboard,
bool isFetching,
});
$DashboardAnalyticCopyWith<$Res> get dashboard;
}
/// @nodoc
class _$HomeStateCopyWithImpl<$Res, $Val extends HomeState>
implements $HomeStateCopyWith<$Res> {
_$HomeStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of HomeState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? dashboard = null,
Object? failureOptionDashboard = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
dashboard: null == dashboard
? _value.dashboard
: dashboard // ignore: cast_nullable_to_non_nullable
as DashboardAnalytic,
failureOptionDashboard: null == failureOptionDashboard
? _value.failureOptionDashboard
: failureOptionDashboard // 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 HomeState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$DashboardAnalyticCopyWith<$Res> get dashboard {
return $DashboardAnalyticCopyWith<$Res>(_value.dashboard, (value) {
return _then(_value.copyWith(dashboard: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$HomeStateImplCopyWith<$Res>
implements $HomeStateCopyWith<$Res> {
factory _$$HomeStateImplCopyWith(
_$HomeStateImpl value,
$Res Function(_$HomeStateImpl) then,
) = __$$HomeStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
DashboardAnalytic dashboard,
Option<AnalyticFailure> failureOptionDashboard,
bool isFetching,
});
@override
$DashboardAnalyticCopyWith<$Res> get dashboard;
}
/// @nodoc
class __$$HomeStateImplCopyWithImpl<$Res>
extends _$HomeStateCopyWithImpl<$Res, _$HomeStateImpl>
implements _$$HomeStateImplCopyWith<$Res> {
__$$HomeStateImplCopyWithImpl(
_$HomeStateImpl _value,
$Res Function(_$HomeStateImpl) _then,
) : super(_value, _then);
/// Create a copy of HomeState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? dashboard = null,
Object? failureOptionDashboard = null,
Object? isFetching = null,
}) {
return _then(
_$HomeStateImpl(
dashboard: null == dashboard
? _value.dashboard
: dashboard // ignore: cast_nullable_to_non_nullable
as DashboardAnalytic,
failureOptionDashboard: null == failureOptionDashboard
? _value.failureOptionDashboard
: failureOptionDashboard // 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 _$HomeStateImpl implements _HomeState {
const _$HomeStateImpl({
required this.dashboard,
required this.failureOptionDashboard,
this.isFetching = false,
});
@override
final DashboardAnalytic dashboard;
@override
final Option<AnalyticFailure> failureOptionDashboard;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'HomeState(dashboard: $dashboard, failureOptionDashboard: $failureOptionDashboard, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$HomeStateImpl &&
(identical(other.dashboard, dashboard) ||
other.dashboard == dashboard) &&
(identical(other.failureOptionDashboard, failureOptionDashboard) ||
other.failureOptionDashboard == failureOptionDashboard) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode =>
Object.hash(runtimeType, dashboard, failureOptionDashboard, isFetching);
/// Create a copy of HomeState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$HomeStateImplCopyWith<_$HomeStateImpl> get copyWith =>
__$$HomeStateImplCopyWithImpl<_$HomeStateImpl>(this, _$identity);
}
abstract class _HomeState implements HomeState {
const factory _HomeState({
required final DashboardAnalytic dashboard,
required final Option<AnalyticFailure> failureOptionDashboard,
final bool isFetching,
}) = _$HomeStateImpl;
@override
DashboardAnalytic get dashboard;
@override
Option<AnalyticFailure> get failureOptionDashboard;
@override
bool get isFetching;
/// Create a copy of HomeState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$HomeStateImplCopyWith<_$HomeStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
+6
View File
@@ -0,0 +1,6 @@
part of 'home_bloc.dart';
@freezed
class HomeEvent with _$HomeEvent {
const factory HomeEvent.fetchedDashboard() = _FetchedDashboard;
}
+15
View File
@@ -0,0 +1,15 @@
part of 'home_bloc.dart';
@freezed
class HomeState with _$HomeState {
const factory HomeState({
required DashboardAnalytic dashboard,
required Option<AnalyticFailure> failureOptionDashboard,
@Default(false) bool isFetching,
}) = _HomeState;
factory HomeState.initial() => HomeState(
dashboard: DashboardAnalytic.empty(),
failureOptionDashboard: none(),
);
}
@@ -21,12 +21,18 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
Emitter<OrderLoaderState> emit,
) {
return event.map(
rangeDateChanged: (e) async {
emit(state.copyWith(dateFrom: e.dateFrom, dateTo: e.dateTo));
},
statusChanged: (e) async {
emit(state.copyWith(status: e.status));
},
searchChanged: (e) async {
emit(state.copyWith(search: e.search));
},
outletChanged: (e) async {
emit(state.copyWith(outletId: e.outletId));
},
fetched: (e) async {
var newState = state;
@@ -63,9 +69,12 @@ class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
}
final failureOrOrder = await _repository.get(
status: state.status,
status: state.status == 'all' ? null : state.status,
page: state.page,
search: state.search,
outletId: state.outletId,
dateFrom: state.dateFrom,
dateTo: state.dateTo,
);
state = failureOrOrder.fold(
@@ -19,39 +19,52 @@ final _privateConstructorUsedError = UnsupportedError(
mixin _$OrderLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@@ -79,6 +92,182 @@ class _$OrderLoaderEventCopyWithImpl<$Res, $Val extends OrderLoaderEvent>
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$RangeDateChangedImplCopyWith<$Res> {
factory _$$RangeDateChangedImplCopyWith(
_$RangeDateChangedImpl value,
$Res Function(_$RangeDateChangedImpl) then,
) = __$$RangeDateChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({DateTime dateFrom, DateTime dateTo});
}
/// @nodoc
class __$$RangeDateChangedImplCopyWithImpl<$Res>
extends _$OrderLoaderEventCopyWithImpl<$Res, _$RangeDateChangedImpl>
implements _$$RangeDateChangedImplCopyWith<$Res> {
__$$RangeDateChangedImplCopyWithImpl(
_$RangeDateChangedImpl _value,
$Res Function(_$RangeDateChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? dateFrom = null, Object? dateTo = null}) {
return _then(
_$RangeDateChangedImpl(
null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$RangeDateChangedImpl implements _RangeDateChanged {
const _$RangeDateChangedImpl(this.dateFrom, this.dateTo);
@override
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
String toString() {
return 'OrderLoaderEvent.rangeDateChanged(dateFrom: $dateFrom, dateTo: $dateTo)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$RangeDateChangedImpl &&
(identical(other.dateFrom, dateFrom) ||
other.dateFrom == dateFrom) &&
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
}
@override
int get hashCode => Object.hash(runtimeType, dateFrom, dateTo);
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$RangeDateChangedImplCopyWith<_$RangeDateChangedImpl> get copyWith =>
__$$RangeDateChangedImplCopyWithImpl<_$RangeDateChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return rangeDateChanged(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return rangeDateChanged?.call(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
if (rangeDateChanged != null) {
return rangeDateChanged(dateFrom, dateTo);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return rangeDateChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return rangeDateChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (rangeDateChanged != null) {
return rangeDateChanged(this);
}
return orElse();
}
}
abstract class _RangeDateChanged implements OrderLoaderEvent {
const factory _RangeDateChanged(
final DateTime dateFrom,
final DateTime dateTo,
) = _$RangeDateChangedImpl;
DateTime get dateFrom;
DateTime get dateTo;
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$RangeDateChangedImplCopyWith<_$RangeDateChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$StatusChangedImplCopyWith<$Res> {
factory _$$StatusChangedImplCopyWith(
@@ -149,8 +338,11 @@ class _$StatusChangedImpl implements _StatusChanged {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return statusChanged(status);
@@ -159,8 +351,10 @@ class _$StatusChangedImpl implements _StatusChanged {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return statusChanged?.call(status);
@@ -169,8 +363,10 @@ class _$StatusChangedImpl implements _StatusChanged {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
@@ -183,8 +379,10 @@ class _$StatusChangedImpl implements _StatusChanged {
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return statusChanged(this);
@@ -193,8 +391,10 @@ class _$StatusChangedImpl implements _StatusChanged {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return statusChanged?.call(this);
@@ -203,8 +403,10 @@ class _$StatusChangedImpl implements _StatusChanged {
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
@@ -297,8 +499,11 @@ class _$SearchChangedImpl implements _SearchChanged {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return searchChanged(search);
@@ -307,8 +512,10 @@ class _$SearchChangedImpl implements _SearchChanged {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return searchChanged?.call(search);
@@ -317,8 +524,10 @@ class _$SearchChangedImpl implements _SearchChanged {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
@@ -331,8 +540,10 @@ class _$SearchChangedImpl implements _SearchChanged {
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return searchChanged(this);
@@ -341,8 +552,10 @@ class _$SearchChangedImpl implements _SearchChanged {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return searchChanged?.call(this);
@@ -351,8 +564,10 @@ class _$SearchChangedImpl implements _SearchChanged {
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
@@ -375,6 +590,168 @@ abstract class _SearchChanged implements OrderLoaderEvent {
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$OutletChangedImplCopyWith<$Res> {
factory _$$OutletChangedImplCopyWith(
_$OutletChangedImpl value,
$Res Function(_$OutletChangedImpl) then,
) = __$$OutletChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String? outletId});
}
/// @nodoc
class __$$OutletChangedImplCopyWithImpl<$Res>
extends _$OrderLoaderEventCopyWithImpl<$Res, _$OutletChangedImpl>
implements _$$OutletChangedImplCopyWith<$Res> {
__$$OutletChangedImplCopyWithImpl(
_$OutletChangedImpl _value,
$Res Function(_$OutletChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? outletId = freezed}) {
return _then(
_$OutletChangedImpl(
freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
class _$OutletChangedImpl implements _OutletChanged {
const _$OutletChangedImpl(this.outletId);
@override
final String? outletId;
@override
String toString() {
return 'OrderLoaderEvent.outletChanged(outletId: $outletId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$OutletChangedImpl &&
(identical(other.outletId, outletId) ||
other.outletId == outletId));
}
@override
int get hashCode => Object.hash(runtimeType, outletId);
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$OutletChangedImplCopyWith<_$OutletChangedImpl> get copyWith =>
__$$OutletChangedImplCopyWithImpl<_$OutletChangedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return outletChanged(outletId);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return outletChanged?.call(outletId);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
if (outletChanged != null) {
return outletChanged(outletId);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return outletChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return outletChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (outletChanged != null) {
return outletChanged(this);
}
return orElse();
}
}
abstract class _OutletChanged implements OrderLoaderEvent {
const factory _OutletChanged(final String? outletId) = _$OutletChangedImpl;
String? get outletId;
/// Create a copy of OrderLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$OutletChangedImplCopyWith<_$OutletChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith(
@@ -447,8 +824,11 @@ class _$FetchedImpl implements _Fetched {
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(DateTime dateFrom, DateTime dateTo)
rangeDateChanged,
required TResult Function(String status) statusChanged,
required TResult Function(String search) searchChanged,
required TResult Function(String? outletId) outletChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return fetched(isRefresh);
@@ -457,8 +837,10 @@ class _$FetchedImpl implements _Fetched {
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult? Function(String status)? statusChanged,
TResult? Function(String search)? searchChanged,
TResult? Function(String? outletId)? outletChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return fetched?.call(isRefresh);
@@ -467,8 +849,10 @@ class _$FetchedImpl implements _Fetched {
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(DateTime dateFrom, DateTime dateTo)? rangeDateChanged,
TResult Function(String status)? statusChanged,
TResult Function(String search)? searchChanged,
TResult Function(String? outletId)? outletChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
@@ -481,8 +865,10 @@ class _$FetchedImpl implements _Fetched {
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_RangeDateChanged value) rangeDateChanged,
required TResult Function(_StatusChanged value) statusChanged,
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_OutletChanged value) outletChanged,
required TResult Function(_Fetched value) fetched,
}) {
return fetched(this);
@@ -491,8 +877,10 @@ class _$FetchedImpl implements _Fetched {
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_RangeDateChanged value)? rangeDateChanged,
TResult? Function(_StatusChanged value)? statusChanged,
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_OutletChanged value)? outletChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return fetched?.call(this);
@@ -501,8 +889,10 @@ class _$FetchedImpl implements _Fetched {
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_RangeDateChanged value)? rangeDateChanged,
TResult Function(_StatusChanged value)? statusChanged,
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_OutletChanged value)? outletChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
@@ -530,11 +920,14 @@ mixin _$OrderLoaderState {
List<Order> get orders => throw _privateConstructorUsedError;
Option<OrderFailure> get failureOptionOrder =>
throw _privateConstructorUsedError;
String? get status => throw _privateConstructorUsedError;
String get status => throw _privateConstructorUsedError;
String? get search => throw _privateConstructorUsedError;
String? get outletId => throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
bool get hasReachedMax => throw _privateConstructorUsedError;
int get page => throw _privateConstructorUsedError;
DateTime get dateFrom => throw _privateConstructorUsedError;
DateTime get dateTo => throw _privateConstructorUsedError;
/// Create a copy of OrderLoaderState
/// with the given fields replaced by the non-null parameter values.
@@ -553,11 +946,14 @@ abstract class $OrderLoaderStateCopyWith<$Res> {
$Res call({
List<Order> orders,
Option<OrderFailure> failureOptionOrder,
String? status,
String status,
String? search,
String? outletId,
bool isFetching,
bool hasReachedMax,
int page,
DateTime dateFrom,
DateTime dateTo,
});
}
@@ -578,11 +974,14 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
$Res call({
Object? orders = null,
Object? failureOptionOrder = null,
Object? status = freezed,
Object? status = null,
Object? search = freezed,
Object? outletId = freezed,
Object? isFetching = null,
Object? hasReachedMax = null,
Object? page = null,
Object? dateFrom = null,
Object? dateTo = null,
}) {
return _then(
_value.copyWith(
@@ -594,14 +993,18 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
? _value.failureOptionOrder
: failureOptionOrder // ignore: cast_nullable_to_non_nullable
as Option<OrderFailure>,
status: freezed == status
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String?,
as String,
search: freezed == search
? _value.search
: search // ignore: cast_nullable_to_non_nullable
as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
@@ -614,6 +1017,14 @@ class _$OrderLoaderStateCopyWithImpl<$Res, $Val extends OrderLoaderState>
? _value.page
: page // ignore: cast_nullable_to_non_nullable
as int,
dateFrom: null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
dateTo: null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
)
as $Val,
);
@@ -632,11 +1043,14 @@ abstract class _$$OrderLoaderStateImplCopyWith<$Res>
$Res call({
List<Order> orders,
Option<OrderFailure> failureOptionOrder,
String? status,
String status,
String? search,
String? outletId,
bool isFetching,
bool hasReachedMax,
int page,
DateTime dateFrom,
DateTime dateTo,
});
}
@@ -656,11 +1070,14 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res>
$Res call({
Object? orders = null,
Object? failureOptionOrder = null,
Object? status = freezed,
Object? status = null,
Object? search = freezed,
Object? outletId = freezed,
Object? isFetching = null,
Object? hasReachedMax = null,
Object? page = null,
Object? dateFrom = null,
Object? dateTo = null,
}) {
return _then(
_$OrderLoaderStateImpl(
@@ -672,14 +1089,18 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res>
? _value.failureOptionOrder
: failureOptionOrder // ignore: cast_nullable_to_non_nullable
as Option<OrderFailure>,
status: freezed == status
status: null == status
? _value.status
: status // ignore: cast_nullable_to_non_nullable
as String?,
as String,
search: freezed == search
? _value.search
: search // ignore: cast_nullable_to_non_nullable
as String?,
outletId: freezed == outletId
? _value.outletId
: outletId // ignore: cast_nullable_to_non_nullable
as String?,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
@@ -692,6 +1113,14 @@ class __$$OrderLoaderStateImplCopyWithImpl<$Res>
? _value.page
: page // ignore: cast_nullable_to_non_nullable
as int,
dateFrom: null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
dateTo: null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
@@ -703,11 +1132,14 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
const _$OrderLoaderStateImpl({
required final List<Order> orders,
required this.failureOptionOrder,
this.status,
required this.status,
this.search,
this.outletId,
this.isFetching = false,
this.hasReachedMax = false,
this.page = 1,
required this.dateFrom,
required this.dateTo,
}) : _orders = orders;
final List<Order> _orders;
@@ -721,10 +1153,12 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
@override
final Option<OrderFailure> failureOptionOrder;
@override
final String? status;
final String status;
@override
final String? search;
@override
final String? outletId;
@override
@JsonKey()
final bool isFetching;
@override
@@ -733,10 +1167,14 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
@override
@JsonKey()
final int page;
@override
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
String toString() {
return 'OrderLoaderState(orders: $orders, failureOptionOrder: $failureOptionOrder, status: $status, search: $search, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page)';
return 'OrderLoaderState(orders: $orders, failureOptionOrder: $failureOptionOrder, status: $status, search: $search, outletId: $outletId, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page, dateFrom: $dateFrom, dateTo: $dateTo)';
}
@override
@@ -749,11 +1187,16 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
other.failureOptionOrder == failureOptionOrder) &&
(identical(other.status, status) || other.status == status) &&
(identical(other.search, search) || other.search == search) &&
(identical(other.outletId, outletId) ||
other.outletId == outletId) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching) &&
(identical(other.hasReachedMax, hasReachedMax) ||
other.hasReachedMax == hasReachedMax) &&
(identical(other.page, page) || other.page == page));
(identical(other.page, page) || other.page == page) &&
(identical(other.dateFrom, dateFrom) ||
other.dateFrom == dateFrom) &&
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
}
@override
@@ -763,9 +1206,12 @@ class _$OrderLoaderStateImpl implements _OrderLoaderState {
failureOptionOrder,
status,
search,
outletId,
isFetching,
hasReachedMax,
page,
dateFrom,
dateTo,
);
/// Create a copy of OrderLoaderState
@@ -784,11 +1230,14 @@ abstract class _OrderLoaderState implements OrderLoaderState {
const factory _OrderLoaderState({
required final List<Order> orders,
required final Option<OrderFailure> failureOptionOrder,
final String? status,
required final String status,
final String? search,
final String? outletId,
final bool isFetching,
final bool hasReachedMax,
final int page,
required final DateTime dateFrom,
required final DateTime dateTo,
}) = _$OrderLoaderStateImpl;
@override
@@ -796,15 +1245,21 @@ abstract class _OrderLoaderState implements OrderLoaderState {
@override
Option<OrderFailure> get failureOptionOrder;
@override
String? get status;
String get status;
@override
String? get search;
@override
String? get outletId;
@override
bool get isFetching;
@override
bool get hasReachedMax;
@override
int get page;
@override
DateTime get dateFrom;
@override
DateTime get dateTo;
/// Create a copy of OrderLoaderState
/// with the given fields replaced by the non-null parameter values.
@@ -2,8 +2,14 @@ part of 'order_loader_bloc.dart';
@freezed
class OrderLoaderEvent with _$OrderLoaderEvent {
const factory OrderLoaderEvent.rangeDateChanged(
DateTime dateFrom,
DateTime dateTo,
) = _RangeDateChanged;
const factory OrderLoaderEvent.statusChanged(String status) = _StatusChanged;
const factory OrderLoaderEvent.searchChanged(String search) = _SearchChanged;
const factory OrderLoaderEvent.outletChanged(String? outletId) =
_OutletChanged;
const factory OrderLoaderEvent.fetched({@Default(false) bool isRefresh}) =
_Fetched;
}
@@ -5,13 +5,21 @@ class OrderLoaderState with _$OrderLoaderState {
const factory OrderLoaderState({
required List<Order> orders,
required Option<OrderFailure> failureOptionOrder,
String? status,
required String status,
String? search,
String? outletId,
@Default(false) bool isFetching,
@Default(false) bool hasReachedMax,
@Default(1) int page,
required DateTime dateFrom,
required DateTime dateTo,
}) = _OrderLoaderState;
factory OrderLoaderState.initial() =>
OrderLoaderState(orders: [], failureOptionOrder: none());
factory OrderLoaderState.initial() => OrderLoaderState(
orders: [],
failureOptionOrder: none(),
dateFrom: DateTime.now(),
dateTo: DateTime.now(),
status: 'all',
);
}
@@ -0,0 +1,40 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/outlet/outlet.dart';
part 'current_outlet_loader_event.dart';
part 'current_outlet_loader_state.dart';
part 'current_outlet_loader_bloc.freezed.dart';
@injectable
class CurrentOutletLoaderBloc
extends Bloc<CurrentOutletLoaderEvent, CurrentOutletLoaderState> {
final IOutletRepository _repository;
CurrentOutletLoaderBloc(this._repository)
: super(CurrentOutletLoaderState.initial()) {
on<CurrentOutletLoaderEvent>(_onCurrentOutletLoaderEvent);
}
Future<void> _onCurrentOutletLoaderEvent(
CurrentOutletLoaderEvent event,
Emitter<CurrentOutletLoaderState> emit,
) {
return event.map(
fetched: (e) async {
emit(state.copyWith(isFetching: true, failureOptionOutlet: none()));
final result = await _repository.currentOutlet();
var data = result.fold(
(f) => state.copyWith(failureOptionOutlet: optionOf(f)),
(currentOutlet) => state.copyWith(outlet: currentOutlet),
);
emit(data.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,382 @@
// 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 'current_outlet_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 _$CurrentOutletLoaderEvent {
@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 $CurrentOutletLoaderEventCopyWith<$Res> {
factory $CurrentOutletLoaderEventCopyWith(
CurrentOutletLoaderEvent value,
$Res Function(CurrentOutletLoaderEvent) then,
) = _$CurrentOutletLoaderEventCopyWithImpl<$Res, CurrentOutletLoaderEvent>;
}
/// @nodoc
class _$CurrentOutletLoaderEventCopyWithImpl<
$Res,
$Val extends CurrentOutletLoaderEvent
>
implements $CurrentOutletLoaderEventCopyWith<$Res> {
_$CurrentOutletLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CurrentOutletLoaderEvent
/// 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 _$CurrentOutletLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
implements _$$FetchedImplCopyWith<$Res> {
__$$FetchedImplCopyWithImpl(
_$FetchedImpl _value,
$Res Function(_$FetchedImpl) _then,
) : super(_value, _then);
/// Create a copy of CurrentOutletLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedImpl implements _Fetched {
const _$FetchedImpl();
@override
String toString() {
return 'CurrentOutletLoaderEvent.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 CurrentOutletLoaderEvent {
const factory _Fetched() = _$FetchedImpl;
}
/// @nodoc
mixin _$CurrentOutletLoaderState {
Outlet get outlet => throw _privateConstructorUsedError;
Option<OutletFailure> get failureOptionOutlet =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
/// Create a copy of CurrentOutletLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$CurrentOutletLoaderStateCopyWith<CurrentOutletLoaderState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $CurrentOutletLoaderStateCopyWith<$Res> {
factory $CurrentOutletLoaderStateCopyWith(
CurrentOutletLoaderState value,
$Res Function(CurrentOutletLoaderState) then,
) = _$CurrentOutletLoaderStateCopyWithImpl<$Res, CurrentOutletLoaderState>;
@useResult
$Res call({
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
});
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class _$CurrentOutletLoaderStateCopyWithImpl<
$Res,
$Val extends CurrentOutletLoaderState
>
implements $CurrentOutletLoaderStateCopyWith<$Res> {
_$CurrentOutletLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of CurrentOutletLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
}) {
return _then(
_value.copyWith(
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of CurrentOutletLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OutletCopyWith<$Res> get outlet {
return $OutletCopyWith<$Res>(_value.outlet, (value) {
return _then(_value.copyWith(outlet: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$CurrentOutletLoaderStateImplCopyWith<$Res>
implements $CurrentOutletLoaderStateCopyWith<$Res> {
factory _$$CurrentOutletLoaderStateImplCopyWith(
_$CurrentOutletLoaderStateImpl value,
$Res Function(_$CurrentOutletLoaderStateImpl) then,
) = __$$CurrentOutletLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
});
@override
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class __$$CurrentOutletLoaderStateImplCopyWithImpl<$Res>
extends
_$CurrentOutletLoaderStateCopyWithImpl<
$Res,
_$CurrentOutletLoaderStateImpl
>
implements _$$CurrentOutletLoaderStateImplCopyWith<$Res> {
__$$CurrentOutletLoaderStateImplCopyWithImpl(
_$CurrentOutletLoaderStateImpl _value,
$Res Function(_$CurrentOutletLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of CurrentOutletLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
}) {
return _then(
_$CurrentOutletLoaderStateImpl(
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$CurrentOutletLoaderStateImpl implements _CurrentOutletLoaderState {
const _$CurrentOutletLoaderStateImpl({
required this.outlet,
required this.failureOptionOutlet,
this.isFetching = false,
});
@override
final Outlet outlet;
@override
final Option<OutletFailure> failureOptionOutlet;
@override
@JsonKey()
final bool isFetching;
@override
String toString() {
return 'CurrentOutletLoaderState(outlet: $outlet, failureOptionOutlet: $failureOptionOutlet, isFetching: $isFetching)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CurrentOutletLoaderStateImpl &&
(identical(other.outlet, outlet) || other.outlet == outlet) &&
(identical(other.failureOptionOutlet, failureOptionOutlet) ||
other.failureOptionOutlet == failureOptionOutlet) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching));
}
@override
int get hashCode =>
Object.hash(runtimeType, outlet, failureOptionOutlet, isFetching);
/// Create a copy of CurrentOutletLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CurrentOutletLoaderStateImplCopyWith<_$CurrentOutletLoaderStateImpl>
get copyWith =>
__$$CurrentOutletLoaderStateImplCopyWithImpl<
_$CurrentOutletLoaderStateImpl
>(this, _$identity);
}
abstract class _CurrentOutletLoaderState implements CurrentOutletLoaderState {
const factory _CurrentOutletLoaderState({
required final Outlet outlet,
required final Option<OutletFailure> failureOptionOutlet,
final bool isFetching,
}) = _$CurrentOutletLoaderStateImpl;
@override
Outlet get outlet;
@override
Option<OutletFailure> get failureOptionOutlet;
@override
bool get isFetching;
/// Create a copy of CurrentOutletLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CurrentOutletLoaderStateImplCopyWith<_$CurrentOutletLoaderStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,6 @@
part of 'current_outlet_loader_bloc.dart';
@freezed
class CurrentOutletLoaderEvent with _$CurrentOutletLoaderEvent {
const factory CurrentOutletLoaderEvent.fetched() = _Fetched;
}
@@ -0,0 +1,15 @@
part of 'current_outlet_loader_bloc.dart';
@freezed
class CurrentOutletLoaderState with _$CurrentOutletLoaderState {
const factory CurrentOutletLoaderState({
required Outlet outlet,
required Option<OutletFailure> failureOptionOutlet,
@Default(false) bool isFetching,
}) = _CurrentOutletLoaderState;
factory CurrentOutletLoaderState.initial() => CurrentOutletLoaderState(
outlet: Outlet.empty(),
failureOptionOutlet: none(),
);
}
@@ -0,0 +1,92 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/outlet/outlet.dart';
part 'outlet_list_loader_event.dart';
part 'outlet_list_loader_state.dart';
part 'outlet_list_loader_bloc.freezed.dart';
@injectable
class OutletListLoaderBloc
extends Bloc<OutletListLoaderEvent, OutletListLoaderState> {
final IOutletRepository _outletRepository;
OutletListLoaderBloc(this._outletRepository)
: super(OutletListLoaderState.initial()) {
on<OutletListLoaderEvent>(_onOutletListLoaderEvent);
}
Future<void> _onOutletListLoaderEvent(
OutletListLoaderEvent event,
Emitter<OutletListLoaderState> emit,
) {
return event.map(
searchChanged: (e) async {
emit(state.copyWith(search: e.search));
},
isActiveChanged: (e) async {
emit(state.copyWith(isActive: e.isActive));
},
fetched: (e) async {
var newState = state;
if (e.isRefresh) {
newState = state.copyWith(isFetching: true);
emit(newState);
}
newState = await _mapFetchedToState(state, isRefresh: e.isRefresh);
emit(newState);
},
);
}
Future<OutletListLoaderState> _mapFetchedToState(
OutletListLoaderState state, {
bool isRefresh = false,
}) async {
state = state.copyWith(isFetching: false);
if (state.hasReachedMax && state.outlets.isNotEmpty && !isRefresh) {
return state;
}
if (isRefresh) {
state = state.copyWith(
page: 1,
failureOptionOutlet: none(),
hasReachedMax: false,
outlets: [],
);
}
final failureOrOutlets = await _outletRepository.getList(
page: state.page,
search: state.search,
isActive: state.isActive,
);
state = failureOrOutlets.fold(
(f) {
if (state.outlets.isNotEmpty) {
return state.copyWith(hasReachedMax: true);
}
return state.copyWith(failureOptionOutlet: optionOf(f));
},
(outlets) {
return state.copyWith(
outlets: List.from(state.outlets)..addAll(outlets),
failureOptionOutlet: none(),
page: state.page + 1,
hasReachedMax: outlets.length < 10,
);
},
);
return state;
}
}
@@ -0,0 +1,828 @@
// 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 'outlet_list_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 _$OutletListLoaderEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String search) searchChanged,
required TResult Function(bool? isActive) isActiveChanged,
required TResult Function(bool isRefresh) fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String search)? searchChanged,
TResult? Function(bool? isActive)? isActiveChanged,
TResult? Function(bool isRefresh)? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String search)? searchChanged,
TResult Function(bool? isActive)? isActiveChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_IsActiveChanged value) isActiveChanged,
required TResult Function(_Fetched value) fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_IsActiveChanged value)? isActiveChanged,
TResult? Function(_Fetched value)? fetched,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_IsActiveChanged value)? isActiveChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $OutletListLoaderEventCopyWith<$Res> {
factory $OutletListLoaderEventCopyWith(
OutletListLoaderEvent value,
$Res Function(OutletListLoaderEvent) then,
) = _$OutletListLoaderEventCopyWithImpl<$Res, OutletListLoaderEvent>;
}
/// @nodoc
class _$OutletListLoaderEventCopyWithImpl<
$Res,
$Val extends OutletListLoaderEvent
>
implements $OutletListLoaderEventCopyWith<$Res> {
_$OutletListLoaderEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$SearchChangedImplCopyWith<$Res> {
factory _$$SearchChangedImplCopyWith(
_$SearchChangedImpl value,
$Res Function(_$SearchChangedImpl) then,
) = __$$SearchChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String search});
}
/// @nodoc
class __$$SearchChangedImplCopyWithImpl<$Res>
extends _$OutletListLoaderEventCopyWithImpl<$Res, _$SearchChangedImpl>
implements _$$SearchChangedImplCopyWith<$Res> {
__$$SearchChangedImplCopyWithImpl(
_$SearchChangedImpl _value,
$Res Function(_$SearchChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? search = null}) {
return _then(
_$SearchChangedImpl(
null == search
? _value.search
: search // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$SearchChangedImpl implements _SearchChanged {
const _$SearchChangedImpl(this.search);
@override
final String search;
@override
String toString() {
return 'OutletListLoaderEvent.searchChanged(search: $search)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SearchChangedImpl &&
(identical(other.search, search) || other.search == search));
}
@override
int get hashCode => Object.hash(runtimeType, search);
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SearchChangedImplCopyWith<_$SearchChangedImpl> get copyWith =>
__$$SearchChangedImplCopyWithImpl<_$SearchChangedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String search) searchChanged,
required TResult Function(bool? isActive) isActiveChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return searchChanged(search);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String search)? searchChanged,
TResult? Function(bool? isActive)? isActiveChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return searchChanged?.call(search);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String search)? searchChanged,
TResult Function(bool? isActive)? isActiveChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
if (searchChanged != null) {
return searchChanged(search);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_IsActiveChanged value) isActiveChanged,
required TResult Function(_Fetched value) fetched,
}) {
return searchChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_IsActiveChanged value)? isActiveChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return searchChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_IsActiveChanged value)? isActiveChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (searchChanged != null) {
return searchChanged(this);
}
return orElse();
}
}
abstract class _SearchChanged implements OutletListLoaderEvent {
const factory _SearchChanged(final String search) = _$SearchChangedImpl;
String get search;
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SearchChangedImplCopyWith<_$SearchChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$IsActiveChangedImplCopyWith<$Res> {
factory _$$IsActiveChangedImplCopyWith(
_$IsActiveChangedImpl value,
$Res Function(_$IsActiveChangedImpl) then,
) = __$$IsActiveChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({bool? isActive});
}
/// @nodoc
class __$$IsActiveChangedImplCopyWithImpl<$Res>
extends _$OutletListLoaderEventCopyWithImpl<$Res, _$IsActiveChangedImpl>
implements _$$IsActiveChangedImplCopyWith<$Res> {
__$$IsActiveChangedImplCopyWithImpl(
_$IsActiveChangedImpl _value,
$Res Function(_$IsActiveChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? isActive = freezed}) {
return _then(
_$IsActiveChangedImpl(
freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
),
);
}
}
/// @nodoc
class _$IsActiveChangedImpl implements _IsActiveChanged {
const _$IsActiveChangedImpl(this.isActive);
@override
final bool? isActive;
@override
String toString() {
return 'OutletListLoaderEvent.isActiveChanged(isActive: $isActive)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$IsActiveChangedImpl &&
(identical(other.isActive, isActive) ||
other.isActive == isActive));
}
@override
int get hashCode => Object.hash(runtimeType, isActive);
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$IsActiveChangedImplCopyWith<_$IsActiveChangedImpl> get copyWith =>
__$$IsActiveChangedImplCopyWithImpl<_$IsActiveChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String search) searchChanged,
required TResult Function(bool? isActive) isActiveChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return isActiveChanged(isActive);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String search)? searchChanged,
TResult? Function(bool? isActive)? isActiveChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return isActiveChanged?.call(isActive);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String search)? searchChanged,
TResult Function(bool? isActive)? isActiveChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
if (isActiveChanged != null) {
return isActiveChanged(isActive);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_IsActiveChanged value) isActiveChanged,
required TResult Function(_Fetched value) fetched,
}) {
return isActiveChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_IsActiveChanged value)? isActiveChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return isActiveChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_IsActiveChanged value)? isActiveChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (isActiveChanged != null) {
return isActiveChanged(this);
}
return orElse();
}
}
abstract class _IsActiveChanged implements OutletListLoaderEvent {
const factory _IsActiveChanged(final bool? isActive) = _$IsActiveChangedImpl;
bool? get isActive;
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$IsActiveChangedImplCopyWith<_$IsActiveChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$FetchedImplCopyWith<$Res> {
factory _$$FetchedImplCopyWith(
_$FetchedImpl value,
$Res Function(_$FetchedImpl) then,
) = __$$FetchedImplCopyWithImpl<$Res>;
@useResult
$Res call({bool isRefresh});
}
/// @nodoc
class __$$FetchedImplCopyWithImpl<$Res>
extends _$OutletListLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
implements _$$FetchedImplCopyWith<$Res> {
__$$FetchedImplCopyWithImpl(
_$FetchedImpl _value,
$Res Function(_$FetchedImpl) _then,
) : super(_value, _then);
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? isRefresh = null}) {
return _then(
_$FetchedImpl(
isRefresh: null == isRefresh
? _value.isRefresh
: isRefresh // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$FetchedImpl implements _Fetched {
const _$FetchedImpl({this.isRefresh = false});
@override
@JsonKey()
final bool isRefresh;
@override
String toString() {
return 'OutletListLoaderEvent.fetched(isRefresh: $isRefresh)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FetchedImpl &&
(identical(other.isRefresh, isRefresh) ||
other.isRefresh == isRefresh));
}
@override
int get hashCode => Object.hash(runtimeType, isRefresh);
/// Create a copy of OutletListLoaderEvent
/// 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(String search) searchChanged,
required TResult Function(bool? isActive) isActiveChanged,
required TResult Function(bool isRefresh) fetched,
}) {
return fetched(isRefresh);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String search)? searchChanged,
TResult? Function(bool? isActive)? isActiveChanged,
TResult? Function(bool isRefresh)? fetched,
}) {
return fetched?.call(isRefresh);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String search)? searchChanged,
TResult Function(bool? isActive)? isActiveChanged,
TResult Function(bool isRefresh)? fetched,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched(isRefresh);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_SearchChanged value) searchChanged,
required TResult Function(_IsActiveChanged value) isActiveChanged,
required TResult Function(_Fetched value) fetched,
}) {
return fetched(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_SearchChanged value)? searchChanged,
TResult? Function(_IsActiveChanged value)? isActiveChanged,
TResult? Function(_Fetched value)? fetched,
}) {
return fetched?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_SearchChanged value)? searchChanged,
TResult Function(_IsActiveChanged value)? isActiveChanged,
TResult Function(_Fetched value)? fetched,
required TResult orElse(),
}) {
if (fetched != null) {
return fetched(this);
}
return orElse();
}
}
abstract class _Fetched implements OutletListLoaderEvent {
const factory _Fetched({final bool isRefresh}) = _$FetchedImpl;
bool get isRefresh;
/// Create a copy of OutletListLoaderEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$OutletListLoaderState {
List<Outlet> get outlets => throw _privateConstructorUsedError;
Option<OutletFailure> get failureOptionOutlet =>
throw _privateConstructorUsedError;
String? get search => throw _privateConstructorUsedError;
bool? get isActive => throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
bool get hasReachedMax => throw _privateConstructorUsedError;
int get page => throw _privateConstructorUsedError;
/// Create a copy of OutletListLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$OutletListLoaderStateCopyWith<OutletListLoaderState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $OutletListLoaderStateCopyWith<$Res> {
factory $OutletListLoaderStateCopyWith(
OutletListLoaderState value,
$Res Function(OutletListLoaderState) then,
) = _$OutletListLoaderStateCopyWithImpl<$Res, OutletListLoaderState>;
@useResult
$Res call({
List<Outlet> outlets,
Option<OutletFailure> failureOptionOutlet,
String? search,
bool? isActive,
bool isFetching,
bool hasReachedMax,
int page,
});
}
/// @nodoc
class _$OutletListLoaderStateCopyWithImpl<
$Res,
$Val extends OutletListLoaderState
>
implements $OutletListLoaderStateCopyWith<$Res> {
_$OutletListLoaderStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of OutletListLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? outlets = null,
Object? failureOptionOutlet = null,
Object? search = freezed,
Object? isActive = freezed,
Object? isFetching = null,
Object? hasReachedMax = null,
Object? page = null,
}) {
return _then(
_value.copyWith(
outlets: null == outlets
? _value.outlets
: outlets // ignore: cast_nullable_to_non_nullable
as List<Outlet>,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
search: freezed == search
? _value.search
: search // ignore: cast_nullable_to_non_nullable
as String?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
hasReachedMax: null == hasReachedMax
? _value.hasReachedMax
: hasReachedMax // ignore: cast_nullable_to_non_nullable
as bool,
page: null == page
? _value.page
: page // ignore: cast_nullable_to_non_nullable
as int,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$OutletListLoaderStateImplCopyWith<$Res>
implements $OutletListLoaderStateCopyWith<$Res> {
factory _$$OutletListLoaderStateImplCopyWith(
_$OutletListLoaderStateImpl value,
$Res Function(_$OutletListLoaderStateImpl) then,
) = __$$OutletListLoaderStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
List<Outlet> outlets,
Option<OutletFailure> failureOptionOutlet,
String? search,
bool? isActive,
bool isFetching,
bool hasReachedMax,
int page,
});
}
/// @nodoc
class __$$OutletListLoaderStateImplCopyWithImpl<$Res>
extends
_$OutletListLoaderStateCopyWithImpl<$Res, _$OutletListLoaderStateImpl>
implements _$$OutletListLoaderStateImplCopyWith<$Res> {
__$$OutletListLoaderStateImplCopyWithImpl(
_$OutletListLoaderStateImpl _value,
$Res Function(_$OutletListLoaderStateImpl) _then,
) : super(_value, _then);
/// Create a copy of OutletListLoaderState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? outlets = null,
Object? failureOptionOutlet = null,
Object? search = freezed,
Object? isActive = freezed,
Object? isFetching = null,
Object? hasReachedMax = null,
Object? page = null,
}) {
return _then(
_$OutletListLoaderStateImpl(
outlets: null == outlets
? _value._outlets
: outlets // ignore: cast_nullable_to_non_nullable
as List<Outlet>,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
search: freezed == search
? _value.search
: search // ignore: cast_nullable_to_non_nullable
as String?,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
hasReachedMax: null == hasReachedMax
? _value.hasReachedMax
: hasReachedMax // ignore: cast_nullable_to_non_nullable
as bool,
page: null == page
? _value.page
: page // ignore: cast_nullable_to_non_nullable
as int,
),
);
}
}
/// @nodoc
class _$OutletListLoaderStateImpl implements _OutletListLoaderState {
const _$OutletListLoaderStateImpl({
required final List<Outlet> outlets,
required this.failureOptionOutlet,
this.search,
this.isActive,
this.isFetching = false,
this.hasReachedMax = false,
this.page = 1,
}) : _outlets = outlets;
final List<Outlet> _outlets;
@override
List<Outlet> get outlets {
if (_outlets is EqualUnmodifiableListView) return _outlets;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_outlets);
}
@override
final Option<OutletFailure> failureOptionOutlet;
@override
final String? search;
@override
final bool? isActive;
@override
@JsonKey()
final bool isFetching;
@override
@JsonKey()
final bool hasReachedMax;
@override
@JsonKey()
final int page;
@override
String toString() {
return 'OutletListLoaderState(outlets: $outlets, failureOptionOutlet: $failureOptionOutlet, search: $search, isActive: $isActive, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$OutletListLoaderStateImpl &&
const DeepCollectionEquality().equals(other._outlets, _outlets) &&
(identical(other.failureOptionOutlet, failureOptionOutlet) ||
other.failureOptionOutlet == failureOptionOutlet) &&
(identical(other.search, search) || other.search == search) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching) &&
(identical(other.hasReachedMax, hasReachedMax) ||
other.hasReachedMax == hasReachedMax) &&
(identical(other.page, page) || other.page == page));
}
@override
int get hashCode => Object.hash(
runtimeType,
const DeepCollectionEquality().hash(_outlets),
failureOptionOutlet,
search,
isActive,
isFetching,
hasReachedMax,
page,
);
/// Create a copy of OutletListLoaderState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$OutletListLoaderStateImplCopyWith<_$OutletListLoaderStateImpl>
get copyWith =>
__$$OutletListLoaderStateImplCopyWithImpl<_$OutletListLoaderStateImpl>(
this,
_$identity,
);
}
abstract class _OutletListLoaderState implements OutletListLoaderState {
const factory _OutletListLoaderState({
required final List<Outlet> outlets,
required final Option<OutletFailure> failureOptionOutlet,
final String? search,
final bool? isActive,
final bool isFetching,
final bool hasReachedMax,
final int page,
}) = _$OutletListLoaderStateImpl;
@override
List<Outlet> get outlets;
@override
Option<OutletFailure> get failureOptionOutlet;
@override
String? get search;
@override
bool? get isActive;
@override
bool get isFetching;
@override
bool get hasReachedMax;
@override
int get page;
/// Create a copy of OutletListLoaderState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$OutletListLoaderStateImplCopyWith<_$OutletListLoaderStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,12 @@
part of 'outlet_list_loader_bloc.dart';
@freezed
class OutletListLoaderEvent with _$OutletListLoaderEvent {
const factory OutletListLoaderEvent.searchChanged(String search) =
_SearchChanged;
const factory OutletListLoaderEvent.isActiveChanged(bool? isActive) =
_IsActiveChanged;
const factory OutletListLoaderEvent.fetched({
@Default(false) bool isRefresh,
}) = _Fetched;
}
@@ -0,0 +1,17 @@
part of 'outlet_list_loader_bloc.dart';
@freezed
class OutletListLoaderState with _$OutletListLoaderState {
const factory OutletListLoaderState({
required List<Outlet> outlets,
required Option<OutletFailure> failureOptionOutlet,
String? search,
bool? isActive,
@Default(false) bool isFetching,
@Default(false) bool hasReachedMax,
@Default(1) int page,
}) = _OutletListLoaderState;
factory OutletListLoaderState.initial() =>
OutletListLoaderState(outlets: [], failureOptionOutlet: none());
}
@@ -0,0 +1,46 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/outlet/outlet.dart';
import '../../../infrastructure/outlet/datasource/local_data_provider.dart';
part 'selected_outlet_event.dart';
part 'selected_outlet_state.dart';
part 'selected_outlet_bloc.freezed.dart';
@injectable
class SelectedOutletBloc
extends Bloc<SelectedOutletEvent, SelectedOutletState> {
final OutletLocalDataProvider _localDataProvider;
SelectedOutletBloc(this._localDataProvider)
: super(SelectedOutletState.initial()) {
on<SelectedOutletEvent>(_onSelectedOutletEvent);
}
Future<void> _onSelectedOutletEvent(
SelectedOutletEvent event,
Emitter<SelectedOutletState> emit,
) {
return event.map(
loaded: (e) async {
final savedId = _localDataProvider.getSelectedOutletId();
emit(state.copyWith(selectedOutletId: savedId));
},
selected: (e) async {
await _localDataProvider.saveSelectedOutletId(e.outlet.id);
emit(
state.copyWith(
selectedOutlet: e.outlet,
selectedOutletId: e.outlet.id,
),
);
},
cleared: (e) async {
await _localDataProvider.deleteSelectedOutletId();
emit(SelectedOutletState.initial());
},
);
}
}
@@ -0,0 +1,649 @@
// 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 'selected_outlet_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 _$SelectedOutletEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() loaded,
required TResult Function(Outlet outlet) selected,
required TResult Function() cleared,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? loaded,
TResult? Function(Outlet outlet)? selected,
TResult? Function()? cleared,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? loaded,
TResult Function(Outlet outlet)? selected,
TResult Function()? cleared,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Loaded value) loaded,
required TResult Function(_Selected value) selected,
required TResult Function(_Cleared value) cleared,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Loaded value)? loaded,
TResult? Function(_Selected value)? selected,
TResult? Function(_Cleared value)? cleared,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Loaded value)? loaded,
TResult Function(_Selected value)? selected,
TResult Function(_Cleared value)? cleared,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SelectedOutletEventCopyWith<$Res> {
factory $SelectedOutletEventCopyWith(
SelectedOutletEvent value,
$Res Function(SelectedOutletEvent) then,
) = _$SelectedOutletEventCopyWithImpl<$Res, SelectedOutletEvent>;
}
/// @nodoc
class _$SelectedOutletEventCopyWithImpl<$Res, $Val extends SelectedOutletEvent>
implements $SelectedOutletEventCopyWith<$Res> {
_$SelectedOutletEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SelectedOutletEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$LoadedImplCopyWith<$Res> {
factory _$$LoadedImplCopyWith(
_$LoadedImpl value,
$Res Function(_$LoadedImpl) then,
) = __$$LoadedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$LoadedImplCopyWithImpl<$Res>
extends _$SelectedOutletEventCopyWithImpl<$Res, _$LoadedImpl>
implements _$$LoadedImplCopyWith<$Res> {
__$$LoadedImplCopyWithImpl(
_$LoadedImpl _value,
$Res Function(_$LoadedImpl) _then,
) : super(_value, _then);
/// Create a copy of SelectedOutletEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$LoadedImpl implements _Loaded {
const _$LoadedImpl();
@override
String toString() {
return 'SelectedOutletEvent.loaded()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$LoadedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() loaded,
required TResult Function(Outlet outlet) selected,
required TResult Function() cleared,
}) {
return loaded();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? loaded,
TResult? Function(Outlet outlet)? selected,
TResult? Function()? cleared,
}) {
return loaded?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? loaded,
TResult Function(Outlet outlet)? selected,
TResult Function()? cleared,
required TResult orElse(),
}) {
if (loaded != null) {
return loaded();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Loaded value) loaded,
required TResult Function(_Selected value) selected,
required TResult Function(_Cleared value) cleared,
}) {
return loaded(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Loaded value)? loaded,
TResult? Function(_Selected value)? selected,
TResult? Function(_Cleared value)? cleared,
}) {
return loaded?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Loaded value)? loaded,
TResult Function(_Selected value)? selected,
TResult Function(_Cleared value)? cleared,
required TResult orElse(),
}) {
if (loaded != null) {
return loaded(this);
}
return orElse();
}
}
abstract class _Loaded implements SelectedOutletEvent {
const factory _Loaded() = _$LoadedImpl;
}
/// @nodoc
abstract class _$$SelectedImplCopyWith<$Res> {
factory _$$SelectedImplCopyWith(
_$SelectedImpl value,
$Res Function(_$SelectedImpl) then,
) = __$$SelectedImplCopyWithImpl<$Res>;
@useResult
$Res call({Outlet outlet});
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class __$$SelectedImplCopyWithImpl<$Res>
extends _$SelectedOutletEventCopyWithImpl<$Res, _$SelectedImpl>
implements _$$SelectedImplCopyWith<$Res> {
__$$SelectedImplCopyWithImpl(
_$SelectedImpl _value,
$Res Function(_$SelectedImpl) _then,
) : super(_value, _then);
/// Create a copy of SelectedOutletEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? outlet = null}) {
return _then(
_$SelectedImpl(
null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
),
);
}
/// Create a copy of SelectedOutletEvent
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OutletCopyWith<$Res> get outlet {
return $OutletCopyWith<$Res>(_value.outlet, (value) {
return _then(_value.copyWith(outlet: value));
});
}
}
/// @nodoc
class _$SelectedImpl implements _Selected {
const _$SelectedImpl(this.outlet);
@override
final Outlet outlet;
@override
String toString() {
return 'SelectedOutletEvent.selected(outlet: $outlet)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SelectedImpl &&
(identical(other.outlet, outlet) || other.outlet == outlet));
}
@override
int get hashCode => Object.hash(runtimeType, outlet);
/// Create a copy of SelectedOutletEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SelectedImplCopyWith<_$SelectedImpl> get copyWith =>
__$$SelectedImplCopyWithImpl<_$SelectedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() loaded,
required TResult Function(Outlet outlet) selected,
required TResult Function() cleared,
}) {
return selected(outlet);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? loaded,
TResult? Function(Outlet outlet)? selected,
TResult? Function()? cleared,
}) {
return selected?.call(outlet);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? loaded,
TResult Function(Outlet outlet)? selected,
TResult Function()? cleared,
required TResult orElse(),
}) {
if (selected != null) {
return selected(outlet);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Loaded value) loaded,
required TResult Function(_Selected value) selected,
required TResult Function(_Cleared value) cleared,
}) {
return selected(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Loaded value)? loaded,
TResult? Function(_Selected value)? selected,
TResult? Function(_Cleared value)? cleared,
}) {
return selected?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Loaded value)? loaded,
TResult Function(_Selected value)? selected,
TResult Function(_Cleared value)? cleared,
required TResult orElse(),
}) {
if (selected != null) {
return selected(this);
}
return orElse();
}
}
abstract class _Selected implements SelectedOutletEvent {
const factory _Selected(final Outlet outlet) = _$SelectedImpl;
Outlet get outlet;
/// Create a copy of SelectedOutletEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SelectedImplCopyWith<_$SelectedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$ClearedImplCopyWith<$Res> {
factory _$$ClearedImplCopyWith(
_$ClearedImpl value,
$Res Function(_$ClearedImpl) then,
) = __$$ClearedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$ClearedImplCopyWithImpl<$Res>
extends _$SelectedOutletEventCopyWithImpl<$Res, _$ClearedImpl>
implements _$$ClearedImplCopyWith<$Res> {
__$$ClearedImplCopyWithImpl(
_$ClearedImpl _value,
$Res Function(_$ClearedImpl) _then,
) : super(_value, _then);
/// Create a copy of SelectedOutletEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$ClearedImpl implements _Cleared {
const _$ClearedImpl();
@override
String toString() {
return 'SelectedOutletEvent.cleared()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$ClearedImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() loaded,
required TResult Function(Outlet outlet) selected,
required TResult Function() cleared,
}) {
return cleared();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? loaded,
TResult? Function(Outlet outlet)? selected,
TResult? Function()? cleared,
}) {
return cleared?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? loaded,
TResult Function(Outlet outlet)? selected,
TResult Function()? cleared,
required TResult orElse(),
}) {
if (cleared != null) {
return cleared();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_Loaded value) loaded,
required TResult Function(_Selected value) selected,
required TResult Function(_Cleared value) cleared,
}) {
return cleared(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_Loaded value)? loaded,
TResult? Function(_Selected value)? selected,
TResult? Function(_Cleared value)? cleared,
}) {
return cleared?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_Loaded value)? loaded,
TResult Function(_Selected value)? selected,
TResult Function(_Cleared value)? cleared,
required TResult orElse(),
}) {
if (cleared != null) {
return cleared(this);
}
return orElse();
}
}
abstract class _Cleared implements SelectedOutletEvent {
const factory _Cleared() = _$ClearedImpl;
}
/// @nodoc
mixin _$SelectedOutletState {
/// null berarti "Semua Outlet"
Outlet? get selectedOutlet => throw _privateConstructorUsedError;
String? get selectedOutletId => throw _privateConstructorUsedError;
/// Create a copy of SelectedOutletState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$SelectedOutletStateCopyWith<SelectedOutletState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SelectedOutletStateCopyWith<$Res> {
factory $SelectedOutletStateCopyWith(
SelectedOutletState value,
$Res Function(SelectedOutletState) then,
) = _$SelectedOutletStateCopyWithImpl<$Res, SelectedOutletState>;
@useResult
$Res call({Outlet? selectedOutlet, String? selectedOutletId});
$OutletCopyWith<$Res>? get selectedOutlet;
}
/// @nodoc
class _$SelectedOutletStateCopyWithImpl<$Res, $Val extends SelectedOutletState>
implements $SelectedOutletStateCopyWith<$Res> {
_$SelectedOutletStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of SelectedOutletState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? selectedOutlet = freezed,
Object? selectedOutletId = freezed,
}) {
return _then(
_value.copyWith(
selectedOutlet: freezed == selectedOutlet
? _value.selectedOutlet
: selectedOutlet // ignore: cast_nullable_to_non_nullable
as Outlet?,
selectedOutletId: freezed == selectedOutletId
? _value.selectedOutletId
: selectedOutletId // ignore: cast_nullable_to_non_nullable
as String?,
)
as $Val,
);
}
/// Create a copy of SelectedOutletState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OutletCopyWith<$Res>? get selectedOutlet {
if (_value.selectedOutlet == null) {
return null;
}
return $OutletCopyWith<$Res>(_value.selectedOutlet!, (value) {
return _then(_value.copyWith(selectedOutlet: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$SelectedOutletStateImplCopyWith<$Res>
implements $SelectedOutletStateCopyWith<$Res> {
factory _$$SelectedOutletStateImplCopyWith(
_$SelectedOutletStateImpl value,
$Res Function(_$SelectedOutletStateImpl) then,
) = __$$SelectedOutletStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({Outlet? selectedOutlet, String? selectedOutletId});
@override
$OutletCopyWith<$Res>? get selectedOutlet;
}
/// @nodoc
class __$$SelectedOutletStateImplCopyWithImpl<$Res>
extends _$SelectedOutletStateCopyWithImpl<$Res, _$SelectedOutletStateImpl>
implements _$$SelectedOutletStateImplCopyWith<$Res> {
__$$SelectedOutletStateImplCopyWithImpl(
_$SelectedOutletStateImpl _value,
$Res Function(_$SelectedOutletStateImpl) _then,
) : super(_value, _then);
/// Create a copy of SelectedOutletState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? selectedOutlet = freezed,
Object? selectedOutletId = freezed,
}) {
return _then(
_$SelectedOutletStateImpl(
selectedOutlet: freezed == selectedOutlet
? _value.selectedOutlet
: selectedOutlet // ignore: cast_nullable_to_non_nullable
as Outlet?,
selectedOutletId: freezed == selectedOutletId
? _value.selectedOutletId
: selectedOutletId // ignore: cast_nullable_to_non_nullable
as String?,
),
);
}
}
/// @nodoc
class _$SelectedOutletStateImpl implements _SelectedOutletState {
const _$SelectedOutletStateImpl({this.selectedOutlet, this.selectedOutletId});
/// null berarti "Semua Outlet"
@override
final Outlet? selectedOutlet;
@override
final String? selectedOutletId;
@override
String toString() {
return 'SelectedOutletState(selectedOutlet: $selectedOutlet, selectedOutletId: $selectedOutletId)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SelectedOutletStateImpl &&
(identical(other.selectedOutlet, selectedOutlet) ||
other.selectedOutlet == selectedOutlet) &&
(identical(other.selectedOutletId, selectedOutletId) ||
other.selectedOutletId == selectedOutletId));
}
@override
int get hashCode =>
Object.hash(runtimeType, selectedOutlet, selectedOutletId);
/// Create a copy of SelectedOutletState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$SelectedOutletStateImplCopyWith<_$SelectedOutletStateImpl> get copyWith =>
__$$SelectedOutletStateImplCopyWithImpl<_$SelectedOutletStateImpl>(
this,
_$identity,
);
}
abstract class _SelectedOutletState implements SelectedOutletState {
const factory _SelectedOutletState({
final Outlet? selectedOutlet,
final String? selectedOutletId,
}) = _$SelectedOutletStateImpl;
/// null berarti "Semua Outlet"
@override
Outlet? get selectedOutlet;
@override
String? get selectedOutletId;
/// Create a copy of SelectedOutletState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$SelectedOutletStateImplCopyWith<_$SelectedOutletStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -0,0 +1,13 @@
part of 'selected_outlet_bloc.dart';
@freezed
class SelectedOutletEvent with _$SelectedOutletEvent {
/// Load selected outlet id dari shared preferences
const factory SelectedOutletEvent.loaded() = _Loaded;
/// User memilih outlet tertentu
const factory SelectedOutletEvent.selected(Outlet outlet) = _Selected;
/// Reset ke "Semua Outlet"
const factory SelectedOutletEvent.cleared() = _Cleared;
}
@@ -0,0 +1,18 @@
part of 'selected_outlet_bloc.dart';
@freezed
class SelectedOutletState with _$SelectedOutletState {
const factory SelectedOutletState({
/// null berarti "Semua Outlet"
Outlet? selectedOutlet,
String? selectedOutletId,
}) = _SelectedOutletState;
factory SelectedOutletState.initial() => const SelectedOutletState();
}
extension SelectedOutletStateX on SelectedOutletState {
bool get isAllOutlets => selectedOutletId == null;
String get displayName => selectedOutlet?.name ?? 'Semua Outlet';
}
@@ -0,0 +1,66 @@
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';
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
import '../../../domain/outlet/outlet.dart';
part 'inventory_report_event.dart';
part 'inventory_report_state.dart';
part 'inventory_report_bloc.freezed.dart';
@injectable
class InventoryReportBloc
extends Bloc<InventoryReportEvent, InventoryReportState> {
final IAnalyticRepository _analyticRepository;
final IOutletRepository _outletRepository;
InventoryReportBloc(this._analyticRepository, this._outletRepository)
: super(InventoryReportState.initial()) {
on<InventoryReportEvent>(_onInventoryReportEvent);
}
Future<void> _onInventoryReportEvent(
InventoryReportEvent event,
Emitter<InventoryReportState> emit,
) {
return event.map(
fetchedOutlet: (e) async {
emit(
state.copyWith(isFetchingOutlet: true, failureOptionOutlet: none()),
);
final result = await _outletRepository.currentOutlet();
var data = result.fold(
(f) => state.copyWith(failureOptionOutlet: optionOf(f)),
(currentOutlet) => state.copyWith(outlet: currentOutlet),
);
emit(data.copyWith(isFetchingOutlet: false));
},
fetchedInventory: (e) async {
emit(
state.copyWith(
isFetching: true,
failureOptionInventoryAnalytic: none(),
),
);
final result = await _analyticRepository.getInventory(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
var data = result.fold(
(f) => state.copyWith(failureOptionInventoryAnalytic: optionOf(f)),
(inventoryAnalytic) =>
state.copyWith(inventoryAnalytic: inventoryAnalytic),
);
emit(data.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,645 @@
// 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_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 _$InventoryReportEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedInventory,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedInventory,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedInventory,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedInventory value) fetchedInventory,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedInventory value)? fetchedInventory,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedInventory value)? fetchedInventory,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $InventoryReportEventCopyWith<$Res> {
factory $InventoryReportEventCopyWith(
InventoryReportEvent value,
$Res Function(InventoryReportEvent) then,
) = _$InventoryReportEventCopyWithImpl<$Res, InventoryReportEvent>;
}
/// @nodoc
class _$InventoryReportEventCopyWithImpl<
$Res,
$Val extends InventoryReportEvent
>
implements $InventoryReportEventCopyWith<$Res> {
_$InventoryReportEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of InventoryReportEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedOutletImplCopyWith<$Res> {
factory _$$FetchedOutletImplCopyWith(
_$FetchedOutletImpl value,
$Res Function(_$FetchedOutletImpl) then,
) = __$$FetchedOutletImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchedOutletImplCopyWithImpl<$Res>
extends _$InventoryReportEventCopyWithImpl<$Res, _$FetchedOutletImpl>
implements _$$FetchedOutletImplCopyWith<$Res> {
__$$FetchedOutletImplCopyWithImpl(
_$FetchedOutletImpl _value,
$Res Function(_$FetchedOutletImpl) _then,
) : super(_value, _then);
/// Create a copy of InventoryReportEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedOutletImpl implements _FetchedOutlet {
const _$FetchedOutletImpl();
@override
String toString() {
return 'InventoryReportEvent.fetchedOutlet()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchedOutletImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedInventory,
}) {
return fetchedOutlet();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedInventory,
}) {
return fetchedOutlet?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedInventory,
required TResult orElse(),
}) {
if (fetchedOutlet != null) {
return fetchedOutlet();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedInventory value) fetchedInventory,
}) {
return fetchedOutlet(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedInventory value)? fetchedInventory,
}) {
return fetchedOutlet?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedInventory value)? fetchedInventory,
required TResult orElse(),
}) {
if (fetchedOutlet != null) {
return fetchedOutlet(this);
}
return orElse();
}
}
abstract class _FetchedOutlet implements InventoryReportEvent {
const factory _FetchedOutlet() = _$FetchedOutletImpl;
}
/// @nodoc
abstract class _$$FetchedInventoryImplCopyWith<$Res> {
factory _$$FetchedInventoryImplCopyWith(
_$FetchedInventoryImpl value,
$Res Function(_$FetchedInventoryImpl) then,
) = __$$FetchedInventoryImplCopyWithImpl<$Res>;
@useResult
$Res call({DateTime dateFrom, DateTime dateTo});
}
/// @nodoc
class __$$FetchedInventoryImplCopyWithImpl<$Res>
extends _$InventoryReportEventCopyWithImpl<$Res, _$FetchedInventoryImpl>
implements _$$FetchedInventoryImplCopyWith<$Res> {
__$$FetchedInventoryImplCopyWithImpl(
_$FetchedInventoryImpl _value,
$Res Function(_$FetchedInventoryImpl) _then,
) : super(_value, _then);
/// Create a copy of InventoryReportEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? dateFrom = null, Object? dateTo = null}) {
return _then(
_$FetchedInventoryImpl(
null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$FetchedInventoryImpl implements _FetchedInventory {
const _$FetchedInventoryImpl(this.dateFrom, this.dateTo);
@override
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
String toString() {
return 'InventoryReportEvent.fetchedInventory(dateFrom: $dateFrom, dateTo: $dateTo)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FetchedInventoryImpl &&
(identical(other.dateFrom, dateFrom) ||
other.dateFrom == dateFrom) &&
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
}
@override
int get hashCode => Object.hash(runtimeType, dateFrom, dateTo);
/// Create a copy of InventoryReportEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$FetchedInventoryImplCopyWith<_$FetchedInventoryImpl> get copyWith =>
__$$FetchedInventoryImplCopyWithImpl<_$FetchedInventoryImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedInventory,
}) {
return fetchedInventory(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedInventory,
}) {
return fetchedInventory?.call(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedInventory,
required TResult orElse(),
}) {
if (fetchedInventory != null) {
return fetchedInventory(dateFrom, dateTo);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedInventory value) fetchedInventory,
}) {
return fetchedInventory(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedInventory value)? fetchedInventory,
}) {
return fetchedInventory?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedInventory value)? fetchedInventory,
required TResult orElse(),
}) {
if (fetchedInventory != null) {
return fetchedInventory(this);
}
return orElse();
}
}
abstract class _FetchedInventory implements InventoryReportEvent {
const factory _FetchedInventory(
final DateTime dateFrom,
final DateTime dateTo,
) = _$FetchedInventoryImpl;
DateTime get dateFrom;
DateTime get dateTo;
/// Create a copy of InventoryReportEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$FetchedInventoryImplCopyWith<_$FetchedInventoryImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$InventoryReportState {
InventoryAnalytic get inventoryAnalytic => throw _privateConstructorUsedError;
Option<AnalyticFailure> get failureOptionInventoryAnalytic =>
throw _privateConstructorUsedError;
Outlet get outlet => throw _privateConstructorUsedError;
Option<OutletFailure> get failureOptionOutlet =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
bool get isFetchingOutlet => throw _privateConstructorUsedError;
/// Create a copy of InventoryReportState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$InventoryReportStateCopyWith<InventoryReportState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $InventoryReportStateCopyWith<$Res> {
factory $InventoryReportStateCopyWith(
InventoryReportState value,
$Res Function(InventoryReportState) then,
) = _$InventoryReportStateCopyWithImpl<$Res, InventoryReportState>;
@useResult
$Res call({
InventoryAnalytic inventoryAnalytic,
Option<AnalyticFailure> failureOptionInventoryAnalytic,
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
bool isFetchingOutlet,
});
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic;
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class _$InventoryReportStateCopyWithImpl<
$Res,
$Val extends InventoryReportState
>
implements $InventoryReportStateCopyWith<$Res> {
_$InventoryReportStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of InventoryReportState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? inventoryAnalytic = null,
Object? failureOptionInventoryAnalytic = null,
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
Object? isFetchingOutlet = null,
}) {
return _then(
_value.copyWith(
inventoryAnalytic: null == inventoryAnalytic
? _value.inventoryAnalytic
: inventoryAnalytic // ignore: cast_nullable_to_non_nullable
as InventoryAnalytic,
failureOptionInventoryAnalytic:
null == failureOptionInventoryAnalytic
? _value.failureOptionInventoryAnalytic
: failureOptionInventoryAnalytic // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
isFetchingOutlet: null == isFetchingOutlet
? _value.isFetchingOutlet
: isFetchingOutlet // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of InventoryReportState
/// 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);
});
}
/// Create a copy of InventoryReportState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OutletCopyWith<$Res> get outlet {
return $OutletCopyWith<$Res>(_value.outlet, (value) {
return _then(_value.copyWith(outlet: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$InventoryReportStateImplCopyWith<$Res>
implements $InventoryReportStateCopyWith<$Res> {
factory _$$InventoryReportStateImplCopyWith(
_$InventoryReportStateImpl value,
$Res Function(_$InventoryReportStateImpl) then,
) = __$$InventoryReportStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
InventoryAnalytic inventoryAnalytic,
Option<AnalyticFailure> failureOptionInventoryAnalytic,
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
bool isFetchingOutlet,
});
@override
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic;
@override
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class __$$InventoryReportStateImplCopyWithImpl<$Res>
extends _$InventoryReportStateCopyWithImpl<$Res, _$InventoryReportStateImpl>
implements _$$InventoryReportStateImplCopyWith<$Res> {
__$$InventoryReportStateImplCopyWithImpl(
_$InventoryReportStateImpl _value,
$Res Function(_$InventoryReportStateImpl) _then,
) : super(_value, _then);
/// Create a copy of InventoryReportState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? inventoryAnalytic = null,
Object? failureOptionInventoryAnalytic = null,
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
Object? isFetchingOutlet = null,
}) {
return _then(
_$InventoryReportStateImpl(
inventoryAnalytic: null == inventoryAnalytic
? _value.inventoryAnalytic
: inventoryAnalytic // ignore: cast_nullable_to_non_nullable
as InventoryAnalytic,
failureOptionInventoryAnalytic: null == failureOptionInventoryAnalytic
? _value.failureOptionInventoryAnalytic
: failureOptionInventoryAnalytic // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
isFetchingOutlet: null == isFetchingOutlet
? _value.isFetchingOutlet
: isFetchingOutlet // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$InventoryReportStateImpl implements _InventoryReportState {
const _$InventoryReportStateImpl({
required this.inventoryAnalytic,
required this.failureOptionInventoryAnalytic,
required this.outlet,
required this.failureOptionOutlet,
this.isFetching = false,
this.isFetchingOutlet = false,
});
@override
final InventoryAnalytic inventoryAnalytic;
@override
final Option<AnalyticFailure> failureOptionInventoryAnalytic;
@override
final Outlet outlet;
@override
final Option<OutletFailure> failureOptionOutlet;
@override
@JsonKey()
final bool isFetching;
@override
@JsonKey()
final bool isFetchingOutlet;
@override
String toString() {
return 'InventoryReportState(inventoryAnalytic: $inventoryAnalytic, failureOptionInventoryAnalytic: $failureOptionInventoryAnalytic, outlet: $outlet, failureOptionOutlet: $failureOptionOutlet, isFetching: $isFetching, isFetchingOutlet: $isFetchingOutlet)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$InventoryReportStateImpl &&
(identical(other.inventoryAnalytic, inventoryAnalytic) ||
other.inventoryAnalytic == inventoryAnalytic) &&
(identical(
other.failureOptionInventoryAnalytic,
failureOptionInventoryAnalytic,
) ||
other.failureOptionInventoryAnalytic ==
failureOptionInventoryAnalytic) &&
(identical(other.outlet, outlet) || other.outlet == outlet) &&
(identical(other.failureOptionOutlet, failureOptionOutlet) ||
other.failureOptionOutlet == failureOptionOutlet) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching) &&
(identical(other.isFetchingOutlet, isFetchingOutlet) ||
other.isFetchingOutlet == isFetchingOutlet));
}
@override
int get hashCode => Object.hash(
runtimeType,
inventoryAnalytic,
failureOptionInventoryAnalytic,
outlet,
failureOptionOutlet,
isFetching,
isFetchingOutlet,
);
/// Create a copy of InventoryReportState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$InventoryReportStateImplCopyWith<_$InventoryReportStateImpl>
get copyWith =>
__$$InventoryReportStateImplCopyWithImpl<_$InventoryReportStateImpl>(
this,
_$identity,
);
}
abstract class _InventoryReportState implements InventoryReportState {
const factory _InventoryReportState({
required final InventoryAnalytic inventoryAnalytic,
required final Option<AnalyticFailure> failureOptionInventoryAnalytic,
required final Outlet outlet,
required final Option<OutletFailure> failureOptionOutlet,
final bool isFetching,
final bool isFetchingOutlet,
}) = _$InventoryReportStateImpl;
@override
InventoryAnalytic get inventoryAnalytic;
@override
Option<AnalyticFailure> get failureOptionInventoryAnalytic;
@override
Outlet get outlet;
@override
Option<OutletFailure> get failureOptionOutlet;
@override
bool get isFetching;
@override
bool get isFetchingOutlet;
/// Create a copy of InventoryReportState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$InventoryReportStateImplCopyWith<_$InventoryReportStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,10 @@
part of 'inventory_report_bloc.dart';
@freezed
class InventoryReportEvent with _$InventoryReportEvent {
const factory InventoryReportEvent.fetchedOutlet() = _FetchedOutlet;
const factory InventoryReportEvent.fetchedInventory(
DateTime dateFrom,
DateTime dateTo,
) = _FetchedInventory;
}
@@ -0,0 +1,20 @@
part of 'inventory_report_bloc.dart';
@freezed
class InventoryReportState with _$InventoryReportState {
const factory InventoryReportState({
required InventoryAnalytic inventoryAnalytic,
required Option<AnalyticFailure> failureOptionInventoryAnalytic,
required Outlet outlet,
required Option<OutletFailure> failureOptionOutlet,
@Default(false) bool isFetching,
@Default(false) bool isFetchingOutlet,
}) = _InventoryReportState;
factory InventoryReportState.initial() => InventoryReportState(
inventoryAnalytic: InventoryAnalytic.empty(),
failureOptionInventoryAnalytic: none(),
outlet: Outlet.empty(),
failureOptionOutlet: none(),
);
}
@@ -0,0 +1,91 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/analytic/analytic.dart';
import '../../../domain/analytic/repositories/i_analytic_repository.dart';
import '../../../domain/outlet/outlet.dart';
part 'transaction_report_event.dart';
part 'transaction_report_state.dart';
part 'transaction_report_bloc.freezed.dart';
@injectable
class TransactionReportBloc
extends Bloc<TransactionReportEvent, TransactionReportState> {
final IAnalyticRepository _analyticRepository;
final IOutletRepository _outletRepository;
TransactionReportBloc(this._analyticRepository, this._outletRepository)
: super(TransactionReportState.initial()) {
on<TransactionReportEvent>(_onTransactionReportEvent);
}
Future<void> _onTransactionReportEvent(
TransactionReportEvent event,
Emitter<TransactionReportState> emit,
) {
return event.map(
fetchedOutlet: (e) async {
emit(
state.copyWith(isFetchingOutlet: true, failureOptionOutlet: none()),
);
final result = await _outletRepository.currentOutlet();
var data = result.fold(
(f) => state.copyWith(failureOptionOutlet: optionOf(f)),
(currentOutlet) => state.copyWith(outlet: currentOutlet),
);
emit(data.copyWith(isFetchingOutlet: false));
},
fetchedTransaction: (e) async {
emit(state.copyWith(isFetching: true, failureOptionAnalytic: none()));
var newState = state;
final category = await _analyticRepository.getCategory(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
final profitLoss = await _analyticRepository.getProfitLoss(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
final paymentMethod = await _analyticRepository.getPaymentMethod(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
final product = await _analyticRepository.getProduct(
dateFrom: e.dateFrom,
dateTo: e.dateTo,
);
newState = category.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(categoryAnalytic) =>
newState.copyWith(categoryAnalytic: categoryAnalytic),
);
newState = profitLoss.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(profitLossAnalytic) =>
newState.copyWith(profitLossAnalytic: profitLossAnalytic),
);
newState = paymentMethod.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(paymentMethodAnalytic) =>
newState.copyWith(paymentMethodAnalytic: paymentMethodAnalytic),
);
newState = product.fold(
(f) => newState.copyWith(failureOptionAnalytic: optionOf(f)),
(productAnalytic) =>
newState.copyWith(productAnalytic: productAnalytic),
);
emit(newState.copyWith(isFetching: false));
},
);
}
}
@@ -0,0 +1,752 @@
// 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 'transaction_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 _$TransactionReportEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedTransaction value) fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedTransaction value)? fetchedTransaction,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedTransaction value)? fetchedTransaction,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TransactionReportEventCopyWith<$Res> {
factory $TransactionReportEventCopyWith(
TransactionReportEvent value,
$Res Function(TransactionReportEvent) then,
) = _$TransactionReportEventCopyWithImpl<$Res, TransactionReportEvent>;
}
/// @nodoc
class _$TransactionReportEventCopyWithImpl<
$Res,
$Val extends TransactionReportEvent
>
implements $TransactionReportEventCopyWith<$Res> {
_$TransactionReportEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$FetchedOutletImplCopyWith<$Res> {
factory _$$FetchedOutletImplCopyWith(
_$FetchedOutletImpl value,
$Res Function(_$FetchedOutletImpl) then,
) = __$$FetchedOutletImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$FetchedOutletImplCopyWithImpl<$Res>
extends _$TransactionReportEventCopyWithImpl<$Res, _$FetchedOutletImpl>
implements _$$FetchedOutletImplCopyWith<$Res> {
__$$FetchedOutletImplCopyWithImpl(
_$FetchedOutletImpl _value,
$Res Function(_$FetchedOutletImpl) _then,
) : super(_value, _then);
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$FetchedOutletImpl implements _FetchedOutlet {
const _$FetchedOutletImpl();
@override
String toString() {
return 'TransactionReportEvent.fetchedOutlet()';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType && other is _$FetchedOutletImpl);
}
@override
int get hashCode => runtimeType.hashCode;
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedTransaction,
}) {
return fetchedOutlet();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
}) {
return fetchedOutlet?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedOutlet != null) {
return fetchedOutlet();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedTransaction value) fetchedTransaction,
}) {
return fetchedOutlet(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedTransaction value)? fetchedTransaction,
}) {
return fetchedOutlet?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedTransaction value)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedOutlet != null) {
return fetchedOutlet(this);
}
return orElse();
}
}
abstract class _FetchedOutlet implements TransactionReportEvent {
const factory _FetchedOutlet() = _$FetchedOutletImpl;
}
/// @nodoc
abstract class _$$FetchedTransactionImplCopyWith<$Res> {
factory _$$FetchedTransactionImplCopyWith(
_$FetchedTransactionImpl value,
$Res Function(_$FetchedTransactionImpl) then,
) = __$$FetchedTransactionImplCopyWithImpl<$Res>;
@useResult
$Res call({DateTime dateFrom, DateTime dateTo});
}
/// @nodoc
class __$$FetchedTransactionImplCopyWithImpl<$Res>
extends _$TransactionReportEventCopyWithImpl<$Res, _$FetchedTransactionImpl>
implements _$$FetchedTransactionImplCopyWith<$Res> {
__$$FetchedTransactionImplCopyWithImpl(
_$FetchedTransactionImpl _value,
$Res Function(_$FetchedTransactionImpl) _then,
) : super(_value, _then);
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? dateFrom = null, Object? dateTo = null}) {
return _then(
_$FetchedTransactionImpl(
null == dateFrom
? _value.dateFrom
: dateFrom // ignore: cast_nullable_to_non_nullable
as DateTime,
null == dateTo
? _value.dateTo
: dateTo // ignore: cast_nullable_to_non_nullable
as DateTime,
),
);
}
}
/// @nodoc
class _$FetchedTransactionImpl implements _FetchedTransaction {
const _$FetchedTransactionImpl(this.dateFrom, this.dateTo);
@override
final DateTime dateFrom;
@override
final DateTime dateTo;
@override
String toString() {
return 'TransactionReportEvent.fetchedTransaction(dateFrom: $dateFrom, dateTo: $dateTo)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FetchedTransactionImpl &&
(identical(other.dateFrom, dateFrom) ||
other.dateFrom == dateFrom) &&
(identical(other.dateTo, dateTo) || other.dateTo == dateTo));
}
@override
int get hashCode => Object.hash(runtimeType, dateFrom, dateTo);
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$FetchedTransactionImplCopyWith<_$FetchedTransactionImpl> get copyWith =>
__$$FetchedTransactionImplCopyWithImpl<_$FetchedTransactionImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() fetchedOutlet,
required TResult Function(DateTime dateFrom, DateTime dateTo)
fetchedTransaction,
}) {
return fetchedTransaction(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function()? fetchedOutlet,
TResult? Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
}) {
return fetchedTransaction?.call(dateFrom, dateTo);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? fetchedOutlet,
TResult Function(DateTime dateFrom, DateTime dateTo)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedTransaction != null) {
return fetchedTransaction(dateFrom, dateTo);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_FetchedOutlet value) fetchedOutlet,
required TResult Function(_FetchedTransaction value) fetchedTransaction,
}) {
return fetchedTransaction(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_FetchedOutlet value)? fetchedOutlet,
TResult? Function(_FetchedTransaction value)? fetchedTransaction,
}) {
return fetchedTransaction?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_FetchedOutlet value)? fetchedOutlet,
TResult Function(_FetchedTransaction value)? fetchedTransaction,
required TResult orElse(),
}) {
if (fetchedTransaction != null) {
return fetchedTransaction(this);
}
return orElse();
}
}
abstract class _FetchedTransaction implements TransactionReportEvent {
const factory _FetchedTransaction(
final DateTime dateFrom,
final DateTime dateTo,
) = _$FetchedTransactionImpl;
DateTime get dateFrom;
DateTime get dateTo;
/// Create a copy of TransactionReportEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$FetchedTransactionImplCopyWith<_$FetchedTransactionImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$TransactionReportState {
CategoryAnalytic get categoryAnalytic => throw _privateConstructorUsedError;
ProfitLossAnalytic get profitLossAnalytic =>
throw _privateConstructorUsedError;
PaymentMethodAnalytic get paymentMethodAnalytic =>
throw _privateConstructorUsedError;
ProductAnalytic get productAnalytic => throw _privateConstructorUsedError;
Option<AnalyticFailure> get failureOptionAnalytic =>
throw _privateConstructorUsedError;
Outlet get outlet => throw _privateConstructorUsedError;
Option<OutletFailure> get failureOptionOutlet =>
throw _privateConstructorUsedError;
bool get isFetching => throw _privateConstructorUsedError;
bool get isFetchingOutlet => throw _privateConstructorUsedError;
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$TransactionReportStateCopyWith<TransactionReportState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TransactionReportStateCopyWith<$Res> {
factory $TransactionReportStateCopyWith(
TransactionReportState value,
$Res Function(TransactionReportState) then,
) = _$TransactionReportStateCopyWithImpl<$Res, TransactionReportState>;
@useResult
$Res call({
CategoryAnalytic categoryAnalytic,
ProfitLossAnalytic profitLossAnalytic,
PaymentMethodAnalytic paymentMethodAnalytic,
ProductAnalytic productAnalytic,
Option<AnalyticFailure> failureOptionAnalytic,
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
bool isFetchingOutlet,
});
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
$ProductAnalyticCopyWith<$Res> get productAnalytic;
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class _$TransactionReportStateCopyWithImpl<
$Res,
$Val extends TransactionReportState
>
implements $TransactionReportStateCopyWith<$Res> {
_$TransactionReportStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? categoryAnalytic = null,
Object? profitLossAnalytic = null,
Object? paymentMethodAnalytic = null,
Object? productAnalytic = null,
Object? failureOptionAnalytic = null,
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
Object? isFetchingOutlet = null,
}) {
return _then(
_value.copyWith(
categoryAnalytic: null == categoryAnalytic
? _value.categoryAnalytic
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
as CategoryAnalytic,
profitLossAnalytic: null == profitLossAnalytic
? _value.profitLossAnalytic
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
as ProfitLossAnalytic,
paymentMethodAnalytic: null == paymentMethodAnalytic
? _value.paymentMethodAnalytic
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
as PaymentMethodAnalytic,
productAnalytic: null == productAnalytic
? _value.productAnalytic
: productAnalytic // ignore: cast_nullable_to_non_nullable
as ProductAnalytic,
failureOptionAnalytic: null == failureOptionAnalytic
? _value.failureOptionAnalytic
: failureOptionAnalytic // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
isFetchingOutlet: null == isFetchingOutlet
? _value.isFetchingOutlet
: isFetchingOutlet // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
/// Create a copy of TransactionReportState
/// 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);
});
}
/// Create a copy of TransactionReportState
/// 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);
});
}
/// Create a copy of TransactionReportState
/// 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);
});
}
/// Create a copy of TransactionReportState
/// 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);
});
}
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$OutletCopyWith<$Res> get outlet {
return $OutletCopyWith<$Res>(_value.outlet, (value) {
return _then(_value.copyWith(outlet: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$TransactionReportStateImplCopyWith<$Res>
implements $TransactionReportStateCopyWith<$Res> {
factory _$$TransactionReportStateImplCopyWith(
_$TransactionReportStateImpl value,
$Res Function(_$TransactionReportStateImpl) then,
) = __$$TransactionReportStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
CategoryAnalytic categoryAnalytic,
ProfitLossAnalytic profitLossAnalytic,
PaymentMethodAnalytic paymentMethodAnalytic,
ProductAnalytic productAnalytic,
Option<AnalyticFailure> failureOptionAnalytic,
Outlet outlet,
Option<OutletFailure> failureOptionOutlet,
bool isFetching,
bool isFetchingOutlet,
});
@override
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
@override
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
@override
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
@override
$ProductAnalyticCopyWith<$Res> get productAnalytic;
@override
$OutletCopyWith<$Res> get outlet;
}
/// @nodoc
class __$$TransactionReportStateImplCopyWithImpl<$Res>
extends
_$TransactionReportStateCopyWithImpl<$Res, _$TransactionReportStateImpl>
implements _$$TransactionReportStateImplCopyWith<$Res> {
__$$TransactionReportStateImplCopyWithImpl(
_$TransactionReportStateImpl _value,
$Res Function(_$TransactionReportStateImpl) _then,
) : super(_value, _then);
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? categoryAnalytic = null,
Object? profitLossAnalytic = null,
Object? paymentMethodAnalytic = null,
Object? productAnalytic = null,
Object? failureOptionAnalytic = null,
Object? outlet = null,
Object? failureOptionOutlet = null,
Object? isFetching = null,
Object? isFetchingOutlet = null,
}) {
return _then(
_$TransactionReportStateImpl(
categoryAnalytic: null == categoryAnalytic
? _value.categoryAnalytic
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
as CategoryAnalytic,
profitLossAnalytic: null == profitLossAnalytic
? _value.profitLossAnalytic
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
as ProfitLossAnalytic,
paymentMethodAnalytic: null == paymentMethodAnalytic
? _value.paymentMethodAnalytic
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
as PaymentMethodAnalytic,
productAnalytic: null == productAnalytic
? _value.productAnalytic
: productAnalytic // ignore: cast_nullable_to_non_nullable
as ProductAnalytic,
failureOptionAnalytic: null == failureOptionAnalytic
? _value.failureOptionAnalytic
: failureOptionAnalytic // ignore: cast_nullable_to_non_nullable
as Option<AnalyticFailure>,
outlet: null == outlet
? _value.outlet
: outlet // ignore: cast_nullable_to_non_nullable
as Outlet,
failureOptionOutlet: null == failureOptionOutlet
? _value.failureOptionOutlet
: failureOptionOutlet // ignore: cast_nullable_to_non_nullable
as Option<OutletFailure>,
isFetching: null == isFetching
? _value.isFetching
: isFetching // ignore: cast_nullable_to_non_nullable
as bool,
isFetchingOutlet: null == isFetchingOutlet
? _value.isFetchingOutlet
: isFetchingOutlet // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$TransactionReportStateImpl implements _TransactionReportState {
const _$TransactionReportStateImpl({
required this.categoryAnalytic,
required this.profitLossAnalytic,
required this.paymentMethodAnalytic,
required this.productAnalytic,
required this.failureOptionAnalytic,
required this.outlet,
required this.failureOptionOutlet,
this.isFetching = false,
this.isFetchingOutlet = false,
});
@override
final CategoryAnalytic categoryAnalytic;
@override
final ProfitLossAnalytic profitLossAnalytic;
@override
final PaymentMethodAnalytic paymentMethodAnalytic;
@override
final ProductAnalytic productAnalytic;
@override
final Option<AnalyticFailure> failureOptionAnalytic;
@override
final Outlet outlet;
@override
final Option<OutletFailure> failureOptionOutlet;
@override
@JsonKey()
final bool isFetching;
@override
@JsonKey()
final bool isFetchingOutlet;
@override
String toString() {
return 'TransactionReportState(categoryAnalytic: $categoryAnalytic, profitLossAnalytic: $profitLossAnalytic, paymentMethodAnalytic: $paymentMethodAnalytic, productAnalytic: $productAnalytic, failureOptionAnalytic: $failureOptionAnalytic, outlet: $outlet, failureOptionOutlet: $failureOptionOutlet, isFetching: $isFetching, isFetchingOutlet: $isFetchingOutlet)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$TransactionReportStateImpl &&
(identical(other.categoryAnalytic, categoryAnalytic) ||
other.categoryAnalytic == categoryAnalytic) &&
(identical(other.profitLossAnalytic, profitLossAnalytic) ||
other.profitLossAnalytic == profitLossAnalytic) &&
(identical(other.paymentMethodAnalytic, paymentMethodAnalytic) ||
other.paymentMethodAnalytic == paymentMethodAnalytic) &&
(identical(other.productAnalytic, productAnalytic) ||
other.productAnalytic == productAnalytic) &&
(identical(other.failureOptionAnalytic, failureOptionAnalytic) ||
other.failureOptionAnalytic == failureOptionAnalytic) &&
(identical(other.outlet, outlet) || other.outlet == outlet) &&
(identical(other.failureOptionOutlet, failureOptionOutlet) ||
other.failureOptionOutlet == failureOptionOutlet) &&
(identical(other.isFetching, isFetching) ||
other.isFetching == isFetching) &&
(identical(other.isFetchingOutlet, isFetchingOutlet) ||
other.isFetchingOutlet == isFetchingOutlet));
}
@override
int get hashCode => Object.hash(
runtimeType,
categoryAnalytic,
profitLossAnalytic,
paymentMethodAnalytic,
productAnalytic,
failureOptionAnalytic,
outlet,
failureOptionOutlet,
isFetching,
isFetchingOutlet,
);
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$TransactionReportStateImplCopyWith<_$TransactionReportStateImpl>
get copyWith =>
__$$TransactionReportStateImplCopyWithImpl<_$TransactionReportStateImpl>(
this,
_$identity,
);
}
abstract class _TransactionReportState implements TransactionReportState {
const factory _TransactionReportState({
required final CategoryAnalytic categoryAnalytic,
required final ProfitLossAnalytic profitLossAnalytic,
required final PaymentMethodAnalytic paymentMethodAnalytic,
required final ProductAnalytic productAnalytic,
required final Option<AnalyticFailure> failureOptionAnalytic,
required final Outlet outlet,
required final Option<OutletFailure> failureOptionOutlet,
final bool isFetching,
final bool isFetchingOutlet,
}) = _$TransactionReportStateImpl;
@override
CategoryAnalytic get categoryAnalytic;
@override
ProfitLossAnalytic get profitLossAnalytic;
@override
PaymentMethodAnalytic get paymentMethodAnalytic;
@override
ProductAnalytic get productAnalytic;
@override
Option<AnalyticFailure> get failureOptionAnalytic;
@override
Outlet get outlet;
@override
Option<OutletFailure> get failureOptionOutlet;
@override
bool get isFetching;
@override
bool get isFetchingOutlet;
/// Create a copy of TransactionReportState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$TransactionReportStateImplCopyWith<_$TransactionReportStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,10 @@
part of 'transaction_report_bloc.dart';
@freezed
class TransactionReportEvent with _$TransactionReportEvent {
const factory TransactionReportEvent.fetchedOutlet() = _FetchedOutlet;
const factory TransactionReportEvent.fetchedTransaction(
DateTime dateFrom,
DateTime dateTo,
) = _FetchedTransaction;
}
@@ -0,0 +1,26 @@
part of 'transaction_report_bloc.dart';
@freezed
class TransactionReportState with _$TransactionReportState {
const factory TransactionReportState({
required CategoryAnalytic categoryAnalytic,
required ProfitLossAnalytic profitLossAnalytic,
required PaymentMethodAnalytic paymentMethodAnalytic,
required ProductAnalytic productAnalytic,
required Option<AnalyticFailure> failureOptionAnalytic,
required Outlet outlet,
required Option<OutletFailure> failureOptionOutlet,
@Default(false) bool isFetching,
@Default(false) bool isFetchingOutlet,
}) = _TransactionReportState;
factory TransactionReportState.initial() => TransactionReportState(
failureOptionAnalytic: none(),
outlet: Outlet.empty(),
failureOptionOutlet: none(),
categoryAnalytic: CategoryAnalytic.empty(),
profitLossAnalytic: ProfitLossAnalytic.empty(),
paymentMethodAnalytic: PaymentMethodAnalytic.empty(),
productAnalytic: ProductAnalytic.empty(),
);
}
@@ -0,0 +1,70 @@
import 'package:bloc/bloc.dart';
import 'package:dartz/dartz.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/user/user.dart';
part 'change_password_form_event.dart';
part 'change_password_form_state.dart';
part 'change_password_form_bloc.freezed.dart';
@injectable
class ChangePasswordFormBloc
extends Bloc<ChangePasswordFormEvent, ChangePasswordFormState> {
final IUserRepository _repository;
ChangePasswordFormBloc(this._repository)
: super(ChangePasswordFormState.initial()) {
on<ChangePasswordFormEvent>(_onChangePasswordFormEvent);
}
Future<void> _onChangePasswordFormEvent(
ChangePasswordFormEvent event,
Emitter<ChangePasswordFormState> emit,
) {
return event.map(
newPasswordChanged: (e) async {
emit(
state.copyWith(
newPassword: e.newPassword,
failureOrChangePasswordOption: none(),
),
);
},
currentPasswordChanged: (e) async {
emit(
state.copyWith(
currentPassword: e.currentPassword,
failureOrChangePasswordOption: none(),
),
);
},
submitted: (e) async {
Either<UserFailure, Unit>? failureOrSuccess;
emit(
state.copyWith(
isSubmitting: true,
failureOrChangePasswordOption: none(),
),
);
final oldPasswordValid = state.newPassword.isNotEmpty;
final currentPasswordValid = state.currentPassword.isNotEmpty;
if (oldPasswordValid && currentPasswordValid) {
failureOrSuccess = await _repository.changePassword(
newPassword: state.newPassword,
currentPassword: state.currentPassword,
);
emit(
state.copyWith(
isSubmitting: false,
failureOrChangePasswordOption: optionOf(failureOrSuccess),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}
@@ -0,0 +1,766 @@
// 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 'change_password_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 _$ChangePasswordFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChangePasswordFormEventCopyWith<$Res> {
factory $ChangePasswordFormEventCopyWith(
ChangePasswordFormEvent value,
$Res Function(ChangePasswordFormEvent) then,
) = _$ChangePasswordFormEventCopyWithImpl<$Res, ChangePasswordFormEvent>;
}
/// @nodoc
class _$ChangePasswordFormEventCopyWithImpl<
$Res,
$Val extends ChangePasswordFormEvent
>
implements $ChangePasswordFormEventCopyWith<$Res> {
_$ChangePasswordFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$NewPasswordChangedImplCopyWith<$Res> {
factory _$$NewPasswordChangedImplCopyWith(
_$NewPasswordChangedImpl value,
$Res Function(_$NewPasswordChangedImpl) then,
) = __$$NewPasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String newPassword});
}
/// @nodoc
class __$$NewPasswordChangedImplCopyWithImpl<$Res>
extends
_$ChangePasswordFormEventCopyWithImpl<$Res, _$NewPasswordChangedImpl>
implements _$$NewPasswordChangedImplCopyWith<$Res> {
__$$NewPasswordChangedImplCopyWithImpl(
_$NewPasswordChangedImpl _value,
$Res Function(_$NewPasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? newPassword = null}) {
return _then(
_$NewPasswordChangedImpl(
null == newPassword
? _value.newPassword
: newPassword // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$NewPasswordChangedImpl implements _NewPasswordChanged {
const _$NewPasswordChangedImpl(this.newPassword);
@override
final String newPassword;
@override
String toString() {
return 'ChangePasswordFormEvent.newPasswordChanged(newPassword: $newPassword)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NewPasswordChangedImpl &&
(identical(other.newPassword, newPassword) ||
other.newPassword == newPassword));
}
@override
int get hashCode => Object.hash(runtimeType, newPassword);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$NewPasswordChangedImplCopyWith<_$NewPasswordChangedImpl> get copyWith =>
__$$NewPasswordChangedImplCopyWithImpl<_$NewPasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) {
return newPasswordChanged(newPassword);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) {
return newPasswordChanged?.call(newPassword);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (newPasswordChanged != null) {
return newPasswordChanged(newPassword);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return newPasswordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return newPasswordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (newPasswordChanged != null) {
return newPasswordChanged(this);
}
return orElse();
}
}
abstract class _NewPasswordChanged implements ChangePasswordFormEvent {
const factory _NewPasswordChanged(final String newPassword) =
_$NewPasswordChangedImpl;
String get newPassword;
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$NewPasswordChangedImplCopyWith<_$NewPasswordChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$CurrentPasswordChangedImplCopyWith<$Res> {
factory _$$CurrentPasswordChangedImplCopyWith(
_$CurrentPasswordChangedImpl value,
$Res Function(_$CurrentPasswordChangedImpl) then,
) = __$$CurrentPasswordChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String currentPassword});
}
/// @nodoc
class __$$CurrentPasswordChangedImplCopyWithImpl<$Res>
extends
_$ChangePasswordFormEventCopyWithImpl<
$Res,
_$CurrentPasswordChangedImpl
>
implements _$$CurrentPasswordChangedImplCopyWith<$Res> {
__$$CurrentPasswordChangedImplCopyWithImpl(
_$CurrentPasswordChangedImpl _value,
$Res Function(_$CurrentPasswordChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? currentPassword = null}) {
return _then(
_$CurrentPasswordChangedImpl(
null == currentPassword
? _value.currentPassword
: currentPassword // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$CurrentPasswordChangedImpl implements _CurrentPasswordChanged {
const _$CurrentPasswordChangedImpl(this.currentPassword);
@override
final String currentPassword;
@override
String toString() {
return 'ChangePasswordFormEvent.currentPasswordChanged(currentPassword: $currentPassword)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$CurrentPasswordChangedImpl &&
(identical(other.currentPassword, currentPassword) ||
other.currentPassword == currentPassword));
}
@override
int get hashCode => Object.hash(runtimeType, currentPassword);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$CurrentPasswordChangedImplCopyWith<_$CurrentPasswordChangedImpl>
get copyWith =>
__$$CurrentPasswordChangedImplCopyWithImpl<_$CurrentPasswordChangedImpl>(
this,
_$identity,
);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) {
return currentPasswordChanged(currentPassword);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) {
return currentPasswordChanged?.call(currentPassword);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (currentPasswordChanged != null) {
return currentPasswordChanged(currentPassword);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return currentPasswordChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return currentPasswordChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (currentPasswordChanged != null) {
return currentPasswordChanged(this);
}
return orElse();
}
}
abstract class _CurrentPasswordChanged implements ChangePasswordFormEvent {
const factory _CurrentPasswordChanged(final String currentPassword) =
_$CurrentPasswordChangedImpl;
String get currentPassword;
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$CurrentPasswordChangedImplCopyWith<_$CurrentPasswordChangedImpl>
get copyWith => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$ChangePasswordFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'ChangePasswordFormEvent.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(String newPassword) newPasswordChanged,
required TResult Function(String currentPassword) currentPasswordChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String newPassword)? newPasswordChanged,
TResult? Function(String currentPassword)? currentPasswordChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String newPassword)? newPasswordChanged,
TResult Function(String currentPassword)? currentPasswordChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NewPasswordChanged value) newPasswordChanged,
required TResult Function(_CurrentPasswordChanged value)
currentPasswordChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NewPasswordChanged value)? newPasswordChanged,
TResult? Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NewPasswordChanged value)? newPasswordChanged,
TResult Function(_CurrentPasswordChanged value)? currentPasswordChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements ChangePasswordFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$ChangePasswordFormState {
String get newPassword => throw _privateConstructorUsedError;
String get currentPassword => throw _privateConstructorUsedError;
Option<Either<UserFailure, Unit>> get failureOrChangePasswordOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$ChangePasswordFormStateCopyWith<ChangePasswordFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $ChangePasswordFormStateCopyWith<$Res> {
factory $ChangePasswordFormStateCopyWith(
ChangePasswordFormState value,
$Res Function(ChangePasswordFormState) then,
) = _$ChangePasswordFormStateCopyWithImpl<$Res, ChangePasswordFormState>;
@useResult
$Res call({
String newPassword,
String currentPassword,
Option<Either<UserFailure, Unit>> failureOrChangePasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$ChangePasswordFormStateCopyWithImpl<
$Res,
$Val extends ChangePasswordFormState
>
implements $ChangePasswordFormStateCopyWith<$Res> {
_$ChangePasswordFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? newPassword = null,
Object? currentPassword = null,
Object? failureOrChangePasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
newPassword: null == newPassword
? _value.newPassword
: newPassword // ignore: cast_nullable_to_non_nullable
as String,
currentPassword: null == currentPassword
? _value.currentPassword
: currentPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrChangePasswordOption: null == failureOrChangePasswordOption
? _value.failureOrChangePasswordOption
: failureOrChangePasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, Unit>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$ChangePasswordFormStateImplCopyWith<$Res>
implements $ChangePasswordFormStateCopyWith<$Res> {
factory _$$ChangePasswordFormStateImplCopyWith(
_$ChangePasswordFormStateImpl value,
$Res Function(_$ChangePasswordFormStateImpl) then,
) = __$$ChangePasswordFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String newPassword,
String currentPassword,
Option<Either<UserFailure, Unit>> failureOrChangePasswordOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$ChangePasswordFormStateImplCopyWithImpl<$Res>
extends
_$ChangePasswordFormStateCopyWithImpl<
$Res,
_$ChangePasswordFormStateImpl
>
implements _$$ChangePasswordFormStateImplCopyWith<$Res> {
__$$ChangePasswordFormStateImplCopyWithImpl(
_$ChangePasswordFormStateImpl _value,
$Res Function(_$ChangePasswordFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? newPassword = null,
Object? currentPassword = null,
Object? failureOrChangePasswordOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$ChangePasswordFormStateImpl(
newPassword: null == newPassword
? _value.newPassword
: newPassword // ignore: cast_nullable_to_non_nullable
as String,
currentPassword: null == currentPassword
? _value.currentPassword
: currentPassword // ignore: cast_nullable_to_non_nullable
as String,
failureOrChangePasswordOption: null == failureOrChangePasswordOption
? _value.failureOrChangePasswordOption
: failureOrChangePasswordOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, Unit>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$ChangePasswordFormStateImpl implements _ChangePasswordFormState {
const _$ChangePasswordFormStateImpl({
required this.newPassword,
required this.currentPassword,
required this.failureOrChangePasswordOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String newPassword;
@override
final String currentPassword;
@override
final Option<Either<UserFailure, Unit>> failureOrChangePasswordOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'ChangePasswordFormState(newPassword: $newPassword, currentPassword: $currentPassword, failureOrChangePasswordOption: $failureOrChangePasswordOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$ChangePasswordFormStateImpl &&
(identical(other.newPassword, newPassword) ||
other.newPassword == newPassword) &&
(identical(other.currentPassword, currentPassword) ||
other.currentPassword == currentPassword) &&
(identical(
other.failureOrChangePasswordOption,
failureOrChangePasswordOption,
) ||
other.failureOrChangePasswordOption ==
failureOrChangePasswordOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
newPassword,
currentPassword,
failureOrChangePasswordOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ChangePasswordFormStateImplCopyWith<_$ChangePasswordFormStateImpl>
get copyWith =>
__$$ChangePasswordFormStateImplCopyWithImpl<
_$ChangePasswordFormStateImpl
>(this, _$identity);
}
abstract class _ChangePasswordFormState implements ChangePasswordFormState {
const factory _ChangePasswordFormState({
required final String newPassword,
required final String currentPassword,
required final Option<Either<UserFailure, Unit>>
failureOrChangePasswordOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$ChangePasswordFormStateImpl;
@override
String get newPassword;
@override
String get currentPassword;
@override
Option<Either<UserFailure, Unit>> get failureOrChangePasswordOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of ChangePasswordFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ChangePasswordFormStateImplCopyWith<_$ChangePasswordFormStateImpl>
get copyWith => throw _privateConstructorUsedError;
}
@@ -0,0 +1,11 @@
part of 'change_password_form_bloc.dart';
@freezed
class ChangePasswordFormEvent with _$ChangePasswordFormEvent {
const factory ChangePasswordFormEvent.newPasswordChanged(String newPassword) =
_NewPasswordChanged;
const factory ChangePasswordFormEvent.currentPasswordChanged(
String currentPassword,
) = _CurrentPasswordChanged;
const factory ChangePasswordFormEvent.submitted() = _Submitted;
}
@@ -0,0 +1,18 @@
part of 'change_password_form_bloc.dart';
@freezed
class ChangePasswordFormState with _$ChangePasswordFormState {
const factory ChangePasswordFormState({
required String newPassword,
required String currentPassword,
required Option<Either<UserFailure, Unit>> failureOrChangePasswordOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _ChangePasswordFormState;
factory ChangePasswordFormState.initial() => ChangePasswordFormState(
currentPassword: '',
newPassword: '',
failureOrChangePasswordOption: none(),
);
}
@@ -0,0 +1,46 @@
import 'package:dartz/dartz.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:injectable/injectable.dart';
import '../../../domain/user/user.dart';
part 'user_edit_form_event.dart';
part 'user_edit_form_state.dart';
part 'user_edit_form_bloc.freezed.dart';
@injectable
class UserEditFormBloc extends Bloc<UserEditFormEvent, UserEditFormState> {
final IUserRepository _repository;
UserEditFormBloc(this._repository) : super(UserEditFormState.initial()) {
on<UserEditFormEvent>(_onUserEditFormEvent);
}
Future<void> _onUserEditFormEvent(
UserEditFormEvent event,
Emitter<UserEditFormState> emit,
) {
return event.map(
nameChanged: (e) async {
emit(state.copyWith(name: e.name, failureOrUserOption: none()));
},
submitted: (e) async {
Either<UserFailure, User>? failureOrUser;
emit(state.copyWith(isSubmitting: true, failureOrUserOption: none()));
final nameValid = state.name.isNotEmpty;
if (nameValid) {
failureOrUser = await _repository.editUser(name: state.name);
emit(
state.copyWith(
isSubmitting: false,
failureOrUserOption: optionOf(failureOrUser),
),
);
}
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
},
);
}
}
@@ -0,0 +1,542 @@
// 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 'user_edit_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 _$UserEditFormEvent {
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function() submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function()? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function()? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_Submitted value) submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_Submitted value)? submitted,
}) => throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) => throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserEditFormEventCopyWith<$Res> {
factory $UserEditFormEventCopyWith(
UserEditFormEvent value,
$Res Function(UserEditFormEvent) then,
) = _$UserEditFormEventCopyWithImpl<$Res, UserEditFormEvent>;
}
/// @nodoc
class _$UserEditFormEventCopyWithImpl<$Res, $Val extends UserEditFormEvent>
implements $UserEditFormEventCopyWith<$Res> {
_$UserEditFormEventCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
abstract class _$$NameChangedImplCopyWith<$Res> {
factory _$$NameChangedImplCopyWith(
_$NameChangedImpl value,
$Res Function(_$NameChangedImpl) then,
) = __$$NameChangedImplCopyWithImpl<$Res>;
@useResult
$Res call({String name});
}
/// @nodoc
class __$$NameChangedImplCopyWithImpl<$Res>
extends _$UserEditFormEventCopyWithImpl<$Res, _$NameChangedImpl>
implements _$$NameChangedImplCopyWith<$Res> {
__$$NameChangedImplCopyWithImpl(
_$NameChangedImpl _value,
$Res Function(_$NameChangedImpl) _then,
) : super(_value, _then);
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({Object? name = null}) {
return _then(
_$NameChangedImpl(
null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
),
);
}
}
/// @nodoc
class _$NameChangedImpl implements _NameChanged {
const _$NameChangedImpl(this.name);
@override
final String name;
@override
String toString() {
return 'UserEditFormEvent.nameChanged(name: $name)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$NameChangedImpl &&
(identical(other.name, name) || other.name == name));
}
@override
int get hashCode => Object.hash(runtimeType, name);
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith =>
__$$NameChangedImplCopyWithImpl<_$NameChangedImpl>(this, _$identity);
@override
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function(String name) nameChanged,
required TResult Function() submitted,
}) {
return nameChanged(name);
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function()? submitted,
}) {
return nameChanged?.call(name);
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (nameChanged != null) {
return nameChanged(name);
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_Submitted value) submitted,
}) {
return nameChanged(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return nameChanged?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (nameChanged != null) {
return nameChanged(this);
}
return orElse();
}
}
abstract class _NameChanged implements UserEditFormEvent {
const factory _NameChanged(final String name) = _$NameChangedImpl;
String get name;
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$NameChangedImplCopyWith<_$NameChangedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class _$$SubmittedImplCopyWith<$Res> {
factory _$$SubmittedImplCopyWith(
_$SubmittedImpl value,
$Res Function(_$SubmittedImpl) then,
) = __$$SubmittedImplCopyWithImpl<$Res>;
}
/// @nodoc
class __$$SubmittedImplCopyWithImpl<$Res>
extends _$UserEditFormEventCopyWithImpl<$Res, _$SubmittedImpl>
implements _$$SubmittedImplCopyWith<$Res> {
__$$SubmittedImplCopyWithImpl(
_$SubmittedImpl _value,
$Res Function(_$SubmittedImpl) _then,
) : super(_value, _then);
/// Create a copy of UserEditFormEvent
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
class _$SubmittedImpl implements _Submitted {
const _$SubmittedImpl();
@override
String toString() {
return 'UserEditFormEvent.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(String name) nameChanged,
required TResult Function() submitted,
}) {
return submitted();
}
@override
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>({
TResult? Function(String name)? nameChanged,
TResult? Function()? submitted,
}) {
return submitted?.call();
}
@override
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String name)? nameChanged,
TResult Function()? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted();
}
return orElse();
}
@override
@optionalTypeArgs
TResult map<TResult extends Object?>({
required TResult Function(_NameChanged value) nameChanged,
required TResult Function(_Submitted value) submitted,
}) {
return submitted(this);
}
@override
@optionalTypeArgs
TResult? mapOrNull<TResult extends Object?>({
TResult? Function(_NameChanged value)? nameChanged,
TResult? Function(_Submitted value)? submitted,
}) {
return submitted?.call(this);
}
@override
@optionalTypeArgs
TResult maybeMap<TResult extends Object?>({
TResult Function(_NameChanged value)? nameChanged,
TResult Function(_Submitted value)? submitted,
required TResult orElse(),
}) {
if (submitted != null) {
return submitted(this);
}
return orElse();
}
}
abstract class _Submitted implements UserEditFormEvent {
const factory _Submitted() = _$SubmittedImpl;
}
/// @nodoc
mixin _$UserEditFormState {
String get name => throw _privateConstructorUsedError;
Option<Either<UserFailure, User>> get failureOrUserOption =>
throw _privateConstructorUsedError;
bool get isSubmitting => throw _privateConstructorUsedError;
bool get showErrorMessages => throw _privateConstructorUsedError;
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$UserEditFormStateCopyWith<UserEditFormState> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $UserEditFormStateCopyWith<$Res> {
factory $UserEditFormStateCopyWith(
UserEditFormState value,
$Res Function(UserEditFormState) then,
) = _$UserEditFormStateCopyWithImpl<$Res, UserEditFormState>;
@useResult
$Res call({
String name,
Option<Either<UserFailure, User>> failureOrUserOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class _$UserEditFormStateCopyWithImpl<$Res, $Val extends UserEditFormState>
implements $UserEditFormStateCopyWith<$Res> {
_$UserEditFormStateCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? failureOrUserOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_value.copyWith(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
failureOrUserOption: null == failureOrUserOption
? _value.failureOrUserOption
: failureOrUserOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, User>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
)
as $Val,
);
}
}
/// @nodoc
abstract class _$$UserEditFormStateImplCopyWith<$Res>
implements $UserEditFormStateCopyWith<$Res> {
factory _$$UserEditFormStateImplCopyWith(
_$UserEditFormStateImpl value,
$Res Function(_$UserEditFormStateImpl) then,
) = __$$UserEditFormStateImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({
String name,
Option<Either<UserFailure, User>> failureOrUserOption,
bool isSubmitting,
bool showErrorMessages,
});
}
/// @nodoc
class __$$UserEditFormStateImplCopyWithImpl<$Res>
extends _$UserEditFormStateCopyWithImpl<$Res, _$UserEditFormStateImpl>
implements _$$UserEditFormStateImplCopyWith<$Res> {
__$$UserEditFormStateImplCopyWithImpl(
_$UserEditFormStateImpl _value,
$Res Function(_$UserEditFormStateImpl) _then,
) : super(_value, _then);
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? name = null,
Object? failureOrUserOption = null,
Object? isSubmitting = null,
Object? showErrorMessages = null,
}) {
return _then(
_$UserEditFormStateImpl(
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
failureOrUserOption: null == failureOrUserOption
? _value.failureOrUserOption
: failureOrUserOption // ignore: cast_nullable_to_non_nullable
as Option<Either<UserFailure, User>>,
isSubmitting: null == isSubmitting
? _value.isSubmitting
: isSubmitting // ignore: cast_nullable_to_non_nullable
as bool,
showErrorMessages: null == showErrorMessages
? _value.showErrorMessages
: showErrorMessages // ignore: cast_nullable_to_non_nullable
as bool,
),
);
}
}
/// @nodoc
class _$UserEditFormStateImpl implements _UserEditFormState {
const _$UserEditFormStateImpl({
required this.name,
required this.failureOrUserOption,
this.isSubmitting = false,
this.showErrorMessages = false,
});
@override
final String name;
@override
final Option<Either<UserFailure, User>> failureOrUserOption;
@override
@JsonKey()
final bool isSubmitting;
@override
@JsonKey()
final bool showErrorMessages;
@override
String toString() {
return 'UserEditFormState(name: $name, failureOrUserOption: $failureOrUserOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$UserEditFormStateImpl &&
(identical(other.name, name) || other.name == name) &&
(identical(other.failureOrUserOption, failureOrUserOption) ||
other.failureOrUserOption == failureOrUserOption) &&
(identical(other.isSubmitting, isSubmitting) ||
other.isSubmitting == isSubmitting) &&
(identical(other.showErrorMessages, showErrorMessages) ||
other.showErrorMessages == showErrorMessages));
}
@override
int get hashCode => Object.hash(
runtimeType,
name,
failureOrUserOption,
isSubmitting,
showErrorMessages,
);
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$UserEditFormStateImplCopyWith<_$UserEditFormStateImpl> get copyWith =>
__$$UserEditFormStateImplCopyWithImpl<_$UserEditFormStateImpl>(
this,
_$identity,
);
}
abstract class _UserEditFormState implements UserEditFormState {
const factory _UserEditFormState({
required final String name,
required final Option<Either<UserFailure, User>> failureOrUserOption,
final bool isSubmitting,
final bool showErrorMessages,
}) = _$UserEditFormStateImpl;
@override
String get name;
@override
Option<Either<UserFailure, User>> get failureOrUserOption;
@override
bool get isSubmitting;
@override
bool get showErrorMessages;
/// Create a copy of UserEditFormState
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$UserEditFormStateImplCopyWith<_$UserEditFormStateImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -0,0 +1,7 @@
part of 'user_edit_form_bloc.dart';
@freezed
class UserEditFormEvent with _$UserEditFormEvent {
const factory UserEditFormEvent.nameChanged(String name) = _NameChanged;
const factory UserEditFormEvent.submitted() = _Submitted;
}
@@ -0,0 +1,14 @@
part of 'user_edit_form_bloc.dart';
@freezed
class UserEditFormState with _$UserEditFormState {
const factory UserEditFormState({
required String name,
required Option<Either<UserFailure, User>> failureOrUserOption,
@Default(false) bool isSubmitting,
@Default(false) bool showErrorMessages,
}) = _UserEditFormState;
factory UserEditFormState.initial() =>
UserEditFormState(name: '', failureOrUserOption: none());
}
+1 -1
View File
@@ -1,3 +1,3 @@
class AppConstant {
static const String appName = "Apskel Owner";
static const String appName = "Enaklo Owner";
}
@@ -2,4 +2,5 @@ class LocalStorageKey {
static const String lang = 'lang';
static const String token = 'token';
static const String user = 'user';
static const String selectedOutletId = 'selected_outlet_id';
}
+8
View File
@@ -0,0 +1,8 @@
import 'package:firebase_core/firebase_core.dart';
import 'package:injectable/injectable.dart';
@module
abstract class FirebaseDi {
@preResolve
Future<FirebaseApp> get firebaseApp => Firebase.initializeApp();
}
+5
View File
@@ -30,4 +30,9 @@ extension DateTimeIndonesia on DateTime {
String get toHourMinute {
return DateFormat('HH:mm', 'id_ID').format(this);
}
/// Format jam + detik: 14:30:05
String get toHourMinuteSecond {
return DateFormat('HH:mm:ss', 'id_ID').format(this);
}
}
+5 -6
View File
@@ -2,9 +2,9 @@ part of 'theme.dart';
class AppColor {
// Primary Colors
static const Color primary = Color(0xFF36175e);
static const Color primaryLight = Color(0xFF5a2d85);
static const Color primaryDark = Color(0xFF1e0d35);
static const Color primary = Color.fromARGB(255, 196, 2, 2); // #d90000
static const Color primaryLight = Color(0xFFFF4D4D); // merah terang
static const Color primaryDark = Color(0xFF990000); // merah gelap
// Secondary Colors
static const Color secondary = Color(0xFF4CAF50);
@@ -41,10 +41,9 @@ class AppColor {
// Gradient Colors
static const List<Color> primaryGradient = [
Color(0xFF36175e),
Color(0xFF5a2d85),
Color(0xFFD90000), // primary
Color(0xFF990000), // dark red
];
static const List<Color> successGradient = [
Color(0xFF4CAF50),
Color(0xFF81C784),
+6
View File
@@ -27,4 +27,10 @@ class ApiPath {
// Order
static const String order = '/api/v1/orders';
// Outlet
static const String outlet = '/api/v1/outlets';
// User
static const String user = '/api/v1/users';
}
+82
View File
@@ -0,0 +1,82 @@
import 'dart:io';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:injectable/injectable.dart';
import 'package:package_info_plus/package_info_plus.dart';
class DeviceInfo {
final String deviceId;
final String deviceName;
final String deviceType;
final String platform;
final String osVersion;
final String appVersion;
const DeviceInfo({
required this.deviceId,
required this.deviceName,
required this.deviceType,
required this.platform,
required this.osVersion,
required this.appVersion,
});
Map<String, dynamic> toJson() => {
'device_id': deviceId,
'device_name': deviceName,
'device_type': deviceType,
'platform': platform,
'os_version': osVersion,
'app_version': appVersion,
};
}
@lazySingleton
class DeviceInfoService {
final DeviceInfoPlugin _deviceInfo = DeviceInfoPlugin();
Future<DeviceInfo> getDeviceInfo() async {
final packageInfo = await PackageInfo.fromPlatform();
final appVersion = packageInfo.version;
if (Platform.isAndroid) {
final info = await _deviceInfo.androidInfo;
return DeviceInfo(
deviceId: info.id,
deviceName: '${info.manufacturer} ${info.model}',
deviceType: _resolveDeviceType(info.model),
platform: 'android',
osVersion: 'Android ${info.version.release}',
appVersion: appVersion,
);
} else if (Platform.isIOS) {
final info = await _deviceInfo.iosInfo;
return DeviceInfo(
deviceId: info.identifierForVendor ?? '',
deviceName: info.name,
deviceType: _resolveDeviceType(info.model),
platform: 'ios',
osVersion: '${info.systemName} ${info.systemVersion}',
appVersion: appVersion,
);
}
// Fallback (web/desktop — tidak dipakai tapi aman)
return DeviceInfo(
deviceId: 'unknown',
deviceName: 'unknown',
deviceType: 'desktop',
platform: 'web',
osVersion: 'unknown',
appVersion: appVersion,
);
}
/// Tentukan device_type berdasarkan model name.
/// Nilai valid: 'mobile' | 'tablet' | 'desktop'
String _resolveDeviceType(String model) {
final lower = model.toLowerCase();
if (lower.contains('ipad') || lower.contains('tablet')) return 'tablet';
return 'mobile';
}
}
+200
View File
@@ -0,0 +1,200 @@
import 'dart:convert';
import 'dart:io';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:injectable/injectable.dart';
/// Background message handler — must be a top-level function.
/// Firebase must be initialized here for background isolate.
@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
debugPrint('[FCM] Background message: ${message.messageId}');
// Show local notification for data-only messages in background
await _showBackgroundNotification(message);
}
/// Standalone local notifications plugin for background isolate use.
final _backgroundLocalNotifications = FlutterLocalNotificationsPlugin();
Future<void> _showBackgroundNotification(RemoteMessage message) async {
const androidInit = AndroidInitializationSettings('@drawable/ic_notification');
await _backgroundLocalNotifications.initialize(
const InitializationSettings(android: androidInit),
);
final notification = message.notification;
// Only show manually for data-only messages (FCM auto-shows notification messages)
if (notification != null) return;
final title = message.data['title'] as String?;
final body = message.data['body'] as String?;
if (title == null && body == null) return;
await _backgroundLocalNotifications.show(
message.hashCode,
title,
body,
const NotificationDetails(
android: AndroidNotificationDetails(
'high_importance_channel',
'High Importance Notifications',
importance: Importance.high,
priority: Priority.high,
icon: '@drawable/ic_notification',
),
),
payload: jsonEncode(message.data),
);
}
@lazySingleton
class FcmService {
final FirebaseMessaging _messaging = FirebaseMessaging.instance;
final FlutterLocalNotificationsPlugin _localNotifications =
FlutterLocalNotificationsPlugin();
static const _androidChannel = AndroidNotificationChannel(
'high_importance_channel',
'High Importance Notifications',
description: 'This channel is used for important notifications.',
importance: Importance.max, // max agar banner (heads-up) muncul
playSound: true,
enableVibration: true,
enableLights: true,
);
/// Call this once during app startup (after Firebase.initializeApp).
Future<void> initialize({
void Function(RemoteMessage message)? onMessageTap,
}) async {
// 1. Request permission (iOS + Android 13+)
await _requestPermission();
// 2. Setup local notifications (needed to show heads-up on Android)
await _setupLocalNotifications();
// 3. Register background handler
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
// 4. Foreground message handler
FirebaseMessaging.onMessage.listen((message) {
debugPrint('[FCM] Foreground message: ${message.messageId}');
_showLocalNotification(message);
});
// 5. App opened from notification (background → foreground)
FirebaseMessaging.onMessageOpenedApp.listen((message) {
debugPrint('[FCM] Notification tapped (background): ${message.messageId}');
onMessageTap?.call(message);
});
// 6. App launched from terminated state via notification
final initialMessage = await _messaging.getInitialMessage();
if (initialMessage != null) {
debugPrint('[FCM] App launched from notification: ${initialMessage.messageId}');
onMessageTap?.call(initialMessage);
}
// 7. Print FCM token for debugging
final token = await getToken();
debugPrint('[FCM] Token: $token');
}
Future<void> _requestPermission() async {
final settings = await _messaging.requestPermission(
alert: true,
badge: true,
sound: true,
);
debugPrint('[FCM] Permission status: ${settings.authorizationStatus}');
}
Future<void> _setupLocalNotifications() async {
// Android init
const androidInit = AndroidInitializationSettings('@mipmap/launcher_icon');
// iOS init
const iosInit = DarwinInitializationSettings(
requestAlertPermission: false,
requestBadgePermission: false,
requestSoundPermission: false,
);
const initSettings = InitializationSettings(
android: androidInit,
iOS: iosInit,
);
await _localNotifications.initialize(
initSettings,
onDidReceiveNotificationResponse: (details) {
debugPrint('[FCM] Local notification tapped: ${details.payload}');
},
);
// Create Android notification channel
if (Platform.isAndroid) {
await _localNotifications
.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()
?.createNotificationChannel(_androidChannel);
}
// iOS: show notification even when app is in foreground
await _messaging.setForegroundNotificationPresentationOptions(
alert: true,
badge: true,
sound: true,
);
}
void _showLocalNotification(RemoteMessage message) {
final notification = message.notification;
if (notification == null) return;
_localNotifications.show(
notification.hashCode,
notification.title,
notification.body,
NotificationDetails(
android: AndroidNotificationDetails(
_androidChannel.id,
_androidChannel.name,
channelDescription: _androidChannel.description,
icon: '@drawable/ic_notification',
importance: Importance.max,
priority: Priority.high,
playSound: true,
enableVibration: true,
// Heads-up notification (banner)
fullScreenIntent: false,
),
iOS: const DarwinNotificationDetails(
presentAlert: true,
presentBadge: true,
presentSound: true,
),
),
payload: jsonEncode(message.data),
);
}
/// Returns the FCM registration token for this device.
Future<String?> getToken() => _messaging.getToken();
/// Subscribe to a topic (e.g. 'all', 'promo').
Future<void> subscribeToTopic(String topic) =>
_messaging.subscribeToTopic(topic);
/// Unsubscribe from a topic.
Future<void> unsubscribeFromTopic(String topic) =>
_messaging.unsubscribeFromTopic(topic);
/// Listen for token refresh.
Stream<String> get onTokenRefresh => _messaging.onTokenRefresh;
}

Some files were not shown because too many files have changed in this diff Show More