UI done
parent
0f1f45223a
commit
d916f638fb
|
|
@ -29,5 +29,11 @@ class Category {
|
||||||
name = map[Category_columnName];
|
name = map[Category_columnName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Category.fromJson(Map<String, dynamic> map) {
|
||||||
|
id = map[Category_columnId];
|
||||||
|
parentIn = map[Category_columnParentIn];
|
||||||
|
name = map[Category_columnName];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,14 @@ class Good {
|
||||||
ean = map[Goog_columnEan];
|
ean = map[Goog_columnEan];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Good.fromJson(Map<String, dynamic> map) {
|
||||||
|
id = map[Goog_columnId];
|
||||||
|
articul = map[Goog_columnArticul];
|
||||||
|
name = map[Goog_columnName];
|
||||||
|
price = double.parse(map[Goog_columnPrice]);
|
||||||
|
categoryId = map[Goog_columnCategoryId];
|
||||||
|
ean = map[Goog_columnEan];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,11 @@ class Service {
|
||||||
price = map[Service_columnPrice]?.toDouble();
|
price = map[Service_columnPrice]?.toDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Service.fromJson(Map<String, dynamic> map) {
|
||||||
|
id = map[Service_columnId];
|
||||||
|
articul = map[Service_columnArticul];
|
||||||
|
name = map[Service_columnName];
|
||||||
|
price = map[Service_columnPrice]?.toDouble(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/services/DbService.dart';
|
|
||||||
import 'package:provider/single_child_widget.dart';
|
|
||||||
|
|
||||||
import '../core/locator.dart';
|
|
||||||
import '../core/services/navigator_service.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import 'services/ApiService.dart';
|
|
||||||
import 'services/authentication_service.dart';
|
|
||||||
|
|
||||||
class ProviderInjector {
|
|
||||||
static List<SingleChildWidget> providers = [
|
|
||||||
..._independentServices,
|
|
||||||
..._dependentServices,
|
|
||||||
..._consumableServices,
|
|
||||||
];
|
|
||||||
|
|
||||||
static List<SingleChildWidget> _independentServices = [
|
|
||||||
// Provider.value(value: locator<NavigatorService>()),
|
|
||||||
// Provider.value(value: locator<ApiService>()),
|
|
||||||
// Provider.value(value: locator<DbService>()),
|
|
||||||
];
|
|
||||||
|
|
||||||
static List<SingleChildWidget> _dependentServices = [
|
|
||||||
// ProxyProvider<ApiService, AuthenticationService>(
|
|
||||||
// update: (context, api, authenticationService) =>
|
|
||||||
// AuthenticationService(api: api),
|
|
||||||
// ),
|
|
||||||
// ProxyProvider2< ApiService ,DbService, DataService>(
|
|
||||||
// update: (context,api , db, authenticationService) =>
|
|
||||||
// DataService(api: api, db: db),
|
|
||||||
// )
|
|
||||||
];
|
|
||||||
|
|
||||||
static List<SingleChildWidget> _consumableServices = [];
|
|
||||||
}
|
|
||||||
|
|
@ -36,21 +36,21 @@ class DataService extends BaseService {
|
||||||
log.i('All tables cleaned');
|
log.i('All tables cleaned');
|
||||||
for (var key in goods.body.keys) {
|
for (var key in goods.body.keys) {
|
||||||
print(goods.body[key]);
|
print(goods.body[key]);
|
||||||
Good row = Good.fromMap(goods.body[key]);
|
Good row = Good.fromJson(goods.body[key]);
|
||||||
_db.insert(Goog_tableName,row.toMap());
|
_db.insert(Goog_tableName,row.toMap());
|
||||||
}
|
}
|
||||||
log.i('Inserted ${goods.body.length} to table $Goog_tableName');
|
log.i('Inserted ${goods.body.length} to table $Goog_tableName');
|
||||||
|
|
||||||
for (var el in categories.body) {
|
for (var el in categories.body) {
|
||||||
print(el);
|
print(el);
|
||||||
Category row = Category.fromMap(el);
|
Category row = Category.fromJson(el);
|
||||||
_db.insert(Category_tableName,row.toMap());
|
_db.insert(Category_tableName,row.toMap());
|
||||||
}
|
}
|
||||||
log.i('Inserted ${categories.body.length} to table $Category_tableName');
|
log.i('Inserted ${categories.body.length} to table $Category_tableName');
|
||||||
|
|
||||||
for (var key in services.body.keys) {
|
for (var key in services.body.keys) {
|
||||||
print(services.body[key]);
|
print(services.body[key]);
|
||||||
Service row = Service.fromMap(services.body[key]);
|
Service row = Service.fromJson(services.body[key]);
|
||||||
_db.insert(Service_tableName,row.toMap());
|
_db.insert(Service_tableName,row.toMap());
|
||||||
}
|
}
|
||||||
log.i('Inserted ${services.body.length} to table $Service_tableName');
|
log.i('Inserted ${services.body.length} to table $Service_tableName');
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
//service & tools
|
//service & tools
|
||||||
import 'package:redux/redux.dart';
|
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
import 'core/locator.dart';
|
import 'core/locator.dart';
|
||||||
import 'core/providers.dart';
|
|
||||||
import 'core/router.dart';
|
import 'core/router.dart';
|
||||||
import 'core/services/navigator_service.dart';
|
import 'core/services/navigator_service.dart';
|
||||||
import 'core/services/dialog_service.dart';
|
import 'core/services/dialog_service.dart';
|
||||||
|
|
|
||||||
|
|
@ -26,24 +26,39 @@ final ApiService _api = locator<ApiService>();
|
||||||
final DataService _dataService = locator<DataService>();
|
final DataService _dataService = locator<DataService>();
|
||||||
final NavigatorService _navigation = locator<NavigatorService>();
|
final NavigatorService _navigation = locator<NavigatorService>();
|
||||||
|
|
||||||
|
|
||||||
Future<void> backBottomElement(Store<AppState> store) async {
|
Future<void> backBottomElement(Store<AppState> store) async {
|
||||||
List<DictDao> prevCategories = store.state.mainState.prevCategories;
|
List<DictDao> prevCategories = store.state.mainState.prevCategories;
|
||||||
DictDao last = prevCategories.removeLast();
|
DictDao last = prevCategories.removeLast();
|
||||||
if(last!=null) {
|
if (last != null) {
|
||||||
store.dispatch(SetMainStateAction(MainState(prevCategories: prevCategories)));
|
store.dispatch(
|
||||||
|
SetMainStateAction(MainState(prevCategories: prevCategories)));
|
||||||
store.dispatch(selectBottomElement(last.id));
|
store.dispatch(selectBottomElement(last.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ThunkAction<AppState> addCustomProductToKassaItems(String name, int count, double price) {
|
||||||
|
return (Store<AppState> store) async {
|
||||||
|
List<ProductDao> items = store.state.mainState.kassaItems;
|
||||||
|
items.add(new ProductDao(name: name, count: count, price: price));
|
||||||
|
store.dispatch(SetMainStateAction(MainState(kassaItems: items)));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ThunkAction<AppState> addProductToKassaItems(Good good) {
|
ThunkAction<AppState> addProductToKassaItems(Good good) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
List<ProductDao> items = store.state.mainState.kassaItems;
|
List<ProductDao> items = store.state.mainState.kassaItems;
|
||||||
items.add(new ProductDao(name: good.name, good: good, count: 1, price: good.price));
|
int index = items.indexWhere((element) => element.good?.id == good.id);
|
||||||
store.dispatch(SetMainStateAction(MainState(kassaItems: items)));
|
if (index > -1) {
|
||||||
|
store.dispatch(counterProductFromKassaItems(index, 1));
|
||||||
|
} else {
|
||||||
|
items.add(new ProductDao(
|
||||||
|
name: good.name, good: good, count: 1, price: good.price));
|
||||||
|
store.dispatch(SetMainStateAction(MainState(kassaItems: items)));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ThunkAction<AppState> removeProductFromKassaItems(int index) {
|
ThunkAction<AppState> removeProductFromKassaItems(int index) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
List<ProductDao> items = List.from(store.state.mainState.kassaItems);
|
List<ProductDao> items = List.from(store.state.mainState.kassaItems);
|
||||||
|
|
@ -51,13 +66,15 @@ ThunkAction<AppState> removeProductFromKassaItems(int index) {
|
||||||
store.dispatch(SetMainStateAction(MainState(kassaItems: items)));
|
store.dispatch(SetMainStateAction(MainState(kassaItems: items)));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ThunkAction<AppState> counterProductFromKassaItems(int index, int counter) {
|
ThunkAction<AppState> counterProductFromKassaItems(int index, int counter) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
List<ProductDao> items = store.state.mainState.kassaItems;
|
List<ProductDao> items = store.state.mainState.kassaItems;
|
||||||
if(items.elementAt(index).count == 1 && counter < 0) {//if count to zero need delete element
|
if (items.elementAt(index).count == 1 && counter < 0) {
|
||||||
|
//if count to zero need delete element
|
||||||
store.dispatch(removeProductFromKassaItems(index));
|
store.dispatch(removeProductFromKassaItems(index));
|
||||||
} else {
|
} else {
|
||||||
items.elementAt(index).count+=counter;
|
items.elementAt(index).count += counter;
|
||||||
store.dispatch(SetMainStateAction(MainState(kassaItems: items)));
|
store.dispatch(SetMainStateAction(MainState(kassaItems: items)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -68,28 +85,25 @@ ThunkAction<AppState> selectBottomElement(int parentId) {
|
||||||
store.dispatch(SetMainStateAction(MainState(bottomSheetLoading: true)));
|
store.dispatch(SetMainStateAction(MainState(bottomSheetLoading: true)));
|
||||||
try {
|
try {
|
||||||
List<DictDao> prevCategories = store.state.mainState.prevCategories;
|
List<DictDao> prevCategories = store.state.mainState.prevCategories;
|
||||||
if(parentId == 0) {
|
if (parentId == 0) {
|
||||||
prevCategories = [];
|
prevCategories = [];
|
||||||
}
|
}
|
||||||
store.state.mainState.bottomSheetElements.forEach((element) {
|
store.state.mainState.bottomSheetElements.forEach((element) {
|
||||||
if(element is Category && element.id == parentId){
|
if (element is Category && element.id == parentId) {
|
||||||
prevCategories.add(DictDao(id: element.parentIn, name: element.name));
|
prevCategories.add(DictDao(id: element.parentIn, name: element.name));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
List<Category> categories = await _dataService.getCategoriesByParentId(parentId: parentId);
|
List<Category> categories =
|
||||||
List<Good> goods = await _dataService.getGoodsByCategoryId(categoryId: parentId);
|
await _dataService.getCategoriesByParentId(parentId: parentId);
|
||||||
|
List<Good> goods =
|
||||||
|
await _dataService.getGoodsByCategoryId(categoryId: parentId);
|
||||||
List _bottomSheetElements = [];
|
List _bottomSheetElements = [];
|
||||||
_bottomSheetElements.addAll(categories);
|
_bottomSheetElements.addAll(categories);
|
||||||
_bottomSheetElements.addAll(goods);
|
_bottomSheetElements.addAll(goods);
|
||||||
store.dispatch(
|
store.dispatch(SetMainStateAction(MainState(
|
||||||
SetMainStateAction(
|
bottomSheetLoading: false,
|
||||||
MainState(
|
bottomSheetElements: _bottomSheetElements,
|
||||||
bottomSheetLoading: false,
|
prevCategories: prevCategories)));
|
||||||
bottomSheetElements: _bottomSheetElements,
|
|
||||||
prevCategories: prevCategories
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
store.dispatch(SetMainStateAction(MainState(bottomSheetLoading: false)));
|
store.dispatch(SetMainStateAction(MainState(bottomSheetLoading: false)));
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ const EdgeInsets largeFieldPadding =
|
||||||
|
|
||||||
// Text Variables
|
// Text Variables
|
||||||
const TextStyle productTextStyle = const TextStyle(fontWeight: FontWeight.w400, color: Colors.black, fontSize: 15);
|
const TextStyle productTextStyle = const TextStyle(fontWeight: FontWeight.w400, color: Colors.black, fontSize: 15);
|
||||||
const TextStyle buttonTitleTextStyle = const TextStyle(fontWeight: FontWeight.w400, color: whiteColor, fontSize: 15);
|
const TextStyle buttonTitleTextStyle = const TextStyle(fontWeight: FontWeight.w700, color: whiteColor, fontSize: 15);
|
||||||
const TextStyle buttonBigTitleTextStyle = const TextStyle(fontWeight: FontWeight.w400, color: whiteColor, fontSize: 22, );
|
const TextStyle buttonBigTitleTextStyle = const TextStyle(fontWeight: FontWeight.w700, color: whiteColor, fontSize: 22, );
|
||||||
|
|
||||||
const TextStyle stepTitleTextStyle =
|
const TextStyle stepTitleTextStyle =
|
||||||
const TextStyle(fontWeight: FontWeight.w700, color: textColor, fontSize: 15);
|
const TextStyle(fontWeight: FontWeight.w700, color: textColor, fontSize: 15);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import 'package:aman_kassa_flutter/core/models/Choice.dart';
|
||||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
|
import 'package:aman_kassa_flutter/widgets/loader/Dialogs.dart';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
@ -31,6 +32,7 @@ class _HomeViewState extends State<HomeView> {
|
||||||
PageController pageController;
|
PageController pageController;
|
||||||
int selectedTabIndex;
|
int selectedTabIndex;
|
||||||
DataService _dataService = locator<DataService>();
|
DataService _dataService = locator<DataService>();
|
||||||
|
final GlobalKey<State> _keyLoader = new GlobalKey<State>();
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -41,12 +43,20 @@ class _HomeViewState extends State<HomeView> {
|
||||||
pageController = new PageController(initialPage: selectedTabIndex);
|
pageController = new PageController(initialPage: selectedTabIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
pageController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
void _onSelectChoice(Choice choice) async {
|
void _onSelectChoice(Choice choice) async {
|
||||||
if(choice.command == 'exit') {
|
if(choice.command == 'exit') {
|
||||||
|
|
||||||
} else if (choice.command == 'update') {
|
} else if (choice.command == 'update') {
|
||||||
|
Dialogs.showLoadingDialog(context, _keyLoader);
|
||||||
bool result = await _dataService.getDataFromServer(Redux.store.state.userState.user.token);
|
bool result = await _dataService.getDataFromServer(Redux.store.state.userState.user.token);
|
||||||
print('result: $result');
|
print('result: $result');
|
||||||
|
Navigator.of(_keyLoader.currentContext,rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
import 'package:aman_kassa_flutter/core/base/base_view_model.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/entity/Category.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/locator.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/models/Choice.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/models/user.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/route_names.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/services/DataService.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/services/authentication_service.dart';
|
|
||||||
import 'package:aman_kassa_flutter/core/services/dialog_service.dart';
|
|
||||||
|
|
||||||
import 'package:aman_kassa_flutter/core/services/navigator_service.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
class HomeViewModel extends BaseViewModel {
|
|
||||||
NavigatorService _navigationService;
|
|
||||||
AuthenticationService _authenticationService;
|
|
||||||
DataService _dataService;
|
|
||||||
final DialogService _dialogService = locator<DialogService>();
|
|
||||||
|
|
||||||
HomeViewModel({
|
|
||||||
@required AuthenticationService authenticationService,
|
|
||||||
@required NavigatorService navigationService,
|
|
||||||
@required DataService dataService,
|
|
||||||
}) : _authenticationService = authenticationService,
|
|
||||||
_dataService = dataService,
|
|
||||||
_navigationService = navigationService;
|
|
||||||
|
|
||||||
User _currentUser;
|
|
||||||
User get currentUser => _currentUser;
|
|
||||||
|
|
||||||
int _tabIndex = 0;
|
|
||||||
int get tabIndex => this._tabIndex;
|
|
||||||
set tabIndex(int index) {
|
|
||||||
this._tabIndex = index;
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
void onSelected(Choice choice) async {
|
|
||||||
log.i(choice.command);
|
|
||||||
if(choice.command == 'exit') {
|
|
||||||
bool result = await _authenticationService.logout(_currentUser.token);
|
|
||||||
if (result) {
|
|
||||||
_navigationService.replace(LoginViewRoute);
|
|
||||||
}
|
|
||||||
} else if (choice.command == 'update') {
|
|
||||||
log.i(_authenticationService.currentUser.token);
|
|
||||||
bool result = await _dataService.getDataFromServer(_authenticationService.currentUser.token);
|
|
||||||
log.i(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PageController get pageController => this._pageController;
|
|
||||||
PageController _pageController;
|
|
||||||
set pageController(PageController pageController) {
|
|
||||||
this._pageController = pageController;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Object> _bottomSheetElements = [];
|
|
||||||
List<Object> get bottomSheetElements => this._bottomSheetElements;
|
|
||||||
int _parentId;
|
|
||||||
void selectBottomElement(int parentId) async {
|
|
||||||
// log.i('parentId=$parentId');
|
|
||||||
// _parentId = parentId;
|
|
||||||
// _bottomSheetElements.clear();
|
|
||||||
// List<Category> categories = await _dataService.getCategoriesByParentId(parentId: parentId);
|
|
||||||
// List<Category> goods = await _dataService.getGoodsByCategoryId(categoryId: parentId);
|
|
||||||
// _bottomSheetElements.addAll(categories);
|
|
||||||
// _bottomSheetElements.addAll(goods);
|
|
||||||
// notifyListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String _text;
|
|
||||||
get text => this._text;
|
|
||||||
set text(String text) => this._text = text;
|
|
||||||
|
|
||||||
void initialize() {
|
|
||||||
|
|
||||||
_currentUser = _authenticationService.currentUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
_pageController.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import 'package:aman_kassa_flutter/redux/state/user_state.dart';
|
import 'package:aman_kassa_flutter/redux/state/user_state.dart';
|
||||||
import 'package:aman_kassa_flutter/redux/store.dart';
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
|
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
||||||
|
import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:aman_kassa_flutter/views/home/home_view_model.dart';
|
|
||||||
import 'package:flutter_redux/flutter_redux.dart';
|
import 'package:flutter_redux/flutter_redux.dart';
|
||||||
import 'package:google_fonts/google_fonts.dart';
|
import 'package:google_fonts/google_fonts.dart';
|
||||||
|
|
||||||
|
|
@ -14,10 +16,39 @@ class AdditionalTab extends StatelessWidget {
|
||||||
converter: (store) => store.state.userState,
|
converter: (store) => store.state.userState,
|
||||||
builder: (context, vm) {
|
builder: (context, vm) {
|
||||||
return Container(
|
return Container(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text('AdditionalTab index:$index ${vm.user.fullName} ',
|
verticalSpaceLarge,
|
||||||
style: GoogleFonts.lato(color: Colors.black87))
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: <Widget>[
|
||||||
|
BusyButton(title: 'Открыть смену', onPressed: null, mainColor: greenColor,),
|
||||||
|
BusyButton(title: 'Закрыть смену', onPressed: null, mainColor: redColor ,),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
verticalSpaceLarge,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
BusyButton(title: 'Денег в кассе', onPressed: null,),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
verticalSpaceLarge,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: <Widget>[
|
||||||
|
BusyButton(title: 'Взнос наличных', onPressed: null,),
|
||||||
|
BusyButton(title: 'Снятие наличных', onPressed: null, mainColor: redColor ,),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
verticalSpaceLarge,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
BusyButton(title: 'Х Отчет', onPressed: null,),
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:aman_kassa_flutter/views/home/home_view_model.dart';
|
|
||||||
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator-buttons.dart';
|
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator-buttons.dart';
|
||||||
import 'package:aman_kassa_flutter/widgets/components/calculator/number-display.dart';
|
import 'package:aman_kassa_flutter/widgets/components/calculator/number-display.dart';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,42 @@
|
||||||
|
import 'package:aman_kassa_flutter/redux/actions/main_actions.dart';
|
||||||
|
import 'package:aman_kassa_flutter/redux/store.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
import 'package:aman_kassa_flutter/shared/ui_helpers.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class ProductAddBottomSheet extends StatelessWidget {
|
class ProductAddBottomSheet extends StatefulWidget {
|
||||||
final ScrollController scrollController;
|
final ScrollController scrollController;
|
||||||
|
|
||||||
ProductAddBottomSheet({this.scrollController});
|
ProductAddBottomSheet({this.scrollController});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_ProductAddBottomSheetState createState() => _ProductAddBottomSheetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProductAddBottomSheetState extends State<ProductAddBottomSheet> {
|
||||||
|
TextEditingController nameController;
|
||||||
|
TextEditingController countController;
|
||||||
|
TextEditingController priceController;
|
||||||
|
double sum = 0.0;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
// TODO: implement initState
|
||||||
|
super.initState();
|
||||||
|
nameController = new TextEditingController();
|
||||||
|
countController = new TextEditingController();
|
||||||
|
priceController = new TextEditingController();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
nameController.dispose();
|
||||||
|
countController.dispose();
|
||||||
|
priceController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
|
@ -15,45 +46,67 @@ class ProductAddBottomSheet extends StatelessWidget {
|
||||||
iconTheme: IconThemeData(color: Colors.black),
|
iconTheme: IconThemeData(color: Colors.black),
|
||||||
backgroundColor: fillColor,
|
backgroundColor: fillColor,
|
||||||
elevation: 3,
|
elevation: 3,
|
||||||
title: Text('Добавить товар/услугу', style: TextStyle(color: Colors.black87),),
|
title: Text(
|
||||||
|
'Добавить товар/услугу',
|
||||||
|
style: TextStyle(color: Colors.black87),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10),
|
padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 10),
|
||||||
child: ListView(
|
child: ListView(
|
||||||
controller: scrollController,
|
controller: widget.scrollController,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
TextField(
|
TextField(
|
||||||
decoration: new InputDecoration(
|
decoration: new InputDecoration(
|
||||||
border: new OutlineInputBorder(borderSide: new BorderSide(color: primaryColor)),
|
border: new OutlineInputBorder(
|
||||||
hintText: 'Введите наименовение',
|
borderSide: new BorderSide(color: primaryColor)),
|
||||||
labelText: 'Наименование',
|
hintText: 'Введите наименовение',
|
||||||
prefixText: ' ',
|
labelText: 'Наименование',
|
||||||
|
prefixText: ' ',
|
||||||
),
|
),
|
||||||
|
controller: nameController,
|
||||||
),
|
),
|
||||||
verticalSpaceSmall,
|
verticalSpaceSmall,
|
||||||
TextField(
|
TextField(
|
||||||
decoration: new InputDecoration(
|
decoration: new InputDecoration(
|
||||||
border: new OutlineInputBorder(borderSide: new BorderSide(color: primaryColor)),
|
border: new OutlineInputBorder(
|
||||||
hintText: 'Введите количество',
|
borderSide: new BorderSide(color: primaryColor)),
|
||||||
labelText: 'Количество',
|
hintText: 'Введите количество',
|
||||||
prefixText: ' ',
|
labelText: 'Количество',
|
||||||
|
prefixText: ' ',
|
||||||
),
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
inputFormatters: <TextInputFormatter>[
|
||||||
|
WhitelistingTextInputFormatter.digitsOnly
|
||||||
|
],
|
||||||
|
controller: countController,
|
||||||
|
onChanged: calcOnChange,
|
||||||
),
|
),
|
||||||
verticalSpaceSmall,
|
verticalSpaceSmall,
|
||||||
TextField(
|
TextField(
|
||||||
decoration: new InputDecoration(
|
decoration: new InputDecoration(
|
||||||
border: new OutlineInputBorder(borderSide: new BorderSide(color: primaryColor)),
|
border: new OutlineInputBorder(
|
||||||
|
borderSide: new BorderSide(color: primaryColor)),
|
||||||
hintText: 'Введите цену за единицу',
|
hintText: 'Введите цену за единицу',
|
||||||
labelText: 'Стоимость',
|
labelText: 'Стоимость',
|
||||||
prefixText: ' ',
|
prefixText: ' ',
|
||||||
),
|
),
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
inputFormatters: <TextInputFormatter>[
|
||||||
|
WhitelistingTextInputFormatter(RegExp("^[0-9.]*")),
|
||||||
|
],
|
||||||
|
controller: priceController,
|
||||||
|
onChanged: calcOnChange,
|
||||||
),
|
),
|
||||||
const Divider(
|
const Divider(
|
||||||
height: 1.0,
|
height: 1.0,
|
||||||
),
|
),
|
||||||
new ListTile(
|
new ListTile(
|
||||||
leading: const Icon(Icons.account_balance_wallet, color: primaryColor,),
|
leading: const Icon(
|
||||||
title: const Text('0,454'),
|
Icons.account_balance_wallet,
|
||||||
|
color: primaryColor,
|
||||||
|
),
|
||||||
|
title: Text(sum == 0 ? '' : sum.toString()),
|
||||||
subtitle: const Text('Стоимость'),
|
subtitle: const Text('Стоимость'),
|
||||||
),
|
),
|
||||||
verticalSpaceMedium,
|
verticalSpaceMedium,
|
||||||
|
|
@ -61,7 +114,7 @@ class ProductAddBottomSheet extends StatelessWidget {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
RawMaterialButton(
|
RawMaterialButton(
|
||||||
onPressed: () {},
|
onPressed: submit,
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
fillColor: greenColor,
|
fillColor: greenColor,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
|
|
@ -73,7 +126,9 @@ class ProductAddBottomSheet extends StatelessWidget {
|
||||||
shape: CircleBorder(),
|
shape: CircleBorder(),
|
||||||
),
|
),
|
||||||
RawMaterialButton(
|
RawMaterialButton(
|
||||||
onPressed: () {},
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
elevation: 2.0,
|
elevation: 2.0,
|
||||||
fillColor: redColor,
|
fillColor: redColor,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
|
|
@ -92,4 +147,50 @@ class ProductAddBottomSheet extends StatelessWidget {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void submit() {
|
||||||
|
if (nameController.text.isEmpty ||
|
||||||
|
countController.text.isEmpty ||
|
||||||
|
priceController.text.isEmpty) {
|
||||||
|
_showDialog();
|
||||||
|
} else {
|
||||||
|
Redux.store.dispatch(addCustomProductToKassaItems(nameController.text,
|
||||||
|
int.parse(countController.text), double.parse(priceController.text)));
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void calcOnChange(value) {
|
||||||
|
setState(() {
|
||||||
|
sum = 0;
|
||||||
|
});
|
||||||
|
double count = double.parse(countController.text);
|
||||||
|
double price = double.parse(priceController.text);
|
||||||
|
double result = count * price;
|
||||||
|
setState(() {
|
||||||
|
sum = ((result * 100).roundToDouble()) / 100;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDialog() {
|
||||||
|
// flutter defined function
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: new Text("Aman Касса"),
|
||||||
|
content: new Text("Введите наименова, количество и цену"),
|
||||||
|
actions: <Widget>[
|
||||||
|
new FlatButton(
|
||||||
|
child: new Text("ОK", style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
|
import 'package:aman_kassa_flutter/shared/app_colors.dart';
|
||||||
|
import 'package:aman_kassa_flutter/widgets/components/calculator/calculator.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
typedef void CalculatorButtonTapCallback({String buttonText});
|
typedef void CalculatorButtonTapCallback({String buttonText});
|
||||||
|
|
||||||
|
List operationsBlue = [Calculations.ADD,Calculations.MULTIPLY,Calculations.EQUAL,Calculations.ERASE];
|
||||||
|
List operationsRed = [Calculations.CLEAR];
|
||||||
|
|
||||||
class CalculatorButton extends StatelessWidget {
|
class CalculatorButton extends StatelessWidget {
|
||||||
CalculatorButton({this.text, @required this.onTap});
|
CalculatorButton({this.text, @required this.onTap});
|
||||||
|
|
||||||
|
|
@ -14,19 +19,37 @@ class CalculatorButton extends StatelessWidget {
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: const Color.fromRGBO(0, 0, 0, 0.1),
|
color: Colors.black,
|
||||||
width: 0.5,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: FlatButton(
|
child: FlatButton(
|
||||||
onPressed: () => onTap(buttonText: text),
|
onPressed: () => onTap(buttonText: text),
|
||||||
child: Text(
|
child: Text(
|
||||||
text,
|
text,
|
||||||
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w500),
|
style: TextStyle(fontSize: 25, fontWeight: FontWeight.w700, color: buildTextColor()),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.all(15),
|
padding: const EdgeInsets.all(20),
|
||||||
highlightColor: Colors.blueGrey[100],
|
highlightColor: Colors.blueGrey[100],
|
||||||
splashColor: Colors.blueAccent[100],
|
splashColor: Colors.blueAccent[100],
|
||||||
|
color: buildMainColor(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildMainColor() {
|
||||||
|
if(operationsBlue.indexOf(text)>-1){
|
||||||
|
return primaryColor;
|
||||||
|
} else if(operationsRed.indexOf(text)>-1){
|
||||||
|
return redColor;
|
||||||
|
}
|
||||||
|
return fillColor;
|
||||||
|
}
|
||||||
|
buildTextColor() {
|
||||||
|
if(operationsBlue.indexOf(text)>-1){
|
||||||
|
return whiteColor;
|
||||||
|
} else if(operationsRed.indexOf(text)>-1){
|
||||||
|
return whiteColor;
|
||||||
|
}
|
||||||
|
return Colors.black;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,10 @@ class CalculatorButtons extends StatelessWidget {
|
||||||
|
|
||||||
final CalculatorButtonTapCallback onTap;
|
final CalculatorButtonTapCallback onTap;
|
||||||
final calculatorButtonRows = [
|
final calculatorButtonRows = [
|
||||||
['7', '8', '9', Calculations.DIVIDE],
|
['7', '8', '9', Calculations.CLEAR],
|
||||||
['4', '5', '6', Calculations.MULTIPLY],
|
['4', '5', '6', Calculations.MULTIPLY],
|
||||||
['1', '2', '3', Calculations.SUBTRACT],
|
['1', '2', '3', Calculations.ADD],
|
||||||
[Calculations.PERIOD, '0', '00', Calculations.ADD],
|
[Calculations.PERIOD, '0', Calculations.ERASE, Calculations.EQUAL]
|
||||||
[Calculations.CLEAR, Calculations.EQUAL]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,15 @@ class Calculations {
|
||||||
static const SUBTRACT = '-';
|
static const SUBTRACT = '-';
|
||||||
static const ADD = '+';
|
static const ADD = '+';
|
||||||
static const DIVIDE = '/';
|
static const DIVIDE = '/';
|
||||||
static const CLEAR = 'CLEAR';
|
static const ERASE = '<<';
|
||||||
|
static const CLEAR = 'C';
|
||||||
static const EQUAL = '=';
|
static const EQUAL = '=';
|
||||||
static const OPERATIONS = [
|
static const OPERATIONS = [
|
||||||
Calculations.ADD,
|
Calculations.ADD,
|
||||||
Calculations.MULTIPLY,
|
Calculations.MULTIPLY,
|
||||||
Calculations.SUBTRACT,
|
Calculations.SUBTRACT,
|
||||||
Calculations.DIVIDE,
|
Calculations.DIVIDE,
|
||||||
|
Calculations.ERASE
|
||||||
];
|
];
|
||||||
|
|
||||||
static double add(double a, double b) => a + b;
|
static double add(double a, double b) => a + b;
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,15 @@ class BusyButton extends StatefulWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final Function onPressed;
|
final Function onPressed;
|
||||||
final bool enabled;
|
final bool enabled;
|
||||||
|
final Color mainColor;
|
||||||
const BusyButton(
|
const BusyButton(
|
||||||
{@required this.title,
|
{
|
||||||
this.busy = false,
|
@required this.title,
|
||||||
@required this.onPressed,
|
this.busy = false,
|
||||||
this.enabled = true});
|
@required this.onPressed,
|
||||||
|
this.enabled = true,
|
||||||
|
this.mainColor
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_BusyButtonState createState() => _BusyButtonState();
|
_BusyButtonState createState() => _BusyButtonState();
|
||||||
|
|
@ -33,7 +37,7 @@ class _BusyButtonState extends State<BusyButton> {
|
||||||
horizontal: widget.busy ? 10 : 25,
|
horizontal: widget.busy ? 10 : 25,
|
||||||
vertical: widget.busy ? 10 : 15),
|
vertical: widget.busy ? 10 : 15),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: widget.enabled ? primaryColor : blueColorLigth,
|
color: widget.enabled ? ( widget.mainColor ?? primaryColor) : blueColorLigth,
|
||||||
borderRadius: BorderRadius.circular(7),
|
borderRadius: BorderRadius.circular(7),
|
||||||
boxShadow: [mainShadowBox]
|
boxShadow: [mainShadowBox]
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class Dialogs {
|
||||||
|
static Future<void> showLoadingDialog(
|
||||||
|
BuildContext context, GlobalKey key) async {
|
||||||
|
return showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return new WillPopScope(
|
||||||
|
onWillPop: () async => false,
|
||||||
|
child: SimpleDialog(
|
||||||
|
key: key,
|
||||||
|
backgroundColor: Colors.black54,
|
||||||
|
children: <Widget>[
|
||||||
|
Center(
|
||||||
|
child: Column(children: [
|
||||||
|
CircularProgressIndicator(),
|
||||||
|
SizedBox(height: 10,),
|
||||||
|
Text("Please Wait....",style: TextStyle(color: Colors.blueAccent),)
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue