Serik.Uvaissov 2020-06-30 20:24:59 +06:00
commit 3a526d8592
11 changed files with 245 additions and 173 deletions

View File

@ -129,7 +129,6 @@
083B51CCB3E82741428E2D55 /* Pods-Runner.release.xcconfig */,
EAB5ED0AB808F923C6D318D5 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
@ -169,8 +168,9 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = YS3FKPC7Y7;
DevelopmentTeam = 94BM6VL7L8;
LastSwiftMigration = 1100;
ProvisioningStyle = Automatic;
};
};
};
@ -384,8 +384,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YS3FKPC7Y7;
DEVELOPMENT_TEAM = 94BM6VL7L8;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -397,10 +399,12 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.amanKassaFlutter;
PRODUCT_BUNDLE_IDENTIFIER = com.kz.amankassaflutter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Profile;
@ -519,8 +523,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YS3FKPC7Y7;
DEVELOPMENT_TEAM = 94BM6VL7L8;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -532,11 +538,13 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.amanKassaFlutter;
PRODUCT_BUNDLE_IDENTIFIER = com.kz.amankassaflutter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@ -547,8 +555,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YS3FKPC7Y7;
DEVELOPMENT_TEAM = 94BM6VL7L8;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -560,10 +570,12 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.amanKassaFlutter;
PRODUCT_BUNDLE_IDENTIFIER = com.kz.amankassaflutter;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;

View File

@ -1,4 +1,5 @@
class Money {
final num total;
Money({this.total});
final bool loading;
Money({this.total, this.loading});
}

View File

@ -23,6 +23,7 @@ class SetUserStateAction {
final UserState userState;
SetUserStateAction(this.userState);
}
final ApiService _api = locator<ApiService>();
final NavigatorService _navigation = locator<NavigatorService>();
final DialogService _dialogService = locator<DialogService>();
@ -32,7 +33,7 @@ Future<void> checkUserAction(Store<AppState> store) async {
try {
String token = store.state.userState.user?.token;
bool isAuthenticated = false;
if(token!=null) {
if (token != null) {
Response<Message> session = await _api.isActive(token);
isAuthenticated = "OK" == session.body.message;
} else {
@ -47,20 +48,17 @@ Future<void> checkUserAction(Store<AppState> store) async {
),
);
if(!isAuthenticated){
if (!isAuthenticated) {
_navigation.replace(LoginViewRoute);
} else {
_navigation.replace(HomeViewRoute);
}
} catch (error) {
print(error);
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
}
}
Future<void> logoutAction(Store<AppState> store) async {
try {
store.dispatch(
@ -79,14 +77,21 @@ Future<void> logoutAction(Store<AppState> store) async {
}
Future<Response<dynamic>> checkMoney(Store<AppState> store) async {
store.dispatch(SetUserStateAction(UserState(money: Money(loading: true))));
try {
Response<dynamic> result = await _api.money(store.state.userState.user.token);
Response<dynamic> result =
await _api.money(store.state.userState.user.token);
if (result.operation) {
store.dispatch(SetUserStateAction(
UserState(money: Money(total: double.parse(result.body['money'])))));
store.dispatch(SetUserStateAction(UserState(
money: Money(
total: double.parse(result.body['money']), loading: false))));
} else {
store.dispatch(
SetUserStateAction(UserState(money: Money(loading: false))));
}
return result;
} catch (error) {
store.dispatch(SetUserStateAction(UserState(money: Money(loading: false))));
return null;
}
}
@ -95,21 +100,26 @@ ThunkAction<AppState> authenticateToken(String token) {
return (Store<AppState> store) async {
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
try {
AuthBody result = await _api.authenticate_token(token, statusCheck: false);
AuthBody result =
await _api.authenticate_token(token, statusCheck: false);
store.dispatch(SetUserStateAction(UserState(
isLoading: false,
loginFormMessage: LoginFormMessage(email: result.email?.join(","), password: result.password?.join(","), message: result.message),
loginFormMessage: LoginFormMessage(
email: result.email?.join(","),
password: result.password?.join(","),
message: result.message),
user: result.user,
authenticateType: AuthenticateTypeQr,
isAuthenticated: result.user != null,
)));
if(result.user == null && result.message!=null){
_dialogService.showDialog(title: 'Warning', buttonTitle: 'Ok', description: result.message);
if (result.user == null && result.message != null) {
_dialogService.showDialog(
title: 'Warning', buttonTitle: 'Ok', description: result.message);
}
if(result.user!=null) {
if (result.user != null) {
_navigation.replace(HomeViewRoute);
}
} catch(e) {
} catch (e) {
print(e);
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
}
@ -120,23 +130,28 @@ ThunkAction<AppState> authenticate(String email, String password) {
return (Store<AppState> store) async {
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
try {
AuthBody result = await _api.authenticate(email, password, statusCheck: false);
AuthBody result =
await _api.authenticate(email, password, statusCheck: false);
store.dispatch(SetUserStateAction(UserState(
isLoading: false,
loginFormMessage: LoginFormMessage(email: result.email?.join(","), password: result.password?.join(","), message: result.message),
loginFormMessage: LoginFormMessage(
email: result.email?.join(","),
password: result.password?.join(","),
message: result.message),
user: result.user,
login: email,
password: password,
authenticateType: AuthenticateTypeLogin,
isAuthenticated: result.user != null,
)));
if(result.user == null && result.message!=null){
_dialogService.showDialog(title: 'Warning', buttonTitle: 'Ok', description: result.message);
if (result.user == null && result.message != null) {
_dialogService.showDialog(
title: 'Warning', buttonTitle: 'Ok', description: result.message);
}
if(result.user!=null) {
if (result.user != null) {
_navigation.replace(HomeViewRoute);
}
} catch(e) {
} catch (e) {
print(e);
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
}
@ -160,7 +175,7 @@ Future<void> openSmena(Store<AppState> store) async {
String token = store.state.userState.user.token;
Response<Smena> result = await _api.openSmena(token);
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
if(result.operation){
if (result.operation) {
store.dispatch(checkSmena);
store.dispatch(checkMoney);
}

View File

@ -38,11 +38,11 @@ class UserState {
authenticateType: payload?.authenticateType ?? null,
login: payload?.login ?? null,
password: payload?.password ?? null,
money: Money(),
money: Money(loading: false),
);
UserState copyWith(
{@required bool isError,
UserState copyWith({
@required bool isError,
@required bool isLoading,
@required User user,
@required bool isAuthenticated,
@ -73,8 +73,7 @@ class UserState {
user: User.fromJson(json['user']),
authenticateType: json['authenticateType'],
login: json['login'],
password: json['password']
)
password: json['password'])
: null;
}

View File

@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
// Box Decorations
BoxDecoration fieldDecortaion = BoxDecoration(
borderRadius: BorderRadius.circular(5), color: Colors.white);
BoxDecoration fieldDecortaion =
BoxDecoration(borderRadius: BorderRadius.circular(5), color: Colors.white);
BoxDecoration disabledFieldDecortaion = BoxDecoration(
borderRadius: BorderRadius.circular(5), color: Colors.grey[100]);
@ -20,14 +20,23 @@ const EdgeInsets largeFieldPadding =
const EdgeInsets.symmetric(horizontal: 15, vertical: 15);
// Text Variables
const TextStyle productTextStyle = const TextStyle(fontWeight: FontWeight.w400, color: Colors.black, fontSize: 15);
const TextStyle buttonTitleTextStyle = const TextStyle(fontWeight: FontWeight.w700, color: whiteColor, fontSize: 15);
const TextStyle buttonBigTitleTextStyle = const TextStyle(fontWeight: FontWeight.w700, color: whiteColor, fontSize: 22, );
const TextStyle dropDownTradeTypeTextStyle = TextStyle( color: Colors.black54, fontWeight: FontWeight.bold, fontSize: 24);
const TextStyle productTextStyle = const TextStyle(
fontWeight: FontWeight.w400, color: Colors.black, fontSize: 15);
const TextStyle buttonTitleTextStyle = const TextStyle(
fontWeight: FontWeight.w700, color: whiteColor, fontSize: 14);
const TextStyle buttonBigTitleTextStyle = const TextStyle(
fontWeight: FontWeight.w700,
color: whiteColor,
fontSize: 22,
);
const TextStyle dropDownTradeTypeTextStyle =
TextStyle(color: Colors.black54, fontWeight: FontWeight.bold, fontSize: 24);
// Box Shadow
const BoxShadow mainShadowBox = BoxShadow(blurRadius: 16, color: shadowColor, offset: Offset(0, 5));
const BoxShadow buttonShadowBox = BoxShadow(blurRadius: 5, color: Colors.grey, offset: Offset(0, 1));
const BoxShadow cardShadowBox = BoxShadow(blurRadius: 5, color: Colors.black26, offset: Offset(0, 5));
const BoxShadow mainShadowBox =
BoxShadow(blurRadius: 16, color: shadowColor, offset: Offset(0, 5));
const BoxShadow buttonShadowBox =
BoxShadow(blurRadius: 5, color: Colors.grey, offset: Offset(0, 1));
const BoxShadow cardShadowBox =
BoxShadow(blurRadius: 5, color: Colors.black26, offset: Offset(0, 5));

View File

@ -104,7 +104,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
Response<dynamic> result = await _api.deposit(
Redux.store.state.userState.user.token, response.responseText);
_dialog.showDialog(description: result.body['message']);
if(result.operation) {
if (result.operation) {
await Redux.store.dispatch(checkMoney);
}
}
@ -131,7 +131,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
Response<dynamic> result = await _api.withdrawal(
Redux.store.state.userState.user.token, response.responseText);
_dialog.showDialog(description: result.body['message']);
if(result.operation) {
if (result.operation) {
await Redux.store.dispatch(checkMoney);
}
}
@ -149,19 +149,10 @@ class _AdditionalTabState extends State<AdditionalTab> {
isMoneyCheckBusy = true;
});
try {
Response<dynamic> result = await Redux.store.dispatch(checkMoney);
//await _api.money(.state.userState.user.token);
await Redux.store.dispatch(checkMoney);
setState(() {
isMoneyCheckBusy = false;
});
if(result != null) {
if (result.operation) {
_dialog.showDialog(
description: 'Денег в кассе: ${result.body['money']}');
} else {
_dialog.showDialog(description: '${result.body['message']}');
}
}
} catch (e) {
print(e);
setState(() {
@ -221,17 +212,42 @@ class _AdditionalTabState extends State<AdditionalTab> {
'Денег в кассе:',
style: TextStyle(color: primaryColor, fontSize: 15),
),
StoreConnector<AppState,Money>(
SizedBox(
height: 50,
width: double.infinity,
child: StoreConnector<AppState, Money>(
converter: (store) => store.state.userState.money,
builder: (_, vm) {
return Text(
vm.total !=null ? '${vm.total} тенге' : 'нет информации',
style: TextStyle(
color: vm.total !=null ? primaryColor : Colors.grey.withOpacity(0.5),
fontSize: 25,
fontWeight: FontWeight.bold),
if (vm.loading == true) {
return Center(
child: SizedBox(
width: 30,
height: 30,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: new AlwaysStoppedAnimation<Color>(
primaryColor),
),
),
),
);
}
return Center(
child: Text(
vm.total != null
? '${vm.total} тенге'
: 'нет информации',
style: TextStyle(
color: vm.total != null
? primaryColor
: Colors.grey.withOpacity(0.5),
fontSize: 25,
fontWeight: FontWeight.bold),
),
);
}),
),
],
)),

View File

@ -15,10 +15,7 @@ import 'package:aman_kassa_flutter/widgets/components/calculator/calculator-butt
import 'package:aman_kassa_flutter/widgets/components/calculator/number-display.dart';
import 'package:flutter_redux/flutter_redux.dart';
class CalculatorTab extends StatelessWidget {
NavigatorService _navigatorService = locator<NavigatorService>();
final int index;
@ -33,36 +30,40 @@ class CalculatorTab extends StatelessWidget {
StoreConnector<AppState, CalcState>(
converter: (store) => store.state.calcState,
builder: (context, vm) {
return NumberDisplay(value: Calculator.parseItems(vm.calcItems, vm.isEqual));
}
),
return NumberDisplay(
value: Calculator.parseItems(vm.calcItems, vm.isEqual));
}),
CalculatorButtons(onTap: _onPress),
Row(
children: <Widget>[
Expanded(
child: RaisedButton(
padding: EdgeInsets.all(8.0),
padding: EdgeInsets.all(16.0),
color: redColor,
child: Text(
"возврат",
style: buttonBigTitleTextStyle,
),
onPressed: () {
_navigatorService.push(PaymentViewRoute, arguments: PaymentModel(mode: SettingModeCalc, operationType: OperationTypeReturn) );
}
),
_navigatorService.push(PaymentViewRoute,
arguments: PaymentModel(
mode: SettingModeCalc,
operationType: OperationTypeReturn));
}),
),
Expanded(
child: RaisedButton(
padding: EdgeInsets.all(8.0),
padding: EdgeInsets.all(16.0),
color: greenColor,
child: Text(
"оплата",
style: buttonBigTitleTextStyle,
),
onPressed: () {
_navigatorService.push(PaymentViewRoute, arguments: PaymentModel(mode: SettingModeCalc, operationType: OperationTypePay) );
_navigatorService.push(PaymentViewRoute,
arguments: PaymentModel(
mode: SettingModeCalc,
operationType: OperationTypePay));
},
),
),
@ -73,9 +74,7 @@ class CalculatorTab extends StatelessWidget {
));
}
void _onPress({ String buttonText}) {
void _onPress({String buttonText}) {
Redux.store.dispatch(onTapAction(buttonText));
}
}

View File

@ -1,6 +1,7 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:auto_size_text/auto_size_text.dart';
class NumberDisplay extends StatelessWidget {
NumberDisplay({this.value: ''});
@ -13,26 +14,30 @@ class NumberDisplay extends StatelessWidget {
Widget build(BuildContext context) {
return Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 20.0 ),
padding: const EdgeInsets.only(left: 20.0, right: 20.0, top: 20.0),
child: Container(
key: stickyKey,
alignment: Alignment.topLeft,
child: AnimatedDefaultTextStyle(
duration: const Duration(milliseconds: 200),
style: TextStyle(
fontSize: fontSizeCalc(value: value, context: context),
fontWeight: FontWeight.bold,
color: Colors.black,
),
child: Text(
child: AutoSizeText(
value,
style: TextStyle(fontSize: 40),
),
),
// child: AnimatedDefaultTextStyle(
// duration: const Duration(milliseconds: 200),
// style: TextStyle(
// fontSize: fontSizeCalc(value: value),
// fontWeight: FontWeight.bold,
// color: Colors.black,
// ),
// child: Text(
// value,
// ),
// ),
)),
);
}
double fontSizeCalc({ String value = " ", context }) {
double fontSizeCalc({String value = " ", context}) {
const double result = 40.0;
try {
double width = MediaQuery.of(context).size.width;
@ -41,11 +46,11 @@ class NumberDisplay extends StatelessWidget {
double scale = (global / value.length);
final pixelOfLetter = sqrt(scale);
final pixelOfLetterP = pixelOfLetter - (pixelOfLetter * 7) / 100;
if(pixelOfLetterP > result){
if (pixelOfLetterP > result) {
return result;
}
return pixelOfLetterP;
} catch(e) {
} catch (e) {
return result;
}
}

View File

@ -1,6 +1,7 @@
import 'package:aman_kassa_flutter/shared/app_colors.dart';
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
/// A button that shows a busy indicator in place of title
@ -12,14 +13,12 @@ class BusyButton extends StatefulWidget {
final Color mainColor;
final IconData icon;
const BusyButton(
{
@required this.title,
{@required this.title,
this.busy = false,
@required this.onPressed,
this.enabled = true,
this.mainColor,
this.icon
});
this.icon});
@override
_BusyButtonState createState() => _BusyButtonState();
@ -31,12 +30,12 @@ class _BusyButtonState extends State<BusyButton> {
return AnimatedContainer(
duration: const Duration(milliseconds: 300),
decoration: BoxDecoration(
color: widget.enabled ? ( widget.mainColor ?? primaryColor) : widget.mainColor?.withOpacity(0.2) ?? primaryColor.withOpacity(0.2),
color: widget.enabled
? (widget.mainColor ?? primaryColor)
: widget.mainColor?.withOpacity(0.2) ??
primaryColor.withOpacity(0.2),
borderRadius: BorderRadius.circular(7),
boxShadow: [
cardShadowBox
]
),
boxShadow: [cardShadowBox]),
child: Material(
type: MaterialType.transparency,
child: InkWell(
@ -52,15 +51,24 @@ class _BusyButtonState extends State<BusyButton> {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
widget.icon!=null ? Container(child: (Icon(widget.icon, color: whiteColor,)), margin: const EdgeInsets.only(right: 10.0 ),) : (Container()),
widget.icon != null
? Container(
child: (Icon(
widget.icon,
color: whiteColor,
)),
margin: const EdgeInsets.only(right: 10.0),
)
: (Container()),
!widget.busy
? Text(
? AutoSizeText(
widget.title,
style: buttonTitleTextStyle,
)
: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(Colors.white)),
valueColor:
AlwaysStoppedAnimation<Color>(Colors.white)),
],
),
),

View File

@ -22,6 +22,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
auto_size_text:
dependency: "direct main"
description:
name: auto_size_text
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
barcode_scan:
dependency: "direct main"
description:

View File

@ -26,6 +26,7 @@ dependencies:
barcode_scan: ^3.0.1
device_info: ^0.4.2+4
esys_flutter_share: ^1.0.2
auto_size_text: ^2.1.0
dev_dependencies:
flutter_test:
sdk: flutter