Compare commits
28 Commits
feature/he
...
feature/ap
| Author | SHA1 | Date | |
|---|---|---|---|
| 5cf2fd7f96 | |||
| fe41e812a0 | |||
| c79cbeffcc | |||
| b7614a39f1 | |||
| a05c167f30 | |||
| c1c903ac93 | |||
| a0a782c91b | |||
| c140daa7ae | |||
| 6d30a59651 | |||
| 8d453dc980 | |||
| 0a50de3d70 | |||
| 02053182db | |||
| 33f3dfa252 | |||
| cb70973d3b | |||
| 1ffeea8b77 | |||
| 5f484036f8 | |||
| 73927557ca | |||
| 5111d5d65f | |||
| ced0895063 | |||
| 34e7a7c60f | |||
| c89f1c666e | |||
| 33c2403aef | |||
| 0088d146f0 | |||
| 48cb23379c | |||
| e526dce2c9 | |||
| cacc2460f1 | |||
| dd53db6795 | |||
| 48d2430c9c |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -6,6 +6,8 @@ PODS:
|
||||
- Flutter
|
||||
- flutter_treezor_entrust_sdk_bridge (0.0.1):
|
||||
- Flutter
|
||||
- image_picker_ios (0.0.1):
|
||||
- Flutter
|
||||
- mobile_scanner (7.0.0):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
@@ -14,6 +16,8 @@ PODS:
|
||||
- FlutterMacOS
|
||||
- permission_handler_apple (9.3.0):
|
||||
- Flutter
|
||||
- share_plus (0.0.1):
|
||||
- Flutter
|
||||
- shared_preferences_foundation (0.0.1):
|
||||
- Flutter
|
||||
- FlutterMacOS
|
||||
@@ -28,9 +32,11 @@ DEPENDENCIES:
|
||||
- flutter_contacts (from `.symlinks/plugins/flutter_contacts/ios`)
|
||||
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
|
||||
- flutter_treezor_entrust_sdk_bridge (from `.symlinks/plugins/flutter_treezor_entrust_sdk_bridge/ios`)
|
||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/darwin`)
|
||||
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
|
||||
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
|
||||
- share_plus (from `.symlinks/plugins/share_plus/ios`)
|
||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)
|
||||
@@ -44,12 +50,16 @@ EXTERNAL SOURCES:
|
||||
:path: ".symlinks/plugins/flutter_native_splash/ios"
|
||||
flutter_treezor_entrust_sdk_bridge:
|
||||
:path: ".symlinks/plugins/flutter_treezor_entrust_sdk_bridge/ios"
|
||||
image_picker_ios:
|
||||
:path: ".symlinks/plugins/image_picker_ios/ios"
|
||||
mobile_scanner:
|
||||
:path: ".symlinks/plugins/mobile_scanner/darwin"
|
||||
path_provider_foundation:
|
||||
:path: ".symlinks/plugins/path_provider_foundation/darwin"
|
||||
permission_handler_apple:
|
||||
:path: ".symlinks/plugins/permission_handler_apple/ios"
|
||||
share_plus:
|
||||
:path: ".symlinks/plugins/share_plus/ios"
|
||||
shared_preferences_foundation:
|
||||
:path: ".symlinks/plugins/shared_preferences_foundation/darwin"
|
||||
url_launcher_ios:
|
||||
@@ -62,9 +72,11 @@ SPEC CHECKSUMS:
|
||||
flutter_contacts: edb1c5ce76aa433e20e6cb14c615f4c0b66e0983
|
||||
flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29
|
||||
flutter_treezor_entrust_sdk_bridge: 4c2c94fb74ab57576e8d49f5f2a4b214e41141fe
|
||||
image_picker_ios: 4f2f91b01abdb52842a8e277617df877e40f905b
|
||||
mobile_scanner: 77265f3dc8d580810e91849d4a0811a90467ed5e
|
||||
path_provider_foundation: 0b743cbb62d8e47eab856f09262bb8c1ddcfe6ba
|
||||
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
|
||||
share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
|
||||
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6
|
||||
url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa
|
||||
webview_flutter_wkwebview: 29eb20d43355b48fe7d07113835b9128f84e3af4
|
||||
|
||||
@@ -30,7 +30,9 @@ Future<void> initApp(EnvironmentEnum env) async {
|
||||
await configureDependencies(
|
||||
QuestiaEnvConfig(),
|
||||
log: env.isDevelopment || kDebugMode,
|
||||
onTokenExpired: () => appRouter.go(AppRoutes.scaTreezor),
|
||||
onTokenExpired: () => appRouter.go(
|
||||
AppRoutes.legacyLogin,
|
||||
), //change to payments app to AppRoutes.scaTreezor
|
||||
onUnauthorized: () async {
|
||||
final currentLocation =
|
||||
appRouter.routerDelegate.currentConfiguration.uri.path;
|
||||
@@ -39,7 +41,7 @@ Future<void> initApp(EnvironmentEnum env) async {
|
||||
await GetIt.I<TreezorWalletConnectionService>().logout();
|
||||
} catch (_) {}
|
||||
await clearSessionData();
|
||||
appRouter.go(AppRoutes.login);
|
||||
appRouter.go(AppRoutes.legacyLogin);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -141,6 +141,26 @@ void configureAppRouter() {
|
||||
name: 'apps_use',
|
||||
pageBuilder: const AppsUseBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'volume_control',
|
||||
name: 'volume_control',
|
||||
pageBuilder: const VolumeControlBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'call_history',
|
||||
name: 'call_history',
|
||||
pageBuilder: const CallHistoryBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'background_image',
|
||||
name: 'background_image',
|
||||
pageBuilder: const BackgroundImageBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'apps_surveillance',
|
||||
name: 'apps_surveillance',
|
||||
pageBuilder: const AppsSurveillanceBuilder().buildPage,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -237,9 +257,9 @@ void configureAppRouter() {
|
||||
pageBuilder: RemoteOnOffBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'sms_alert',
|
||||
name: 'sms_alert',
|
||||
pageBuilder: SmsAlertBuilder().buildPage,
|
||||
path: 'alerts',
|
||||
name: 'alerts',
|
||||
pageBuilder: AlertsBuilder().buildPage,
|
||||
),
|
||||
GoRoute(
|
||||
path: 'timezone',
|
||||
|
||||
@@ -34,7 +34,9 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
|
||||
walletHeartbeat = WalletHeartbeatService(
|
||||
repository: ref.read(treezorRepositoryProvider),
|
||||
sessionLocal: SessionLocalDatasourceImpl(),
|
||||
onError: () => appRouter.go(AppRoutes.scaTreezor),
|
||||
onError: () => appRouter.go(
|
||||
AppRoutes.legacyLogin,
|
||||
), //change to payments app to AppRoutes.scaTreezor
|
||||
);
|
||||
legacyHeartbeat = LegacyHeartbeatService(
|
||||
repository: GetIt.I<QuestiaRepository>(),
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.4/
|
||||
@@ -0,0 +1 @@
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.2/
|
||||
@@ -1 +1 @@
|
||||
C:/Users/Aitor Arana/AppData/Local/Pub/Cache/hosted/pub.dev/path_provider_linux-2.2.1/
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/
|
||||
@@ -0,0 +1 @@
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/share_plus-10.1.4/
|
||||
@@ -1 +1 @@
|
||||
C:/Users/Aitor Arana/AppData/Local/Pub/Cache/hosted/pub.dev/shared_preferences_linux-2.4.1/
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/
|
||||
@@ -1 +1 @@
|
||||
C:/Users/Aitor Arana/AppData/Local/Pub/Cache/hosted/pub.dev/url_launcher_linux-3.2.2/
|
||||
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/url_launcher_linux-3.2.2/
|
||||
@@ -6,9 +6,13 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <file_selector_linux/file_selector_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) file_selector_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
|
||||
file_selector_plugin_register_with_registrar(file_selector_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
|
||||
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
file_selector_linux
|
||||
url_launcher_linux
|
||||
)
|
||||
|
||||
|
||||
@@ -245,6 +245,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.15.0"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cross_file
|
||||
sha256: "28bb3ae56f117b5aec029d702a90f57d285cd975c3c5c281eaca38dbc47c5937"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.5+2"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -385,6 +393,38 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.1"
|
||||
file_selector_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_linux
|
||||
sha256: "2567f398e06ac72dcf2e98a0c95df2a9edd03c2c2e0cacd4780f20cdf56263a0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.4"
|
||||
file_selector_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_macos
|
||||
sha256: "5e0bbe9c312416f1787a68259ea1505b52f258c587f12920422671807c4d618a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.5"
|
||||
file_selector_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_platform_interface
|
||||
sha256: "35e0bd61ebcdb91a3505813b055b09b79dfdc7d0aee9c09a7ba59ae4bb13dc85"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
file_selector_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_windows
|
||||
sha256: "62197474ae75893a62df75939c777763d39c2bc5f73ce5b88497208bc269abfd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3+5"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -451,6 +491,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.7"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_plugin_android_lifecycle
|
||||
sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.33"
|
||||
flutter_riverpod:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -602,6 +650,70 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.8.0"
|
||||
image_picker:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker
|
||||
sha256: "784210112be18ea55f69d7076e2c656a4e24949fa9e76429fe53af0c0f4fa320"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
image_picker_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_android
|
||||
sha256: eda9b91b7e266d9041084a42d605a74937d996b87083395c5e47835916a86156
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.13+14"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_for_web
|
||||
sha256: "66257a3191ab360d23a55c8241c91a6e329d31e94efa7be9cf7a212e65850214"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
image_picker_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_ios
|
||||
sha256: "956c16a42c0c708f914021666ffcd8265dde36e673c9fa68c81f7d085d9774ad"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.13+3"
|
||||
image_picker_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_linux
|
||||
sha256: "1f81c5f2046b9ab724f85523e4af65be1d47b038160a8c8deed909762c308ed4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
image_picker_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_macos
|
||||
sha256: "86f0f15a309de7e1a552c12df9ce5b59fe927e71385329355aec4776c6a8ec91"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.2+1"
|
||||
image_picker_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_platform_interface
|
||||
sha256: "567e056716333a1647c64bb6bd873cff7622233a5c3f694be28a583d4715690c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.1"
|
||||
image_picker_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_windows
|
||||
sha256: d248c86554a72b5495a31c56f060cf73a41c7ff541689327b1a7dbccc33adfae
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
intl:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1117,6 +1229,22 @@ packages:
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.0.1"
|
||||
share_plus:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: share_plus
|
||||
sha256: fce43200aa03ea87b91ce4c3ac79f0cecd52e2a7a56c7a4185023c271fbfa6da
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.1.4"
|
||||
share_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: share_plus_platform_interface
|
||||
sha256: cc012a23fc2d479854e6c80150696c4a5f5bb62cb89af4de1c505cf78d0a5d0b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.0.2"
|
||||
shared_preferences:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1560,6 +1688,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.23.8"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.15.0"
|
||||
wkt_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.0+5
|
||||
version: 1.0.0+6
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.2
|
||||
@@ -123,6 +123,7 @@ flutter:
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
assets:
|
||||
- assets/shared/images/
|
||||
- assets/shared/animations/
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/to/resolution-aware-images
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/save-family-app/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/save-family-app/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_android-2.2.22/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_android-2.4.20/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"path_provider_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"],"dev_dependency":false}],"windows":[{"name":"path_provider_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"],"dev_dependency":false}],"web":[{"name":"shared_preferences_web","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.3/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"flutter_treezor_entrust_sdk_bridge","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2026-03-18 14:45:38.408085","version":"3.35.7","swift_package_manager_enabled":{"ios":false,"macos":false}}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/save-family-app/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_treezor_entrust_sdk_bridge","path":"/Users/juliandalcalaf/Desktop/save-family-app/sf-app-platform/packages/flutter_treezor_entrust_sdk_bridge/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_android-2.2.22/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_android-2.4.20/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_foundation-2.5.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_foundation","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.6/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"path_provider_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"],"dev_dependency":false}],"windows":[{"name":"path_provider_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"],"dev_dependency":false}],"web":[{"name":"shared_preferences_web","path":"/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.3/","dependencies":[],"dev_dependency":false}]},"dependencyGraph":[{"name":"flutter_treezor_entrust_sdk_bridge","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2026-03-25 02:38:09.414683","version":"3.35.7","swift_package_manager_enabled":{"ios":false,"macos":false}}
|
||||
3
modules/auth/devtools_options.yaml
Normal file
3
modules/auth/devtools_options.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
||||
3
modules/home/devtools_options.yaml
Normal file
3
modules/home/devtools_options.yaml
Normal file
@@ -0,0 +1,3 @@
|
||||
description: This file stores settings for Dart & Flutter DevTools.
|
||||
documentation: https://docs.flutter.dev/tools/devtools/extensions#configure-extension-enablement-states
|
||||
extensions:
|
||||
@@ -32,6 +32,9 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/settings/.dart_tool" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/settings/.pub" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/modules/settings/build" />
|
||||
</content>
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Dart SDK" level="project" />
|
||||
|
||||
@@ -27,21 +27,23 @@ class LinkedDevicesScreen extends ConsumerWidget {
|
||||
title: context.translate(I18n.linkedDevices),
|
||||
showEdit: true,
|
||||
onEditChange: vm.toggleIsEditing,
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: SizeUtils.getByScreen(small: 10, big: 12)),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
|
||||
navigationContract: navigationContract,
|
||||
device: state.linkedDevices[index],
|
||||
isEditing: state.isEditing,
|
||||
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
|
||||
body: state.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: SizeUtils.getByScreen(small: 10, big: 12)),
|
||||
child: ListView.separated(
|
||||
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
|
||||
navigationContract: navigationContract,
|
||||
device: state.linkedDevices[index],
|
||||
isEditing: state.isEditing,
|
||||
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]),
|
||||
),
|
||||
separatorBuilder: (BuildContext context, int index)=>SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 18, big: 17)
|
||||
),
|
||||
itemCount: state.linkedDevices.length
|
||||
),
|
||||
),
|
||||
separatorBuilder: (BuildContext context, int index)=>SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 18, big: 17)
|
||||
),
|
||||
itemCount: state.linkedDevices.length
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ extension LatestPositionsResponseModelMapper on LatestPositionsResponseModel {
|
||||
@freezed
|
||||
abstract class LatestPositionsAddressResponseModel with _$LatestPositionsAddressResponseModel {
|
||||
const factory LatestPositionsAddressResponseModel({
|
||||
required String street,
|
||||
required String city,
|
||||
required String province,
|
||||
required String state,
|
||||
required String country,
|
||||
String? street,
|
||||
String? city,
|
||||
String? province,
|
||||
String? state,
|
||||
String? country,
|
||||
}) = _LatestPositionsAddressResponseModel;
|
||||
|
||||
factory LatestPositionsAddressResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
|
||||
@@ -628,7 +628,7 @@ $LatestPositionsAddressResponseModelCopyWith<$Res>? get address {
|
||||
/// @nodoc
|
||||
mixin _$LatestPositionsAddressResponseModel {
|
||||
|
||||
String get street; String get city; String get province; String get state; String get country;
|
||||
String? get street; String? get city; String? get province; String? get state; String? get country;
|
||||
/// Create a copy of LatestPositionsAddressResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -661,7 +661,7 @@ abstract mixin class $LatestPositionsAddressResponseModelCopyWith<$Res> {
|
||||
factory $LatestPositionsAddressResponseModelCopyWith(LatestPositionsAddressResponseModel value, $Res Function(LatestPositionsAddressResponseModel) _then) = _$LatestPositionsAddressResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String street, String city, String province, String state, String country
|
||||
String? street, String? city, String? province, String? state, String? country
|
||||
});
|
||||
|
||||
|
||||
@@ -678,14 +678,14 @@ class _$LatestPositionsAddressResponseModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LatestPositionsAddressResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? street = null,Object? city = null,Object? province = null,Object? state = null,Object? country = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? street = freezed,Object? city = freezed,Object? province = freezed,Object? state = freezed,Object? country = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String,city: null == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String,province: null == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
street: freezed == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String?,province: freezed == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String?,state: freezed == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -770,7 +770,7 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String street, String city, String province, String state, String country)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String? street, String? city, String? province, String? state, String? country)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LatestPositionsAddressResponseModel() when $default != null:
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country);case _:
|
||||
@@ -791,7 +791,7 @@ return $default(_that.street,_that.city,_that.province,_that.state,_that.country
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String street, String city, String province, String state, String country) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String? street, String? city, String? province, String? state, String? country) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LatestPositionsAddressResponseModel():
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country);case _:
|
||||
@@ -811,7 +811,7 @@ return $default(_that.street,_that.city,_that.province,_that.state,_that.country
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String street, String city, String province, String state, String country)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String? street, String? city, String? province, String? state, String? country)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _LatestPositionsAddressResponseModel() when $default != null:
|
||||
return $default(_that.street,_that.city,_that.province,_that.state,_that.country);case _:
|
||||
@@ -826,14 +826,14 @@ return $default(_that.street,_that.city,_that.province,_that.state,_that.country
|
||||
@JsonSerializable()
|
||||
|
||||
class _LatestPositionsAddressResponseModel implements LatestPositionsAddressResponseModel {
|
||||
const _LatestPositionsAddressResponseModel({required this.street, required this.city, required this.province, required this.state, required this.country});
|
||||
const _LatestPositionsAddressResponseModel({this.street, this.city, this.province, this.state, this.country});
|
||||
factory _LatestPositionsAddressResponseModel.fromJson(Map<String, dynamic> json) => _$LatestPositionsAddressResponseModelFromJson(json);
|
||||
|
||||
@override final String street;
|
||||
@override final String city;
|
||||
@override final String province;
|
||||
@override final String state;
|
||||
@override final String country;
|
||||
@override final String? street;
|
||||
@override final String? city;
|
||||
@override final String? province;
|
||||
@override final String? state;
|
||||
@override final String? country;
|
||||
|
||||
/// Create a copy of LatestPositionsAddressResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -868,7 +868,7 @@ abstract mixin class _$LatestPositionsAddressResponseModelCopyWith<$Res> impleme
|
||||
factory _$LatestPositionsAddressResponseModelCopyWith(_LatestPositionsAddressResponseModel value, $Res Function(_LatestPositionsAddressResponseModel) _then) = __$LatestPositionsAddressResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String street, String city, String province, String state, String country
|
||||
String? street, String? city, String? province, String? state, String? country
|
||||
});
|
||||
|
||||
|
||||
@@ -885,14 +885,14 @@ class __$LatestPositionsAddressResponseModelCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of LatestPositionsAddressResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? street = null,Object? city = null,Object? province = null,Object? state = null,Object? country = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? street = freezed,Object? city = freezed,Object? province = freezed,Object? state = freezed,Object? country = freezed,}) {
|
||||
return _then(_LatestPositionsAddressResponseModel(
|
||||
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String,city: null == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String,province: null == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String,state: null == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String,country: null == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
street: freezed == street ? _self.street : street // ignore: cast_nullable_to_non_nullable
|
||||
as String?,city: freezed == city ? _self.city : city // ignore: cast_nullable_to_non_nullable
|
||||
as String?,province: freezed == province ? _self.province : province // ignore: cast_nullable_to_non_nullable
|
||||
as String?,state: freezed == state ? _self.state : state // ignore: cast_nullable_to_non_nullable
|
||||
as String?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,11 @@ Map<String, dynamic> _$LatestPositionsItemResponseModelToJson(
|
||||
_LatestPositionsAddressResponseModel
|
||||
_$LatestPositionsAddressResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_LatestPositionsAddressResponseModel(
|
||||
street: json['street'] as String,
|
||||
city: json['city'] as String,
|
||||
province: json['province'] as String,
|
||||
state: json['state'] as String,
|
||||
country: json['country'] as String,
|
||||
street: json['street'] as String?,
|
||||
city: json['city'] as String?,
|
||||
province: json['province'] as String?,
|
||||
state: json['state'] as String?,
|
||||
country: json['country'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LatestPositionsAddressResponseModelToJson(
|
||||
|
||||
@@ -69,8 +69,9 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
|
||||
final latestPositions = positionLists
|
||||
.where((list) => list.isNotEmpty)
|
||||
.map((list) {
|
||||
final valid = list.where((p) => p.latitude != 0 || p.longitude != 0);
|
||||
return valid.isNotEmpty ? valid.last : list.last;
|
||||
final valid = list.where((p) => p.latitude != 0 || p.longitude != 0).toList()
|
||||
..sort((a, b) => b.createdAt.compareTo(a.createdAt));
|
||||
return valid.isNotEmpty ? valid.first : list.last;
|
||||
})
|
||||
.toList();
|
||||
|
||||
@@ -92,6 +93,7 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
|
||||
|
||||
Future<void> refreshPositions() async {
|
||||
if (state.devices.isEmpty) return;
|
||||
state = state.copyWith(errorMessage: '');
|
||||
try {
|
||||
final positionLists = await Future.wait(
|
||||
state.devices.map(
|
||||
|
||||
@@ -59,6 +59,7 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mapStyle = ref.watch(mapStyleProvider);
|
||||
final primaryColor = ref.read(themePortProvider).getColorFor(ThemeCode.legacyPrimary);
|
||||
final initialCenter = widget.selectedPosition != null
|
||||
? LatLng(
|
||||
widget.selectedPosition!.latitude,
|
||||
@@ -88,7 +89,7 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
|
||||
),
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: const PulsingLocationMarker(),
|
||||
child: PulsingLocationMarker(color: primaryColor),
|
||||
rotate: true,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -9,4 +9,8 @@ export 'src/features/locate_device/locate_device_builder.dart';
|
||||
export 'src/features/health/health_builder.dart';
|
||||
export 'src/features/rewards/rewards_builder.dart';
|
||||
export 'src/features/activity_meter/activity_meter_builder.dart';
|
||||
export 'src/features/apps_use/apps_use_builder.dart';
|
||||
export 'src/features/apps_use/apps_use_builder.dart';
|
||||
export 'src/features/apps_surveillance/apps_surveillance_builder.dart';
|
||||
export 'src/features/volume_control/volume_control_builder.dart';
|
||||
export 'src/features/call_history/call_history_builder.dart';
|
||||
export 'src/features/background_image/background_image_builder.dart';
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:device_management/src/core/data/models/get_schedule_response_model.dart';
|
||||
import 'package:device_management/src/core/data/models/upsert_schedule_request_model.dart';
|
||||
|
||||
import '../models/get_installed_apps_response_model.dart';
|
||||
|
||||
abstract class AppSurveillanceRemoteDatasource {
|
||||
Future<GetInstalledAppsResponseModel> getInstalledApps({
|
||||
required String deviceId
|
||||
});
|
||||
|
||||
Future<GetScheduleResponseModel> getSchedule({required String deviceId});
|
||||
|
||||
Future<void> upsertSchedule({
|
||||
required String deviceId,
|
||||
required UpdateScheduleRequestModel request
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'package:device_management/src/core/data/models/get_schedule_response_model.dart';
|
||||
import 'package:device_management/src/core/data/models/upsert_schedule_request_model.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../models/get_installed_apps_response_model.dart';
|
||||
import 'apps_surveillance_remote_datasource.dart';
|
||||
|
||||
class AppSurveillanceRemoteDatasourceImpl
|
||||
implements AppSurveillanceRemoteDatasource {
|
||||
AppSurveillanceRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<GetInstalledAppsResponseModel> getInstalledApps({
|
||||
required String deviceId
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/devices/identificator/$deviceId/installed-apps',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception(
|
||||
'Empty response from /devices/$deviceId/installed-apps',
|
||||
);
|
||||
}
|
||||
|
||||
return GetInstalledAppsResponseModel.fromJson(data);
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error getting installed apps',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetScheduleResponseModel> getSchedule({
|
||||
required String deviceId
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/devices/identificator/$deviceId/app-usage-schedules',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception(
|
||||
'Empty response from /devices/$deviceId/app-usage-schedules',
|
||||
);
|
||||
}
|
||||
|
||||
return GetScheduleResponseModel.fromJson(data);
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(
|
||||
error,
|
||||
defaultMessage: 'Error getting activities schedule',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> upsertSchedule({
|
||||
required String deviceId,
|
||||
required UpdateScheduleRequestModel request
|
||||
}) async {
|
||||
await safeCall(
|
||||
() => _repository.put<dynamic>(
|
||||
'/devices/identificator/$deviceId/app-usage-schedules',
|
||||
body: request.toJson(),
|
||||
),
|
||||
'Error updating activity schedule',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import '../models/get_background_image_response_model.dart';
|
||||
|
||||
abstract class BackgroundImageRemoteDatasource {
|
||||
Future<GetBackgroundImageResponseModel> getBackgroundImage();
|
||||
|
||||
Future<String> uploadImage({
|
||||
required String path,
|
||||
});
|
||||
|
||||
Future<void> setBackgroundImage({
|
||||
required String deviceId,
|
||||
required String photoId,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/configure_dependencies.dart';
|
||||
|
||||
import '../models/get_background_image_response_model.dart';
|
||||
import 'background_image_remote_datasource.dart';
|
||||
|
||||
class BackgroundImageRemoteDatasourceImpl
|
||||
implements BackgroundImageRemoteDatasource {
|
||||
BackgroundImageRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<GetBackgroundImageResponseModel> getBackgroundImage() async {
|
||||
final response = await safeCall(
|
||||
() => _repository.get<dynamic>('/photos/files'),
|
||||
'Error getting background image',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || (data is Map && data.isEmpty)) {
|
||||
return const GetBackgroundImageResponseModel(items: []);
|
||||
}
|
||||
|
||||
return GetBackgroundImageResponseModel.fromJson(
|
||||
data is Map<String, dynamic> ? data : data as Map<String, dynamic>,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> uploadImage({required String path}) async {
|
||||
final formData = FormData.fromMap({
|
||||
'file': await MultipartFile.fromFile(path, filename: 'photo.jpg'),
|
||||
});
|
||||
|
||||
final dio = GetIt.I<Dio>();
|
||||
dio.options.headers.remove('content-type');
|
||||
try {
|
||||
final response = await dio.post<dynamic>('/photos', data: formData);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
throw Exception('Empty response from upload');
|
||||
}
|
||||
final map = data is Map<String, dynamic> ? data : <String, dynamic>{};
|
||||
final id = map['id'] as String?;
|
||||
if (id == null) {
|
||||
throw Exception('No photo ID in upload response');
|
||||
}
|
||||
return id;
|
||||
} on DioException catch (e) {
|
||||
throw mapDioError(e, defaultMessage: 'Error uploading image');
|
||||
} finally {
|
||||
dio.options.headers['content-type'] = 'application/json';
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setBackgroundImage({
|
||||
required String deviceId,
|
||||
required String photoId,
|
||||
}) async {
|
||||
await safeCall(
|
||||
() => _repository.put<dynamic>(
|
||||
'/devices/$deviceId/background-image',
|
||||
body: {'photoId': photoId},
|
||||
),
|
||||
'Error setting background image',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -68,17 +68,31 @@ class ContactsRemoteDatasourceImpl implements ContactsRemoteDatasource {
|
||||
required String deviceId,
|
||||
required List<Map<String, String>> contacts,
|
||||
}) async {
|
||||
await safeCall(
|
||||
() => _repository.post<dynamic>(
|
||||
'/contact-lists',
|
||||
body: {
|
||||
'userId': userId,
|
||||
'deviceId': deviceId,
|
||||
'type': 'secondary',
|
||||
'contacts': contacts,
|
||||
},
|
||||
await Future.wait([
|
||||
safeCall(
|
||||
() => _repository.post<dynamic>(
|
||||
'/contact-lists',
|
||||
body: {
|
||||
'userId': userId,
|
||||
'deviceId': deviceId,
|
||||
'type': 'secondary',
|
||||
'contacts': contacts,
|
||||
},
|
||||
),
|
||||
'Error syncing contacts to device',
|
||||
),
|
||||
'Error syncing contacts to device',
|
||||
);
|
||||
safeCall(
|
||||
() => _repository.post<dynamic>(
|
||||
'/contact-lists',
|
||||
body: {
|
||||
'userId': userId,
|
||||
'deviceId': deviceId,
|
||||
'type': 'white',
|
||||
'contacts': contacts,
|
||||
},
|
||||
),
|
||||
'Error syncing whitelist to device',
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
|
||||
abstract class FunctionsRemoteDatasource {
|
||||
Future<List<PictureEntity>> getPictures({required String userId});
|
||||
|
||||
Future<PictureEntity> takePicture({required String userId});
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
import 'package:device_management/src/core/data/datasources/functions_remote_datasource.dart';
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
class FunctionsRemoteDatasourceImpl implements FunctionsRemoteDatasource {
|
||||
FunctionsRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<PictureEntity>> getPictures({required String userId}) async {
|
||||
/*try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /users/:userId/contacts');
|
||||
}
|
||||
|
||||
final model = GetPicturesResponseModel.fromJson(data);
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(error, defaultMessage: 'Error to get pictures');
|
||||
}*/
|
||||
return [];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PictureEntity> takePicture({required String userId}) async {
|
||||
/*try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
throw Exception('Empty response from /users/:userId/contacts');
|
||||
}
|
||||
|
||||
final model = GetContactsResponseModel.fromJson(data);
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
throw mapDioError(error, defaultMessage: 'Error to get contacts');
|
||||
}*/
|
||||
return PictureEntity(
|
||||
id: '1',
|
||||
deviceId: '1111',
|
||||
createdAt: DateTime.now(),
|
||||
takenAt: DateTime.now(),
|
||||
asset: 'assets/shared/images/iso_sf.png',
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class HealthQueryBuilder {
|
||||
String orderField = 'occurredAt',
|
||||
}) {
|
||||
final orderBy = base64Encode(
|
||||
utf8.encode('[{"field":"$orderField","order":"${orderDirection.value}"}]'),
|
||||
utf8.encode('[{"field":"$orderField","sortDirection":"${orderDirection.value}"}]'),
|
||||
);
|
||||
|
||||
final params = <String, dynamic>{'orderBy': orderBy};
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
|
||||
abstract class PicturesRemoteDatasource {
|
||||
Future<List<PictureEntity>> getPictures({required String deviceId});
|
||||
|
||||
Future<PictureEntity> takePicture({required String deviceId});
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import 'package:device_management/src/core/data/datasources/pictures_remote_datasource.dart';
|
||||
import 'package:device_management/src/core/data/models/get_pictures_response_model.dart';
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
class PicturesRemoteDatasourceImpl implements PicturesRemoteDatasource {
|
||||
PicturesRemoteDatasourceImpl(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
@override
|
||||
Future<List<PictureEntity>> getPictures({required String deviceId}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/devices/identificator/$deviceId/photos/files',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
|
||||
final model = GetPicturesResponseModel.fromJson(data);
|
||||
return model.toEntity();
|
||||
} on DioException catch (error) {
|
||||
if (error.response?.statusCode == 404) return [];
|
||||
throw mapDioError(error, defaultMessage: 'Error getting pictures');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PictureEntity> takePicture({required String deviceId}) async {
|
||||
throw UnimplementedError('takePicture is handled via commands');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import 'get_pictures_response_model.dart';
|
||||
|
||||
part 'get_background_image_response_model.freezed.dart';
|
||||
part 'get_background_image_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetBackgroundImageResponseModel with _$GetBackgroundImageResponseModel {
|
||||
const factory GetBackgroundImageResponseModel({
|
||||
@Default([]) List<GetPicturesItemResponseModel> items,
|
||||
@Default(0) int total,
|
||||
@Default(1) int page,
|
||||
@Default(1) int pages,
|
||||
}) = _GetBackgroundImageResponseModel;
|
||||
|
||||
factory GetBackgroundImageResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetBackgroundImageResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetBackgroundImageResponseModelMapper on GetBackgroundImageResponseModel {
|
||||
List<PictureEntity> toEntities() {
|
||||
return items
|
||||
.map((item) => PictureEntity(
|
||||
id: item.id,
|
||||
deviceIdentificator: item.deviceIdentificator,
|
||||
imgType: item.imgType,
|
||||
timestamp: item.timestamp,
|
||||
fileId: item.fileId,
|
||||
fileName: item.fileName,
|
||||
contentType: item.contentType,
|
||||
createdAt: item.createdAt,
|
||||
fileBytes: extractFileBytes(item.file),
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'get_background_image_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetBackgroundImageResponseModel {
|
||||
|
||||
List<GetPicturesItemResponseModel> get items; int get total; int get page; int get pages;
|
||||
/// Create a copy of GetBackgroundImageResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetBackgroundImageResponseModelCopyWith<GetBackgroundImageResponseModel> get copyWith => _$GetBackgroundImageResponseModelCopyWithImpl<GetBackgroundImageResponseModel>(this as GetBackgroundImageResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetBackgroundImageResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetBackgroundImageResponseModel&&const DeepCollectionEquality().equals(other.items, items)&&(identical(other.total, total) || other.total == total)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items),total,page,pages);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetBackgroundImageResponseModel(items: $items, total: $total, page: $page, pages: $pages)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetBackgroundImageResponseModelCopyWith<$Res> {
|
||||
factory $GetBackgroundImageResponseModelCopyWith(GetBackgroundImageResponseModel value, $Res Function(GetBackgroundImageResponseModel) _then) = _$GetBackgroundImageResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<GetPicturesItemResponseModel> items, int total, int page, int pages
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetBackgroundImageResponseModelCopyWithImpl<$Res>
|
||||
implements $GetBackgroundImageResponseModelCopyWith<$Res> {
|
||||
_$GetBackgroundImageResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetBackgroundImageResponseModel _self;
|
||||
final $Res Function(GetBackgroundImageResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetBackgroundImageResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,Object? total = null,Object? page = null,Object? pages = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetPicturesItemResponseModel>,total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetBackgroundImageResponseModel].
|
||||
extension GetBackgroundImageResponseModelPatterns on GetBackgroundImageResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetBackgroundImageResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetBackgroundImageResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetBackgroundImageResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetBackgroundImageResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetBackgroundImageResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetBackgroundImageResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<GetPicturesItemResponseModel> items, int total, int page, int pages)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetBackgroundImageResponseModel() when $default != null:
|
||||
return $default(_that.items,_that.total,_that.page,_that.pages);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<GetPicturesItemResponseModel> items, int total, int page, int pages) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetBackgroundImageResponseModel():
|
||||
return $default(_that.items,_that.total,_that.page,_that.pages);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<GetPicturesItemResponseModel> items, int total, int page, int pages)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetBackgroundImageResponseModel() when $default != null:
|
||||
return $default(_that.items,_that.total,_that.page,_that.pages);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetBackgroundImageResponseModel implements GetBackgroundImageResponseModel {
|
||||
const _GetBackgroundImageResponseModel({final List<GetPicturesItemResponseModel> items = const [], this.total = 0, this.page = 1, this.pages = 1}): _items = items;
|
||||
factory _GetBackgroundImageResponseModel.fromJson(Map<String, dynamic> json) => _$GetBackgroundImageResponseModelFromJson(json);
|
||||
|
||||
final List<GetPicturesItemResponseModel> _items;
|
||||
@override@JsonKey() List<GetPicturesItemResponseModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
@override@JsonKey() final int total;
|
||||
@override@JsonKey() final int page;
|
||||
@override@JsonKey() final int pages;
|
||||
|
||||
/// Create a copy of GetBackgroundImageResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetBackgroundImageResponseModelCopyWith<_GetBackgroundImageResponseModel> get copyWith => __$GetBackgroundImageResponseModelCopyWithImpl<_GetBackgroundImageResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetBackgroundImageResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetBackgroundImageResponseModel&&const DeepCollectionEquality().equals(other._items, _items)&&(identical(other.total, total) || other.total == total)&&(identical(other.page, page) || other.page == page)&&(identical(other.pages, pages) || other.pages == pages));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items),total,page,pages);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetBackgroundImageResponseModel(items: $items, total: $total, page: $page, pages: $pages)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetBackgroundImageResponseModelCopyWith<$Res> implements $GetBackgroundImageResponseModelCopyWith<$Res> {
|
||||
factory _$GetBackgroundImageResponseModelCopyWith(_GetBackgroundImageResponseModel value, $Res Function(_GetBackgroundImageResponseModel) _then) = __$GetBackgroundImageResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<GetPicturesItemResponseModel> items, int total, int page, int pages
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetBackgroundImageResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetBackgroundImageResponseModelCopyWith<$Res> {
|
||||
__$GetBackgroundImageResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetBackgroundImageResponseModel _self;
|
||||
final $Res Function(_GetBackgroundImageResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetBackgroundImageResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,Object? total = null,Object? page = null,Object? pages = null,}) {
|
||||
return _then(_GetBackgroundImageResponseModel(
|
||||
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetPicturesItemResponseModel>,total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable
|
||||
as int,pages: null == pages ? _self.pages : pages // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,33 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_background_image_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetBackgroundImageResponseModel _$GetBackgroundImageResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetBackgroundImageResponseModel(
|
||||
items:
|
||||
(json['items'] as List<dynamic>?)
|
||||
?.map(
|
||||
(e) => GetPicturesItemResponseModel.fromJson(
|
||||
e as Map<String, dynamic>,
|
||||
),
|
||||
)
|
||||
.toList() ??
|
||||
const [],
|
||||
total: (json['total'] as num?)?.toInt() ?? 0,
|
||||
page: (json['page'] as num?)?.toInt() ?? 1,
|
||||
pages: (json['pages'] as num?)?.toInt() ?? 1,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetBackgroundImageResponseModelToJson(
|
||||
_GetBackgroundImageResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'items': instance.items,
|
||||
'total': instance.total,
|
||||
'page': instance.page,
|
||||
'pages': instance.pages,
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../../features/apps_surveillance/data/installed_app_entity.dart';
|
||||
|
||||
part 'get_installed_apps_response_model.freezed.dart';
|
||||
part 'get_installed_apps_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetInstalledAppsResponseModel
|
||||
with _$GetInstalledAppsResponseModel {
|
||||
const factory GetInstalledAppsResponseModel({
|
||||
required int total,
|
||||
required List<InstalledAppItemResponseModel> items,
|
||||
}) = _GetInstalledAppsResponseModel;
|
||||
|
||||
factory GetInstalledAppsResponseModel.fromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$GetInstalledAppsResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class InstalledAppItemResponseModel
|
||||
with _$InstalledAppItemResponseModel {
|
||||
const factory InstalledAppItemResponseModel({
|
||||
required String appUid,
|
||||
required String appName,
|
||||
required bool isEnabled
|
||||
}) = _InstalledAppItemResponseModel;
|
||||
|
||||
factory InstalledAppItemResponseModel.fromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$InstalledAppItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension InstalledAppsResponseMapper
|
||||
on GetInstalledAppsResponseModel {
|
||||
List<InstalledAppEntity> toEntity() {
|
||||
return items
|
||||
.map((item) => InstalledAppEntity(
|
||||
appUid: item.appUid,
|
||||
appName: item.appName,
|
||||
isEnabled: item.isEnabled
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'get_installed_apps_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetInstalledAppsResponseModel {
|
||||
|
||||
int get total; List<InstalledAppItemResponseModel> get items;
|
||||
/// Create a copy of GetInstalledAppsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetInstalledAppsResponseModelCopyWith<GetInstalledAppsResponseModel> get copyWith => _$GetInstalledAppsResponseModelCopyWithImpl<GetInstalledAppsResponseModel>(this as GetInstalledAppsResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetInstalledAppsResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetInstalledAppsResponseModel&&(identical(other.total, total) || other.total == total)&&const DeepCollectionEquality().equals(other.items, items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,const DeepCollectionEquality().hash(items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetInstalledAppsResponseModel(total: $total, items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetInstalledAppsResponseModelCopyWith<$Res> {
|
||||
factory $GetInstalledAppsResponseModelCopyWith(GetInstalledAppsResponseModel value, $Res Function(GetInstalledAppsResponseModel) _then) = _$GetInstalledAppsResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int total, List<InstalledAppItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetInstalledAppsResponseModelCopyWithImpl<$Res>
|
||||
implements $GetInstalledAppsResponseModelCopyWith<$Res> {
|
||||
_$GetInstalledAppsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetInstalledAppsResponseModel _self;
|
||||
final $Res Function(GetInstalledAppsResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetInstalledAppsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? total = null,Object? items = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<InstalledAppItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetInstalledAppsResponseModel].
|
||||
extension GetInstalledAppsResponseModelPatterns on GetInstalledAppsResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetInstalledAppsResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetInstalledAppsResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetInstalledAppsResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetInstalledAppsResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetInstalledAppsResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetInstalledAppsResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int total, List<InstalledAppItemResponseModel> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetInstalledAppsResponseModel() when $default != null:
|
||||
return $default(_that.total,_that.items);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int total, List<InstalledAppItemResponseModel> items) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetInstalledAppsResponseModel():
|
||||
return $default(_that.total,_that.items);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int total, List<InstalledAppItemResponseModel> items)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetInstalledAppsResponseModel() when $default != null:
|
||||
return $default(_that.total,_that.items);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetInstalledAppsResponseModel implements GetInstalledAppsResponseModel {
|
||||
const _GetInstalledAppsResponseModel({required this.total, required final List<InstalledAppItemResponseModel> items}): _items = items;
|
||||
factory _GetInstalledAppsResponseModel.fromJson(Map<String, dynamic> json) => _$GetInstalledAppsResponseModelFromJson(json);
|
||||
|
||||
@override final int total;
|
||||
final List<InstalledAppItemResponseModel> _items;
|
||||
@override List<InstalledAppItemResponseModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetInstalledAppsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetInstalledAppsResponseModelCopyWith<_GetInstalledAppsResponseModel> get copyWith => __$GetInstalledAppsResponseModelCopyWithImpl<_GetInstalledAppsResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetInstalledAppsResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetInstalledAppsResponseModel&&(identical(other.total, total) || other.total == total)&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,const DeepCollectionEquality().hash(_items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetInstalledAppsResponseModel(total: $total, items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetInstalledAppsResponseModelCopyWith<$Res> implements $GetInstalledAppsResponseModelCopyWith<$Res> {
|
||||
factory _$GetInstalledAppsResponseModelCopyWith(_GetInstalledAppsResponseModel value, $Res Function(_GetInstalledAppsResponseModel) _then) = __$GetInstalledAppsResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int total, List<InstalledAppItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetInstalledAppsResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetInstalledAppsResponseModelCopyWith<$Res> {
|
||||
__$GetInstalledAppsResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetInstalledAppsResponseModel _self;
|
||||
final $Res Function(_GetInstalledAppsResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetInstalledAppsResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? total = null,Object? items = null,}) {
|
||||
return _then(_GetInstalledAppsResponseModel(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<InstalledAppItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$InstalledAppItemResponseModel {
|
||||
|
||||
String get appUid; String get appName; bool get isEnabled;
|
||||
/// Create a copy of InstalledAppItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$InstalledAppItemResponseModelCopyWith<InstalledAppItemResponseModel> get copyWith => _$InstalledAppItemResponseModelCopyWithImpl<InstalledAppItemResponseModel>(this as InstalledAppItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this InstalledAppItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is InstalledAppItemResponseModel&&(identical(other.appUid, appUid) || other.appUid == appUid)&&(identical(other.appName, appName) || other.appName == appName)&&(identical(other.isEnabled, isEnabled) || other.isEnabled == isEnabled));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,appUid,appName,isEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InstalledAppItemResponseModel(appUid: $appUid, appName: $appName, isEnabled: $isEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $InstalledAppItemResponseModelCopyWith<$Res> {
|
||||
factory $InstalledAppItemResponseModelCopyWith(InstalledAppItemResponseModel value, $Res Function(InstalledAppItemResponseModel) _then) = _$InstalledAppItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String appUid, String appName, bool isEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$InstalledAppItemResponseModelCopyWithImpl<$Res>
|
||||
implements $InstalledAppItemResponseModelCopyWith<$Res> {
|
||||
_$InstalledAppItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final InstalledAppItemResponseModel _self;
|
||||
final $Res Function(InstalledAppItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of InstalledAppItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? appUid = null,Object? appName = null,Object? isEnabled = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
appUid: null == appUid ? _self.appUid : appUid // ignore: cast_nullable_to_non_nullable
|
||||
as String,appName: null == appName ? _self.appName : appName // ignore: cast_nullable_to_non_nullable
|
||||
as String,isEnabled: null == isEnabled ? _self.isEnabled : isEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [InstalledAppItemResponseModel].
|
||||
extension InstalledAppItemResponseModelPatterns on InstalledAppItemResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _InstalledAppItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _InstalledAppItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppItemResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _InstalledAppItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String appUid, String appName, bool isEnabled)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppItemResponseModel() when $default != null:
|
||||
return $default(_that.appUid,_that.appName,_that.isEnabled);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String appUid, String appName, bool isEnabled) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppItemResponseModel():
|
||||
return $default(_that.appUid,_that.appName,_that.isEnabled);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String appUid, String appName, bool isEnabled)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppItemResponseModel() when $default != null:
|
||||
return $default(_that.appUid,_that.appName,_that.isEnabled);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _InstalledAppItemResponseModel implements InstalledAppItemResponseModel {
|
||||
const _InstalledAppItemResponseModel({required this.appUid, required this.appName, required this.isEnabled});
|
||||
factory _InstalledAppItemResponseModel.fromJson(Map<String, dynamic> json) => _$InstalledAppItemResponseModelFromJson(json);
|
||||
|
||||
@override final String appUid;
|
||||
@override final String appName;
|
||||
@override final bool isEnabled;
|
||||
|
||||
/// Create a copy of InstalledAppItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$InstalledAppItemResponseModelCopyWith<_InstalledAppItemResponseModel> get copyWith => __$InstalledAppItemResponseModelCopyWithImpl<_InstalledAppItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$InstalledAppItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _InstalledAppItemResponseModel&&(identical(other.appUid, appUid) || other.appUid == appUid)&&(identical(other.appName, appName) || other.appName == appName)&&(identical(other.isEnabled, isEnabled) || other.isEnabled == isEnabled));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,appUid,appName,isEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InstalledAppItemResponseModel(appUid: $appUid, appName: $appName, isEnabled: $isEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$InstalledAppItemResponseModelCopyWith<$Res> implements $InstalledAppItemResponseModelCopyWith<$Res> {
|
||||
factory _$InstalledAppItemResponseModelCopyWith(_InstalledAppItemResponseModel value, $Res Function(_InstalledAppItemResponseModel) _then) = __$InstalledAppItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String appUid, String appName, bool isEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$InstalledAppItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$InstalledAppItemResponseModelCopyWith<$Res> {
|
||||
__$InstalledAppItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _InstalledAppItemResponseModel _self;
|
||||
final $Res Function(_InstalledAppItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of InstalledAppItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? appUid = null,Object? appName = null,Object? isEnabled = null,}) {
|
||||
return _then(_InstalledAppItemResponseModel(
|
||||
appUid: null == appUid ? _self.appUid : appUid // ignore: cast_nullable_to_non_nullable
|
||||
as String,appName: null == appName ? _self.appName : appName // ignore: cast_nullable_to_non_nullable
|
||||
as String,isEnabled: null == isEnabled ? _self.isEnabled : isEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,39 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_installed_apps_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetInstalledAppsResponseModel _$GetInstalledAppsResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetInstalledAppsResponseModel(
|
||||
total: (json['total'] as num).toInt(),
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map(
|
||||
(e) =>
|
||||
InstalledAppItemResponseModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetInstalledAppsResponseModelToJson(
|
||||
_GetInstalledAppsResponseModel instance,
|
||||
) => <String, dynamic>{'total': instance.total, 'items': instance.items};
|
||||
|
||||
_InstalledAppItemResponseModel _$InstalledAppItemResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _InstalledAppItemResponseModel(
|
||||
appUid: json['appUid'] as String,
|
||||
appName: json['appName'] as String,
|
||||
isEnabled: json['isEnabled'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$InstalledAppItemResponseModelToJson(
|
||||
_InstalledAppItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'appUid': instance.appUid,
|
||||
'appName': instance.appName,
|
||||
'isEnabled': instance.isEnabled,
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'get_pictures_response_model.freezed.dart';
|
||||
part 'get_pictures_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetPicturesResponseModel with _$GetPicturesResponseModel {
|
||||
const factory GetPicturesResponseModel({
|
||||
required List<GetPicturesItemResponseModel> items,
|
||||
}) = _GetPicturesResponseModel;
|
||||
|
||||
factory GetPicturesResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetPicturesResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetPicturesItemResponseModel
|
||||
with _$GetPicturesItemResponseModel {
|
||||
const factory GetPicturesItemResponseModel({
|
||||
required String id,
|
||||
@Default('') String deviceIdentificator,
|
||||
String? imgType,
|
||||
String? timestamp,
|
||||
@Default('') String fileId,
|
||||
String? fileName,
|
||||
String? contentType,
|
||||
@Default(0) int createdAt,
|
||||
Map<String, dynamic>? file,
|
||||
}) = _GetPicturesItemResponseModel;
|
||||
|
||||
factory GetPicturesItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetPicturesItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
Uint8List? extractFileBytes(Map<String, dynamic>? file) {
|
||||
if (file == null) return null;
|
||||
final fileData = file['file'];
|
||||
if (fileData is String) {
|
||||
try {
|
||||
return base64Decode(fileData);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (fileData is Map) {
|
||||
final data = fileData['data'];
|
||||
if (data is List) {
|
||||
return Uint8List.fromList(data.cast<int>());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
extension GetPicturesResponseModelMapper on GetPicturesResponseModel {
|
||||
List<PictureEntity> toEntity() {
|
||||
return items
|
||||
.map((item) => PictureEntity(
|
||||
id: item.id,
|
||||
deviceIdentificator: item.deviceIdentificator,
|
||||
imgType: item.imgType,
|
||||
timestamp: item.timestamp,
|
||||
fileId: item.fileId,
|
||||
fileName: item.fileName,
|
||||
contentType: item.contentType,
|
||||
createdAt: item.createdAt,
|
||||
fileBytes: extractFileBytes(item.file),
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,578 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'get_pictures_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetPicturesResponseModel {
|
||||
|
||||
List<GetPicturesItemResponseModel> get items;
|
||||
/// Create a copy of GetPicturesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetPicturesResponseModelCopyWith<GetPicturesResponseModel> get copyWith => _$GetPicturesResponseModelCopyWithImpl<GetPicturesResponseModel>(this as GetPicturesResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetPicturesResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetPicturesResponseModel&&const DeepCollectionEquality().equals(other.items, items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetPicturesResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetPicturesResponseModelCopyWith<$Res> {
|
||||
factory $GetPicturesResponseModelCopyWith(GetPicturesResponseModel value, $Res Function(GetPicturesResponseModel) _then) = _$GetPicturesResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<GetPicturesItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetPicturesResponseModelCopyWithImpl<$Res>
|
||||
implements $GetPicturesResponseModelCopyWith<$Res> {
|
||||
_$GetPicturesResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetPicturesResponseModel _self;
|
||||
final $Res Function(GetPicturesResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetPicturesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? items = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetPicturesItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetPicturesResponseModel].
|
||||
extension GetPicturesResponseModelPatterns on GetPicturesResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetPicturesResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetPicturesResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetPicturesResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<GetPicturesItemResponseModel> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesResponseModel() when $default != null:
|
||||
return $default(_that.items);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<GetPicturesItemResponseModel> items) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesResponseModel():
|
||||
return $default(_that.items);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<GetPicturesItemResponseModel> items)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesResponseModel() when $default != null:
|
||||
return $default(_that.items);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetPicturesResponseModel implements GetPicturesResponseModel {
|
||||
const _GetPicturesResponseModel({required final List<GetPicturesItemResponseModel> items}): _items = items;
|
||||
factory _GetPicturesResponseModel.fromJson(Map<String, dynamic> json) => _$GetPicturesResponseModelFromJson(json);
|
||||
|
||||
final List<GetPicturesItemResponseModel> _items;
|
||||
@override List<GetPicturesItemResponseModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetPicturesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetPicturesResponseModelCopyWith<_GetPicturesResponseModel> get copyWith => __$GetPicturesResponseModelCopyWithImpl<_GetPicturesResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetPicturesResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetPicturesResponseModel&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetPicturesResponseModel(items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetPicturesResponseModelCopyWith<$Res> implements $GetPicturesResponseModelCopyWith<$Res> {
|
||||
factory _$GetPicturesResponseModelCopyWith(_GetPicturesResponseModel value, $Res Function(_GetPicturesResponseModel) _then) = __$GetPicturesResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<GetPicturesItemResponseModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetPicturesResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetPicturesResponseModelCopyWith<$Res> {
|
||||
__$GetPicturesResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetPicturesResponseModel _self;
|
||||
final $Res Function(_GetPicturesResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetPicturesResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? items = null,}) {
|
||||
return _then(_GetPicturesResponseModel(
|
||||
items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetPicturesItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetPicturesItemResponseModel {
|
||||
|
||||
String get id; String get deviceIdentificator; String? get imgType; String? get timestamp; String get fileId; String? get fileName; String? get contentType; int get createdAt; Map<String, dynamic>? get file;
|
||||
/// Create a copy of GetPicturesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetPicturesItemResponseModelCopyWith<GetPicturesItemResponseModel> get copyWith => _$GetPicturesItemResponseModelCopyWithImpl<GetPicturesItemResponseModel>(this as GetPicturesItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetPicturesItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetPicturesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.imgType, imgType) || other.imgType == imgType)&&(identical(other.timestamp, timestamp) || other.timestamp == timestamp)&&(identical(other.fileId, fileId) || other.fileId == fileId)&&(identical(other.fileName, fileName) || other.fileName == fileName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&const DeepCollectionEquality().equals(other.file, file));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,imgType,timestamp,fileId,fileName,contentType,createdAt,const DeepCollectionEquality().hash(file));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetPicturesItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, imgType: $imgType, timestamp: $timestamp, fileId: $fileId, fileName: $fileName, contentType: $contentType, createdAt: $createdAt, file: $file)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetPicturesItemResponseModelCopyWith<$Res> {
|
||||
factory $GetPicturesItemResponseModelCopyWith(GetPicturesItemResponseModel value, $Res Function(GetPicturesItemResponseModel) _then) = _$GetPicturesItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Map<String, dynamic>? file
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetPicturesItemResponseModelCopyWithImpl<$Res>
|
||||
implements $GetPicturesItemResponseModelCopyWith<$Res> {
|
||||
_$GetPicturesItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetPicturesItemResponseModel _self;
|
||||
final $Res Function(GetPicturesItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetPicturesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? imgType = freezed,Object? timestamp = freezed,Object? fileId = null,Object? fileName = freezed,Object? contentType = freezed,Object? createdAt = null,Object? file = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,imgType: freezed == imgType ? _self.imgType : imgType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,timestamp: freezed == timestamp ? _self.timestamp : timestamp // ignore: cast_nullable_to_non_nullable
|
||||
as String?,fileId: null == fileId ? _self.fileId : fileId // ignore: cast_nullable_to_non_nullable
|
||||
as String,fileName: freezed == fileName ? _self.fileName : fileName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,contentType: freezed == contentType ? _self.contentType : contentType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,file: freezed == file ? _self.file : file // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetPicturesItemResponseModel].
|
||||
extension GetPicturesItemResponseModelPatterns on GetPicturesItemResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetPicturesItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetPicturesItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesItemResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetPicturesItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Map<String, dynamic>? file)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.imgType,_that.timestamp,_that.fileId,_that.fileName,_that.contentType,_that.createdAt,_that.file);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Map<String, dynamic>? file) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesItemResponseModel():
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.imgType,_that.timestamp,_that.fileId,_that.fileName,_that.contentType,_that.createdAt,_that.file);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Map<String, dynamic>? file)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetPicturesItemResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.imgType,_that.timestamp,_that.fileId,_that.fileName,_that.contentType,_that.createdAt,_that.file);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetPicturesItemResponseModel implements GetPicturesItemResponseModel {
|
||||
const _GetPicturesItemResponseModel({required this.id, this.deviceIdentificator = '', this.imgType, this.timestamp, this.fileId = '', this.fileName, this.contentType, this.createdAt = 0, final Map<String, dynamic>? file}): _file = file;
|
||||
factory _GetPicturesItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetPicturesItemResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override@JsonKey() final String deviceIdentificator;
|
||||
@override final String? imgType;
|
||||
@override final String? timestamp;
|
||||
@override@JsonKey() final String fileId;
|
||||
@override final String? fileName;
|
||||
@override final String? contentType;
|
||||
@override@JsonKey() final int createdAt;
|
||||
final Map<String, dynamic>? _file;
|
||||
@override Map<String, dynamic>? get file {
|
||||
final value = _file;
|
||||
if (value == null) return null;
|
||||
if (_file is EqualUnmodifiableMapView) return _file;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableMapView(value);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetPicturesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetPicturesItemResponseModelCopyWith<_GetPicturesItemResponseModel> get copyWith => __$GetPicturesItemResponseModelCopyWithImpl<_GetPicturesItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetPicturesItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetPicturesItemResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.imgType, imgType) || other.imgType == imgType)&&(identical(other.timestamp, timestamp) || other.timestamp == timestamp)&&(identical(other.fileId, fileId) || other.fileId == fileId)&&(identical(other.fileName, fileName) || other.fileName == fileName)&&(identical(other.contentType, contentType) || other.contentType == contentType)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&const DeepCollectionEquality().equals(other._file, _file));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,imgType,timestamp,fileId,fileName,contentType,createdAt,const DeepCollectionEquality().hash(_file));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetPicturesItemResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, imgType: $imgType, timestamp: $timestamp, fileId: $fileId, fileName: $fileName, contentType: $contentType, createdAt: $createdAt, file: $file)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetPicturesItemResponseModelCopyWith<$Res> implements $GetPicturesItemResponseModelCopyWith<$Res> {
|
||||
factory _$GetPicturesItemResponseModelCopyWith(_GetPicturesItemResponseModel value, $Res Function(_GetPicturesItemResponseModel) _then) = __$GetPicturesItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Map<String, dynamic>? file
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetPicturesItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetPicturesItemResponseModelCopyWith<$Res> {
|
||||
__$GetPicturesItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetPicturesItemResponseModel _self;
|
||||
final $Res Function(_GetPicturesItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetPicturesItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? imgType = freezed,Object? timestamp = freezed,Object? fileId = null,Object? fileName = freezed,Object? contentType = freezed,Object? createdAt = null,Object? file = freezed,}) {
|
||||
return _then(_GetPicturesItemResponseModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,imgType: freezed == imgType ? _self.imgType : imgType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,timestamp: freezed == timestamp ? _self.timestamp : timestamp // ignore: cast_nullable_to_non_nullable
|
||||
as String?,fileId: null == fileId ? _self.fileId : fileId // ignore: cast_nullable_to_non_nullable
|
||||
as String,fileName: freezed == fileName ? _self.fileName : fileName // ignore: cast_nullable_to_non_nullable
|
||||
as String?,contentType: freezed == contentType ? _self.contentType : contentType // ignore: cast_nullable_to_non_nullable
|
||||
as String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,file: freezed == file ? _self._file : file // ignore: cast_nullable_to_non_nullable
|
||||
as Map<String, dynamic>?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,49 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_pictures_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetPicturesResponseModel _$GetPicturesResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetPicturesResponseModel(
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => GetPicturesItemResponseModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetPicturesResponseModelToJson(
|
||||
_GetPicturesResponseModel instance,
|
||||
) => <String, dynamic>{'items': instance.items};
|
||||
|
||||
_GetPicturesItemResponseModel _$GetPicturesItemResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetPicturesItemResponseModel(
|
||||
id: json['id'] as String,
|
||||
deviceIdentificator: json['deviceIdentificator'] as String? ?? '',
|
||||
imgType: json['imgType'] as String?,
|
||||
timestamp: json['timestamp'] as String?,
|
||||
fileId: json['fileId'] as String? ?? '',
|
||||
fileName: json['fileName'] as String?,
|
||||
contentType: json['contentType'] as String?,
|
||||
createdAt: (json['createdAt'] as num?)?.toInt() ?? 0,
|
||||
file: json['file'] as Map<String, dynamic>?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetPicturesItemResponseModelToJson(
|
||||
_GetPicturesItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'deviceIdentificator': instance.deviceIdentificator,
|
||||
'imgType': instance.imgType,
|
||||
'timestamp': instance.timestamp,
|
||||
'fileId': instance.fileId,
|
||||
'fileName': instance.fileName,
|
||||
'contentType': instance.contentType,
|
||||
'createdAt': instance.createdAt,
|
||||
'file': instance.file,
|
||||
};
|
||||
@@ -0,0 +1,56 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:device_management/src/core/domain/entities/schedule_period_entity.dart';
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'get_schedule_response_model.freezed.dart';
|
||||
part 'get_schedule_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class GetScheduleResponseModel with _$GetScheduleResponseModel {
|
||||
const factory GetScheduleResponseModel({
|
||||
required GetScheduleListResponseModel item,
|
||||
}) = _GetScheduleResponseModel;
|
||||
|
||||
factory GetScheduleResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetScheduleResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetScheduleListResponseModel with _$GetScheduleListResponseModel {
|
||||
const factory GetScheduleListResponseModel({
|
||||
required String id,
|
||||
required String deviceIdentificator,
|
||||
required List<GetScheduleItemResponseModel> periods,
|
||||
}) = _GetScheduleListResponseModel;
|
||||
|
||||
factory GetScheduleListResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetScheduleListResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class GetScheduleItemResponseModel
|
||||
with _$GetScheduleItemResponseModel {
|
||||
const factory GetScheduleItemResponseModel({
|
||||
required String periodStart,
|
||||
required String periodEnd,
|
||||
required bool isPeriodEnabled,
|
||||
}) = _GetScheduleItemResponseModel;
|
||||
|
||||
factory GetScheduleItemResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$GetScheduleItemResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
extension GetScheduleResponseModelMapper on GetScheduleResponseModel {
|
||||
List<SchedulePeriodEntity> toEntity() {
|
||||
return item.periods
|
||||
.map((period) => SchedulePeriodEntity(
|
||||
periodStart: period.periodStart,
|
||||
periodEnd: period.periodEnd,
|
||||
isPeriodEnabled: period.isPeriodEnabled,
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,839 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'get_schedule_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetScheduleResponseModel {
|
||||
|
||||
GetScheduleListResponseModel get item;
|
||||
/// Create a copy of GetScheduleResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetScheduleResponseModelCopyWith<GetScheduleResponseModel> get copyWith => _$GetScheduleResponseModelCopyWithImpl<GetScheduleResponseModel>(this as GetScheduleResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetScheduleResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetScheduleResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetScheduleResponseModel(item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetScheduleResponseModelCopyWith<$Res> {
|
||||
factory $GetScheduleResponseModelCopyWith(GetScheduleResponseModel value, $Res Function(GetScheduleResponseModel) _then) = _$GetScheduleResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
GetScheduleListResponseModel item
|
||||
});
|
||||
|
||||
|
||||
$GetScheduleListResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetScheduleResponseModelCopyWithImpl<$Res>
|
||||
implements $GetScheduleResponseModelCopyWith<$Res> {
|
||||
_$GetScheduleResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetScheduleResponseModel _self;
|
||||
final $Res Function(GetScheduleResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetScheduleResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? item = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as GetScheduleListResponseModel,
|
||||
));
|
||||
}
|
||||
/// Create a copy of GetScheduleResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetScheduleListResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $GetScheduleListResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetScheduleResponseModel].
|
||||
extension GetScheduleResponseModelPatterns on GetScheduleResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetScheduleResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetScheduleResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetScheduleResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( GetScheduleListResponseModel item)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleResponseModel() when $default != null:
|
||||
return $default(_that.item);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( GetScheduleListResponseModel item) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleResponseModel():
|
||||
return $default(_that.item);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( GetScheduleListResponseModel item)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleResponseModel() when $default != null:
|
||||
return $default(_that.item);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetScheduleResponseModel implements GetScheduleResponseModel {
|
||||
const _GetScheduleResponseModel({required this.item});
|
||||
factory _GetScheduleResponseModel.fromJson(Map<String, dynamic> json) => _$GetScheduleResponseModelFromJson(json);
|
||||
|
||||
@override final GetScheduleListResponseModel item;
|
||||
|
||||
/// Create a copy of GetScheduleResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetScheduleResponseModelCopyWith<_GetScheduleResponseModel> get copyWith => __$GetScheduleResponseModelCopyWithImpl<_GetScheduleResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetScheduleResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetScheduleResponseModel&&(identical(other.item, item) || other.item == item));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetScheduleResponseModel(item: $item)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetScheduleResponseModelCopyWith<$Res> implements $GetScheduleResponseModelCopyWith<$Res> {
|
||||
factory _$GetScheduleResponseModelCopyWith(_GetScheduleResponseModel value, $Res Function(_GetScheduleResponseModel) _then) = __$GetScheduleResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
GetScheduleListResponseModel item
|
||||
});
|
||||
|
||||
|
||||
@override $GetScheduleListResponseModelCopyWith<$Res> get item;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetScheduleResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetScheduleResponseModelCopyWith<$Res> {
|
||||
__$GetScheduleResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetScheduleResponseModel _self;
|
||||
final $Res Function(_GetScheduleResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetScheduleResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? item = null,}) {
|
||||
return _then(_GetScheduleResponseModel(
|
||||
item: null == item ? _self.item : item // ignore: cast_nullable_to_non_nullable
|
||||
as GetScheduleListResponseModel,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of GetScheduleResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetScheduleListResponseModelCopyWith<$Res> get item {
|
||||
|
||||
return $GetScheduleListResponseModelCopyWith<$Res>(_self.item, (value) {
|
||||
return _then(_self.copyWith(item: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetScheduleListResponseModel {
|
||||
|
||||
String get id; String get deviceIdentificator; List<GetScheduleItemResponseModel> get periods;
|
||||
/// Create a copy of GetScheduleListResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetScheduleListResponseModelCopyWith<GetScheduleListResponseModel> get copyWith => _$GetScheduleListResponseModelCopyWithImpl<GetScheduleListResponseModel>(this as GetScheduleListResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetScheduleListResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetScheduleListResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&const DeepCollectionEquality().equals(other.periods, periods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,const DeepCollectionEquality().hash(periods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetScheduleListResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, periods: $periods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetScheduleListResponseModelCopyWith<$Res> {
|
||||
factory $GetScheduleListResponseModelCopyWith(GetScheduleListResponseModel value, $Res Function(GetScheduleListResponseModel) _then) = _$GetScheduleListResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, List<GetScheduleItemResponseModel> periods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetScheduleListResponseModelCopyWithImpl<$Res>
|
||||
implements $GetScheduleListResponseModelCopyWith<$Res> {
|
||||
_$GetScheduleListResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetScheduleListResponseModel _self;
|
||||
final $Res Function(GetScheduleListResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetScheduleListResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceIdentificator = null,Object? periods = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,periods: null == periods ? _self.periods : periods // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetScheduleItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetScheduleListResponseModel].
|
||||
extension GetScheduleListResponseModelPatterns on GetScheduleListResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetScheduleListResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleListResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetScheduleListResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleListResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetScheduleListResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleListResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, List<GetScheduleItemResponseModel> periods)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleListResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.periods);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, List<GetScheduleItemResponseModel> periods) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleListResponseModel():
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.periods);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, List<GetScheduleItemResponseModel> periods)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleListResponseModel() when $default != null:
|
||||
return $default(_that.id,_that.deviceIdentificator,_that.periods);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetScheduleListResponseModel implements GetScheduleListResponseModel {
|
||||
const _GetScheduleListResponseModel({required this.id, required this.deviceIdentificator, required final List<GetScheduleItemResponseModel> periods}): _periods = periods;
|
||||
factory _GetScheduleListResponseModel.fromJson(Map<String, dynamic> json) => _$GetScheduleListResponseModelFromJson(json);
|
||||
|
||||
@override final String id;
|
||||
@override final String deviceIdentificator;
|
||||
final List<GetScheduleItemResponseModel> _periods;
|
||||
@override List<GetScheduleItemResponseModel> get periods {
|
||||
if (_periods is EqualUnmodifiableListView) return _periods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_periods);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of GetScheduleListResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetScheduleListResponseModelCopyWith<_GetScheduleListResponseModel> get copyWith => __$GetScheduleListResponseModelCopyWithImpl<_GetScheduleListResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetScheduleListResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetScheduleListResponseModel&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&const DeepCollectionEquality().equals(other._periods, _periods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,const DeepCollectionEquality().hash(_periods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetScheduleListResponseModel(id: $id, deviceIdentificator: $deviceIdentificator, periods: $periods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetScheduleListResponseModelCopyWith<$Res> implements $GetScheduleListResponseModelCopyWith<$Res> {
|
||||
factory _$GetScheduleListResponseModelCopyWith(_GetScheduleListResponseModel value, $Res Function(_GetScheduleListResponseModel) _then) = __$GetScheduleListResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String id, String deviceIdentificator, List<GetScheduleItemResponseModel> periods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetScheduleListResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetScheduleListResponseModelCopyWith<$Res> {
|
||||
__$GetScheduleListResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetScheduleListResponseModel _self;
|
||||
final $Res Function(_GetScheduleListResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetScheduleListResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceIdentificator = null,Object? periods = null,}) {
|
||||
return _then(_GetScheduleListResponseModel(
|
||||
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
|
||||
as String,deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,periods: null == periods ? _self._periods : periods // ignore: cast_nullable_to_non_nullable
|
||||
as List<GetScheduleItemResponseModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$GetScheduleItemResponseModel {
|
||||
|
||||
String get periodStart; String get periodEnd; bool get isPeriodEnabled;
|
||||
/// Create a copy of GetScheduleItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$GetScheduleItemResponseModelCopyWith<GetScheduleItemResponseModel> get copyWith => _$GetScheduleItemResponseModelCopyWithImpl<GetScheduleItemResponseModel>(this as GetScheduleItemResponseModel, _$identity);
|
||||
|
||||
/// Serializes this GetScheduleItemResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is GetScheduleItemResponseModel&&(identical(other.periodStart, periodStart) || other.periodStart == periodStart)&&(identical(other.periodEnd, periodEnd) || other.periodEnd == periodEnd)&&(identical(other.isPeriodEnabled, isPeriodEnabled) || other.isPeriodEnabled == isPeriodEnabled));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,periodStart,periodEnd,isPeriodEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetScheduleItemResponseModel(periodStart: $periodStart, periodEnd: $periodEnd, isPeriodEnabled: $isPeriodEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $GetScheduleItemResponseModelCopyWith<$Res> {
|
||||
factory $GetScheduleItemResponseModelCopyWith(GetScheduleItemResponseModel value, $Res Function(GetScheduleItemResponseModel) _then) = _$GetScheduleItemResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String periodStart, String periodEnd, bool isPeriodEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$GetScheduleItemResponseModelCopyWithImpl<$Res>
|
||||
implements $GetScheduleItemResponseModelCopyWith<$Res> {
|
||||
_$GetScheduleItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final GetScheduleItemResponseModel _self;
|
||||
final $Res Function(GetScheduleItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetScheduleItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? periodStart = null,Object? periodEnd = null,Object? isPeriodEnabled = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
periodStart: null == periodStart ? _self.periodStart : periodStart // ignore: cast_nullable_to_non_nullable
|
||||
as String,periodEnd: null == periodEnd ? _self.periodEnd : periodEnd // ignore: cast_nullable_to_non_nullable
|
||||
as String,isPeriodEnabled: null == isPeriodEnabled ? _self.isPeriodEnabled : isPeriodEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [GetScheduleItemResponseModel].
|
||||
extension GetScheduleItemResponseModelPatterns on GetScheduleItemResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _GetScheduleItemResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _GetScheduleItemResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleItemResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _GetScheduleItemResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleItemResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String periodStart, String periodEnd, bool isPeriodEnabled)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleItemResponseModel() when $default != null:
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String periodStart, String periodEnd, bool isPeriodEnabled) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleItemResponseModel():
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String periodStart, String periodEnd, bool isPeriodEnabled)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _GetScheduleItemResponseModel() when $default != null:
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _GetScheduleItemResponseModel implements GetScheduleItemResponseModel {
|
||||
const _GetScheduleItemResponseModel({required this.periodStart, required this.periodEnd, required this.isPeriodEnabled});
|
||||
factory _GetScheduleItemResponseModel.fromJson(Map<String, dynamic> json) => _$GetScheduleItemResponseModelFromJson(json);
|
||||
|
||||
@override final String periodStart;
|
||||
@override final String periodEnd;
|
||||
@override final bool isPeriodEnabled;
|
||||
|
||||
/// Create a copy of GetScheduleItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$GetScheduleItemResponseModelCopyWith<_GetScheduleItemResponseModel> get copyWith => __$GetScheduleItemResponseModelCopyWithImpl<_GetScheduleItemResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$GetScheduleItemResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _GetScheduleItemResponseModel&&(identical(other.periodStart, periodStart) || other.periodStart == periodStart)&&(identical(other.periodEnd, periodEnd) || other.periodEnd == periodEnd)&&(identical(other.isPeriodEnabled, isPeriodEnabled) || other.isPeriodEnabled == isPeriodEnabled));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,periodStart,periodEnd,isPeriodEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'GetScheduleItemResponseModel(periodStart: $periodStart, periodEnd: $periodEnd, isPeriodEnabled: $isPeriodEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$GetScheduleItemResponseModelCopyWith<$Res> implements $GetScheduleItemResponseModelCopyWith<$Res> {
|
||||
factory _$GetScheduleItemResponseModelCopyWith(_GetScheduleItemResponseModel value, $Res Function(_GetScheduleItemResponseModel) _then) = __$GetScheduleItemResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String periodStart, String periodEnd, bool isPeriodEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$GetScheduleItemResponseModelCopyWithImpl<$Res>
|
||||
implements _$GetScheduleItemResponseModelCopyWith<$Res> {
|
||||
__$GetScheduleItemResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _GetScheduleItemResponseModel _self;
|
||||
final $Res Function(_GetScheduleItemResponseModel) _then;
|
||||
|
||||
/// Create a copy of GetScheduleItemResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? periodStart = null,Object? periodEnd = null,Object? isPeriodEnabled = null,}) {
|
||||
return _then(_GetScheduleItemResponseModel(
|
||||
periodStart: null == periodStart ? _self.periodStart : periodStart // ignore: cast_nullable_to_non_nullable
|
||||
as String,periodEnd: null == periodEnd ? _self.periodEnd : periodEnd // ignore: cast_nullable_to_non_nullable
|
||||
as String,isPeriodEnabled: null == isPeriodEnabled ? _self.isPeriodEnabled : isPeriodEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,55 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'get_schedule_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_GetScheduleResponseModel _$GetScheduleResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetScheduleResponseModel(
|
||||
item: GetScheduleListResponseModel.fromJson(
|
||||
json['item'] as Map<String, dynamic>,
|
||||
),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetScheduleResponseModelToJson(
|
||||
_GetScheduleResponseModel instance,
|
||||
) => <String, dynamic>{'item': instance.item};
|
||||
|
||||
_GetScheduleListResponseModel _$GetScheduleListResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetScheduleListResponseModel(
|
||||
id: json['id'] as String,
|
||||
deviceIdentificator: json['deviceIdentificator'] as String,
|
||||
periods: (json['periods'] as List<dynamic>)
|
||||
.map(
|
||||
(e) => GetScheduleItemResponseModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetScheduleListResponseModelToJson(
|
||||
_GetScheduleListResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'deviceIdentificator': instance.deviceIdentificator,
|
||||
'periods': instance.periods,
|
||||
};
|
||||
|
||||
_GetScheduleItemResponseModel _$GetScheduleItemResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _GetScheduleItemResponseModel(
|
||||
periodStart: json['periodStart'] as String,
|
||||
periodEnd: json['periodEnd'] as String,
|
||||
isPeriodEnabled: json['isPeriodEnabled'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$GetScheduleItemResponseModelToJson(
|
||||
_GetScheduleItemResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'periodStart': instance.periodStart,
|
||||
'periodEnd': instance.periodEnd,
|
||||
'isPeriodEnabled': instance.isPeriodEnabled,
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'upsert_schedule_request_model.freezed.dart';
|
||||
part 'upsert_schedule_request_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class UpdateScheduleRequestModel with _$UpdateScheduleRequestModel {
|
||||
const factory UpdateScheduleRequestModel({
|
||||
required List<UpdateScheduleItemRequestModel> periods,
|
||||
}) = _UpdateScheduleRequestModel;
|
||||
|
||||
factory UpdateScheduleRequestModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$UpdateScheduleRequestModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class UpdateScheduleItemRequestModel
|
||||
with _$UpdateScheduleItemRequestModel {
|
||||
const factory UpdateScheduleItemRequestModel({
|
||||
required String periodStart,
|
||||
required String periodEnd,
|
||||
required bool isPeriodEnabled,
|
||||
}) = _UpdateScheduleItemRequestModel;
|
||||
|
||||
factory UpdateScheduleItemRequestModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$UpdateScheduleItemRequestModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,552 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'upsert_schedule_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UpdateScheduleRequestModel {
|
||||
|
||||
List<UpdateScheduleItemRequestModel> get periods;
|
||||
/// Create a copy of UpdateScheduleRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$UpdateScheduleRequestModelCopyWith<UpdateScheduleRequestModel> get copyWith => _$UpdateScheduleRequestModelCopyWithImpl<UpdateScheduleRequestModel>(this as UpdateScheduleRequestModel, _$identity);
|
||||
|
||||
/// Serializes this UpdateScheduleRequestModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateScheduleRequestModel&&const DeepCollectionEquality().equals(other.periods, periods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(periods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateScheduleRequestModel(periods: $periods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $UpdateScheduleRequestModelCopyWith<$Res> {
|
||||
factory $UpdateScheduleRequestModelCopyWith(UpdateScheduleRequestModel value, $Res Function(UpdateScheduleRequestModel) _then) = _$UpdateScheduleRequestModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<UpdateScheduleItemRequestModel> periods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$UpdateScheduleRequestModelCopyWithImpl<$Res>
|
||||
implements $UpdateScheduleRequestModelCopyWith<$Res> {
|
||||
_$UpdateScheduleRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final UpdateScheduleRequestModel _self;
|
||||
final $Res Function(UpdateScheduleRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateScheduleRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? periods = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
periods: null == periods ? _self.periods : periods // ignore: cast_nullable_to_non_nullable
|
||||
as List<UpdateScheduleItemRequestModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UpdateScheduleRequestModel].
|
||||
extension UpdateScheduleRequestModelPatterns on UpdateScheduleRequestModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _UpdateScheduleRequestModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _UpdateScheduleRequestModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleRequestModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _UpdateScheduleRequestModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<UpdateScheduleItemRequestModel> periods)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleRequestModel() when $default != null:
|
||||
return $default(_that.periods);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<UpdateScheduleItemRequestModel> periods) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleRequestModel():
|
||||
return $default(_that.periods);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<UpdateScheduleItemRequestModel> periods)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleRequestModel() when $default != null:
|
||||
return $default(_that.periods);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _UpdateScheduleRequestModel implements UpdateScheduleRequestModel {
|
||||
const _UpdateScheduleRequestModel({required final List<UpdateScheduleItemRequestModel> periods}): _periods = periods;
|
||||
factory _UpdateScheduleRequestModel.fromJson(Map<String, dynamic> json) => _$UpdateScheduleRequestModelFromJson(json);
|
||||
|
||||
final List<UpdateScheduleItemRequestModel> _periods;
|
||||
@override List<UpdateScheduleItemRequestModel> get periods {
|
||||
if (_periods is EqualUnmodifiableListView) return _periods;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_periods);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of UpdateScheduleRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$UpdateScheduleRequestModelCopyWith<_UpdateScheduleRequestModel> get copyWith => __$UpdateScheduleRequestModelCopyWithImpl<_UpdateScheduleRequestModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$UpdateScheduleRequestModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateScheduleRequestModel&&const DeepCollectionEquality().equals(other._periods, _periods));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_periods));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateScheduleRequestModel(periods: $periods)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$UpdateScheduleRequestModelCopyWith<$Res> implements $UpdateScheduleRequestModelCopyWith<$Res> {
|
||||
factory _$UpdateScheduleRequestModelCopyWith(_UpdateScheduleRequestModel value, $Res Function(_UpdateScheduleRequestModel) _then) = __$UpdateScheduleRequestModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<UpdateScheduleItemRequestModel> periods
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$UpdateScheduleRequestModelCopyWithImpl<$Res>
|
||||
implements _$UpdateScheduleRequestModelCopyWith<$Res> {
|
||||
__$UpdateScheduleRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _UpdateScheduleRequestModel _self;
|
||||
final $Res Function(_UpdateScheduleRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateScheduleRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? periods = null,}) {
|
||||
return _then(_UpdateScheduleRequestModel(
|
||||
periods: null == periods ? _self._periods : periods // ignore: cast_nullable_to_non_nullable
|
||||
as List<UpdateScheduleItemRequestModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$UpdateScheduleItemRequestModel {
|
||||
|
||||
String get periodStart; String get periodEnd; bool get isPeriodEnabled;
|
||||
/// Create a copy of UpdateScheduleItemRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$UpdateScheduleItemRequestModelCopyWith<UpdateScheduleItemRequestModel> get copyWith => _$UpdateScheduleItemRequestModelCopyWithImpl<UpdateScheduleItemRequestModel>(this as UpdateScheduleItemRequestModel, _$identity);
|
||||
|
||||
/// Serializes this UpdateScheduleItemRequestModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is UpdateScheduleItemRequestModel&&(identical(other.periodStart, periodStart) || other.periodStart == periodStart)&&(identical(other.periodEnd, periodEnd) || other.periodEnd == periodEnd)&&(identical(other.isPeriodEnabled, isPeriodEnabled) || other.isPeriodEnabled == isPeriodEnabled));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,periodStart,periodEnd,isPeriodEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateScheduleItemRequestModel(periodStart: $periodStart, periodEnd: $periodEnd, isPeriodEnabled: $isPeriodEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $UpdateScheduleItemRequestModelCopyWith<$Res> {
|
||||
factory $UpdateScheduleItemRequestModelCopyWith(UpdateScheduleItemRequestModel value, $Res Function(UpdateScheduleItemRequestModel) _then) = _$UpdateScheduleItemRequestModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String periodStart, String periodEnd, bool isPeriodEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$UpdateScheduleItemRequestModelCopyWithImpl<$Res>
|
||||
implements $UpdateScheduleItemRequestModelCopyWith<$Res> {
|
||||
_$UpdateScheduleItemRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final UpdateScheduleItemRequestModel _self;
|
||||
final $Res Function(UpdateScheduleItemRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateScheduleItemRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? periodStart = null,Object? periodEnd = null,Object? isPeriodEnabled = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
periodStart: null == periodStart ? _self.periodStart : periodStart // ignore: cast_nullable_to_non_nullable
|
||||
as String,periodEnd: null == periodEnd ? _self.periodEnd : periodEnd // ignore: cast_nullable_to_non_nullable
|
||||
as String,isPeriodEnabled: null == isPeriodEnabled ? _self.isPeriodEnabled : isPeriodEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [UpdateScheduleItemRequestModel].
|
||||
extension UpdateScheduleItemRequestModelPatterns on UpdateScheduleItemRequestModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _UpdateScheduleItemRequestModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleItemRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _UpdateScheduleItemRequestModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleItemRequestModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _UpdateScheduleItemRequestModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleItemRequestModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String periodStart, String periodEnd, bool isPeriodEnabled)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleItemRequestModel() when $default != null:
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String periodStart, String periodEnd, bool isPeriodEnabled) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleItemRequestModel():
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String periodStart, String periodEnd, bool isPeriodEnabled)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _UpdateScheduleItemRequestModel() when $default != null:
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _UpdateScheduleItemRequestModel implements UpdateScheduleItemRequestModel {
|
||||
const _UpdateScheduleItemRequestModel({required this.periodStart, required this.periodEnd, required this.isPeriodEnabled});
|
||||
factory _UpdateScheduleItemRequestModel.fromJson(Map<String, dynamic> json) => _$UpdateScheduleItemRequestModelFromJson(json);
|
||||
|
||||
@override final String periodStart;
|
||||
@override final String periodEnd;
|
||||
@override final bool isPeriodEnabled;
|
||||
|
||||
/// Create a copy of UpdateScheduleItemRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$UpdateScheduleItemRequestModelCopyWith<_UpdateScheduleItemRequestModel> get copyWith => __$UpdateScheduleItemRequestModelCopyWithImpl<_UpdateScheduleItemRequestModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$UpdateScheduleItemRequestModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _UpdateScheduleItemRequestModel&&(identical(other.periodStart, periodStart) || other.periodStart == periodStart)&&(identical(other.periodEnd, periodEnd) || other.periodEnd == periodEnd)&&(identical(other.isPeriodEnabled, isPeriodEnabled) || other.isPeriodEnabled == isPeriodEnabled));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,periodStart,periodEnd,isPeriodEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'UpdateScheduleItemRequestModel(periodStart: $periodStart, periodEnd: $periodEnd, isPeriodEnabled: $isPeriodEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$UpdateScheduleItemRequestModelCopyWith<$Res> implements $UpdateScheduleItemRequestModelCopyWith<$Res> {
|
||||
factory _$UpdateScheduleItemRequestModelCopyWith(_UpdateScheduleItemRequestModel value, $Res Function(_UpdateScheduleItemRequestModel) _then) = __$UpdateScheduleItemRequestModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String periodStart, String periodEnd, bool isPeriodEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$UpdateScheduleItemRequestModelCopyWithImpl<$Res>
|
||||
implements _$UpdateScheduleItemRequestModelCopyWith<$Res> {
|
||||
__$UpdateScheduleItemRequestModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _UpdateScheduleItemRequestModel _self;
|
||||
final $Res Function(_UpdateScheduleItemRequestModel) _then;
|
||||
|
||||
/// Create a copy of UpdateScheduleItemRequestModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? periodStart = null,Object? periodEnd = null,Object? isPeriodEnabled = null,}) {
|
||||
return _then(_UpdateScheduleItemRequestModel(
|
||||
periodStart: null == periodStart ? _self.periodStart : periodStart // ignore: cast_nullable_to_non_nullable
|
||||
as String,periodEnd: null == periodEnd ? _self.periodEnd : periodEnd // ignore: cast_nullable_to_non_nullable
|
||||
as String,isPeriodEnabled: null == isPeriodEnabled ? _self.isPeriodEnabled : isPeriodEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,38 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'upsert_schedule_request_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_UpdateScheduleRequestModel _$UpdateScheduleRequestModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _UpdateScheduleRequestModel(
|
||||
periods: (json['periods'] as List<dynamic>)
|
||||
.map(
|
||||
(e) =>
|
||||
UpdateScheduleItemRequestModel.fromJson(e as Map<String, dynamic>),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UpdateScheduleRequestModelToJson(
|
||||
_UpdateScheduleRequestModel instance,
|
||||
) => <String, dynamic>{'periods': instance.periods};
|
||||
|
||||
_UpdateScheduleItemRequestModel _$UpdateScheduleItemRequestModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _UpdateScheduleItemRequestModel(
|
||||
periodStart: json['periodStart'] as String,
|
||||
periodEnd: json['periodEnd'] as String,
|
||||
isPeriodEnabled: json['isPeriodEnabled'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UpdateScheduleItemRequestModelToJson(
|
||||
_UpdateScheduleItemRequestModel instance,
|
||||
) => <String, dynamic>{
|
||||
'periodStart': instance.periodStart,
|
||||
'periodEnd': instance.periodEnd,
|
||||
'isPeriodEnabled': instance.isPeriodEnabled,
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:device_management/src/core/data/models/get_installed_apps_response_model.dart';
|
||||
import 'package:device_management/src/core/data/models/get_schedule_response_model.dart';
|
||||
import 'package:device_management/src/core/domain/entities/schedule_period_entity.dart';
|
||||
import 'package:device_management/src/features/apps_surveillance/data/installed_app_entity.dart';
|
||||
|
||||
import '../../domain/repositories/app_surveillance_repository.dart';
|
||||
import '../datasources/apps_surveillance_remote_datasource.dart';
|
||||
import '../models/upsert_schedule_request_model.dart';
|
||||
|
||||
class AppSurveillanceRepositoryImpl
|
||||
implements AppSurveillanceRepository {
|
||||
const AppSurveillanceRepositoryImpl(this._remote);
|
||||
|
||||
final AppSurveillanceRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<InstalledAppEntity>> getInstalledApps({
|
||||
required String deviceId
|
||||
}) async {
|
||||
final model = await _remote.getInstalledApps(deviceId: deviceId);
|
||||
return model.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<SchedulePeriodEntity>> getSchedule({required String deviceId}) async {
|
||||
final model = await _remote.getSchedule(deviceId: deviceId);
|
||||
return model.toEntity();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> upsertSchedule({
|
||||
required String deviceId,
|
||||
required UpdateScheduleRequestModel request
|
||||
}) {
|
||||
return _remote.upsertSchedule(
|
||||
deviceId: deviceId,
|
||||
request: request
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
import 'package:device_management/src/core/data/models/get_background_image_response_model.dart';
|
||||
|
||||
import '../../../features/remote_connection/domain/entities/picture_entity.dart';
|
||||
import '../../domain/repositories/background_image_repository.dart';
|
||||
import '../datasources/background_image_remote_datasource.dart';
|
||||
|
||||
class BackgroundImageRepositoryImpl implements BackgroundImageRepository {
|
||||
const BackgroundImageRepositoryImpl(this._remote);
|
||||
|
||||
final BackgroundImageRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<PictureEntity>> getPhotos() async {
|
||||
final model = await _remote.getBackgroundImage();
|
||||
return model.toEntities();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> uploadImage({required String path}) {
|
||||
return _remote.uploadImage(path: path);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setBackgroundImage({required String deviceId, required String photoId}) {
|
||||
return _remote.setBackgroundImage(deviceId: deviceId, photoId: photoId);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import 'package:device_management/src/core/data/datasources/functions_remote_datasource.dart';
|
||||
import 'package:device_management/src/core/domain/repositories/functions_repository.dart';
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
|
||||
class FunctionsRepositoryImpl implements FunctionsRepository {
|
||||
const FunctionsRepositoryImpl(this._remote);
|
||||
|
||||
final FunctionsRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<PictureEntity>> getPictures({required String userId}) async {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 2000));
|
||||
return _remote.getPictures(userId: userId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PictureEntity> takePicture({required String userId}) async {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 2000));
|
||||
return _remote.takePicture(userId: userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
|
||||
import '../../domain/repositories/pictures_repository.dart';
|
||||
import '../datasources/pictures_remote_datasource.dart';
|
||||
|
||||
class PicturesRepositoryImpl implements PicturesRepository {
|
||||
const PicturesRepositoryImpl(this._remote);
|
||||
|
||||
final PicturesRemoteDatasource _remote;
|
||||
|
||||
@override
|
||||
Future<List<PictureEntity>> getPictures({required String deviceId}) {
|
||||
return _remote.getPictures(deviceId: deviceId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PictureEntity> takePicture({required String deviceId}) {
|
||||
return _remote.takePicture(deviceId: deviceId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'schedule_period_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class SchedulePeriodEntity with _$SchedulePeriodEntity {
|
||||
const factory SchedulePeriodEntity({
|
||||
required String periodStart,
|
||||
required String periodEnd,
|
||||
required bool isPeriodEnabled,
|
||||
}) = _SchedulePeriodEntity;
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'schedule_period_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$SchedulePeriodEntity {
|
||||
|
||||
String get periodStart; String get periodEnd; bool get isPeriodEnabled;
|
||||
/// Create a copy of SchedulePeriodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$SchedulePeriodEntityCopyWith<SchedulePeriodEntity> get copyWith => _$SchedulePeriodEntityCopyWithImpl<SchedulePeriodEntity>(this as SchedulePeriodEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is SchedulePeriodEntity&&(identical(other.periodStart, periodStart) || other.periodStart == periodStart)&&(identical(other.periodEnd, periodEnd) || other.periodEnd == periodEnd)&&(identical(other.isPeriodEnabled, isPeriodEnabled) || other.isPeriodEnabled == isPeriodEnabled));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,periodStart,periodEnd,isPeriodEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SchedulePeriodEntity(periodStart: $periodStart, periodEnd: $periodEnd, isPeriodEnabled: $isPeriodEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $SchedulePeriodEntityCopyWith<$Res> {
|
||||
factory $SchedulePeriodEntityCopyWith(SchedulePeriodEntity value, $Res Function(SchedulePeriodEntity) _then) = _$SchedulePeriodEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String periodStart, String periodEnd, bool isPeriodEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$SchedulePeriodEntityCopyWithImpl<$Res>
|
||||
implements $SchedulePeriodEntityCopyWith<$Res> {
|
||||
_$SchedulePeriodEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final SchedulePeriodEntity _self;
|
||||
final $Res Function(SchedulePeriodEntity) _then;
|
||||
|
||||
/// Create a copy of SchedulePeriodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? periodStart = null,Object? periodEnd = null,Object? isPeriodEnabled = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
periodStart: null == periodStart ? _self.periodStart : periodStart // ignore: cast_nullable_to_non_nullable
|
||||
as String,periodEnd: null == periodEnd ? _self.periodEnd : periodEnd // ignore: cast_nullable_to_non_nullable
|
||||
as String,isPeriodEnabled: null == isPeriodEnabled ? _self.isPeriodEnabled : isPeriodEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [SchedulePeriodEntity].
|
||||
extension SchedulePeriodEntityPatterns on SchedulePeriodEntity {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _SchedulePeriodEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SchedulePeriodEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _SchedulePeriodEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SchedulePeriodEntity():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _SchedulePeriodEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _SchedulePeriodEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String periodStart, String periodEnd, bool isPeriodEnabled)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SchedulePeriodEntity() when $default != null:
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String periodStart, String periodEnd, bool isPeriodEnabled) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SchedulePeriodEntity():
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String periodStart, String periodEnd, bool isPeriodEnabled)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _SchedulePeriodEntity() when $default != null:
|
||||
return $default(_that.periodStart,_that.periodEnd,_that.isPeriodEnabled);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _SchedulePeriodEntity implements SchedulePeriodEntity {
|
||||
const _SchedulePeriodEntity({required this.periodStart, required this.periodEnd, required this.isPeriodEnabled});
|
||||
|
||||
|
||||
@override final String periodStart;
|
||||
@override final String periodEnd;
|
||||
@override final bool isPeriodEnabled;
|
||||
|
||||
/// Create a copy of SchedulePeriodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$SchedulePeriodEntityCopyWith<_SchedulePeriodEntity> get copyWith => __$SchedulePeriodEntityCopyWithImpl<_SchedulePeriodEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SchedulePeriodEntity&&(identical(other.periodStart, periodStart) || other.periodStart == periodStart)&&(identical(other.periodEnd, periodEnd) || other.periodEnd == periodEnd)&&(identical(other.isPeriodEnabled, isPeriodEnabled) || other.isPeriodEnabled == isPeriodEnabled));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,periodStart,periodEnd,isPeriodEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'SchedulePeriodEntity(periodStart: $periodStart, periodEnd: $periodEnd, isPeriodEnabled: $isPeriodEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$SchedulePeriodEntityCopyWith<$Res> implements $SchedulePeriodEntityCopyWith<$Res> {
|
||||
factory _$SchedulePeriodEntityCopyWith(_SchedulePeriodEntity value, $Res Function(_SchedulePeriodEntity) _then) = __$SchedulePeriodEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String periodStart, String periodEnd, bool isPeriodEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$SchedulePeriodEntityCopyWithImpl<$Res>
|
||||
implements _$SchedulePeriodEntityCopyWith<$Res> {
|
||||
__$SchedulePeriodEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _SchedulePeriodEntity _self;
|
||||
final $Res Function(_SchedulePeriodEntity) _then;
|
||||
|
||||
/// Create a copy of SchedulePeriodEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? periodStart = null,Object? periodEnd = null,Object? isPeriodEnabled = null,}) {
|
||||
return _then(_SchedulePeriodEntity(
|
||||
periodStart: null == periodStart ? _self.periodStart : periodStart // ignore: cast_nullable_to_non_nullable
|
||||
as String,periodEnd: null == periodEnd ? _self.periodEnd : periodEnd // ignore: cast_nullable_to_non_nullable
|
||||
as String,isPeriodEnabled: null == isPeriodEnabled ? _self.isPeriodEnabled : isPeriodEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:device_management/src/core/domain/entities/schedule_period_entity.dart';
|
||||
import 'package:device_management/src/features/apps_surveillance/data/installed_app_entity.dart';
|
||||
|
||||
import '../../data/models/upsert_schedule_request_model.dart';
|
||||
|
||||
abstract class AppSurveillanceRepository {
|
||||
Future<List<InstalledAppEntity>> getInstalledApps({
|
||||
required String deviceId,
|
||||
});
|
||||
|
||||
Future<List<SchedulePeriodEntity>> getSchedule({
|
||||
required String deviceId,
|
||||
});
|
||||
|
||||
Future<void> upsertSchedule({
|
||||
required String deviceId,
|
||||
required UpdateScheduleRequestModel request,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
|
||||
abstract class BackgroundImageRepository {
|
||||
Future<List<PictureEntity>> getPhotos();
|
||||
Future<String> uploadImage({required String path});
|
||||
Future<void> setBackgroundImage({required String deviceId, required String photoId});
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
|
||||
abstract class FunctionsRepository {
|
||||
Future<List<PictureEntity>> getPictures({required String userId});
|
||||
|
||||
Future<PictureEntity> takePicture({required String userId});
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
|
||||
abstract class PicturesRepository {
|
||||
Future<List<PictureEntity>> getPictures({required String deviceId});
|
||||
|
||||
Future<PictureEntity> takePicture({required String deviceId});
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../data/datasources/apps_surveillance_remote_datasource.dart';
|
||||
import '../data/datasources/apps_surveillance_remote_datasource_impl.dart';
|
||||
import '../data/datasources/scheduled_activities_remote_datasource.dart';
|
||||
import '../data/datasources/scheduled_activities_remote_datasource_impl.dart';
|
||||
|
||||
final appSurveillanceRemoteDatasourceProvider =
|
||||
Provider<AppSurveillanceRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return AppSurveillanceRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../data/repositories/app_surveillance_repository_impl.dart';
|
||||
import '../data/repositories/scheduled_activities_repository_impl.dart';
|
||||
import '../domain/repositories/app_surveillance_repository.dart';
|
||||
import '../domain/repositories/scheduled_activities_repository.dart';
|
||||
import 'app_surveillance_remote_datasource.dart';
|
||||
import 'scheduled_activities_remote_datasource_provider.dart';
|
||||
|
||||
final appSurveillanceRepositoryProvider =
|
||||
Provider<AppSurveillanceRepository>((ref) {
|
||||
final remote = ref.read(appSurveillanceRemoteDatasourceProvider);
|
||||
return AppSurveillanceRepositoryImpl(remote);
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../data/datasources/background_image_remote_datasource.dart';
|
||||
import '../data/datasources/background_image_remote_datasource_impl.dart';
|
||||
|
||||
final backgroundImageRemoteDatasourceProvider =
|
||||
Provider<BackgroundImageRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return BackgroundImageRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../data/repositories/background_image_repository_impl.dart';
|
||||
import '../domain/repositories/background_image_repository.dart';
|
||||
import 'background_image_remote_datasource_provider.dart';
|
||||
|
||||
final backgroundImageRepositoryProvider =
|
||||
Provider<BackgroundImageRepository>((ref) {
|
||||
final remote = ref.read(backgroundImageRemoteDatasourceProvider);
|
||||
return BackgroundImageRepositoryImpl(remote);
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:device_management/src/core/data/datasources/functions_remote_datasource.dart';
|
||||
import 'package:device_management/src/core/data/datasources/functions_remote_datasource_impl.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
final functionsRemoteDatasourceProvider = Provider<FunctionsRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return FunctionsRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:device_management/src/core/providers/functions_remote_datasource_provider.dart';
|
||||
import 'package:device_management/src/core/data/repositories/functions_repository_impl.dart';
|
||||
import 'package:device_management/src/core/domain/repositories/functions_repository.dart';
|
||||
|
||||
final functionsRepositoryProvider = Provider<FunctionsRepository>((ref) {
|
||||
final remote = ref.read(functionsRemoteDatasourceProvider);
|
||||
return FunctionsRepositoryImpl(remote);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import '../data/datasources/pictures_remote_datasource.dart';
|
||||
import '../data/datasources/pictures_remote_datasource_impl.dart';
|
||||
|
||||
final picturesRemoteDatasourceProvider = Provider<PicturesRemoteDatasource>((ref) {
|
||||
final questiaRepository = getIt<QuestiaRepository>();
|
||||
return PicturesRemoteDatasourceImpl(questiaRepository);
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../data/repositories/pictures_repository_impl.dart';
|
||||
import '../domain/repositories/pictures_repository.dart';
|
||||
import 'pictures_remote_datasource_provider.dart';
|
||||
|
||||
final picturesRepositoryProvider = Provider<PicturesRepository>((ref) {
|
||||
final remote = ref.read(picturesRemoteDatasourceProvider);
|
||||
return PicturesRepositoryImpl(remote);
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import 'package:utils/utils.dart';
|
||||
|
||||
import '../../../core/presentation/widgets/time_range_selector.dart';
|
||||
import 'state/activity_meter_view_model.dart';
|
||||
import 'state/activity_meter_view_state.dart';
|
||||
import 'widgets/steps_bar_chart.dart';
|
||||
import 'widgets/steps_history_section.dart';
|
||||
import 'widgets/steps_progress_ring.dart';
|
||||
@@ -20,12 +21,18 @@ class ActivityMeterScreen extends ConsumerWidget {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final state = ref.watch(activityMeterViewModelProvider);
|
||||
final vm = ref.read(activityMeterViewModelProvider.notifier);
|
||||
final device = ref.watch(selectedDeviceProvider);
|
||||
|
||||
ref.listen(
|
||||
activityMeterViewModelProvider.select((s) => s.errorMessage),
|
||||
activityMeterViewModelProvider.select((s) => s.errorEvent),
|
||||
(previous, next) {
|
||||
if (next.isNotEmpty) {
|
||||
showTopSnackbar(context, message: next, type: MessageType.error);
|
||||
if (next != null) {
|
||||
final message = switch (next) {
|
||||
ActivityMeterErrorEvent.loadData => context.translate(I18n.errorActivityData),
|
||||
ActivityMeterErrorEvent.loadMore => context.translate(I18n.errorActivityData),
|
||||
ActivityMeterErrorEvent.pedometer => context.translate(I18n.errorPedometer),
|
||||
};
|
||||
showTopSnackbar(context, message: message, type: MessageType.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -69,6 +76,43 @@ class ActivityMeterScreen extends ConsumerWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
vertical: SizeUtils.getByScreen(small: 4, big: 4),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
context.translate(I18n.activityMeterPedometer),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 14, big: 15),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Switch.adaptive(
|
||||
value: device?.settings.pedometer ?? false,
|
||||
activeTrackColor: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
onChanged: (value) async {
|
||||
final success = await vm.togglePedometer(enabled: value);
|
||||
if (!context.mounted) return;
|
||||
if (success) {
|
||||
showTopSnackbar(
|
||||
context,
|
||||
message: context.translate(
|
||||
value
|
||||
? I18n.activityMeterPedometerEnabled
|
||||
: I18n.activityMeterPedometerDisabled,
|
||||
),
|
||||
type: MessageType.success,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
StepsProgressRing(
|
||||
steps: state.todayTotal,
|
||||
goal: state.dailyGoal,
|
||||
|
||||
@@ -79,7 +79,7 @@ class ActivityMeterViewModel extends Notifier<ActivityMeterViewState> {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoadingMore: false,
|
||||
errorMessage: _formatError(e),
|
||||
errorEvent: ActivityMeterErrorEvent.loadMore,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ class ActivityMeterViewModel extends Notifier<ActivityMeterViewState> {
|
||||
await _loadFilteredData();
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoading: false, errorMessage: _formatError(e));
|
||||
state = state.copyWith(isLoading: false, errorEvent: ActivityMeterErrorEvent.loadData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,11 +157,11 @@ class ActivityMeterViewModel extends Notifier<ActivityMeterViewState> {
|
||||
hasMoreHistory: histSteps.length >= _historyPageSize,
|
||||
stats: _computeStats(chartDaily),
|
||||
isLoading: false,
|
||||
errorMessage: '',
|
||||
errorEvent: null,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(isLoading: false, errorMessage: _formatError(e));
|
||||
state = state.copyWith(isLoading: false, errorEvent: ActivityMeterErrorEvent.loadData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,8 +243,25 @@ class ActivityMeterViewModel extends Notifier<ActivityMeterViewState> {
|
||||
}
|
||||
}
|
||||
|
||||
String _formatError(Object e) {
|
||||
final msg = e.toString();
|
||||
return msg.startsWith('Exception: ') ? msg.substring(11) : msg;
|
||||
Future<bool> togglePedometer({required bool enabled}) async {
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if (device == null) return false;
|
||||
|
||||
state = state.copyWith(errorEvent: null);
|
||||
try {
|
||||
final updatedSettings = device.settings.copyWith(pedometer: enabled);
|
||||
await ref.read(deviceSettingsUpdateProvider).updateDeviceSettings(
|
||||
device: device,
|
||||
updatedSettings: updatedSettings,
|
||||
);
|
||||
if (!ref.mounted) return false;
|
||||
ref.syncDeviceSettings(device, updatedSettings);
|
||||
return true;
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return false;
|
||||
state = state.copyWith(errorEvent: ActivityMeterErrorEvent.pedometer);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,12 @@ import '../../../../core/presentation/time_range.dart';
|
||||
|
||||
part 'activity_meter_view_state.freezed.dart';
|
||||
|
||||
enum ActivityMeterErrorEvent {
|
||||
loadData,
|
||||
loadMore,
|
||||
pedometer,
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class DailySteps with _$DailySteps {
|
||||
const factory DailySteps({
|
||||
@@ -36,6 +42,6 @@ abstract class ActivityMeterViewState with _$ActivityMeterViewState {
|
||||
DateTime? customEnd,
|
||||
@Default(true) bool isLoading,
|
||||
@Default(false) bool isLoadingMore,
|
||||
@Default('') String errorMessage,
|
||||
ActivityMeterErrorEvent? errorEvent,
|
||||
}) = _ActivityMeterViewState;
|
||||
}
|
||||
|
||||
@@ -537,7 +537,7 @@ as int,
|
||||
/// @nodoc
|
||||
mixin _$ActivityMeterViewState {
|
||||
|
||||
int get todayTotal; int get dailyGoal; List<DailySteps> get chartData; List<DailySteps> get historyData; int get currentHistoryPage; bool get hasMoreHistory; StepsStats get stats; TimeRange get timeRange; DateTime? get customStart; DateTime? get customEnd; bool get isLoading; bool get isLoadingMore; String get errorMessage;
|
||||
int get todayTotal; int get dailyGoal; List<DailySteps> get chartData; List<DailySteps> get historyData; int get currentHistoryPage; bool get hasMoreHistory; StepsStats get stats; TimeRange get timeRange; DateTime? get customStart; DateTime? get customEnd; bool get isLoading; bool get isLoadingMore; ActivityMeterErrorEvent? get errorEvent;
|
||||
/// Create a copy of ActivityMeterViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@@ -548,16 +548,16 @@ $ActivityMeterViewStateCopyWith<ActivityMeterViewState> get copyWith => _$Activi
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ActivityMeterViewState&&(identical(other.todayTotal, todayTotal) || other.todayTotal == todayTotal)&&(identical(other.dailyGoal, dailyGoal) || other.dailyGoal == dailyGoal)&&const DeepCollectionEquality().equals(other.chartData, chartData)&&const DeepCollectionEquality().equals(other.historyData, historyData)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.stats, stats) || other.stats == stats)&&(identical(other.timeRange, timeRange) || other.timeRange == timeRange)&&(identical(other.customStart, customStart) || other.customStart == customStart)&&(identical(other.customEnd, customEnd) || other.customEnd == customEnd)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is ActivityMeterViewState&&(identical(other.todayTotal, todayTotal) || other.todayTotal == todayTotal)&&(identical(other.dailyGoal, dailyGoal) || other.dailyGoal == dailyGoal)&&const DeepCollectionEquality().equals(other.chartData, chartData)&&const DeepCollectionEquality().equals(other.historyData, historyData)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.stats, stats) || other.stats == stats)&&(identical(other.timeRange, timeRange) || other.timeRange == timeRange)&&(identical(other.customStart, customStart) || other.customStart == customStart)&&(identical(other.customEnd, customEnd) || other.customEnd == customEnd)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,todayTotal,dailyGoal,const DeepCollectionEquality().hash(chartData),const DeepCollectionEquality().hash(historyData),currentHistoryPage,hasMoreHistory,stats,timeRange,customStart,customEnd,isLoading,isLoadingMore,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,todayTotal,dailyGoal,const DeepCollectionEquality().hash(chartData),const DeepCollectionEquality().hash(historyData),currentHistoryPage,hasMoreHistory,stats,timeRange,customStart,customEnd,isLoading,isLoadingMore,errorEvent);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ActivityMeterViewState(todayTotal: $todayTotal, dailyGoal: $dailyGoal, chartData: $chartData, historyData: $historyData, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, stats: $stats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, errorMessage: $errorMessage)';
|
||||
return 'ActivityMeterViewState(todayTotal: $todayTotal, dailyGoal: $dailyGoal, chartData: $chartData, historyData: $historyData, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, stats: $stats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, errorEvent: $errorEvent)';
|
||||
}
|
||||
|
||||
|
||||
@@ -568,7 +568,7 @@ abstract mixin class $ActivityMeterViewStateCopyWith<$Res> {
|
||||
factory $ActivityMeterViewStateCopyWith(ActivityMeterViewState value, $Res Function(ActivityMeterViewState) _then) = _$ActivityMeterViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage
|
||||
int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, ActivityMeterErrorEvent? errorEvent
|
||||
});
|
||||
|
||||
|
||||
@@ -585,7 +585,7 @@ class _$ActivityMeterViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ActivityMeterViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? todayTotal = null,Object? dailyGoal = null,Object? chartData = null,Object? historyData = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? stats = null,Object? timeRange = null,Object? customStart = freezed,Object? customEnd = freezed,Object? isLoading = null,Object? isLoadingMore = null,Object? errorMessage = null,}) {
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? todayTotal = null,Object? dailyGoal = null,Object? chartData = null,Object? historyData = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? stats = null,Object? timeRange = null,Object? customStart = freezed,Object? customEnd = freezed,Object? isLoading = null,Object? isLoadingMore = null,Object? errorEvent = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
todayTotal: null == todayTotal ? _self.todayTotal : todayTotal // ignore: cast_nullable_to_non_nullable
|
||||
as int,dailyGoal: null == dailyGoal ? _self.dailyGoal : dailyGoal // ignore: cast_nullable_to_non_nullable
|
||||
@@ -599,8 +599,8 @@ as TimeRange,customStart: freezed == customStart ? _self.customStart : customSta
|
||||
as DateTime?,customEnd: freezed == customEnd ? _self.customEnd : customEnd // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as bool,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
|
||||
as ActivityMeterErrorEvent?,
|
||||
));
|
||||
}
|
||||
/// Create a copy of ActivityMeterViewState
|
||||
@@ -694,10 +694,10 @@ return $default(_that);case _:
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, ActivityMeterErrorEvent? errorEvent)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ActivityMeterViewState() when $default != null:
|
||||
return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyData,_that.currentHistoryPage,_that.hasMoreHistory,_that.stats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorMessage);case _:
|
||||
return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyData,_that.currentHistoryPage,_that.hasMoreHistory,_that.stats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorEvent);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
@@ -715,10 +715,10 @@ return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyDa
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage) $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, ActivityMeterErrorEvent? errorEvent) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ActivityMeterViewState():
|
||||
return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyData,_that.currentHistoryPage,_that.hasMoreHistory,_that.stats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorMessage);case _:
|
||||
return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyData,_that.currentHistoryPage,_that.hasMoreHistory,_that.stats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorEvent);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
@@ -735,10 +735,10 @@ return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyDa
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage)? $default,) {final _that = this;
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, ActivityMeterErrorEvent? errorEvent)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _ActivityMeterViewState() when $default != null:
|
||||
return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyData,_that.currentHistoryPage,_that.hasMoreHistory,_that.stats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorMessage);case _:
|
||||
return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyData,_that.currentHistoryPage,_that.hasMoreHistory,_that.stats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorEvent);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
@@ -750,7 +750,7 @@ return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyDa
|
||||
|
||||
|
||||
class _ActivityMeterViewState implements ActivityMeterViewState {
|
||||
const _ActivityMeterViewState({this.todayTotal = 0, this.dailyGoal = 8000, final List<DailySteps> chartData = const [], final List<DailySteps> historyData = const [], this.currentHistoryPage = 1, this.hasMoreHistory = false, this.stats = const StepsStats(), this.timeRange = TimeRange.today, this.customStart, this.customEnd, this.isLoading = true, this.isLoadingMore = false, this.errorMessage = ''}): _chartData = chartData,_historyData = historyData;
|
||||
const _ActivityMeterViewState({this.todayTotal = 0, this.dailyGoal = 8000, final List<DailySteps> chartData = const [], final List<DailySteps> historyData = const [], this.currentHistoryPage = 1, this.hasMoreHistory = false, this.stats = const StepsStats(), this.timeRange = TimeRange.today, this.customStart, this.customEnd, this.isLoading = true, this.isLoadingMore = false, this.errorEvent}): _chartData = chartData,_historyData = historyData;
|
||||
|
||||
|
||||
@override@JsonKey() final int todayTotal;
|
||||
@@ -777,7 +777,7 @@ class _ActivityMeterViewState implements ActivityMeterViewState {
|
||||
@override final DateTime? customEnd;
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isLoadingMore;
|
||||
@override@JsonKey() final String errorMessage;
|
||||
@override final ActivityMeterErrorEvent? errorEvent;
|
||||
|
||||
/// Create a copy of ActivityMeterViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@@ -789,16 +789,16 @@ _$ActivityMeterViewStateCopyWith<_ActivityMeterViewState> get copyWith => __$Act
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ActivityMeterViewState&&(identical(other.todayTotal, todayTotal) || other.todayTotal == todayTotal)&&(identical(other.dailyGoal, dailyGoal) || other.dailyGoal == dailyGoal)&&const DeepCollectionEquality().equals(other._chartData, _chartData)&&const DeepCollectionEquality().equals(other._historyData, _historyData)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.stats, stats) || other.stats == stats)&&(identical(other.timeRange, timeRange) || other.timeRange == timeRange)&&(identical(other.customStart, customStart) || other.customStart == customStart)&&(identical(other.customEnd, customEnd) || other.customEnd == customEnd)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ActivityMeterViewState&&(identical(other.todayTotal, todayTotal) || other.todayTotal == todayTotal)&&(identical(other.dailyGoal, dailyGoal) || other.dailyGoal == dailyGoal)&&const DeepCollectionEquality().equals(other._chartData, _chartData)&&const DeepCollectionEquality().equals(other._historyData, _historyData)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.stats, stats) || other.stats == stats)&&(identical(other.timeRange, timeRange) || other.timeRange == timeRange)&&(identical(other.customStart, customStart) || other.customStart == customStart)&&(identical(other.customEnd, customEnd) || other.customEnd == customEnd)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isLoadingMore, isLoadingMore) || other.isLoadingMore == isLoadingMore)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,todayTotal,dailyGoal,const DeepCollectionEquality().hash(_chartData),const DeepCollectionEquality().hash(_historyData),currentHistoryPage,hasMoreHistory,stats,timeRange,customStart,customEnd,isLoading,isLoadingMore,errorMessage);
|
||||
int get hashCode => Object.hash(runtimeType,todayTotal,dailyGoal,const DeepCollectionEquality().hash(_chartData),const DeepCollectionEquality().hash(_historyData),currentHistoryPage,hasMoreHistory,stats,timeRange,customStart,customEnd,isLoading,isLoadingMore,errorEvent);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ActivityMeterViewState(todayTotal: $todayTotal, dailyGoal: $dailyGoal, chartData: $chartData, historyData: $historyData, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, stats: $stats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, errorMessage: $errorMessage)';
|
||||
return 'ActivityMeterViewState(todayTotal: $todayTotal, dailyGoal: $dailyGoal, chartData: $chartData, historyData: $historyData, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, stats: $stats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, errorEvent: $errorEvent)';
|
||||
}
|
||||
|
||||
|
||||
@@ -809,7 +809,7 @@ abstract mixin class _$ActivityMeterViewStateCopyWith<$Res> implements $Activity
|
||||
factory _$ActivityMeterViewStateCopyWith(_ActivityMeterViewState value, $Res Function(_ActivityMeterViewState) _then) = __$ActivityMeterViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage
|
||||
int todayTotal, int dailyGoal, List<DailySteps> chartData, List<DailySteps> historyData, int currentHistoryPage, bool hasMoreHistory, StepsStats stats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, ActivityMeterErrorEvent? errorEvent
|
||||
});
|
||||
|
||||
|
||||
@@ -826,7 +826,7 @@ class __$ActivityMeterViewStateCopyWithImpl<$Res>
|
||||
|
||||
/// Create a copy of ActivityMeterViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? todayTotal = null,Object? dailyGoal = null,Object? chartData = null,Object? historyData = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? stats = null,Object? timeRange = null,Object? customStart = freezed,Object? customEnd = freezed,Object? isLoading = null,Object? isLoadingMore = null,Object? errorMessage = null,}) {
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? todayTotal = null,Object? dailyGoal = null,Object? chartData = null,Object? historyData = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? stats = null,Object? timeRange = null,Object? customStart = freezed,Object? customEnd = freezed,Object? isLoading = null,Object? isLoadingMore = null,Object? errorEvent = freezed,}) {
|
||||
return _then(_ActivityMeterViewState(
|
||||
todayTotal: null == todayTotal ? _self.todayTotal : todayTotal // ignore: cast_nullable_to_non_nullable
|
||||
as int,dailyGoal: null == dailyGoal ? _self.dailyGoal : dailyGoal // ignore: cast_nullable_to_non_nullable
|
||||
@@ -840,8 +840,8 @@ as TimeRange,customStart: freezed == customStart ? _self.customStart : customSta
|
||||
as DateTime?,customEnd: freezed == customEnd ? _self.customEnd : customEnd // ignore: cast_nullable_to_non_nullable
|
||||
as DateTime?,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isLoadingMore: null == isLoadingMore ? _self.isLoadingMore : isLoadingMore // ignore: cast_nullable_to_non_nullable
|
||||
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
as bool,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
|
||||
as ActivityMeterErrorEvent?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:device_management/src/features/apps_surveillance/presentation/apps_surveillance_screen.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class AppsSurveillanceBuilder {
|
||||
const AppsSurveillanceBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return MaterialPage(
|
||||
child: const AppsSurveillanceScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'installed_app_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class InstalledAppEntity with _$InstalledAppEntity {
|
||||
const factory InstalledAppEntity({
|
||||
required String appUid,
|
||||
required String appName,
|
||||
required bool isEnabled
|
||||
}) = _InstalledAppEntity;
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'installed_app_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$InstalledAppEntity {
|
||||
|
||||
String get appUid; String get appName; bool get isEnabled;
|
||||
/// Create a copy of InstalledAppEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$InstalledAppEntityCopyWith<InstalledAppEntity> get copyWith => _$InstalledAppEntityCopyWithImpl<InstalledAppEntity>(this as InstalledAppEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is InstalledAppEntity&&(identical(other.appUid, appUid) || other.appUid == appUid)&&(identical(other.appName, appName) || other.appName == appName)&&(identical(other.isEnabled, isEnabled) || other.isEnabled == isEnabled));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,appUid,appName,isEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InstalledAppEntity(appUid: $appUid, appName: $appName, isEnabled: $isEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $InstalledAppEntityCopyWith<$Res> {
|
||||
factory $InstalledAppEntityCopyWith(InstalledAppEntity value, $Res Function(InstalledAppEntity) _then) = _$InstalledAppEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String appUid, String appName, bool isEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$InstalledAppEntityCopyWithImpl<$Res>
|
||||
implements $InstalledAppEntityCopyWith<$Res> {
|
||||
_$InstalledAppEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final InstalledAppEntity _self;
|
||||
final $Res Function(InstalledAppEntity) _then;
|
||||
|
||||
/// Create a copy of InstalledAppEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? appUid = null,Object? appName = null,Object? isEnabled = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
appUid: null == appUid ? _self.appUid : appUid // ignore: cast_nullable_to_non_nullable
|
||||
as String,appName: null == appName ? _self.appName : appName // ignore: cast_nullable_to_non_nullable
|
||||
as String,isEnabled: null == isEnabled ? _self.isEnabled : isEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [InstalledAppEntity].
|
||||
extension InstalledAppEntityPatterns on InstalledAppEntity {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _InstalledAppEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _InstalledAppEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppEntity():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _InstalledAppEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String appUid, String appName, bool isEnabled)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppEntity() when $default != null:
|
||||
return $default(_that.appUid,_that.appName,_that.isEnabled);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String appUid, String appName, bool isEnabled) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppEntity():
|
||||
return $default(_that.appUid,_that.appName,_that.isEnabled);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String appUid, String appName, bool isEnabled)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _InstalledAppEntity() when $default != null:
|
||||
return $default(_that.appUid,_that.appName,_that.isEnabled);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _InstalledAppEntity implements InstalledAppEntity {
|
||||
const _InstalledAppEntity({required this.appUid, required this.appName, required this.isEnabled});
|
||||
|
||||
|
||||
@override final String appUid;
|
||||
@override final String appName;
|
||||
@override final bool isEnabled;
|
||||
|
||||
/// Create a copy of InstalledAppEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$InstalledAppEntityCopyWith<_InstalledAppEntity> get copyWith => __$InstalledAppEntityCopyWithImpl<_InstalledAppEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _InstalledAppEntity&&(identical(other.appUid, appUid) || other.appUid == appUid)&&(identical(other.appName, appName) || other.appName == appName)&&(identical(other.isEnabled, isEnabled) || other.isEnabled == isEnabled));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,appUid,appName,isEnabled);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'InstalledAppEntity(appUid: $appUid, appName: $appName, isEnabled: $isEnabled)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$InstalledAppEntityCopyWith<$Res> implements $InstalledAppEntityCopyWith<$Res> {
|
||||
factory _$InstalledAppEntityCopyWith(_InstalledAppEntity value, $Res Function(_InstalledAppEntity) _then) = __$InstalledAppEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String appUid, String appName, bool isEnabled
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$InstalledAppEntityCopyWithImpl<$Res>
|
||||
implements _$InstalledAppEntityCopyWith<$Res> {
|
||||
__$InstalledAppEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _InstalledAppEntity _self;
|
||||
final $Res Function(_InstalledAppEntity) _then;
|
||||
|
||||
/// Create a copy of InstalledAppEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? appUid = null,Object? appName = null,Object? isEnabled = null,}) {
|
||||
return _then(_InstalledAppEntity(
|
||||
appUid: null == appUid ? _self.appUid : appUid // ignore: cast_nullable_to_non_nullable
|
||||
as String,appName: null == appName ? _self.appName : appName // ignore: cast_nullable_to_non_nullable
|
||||
as String,isEnabled: null == isEnabled ? _self.isEnabled : isEnabled // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,168 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:device_management/src/core/domain/entities/schedule_period_entity.dart';
|
||||
import 'package:device_management/src/core/presentation/format_date.dart';
|
||||
import 'package:device_management/src/features/apps_surveillance/presentation/state/apps_surveillance_view_model.dart';
|
||||
import 'package:device_management/src/features/apps_surveillance/presentation/widgets/period_form_dialog.dart';
|
||||
import 'package:device_management/src/features/scheduled_activities/presentation/state/scheduled_activities_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
class AppsScheduleScreen extends ConsumerWidget {
|
||||
|
||||
const AppsScheduleScreen();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
final vm = ref.read(appsSurveillanceViewModelProvider.notifier);
|
||||
final state = ref.watch(appsSurveillanceViewModelProvider);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.disablePeriods),
|
||||
body: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 16, big: 14)
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.appsScheduleMessage)),
|
||||
...List<Widget>.generate(3, (int index) {
|
||||
return _Item(index: index);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
footer: _SaveButton(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Item extends ConsumerWidget {
|
||||
final int index;
|
||||
|
||||
const _Item({required this.index});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final period = ref.watch(
|
||||
appsSurveillanceViewModelProvider.select((s)=>
|
||||
s.schedule.elementAtOrNull(index)
|
||||
)
|
||||
);
|
||||
|
||||
if (period == null) {
|
||||
return _EmptyPeriodCard(index: index);
|
||||
} else {
|
||||
return _PeriodCard(index: index, period: period);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _EmptyPeriodCard extends ConsumerWidget {
|
||||
final int index;
|
||||
|
||||
const _EmptyPeriodCard({required this.index});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: (){showPeriodForm(context, index: index);},
|
||||
child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 6, vertical: 8),
|
||||
big: EdgeInsets.symmetric(horizontal: 4, vertical: 6),
|
||||
),
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
child: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text(context.translate(I18n.period, args: {'index': index}),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: SizeUtils.getByScreen(small: 17, big: 16)
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class _PeriodCard extends ConsumerWidget {
|
||||
final int index;
|
||||
final SchedulePeriodEntity period;
|
||||
|
||||
const _PeriodCard({
|
||||
required this.index,
|
||||
required this.period
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
final vm = ref.read(appsSurveillanceViewModelProvider.notifier);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: (){showPeriodForm(context, index: index, period: period);},
|
||||
child: Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 6, vertical: 8),
|
||||
big: EdgeInsets.symmetric(horizontal: 4, vertical: 6),
|
||||
),
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(context.translate(I18n.period, args: {'index': index}),
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: SizeUtils.getByScreen(small: 17, big: 16)
|
||||
),
|
||||
),
|
||||
Text('${period.periodStart} - ${period.periodEnd}',
|
||||
style: TextStyle(
|
||||
color: theme.getColorFor(ThemeCode.textTertiary)
|
||||
),
|
||||
)
|
||||
]
|
||||
),
|
||||
Switch(
|
||||
value: period.isPeriodEnabled,
|
||||
onChanged: (_){vm.togglePeriodEnabled(index);}
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _SaveButton extends ConsumerWidget {
|
||||
const _SaveButton();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final vm = ref.read(appsSurveillanceViewModelProvider.notifier);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 10),
|
||||
child: PrimaryButton(
|
||||
onPressed: vm.updateSchedule,
|
||||
text: context.translate(I18n.save),
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:device_management/src/features/apps_surveillance/presentation/state/apps_surveillance_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
import 'apps_schedule_screen.dart';
|
||||
|
||||
class AppsSurveillanceScreen extends ConsumerWidget {
|
||||
|
||||
const AppsSurveillanceScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
final installedApps = ref.watch(
|
||||
appsSurveillanceViewModelProvider.select((s)=>s.apps)
|
||||
);
|
||||
final vm = ref.read(appsSurveillanceViewModelProvider.notifier);
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.appsSurveillance),
|
||||
showEdit: true,
|
||||
onEditChange: (){
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => AppsScheduleScreen()),
|
||||
);
|
||||
},
|
||||
body: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 14),
|
||||
big: EdgeInsets.symmetric(horizontal: 12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(context.translate(I18n.appsSurveillanceMessage)),
|
||||
...List<Widget>.generate(installedApps.length, (int i){
|
||||
return _Item(
|
||||
appCode: installedApps.elementAt(i).appUid,
|
||||
name: installedApps.elementAt(i).appName,
|
||||
enabled: installedApps.elementAt(i).isEnabled,
|
||||
onChanged: (value) {
|
||||
vm.setAppEnabled(i, value);
|
||||
},
|
||||
);
|
||||
})
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Item extends ConsumerWidget {
|
||||
|
||||
final String appCode;
|
||||
final String name;
|
||||
final bool enabled;
|
||||
final ValueChanged<bool> onChanged;
|
||||
|
||||
const _Item({
|
||||
required this.appCode,
|
||||
required this.name,
|
||||
required this.enabled,
|
||||
required this.onChanged,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
|
||||
return Container(
|
||||
padding: SizeUtils.getByScreen(
|
||||
small: EdgeInsets.symmetric(horizontal: 6, vertical: 10),
|
||||
big: EdgeInsets.symmetric(horizontal: 4, vertical: 8),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(name,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500
|
||||
)
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(context.translate(enabled? I18n.enabled : I18n.disabled)),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 18, big: 16)),
|
||||
Switch(value: !enabled, onChanged: onChanged),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
import 'package:device_management/src/core/data/models/upsert_schedule_request_model.dart';
|
||||
import 'package:device_management/src/core/domain/entities/schedule_period_entity.dart';
|
||||
import 'package:device_management/src/core/domain/repositories/app_surveillance_repository.dart';
|
||||
import 'package:device_management/src/core/providers/app_surveillance_repository.dart';
|
||||
import 'package:device_management/src/features/apps_surveillance/data/installed_app_entity.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
import 'apps_surveillance_view_state.dart';
|
||||
|
||||
final appsSurveillanceViewModelProvider =
|
||||
NotifierProvider.autoDispose<AppsSurveillanceViewModel, AppsSurveillanceViewState>(
|
||||
AppsSurveillanceViewModel.new,
|
||||
);
|
||||
|
||||
class AppsSurveillanceViewModel extends Notifier<AppsSurveillanceViewState> {
|
||||
|
||||
late final AppSurveillanceRepository _repository;
|
||||
|
||||
@override
|
||||
AppsSurveillanceViewState build() {
|
||||
|
||||
_repository = ref.read(appSurveillanceRepositoryProvider);
|
||||
|
||||
final state = const AppsSurveillanceViewState();
|
||||
_load();
|
||||
return state;
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if(device == null) return;
|
||||
|
||||
final apps = await _repository.getInstalledApps(
|
||||
deviceId: device.identificator
|
||||
);
|
||||
|
||||
final schedule = (await _repository.getSchedule(
|
||||
deviceId: device.identificator
|
||||
))
|
||||
.where((p)=>
|
||||
p.periodStart.compareTo(p.periodEnd)!=0
|
||||
)
|
||||
.toList();
|
||||
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
apps: apps,
|
||||
schedule: schedule
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> setAppEnabled(int index, bool value) async {
|
||||
if (state.isSaving) return;
|
||||
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if (device == null) return;
|
||||
|
||||
try {
|
||||
state = state.copyWith(
|
||||
isSaving: true,
|
||||
);
|
||||
|
||||
final updatedApp = state.apps[index]
|
||||
.copyWith(isEnabled: value);
|
||||
List<InstalledAppEntity> updatedApps = state.apps.toList();
|
||||
updatedApps[index] = updatedApp;
|
||||
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
apps: updatedApps,
|
||||
);
|
||||
} catch (e) {
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
errorEvent: AppsSurveillanceErrorEvent.set
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateScheduleRequestModel _toRequest() {
|
||||
return UpdateScheduleRequestModel(
|
||||
periods: state.schedule.map((e)=>
|
||||
UpdateScheduleItemRequestModel(
|
||||
periodStart: e.periodStart,
|
||||
periodEnd: e.periodEnd,
|
||||
isPeriodEnabled: e.isPeriodEnabled
|
||||
)
|
||||
).toList()
|
||||
);
|
||||
}
|
||||
|
||||
bool validatePeriods() {
|
||||
return state.schedule.every((p) =>
|
||||
p.periodStart.compareTo(p.periodEnd) < 0
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateSchedule() async {
|
||||
if (state.isLoading) return;
|
||||
if (state.isSaving) return;
|
||||
|
||||
print(state.schedule);
|
||||
if (!validatePeriods()) {
|
||||
state = state.copyWith(
|
||||
errorEvent: AppsSurveillanceErrorEvent.invalid
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if (device == null) return;
|
||||
|
||||
try {
|
||||
state = state.copyWith(
|
||||
isSaving: true,
|
||||
);
|
||||
|
||||
final request = _toRequest();
|
||||
await _repository.upsertSchedule(deviceId: device.identificator, request: request);
|
||||
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
successEvent: AppsSurveillanceSuccessEvent.saved
|
||||
);
|
||||
} catch (e) {
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
errorEvent: AppsSurveillanceErrorEvent.upload
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void togglePeriodEnabled(int index) {
|
||||
SchedulePeriodEntity updatedPeriod = state.schedule.elementAt(index);
|
||||
updatedPeriod = updatedPeriod.copyWith(
|
||||
isPeriodEnabled: !updatedPeriod.isPeriodEnabled
|
||||
);
|
||||
|
||||
List<SchedulePeriodEntity> updatedSchedule = state.schedule.toList();
|
||||
updatedSchedule[index] = updatedPeriod;
|
||||
|
||||
state = state.copyWith(
|
||||
schedule: updatedSchedule
|
||||
);
|
||||
}
|
||||
|
||||
void updatePeriod({
|
||||
required int index,
|
||||
required String startTime,
|
||||
required String endTime
|
||||
}) {
|
||||
final period = state.schedule.elementAtOrNull(index);
|
||||
final updatedPeriod = SchedulePeriodEntity(
|
||||
periodStart: startTime,
|
||||
periodEnd: endTime,
|
||||
isPeriodEnabled: period?.isPeriodEnabled ?? false
|
||||
);
|
||||
|
||||
List<SchedulePeriodEntity> updatedSchedule = state.schedule.toList();
|
||||
|
||||
if (period == null) {
|
||||
updatedSchedule.add(updatedPeriod);
|
||||
} else {
|
||||
updatedSchedule[index] = updatedPeriod;
|
||||
}
|
||||
|
||||
state = state.copyWith(
|
||||
schedule: updatedSchedule
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'package:device_management/src/features/apps_surveillance/data/installed_app_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:sf_shared/sf_shared.dart';
|
||||
|
||||
import '../../../../core/domain/entities/schedule_period_entity.dart';
|
||||
|
||||
part 'apps_surveillance_view_state.freezed.dart';
|
||||
|
||||
enum AppsSurveillanceErrorEvent { invalid, load, upload, set }
|
||||
enum AppsSurveillanceSuccessEvent { saved }
|
||||
|
||||
@freezed
|
||||
abstract class AppsSurveillanceViewState with _$AppsSurveillanceViewState {
|
||||
const factory AppsSurveillanceViewState({
|
||||
@Default(true) bool isLoading,
|
||||
@Default(false) bool isSaving,
|
||||
DeviceEntity? selectedDevice,
|
||||
@Default([]) List<InstalledAppEntity> apps,
|
||||
@Default([]) List<SchedulePeriodEntity> schedule,
|
||||
@Default('') String deviceName,
|
||||
AppsSurveillanceErrorEvent? errorEvent,
|
||||
AppsSurveillanceSuccessEvent? successEvent,
|
||||
}) = _AppsSurveillanceViewState;
|
||||
}
|
||||
@@ -0,0 +1,328 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'apps_surveillance_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$AppsSurveillanceViewState {
|
||||
|
||||
bool get isLoading; bool get isSaving; DeviceEntity? get selectedDevice; List<InstalledAppEntity> get apps; List<SchedulePeriodEntity> get schedule; String get deviceName; AppsSurveillanceErrorEvent? get errorEvent; AppsSurveillanceSuccessEvent? get successEvent;
|
||||
/// Create a copy of AppsSurveillanceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$AppsSurveillanceViewStateCopyWith<AppsSurveillanceViewState> get copyWith => _$AppsSurveillanceViewStateCopyWithImpl<AppsSurveillanceViewState>(this as AppsSurveillanceViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is AppsSurveillanceViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other.apps, apps)&&const DeepCollectionEquality().equals(other.schedule, schedule)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent)&&(identical(other.successEvent, successEvent) || other.successEvent == successEvent));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isSaving,selectedDevice,const DeepCollectionEquality().hash(apps),const DeepCollectionEquality().hash(schedule),deviceName,errorEvent,successEvent);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppsSurveillanceViewState(isLoading: $isLoading, isSaving: $isSaving, selectedDevice: $selectedDevice, apps: $apps, schedule: $schedule, deviceName: $deviceName, errorEvent: $errorEvent, successEvent: $successEvent)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $AppsSurveillanceViewStateCopyWith<$Res> {
|
||||
factory $AppsSurveillanceViewStateCopyWith(AppsSurveillanceViewState value, $Res Function(AppsSurveillanceViewState) _then) = _$AppsSurveillanceViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isSaving, DeviceEntity? selectedDevice, List<InstalledAppEntity> apps, List<SchedulePeriodEntity> schedule, String deviceName, AppsSurveillanceErrorEvent? errorEvent, AppsSurveillanceSuccessEvent? successEvent
|
||||
});
|
||||
|
||||
|
||||
$DeviceEntityCopyWith<$Res>? get selectedDevice;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$AppsSurveillanceViewStateCopyWithImpl<$Res>
|
||||
implements $AppsSurveillanceViewStateCopyWith<$Res> {
|
||||
_$AppsSurveillanceViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final AppsSurveillanceViewState _self;
|
||||
final $Res Function(AppsSurveillanceViewState) _then;
|
||||
|
||||
/// Create a copy of AppsSurveillanceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? isSaving = null,Object? selectedDevice = freezed,Object? apps = null,Object? schedule = null,Object? deviceName = null,Object? errorEvent = freezed,Object? successEvent = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,apps: null == apps ? _self.apps : apps // ignore: cast_nullable_to_non_nullable
|
||||
as List<InstalledAppEntity>,schedule: null == schedule ? _self.schedule : schedule // ignore: cast_nullable_to_non_nullable
|
||||
as List<SchedulePeriodEntity>,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
|
||||
as AppsSurveillanceErrorEvent?,successEvent: freezed == successEvent ? _self.successEvent : successEvent // ignore: cast_nullable_to_non_nullable
|
||||
as AppsSurveillanceSuccessEvent?,
|
||||
));
|
||||
}
|
||||
/// Create a copy of AppsSurveillanceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get selectedDevice {
|
||||
if (_self.selectedDevice == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.selectedDevice!, (value) {
|
||||
return _then(_self.copyWith(selectedDevice: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [AppsSurveillanceViewState].
|
||||
extension AppsSurveillanceViewStatePatterns on AppsSurveillanceViewState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _AppsSurveillanceViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AppsSurveillanceViewState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _AppsSurveillanceViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AppsSurveillanceViewState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _AppsSurveillanceViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _AppsSurveillanceViewState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( bool isLoading, bool isSaving, DeviceEntity? selectedDevice, List<InstalledAppEntity> apps, List<SchedulePeriodEntity> schedule, String deviceName, AppsSurveillanceErrorEvent? errorEvent, AppsSurveillanceSuccessEvent? successEvent)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AppsSurveillanceViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isSaving,_that.selectedDevice,_that.apps,_that.schedule,_that.deviceName,_that.errorEvent,_that.successEvent);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( bool isLoading, bool isSaving, DeviceEntity? selectedDevice, List<InstalledAppEntity> apps, List<SchedulePeriodEntity> schedule, String deviceName, AppsSurveillanceErrorEvent? errorEvent, AppsSurveillanceSuccessEvent? successEvent) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AppsSurveillanceViewState():
|
||||
return $default(_that.isLoading,_that.isSaving,_that.selectedDevice,_that.apps,_that.schedule,_that.deviceName,_that.errorEvent,_that.successEvent);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( bool isLoading, bool isSaving, DeviceEntity? selectedDevice, List<InstalledAppEntity> apps, List<SchedulePeriodEntity> schedule, String deviceName, AppsSurveillanceErrorEvent? errorEvent, AppsSurveillanceSuccessEvent? successEvent)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _AppsSurveillanceViewState() when $default != null:
|
||||
return $default(_that.isLoading,_that.isSaving,_that.selectedDevice,_that.apps,_that.schedule,_that.deviceName,_that.errorEvent,_that.successEvent);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _AppsSurveillanceViewState implements AppsSurveillanceViewState {
|
||||
const _AppsSurveillanceViewState({this.isLoading = true, this.isSaving = false, this.selectedDevice, final List<InstalledAppEntity> apps = const [], final List<SchedulePeriodEntity> schedule = const [], this.deviceName = '', this.errorEvent, this.successEvent}): _apps = apps,_schedule = schedule;
|
||||
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isSaving;
|
||||
@override final DeviceEntity? selectedDevice;
|
||||
final List<InstalledAppEntity> _apps;
|
||||
@override@JsonKey() List<InstalledAppEntity> get apps {
|
||||
if (_apps is EqualUnmodifiableListView) return _apps;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_apps);
|
||||
}
|
||||
|
||||
final List<SchedulePeriodEntity> _schedule;
|
||||
@override@JsonKey() List<SchedulePeriodEntity> get schedule {
|
||||
if (_schedule is EqualUnmodifiableListView) return _schedule;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_schedule);
|
||||
}
|
||||
|
||||
@override@JsonKey() final String deviceName;
|
||||
@override final AppsSurveillanceErrorEvent? errorEvent;
|
||||
@override final AppsSurveillanceSuccessEvent? successEvent;
|
||||
|
||||
/// Create a copy of AppsSurveillanceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$AppsSurveillanceViewStateCopyWith<_AppsSurveillanceViewState> get copyWith => __$AppsSurveillanceViewStateCopyWithImpl<_AppsSurveillanceViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AppsSurveillanceViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.selectedDevice, selectedDevice) || other.selectedDevice == selectedDevice)&&const DeepCollectionEquality().equals(other._apps, _apps)&&const DeepCollectionEquality().equals(other._schedule, _schedule)&&(identical(other.deviceName, deviceName) || other.deviceName == deviceName)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent)&&(identical(other.successEvent, successEvent) || other.successEvent == successEvent));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,isLoading,isSaving,selectedDevice,const DeepCollectionEquality().hash(_apps),const DeepCollectionEquality().hash(_schedule),deviceName,errorEvent,successEvent);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppsSurveillanceViewState(isLoading: $isLoading, isSaving: $isSaving, selectedDevice: $selectedDevice, apps: $apps, schedule: $schedule, deviceName: $deviceName, errorEvent: $errorEvent, successEvent: $successEvent)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$AppsSurveillanceViewStateCopyWith<$Res> implements $AppsSurveillanceViewStateCopyWith<$Res> {
|
||||
factory _$AppsSurveillanceViewStateCopyWith(_AppsSurveillanceViewState value, $Res Function(_AppsSurveillanceViewState) _then) = __$AppsSurveillanceViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
bool isLoading, bool isSaving, DeviceEntity? selectedDevice, List<InstalledAppEntity> apps, List<SchedulePeriodEntity> schedule, String deviceName, AppsSurveillanceErrorEvent? errorEvent, AppsSurveillanceSuccessEvent? successEvent
|
||||
});
|
||||
|
||||
|
||||
@override $DeviceEntityCopyWith<$Res>? get selectedDevice;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$AppsSurveillanceViewStateCopyWithImpl<$Res>
|
||||
implements _$AppsSurveillanceViewStateCopyWith<$Res> {
|
||||
__$AppsSurveillanceViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _AppsSurveillanceViewState _self;
|
||||
final $Res Function(_AppsSurveillanceViewState) _then;
|
||||
|
||||
/// Create a copy of AppsSurveillanceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? isSaving = null,Object? selectedDevice = freezed,Object? apps = null,Object? schedule = null,Object? deviceName = null,Object? errorEvent = freezed,Object? successEvent = freezed,}) {
|
||||
return _then(_AppsSurveillanceViewState(
|
||||
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,selectedDevice: freezed == selectedDevice ? _self.selectedDevice : selectedDevice // ignore: cast_nullable_to_non_nullable
|
||||
as DeviceEntity?,apps: null == apps ? _self._apps : apps // ignore: cast_nullable_to_non_nullable
|
||||
as List<InstalledAppEntity>,schedule: null == schedule ? _self._schedule : schedule // ignore: cast_nullable_to_non_nullable
|
||||
as List<SchedulePeriodEntity>,deviceName: null == deviceName ? _self.deviceName : deviceName // ignore: cast_nullable_to_non_nullable
|
||||
as String,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
|
||||
as AppsSurveillanceErrorEvent?,successEvent: freezed == successEvent ? _self.successEvent : successEvent // ignore: cast_nullable_to_non_nullable
|
||||
as AppsSurveillanceSuccessEvent?,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of AppsSurveillanceViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$DeviceEntityCopyWith<$Res>? get selectedDevice {
|
||||
if (_self.selectedDevice == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $DeviceEntityCopyWith<$Res>(_self.selectedDevice!, (value) {
|
||||
return _then(_self.copyWith(selectedDevice: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,513 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:device_management/src/core/domain/entities/schedule_period_entity.dart';
|
||||
import 'package:device_management/src/features/apps_surveillance/presentation/state/apps_surveillance_view_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
void showPeriodForm(BuildContext context, {
|
||||
SchedulePeriodEntity? period,
|
||||
required int index
|
||||
}) {
|
||||
showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (_) => _PeriodFormSheet(period: period, index: index),
|
||||
);
|
||||
}
|
||||
|
||||
class _PeriodFormSheet extends ConsumerStatefulWidget {
|
||||
final SchedulePeriodEntity? period;
|
||||
final int index;
|
||||
|
||||
const _PeriodFormSheet({this.period, required this.index});
|
||||
|
||||
@override
|
||||
ConsumerState<_PeriodFormSheet> createState() => _PeriodFormSheetState();
|
||||
}
|
||||
|
||||
class _PeriodFormSheetState extends ConsumerState<_PeriodFormSheet> {
|
||||
late TimeOfDay _startTime;
|
||||
late TimeOfDay _endTime;
|
||||
bool _showStartPicker = false;
|
||||
bool _showEndPicker = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_startTime = _parseTime(widget.period?.periodStart ?? '00:00');
|
||||
_endTime = _parseTime(widget.period?.periodEnd ?? '00:00');
|
||||
}
|
||||
|
||||
bool get _isEditing => widget.period != null;
|
||||
|
||||
TimeOfDay _parseTime(String raw) {
|
||||
final split = raw.split(':');
|
||||
final hour = int.parse(split[0]);
|
||||
final minute = int.parse(split[1]);
|
||||
return TimeOfDay(hour: hour, minute: minute);
|
||||
}
|
||||
|
||||
String _buildTime(TimeOfDay time) {
|
||||
final hh = time.hour.toString().padLeft(2, '0');
|
||||
final mm = time.minute.toString().padLeft(2, '0');
|
||||
return '$hh:$mm';
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
if (!_isFormValid) return;
|
||||
|
||||
final vm = ref.read(appsSurveillanceViewModelProvider.notifier);
|
||||
|
||||
vm.updatePeriod(
|
||||
index: widget.index,
|
||||
startTime: _buildTime(_startTime),
|
||||
endTime: _buildTime(_endTime),
|
||||
);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
void _togglePicker({required bool isStart}) {
|
||||
setState(() {
|
||||
if (isStart) {
|
||||
_showStartPicker = !_showStartPicker;
|
||||
_showEndPicker = false;
|
||||
} else {
|
||||
_showEndPicker = !_showEndPicker;
|
||||
_showStartPicker = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
bool get _isFormValid {
|
||||
return !_startTime.isAfter(_endTime);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: bottomInset),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(SizeUtils.getByScreen(small: 20, big: 18)),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 22, big: 20)),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
margin: EdgeInsets.only(
|
||||
bottom: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
context.translate(
|
||||
_isEditing
|
||||
? I18n.scheduledActivityEditTitle
|
||||
: I18n.scheduledActivityNewTitle,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 20, big: 18)),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _TimeSelector(
|
||||
label: context.translate(
|
||||
I18n.scheduledActivityStartTime,
|
||||
),
|
||||
time: _startTime,
|
||||
isExpanded: _showStartPicker,
|
||||
onTap: () => _togglePicker(isStart: true),
|
||||
theme: theme,
|
||||
),
|
||||
),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Expanded(
|
||||
child: _TimeSelector(
|
||||
label: context.translate(I18n.scheduledActivityEndTime),
|
||||
time: _endTime,
|
||||
isExpanded: _showEndPicker,
|
||||
onTap: () => _togglePicker(isStart: false),
|
||||
theme: theme,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_showStartPicker)
|
||||
_InlineTimePicker(
|
||||
initialTime: _startTime,
|
||||
onChanged: (time) => setState(() => _startTime = time),
|
||||
),
|
||||
if (_showEndPicker)
|
||||
_InlineTimePicker(
|
||||
initialTime: _endTime,
|
||||
onChanged: (time) => setState(() => _endTime = time),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 48, big: 46),
|
||||
child: ElevatedButton(
|
||||
onPressed: _isFormValid ? _submit : null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.getColorFor(
|
||||
ThemeCode.legacyPrimary,
|
||||
),
|
||||
disabledBackgroundColor: Colors.grey[300],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
SizeUtils.getByScreen(small: 12, big: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
context.translate(I18n.save),
|
||||
style: TextStyle(
|
||||
color: _isFormValid ? Colors.white : Colors.grey,
|
||||
fontSize: SizeUtils.getByScreen(small: 16, big: 15),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/*class _ActivityFormSheetState extends ConsumerState<ActivityFormSheet> {
|
||||
late final TextEditingController _nameController;
|
||||
late int _selectedWeekDay;
|
||||
late TimeOfDay _startTime;
|
||||
late TimeOfDay _endTime;
|
||||
bool _showStartPicker = false;
|
||||
bool _showEndPicker = false;
|
||||
|
||||
bool get _isEditing => widget.activity != null;
|
||||
|
||||
bool get _isFormValid {
|
||||
if (_nameController.text.trim().isEmpty) return false;
|
||||
return _timeToMinutes(_startTime) < _timeToMinutes(_endTime);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final activity = widget.activity;
|
||||
_nameController = TextEditingController(text: activity?.name ?? '');
|
||||
_nameController.addListener(() => setState(() {}));
|
||||
_selectedWeekDay = activity?.weekDay ?? widget.weekDay ?? 1;
|
||||
|
||||
if (activity != null && activity.hasValidPeriod) {
|
||||
_startTime = TimeOfDay(
|
||||
hour: int.parse(activity.period.substring(0, 2)),
|
||||
minute: int.parse(activity.period.substring(2, 4)),
|
||||
);
|
||||
_endTime = TimeOfDay(
|
||||
hour: int.parse(activity.period.substring(4, 6)),
|
||||
minute: int.parse(activity.period.substring(6, 8)),
|
||||
);
|
||||
} else {
|
||||
_startTime = const TimeOfDay(hour: 8, minute: 0);
|
||||
_endTime = const TimeOfDay(hour: 9, minute: 0);
|
||||
}
|
||||
}
|
||||
|
||||
void _togglePicker({required bool isStart}) {
|
||||
setState(() {
|
||||
if (isStart) {
|
||||
_showStartPicker = !_showStartPicker;
|
||||
_showEndPicker = false;
|
||||
} else {
|
||||
_showEndPicker = !_showEndPicker;
|
||||
_showStartPicker = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _submit() {
|
||||
if (!_isFormValid) return;
|
||||
|
||||
final name = _nameController.text.trim();
|
||||
final period = _buildPeriod();
|
||||
final vm = ref.read(scheduledActivitiesViewModelProvider.notifier);
|
||||
|
||||
if (_isEditing) {
|
||||
vm.updateActivity(
|
||||
activityId: widget.activity!.id,
|
||||
weekDay: widget.activity!.weekDay,
|
||||
name: name,
|
||||
period: period,
|
||||
);
|
||||
} else {
|
||||
vm.createActivity(name: name, weekDay: _selectedWeekDay, period: period);
|
||||
}
|
||||
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final bottomInset = MediaQuery.of(context).viewInsets.bottom;
|
||||
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: bottomInset),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.getColorFor(ThemeCode.backgroundPrimary),
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(SizeUtils.getByScreen(small: 20, big: 18)),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(SizeUtils.getByScreen(small: 22, big: 20)),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
width: 40,
|
||||
height: 4,
|
||||
margin: EdgeInsets.only(
|
||||
bottom: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[300],
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
context.translate(
|
||||
_isEditing
|
||||
? I18n.scheduledActivityEditTitle
|
||||
: I18n.scheduledActivityNewTitle,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
|
||||
fontWeight: FontWeight.bold,
|
||||
color: theme.getColorFor(ThemeCode.legacyPrimary),
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 20, big: 18)),
|
||||
TextField(
|
||||
controller: _nameController,
|
||||
decoration: InputDecoration(
|
||||
labelText: context.translate(I18n.name),
|
||||
border: const OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 14)),
|
||||
WeekDayChips.single(
|
||||
selectedWeekDay: _isEditing
|
||||
? widget.activity!.weekDay
|
||||
: _selectedWeekDay,
|
||||
enabled: !_isEditing,
|
||||
theme: theme,
|
||||
onChanged: (value) =>
|
||||
setState(() => _selectedWeekDay = value),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 14)),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: _TimeSelector(
|
||||
label: context.translate(
|
||||
I18n.scheduledActivityStartTime,
|
||||
),
|
||||
time: _startTime,
|
||||
isExpanded: _showStartPicker,
|
||||
onTap: () => _togglePicker(isStart: true),
|
||||
theme: theme,
|
||||
),
|
||||
),
|
||||
SizedBox(width: SizeUtils.getByScreen(small: 12, big: 10)),
|
||||
Expanded(
|
||||
child: _TimeSelector(
|
||||
label: context.translate(I18n.scheduledActivityEndTime),
|
||||
time: _endTime,
|
||||
isExpanded: _showEndPicker,
|
||||
onTap: () => _togglePicker(isStart: false),
|
||||
theme: theme,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (_showStartPicker)
|
||||
_InlineTimePicker(
|
||||
initialTime: _startTime,
|
||||
onChanged: (time) => setState(() => _startTime = time),
|
||||
),
|
||||
if (_showEndPicker)
|
||||
_InlineTimePicker(
|
||||
initialTime: _endTime,
|
||||
onChanged: (time) => setState(() => _endTime = time),
|
||||
),
|
||||
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)),
|
||||
SizedBox(
|
||||
height: SizeUtils.getByScreen(small: 48, big: 46),
|
||||
child: ElevatedButton(
|
||||
onPressed: _isFormValid ? _submit : null,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: theme.getColorFor(
|
||||
ThemeCode.legacyPrimary,
|
||||
),
|
||||
disabledBackgroundColor: Colors.grey[300],
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
SizeUtils.getByScreen(small: 12, big: 10),
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
context.translate(I18n.save),
|
||||
style: TextStyle(
|
||||
color: _isFormValid ? Colors.white : Colors.grey,
|
||||
fontSize: SizeUtils.getByScreen(small: 16, big: 15),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
class _TimeSelector extends StatelessWidget {
|
||||
final String label;
|
||||
final TimeOfDay time;
|
||||
final bool isExpanded;
|
||||
final VoidCallback onTap;
|
||||
final ThemePort theme;
|
||||
|
||||
const _TimeSelector({
|
||||
required this.label,
|
||||
required this.time,
|
||||
required this.isExpanded,
|
||||
required this.onTap,
|
||||
required this.theme,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: SizeUtils.getByScreen(small: 12, big: 10),
|
||||
vertical: SizeUtils.getByScreen(small: 14, big: 12),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: isExpanded
|
||||
? theme.getColorFor(ThemeCode.legacyPrimary)
|
||||
: Colors.grey,
|
||||
width: isExpanded ? 2 : 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
|
||||
color: theme
|
||||
.getColorFor(ThemeCode.textPrimary)
|
||||
.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
time.format(context),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 16, big: 15),
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Icon(
|
||||
isExpanded
|
||||
? Icons.keyboard_arrow_up
|
||||
: Icons.keyboard_arrow_down,
|
||||
size: SizeUtils.getByScreen(small: 20, big: 18),
|
||||
color: theme
|
||||
.getColorFor(ThemeCode.textPrimary)
|
||||
.withValues(alpha: 0.5),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _InlineTimePicker extends StatelessWidget {
|
||||
final TimeOfDay initialTime;
|
||||
final ValueChanged<TimeOfDay> onChanged;
|
||||
|
||||
const _InlineTimePicker({required this.initialTime, required this.onChanged});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: SizeUtils.getByScreen(small: 180, big: 160),
|
||||
margin: EdgeInsets.only(top: SizeUtils.getByScreen(small: 8, big: 6)),
|
||||
child: CupertinoDatePicker(
|
||||
mode: CupertinoDatePickerMode.time,
|
||||
use24hFormat: true,
|
||||
initialDateTime: DateTime(
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
initialTime.hour,
|
||||
initialTime.minute,
|
||||
),
|
||||
onDateTimeChanged: (dateTime) {
|
||||
onChanged(TimeOfDay(hour: dateTime.hour, minute: dateTime.minute));
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
|
||||
import 'presentation/background_image_screen.dart';
|
||||
|
||||
class BackgroundImageBuilder {
|
||||
const BackgroundImageBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
final NavigationContract navigationContract = GetIt.I<NavigationContract>();
|
||||
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: BackgroundImageScreen(navigationContract: navigationContract),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:navigation/navigation.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
import 'package:utils/utils.dart';
|
||||
|
||||
import 'state/background_image_view_model.dart';
|
||||
import 'state/background_image_view_state.dart';
|
||||
|
||||
class BackgroundImageScreen extends ConsumerWidget {
|
||||
final NavigationContract navigationContract;
|
||||
|
||||
const BackgroundImageScreen({super.key, required this.navigationContract});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.read(themePortProvider);
|
||||
final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
|
||||
|
||||
final state = ref.watch(backgroundImageViewModelProvider);
|
||||
final vm = ref.read(backgroundImageViewModelProvider.notifier);
|
||||
|
||||
ref.listen(
|
||||
backgroundImageViewModelProvider.select((s) => s.errorEvent),
|
||||
(previous, next) {
|
||||
if (next != null) {
|
||||
final message = switch (next) {
|
||||
BackgroundImageErrorEvent.load =>
|
||||
context.translate(I18n.errorBackgroundImageLoad),
|
||||
BackgroundImageErrorEvent.upload =>
|
||||
context.translate(I18n.errorBackgroundImageUpload),
|
||||
BackgroundImageErrorEvent.set =>
|
||||
context.translate(I18n.errorBackgroundImageSet),
|
||||
};
|
||||
showTopSnackbar(context, message: message, type: MessageType.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
backgroundImageViewModelProvider.select((s) => s.successEvent),
|
||||
(previous, next) {
|
||||
if (next != null) {
|
||||
final message = switch (next) {
|
||||
BackgroundImageSuccessEvent.uploaded =>
|
||||
context.translate(I18n.backgroundImageUploaded),
|
||||
BackgroundImageSuccessEvent.backgroundSet =>
|
||||
context.translate(I18n.backgroundImageSet),
|
||||
};
|
||||
showTopSnackbar(context, message: message, type: MessageType.success);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.white,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
automaticallyImplyLeading: false,
|
||||
leading: IconButton(
|
||||
onPressed: () => navigationContract.goBack(),
|
||||
icon: Icon(
|
||||
Icons.adaptive.arrow_back,
|
||||
color: primaryColor,
|
||||
size: SizeUtils.getByScreen(small: 32, big: 28),
|
||||
),
|
||||
),
|
||||
title: Text(
|
||||
context.translate(I18n.customBackground).toUpperCase(),
|
||||
style: TextStyle(
|
||||
fontSize: SizeUtils.getByScreen(small: 20, big: 19),
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 0,
|
||||
color: primaryColor,
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
right: SizeUtils.getByScreen(small: 16, big: 14),
|
||||
),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: IconButton(
|
||||
onPressed: state.isSaving ? null : vm.uploadPhoto,
|
||||
icon: Icon(
|
||||
Icons.add_photo_alternate_outlined,
|
||||
color: Colors.white,
|
||||
size: SizeUtils.getByScreen(small: 24, big: 22),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: SafeArea(
|
||||
top: false,
|
||||
child: state.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: state.isSaving
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: state.photos.isEmpty
|
||||
? _EmptyState(
|
||||
onUpload: vm.uploadPhoto,
|
||||
primaryColor: primaryColor,
|
||||
)
|
||||
: _PhotoGrid(
|
||||
state: state,
|
||||
onPhotoTap: vm.setAsBackground,
|
||||
primaryColor: primaryColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _EmptyState extends StatelessWidget {
|
||||
final VoidCallback onUpload;
|
||||
final Color primaryColor;
|
||||
|
||||
const _EmptyState({required this.onUpload, required this.primaryColor});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 28),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.add_photo_alternate_outlined,
|
||||
size: 100,
|
||||
color: Colors.grey.shade400,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
context.translate(I18n.backgroundImageDescription),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
PrimaryButton(
|
||||
onPressed: onUpload,
|
||||
text: context.translate(I18n.backgroundImageTapToSelect),
|
||||
color: primaryColor,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _PhotoGrid extends StatelessWidget {
|
||||
final BackgroundImageViewState state;
|
||||
final ValueChanged<String> onPhotoTap;
|
||||
final Color primaryColor;
|
||||
|
||||
const _PhotoGrid({
|
||||
required this.state,
|
||||
required this.onPhotoTap,
|
||||
required this.primaryColor,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Text(
|
||||
context.translate(I18n.backgroundImageTapToChange),
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(fontSize: 14),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.all(12),
|
||||
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisSpacing: 10,
|
||||
mainAxisSpacing: 10,
|
||||
),
|
||||
itemCount: state.photos.length,
|
||||
itemBuilder: (context, index) {
|
||||
final photo = state.photos[index];
|
||||
final isActive = state.currentBackgroundId == photo.id;
|
||||
return GestureDetector(
|
||||
onTap: () => onPhotoTap(photo.id),
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: isActive ? primaryColor : Colors.grey.shade300,
|
||||
width: isActive ? 3 : 1,
|
||||
),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: photo.fileBytes != null
|
||||
? Image.memory(
|
||||
photo.fileBytes!,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Center(
|
||||
child: Icon(
|
||||
Icons.image_outlined,
|
||||
size: 48,
|
||||
color: Colors.grey.shade400,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isActive)
|
||||
Positioned(
|
||||
top: 8,
|
||||
right: 8,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.check,
|
||||
color: Colors.white,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
import '../../../../core/domain/repositories/background_image_repository.dart';
|
||||
import '../../../../core/providers/background_image_repository_provider.dart';
|
||||
import 'background_image_view_state.dart';
|
||||
|
||||
final backgroundImageViewModelProvider =
|
||||
NotifierProvider.autoDispose<BackgroundImageViewModel, BackgroundImageViewState>(
|
||||
BackgroundImageViewModel.new,
|
||||
);
|
||||
|
||||
class BackgroundImageViewModel extends Notifier<BackgroundImageViewState> {
|
||||
late final BackgroundImageRepository _repository;
|
||||
|
||||
@override
|
||||
BackgroundImageViewState build() {
|
||||
_repository = ref.read(backgroundImageRepositoryProvider);
|
||||
Future.microtask(_load);
|
||||
return const BackgroundImageViewState();
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if (device == null) return;
|
||||
|
||||
final photos = await _repository.getPhotos();
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
photos: photos,
|
||||
currentBackgroundId: device.settings.backgroundImageId,
|
||||
isLoading: false,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorEvent: BackgroundImageErrorEvent.load,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> reload() async {
|
||||
state = state.copyWith(isLoading: true, errorEvent: null);
|
||||
await _load();
|
||||
}
|
||||
|
||||
Future<void> uploadPhoto() async {
|
||||
if (state.isSaving) return;
|
||||
|
||||
final picker = ImagePicker();
|
||||
final image = await picker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
maxWidth: 800,
|
||||
imageQuality: 80,
|
||||
);
|
||||
if (image == null) return;
|
||||
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if (device == null) return;
|
||||
|
||||
state = state.copyWith(isSaving: true, errorEvent: null, successEvent: null);
|
||||
|
||||
try {
|
||||
final photoId = await _repository.uploadImage(path: image.path);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
await _repository.setBackgroundImage(
|
||||
deviceId: device.id,
|
||||
photoId: photoId,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
ref.syncDeviceSettings(
|
||||
device,
|
||||
device.settings.copyWith(backgroundImageId: photoId),
|
||||
);
|
||||
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
currentBackgroundId: photoId,
|
||||
successEvent: BackgroundImageSuccessEvent.uploaded,
|
||||
);
|
||||
|
||||
await reload();
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
errorEvent: BackgroundImageErrorEvent.upload,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setAsBackground(String photoId) async {
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if (device == null) return;
|
||||
|
||||
state = state.copyWith(isSaving: true, errorEvent: null, successEvent: null);
|
||||
|
||||
try {
|
||||
await _repository.setBackgroundImage(
|
||||
deviceId: device.id,
|
||||
photoId: photoId,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
ref.syncDeviceSettings(
|
||||
device,
|
||||
device.settings.copyWith(backgroundImageId: photoId),
|
||||
);
|
||||
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
currentBackgroundId: photoId,
|
||||
successEvent: BackgroundImageSuccessEvent.backgroundSet,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isSaving: false,
|
||||
errorEvent: BackgroundImageErrorEvent.set,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'background_image_view_state.freezed.dart';
|
||||
|
||||
enum BackgroundImageErrorEvent { load, upload, set }
|
||||
enum BackgroundImageSuccessEvent { uploaded, backgroundSet }
|
||||
|
||||
@freezed
|
||||
abstract class BackgroundImageViewState with _$BackgroundImageViewState {
|
||||
const factory BackgroundImageViewState({
|
||||
@Default([]) List<PictureEntity> photos,
|
||||
@Default(true) bool isLoading,
|
||||
@Default(false) bool isSaving,
|
||||
String? currentBackgroundId,
|
||||
BackgroundImageSuccessEvent? successEvent,
|
||||
BackgroundImageErrorEvent? errorEvent,
|
||||
}) = _BackgroundImageViewState;
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'background_image_view_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$BackgroundImageViewState {
|
||||
|
||||
List<PictureEntity> get photos; bool get isLoading; bool get isSaving; String? get currentBackgroundId; BackgroundImageSuccessEvent? get successEvent; BackgroundImageErrorEvent? get errorEvent;
|
||||
/// Create a copy of BackgroundImageViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$BackgroundImageViewStateCopyWith<BackgroundImageViewState> get copyWith => _$BackgroundImageViewStateCopyWithImpl<BackgroundImageViewState>(this as BackgroundImageViewState, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is BackgroundImageViewState&&const DeepCollectionEquality().equals(other.photos, photos)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.currentBackgroundId, currentBackgroundId) || other.currentBackgroundId == currentBackgroundId)&&(identical(other.successEvent, successEvent) || other.successEvent == successEvent)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(photos),isLoading,isSaving,currentBackgroundId,successEvent,errorEvent);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BackgroundImageViewState(photos: $photos, isLoading: $isLoading, isSaving: $isSaving, currentBackgroundId: $currentBackgroundId, successEvent: $successEvent, errorEvent: $errorEvent)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $BackgroundImageViewStateCopyWith<$Res> {
|
||||
factory $BackgroundImageViewStateCopyWith(BackgroundImageViewState value, $Res Function(BackgroundImageViewState) _then) = _$BackgroundImageViewStateCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
List<PictureEntity> photos, bool isLoading, bool isSaving, String? currentBackgroundId, BackgroundImageSuccessEvent? successEvent, BackgroundImageErrorEvent? errorEvent
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$BackgroundImageViewStateCopyWithImpl<$Res>
|
||||
implements $BackgroundImageViewStateCopyWith<$Res> {
|
||||
_$BackgroundImageViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final BackgroundImageViewState _self;
|
||||
final $Res Function(BackgroundImageViewState) _then;
|
||||
|
||||
/// Create a copy of BackgroundImageViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? photos = null,Object? isLoading = null,Object? isSaving = null,Object? currentBackgroundId = freezed,Object? successEvent = freezed,Object? errorEvent = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
photos: null == photos ? _self.photos : photos // ignore: cast_nullable_to_non_nullable
|
||||
as List<PictureEntity>,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentBackgroundId: freezed == currentBackgroundId ? _self.currentBackgroundId : currentBackgroundId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,successEvent: freezed == successEvent ? _self.successEvent : successEvent // ignore: cast_nullable_to_non_nullable
|
||||
as BackgroundImageSuccessEvent?,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
|
||||
as BackgroundImageErrorEvent?,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [BackgroundImageViewState].
|
||||
extension BackgroundImageViewStatePatterns on BackgroundImageViewState {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BackgroundImageViewState value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BackgroundImageViewState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BackgroundImageViewState value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BackgroundImageViewState():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BackgroundImageViewState value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _BackgroundImageViewState() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<PictureEntity> photos, bool isLoading, bool isSaving, String? currentBackgroundId, BackgroundImageSuccessEvent? successEvent, BackgroundImageErrorEvent? errorEvent)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BackgroundImageViewState() when $default != null:
|
||||
return $default(_that.photos,_that.isLoading,_that.isSaving,_that.currentBackgroundId,_that.successEvent,_that.errorEvent);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<PictureEntity> photos, bool isLoading, bool isSaving, String? currentBackgroundId, BackgroundImageSuccessEvent? successEvent, BackgroundImageErrorEvent? errorEvent) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BackgroundImageViewState():
|
||||
return $default(_that.photos,_that.isLoading,_that.isSaving,_that.currentBackgroundId,_that.successEvent,_that.errorEvent);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<PictureEntity> photos, bool isLoading, bool isSaving, String? currentBackgroundId, BackgroundImageSuccessEvent? successEvent, BackgroundImageErrorEvent? errorEvent)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _BackgroundImageViewState() when $default != null:
|
||||
return $default(_that.photos,_that.isLoading,_that.isSaving,_that.currentBackgroundId,_that.successEvent,_that.errorEvent);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _BackgroundImageViewState implements BackgroundImageViewState {
|
||||
const _BackgroundImageViewState({final List<PictureEntity> photos = const [], this.isLoading = true, this.isSaving = false, this.currentBackgroundId, this.successEvent, this.errorEvent}): _photos = photos;
|
||||
|
||||
|
||||
final List<PictureEntity> _photos;
|
||||
@override@JsonKey() List<PictureEntity> get photos {
|
||||
if (_photos is EqualUnmodifiableListView) return _photos;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_photos);
|
||||
}
|
||||
|
||||
@override@JsonKey() final bool isLoading;
|
||||
@override@JsonKey() final bool isSaving;
|
||||
@override final String? currentBackgroundId;
|
||||
@override final BackgroundImageSuccessEvent? successEvent;
|
||||
@override final BackgroundImageErrorEvent? errorEvent;
|
||||
|
||||
/// Create a copy of BackgroundImageViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$BackgroundImageViewStateCopyWith<_BackgroundImageViewState> get copyWith => __$BackgroundImageViewStateCopyWithImpl<_BackgroundImageViewState>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BackgroundImageViewState&&const DeepCollectionEquality().equals(other._photos, _photos)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isSaving, isSaving) || other.isSaving == isSaving)&&(identical(other.currentBackgroundId, currentBackgroundId) || other.currentBackgroundId == currentBackgroundId)&&(identical(other.successEvent, successEvent) || other.successEvent == successEvent)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_photos),isLoading,isSaving,currentBackgroundId,successEvent,errorEvent);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'BackgroundImageViewState(photos: $photos, isLoading: $isLoading, isSaving: $isSaving, currentBackgroundId: $currentBackgroundId, successEvent: $successEvent, errorEvent: $errorEvent)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$BackgroundImageViewStateCopyWith<$Res> implements $BackgroundImageViewStateCopyWith<$Res> {
|
||||
factory _$BackgroundImageViewStateCopyWith(_BackgroundImageViewState value, $Res Function(_BackgroundImageViewState) _then) = __$BackgroundImageViewStateCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
List<PictureEntity> photos, bool isLoading, bool isSaving, String? currentBackgroundId, BackgroundImageSuccessEvent? successEvent, BackgroundImageErrorEvent? errorEvent
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$BackgroundImageViewStateCopyWithImpl<$Res>
|
||||
implements _$BackgroundImageViewStateCopyWith<$Res> {
|
||||
__$BackgroundImageViewStateCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _BackgroundImageViewState _self;
|
||||
final $Res Function(_BackgroundImageViewState) _then;
|
||||
|
||||
/// Create a copy of BackgroundImageViewState
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? photos = null,Object? isLoading = null,Object? isSaving = null,Object? currentBackgroundId = freezed,Object? successEvent = freezed,Object? errorEvent = freezed,}) {
|
||||
return _then(_BackgroundImageViewState(
|
||||
photos: null == photos ? _self._photos : photos // ignore: cast_nullable_to_non_nullable
|
||||
as List<PictureEntity>,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isSaving: null == isSaving ? _self.isSaving : isSaving // ignore: cast_nullable_to_non_nullable
|
||||
as bool,currentBackgroundId: freezed == currentBackgroundId ? _self.currentBackgroundId : currentBackgroundId // ignore: cast_nullable_to_non_nullable
|
||||
as String?,successEvent: freezed == successEvent ? _self.successEvent : successEvent // ignore: cast_nullable_to_non_nullable
|
||||
as BackgroundImageSuccessEvent?,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
|
||||
as BackgroundImageErrorEvent?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'presentation/call_history_screen.dart';
|
||||
|
||||
class CallHistoryBuilder {
|
||||
const CallHistoryBuilder();
|
||||
|
||||
Page<void> buildPage(BuildContext context, GoRouterState state) {
|
||||
return MaterialPage<void>(
|
||||
key: state.pageKey,
|
||||
child: const CallHistoryScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import 'call_history_entity.dart';
|
||||
import 'call_history_response_model.dart';
|
||||
|
||||
class CallHistoryDatasource {
|
||||
CallHistoryDatasource(this._repository);
|
||||
|
||||
final QuestiaRepository _repository;
|
||||
|
||||
Future<List<CallHistoryEntity>> getCallHistory({
|
||||
required String deviceIdentificator,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _repository.get<Map<String, dynamic>>(
|
||||
'/devices/identificator/$deviceIdentificator/call-histories',
|
||||
);
|
||||
|
||||
final data = response.data;
|
||||
if (data == null || data.isEmpty) return [];
|
||||
|
||||
final model = CallHistoryResponseModel.fromJson(data);
|
||||
return model.items
|
||||
.map((item) => CallHistoryEntity(
|
||||
deviceIdentificator: item.deviceIdentificator,
|
||||
phone: item.phone,
|
||||
name: item.name,
|
||||
isIncoming: item.isIncoming,
|
||||
isAccepted: item.isAccepted,
|
||||
duration: item.duration,
|
||||
occurredAt: item.occurredAt,
|
||||
createdAt: item.createdAt,
|
||||
))
|
||||
.toList();
|
||||
} on DioException catch (error) {
|
||||
if (error.response?.statusCode == 404) return [];
|
||||
throw mapDioError(error, defaultMessage: 'Error getting call history');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:sf_infrastructure/sf_infrastructure.dart';
|
||||
|
||||
import 'call_history_datasource.dart';
|
||||
|
||||
final callHistoryDatasourceProvider = Provider<CallHistoryDatasource>((ref) {
|
||||
return CallHistoryDatasource(GetIt.I<QuestiaRepository>());
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'call_history_entity.freezed.dart';
|
||||
|
||||
@freezed
|
||||
abstract class CallHistoryEntity with _$CallHistoryEntity {
|
||||
const factory CallHistoryEntity({
|
||||
required String deviceIdentificator,
|
||||
required String phone,
|
||||
String? name,
|
||||
required bool isIncoming,
|
||||
required bool isAccepted,
|
||||
required int duration,
|
||||
required int occurredAt,
|
||||
required int createdAt,
|
||||
}) = _CallHistoryEntity;
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'call_history_entity.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
/// @nodoc
|
||||
mixin _$CallHistoryEntity {
|
||||
|
||||
String get deviceIdentificator; String get phone; String? get name; bool get isIncoming; bool get isAccepted; int get duration; int get occurredAt; int get createdAt;
|
||||
/// Create a copy of CallHistoryEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$CallHistoryEntityCopyWith<CallHistoryEntity> get copyWith => _$CallHistoryEntityCopyWithImpl<CallHistoryEntity>(this as CallHistoryEntity, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is CallHistoryEntity&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.name, name) || other.name == name)&&(identical(other.isIncoming, isIncoming) || other.isIncoming == isIncoming)&&(identical(other.isAccepted, isAccepted) || other.isAccepted == isAccepted)&&(identical(other.duration, duration) || other.duration == duration)&&(identical(other.occurredAt, occurredAt) || other.occurredAt == occurredAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,deviceIdentificator,phone,name,isIncoming,isAccepted,duration,occurredAt,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CallHistoryEntity(deviceIdentificator: $deviceIdentificator, phone: $phone, name: $name, isIncoming: $isIncoming, isAccepted: $isAccepted, duration: $duration, occurredAt: $occurredAt, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $CallHistoryEntityCopyWith<$Res> {
|
||||
factory $CallHistoryEntityCopyWith(CallHistoryEntity value, $Res Function(CallHistoryEntity) _then) = _$CallHistoryEntityCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$CallHistoryEntityCopyWithImpl<$Res>
|
||||
implements $CallHistoryEntityCopyWith<$Res> {
|
||||
_$CallHistoryEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final CallHistoryEntity _self;
|
||||
final $Res Function(CallHistoryEntity) _then;
|
||||
|
||||
/// Create a copy of CallHistoryEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? deviceIdentificator = null,Object? phone = null,Object? name = freezed,Object? isIncoming = null,Object? isAccepted = null,Object? duration = null,Object? occurredAt = null,Object? createdAt = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isIncoming: null == isIncoming ? _self.isIncoming : isIncoming // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isAccepted: null == isAccepted ? _self.isAccepted : isAccepted // ignore: cast_nullable_to_non_nullable
|
||||
as bool,duration: null == duration ? _self.duration : duration // ignore: cast_nullable_to_non_nullable
|
||||
as int,occurredAt: null == occurredAt ? _self.occurredAt : occurredAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [CallHistoryEntity].
|
||||
extension CallHistoryEntityPatterns on CallHistoryEntity {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CallHistoryEntity value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CallHistoryEntity value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryEntity():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CallHistoryEntity value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryEntity() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryEntity() when $default != null:
|
||||
return $default(_that.deviceIdentificator,_that.phone,_that.name,_that.isIncoming,_that.isAccepted,_that.duration,_that.occurredAt,_that.createdAt);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryEntity():
|
||||
return $default(_that.deviceIdentificator,_that.phone,_that.name,_that.isIncoming,_that.isAccepted,_that.duration,_that.occurredAt,_that.createdAt);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryEntity() when $default != null:
|
||||
return $default(_that.deviceIdentificator,_that.phone,_that.name,_that.isIncoming,_that.isAccepted,_that.duration,_that.occurredAt,_that.createdAt);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
|
||||
class _CallHistoryEntity implements CallHistoryEntity {
|
||||
const _CallHistoryEntity({required this.deviceIdentificator, required this.phone, this.name, required this.isIncoming, required this.isAccepted, required this.duration, required this.occurredAt, required this.createdAt});
|
||||
|
||||
|
||||
@override final String deviceIdentificator;
|
||||
@override final String phone;
|
||||
@override final String? name;
|
||||
@override final bool isIncoming;
|
||||
@override final bool isAccepted;
|
||||
@override final int duration;
|
||||
@override final int occurredAt;
|
||||
@override final int createdAt;
|
||||
|
||||
/// Create a copy of CallHistoryEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$CallHistoryEntityCopyWith<_CallHistoryEntity> get copyWith => __$CallHistoryEntityCopyWithImpl<_CallHistoryEntity>(this, _$identity);
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CallHistoryEntity&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.name, name) || other.name == name)&&(identical(other.isIncoming, isIncoming) || other.isIncoming == isIncoming)&&(identical(other.isAccepted, isAccepted) || other.isAccepted == isAccepted)&&(identical(other.duration, duration) || other.duration == duration)&&(identical(other.occurredAt, occurredAt) || other.occurredAt == occurredAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,deviceIdentificator,phone,name,isIncoming,isAccepted,duration,occurredAt,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CallHistoryEntity(deviceIdentificator: $deviceIdentificator, phone: $phone, name: $name, isIncoming: $isIncoming, isAccepted: $isAccepted, duration: $duration, occurredAt: $occurredAt, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$CallHistoryEntityCopyWith<$Res> implements $CallHistoryEntityCopyWith<$Res> {
|
||||
factory _$CallHistoryEntityCopyWith(_CallHistoryEntity value, $Res Function(_CallHistoryEntity) _then) = __$CallHistoryEntityCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$CallHistoryEntityCopyWithImpl<$Res>
|
||||
implements _$CallHistoryEntityCopyWith<$Res> {
|
||||
__$CallHistoryEntityCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _CallHistoryEntity _self;
|
||||
final $Res Function(_CallHistoryEntity) _then;
|
||||
|
||||
/// Create a copy of CallHistoryEntity
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? deviceIdentificator = null,Object? phone = null,Object? name = freezed,Object? isIncoming = null,Object? isAccepted = null,Object? duration = null,Object? occurredAt = null,Object? createdAt = null,}) {
|
||||
return _then(_CallHistoryEntity(
|
||||
deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isIncoming: null == isIncoming ? _self.isIncoming : isIncoming // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isAccepted: null == isAccepted ? _self.isAccepted : isAccepted // ignore: cast_nullable_to_non_nullable
|
||||
as bool,duration: null == duration ? _self.duration : duration // ignore: cast_nullable_to_non_nullable
|
||||
as int,occurredAt: null == occurredAt ? _self.occurredAt : occurredAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,32 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'call_history_response_model.freezed.dart';
|
||||
part 'call_history_response_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class CallHistoryResponseModel with _$CallHistoryResponseModel {
|
||||
const factory CallHistoryResponseModel({
|
||||
required int total,
|
||||
required List<CallHistoryItemModel> items,
|
||||
}) = _CallHistoryResponseModel;
|
||||
|
||||
factory CallHistoryResponseModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$CallHistoryResponseModelFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class CallHistoryItemModel with _$CallHistoryItemModel {
|
||||
const factory CallHistoryItemModel({
|
||||
required String deviceIdentificator,
|
||||
required String phone,
|
||||
String? name,
|
||||
required bool isIncoming,
|
||||
required bool isAccepted,
|
||||
required int duration,
|
||||
required int occurredAt,
|
||||
required int createdAt,
|
||||
}) = _CallHistoryItemModel;
|
||||
|
||||
factory CallHistoryItemModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$CallHistoryItemModelFromJson(json);
|
||||
}
|
||||
@@ -0,0 +1,570 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||
|
||||
part of 'call_history_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CallHistoryResponseModel {
|
||||
|
||||
int get total; List<CallHistoryItemModel> get items;
|
||||
/// Create a copy of CallHistoryResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$CallHistoryResponseModelCopyWith<CallHistoryResponseModel> get copyWith => _$CallHistoryResponseModelCopyWithImpl<CallHistoryResponseModel>(this as CallHistoryResponseModel, _$identity);
|
||||
|
||||
/// Serializes this CallHistoryResponseModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is CallHistoryResponseModel&&(identical(other.total, total) || other.total == total)&&const DeepCollectionEquality().equals(other.items, items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,const DeepCollectionEquality().hash(items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CallHistoryResponseModel(total: $total, items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $CallHistoryResponseModelCopyWith<$Res> {
|
||||
factory $CallHistoryResponseModelCopyWith(CallHistoryResponseModel value, $Res Function(CallHistoryResponseModel) _then) = _$CallHistoryResponseModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
int total, List<CallHistoryItemModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$CallHistoryResponseModelCopyWithImpl<$Res>
|
||||
implements $CallHistoryResponseModelCopyWith<$Res> {
|
||||
_$CallHistoryResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final CallHistoryResponseModel _self;
|
||||
final $Res Function(CallHistoryResponseModel) _then;
|
||||
|
||||
/// Create a copy of CallHistoryResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? total = null,Object? items = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self.items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<CallHistoryItemModel>,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [CallHistoryResponseModel].
|
||||
extension CallHistoryResponseModelPatterns on CallHistoryResponseModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CallHistoryResponseModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CallHistoryResponseModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryResponseModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CallHistoryResponseModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryResponseModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int total, List<CallHistoryItemModel> items)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryResponseModel() when $default != null:
|
||||
return $default(_that.total,_that.items);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int total, List<CallHistoryItemModel> items) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryResponseModel():
|
||||
return $default(_that.total,_that.items);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int total, List<CallHistoryItemModel> items)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryResponseModel() when $default != null:
|
||||
return $default(_that.total,_that.items);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _CallHistoryResponseModel implements CallHistoryResponseModel {
|
||||
const _CallHistoryResponseModel({required this.total, required final List<CallHistoryItemModel> items}): _items = items;
|
||||
factory _CallHistoryResponseModel.fromJson(Map<String, dynamic> json) => _$CallHistoryResponseModelFromJson(json);
|
||||
|
||||
@override final int total;
|
||||
final List<CallHistoryItemModel> _items;
|
||||
@override List<CallHistoryItemModel> get items {
|
||||
if (_items is EqualUnmodifiableListView) return _items;
|
||||
// ignore: implicit_dynamic_type
|
||||
return EqualUnmodifiableListView(_items);
|
||||
}
|
||||
|
||||
|
||||
/// Create a copy of CallHistoryResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$CallHistoryResponseModelCopyWith<_CallHistoryResponseModel> get copyWith => __$CallHistoryResponseModelCopyWithImpl<_CallHistoryResponseModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$CallHistoryResponseModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CallHistoryResponseModel&&(identical(other.total, total) || other.total == total)&&const DeepCollectionEquality().equals(other._items, _items));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,total,const DeepCollectionEquality().hash(_items));
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CallHistoryResponseModel(total: $total, items: $items)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$CallHistoryResponseModelCopyWith<$Res> implements $CallHistoryResponseModelCopyWith<$Res> {
|
||||
factory _$CallHistoryResponseModelCopyWith(_CallHistoryResponseModel value, $Res Function(_CallHistoryResponseModel) _then) = __$CallHistoryResponseModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
int total, List<CallHistoryItemModel> items
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$CallHistoryResponseModelCopyWithImpl<$Res>
|
||||
implements _$CallHistoryResponseModelCopyWith<$Res> {
|
||||
__$CallHistoryResponseModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _CallHistoryResponseModel _self;
|
||||
final $Res Function(_CallHistoryResponseModel) _then;
|
||||
|
||||
/// Create a copy of CallHistoryResponseModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? total = null,Object? items = null,}) {
|
||||
return _then(_CallHistoryResponseModel(
|
||||
total: null == total ? _self.total : total // ignore: cast_nullable_to_non_nullable
|
||||
as int,items: null == items ? _self._items : items // ignore: cast_nullable_to_non_nullable
|
||||
as List<CallHistoryItemModel>,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CallHistoryItemModel {
|
||||
|
||||
String get deviceIdentificator; String get phone; String? get name; bool get isIncoming; bool get isAccepted; int get duration; int get occurredAt; int get createdAt;
|
||||
/// Create a copy of CallHistoryItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$CallHistoryItemModelCopyWith<CallHistoryItemModel> get copyWith => _$CallHistoryItemModelCopyWithImpl<CallHistoryItemModel>(this as CallHistoryItemModel, _$identity);
|
||||
|
||||
/// Serializes this CallHistoryItemModel to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is CallHistoryItemModel&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.name, name) || other.name == name)&&(identical(other.isIncoming, isIncoming) || other.isIncoming == isIncoming)&&(identical(other.isAccepted, isAccepted) || other.isAccepted == isAccepted)&&(identical(other.duration, duration) || other.duration == duration)&&(identical(other.occurredAt, occurredAt) || other.occurredAt == occurredAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,deviceIdentificator,phone,name,isIncoming,isAccepted,duration,occurredAt,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CallHistoryItemModel(deviceIdentificator: $deviceIdentificator, phone: $phone, name: $name, isIncoming: $isIncoming, isAccepted: $isAccepted, duration: $duration, occurredAt: $occurredAt, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $CallHistoryItemModelCopyWith<$Res> {
|
||||
factory $CallHistoryItemModelCopyWith(CallHistoryItemModel value, $Res Function(CallHistoryItemModel) _then) = _$CallHistoryItemModelCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$CallHistoryItemModelCopyWithImpl<$Res>
|
||||
implements $CallHistoryItemModelCopyWith<$Res> {
|
||||
_$CallHistoryItemModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final CallHistoryItemModel _self;
|
||||
final $Res Function(CallHistoryItemModel) _then;
|
||||
|
||||
/// Create a copy of CallHistoryItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? deviceIdentificator = null,Object? phone = null,Object? name = freezed,Object? isIncoming = null,Object? isAccepted = null,Object? duration = null,Object? occurredAt = null,Object? createdAt = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isIncoming: null == isIncoming ? _self.isIncoming : isIncoming // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isAccepted: null == isAccepted ? _self.isAccepted : isAccepted // ignore: cast_nullable_to_non_nullable
|
||||
as bool,duration: null == duration ? _self.duration : duration // ignore: cast_nullable_to_non_nullable
|
||||
as int,occurredAt: null == occurredAt ? _self.occurredAt : occurredAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [CallHistoryItemModel].
|
||||
extension CallHistoryItemModelPatterns on CallHistoryItemModel {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _CallHistoryItemModel value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryItemModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _CallHistoryItemModel value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryItemModel():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _CallHistoryItemModel value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryItemModel() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryItemModel() when $default != null:
|
||||
return $default(_that.deviceIdentificator,_that.phone,_that.name,_that.isIncoming,_that.isAccepted,_that.duration,_that.occurredAt,_that.createdAt);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryItemModel():
|
||||
return $default(_that.deviceIdentificator,_that.phone,_that.name,_that.isIncoming,_that.isAccepted,_that.duration,_that.occurredAt,_that.createdAt);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _CallHistoryItemModel() when $default != null:
|
||||
return $default(_that.deviceIdentificator,_that.phone,_that.name,_that.isIncoming,_that.isAccepted,_that.duration,_that.occurredAt,_that.createdAt);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _CallHistoryItemModel implements CallHistoryItemModel {
|
||||
const _CallHistoryItemModel({required this.deviceIdentificator, required this.phone, this.name, required this.isIncoming, required this.isAccepted, required this.duration, required this.occurredAt, required this.createdAt});
|
||||
factory _CallHistoryItemModel.fromJson(Map<String, dynamic> json) => _$CallHistoryItemModelFromJson(json);
|
||||
|
||||
@override final String deviceIdentificator;
|
||||
@override final String phone;
|
||||
@override final String? name;
|
||||
@override final bool isIncoming;
|
||||
@override final bool isAccepted;
|
||||
@override final int duration;
|
||||
@override final int occurredAt;
|
||||
@override final int createdAt;
|
||||
|
||||
/// Create a copy of CallHistoryItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$CallHistoryItemModelCopyWith<_CallHistoryItemModel> get copyWith => __$CallHistoryItemModelCopyWithImpl<_CallHistoryItemModel>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$CallHistoryItemModelToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CallHistoryItemModel&&(identical(other.deviceIdentificator, deviceIdentificator) || other.deviceIdentificator == deviceIdentificator)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.name, name) || other.name == name)&&(identical(other.isIncoming, isIncoming) || other.isIncoming == isIncoming)&&(identical(other.isAccepted, isAccepted) || other.isAccepted == isAccepted)&&(identical(other.duration, duration) || other.duration == duration)&&(identical(other.occurredAt, occurredAt) || other.occurredAt == occurredAt)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,deviceIdentificator,phone,name,isIncoming,isAccepted,duration,occurredAt,createdAt);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CallHistoryItemModel(deviceIdentificator: $deviceIdentificator, phone: $phone, name: $name, isIncoming: $isIncoming, isAccepted: $isAccepted, duration: $duration, occurredAt: $occurredAt, createdAt: $createdAt)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$CallHistoryItemModelCopyWith<$Res> implements $CallHistoryItemModelCopyWith<$Res> {
|
||||
factory _$CallHistoryItemModelCopyWith(_CallHistoryItemModel value, $Res Function(_CallHistoryItemModel) _then) = __$CallHistoryItemModelCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String deviceIdentificator, String phone, String? name, bool isIncoming, bool isAccepted, int duration, int occurredAt, int createdAt
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$CallHistoryItemModelCopyWithImpl<$Res>
|
||||
implements _$CallHistoryItemModelCopyWith<$Res> {
|
||||
__$CallHistoryItemModelCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _CallHistoryItemModel _self;
|
||||
final $Res Function(_CallHistoryItemModel) _then;
|
||||
|
||||
/// Create a copy of CallHistoryItemModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? deviceIdentificator = null,Object? phone = null,Object? name = freezed,Object? isIncoming = null,Object? isAccepted = null,Object? duration = null,Object? occurredAt = null,Object? createdAt = null,}) {
|
||||
return _then(_CallHistoryItemModel(
|
||||
deviceIdentificator: null == deviceIdentificator ? _self.deviceIdentificator : deviceIdentificator // ignore: cast_nullable_to_non_nullable
|
||||
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
|
||||
as String,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable
|
||||
as String?,isIncoming: null == isIncoming ? _self.isIncoming : isIncoming // ignore: cast_nullable_to_non_nullable
|
||||
as bool,isAccepted: null == isAccepted ? _self.isAccepted : isAccepted // ignore: cast_nullable_to_non_nullable
|
||||
as bool,duration: null == duration ? _self.duration : duration // ignore: cast_nullable_to_non_nullable
|
||||
as int,occurredAt: null == occurredAt ? _self.occurredAt : occurredAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
@@ -0,0 +1,46 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'call_history_response_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_CallHistoryResponseModel _$CallHistoryResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _CallHistoryResponseModel(
|
||||
total: (json['total'] as num).toInt(),
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => CallHistoryItemModel.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CallHistoryResponseModelToJson(
|
||||
_CallHistoryResponseModel instance,
|
||||
) => <String, dynamic>{'total': instance.total, 'items': instance.items};
|
||||
|
||||
_CallHistoryItemModel _$CallHistoryItemModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _CallHistoryItemModel(
|
||||
deviceIdentificator: json['deviceIdentificator'] as String,
|
||||
phone: json['phone'] as String,
|
||||
name: json['name'] as String?,
|
||||
isIncoming: json['isIncoming'] as bool,
|
||||
isAccepted: json['isAccepted'] as bool,
|
||||
duration: (json['duration'] as num).toInt(),
|
||||
occurredAt: (json['occurredAt'] as num).toInt(),
|
||||
createdAt: (json['createdAt'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CallHistoryItemModelToJson(
|
||||
_CallHistoryItemModel instance,
|
||||
) => <String, dynamic>{
|
||||
'deviceIdentificator': instance.deviceIdentificator,
|
||||
'phone': instance.phone,
|
||||
'name': instance.name,
|
||||
'isIncoming': instance.isIncoming,
|
||||
'isAccepted': instance.isAccepted,
|
||||
'duration': instance.duration,
|
||||
'occurredAt': instance.occurredAt,
|
||||
'createdAt': instance.createdAt,
|
||||
};
|
||||
@@ -0,0 +1,321 @@
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
import 'package:sf_localizations/sf_localizations.dart';
|
||||
|
||||
import '../data/call_history_entity.dart';
|
||||
import 'state/call_history_view_model.dart';
|
||||
import 'state/call_history_view_state.dart';
|
||||
|
||||
class CallHistoryScreen extends ConsumerWidget {
|
||||
const CallHistoryScreen({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = ref.watch(themePortProvider);
|
||||
final state = ref.watch(callHistoryViewModelProvider);
|
||||
final vm = ref.read(callHistoryViewModelProvider.notifier);
|
||||
final filtered = state.filteredCalls;
|
||||
|
||||
return LegacyPageLayout(
|
||||
theme: theme,
|
||||
title: context.translate(I18n.callHistory),
|
||||
body: state.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: state.errorMessage.isNotEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.error_outline,
|
||||
size: 64, color: Colors.grey.shade300),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
state.errorMessage,
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade500, fontSize: 14),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
_FilterBar(
|
||||
selected: state.filter,
|
||||
onChanged: vm.setFilter,
|
||||
),
|
||||
Expanded(
|
||||
child: filtered.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.phone_missed_outlined,
|
||||
size: 64,
|
||||
color: Colors.grey.shade300),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
context
|
||||
.translate(I18n.callHistoryEmpty),
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade500,
|
||||
fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 16, vertical: 4),
|
||||
itemCount: filtered.length,
|
||||
itemBuilder: (context, index) {
|
||||
final call = filtered[index];
|
||||
final showDateHeader = index == 0 ||
|
||||
!_isSameDay(
|
||||
filtered[index - 1].occurredAt,
|
||||
call.occurredAt,
|
||||
);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (showDateHeader)
|
||||
_DateHeader(
|
||||
timestamp: call.occurredAt),
|
||||
_CallTile(
|
||||
call: call,
|
||||
primaryColor: theme.getColorFor(
|
||||
ThemeCode.legacyPrimary),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static bool _isSameDay(int ts1, int ts2) {
|
||||
final d1 = DateTime.fromMillisecondsSinceEpoch(ts1);
|
||||
final d2 = DateTime.fromMillisecondsSinceEpoch(ts2);
|
||||
return d1.year == d2.year && d1.month == d2.month && d1.day == d2.day;
|
||||
}
|
||||
}
|
||||
|
||||
class _FilterBar extends StatelessWidget {
|
||||
final CallFilter selected;
|
||||
final ValueChanged<CallFilter> onChanged;
|
||||
|
||||
const _FilterBar({required this.selected, required this.onChanged});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final filters = CallFilter.values;
|
||||
final selectedIndex = filters.indexOf(selected);
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
padding: const EdgeInsets.all(4),
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade200,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final tabWidth = constraints.maxWidth / filters.length;
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
AnimatedPositioned(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
left: selectedIndex * tabWidth,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
width: tabWidth,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.08),
|
||||
blurRadius: 4,
|
||||
offset: const Offset(0, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: filters.map((filter) {
|
||||
final isSelected = filter == selected;
|
||||
final label = switch (filter) {
|
||||
CallFilter.all =>
|
||||
context.translate(I18n.locationListAll),
|
||||
CallFilter.incoming =>
|
||||
context.translate(I18n.callIncoming),
|
||||
CallFilter.outgoing =>
|
||||
context.translate(I18n.callOutgoing),
|
||||
CallFilter.missed =>
|
||||
context.translate(I18n.callMissed),
|
||||
};
|
||||
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () => onChanged(filter),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
child: Center(
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: isSelected
|
||||
? FontWeight.w600
|
||||
: FontWeight.w500,
|
||||
color: isSelected
|
||||
? Colors.black87
|
||||
: Colors.grey.shade600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DateHeader extends StatelessWidget {
|
||||
final int timestamp;
|
||||
|
||||
const _DateHeader({required this.timestamp});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final date = DateTime.fromMillisecondsSinceEpoch(timestamp);
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final dateDay = DateTime(date.year, date.month, date.day);
|
||||
final diff = today.difference(dateDay).inDays;
|
||||
|
||||
String label;
|
||||
if (diff == 0) {
|
||||
label = context.translate(I18n.today);
|
||||
} else if (diff == 1) {
|
||||
label = context.translate(I18n.yesterday);
|
||||
} else {
|
||||
label =
|
||||
'${date.day.toString().padLeft(2, '0')}/${date.month.toString().padLeft(2, '0')}/${date.year}';
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 12, bottom: 6, left: 4),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.grey.shade500,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _CallTile extends StatelessWidget {
|
||||
final CallHistoryEntity call;
|
||||
final Color primaryColor;
|
||||
|
||||
const _CallTile({required this.call, required this.primaryColor});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final date = DateTime.fromMillisecondsSinceEpoch(call.occurredAt);
|
||||
final timeStr =
|
||||
'${date.hour.toString().padLeft(2, '0')}:${date.minute.toString().padLeft(2, '0')}';
|
||||
|
||||
final displayName = call.name ?? call.phone;
|
||||
final subtitle = call.name != null ? call.phone : null;
|
||||
|
||||
final durationMin = call.duration ~/ 60;
|
||||
final durationSec = call.duration % 60;
|
||||
final durationStr = durationMin > 0
|
||||
? '${durationMin}m ${durationSec}s'
|
||||
: '${durationSec}s';
|
||||
|
||||
final isAccepted = call.isAccepted;
|
||||
final isIncoming = call.isIncoming;
|
||||
|
||||
final IconData icon;
|
||||
final Color iconColor;
|
||||
if (!isAccepted) {
|
||||
icon = isIncoming ? Icons.phone_missed : Icons.phone_disabled;
|
||||
iconColor = Colors.red;
|
||||
} else {
|
||||
icon = isIncoming ? Icons.call_received : Icons.call_made;
|
||||
iconColor = primaryColor;
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 2),
|
||||
child: ListTile(
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
leading: Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: iconColor.withValues(alpha: 0.08),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(icon, color: iconColor, size: 22),
|
||||
),
|
||||
title: Text(
|
||||
displayName,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isAccepted ? Colors.black87 : Colors.red.shade700,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
Icon(
|
||||
isIncoming ? Icons.south_west : Icons.north_east,
|
||||
size: 12,
|
||||
color: iconColor.withValues(alpha: 0.7),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
if (subtitle != null) ...[
|
||||
Text(subtitle,
|
||||
style:
|
||||
TextStyle(fontSize: 12, color: Colors.grey.shade600)),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
if (isAccepted)
|
||||
Text(durationStr,
|
||||
style:
|
||||
TextStyle(fontSize: 12, color: Colors.grey.shade500)),
|
||||
],
|
||||
),
|
||||
trailing: Text(
|
||||
timeStr,
|
||||
style: TextStyle(fontSize: 13, color: Colors.grey.shade500),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:legacy_shared/legacy_shared.dart';
|
||||
|
||||
import '../../data/call_history_datasource.dart';
|
||||
import '../../data/call_history_datasource_provider.dart';
|
||||
import '../../data/call_history_entity.dart';
|
||||
import 'call_history_view_state.dart';
|
||||
|
||||
final callHistoryViewModelProvider =
|
||||
NotifierProvider.autoDispose<CallHistoryViewModel, CallHistoryViewState>(
|
||||
CallHistoryViewModel.new,
|
||||
);
|
||||
|
||||
class CallHistoryViewModel extends Notifier<CallHistoryViewState> {
|
||||
late final CallHistoryDatasource _datasource;
|
||||
|
||||
@override
|
||||
CallHistoryViewState build() {
|
||||
_datasource = ref.read(callHistoryDatasourceProvider);
|
||||
Future.microtask(() => _load());
|
||||
return const CallHistoryViewState();
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
final device = ref.read(selectedDeviceProvider);
|
||||
if (device == null) {
|
||||
state = state.copyWith(isLoading: false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final calls = await _datasource.getCallHistory(
|
||||
deviceIdentificator: device.identificator,
|
||||
);
|
||||
if (!ref.mounted) return;
|
||||
|
||||
state = state.copyWith(
|
||||
calls: calls,
|
||||
filteredCalls: calls,
|
||||
isLoading: false,
|
||||
);
|
||||
} catch (e) {
|
||||
if (!ref.mounted) return;
|
||||
state = state.copyWith(
|
||||
isLoading: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void setFilter(CallFilter filter) {
|
||||
state = state.copyWith(
|
||||
filter: filter,
|
||||
filteredCalls: _applyFilter(state.calls, filter),
|
||||
);
|
||||
}
|
||||
|
||||
List<CallHistoryEntity> _applyFilter(
|
||||
List<CallHistoryEntity> calls, CallFilter filter) {
|
||||
switch (filter) {
|
||||
case CallFilter.all:
|
||||
return calls;
|
||||
case CallFilter.incoming:
|
||||
return calls.where((c) => c.isIncoming).toList();
|
||||
case CallFilter.outgoing:
|
||||
return calls.where((c) => !c.isIncoming).toList();
|
||||
case CallFilter.missed:
|
||||
return calls.where((c) => !c.isAccepted).toList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
import '../../data/call_history_entity.dart';
|
||||
|
||||
part 'call_history_view_state.freezed.dart';
|
||||
|
||||
enum CallFilter { all, incoming, outgoing, missed }
|
||||
|
||||
@freezed
|
||||
abstract class CallHistoryViewState with _$CallHistoryViewState {
|
||||
const factory CallHistoryViewState({
|
||||
@Default(true) bool isLoading,
|
||||
@Default([]) List<CallHistoryEntity> calls,
|
||||
@Default([]) List<CallHistoryEntity> filteredCalls,
|
||||
@Default(CallFilter.all) CallFilter filter,
|
||||
@Default('') String errorMessage,
|
||||
}) = _CallHistoryViewState;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user