Compare commits
No commits in common. "dev" and "main" have entirely different histories.
@ -1,20 +1,28 @@
|
|||||||
|
# This file configures the analyzer, which statically analyzes Dart code to
|
||||||
|
# check for errors, warnings, and lints.
|
||||||
|
#
|
||||||
|
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
|
||||||
|
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
|
||||||
|
# invoked from the command line by running `flutter analyze`.
|
||||||
|
|
||||||
|
# The following line activates a set of recommended lints for Flutter apps,
|
||||||
|
# packages, and plugins designed to encourage good coding practices.
|
||||||
include: package:flutter_lints/flutter.yaml
|
include: package:flutter_lints/flutter.yaml
|
||||||
|
|
||||||
linter:
|
linter:
|
||||||
|
# The lint rules applied to this project can be customized in the
|
||||||
|
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
|
||||||
|
# included above or to enable additional rules. A list of all available lints
|
||||||
|
# and their documentation is published at https://dart.dev/lints.
|
||||||
|
#
|
||||||
|
# Instead of disabling a lint rule for the entire project in the
|
||||||
|
# section below, it can also be suppressed for a single line of code
|
||||||
|
# or a specific dart file by using the `// ignore: name_of_lint` and
|
||||||
|
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
|
||||||
|
# producing the lint.
|
||||||
rules:
|
rules:
|
||||||
sort_pub_dependencies: false
|
# avoid_print: false # Uncomment to disable the `avoid_print` rule
|
||||||
prefer_relative_imports: true
|
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
|
||||||
|
|
||||||
analyzer:
|
# Additional information about this file can be found at
|
||||||
errors:
|
# https://dart.dev/guides/language/analysis-options
|
||||||
missing_required_param: error
|
|
||||||
missing_return: error
|
|
||||||
must_be_immutable: error
|
|
||||||
sort_unnamed_constructors_first: ignore
|
|
||||||
invalid_annotation_target: ignore
|
|
||||||
use_build_context_synchronously: ignore
|
|
||||||
deprecated_member_use: ignore
|
|
||||||
exclude:
|
|
||||||
- test/generated/**
|
|
||||||
- "**/**.g.dart"
|
|
||||||
- "**/**.freezed.dart"
|
|
||||||
|
|||||||
@ -3,11 +3,10 @@ plugins {
|
|||||||
id("kotlin-android")
|
id("kotlin-android")
|
||||||
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
|
||||||
id("dev.flutter.flutter-gradle-plugin")
|
id("dev.flutter.flutter-gradle-plugin")
|
||||||
id("com.google.gms.google-services")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.apskel.pos"
|
namespace = "com.example.apskel_pos_flutter_v2"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = flutter.ndkVersion
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId = "com.apskel.pos"
|
applicationId = "com.example.apskel_pos_flutter_v2"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
minSdk = flutter.minSdkVersion
|
minSdk = flutter.minSdkVersion
|
||||||
@ -43,10 +42,3 @@ android {
|
|||||||
flutter {
|
flutter {
|
||||||
source = "../.."
|
source = "../.."
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
|
||||||
// Import the Firebase BoM
|
|
||||||
implementation(platform("com.google.firebase:firebase-bom:34.4.0"))
|
|
||||||
|
|
||||||
implementation("com.google.firebase:firebase-analytics")
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"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: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"
|
|
||||||
}
|
|
||||||
@ -1,19 +1,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
|
||||||
<!-- Izin khusus untuk akses foto (media images) di Android 33 ke atas -->
|
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
|
||||||
<application
|
<application
|
||||||
android:label="Apskel POS"
|
android:label="apskel_pos_flutter_v2"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/launcher_icon">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package com.apskel.pos
|
package com.example.apskel_pos_flutter_v2
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 19 KiB |
@ -20,7 +20,6 @@ plugins {
|
|||||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||||
id("com.android.application") version "8.7.3" apply false
|
id("com.android.application") version "8.7.3" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
|
id("org.jetbrains.kotlin.android") version "2.1.0" apply false
|
||||||
id("com.google.gms.google-services") version "4.4.4" apply false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 79 KiB |
|
Before Width: | Height: | Size: 125 KiB |
@ -1,2 +1 @@
|
|||||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
|
||||||
#include "Generated.xcconfig"
|
#include "Generated.xcconfig"
|
||||||
|
|||||||
@ -1,2 +1 @@
|
|||||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
|
||||||
#include "Generated.xcconfig"
|
#include "Generated.xcconfig"
|
||||||
|
|||||||
43
ios/Podfile
@ -1,43 +0,0 @@
|
|||||||
# Uncomment this line to define a global platform for your project
|
|
||||||
# platform :ios, '13.0'
|
|
||||||
|
|
||||||
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
|
|
||||||
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
|
|
||||||
|
|
||||||
project 'Runner', {
|
|
||||||
'Debug' => :debug,
|
|
||||||
'Profile' => :release,
|
|
||||||
'Release' => :release,
|
|
||||||
}
|
|
||||||
|
|
||||||
def flutter_root
|
|
||||||
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
|
|
||||||
unless File.exist?(generated_xcode_build_settings_path)
|
|
||||||
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
|
|
||||||
end
|
|
||||||
|
|
||||||
File.foreach(generated_xcode_build_settings_path) do |line|
|
|
||||||
matches = line.match(/FLUTTER_ROOT\=(.*)/)
|
|
||||||
return matches[1].strip if matches
|
|
||||||
end
|
|
||||||
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
|
|
||||||
end
|
|
||||||
|
|
||||||
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
|
|
||||||
|
|
||||||
flutter_ios_podfile_setup
|
|
||||||
|
|
||||||
target 'Runner' do
|
|
||||||
use_frameworks!
|
|
||||||
|
|
||||||
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
|
|
||||||
target 'RunnerTests' do
|
|
||||||
inherit! :search_paths
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
post_install do |installer|
|
|
||||||
installer.pods_project.targets.each do |target|
|
|
||||||
flutter_additional_ios_build_settings(target)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -427,7 +427,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
@ -484,7 +484,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
CLANG_ANALYZER_NONNULL = YES;
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||||
CLANG_CXX_LIBRARY = "libc++";
|
CLANG_CXX_LIBRARY = "libc++";
|
||||||
|
|||||||
@ -1 +1,122 @@
|
|||||||
{"images":[{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"20x20","idiom":"iphone","filename":"Icon-App-20x20@3x.png","scale":"3x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"29x29","idiom":"iphone","filename":"Icon-App-29x29@3x.png","scale":"3x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"40x40","idiom":"iphone","filename":"Icon-App-40x40@3x.png","scale":"3x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@1x.png","scale":"1x"},{"size":"57x57","idiom":"iphone","filename":"Icon-App-57x57@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@2x.png","scale":"2x"},{"size":"60x60","idiom":"iphone","filename":"Icon-App-60x60@3x.png","scale":"3x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@1x.png","scale":"1x"},{"size":"20x20","idiom":"ipad","filename":"Icon-App-20x20@2x.png","scale":"2x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@1x.png","scale":"1x"},{"size":"29x29","idiom":"ipad","filename":"Icon-App-29x29@2x.png","scale":"2x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@1x.png","scale":"1x"},{"size":"40x40","idiom":"ipad","filename":"Icon-App-40x40@2x.png","scale":"2x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@1x.png","scale":"1x"},{"size":"50x50","idiom":"ipad","filename":"Icon-App-50x50@2x.png","scale":"2x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@1x.png","scale":"1x"},{"size":"72x72","idiom":"ipad","filename":"Icon-App-72x72@2x.png","scale":"2x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@1x.png","scale":"1x"},{"size":"76x76","idiom":"ipad","filename":"Icon-App-76x76@2x.png","scale":"2x"},{"size":"83.5x83.5","idiom":"ipad","filename":"Icon-App-83.5x83.5@2x.png","scale":"2x"},{"size":"1024x1024","idiom":"ios-marketing","filename":"Icon-App-1024x1024@1x.png","scale":"1x"}],"info":{"version":1,"author":"xcode"}}
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-20x20@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-29x29@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-40x40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-40x40@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-60x60@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "60x60",
|
||||||
|
"idiom" : "iphone",
|
||||||
|
"filename" : "Icon-App-60x60@3x.png",
|
||||||
|
"scale" : "3x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-20x20@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "20x20",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-20x20@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-29x29@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "29x29",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-29x29@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-40x40@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "40x40",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-40x40@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-76x76@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "76x76",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-76x76@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "83.5x83.5",
|
||||||
|
"idiom" : "ipad",
|
||||||
|
"filename" : "Icon-App-83.5x83.5@2x.png",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"size" : "1024x1024",
|
||||||
|
"idiom" : "ios-marketing",
|
||||||
|
"filename" : "Icon-App-1024x1024@1x.png",
|
||||||
|
"scale" : "1x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 150 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 678 B After Width: | Height: | Size: 295 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 450 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 282 B |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 462 B |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 704 B |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 406 B |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 586 B |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 862 B |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 9.1 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 862 B |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 762 B |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 1.4 KiB |
@ -1,15 +0,0 @@
|
|||||||
# Generate: dart run flutter_launcher_icons -f launcher_icon.yaml
|
|
||||||
|
|
||||||
flutter_launcher_icons:
|
|
||||||
android: "launcher_icon"
|
|
||||||
ios: true
|
|
||||||
image_path: "assets/images/logo.png"
|
|
||||||
remove_alpha_ios: true
|
|
||||||
min_sdk_android: 21 # android min sdk min:16, default 21
|
|
||||||
web:
|
|
||||||
generate: true
|
|
||||||
image_path: "assets/images/logo.png"
|
|
||||||
windows:
|
|
||||||
generate: true
|
|
||||||
image_path: "assets/images/logo.png"
|
|
||||||
icon_size: 48
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/analytic/analytic.dart';
|
|
||||||
|
|
||||||
part 'category_analytic_loader_event.dart';
|
|
||||||
part 'category_analytic_loader_state.dart';
|
|
||||||
part 'category_analytic_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class CategoryAnalyticLoaderBloc
|
|
||||||
extends Bloc<CategoryAnalyticLoaderEvent, CategoryAnalyticLoaderState> {
|
|
||||||
final IAnalyticRepository _analyticRepository;
|
|
||||||
CategoryAnalyticLoaderBloc(this._analyticRepository)
|
|
||||||
: super(CategoryAnalyticLoaderState.initial()) {
|
|
||||||
on<CategoryAnalyticLoaderEvent>(_onCategoryAnalyticLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onCategoryAnalyticLoaderEvent(
|
|
||||||
CategoryAnalyticLoaderEvent event,
|
|
||||||
Emitter<CategoryAnalyticLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
||||||
|
|
||||||
final result = await _analyticRepository.getCategories(
|
|
||||||
dateFrom: e.startDate,
|
|
||||||
dateTo: e.endDate,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(categories) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(isFetching: false, categoryAnalytic: categories),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,476 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'category_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$CategoryAnalyticLoaderEvent {
|
|
||||||
DateTime get startDate => throw _privateConstructorUsedError;
|
|
||||||
DateTime get endDate => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$CategoryAnalyticLoaderEventCopyWith<CategoryAnalyticLoaderEvent>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $CategoryAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory $CategoryAnalyticLoaderEventCopyWith(
|
|
||||||
CategoryAnalyticLoaderEvent value,
|
|
||||||
$Res Function(CategoryAnalyticLoaderEvent) then,
|
|
||||||
) =
|
|
||||||
_$CategoryAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
CategoryAnalyticLoaderEvent
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$CategoryAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends CategoryAnalyticLoaderEvent
|
|
||||||
>
|
|
||||||
implements $CategoryAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
_$CategoryAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$FetchedImplCopyWith<$Res>
|
|
||||||
implements $CategoryAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$FetchedImplCopyWith(
|
|
||||||
_$FetchedImpl value,
|
|
||||||
$Res Function(_$FetchedImpl) then,
|
|
||||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$FetchedImplCopyWithImpl<$Res>
|
|
||||||
extends _$CategoryAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_$FetchedImpl(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$FetchedImpl implements _Fetched {
|
|
||||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DateTime startDate;
|
|
||||||
@override
|
|
||||||
final DateTime endDate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'CategoryAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$FetchedImpl &&
|
|
||||||
(identical(other.startDate, startDate) ||
|
|
||||||
other.startDate == startDate) &&
|
|
||||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements CategoryAnalyticLoaderEvent {
|
|
||||||
const factory _Fetched({
|
|
||||||
required final DateTime startDate,
|
|
||||||
required final DateTime endDate,
|
|
||||||
}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DateTime get startDate;
|
|
||||||
@override
|
|
||||||
DateTime get endDate;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$CategoryAnalyticLoaderState {
|
|
||||||
CategoryAnalytic get categoryAnalytic => throw _privateConstructorUsedError;
|
|
||||||
Option<AnalyticFailure> get failureOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$CategoryAnalyticLoaderStateCopyWith<CategoryAnalyticLoaderState>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $CategoryAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory $CategoryAnalyticLoaderStateCopyWith(
|
|
||||||
CategoryAnalyticLoaderState value,
|
|
||||||
$Res Function(CategoryAnalyticLoaderState) then,
|
|
||||||
) =
|
|
||||||
_$CategoryAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
CategoryAnalyticLoaderState
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
CategoryAnalytic categoryAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$CategoryAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends CategoryAnalyticLoaderState
|
|
||||||
>
|
|
||||||
implements $CategoryAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
_$CategoryAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? categoryAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
categoryAnalytic: null == categoryAnalytic
|
|
||||||
? _value.categoryAnalytic
|
|
||||||
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as CategoryAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic {
|
|
||||||
return $CategoryAnalyticCopyWith<$Res>(_value.categoryAnalytic, (value) {
|
|
||||||
return _then(_value.copyWith(categoryAnalytic: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$CategoryAnalyticLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $CategoryAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$CategoryAnalyticLoaderStateImplCopyWith(
|
|
||||||
_$CategoryAnalyticLoaderStateImpl value,
|
|
||||||
$Res Function(_$CategoryAnalyticLoaderStateImpl) then,
|
|
||||||
) = __$$CategoryAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
CategoryAnalytic categoryAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$CategoryAnalyticCopyWith<$Res> get categoryAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$CategoryAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends
|
|
||||||
_$CategoryAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
_$CategoryAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
implements _$$CategoryAnalyticLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$CategoryAnalyticLoaderStateImplCopyWithImpl(
|
|
||||||
_$CategoryAnalyticLoaderStateImpl _value,
|
|
||||||
$Res Function(_$CategoryAnalyticLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? categoryAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$CategoryAnalyticLoaderStateImpl(
|
|
||||||
categoryAnalytic: null == categoryAnalytic
|
|
||||||
? _value.categoryAnalytic
|
|
||||||
: categoryAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as CategoryAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$CategoryAnalyticLoaderStateImpl
|
|
||||||
implements _CategoryAnalyticLoaderState {
|
|
||||||
_$CategoryAnalyticLoaderStateImpl({
|
|
||||||
required this.categoryAnalytic,
|
|
||||||
required this.failureOption,
|
|
||||||
this.isFetching = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final CategoryAnalytic categoryAnalytic;
|
|
||||||
@override
|
|
||||||
final Option<AnalyticFailure> failureOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'CategoryAnalyticLoaderState(categoryAnalytic: $categoryAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$CategoryAnalyticLoaderStateImpl &&
|
|
||||||
(identical(other.categoryAnalytic, categoryAnalytic) ||
|
|
||||||
other.categoryAnalytic == categoryAnalytic) &&
|
|
||||||
(identical(other.failureOption, failureOption) ||
|
|
||||||
other.failureOption == failureOption) &&
|
|
||||||
(identical(other.isFetching, isFetching) ||
|
|
||||||
other.isFetching == isFetching));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
Object.hash(runtimeType, categoryAnalytic, failureOption, isFetching);
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$CategoryAnalyticLoaderStateImplCopyWith<_$CategoryAnalyticLoaderStateImpl>
|
|
||||||
get copyWith =>
|
|
||||||
__$$CategoryAnalyticLoaderStateImplCopyWithImpl<
|
|
||||||
_$CategoryAnalyticLoaderStateImpl
|
|
||||||
>(this, _$identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _CategoryAnalyticLoaderState
|
|
||||||
implements CategoryAnalyticLoaderState {
|
|
||||||
factory _CategoryAnalyticLoaderState({
|
|
||||||
required final CategoryAnalytic categoryAnalytic,
|
|
||||||
required final Option<AnalyticFailure> failureOption,
|
|
||||||
final bool isFetching,
|
|
||||||
}) = _$CategoryAnalyticLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
CategoryAnalytic get categoryAnalytic;
|
|
||||||
@override
|
|
||||||
Option<AnalyticFailure> get failureOption;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
|
|
||||||
/// Create a copy of CategoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$CategoryAnalyticLoaderStateImplCopyWith<_$CategoryAnalyticLoaderStateImpl>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'category_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CategoryAnalyticLoaderEvent with _$CategoryAnalyticLoaderEvent {
|
|
||||||
const factory CategoryAnalyticLoaderEvent.fetched({
|
|
||||||
required DateTime startDate,
|
|
||||||
required DateTime endDate,
|
|
||||||
}) = _Fetched;
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
part of 'category_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CategoryAnalyticLoaderState with _$CategoryAnalyticLoaderState {
|
|
||||||
factory CategoryAnalyticLoaderState({
|
|
||||||
required CategoryAnalytic categoryAnalytic,
|
|
||||||
required Option<AnalyticFailure> failureOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
}) = _CategoryAnalyticLoaderState;
|
|
||||||
|
|
||||||
factory CategoryAnalyticLoaderState.initial() => CategoryAnalyticLoaderState(
|
|
||||||
categoryAnalytic: CategoryAnalytic.empty(),
|
|
||||||
failureOption: none(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/analytic/analytic.dart';
|
|
||||||
|
|
||||||
part 'dashboard_analytic_loader_event.dart';
|
|
||||||
part 'dashboard_analytic_loader_state.dart';
|
|
||||||
part 'dashboard_analytic_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class DashboardAnalyticLoaderBloc
|
|
||||||
extends Bloc<DashboardAnalyticLoaderEvent, DashboardAnalyticLoaderState> {
|
|
||||||
final IAnalyticRepository _analyticRepository;
|
|
||||||
|
|
||||||
DashboardAnalyticLoaderBloc(this._analyticRepository)
|
|
||||||
: super(DashboardAnalyticLoaderState.initial()) {
|
|
||||||
on<DashboardAnalyticLoaderEvent>(_onDashboardAnalyticLoader);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onDashboardAnalyticLoader(
|
|
||||||
DashboardAnalyticLoaderEvent event,
|
|
||||||
Emitter<DashboardAnalyticLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
||||||
|
|
||||||
final result = await _analyticRepository.getDashboard(
|
|
||||||
dateFrom: e.startDate,
|
|
||||||
dateTo: e.endDate,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(dashboard) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(isFetching: false, dashboardAnalytic: dashboard),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,480 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'dashboard_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$DashboardAnalyticLoaderEvent {
|
|
||||||
DateTime get startDate => throw _privateConstructorUsedError;
|
|
||||||
DateTime get endDate => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$DashboardAnalyticLoaderEventCopyWith<DashboardAnalyticLoaderEvent>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $DashboardAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory $DashboardAnalyticLoaderEventCopyWith(
|
|
||||||
DashboardAnalyticLoaderEvent value,
|
|
||||||
$Res Function(DashboardAnalyticLoaderEvent) then,
|
|
||||||
) =
|
|
||||||
_$DashboardAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
DashboardAnalyticLoaderEvent
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$DashboardAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends DashboardAnalyticLoaderEvent
|
|
||||||
>
|
|
||||||
implements $DashboardAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
_$DashboardAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$FetchedImplCopyWith<$Res>
|
|
||||||
implements $DashboardAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$FetchedImplCopyWith(
|
|
||||||
_$FetchedImpl value,
|
|
||||||
$Res Function(_$FetchedImpl) then,
|
|
||||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$FetchedImplCopyWithImpl<$Res>
|
|
||||||
extends _$DashboardAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_$FetchedImpl(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$FetchedImpl implements _Fetched {
|
|
||||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DateTime startDate;
|
|
||||||
@override
|
|
||||||
final DateTime endDate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'DashboardAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$FetchedImpl &&
|
|
||||||
(identical(other.startDate, startDate) ||
|
|
||||||
other.startDate == startDate) &&
|
|
||||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements DashboardAnalyticLoaderEvent {
|
|
||||||
const factory _Fetched({
|
|
||||||
required final DateTime startDate,
|
|
||||||
required final DateTime endDate,
|
|
||||||
}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DateTime get startDate;
|
|
||||||
@override
|
|
||||||
DateTime get endDate;
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$DashboardAnalyticLoaderState {
|
|
||||||
DashboardAnalytic get dashboardAnalytic => throw _privateConstructorUsedError;
|
|
||||||
Option<AnalyticFailure> get failureOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$DashboardAnalyticLoaderStateCopyWith<DashboardAnalyticLoaderState>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $DashboardAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory $DashboardAnalyticLoaderStateCopyWith(
|
|
||||||
DashboardAnalyticLoaderState value,
|
|
||||||
$Res Function(DashboardAnalyticLoaderState) then,
|
|
||||||
) =
|
|
||||||
_$DashboardAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
DashboardAnalyticLoaderState
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
DashboardAnalytic dashboardAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$DashboardAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends DashboardAnalyticLoaderState
|
|
||||||
>
|
|
||||||
implements $DashboardAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
_$DashboardAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? dashboardAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
dashboardAnalytic: null == dashboardAnalytic
|
|
||||||
? _value.dashboardAnalytic
|
|
||||||
: dashboardAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DashboardAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic {
|
|
||||||
return $DashboardAnalyticCopyWith<$Res>(_value.dashboardAnalytic, (value) {
|
|
||||||
return _then(_value.copyWith(dashboardAnalytic: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$DashboardAnalyticLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $DashboardAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$DashboardAnalyticLoaderStateImplCopyWith(
|
|
||||||
_$DashboardAnalyticLoaderStateImpl value,
|
|
||||||
$Res Function(_$DashboardAnalyticLoaderStateImpl) then,
|
|
||||||
) = __$$DashboardAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
DashboardAnalytic dashboardAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$DashboardAnalyticCopyWith<$Res> get dashboardAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$DashboardAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends
|
|
||||||
_$DashboardAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
_$DashboardAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
implements _$$DashboardAnalyticLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$DashboardAnalyticLoaderStateImplCopyWithImpl(
|
|
||||||
_$DashboardAnalyticLoaderStateImpl _value,
|
|
||||||
$Res Function(_$DashboardAnalyticLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? dashboardAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$DashboardAnalyticLoaderStateImpl(
|
|
||||||
dashboardAnalytic: null == dashboardAnalytic
|
|
||||||
? _value.dashboardAnalytic
|
|
||||||
: dashboardAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DashboardAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$DashboardAnalyticLoaderStateImpl
|
|
||||||
implements _DashboardAnalyticLoaderState {
|
|
||||||
_$DashboardAnalyticLoaderStateImpl({
|
|
||||||
required this.dashboardAnalytic,
|
|
||||||
required this.failureOption,
|
|
||||||
this.isFetching = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DashboardAnalytic dashboardAnalytic;
|
|
||||||
@override
|
|
||||||
final Option<AnalyticFailure> failureOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'DashboardAnalyticLoaderState(dashboardAnalytic: $dashboardAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$DashboardAnalyticLoaderStateImpl &&
|
|
||||||
(identical(other.dashboardAnalytic, dashboardAnalytic) ||
|
|
||||||
other.dashboardAnalytic == dashboardAnalytic) &&
|
|
||||||
(identical(other.failureOption, failureOption) ||
|
|
||||||
other.failureOption == failureOption) &&
|
|
||||||
(identical(other.isFetching, isFetching) ||
|
|
||||||
other.isFetching == isFetching));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
Object.hash(runtimeType, dashboardAnalytic, failureOption, isFetching);
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$DashboardAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$DashboardAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith =>
|
|
||||||
__$$DashboardAnalyticLoaderStateImplCopyWithImpl<
|
|
||||||
_$DashboardAnalyticLoaderStateImpl
|
|
||||||
>(this, _$identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _DashboardAnalyticLoaderState
|
|
||||||
implements DashboardAnalyticLoaderState {
|
|
||||||
factory _DashboardAnalyticLoaderState({
|
|
||||||
required final DashboardAnalytic dashboardAnalytic,
|
|
||||||
required final Option<AnalyticFailure> failureOption,
|
|
||||||
final bool isFetching,
|
|
||||||
}) = _$DashboardAnalyticLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DashboardAnalytic get dashboardAnalytic;
|
|
||||||
@override
|
|
||||||
Option<AnalyticFailure> get failureOption;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
|
|
||||||
/// Create a copy of DashboardAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$DashboardAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$DashboardAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'dashboard_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class DashboardAnalyticLoaderEvent with _$DashboardAnalyticLoaderEvent {
|
|
||||||
const factory DashboardAnalyticLoaderEvent.fetched({
|
|
||||||
required DateTime startDate,
|
|
||||||
required DateTime endDate,
|
|
||||||
}) = _Fetched;
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
part of 'dashboard_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class DashboardAnalyticLoaderState with _$DashboardAnalyticLoaderState {
|
|
||||||
factory DashboardAnalyticLoaderState({
|
|
||||||
required DashboardAnalytic dashboardAnalytic,
|
|
||||||
required Option<AnalyticFailure> failureOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
}) = _DashboardAnalyticLoaderState;
|
|
||||||
|
|
||||||
factory DashboardAnalyticLoaderState.initial() =>
|
|
||||||
DashboardAnalyticLoaderState(
|
|
||||||
dashboardAnalytic: DashboardAnalytic.empty(),
|
|
||||||
failureOption: none(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/analytic/analytic.dart';
|
|
||||||
|
|
||||||
part 'inventory_analytic_loader_event.dart';
|
|
||||||
part 'inventory_analytic_loader_state.dart';
|
|
||||||
part 'inventory_analytic_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class InventoryAnalyticLoaderBloc
|
|
||||||
extends Bloc<InventoryAnalyticLoaderEvent, InventoryAnalyticLoaderState> {
|
|
||||||
final IAnalyticRepository _analyticRepository;
|
|
||||||
InventoryAnalyticLoaderBloc(this._analyticRepository)
|
|
||||||
: super(InventoryAnalyticLoaderState.initial()) {
|
|
||||||
on<InventoryAnalyticLoaderEvent>(_onInventoryAnalyticLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onInventoryAnalyticLoaderEvent(
|
|
||||||
InventoryAnalyticLoaderEvent event,
|
|
||||||
Emitter<InventoryAnalyticLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
||||||
|
|
||||||
final result = await _analyticRepository.getInventory(
|
|
||||||
dateFrom: e.startDate,
|
|
||||||
dateTo: e.endDate,
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
result.fold(
|
|
||||||
(l) => state.copyWith(isFetching: false, failureOption: some(l)),
|
|
||||||
(r) => state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: none(),
|
|
||||||
inventoryAnalytic: r,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,480 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'inventory_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$InventoryAnalyticLoaderEvent {
|
|
||||||
DateTime get startDate => throw _privateConstructorUsedError;
|
|
||||||
DateTime get endDate => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$InventoryAnalyticLoaderEventCopyWith<InventoryAnalyticLoaderEvent>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $InventoryAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory $InventoryAnalyticLoaderEventCopyWith(
|
|
||||||
InventoryAnalyticLoaderEvent value,
|
|
||||||
$Res Function(InventoryAnalyticLoaderEvent) then,
|
|
||||||
) =
|
|
||||||
_$InventoryAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
InventoryAnalyticLoaderEvent
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$InventoryAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends InventoryAnalyticLoaderEvent
|
|
||||||
>
|
|
||||||
implements $InventoryAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
_$InventoryAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$FetchedImplCopyWith<$Res>
|
|
||||||
implements $InventoryAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$FetchedImplCopyWith(
|
|
||||||
_$FetchedImpl value,
|
|
||||||
$Res Function(_$FetchedImpl) then,
|
|
||||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$FetchedImplCopyWithImpl<$Res>
|
|
||||||
extends _$InventoryAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_$FetchedImpl(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$FetchedImpl implements _Fetched {
|
|
||||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DateTime startDate;
|
|
||||||
@override
|
|
||||||
final DateTime endDate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'InventoryAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$FetchedImpl &&
|
|
||||||
(identical(other.startDate, startDate) ||
|
|
||||||
other.startDate == startDate) &&
|
|
||||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements InventoryAnalyticLoaderEvent {
|
|
||||||
const factory _Fetched({
|
|
||||||
required final DateTime startDate,
|
|
||||||
required final DateTime endDate,
|
|
||||||
}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DateTime get startDate;
|
|
||||||
@override
|
|
||||||
DateTime get endDate;
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$InventoryAnalyticLoaderState {
|
|
||||||
InventoryAnalytic get inventoryAnalytic => throw _privateConstructorUsedError;
|
|
||||||
Option<AnalyticFailure> get failureOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$InventoryAnalyticLoaderStateCopyWith<InventoryAnalyticLoaderState>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $InventoryAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory $InventoryAnalyticLoaderStateCopyWith(
|
|
||||||
InventoryAnalyticLoaderState value,
|
|
||||||
$Res Function(InventoryAnalyticLoaderState) then,
|
|
||||||
) =
|
|
||||||
_$InventoryAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
InventoryAnalyticLoaderState
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
InventoryAnalytic inventoryAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$InventoryAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends InventoryAnalyticLoaderState
|
|
||||||
>
|
|
||||||
implements $InventoryAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
_$InventoryAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? inventoryAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
inventoryAnalytic: null == inventoryAnalytic
|
|
||||||
? _value.inventoryAnalytic
|
|
||||||
: inventoryAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as InventoryAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic {
|
|
||||||
return $InventoryAnalyticCopyWith<$Res>(_value.inventoryAnalytic, (value) {
|
|
||||||
return _then(_value.copyWith(inventoryAnalytic: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$InventoryAnalyticLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $InventoryAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$InventoryAnalyticLoaderStateImplCopyWith(
|
|
||||||
_$InventoryAnalyticLoaderStateImpl value,
|
|
||||||
$Res Function(_$InventoryAnalyticLoaderStateImpl) then,
|
|
||||||
) = __$$InventoryAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
InventoryAnalytic inventoryAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$InventoryAnalyticCopyWith<$Res> get inventoryAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$InventoryAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends
|
|
||||||
_$InventoryAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
_$InventoryAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
implements _$$InventoryAnalyticLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$InventoryAnalyticLoaderStateImplCopyWithImpl(
|
|
||||||
_$InventoryAnalyticLoaderStateImpl _value,
|
|
||||||
$Res Function(_$InventoryAnalyticLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? inventoryAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$InventoryAnalyticLoaderStateImpl(
|
|
||||||
inventoryAnalytic: null == inventoryAnalytic
|
|
||||||
? _value.inventoryAnalytic
|
|
||||||
: inventoryAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as InventoryAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$InventoryAnalyticLoaderStateImpl
|
|
||||||
implements _InventoryAnalyticLoaderState {
|
|
||||||
_$InventoryAnalyticLoaderStateImpl({
|
|
||||||
required this.inventoryAnalytic,
|
|
||||||
required this.failureOption,
|
|
||||||
this.isFetching = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final InventoryAnalytic inventoryAnalytic;
|
|
||||||
@override
|
|
||||||
final Option<AnalyticFailure> failureOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'InventoryAnalyticLoaderState(inventoryAnalytic: $inventoryAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$InventoryAnalyticLoaderStateImpl &&
|
|
||||||
(identical(other.inventoryAnalytic, inventoryAnalytic) ||
|
|
||||||
other.inventoryAnalytic == inventoryAnalytic) &&
|
|
||||||
(identical(other.failureOption, failureOption) ||
|
|
||||||
other.failureOption == failureOption) &&
|
|
||||||
(identical(other.isFetching, isFetching) ||
|
|
||||||
other.isFetching == isFetching));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
Object.hash(runtimeType, inventoryAnalytic, failureOption, isFetching);
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$InventoryAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$InventoryAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith =>
|
|
||||||
__$$InventoryAnalyticLoaderStateImplCopyWithImpl<
|
|
||||||
_$InventoryAnalyticLoaderStateImpl
|
|
||||||
>(this, _$identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _InventoryAnalyticLoaderState
|
|
||||||
implements InventoryAnalyticLoaderState {
|
|
||||||
factory _InventoryAnalyticLoaderState({
|
|
||||||
required final InventoryAnalytic inventoryAnalytic,
|
|
||||||
required final Option<AnalyticFailure> failureOption,
|
|
||||||
final bool isFetching,
|
|
||||||
}) = _$InventoryAnalyticLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
InventoryAnalytic get inventoryAnalytic;
|
|
||||||
@override
|
|
||||||
Option<AnalyticFailure> get failureOption;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
|
|
||||||
/// Create a copy of InventoryAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$InventoryAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$InventoryAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'inventory_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class InventoryAnalyticLoaderEvent with _$InventoryAnalyticLoaderEvent {
|
|
||||||
const factory InventoryAnalyticLoaderEvent.fetched({
|
|
||||||
required DateTime startDate,
|
|
||||||
required DateTime endDate,
|
|
||||||
}) = _Fetched;
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
part of 'inventory_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class InventoryAnalyticLoaderState with _$InventoryAnalyticLoaderState {
|
|
||||||
factory InventoryAnalyticLoaderState({
|
|
||||||
required InventoryAnalytic inventoryAnalytic,
|
|
||||||
required Option<AnalyticFailure> failureOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
}) = _InventoryAnalyticLoaderState;
|
|
||||||
|
|
||||||
factory InventoryAnalyticLoaderState.initial() =>
|
|
||||||
InventoryAnalyticLoaderState(
|
|
||||||
inventoryAnalytic: InventoryAnalytic.empty(),
|
|
||||||
failureOption: none(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/analytic/analytic.dart';
|
|
||||||
|
|
||||||
part 'payment_method_analytic_loader_event.dart';
|
|
||||||
part 'payment_method_analytic_loader_state.dart';
|
|
||||||
part 'payment_method_analytic_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class PaymentMethodAnalyticLoaderBloc
|
|
||||||
extends
|
|
||||||
Bloc<
|
|
||||||
PaymentMethodAnalyticLoaderEvent,
|
|
||||||
PaymentMethodAnalyticLoaderState
|
|
||||||
> {
|
|
||||||
final IAnalyticRepository _analyticRepository;
|
|
||||||
PaymentMethodAnalyticLoaderBloc(this._analyticRepository)
|
|
||||||
: super(PaymentMethodAnalyticLoaderState.initial()) {
|
|
||||||
on<PaymentMethodAnalyticLoaderEvent>(_onPaymentMethodAnalyticLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onPaymentMethodAnalyticLoaderEvent(
|
|
||||||
PaymentMethodAnalyticLoaderEvent event,
|
|
||||||
Emitter<PaymentMethodAnalyticLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
||||||
|
|
||||||
final result = await _analyticRepository.getPaymentMethod(
|
|
||||||
dateFrom: e.startDate,
|
|
||||||
dateTo: e.endDate,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(paymentMethod) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
paymentMethodAnalytic: paymentMethod,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,487 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'payment_method_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$PaymentMethodAnalyticLoaderEvent {
|
|
||||||
DateTime get startDate => throw _privateConstructorUsedError;
|
|
||||||
DateTime get endDate => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$PaymentMethodAnalyticLoaderEventCopyWith<PaymentMethodAnalyticLoaderEvent>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $PaymentMethodAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory $PaymentMethodAnalyticLoaderEventCopyWith(
|
|
||||||
PaymentMethodAnalyticLoaderEvent value,
|
|
||||||
$Res Function(PaymentMethodAnalyticLoaderEvent) then,
|
|
||||||
) =
|
|
||||||
_$PaymentMethodAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
PaymentMethodAnalyticLoaderEvent
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$PaymentMethodAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends PaymentMethodAnalyticLoaderEvent
|
|
||||||
>
|
|
||||||
implements $PaymentMethodAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
_$PaymentMethodAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$FetchedImplCopyWith<$Res>
|
|
||||||
implements $PaymentMethodAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$FetchedImplCopyWith(
|
|
||||||
_$FetchedImpl value,
|
|
||||||
$Res Function(_$FetchedImpl) then,
|
|
||||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$FetchedImplCopyWithImpl<$Res>
|
|
||||||
extends _$PaymentMethodAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_$FetchedImpl(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$FetchedImpl implements _Fetched {
|
|
||||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DateTime startDate;
|
|
||||||
@override
|
|
||||||
final DateTime endDate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'PaymentMethodAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$FetchedImpl &&
|
|
||||||
(identical(other.startDate, startDate) ||
|
|
||||||
other.startDate == startDate) &&
|
|
||||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements PaymentMethodAnalyticLoaderEvent {
|
|
||||||
const factory _Fetched({
|
|
||||||
required final DateTime startDate,
|
|
||||||
required final DateTime endDate,
|
|
||||||
}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DateTime get startDate;
|
|
||||||
@override
|
|
||||||
DateTime get endDate;
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$PaymentMethodAnalyticLoaderState {
|
|
||||||
PaymentMethodAnalytic get paymentMethodAnalytic =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
Option<AnalyticFailure> get failureOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$PaymentMethodAnalyticLoaderStateCopyWith<PaymentMethodAnalyticLoaderState>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $PaymentMethodAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory $PaymentMethodAnalyticLoaderStateCopyWith(
|
|
||||||
PaymentMethodAnalyticLoaderState value,
|
|
||||||
$Res Function(PaymentMethodAnalyticLoaderState) then,
|
|
||||||
) =
|
|
||||||
_$PaymentMethodAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
PaymentMethodAnalyticLoaderState
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
PaymentMethodAnalytic paymentMethodAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$PaymentMethodAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends PaymentMethodAnalyticLoaderState
|
|
||||||
>
|
|
||||||
implements $PaymentMethodAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
_$PaymentMethodAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? paymentMethodAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
paymentMethodAnalytic: null == paymentMethodAnalytic
|
|
||||||
? _value.paymentMethodAnalytic
|
|
||||||
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as PaymentMethodAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic {
|
|
||||||
return $PaymentMethodAnalyticCopyWith<$Res>(_value.paymentMethodAnalytic, (
|
|
||||||
value,
|
|
||||||
) {
|
|
||||||
return _then(_value.copyWith(paymentMethodAnalytic: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$PaymentMethodAnalyticLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $PaymentMethodAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$PaymentMethodAnalyticLoaderStateImplCopyWith(
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl value,
|
|
||||||
$Res Function(_$PaymentMethodAnalyticLoaderStateImpl) then,
|
|
||||||
) = __$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
PaymentMethodAnalytic paymentMethodAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$PaymentMethodAnalyticCopyWith<$Res> get paymentMethodAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends
|
|
||||||
_$PaymentMethodAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
implements _$$PaymentMethodAnalyticLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl(
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl _value,
|
|
||||||
$Res Function(_$PaymentMethodAnalyticLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? paymentMethodAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl(
|
|
||||||
paymentMethodAnalytic: null == paymentMethodAnalytic
|
|
||||||
? _value.paymentMethodAnalytic
|
|
||||||
: paymentMethodAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as PaymentMethodAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$PaymentMethodAnalyticLoaderStateImpl
|
|
||||||
implements _PaymentMethodAnalyticLoaderState {
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl({
|
|
||||||
required this.paymentMethodAnalytic,
|
|
||||||
required this.failureOption,
|
|
||||||
this.isFetching = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final PaymentMethodAnalytic paymentMethodAnalytic;
|
|
||||||
@override
|
|
||||||
final Option<AnalyticFailure> failureOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'PaymentMethodAnalyticLoaderState(paymentMethodAnalytic: $paymentMethodAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$PaymentMethodAnalyticLoaderStateImpl &&
|
|
||||||
(identical(other.paymentMethodAnalytic, paymentMethodAnalytic) ||
|
|
||||||
other.paymentMethodAnalytic == paymentMethodAnalytic) &&
|
|
||||||
(identical(other.failureOption, failureOption) ||
|
|
||||||
other.failureOption == failureOption) &&
|
|
||||||
(identical(other.isFetching, isFetching) ||
|
|
||||||
other.isFetching == isFetching));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(
|
|
||||||
runtimeType,
|
|
||||||
paymentMethodAnalytic,
|
|
||||||
failureOption,
|
|
||||||
isFetching,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$PaymentMethodAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith =>
|
|
||||||
__$$PaymentMethodAnalyticLoaderStateImplCopyWithImpl<
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl
|
|
||||||
>(this, _$identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _PaymentMethodAnalyticLoaderState
|
|
||||||
implements PaymentMethodAnalyticLoaderState {
|
|
||||||
factory _PaymentMethodAnalyticLoaderState({
|
|
||||||
required final PaymentMethodAnalytic paymentMethodAnalytic,
|
|
||||||
required final Option<AnalyticFailure> failureOption,
|
|
||||||
final bool isFetching,
|
|
||||||
}) = _$PaymentMethodAnalyticLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
PaymentMethodAnalytic get paymentMethodAnalytic;
|
|
||||||
@override
|
|
||||||
Option<AnalyticFailure> get failureOption;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
|
|
||||||
/// Create a copy of PaymentMethodAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$PaymentMethodAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$PaymentMethodAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'payment_method_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class PaymentMethodAnalyticLoaderEvent with _$PaymentMethodAnalyticLoaderEvent {
|
|
||||||
const factory PaymentMethodAnalyticLoaderEvent.fetched({
|
|
||||||
required DateTime startDate,
|
|
||||||
required DateTime endDate,
|
|
||||||
}) = _Fetched;
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
part of 'payment_method_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class PaymentMethodAnalyticLoaderState with _$PaymentMethodAnalyticLoaderState {
|
|
||||||
factory PaymentMethodAnalyticLoaderState({
|
|
||||||
required PaymentMethodAnalytic paymentMethodAnalytic,
|
|
||||||
required Option<AnalyticFailure> failureOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
}) = _PaymentMethodAnalyticLoaderState;
|
|
||||||
|
|
||||||
factory PaymentMethodAnalyticLoaderState.initial() =>
|
|
||||||
PaymentMethodAnalyticLoaderState(
|
|
||||||
paymentMethodAnalytic: PaymentMethodAnalytic.empty(),
|
|
||||||
failureOption: none(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/analytic/analytic.dart';
|
|
||||||
|
|
||||||
part 'product_analytic_loader_event.dart';
|
|
||||||
part 'product_analytic_loader_state.dart';
|
|
||||||
part 'product_analytic_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class ProductAnalyticLoaderBloc
|
|
||||||
extends Bloc<ProductAnalyticLoaderEvent, ProductAnalyticLoaderState> {
|
|
||||||
final IAnalyticRepository _analyticRepository;
|
|
||||||
ProductAnalyticLoaderBloc(this._analyticRepository)
|
|
||||||
: super(ProductAnalyticLoaderState.initial()) {
|
|
||||||
on<ProductAnalyticLoaderEvent>(_onProductAnalyticLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onProductAnalyticLoaderEvent(
|
|
||||||
ProductAnalyticLoaderEvent event,
|
|
||||||
Emitter<ProductAnalyticLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
||||||
|
|
||||||
final result = await _analyticRepository.getProducts(
|
|
||||||
dateFrom: e.startDate,
|
|
||||||
dateTo: e.endDate,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(products) async {
|
|
||||||
emit(state.copyWith(isFetching: false, productAnalytic: products));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,475 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'product_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$ProductAnalyticLoaderEvent {
|
|
||||||
DateTime get startDate => throw _privateConstructorUsedError;
|
|
||||||
DateTime get endDate => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$ProductAnalyticLoaderEventCopyWith<ProductAnalyticLoaderEvent>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $ProductAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory $ProductAnalyticLoaderEventCopyWith(
|
|
||||||
ProductAnalyticLoaderEvent value,
|
|
||||||
$Res Function(ProductAnalyticLoaderEvent) then,
|
|
||||||
) =
|
|
||||||
_$ProductAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
ProductAnalyticLoaderEvent
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$ProductAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends ProductAnalyticLoaderEvent
|
|
||||||
>
|
|
||||||
implements $ProductAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
_$ProductAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$FetchedImplCopyWith<$Res>
|
|
||||||
implements $ProductAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$FetchedImplCopyWith(
|
|
||||||
_$FetchedImpl value,
|
|
||||||
$Res Function(_$FetchedImpl) then,
|
|
||||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$FetchedImplCopyWithImpl<$Res>
|
|
||||||
extends _$ProductAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_$FetchedImpl(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$FetchedImpl implements _Fetched {
|
|
||||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DateTime startDate;
|
|
||||||
@override
|
|
||||||
final DateTime endDate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'ProductAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$FetchedImpl &&
|
|
||||||
(identical(other.startDate, startDate) ||
|
|
||||||
other.startDate == startDate) &&
|
|
||||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements ProductAnalyticLoaderEvent {
|
|
||||||
const factory _Fetched({
|
|
||||||
required final DateTime startDate,
|
|
||||||
required final DateTime endDate,
|
|
||||||
}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DateTime get startDate;
|
|
||||||
@override
|
|
||||||
DateTime get endDate;
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$ProductAnalyticLoaderState {
|
|
||||||
ProductAnalytic get productAnalytic => throw _privateConstructorUsedError;
|
|
||||||
Option<AnalyticFailure> get failureOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$ProductAnalyticLoaderStateCopyWith<ProductAnalyticLoaderState>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $ProductAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory $ProductAnalyticLoaderStateCopyWith(
|
|
||||||
ProductAnalyticLoaderState value,
|
|
||||||
$Res Function(ProductAnalyticLoaderState) then,
|
|
||||||
) =
|
|
||||||
_$ProductAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
ProductAnalyticLoaderState
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
ProductAnalytic productAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
$ProductAnalyticCopyWith<$Res> get productAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$ProductAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends ProductAnalyticLoaderState
|
|
||||||
>
|
|
||||||
implements $ProductAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
_$ProductAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? productAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
productAnalytic: null == productAnalytic
|
|
||||||
? _value.productAnalytic
|
|
||||||
: productAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as ProductAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$ProductAnalyticCopyWith<$Res> get productAnalytic {
|
|
||||||
return $ProductAnalyticCopyWith<$Res>(_value.productAnalytic, (value) {
|
|
||||||
return _then(_value.copyWith(productAnalytic: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$ProductAnalyticLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $ProductAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$ProductAnalyticLoaderStateImplCopyWith(
|
|
||||||
_$ProductAnalyticLoaderStateImpl value,
|
|
||||||
$Res Function(_$ProductAnalyticLoaderStateImpl) then,
|
|
||||||
) = __$$ProductAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
ProductAnalytic productAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$ProductAnalyticCopyWith<$Res> get productAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$ProductAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends
|
|
||||||
_$ProductAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
_$ProductAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
implements _$$ProductAnalyticLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$ProductAnalyticLoaderStateImplCopyWithImpl(
|
|
||||||
_$ProductAnalyticLoaderStateImpl _value,
|
|
||||||
$Res Function(_$ProductAnalyticLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? productAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$ProductAnalyticLoaderStateImpl(
|
|
||||||
productAnalytic: null == productAnalytic
|
|
||||||
? _value.productAnalytic
|
|
||||||
: productAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as ProductAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$ProductAnalyticLoaderStateImpl implements _ProductAnalyticLoaderState {
|
|
||||||
_$ProductAnalyticLoaderStateImpl({
|
|
||||||
required this.productAnalytic,
|
|
||||||
required this.failureOption,
|
|
||||||
this.isFetching = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final ProductAnalytic productAnalytic;
|
|
||||||
@override
|
|
||||||
final Option<AnalyticFailure> failureOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'ProductAnalyticLoaderState(productAnalytic: $productAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$ProductAnalyticLoaderStateImpl &&
|
|
||||||
(identical(other.productAnalytic, productAnalytic) ||
|
|
||||||
other.productAnalytic == productAnalytic) &&
|
|
||||||
(identical(other.failureOption, failureOption) ||
|
|
||||||
other.failureOption == failureOption) &&
|
|
||||||
(identical(other.isFetching, isFetching) ||
|
|
||||||
other.isFetching == isFetching));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
Object.hash(runtimeType, productAnalytic, failureOption, isFetching);
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$ProductAnalyticLoaderStateImplCopyWith<_$ProductAnalyticLoaderStateImpl>
|
|
||||||
get copyWith =>
|
|
||||||
__$$ProductAnalyticLoaderStateImplCopyWithImpl<
|
|
||||||
_$ProductAnalyticLoaderStateImpl
|
|
||||||
>(this, _$identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _ProductAnalyticLoaderState
|
|
||||||
implements ProductAnalyticLoaderState {
|
|
||||||
factory _ProductAnalyticLoaderState({
|
|
||||||
required final ProductAnalytic productAnalytic,
|
|
||||||
required final Option<AnalyticFailure> failureOption,
|
|
||||||
final bool isFetching,
|
|
||||||
}) = _$ProductAnalyticLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
ProductAnalytic get productAnalytic;
|
|
||||||
@override
|
|
||||||
Option<AnalyticFailure> get failureOption;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
|
|
||||||
/// Create a copy of ProductAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$ProductAnalyticLoaderStateImplCopyWith<_$ProductAnalyticLoaderStateImpl>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'product_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class ProductAnalyticLoaderEvent with _$ProductAnalyticLoaderEvent {
|
|
||||||
const factory ProductAnalyticLoaderEvent.fetched({
|
|
||||||
required DateTime startDate,
|
|
||||||
required DateTime endDate,
|
|
||||||
}) = _Fetched;
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
part of 'product_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class ProductAnalyticLoaderState with _$ProductAnalyticLoaderState {
|
|
||||||
factory ProductAnalyticLoaderState({
|
|
||||||
required ProductAnalytic productAnalytic,
|
|
||||||
required Option<AnalyticFailure> failureOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
}) = _ProductAnalyticLoaderState;
|
|
||||||
|
|
||||||
factory ProductAnalyticLoaderState.initial() => ProductAnalyticLoaderState(
|
|
||||||
productAnalytic: ProductAnalytic.empty(),
|
|
||||||
failureOption: none(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,52 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/analytic/analytic.dart';
|
|
||||||
|
|
||||||
part 'profit_loss_analytic_loader_event.dart';
|
|
||||||
part 'profit_loss_analytic_loader_state.dart';
|
|
||||||
part 'profit_loss_analytic_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class ProfitLossAnalyticLoaderBloc
|
|
||||||
extends Bloc<ProfitLossAnalyticLoaderEvent, ProfitLossAnalyticLoaderState> {
|
|
||||||
final IAnalyticRepository _analyticRepository;
|
|
||||||
ProfitLossAnalyticLoaderBloc(this._analyticRepository)
|
|
||||||
: super(ProfitLossAnalyticLoaderState.initial()) {
|
|
||||||
on<ProfitLossAnalyticLoaderEvent>(_onProfitLossAnalyticLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onProfitLossAnalyticLoaderEvent(
|
|
||||||
ProfitLossAnalyticLoaderEvent event,
|
|
||||||
Emitter<ProfitLossAnalyticLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
||||||
|
|
||||||
final result = await _analyticRepository.getProfitLoss(
|
|
||||||
dateFrom: e.startDate,
|
|
||||||
dateTo: e.endDate,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(profitLoss) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(isFetching: false, profitLossAnalytic: profitLoss),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,483 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'profit_loss_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$ProfitLossAnalyticLoaderEvent {
|
|
||||||
DateTime get startDate => throw _privateConstructorUsedError;
|
|
||||||
DateTime get endDate => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$ProfitLossAnalyticLoaderEventCopyWith<ProfitLossAnalyticLoaderEvent>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $ProfitLossAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory $ProfitLossAnalyticLoaderEventCopyWith(
|
|
||||||
ProfitLossAnalyticLoaderEvent value,
|
|
||||||
$Res Function(ProfitLossAnalyticLoaderEvent) then,
|
|
||||||
) =
|
|
||||||
_$ProfitLossAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
ProfitLossAnalyticLoaderEvent
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$ProfitLossAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends ProfitLossAnalyticLoaderEvent
|
|
||||||
>
|
|
||||||
implements $ProfitLossAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
_$ProfitLossAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$FetchedImplCopyWith<$Res>
|
|
||||||
implements $ProfitLossAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$FetchedImplCopyWith(
|
|
||||||
_$FetchedImpl value,
|
|
||||||
$Res Function(_$FetchedImpl) then,
|
|
||||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$FetchedImplCopyWithImpl<$Res>
|
|
||||||
extends _$ProfitLossAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_$FetchedImpl(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$FetchedImpl implements _Fetched {
|
|
||||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DateTime startDate;
|
|
||||||
@override
|
|
||||||
final DateTime endDate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'ProfitLossAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$FetchedImpl &&
|
|
||||||
(identical(other.startDate, startDate) ||
|
|
||||||
other.startDate == startDate) &&
|
|
||||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements ProfitLossAnalyticLoaderEvent {
|
|
||||||
const factory _Fetched({
|
|
||||||
required final DateTime startDate,
|
|
||||||
required final DateTime endDate,
|
|
||||||
}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DateTime get startDate;
|
|
||||||
@override
|
|
||||||
DateTime get endDate;
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$ProfitLossAnalyticLoaderState {
|
|
||||||
ProfitLossAnalytic get profitLossAnalytic =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
Option<AnalyticFailure> get failureOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$ProfitLossAnalyticLoaderStateCopyWith<ProfitLossAnalyticLoaderState>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $ProfitLossAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory $ProfitLossAnalyticLoaderStateCopyWith(
|
|
||||||
ProfitLossAnalyticLoaderState value,
|
|
||||||
$Res Function(ProfitLossAnalyticLoaderState) then,
|
|
||||||
) =
|
|
||||||
_$ProfitLossAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
ProfitLossAnalyticLoaderState
|
|
||||||
>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
ProfitLossAnalytic profitLossAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$ProfitLossAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends ProfitLossAnalyticLoaderState
|
|
||||||
>
|
|
||||||
implements $ProfitLossAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
_$ProfitLossAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? profitLossAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
profitLossAnalytic: null == profitLossAnalytic
|
|
||||||
? _value.profitLossAnalytic
|
|
||||||
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as ProfitLossAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic {
|
|
||||||
return $ProfitLossAnalyticCopyWith<$Res>(_value.profitLossAnalytic, (
|
|
||||||
value,
|
|
||||||
) {
|
|
||||||
return _then(_value.copyWith(profitLossAnalytic: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$ProfitLossAnalyticLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $ProfitLossAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$ProfitLossAnalyticLoaderStateImplCopyWith(
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl value,
|
|
||||||
$Res Function(_$ProfitLossAnalyticLoaderStateImpl) then,
|
|
||||||
) = __$$ProfitLossAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
ProfitLossAnalytic profitLossAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$ProfitLossAnalyticCopyWith<$Res> get profitLossAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$ProfitLossAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends
|
|
||||||
_$ProfitLossAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
implements _$$ProfitLossAnalyticLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$ProfitLossAnalyticLoaderStateImplCopyWithImpl(
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl _value,
|
|
||||||
$Res Function(_$ProfitLossAnalyticLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? profitLossAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl(
|
|
||||||
profitLossAnalytic: null == profitLossAnalytic
|
|
||||||
? _value.profitLossAnalytic
|
|
||||||
: profitLossAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as ProfitLossAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$ProfitLossAnalyticLoaderStateImpl
|
|
||||||
implements _ProfitLossAnalyticLoaderState {
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl({
|
|
||||||
required this.profitLossAnalytic,
|
|
||||||
required this.failureOption,
|
|
||||||
this.isFetching = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final ProfitLossAnalytic profitLossAnalytic;
|
|
||||||
@override
|
|
||||||
final Option<AnalyticFailure> failureOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'ProfitLossAnalyticLoaderState(profitLossAnalytic: $profitLossAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$ProfitLossAnalyticLoaderStateImpl &&
|
|
||||||
(identical(other.profitLossAnalytic, profitLossAnalytic) ||
|
|
||||||
other.profitLossAnalytic == profitLossAnalytic) &&
|
|
||||||
(identical(other.failureOption, failureOption) ||
|
|
||||||
other.failureOption == failureOption) &&
|
|
||||||
(identical(other.isFetching, isFetching) ||
|
|
||||||
other.isFetching == isFetching));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
Object.hash(runtimeType, profitLossAnalytic, failureOption, isFetching);
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$ProfitLossAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith =>
|
|
||||||
__$$ProfitLossAnalyticLoaderStateImplCopyWithImpl<
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl
|
|
||||||
>(this, _$identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _ProfitLossAnalyticLoaderState
|
|
||||||
implements ProfitLossAnalyticLoaderState {
|
|
||||||
factory _ProfitLossAnalyticLoaderState({
|
|
||||||
required final ProfitLossAnalytic profitLossAnalytic,
|
|
||||||
required final Option<AnalyticFailure> failureOption,
|
|
||||||
final bool isFetching,
|
|
||||||
}) = _$ProfitLossAnalyticLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
ProfitLossAnalytic get profitLossAnalytic;
|
|
||||||
@override
|
|
||||||
Option<AnalyticFailure> get failureOption;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
|
|
||||||
/// Create a copy of ProfitLossAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$ProfitLossAnalyticLoaderStateImplCopyWith<
|
|
||||||
_$ProfitLossAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'profit_loss_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class ProfitLossAnalyticLoaderEvent with _$ProfitLossAnalyticLoaderEvent {
|
|
||||||
const factory ProfitLossAnalyticLoaderEvent.fetched({
|
|
||||||
required DateTime startDate,
|
|
||||||
required DateTime endDate,
|
|
||||||
}) = _Fetched;
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
part of 'profit_loss_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class ProfitLossAnalyticLoaderState with _$ProfitLossAnalyticLoaderState {
|
|
||||||
factory ProfitLossAnalyticLoaderState({
|
|
||||||
required ProfitLossAnalytic profitLossAnalytic,
|
|
||||||
required Option<AnalyticFailure> failureOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
}) = _ProfitLossAnalyticLoaderState;
|
|
||||||
|
|
||||||
factory ProfitLossAnalyticLoaderState.initial() =>
|
|
||||||
ProfitLossAnalyticLoaderState(
|
|
||||||
profitLossAnalytic: ProfitLossAnalytic.empty(),
|
|
||||||
failureOption: none(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,50 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/analytic/analytic.dart';
|
|
||||||
|
|
||||||
part 'sales_analytic_loader_event.dart';
|
|
||||||
part 'sales_analytic_loader_state.dart';
|
|
||||||
part 'sales_analytic_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class SalesAnalyticLoaderBloc
|
|
||||||
extends Bloc<SalesAnalyticLoaderEvent, SalesAnalyticLoaderState> {
|
|
||||||
final IAnalyticRepository _analyticRepository;
|
|
||||||
SalesAnalyticLoaderBloc(this._analyticRepository)
|
|
||||||
: super(SalesAnalyticLoaderState.initial()) {
|
|
||||||
on<SalesAnalyticLoaderEvent>(_onSalesAnalyticLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onSalesAnalyticLoaderEvent(
|
|
||||||
SalesAnalyticLoaderEvent event,
|
|
||||||
Emitter<SalesAnalyticLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
emit(state.copyWith(isFetching: true, failureOption: none()));
|
|
||||||
|
|
||||||
final result = await _analyticRepository.getSales(
|
|
||||||
dateFrom: e.startDate,
|
|
||||||
dateTo: e.endDate,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(sales) async {
|
|
||||||
emit(state.copyWith(isFetching: false, salesAnalytic: sales));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,466 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'sales_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// FreezedGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
T _$identity<T>(T value) => value;
|
|
||||||
|
|
||||||
final _privateConstructorUsedError = UnsupportedError(
|
|
||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models',
|
|
||||||
);
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$SalesAnalyticLoaderEvent {
|
|
||||||
DateTime get startDate => throw _privateConstructorUsedError;
|
|
||||||
DateTime get endDate => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$SalesAnalyticLoaderEventCopyWith<SalesAnalyticLoaderEvent> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $SalesAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory $SalesAnalyticLoaderEventCopyWith(
|
|
||||||
SalesAnalyticLoaderEvent value,
|
|
||||||
$Res Function(SalesAnalyticLoaderEvent) then,
|
|
||||||
) = _$SalesAnalyticLoaderEventCopyWithImpl<$Res, SalesAnalyticLoaderEvent>;
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$SalesAnalyticLoaderEventCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends SalesAnalyticLoaderEvent
|
|
||||||
>
|
|
||||||
implements $SalesAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
_$SalesAnalyticLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$FetchedImplCopyWith<$Res>
|
|
||||||
implements $SalesAnalyticLoaderEventCopyWith<$Res> {
|
|
||||||
factory _$$FetchedImplCopyWith(
|
|
||||||
_$FetchedImpl value,
|
|
||||||
$Res Function(_$FetchedImpl) then,
|
|
||||||
) = __$$FetchedImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({DateTime startDate, DateTime endDate});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$FetchedImplCopyWithImpl<$Res>
|
|
||||||
extends _$SalesAnalyticLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? startDate = null, Object? endDate = null}) {
|
|
||||||
return _then(
|
|
||||||
_$FetchedImpl(
|
|
||||||
startDate: null == startDate
|
|
||||||
? _value.startDate
|
|
||||||
: startDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
endDate: null == endDate
|
|
||||||
? _value.endDate
|
|
||||||
: endDate // ignore: cast_nullable_to_non_nullable
|
|
||||||
as DateTime,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$FetchedImpl implements _Fetched {
|
|
||||||
const _$FetchedImpl({required this.startDate, required this.endDate});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final DateTime startDate;
|
|
||||||
@override
|
|
||||||
final DateTime endDate;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'SalesAnalyticLoaderEvent.fetched(startDate: $startDate, endDate: $endDate)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$FetchedImpl &&
|
|
||||||
(identical(other.startDate, startDate) ||
|
|
||||||
other.startDate == startDate) &&
|
|
||||||
(identical(other.endDate, endDate) || other.endDate == endDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, startDate, endDate);
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
__$$FetchedImplCopyWithImpl<_$FetchedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(DateTime startDate, DateTime endDate) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(startDate, endDate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(DateTime startDate, DateTime endDate)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(startDate, endDate);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements SalesAnalyticLoaderEvent {
|
|
||||||
const factory _Fetched({
|
|
||||||
required final DateTime startDate,
|
|
||||||
required final DateTime endDate,
|
|
||||||
}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
DateTime get startDate;
|
|
||||||
@override
|
|
||||||
DateTime get endDate;
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$SalesAnalyticLoaderState {
|
|
||||||
SalesAnalytic get salesAnalytic => throw _privateConstructorUsedError;
|
|
||||||
Option<AnalyticFailure> get failureOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$SalesAnalyticLoaderStateCopyWith<SalesAnalyticLoaderState> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $SalesAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory $SalesAnalyticLoaderStateCopyWith(
|
|
||||||
SalesAnalyticLoaderState value,
|
|
||||||
$Res Function(SalesAnalyticLoaderState) then,
|
|
||||||
) = _$SalesAnalyticLoaderStateCopyWithImpl<$Res, SalesAnalyticLoaderState>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
SalesAnalytic salesAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
$SalesAnalyticCopyWith<$Res> get salesAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$SalesAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
$Val extends SalesAnalyticLoaderState
|
|
||||||
>
|
|
||||||
implements $SalesAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
_$SalesAnalyticLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? salesAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
salesAnalytic: null == salesAnalytic
|
|
||||||
? _value.salesAnalytic
|
|
||||||
: salesAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as SalesAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
)
|
|
||||||
as $Val,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$SalesAnalyticCopyWith<$Res> get salesAnalytic {
|
|
||||||
return $SalesAnalyticCopyWith<$Res>(_value.salesAnalytic, (value) {
|
|
||||||
return _then(_value.copyWith(salesAnalytic: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$SalesAnalyticLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $SalesAnalyticLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$SalesAnalyticLoaderStateImplCopyWith(
|
|
||||||
_$SalesAnalyticLoaderStateImpl value,
|
|
||||||
$Res Function(_$SalesAnalyticLoaderStateImpl) then,
|
|
||||||
) = __$$SalesAnalyticLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
SalesAnalytic salesAnalytic,
|
|
||||||
Option<AnalyticFailure> failureOption,
|
|
||||||
bool isFetching,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$SalesAnalyticCopyWith<$Res> get salesAnalytic;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$SalesAnalyticLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends
|
|
||||||
_$SalesAnalyticLoaderStateCopyWithImpl<
|
|
||||||
$Res,
|
|
||||||
_$SalesAnalyticLoaderStateImpl
|
|
||||||
>
|
|
||||||
implements _$$SalesAnalyticLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$SalesAnalyticLoaderStateImplCopyWithImpl(
|
|
||||||
_$SalesAnalyticLoaderStateImpl _value,
|
|
||||||
$Res Function(_$SalesAnalyticLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? salesAnalytic = null,
|
|
||||||
Object? failureOption = null,
|
|
||||||
Object? isFetching = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$SalesAnalyticLoaderStateImpl(
|
|
||||||
salesAnalytic: null == salesAnalytic
|
|
||||||
? _value.salesAnalytic
|
|
||||||
: salesAnalytic // ignore: cast_nullable_to_non_nullable
|
|
||||||
as SalesAnalytic,
|
|
||||||
failureOption: null == failureOption
|
|
||||||
? _value.failureOption
|
|
||||||
: failureOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<AnalyticFailure>,
|
|
||||||
isFetching: null == isFetching
|
|
||||||
? _value.isFetching
|
|
||||||
: isFetching // ignore: cast_nullable_to_non_nullable
|
|
||||||
as bool,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$SalesAnalyticLoaderStateImpl implements _SalesAnalyticLoaderState {
|
|
||||||
_$SalesAnalyticLoaderStateImpl({
|
|
||||||
required this.salesAnalytic,
|
|
||||||
required this.failureOption,
|
|
||||||
this.isFetching = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final SalesAnalytic salesAnalytic;
|
|
||||||
@override
|
|
||||||
final Option<AnalyticFailure> failureOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'SalesAnalyticLoaderState(salesAnalytic: $salesAnalytic, failureOption: $failureOption, isFetching: $isFetching)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$SalesAnalyticLoaderStateImpl &&
|
|
||||||
(identical(other.salesAnalytic, salesAnalytic) ||
|
|
||||||
other.salesAnalytic == salesAnalytic) &&
|
|
||||||
(identical(other.failureOption, failureOption) ||
|
|
||||||
other.failureOption == failureOption) &&
|
|
||||||
(identical(other.isFetching, isFetching) ||
|
|
||||||
other.isFetching == isFetching));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode =>
|
|
||||||
Object.hash(runtimeType, salesAnalytic, failureOption, isFetching);
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$SalesAnalyticLoaderStateImplCopyWith<_$SalesAnalyticLoaderStateImpl>
|
|
||||||
get copyWith =>
|
|
||||||
__$$SalesAnalyticLoaderStateImplCopyWithImpl<
|
|
||||||
_$SalesAnalyticLoaderStateImpl
|
|
||||||
>(this, _$identity);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _SalesAnalyticLoaderState implements SalesAnalyticLoaderState {
|
|
||||||
factory _SalesAnalyticLoaderState({
|
|
||||||
required final SalesAnalytic salesAnalytic,
|
|
||||||
required final Option<AnalyticFailure> failureOption,
|
|
||||||
final bool isFetching,
|
|
||||||
}) = _$SalesAnalyticLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
SalesAnalytic get salesAnalytic;
|
|
||||||
@override
|
|
||||||
Option<AnalyticFailure> get failureOption;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
|
|
||||||
/// Create a copy of SalesAnalyticLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$SalesAnalyticLoaderStateImplCopyWith<_$SalesAnalyticLoaderStateImpl>
|
|
||||||
get copyWith => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'sales_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class SalesAnalyticLoaderEvent with _$SalesAnalyticLoaderEvent {
|
|
||||||
const factory SalesAnalyticLoaderEvent.fetched({
|
|
||||||
required DateTime startDate,
|
|
||||||
required DateTime endDate,
|
|
||||||
}) = _Fetched;
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
part of 'sales_analytic_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class SalesAnalyticLoaderState with _$SalesAnalyticLoaderState {
|
|
||||||
factory SalesAnalyticLoaderState({
|
|
||||||
required SalesAnalytic salesAnalytic,
|
|
||||||
required Option<AnalyticFailure> failureOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
}) = _SalesAnalyticLoaderState;
|
|
||||||
|
|
||||||
factory SalesAnalyticLoaderState.initial() => SalesAnalyticLoaderState(
|
|
||||||
failureOption: none(),
|
|
||||||
salesAnalytic: SalesAnalytic.empty(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,66 +0,0 @@
|
|||||||
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/outlet/outlet.dart';
|
|
||||||
|
|
||||||
part 'auth_event.dart';
|
|
||||||
part 'auth_state.dart';
|
|
||||||
part 'auth_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
|
||||||
final IAuthRepository _repository;
|
|
||||||
final IOutletRepository _outletRepository;
|
|
||||||
AuthBloc(this._repository, this._outletRepository)
|
|
||||||
: super(AuthState.initial()) {
|
|
||||||
on<AuthEvent>(_onAuthEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onAuthEvent(AuthEvent event, Emitter<AuthState> emit) {
|
|
||||||
return event.map(
|
|
||||||
fetchCurrentUser: (e) async {
|
|
||||||
emit(state.copyWith(failureOption: none()));
|
|
||||||
|
|
||||||
final token = await _repository.hasToken();
|
|
||||||
|
|
||||||
final failureOrAuth = await _repository.currentUser();
|
|
||||||
|
|
||||||
failureOrAuth.fold(
|
|
||||||
(f) => emit(
|
|
||||||
state.copyWith(
|
|
||||||
failureOption: optionOf(f),
|
|
||||||
status: token
|
|
||||||
? AuthStatus.authenticated()
|
|
||||||
: AuthStatus.unauthenticated(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(user) => emit(
|
|
||||||
state.copyWith(
|
|
||||||
user: user,
|
|
||||||
status: token
|
|
||||||
? AuthStatus.authenticated()
|
|
||||||
: AuthStatus.unauthenticated(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
add(AuthEvent.fetchCurrentOutlet(state.user.outletId));
|
|
||||||
},
|
|
||||||
fetchCurrentOutlet: (e) async {
|
|
||||||
emit(state.copyWith(failureOutletOption: none()));
|
|
||||||
|
|
||||||
final failureOrOutlet = await _outletRepository.getOutletById(
|
|
||||||
e.outletId,
|
|
||||||
);
|
|
||||||
|
|
||||||
failureOrOutlet.fold(
|
|
||||||
(f) => emit(state.copyWith(failureOutletOption: optionOf(f))),
|
|
||||||
(outlet) => emit(state.copyWith(outlet: outlet)),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
part of 'auth_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class AuthEvent with _$AuthEvent {
|
|
||||||
const factory AuthEvent.fetchCurrentUser() = _FetchCurrentUser;
|
|
||||||
const factory AuthEvent.fetchCurrentOutlet(String outletId) =
|
|
||||||
_FetchCurrentOutlet;
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
part of 'auth_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class AuthState with _$AuthState {
|
|
||||||
const AuthState._();
|
|
||||||
|
|
||||||
const factory AuthState({
|
|
||||||
required User user,
|
|
||||||
required Outlet outlet,
|
|
||||||
@Default(AuthStatus.initial()) AuthStatus status,
|
|
||||||
required Option<AuthFailure> failureOption,
|
|
||||||
required Option<OutletFailure> failureOutletOption,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
@Default(false) bool isFetchingOutlet,
|
|
||||||
}) = _AuthState;
|
|
||||||
|
|
||||||
factory AuthState.initial() => AuthState(
|
|
||||||
user: User.empty(),
|
|
||||||
failureOption: none(),
|
|
||||||
outlet: Outlet.empty(),
|
|
||||||
failureOutletOption: none(),
|
|
||||||
);
|
|
||||||
|
|
||||||
bool get isAuthenticated => status == const AuthStatus.authenticated();
|
|
||||||
bool get isInitial => status == const AuthStatus.initial();
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
sealed class AuthStatus with _$AuthStatus {
|
|
||||||
const factory AuthStatus.authenticated() = _Authenticated;
|
|
||||||
const factory AuthStatus.unauthenticated() = _Unauthenticated;
|
|
||||||
const factory AuthStatus.initial() = _Initial;
|
|
||||||
}
|
|
||||||
@ -1,62 +0,0 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/auth/auth.dart';
|
|
||||||
|
|
||||||
part 'login_form_event.dart';
|
|
||||||
part 'login_form_state.dart';
|
|
||||||
part 'login_form_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class LoginFormBloc extends Bloc<LoginFormEvent, LoginFormState> {
|
|
||||||
final IAuthRepository _authRepository;
|
|
||||||
LoginFormBloc(this._authRepository) : super(LoginFormState.initial()) {
|
|
||||||
on<LoginFormEvent>(_onLoginFormEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onLoginFormEvent(
|
|
||||||
LoginFormEvent event,
|
|
||||||
Emitter<LoginFormState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
emailChanged: (e) async {
|
|
||||||
emit(state.copyWith(email: e.email, failureOrLoginOption: none()));
|
|
||||||
},
|
|
||||||
passwordChanged: (e) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(password: e.password, failureOrLoginOption: none()),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
submitted: (e) async {
|
|
||||||
Either<AuthFailure, Login>? failureOrLogin;
|
|
||||||
emit(state.copyWith(isSubmitting: true, failureOrLoginOption: none()));
|
|
||||||
|
|
||||||
final emailValid = state.email.isNotEmpty;
|
|
||||||
final passwordValid = state.password.isNotEmpty;
|
|
||||||
|
|
||||||
log(
|
|
||||||
'emailValid: $emailValid, passwordValid: $passwordValid, email: ${state.email}, password: ${state.password}',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (emailValid && passwordValid) {
|
|
||||||
failureOrLogin = await _authRepository.login(
|
|
||||||
email: state.email,
|
|
||||||
password: state.password,
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isSubmitting: false,
|
|
||||||
failureOrLoginOption: optionOf(failureOrLogin),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
emit(state.copyWith(showErrorMessages: true, isSubmitting: false));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,734 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'login_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 _$LoginFormEvent {
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(String email) emailChanged,
|
|
||||||
required TResult Function(String password) passwordChanged,
|
|
||||||
required TResult Function() submitted,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(String email)? emailChanged,
|
|
||||||
TResult? Function(String password)? passwordChanged,
|
|
||||||
TResult? Function()? submitted,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(String email)? emailChanged,
|
|
||||||
TResult Function(String password)? passwordChanged,
|
|
||||||
TResult Function()? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_EmailChanged value) emailChanged,
|
|
||||||
required TResult Function(_PasswordChanged value) passwordChanged,
|
|
||||||
required TResult Function(_Submitted value) submitted,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult? Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult? Function(_Submitted value)? submitted,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult Function(_Submitted value)? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $LoginFormEventCopyWith<$Res> {
|
|
||||||
factory $LoginFormEventCopyWith(
|
|
||||||
LoginFormEvent value,
|
|
||||||
$Res Function(LoginFormEvent) then,
|
|
||||||
) = _$LoginFormEventCopyWithImpl<$Res, LoginFormEvent>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$LoginFormEventCopyWithImpl<$Res, $Val extends LoginFormEvent>
|
|
||||||
implements $LoginFormEventCopyWith<$Res> {
|
|
||||||
_$LoginFormEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$EmailChangedImplCopyWith<$Res> {
|
|
||||||
factory _$$EmailChangedImplCopyWith(
|
|
||||||
_$EmailChangedImpl value,
|
|
||||||
$Res Function(_$EmailChangedImpl) then,
|
|
||||||
) = __$$EmailChangedImplCopyWithImpl<$Res>;
|
|
||||||
@useResult
|
|
||||||
$Res call({String email});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$EmailChangedImplCopyWithImpl<$Res>
|
|
||||||
extends _$LoginFormEventCopyWithImpl<$Res, _$EmailChangedImpl>
|
|
||||||
implements _$$EmailChangedImplCopyWith<$Res> {
|
|
||||||
__$$EmailChangedImplCopyWithImpl(
|
|
||||||
_$EmailChangedImpl _value,
|
|
||||||
$Res Function(_$EmailChangedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? email = null}) {
|
|
||||||
return _then(
|
|
||||||
_$EmailChangedImpl(
|
|
||||||
null == email
|
|
||||||
? _value.email
|
|
||||||
: email // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$EmailChangedImpl implements _EmailChanged {
|
|
||||||
const _$EmailChangedImpl(this.email);
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String email;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'LoginFormEvent.emailChanged(email: $email)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$EmailChangedImpl &&
|
|
||||||
(identical(other.email, email) || other.email == email));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, email);
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$EmailChangedImplCopyWith<_$EmailChangedImpl> get copyWith =>
|
|
||||||
__$$EmailChangedImplCopyWithImpl<_$EmailChangedImpl>(this, _$identity);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(String email) emailChanged,
|
|
||||||
required TResult Function(String password) passwordChanged,
|
|
||||||
required TResult Function() submitted,
|
|
||||||
}) {
|
|
||||||
return emailChanged(email);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(String email)? emailChanged,
|
|
||||||
TResult? Function(String password)? passwordChanged,
|
|
||||||
TResult? Function()? submitted,
|
|
||||||
}) {
|
|
||||||
return emailChanged?.call(email);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(String email)? emailChanged,
|
|
||||||
TResult Function(String password)? passwordChanged,
|
|
||||||
TResult Function()? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (emailChanged != null) {
|
|
||||||
return emailChanged(email);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_EmailChanged value) emailChanged,
|
|
||||||
required TResult Function(_PasswordChanged value) passwordChanged,
|
|
||||||
required TResult Function(_Submitted value) submitted,
|
|
||||||
}) {
|
|
||||||
return emailChanged(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult? Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult? Function(_Submitted value)? submitted,
|
|
||||||
}) {
|
|
||||||
return emailChanged?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult Function(_Submitted value)? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (emailChanged != null) {
|
|
||||||
return emailChanged(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _EmailChanged implements LoginFormEvent {
|
|
||||||
const factory _EmailChanged(final String email) = _$EmailChangedImpl;
|
|
||||||
|
|
||||||
String get email;
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$EmailChangedImplCopyWith<_$EmailChangedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$PasswordChangedImplCopyWith<$Res> {
|
|
||||||
factory _$$PasswordChangedImplCopyWith(
|
|
||||||
_$PasswordChangedImpl value,
|
|
||||||
$Res Function(_$PasswordChangedImpl) then,
|
|
||||||
) = __$$PasswordChangedImplCopyWithImpl<$Res>;
|
|
||||||
@useResult
|
|
||||||
$Res call({String password});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$PasswordChangedImplCopyWithImpl<$Res>
|
|
||||||
extends _$LoginFormEventCopyWithImpl<$Res, _$PasswordChangedImpl>
|
|
||||||
implements _$$PasswordChangedImplCopyWith<$Res> {
|
|
||||||
__$$PasswordChangedImplCopyWithImpl(
|
|
||||||
_$PasswordChangedImpl _value,
|
|
||||||
$Res Function(_$PasswordChangedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? password = null}) {
|
|
||||||
return _then(
|
|
||||||
_$PasswordChangedImpl(
|
|
||||||
null == password
|
|
||||||
? _value.password
|
|
||||||
: password // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$PasswordChangedImpl implements _PasswordChanged {
|
|
||||||
const _$PasswordChangedImpl(this.password);
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String password;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'LoginFormEvent.passwordChanged(password: $password)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$PasswordChangedImpl &&
|
|
||||||
(identical(other.password, password) ||
|
|
||||||
other.password == password));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, password);
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
|
|
||||||
__$$PasswordChangedImplCopyWithImpl<_$PasswordChangedImpl>(
|
|
||||||
this,
|
|
||||||
_$identity,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(String email) emailChanged,
|
|
||||||
required TResult Function(String password) passwordChanged,
|
|
||||||
required TResult Function() submitted,
|
|
||||||
}) {
|
|
||||||
return passwordChanged(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(String email)? emailChanged,
|
|
||||||
TResult? Function(String password)? passwordChanged,
|
|
||||||
TResult? Function()? submitted,
|
|
||||||
}) {
|
|
||||||
return passwordChanged?.call(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(String email)? emailChanged,
|
|
||||||
TResult Function(String password)? passwordChanged,
|
|
||||||
TResult Function()? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (passwordChanged != null) {
|
|
||||||
return passwordChanged(password);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_EmailChanged value) emailChanged,
|
|
||||||
required TResult Function(_PasswordChanged value) passwordChanged,
|
|
||||||
required TResult Function(_Submitted value) submitted,
|
|
||||||
}) {
|
|
||||||
return passwordChanged(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult? Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult? Function(_Submitted value)? submitted,
|
|
||||||
}) {
|
|
||||||
return passwordChanged?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult Function(_Submitted value)? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (passwordChanged != null) {
|
|
||||||
return passwordChanged(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _PasswordChanged implements LoginFormEvent {
|
|
||||||
const factory _PasswordChanged(final String password) = _$PasswordChangedImpl;
|
|
||||||
|
|
||||||
String get password;
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$PasswordChangedImplCopyWith<_$PasswordChangedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$SubmittedImplCopyWith<$Res> {
|
|
||||||
factory _$$SubmittedImplCopyWith(
|
|
||||||
_$SubmittedImpl value,
|
|
||||||
$Res Function(_$SubmittedImpl) then,
|
|
||||||
) = __$$SubmittedImplCopyWithImpl<$Res>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$SubmittedImplCopyWithImpl<$Res>
|
|
||||||
extends _$LoginFormEventCopyWithImpl<$Res, _$SubmittedImpl>
|
|
||||||
implements _$$SubmittedImplCopyWith<$Res> {
|
|
||||||
__$$SubmittedImplCopyWithImpl(
|
|
||||||
_$SubmittedImpl _value,
|
|
||||||
$Res Function(_$SubmittedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$SubmittedImpl implements _Submitted {
|
|
||||||
const _$SubmittedImpl();
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'LoginFormEvent.submitted()';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType && other is _$SubmittedImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => runtimeType.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(String email) emailChanged,
|
|
||||||
required TResult Function(String password) passwordChanged,
|
|
||||||
required TResult Function() submitted,
|
|
||||||
}) {
|
|
||||||
return submitted();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(String email)? emailChanged,
|
|
||||||
TResult? Function(String password)? passwordChanged,
|
|
||||||
TResult? Function()? submitted,
|
|
||||||
}) {
|
|
||||||
return submitted?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(String email)? emailChanged,
|
|
||||||
TResult Function(String password)? passwordChanged,
|
|
||||||
TResult Function()? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (submitted != null) {
|
|
||||||
return submitted();
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_EmailChanged value) emailChanged,
|
|
||||||
required TResult Function(_PasswordChanged value) passwordChanged,
|
|
||||||
required TResult Function(_Submitted value) submitted,
|
|
||||||
}) {
|
|
||||||
return submitted(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult? Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult? Function(_Submitted value)? submitted,
|
|
||||||
}) {
|
|
||||||
return submitted?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_EmailChanged value)? emailChanged,
|
|
||||||
TResult Function(_PasswordChanged value)? passwordChanged,
|
|
||||||
TResult Function(_Submitted value)? submitted,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (submitted != null) {
|
|
||||||
return submitted(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Submitted implements LoginFormEvent {
|
|
||||||
const factory _Submitted() = _$SubmittedImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$LoginFormState {
|
|
||||||
String get email => throw _privateConstructorUsedError;
|
|
||||||
String get password => throw _privateConstructorUsedError;
|
|
||||||
Option<Either<AuthFailure, Login>> get failureOrLoginOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
bool get isSubmitting => throw _privateConstructorUsedError;
|
|
||||||
bool get showErrorMessages => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$LoginFormStateCopyWith<LoginFormState> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $LoginFormStateCopyWith<$Res> {
|
|
||||||
factory $LoginFormStateCopyWith(
|
|
||||||
LoginFormState value,
|
|
||||||
$Res Function(LoginFormState) then,
|
|
||||||
) = _$LoginFormStateCopyWithImpl<$Res, LoginFormState>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
String email,
|
|
||||||
String password,
|
|
||||||
Option<Either<AuthFailure, Login>> failureOrLoginOption,
|
|
||||||
bool isSubmitting,
|
|
||||||
bool showErrorMessages,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$LoginFormStateCopyWithImpl<$Res, $Val extends LoginFormState>
|
|
||||||
implements $LoginFormStateCopyWith<$Res> {
|
|
||||||
_$LoginFormStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? email = null,
|
|
||||||
Object? password = null,
|
|
||||||
Object? failureOrLoginOption = null,
|
|
||||||
Object? isSubmitting = null,
|
|
||||||
Object? showErrorMessages = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
email: null == email
|
|
||||||
? _value.email
|
|
||||||
: email // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
password: null == password
|
|
||||||
? _value.password
|
|
||||||
: password // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
failureOrLoginOption: null == failureOrLoginOption
|
|
||||||
? _value.failureOrLoginOption
|
|
||||||
: failureOrLoginOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<Either<AuthFailure, Login>>,
|
|
||||||
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 _$$LoginFormStateImplCopyWith<$Res>
|
|
||||||
implements $LoginFormStateCopyWith<$Res> {
|
|
||||||
factory _$$LoginFormStateImplCopyWith(
|
|
||||||
_$LoginFormStateImpl value,
|
|
||||||
$Res Function(_$LoginFormStateImpl) then,
|
|
||||||
) = __$$LoginFormStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
String email,
|
|
||||||
String password,
|
|
||||||
Option<Either<AuthFailure, Login>> failureOrLoginOption,
|
|
||||||
bool isSubmitting,
|
|
||||||
bool showErrorMessages,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$LoginFormStateImplCopyWithImpl<$Res>
|
|
||||||
extends _$LoginFormStateCopyWithImpl<$Res, _$LoginFormStateImpl>
|
|
||||||
implements _$$LoginFormStateImplCopyWith<$Res> {
|
|
||||||
__$$LoginFormStateImplCopyWithImpl(
|
|
||||||
_$LoginFormStateImpl _value,
|
|
||||||
$Res Function(_$LoginFormStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? email = null,
|
|
||||||
Object? password = null,
|
|
||||||
Object? failureOrLoginOption = null,
|
|
||||||
Object? isSubmitting = null,
|
|
||||||
Object? showErrorMessages = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$LoginFormStateImpl(
|
|
||||||
email: null == email
|
|
||||||
? _value.email
|
|
||||||
: email // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
password: null == password
|
|
||||||
? _value.password
|
|
||||||
: password // ignore: cast_nullable_to_non_nullable
|
|
||||||
as String,
|
|
||||||
failureOrLoginOption: null == failureOrLoginOption
|
|
||||||
? _value.failureOrLoginOption
|
|
||||||
: failureOrLoginOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<Either<AuthFailure, Login>>,
|
|
||||||
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 _$LoginFormStateImpl implements _LoginFormState {
|
|
||||||
const _$LoginFormStateImpl({
|
|
||||||
required this.email,
|
|
||||||
required this.password,
|
|
||||||
required this.failureOrLoginOption,
|
|
||||||
this.isSubmitting = false,
|
|
||||||
this.showErrorMessages = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
final String email;
|
|
||||||
@override
|
|
||||||
final String password;
|
|
||||||
@override
|
|
||||||
final Option<Either<AuthFailure, Login>> failureOrLoginOption;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isSubmitting;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool showErrorMessages;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'LoginFormState(email: $email, password: $password, failureOrLoginOption: $failureOrLoginOption, isSubmitting: $isSubmitting, showErrorMessages: $showErrorMessages)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$LoginFormStateImpl &&
|
|
||||||
(identical(other.email, email) || other.email == email) &&
|
|
||||||
(identical(other.password, password) ||
|
|
||||||
other.password == password) &&
|
|
||||||
(identical(other.failureOrLoginOption, failureOrLoginOption) ||
|
|
||||||
other.failureOrLoginOption == failureOrLoginOption) &&
|
|
||||||
(identical(other.isSubmitting, isSubmitting) ||
|
|
||||||
other.isSubmitting == isSubmitting) &&
|
|
||||||
(identical(other.showErrorMessages, showErrorMessages) ||
|
|
||||||
other.showErrorMessages == showErrorMessages));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(
|
|
||||||
runtimeType,
|
|
||||||
email,
|
|
||||||
password,
|
|
||||||
failureOrLoginOption,
|
|
||||||
isSubmitting,
|
|
||||||
showErrorMessages,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$LoginFormStateImplCopyWith<_$LoginFormStateImpl> get copyWith =>
|
|
||||||
__$$LoginFormStateImplCopyWithImpl<_$LoginFormStateImpl>(
|
|
||||||
this,
|
|
||||||
_$identity,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _LoginFormState implements LoginFormState {
|
|
||||||
const factory _LoginFormState({
|
|
||||||
required final String email,
|
|
||||||
required final String password,
|
|
||||||
required final Option<Either<AuthFailure, Login>> failureOrLoginOption,
|
|
||||||
final bool isSubmitting,
|
|
||||||
final bool showErrorMessages,
|
|
||||||
}) = _$LoginFormStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String get email;
|
|
||||||
@override
|
|
||||||
String get password;
|
|
||||||
@override
|
|
||||||
Option<Either<AuthFailure, Login>> get failureOrLoginOption;
|
|
||||||
@override
|
|
||||||
bool get isSubmitting;
|
|
||||||
@override
|
|
||||||
bool get showErrorMessages;
|
|
||||||
|
|
||||||
/// Create a copy of LoginFormState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$LoginFormStateImplCopyWith<_$LoginFormStateImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'login_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class LoginFormEvent with _$LoginFormEvent {
|
|
||||||
const factory LoginFormEvent.emailChanged(String email) = _EmailChanged;
|
|
||||||
const factory LoginFormEvent.passwordChanged(String password) =
|
|
||||||
_PasswordChanged;
|
|
||||||
const factory LoginFormEvent.submitted() = _Submitted;
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
part of 'login_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class LoginFormState with _$LoginFormState {
|
|
||||||
const factory LoginFormState({
|
|
||||||
required String email,
|
|
||||||
required String password,
|
|
||||||
required Option<Either<AuthFailure, Login>> failureOrLoginOption,
|
|
||||||
@Default(false) bool isSubmitting,
|
|
||||||
@Default(false) bool showErrorMessages,
|
|
||||||
}) = _LoginFormState;
|
|
||||||
|
|
||||||
factory LoginFormState.initial() =>
|
|
||||||
LoginFormState(email: '', password: '', failureOrLoginOption: none());
|
|
||||||
}
|
|
||||||
@ -1,314 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
|
|
||||||
import '../../../domain/category/category.dart';
|
|
||||||
|
|
||||||
part 'category_loader_event.dart';
|
|
||||||
part 'category_loader_state.dart';
|
|
||||||
part 'category_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class CategoryLoaderBloc
|
|
||||||
extends Bloc<CategoryLoaderEvent, CategoryLoaderState> {
|
|
||||||
final ICategoryRepository _categoryRepository;
|
|
||||||
|
|
||||||
Timer? _searchDebounce;
|
|
||||||
bool _isLoadingMore = false;
|
|
||||||
|
|
||||||
CategoryLoaderBloc(this._categoryRepository)
|
|
||||||
: super(CategoryLoaderState.initial()) {
|
|
||||||
on<CategoryLoaderEvent>(_onCategoryLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onCategoryLoaderEvent(
|
|
||||||
CategoryLoaderEvent event,
|
|
||||||
Emitter<CategoryLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
getCategories: (e) async {
|
|
||||||
emit(state.copyWith(isLoadingMore: true));
|
|
||||||
|
|
||||||
log(
|
|
||||||
'📱 Loading categories - isActive: ${e.isActive}, forceRemote: ${e.forceRemote}',
|
|
||||||
);
|
|
||||||
|
|
||||||
final result = await _categoryRepository.getCategories(
|
|
||||||
page: 1,
|
|
||||||
limit: 50,
|
|
||||||
isActive: e.isActive,
|
|
||||||
search: e.search,
|
|
||||||
forceRemote: e.forceRemote,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isLoadingMore: false,
|
|
||||||
failureOptionCategory: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(response) async {
|
|
||||||
final categories = [Category.all(), ...response.categories];
|
|
||||||
|
|
||||||
final totalPages = response.totalPages;
|
|
||||||
final hasReachedMax = categories.length < 50 || 1 >= totalPages;
|
|
||||||
|
|
||||||
log(
|
|
||||||
'âś… Categories loaded: ${categories.length}, hasReachedMax: $hasReachedMax',
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
categories: categories,
|
|
||||||
page: 1,
|
|
||||||
hasReachedMax: hasReachedMax,
|
|
||||||
isLoadingMore: false,
|
|
||||||
failureOptionCategory: none(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
loadMore: (e) async {
|
|
||||||
final currentState = state;
|
|
||||||
|
|
||||||
// ❌ HAPUS pengecekan is! _Loaded karena state cuma 1 class doang
|
|
||||||
if (currentState.hasReachedMax ||
|
|
||||||
_isLoadingMore ||
|
|
||||||
currentState.isLoadingMore) {
|
|
||||||
log(
|
|
||||||
'⏹️ Load more blocked - hasReachedMax: ${currentState.hasReachedMax}, isLoadingMore: $_isLoadingMore',
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_isLoadingMore = true;
|
|
||||||
emit(currentState.copyWith(isLoadingMore: true));
|
|
||||||
|
|
||||||
final nextPage = currentState.page + 1; // âś… Ganti currentPage jadi page
|
|
||||||
log('đź“„ Loading more categories - page: $nextPage');
|
|
||||||
|
|
||||||
try {
|
|
||||||
final result = await _categoryRepository.getCategories(
|
|
||||||
page: nextPage,
|
|
||||||
limit: 10,
|
|
||||||
isActive: true,
|
|
||||||
search: currentState.searchQuery,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
log('❌ Error loading more categories: $failure');
|
|
||||||
emit(currentState.copyWith(isLoadingMore: false));
|
|
||||||
},
|
|
||||||
(response) async {
|
|
||||||
final newCategories = response.categories;
|
|
||||||
final totalPages = response.totalPages;
|
|
||||||
|
|
||||||
// Prevent duplicate categories
|
|
||||||
final currentCategoryIds = currentState.categories
|
|
||||||
.map((c) => c.id)
|
|
||||||
.toSet();
|
|
||||||
final filteredNewCategories = newCategories
|
|
||||||
.where(
|
|
||||||
(category) => !currentCategoryIds.contains(category.id),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
final allCategories = List<Category>.from(currentState.categories)
|
|
||||||
..addAll(filteredNewCategories);
|
|
||||||
|
|
||||||
final hasReachedMax =
|
|
||||||
newCategories.length < 10 || nextPage >= totalPages;
|
|
||||||
|
|
||||||
log(
|
|
||||||
'âś… More categories loaded: ${filteredNewCategories.length} new, total: ${allCategories.length}',
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
currentState.copyWith(
|
|
||||||
categories: allCategories,
|
|
||||||
hasReachedMax: hasReachedMax,
|
|
||||||
page: nextPage, // âś… Update page
|
|
||||||
isLoadingMore: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
log('❌ Exception loading more categories: $e');
|
|
||||||
emit(currentState.copyWith(isLoadingMore: false));
|
|
||||||
} finally {
|
|
||||||
_isLoadingMore = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
refresh: (e) async {
|
|
||||||
final currentState = state;
|
|
||||||
bool isActive = true;
|
|
||||||
String? searchQuery = currentState.searchQuery;
|
|
||||||
|
|
||||||
_isLoadingMore = false;
|
|
||||||
_searchDebounce?.cancel();
|
|
||||||
|
|
||||||
log('🔄 Refreshing categories');
|
|
||||||
|
|
||||||
// Clear local cache
|
|
||||||
_categoryRepository.clearCache();
|
|
||||||
|
|
||||||
add(
|
|
||||||
CategoryLoaderEvent.getCategories(
|
|
||||||
isActive: isActive,
|
|
||||||
search: searchQuery,
|
|
||||||
forceRemote: true, // Force remote refresh
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
search: (e) async {
|
|
||||||
// Cancel previous search
|
|
||||||
_searchDebounce?.cancel();
|
|
||||||
|
|
||||||
// Debounce search for better UX
|
|
||||||
_searchDebounce = Timer(Duration(milliseconds: 300), () async {
|
|
||||||
emit(state.copyWith(isLoadingMore: true));
|
|
||||||
_isLoadingMore = false;
|
|
||||||
|
|
||||||
log('🔍 Searching categories: "${e.query}"');
|
|
||||||
|
|
||||||
final result = await _categoryRepository.getCategories(
|
|
||||||
page: 1,
|
|
||||||
limit: 20, // More results for search
|
|
||||||
isActive: e.isActive,
|
|
||||||
search: e.query,
|
|
||||||
);
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
log('❌ Search error: $failure');
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isLoadingMore: false,
|
|
||||||
failureOptionCategory: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
(response) async {
|
|
||||||
final categories = [Category.all(), ...response.categories];
|
|
||||||
final totalPages = response.totalPages;
|
|
||||||
final hasReachedMax = categories.length < 20 || 1 >= totalPages;
|
|
||||||
|
|
||||||
log('âś… Search results: ${categories.length} categories found');
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
categories: categories,
|
|
||||||
hasReachedMax: hasReachedMax,
|
|
||||||
page: 1,
|
|
||||||
isLoadingMore: false,
|
|
||||||
failureOptionCategory: none(),
|
|
||||||
searchQuery: e.query,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
syncAll: (e) async {
|
|
||||||
emit(state.copyWith(isLoadingMore: true));
|
|
||||||
|
|
||||||
log('🔄 Starting full category sync...');
|
|
||||||
|
|
||||||
final result = await _categoryRepository.syncAllCategories();
|
|
||||||
|
|
||||||
await result.fold(
|
|
||||||
(failure) async {
|
|
||||||
log('❌ Sync failed: $failure');
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isLoadingMore: false,
|
|
||||||
failureOptionCategory: optionOf(failure),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// After sync error, try to load local data
|
|
||||||
Timer(Duration(seconds: 2), () {
|
|
||||||
add(const CategoryLoaderEvent.getCategories());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
(successMessage) async {
|
|
||||||
log('âś… Sync completed: $successMessage');
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isLoadingMore: false,
|
|
||||||
failureOptionCategory: none(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// After successful sync, load the updated data
|
|
||||||
Timer(Duration(seconds: 1), () {
|
|
||||||
add(const CategoryLoaderEvent.getCategories());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
},
|
|
||||||
getAllCategories: (e) async {
|
|
||||||
try {
|
|
||||||
log('đź“‹ Loading all categories for dropdown...');
|
|
||||||
|
|
||||||
// final categories = await _categoryRepository.getAllCategories();
|
|
||||||
|
|
||||||
// emit(
|
|
||||||
// state.copyWith(
|
|
||||||
// categories: categories,
|
|
||||||
// isLoadingMore: false,
|
|
||||||
// failureOptionCategory: none(),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// log('âś… All categories loaded: ${categories.length}');
|
|
||||||
} catch (e) {
|
|
||||||
log('❌ Error loading all categories: $e');
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isLoadingMore: false,
|
|
||||||
failureOptionCategory: optionOf(
|
|
||||||
CategoryFailure.dynamicErrorMessage(
|
|
||||||
'Gagal memuat semua kategori: $e',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getDatabaseStats: (e) async {
|
|
||||||
try {
|
|
||||||
final stats = await _categoryRepository.getDatabaseStats();
|
|
||||||
log('📊 Category database stats retrieved: $stats');
|
|
||||||
|
|
||||||
// You can emit a special state here if needed for UI updates
|
|
||||||
// For now, just log the stats
|
|
||||||
} catch (e) {
|
|
||||||
log('❌ Error getting category database stats: $e');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
clearCache: (e) async {
|
|
||||||
log('đź§ą Manually clearing category cache');
|
|
||||||
_categoryRepository.clearCache();
|
|
||||||
|
|
||||||
// Refresh current data after cache clear
|
|
||||||
add(const CategoryLoaderEvent.refresh());
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> close() {
|
|
||||||
_searchDebounce?.cancel();
|
|
||||||
return super.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
part of 'category_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CategoryLoaderEvent with _$CategoryLoaderEvent {
|
|
||||||
const factory CategoryLoaderEvent.getCategories({
|
|
||||||
@Default(true) bool isActive,
|
|
||||||
String? search,
|
|
||||||
@Default(false) bool forceRemote,
|
|
||||||
}) = _GetCategories;
|
|
||||||
|
|
||||||
const factory CategoryLoaderEvent.loadMore() = _LoadMore;
|
|
||||||
|
|
||||||
const factory CategoryLoaderEvent.refresh() = _Refresh;
|
|
||||||
|
|
||||||
const factory CategoryLoaderEvent.search({
|
|
||||||
required String query,
|
|
||||||
@Default(true) bool isActive,
|
|
||||||
}) = _Search;
|
|
||||||
|
|
||||||
const factory CategoryLoaderEvent.syncAll() = _SyncAll;
|
|
||||||
|
|
||||||
const factory CategoryLoaderEvent.getAllCategories() = _GetAllCategories;
|
|
||||||
|
|
||||||
const factory CategoryLoaderEvent.getDatabaseStats() = _GetDatabaseStats;
|
|
||||||
|
|
||||||
const factory CategoryLoaderEvent.clearCache() = _ClearCache;
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
part of 'category_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CategoryLoaderState with _$CategoryLoaderState {
|
|
||||||
factory CategoryLoaderState({
|
|
||||||
required List<Category> categories,
|
|
||||||
required Option<CategoryFailure> failureOptionCategory,
|
|
||||||
@Default(false) bool hasReachedMax,
|
|
||||||
@Default(1) int page,
|
|
||||||
@Default(false) bool isLoadingMore,
|
|
||||||
String? searchQuery,
|
|
||||||
}) = _CategoryLoaderState;
|
|
||||||
|
|
||||||
factory CategoryLoaderState.initial() =>
|
|
||||||
CategoryLoaderState(categories: [], failureOptionCategory: none());
|
|
||||||
}
|
|
||||||
@ -1,185 +0,0 @@
|
|||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart' hide Order;
|
|
||||||
|
|
||||||
import '../../../common/types/order_type.dart';
|
|
||||||
import '../../../domain/delivery/delivery.dart';
|
|
||||||
import '../../../domain/order/order.dart';
|
|
||||||
import '../../../domain/product/product.dart';
|
|
||||||
import '../../../domain/table/table.dart';
|
|
||||||
|
|
||||||
part 'checkout_form_event.dart';
|
|
||||||
part 'checkout_form_state.dart';
|
|
||||||
part 'checkout_form_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class CheckoutFormBloc extends Bloc<CheckoutFormEvent, CheckoutFormState> {
|
|
||||||
CheckoutFormBloc() : super(CheckoutFormState.initial()) {
|
|
||||||
on<CheckoutFormEvent>(_onCheckoutFormEvent);
|
|
||||||
}
|
|
||||||
Future<void> _onCheckoutFormEvent(
|
|
||||||
CheckoutFormEvent event,
|
|
||||||
Emitter<CheckoutFormState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
addItem: (e) async {
|
|
||||||
final currentState = state;
|
|
||||||
emit(currentState.copyWith(isLoading: true));
|
|
||||||
|
|
||||||
List<ProductQuantity> items = [...currentState.items];
|
|
||||||
|
|
||||||
final index = items.indexWhere(
|
|
||||||
(element) =>
|
|
||||||
element.product.id == e.product.id &&
|
|
||||||
element.variant?.id == e.variant?.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (index != -1) {
|
|
||||||
// Jika sudah ada → tambah quantity
|
|
||||||
items[index] = items[index].copyWith(
|
|
||||||
quantity: items[index].quantity + 1,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Jika belum ada → tambahkan item baru
|
|
||||||
items.add(
|
|
||||||
ProductQuantity(
|
|
||||||
product: e.product,
|
|
||||||
quantity: 1,
|
|
||||||
variant: e.variant,
|
|
||||||
notes: '',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
log('đź›’ Items updated: ${items.length} items total ${items.toList()}');
|
|
||||||
|
|
||||||
final totalQuantity = items.fold<int>(
|
|
||||||
0,
|
|
||||||
(sum, item) => sum + item.quantity,
|
|
||||||
);
|
|
||||||
|
|
||||||
final totalPrice = state.items.isEmpty
|
|
||||||
? 0.0
|
|
||||||
: state.items
|
|
||||||
.map(
|
|
||||||
(e) =>
|
|
||||||
(e.product.price * e.quantity) +
|
|
||||||
(e.variant?.priceModifier ?? 0),
|
|
||||||
)
|
|
||||||
.reduce((value, element) => value + element);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
currentState.copyWith(
|
|
||||||
items: items,
|
|
||||||
totalQuantity: totalQuantity,
|
|
||||||
totalPrice: totalPrice.toInt(),
|
|
||||||
isLoading: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
removeItem: (e) async {
|
|
||||||
final currentState = state;
|
|
||||||
emit(currentState.copyWith(isLoading: true));
|
|
||||||
List<ProductQuantity> items = [...currentState.items];
|
|
||||||
|
|
||||||
final index = items.indexWhere(
|
|
||||||
(element) =>
|
|
||||||
element.product.id == e.product.id &&
|
|
||||||
element.variant?.id == e.variant?.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (index != -1) {
|
|
||||||
final currentItem = items[index];
|
|
||||||
if (currentItem.quantity > 1) {
|
|
||||||
// Kurangi quantity
|
|
||||||
items[index] = currentItem.copyWith(
|
|
||||||
quantity: currentItem.quantity - 1,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Hapus item kalau quantity = 1
|
|
||||||
items.removeAt(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final totalQuantity = items.fold<int>(
|
|
||||||
0,
|
|
||||||
(sum, item) => sum + item.quantity,
|
|
||||||
);
|
|
||||||
final totalPrice = items.fold<int>(
|
|
||||||
0,
|
|
||||||
(sum, item) =>
|
|
||||||
sum +
|
|
||||||
(item.quantity *
|
|
||||||
(item.variant?.priceModifier.toInt() ??
|
|
||||||
item.product.price.toInt())),
|
|
||||||
);
|
|
||||||
|
|
||||||
log(
|
|
||||||
'🗑️ Item removed. Total items: ${items.length}, totalQuantity: $totalQuantity, totalPrice: $totalPrice',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Emit state baru
|
|
||||||
emit(
|
|
||||||
currentState.copyWith(
|
|
||||||
items: items,
|
|
||||||
totalQuantity: totalQuantity,
|
|
||||||
totalPrice: totalPrice,
|
|
||||||
isLoading: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
started: (e) async {
|
|
||||||
emit(CheckoutFormState.initial().copyWith(isLoading: true));
|
|
||||||
try {
|
|
||||||
emit(
|
|
||||||
CheckoutFormState.initial().copyWith(
|
|
||||||
items: e.items,
|
|
||||||
tax: 0,
|
|
||||||
serviceCharge: 0,
|
|
||||||
isLoading: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
// Kalau gagal, pakai default values
|
|
||||||
log('⚠️ Failed to load settings: $e');
|
|
||||||
emit(
|
|
||||||
CheckoutFormState.initial().copyWith(
|
|
||||||
tax: 10,
|
|
||||||
serviceCharge: 5,
|
|
||||||
isLoading: false,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateItemNotes: (e) async {
|
|
||||||
final currentState = state;
|
|
||||||
|
|
||||||
// Clone list items agar tidak mutasi langsung
|
|
||||||
final items = [...currentState.items];
|
|
||||||
final index = items.indexWhere(
|
|
||||||
(element) => element.product.id == e.product.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (index != -1) {
|
|
||||||
items[index] = items[index].copyWith(notes: e.notes);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(currentState.copyWith(items: items, isLoading: false));
|
|
||||||
},
|
|
||||||
updateOrderType: (e) async {
|
|
||||||
emit(state.copyWith(orderType: e.orderType));
|
|
||||||
},
|
|
||||||
updateDelivery: (e) async {
|
|
||||||
emit(state.copyWith(delivery: e.delivery));
|
|
||||||
},
|
|
||||||
updateTable: (e) async {
|
|
||||||
emit(state.copyWith(table: e.table));
|
|
||||||
},
|
|
||||||
orderAddedItems: (e) async {
|
|
||||||
emit(state.copyWith(orderAdded: e.order));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,33 +0,0 @@
|
|||||||
part of 'checkout_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CheckoutFormEvent with _$CheckoutFormEvent {
|
|
||||||
const factory CheckoutFormEvent.started(List<ProductQuantity> items) =
|
|
||||||
_Started;
|
|
||||||
|
|
||||||
const factory CheckoutFormEvent.addItem(
|
|
||||||
Product product,
|
|
||||||
ProductVariant? variant,
|
|
||||||
) = _AddItem;
|
|
||||||
|
|
||||||
const factory CheckoutFormEvent.removeItem(
|
|
||||||
Product product,
|
|
||||||
ProductVariant? variant,
|
|
||||||
) = _RemoveItem;
|
|
||||||
|
|
||||||
const factory CheckoutFormEvent.updateItemNotes(
|
|
||||||
Product product,
|
|
||||||
String notes,
|
|
||||||
) = _UpdateItemNotes;
|
|
||||||
|
|
||||||
const factory CheckoutFormEvent.updateOrderType(OrderType orderType) =
|
|
||||||
_UpdateOrderType;
|
|
||||||
|
|
||||||
const factory CheckoutFormEvent.updateDelivery(Delivery delivery) =
|
|
||||||
_UpdateDelivery;
|
|
||||||
|
|
||||||
const factory CheckoutFormEvent.updateTable(Table? table) = _UpdateTable;
|
|
||||||
|
|
||||||
const factory CheckoutFormEvent.orderAddedItems(Order? order) =
|
|
||||||
_OrderAddedItems;
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
part of 'checkout_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CheckoutFormState with _$CheckoutFormState {
|
|
||||||
factory CheckoutFormState({
|
|
||||||
Order? orderAdded,
|
|
||||||
required List<ProductQuantity> items,
|
|
||||||
required int discount,
|
|
||||||
required int discountAmount,
|
|
||||||
required int tax,
|
|
||||||
required int serviceCharge,
|
|
||||||
required int totalQuantity,
|
|
||||||
required int totalPrice,
|
|
||||||
required String draftName,
|
|
||||||
required OrderType orderType,
|
|
||||||
Delivery? delivery,
|
|
||||||
Table? table,
|
|
||||||
@Default(false) bool isLoading,
|
|
||||||
}) = _CheckoutFormState;
|
|
||||||
|
|
||||||
factory CheckoutFormState.initial() => CheckoutFormState(
|
|
||||||
items: [],
|
|
||||||
discount: 0,
|
|
||||||
discountAmount: 0,
|
|
||||||
tax: 0,
|
|
||||||
serviceCharge: 0,
|
|
||||||
totalQuantity: 0,
|
|
||||||
totalPrice: 0,
|
|
||||||
draftName: '',
|
|
||||||
orderType: OrderType.dineIn,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,82 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart';
|
|
||||||
import '../../../domain/customer/customer.dart';
|
|
||||||
|
|
||||||
part 'customer_loader_event.dart';
|
|
||||||
part 'customer_loader_state.dart';
|
|
||||||
part 'customer_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class CustomerLoaderBloc
|
|
||||||
extends Bloc<CustomerLoaderEvent, CustomerLoaderState> {
|
|
||||||
final ICustomerRepository _repository;
|
|
||||||
CustomerLoaderBloc(this._repository) : super(CustomerLoaderState.initial()) {
|
|
||||||
on<CustomerLoaderEvent>(_onCustomerLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onCustomerLoaderEvent(
|
|
||||||
CustomerLoaderEvent event,
|
|
||||||
Emitter<CustomerLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
fetched: (e) async {
|
|
||||||
var newState = state;
|
|
||||||
|
|
||||||
if (e.isRefresh) {
|
|
||||||
newState = newState.copyWith(isFetching: true);
|
|
||||||
emit(newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
newState = await _mapFetchedToState(newState, isRefresh: e.isRefresh);
|
|
||||||
|
|
||||||
emit(newState);
|
|
||||||
},
|
|
||||||
setSelectedCustomer: (e) async {
|
|
||||||
emit(state.copyWith(selectedCustomer: e.customer));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<CustomerLoaderState> _mapFetchedToState(
|
|
||||||
CustomerLoaderState state, {
|
|
||||||
bool isRefresh = false,
|
|
||||||
}) async {
|
|
||||||
state = state.copyWith(isFetching: false);
|
|
||||||
|
|
||||||
if (state.hasReachedMax && state.customers.isNotEmpty && !isRefresh) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRefresh) {
|
|
||||||
state = state.copyWith(
|
|
||||||
page: 1,
|
|
||||||
failureOrOption: none(),
|
|
||||||
hasReachedMax: false,
|
|
||||||
customers: [],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final failureOrCustomer = await _repository.getCustomer(page: state.page);
|
|
||||||
|
|
||||||
state = failureOrCustomer.fold(
|
|
||||||
(f) {
|
|
||||||
if (state.customers.isNotEmpty) {
|
|
||||||
return state.copyWith(hasReachedMax: true);
|
|
||||||
}
|
|
||||||
return state.copyWith(failureOrOption: optionOf(f));
|
|
||||||
},
|
|
||||||
(customers) {
|
|
||||||
return state.copyWith(
|
|
||||||
customers: List.from(state.customers)..addAll(customers.customers),
|
|
||||||
failureOrOption: none(),
|
|
||||||
page: state.page + 1,
|
|
||||||
hasReachedMax: customers.customers.length < 10,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,668 +0,0 @@
|
|||||||
// coverage:ignore-file
|
|
||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
// ignore_for_file: type=lint
|
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
||||||
|
|
||||||
part of 'customer_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 _$CustomerLoaderEvent {
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(Customer customer) setSelectedCustomer,
|
|
||||||
required TResult Function(bool isRefresh) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(Customer customer)? setSelectedCustomer,
|
|
||||||
TResult? Function(bool isRefresh)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(Customer customer)? setSelectedCustomer,
|
|
||||||
TResult Function(bool isRefresh)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_SetSelectedCustomer value) setSelectedCustomer,
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) => throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $CustomerLoaderEventCopyWith<$Res> {
|
|
||||||
factory $CustomerLoaderEventCopyWith(
|
|
||||||
CustomerLoaderEvent value,
|
|
||||||
$Res Function(CustomerLoaderEvent) then,
|
|
||||||
) = _$CustomerLoaderEventCopyWithImpl<$Res, CustomerLoaderEvent>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$CustomerLoaderEventCopyWithImpl<$Res, $Val extends CustomerLoaderEvent>
|
|
||||||
implements $CustomerLoaderEventCopyWith<$Res> {
|
|
||||||
_$CustomerLoaderEventCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$SetSelectedCustomerImplCopyWith<$Res> {
|
|
||||||
factory _$$SetSelectedCustomerImplCopyWith(
|
|
||||||
_$SetSelectedCustomerImpl value,
|
|
||||||
$Res Function(_$SetSelectedCustomerImpl) then,
|
|
||||||
) = __$$SetSelectedCustomerImplCopyWithImpl<$Res>;
|
|
||||||
@useResult
|
|
||||||
$Res call({Customer customer});
|
|
||||||
|
|
||||||
$CustomerCopyWith<$Res> get customer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$SetSelectedCustomerImplCopyWithImpl<$Res>
|
|
||||||
extends _$CustomerLoaderEventCopyWithImpl<$Res, _$SetSelectedCustomerImpl>
|
|
||||||
implements _$$SetSelectedCustomerImplCopyWith<$Res> {
|
|
||||||
__$$SetSelectedCustomerImplCopyWithImpl(
|
|
||||||
_$SetSelectedCustomerImpl _value,
|
|
||||||
$Res Function(_$SetSelectedCustomerImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({Object? customer = null}) {
|
|
||||||
return _then(
|
|
||||||
_$SetSelectedCustomerImpl(
|
|
||||||
null == customer
|
|
||||||
? _value.customer
|
|
||||||
: customer // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Customer,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$CustomerCopyWith<$Res> get customer {
|
|
||||||
return $CustomerCopyWith<$Res>(_value.customer, (value) {
|
|
||||||
return _then(_value.copyWith(customer: value));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
|
|
||||||
class _$SetSelectedCustomerImpl implements _SetSelectedCustomer {
|
|
||||||
const _$SetSelectedCustomerImpl(this.customer);
|
|
||||||
|
|
||||||
@override
|
|
||||||
final Customer customer;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'CustomerLoaderEvent.setSelectedCustomer(customer: $customer)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$SetSelectedCustomerImpl &&
|
|
||||||
(identical(other.customer, customer) ||
|
|
||||||
other.customer == customer));
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => Object.hash(runtimeType, customer);
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$SetSelectedCustomerImplCopyWith<_$SetSelectedCustomerImpl> get copyWith =>
|
|
||||||
__$$SetSelectedCustomerImplCopyWithImpl<_$SetSelectedCustomerImpl>(
|
|
||||||
this,
|
|
||||||
_$identity,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult when<TResult extends Object?>({
|
|
||||||
required TResult Function(Customer customer) setSelectedCustomer,
|
|
||||||
required TResult Function(bool isRefresh) fetched,
|
|
||||||
}) {
|
|
||||||
return setSelectedCustomer(customer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(Customer customer)? setSelectedCustomer,
|
|
||||||
TResult? Function(bool isRefresh)? fetched,
|
|
||||||
}) {
|
|
||||||
return setSelectedCustomer?.call(customer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(Customer customer)? setSelectedCustomer,
|
|
||||||
TResult Function(bool isRefresh)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (setSelectedCustomer != null) {
|
|
||||||
return setSelectedCustomer(customer);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult map<TResult extends Object?>({
|
|
||||||
required TResult Function(_SetSelectedCustomer value) setSelectedCustomer,
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return setSelectedCustomer(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return setSelectedCustomer?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (setSelectedCustomer != null) {
|
|
||||||
return setSelectedCustomer(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _SetSelectedCustomer implements CustomerLoaderEvent {
|
|
||||||
const factory _SetSelectedCustomer(final Customer customer) =
|
|
||||||
_$SetSelectedCustomerImpl;
|
|
||||||
|
|
||||||
Customer get customer;
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$SetSelectedCustomerImplCopyWith<_$SetSelectedCustomerImpl> 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 _$CustomerLoaderEventCopyWithImpl<$Res, _$FetchedImpl>
|
|
||||||
implements _$$FetchedImplCopyWith<$Res> {
|
|
||||||
__$$FetchedImplCopyWithImpl(
|
|
||||||
_$FetchedImpl _value,
|
|
||||||
$Res Function(_$FetchedImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderEvent
|
|
||||||
/// 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 'CustomerLoaderEvent.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 CustomerLoaderEvent
|
|
||||||
/// 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(Customer customer) setSelectedCustomer,
|
|
||||||
required TResult Function(bool isRefresh) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? whenOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(Customer customer)? setSelectedCustomer,
|
|
||||||
TResult? Function(bool isRefresh)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(isRefresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeWhen<TResult extends Object?>({
|
|
||||||
TResult Function(Customer customer)? setSelectedCustomer,
|
|
||||||
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(_SetSelectedCustomer value) setSelectedCustomer,
|
|
||||||
required TResult Function(_Fetched value) fetched,
|
|
||||||
}) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult? mapOrNull<TResult extends Object?>({
|
|
||||||
TResult? Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
|
||||||
TResult? Function(_Fetched value)? fetched,
|
|
||||||
}) {
|
|
||||||
return fetched?.call(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
@optionalTypeArgs
|
|
||||||
TResult maybeMap<TResult extends Object?>({
|
|
||||||
TResult Function(_SetSelectedCustomer value)? setSelectedCustomer,
|
|
||||||
TResult Function(_Fetched value)? fetched,
|
|
||||||
required TResult orElse(),
|
|
||||||
}) {
|
|
||||||
if (fetched != null) {
|
|
||||||
return fetched(this);
|
|
||||||
}
|
|
||||||
return orElse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _Fetched implements CustomerLoaderEvent {
|
|
||||||
const factory _Fetched({final bool isRefresh}) = _$FetchedImpl;
|
|
||||||
|
|
||||||
bool get isRefresh;
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderEvent
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$FetchedImplCopyWith<_$FetchedImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
mixin _$CustomerLoaderState {
|
|
||||||
List<Customer> get customers => throw _privateConstructorUsedError;
|
|
||||||
Option<CustomerFailure> get failureOrOption =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
Customer? get selectedCustomer => throw _privateConstructorUsedError;
|
|
||||||
bool get isFetching => throw _privateConstructorUsedError;
|
|
||||||
bool get hasReachedMax => throw _privateConstructorUsedError;
|
|
||||||
int get page => throw _privateConstructorUsedError;
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
$CustomerLoaderStateCopyWith<CustomerLoaderState> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class $CustomerLoaderStateCopyWith<$Res> {
|
|
||||||
factory $CustomerLoaderStateCopyWith(
|
|
||||||
CustomerLoaderState value,
|
|
||||||
$Res Function(CustomerLoaderState) then,
|
|
||||||
) = _$CustomerLoaderStateCopyWithImpl<$Res, CustomerLoaderState>;
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
List<Customer> customers,
|
|
||||||
Option<CustomerFailure> failureOrOption,
|
|
||||||
Customer? selectedCustomer,
|
|
||||||
bool isFetching,
|
|
||||||
bool hasReachedMax,
|
|
||||||
int page,
|
|
||||||
});
|
|
||||||
|
|
||||||
$CustomerCopyWith<$Res>? get selectedCustomer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class _$CustomerLoaderStateCopyWithImpl<$Res, $Val extends CustomerLoaderState>
|
|
||||||
implements $CustomerLoaderStateCopyWith<$Res> {
|
|
||||||
_$CustomerLoaderStateCopyWithImpl(this._value, this._then);
|
|
||||||
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Val _value;
|
|
||||||
// ignore: unused_field
|
|
||||||
final $Res Function($Val) _then;
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? customers = null,
|
|
||||||
Object? failureOrOption = null,
|
|
||||||
Object? selectedCustomer = freezed,
|
|
||||||
Object? isFetching = null,
|
|
||||||
Object? hasReachedMax = null,
|
|
||||||
Object? page = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_value.copyWith(
|
|
||||||
customers: null == customers
|
|
||||||
? _value.customers
|
|
||||||
: customers // ignore: cast_nullable_to_non_nullable
|
|
||||||
as List<Customer>,
|
|
||||||
failureOrOption: null == failureOrOption
|
|
||||||
? _value.failureOrOption
|
|
||||||
: failureOrOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<CustomerFailure>,
|
|
||||||
selectedCustomer: freezed == selectedCustomer
|
|
||||||
? _value.selectedCustomer
|
|
||||||
: selectedCustomer // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Customer?,
|
|
||||||
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,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
$CustomerCopyWith<$Res>? get selectedCustomer {
|
|
||||||
if (_value.selectedCustomer == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $CustomerCopyWith<$Res>(_value.selectedCustomer!, (value) {
|
|
||||||
return _then(_value.copyWith(selectedCustomer: value) as $Val);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
abstract class _$$CustomerLoaderStateImplCopyWith<$Res>
|
|
||||||
implements $CustomerLoaderStateCopyWith<$Res> {
|
|
||||||
factory _$$CustomerLoaderStateImplCopyWith(
|
|
||||||
_$CustomerLoaderStateImpl value,
|
|
||||||
$Res Function(_$CustomerLoaderStateImpl) then,
|
|
||||||
) = __$$CustomerLoaderStateImplCopyWithImpl<$Res>;
|
|
||||||
@override
|
|
||||||
@useResult
|
|
||||||
$Res call({
|
|
||||||
List<Customer> customers,
|
|
||||||
Option<CustomerFailure> failureOrOption,
|
|
||||||
Customer? selectedCustomer,
|
|
||||||
bool isFetching,
|
|
||||||
bool hasReachedMax,
|
|
||||||
int page,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
$CustomerCopyWith<$Res>? get selectedCustomer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @nodoc
|
|
||||||
class __$$CustomerLoaderStateImplCopyWithImpl<$Res>
|
|
||||||
extends _$CustomerLoaderStateCopyWithImpl<$Res, _$CustomerLoaderStateImpl>
|
|
||||||
implements _$$CustomerLoaderStateImplCopyWith<$Res> {
|
|
||||||
__$$CustomerLoaderStateImplCopyWithImpl(
|
|
||||||
_$CustomerLoaderStateImpl _value,
|
|
||||||
$Res Function(_$CustomerLoaderStateImpl) _then,
|
|
||||||
) : super(_value, _then);
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
@override
|
|
||||||
$Res call({
|
|
||||||
Object? customers = null,
|
|
||||||
Object? failureOrOption = null,
|
|
||||||
Object? selectedCustomer = freezed,
|
|
||||||
Object? isFetching = null,
|
|
||||||
Object? hasReachedMax = null,
|
|
||||||
Object? page = null,
|
|
||||||
}) {
|
|
||||||
return _then(
|
|
||||||
_$CustomerLoaderStateImpl(
|
|
||||||
customers: null == customers
|
|
||||||
? _value._customers
|
|
||||||
: customers // ignore: cast_nullable_to_non_nullable
|
|
||||||
as List<Customer>,
|
|
||||||
failureOrOption: null == failureOrOption
|
|
||||||
? _value.failureOrOption
|
|
||||||
: failureOrOption // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Option<CustomerFailure>,
|
|
||||||
selectedCustomer: freezed == selectedCustomer
|
|
||||||
? _value.selectedCustomer
|
|
||||||
: selectedCustomer // ignore: cast_nullable_to_non_nullable
|
|
||||||
as Customer?,
|
|
||||||
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 _$CustomerLoaderStateImpl implements _CustomerLoaderState {
|
|
||||||
_$CustomerLoaderStateImpl({
|
|
||||||
required final List<Customer> customers,
|
|
||||||
required this.failureOrOption,
|
|
||||||
this.selectedCustomer,
|
|
||||||
this.isFetching = false,
|
|
||||||
this.hasReachedMax = false,
|
|
||||||
this.page = 1,
|
|
||||||
}) : _customers = customers;
|
|
||||||
|
|
||||||
final List<Customer> _customers;
|
|
||||||
@override
|
|
||||||
List<Customer> get customers {
|
|
||||||
if (_customers is EqualUnmodifiableListView) return _customers;
|
|
||||||
// ignore: implicit_dynamic_type
|
|
||||||
return EqualUnmodifiableListView(_customers);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
final Option<CustomerFailure> failureOrOption;
|
|
||||||
@override
|
|
||||||
final Customer? selectedCustomer;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool isFetching;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final bool hasReachedMax;
|
|
||||||
@override
|
|
||||||
@JsonKey()
|
|
||||||
final int page;
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString() {
|
|
||||||
return 'CustomerLoaderState(customers: $customers, failureOrOption: $failureOrOption, selectedCustomer: $selectedCustomer, isFetching: $isFetching, hasReachedMax: $hasReachedMax, page: $page)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return identical(this, other) ||
|
|
||||||
(other.runtimeType == runtimeType &&
|
|
||||||
other is _$CustomerLoaderStateImpl &&
|
|
||||||
const DeepCollectionEquality().equals(
|
|
||||||
other._customers,
|
|
||||||
_customers,
|
|
||||||
) &&
|
|
||||||
(identical(other.failureOrOption, failureOrOption) ||
|
|
||||||
other.failureOrOption == failureOrOption) &&
|
|
||||||
(identical(other.selectedCustomer, selectedCustomer) ||
|
|
||||||
other.selectedCustomer == selectedCustomer) &&
|
|
||||||
(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(_customers),
|
|
||||||
failureOrOption,
|
|
||||||
selectedCustomer,
|
|
||||||
isFetching,
|
|
||||||
hasReachedMax,
|
|
||||||
page,
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
@override
|
|
||||||
@pragma('vm:prefer-inline')
|
|
||||||
_$$CustomerLoaderStateImplCopyWith<_$CustomerLoaderStateImpl> get copyWith =>
|
|
||||||
__$$CustomerLoaderStateImplCopyWithImpl<_$CustomerLoaderStateImpl>(
|
|
||||||
this,
|
|
||||||
_$identity,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class _CustomerLoaderState implements CustomerLoaderState {
|
|
||||||
factory _CustomerLoaderState({
|
|
||||||
required final List<Customer> customers,
|
|
||||||
required final Option<CustomerFailure> failureOrOption,
|
|
||||||
final Customer? selectedCustomer,
|
|
||||||
final bool isFetching,
|
|
||||||
final bool hasReachedMax,
|
|
||||||
final int page,
|
|
||||||
}) = _$CustomerLoaderStateImpl;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Customer> get customers;
|
|
||||||
@override
|
|
||||||
Option<CustomerFailure> get failureOrOption;
|
|
||||||
@override
|
|
||||||
Customer? get selectedCustomer;
|
|
||||||
@override
|
|
||||||
bool get isFetching;
|
|
||||||
@override
|
|
||||||
bool get hasReachedMax;
|
|
||||||
@override
|
|
||||||
int get page;
|
|
||||||
|
|
||||||
/// Create a copy of CustomerLoaderState
|
|
||||||
/// with the given fields replaced by the non-null parameter values.
|
|
||||||
@override
|
|
||||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
||||||
_$$CustomerLoaderStateImplCopyWith<_$CustomerLoaderStateImpl> get copyWith =>
|
|
||||||
throw _privateConstructorUsedError;
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
part of 'customer_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CustomerLoaderEvent with _$CustomerLoaderEvent {
|
|
||||||
const factory CustomerLoaderEvent.setSelectedCustomer(Customer customer) =
|
|
||||||
_SetSelectedCustomer;
|
|
||||||
const factory CustomerLoaderEvent.fetched({@Default(false) bool isRefresh}) =
|
|
||||||
_Fetched;
|
|
||||||
}
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
part of 'customer_loader_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class CustomerLoaderState with _$CustomerLoaderState {
|
|
||||||
factory CustomerLoaderState({
|
|
||||||
required List<Customer> customers,
|
|
||||||
required Option<CustomerFailure> failureOrOption,
|
|
||||||
Customer? selectedCustomer,
|
|
||||||
@Default(false) bool isFetching,
|
|
||||||
@Default(false) bool hasReachedMax,
|
|
||||||
@Default(1) int page,
|
|
||||||
}) = _CustomerLoaderState;
|
|
||||||
|
|
||||||
factory CustomerLoaderState.initial() =>
|
|
||||||
CustomerLoaderState(customers: [], failureOrOption: none());
|
|
||||||
}
|
|
||||||
@ -1,159 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart' hide Order;
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart' hide Order;
|
|
||||||
|
|
||||||
import '../../../common/types/order_type.dart';
|
|
||||||
import '../../../domain/customer/customer.dart';
|
|
||||||
import '../../../domain/order/order.dart';
|
|
||||||
import '../../../domain/outlet/outlet.dart';
|
|
||||||
import '../../../domain/payment_method/payment_method.dart';
|
|
||||||
import '../../../domain/product/product.dart';
|
|
||||||
import '../../../domain/table/table.dart';
|
|
||||||
part 'order_form_event.dart';
|
|
||||||
part 'order_form_state.dart';
|
|
||||||
part 'order_form_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class OrderFormBloc extends Bloc<OrderFormEvent, OrderFormState> {
|
|
||||||
final IOrderRepository _repository;
|
|
||||||
final IOutletRepository _outletRepository;
|
|
||||||
OrderFormBloc(this._repository, this._outletRepository)
|
|
||||||
: super(OrderFormState.initial()) {
|
|
||||||
on<OrderFormEvent>(_onOrderFormBloc);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onOrderFormBloc(
|
|
||||||
OrderFormEvent event,
|
|
||||||
Emitter<OrderFormState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
customerNameChanged: (e) async {
|
|
||||||
emit(state.copyWith(customerName: e.customerName));
|
|
||||||
},
|
|
||||||
paymentMethodChanged: (e) async {
|
|
||||||
emit(state.copyWith(paymentMethod: e.payment));
|
|
||||||
},
|
|
||||||
customerChanged: (e) async {
|
|
||||||
emit(state.copyWith(customer: e.customer));
|
|
||||||
},
|
|
||||||
createOrderWithPayment: (e) async {
|
|
||||||
Either<OrderFailure, Order> failureOrOrder;
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isCreatingWithPayment: true,
|
|
||||||
failureOrCreateOrderWithPayment: none(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final outlet = await _outletRepository.currentOutlet();
|
|
||||||
|
|
||||||
final request = OrderRequest(
|
|
||||||
outletId: outlet.id,
|
|
||||||
customerId: state.customer?.id ?? '',
|
|
||||||
tableNumber: e.table?.tableName ?? '',
|
|
||||||
tableId: e.table?.id ?? '',
|
|
||||||
orderType: e.orderType.name,
|
|
||||||
notes: '',
|
|
||||||
customerName: state.customerName ?? "",
|
|
||||||
orderItems: e.items
|
|
||||||
.map(
|
|
||||||
(item) => OrderItemRequest(
|
|
||||||
productId: item.product.id,
|
|
||||||
productVariantId: item.variant?.id ?? "",
|
|
||||||
quantity: item.quantity,
|
|
||||||
unitPrice: item.product.price.toInt(),
|
|
||||||
notes: item.notes,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
|
|
||||||
failureOrOrder = await _repository.createOrderWithPayment(
|
|
||||||
request: request,
|
|
||||||
paymentMethodId: state.paymentMethod?.id ?? '',
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isCreatingWithPayment: false,
|
|
||||||
failureOrCreateOrderWithPayment: optionOf(failureOrOrder),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
createOrder: (e) async {
|
|
||||||
Either<OrderFailure, Order> failureOrOrder;
|
|
||||||
|
|
||||||
emit(state.copyWith(isCreating: true, failureOrCreateOrder: none()));
|
|
||||||
|
|
||||||
final outlet = await _outletRepository.currentOutlet();
|
|
||||||
|
|
||||||
final request = OrderRequest(
|
|
||||||
outletId: outlet.id,
|
|
||||||
customerId: state.customer?.id ?? '',
|
|
||||||
tableNumber: e.table?.tableName ?? '',
|
|
||||||
tableId: e.table?.id ?? '',
|
|
||||||
orderType: e.orderType.name,
|
|
||||||
notes: '',
|
|
||||||
customerName: state.customerName ?? "",
|
|
||||||
orderItems: e.items
|
|
||||||
.map(
|
|
||||||
(item) => OrderItemRequest(
|
|
||||||
productId: item.product.id,
|
|
||||||
productVariantId: item.variant?.id ?? "",
|
|
||||||
quantity: item.quantity,
|
|
||||||
unitPrice: item.product.price.toInt(),
|
|
||||||
notes: item.notes,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList(),
|
|
||||||
);
|
|
||||||
|
|
||||||
failureOrOrder = await _repository.createOrder(request: request);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isCreating: false,
|
|
||||||
failureOrCreateOrder: optionOf(failureOrOrder),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
addItemOrder: (e) async {
|
|
||||||
Either<OrderFailure, Order> failureOrAddItemOrder;
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isAddingItemOrder: true,
|
|
||||||
failureOrAddItemOrder: none(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
final request = e.items
|
|
||||||
.map(
|
|
||||||
(item) => AddItemOrderRequest(
|
|
||||||
productId: item.product.id,
|
|
||||||
productVariantId: item.variant?.id ?? '',
|
|
||||||
quantity: item.quantity,
|
|
||||||
unitPrice: item.product.price.toInt(),
|
|
||||||
notes: item.notes,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
failureOrAddItemOrder = await _repository.addItemOrder(
|
|
||||||
id: e.orderId,
|
|
||||||
request: request,
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isAddingItemOrder: false,
|
|
||||||
failureOrAddItemOrder: optionOf(failureOrAddItemOrder),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
part of 'order_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class OrderFormEvent with _$OrderFormEvent {
|
|
||||||
const factory OrderFormEvent.customerNameChanged(String customerName) =
|
|
||||||
_CustomerNameChanged;
|
|
||||||
const factory OrderFormEvent.paymentMethodChanged(PaymentMethod payment) =
|
|
||||||
_PaymentMethodChanged;
|
|
||||||
const factory OrderFormEvent.customerChanged(Customer? customer) =
|
|
||||||
_CustomerChanged;
|
|
||||||
const factory OrderFormEvent.createOrderWithPayment({
|
|
||||||
required List<ProductQuantity> items,
|
|
||||||
required OrderType orderType,
|
|
||||||
Table? table,
|
|
||||||
}) = _CreateOrderWithPayment;
|
|
||||||
|
|
||||||
const factory OrderFormEvent.createOrder({
|
|
||||||
required List<ProductQuantity> items,
|
|
||||||
required OrderType orderType,
|
|
||||||
Table? table,
|
|
||||||
}) = _CreateOrder;
|
|
||||||
|
|
||||||
const factory OrderFormEvent.addItemOrder({
|
|
||||||
required String orderId,
|
|
||||||
required List<ProductQuantity> items,
|
|
||||||
}) = _AddItemOrder;
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
part of 'order_form_bloc.dart';
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class OrderFormState with _$OrderFormState {
|
|
||||||
factory OrderFormState({
|
|
||||||
PaymentMethod? paymentMethod,
|
|
||||||
String? customerName,
|
|
||||||
Customer? customer,
|
|
||||||
required Option<Either<OrderFailure, Order>> failureOrCreateOrder,
|
|
||||||
required Option<Either<OrderFailure, Order>>
|
|
||||||
failureOrCreateOrderWithPayment,
|
|
||||||
required Option<Either<OrderFailure, Order>> failureOrAddItemOrder,
|
|
||||||
@Default(false) bool isCreating,
|
|
||||||
@Default(false) bool isCreatingWithPayment,
|
|
||||||
@Default(false) bool isAddingItemOrder,
|
|
||||||
}) = _OrderFormState;
|
|
||||||
|
|
||||||
factory OrderFormState.initial() => OrderFormState(
|
|
||||||
failureOrCreateOrder: none(),
|
|
||||||
failureOrCreateOrderWithPayment: none(),
|
|
||||||
failureOrAddItemOrder: none(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@ -1,118 +0,0 @@
|
|||||||
import 'package:bloc/bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart' hide Order;
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:injectable/injectable.dart' hide Order;
|
|
||||||
|
|
||||||
import '../../../domain/order/order.dart';
|
|
||||||
|
|
||||||
part 'order_loader_event.dart';
|
|
||||||
part 'order_loader_state.dart';
|
|
||||||
part 'order_loader_bloc.freezed.dart';
|
|
||||||
|
|
||||||
@injectable
|
|
||||||
class OrderLoaderBloc extends Bloc<OrderLoaderEvent, OrderLoaderState> {
|
|
||||||
final IOrderRepository _repository;
|
|
||||||
OrderLoaderBloc(this._repository) : super(OrderLoaderState.initial()) {
|
|
||||||
on<OrderLoaderEvent>(_onOrderLoaderEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _onOrderLoaderEvent(
|
|
||||||
OrderLoaderEvent event,
|
|
||||||
Emitter<OrderLoaderState> emit,
|
|
||||||
) {
|
|
||||||
return event.map(
|
|
||||||
setSelectedOrder: (e) async {
|
|
||||||
emit(state.copyWith(selectedOrder: e.order));
|
|
||||||
},
|
|
||||||
dateTimeRangeChange: (e) async {
|
|
||||||
emit(state.copyWith(startDate: e.startDate, endDate: e.endDate));
|
|
||||||
},
|
|
||||||
searchChange: (e) async {
|
|
||||||
emit(state.copyWith(search: e.search));
|
|
||||||
},
|
|
||||||
fetched: (e) async {
|
|
||||||
var newState = state;
|
|
||||||
|
|
||||||
if (e.isRefresh) {
|
|
||||||
newState = newState.copyWith(isFetching: true);
|
|
||||||
emit(newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
newState = await _mapFetchedToState(
|
|
||||||
newState,
|
|
||||||
isRefresh: e.isRefresh,
|
|
||||||
status: e.status,
|
|
||||||
);
|
|
||||||
emit(newState);
|
|
||||||
},
|
|
||||||
getById: (e) async {
|
|
||||||
emit(state.copyWith(isFetchingById: true, failureOption: none()));
|
|
||||||
|
|
||||||
final failureOrOrder = await _repository.getOrderById(e.id);
|
|
||||||
failureOrOrder.fold(
|
|
||||||
(f) => emit(
|
|
||||||
state.copyWith(failureOption: optionOf(f), isFetching: false),
|
|
||||||
),
|
|
||||||
(order) => emit(
|
|
||||||
state.copyWith(
|
|
||||||
order: order,
|
|
||||||
isFetching: false,
|
|
||||||
failureOption: none(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
emit(state.copyWith(isFetchingById: false));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<OrderLoaderState> _mapFetchedToState(
|
|
||||||
OrderLoaderState state, {
|
|
||||||
bool isRefresh = false,
|
|
||||||
String status = 'completed',
|
|
||||||
}) async {
|
|
||||||
state = state.copyWith(isFetching: false);
|
|
||||||
|
|
||||||
if (state.hasReachedMax && state.orders.isNotEmpty && !isRefresh) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRefresh) {
|
|
||||||
state = state.copyWith(
|
|
||||||
page: 1,
|
|
||||||
failureOption: none(),
|
|
||||||
hasReachedMax: false,
|
|
||||||
orders: [],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
final failureOrTable = await _repository.getOrders(
|
|
||||||
page: state.page,
|
|
||||||
status: status,
|
|
||||||
startDate: state.startDate,
|
|
||||||
endDate: state.endDate,
|
|
||||||
search: state.search,
|
|
||||||
);
|
|
||||||
|
|
||||||
state = failureOrTable.fold(
|
|
||||||
(f) {
|
|
||||||
if (state.orders.isNotEmpty) {
|
|
||||||
return state.copyWith(hasReachedMax: true);
|
|
||||||
}
|
|
||||||
return state.copyWith(failureOption: optionOf(f));
|
|
||||||
},
|
|
||||||
(orders) {
|
|
||||||
return state.copyWith(
|
|
||||||
orders: List.from(state.orders)..addAll(orders.orders),
|
|
||||||
failureOption: none(),
|
|
||||||
page: state.page + 1,
|
|
||||||
hasReachedMax: orders.orders.length < 10,
|
|
||||||
totalOrder: orders.totalCount,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
}
|
|
||||||