| @@ -2,6 +2,7 @@ import 'dart:io'; | |||
| import 'package:camera/camera.dart'; | |||
| import 'package:farm_tpf/main.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | |||
| import 'package:file_picker/file_picker.dart'; | |||
| import 'package:flutter/material.dart'; | |||
| import 'package:get/get.dart'; | |||
| @@ -221,7 +222,7 @@ class _CameraHelperState extends State<CameraHelper> | |||
| String timestamp() => DateTime.now().millisecondsSinceEpoch.toString(); | |||
| void showInSnackBar(String message) { | |||
| _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message))); | |||
| Utils.showSnackBarError(message: message); | |||
| } | |||
| void onNewCameraSelected(CameraDescription cameraDescription) async { | |||
| @@ -1,6 +1,7 @@ | |||
| import 'package:dio/dio.dart'; | |||
| import 'package:farm_tpf/custom_model/Device.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | |||
| import 'package:farm_tpf/presentation/screens/control_device/bloc/device_bloc.dart'; | |||
| import 'package:farm_tpf/utils/const_common.dart'; | |||
| import 'package:farm_tpf/utils/pref.dart'; | |||
| @@ -198,36 +199,12 @@ class _WidgetDeviceListState extends State<WidgetDeviceList> { | |||
| if (200 <= response.statusCode && response.statusCode < 299) { | |||
| BlocProvider.of<DeviceBloc>(_context).add(ControlDevice( | |||
| currentDevices: currentDevices, updatedDeviceId: item.id)); | |||
| Scaffold.of(context) | |||
| ..hideCurrentSnackBar() | |||
| ..showSnackBar( | |||
| SnackBar( | |||
| content: Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: <Widget>[ | |||
| Text('Điều khiển thành công thiết bị ${item.name}'), | |||
| Icon(Icons.done), | |||
| ], | |||
| ), | |||
| backgroundColor: Colors.green, | |||
| ), | |||
| ); | |||
| Utils.showSnackBarSuccess( | |||
| message: 'Điều khiển thành công thiết bị ${item.name}'); | |||
| } | |||
| } catch (error) { | |||
| Scaffold.of(context) | |||
| ..hideCurrentSnackBar() | |||
| ..showSnackBar( | |||
| SnackBar( | |||
| content: Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: <Widget>[ | |||
| Text('Điều khiển thiết bị ${item.name} thất bại'), | |||
| Icon(Icons.error), | |||
| ], | |||
| ), | |||
| backgroundColor: Colors.red, | |||
| ), | |||
| ); | |||
| Utils.showSnackBarError( | |||
| message: 'Điều khiển thiết bị ${item.name} thất bại'); | |||
| } | |||
| LoadingDialog.hideLoadingDialog(_context); | |||
| }, | |||
| @@ -1,6 +1,7 @@ | |||
| import 'package:farm_tpf/authentication/authentication.dart'; | |||
| import 'package:farm_tpf/data/repository/authentication_repository.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; | |||
| import 'package:farm_tpf/presentation/custom_widgets/widget_utils.dart'; | |||
| import 'package:farm_tpf/presentation/screens/forgot_password/sc_forgot_password.dart'; | |||
| import 'package:farm_tpf/presentation/screens/login/bloc/login_bloc.dart'; | |||
| import 'package:farm_tpf/utils/const_color.dart'; | |||
| @@ -20,19 +21,8 @@ class LoginForm extends StatelessWidget { | |||
| listener: (context, state) { | |||
| if (state.status.isSubmissionFailure) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||
| Scaffold.of(context) | |||
| ..hideCurrentSnackBar() | |||
| ..showSnackBar( | |||
| SnackBar( | |||
| content: Row( | |||
| mainAxisAlignment: MainAxisAlignment.spaceBetween, | |||
| children: <Widget>[ | |||
| Text('Tài khoản hoặc mật khẩu không đúng.'), | |||
| Icon(Icons.error), | |||
| ], | |||
| ), | |||
| backgroundColor: Colors.red), | |||
| ); | |||
| Utils.showSnackBarError( | |||
| message: 'Tài khoản hoặc mật khẩu không đúng.'); | |||
| } | |||
| if (state.status.isSubmissionSuccess) { | |||
| LoadingDialog.hideLoadingDialog(context); | |||