fixed remote connection dialogs and edit contact screen

This commit is contained in:
2026-02-11 11:57:45 +01:00
parent 46b7ba4a1d
commit f8ff70c35d
5 changed files with 126 additions and 31 deletions

View File

@@ -14,12 +14,14 @@ class FunctionsRepositoryImpl implements FunctionsRepository {
}
@override
Future<List<PictureEntity>> getPictures({required String userId}) {
Future<List<PictureEntity>> getPictures({required String userId}) async {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.getPictures(userId: userId);
}
@override
Future<PictureEntity> takePicture({required String userId}) {
Future<PictureEntity> takePicture({required String userId}) async {
await Future<void>.delayed(const Duration(milliseconds: 2000));
return _remote.takePicture(userId: userId);
}
}

View File

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

View File

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

View File

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

View File

@@ -19,11 +19,12 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
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<RemoteConnectionViewState> {
phoneController.addListener(_onPhoneChanged);
// _getPicturesUseCase.getImages(userId: '').then(setImages);
_getPicturesUseCase.getPictures(userId: '').then(setImages);
ref.onDispose(disposeControllers);
@@ -44,7 +45,7 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
void setImages(List<PictureEntity> pictures) {
state = state.copyWith(
pictures: pictures
pictures: pictures
);
}
@@ -55,17 +56,16 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
state = state.copyWith(phone: text, errorMessage: '');
}
void takePicture() {
Future<void> takePicture() async {
try {
state = state.copyWith(isTakingPicture: true);
_takePictureUseCase.takePicture(userId: '')
await _takePictureUseCase.takePicture(userId: '')
.then((picture) {
List<PictureEntity> pictures = state.pictures;
pictures.add(picture);
//pictures.add(picture);
state = state.copyWith(
isTakingPicture: true,
);
});
} catch (e){
@@ -76,6 +76,19 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
}
}
Future<void> 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);