parent
34123689de
commit
14d035ecc9
|
|
@ -5,12 +5,14 @@ class DialogRequest {
|
|||
final String description;
|
||||
final String buttonTitle;
|
||||
final String cancelTitle;
|
||||
final String formatType;
|
||||
|
||||
DialogRequest(
|
||||
{@required this.title,
|
||||
@required this.description,
|
||||
@required this.buttonTitle,
|
||||
this.cancelTitle});
|
||||
this.cancelTitle,
|
||||
this.formatType});
|
||||
}
|
||||
|
||||
class DialogResponse {
|
||||
|
|
|
|||
|
|
@ -132,10 +132,12 @@ class ApiService extends BaseService {
|
|||
HttpHeaders.contentTypeHeader: "multipart/form-data",
|
||||
HttpHeaders.cacheControlHeader: "no-cache"
|
||||
};
|
||||
|
||||
if(Platform.isAndroid) {
|
||||
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
|
||||
headers.addAll(<String, String>{
|
||||
HttpHeaders.userAgentHeader: androidInfo.model,
|
||||
"mob_agent" : "e40c519e7a24d0c93530fd362023afa0",
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -143,8 +145,10 @@ class ApiService extends BaseService {
|
|||
IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
|
||||
headers.addAll(<String, String>{
|
||||
HttpHeaders.userAgentHeader: iosInfo.utsname.machine,
|
||||
"mob_agent" : "fbd69e994b6251837ba82a08c6f68307",
|
||||
});
|
||||
}
|
||||
|
||||
String url = '$endpoint$point';
|
||||
if(this._test) {
|
||||
url = '$test_endpoint$point';
|
||||
|
|
@ -161,7 +165,7 @@ class ApiService extends BaseService {
|
|||
Response check = Response.fromJsonDynamic(json.decode(body));
|
||||
if (!check.operation && ( [401,402,403,412].contains(check.status) ) ) {
|
||||
|
||||
var future = new Future.delayed(const Duration(milliseconds: 1000), (){
|
||||
new Future.delayed(const Duration(milliseconds: 1000), (){
|
||||
_dialogService.showDialog(description: 'Необходимо пройти повторную авторизацию');
|
||||
UserState state = Redux.store.state.userState;
|
||||
_navigatorService.replace(LoginViewRoute, arguments: LoginModel(authType: state.authenticateType, login: state.login, password: state.password ));
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ class DialogService {
|
|||
GlobalKey<NavigatorState> get dialogNavigationKey => _dialogNavigationKey;
|
||||
|
||||
/// Registers a callback function. Typically to show the dialog
|
||||
void registerDialogListener(Function(DialogRequest) showDialogListener, Function(DialogRequest) showDialogInputListener) {
|
||||
void registerDialogListener(Function(DialogRequest) showDialogListener,
|
||||
Function(DialogRequest) showDialogInputListener) {
|
||||
_showDialogListener = showDialogListener;
|
||||
_showDialogInputListener = showDialogInputListener;
|
||||
}
|
||||
|
|
@ -50,16 +51,18 @@ class DialogService {
|
|||
}
|
||||
|
||||
Future<DialogResponse> showConfirmationDialogInput(
|
||||
{String title =' Aman Касса',
|
||||
{String title = ' Aman Касса',
|
||||
String description,
|
||||
String confirmationTitle = 'Ok',
|
||||
String cancelTitle = 'Cancel'}) {
|
||||
String cancelTitle = 'Cancel',
|
||||
String formatType}) {
|
||||
_dialogCompleter = Completer<DialogResponse>();
|
||||
_showDialogInputListener(DialogRequest(
|
||||
title: title,
|
||||
description: description,
|
||||
buttonTitle: confirmationTitle,
|
||||
cancelTitle: cancelTitle));
|
||||
cancelTitle: cancelTitle,
|
||||
formatType: formatType));
|
||||
return _dialogCompleter.future;
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +72,4 @@ class DialogService {
|
|||
_dialogCompleter.complete(response);
|
||||
_dialogCompleter = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,3 +186,7 @@ Future<void> openSmena(Store<AppState> store) async {
|
|||
store.dispatch(checkMoney);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> openSmenaPseudo(Store<AppState> store) async {
|
||||
store.dispatch(SetUserStateAction(UserState(smena: Smena(startedAt: DateTime.now() ))));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ class _MyFloatingActionButtonState extends State<MyFloatingActionButton> {
|
|||
description: 'Номер телефона',
|
||||
cancelTitle: 'Отмена',
|
||||
confirmationTitle: 'Отправить',
|
||||
formatType: 'phone'
|
||||
);
|
||||
if (response.confirmed) {
|
||||
String phoneNumber = response.responseText;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class HeaderTitle extends StatelessWidget {
|
|||
vm.smena.message !=null
|
||||
? Text(vm.smena.message, style: TextStyle(fontSize: 13, color: redColor) )
|
||||
: vm.smena.startedAt !=null
|
||||
? Text('Смена от: ${dateFormat.format(vm.smena.startedAt)}', overflow: TextOverflow.fade, maxLines: 1, softWrap: false , style: TextStyle(fontSize: 13, color: Colors.black),)
|
||||
? Text('Смена открыта', overflow: TextOverflow.fade, maxLines: 1, softWrap: false , style: TextStyle(fontSize: 13, color: Colors.black),)
|
||||
: Text('Смена от:', style: TextStyle(fontSize: 13, color: Colors.black),),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@ class _LoginViewState extends State<LoginView> {
|
|||
controller: passwordController,
|
||||
fieldFocusNode: passwordNode,
|
||||
additionalNote: vm.loginFormMessage.password,
|
||||
enterPressed: _pressBtnEnter),
|
||||
enterPressed: _pressBtnEnter,
|
||||
textInputAction: TextInputAction.done,
|
||||
),
|
||||
verticalSpaceMedium,
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ class _PaymentViewState extends State<PaymentView> {
|
|||
Redux.store.dispatch(cleanKassaItems);
|
||||
}
|
||||
Redux.store.dispatch(checkMoney);
|
||||
Redux.store.dispatch(openSmenaPseudo);
|
||||
Navigator.of(_keyLoader.currentContext, rootNavigator: true).pop();
|
||||
_navigatorService.pop();
|
||||
_navigatorService.push(ImageShowRoute,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
|||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mask_text_input_formatter/mask_text_input_formatter.dart';
|
||||
|
||||
class DialogManager extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
|
@ -15,18 +16,18 @@ class DialogManager extends StatefulWidget {
|
|||
|
||||
class _DialogManagerState extends State<DialogManager> {
|
||||
final DialogService _dialogService = locator<DialogService>();
|
||||
TextEditingController controller;
|
||||
TextEditingController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = new TextEditingController();
|
||||
_controller = new TextEditingController();
|
||||
_dialogService.registerDialogListener(_showDialog, _showDialogInput);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
controller.dispose();
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +78,13 @@ class _DialogManagerState extends State<DialogManager> {
|
|||
|
||||
void _showDialogInput(DialogRequest request) {
|
||||
var isConfirmationDialog = request.cancelTitle != null;
|
||||
controller.clear();
|
||||
|
||||
_controller.clear();
|
||||
|
||||
var maskFormatter = new MaskTextInputFormatter(
|
||||
mask: '+% (###) ###-##-##',
|
||||
filter: {"#": RegExp(r'[0-9]'), "%": RegExp(r'[7]')});
|
||||
|
||||
var dialogController = showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
|
|
@ -101,14 +108,20 @@ class _DialogManagerState extends State<DialogManager> {
|
|||
//Text(request.description),
|
||||
TextField(
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(labelText: request.description),
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
labelText: request.description,
|
||||
hintText: request.formatType == "phone"
|
||||
? "+7 (123) 456-78-90"
|
||||
: ""),
|
||||
controller: _controller,
|
||||
onSubmitted: (value) {
|
||||
_dialogService
|
||||
.dialogComplete(DialogResponse(confirmed: false));
|
||||
},
|
||||
keyboardType: TextInputType.phone,
|
||||
inputFormatters: <TextInputFormatter>[
|
||||
if (request.formatType == "phone") maskFormatter,
|
||||
if (request.formatType == null)
|
||||
WhitelistingTextInputFormatter(RegExp("^[0-9.]*")),
|
||||
],
|
||||
)
|
||||
|
|
@ -137,8 +150,12 @@ class _DialogManagerState extends State<DialogManager> {
|
|||
style: TextStyle(fontSize: 18),
|
||||
),
|
||||
onPressed: () {
|
||||
_dialogService.dialogComplete(DialogResponse(
|
||||
confirmed: true, responseText: controller.text));
|
||||
String _result = _controller.text;
|
||||
if (request.formatType == "phone") {
|
||||
_result = maskFormatter.getUnmaskedText();
|
||||
}
|
||||
_dialogService.dialogComplete(
|
||||
DialogResponse(confirmed: true, responseText: _result));
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ packages:
|
|||
name: equatable
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
version: "1.2.2"
|
||||
esys_flutter_share:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -309,7 +309,7 @@ packages:
|
|||
name: provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.3.0"
|
||||
version: "4.3.1"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
name: aman_kassa_flutter
|
||||
description: A new Flutter project.
|
||||
version: 1.0.0+8
|
||||
version: 1.0.1+21
|
||||
environment:
|
||||
sdk: '>=2.3.0 <3.0.0'
|
||||
dependencies:
|
||||
|
|
@ -13,10 +13,10 @@ dependencies:
|
|||
redux_persist: ^0.8.4
|
||||
redux_persist_flutter: ^0.8.2
|
||||
responsive_builder: ^0.2.0+2
|
||||
provider: ^4.3.0
|
||||
provider: ^4.3.1
|
||||
logger: ^0.9.1
|
||||
get_it: ^4.0.2
|
||||
equatable: ^1.2.0
|
||||
equatable: ^1.2.2
|
||||
http: ^0.12.1
|
||||
sqflite: ^1.3.1
|
||||
path_provider: ^1.6.11
|
||||
|
|
|
|||
Loading…
Reference in New Issue