diff --git a/modules/legacy/modules/functions/lib/src/core/data/repositories/functions_repository_impl.dart b/modules/legacy/modules/functions/lib/src/core/data/repositories/functions_repository_impl.dart index 05b906cb..bd6969d5 100644 --- a/modules/legacy/modules/functions/lib/src/core/data/repositories/functions_repository_impl.dart +++ b/modules/legacy/modules/functions/lib/src/core/data/repositories/functions_repository_impl.dart @@ -14,12 +14,14 @@ class FunctionsRepositoryImpl implements FunctionsRepository { } @override - Future> getPictures({required String userId}) { + Future> getPictures({required String userId}) async { + await Future.delayed(const Duration(milliseconds: 2000)); return _remote.getPictures(userId: userId); } @override - Future takePicture({required String userId}) { + Future takePicture({required String userId}) async { + await Future.delayed(const Duration(milliseconds: 2000)); return _remote.takePicture(userId: userId); } } diff --git a/modules/legacy/modules/functions/lib/src/features/contacts/presentation/edit_contact_screen.dart b/modules/legacy/modules/functions/lib/src/features/contacts/presentation/edit_contact_screen.dart index 519fdf98..eba3b459 100644 --- a/modules/legacy/modules/functions/lib/src/features/contacts/presentation/edit_contact_screen.dart +++ b/modules/legacy/modules/functions/lib/src/features/contacts/presentation/edit_contact_screen.dart @@ -100,22 +100,26 @@ class EditContactScreen extends ConsumerWidget { hint: contact.phone, label: context.translate('Phone number'), ), - Align( - alignment: Alignment.centerRight, - child: IconButton( - onPressed: (){}, - icon: DecoratedBox( - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Color(0xFF588EA5) - ), - child: Icon( - SFIcons.contactsCircle, - color: Colors.white, + SizedBox( + height: SizeUtils.getByScreen(small: 90, big: 85), + child: Align( + alignment: Alignment.bottomRight, + child: IconButton( + onPressed: (){}, + icon: DecoratedBox( + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Color(0xFF588EA5) + ), + child: Icon( + SFIcons.contactsCircle, + color: Colors.white, + size: SizeUtils.getByScreen(small: 40, big: 38), + ) ) - ) + ), ), - ) + ), ], ) ], diff --git a/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_camera_screen.dart b/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_camera_screen.dart index 9d4fc72f..12afa923 100644 --- a/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_camera_screen.dart +++ b/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_camera_screen.dart @@ -48,22 +48,22 @@ class RemoteCameraScreen extends ConsumerWidget { big: EdgeInsets.symmetric(vertical: 10, horizontal: 25) ), child: PrimaryButton( - onPressed: () { + onPressed: () async { showDialog(context: context, builder: (context)=>Dialog( child: Container( padding: SizeUtils.getByScreen( - small: EdgeInsets.symmetric(horizontal: 32, vertical: 30), - big: EdgeInsets.symmetric(horizontal: 30, vertical: 28) + small: EdgeInsets.symmetric(horizontal: 32, vertical: 30), + big: EdgeInsets.symmetric(horizontal: 30, vertical: 28) ), width: SizeUtils.getByScreen(small: 360, big: 350), height: SizeUtils.getByScreen(small: 195, big: 185), - child: Text(context.translate('Loading photo...'), + child: Center(child: Text(context.translate('Loading photo...'), textAlign: TextAlign.center, - style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)), - ), + style: TextStyle(fontSize: SizeUtils.getByScreen(small: 26, big: 25)), + )), ), )); - viewModel.takePicture(); + await viewModel.takePicture(); Navigator.pop(context); }, text: context.translate('Take a picture'), diff --git a/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_connection_screen.dart b/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_connection_screen.dart index 17e0d416..06c92051 100644 --- a/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_connection_screen.dart +++ b/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/remote_connection_screen.dart @@ -3,6 +3,7 @@ import 'package:design_system/design_system.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:functions/src/features/remote_connection/presentation/remote_camera_screen.dart'; +import 'package:functions/src/features/remote_connection/presentation/state/remote_connection_view_model.dart'; import 'package:legacy_shared/legacy_shared.dart'; import 'package:navigation/navigation.dart'; import 'package:sf_localizations/sf_localizations.dart'; @@ -17,6 +18,9 @@ class RemoteConnectionScreen extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { // final theme = ref.watch(themePortProvider); + final viewModel = ref.read(remoteConnectionViewModelProvider.notifier); + final viewState = ref.watch(remoteConnectionViewModelProvider); + return PageLayout( title: 'Remote Connection', body: SingleChildScrollView(child: Container( @@ -35,7 +39,10 @@ class RemoteConnectionScreen extends ConsumerWidget { ), SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)), AppSectionButton( - onPressed: (){}, + onPressed: (){showDialog(context: context, builder: (context)=>Dialog( + child: CallDialog( + ) + ));}, icon: SFIcons.listen, text: 'Remote listening' ), @@ -46,6 +53,75 @@ class RemoteConnectionScreen extends ConsumerWidget { } } +class CallDialog extends ConsumerWidget { + + @override + Widget build(BuildContext context, WidgetRef ref) { + + final viewModel = ref.read(remoteConnectionViewModelProvider.notifier); + final viewState = ref.watch(remoteConnectionViewModelProvider); + + return Container( + padding: SizeUtils.getByScreen( + small: EdgeInsets.symmetric(horizontal: 26, vertical: 20), + big: EdgeInsets.symmetric(horizontal: 24, vertical: 18) + ), + width: SizeUtils.getByScreen(small: 390, big: 380), + height: SizeUtils.getByScreen(small: 250, big: 243), + child: Column( + children: [ + Stack( + children: [ + Center(child: Text(context.translate('Remote listening'), + textAlign: TextAlign.center, + style: TextStyle(fontSize: SizeUtils.getByScreen(small: 19, big: 18)), + )), + Align( + alignment: Alignment.centerRight, + child: IconButton( + onPressed: (){Navigator.pop(context);}, + icon: Icon(Icons.close, color: Color(0xFF588EA5)), + ) + ) + ], + ), + SizedBox(height: SizeUtils.getByScreen(small: 8, big: 7)), + CustomTextField( + controller: viewModel.phoneController, + hint: context.translate('Insert your phone number'), + keyboardType: TextInputType.number, + ), + if (viewState.errorMessage.isNotEmpty) ...[ + const SizedBox(height: 4), + Text( + viewState.errorMessage, + textAlign: TextAlign.center, + style: const TextStyle( + color: Color.fromRGBO(239, 17, 17, 1), + fontSize: 12, + ), + ), + ], + SizedBox(height: SizeUtils.getByScreen(small: 28, big: 27)), + PrimaryButton( + onPressed: () async { + await viewModel.call(); + if (viewState.errorMessage.isEmpty){ + Navigator.pop(context); + } + }, + text: context.translate('Call me'), + color: Color(0xFF588EA5), + height: SizeUtils.getByScreen(small: 38, big: 36), + radius: SizeUtils.getByScreen(small: 32, big: 34), + ), + ], + ), + ); + } + +} + class AppSectionButton extends ConsumerWidget { final GestureTapCallback onPressed; diff --git a/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/state/remote_connection_view_model.dart b/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/state/remote_connection_view_model.dart index b7b8f03a..5f56e935 100644 --- a/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/state/remote_connection_view_model.dart +++ b/modules/legacy/modules/functions/lib/src/features/remote_connection/presentation/state/remote_connection_view_model.dart @@ -19,11 +19,12 @@ class RemoteConnectionViewModel extends Notifier { late final GetPicturesUseCase _getPicturesUseCase; late final TakePictureUseCase _takePictureUseCase; - late final TextEditingController nameController; late final TextEditingController phoneController; // late final UserEntity loggedUser; + static final RegExp _phoneRegex = RegExp(r'^\+?\d{6,15}$'); + @override RemoteConnectionViewState build() { _getPicturesUseCase = ref.read(getPicturesUseCaseProvider); @@ -35,7 +36,7 @@ class RemoteConnectionViewModel extends Notifier { phoneController.addListener(_onPhoneChanged); - // _getPicturesUseCase.getImages(userId: '').then(setImages); + _getPicturesUseCase.getPictures(userId: '').then(setImages); ref.onDispose(disposeControllers); @@ -44,7 +45,7 @@ class RemoteConnectionViewModel extends Notifier { void setImages(List pictures) { state = state.copyWith( - pictures: pictures + pictures: pictures ); } @@ -55,17 +56,16 @@ class RemoteConnectionViewModel extends Notifier { state = state.copyWith(phone: text, errorMessage: ''); } - void takePicture() { + Future takePicture() async { try { state = state.copyWith(isTakingPicture: true); - _takePictureUseCase.takePicture(userId: '') + await _takePictureUseCase.takePicture(userId: '') .then((picture) { List pictures = state.pictures; - pictures.add(picture); + //pictures.add(picture); state = state.copyWith( isTakingPicture: true, - ); }); } catch (e){ @@ -76,6 +76,19 @@ class RemoteConnectionViewModel extends Notifier { } } + Future call() async { + final phone = phoneController.text; + if (phone.isEmpty){ + state = state.copyWith(errorMessage: 'errorMessagePhoneIsEmpty'); + return; + } + if (!_phoneRegex.hasMatch(phone)) { + state = state.copyWith(errorMessage: 'errorMessagePhoneIsInvalid'); + return; + } + + } + void disposeControllers() { phoneController.removeListener(_onPhoneChanged);