Merge branch 'master' of http://gitea.a7.kz/dev/aman-kassa-flutter
commit
3a526d8592
|
|
@ -129,7 +129,6 @@
|
||||||
083B51CCB3E82741428E2D55 /* Pods-Runner.release.xcconfig */,
|
083B51CCB3E82741428E2D55 /* Pods-Runner.release.xcconfig */,
|
||||||
EAB5ED0AB808F923C6D318D5 /* Pods-Runner.profile.xcconfig */,
|
EAB5ED0AB808F923C6D318D5 /* Pods-Runner.profile.xcconfig */,
|
||||||
);
|
);
|
||||||
name = Pods;
|
|
||||||
path = Pods;
|
path = Pods;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
|
@ -169,8 +168,9 @@
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
97C146ED1CF9000F007C117D = {
|
97C146ED1CF9000F007C117D = {
|
||||||
CreatedOnToolsVersion = 7.3.1;
|
CreatedOnToolsVersion = 7.3.1;
|
||||||
DevelopmentTeam = YS3FKPC7Y7;
|
DevelopmentTeam = 94BM6VL7L8;
|
||||||
LastSwiftMigration = 1100;
|
LastSwiftMigration = 1100;
|
||||||
|
ProvisioningStyle = Automatic;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -384,8 +384,10 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = YS3FKPC7Y7;
|
DEVELOPMENT_TEAM = 94BM6VL7L8;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|
@ -397,10 +399,12 @@
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.amanKassaFlutter;
|
PRODUCT_BUNDLE_IDENTIFIER = com.kz.amankassaflutter;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
};
|
};
|
||||||
name = Profile;
|
name = Profile;
|
||||||
|
|
@ -519,8 +523,10 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = YS3FKPC7Y7;
|
DEVELOPMENT_TEAM = 94BM6VL7L8;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|
@ -532,11 +538,13 @@
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.amanKassaFlutter;
|
PRODUCT_BUNDLE_IDENTIFIER = com.kz.amankassaflutter;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
|
@ -547,8 +555,10 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
|
||||||
DEVELOPMENT_TEAM = YS3FKPC7Y7;
|
DEVELOPMENT_TEAM = 94BM6VL7L8;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
|
@ -560,10 +570,12 @@
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"$(PROJECT_DIR)/Flutter",
|
"$(PROJECT_DIR)/Flutter",
|
||||||
);
|
);
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.example.amanKassaFlutter;
|
PRODUCT_BUNDLE_IDENTIFIER = com.kz.amankassaflutter;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
VERSIONING_SYSTEM = "apple-generic";
|
VERSIONING_SYSTEM = "apple-generic";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
class Money {
|
class Money {
|
||||||
final num total;
|
final num total;
|
||||||
Money({this.total});
|
final bool loading;
|
||||||
}
|
Money({this.total, this.loading});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class SetUserStateAction {
|
||||||
final UserState userState;
|
final UserState userState;
|
||||||
SetUserStateAction(this.userState);
|
SetUserStateAction(this.userState);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ApiService _api = locator<ApiService>();
|
final ApiService _api = locator<ApiService>();
|
||||||
final NavigatorService _navigation = locator<NavigatorService>();
|
final NavigatorService _navigation = locator<NavigatorService>();
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
final DialogService _dialogService = locator<DialogService>();
|
||||||
|
|
@ -30,9 +31,9 @@ final DialogService _dialogService = locator<DialogService>();
|
||||||
Future<void> checkUserAction(Store<AppState> store) async {
|
Future<void> checkUserAction(Store<AppState> store) async {
|
||||||
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
||||||
try {
|
try {
|
||||||
String token = store.state.userState.user?.token;
|
String token = store.state.userState.user?.token;
|
||||||
bool isAuthenticated = false;
|
bool isAuthenticated = false;
|
||||||
if(token!=null) {
|
if (token != null) {
|
||||||
Response<Message> session = await _api.isActive(token);
|
Response<Message> session = await _api.isActive(token);
|
||||||
isAuthenticated = "OK" == session.body.message;
|
isAuthenticated = "OK" == session.body.message;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -42,25 +43,22 @@ Future<void> checkUserAction(Store<AppState> store) async {
|
||||||
SetUserStateAction(
|
SetUserStateAction(
|
||||||
UserState(
|
UserState(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
isAuthenticated: isAuthenticated,
|
isAuthenticated: isAuthenticated,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!isAuthenticated){
|
if (!isAuthenticated) {
|
||||||
_navigation.replace(LoginViewRoute);
|
_navigation.replace(LoginViewRoute);
|
||||||
} else {
|
} else {
|
||||||
_navigation.replace(HomeViewRoute);
|
_navigation.replace(HomeViewRoute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
print(error);
|
print(error);
|
||||||
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
|
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> logoutAction(Store<AppState> store) async {
|
Future<void> logoutAction(Store<AppState> store) async {
|
||||||
try {
|
try {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
|
|
@ -79,14 +77,21 @@ Future<void> logoutAction(Store<AppState> store) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Response<dynamic>> checkMoney(Store<AppState> store) async {
|
Future<Response<dynamic>> checkMoney(Store<AppState> store) async {
|
||||||
|
store.dispatch(SetUserStateAction(UserState(money: Money(loading: true))));
|
||||||
try {
|
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) {
|
if (result.operation) {
|
||||||
store.dispatch(SetUserStateAction(
|
store.dispatch(SetUserStateAction(UserState(
|
||||||
UserState(money: Money(total: double.parse(result.body['money'])))));
|
money: Money(
|
||||||
|
total: double.parse(result.body['money']), loading: false))));
|
||||||
|
} else {
|
||||||
|
store.dispatch(
|
||||||
|
SetUserStateAction(UserState(money: Money(loading: false))));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
store.dispatch(SetUserStateAction(UserState(money: Money(loading: false))));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -95,21 +100,26 @@ ThunkAction<AppState> authenticateToken(String token) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
||||||
try {
|
try {
|
||||||
AuthBody result = await _api.authenticate_token(token, statusCheck: false);
|
AuthBody result =
|
||||||
|
await _api.authenticate_token(token, statusCheck: false);
|
||||||
store.dispatch(SetUserStateAction(UserState(
|
store.dispatch(SetUserStateAction(UserState(
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
loginFormMessage: LoginFormMessage(email: result.email?.join(","), password: result.password?.join(","), message: result.message),
|
loginFormMessage: LoginFormMessage(
|
||||||
user: result.user,
|
email: result.email?.join(","),
|
||||||
authenticateType: AuthenticateTypeQr,
|
password: result.password?.join(","),
|
||||||
isAuthenticated: result.user != null,
|
message: result.message),
|
||||||
|
user: result.user,
|
||||||
|
authenticateType: AuthenticateTypeQr,
|
||||||
|
isAuthenticated: result.user != null,
|
||||||
)));
|
)));
|
||||||
if(result.user == null && result.message!=null){
|
if (result.user == null && result.message != null) {
|
||||||
_dialogService.showDialog(title: 'Warning', buttonTitle: 'Ok', description: result.message);
|
_dialogService.showDialog(
|
||||||
|
title: 'Warning', buttonTitle: 'Ok', description: result.message);
|
||||||
}
|
}
|
||||||
if(result.user!=null) {
|
if (result.user != null) {
|
||||||
_navigation.replace(HomeViewRoute);
|
_navigation.replace(HomeViewRoute);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
|
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
|
||||||
}
|
}
|
||||||
|
|
@ -120,23 +130,28 @@ ThunkAction<AppState> authenticate(String email, String password) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
store.dispatch(SetUserStateAction(UserState(isLoading: true)));
|
||||||
try {
|
try {
|
||||||
AuthBody result = await _api.authenticate(email, password, statusCheck: false);
|
AuthBody result =
|
||||||
|
await _api.authenticate(email, password, statusCheck: false);
|
||||||
store.dispatch(SetUserStateAction(UserState(
|
store.dispatch(SetUserStateAction(UserState(
|
||||||
isLoading: false,
|
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,
|
user: result.user,
|
||||||
login: email,
|
login: email,
|
||||||
password: password,
|
password: password,
|
||||||
authenticateType: AuthenticateTypeLogin,
|
authenticateType: AuthenticateTypeLogin,
|
||||||
isAuthenticated: result.user != null,
|
isAuthenticated: result.user != null,
|
||||||
)));
|
)));
|
||||||
if(result.user == null && result.message!=null){
|
if (result.user == null && result.message != null) {
|
||||||
_dialogService.showDialog(title: 'Warning', buttonTitle: 'Ok', description: result.message);
|
_dialogService.showDialog(
|
||||||
|
title: 'Warning', buttonTitle: 'Ok', description: result.message);
|
||||||
}
|
}
|
||||||
if(result.user!=null) {
|
if (result.user != null) {
|
||||||
_navigation.replace(HomeViewRoute);
|
_navigation.replace(HomeViewRoute);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
|
store.dispatch(SetUserStateAction(UserState(isLoading: false)));
|
||||||
}
|
}
|
||||||
|
|
@ -160,7 +175,7 @@ Future<void> openSmena(Store<AppState> store) async {
|
||||||
String token = store.state.userState.user.token;
|
String token = store.state.userState.user.token;
|
||||||
Response<Smena> result = await _api.openSmena(token);
|
Response<Smena> result = await _api.openSmena(token);
|
||||||
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
store.dispatch(SetUserStateAction(UserState(smena: result.body)));
|
||||||
if(result.operation){
|
if (result.operation) {
|
||||||
store.dispatch(checkSmena);
|
store.dispatch(checkSmena);
|
||||||
store.dispatch(checkMoney);
|
store.dispatch(checkMoney);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,32 +38,32 @@ class UserState {
|
||||||
authenticateType: payload?.authenticateType ?? null,
|
authenticateType: payload?.authenticateType ?? null,
|
||||||
login: payload?.login ?? null,
|
login: payload?.login ?? null,
|
||||||
password: payload?.password ?? null,
|
password: payload?.password ?? null,
|
||||||
money: Money(),
|
money: Money(loading: false),
|
||||||
);
|
);
|
||||||
|
|
||||||
UserState copyWith(
|
UserState copyWith({
|
||||||
{@required bool isError,
|
@required bool isError,
|
||||||
@required bool isLoading,
|
@required bool isLoading,
|
||||||
@required User user,
|
@required User user,
|
||||||
@required bool isAuthenticated,
|
@required bool isAuthenticated,
|
||||||
@required LoginFormMessage loginFormMessage,
|
@required LoginFormMessage loginFormMessage,
|
||||||
@required Smena smena,
|
@required Smena smena,
|
||||||
@required String authenticateType,
|
@required String authenticateType,
|
||||||
@required String login,
|
@required String login,
|
||||||
@required String password,
|
@required String password,
|
||||||
@required Money money,
|
@required Money money,
|
||||||
}) {
|
}) {
|
||||||
return UserState(
|
return UserState(
|
||||||
isError: isError ?? this.isError,
|
isError: isError ?? this.isError,
|
||||||
isLoading: isLoading ?? this.isLoading,
|
isLoading: isLoading ?? this.isLoading,
|
||||||
isAuthenticated: isAuthenticated ?? this.isAuthenticated,
|
isAuthenticated: isAuthenticated ?? this.isAuthenticated,
|
||||||
user: user ?? this.user,
|
user: user ?? this.user,
|
||||||
loginFormMessage: loginFormMessage ?? this.loginFormMessage,
|
loginFormMessage: loginFormMessage ?? this.loginFormMessage,
|
||||||
smena: smena ?? this.smena,
|
smena: smena ?? this.smena,
|
||||||
authenticateType: authenticateType ?? this.authenticateType,
|
authenticateType: authenticateType ?? this.authenticateType,
|
||||||
login: login ?? this.login,
|
login: login ?? this.login,
|
||||||
password: password ?? this.password,
|
password: password ?? this.password,
|
||||||
money: money ?? this.money,
|
money: money ?? this.money,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,8 +73,7 @@ class UserState {
|
||||||
user: User.fromJson(json['user']),
|
user: User.fromJson(json['user']),
|
||||||
authenticateType: json['authenticateType'],
|
authenticateType: json['authenticateType'],
|
||||||
login: json['login'],
|
login: json['login'],
|
||||||
password: json['password']
|
password: json['password'])
|
||||||
)
|
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
||||||
|
|
||||||
// Box Decorations
|
// Box Decorations
|
||||||
|
|
||||||
BoxDecoration fieldDecortaion = BoxDecoration(
|
BoxDecoration fieldDecortaion =
|
||||||
borderRadius: BorderRadius.circular(5), color: Colors.white);
|
BoxDecoration(borderRadius: BorderRadius.circular(5), color: Colors.white);
|
||||||
|
|
||||||
BoxDecoration disabledFieldDecortaion = BoxDecoration(
|
BoxDecoration disabledFieldDecortaion = BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(5), color: Colors.grey[100]);
|
borderRadius: BorderRadius.circular(5), color: Colors.grey[100]);
|
||||||
|
|
@ -20,14 +20,23 @@ const EdgeInsets largeFieldPadding =
|
||||||
const EdgeInsets.symmetric(horizontal: 15, vertical: 15);
|
const EdgeInsets.symmetric(horizontal: 15, vertical: 15);
|
||||||
|
|
||||||
// Text Variables
|
// Text Variables
|
||||||
const TextStyle productTextStyle = const TextStyle(fontWeight: FontWeight.w400, color: Colors.black, fontSize: 15);
|
const TextStyle productTextStyle = const TextStyle(
|
||||||
const TextStyle buttonTitleTextStyle = const TextStyle(fontWeight: FontWeight.w700, color: whiteColor, fontSize: 15);
|
fontWeight: FontWeight.w400, color: Colors.black, fontSize: 15);
|
||||||
const TextStyle buttonBigTitleTextStyle = const TextStyle(fontWeight: FontWeight.w700, color: whiteColor, fontSize: 22, );
|
const TextStyle buttonTitleTextStyle = const TextStyle(
|
||||||
|
fontWeight: FontWeight.w700, color: whiteColor, fontSize: 14);
|
||||||
const TextStyle dropDownTradeTypeTextStyle = TextStyle( color: Colors.black54, fontWeight: FontWeight.bold, fontSize: 24);
|
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
|
// Box Shadow
|
||||||
const BoxShadow mainShadowBox = BoxShadow(blurRadius: 16, color: shadowColor, offset: Offset(0, 5));
|
const BoxShadow mainShadowBox =
|
||||||
const BoxShadow buttonShadowBox = BoxShadow(blurRadius: 5, color: Colors.grey, offset: Offset(0, 1));
|
BoxShadow(blurRadius: 16, color: shadowColor, offset: Offset(0, 5));
|
||||||
const BoxShadow cardShadowBox = BoxShadow(blurRadius: 5, color: Colors.black26, 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));
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
Response<dynamic> result = await _api.deposit(
|
Response<dynamic> result = await _api.deposit(
|
||||||
Redux.store.state.userState.user.token, response.responseText);
|
Redux.store.state.userState.user.token, response.responseText);
|
||||||
_dialog.showDialog(description: result.body['message']);
|
_dialog.showDialog(description: result.body['message']);
|
||||||
if(result.operation) {
|
if (result.operation) {
|
||||||
await Redux.store.dispatch(checkMoney);
|
await Redux.store.dispatch(checkMoney);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -131,7 +131,7 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
Response<dynamic> result = await _api.withdrawal(
|
Response<dynamic> result = await _api.withdrawal(
|
||||||
Redux.store.state.userState.user.token, response.responseText);
|
Redux.store.state.userState.user.token, response.responseText);
|
||||||
_dialog.showDialog(description: result.body['message']);
|
_dialog.showDialog(description: result.body['message']);
|
||||||
if(result.operation) {
|
if (result.operation) {
|
||||||
await Redux.store.dispatch(checkMoney);
|
await Redux.store.dispatch(checkMoney);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,19 +149,10 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
isMoneyCheckBusy = true;
|
isMoneyCheckBusy = true;
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
Response<dynamic> result = await Redux.store.dispatch(checkMoney);
|
await Redux.store.dispatch(checkMoney);
|
||||||
//await _api.money(.state.userState.user.token);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isMoneyCheckBusy = false;
|
isMoneyCheckBusy = false;
|
||||||
});
|
});
|
||||||
if(result != null) {
|
|
||||||
if (result.operation) {
|
|
||||||
_dialog.showDialog(
|
|
||||||
description: 'Денег в кассе: ${result.body['money']}');
|
|
||||||
} else {
|
|
||||||
_dialog.showDialog(description: '${result.body['message']}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -221,17 +212,42 @@ class _AdditionalTabState extends State<AdditionalTab> {
|
||||||
'Денег в кассе:',
|
'Денег в кассе:',
|
||||||
style: TextStyle(color: primaryColor, fontSize: 15),
|
style: TextStyle(color: primaryColor, fontSize: 15),
|
||||||
),
|
),
|
||||||
StoreConnector<AppState,Money>(
|
SizedBox(
|
||||||
converter: (store) => store.state.userState.money,
|
height: 50,
|
||||||
builder: (_, vm) {
|
width: double.infinity,
|
||||||
return Text(
|
child: StoreConnector<AppState, Money>(
|
||||||
vm.total !=null ? '${vm.total} тенге' : 'нет информации',
|
converter: (store) => store.state.userState.money,
|
||||||
style: TextStyle(
|
builder: (_, vm) {
|
||||||
color: vm.total !=null ? primaryColor : Colors.grey.withOpacity(0.5),
|
if (vm.loading == true) {
|
||||||
fontSize: 25,
|
return Center(
|
||||||
fontWeight: FontWeight.bold),
|
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),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
|
|
@ -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:aman_kassa_flutter/widgets/components/calculator/number-display.dart';
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CalculatorTab extends StatelessWidget {
|
class CalculatorTab extends StatelessWidget {
|
||||||
|
|
||||||
NavigatorService _navigatorService = locator<NavigatorService>();
|
NavigatorService _navigatorService = locator<NavigatorService>();
|
||||||
|
|
||||||
final int index;
|
final int index;
|
||||||
|
|
@ -29,53 +26,55 @@ class CalculatorTab extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Column(
|
body: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
StoreConnector<AppState, CalcState>(
|
||||||
|
converter: (store) => store.state.calcState,
|
||||||
|
builder: (context, vm) {
|
||||||
|
return NumberDisplay(
|
||||||
|
value: Calculator.parseItems(vm.calcItems, vm.isEqual));
|
||||||
|
}),
|
||||||
|
CalculatorButtons(onTap: _onPress),
|
||||||
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
StoreConnector<AppState, CalcState>(
|
Expanded(
|
||||||
converter: (store) => store.state.calcState,
|
child: RaisedButton(
|
||||||
builder: (context, vm) {
|
padding: EdgeInsets.all(16.0),
|
||||||
return NumberDisplay(value: Calculator.parseItems(vm.calcItems, vm.isEqual));
|
color: redColor,
|
||||||
}
|
child: Text(
|
||||||
|
"возврат",
|
||||||
|
style: buttonBigTitleTextStyle,
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
_navigatorService.push(PaymentViewRoute,
|
||||||
|
arguments: PaymentModel(
|
||||||
|
mode: SettingModeCalc,
|
||||||
|
operationType: OperationTypeReturn));
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
CalculatorButtons(onTap: _onPress),
|
Expanded(
|
||||||
Row(
|
child: RaisedButton(
|
||||||
children: <Widget>[
|
padding: EdgeInsets.all(16.0),
|
||||||
Expanded(
|
color: greenColor,
|
||||||
child: RaisedButton(
|
child: Text(
|
||||||
padding: EdgeInsets.all(8.0),
|
"оплата",
|
||||||
color: redColor,
|
style: buttonBigTitleTextStyle,
|
||||||
child: Text(
|
|
||||||
"возврат",
|
|
||||||
style: buttonBigTitleTextStyle,
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
_navigatorService.push(PaymentViewRoute, arguments: PaymentModel(mode: SettingModeCalc, operationType: OperationTypeReturn) );
|
|
||||||
}
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
onPressed: () {
|
||||||
child: RaisedButton(
|
_navigatorService.push(PaymentViewRoute,
|
||||||
padding: EdgeInsets.all(8.0),
|
arguments: PaymentModel(
|
||||||
|
mode: SettingModeCalc,
|
||||||
color: greenColor,
|
operationType: OperationTypePay));
|
||||||
child: Text(
|
},
|
||||||
"оплата",
|
),
|
||||||
style: buttonBigTitleTextStyle,
|
),
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
_navigatorService.push(PaymentViewRoute, arguments: PaymentModel(mode: SettingModeCalc, operationType: OperationTypePay) );
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
)
|
||||||
));
|
],
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onPress({ String buttonText}) {
|
void _onPress({String buttonText}) {
|
||||||
Redux.store.dispatch(onTapAction(buttonText));
|
Redux.store.dispatch(onTapAction(buttonText));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
|
|
||||||
class NumberDisplay extends StatelessWidget {
|
class NumberDisplay extends StatelessWidget {
|
||||||
NumberDisplay({this.value: ''});
|
NumberDisplay({this.value: ''});
|
||||||
|
|
@ -13,39 +14,43 @@ class NumberDisplay extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: Padding(
|
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(
|
child: Container(
|
||||||
key: stickyKey,
|
key: stickyKey,
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: AnimatedDefaultTextStyle(
|
child: AutoSizeText(
|
||||||
duration: const Duration(milliseconds: 200),
|
value,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 40),
|
||||||
fontSize: fontSizeCalc(value: value, context: context),
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
value,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
// 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;
|
const double result = 40.0;
|
||||||
try {
|
try {
|
||||||
double width = MediaQuery.of(context).size.width;
|
double width = MediaQuery.of(context).size.width;
|
||||||
double height = MediaQuery.of(context).size.height;
|
double height = MediaQuery.of(context).size.height;
|
||||||
double global = width * height / 2;
|
double global = width * height / 2;
|
||||||
double scale = (global / value.length);
|
double scale = (global / value.length);
|
||||||
final pixelOfLetter = sqrt(scale);
|
final pixelOfLetter = sqrt(scale);
|
||||||
final pixelOfLetterP = pixelOfLetter - (pixelOfLetter * 7) / 100;
|
final pixelOfLetterP = pixelOfLetter - (pixelOfLetter * 7) / 100;
|
||||||
if(pixelOfLetterP > result){
|
if (pixelOfLetterP > result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return pixelOfLetterP;
|
return pixelOfLetterP;
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
|
import 'package:aman_kassa_flutter/shared/shared_styles.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
||||||
|
import 'package:auto_size_text/auto_size_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// A button that shows a busy indicator in place of title
|
/// A button that shows a busy indicator in place of title
|
||||||
|
|
@ -12,14 +13,12 @@ class BusyButton extends StatefulWidget {
|
||||||
final Color mainColor;
|
final Color mainColor;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
const BusyButton(
|
const BusyButton(
|
||||||
{
|
{@required this.title,
|
||||||
@required this.title,
|
this.busy = false,
|
||||||
this.busy = false,
|
@required this.onPressed,
|
||||||
@required this.onPressed,
|
this.enabled = true,
|
||||||
this.enabled = true,
|
this.mainColor,
|
||||||
this.mainColor,
|
this.icon});
|
||||||
this.icon
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_BusyButtonState createState() => _BusyButtonState();
|
_BusyButtonState createState() => _BusyButtonState();
|
||||||
|
|
@ -31,12 +30,12 @@ class _BusyButtonState extends State<BusyButton> {
|
||||||
return AnimatedContainer(
|
return AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
decoration: BoxDecoration(
|
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),
|
borderRadius: BorderRadius.circular(7),
|
||||||
boxShadow: [
|
boxShadow: [cardShadowBox]),
|
||||||
cardShadowBox
|
|
||||||
]
|
|
||||||
),
|
|
||||||
child: Material(
|
child: Material(
|
||||||
type: MaterialType.transparency,
|
type: MaterialType.transparency,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
|
@ -49,18 +48,27 @@ class _BusyButtonState extends State<BusyButton> {
|
||||||
margin: EdgeInsets.symmetric(
|
margin: EdgeInsets.symmetric(
|
||||||
horizontal: widget.busy ? 10 : 25,
|
horizontal: widget.busy ? 10 : 25,
|
||||||
vertical: widget.busy ? 10 : 15),
|
vertical: widget.busy ? 10 : 15),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
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
|
!widget.busy
|
||||||
? Text(
|
? AutoSizeText(
|
||||||
widget.title,
|
widget.title,
|
||||||
style: buttonTitleTextStyle,
|
style: buttonTitleTextStyle,
|
||||||
)
|
)
|
||||||
: CircularProgressIndicator(
|
: CircularProgressIndicator(
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.white)),
|
valueColor:
|
||||||
|
AlwaysStoppedAnimation<Color>(Colors.white)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.1"
|
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:
|
barcode_scan:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ dependencies:
|
||||||
barcode_scan: ^3.0.1
|
barcode_scan: ^3.0.1
|
||||||
device_info: ^0.4.2+4
|
device_info: ^0.4.2+4
|
||||||
esys_flutter_share: ^1.0.2
|
esys_flutter_share: ^1.0.2
|
||||||
|
auto_size_text: ^2.1.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue