fixed remote connection dialogs and edit contact screen
This commit is contained in:
@@ -14,12 +14,14 @@ class FunctionsRepositoryImpl implements FunctionsRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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);
|
return _remote.getPictures(userId: userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@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);
|
return _remote.takePicture(userId: userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,22 +100,26 @@ class EditContactScreen extends ConsumerWidget {
|
|||||||
hint: contact.phone,
|
hint: contact.phone,
|
||||||
label: context.translate('Phone number'),
|
label: context.translate('Phone number'),
|
||||||
),
|
),
|
||||||
Align(
|
SizedBox(
|
||||||
alignment: Alignment.centerRight,
|
height: SizeUtils.getByScreen(small: 90, big: 85),
|
||||||
child: IconButton(
|
child: Align(
|
||||||
onPressed: (){},
|
alignment: Alignment.bottomRight,
|
||||||
icon: DecoratedBox(
|
child: IconButton(
|
||||||
decoration: BoxDecoration(
|
onPressed: (){},
|
||||||
shape: BoxShape.circle,
|
icon: DecoratedBox(
|
||||||
color: Color(0xFF588EA5)
|
decoration: BoxDecoration(
|
||||||
),
|
shape: BoxShape.circle,
|
||||||
child: Icon(
|
color: Color(0xFF588EA5)
|
||||||
SFIcons.contactsCircle,
|
),
|
||||||
color: Colors.white,
|
child: Icon(
|
||||||
|
SFIcons.contactsCircle,
|
||||||
|
color: Colors.white,
|
||||||
|
size: SizeUtils.getByScreen(small: 40, big: 38),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -48,22 +48,22 @@ class RemoteCameraScreen extends ConsumerWidget {
|
|||||||
big: EdgeInsets.symmetric(vertical: 10, horizontal: 25)
|
big: EdgeInsets.symmetric(vertical: 10, horizontal: 25)
|
||||||
),
|
),
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
showDialog(context: context, builder: (context)=>Dialog(
|
showDialog(context: context, builder: (context)=>Dialog(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: SizeUtils.getByScreen(
|
padding: SizeUtils.getByScreen(
|
||||||
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
small: EdgeInsets.symmetric(horizontal: 32, vertical: 30),
|
||||||
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
big: EdgeInsets.symmetric(horizontal: 30, vertical: 28)
|
||||||
),
|
),
|
||||||
width: SizeUtils.getByScreen(small: 360, big: 350),
|
width: SizeUtils.getByScreen(small: 360, big: 350),
|
||||||
height: SizeUtils.getByScreen(small: 195, big: 185),
|
height: SizeUtils.getByScreen(small: 195, big: 185),
|
||||||
child: Text(context.translate('Loading photo...'),
|
child: Center(child: Text(context.translate('Loading photo...'),
|
||||||
textAlign: TextAlign.center,
|
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);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
text: context.translate('Take a picture'),
|
text: context.translate('Take a picture'),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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:functions/src/features/remote_connection/presentation/remote_camera_screen.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:legacy_shared/legacy_shared.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,6 +18,9 @@ class RemoteConnectionScreen extends ConsumerWidget {
|
|||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
// final theme = ref.watch(themePortProvider);
|
// final theme = ref.watch(themePortProvider);
|
||||||
|
|
||||||
|
final viewModel = ref.read(remoteConnectionViewModelProvider.notifier);
|
||||||
|
final viewState = ref.watch(remoteConnectionViewModelProvider);
|
||||||
|
|
||||||
return PageLayout(
|
return PageLayout(
|
||||||
title: 'Remote Connection',
|
title: 'Remote Connection',
|
||||||
body: SingleChildScrollView(child: Container(
|
body: SingleChildScrollView(child: Container(
|
||||||
@@ -35,7 +39,10 @@ class RemoteConnectionScreen extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
SizedBox(height: SizeUtils.getByScreen(small: 16, big: 15)),
|
||||||
AppSectionButton(
|
AppSectionButton(
|
||||||
onPressed: (){},
|
onPressed: (){showDialog(context: context, builder: (context)=>Dialog(
|
||||||
|
child: CallDialog(
|
||||||
|
)
|
||||||
|
));},
|
||||||
icon: SFIcons.listen,
|
icon: SFIcons.listen,
|
||||||
text: 'Remote listening'
|
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 {
|
class AppSectionButton extends ConsumerWidget {
|
||||||
|
|
||||||
final GestureTapCallback onPressed;
|
final GestureTapCallback onPressed;
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
|
|||||||
late final GetPicturesUseCase _getPicturesUseCase;
|
late final GetPicturesUseCase _getPicturesUseCase;
|
||||||
late final TakePictureUseCase _takePictureUseCase;
|
late final TakePictureUseCase _takePictureUseCase;
|
||||||
|
|
||||||
late final TextEditingController nameController;
|
|
||||||
late final TextEditingController phoneController;
|
late final TextEditingController phoneController;
|
||||||
|
|
||||||
// late final UserEntity loggedUser;
|
// late final UserEntity loggedUser;
|
||||||
|
|
||||||
|
static final RegExp _phoneRegex = RegExp(r'^\+?\d{6,15}$');
|
||||||
|
|
||||||
@override
|
@override
|
||||||
RemoteConnectionViewState build() {
|
RemoteConnectionViewState build() {
|
||||||
_getPicturesUseCase = ref.read(getPicturesUseCaseProvider);
|
_getPicturesUseCase = ref.read(getPicturesUseCaseProvider);
|
||||||
@@ -35,7 +36,7 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
|
|||||||
|
|
||||||
phoneController.addListener(_onPhoneChanged);
|
phoneController.addListener(_onPhoneChanged);
|
||||||
|
|
||||||
// _getPicturesUseCase.getImages(userId: '').then(setImages);
|
_getPicturesUseCase.getPictures(userId: '').then(setImages);
|
||||||
|
|
||||||
ref.onDispose(disposeControllers);
|
ref.onDispose(disposeControllers);
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
|
|||||||
|
|
||||||
void setImages(List<PictureEntity> pictures) {
|
void setImages(List<PictureEntity> pictures) {
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
pictures: pictures
|
pictures: pictures
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,17 +56,16 @@ class RemoteConnectionViewModel extends Notifier<RemoteConnectionViewState> {
|
|||||||
state = state.copyWith(phone: text, errorMessage: '');
|
state = state.copyWith(phone: text, errorMessage: '');
|
||||||
}
|
}
|
||||||
|
|
||||||
void takePicture() {
|
Future<void> takePicture() async {
|
||||||
try {
|
try {
|
||||||
state = state.copyWith(isTakingPicture: true);
|
state = state.copyWith(isTakingPicture: true);
|
||||||
|
|
||||||
_takePictureUseCase.takePicture(userId: '')
|
await _takePictureUseCase.takePicture(userId: '')
|
||||||
.then((picture) {
|
.then((picture) {
|
||||||
List<PictureEntity> pictures = state.pictures;
|
List<PictureEntity> pictures = state.pictures;
|
||||||
pictures.add(picture);
|
//pictures.add(picture);
|
||||||
state = state.copyWith(
|
state = state.copyWith(
|
||||||
isTakingPicture: true,
|
isTakingPicture: true,
|
||||||
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
} catch (e){
|
} 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() {
|
void disposeControllers() {
|
||||||
phoneController.removeListener(_onPhoneChanged);
|
phoneController.removeListener(_onPhoneChanged);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user