diff --git a/assets/images/logo.png b/assets/images/logo.png index eec3735..f086cf0 100644 Binary files a/assets/images/logo.png and b/assets/images/logo.png differ diff --git a/assets/images/top_bar_bg.png b/assets/images/top_bar_bg.png new file mode 100644 index 0000000..4dfd66a Binary files /dev/null and b/assets/images/top_bar_bg.png differ diff --git a/lib/core/redux/actions/user_actions.dart b/lib/core/redux/actions/user_actions.dart index 975b48e..440c280 100644 --- a/lib/core/redux/actions/user_actions.dart +++ b/lib/core/redux/actions/user_actions.dart @@ -49,17 +49,21 @@ Future auth(Store store) async { store.dispatch(SetUserStateAction(UserState(isLoading: true))); try { UserState? state = store.state.userState; - if(state!.auth!.operation == false) { - _navigation.replace(LoginViewRoute); - } else { - AuthResponse response = await _api.auth(state.auth!.token!); - if(response.operation!){ - _api.token = response.token!; - _navigation.replace(MainViewRoute); - _afterAuth(store); - } else { + if(state != null) { + if (state.auth?.operation == false) { _navigation.replace(LoginViewRoute); + } else { + AuthResponse response = await _api.auth(state.auth?.token ?? ''); + if (response.operation!) { + _api.token = response.token!; + _navigation.replace(MainViewRoute); + _afterAuth(store); + } else { + _navigation.replace(LoginViewRoute); + } } + } else { + _navigation.replace(LoginViewRoute); } } catch (e) { print(e); diff --git a/lib/main.dart b/lib/main.dart index c6b3a8d..ec1015e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -36,13 +36,13 @@ class MainApplication extends StatelessWidget { return StoreProvider( store: Redux.store!, child: ScreenUtilInit( - designSize: Size(411.43, 683.43), + designSize: Size(375, 812), builder: () => MaterialApp( theme: ThemeData( backgroundColor: backgroundColor, primaryColor: whiteColor, - accentColor: yellowColor, - scaffoldBackgroundColor: fillColor, + accentColor: primaryColor, + scaffoldBackgroundColor: backgroundColor // textTheme: GoogleFonts.robotoTextTheme( // Theme.of(context).textTheme, // ) diff --git a/lib/shared/app_colors.dart b/lib/shared/app_colors.dart index 44d6246..dae6de4 100644 --- a/lib/shared/app_colors.dart +++ b/lib/shared/app_colors.dart @@ -1,38 +1,22 @@ import 'package:flutter/material.dart'; -const Color backgroundColor = Color.fromRGBO(255, 255, 255, 1); -// const Color fillColor = Color.fromRGBO(248, 248, 248, 1); -const Color fillColor = Color.fromRGBO(252, 252, 252, 1); -const Color primaryColor = Color.fromRGBO(51, 122, 183, 1); +const Color backgroundColor = Color.fromRGBO(235, 239, 248, 1); +const Color primaryColor = Color.fromRGBO(255, 196, 45, 1); -const Color halykColor = Color.fromRGBO(0, 118, 59, 1); - - -const Color menuColor = Color.fromRGBO(0, 75, 120, 1); - -const Color redColor = Color.fromRGBO(217, 83, 79, 1); -const Color greenColor = Color.fromRGBO(92, 184, 92, 1); +const Color dangerColor = Color.fromRGBO(243, 98, 88, 1); +const Color successColor = Color.fromRGBO(39, 174, 96, 1); const Color whiteColor = Color.fromRGBO(255, 255, 255, 1); -const Color blackColor = Color.fromRGBO(0, 0, 0, 1); -const Color yellowColor = Color.fromRGBO(250, 175, 0, 1); +const Color blackColor = Color.fromRGBO(35, 35, 35, 1); -const Color purpleColor = Color.fromRGBO(118, 122, 230, 1); -const Color purpleSecondColor = Color.fromRGBO(140, 143, 236, 1); - -const Color textColor = Color.fromRGBO(51, 51, 51, 1); +const Color shadowColor = Color.fromRGBO(72, 72, 72, 0.25); +const Color primaryGrStartColor = Color.fromRGBO(255, 220, 96, 1); +const Color primaryGrEndColor = Color.fromRGBO(237, 137, 44, 1); -const Color shadowColor = Color.fromRGBO(80, 137, 196, 0.47); -const Color cardShadowColor = Color.fromRGBO(228, 229, 231, 0.25); -const Color blueColor = Color.fromRGBO(96, 205, 255, 1); -const Color blueColorLigth = Color.fromRGBO(96, 205, 255, 0.536); - - - -const Color textColorLight = Color.fromRGBO(162, 171, 191, 1); -const Color dayColor = Color.fromRGBO(52, 72, 94, 0.536); -const Color dayColorLight = Color.fromRGBO(255, 228, 231, 1); +const Color textColor = Color.fromRGBO(69, 69, 69, 1); +const Color placeholderColor = Color.fromRGBO( 153, 153, 153, 1); +const Color disableColor = Color.fromRGBO( 221, 221, 221, 1); diff --git a/lib/shared/shared_styles.dart b/lib/shared/shared_styles.dart index a46dc4f..cef8562 100644 --- a/lib/shared/shared_styles.dart +++ b/lib/shared/shared_styles.dart @@ -1,18 +1,23 @@ - import 'package:flutter/material.dart'; import 'app_colors.dart'; // Box Decorations - -BoxDecoration fieldDecoration = - BoxDecoration(borderRadius: BorderRadius.circular(5) , color: Colors.white); - +BoxDecoration fieldDecoration = BoxDecoration(color: whiteColor); BoxDecoration disabledFieldDecoration = BoxDecoration( borderRadius: BorderRadius.circular(5), color: Colors.grey[100]); -// Field Variables +const LinearGradient primaryGradient = LinearGradient( + colors: [ + primaryGrStartColor, + primaryGrEndColor, + ], + begin: const FractionalOffset(0.0, 0.0), + end: const FractionalOffset(1.0, 0.0), + stops: [0.0, 1.0], + tileMode: TileMode.clamp); +// Field Variables const double fieldHeight = 55; const double smallFieldHeight = 40; const double inputFieldBottomMargin = 30; @@ -22,26 +27,14 @@ const EdgeInsets largeFieldPadding = const EdgeInsets.symmetric(horizontal: 15, vertical: 15); // Text Variables -const TextStyle productTextStyle = const TextStyle( fontWeight: FontWeight.w600, color: Colors.black, fontSize: 15); -const TextStyle productSubTextStyle = const TextStyle( fontWeight: FontWeight.w400, color: Colors.black54, fontSize: 12); -const TextStyle buttonTitleTextStyle = const TextStyle( - fontWeight: FontWeight.w700, color: whiteColor, fontSize: 14); -const TextStyle buttonTitleTextBlackStyle = const TextStyle( - fontWeight: FontWeight.w700, color: Colors.black, 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)); + BoxShadow(blurRadius: 10, color: shadowColor, offset: Offset(0, 4)); const BoxShadow cardShadowBox = - BoxShadow(blurRadius: 5, color: Colors.black26, offset: Offset(0, 5)); + BoxShadow(blurRadius: 3, color: Color.fromRGBO(0, 0, 0, 0.15), offset: Offset(0, 1)); diff --git a/lib/views/add_product/add_product_view.dart b/lib/views/add_product/add_product_view.dart index f01d781..2043ad0 100644 --- a/lib/views/add_product/add_product_view.dart +++ b/lib/views/add_product/add_product_view.dart @@ -36,7 +36,7 @@ class _AddProductViewState extends State { _searchTextController = TextEditingController(); _searchTextController.addListener(() { if(_searchTextController.text.isNotEmpty){ - searchByField(_searchTextController.text); + searchByField(_searchTextController.text); } else { reset(); } @@ -93,8 +93,10 @@ class _AddProductViewState extends State { isOdd: index % 2 == 0, name: good.name, price: good.price, - categoryName: _history?.last?.name!, - onPress: () => onGoodPress(good), + categoryName: _history?.last?.name, + onPress: () { + onGoodPress(good); + } , ); }, ), @@ -119,12 +121,12 @@ class _AddProductViewState extends State { List actions() { return [ if(_history!.length > 1) - FlatButton(onPressed: () { + TextButton(onPressed: () { _history!.removeLast(); navigateCategory(_history!.last.id!); }, child: Text('Назад', style: TextStyle(color: Colors.black),),), - FlatButton(onPressed: reset, child: Text('Сбросить', style: TextStyle(color: Colors.black),),) + TextButton(onPressed: reset, child: Text('Сбросить', style: TextStyle(color: Colors.black),),) ]; } diff --git a/lib/views/add_product/component/add_category_list_item.dart b/lib/views/add_product/component/add_category_list_item.dart index 667b59a..b97b2fa 100644 --- a/lib/views/add_product/component/add_category_list_item.dart +++ b/lib/views/add_product/component/add_category_list_item.dart @@ -15,7 +15,7 @@ class AddCategoryListItem extends StatelessWidget { Widget build(BuildContext context) { return Card( child: ListTile( - onTap: () => onPress, + onTap: () => onPress!(), contentPadding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), title: Padding( padding: const EdgeInsets.only(top: 4.0), @@ -24,17 +24,18 @@ class AddCategoryListItem extends StatelessWidget { child: Center( child: Text( name!, - style: productTextStyle, + style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.black, fontSize: 15), overflow: TextOverflow.ellipsis, maxLines: 3, ), ) ), ), - tileColor: !isOdd! ? fillColor : backgroundColor, + tileColor: !isOdd! ? whiteColor : backgroundColor, trailing: Icon( Icons.arrow_right, - color: yellowColor, + color: primaryColor, ), ), ); diff --git a/lib/views/add_product/component/add_product_list_item.dart b/lib/views/add_product/component/add_product_list_item.dart index dee6833..559521c 100644 --- a/lib/views/add_product/component/add_product_list_item.dart +++ b/lib/views/add_product/component/add_product_list_item.dart @@ -19,7 +19,7 @@ class AddProductListItem extends StatelessWidget { Widget build(BuildContext context) { return Card( child: ListTile( - onTap: () => onPress, + onTap: () => onPress!(), contentPadding: const EdgeInsets.symmetric( horizontal: 8.0 ,vertical: 4.0 ), title: Padding( padding: const EdgeInsets.all(4.0), @@ -32,12 +32,15 @@ class AddProductListItem extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(name! , style: productTextStyle, overflow: TextOverflow.ellipsis, maxLines: 2,), + Text(name! , style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.black, fontSize: 15), overflow: TextOverflow.ellipsis, maxLines: 2,), verticalSpaceTiny, if(ean!=null) - Text('Штрих-код: $ean' , style: productSubTextStyle,), + Text('Штрих-код: $ean' , style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.black, fontSize: 12),), if(categoryName!=null) - Text(categoryName!, style: productSubTextStyle,), + Text(categoryName!, style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.black, fontSize: 12),), ], ), ), @@ -54,7 +57,7 @@ class AddProductListItem extends StatelessWidget { ], ), ), - tileColor: !isOdd! ? fillColor : backgroundColor, + tileColor: !isOdd! ? whiteColor : backgroundColor, ), ); } diff --git a/lib/views/login/login_view.dart b/lib/views/login/login_view.dart index f568e3d..ebbea81 100644 --- a/lib/views/login/login_view.dart +++ b/lib/views/login/login_view.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:flutter/services.dart'; import 'package:flutter_redux/flutter_redux.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; import 'package:satu/core/redux/actions/user_actions.dart'; import 'package:satu/core/redux/state/user_state.dart'; @@ -13,6 +14,7 @@ import 'package:satu/shared/app_colors.dart'; import 'package:satu/shared/ui_helpers.dart'; import 'package:satu/widgets/buttons/busy_button.dart'; import 'package:satu/widgets/fields/input_field.dart'; +import 'package:satu/widgets/ui/logo.dart'; class LoginView extends StatefulWidget { @@ -28,17 +30,15 @@ class _LoginViewState extends State { final FocusNode passwordNode = new FocusNode(); - final GlobalKey _scaffoldKey = new GlobalKey(); + final DialogService _dialogService = locator(); @override void initState() { super.initState(); - emailController = TextEditingController(text: 'test11@gmail.com'); - passwordController = TextEditingController(text: 'qwe123'); - + passwordController = TextEditingController(); } @override @@ -55,77 +55,44 @@ class _LoginViewState extends State { converter: (store) => store.state.userState!, builder: (context, vm) { return Scaffold( - key: _scaffoldKey, - backgroundColor: fillColor, - body: Padding( - padding: const EdgeInsets.symmetric(horizontal: 50), - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Stack( - alignment: Alignment.bottomLeft, - children: [ - SizedBox( - height: 150, - child: Image.asset('assets/images/logo.png'), - ), - Positioned( - child: Text( - 'онлайн касса', - style: TextStyle(fontWeight: FontWeight.bold), - ), - bottom: 23.0, - left: 25.0, - ), - ], + body: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + LogoSatu(), + InputField( + placeholder: 'Введите почту', + controller: emailController, + textInputType: TextInputType.emailAddress, + nextFocusNode: passwordNode, + ), + verticalSpaceSmall, + InputField( + placeholder: 'Введите пароль', + password: true, + controller: passwordController, + fieldFocusNode: passwordNode, + enterPressed: _pressBtnEnter, + textInputAction: TextInputAction.done, + ), + verticalSpaceMedium, + Padding( + padding: EdgeInsets.only( left: 45.sp, right: 45.sp, top: 30.sp ), + child: BusyButton( + title: 'ВОЙТИ', + busy: vm.isLoading!, + onPressed: _pressBtnEnter, ), - - InputField( - placeholder: 'Электронная почта', - controller: emailController, - textInputType: TextInputType.emailAddress, - nextFocusNode: passwordNode, - ), - verticalSpaceSmall, - InputField( - placeholder: 'Пароль', - password: true, - controller: passwordController, - fieldFocusNode: passwordNode, - enterPressed: _pressBtnEnter, - textInputAction: TextInputAction.done, - ), - verticalSpaceMedium, - Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - SizedBox( - width: 150, - child: BusyButton( - title: 'Войти', - busy: vm.isLoading!, - onPressed: _pressBtnEnter, - mainColor: yellowColor, - ), - ) - ], - ), - verticalSpaceLarge, -// TextLink( -// 'Регистрация', -// onPressed: () {}, -// ), - IconButton( - icon: Icon(MdiIcons.qrcodeScan), - iconSize: 40, - tooltip: "Scan", - onPressed: scan, - ) - ], - ), + ), + verticalSpaceLarge, + IconButton( + icon: Icon(MdiIcons.qrcodeScan), + iconSize: ScreenUtil().setSp(40.0), + tooltip: "Scan", + onPressed: scan, + ) + ], )); }); } diff --git a/lib/views/work/tabs/buy_view.dart b/lib/views/work/tabs/buy_view.dart index de5967d..39d9dbe 100644 --- a/lib/views/work/tabs/buy_view.dart +++ b/lib/views/work/tabs/buy_view.dart @@ -13,7 +13,8 @@ class BuyView extends StatelessWidget { body: Center( child: Text( 'Index 2: School', - style: productTextStyle, + style: TextStyle( + fontWeight: FontWeight.w600, color: Colors.black, fontSize: 15), ), ), ); diff --git a/lib/views/work/tabs/component/contagent_select_bar.dart b/lib/views/work/tabs/component/contagent_select_bar.dart new file mode 100644 index 0000000..fe011a4 --- /dev/null +++ b/lib/views/work/tabs/component/contagent_select_bar.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:satu/shared/app_colors.dart'; +import 'package:satu/shared/shared_styles.dart'; +import 'package:satu/widgets/dialog/modal_select_dialog.dart'; + +class ContragentSelectBar extends StatelessWidget { + final String value; + + const ContragentSelectBar({Key? key, required this.value}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration(color: whiteColor), + child: Material( + type: MaterialType.transparency, + child: InkWell( + onTap: () {}, + child: Padding( + padding: EdgeInsets.symmetric( vertical: 8.w, horizontal: 15.w ), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Контрагент', + style: TextStyle(fontSize: ScreenUtil().setSp(10), color: placeholderColor), + ), + Text( + value, + style: TextStyle(fontSize: ScreenUtil().setSp(14), color: textColor), + ), + ], + )), + Center( + child: Icon(Icons.arrow_forward_ios, size: ScreenUtil().setSp(14),), + ) + ], + ), + ))), + ); + } +} diff --git a/lib/views/work/tabs/component/product_list_item.dart b/lib/views/work/tabs/component/product_list_item.dart index f030d32..8e3217c 100644 --- a/lib/views/work/tabs/component/product_list_item.dart +++ b/lib/views/work/tabs/component/product_list_item.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:satu/core/redux/actions/sell_actions.dart'; import 'package:satu/core/redux/store.dart'; import 'package:satu/core/services/navigator_service.dart'; @@ -43,12 +44,11 @@ class _ProductListItemState extends State { return Dismissible( background: Container( alignment: AlignmentDirectional.centerEnd, - color: redColor, + color: dangerColor, child: Padding( padding: const EdgeInsets.all(8.0), child: Text( 'Удалить', - style: buttonTitleTextStyle, ), ), ), @@ -61,8 +61,8 @@ class _ProductListItemState extends State { title: const Text("Внимание"), content: Text("Удалить товар \"${this.widget.name}\" - ${widget.count} ед. ?"), actions: [ - FlatButton(onPressed: () => Navigator.of(context).pop(true), child: const Text("Удалить")), - FlatButton( + TextButton(onPressed: () => Navigator.of(context).pop(true), child: const Text("Удалить")), + TextButton( onPressed: () => Navigator.of(context).pop(false), child: const Text("Отмена"), ), @@ -77,57 +77,113 @@ class _ProductListItemState extends State { }, key: Key(widget.name ?? ''), child: ListTile( - onTap: () => _onItemTapped(context), + //onTap: () => _onItemTapped(context), contentPadding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 4.0), - title: Padding( - padding: const EdgeInsets.only(top: 4.0), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - flex: 3, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + title: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + widget.name ?? '', + style: TextStyle(fontSize: 12.sp, color: textColor), + overflow: TextOverflow.ellipsis, + maxLines: 2, + ), + verticalSpaceTiny, + Text( + 'Штрих-код: ${widget.ean}', + style: TextStyle(color: placeholderColor, fontSize: 8.sp), + ), + if (widget.categoryName != null) Text( - widget.name ?? '', - style: const TextStyle(fontWeight: FontWeight.w500), - overflow: TextOverflow.ellipsis, - maxLines: 2, - ), - verticalSpaceTiny, - Text( - 'Штрих-код: ${widget.ean}', - style: productSubTextStyle, - ), - Text( - widget.categoryName ?? '', - style: productSubTextStyle, + 'Категория: ${widget.categoryName}', + style: TextStyle(color: placeholderColor, fontSize: 8.sp), ) - ], - ), + ], ), - Flexible( - flex: 1, - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text( + ), + SizedBox( + width: 100.w, + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 3.0), + child: Text( '${widget.price} ₸', - style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w500, color: textColor), ), - Text( - '${widget.count} шт', - style: const TextStyle(fontSize: 12), - ), - ], - ), + ), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Material( + color: Colors.transparent, + borderRadius: BorderRadius.circular(ScreenUtil().radius(5)), + child: InkWell( + onTap: () {}, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(ScreenUtil().radius(5)), + border: Border.all(width: 1.0.sp, color: successColor)), + child: Icon( + Icons.add, + color: successColor, + size: 20.0.sp, + ), + ), + ), + ), + Container( + width: 45.w, + margin: EdgeInsets.symmetric( horizontal: 5.w), + padding: EdgeInsets.symmetric( vertical: 6.0.w ), + decoration: BoxDecoration( + color: whiteColor, + borderRadius: BorderRadius.circular(ScreenUtil().radius(5)), + boxShadow: [cardShadowBox]), + child: SizedBox( + width: 45.w, + child: Text( + '${widget.count} шт', + style: TextStyle( + fontSize: 8.sp, + color: placeholderColor + ), + textAlign: TextAlign.center, + ), + ), + ), + Material( + color: Colors.transparent, + borderRadius: BorderRadius.circular(ScreenUtil().radius(5)), + child: InkWell( + onTap: () {}, + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(ScreenUtil().radius(5)), + border: Border.all(width: 1.0.sp, color: widget.count! <= 1.0 ? disableColor : dangerColor)), + child: Icon( + Icons.remove, + color: widget.count! <= 1.0 ? disableColor : dangerColor, + size: 20.0.sp, + ), + ), + ), + ), + ], + ), + ], ), - ], - ), + ), + ], ), - tileColor: !widget.isOdd! ? fillColor : backgroundColor, + tileColor: !widget.isOdd! ? whiteColor : whiteColor, ), ); } diff --git a/lib/views/work/tabs/component/products_app_bar.dart b/lib/views/work/tabs/component/products_app_bar.dart index 3db68ab..98171db 100644 --- a/lib/views/work/tabs/component/products_app_bar.dart +++ b/lib/views/work/tabs/component/products_app_bar.dart @@ -12,30 +12,55 @@ class ProductsAppBar extends StatelessWidget implements PreferredSizeWidget { final double elevation; final Color? backgroundColor; - const ProductsAppBar({Key? key, this.title, this.actions, this.child,this.childHeight = 0, this.elevation = 0.0, this.backgroundColor = Colors.transparent }) : super(key: key); + const ProductsAppBar( + {Key? key, + this.title, + this.actions, + this.child, + this.childHeight = 0, + this.elevation = 0.0, + this.backgroundColor = Colors.transparent}) + : super(key: key); + @override - Widget build(BuildContext context) { + Widget build(BuildContext context) { return Material( elevation: elevation, color: backgroundColor, - child: Column( - children: [ - AppBar( - title: Text(title ?? ''), - backgroundColor: Colors.transparent, - elevation: 0.0, - leading: IconButton( - icon: Icon(Icons.menu, color: yellowColor,), - onPressed: () { - locator().scaffoldDrawerKey.currentState!.openDrawer(); - }, - ), - actions: actions - , + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('assets/images/top_bar_bg.png'), + fit: BoxFit.fitWidth, + alignment: FractionalOffset.topLeft, ), - if(child !=null && childHeight! > 0) - child!, - ], + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + AppBar( + title: Text(title ?? ''), + centerTitle: true, + backgroundColor: Colors.transparent, + elevation: 0.0, + leading: IconButton( + icon: Icon( + Icons.menu, + color: blackColor, + ), + onPressed: () { + locator() + .scaffoldDrawerKey + .currentState! + .openDrawer(); + }, + ), + actions: actions, + ), + if (child != null && childHeight! > 0) child!, + ], + ), ), ); } diff --git a/lib/views/work/tabs/component/products_header_bar.dart b/lib/views/work/tabs/component/products_header_bar.dart index c2d8255..f05bbf9 100644 --- a/lib/views/work/tabs/component/products_header_bar.dart +++ b/lib/views/work/tabs/component/products_header_bar.dart @@ -1,73 +1,36 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:satu/shared/app_colors.dart'; import 'package:satu/shared/shared_styles.dart'; import 'package:satu/widgets/dialog/modal_select_dialog.dart'; - class ProductHeaderBar extends StatelessWidget { final int count; final num sum; - const ProductHeaderBar({Key? key, required this.count, required this.sum}) : super(key: key); + const ProductHeaderBar({Key? key, required this.count, required this.sum}) + : super(key: key); @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.only( - bottom: 16.00, - left: 8.0, - right: 8.0, - ), + padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 10.w), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Контрагент: Частное лицо', - style: productTextStyle, - ), - IconButton( - icon: Icon( - Icons.edit, - color: yellowColor, - ), - onPressed: () { - List selected = [1]; - showDialog( - context: context, - builder: (BuildContext context) { - return Container(); - // return DropdownDialog( - // dialogBox: true, - // multipleSelection: false, - // items: ['Частное лицо', 'ИП Иванов', 'ТО "Рога и копыта"', 'Network Energy'] - // .map>((String value) { - // return DropdownMenuItem( - // value: value, - // child: Text(value), - // ); - // }).toList(), - // selectedItems: selected, - // hint: Text('Выберите контрагента'), - // closeButton: 'Отмена', - // ); - }).then((value) => { - print(selected) - }); - }), - - ], + Text( + 'Итого: $sum тнг', + style: TextStyle( + fontWeight: FontWeight.w700, + color: blackColor, + fontSize: ScreenUtil().setSp(20)), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - 'Всего: $count наим.', - style: productTextStyle, - ), - Text('Итого: $sum тнг', style: productTextStyle), - ], + Text( + 'Товаров выбрано: $count', + style: TextStyle( + fontWeight: FontWeight.w400, + color: blackColor, + fontSize: ScreenUtil().setSp(15)), ), ], ), diff --git a/lib/views/work/tabs/component/products_title_bar.dart b/lib/views/work/tabs/component/products_title_bar.dart new file mode 100644 index 0000000..10dc845 --- /dev/null +++ b/lib/views/work/tabs/component/products_title_bar.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:satu/core/redux/actions/sell_actions.dart'; +import 'package:satu/core/redux/store.dart'; +import 'package:satu/shared/app_colors.dart'; +import 'package:satu/shared/shared_styles.dart'; +import 'package:satu/widgets/dialog/modal_select_dialog.dart'; + +class ProductsTitleBarBar extends StatelessWidget { + final bool itemsExist; + + const ProductsTitleBarBar({Key? key, required this.itemsExist}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + child: Padding( + padding: EdgeInsets.only(left: 15.w, right: 5.w, top: 30.w), + child: Row( + children: [ + Expanded( + child: Padding( + padding: EdgeInsets.symmetric( vertical: 16.w ), + child: Text( + 'Товары', + style: TextStyle(fontSize: ScreenUtil().setSp(14), color: placeholderColor), + ), + )), + if(itemsExist) + TextButton( + onPressed: () { + Redux.store!.dispatch(removeAllSellData); + }, + child: Text( + 'Удалить все', + style: TextStyle(fontSize: 14.sp, color: dangerColor), + )) + ], + ), + ), + ); + } +} diff --git a/lib/views/work/tabs/sell_view.dart b/lib/views/work/tabs/sell_view.dart index 5ce57f8..fc01138 100644 --- a/lib/views/work/tabs/sell_view.dart +++ b/lib/views/work/tabs/sell_view.dart @@ -14,11 +14,12 @@ import 'package:satu/shared/ui_helpers.dart'; import 'package:satu/views/work/tabs/component/product_list_item.dart'; import 'package:satu/views/work/tabs/component/products_app_bar.dart'; import 'package:satu/views/work/tabs/component/products_header_bar.dart'; +import 'package:satu/views/work/tabs/component/products_title_bar.dart'; import 'package:satu/views/work/tabs/utils/ProductUtils.dart'; +import 'component/contagent_select_bar.dart'; + class SellView extends StatelessWidget { - - @override Widget build(BuildContext context) { return StoreConnector( @@ -27,31 +28,38 @@ class SellView extends StatelessWidget { return Scaffold( appBar: ProductsAppBar( title: 'Продажа', - actions: actions(), - elevation: 2.0, child: ProductHeaderBar( count: state.items!.length, sum: sumProducts(state.items!), ), backgroundColor: backgroundColor, - childHeight: 80, + childHeight: 60, ), - body: ListView.builder( - physics: BouncingScrollPhysics(), - itemCount: state.items!.length, - itemBuilder: (BuildContext context, int index) { - ProductDao product = state.items!.elementAt(index); - return ProductListItem( - key: UniqueKey(), - ean: product.eanCode, - isOdd: index % 2 == 0, - name: product.productName, - price: product.price, - count: product.count, - categoryName: product.categoryName, - transactionId: product.transactionId, - ); - }, + body: Column( + children: [ + ContragentSelectBar( + value: 'Частное лицо', + ), + ProductsTitleBarBar(itemsExist: state.items!.isNotEmpty), + ListView.builder( + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemCount: state.items!.length, + itemBuilder: (BuildContext context, int index) { + ProductDao product = state.items!.elementAt(index); + return ProductListItem( + key: UniqueKey(), + ean: product.eanCode, + isOdd: index % 2 == 0, + name: product.productName, + price: product.price, + count: product.count, + categoryName: product.categoryName, + transactionId: product.transactionId, + ); + }, + ), + ], ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: floatingActionButtonRender(), @@ -64,37 +72,36 @@ class SellView extends StatelessWidget { converter: (store) => store.state.sellState!, builder: (_, snapshot) { return Padding( - padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 16.0), + padding: EdgeInsets.all(15.w), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.end, children: [ Visibility( - visible: snapshot.items!.isNotEmpty, + visible: snapshot.items!.isNotEmpty, child: FloatingActionButton( elevation: 2, - backgroundColor: greenColor, - + backgroundColor: successColor, onPressed: () => print('check'), - child: Icon( - Icons.check, - color: whiteColor, - size: 30.sp - ), - )), + child: Icon(Icons.check, color: whiteColor, size: 35.sp), + )), Column( mainAxisAlignment: MainAxisAlignment.end, children: [ FloatingActionButton( elevation: 2, onPressed: () => locator().push(AddProductViewRoute), - child: Icon(Icons.add, size: 30.sp,), + child: Icon( + Icons.add_rounded, + size: 45.sp, + color: whiteColor, + ), ), verticalSpaceMedium, FloatingActionButton( elevation: 2, onPressed: () => locator().push(AddByBarcodeViewRoute), - child: Icon(Icons.qr_code_rounded, size: 30.sp), + child: Icon(Icons.qr_code_rounded, size: 35.sp, color: whiteColor), ), ], ) @@ -103,17 +110,4 @@ class SellView extends StatelessWidget { ); }); } - - List actions() { - return [ - Padding( - padding: const EdgeInsets.all(8.0), - child: IconButton( - icon: Icon(Icons.delete, size: 30.0, color: yellowColor), - onPressed: () { - Redux.store!.dispatch(removeAllSellData); - }), - ) - ]; - } } diff --git a/lib/views/work/work_view.dart b/lib/views/work/work_view.dart index a69c0f9..105bf1a 100644 --- a/lib/views/work/work_view.dart +++ b/lib/views/work/work_view.dart @@ -61,7 +61,7 @@ class _WorkViewState extends State { ], currentIndex: _selectedIndex, unselectedItemColor: Colors.black54, - selectedItemColor: yellowColor, + selectedItemColor: primaryColor, selectedLabelStyle: const TextStyle( fontWeight: FontWeight.w600 ), backgroundColor: whiteColor, elevation: 8.0, diff --git a/lib/widgets/buttons/busy_button.dart b/lib/widgets/buttons/busy_button.dart index 02712da..1fa3169 100644 --- a/lib/widgets/buttons/busy_button.dart +++ b/lib/widgets/buttons/busy_button.dart @@ -1,5 +1,6 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:satu/shared/app_colors.dart'; import 'package:satu/shared/shared_styles.dart'; @@ -29,12 +30,9 @@ class _BusyButtonState extends State { return AnimatedContainer( duration: const Duration(milliseconds: 300), decoration: BoxDecoration( - color: widget.enabled - ? (widget.mainColor ?? primaryColor) - : widget.mainColor?.withOpacity(0.2) ?? - primaryColor.withOpacity(0.2), - borderRadius: BorderRadius.circular(7), - boxShadow: [cardShadowBox]), + gradient: primaryGradient, + borderRadius: BorderRadius.circular(5), + boxShadow: [buttonShadowBox]), child: Material( type: MaterialType.transparency, child: InkWell( @@ -43,25 +41,22 @@ class _BusyButtonState extends State { widget.onPressed(); }, child: AnimatedContainer( - height: widget.busy ? 45 : 45, - //width: widget.busy ? 40 : 40, + height: 40.h, duration: const Duration(milliseconds: 300), alignment: Alignment.center, - margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0 - //horizontal: widget.busy ? 10 : 10, - //vertical: widget.busy ? 10 : 10 - ), + //margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0 ), child: !widget.busy - ? AutoSizeText( + ? Text( widget.title, textAlign: TextAlign.center, - style: buttonTitleTextBlackStyle, - minFontSize: 2, + style: TextStyle( + fontWeight: FontWeight.w400, color: blackColor, fontSize: 12.sp ), + //minFontSize: 2, maxLines: 1, ) : SizedBox( - width: 30, - height: 30, + width: 20.h, + height: 20.h, child: CircularProgressIndicator( strokeWidth: 2, valueColor: diff --git a/lib/widgets/dialog/dialog_manager.dart b/lib/widgets/dialog/dialog_manager.dart index f597ba9..a937119 100644 --- a/lib/widgets/dialog/dialog_manager.dart +++ b/lib/widgets/dialog/dialog_manager.dart @@ -57,14 +57,14 @@ class _DialogManagerState extends State { content: Text(request.description!), actions: [ if (isConfirmationDialog) - FlatButton( + TextButton( child: Text(request.cancelTitle!), onPressed: () { _dialogService .dialogComplete(DialogResponse(confirmed: false)); }, ), - FlatButton( + TextButton( child: Text(request.buttonTitle!), onPressed: () { _dialogService diff --git a/lib/widgets/dialog/modal_select_dialog.dart b/lib/widgets/dialog/modal_select_dialog.dart index e4b9eae..d368b4e 100644 --- a/lib/widgets/dialog/modal_select_dialog.dart +++ b/lib/widgets/dialog/modal_select_dialog.dart @@ -66,7 +66,7 @@ class _DialogModalSelectState extends State { ), Align( alignment: Alignment.bottomRight, - child: FlatButton( + child: TextButton( onPressed: () { Navigator.of(context).pop(); }, diff --git a/lib/widgets/drawer/app_drawer.dart b/lib/widgets/drawer/app_drawer.dart index 4e39c07..c59270a 100644 --- a/lib/widgets/drawer/app_drawer.dart +++ b/lib/widgets/drawer/app_drawer.dart @@ -69,7 +69,7 @@ class AppDrawer extends StatelessWidget { margin: EdgeInsets.zero, padding: EdgeInsets.zero, decoration: BoxDecoration( - color: yellowColor + color: primaryColor ), // decoration: BoxDecoration( // image: DecorationImage( diff --git a/lib/widgets/fields/input_field.dart b/lib/widgets/fields/input_field.dart index 0c9ad9d..3206f06 100644 --- a/lib/widgets/fields/input_field.dart +++ b/lib/widgets/fields/input_field.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:satu/shared/app_colors.dart'; import 'package:satu/shared/shared_styles.dart'; import 'package:satu/shared/ui_helpers.dart'; @@ -53,7 +54,7 @@ class InputField extends StatefulWidget { class _InputFieldState extends State { late bool isPassword; late bool isSearch; - double fieldHeight = 55; + double fieldHeight = 45; @override void initState() { @@ -79,7 +80,7 @@ class _InputFieldState extends State { if (widget.labelText != null) NoteText(widget.labelText ?? ''), Container( //height: widget.smallVersion ? 40 : fieldHeight, - constraints: BoxConstraints(minHeight: widget.smallVersion ? 40 : fieldHeight), + constraints: BoxConstraints(minHeight: widget.smallVersion ? 40.h : fieldHeight), alignment: Alignment.centerLeft, padding: fieldPadding, decoration: @@ -88,7 +89,7 @@ class _InputFieldState extends State { children: [ Expanded( child: TextFormField( - style: TextStyle( color: textColor ), + style: TextStyle( color: textColor, fontSize: widget.smallVersion ? ScreenUtil().setSp(12) : ScreenUtil().setSp(15) ), controller: widget.controller, keyboardType: widget.textInputType, focusNode: widget.fieldFocusNode, @@ -114,10 +115,10 @@ class _InputFieldState extends State { decoration: InputDecoration( hintText: widget.placeholder, filled: true, - fillColor: Colors.white, + fillColor: whiteColor, border: InputBorder.none, hintStyle: - TextStyle(fontSize: widget.smallVersion ? 12 : 15, color: textColorLight)), + TextStyle(fontSize: widget.smallVersion ? ScreenUtil().setSp(12) : ScreenUtil().setSp(15), color: placeholderColor)), ), ), GestureDetector( @@ -162,7 +163,7 @@ class _InputFieldState extends State { if (widget.validationMessage != null) NoteText( widget.validationMessage ?? '', - color: Colors.red, + color: dangerColor, ), if (widget.additionalNote != null) verticalSpace(5), if (widget.additionalNote != null) NoteText(widget.additionalNote ?? ''), diff --git a/lib/widgets/fields/note_text.dart b/lib/widgets/fields/note_text.dart index 6a7f99e..c1fc495 100644 --- a/lib/widgets/fields/note_text.dart +++ b/lib/widgets/fields/note_text.dart @@ -16,7 +16,7 @@ class NoteText extends StatelessWidget { style: TextStyle( fontSize: fontSize ?? 12, fontWeight: FontWeight.normal, - color: color ?? dayColor, + color: color ?? placeholderColor, ), ); } diff --git a/lib/widgets/ui/logo.dart b/lib/widgets/ui/logo.dart new file mode 100644 index 0000000..efa096d --- /dev/null +++ b/lib/widgets/ui/logo.dart @@ -0,0 +1,29 @@ +import 'package:auto_size_text/auto_size_text.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class LogoSatu extends StatelessWidget { + const LogoSatu({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Padding( + padding: EdgeInsets.all(50.0.sp), + child: SizedBox( + width: 185.w, + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox( + height: 75.h, + child: Image.asset('assets/images/logo.png'), + ), + AutoSizeText('Товароучетная система', style: TextStyle(fontSize: 16.sp, fontWeight: FontWeight.w400 ), ) + ], + ), + ), + ); + } +}