Compare commits

...

30 Commits

Author SHA1 Message Date
ecb9d7316e fix: resize ui 2026-03-26 19:09:09 +01:00
1810dc6e2a fix 2026-03-25 18:53:21 +01:00
4d2d25f47b fix 2026-03-25 16:39:47 +01:00
c79cbeffcc bump build to 6 2026-03-25 14:43:27 +01:00
b7614a39f1 feat: sync device settings after updates and improve remote connection features
- Add DeviceSettingsSync extension on Ref to centralize device provider
    updates after settings changes (sound, volume, language, timezone,
    battery, disable functions, alerts, pedometer, heart rate freq,
    location freq, background image)
  - Add photo capture countdown with Lottie animation in remote camera
  - Replace Image.network with Image.memory for photo display
  - Fix commands datasource to handle text/html responses (post<dynamic>)
  - Add typed error/success events to RemoteConnectionViewModel
  - Add background image active indicator and backgroundImageId to device settings
  - Change photos endpoint from /devices/identificator/:id/photos/files to /photos/files
  - Remove dead deviceId param from getBackgroundImage chain
  - Relax PictureEntity required fields to @Default for API compatibility
  - Fix LocationViewModel rebuild crash (ref.watch → ref.read)
  - Use .select() in RemoteCameraScreen for optimized rebuilds
  - Increase health measure countdown to 60s
2026-03-25 13:51:48 +01:00
a05c167f30 fix 2026-03-25 06:11:48 +01:00
c1c903ac93 feat: add country code picker to call watch dialog 2026-03-25 06:06:33 +01:00
a0a782c91b clean 2026-03-25 05:46:49 +01:00
c140daa7ae refactor: extract timezone data, remove duplicate i18n keys 2026-03-25 05:45:05 +01:00
6d30a59651 feat: implement alerts, disable functions, and battery night mode settings
- Rename sms_alert feature to alerts with toggle list from device capabilities
  - Implement disable functions (keyboard, GPS) with device settings update
  - Implement battery night mode with dedicated view model
  - Add keyboard, gps, nightMode fields to DeviceSettingsEntity/Model
  - Fix photos endpoint to use /photos/files for file content
2026-03-25 05:03:40 +01:00
8d453dc980 feature/background-image into fusion-app with fixes
- Fix upload flow: capture photo ID from POST /photos response
  - Fix endpoint: use /devices/identificator/{id}/photos/files for listing
  - Fix setBackgroundImage: use device.id (UUID) instead of identificator
  - Redesign screen as photo gallery with grid view
  - Add image compression on pick (maxWidth: 800, quality: 80%)
  - Fix multipart upload: remove content-type header for FormData auto-detection
  - Replace hardcoded Spanish text with i18n in 6 languages
  - Add typed error/success enums (BackgroundImageErrorEvent, BackgroundImageSuccessEvent)
  - Revert initialLocation to splash
  - Add missing translations for contacts and background-image features
2026-03-25 03:52:24 +01:00
0a50de3d70 Merge remote-tracking branch 'origin/feature/contacts' into fusion-app 2026-03-25 02:30:09 +01:00
02053182db Merge remote-tracking branch 'origin/feature/linked-devices' into fusion-app 2026-03-25 02:22:48 +01:00
33f3dfa252 feat: type device settings and capabilities, centralize device updates, and improve error handling
- Type device.settings and device.capabilities from untyped maps to Freezed models
  - Centralize all device settings updates through shared DeviceSettingsUpdateDatasource
  - Add frequency selectors for location and heart rate, pedometer toggle, and health measurement countdown with Lottie animation
  - Replace raw backend error messages with typed i18n error events across location, health, and activity meter
  - Fix silent error swallowing in commands datasource and stuck dialog in locate device
2026-03-25 02:15:25 +01:00
cb70973d3b feat: change background image 2026-03-24 17:31:49 +01:00
1ffeea8b77 background image screen and state 2026-03-24 11:25:45 +01:00
5f484036f8 feat: contacts upper and lower limits 2026-03-23 15:38:47 +01:00
73927557ca fix: show activation code dialog with qr scan 2026-03-23 13:58:59 +01:00
5111d5d65f feat: add call history screen
- Add call history screen with list of incoming/outgoing calls
  - Implement GET /devices/identificator/{id}/call-histories endpoint
  - Add CallHistoryResponseModel with freezed
  - Add Riverpod provider for CallHistoryDatasource
  - Add route, builder, and menu button in device management
2026-03-22 05:50:20 +01:00
ced0895063 feat: merge health feature and add measure command
- Add REQUEST_HEART_RATE command with measure button in health screen
  - Add ref.mounted checks and fix early return in measure()
  - Remove unused SET_LANGUAGE from DeviceCommand enum
2026-03-22 05:15:22 +01:00
34e7a7c60f feat: merge remote-call feature and fix remote connection
- Implement photos API (GET /devices/identificator/{id}/photos)
  - Fix deviceId empty in commands (set before async load)
  - Fix missing await in call() method
  - Add ref.mounted checks on all async operations
  - Reload photos after REQUEST_PHOTO command
  - Add CountryPrefixPicker to spy call dialog
  - Add loading state and topSnackbar feedback on call
  - Handle empty photos list in gallery
  - Fix Expanded overflow in remote camera screen
  - Change keyboard to phone type in spy call
  - Remove unnecessary use cases
  - Add GetPicturesResponseModel with freezed
2026-03-22 04:57:38 +01:00
c89f1c666e feat: add volume control and merge sound mode feature
- Add volume control screen with sliders for media, ringtone, and alarm
- Update device settings via PUT /devices with CSV (same as language)
- Extract DeviceCsvBuilder to legacy_shared (shared between language and volume)
- Create Riverpod provider for DeviceUpdateDatasource
- Extract VolumeThumbShape to separate widget file
- Merge sound mode feature (SET_SOUND_MODE command, pending backend whitelist)
- Fix sound screen overflow with SingleChildScrollView
2026-03-22 04:01:09 +01:00
33c2403aef fix: improve language feature and fix merge issues
- Change language update from POST /commands to PUT /devices with CSV
- Add CSV escape for JSON fields (doubled quotes)
- Move device payload construction to datasource layer
- Add loading indicator on save button
- Fix 401 redirect to legacy login
- Remove debug print from commands datasource
2026-03-22 03:16:07 +01:00
0088d146f0 feat: enhance location map with route history, animations, follow mode, and fix API models
- Fix position address model nullability (province field missing from API)
  - Fix health query order to sortDirection to match backend API
  - Add pagination to health chart queries to prevent backend timeout
  - Align GetDevicesResponseModel with full backend schema
  - Add route history with gradient polyline, direction arrows, and clustering
  - Add animated map movements
  - Add follow mode with auto-refresh
  - Add share location via Google Maps link
  - Add fit bounds on history load
  - Add expandable action buttons panel
  - Add location list bottom sheet with type filters
  - Add whitelist sync alongside secondary contacts
  - Add loading state to linked devices screen
  - Refactor location_map.dart: extract RouteHistoryLayer, MapActionsPanel
  - Migrate setState to LocationMapViewModel
2026-03-22 02:30:21 +01:00
94c042d403 manual health measurement command 2026-03-20 15:35:12 +01:00
e526dce2c9 change language options and fix command 2026-03-20 10:41:03 +01:00
cacc2460f1 Merge branch 'fusion-app' into feature/language 2026-03-20 09:34:47 +01:00
dd53db6795 set language 2026-03-20 09:33:57 +01:00
435a9c04f9 bump build to 5 2026-03-18 21:00:03 +01:00
8e3a27e0d3 feat: add route history, map controls, and geofence/FP management
- Position history with polyline trail and date range picker
  - Map style selector (standard, voyager, light, dark, satellite) persisted via SharedPreferences
  - Geofence and frequent place CRUD with info cards
  - Device banner with swipeable carousel
  - Refresh position button
  - Widget extraction: map controls, info cards, device banner, modal overlay
2026-03-18 19:48:30 +01:00
269 changed files with 29543 additions and 2000 deletions

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

View File

@@ -6,6 +6,8 @@ PODS:
- Flutter - Flutter
- flutter_treezor_entrust_sdk_bridge (0.0.1): - flutter_treezor_entrust_sdk_bridge (0.0.1):
- Flutter - Flutter
- image_picker_ios (0.0.1):
- Flutter
- mobile_scanner (7.0.0): - mobile_scanner (7.0.0):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
@@ -14,6 +16,8 @@ PODS:
- FlutterMacOS - FlutterMacOS
- permission_handler_apple (9.3.0): - permission_handler_apple (9.3.0):
- Flutter - Flutter
- share_plus (0.0.1):
- Flutter
- shared_preferences_foundation (0.0.1): - shared_preferences_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
@@ -28,9 +32,11 @@ DEPENDENCIES:
- flutter_contacts (from `.symlinks/plugins/flutter_contacts/ios`) - flutter_contacts (from `.symlinks/plugins/flutter_contacts/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/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`) - 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`) - mobile_scanner (from `.symlinks/plugins/mobile_scanner/darwin`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - 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`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`) - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)
@@ -44,12 +50,16 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_native_splash/ios" :path: ".symlinks/plugins/flutter_native_splash/ios"
flutter_treezor_entrust_sdk_bridge: flutter_treezor_entrust_sdk_bridge:
:path: ".symlinks/plugins/flutter_treezor_entrust_sdk_bridge/ios" :path: ".symlinks/plugins/flutter_treezor_entrust_sdk_bridge/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
mobile_scanner: mobile_scanner:
:path: ".symlinks/plugins/mobile_scanner/darwin" :path: ".symlinks/plugins/mobile_scanner/darwin"
path_provider_foundation: path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin" :path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple: permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios" :path: ".symlinks/plugins/permission_handler_apple/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation: shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin" :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
url_launcher_ios: url_launcher_ios:
@@ -62,9 +72,11 @@ SPEC CHECKSUMS:
flutter_contacts: edb1c5ce76aa433e20e6cb14c615f4c0b66e0983 flutter_contacts: edb1c5ce76aa433e20e6cb14c615f4c0b66e0983
flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29 flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29
flutter_treezor_entrust_sdk_bridge: 4c2c94fb74ab57576e8d49f5f2a4b214e41141fe flutter_treezor_entrust_sdk_bridge: 4c2c94fb74ab57576e8d49f5f2a4b214e41141fe
image_picker_ios: 4f2f91b01abdb52842a8e277617df877e40f905b
mobile_scanner: 77265f3dc8d580810e91849d4a0811a90467ed5e mobile_scanner: 77265f3dc8d580810e91849d4a0811a90467ed5e
path_provider_foundation: 0b743cbb62d8e47eab856f09262bb8c1ddcfe6ba path_provider_foundation: 0b743cbb62d8e47eab856f09262bb8c1ddcfe6ba
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6 shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6
url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa
webview_flutter_wkwebview: 29eb20d43355b48fe7d07113835b9128f84e3af4 webview_flutter_wkwebview: 29eb20d43355b48fe7d07113835b9128f84e3af4

View File

@@ -543,7 +543,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-development;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Runner/Runner-development.entitlements"; CODE_SIGN_ENTITLEMENTS = "Runner/Runner-development.entitlements";
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -727,7 +727,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-development;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Runner/Runner-development.entitlements"; CODE_SIGN_ENTITLEMENTS = "Runner/Runner-development.entitlements";
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -751,7 +751,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-development;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Runner/Runner-development.entitlements"; CODE_SIGN_ENTITLEMENTS = "Runner/Runner-development.entitlements";
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -1100,7 +1100,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-staging;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Runner/Runner-staging.entitlements"; CODE_SIGN_ENTITLEMENTS = "Runner/Runner-staging.entitlements";
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -1124,7 +1124,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-production;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -1148,7 +1148,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-staging;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Runner/Runner-staging.entitlements"; CODE_SIGN_ENTITLEMENTS = "Runner/Runner-staging.entitlements";
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -1171,7 +1171,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-production;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -1194,7 +1194,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-staging;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = "Runner/Runner-staging.entitlements"; CODE_SIGN_ENTITLEMENTS = "Runner/Runner-staging.entitlements";
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -1217,7 +1217,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon-production;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";

View File

@@ -30,7 +30,9 @@ Future<void> initApp(EnvironmentEnum env) async {
await configureDependencies( await configureDependencies(
QuestiaEnvConfig(), QuestiaEnvConfig(),
log: env.isDevelopment || kDebugMode, log: env.isDevelopment || kDebugMode,
onTokenExpired: () => appRouter.go(AppRoutes.scaTreezor), onTokenExpired: () => appRouter.go(
AppRoutes.legacyLogin,
), //change to payments app to AppRoutes.scaTreezor
onUnauthorized: () async { onUnauthorized: () async {
final currentLocation = final currentLocation =
appRouter.routerDelegate.currentConfiguration.uri.path; appRouter.routerDelegate.currentConfiguration.uri.path;
@@ -39,7 +41,7 @@ Future<void> initApp(EnvironmentEnum env) async {
await GetIt.I<TreezorWalletConnectionService>().logout(); await GetIt.I<TreezorWalletConnectionService>().logout();
} catch (_) {} } catch (_) {}
await clearSessionData(); await clearSessionData();
appRouter.go(AppRoutes.login); appRouter.go(AppRoutes.legacyLogin);
}, },
); );

View File

@@ -141,6 +141,21 @@ void configureAppRouter() {
name: 'apps_use', name: 'apps_use',
pageBuilder: const AppsUseBuilder().buildPage, 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,
),
], ],
), ),
], ],
@@ -237,9 +252,9 @@ void configureAppRouter() {
pageBuilder: RemoteOnOffBuilder().buildPage, pageBuilder: RemoteOnOffBuilder().buildPage,
), ),
GoRoute( GoRoute(
path: 'sms_alert', path: 'alerts',
name: 'sms_alert', name: 'alerts',
pageBuilder: SmsAlertBuilder().buildPage, pageBuilder: AlertsBuilder().buildPage,
), ),
GoRoute( GoRoute(
path: 'timezone', path: 'timezone',

View File

@@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:sf_infrastructure/sf_infrastructure.dart'; import 'package:sf_infrastructure/sf_infrastructure.dart';
@@ -35,8 +36,10 @@ class LegacyHeartbeatService {
debugPrint('[LegacyHeartbeat] /auth/me => OK'); debugPrint('[LegacyHeartbeat] /auth/me => OK');
} catch (e) { } catch (e) {
debugPrint('[LegacyHeartbeat] error: $e'); debugPrint('[LegacyHeartbeat] error: $e');
stop(); if (e is DioException && e.response?.statusCode == 401) {
_onUnauthorized(); stop();
_onUnauthorized();
}
} }
} }
} }

View File

@@ -34,7 +34,9 @@ class SaveFamilyAppState extends ConsumerState<SaveFamilyApp>
walletHeartbeat = WalletHeartbeatService( walletHeartbeat = WalletHeartbeatService(
repository: ref.read(treezorRepositoryProvider), repository: ref.read(treezorRepositoryProvider),
sessionLocal: SessionLocalDatasourceImpl(), sessionLocal: SessionLocalDatasourceImpl(),
onError: () => appRouter.go(AppRoutes.scaTreezor), onError: () => appRouter.go(
AppRoutes.legacyLogin,
), //change to payments app to AppRoutes.scaTreezor
); );
legacyHeartbeat = LegacyHeartbeatService( legacyHeartbeat = LegacyHeartbeatService(
repository: GetIt.I<QuestiaRepository>(), repository: GetIt.I<QuestiaRepository>(),

View File

@@ -0,0 +1 @@
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/file_selector_linux-0.9.4/

View File

@@ -0,0 +1 @@
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/image_picker_linux-0.2.2/

View File

@@ -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/

View File

@@ -0,0 +1 @@
/Users/juliandalcalaf/.pub-cache/hosted/pub.dev/share_plus-10.1.4/

View File

@@ -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/

View File

@@ -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/

View File

@@ -6,9 +6,13 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <file_selector_linux/file_selector_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) { 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 = g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);

View File

@@ -3,6 +3,7 @@
# #
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
file_selector_linux
url_launcher_linux url_launcher_linux
) )

View File

@@ -245,6 +245,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.15.0" 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: crypto:
dependency: transitive dependency: transitive
description: description:
@@ -385,6 +393,38 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "7.0.1" 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: fixnum:
dependency: transitive dependency: transitive
description: description:
@@ -451,6 +491,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.4.7" 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: flutter_riverpod:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -602,6 +650,70 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.8.0" 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: intl:
dependency: transitive dependency: transitive
description: description:
@@ -1117,6 +1229,22 @@ packages:
relative: true relative: true
source: path source: path
version: "0.0.1" 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: shared_preferences:
dependency: transitive dependency: transitive
description: description:
@@ -1560,6 +1688,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.23.8" version: "3.23.8"
win32:
dependency: transitive
description:
name: win32
sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e
url: "https://pub.dev"
source: hosted
version: "5.15.0"
wkt_parser: wkt_parser:
dependency: transitive dependency: transitive
description: description:

View File

@@ -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 # 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 # 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. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+4 version: 1.0.0+6
environment: environment:
sdk: ^3.9.2 sdk: ^3.9.2
@@ -123,6 +123,7 @@ flutter:
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
assets: assets:
- assets/shared/images/ - assets/shared/images/
- assets/shared/animations/
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/to/resolution-aware-images # https://flutter.dev/to/resolution-aware-images

View File

@@ -1 +1 @@
{"version":2,"entries":[{"package":"design_system","rootUri":"../../../packages/design_system/","packageUri":"lib/"},{"package":"flutter_treezor_entrust_sdk_bridge","rootUri":"../../../packages/flutter_treezor_entrust_sdk_bridge/","packageUri":"lib/"},{"package":"fonts","rootUri":"../../../packages/fonts/","packageUri":"lib/"},{"package":"get_it","rootUri":"file:///Users/juliandalcalaf/.pub-cache/hosted/pub.dev/get_it-9.2.0/","packageUri":"lib/","config":{"name":"get_it","issueTracker":"https://github.com/fluttercommunity/get_it/issues","version":"0.0.1","materialIconCodePoint":"0xe189"}},{"package":"sca_treezor","rootUri":"../../../packages/sca_treezor/","packageUri":"lib/"},{"package":"sf_infrastructure","rootUri":"../../../packages/sf_infrastructure/","packageUri":"lib/"},{"package":"sf_localizations","rootUri":"../../../packages/sf_localizations/","packageUri":"lib/"},{"package":"sf_shared","rootUri":"../../../packages/sf_shared/","packageUri":"lib/"},{"package":"shared_preferences","rootUri":"file:///Users/juliandalcalaf/.pub-cache/hosted/pub.dev/shared_preferences-2.5.4/","packageUri":"lib/","config":{"name":"shared_preferences","issueTracker":"https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22","version":"1.0.0","materialIconCodePoint":"0xe683"}},{"package":"utils","rootUri":"../../../packages/utils/","packageUri":"lib/"},{"package":"activity","rootUri":"../","packageUri":"lib/"}]} {"version":2,"entries":[{"package":"design_system","rootUri":"../../../packages/design_system/","packageUri":"lib/"},{"package":"flutter_treezor_entrust_sdk_bridge","rootUri":"../../../packages/flutter_treezor_entrust_sdk_bridge/","packageUri":"lib/"},{"package":"fonts","rootUri":"../../../packages/fonts/","packageUri":"lib/"},{"package":"get_it","rootUri":"file:///C:/Users/Aitor%20Arana/AppData/Local/Pub/Cache/hosted/pub.dev/get_it-9.2.0/","packageUri":"lib/","config":{"name":"get_it","issueTracker":"https://github.com/fluttercommunity/get_it/issues","version":"0.0.1","materialIconCodePoint":"0xe189"}},{"package":"sca_treezor","rootUri":"../../../packages/sca_treezor/","packageUri":"lib/"},{"package":"sf_infrastructure","rootUri":"../../../packages/sf_infrastructure/","packageUri":"lib/"},{"package":"sf_localizations","rootUri":"../../../packages/sf_localizations/","packageUri":"lib/"},{"package":"sf_shared","rootUri":"../../../packages/sf_shared/","packageUri":"lib/"},{"package":"shared_preferences","rootUri":"file:///C:/Users/Aitor%20Arana/AppData/Local/Pub/Cache/hosted/pub.dev/shared_preferences-2.5.4/","packageUri":"lib/","config":{"name":"shared_preferences","issueTracker":"https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22","version":"1.0.0","materialIconCodePoint":"0xe683"}},{"package":"utils","rootUri":"../../../packages/utils/","packageUri":"lib/"},{"package":"activity","rootUri":"../","packageUri":"lib/"}]}

View File

@@ -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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.22\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_android-2.4.20\\\\","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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-16 09:33:25.098373","version":"3.35.6","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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\dev\\\\sf-app-platform\\\\packages\\\\flutter_treezor_entrust_sdk_bridge\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.22\\\\","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_android","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\shared_preferences_android-2.4.20\\\\","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_linux","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.3.0\\\\","native_build":false,"dependencies":[],"dev_dependency":false},{"name":"shared_preferences_windows","path":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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":"C:\\\\Users\\\\Aitor Arana\\\\AppData\\\\Local\\\\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-26 13:15:48.703271","version":"3.35.6","swift_package_manager_enabled":{"ios":false,"macos":false}}

View 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:

View 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:

View File

@@ -32,6 +32,9 @@
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/.dart_tool" /> <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/.pub" />
<excludeFolder url="file://$MODULE_DIR$/packages/legacy_design_system/build" /> <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> </content>
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" /> <orderEntry type="library" name="Dart SDK" level="project" />

View File

@@ -163,9 +163,10 @@ class AccountSettingsScreen extends ConsumerWidget {
onPressed: onPressed, onPressed: onPressed,
icon: Icon( icon: Icon(
icon, icon,
size: SizeUtils.getByScreen(small: 28, big: 26), size: SizeUtils.getByScreen(small: 36, big: 34),
color: color, color: color,
), ),
iconPadding: SizeUtils.getByScreen(small: 12, big: 14),
body: Text( body: Text(
context.translate(text), context.translate(text),
style: TextStyle( style: TextStyle(

View File

@@ -27,21 +27,23 @@ class LinkedDevicesScreen extends ConsumerWidget {
title: context.translate(I18n.linkedDevices), title: context.translate(I18n.linkedDevices),
showEdit: true, showEdit: true,
onEditChange: vm.toggleIsEditing, onEditChange: vm.toggleIsEditing,
body: Padding( body: state.isLoading
padding: EdgeInsets.symmetric(horizontal: SizeUtils.getByScreen(small: 10, big: 12)), ? const Center(child: CircularProgressIndicator())
child: ListView.separated( : Padding(
itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard( padding: EdgeInsets.symmetric(horizontal: SizeUtils.getByScreen(small: 10, big: 12)),
navigationContract: navigationContract, child: ListView.separated(
device: state.linkedDevices[index], itemBuilder: (BuildContext context, int index)=>_LinkedDeviceCard(
isEditing: state.isEditing, navigationContract: navigationContract,
onDelete: ()=>vm.deleteDevice(state.linkedDevices[index]), 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
),
),
); );
} }
} }

View File

@@ -28,6 +28,10 @@ class DeleteDeviceDialog extends ConsumerWidget {
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30), small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
big: EdgeInsets.symmetric(horizontal: 24, vertical: 18) big: EdgeInsets.symmetric(horizontal: 24, vertical: 18)
), ),
decoration: BoxDecoration(
color: theme.getColorFor(ThemeCode.backgroundPrimary),
borderRadius: BorderRadius.all(Radius.circular(14))
),
width: SizeUtils.getByScreen(small: 360, big: 350), width: SizeUtils.getByScreen(small: 360, big: 350),
height: SizeUtils.getByScreen(small: 184, big: 160), height: SizeUtils.getByScreen(small: 184, big: 160),
child: Column( child: Column(

View File

@@ -59,11 +59,11 @@ class PersonalDataScreen extends ConsumerWidget {
const _ProfilePicture(), const _ProfilePicture(),
SizedBox(height: SizeUtils.getByScreen(small: 18, big: 16)), SizedBox(height: SizeUtils.getByScreen(small: 18, big: 16)),
const _EmailLabel(), const _EmailLabel(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)), SizedBox(height: SizeUtils.getByScreen(small: 22, big: 20)),
const _FirstNameField(), const _FirstNameField(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)), SizedBox(height: SizeUtils.getByScreen(small: 22, big: 20)),
const _LastNameField(), const _LastNameField(),
SizedBox(height: SizeUtils.getByScreen(small: 24, big: 22)), SizedBox(height: SizeUtils.getByScreen(small: 22, big: 20)),
const _PhoneField(), const _PhoneField(),
], ],
), ),
@@ -117,7 +117,9 @@ class _EmailLabel extends ConsumerWidget {
), ),
Text( Text(
email, email,
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 18, big: 17)), style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 18, big: 17, xl: 16)
),
), ),
], ],
); );

View File

@@ -1,3 +1,9 @@
export 'src/core/data/models/latest_positions_response_model.dart';
export 'src/core/domain/entities/address_entity.dart';
export 'src/core/domain/entities/network_entity.dart';
export 'src/core/domain/entities/position_entity.dart';
export 'src/core/utils/battery_utils.dart';
export 'src/core/utils/date_format_utils.dart';
export 'src/features/control_panel/control_panel_builder.dart'; export 'src/features/control_panel/control_panel_builder.dart';
export 'src/features/control_panel/presentation/state/control_panel_view_model.dart'; export 'src/features/control_panel/presentation/state/control_panel_view_model.dart';
export 'src/shared/widgets/device_map.dart'; export 'src/shared/widgets/device_map.dart';

View File

@@ -72,11 +72,11 @@ extension LatestPositionsResponseModelMapper on LatestPositionsResponseModel {
@freezed @freezed
abstract class LatestPositionsAddressResponseModel with _$LatestPositionsAddressResponseModel { abstract class LatestPositionsAddressResponseModel with _$LatestPositionsAddressResponseModel {
const factory LatestPositionsAddressResponseModel({ const factory LatestPositionsAddressResponseModel({
required String street, String? street,
required String city, String? city,
required String province, String? province,
required String state, String? state,
required String country, String? country,
}) = _LatestPositionsAddressResponseModel; }) = _LatestPositionsAddressResponseModel;
factory LatestPositionsAddressResponseModel.fromJson(Map<String, dynamic> json) => factory LatestPositionsAddressResponseModel.fromJson(Map<String, dynamic> json) =>

View File

@@ -628,7 +628,7 @@ $LatestPositionsAddressResponseModelCopyWith<$Res>? get address {
/// @nodoc /// @nodoc
mixin _$LatestPositionsAddressResponseModel { 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 /// Create a copy of LatestPositionsAddressResponseModel
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -661,7 +661,7 @@ abstract mixin class $LatestPositionsAddressResponseModelCopyWith<$Res> {
factory $LatestPositionsAddressResponseModelCopyWith(LatestPositionsAddressResponseModel value, $Res Function(LatestPositionsAddressResponseModel) _then) = _$LatestPositionsAddressResponseModelCopyWithImpl; factory $LatestPositionsAddressResponseModelCopyWith(LatestPositionsAddressResponseModel value, $Res Function(LatestPositionsAddressResponseModel) _then) = _$LatestPositionsAddressResponseModelCopyWithImpl;
@useResult @useResult
$Res call({ $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 /// Create a copy of LatestPositionsAddressResponseModel
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_self.copyWith(
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable street: freezed == 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?,city: freezed == 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?,province: freezed == 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?,state: freezed == 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?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
as String, 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) { switch (_that) {
case _LatestPositionsAddressResponseModel() when $default != null: case _LatestPositionsAddressResponseModel() when $default != null:
return $default(_that.street,_that.city,_that.province,_that.state,_that.country);case _: 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) { switch (_that) {
case _LatestPositionsAddressResponseModel(): case _LatestPositionsAddressResponseModel():
return $default(_that.street,_that.city,_that.province,_that.state,_that.country);case _: 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) { switch (_that) {
case _LatestPositionsAddressResponseModel() when $default != null: case _LatestPositionsAddressResponseModel() when $default != null:
return $default(_that.street,_that.city,_that.province,_that.state,_that.country);case _: 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() @JsonSerializable()
class _LatestPositionsAddressResponseModel implements LatestPositionsAddressResponseModel { 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); factory _LatestPositionsAddressResponseModel.fromJson(Map<String, dynamic> json) => _$LatestPositionsAddressResponseModelFromJson(json);
@override final String street; @override final String? street;
@override final String city; @override final String? city;
@override final String province; @override final String? province;
@override final String state; @override final String? state;
@override final String country; @override final String? country;
/// Create a copy of LatestPositionsAddressResponseModel /// Create a copy of LatestPositionsAddressResponseModel
/// with the given fields replaced by the non-null parameter values. /// 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; factory _$LatestPositionsAddressResponseModelCopyWith(_LatestPositionsAddressResponseModel value, $Res Function(_LatestPositionsAddressResponseModel) _then) = __$LatestPositionsAddressResponseModelCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $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 /// Create a copy of LatestPositionsAddressResponseModel
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_LatestPositionsAddressResponseModel(
street: null == street ? _self.street : street // ignore: cast_nullable_to_non_nullable street: freezed == 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?,city: freezed == 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?,province: freezed == 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?,state: freezed == 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?,country: freezed == country ? _self.country : country // ignore: cast_nullable_to_non_nullable
as String, as String?,
)); ));
} }

View File

@@ -81,11 +81,11 @@ Map<String, dynamic> _$LatestPositionsItemResponseModelToJson(
_LatestPositionsAddressResponseModel _LatestPositionsAddressResponseModel
_$LatestPositionsAddressResponseModelFromJson(Map<String, dynamic> json) => _$LatestPositionsAddressResponseModelFromJson(Map<String, dynamic> json) =>
_LatestPositionsAddressResponseModel( _LatestPositionsAddressResponseModel(
street: json['street'] as String, street: json['street'] as String?,
city: json['city'] as String, city: json['city'] as String?,
province: json['province'] as String, province: json['province'] as String?,
state: json['state'] as String, state: json['state'] as String?,
country: json['country'] as String, country: json['country'] as String?,
); );
Map<String, dynamic> _$LatestPositionsAddressResponseModelToJson( Map<String, dynamic> _$LatestPositionsAddressResponseModelToJson(

View File

@@ -254,11 +254,10 @@ class _MapSection extends ConsumerWidget {
SizedBox(height: SizeUtils.getByScreen(small: 4, big: 8)), SizedBox(height: SizeUtils.getByScreen(small: 4, big: 8)),
AbsorbPointer( AbsorbPointer(
child: SizedBox( child: SizedBox(
height: SizeUtils.getByScreen(small: 200, big: 300), height: SizeUtils.getByScreen(small: 260, big: 300),
child: DeviceMap( child: DeviceMap(
selectedPosition: state.selectedPosition, selectedPosition: state.selectedPosition,
selectedDevice: state.selectedDevice, selectedDevice: state.selectedDevice,
markerSize: 40,
), ),
), ),
), ),

View File

@@ -69,8 +69,9 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
final latestPositions = positionLists final latestPositions = positionLists
.where((list) => list.isNotEmpty) .where((list) => list.isNotEmpty)
.map((list) { .map((list) {
final valid = list.where((p) => p.latitude != 0 || p.longitude != 0); final valid = list.where((p) => p.latitude != 0 || p.longitude != 0).toList()
return valid.isNotEmpty ? valid.last : list.last; ..sort((a, b) => b.createdAt.compareTo(a.createdAt));
return valid.isNotEmpty ? valid.first : list.last;
}) })
.toList(); .toList();
@@ -92,6 +93,7 @@ class ControlPanelViewModel extends Notifier<ControlPanelViewState> {
Future<void> refreshPositions() async { Future<void> refreshPositions() async {
if (state.devices.isEmpty) return; if (state.devices.isEmpty) return;
state = state.copyWith(errorMessage: '');
try { try {
final positionLists = await Future.wait( final positionLists = await Future.wait(
state.devices.map( state.devices.map(

View File

@@ -5,25 +5,21 @@ import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart'; import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:latlong2/latlong.dart'; import 'package:latlong2/latlong.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_shared/sf_shared.dart'; import 'package:sf_shared/sf_shared.dart';
import 'package:utils/utils.dart';
const _defaultCenter = LatLng(40.4168, -3.7038); const _defaultCenter = LatLng(40.4168, -3.7038);
const _defaultZoom = 15.0; const _defaultZoom = 15.0;
const _tileServerUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
class DeviceMap extends ConsumerStatefulWidget { class DeviceMap extends ConsumerStatefulWidget {
final PositionEntity? selectedPosition; final PositionEntity? selectedPosition;
final DeviceEntity? selectedDevice; final DeviceEntity? selectedDevice;
final double markerSize;
const DeviceMap({ const DeviceMap({
super.key, super.key,
required this.selectedPosition, required this.selectedPosition,
required this.selectedDevice, required this.selectedDevice,
this.markerSize = 80,
}); });
@override @override
@@ -62,6 +58,8 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final mapStyle = ref.watch(mapStyleProvider);
final primaryColor = ref.read(themePortProvider).getColorFor(ThemeCode.legacyPrimary);
final initialCenter = widget.selectedPosition != null final initialCenter = widget.selectedPosition != null
? LatLng( ? LatLng(
widget.selectedPosition!.latitude, widget.selectedPosition!.latitude,
@@ -78,7 +76,7 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
), ),
children: [ children: [
TileLayer( TileLayer(
urlTemplate: _tileServerUrl, urlTemplate: mapStyle.urlTemplate,
userAgentPackageName: 'com.savefamily.sf_platform', userAgentPackageName: 'com.savefamily.sf_platform',
), ),
MarkerLayer( MarkerLayer(
@@ -89,15 +87,9 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
widget.selectedPosition!.latitude, widget.selectedPosition!.latitude,
widget.selectedPosition!.longitude, widget.selectedPosition!.longitude,
), ),
width: widget.markerSize * 2.5, width: 100,
height: widget.markerSize * 1.8, height: 100,
child: Align( child: PulsingLocationMarker(color: primaryColor),
alignment: Alignment.topCenter,
child: SvgPicture.asset(
'assets/shared/images/location.svg',
height: widget.markerSize,
),
),
rotate: true, rotate: true,
), ),
], ],
@@ -107,7 +99,7 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: LocationBanner( child: LocationBanner(
position: widget.selectedPosition!, position: widget.selectedPosition!,
battery: widget.selectedDevice?.battery ?? 0, device: widget.selectedDevice,
), ),
), ),
], ],
@@ -117,86 +109,156 @@ class _DeviceMapState extends ConsumerState<DeviceMap> {
class LocationBanner extends ConsumerWidget { class LocationBanner extends ConsumerWidget {
final PositionEntity position; final PositionEntity position;
final int battery; final DeviceEntity? device;
const LocationBanner({ const LocationBanner({
super.key, super.key,
required this.position, required this.position,
required this.battery, this.device,
}); });
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider); final theme = ref.read(themePortProvider);
final batteryIcon = toBatteryIcon(battery); final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
final batteryValue = device?.battery ?? 0;
final batteryIcon = toBatteryIcon(batteryValue);
final dateText = formatPositionDate(position.positionDate); final dateText = formatPositionDate(position.positionDate);
final localDevice = device;
final name = localDevice?.carrierName;
final deviceName = localDevice != null
? (name != null && name.isNotEmpty ? name : localDevice.identificator)
: null;
final initial = deviceName != null && deviceName.isNotEmpty
? deviceName[0].toUpperCase()
: null;
final addressText = [ final addressText = [
position.address?.street, position.address?.street,
position.address?.province, position.address?.province,
position.address?.country,
].whereType<String>().where((s) => s.isNotEmpty).join(', '); ].whereType<String>().where((s) => s.isNotEmpty).join(', ');
return Container( return LayoutBuilder(
height: SizeUtils.getByScreen(small: 60, big: 58), builder: (context, constraints) {
width: SizeUtils.getByScreen(small: 300, big: 298), final isCompact = constraints.maxWidth < 320;
margin: EdgeInsets.only(
bottom: SizeUtils.getByScreen(small: 20, big: 16), return Container(
), width: isCompact ? constraints.maxWidth * 0.85 : 340,
decoration: BoxDecoration( margin: EdgeInsets.only(bottom: isCompact ? 8 : 16),
color: theme.getColorFor(ThemeCode.backgroundPrimary), padding: EdgeInsets.symmetric(
borderRadius: BorderRadius.all( horizontal: isCompact ? 8 : 12,
Radius.circular(SizeUtils.getByScreen(small: 9, big: 8)), vertical: isCompact ? 6 : 10,
),
),
child: Row(
children: [
Icon(
SFIcons.location,
size: SizeUtils.getByScreen(small: 40, big: 38),
color: theme.getColorFor(ThemeCode.legacyPrimary),
), ),
Expanded( decoration: BoxDecoration(
child: Column( color: Colors.white,
crossAxisAlignment: CrossAxisAlignment.start, borderRadius: BorderRadius.circular(isCompact ? 10 : 16),
mainAxisAlignment: MainAxisAlignment.center, boxShadow: [
children: [ BoxShadow(
Text( color: Colors.black.withValues(alpha: 0.1),
addressText, blurRadius: isCompact ? 6 : 10,
overflow: TextOverflow.ellipsis, offset: const Offset(0, 2),
),
],
),
child: Row(
children: [
if (initial != null)
Container(
width: isCompact ? 30 : 42,
height: isCompact ? 30 : 42,
decoration: BoxDecoration(
color: primaryColor.withValues(alpha: 0.12),
shape: BoxShape.circle,
),
child: Center(
child: Text(
initial,
style: TextStyle(
fontSize: isCompact ? 13 : 18,
fontWeight: FontWeight.w700,
color: primaryColor,
),
),
),
), ),
Row( SizedBox(width: isCompact ? 6 : 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [ children: [
Flexible( if (deviceName != null)
child: Text( Text(
dateText, deviceName,
style: TextStyle( style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11), fontSize: isCompact ? 12 : 14,
fontWeight: FontWeight.w600,
color: Colors.grey.shade800,
), ),
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
), ),
), if (addressText.isNotEmpty)
if (position.networks.isNotEmpty) Padding(
Text( padding: EdgeInsets.only(
' | ${position.networks.first.signal}', top: deviceName != null ? 1 : 0),
style: TextStyle( child: Text(
fontSize: SizeUtils.getByScreen(small: 12, big: 11), addressText,
style: TextStyle(
fontSize: isCompact ? 9 : 11,
color: Colors.grey.shade500,
),
overflow: TextOverflow.ellipsis,
), ),
), ),
Icon(batteryIcon),
Text(
'$battery%',
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 12, big: 11),
),
),
], ],
), ),
], ),
), Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
batteryIcon,
size: isCompact ? 13 : 16,
color: batteryValue > 20
? primaryColor
: Colors.orange,
),
const SizedBox(width: 2),
Text(
'$batteryValue%',
style: TextStyle(
fontSize: isCompact ? 10 : 12,
fontWeight: FontWeight.w600,
color: batteryValue > 20
? primaryColor
: Colors.orange,
),
),
],
),
if (!isCompact)
Padding(
padding: const EdgeInsets.only(top: 3),
child: Text(
dateText,
style: TextStyle(
fontSize: 10,
color: Colors.grey.shade400,
),
),
),
],
),
],
), ),
], );
), },
); );
} }
} }

View File

@@ -163,7 +163,7 @@ class _MessageSection extends ConsumerWidget {
controller: vm.bodyController, controller: vm.bodyController,
keyboardType: TextInputType.multiline, keyboardType: TextInputType.multiline,
hint: context.translate(I18n.enterMessage), hint: context.translate(I18n.enterMessage),
lines: 8, lines: 7,
onSubmitted: (_) => onSubmit(), onSubmitted: (_) => onSubmit(),
); );
} }
@@ -212,7 +212,7 @@ class _SendSection extends ConsumerWidget {
return Container( return Container(
padding: SizeUtils.getByScreen( padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 38, vertical: 14), small: EdgeInsets.symmetric(horizontal: 38, vertical: 14),
big: EdgeInsets.symmetric(horizontal: 36, vertical: 12) big: EdgeInsets.symmetric(horizontal: 36, vertical: 10)
), ),
child: PrimaryButton( child: PrimaryButton(
onPressed: onSend, onPressed: onSend,

View File

@@ -86,7 +86,7 @@ class CustomerServiceScreen extends ConsumerWidget {
}, },
icon: Icon( icon: Icon(
Icons.email_outlined, Icons.email_outlined,
size: SizeUtils.getByScreen(small: 44, big: 48), size: SizeUtils.getByScreen(small: 46, big: 48),
color: theme.getColorFor(ThemeCode.legacyPrimary), color: theme.getColorFor(ThemeCode.legacyPrimary),
weight: 30, weight: 30,
), ),

View File

@@ -10,3 +10,6 @@ export 'src/features/health/health_builder.dart';
export 'src/features/rewards/rewards_builder.dart'; export 'src/features/rewards/rewards_builder.dart';
export 'src/features/activity_meter/activity_meter_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/volume_control/volume_control_builder.dart';
export 'src/features/call_history/call_history_builder.dart';
export 'src/features/background_image/background_image_builder.dart';

View File

@@ -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,
});
}

View File

@@ -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',
);
}
}

View File

@@ -68,17 +68,31 @@ class ContactsRemoteDatasourceImpl implements ContactsRemoteDatasource {
required String deviceId, required String deviceId,
required List<Map<String, String>> contacts, required List<Map<String, String>> contacts,
}) async { }) async {
await safeCall( await Future.wait([
() => _repository.post<dynamic>( safeCall(
'/contact-lists', () => _repository.post<dynamic>(
body: { '/contact-lists',
'userId': userId, body: {
'deviceId': deviceId, 'userId': userId,
'type': 'secondary', 'deviceId': deviceId,
'contacts': contacts, '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',
),
]);
} }
} }

View File

@@ -19,7 +19,7 @@ class HealthQueryBuilder {
String orderField = 'occurredAt', String orderField = 'occurredAt',
}) { }) {
final orderBy = base64Encode( final orderBy = base64Encode(
utf8.encode('[{"field":"$orderField","order":"${orderDirection.value}"}]'), utf8.encode('[{"field":"$orderField","sortDirection":"${orderDirection.value}"}]'),
); );
final params = <String, dynamic>{'orderBy': orderBy}; final params = <String, dynamic>{'orderBy': orderBy};

View File

@@ -1,4 +1,5 @@
import 'package:device_management/src/core/data/datasources/pictures_remote_datasource.dart'; 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:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:legacy_shared/legacy_shared.dart'; import 'package:legacy_shared/legacy_shared.dart';
@@ -11,47 +12,26 @@ class PicturesRemoteDatasourceImpl implements PicturesRemoteDatasource {
@override @override
Future<List<PictureEntity>> getPictures({required String deviceId}) async { Future<List<PictureEntity>> getPictures({required String deviceId}) async {
/*try { try {
final response = await _repository.get<Map<String, dynamic>>( final response = await _repository.get<Map<String, dynamic>>(
'/devices/identificator/$deviceId/photos', '/devices/identificator/$deviceId/photos/files',
); );
final data = response.data; final data = response.data;
if (data == null || data.isEmpty) { if (data == null || data.isEmpty) {
throw Exception('Empty response from /users/:userId/contacts'); return [];
} }
final model = GetPicturesResponseModel.fromJson(data); final model = GetPicturesResponseModel.fromJson(data);
return model.toEntity(); return model.toEntity();
} on DioException catch (error) { } on DioException catch (error) {
throw mapDioError(error, defaultMessage: 'Error to get pictures'); if (error.response?.statusCode == 404) return [];
}*/ throw mapDioError(error, defaultMessage: 'Error getting pictures');
return []; }
} }
@override @override
Future<PictureEntity> takePicture({required String deviceId}) async { Future<PictureEntity> takePicture({required String deviceId}) async {
/*try { throw UnimplementedError('takePicture is handled via commands');
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',
);
} }
} }

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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,
};

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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,
};

View File

@@ -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);
}
}

View File

@@ -9,14 +9,12 @@ class PicturesRepositoryImpl implements PicturesRepository {
final PicturesRemoteDatasource _remote; final PicturesRemoteDatasource _remote;
@override @override
Future<List<PictureEntity>> getPictures({required String deviceId}) async { Future<List<PictureEntity>> getPictures({required String deviceId}) {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.getPictures(deviceId: deviceId); return _remote.getPictures(deviceId: deviceId);
} }
@override @override
Future<PictureEntity> takePicture({required String deviceId}) async { Future<PictureEntity> takePicture({required String deviceId}) {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.takePicture(deviceId: deviceId); return _remote.takePicture(deviceId: deviceId);
} }
} }

View File

@@ -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});
}

View File

@@ -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);
});

View File

@@ -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);
});

View File

@@ -7,6 +7,7 @@ import 'package:utils/utils.dart';
import '../../../core/presentation/widgets/time_range_selector.dart'; import '../../../core/presentation/widgets/time_range_selector.dart';
import 'state/activity_meter_view_model.dart'; import 'state/activity_meter_view_model.dart';
import 'state/activity_meter_view_state.dart';
import 'widgets/steps_bar_chart.dart'; import 'widgets/steps_bar_chart.dart';
import 'widgets/steps_history_section.dart'; import 'widgets/steps_history_section.dart';
import 'widgets/steps_progress_ring.dart'; import 'widgets/steps_progress_ring.dart';
@@ -20,12 +21,18 @@ class ActivityMeterScreen extends ConsumerWidget {
final theme = ref.watch(themePortProvider); final theme = ref.watch(themePortProvider);
final state = ref.watch(activityMeterViewModelProvider); final state = ref.watch(activityMeterViewModelProvider);
final vm = ref.read(activityMeterViewModelProvider.notifier); final vm = ref.read(activityMeterViewModelProvider.notifier);
final device = ref.watch(selectedDeviceProvider);
ref.listen( ref.listen(
activityMeterViewModelProvider.select((s) => s.errorMessage), activityMeterViewModelProvider.select((s) => s.errorEvent),
(previous, next) { (previous, next) {
if (next.isNotEmpty) { if (next != null) {
showTopSnackbar(context, message: next, type: MessageType.error); 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( StepsProgressRing(
steps: state.todayTotal, steps: state.todayTotal,
goal: state.dailyGoal, goal: state.dailyGoal,

View File

@@ -79,7 +79,7 @@ class ActivityMeterViewModel extends Notifier<ActivityMeterViewState> {
if (!ref.mounted) return; if (!ref.mounted) return;
state = state.copyWith( state = state.copyWith(
isLoadingMore: false, isLoadingMore: false,
errorMessage: _formatError(e), errorEvent: ActivityMeterErrorEvent.loadMore,
); );
} }
} }
@@ -113,7 +113,7 @@ class ActivityMeterViewModel extends Notifier<ActivityMeterViewState> {
await _loadFilteredData(); await _loadFilteredData();
} catch (e) { } catch (e) {
if (!ref.mounted) return; 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, hasMoreHistory: histSteps.length >= _historyPageSize,
stats: _computeStats(chartDaily), stats: _computeStats(chartDaily),
isLoading: false, isLoading: false,
errorMessage: '', errorEvent: null,
); );
} catch (e) { } catch (e) {
if (!ref.mounted) return; 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) { Future<bool> togglePedometer({required bool enabled}) async {
final msg = e.toString(); final device = ref.read(selectedDeviceProvider);
return msg.startsWith('Exception: ') ? msg.substring(11) : msg; 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;
}
} }
} }

View File

@@ -4,6 +4,12 @@ import '../../../../core/presentation/time_range.dart';
part 'activity_meter_view_state.freezed.dart'; part 'activity_meter_view_state.freezed.dart';
enum ActivityMeterErrorEvent {
loadData,
loadMore,
pedometer,
}
@freezed @freezed
abstract class DailySteps with _$DailySteps { abstract class DailySteps with _$DailySteps {
const factory DailySteps({ const factory DailySteps({
@@ -36,6 +42,6 @@ abstract class ActivityMeterViewState with _$ActivityMeterViewState {
DateTime? customEnd, DateTime? customEnd,
@Default(true) bool isLoading, @Default(true) bool isLoading,
@Default(false) bool isLoadingMore, @Default(false) bool isLoadingMore,
@Default('') String errorMessage, ActivityMeterErrorEvent? errorEvent,
}) = _ActivityMeterViewState; }) = _ActivityMeterViewState;
} }

View File

@@ -537,7 +537,7 @@ as int,
/// @nodoc /// @nodoc
mixin _$ActivityMeterViewState { 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 /// Create a copy of ActivityMeterViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -548,16 +548,16 @@ $ActivityMeterViewStateCopyWith<ActivityMeterViewState> get copyWith => _$Activi
@override @override
bool operator ==(Object other) { 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 @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 @override
String toString() { 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; factory $ActivityMeterViewStateCopyWith(ActivityMeterViewState value, $Res Function(ActivityMeterViewState) _then) = _$ActivityMeterViewStateCopyWithImpl;
@useResult @useResult
$Res call({ $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 /// Create a copy of ActivityMeterViewState
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_self.copyWith(
todayTotal: null == todayTotal ? _self.todayTotal : todayTotal // ignore: cast_nullable_to_non_nullable 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 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?,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 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,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 bool,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
as String, as ActivityMeterErrorEvent?,
)); ));
} }
/// Create a copy of ActivityMeterViewState /// 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) { switch (_that) {
case _ActivityMeterViewState() when $default != null: 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(); 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) { switch (_that) {
case _ActivityMeterViewState(): 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'); 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) { switch (_that) {
case _ActivityMeterViewState() when $default != null: 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; return null;
} }
@@ -750,7 +750,7 @@ return $default(_that.todayTotal,_that.dailyGoal,_that.chartData,_that.historyDa
class _ActivityMeterViewState implements ActivityMeterViewState { 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; @override@JsonKey() final int todayTotal;
@@ -777,7 +777,7 @@ class _ActivityMeterViewState implements ActivityMeterViewState {
@override final DateTime? customEnd; @override final DateTime? customEnd;
@override@JsonKey() final bool isLoading; @override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isLoadingMore; @override@JsonKey() final bool isLoadingMore;
@override@JsonKey() final String errorMessage; @override final ActivityMeterErrorEvent? errorEvent;
/// Create a copy of ActivityMeterViewState /// Create a copy of ActivityMeterViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -789,16 +789,16 @@ _$ActivityMeterViewStateCopyWith<_ActivityMeterViewState> get copyWith => __$Act
@override @override
bool operator ==(Object other) { 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 @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 @override
String toString() { 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; factory _$ActivityMeterViewStateCopyWith(_ActivityMeterViewState value, $Res Function(_ActivityMeterViewState) _then) = __$ActivityMeterViewStateCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $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 /// Create a copy of ActivityMeterViewState
/// with the given fields replaced by the non-null parameter values. /// 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( return _then(_ActivityMeterViewState(
todayTotal: null == todayTotal ? _self.todayTotal : todayTotal // ignore: cast_nullable_to_non_nullable 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 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?,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 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,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 bool,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
as String, as ActivityMeterErrorEvent?,
)); ));
} }

View File

@@ -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),
);
}
}

View File

@@ -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,
),
),
),
],
),
);
},
),
),
],
);
}
}

View File

@@ -0,0 +1,148 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:image_picker/image_picker.dart';
import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_shared/sf_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;
late final SharedDevicesRepository _devicesRepository;
@override
BackgroundImageViewState build() {
_repository = ref.read(backgroundImageRepositoryProvider);
_devicesRepository = ref.read(sharedDevicesRepositoryProvider);
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.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;
await _refreshDevice(device);
if (!ref.mounted) return;
state = state.copyWith(
isSaving: false,
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;
await _refreshDevice(device);
if (!ref.mounted) return;
state = state.copyWith(
isSaving: false,
successEvent: BackgroundImageSuccessEvent.backgroundSet,
);
await reload();
} catch (e) {
if (!ref.mounted) return;
state = state.copyWith(
isSaving: false,
errorEvent: BackgroundImageErrorEvent.set,
);
}
}
Future<void> _refreshDevice(DeviceEntity currentDevice) async {
final devices = await _devicesRepository.getDevices();
if (!ref.mounted) return;
final updated = devices.firstWhere(
(d) => d.identificator == currentDevice.identificator,
orElse: () => currentDevice,
);
ref.read(selectedDeviceProvider.notifier).setSelectedDevice(updated);
}
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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(),
);
}
}

View File

@@ -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');
}
}
}

View File

@@ -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>());
});

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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,
};

View File

@@ -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),
),
),
);
}
}

View File

@@ -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();
}
}
}

View File

@@ -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;
}

View File

@@ -0,0 +1,295 @@
// 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_view_state.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$CallHistoryViewState {
bool get isLoading; List<CallHistoryEntity> get calls; List<CallHistoryEntity> get filteredCalls; CallFilter get filter; String get errorMessage;
/// Create a copy of CallHistoryViewState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$CallHistoryViewStateCopyWith<CallHistoryViewState> get copyWith => _$CallHistoryViewStateCopyWithImpl<CallHistoryViewState>(this as CallHistoryViewState, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is CallHistoryViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other.calls, calls)&&const DeepCollectionEquality().equals(other.filteredCalls, filteredCalls)&&(identical(other.filter, filter) || other.filter == filter)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,const DeepCollectionEquality().hash(calls),const DeepCollectionEquality().hash(filteredCalls),filter,errorMessage);
@override
String toString() {
return 'CallHistoryViewState(isLoading: $isLoading, calls: $calls, filteredCalls: $filteredCalls, filter: $filter, errorMessage: $errorMessage)';
}
}
/// @nodoc
abstract mixin class $CallHistoryViewStateCopyWith<$Res> {
factory $CallHistoryViewStateCopyWith(CallHistoryViewState value, $Res Function(CallHistoryViewState) _then) = _$CallHistoryViewStateCopyWithImpl;
@useResult
$Res call({
bool isLoading, List<CallHistoryEntity> calls, List<CallHistoryEntity> filteredCalls, CallFilter filter, String errorMessage
});
}
/// @nodoc
class _$CallHistoryViewStateCopyWithImpl<$Res>
implements $CallHistoryViewStateCopyWith<$Res> {
_$CallHistoryViewStateCopyWithImpl(this._self, this._then);
final CallHistoryViewState _self;
final $Res Function(CallHistoryViewState) _then;
/// Create a copy of CallHistoryViewState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? isLoading = null,Object? calls = null,Object? filteredCalls = null,Object? filter = null,Object? errorMessage = null,}) {
return _then(_self.copyWith(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,calls: null == calls ? _self.calls : calls // ignore: cast_nullable_to_non_nullable
as List<CallHistoryEntity>,filteredCalls: null == filteredCalls ? _self.filteredCalls : filteredCalls // ignore: cast_nullable_to_non_nullable
as List<CallHistoryEntity>,filter: null == filter ? _self.filter : filter // ignore: cast_nullable_to_non_nullable
as CallFilter,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [CallHistoryViewState].
extension CallHistoryViewStatePatterns on CallHistoryViewState {
/// 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( _CallHistoryViewState value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _CallHistoryViewState() 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( _CallHistoryViewState value) $default,){
final _that = this;
switch (_that) {
case _CallHistoryViewState():
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( _CallHistoryViewState value)? $default,){
final _that = this;
switch (_that) {
case _CallHistoryViewState() 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, List<CallHistoryEntity> calls, List<CallHistoryEntity> filteredCalls, CallFilter filter, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _CallHistoryViewState() when $default != null:
return $default(_that.isLoading,_that.calls,_that.filteredCalls,_that.filter,_that.errorMessage);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, List<CallHistoryEntity> calls, List<CallHistoryEntity> filteredCalls, CallFilter filter, String errorMessage) $default,) {final _that = this;
switch (_that) {
case _CallHistoryViewState():
return $default(_that.isLoading,_that.calls,_that.filteredCalls,_that.filter,_that.errorMessage);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, List<CallHistoryEntity> calls, List<CallHistoryEntity> filteredCalls, CallFilter filter, String errorMessage)? $default,) {final _that = this;
switch (_that) {
case _CallHistoryViewState() when $default != null:
return $default(_that.isLoading,_that.calls,_that.filteredCalls,_that.filter,_that.errorMessage);case _:
return null;
}
}
}
/// @nodoc
class _CallHistoryViewState implements CallHistoryViewState {
const _CallHistoryViewState({this.isLoading = true, final List<CallHistoryEntity> calls = const [], final List<CallHistoryEntity> filteredCalls = const [], this.filter = CallFilter.all, this.errorMessage = ''}): _calls = calls,_filteredCalls = filteredCalls;
@override@JsonKey() final bool isLoading;
final List<CallHistoryEntity> _calls;
@override@JsonKey() List<CallHistoryEntity> get calls {
if (_calls is EqualUnmodifiableListView) return _calls;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_calls);
}
final List<CallHistoryEntity> _filteredCalls;
@override@JsonKey() List<CallHistoryEntity> get filteredCalls {
if (_filteredCalls is EqualUnmodifiableListView) return _filteredCalls;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_filteredCalls);
}
@override@JsonKey() final CallFilter filter;
@override@JsonKey() final String errorMessage;
/// Create a copy of CallHistoryViewState
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$CallHistoryViewStateCopyWith<_CallHistoryViewState> get copyWith => __$CallHistoryViewStateCopyWithImpl<_CallHistoryViewState>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CallHistoryViewState&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&const DeepCollectionEquality().equals(other._calls, _calls)&&const DeepCollectionEquality().equals(other._filteredCalls, _filteredCalls)&&(identical(other.filter, filter) || other.filter == filter)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
}
@override
int get hashCode => Object.hash(runtimeType,isLoading,const DeepCollectionEquality().hash(_calls),const DeepCollectionEquality().hash(_filteredCalls),filter,errorMessage);
@override
String toString() {
return 'CallHistoryViewState(isLoading: $isLoading, calls: $calls, filteredCalls: $filteredCalls, filter: $filter, errorMessage: $errorMessage)';
}
}
/// @nodoc
abstract mixin class _$CallHistoryViewStateCopyWith<$Res> implements $CallHistoryViewStateCopyWith<$Res> {
factory _$CallHistoryViewStateCopyWith(_CallHistoryViewState value, $Res Function(_CallHistoryViewState) _then) = __$CallHistoryViewStateCopyWithImpl;
@override @useResult
$Res call({
bool isLoading, List<CallHistoryEntity> calls, List<CallHistoryEntity> filteredCalls, CallFilter filter, String errorMessage
});
}
/// @nodoc
class __$CallHistoryViewStateCopyWithImpl<$Res>
implements _$CallHistoryViewStateCopyWith<$Res> {
__$CallHistoryViewStateCopyWithImpl(this._self, this._then);
final _CallHistoryViewState _self;
final $Res Function(_CallHistoryViewState) _then;
/// Create a copy of CallHistoryViewState
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? isLoading = null,Object? calls = null,Object? filteredCalls = null,Object? filter = null,Object? errorMessage = null,}) {
return _then(_CallHistoryViewState(
isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,calls: null == calls ? _self._calls : calls // ignore: cast_nullable_to_non_nullable
as List<CallHistoryEntity>,filteredCalls: null == filteredCalls ? _self._filteredCalls : filteredCalls // ignore: cast_nullable_to_non_nullable
as List<CallHistoryEntity>,filter: null == filter ? _self.filter : filter // ignore: cast_nullable_to_non_nullable
as CallFilter,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View File

@@ -25,7 +25,7 @@ class ContactsScreen extends ConsumerWidget {
contactsViewModelProvider.select((s) => s.errorMessage), contactsViewModelProvider.select((s) => s.errorMessage),
(previous, next) { (previous, next) {
if (next.isNotEmpty) { if (next.isNotEmpty) {
showTopSnackbar(context, message: next, type: MessageType.error); showTopSnackbar(context, message: context.translate(next), type: MessageType.error);
} }
}, },
); );
@@ -58,14 +58,21 @@ class ContactsScreen extends ConsumerWidget {
shape: const CircleBorder(), shape: const CircleBorder(),
child: InkWell( child: InkWell(
customBorder: const CircleBorder(), customBorder: const CircleBorder(),
onTap: () => showDialog( onTap: () {
context: context, if (state.contacts.length == state.maxLimit) {
builder: (_) => const Dialog( showTopSnackbar(context, message: context.translate(I18n.errorContactsMax));
backgroundColor: Colors.transparent, return;
child: NewContactDialog(), }
),
), showDialog(
child: SizedBox( context: context,
builder: (_) => const Dialog(
backgroundColor: Colors.transparent,
child: NewContactDialog(),
),
);
},
child: SizedBox(
width: SizeUtils.getByScreen(small: 48, big: 46), width: SizeUtils.getByScreen(small: 48, big: 46),
height: SizeUtils.getByScreen(small: 48, big: 46), height: SizeUtils.getByScreen(small: 48, big: 46),
child: Icon( child: Icon(

View File

@@ -104,18 +104,22 @@ class _EditContactScreenState extends ConsumerState<EditContactScreen> {
height: SizeUtils.getByScreen(small: 28, big: 26), height: SizeUtils.getByScreen(small: 28, big: 26),
), ),
Row( Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
CountryPrefixPicker( Align(
headerText: context.translate(I18n.selectYourCountry), alignment: Alignment.bottomLeft,
initialSelection: state.dialCode, child: CountryPrefixPicker(
onChanged: (country) { headerText: context.translate(I18n.selectYourCountry),
final vm = initialSelection: state.dialCode,
ref.read(contactsViewModelProvider.notifier); onChanged: (country) {
vm.updateDialCode( final vm =
country.dialCode ?? state.dialCode, ref.read(contactsViewModelProvider.notifier);
); vm.updateDialCode(
}, country.dialCode ?? state.dialCode,
width: 80, );
},
width: 80,
),
), ),
SizedBox( SizedBox(
width: SizeUtils.getByScreen(small: 10, big: 10, xl: 6), width: SizeUtils.getByScreen(small: 10, big: 10, xl: 6),

View File

@@ -134,6 +134,11 @@ class ContactsViewModel extends Notifier<ContactsViewState> {
Future<bool> deleteContact(ContactEntity contact) async { Future<bool> deleteContact(ContactEntity contact) async {
if (state.isLoading) return false; if (state.isLoading) return false;
if (state.contacts.length == 1){
state = state.copyWith(errorMessage: I18n.errorContactsMin);
return true;
}
try { try {
state = state.copyWith(isLoading: true, errorMessage: ''); state = state.copyWith(isLoading: true, errorMessage: '');

View File

@@ -8,9 +8,10 @@ part 'contacts_view_state.freezed.dart';
abstract class ContactsViewState with _$ContactsViewState { abstract class ContactsViewState with _$ContactsViewState {
const factory ContactsViewState({ const factory ContactsViewState({
@Default([]) List<ContactEntity> contacts, @Default([]) List<ContactEntity> contacts,
@Default(10) int maxLimit,
@Default('+34') String dialCode, @Default('+34') String dialCode,
@Default(true) bool isLoading, @Default(true) bool isLoading,
@Default(false) bool isEditing, @Default(false) bool isEditing,
@Default('') String errorMessage, @Default('') String errorMessage
}) = _ContactsViewState; }) = _ContactsViewState;
} }

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$ContactsViewState { mixin _$ContactsViewState {
List<ContactEntity> get contacts; String get dialCode; bool get isLoading; bool get isEditing; String get errorMessage; List<ContactEntity> get contacts; int get maxLimit; String get dialCode; bool get isLoading; bool get isEditing; String get errorMessage;
/// Create a copy of ContactsViewState /// Create a copy of ContactsViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $ContactsViewStateCopyWith<ContactsViewState> get copyWith => _$ContactsViewStat
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is ContactsViewState&&const DeepCollectionEquality().equals(other.contacts, contacts)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); return identical(this, other) || (other.runtimeType == runtimeType&&other is ContactsViewState&&const DeepCollectionEquality().equals(other.contacts, contacts)&&(identical(other.maxLimit, maxLimit) || other.maxLimit == maxLimit)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
} }
@override @override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(contacts),dialCode,isLoading,isEditing,errorMessage); int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(contacts),maxLimit,dialCode,isLoading,isEditing,errorMessage);
@override @override
String toString() { String toString() {
return 'ContactsViewState(contacts: $contacts, dialCode: $dialCode, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)'; return 'ContactsViewState(contacts: $contacts, maxLimit: $maxLimit, dialCode: $dialCode, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)';
} }
@@ -45,7 +45,7 @@ abstract mixin class $ContactsViewStateCopyWith<$Res> {
factory $ContactsViewStateCopyWith(ContactsViewState value, $Res Function(ContactsViewState) _then) = _$ContactsViewStateCopyWithImpl; factory $ContactsViewStateCopyWith(ContactsViewState value, $Res Function(ContactsViewState) _then) = _$ContactsViewStateCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage List<ContactEntity> contacts, int maxLimit, String dialCode, bool isLoading, bool isEditing, String errorMessage
}); });
@@ -62,10 +62,11 @@ class _$ContactsViewStateCopyWithImpl<$Res>
/// Create a copy of ContactsViewState /// Create a copy of ContactsViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? contacts = null,Object? dialCode = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) { @pragma('vm:prefer-inline') @override $Res call({Object? contacts = null,Object? maxLimit = null,Object? dialCode = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
contacts: null == contacts ? _self.contacts : contacts // ignore: cast_nullable_to_non_nullable contacts: null == contacts ? _self.contacts : contacts // ignore: cast_nullable_to_non_nullable
as List<ContactEntity>,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable as List<ContactEntity>,maxLimit: null == maxLimit ? _self.maxLimit : maxLimit // ignore: cast_nullable_to_non_nullable
as int,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable as bool,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
@@ -154,10 +155,10 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this; @optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, int maxLimit, String dialCode, bool isLoading, bool isEditing, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _ContactsViewState() when $default != null: case _ContactsViewState() when $default != null:
return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _: return $default(_that.contacts,_that.maxLimit,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
return orElse(); return orElse();
} }
@@ -175,10 +176,10 @@ return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_t
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<ContactEntity> contacts, int maxLimit, String dialCode, bool isLoading, bool isEditing, String errorMessage) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _ContactsViewState(): case _ContactsViewState():
return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _: return $default(_that.contacts,_that.maxLimit,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
throw StateError('Unexpected subclass'); throw StateError('Unexpected subclass');
} }
@@ -195,10 +196,10 @@ return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_t
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<ContactEntity> contacts, int maxLimit, String dialCode, bool isLoading, bool isEditing, String errorMessage)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _ContactsViewState() when $default != null: case _ContactsViewState() when $default != null:
return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _: return $default(_that.contacts,_that.maxLimit,_that.dialCode,_that.isLoading,_that.isEditing,_that.errorMessage);case _:
return null; return null;
} }
@@ -210,7 +211,7 @@ return $default(_that.contacts,_that.dialCode,_that.isLoading,_that.isEditing,_t
class _ContactsViewState implements ContactsViewState { class _ContactsViewState implements ContactsViewState {
const _ContactsViewState({final List<ContactEntity> contacts = const [], this.dialCode = '+34', this.isLoading = true, this.isEditing = false, this.errorMessage = ''}): _contacts = contacts; const _ContactsViewState({final List<ContactEntity> contacts = const [], this.maxLimit = 10, this.dialCode = '+34', this.isLoading = true, this.isEditing = false, this.errorMessage = ''}): _contacts = contacts;
final List<ContactEntity> _contacts; final List<ContactEntity> _contacts;
@@ -220,6 +221,7 @@ class _ContactsViewState implements ContactsViewState {
return EqualUnmodifiableListView(_contacts); return EqualUnmodifiableListView(_contacts);
} }
@override@JsonKey() final int maxLimit;
@override@JsonKey() final String dialCode; @override@JsonKey() final String dialCode;
@override@JsonKey() final bool isLoading; @override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isEditing; @override@JsonKey() final bool isEditing;
@@ -235,16 +237,16 @@ _$ContactsViewStateCopyWith<_ContactsViewState> get copyWith => __$ContactsViewS
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _ContactsViewState&&const DeepCollectionEquality().equals(other._contacts, _contacts)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); return identical(this, other) || (other.runtimeType == runtimeType&&other is _ContactsViewState&&const DeepCollectionEquality().equals(other._contacts, _contacts)&&(identical(other.maxLimit, maxLimit) || other.maxLimit == maxLimit)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.isLoading, isLoading) || other.isLoading == isLoading)&&(identical(other.isEditing, isEditing) || other.isEditing == isEditing)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
} }
@override @override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_contacts),dialCode,isLoading,isEditing,errorMessage); int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_contacts),maxLimit,dialCode,isLoading,isEditing,errorMessage);
@override @override
String toString() { String toString() {
return 'ContactsViewState(contacts: $contacts, dialCode: $dialCode, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)'; return 'ContactsViewState(contacts: $contacts, maxLimit: $maxLimit, dialCode: $dialCode, isLoading: $isLoading, isEditing: $isEditing, errorMessage: $errorMessage)';
} }
@@ -255,7 +257,7 @@ abstract mixin class _$ContactsViewStateCopyWith<$Res> implements $ContactsViewS
factory _$ContactsViewStateCopyWith(_ContactsViewState value, $Res Function(_ContactsViewState) _then) = __$ContactsViewStateCopyWithImpl; factory _$ContactsViewStateCopyWith(_ContactsViewState value, $Res Function(_ContactsViewState) _then) = __$ContactsViewStateCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
List<ContactEntity> contacts, String dialCode, bool isLoading, bool isEditing, String errorMessage List<ContactEntity> contacts, int maxLimit, String dialCode, bool isLoading, bool isEditing, String errorMessage
}); });
@@ -272,10 +274,11 @@ class __$ContactsViewStateCopyWithImpl<$Res>
/// Create a copy of ContactsViewState /// Create a copy of ContactsViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? contacts = null,Object? dialCode = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) { @override @pragma('vm:prefer-inline') $Res call({Object? contacts = null,Object? maxLimit = null,Object? dialCode = null,Object? isLoading = null,Object? isEditing = null,Object? errorMessage = null,}) {
return _then(_ContactsViewState( return _then(_ContactsViewState(
contacts: null == contacts ? _self._contacts : contacts // ignore: cast_nullable_to_non_nullable contacts: null == contacts ? _self._contacts : contacts // ignore: cast_nullable_to_non_nullable
as List<ContactEntity>,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable as List<ContactEntity>,maxLimit: null == maxLimit ? _self.maxLimit : maxLimit // ignore: cast_nullable_to_non_nullable
as int,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable as String,isLoading: null == isLoading ? _self.isLoading : isLoading // ignore: cast_nullable_to_non_nullable
as bool,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable as bool,isEditing: null == isEditing ? _self.isEditing : isEditing // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable

View File

@@ -24,7 +24,7 @@ class ContactCard extends ConsumerWidget {
return Container( return Container(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: SizeUtils.getByScreen(small: 22, big: 21), horizontal: SizeUtils.getByScreen(small: 22, big: 21, xl: 18),
vertical: SizeUtils.getByScreen(small: 12, big: 8), vertical: SizeUtils.getByScreen(small: 12, big: 8),
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -71,11 +71,13 @@ class ContactCard extends ConsumerWidget {
), ),
), ),
if (isEditing) ...[ if (isEditing) ...[
DecoratedBox( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: const Color(0xFFFF5D52), color: const Color(0xFFFF5D52),
borderRadius: BorderRadius.all(Radius.circular(12)), borderRadius: BorderRadius.all(Radius.circular(12)),
), ),
height: SizeUtils.getByScreen(small: 48, big: 48, xl: 40),
width: SizeUtils.getByScreen(small: 48, big: 48, xl: 40),
child: IconButton( child: IconButton(
onPressed: () => showDialog( onPressed: () => showDialog(
context: context, context: context,
@@ -83,21 +85,30 @@ class ContactCard extends ConsumerWidget {
child: ConfirmDeleteDialog(contact: contact), child: ConfirmDeleteDialog(contact: contact),
), ),
), ),
icon: const Icon(Icons.close, color: Colors.white), icon: Icon(
Icons.close,
color: Colors.white,
size: SizeUtils.getByScreen(small: 28, big: 22),),
), ),
), ),
SizedBox(width: SizeUtils.getByScreen(small: 16, big: 14)), SizedBox(width: SizeUtils.getByScreen(small: 16, big: 14, xl: 10)),
DecoratedBox( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.getColorFor(ThemeCode.legacyPrimary), color: theme.getColorFor(ThemeCode.legacyPrimary),
borderRadius: BorderRadius.all(Radius.circular(12)), borderRadius: BorderRadius.all(Radius.circular(12)),
), ),
height: SizeUtils.getByScreen(small: 48, big: 48, xl: 40),
width: SizeUtils.getByScreen(small: 48, big: 48, xl: 40),
child: IconButton( child: IconButton(
onPressed: () { onPressed: () {
final nav = GetIt.I<NavigationContract>(); final nav = GetIt.I<NavigationContract>();
nav.pushTo(AppRoutes.editContactPath(contact.id)); nav.pushTo(AppRoutes.editContactPath(contact.id));
}, },
icon: const Icon(Icons.edit_outlined, color: Colors.white), icon: Icon(
Icons.edit_outlined,
color: Colors.white,
size: SizeUtils.getByScreen(small: 28, big: 22),
),
), ),
), ),
], ],

View File

@@ -39,8 +39,8 @@ class _NewContactDialogState extends ConsumerState<NewContactDialog> {
horizontal: SizeUtils.getByScreen(small: 10, big: 8), horizontal: SizeUtils.getByScreen(small: 10, big: 8),
vertical: SizeUtils.getByScreen(small: 10, big: 8), vertical: SizeUtils.getByScreen(small: 10, big: 8),
), ),
height: SizeUtils.getByScreen(small: 430, big: 410), height: SizeUtils.getByScreen(small: 430, big: 410, xl: 400),
width: SizeUtils.getByScreen(small: 400, big: 390), width: SizeUtils.getByScreen(small: 400, big: 390, xl: 400),
decoration: BoxDecoration( decoration: BoxDecoration(
color: theme.getColorFor(ThemeCode.backgroundPrimary), color: theme.getColorFor(ThemeCode.backgroundPrimary),
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
@@ -49,6 +49,7 @@ class _NewContactDialogState extends ConsumerState<NewContactDialog> {
), ),
child: SingleChildScrollView( child: SingleChildScrollView(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Stack( Stack(
children: [ children: [

View File

@@ -51,14 +51,14 @@ class DeviceManagementScreen extends ConsumerWidget {
negativeIcon: true, negativeIcon: true,
text: context.translate(I18n.contacts), text: context.translate(I18n.contacts),
), ),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), // SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton( // AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary), // color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () {}, // onPressed: () {},
icon: SFIcons.doNotDisturbCircle, // icon: SFIcons.doNotDisturbCircle,
negativeIcon: true, // negativeIcon: true,
text: context.translate(I18n.doNotDisturb), // text: context.translate(I18n.doNotDisturb),
), // ),
// SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), // SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
// AppMenuButton( // AppMenuButton(
// color: theme.getColorFor(ThemeCode.legacyPrimary), // color: theme.getColorFor(ThemeCode.legacyPrimary),
@@ -68,6 +68,15 @@ class DeviceManagementScreen extends ConsumerWidget {
// text: context.translate(I18n.videoCall), // text: context.translate(I18n.videoCall),
// ), // ),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () =>
navigationContract.pushTo(AppRoutes.volumeControl),
icon: Icons.volume_up_outlined,
iconSize: SizeUtils.getByScreen(small: 42, big: 40),
text: context.translate(I18n.volumeControl),
),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton( AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary), color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () => navigationContract.pushTo(AppRoutes.health), onPressed: () => navigationContract.pushTo(AppRoutes.health),
@@ -104,27 +113,36 @@ class DeviceManagementScreen extends ConsumerWidget {
text: context.translate(I18n.callWatch), text: context.translate(I18n.callWatch),
), ),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () =>
navigationContract.pushTo(AppRoutes.callHistory),
icon: Icons.history_outlined,
iconSize: SizeUtils.getByScreen(small: 42, big: 40),
text: context.translate(I18n.callHistory),
),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton( AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary), color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () => navigationContract.pushTo(AppRoutes.appsUse), onPressed: () => navigationContract.pushTo(AppRoutes.appsUse),
icon: SFIcons.screenTime, icon: SFIcons.screenTime,
text: context.translate(I18n.appsUse), text: context.translate(I18n.appsUse),
), ),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), // SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton( // AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary), // color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () {}, // onPressed: () {},
icon: Icons.app_registration_sharp, // icon: Icons.app_registration_sharp,
text: context.translate(I18n.appsSurveillance), // text: context.translate(I18n.appsSurveillance),
), // ),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), // SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton( // AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary), // color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () {}, // onPressed: () {},
icon: SFIcons.friendsCircle, // icon: SFIcons.friendsCircle,
negativeIcon: true, // negativeIcon: true,
text: context.translate(I18n.makeFriends), // text: context.translate(I18n.makeFriends),
), // ),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton( AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary), color: theme.getColorFor(ThemeCode.legacyPrimary),
@@ -134,6 +152,16 @@ class DeviceManagementScreen extends ConsumerWidget {
negativeIcon: true, negativeIcon: true,
text: context.translate(I18n.locateSF), text: context.translate(I18n.locateSF),
), ),
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
AppMenuButton(
color: theme.getColorFor(ThemeCode.legacyPrimary),
onPressed: () =>
navigationContract.pushTo(AppRoutes.backgroundImage),
icon: Icons.add_photo_alternate_outlined,
iconSize: SizeUtils.getByScreen(small: 32, big: 30),
negativeIcon: false,
text: context.translate(I18n.customBackground),
),
], ],
), ),
), ),

View File

@@ -33,9 +33,13 @@ class CallWatchViewModel extends Notifier<CallWatchViewState> {
state = state.copyWith(phone: text, errorMessage: ''); state = state.copyWith(phone: text, errorMessage: '');
} }
void updateDialCode(String code) {
state = state.copyWith(dialCode: code, errorMessage: '');
}
void call() async { void call() async {
final phone = state.phone; final phone = state.phone;
if (phone.isEmpty){ if (phone.isEmpty) {
state = state.copyWith(errorMessage: 'errorMessagePhoneIsEmpty'); state = state.copyWith(errorMessage: 'errorMessagePhoneIsEmpty');
return; return;
} }
@@ -44,7 +48,8 @@ class CallWatchViewModel extends Notifier<CallWatchViewState> {
return; return;
} }
final url = Uri(scheme: 'tel', path: phone); final fullNumber = '${state.dialCode}$phone';
final url = Uri(scheme: 'tel', path: fullNumber);
if (await canLaunchUrl(url)) { if (await canLaunchUrl(url)) {
launchUrl(url); launchUrl(url);

View File

@@ -5,6 +5,7 @@ part 'call_watch_view_state.freezed.dart';
@freezed @freezed
abstract class CallWatchViewState with _$CallWatchViewState { abstract class CallWatchViewState with _$CallWatchViewState {
const factory CallWatchViewState({ const factory CallWatchViewState({
@Default('+34') String dialCode,
@Default('') String phone, @Default('') String phone,
@Default('') String errorMessage, @Default('') String errorMessage,
}) = _CallWatchViewState; }) = _CallWatchViewState;

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$CallWatchViewState { mixin _$CallWatchViewState {
String get phone; String get errorMessage; String get dialCode; String get phone; String get errorMessage;
/// Create a copy of CallWatchViewState /// Create a copy of CallWatchViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $CallWatchViewStateCopyWith<CallWatchViewState> get copyWith => _$CallWatchViewS
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is CallWatchViewState&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); return identical(this, other) || (other.runtimeType == runtimeType&&other is CallWatchViewState&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
} }
@override @override
int get hashCode => Object.hash(runtimeType,phone,errorMessage); int get hashCode => Object.hash(runtimeType,dialCode,phone,errorMessage);
@override @override
String toString() { String toString() {
return 'CallWatchViewState(phone: $phone, errorMessage: $errorMessage)'; return 'CallWatchViewState(dialCode: $dialCode, phone: $phone, errorMessage: $errorMessage)';
} }
@@ -45,7 +45,7 @@ abstract mixin class $CallWatchViewStateCopyWith<$Res> {
factory $CallWatchViewStateCopyWith(CallWatchViewState value, $Res Function(CallWatchViewState) _then) = _$CallWatchViewStateCopyWithImpl; factory $CallWatchViewStateCopyWith(CallWatchViewState value, $Res Function(CallWatchViewState) _then) = _$CallWatchViewStateCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String phone, String errorMessage String dialCode, String phone, String errorMessage
}); });
@@ -62,9 +62,10 @@ class _$CallWatchViewStateCopyWithImpl<$Res>
/// Create a copy of CallWatchViewState /// Create a copy of CallWatchViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? phone = null,Object? errorMessage = null,}) { @pragma('vm:prefer-inline') @override $Res call({Object? dialCode = null,Object? phone = null,Object? errorMessage = null,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ));
@@ -151,10 +152,10 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String phone, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this; @optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String dialCode, String phone, String errorMessage)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _CallWatchViewState() when $default != null: case _CallWatchViewState() when $default != null:
return $default(_that.phone,_that.errorMessage);case _: return $default(_that.dialCode,_that.phone,_that.errorMessage);case _:
return orElse(); return orElse();
} }
@@ -172,10 +173,10 @@ return $default(_that.phone,_that.errorMessage);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String phone, String errorMessage) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String dialCode, String phone, String errorMessage) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _CallWatchViewState(): case _CallWatchViewState():
return $default(_that.phone,_that.errorMessage);case _: return $default(_that.dialCode,_that.phone,_that.errorMessage);case _:
throw StateError('Unexpected subclass'); throw StateError('Unexpected subclass');
} }
@@ -192,10 +193,10 @@ return $default(_that.phone,_that.errorMessage);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String phone, String errorMessage)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String dialCode, String phone, String errorMessage)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _CallWatchViewState() when $default != null: case _CallWatchViewState() when $default != null:
return $default(_that.phone,_that.errorMessage);case _: return $default(_that.dialCode,_that.phone,_that.errorMessage);case _:
return null; return null;
} }
@@ -207,9 +208,10 @@ return $default(_that.phone,_that.errorMessage);case _:
class _CallWatchViewState implements CallWatchViewState { class _CallWatchViewState implements CallWatchViewState {
const _CallWatchViewState({this.phone = '', this.errorMessage = ''}); const _CallWatchViewState({this.dialCode = '+34', this.phone = '', this.errorMessage = ''});
@override@JsonKey() final String dialCode;
@override@JsonKey() final String phone; @override@JsonKey() final String phone;
@override@JsonKey() final String errorMessage; @override@JsonKey() final String errorMessage;
@@ -223,16 +225,16 @@ _$CallWatchViewStateCopyWith<_CallWatchViewState> get copyWith => __$CallWatchVi
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _CallWatchViewState&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)); return identical(this, other) || (other.runtimeType == runtimeType&&other is _CallWatchViewState&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage));
} }
@override @override
int get hashCode => Object.hash(runtimeType,phone,errorMessage); int get hashCode => Object.hash(runtimeType,dialCode,phone,errorMessage);
@override @override
String toString() { String toString() {
return 'CallWatchViewState(phone: $phone, errorMessage: $errorMessage)'; return 'CallWatchViewState(dialCode: $dialCode, phone: $phone, errorMessage: $errorMessage)';
} }
@@ -243,7 +245,7 @@ abstract mixin class _$CallWatchViewStateCopyWith<$Res> implements $CallWatchVie
factory _$CallWatchViewStateCopyWith(_CallWatchViewState value, $Res Function(_CallWatchViewState) _then) = __$CallWatchViewStateCopyWithImpl; factory _$CallWatchViewStateCopyWith(_CallWatchViewState value, $Res Function(_CallWatchViewState) _then) = __$CallWatchViewStateCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
String phone, String errorMessage String dialCode, String phone, String errorMessage
}); });
@@ -260,9 +262,10 @@ class __$CallWatchViewStateCopyWithImpl<$Res>
/// Create a copy of CallWatchViewState /// Create a copy of CallWatchViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? phone = null,Object? errorMessage = null,}) { @override @pragma('vm:prefer-inline') $Res call({Object? dialCode = null,Object? phone = null,Object? errorMessage = null,}) {
return _then(_CallWatchViewState( return _then(_CallWatchViewState(
phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
as String,phone: null == phone ? _self.phone : phone // ignore: cast_nullable_to_non_nullable
as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as String,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable
as String, as String,
)); ));

View File

@@ -6,6 +6,7 @@ import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart'; import 'package:utils/utils.dart';
class CallWatchDialog extends ConsumerWidget { class CallWatchDialog extends ConsumerWidget {
const CallWatchDialog({super.key});
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
@@ -16,33 +17,67 @@ class CallWatchDialog extends ConsumerWidget {
return Container( return Container(
padding: SizeUtils.getByScreen( padding: SizeUtils.getByScreen(
small: EdgeInsets.symmetric(horizontal: 26, vertical: 20), small: EdgeInsets.symmetric(horizontal: 16, vertical: 20),
big: EdgeInsets.symmetric(horizontal: 24, vertical: 18) big: EdgeInsets.symmetric(horizontal: 14, vertical: 18),
), ),
width: SizeUtils.getByScreen(small: 390, big: 380), decoration: BoxDecoration(
height: SizeUtils.getByScreen(small: 250, big: 243), borderRadius: BorderRadius.all(Radius.circular(14)),
color: theme.getColorFor(ThemeCode.backgroundPrimary),
),
width: SizeUtils.getByScreen(small: 390, big: 380, xl: 390),
height: SizeUtils.getByScreen(small: 250, big: 230),
child: Column( child: Column(
children: [ children: [
Stack( Stack(
children: [ children: [
Center(child: Text(context.translate(I18n.callWatch), Center(
textAlign: TextAlign.center, child: Text(
style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)), context.translate(I18n.callWatch),
)), textAlign: TextAlign.center,
style: TextStyle(
fontSize: SizeUtils.getByScreen(small: 19, big: 18),
),
),
),
Align( Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: IconButton( child: IconButton(
onPressed: (){Navigator.pop(context);}, onPressed: () {
icon: Icon(Icons.close, color: theme.getColorFor(ThemeCode.legacyPrimary)), Navigator.pop(context);
) },
) icon: Icon(
Icons.close,
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
),
),
], ],
), ),
SizedBox(height: SizeUtils.getByScreen(small: 8, big: 7)), SizedBox(height: SizeUtils.getByScreen(small: 8, big: 7)),
CustomTextField( Row(
controller: viewModel.phoneController, crossAxisAlignment: CrossAxisAlignment.start,
hint: context.translate(I18n.mainContactPhoneNumber), children: [
keyboardType: TextInputType.number, CountryPrefixPicker(
headerText: context.translate(I18n.selectYourCountry),
initialSelection: viewState.dialCode,
onChanged: (country) {
viewModel.updateDialCode(
country.dialCode ?? viewState.dialCode,
);
},
width: 80,
backgroundColor: Colors.transparent,
borderColor: Colors.black,
),
SizedBox(width: SizeUtils.getByScreen(small: 8, big: 7)),
Expanded(
child: CustomTextField(
controller: viewModel.phoneController,
hint: context.translate(I18n.mainContactPhoneNumber),
keyboardType: TextInputType.phone,
),
),
],
), ),
if (viewState.errorMessage.isNotEmpty) if (viewState.errorMessage.isNotEmpty)
Padding( Padding(
@@ -68,5 +103,4 @@ class CallWatchDialog extends ConsumerWidget {
), ),
); );
} }
} }

View File

@@ -2,11 +2,13 @@ import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/legacy_shared.dart'; import 'package:legacy_shared/legacy_shared.dart';
import 'package:lottie/lottie.dart';
import 'package:navigation/navigation.dart'; import 'package:navigation/navigation.dart';
import 'package:sf_localizations/sf_localizations.dart'; import 'package:sf_localizations/sf_localizations.dart';
import 'package:utils/utils.dart'; import 'package:utils/utils.dart';
import 'state/health_view_model.dart'; import 'state/health_view_model.dart';
import 'state/health_view_state.dart';
import 'widgets/blood_pressure_tab.dart'; import 'widgets/blood_pressure_tab.dart';
import 'widgets/health_summary_cards.dart'; import 'widgets/health_summary_cards.dart';
import 'widgets/heart_rate_tab.dart'; import 'widgets/heart_rate_tab.dart';
@@ -55,22 +57,34 @@ class _HealthScreenState extends ConsumerState<HealthScreen>
final theme = ref.watch(themePortProvider); final theme = ref.watch(themePortProvider);
final state = ref.watch(healthViewModelProvider); final state = ref.watch(healthViewModelProvider);
final vm = ref.read(healthViewModelProvider.notifier); final vm = ref.read(healthViewModelProvider.notifier);
final device = ref.watch(selectedDeviceProvider);
ref.listen( ref.listen(healthViewModelProvider.select((s) => s.errorEvent), (
healthViewModelProvider.select((s) => s.errorMessage), previous,
(previous, next) { next,
if (next.isNotEmpty) { ) {
showTopSnackbar(context, message: next, type: MessageType.error); if (next != null) {
} final message = switch (next) {
}, HealthErrorEvent.loadData => context.translate(I18n.errorHealthData),
); HealthErrorEvent.loadMore => context.translate(I18n.errorHealthData),
HealthErrorEvent.measure => context.translate(I18n.errorHealthMeasure),
HealthErrorEvent.heartRateFrequency => context.translate(I18n.errorHeartRateFrequency),
};
showTopSnackbar(context, message: message, type: MessageType.error);
}
});
return LegacyPageLayout( return LegacyPageLayout(
theme: theme, theme: theme,
title: context.translate(I18n.health), title: context.translate(I18n.health),
body: state.isLoading body: state.isLoading
? const Center(child: CircularProgressIndicator()) ? const Center(child: CircularProgressIndicator())
: Column( : state.isMeasuringCountdown
? _MeasuringOverlay(
remainingSeconds: state.measureRemainingSeconds,
theme: theme,
)
: Column(
children: [ children: [
HealthSummaryCards( HealthSummaryCards(
heartbeats: state.latestHeartbeats, heartbeats: state.latestHeartbeats,
@@ -84,6 +98,31 @@ class _HealthScreenState extends ConsumerState<HealthScreen>
onCustomTap: () => _pickCustomRange(vm), onCustomTap: () => _pickCustomRange(vm),
theme: theme, theme: theme,
), ),
if (device?.capabilities?.heartbeats != null &&
device!.capabilities!.heartbeats!.options.isNotEmpty)
_HeartRateFrequencySelector(
currentFrequency:
device.settings.frequencyHeartRate,
options:
device.capabilities!.heartbeats!.options,
theme: theme,
onChanged: (frequency) async {
final success =
await vm.updateHeartRateFrequency(
frequency: frequency);
if (!context.mounted) return;
if (success) {
showTopSnackbar(
context,
message: context.translate(
I18n.locationFrequencyUpdated,
args: {'minutes': '${frequency ~/ 60}'},
),
type: MessageType.success,
);
}
},
),
TabBar( TabBar(
controller: _tabController, controller: _tabController,
labelColor: theme.getColorFor(ThemeCode.legacyPrimary), labelColor: theme.getColorFor(ThemeCode.legacyPrimary),
@@ -130,6 +169,134 @@ class _HealthScreenState extends ConsumerState<HealthScreen>
), ),
], ],
), ),
footer: _SaveSection(),
);
}
}
class _SaveSection extends ConsumerWidget {
const _SaveSection();
@override
Widget build(BuildContext context, WidgetRef ref) {
final theme = ref.read(themePortProvider);
final vm = ref.read(healthViewModelProvider.notifier);
final isMeasuring = ref.watch(
healthViewModelProvider.select((s) => s.isMeasuring),
);
final isCountdown = ref.watch(
healthViewModelProvider.select((s) => s.isMeasuringCountdown),
);
if (isCountdown) return const SizedBox.shrink();
return Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 10),
child: PrimaryButton(
onPressed: isMeasuring ? null : () => vm.measure(),
text: isMeasuring
? '...'
: context.translate(I18n.measure),
color: theme.getColorFor(ThemeCode.legacyPrimary),
),
);
}
}
class _HeartRateFrequencySelector extends StatelessWidget {
final int currentFrequency;
final List<int> options;
final ThemePort theme;
final ValueChanged<int> onChanged;
const _HeartRateFrequencySelector({
required this.currentFrequency,
required this.options,
required this.theme,
required this.onChanged,
});
@override
Widget build(BuildContext context) {
final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
Icon(Icons.timer_outlined, size: 18, color: primaryColor),
const SizedBox(width: 8),
Text(
context.translate(I18n.healthFrequency),
style: TextStyle(fontSize: 13, color: primaryColor),
),
const Spacer(),
...options.map(
(opt) => Padding(
padding: const EdgeInsets.only(left: 6),
child: ChoiceChip(
label: Text('${opt ~/ 60}m'),
selected: opt == currentFrequency,
selectedColor: primaryColor,
labelStyle: TextStyle(
fontSize: 12,
color: opt == currentFrequency ? Colors.white : primaryColor,
),
side: BorderSide(color: primaryColor),
onSelected: (_) => onChanged(opt),
visualDensity: VisualDensity.compact,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
),
),
],
),
);
}
}
class _MeasuringOverlay extends StatelessWidget {
final int remainingSeconds;
final ThemePort theme;
const _MeasuringOverlay({
required this.remainingSeconds,
required this.theme,
});
@override
Widget build(BuildContext context) {
final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Lottie.asset(
'assets/shared/animations/fitness_tracker.json',
width: 200,
height: 200,
),
const SizedBox(height: 24),
Text(
context.translate(I18n.healthMeasuring),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: primaryColor,
),
),
const SizedBox(height: 12),
Text(
'${remainingSeconds}s',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: primaryColor,
),
),
],
),
); );
} }
} }

View File

@@ -1,3 +1,5 @@
import 'dart:async';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:legacy_shared/legacy_shared.dart'; import 'package:legacy_shared/legacy_shared.dart';
@@ -7,6 +9,18 @@ import '../../../../core/domain/repositories/health_repository.dart';
import '../../../../core/providers/health_repository_provider.dart'; import '../../../../core/providers/health_repository_provider.dart';
import 'health_view_state.dart'; import 'health_view_state.dart';
final _measureEndTimeProvider =
NotifierProvider<_MeasureEndTimeNotifier, DateTime?>(
_MeasureEndTimeNotifier.new,
);
class _MeasureEndTimeNotifier extends Notifier<DateTime?> {
@override
DateTime? build() => null;
void set(DateTime? value) => state = value;
}
final healthViewModelProvider = final healthViewModelProvider =
NotifierProvider.autoDispose<HealthViewModel, HealthViewState>( NotifierProvider.autoDispose<HealthViewModel, HealthViewState>(
HealthViewModel.new, HealthViewModel.new,
@@ -14,23 +28,47 @@ final healthViewModelProvider =
class HealthViewModel extends Notifier<HealthViewState> { class HealthViewModel extends Notifier<HealthViewState> {
late final HealthRepository _repository; late final HealthRepository _repository;
late final CommandsRepository _commandsRepository;
Timer? _measureTimer;
static const int _historyPageSize = 20; static const int _historyPageSize = 20;
static const int _measureDurationSeconds = 60;
@override @override
HealthViewState build() { HealthViewState build() {
_repository = ref.read(healthRepositoryProvider); _repository = ref.read(healthRepositoryProvider);
_commandsRepository = ref.read(commandsRepositoryProvider);
_init(); _init();
_resumeMeasureIfNeeded();
return const HealthViewState(); return const HealthViewState();
} }
void _resumeMeasureIfNeeded() {
final endTime = ref.read(_measureEndTimeProvider);
if (endTime == null) return;
final remaining = endTime.difference(DateTime.now()).inSeconds;
if (remaining <= 0) {
ref.read(_measureEndTimeProvider.notifier).set(null);
return;
}
Future.microtask(() {
state = state.copyWith(
isMeasuringCountdown: true,
measureRemainingSeconds: remaining,
);
_startCountdownTimer();
});
}
String? get _identificator => String? get _identificator =>
ref.read(selectedDeviceProvider)?.identificator; ref.read(selectedDeviceProvider)?.identificator;
Future<void> selectTimeRange(TimeRange range) async { Future<void> selectTimeRange(TimeRange range) async {
if (range == state.timeRange) return; if (range == state.timeRange) return;
state = state.copyWith(timeRange: range, isLoading: true); state = state.copyWith(timeRange: range, isLoading: true, errorEvent: null);
await _loadFilteredData(); await _loadFilteredData();
} }
@@ -40,6 +78,7 @@ class HealthViewModel extends Notifier<HealthViewState> {
customStart: start, customStart: start,
customEnd: end, customEnd: end,
isLoading: true, isLoading: true,
errorEvent: null,
); );
await _loadFilteredData(); await _loadFilteredData();
} }
@@ -89,7 +128,7 @@ class HealthViewModel extends Notifier<HealthViewState> {
if (!ref.mounted) return; if (!ref.mounted) return;
state = state.copyWith( state = state.copyWith(
isLoadingMore: false, isLoadingMore: false,
errorMessage: _formatError(e), errorEvent: HealthErrorEvent.loadMore,
); );
} }
} }
@@ -129,7 +168,7 @@ class HealthViewModel extends Notifier<HealthViewState> {
await _loadFilteredData(); await _loadFilteredData();
} catch (e) { } catch (e) {
if (!ref.mounted) return; if (!ref.mounted) return;
state = state.copyWith(isLoading: false, errorMessage: _formatError(e)); state = state.copyWith(isLoading: false, errorEvent: HealthErrorEvent.loadData);
} }
} }
@@ -149,6 +188,8 @@ class HealthViewModel extends Notifier<HealthViewState> {
identificator: identificator, identificator: identificator,
queryParameters: HealthQueryBuilder.build( queryParameters: HealthQueryBuilder.build(
orderDirection: OrderDirection.asc, orderDirection: OrderDirection.asc,
page: 1,
pageSize: 1000,
filters: filters, filters: filters,
), ),
), ),
@@ -156,6 +197,8 @@ class HealthViewModel extends Notifier<HealthViewState> {
identificator: identificator, identificator: identificator,
queryParameters: HealthQueryBuilder.build( queryParameters: HealthQueryBuilder.build(
orderDirection: OrderDirection.asc, orderDirection: OrderDirection.asc,
page: 1,
pageSize: 1000,
filters: filters, filters: filters,
), ),
), ),
@@ -195,11 +238,11 @@ class HealthViewModel extends Notifier<HealthViewState> {
chartOxygens.map((e) => e.oxygen).toList(), chartOxygens.map((e) => e.oxygen).toList(),
), ),
isLoading: false, isLoading: false,
errorMessage: '', errorEvent: null,
); );
} catch (e) { } catch (e) {
if (!ref.mounted) return; if (!ref.mounted) return;
state = state.copyWith(isLoading: false, errorMessage: _formatError(e)); state = state.copyWith(isLoading: false, errorEvent: HealthErrorEvent.loadData);
} }
} }
@@ -239,8 +282,81 @@ class HealthViewModel extends Notifier<HealthViewState> {
); );
} }
String _formatError(Object e) { Future<bool> updateHeartRateFrequency({required int frequency}) async {
final msg = e.toString(); final device = ref.read(selectedDeviceProvider);
return msg.startsWith('Exception: ') ? msg.substring(11) : msg; if (device == null) return false;
try {
final updatedSettings = device.settings.copyWith(
frequencyHeartRate: frequency,
);
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: HealthErrorEvent.heartRateFrequency);
return false;
}
}
Future<void> measure() async {
final device = ref.read(selectedDeviceProvider);
if (device == null) return;
try {
state = state.copyWith(isMeasuring: true, errorEvent: null);
final request = SendCommandRequestModel(
device: device.identificator,
command: DeviceCommand.requestHeartRate,
);
await _commandsRepository.send(request: request);
if (!ref.mounted) return;
ref.read(_measureEndTimeProvider.notifier).set(
DateTime.now().add(const Duration(seconds: _measureDurationSeconds)));
state = state.copyWith(
isMeasuring: false,
isMeasuringCountdown: true,
measureRemainingSeconds: _measureDurationSeconds,
);
_startCountdownTimer();
} catch (e) {
if (!ref.mounted) return;
state = state.copyWith(
isMeasuring: false,
errorEvent: HealthErrorEvent.measure,
);
}
}
void _startCountdownTimer() {
_measureTimer?.cancel();
_measureTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (!ref.mounted) {
timer.cancel();
return;
}
final remaining = state.measureRemainingSeconds - 1;
if (remaining <= 0) {
timer.cancel();
_measureTimer = null;
ref.read(_measureEndTimeProvider.notifier).set(null);
state = state.copyWith(
isMeasuringCountdown: false,
measureRemainingSeconds: 0,
);
_init();
} else {
state = state.copyWith(measureRemainingSeconds: remaining);
}
});
} }
} }

View File

@@ -6,6 +6,13 @@ import '../../domain/entities/oxygen_entity.dart';
part 'health_view_state.freezed.dart'; part 'health_view_state.freezed.dart';
enum HealthErrorEvent {
loadData,
loadMore,
measure,
heartRateFrequency,
}
@freezed @freezed
abstract class HealthStats with _$HealthStats { abstract class HealthStats with _$HealthStats {
const factory HealthStats({ const factory HealthStats({
@@ -33,6 +40,9 @@ abstract class HealthViewState with _$HealthViewState {
@Default(null) DateTime? customEnd, @Default(null) DateTime? customEnd,
@Default(true) bool isLoading, @Default(true) bool isLoading,
@Default(false) bool isLoadingMore, @Default(false) bool isLoadingMore,
@Default('') String errorMessage, @Default(false) bool isMeasuring,
@Default(false) bool isMeasuringCountdown,
@Default(0) int measureRemainingSeconds,
HealthErrorEvent? errorEvent,
}) = _HealthViewState; }) = _HealthViewState;
} }

View File

@@ -277,7 +277,7 @@ as int,
/// @nodoc /// @nodoc
mixin _$HealthViewState { mixin _$HealthViewState {
List<HeartbeatEntity> get latestHeartbeats; List<OxygenEntity> get latestOxygens; List<HeartbeatEntity> get chartHeartbeats; List<OxygenEntity> get chartOxygens; List<HeartbeatEntity> get historyHeartbeats; List<OxygenEntity> get historyOxygens; int get currentHistoryPage; bool get hasMoreHistory; HealthStats get heartRateStats; HealthStats get oxygenStats; TimeRange get timeRange; DateTime? get customStart; DateTime? get customEnd; bool get isLoading; bool get isLoadingMore; String get errorMessage; List<HeartbeatEntity> get latestHeartbeats; List<OxygenEntity> get latestOxygens; List<HeartbeatEntity> get chartHeartbeats; List<OxygenEntity> get chartOxygens; List<HeartbeatEntity> get historyHeartbeats; List<OxygenEntity> get historyOxygens; int get currentHistoryPage; bool get hasMoreHistory; HealthStats get heartRateStats; HealthStats get oxygenStats; TimeRange get timeRange; DateTime? get customStart; DateTime? get customEnd; bool get isLoading; bool get isLoadingMore; bool get isMeasuring; bool get isMeasuringCountdown; int get measureRemainingSeconds; HealthErrorEvent? get errorEvent;
/// Create a copy of HealthViewState /// Create a copy of HealthViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -288,16 +288,16 @@ $HealthViewStateCopyWith<HealthViewState> get copyWith => _$HealthViewStateCopyW
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is HealthViewState&&const DeepCollectionEquality().equals(other.latestHeartbeats, latestHeartbeats)&&const DeepCollectionEquality().equals(other.latestOxygens, latestOxygens)&&const DeepCollectionEquality().equals(other.chartHeartbeats, chartHeartbeats)&&const DeepCollectionEquality().equals(other.chartOxygens, chartOxygens)&&const DeepCollectionEquality().equals(other.historyHeartbeats, historyHeartbeats)&&const DeepCollectionEquality().equals(other.historyOxygens, historyOxygens)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.heartRateStats, heartRateStats) || other.heartRateStats == heartRateStats)&&(identical(other.oxygenStats, oxygenStats) || other.oxygenStats == oxygenStats)&&(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 HealthViewState&&const DeepCollectionEquality().equals(other.latestHeartbeats, latestHeartbeats)&&const DeepCollectionEquality().equals(other.latestOxygens, latestOxygens)&&const DeepCollectionEquality().equals(other.chartHeartbeats, chartHeartbeats)&&const DeepCollectionEquality().equals(other.chartOxygens, chartOxygens)&&const DeepCollectionEquality().equals(other.historyHeartbeats, historyHeartbeats)&&const DeepCollectionEquality().equals(other.historyOxygens, historyOxygens)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.heartRateStats, heartRateStats) || other.heartRateStats == heartRateStats)&&(identical(other.oxygenStats, oxygenStats) || other.oxygenStats == oxygenStats)&&(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.isMeasuring, isMeasuring) || other.isMeasuring == isMeasuring)&&(identical(other.isMeasuringCountdown, isMeasuringCountdown) || other.isMeasuringCountdown == isMeasuringCountdown)&&(identical(other.measureRemainingSeconds, measureRemainingSeconds) || other.measureRemainingSeconds == measureRemainingSeconds)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent));
} }
@override @override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(latestHeartbeats),const DeepCollectionEquality().hash(latestOxygens),const DeepCollectionEquality().hash(chartHeartbeats),const DeepCollectionEquality().hash(chartOxygens),const DeepCollectionEquality().hash(historyHeartbeats),const DeepCollectionEquality().hash(historyOxygens),currentHistoryPage,hasMoreHistory,heartRateStats,oxygenStats,timeRange,customStart,customEnd,isLoading,isLoadingMore,errorMessage); int get hashCode => Object.hashAll([runtimeType,const DeepCollectionEquality().hash(latestHeartbeats),const DeepCollectionEquality().hash(latestOxygens),const DeepCollectionEquality().hash(chartHeartbeats),const DeepCollectionEquality().hash(chartOxygens),const DeepCollectionEquality().hash(historyHeartbeats),const DeepCollectionEquality().hash(historyOxygens),currentHistoryPage,hasMoreHistory,heartRateStats,oxygenStats,timeRange,customStart,customEnd,isLoading,isLoadingMore,isMeasuring,isMeasuringCountdown,measureRemainingSeconds,errorEvent]);
@override @override
String toString() { String toString() {
return 'HealthViewState(latestHeartbeats: $latestHeartbeats, latestOxygens: $latestOxygens, chartHeartbeats: $chartHeartbeats, chartOxygens: $chartOxygens, historyHeartbeats: $historyHeartbeats, historyOxygens: $historyOxygens, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, heartRateStats: $heartRateStats, oxygenStats: $oxygenStats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, errorMessage: $errorMessage)'; return 'HealthViewState(latestHeartbeats: $latestHeartbeats, latestOxygens: $latestOxygens, chartHeartbeats: $chartHeartbeats, chartOxygens: $chartOxygens, historyHeartbeats: $historyHeartbeats, historyOxygens: $historyOxygens, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, heartRateStats: $heartRateStats, oxygenStats: $oxygenStats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, isMeasuring: $isMeasuring, isMeasuringCountdown: $isMeasuringCountdown, measureRemainingSeconds: $measureRemainingSeconds, errorEvent: $errorEvent)';
} }
@@ -308,7 +308,7 @@ abstract mixin class $HealthViewStateCopyWith<$Res> {
factory $HealthViewStateCopyWith(HealthViewState value, $Res Function(HealthViewState) _then) = _$HealthViewStateCopyWithImpl; factory $HealthViewStateCopyWith(HealthViewState value, $Res Function(HealthViewState) _then) = _$HealthViewStateCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, bool isMeasuring, bool isMeasuringCountdown, int measureRemainingSeconds, HealthErrorEvent? errorEvent
}); });
@@ -325,7 +325,7 @@ class _$HealthViewStateCopyWithImpl<$Res>
/// Create a copy of HealthViewState /// Create a copy of HealthViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? latestHeartbeats = null,Object? latestOxygens = null,Object? chartHeartbeats = null,Object? chartOxygens = null,Object? historyHeartbeats = null,Object? historyOxygens = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? heartRateStats = null,Object? oxygenStats = 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? latestHeartbeats = null,Object? latestOxygens = null,Object? chartHeartbeats = null,Object? chartOxygens = null,Object? historyHeartbeats = null,Object? historyOxygens = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? heartRateStats = null,Object? oxygenStats = null,Object? timeRange = null,Object? customStart = freezed,Object? customEnd = freezed,Object? isLoading = null,Object? isLoadingMore = null,Object? isMeasuring = null,Object? isMeasuringCountdown = null,Object? measureRemainingSeconds = null,Object? errorEvent = freezed,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
latestHeartbeats: null == latestHeartbeats ? _self.latestHeartbeats : latestHeartbeats // ignore: cast_nullable_to_non_nullable latestHeartbeats: null == latestHeartbeats ? _self.latestHeartbeats : latestHeartbeats // ignore: cast_nullable_to_non_nullable
as List<HeartbeatEntity>,latestOxygens: null == latestOxygens ? _self.latestOxygens : latestOxygens // ignore: cast_nullable_to_non_nullable as List<HeartbeatEntity>,latestOxygens: null == latestOxygens ? _self.latestOxygens : latestOxygens // ignore: cast_nullable_to_non_nullable
@@ -342,8 +342,11 @@ as TimeRange,customStart: freezed == customStart ? _self.customStart : customSta
as DateTime?,customEnd: freezed == customEnd ? _self.customEnd : customEnd // ignore: cast_nullable_to_non_nullable 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 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,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 bool,isMeasuring: null == isMeasuring ? _self.isMeasuring : isMeasuring // ignore: cast_nullable_to_non_nullable
as String, as bool,isMeasuringCountdown: null == isMeasuringCountdown ? _self.isMeasuringCountdown : isMeasuringCountdown // ignore: cast_nullable_to_non_nullable
as bool,measureRemainingSeconds: null == measureRemainingSeconds ? _self.measureRemainingSeconds : measureRemainingSeconds // ignore: cast_nullable_to_non_nullable
as int,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
as HealthErrorEvent?,
)); ));
} }
/// Create a copy of HealthViewState /// Create a copy of HealthViewState
@@ -446,10 +449,10 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, 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( List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, bool isMeasuring, bool isMeasuringCountdown, int measureRemainingSeconds, HealthErrorEvent? errorEvent)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _HealthViewState() when $default != null: case _HealthViewState() when $default != null:
return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats,_that.chartOxygens,_that.historyHeartbeats,_that.historyOxygens,_that.currentHistoryPage,_that.hasMoreHistory,_that.heartRateStats,_that.oxygenStats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorMessage);case _: return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats,_that.chartOxygens,_that.historyHeartbeats,_that.historyOxygens,_that.currentHistoryPage,_that.hasMoreHistory,_that.heartRateStats,_that.oxygenStats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.isMeasuring,_that.isMeasuringCountdown,_that.measureRemainingSeconds,_that.errorEvent);case _:
return orElse(); return orElse();
} }
@@ -467,10 +470,10 @@ return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, bool isMeasuring, bool isMeasuringCountdown, int measureRemainingSeconds, HealthErrorEvent? errorEvent) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _HealthViewState(): case _HealthViewState():
return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats,_that.chartOxygens,_that.historyHeartbeats,_that.historyOxygens,_that.currentHistoryPage,_that.hasMoreHistory,_that.heartRateStats,_that.oxygenStats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorMessage);case _: return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats,_that.chartOxygens,_that.historyHeartbeats,_that.historyOxygens,_that.currentHistoryPage,_that.hasMoreHistory,_that.heartRateStats,_that.oxygenStats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.isMeasuring,_that.isMeasuringCountdown,_that.measureRemainingSeconds,_that.errorEvent);case _:
throw StateError('Unexpected subclass'); throw StateError('Unexpected subclass');
} }
@@ -487,10 +490,10 @@ return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, bool isMeasuring, bool isMeasuringCountdown, int measureRemainingSeconds, HealthErrorEvent? errorEvent)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _HealthViewState() when $default != null: case _HealthViewState() when $default != null:
return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats,_that.chartOxygens,_that.historyHeartbeats,_that.historyOxygens,_that.currentHistoryPage,_that.hasMoreHistory,_that.heartRateStats,_that.oxygenStats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.errorMessage);case _: return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats,_that.chartOxygens,_that.historyHeartbeats,_that.historyOxygens,_that.currentHistoryPage,_that.hasMoreHistory,_that.heartRateStats,_that.oxygenStats,_that.timeRange,_that.customStart,_that.customEnd,_that.isLoading,_that.isLoadingMore,_that.isMeasuring,_that.isMeasuringCountdown,_that.measureRemainingSeconds,_that.errorEvent);case _:
return null; return null;
} }
@@ -502,7 +505,7 @@ return $default(_that.latestHeartbeats,_that.latestOxygens,_that.chartHeartbeats
class _HealthViewState implements HealthViewState { class _HealthViewState implements HealthViewState {
const _HealthViewState({final List<HeartbeatEntity> latestHeartbeats = const [], final List<OxygenEntity> latestOxygens = const [], final List<HeartbeatEntity> chartHeartbeats = const [], final List<OxygenEntity> chartOxygens = const [], final List<HeartbeatEntity> historyHeartbeats = const [], final List<OxygenEntity> historyOxygens = const [], this.currentHistoryPage = 1, this.hasMoreHistory = false, this.heartRateStats = const HealthStats(), this.oxygenStats = const HealthStats(), this.timeRange = TimeRange.today, this.customStart = null, this.customEnd = null, this.isLoading = true, this.isLoadingMore = false, this.errorMessage = ''}): _latestHeartbeats = latestHeartbeats,_latestOxygens = latestOxygens,_chartHeartbeats = chartHeartbeats,_chartOxygens = chartOxygens,_historyHeartbeats = historyHeartbeats,_historyOxygens = historyOxygens; const _HealthViewState({final List<HeartbeatEntity> latestHeartbeats = const [], final List<OxygenEntity> latestOxygens = const [], final List<HeartbeatEntity> chartHeartbeats = const [], final List<OxygenEntity> chartOxygens = const [], final List<HeartbeatEntity> historyHeartbeats = const [], final List<OxygenEntity> historyOxygens = const [], this.currentHistoryPage = 1, this.hasMoreHistory = false, this.heartRateStats = const HealthStats(), this.oxygenStats = const HealthStats(), this.timeRange = TimeRange.today, this.customStart = null, this.customEnd = null, this.isLoading = true, this.isLoadingMore = false, this.isMeasuring = false, this.isMeasuringCountdown = false, this.measureRemainingSeconds = 0, this.errorEvent}): _latestHeartbeats = latestHeartbeats,_latestOxygens = latestOxygens,_chartHeartbeats = chartHeartbeats,_chartOxygens = chartOxygens,_historyHeartbeats = historyHeartbeats,_historyOxygens = historyOxygens;
final List<HeartbeatEntity> _latestHeartbeats; final List<HeartbeatEntity> _latestHeartbeats;
@@ -556,7 +559,10 @@ class _HealthViewState implements HealthViewState {
@override@JsonKey() final DateTime? customEnd; @override@JsonKey() final DateTime? customEnd;
@override@JsonKey() final bool isLoading; @override@JsonKey() final bool isLoading;
@override@JsonKey() final bool isLoadingMore; @override@JsonKey() final bool isLoadingMore;
@override@JsonKey() final String errorMessage; @override@JsonKey() final bool isMeasuring;
@override@JsonKey() final bool isMeasuringCountdown;
@override@JsonKey() final int measureRemainingSeconds;
@override final HealthErrorEvent? errorEvent;
/// Create a copy of HealthViewState /// Create a copy of HealthViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -568,16 +574,16 @@ _$HealthViewStateCopyWith<_HealthViewState> get copyWith => __$HealthViewStateCo
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _HealthViewState&&const DeepCollectionEquality().equals(other._latestHeartbeats, _latestHeartbeats)&&const DeepCollectionEquality().equals(other._latestOxygens, _latestOxygens)&&const DeepCollectionEquality().equals(other._chartHeartbeats, _chartHeartbeats)&&const DeepCollectionEquality().equals(other._chartOxygens, _chartOxygens)&&const DeepCollectionEquality().equals(other._historyHeartbeats, _historyHeartbeats)&&const DeepCollectionEquality().equals(other._historyOxygens, _historyOxygens)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.heartRateStats, heartRateStats) || other.heartRateStats == heartRateStats)&&(identical(other.oxygenStats, oxygenStats) || other.oxygenStats == oxygenStats)&&(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 _HealthViewState&&const DeepCollectionEquality().equals(other._latestHeartbeats, _latestHeartbeats)&&const DeepCollectionEquality().equals(other._latestOxygens, _latestOxygens)&&const DeepCollectionEquality().equals(other._chartHeartbeats, _chartHeartbeats)&&const DeepCollectionEquality().equals(other._chartOxygens, _chartOxygens)&&const DeepCollectionEquality().equals(other._historyHeartbeats, _historyHeartbeats)&&const DeepCollectionEquality().equals(other._historyOxygens, _historyOxygens)&&(identical(other.currentHistoryPage, currentHistoryPage) || other.currentHistoryPage == currentHistoryPage)&&(identical(other.hasMoreHistory, hasMoreHistory) || other.hasMoreHistory == hasMoreHistory)&&(identical(other.heartRateStats, heartRateStats) || other.heartRateStats == heartRateStats)&&(identical(other.oxygenStats, oxygenStats) || other.oxygenStats == oxygenStats)&&(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.isMeasuring, isMeasuring) || other.isMeasuring == isMeasuring)&&(identical(other.isMeasuringCountdown, isMeasuringCountdown) || other.isMeasuringCountdown == isMeasuringCountdown)&&(identical(other.measureRemainingSeconds, measureRemainingSeconds) || other.measureRemainingSeconds == measureRemainingSeconds)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent));
} }
@override @override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_latestHeartbeats),const DeepCollectionEquality().hash(_latestOxygens),const DeepCollectionEquality().hash(_chartHeartbeats),const DeepCollectionEquality().hash(_chartOxygens),const DeepCollectionEquality().hash(_historyHeartbeats),const DeepCollectionEquality().hash(_historyOxygens),currentHistoryPage,hasMoreHistory,heartRateStats,oxygenStats,timeRange,customStart,customEnd,isLoading,isLoadingMore,errorMessage); int get hashCode => Object.hashAll([runtimeType,const DeepCollectionEquality().hash(_latestHeartbeats),const DeepCollectionEquality().hash(_latestOxygens),const DeepCollectionEquality().hash(_chartHeartbeats),const DeepCollectionEquality().hash(_chartOxygens),const DeepCollectionEquality().hash(_historyHeartbeats),const DeepCollectionEquality().hash(_historyOxygens),currentHistoryPage,hasMoreHistory,heartRateStats,oxygenStats,timeRange,customStart,customEnd,isLoading,isLoadingMore,isMeasuring,isMeasuringCountdown,measureRemainingSeconds,errorEvent]);
@override @override
String toString() { String toString() {
return 'HealthViewState(latestHeartbeats: $latestHeartbeats, latestOxygens: $latestOxygens, chartHeartbeats: $chartHeartbeats, chartOxygens: $chartOxygens, historyHeartbeats: $historyHeartbeats, historyOxygens: $historyOxygens, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, heartRateStats: $heartRateStats, oxygenStats: $oxygenStats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, errorMessage: $errorMessage)'; return 'HealthViewState(latestHeartbeats: $latestHeartbeats, latestOxygens: $latestOxygens, chartHeartbeats: $chartHeartbeats, chartOxygens: $chartOxygens, historyHeartbeats: $historyHeartbeats, historyOxygens: $historyOxygens, currentHistoryPage: $currentHistoryPage, hasMoreHistory: $hasMoreHistory, heartRateStats: $heartRateStats, oxygenStats: $oxygenStats, timeRange: $timeRange, customStart: $customStart, customEnd: $customEnd, isLoading: $isLoading, isLoadingMore: $isLoadingMore, isMeasuring: $isMeasuring, isMeasuringCountdown: $isMeasuringCountdown, measureRemainingSeconds: $measureRemainingSeconds, errorEvent: $errorEvent)';
} }
@@ -588,7 +594,7 @@ abstract mixin class _$HealthViewStateCopyWith<$Res> implements $HealthViewState
factory _$HealthViewStateCopyWith(_HealthViewState value, $Res Function(_HealthViewState) _then) = __$HealthViewStateCopyWithImpl; factory _$HealthViewStateCopyWith(_HealthViewState value, $Res Function(_HealthViewState) _then) = __$HealthViewStateCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, String errorMessage List<HeartbeatEntity> latestHeartbeats, List<OxygenEntity> latestOxygens, List<HeartbeatEntity> chartHeartbeats, List<OxygenEntity> chartOxygens, List<HeartbeatEntity> historyHeartbeats, List<OxygenEntity> historyOxygens, int currentHistoryPage, bool hasMoreHistory, HealthStats heartRateStats, HealthStats oxygenStats, TimeRange timeRange, DateTime? customStart, DateTime? customEnd, bool isLoading, bool isLoadingMore, bool isMeasuring, bool isMeasuringCountdown, int measureRemainingSeconds, HealthErrorEvent? errorEvent
}); });
@@ -605,7 +611,7 @@ class __$HealthViewStateCopyWithImpl<$Res>
/// Create a copy of HealthViewState /// Create a copy of HealthViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? latestHeartbeats = null,Object? latestOxygens = null,Object? chartHeartbeats = null,Object? chartOxygens = null,Object? historyHeartbeats = null,Object? historyOxygens = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? heartRateStats = null,Object? oxygenStats = 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? latestHeartbeats = null,Object? latestOxygens = null,Object? chartHeartbeats = null,Object? chartOxygens = null,Object? historyHeartbeats = null,Object? historyOxygens = null,Object? currentHistoryPage = null,Object? hasMoreHistory = null,Object? heartRateStats = null,Object? oxygenStats = null,Object? timeRange = null,Object? customStart = freezed,Object? customEnd = freezed,Object? isLoading = null,Object? isLoadingMore = null,Object? isMeasuring = null,Object? isMeasuringCountdown = null,Object? measureRemainingSeconds = null,Object? errorEvent = freezed,}) {
return _then(_HealthViewState( return _then(_HealthViewState(
latestHeartbeats: null == latestHeartbeats ? _self._latestHeartbeats : latestHeartbeats // ignore: cast_nullable_to_non_nullable latestHeartbeats: null == latestHeartbeats ? _self._latestHeartbeats : latestHeartbeats // ignore: cast_nullable_to_non_nullable
as List<HeartbeatEntity>,latestOxygens: null == latestOxygens ? _self._latestOxygens : latestOxygens // ignore: cast_nullable_to_non_nullable as List<HeartbeatEntity>,latestOxygens: null == latestOxygens ? _self._latestOxygens : latestOxygens // ignore: cast_nullable_to_non_nullable
@@ -622,8 +628,11 @@ as TimeRange,customStart: freezed == customStart ? _self.customStart : customSta
as DateTime?,customEnd: freezed == customEnd ? _self.customEnd : customEnd // ignore: cast_nullable_to_non_nullable 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 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,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 bool,isMeasuring: null == isMeasuring ? _self.isMeasuring : isMeasuring // ignore: cast_nullable_to_non_nullable
as String, as bool,isMeasuringCountdown: null == isMeasuringCountdown ? _self.isMeasuringCountdown : isMeasuringCountdown // ignore: cast_nullable_to_non_nullable
as bool,measureRemainingSeconds: null == measureRemainingSeconds ? _self.measureRemainingSeconds : measureRemainingSeconds // ignore: cast_nullable_to_non_nullable
as int,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
as HealthErrorEvent?,
)); ));
} }

View File

@@ -42,7 +42,7 @@ class LocateDeviceScreen extends ConsumerWidget {
title: context.translate(I18n.locateSF), title: context.translate(I18n.locateSF),
body: Padding( body: Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: SizeUtils.getByScreen(small: 16, big: 15), horizontal: SizeUtils.getByScreen(small: 20, big: 18),
), ),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,

View File

@@ -46,7 +46,11 @@ class LocateDeviceViewModel extends Notifier<LocateDeviceViewState> {
} }
} }
void resetError() { void reset() {
state = state.copyWith(errorMessage: ''); state = state.copyWith(
isLoading: false,
isComplete: false,
errorMessage: '',
);
} }
} }

View File

@@ -15,10 +15,28 @@ class LocateDeviceDialog extends ConsumerWidget {
final state = ref.watch(locateDeviceViewModelProvider); final state = ref.watch(locateDeviceViewModelProvider);
final vm = ref.read(locateDeviceViewModelProvider.notifier); final vm = ref.read(locateDeviceViewModelProvider.notifier);
ref.listen(
locateDeviceViewModelProvider.select((s) => s.isComplete),
(previous, next) {
if (next && !(previous ?? false)) {
Future.delayed(const Duration(seconds: 1), () {
if (context.mounted) {
Navigator.pop(context);
vm.reset();
}
});
}
},
);
return Container( return Container(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: SizeUtils.getByScreen(small: 32, big: 30), horizontal: SizeUtils.getByScreen(small: 32, big: 30),
vertical: SizeUtils.getByScreen(small: 30, big: 28), vertical: SizeUtils.getByScreen(small: 40, big: 38),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(14)),
color: theme.getColorFor(ThemeCode.backgroundPrimary),
), ),
width: SizeUtils.getByScreen(small: 360, big: 350), width: SizeUtils.getByScreen(small: 360, big: 350),
child: Column( child: Column(
@@ -44,7 +62,7 @@ class LocateDeviceDialog extends ConsumerWidget {
PrimaryButton( PrimaryButton(
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
vm.resetError(); vm.reset();
}, },
text: context.translate(I18n.ok), text: context.translate(I18n.ok),
color: theme.getColorFor(ThemeCode.legacyPrimary), color: theme.getColorFor(ThemeCode.legacyPrimary),

View File

@@ -1,3 +1,5 @@
import 'dart:typed_data';
import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart';
part 'picture_entity.freezed.dart'; part 'picture_entity.freezed.dart';
@@ -6,9 +8,13 @@ part 'picture_entity.freezed.dart';
abstract class PictureEntity with _$PictureEntity { abstract class PictureEntity with _$PictureEntity {
const factory PictureEntity({ const factory PictureEntity({
required String id, required String id,
required String? deviceId, @Default('') String deviceIdentificator,
required DateTime createdAt, String? imgType,
required DateTime takenAt, String? timestamp,
required String asset, @Default('') String fileId,
String? fileName,
String? contentType,
@Default(0) int createdAt,
Uint8List? fileBytes,
}) = _PictureEntity; }) = _PictureEntity;
} }

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$PictureEntity { mixin _$PictureEntity {
String get id; String? get deviceId; DateTime get createdAt; DateTime get takenAt; String get asset; String get id; String get deviceIdentificator; String? get imgType; String? get timestamp; String get fileId; String? get fileName; String? get contentType; int get createdAt; Uint8List? get fileBytes;
/// Create a copy of PictureEntity /// Create a copy of PictureEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $PictureEntityCopyWith<PictureEntity> get copyWith => _$PictureEntityCopyWithImp
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is PictureEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.takenAt, takenAt) || other.takenAt == takenAt)&&(identical(other.asset, asset) || other.asset == asset)); return identical(this, other) || (other.runtimeType == runtimeType&&other is PictureEntity&&(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.fileBytes, fileBytes));
} }
@override @override
int get hashCode => Object.hash(runtimeType,id,deviceId,createdAt,takenAt,asset); int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,imgType,timestamp,fileId,fileName,contentType,createdAt,const DeepCollectionEquality().hash(fileBytes));
@override @override
String toString() { String toString() {
return 'PictureEntity(id: $id, deviceId: $deviceId, createdAt: $createdAt, takenAt: $takenAt, asset: $asset)'; return 'PictureEntity(id: $id, deviceIdentificator: $deviceIdentificator, imgType: $imgType, timestamp: $timestamp, fileId: $fileId, fileName: $fileName, contentType: $contentType, createdAt: $createdAt, fileBytes: $fileBytes)';
} }
@@ -45,7 +45,7 @@ abstract mixin class $PictureEntityCopyWith<$Res> {
factory $PictureEntityCopyWith(PictureEntity value, $Res Function(PictureEntity) _then) = _$PictureEntityCopyWithImpl; factory $PictureEntityCopyWith(PictureEntity value, $Res Function(PictureEntity) _then) = _$PictureEntityCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String id, String? deviceId, DateTime createdAt, DateTime takenAt, String asset String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Uint8List? fileBytes
}); });
@@ -62,14 +62,18 @@ class _$PictureEntityCopyWithImpl<$Res>
/// Create a copy of PictureEntity /// Create a copy of PictureEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? deviceId = freezed,Object? createdAt = null,Object? takenAt = null,Object? asset = null,}) { @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? fileBytes = freezed,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,deviceId: freezed == deviceId ? _self.deviceId : deviceId // 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 String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,takenAt: null == takenAt ? _self.takenAt : takenAt // ignore: cast_nullable_to_non_nullable as int,fileBytes: freezed == fileBytes ? _self.fileBytes : fileBytes // ignore: cast_nullable_to_non_nullable
as DateTime,asset: null == asset ? _self.asset : asset // ignore: cast_nullable_to_non_nullable as Uint8List?,
as String,
)); ));
} }
@@ -154,10 +158,10 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String? deviceId, DateTime createdAt, DateTime takenAt, String asset)? $default,{required TResult orElse(),}) {final _that = this; @optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Uint8List? fileBytes)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _PictureEntity() when $default != null: case _PictureEntity() when $default != null:
return $default(_that.id,_that.deviceId,_that.createdAt,_that.takenAt,_that.asset);case _: return $default(_that.id,_that.deviceIdentificator,_that.imgType,_that.timestamp,_that.fileId,_that.fileName,_that.contentType,_that.createdAt,_that.fileBytes);case _:
return orElse(); return orElse();
} }
@@ -175,10 +179,10 @@ return $default(_that.id,_that.deviceId,_that.createdAt,_that.takenAt,_that.asse
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String? deviceId, DateTime createdAt, DateTime takenAt, String asset) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Uint8List? fileBytes) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _PictureEntity(): case _PictureEntity():
return $default(_that.id,_that.deviceId,_that.createdAt,_that.takenAt,_that.asset);case _: return $default(_that.id,_that.deviceIdentificator,_that.imgType,_that.timestamp,_that.fileId,_that.fileName,_that.contentType,_that.createdAt,_that.fileBytes);case _:
throw StateError('Unexpected subclass'); throw StateError('Unexpected subclass');
} }
@@ -195,10 +199,10 @@ return $default(_that.id,_that.deviceId,_that.createdAt,_that.takenAt,_that.asse
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String? deviceId, DateTime createdAt, DateTime takenAt, String asset)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Uint8List? fileBytes)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _PictureEntity() when $default != null: case _PictureEntity() when $default != null:
return $default(_that.id,_that.deviceId,_that.createdAt,_that.takenAt,_that.asset);case _: return $default(_that.id,_that.deviceIdentificator,_that.imgType,_that.timestamp,_that.fileId,_that.fileName,_that.contentType,_that.createdAt,_that.fileBytes);case _:
return null; return null;
} }
@@ -210,14 +214,18 @@ return $default(_that.id,_that.deviceId,_that.createdAt,_that.takenAt,_that.asse
class _PictureEntity implements PictureEntity { class _PictureEntity implements PictureEntity {
const _PictureEntity({required this.id, required this.deviceId, required this.createdAt, required this.takenAt, required this.asset}); const _PictureEntity({required this.id, this.deviceIdentificator = '', this.imgType, this.timestamp, this.fileId = '', this.fileName, this.contentType, this.createdAt = 0, this.fileBytes});
@override final String id; @override final String id;
@override final String? deviceId; @override@JsonKey() final String deviceIdentificator;
@override final DateTime createdAt; @override final String? imgType;
@override final DateTime takenAt; @override final String? timestamp;
@override final String asset; @override@JsonKey() final String fileId;
@override final String? fileName;
@override final String? contentType;
@override@JsonKey() final int createdAt;
@override final Uint8List? fileBytes;
/// Create a copy of PictureEntity /// Create a copy of PictureEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -229,16 +237,16 @@ _$PictureEntityCopyWith<_PictureEntity> get copyWith => __$PictureEntityCopyWith
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _PictureEntity&&(identical(other.id, id) || other.id == id)&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.takenAt, takenAt) || other.takenAt == takenAt)&&(identical(other.asset, asset) || other.asset == asset)); return identical(this, other) || (other.runtimeType == runtimeType&&other is _PictureEntity&&(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.fileBytes, fileBytes));
} }
@override @override
int get hashCode => Object.hash(runtimeType,id,deviceId,createdAt,takenAt,asset); int get hashCode => Object.hash(runtimeType,id,deviceIdentificator,imgType,timestamp,fileId,fileName,contentType,createdAt,const DeepCollectionEquality().hash(fileBytes));
@override @override
String toString() { String toString() {
return 'PictureEntity(id: $id, deviceId: $deviceId, createdAt: $createdAt, takenAt: $takenAt, asset: $asset)'; return 'PictureEntity(id: $id, deviceIdentificator: $deviceIdentificator, imgType: $imgType, timestamp: $timestamp, fileId: $fileId, fileName: $fileName, contentType: $contentType, createdAt: $createdAt, fileBytes: $fileBytes)';
} }
@@ -249,7 +257,7 @@ abstract mixin class _$PictureEntityCopyWith<$Res> implements $PictureEntityCopy
factory _$PictureEntityCopyWith(_PictureEntity value, $Res Function(_PictureEntity) _then) = __$PictureEntityCopyWithImpl; factory _$PictureEntityCopyWith(_PictureEntity value, $Res Function(_PictureEntity) _then) = __$PictureEntityCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
String id, String? deviceId, DateTime createdAt, DateTime takenAt, String asset String id, String deviceIdentificator, String? imgType, String? timestamp, String fileId, String? fileName, String? contentType, int createdAt, Uint8List? fileBytes
}); });
@@ -266,14 +274,18 @@ class __$PictureEntityCopyWithImpl<$Res>
/// Create a copy of PictureEntity /// Create a copy of PictureEntity
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? deviceId = freezed,Object? createdAt = null,Object? takenAt = null,Object? asset = null,}) { @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? fileBytes = freezed,}) {
return _then(_PictureEntity( return _then(_PictureEntity(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,deviceId: freezed == deviceId ? _self.deviceId : deviceId // 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 String?,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,takenAt: null == takenAt ? _self.takenAt : takenAt // ignore: cast_nullable_to_non_nullable as int,fileBytes: freezed == fileBytes ? _self.fileBytes : fileBytes // ignore: cast_nullable_to_non_nullable
as DateTime,asset: null == asset ? _self.asset : asset // ignore: cast_nullable_to_non_nullable as Uint8List?,
as String,
)); ));
} }

View File

@@ -1,7 +1,9 @@
import 'package:design_system/design_system.dart'; import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:lottie/lottie.dart';
import 'package:device_management/src/features/remote_connection/presentation/state/remote_connection_view_model.dart'; import 'package:device_management/src/features/remote_connection/presentation/state/remote_connection_view_model.dart';
import 'package:device_management/src/features/remote_connection/presentation/state/remote_connection_view_state.dart';
import 'package:device_management/src/features/remote_connection/presentation/widgets/show_picture_dialog.dart'; import 'package:device_management/src/features/remote_connection/presentation/widgets/show_picture_dialog.dart';
import 'package:navigation/navigation.dart'; import 'package:navigation/navigation.dart';
import 'package:sf_localizations/sf_localizations.dart'; import 'package:sf_localizations/sf_localizations.dart';
@@ -17,10 +19,33 @@ class RemoteCameraScreen extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
ref.listen( ref.listen(
remoteConnectionViewModelProvider.select((s) => s.successMessage), remoteConnectionViewModelProvider.select((s) => s.errorEvent),
(_, successMessage) { (_, next) {
if (successMessage.isNotEmpty) { if (next != null) {
showTopSnackbar(context, message: context.translate(successMessage), type: MessageType.success); final message = switch (next) {
RemoteConnectionErrorEvent.takePicture =>
context.translate(I18n.errorTakePicture),
RemoteConnectionErrorEvent.fetchPhotos =>
context.translate(I18n.errorFetchPhotos),
RemoteConnectionErrorEvent.call =>
context.translate(I18n.errorCall),
RemoteConnectionErrorEvent.invalidPhone =>
context.translate(I18n.errorMessagePhoneIsInvalid),
};
showTopSnackbar(context, message: message, type: MessageType.error);
}
},
);
ref.listen(
remoteConnectionViewModelProvider.select((s) => s.successEvent),
(_, next) {
if (next != null) {
final message = switch (next) {
RemoteConnectionSuccessEvent.photoTaken =>
context.translate(I18n.photoTaken),
};
showTopSnackbar(context, message: message, type: MessageType.success);
ref.read(remoteConnectionViewModelProvider.notifier).clearSuccess(); ref.read(remoteConnectionViewModelProvider.notifier).clearSuccess();
} }
}, },
@@ -28,21 +53,38 @@ class RemoteCameraScreen extends ConsumerWidget {
final theme = ref.watch(themePortProvider); final theme = ref.watch(themePortProvider);
final isLoadingPictures = ref.watch( final isLoading = ref.watch(
remoteConnectionViewModelProvider.select((s)=>s.isLoadingPictures) remoteConnectionViewModelProvider.select((s) => s.isLoadingPictures),
); );
final isTakingPicture = ref.watch( final isTaking = ref.watch(
remoteConnectionViewModelProvider.select((s)=>s.isTakingPicture) remoteConnectionViewModelProvider.select((s) => s.isTakingPicture),
); );
final isWaiting = ref.watch(
remoteConnectionViewModelProvider.select((s) => s.isWaitingForPhoto),
);
final countdown = ref.watch(
remoteConnectionViewModelProvider.select((s) => s.photoCountdown),
);
Widget body;
if (isLoading || isTaking) {
body = const Center(child: CircularProgressIndicator());
} else if (isWaiting) {
body = _WaitingForPhotoOverlay(
remainingSeconds: countdown,
theme: theme,
);
} else {
body = const _GallerySection();
}
return LegacyPageLayout( return LegacyPageLayout(
theme: theme, theme: theme,
title: context.translate(I18n.remoteCamera), title: context.translate(I18n.remoteCamera),
body: Expanded(child: isLoadingPictures || isTakingPicture body: body,
? const Center(child: CircularProgressIndicator()) footer: isWaiting
: const _GallerySection() ? const SizedBox.shrink()
), : const _TakePictureSection(),
footer: _TakePictureSection(),
); );
} }
} }
@@ -81,18 +123,19 @@ class _GallerySection extends ConsumerWidget {
)); ));
}, },
child: Container( child: Container(
height: SizeUtils.getByScreen(small: 110, big: 105), height: SizeUtils.getByScreen(small: 120, big: 115),
width: SizeUtils.getByScreen(small: 60, big: 58), width: SizeUtils.getByScreen(small: 80, big: 78),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.fromBorderSide(BorderSide( border: Border.fromBorderSide(BorderSide(
color: theme.getColorFor(ThemeCode.textTertiary) color: theme.getColorFor(ThemeCode.textTertiary)
)) ))
), ),
child: Column( child: pictures[index].fileBytes != null
children: [ ? Image.memory(
Image.asset(pictures[index].asset), pictures[index].fileBytes!,
], fit: BoxFit.cover,
) )
: const Icon(Icons.broken_image, color: Colors.grey),
) )
) )
), ),
@@ -120,9 +163,57 @@ class _TakePictureSection extends ConsumerWidget {
onPressed: vm.takePicture, onPressed: vm.takePicture,
text: context.translate(I18n.takePicture), text: context.translate(I18n.takePicture),
color: theme.getColorFor(ThemeCode.legacyPrimary), color: theme.getColorFor(ThemeCode.legacyPrimary),
height: SizeUtils.getByScreen(small: 36, big: 35), height: SizeUtils.getByScreen(small: 36, big: 38),
),
);
}
}
class _WaitingForPhotoOverlay extends StatelessWidget {
static const String _animationAsset =
'assets/shared/animations/shooting_photo.json';
final int remainingSeconds;
final ThemePort theme;
const _WaitingForPhotoOverlay({
required this.remainingSeconds,
required this.theme,
});
@override
Widget build(BuildContext context) {
final primaryColor = theme.getColorFor(ThemeCode.legacyPrimary);
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Lottie.asset(
_animationAsset,
width: 200,
height: 200,
),
const SizedBox(height: 24),
Text(
context.translate(I18n.takingPhoto),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: primaryColor,
),
),
const SizedBox(height: 12),
Text(
'${remainingSeconds}s',
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
color: primaryColor,
),
),
],
), ),
); );
} }
} }

View File

@@ -1,10 +1,11 @@
import 'dart:async';
import 'package:device_management/src/core/providers/pictures_repository_provider.dart'; import 'package:device_management/src/core/providers/pictures_repository_provider.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart'; import 'package:device_management/src/features/remote_connection/domain/entities/picture_entity.dart';
import 'package:device_management/src/features/remote_connection/presentation/state/remote_connection_view_state.dart'; import 'package:device_management/src/features/remote_connection/presentation/state/remote_connection_view_state.dart';
import 'package:legacy_shared/legacy_shared.dart'; import 'package:legacy_shared/legacy_shared.dart';
import 'package:sf_localizations/sf_localizations.dart';
import '../../../../core/domain/repositories/pictures_repository.dart'; import '../../../../core/domain/repositories/pictures_repository.dart';
@@ -18,8 +19,10 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
late final TextEditingController phoneController; late final TextEditingController phoneController;
late final CommandsRepository _commandsRepository; late final CommandsRepository _commandsRepository;
late final PicturesRepository _picturesRepository; late final PicturesRepository _picturesRepository;
Timer? _photoTimer;
static final RegExp _phoneRegex = RegExp(r'^\+?\d{6,15}$'); static final RegExp _phoneRegex = RegExp(r'^\+?\d{6,15}$');
static const int _photoWaitSeconds = 5;
@override @override
RemoteConnectionViewState build() { RemoteConnectionViewState build() {
@@ -40,19 +43,32 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
final device = ref.read(selectedDeviceProvider); final device = ref.read(selectedDeviceProvider);
if (device == null) return; if (device == null) return;
final pictures = await _picturesRepository.getPictures(deviceId: device.identificator); state = state.copyWith(deviceId: device.identificator);
state = state.copyWith( try {
pictures: pictures, final pictures = await _picturesRepository.getPictures(deviceId: device.identificator);
isLoadingPictures: false, if (!ref.mounted) return;
);
state = state.copyWith(
pictures: pictures,
isLoadingPictures: false,
);
} catch (_) {
if (!ref.mounted) return;
state = state.copyWith(isLoadingPictures: false);
}
} }
void _onPhoneChanged() { void _onPhoneChanged() {
final text = phoneController.text; final text = phoneController.text;
if (text == state.phone) return; if (text == state.phone) return;
state = state.copyWith(phone: text, errorMessage: ''); state = state.copyWith(phone: text, errorEvent: null);
}
void updateDialCode(String value) {
if (value == state.dialCode) return;
state = state.copyWith(dialCode: value, errorEvent: null);
} }
void prevPicture() { void prevPicture() {
@@ -82,16 +98,15 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
} }
void clearSuccess() { void clearSuccess() {
state = state.copyWith( state = state.copyWith(successEvent: null);
successMessage: '',
);
} }
Future<void> takePicture() async { Future<void> takePicture() async {
try { try {
state = state.copyWith( state = state.copyWith(
isTakingPicture: true, isTakingPicture: true,
successMessage: '', successEvent: null,
errorEvent: null,
); );
final request = SendCommandRequestModel( final request = SendCommandRequestModel(
@@ -100,15 +115,61 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
); );
await _commandsRepository.send(request: request); await _commandsRepository.send(request: request);
if (!ref.mounted) return;
state = state.copyWith( state = state.copyWith(
isTakingPicture: false, isTakingPicture: false,
successMessage: I18n.photoTaken isWaitingForPhoto: true,
photoCountdown: _photoWaitSeconds,
); );
} catch (e){
_startPhotoCountdown();
} catch (e) {
if (!ref.mounted) return;
state = state.copyWith( state = state.copyWith(
isTakingPicture: false, isTakingPicture: false,
errorMessage: e.toString(), errorEvent: RemoteConnectionErrorEvent.takePicture,
);
}
}
void _startPhotoCountdown() {
_photoTimer?.cancel();
_photoTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (!ref.mounted) {
timer.cancel();
return;
}
final remaining = state.photoCountdown - 1;
if (remaining <= 0) {
timer.cancel();
_photoTimer = null;
_fetchPhotosAfterCapture();
} else {
state = state.copyWith(photoCountdown: remaining);
}
});
}
Future<void> _fetchPhotosAfterCapture() async {
try {
final pictures = await _picturesRepository.getPictures(
deviceId: state.deviceId,
);
if (!ref.mounted) return;
state = state.copyWith(
isWaitingForPhoto: false,
photoCountdown: 0,
pictures: pictures,
successEvent: RemoteConnectionSuccessEvent.photoTaken,
);
} catch (e) {
if (!ref.mounted) return;
state = state.copyWith(
isWaitingForPhoto: false,
photoCountdown: 0,
errorEvent: RemoteConnectionErrorEvent.fetchPhotos,
); );
} }
} }
@@ -116,37 +177,31 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
Future<void> call() async { Future<void> call() async {
final phone = phoneController.text; final phone = phoneController.text;
final dialCode = state.dialCode; final dialCode = state.dialCode;
if (phone.isEmpty){ if (phone.isEmpty || !_phoneRegex.hasMatch(phone)) {
state = state.copyWith(errorMessage: 'errorMessagePhoneIsEmpty'); state = state.copyWith(errorEvent: RemoteConnectionErrorEvent.invalidPhone);
return;
}
if (!_phoneRegex.hasMatch(phone)) {
state = state.copyWith(errorMessage: 'errorMessagePhoneIsInvalid');
return; return;
} }
try { try {
state = state.copyWith( state = state.copyWith(isCalling: true);
isCalling: true,
);
final fullPhone = dialCode + phone; final fullPhone = dialCode + phone;
final request = SendCommandRequestModel( final request = SendCommandRequestModel(
device: state.deviceId, device: state.deviceId,
command: DeviceCommand.callCenter, command: DeviceCommand.callCenter,
data: { data: {'phone_number': fullPhone},
'phone_number': fullPhone,
}
); );
_commandsRepository.send(request: request); await _commandsRepository.send(request: request);
if (!ref.mounted) return;
state = state.copyWith(isCalling: false);
} catch (e) { } catch (e) {
if (!ref.mounted) return;
state = state.copyWith( state = state.copyWith(
isCalling: false, isCalling: false,
errorMessage: e.toString(), errorEvent: RemoteConnectionErrorEvent.call,
); );
} }
} }
void disposeControllers() { void disposeControllers() {

View File

@@ -3,6 +3,9 @@ import 'package:device_management/src/features/remote_connection/domain/entities
part 'remote_connection_view_state.freezed.dart'; part 'remote_connection_view_state.freezed.dart';
enum RemoteConnectionErrorEvent { takePicture, fetchPhotos, call, invalidPhone }
enum RemoteConnectionSuccessEvent { photoTaken }
@freezed @freezed
abstract class RemoteConnectionViewState with _$RemoteConnectionViewState { abstract class RemoteConnectionViewState with _$RemoteConnectionViewState {
const factory RemoteConnectionViewState({ const factory RemoteConnectionViewState({
@@ -13,8 +16,10 @@ abstract class RemoteConnectionViewState with _$RemoteConnectionViewState {
@Default(0) int pictureIndex, @Default(0) int pictureIndex,
@Default(true) bool isLoadingPictures, @Default(true) bool isLoadingPictures,
@Default(false) bool isTakingPicture, @Default(false) bool isTakingPicture,
@Default(false) bool isWaitingForPhoto,
@Default(0) int photoCountdown,
@Default(false) bool isCalling, @Default(false) bool isCalling,
@Default('') String errorMessage, RemoteConnectionErrorEvent? errorEvent,
@Default('') String successMessage RemoteConnectionSuccessEvent? successEvent,
}) = _RemoteConnectionViewState; }) = _RemoteConnectionViewState;
} }

View File

@@ -14,7 +14,7 @@ T _$identity<T>(T value) => value;
/// @nodoc /// @nodoc
mixin _$RemoteConnectionViewState { mixin _$RemoteConnectionViewState {
String get deviceId; String get dialCode; String get phone; List<PictureEntity> get pictures; int get pictureIndex; bool get isLoadingPictures; bool get isTakingPicture; bool get isCalling; String get errorMessage; String get successMessage; String get deviceId; String get dialCode; String get phone; List<PictureEntity> get pictures; int get pictureIndex; bool get isLoadingPictures; bool get isTakingPicture; bool get isWaitingForPhoto; int get photoCountdown; bool get isCalling; RemoteConnectionErrorEvent? get errorEvent; RemoteConnectionSuccessEvent? get successEvent;
/// Create a copy of RemoteConnectionViewState /// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false) @JsonKey(includeFromJson: false, includeToJson: false)
@@ -25,16 +25,16 @@ $RemoteConnectionViewStateCopyWith<RemoteConnectionViewState> get copyWith => _$
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is RemoteConnectionViewState&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other.pictures, pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.successMessage, successMessage) || other.successMessage == successMessage)); return identical(this, other) || (other.runtimeType == runtimeType&&other is RemoteConnectionViewState&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other.pictures, pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isWaitingForPhoto, isWaitingForPhoto) || other.isWaitingForPhoto == isWaitingForPhoto)&&(identical(other.photoCountdown, photoCountdown) || other.photoCountdown == photoCountdown)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent)&&(identical(other.successEvent, successEvent) || other.successEvent == successEvent));
} }
@override @override
int get hashCode => Object.hash(runtimeType,deviceId,dialCode,phone,const DeepCollectionEquality().hash(pictures),pictureIndex,isLoadingPictures,isTakingPicture,isCalling,errorMessage,successMessage); int get hashCode => Object.hash(runtimeType,deviceId,dialCode,phone,const DeepCollectionEquality().hash(pictures),pictureIndex,isLoadingPictures,isTakingPicture,isWaitingForPhoto,photoCountdown,isCalling,errorEvent,successEvent);
@override @override
String toString() { String toString() {
return 'RemoteConnectionViewState(deviceId: $deviceId, dialCode: $dialCode, phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isCalling: $isCalling, errorMessage: $errorMessage, successMessage: $successMessage)'; return 'RemoteConnectionViewState(deviceId: $deviceId, dialCode: $dialCode, phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isWaitingForPhoto: $isWaitingForPhoto, photoCountdown: $photoCountdown, isCalling: $isCalling, errorEvent: $errorEvent, successEvent: $successEvent)';
} }
@@ -45,7 +45,7 @@ abstract mixin class $RemoteConnectionViewStateCopyWith<$Res> {
factory $RemoteConnectionViewStateCopyWith(RemoteConnectionViewState value, $Res Function(RemoteConnectionViewState) _then) = _$RemoteConnectionViewStateCopyWithImpl; factory $RemoteConnectionViewStateCopyWith(RemoteConnectionViewState value, $Res Function(RemoteConnectionViewState) _then) = _$RemoteConnectionViewStateCopyWithImpl;
@useResult @useResult
$Res call({ $Res call({
String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isWaitingForPhoto, int photoCountdown, bool isCalling, RemoteConnectionErrorEvent? errorEvent, RemoteConnectionSuccessEvent? successEvent
}); });
@@ -62,7 +62,7 @@ class _$RemoteConnectionViewStateCopyWithImpl<$Res>
/// Create a copy of RemoteConnectionViewState /// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? deviceId = null,Object? dialCode = null,Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isCalling = null,Object? errorMessage = null,Object? successMessage = null,}) { @pragma('vm:prefer-inline') @override $Res call({Object? deviceId = null,Object? dialCode = null,Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isWaitingForPhoto = null,Object? photoCountdown = null,Object? isCalling = null,Object? errorEvent = freezed,Object? successEvent = freezed,}) {
return _then(_self.copyWith( return _then(_self.copyWith(
deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
@@ -71,10 +71,12 @@ as String,pictures: null == pictures ? _self.pictures : pictures // ignore: cast
as List<PictureEntity>,pictureIndex: null == pictureIndex ? _self.pictureIndex : pictureIndex // ignore: cast_nullable_to_non_nullable as List<PictureEntity>,pictureIndex: null == pictureIndex ? _self.pictureIndex : pictureIndex // ignore: cast_nullable_to_non_nullable
as int,isLoadingPictures: null == isLoadingPictures ? _self.isLoadingPictures : isLoadingPictures // ignore: cast_nullable_to_non_nullable as int,isLoadingPictures: null == isLoadingPictures ? _self.isLoadingPictures : isLoadingPictures // ignore: cast_nullable_to_non_nullable
as bool,isTakingPicture: null == isTakingPicture ? _self.isTakingPicture : isTakingPicture // ignore: cast_nullable_to_non_nullable as bool,isTakingPicture: null == isTakingPicture ? _self.isTakingPicture : isTakingPicture // ignore: cast_nullable_to_non_nullable
as bool,isCalling: null == isCalling ? _self.isCalling : isCalling // ignore: cast_nullable_to_non_nullable as bool,isWaitingForPhoto: null == isWaitingForPhoto ? _self.isWaitingForPhoto : isWaitingForPhoto // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as bool,photoCountdown: null == photoCountdown ? _self.photoCountdown : photoCountdown // ignore: cast_nullable_to_non_nullable
as String,successMessage: null == successMessage ? _self.successMessage : successMessage // ignore: cast_nullable_to_non_nullable as int,isCalling: null == isCalling ? _self.isCalling : isCalling // ignore: cast_nullable_to_non_nullable
as String, as bool,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
as RemoteConnectionErrorEvent?,successEvent: freezed == successEvent ? _self.successEvent : successEvent // ignore: cast_nullable_to_non_nullable
as RemoteConnectionSuccessEvent?,
)); ));
} }
@@ -159,10 +161,10 @@ return $default(_that);case _:
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage)? $default,{required TResult orElse(),}) {final _that = this; @optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isWaitingForPhoto, int photoCountdown, bool isCalling, RemoteConnectionErrorEvent? errorEvent, RemoteConnectionSuccessEvent? successEvent)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) { switch (_that) {
case _RemoteConnectionViewState() when $default != null: case _RemoteConnectionViewState() when $default != null:
return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage,_that.successMessage);case _: return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isWaitingForPhoto,_that.photoCountdown,_that.isCalling,_that.errorEvent,_that.successEvent);case _:
return orElse(); return orElse();
} }
@@ -180,10 +182,10 @@ return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.p
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage) $default,) {final _that = this; @optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isWaitingForPhoto, int photoCountdown, bool isCalling, RemoteConnectionErrorEvent? errorEvent, RemoteConnectionSuccessEvent? successEvent) $default,) {final _that = this;
switch (_that) { switch (_that) {
case _RemoteConnectionViewState(): case _RemoteConnectionViewState():
return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage,_that.successMessage);case _: return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isWaitingForPhoto,_that.photoCountdown,_that.isCalling,_that.errorEvent,_that.successEvent);case _:
throw StateError('Unexpected subclass'); throw StateError('Unexpected subclass');
} }
@@ -200,10 +202,10 @@ return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.p
/// } /// }
/// ``` /// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage)? $default,) {final _that = this; @optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isWaitingForPhoto, int photoCountdown, bool isCalling, RemoteConnectionErrorEvent? errorEvent, RemoteConnectionSuccessEvent? successEvent)? $default,) {final _that = this;
switch (_that) { switch (_that) {
case _RemoteConnectionViewState() when $default != null: case _RemoteConnectionViewState() when $default != null:
return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isCalling,_that.errorMessage,_that.successMessage);case _: return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.pictureIndex,_that.isLoadingPictures,_that.isTakingPicture,_that.isWaitingForPhoto,_that.photoCountdown,_that.isCalling,_that.errorEvent,_that.successEvent);case _:
return null; return null;
} }
@@ -215,7 +217,7 @@ return $default(_that.deviceId,_that.dialCode,_that.phone,_that.pictures,_that.p
class _RemoteConnectionViewState implements RemoteConnectionViewState { class _RemoteConnectionViewState implements RemoteConnectionViewState {
const _RemoteConnectionViewState({this.deviceId = '', this.dialCode = '+34', this.phone = '', final List<PictureEntity> pictures = const [], this.pictureIndex = 0, this.isLoadingPictures = true, this.isTakingPicture = false, this.isCalling = false, this.errorMessage = '', this.successMessage = ''}): _pictures = pictures; const _RemoteConnectionViewState({this.deviceId = '', this.dialCode = '+34', this.phone = '', final List<PictureEntity> pictures = const [], this.pictureIndex = 0, this.isLoadingPictures = true, this.isTakingPicture = false, this.isWaitingForPhoto = false, this.photoCountdown = 0, this.isCalling = false, this.errorEvent, this.successEvent}): _pictures = pictures;
@override@JsonKey() final String deviceId; @override@JsonKey() final String deviceId;
@@ -231,9 +233,11 @@ class _RemoteConnectionViewState implements RemoteConnectionViewState {
@override@JsonKey() final int pictureIndex; @override@JsonKey() final int pictureIndex;
@override@JsonKey() final bool isLoadingPictures; @override@JsonKey() final bool isLoadingPictures;
@override@JsonKey() final bool isTakingPicture; @override@JsonKey() final bool isTakingPicture;
@override@JsonKey() final bool isWaitingForPhoto;
@override@JsonKey() final int photoCountdown;
@override@JsonKey() final bool isCalling; @override@JsonKey() final bool isCalling;
@override@JsonKey() final String errorMessage; @override final RemoteConnectionErrorEvent? errorEvent;
@override@JsonKey() final String successMessage; @override final RemoteConnectionSuccessEvent? successEvent;
/// Create a copy of RemoteConnectionViewState /// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@@ -245,16 +249,16 @@ _$RemoteConnectionViewStateCopyWith<_RemoteConnectionViewState> get copyWith =>
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _RemoteConnectionViewState&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other._pictures, _pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorMessage, errorMessage) || other.errorMessage == errorMessage)&&(identical(other.successMessage, successMessage) || other.successMessage == successMessage)); return identical(this, other) || (other.runtimeType == runtimeType&&other is _RemoteConnectionViewState&&(identical(other.deviceId, deviceId) || other.deviceId == deviceId)&&(identical(other.dialCode, dialCode) || other.dialCode == dialCode)&&(identical(other.phone, phone) || other.phone == phone)&&const DeepCollectionEquality().equals(other._pictures, _pictures)&&(identical(other.pictureIndex, pictureIndex) || other.pictureIndex == pictureIndex)&&(identical(other.isLoadingPictures, isLoadingPictures) || other.isLoadingPictures == isLoadingPictures)&&(identical(other.isTakingPicture, isTakingPicture) || other.isTakingPicture == isTakingPicture)&&(identical(other.isWaitingForPhoto, isWaitingForPhoto) || other.isWaitingForPhoto == isWaitingForPhoto)&&(identical(other.photoCountdown, photoCountdown) || other.photoCountdown == photoCountdown)&&(identical(other.isCalling, isCalling) || other.isCalling == isCalling)&&(identical(other.errorEvent, errorEvent) || other.errorEvent == errorEvent)&&(identical(other.successEvent, successEvent) || other.successEvent == successEvent));
} }
@override @override
int get hashCode => Object.hash(runtimeType,deviceId,dialCode,phone,const DeepCollectionEquality().hash(_pictures),pictureIndex,isLoadingPictures,isTakingPicture,isCalling,errorMessage,successMessage); int get hashCode => Object.hash(runtimeType,deviceId,dialCode,phone,const DeepCollectionEquality().hash(_pictures),pictureIndex,isLoadingPictures,isTakingPicture,isWaitingForPhoto,photoCountdown,isCalling,errorEvent,successEvent);
@override @override
String toString() { String toString() {
return 'RemoteConnectionViewState(deviceId: $deviceId, dialCode: $dialCode, phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isCalling: $isCalling, errorMessage: $errorMessage, successMessage: $successMessage)'; return 'RemoteConnectionViewState(deviceId: $deviceId, dialCode: $dialCode, phone: $phone, pictures: $pictures, pictureIndex: $pictureIndex, isLoadingPictures: $isLoadingPictures, isTakingPicture: $isTakingPicture, isWaitingForPhoto: $isWaitingForPhoto, photoCountdown: $photoCountdown, isCalling: $isCalling, errorEvent: $errorEvent, successEvent: $successEvent)';
} }
@@ -265,7 +269,7 @@ abstract mixin class _$RemoteConnectionViewStateCopyWith<$Res> implements $Remot
factory _$RemoteConnectionViewStateCopyWith(_RemoteConnectionViewState value, $Res Function(_RemoteConnectionViewState) _then) = __$RemoteConnectionViewStateCopyWithImpl; factory _$RemoteConnectionViewStateCopyWith(_RemoteConnectionViewState value, $Res Function(_RemoteConnectionViewState) _then) = __$RemoteConnectionViewStateCopyWithImpl;
@override @useResult @override @useResult
$Res call({ $Res call({
String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isCalling, String errorMessage, String successMessage String deviceId, String dialCode, String phone, List<PictureEntity> pictures, int pictureIndex, bool isLoadingPictures, bool isTakingPicture, bool isWaitingForPhoto, int photoCountdown, bool isCalling, RemoteConnectionErrorEvent? errorEvent, RemoteConnectionSuccessEvent? successEvent
}); });
@@ -282,7 +286,7 @@ class __$RemoteConnectionViewStateCopyWithImpl<$Res>
/// Create a copy of RemoteConnectionViewState /// Create a copy of RemoteConnectionViewState
/// with the given fields replaced by the non-null parameter values. /// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? deviceId = null,Object? dialCode = null,Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isCalling = null,Object? errorMessage = null,Object? successMessage = null,}) { @override @pragma('vm:prefer-inline') $Res call({Object? deviceId = null,Object? dialCode = null,Object? phone = null,Object? pictures = null,Object? pictureIndex = null,Object? isLoadingPictures = null,Object? isTakingPicture = null,Object? isWaitingForPhoto = null,Object? photoCountdown = null,Object? isCalling = null,Object? errorEvent = freezed,Object? successEvent = freezed,}) {
return _then(_RemoteConnectionViewState( return _then(_RemoteConnectionViewState(
deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable deviceId: null == deviceId ? _self.deviceId : deviceId // ignore: cast_nullable_to_non_nullable
as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable as String,dialCode: null == dialCode ? _self.dialCode : dialCode // ignore: cast_nullable_to_non_nullable
@@ -291,10 +295,12 @@ as String,pictures: null == pictures ? _self._pictures : pictures // ignore: cas
as List<PictureEntity>,pictureIndex: null == pictureIndex ? _self.pictureIndex : pictureIndex // ignore: cast_nullable_to_non_nullable as List<PictureEntity>,pictureIndex: null == pictureIndex ? _self.pictureIndex : pictureIndex // ignore: cast_nullable_to_non_nullable
as int,isLoadingPictures: null == isLoadingPictures ? _self.isLoadingPictures : isLoadingPictures // ignore: cast_nullable_to_non_nullable as int,isLoadingPictures: null == isLoadingPictures ? _self.isLoadingPictures : isLoadingPictures // ignore: cast_nullable_to_non_nullable
as bool,isTakingPicture: null == isTakingPicture ? _self.isTakingPicture : isTakingPicture // ignore: cast_nullable_to_non_nullable as bool,isTakingPicture: null == isTakingPicture ? _self.isTakingPicture : isTakingPicture // ignore: cast_nullable_to_non_nullable
as bool,isCalling: null == isCalling ? _self.isCalling : isCalling // ignore: cast_nullable_to_non_nullable as bool,isWaitingForPhoto: null == isWaitingForPhoto ? _self.isWaitingForPhoto : isWaitingForPhoto // ignore: cast_nullable_to_non_nullable
as bool,errorMessage: null == errorMessage ? _self.errorMessage : errorMessage // ignore: cast_nullable_to_non_nullable as bool,photoCountdown: null == photoCountdown ? _self.photoCountdown : photoCountdown // ignore: cast_nullable_to_non_nullable
as String,successMessage: null == successMessage ? _self.successMessage : successMessage // ignore: cast_nullable_to_non_nullable as int,isCalling: null == isCalling ? _self.isCalling : isCalling // ignore: cast_nullable_to_non_nullable
as String, as bool,errorEvent: freezed == errorEvent ? _self.errorEvent : errorEvent // ignore: cast_nullable_to_non_nullable
as RemoteConnectionErrorEvent?,successEvent: freezed == successEvent ? _self.successEvent : successEvent // ignore: cast_nullable_to_non_nullable
as RemoteConnectionSuccessEvent?,
)); ));
} }

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