refactoring ui
parent
9b866298f5
commit
6590fba912
|
|
@ -14,7 +14,7 @@ const String GoodColumnAppCompanyId = 'app_company_id';
|
||||||
class Good {
|
class Good {
|
||||||
int? id;
|
int? id;
|
||||||
int? categoryId;
|
int? categoryId;
|
||||||
String? name;
|
String name = '';
|
||||||
String? ean;
|
String? ean;
|
||||||
int? articul;
|
int? articul;
|
||||||
num? price;
|
num? price;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
class GoodResponse {
|
class GoodResponse {
|
||||||
int? id;
|
int? id;
|
||||||
int? categoryId;
|
int? categoryId;
|
||||||
String? name;
|
String name = '';
|
||||||
String? ean;
|
String? ean;
|
||||||
int? articul;
|
int? articul;
|
||||||
int? price;
|
int? price;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ class ProductDao {
|
||||||
int? categoryId;
|
int? categoryId;
|
||||||
num? count;
|
num? count;
|
||||||
num? price;
|
num? price;
|
||||||
String? productName;
|
String productName = '';
|
||||||
String? categoryName;
|
String? categoryName;
|
||||||
String? eanCode;
|
String? eanCode;
|
||||||
int? article;
|
int? article;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:satu/views/work/tabs/component/products_app_bar.dart';
|
import 'package:satu/widgets/bar/products_app_bar.dart';
|
||||||
import 'package:satu/widgets/tools/app_barcode_scanner_widget.dart';
|
import 'package:satu/widgets/tools/app_barcode_scanner_widget.dart';
|
||||||
|
|
||||||
class AddByBarcodeView extends StatefulWidget {
|
class AddByBarcodeView extends StatefulWidget {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ import 'package:satu/core/utils/locator.dart';
|
||||||
import 'package:satu/shared/app_colors.dart';
|
import 'package:satu/shared/app_colors.dart';
|
||||||
import 'package:satu/shared/ui_helpers.dart';
|
import 'package:satu/shared/ui_helpers.dart';
|
||||||
import 'package:satu/views/add_product/component/add_category_list_item.dart';
|
import 'package:satu/views/add_product/component/add_category_list_item.dart';
|
||||||
import 'package:satu/views/add_product/component/app_bar.dart';
|
import 'package:satu/widgets/bar/products_app_bar.dart';
|
||||||
|
import 'package:satu/widgets/bar/products_title_bar.dart';
|
||||||
import 'package:satu/widgets/fields/input_field.dart';
|
import 'package:satu/widgets/fields/input_field.dart';
|
||||||
|
|
||||||
import 'component/add_product_list_item.dart';
|
import 'component/add_product_list_item.dart';
|
||||||
|
|
@ -62,44 +63,42 @@ class _AddProductViewState extends State<AddProductView> {
|
||||||
int catSize = _categories?.length ?? 0;
|
int catSize = _categories?.length ?? 0;
|
||||||
int goodSize = _goods?.length ?? 0;
|
int goodSize = _goods?.length ?? 0;
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AddProductAppBar(title: 'Товар', actions: actions(),),
|
appBar: ProductsAppBar( title: 'Категория',),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
InputField(placeholder: 'Поиск по наименованию и коду товара',
|
InputField(placeholder: 'Поиск по наименованию или коду товара',
|
||||||
search: true,
|
search: true,
|
||||||
controller: _searchTextController,
|
controller: _searchTextController,
|
||||||
fieldFocusNode: _searchFocusNode,),
|
fieldFocusNode: _searchFocusNode,),
|
||||||
verticalSpaceTiny,
|
verticalSpaceTiny,
|
||||||
|
ProductsTitleBarBar(title: goodSize > 0 ? 'Выберите товар' : 'Выберите категорию',),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: ListView.separated(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
physics: BouncingScrollPhysics(),
|
||||||
child: ListView.builder(
|
itemCount: catSize + goodSize,
|
||||||
physics: BouncingScrollPhysics(),
|
itemBuilder: (BuildContext context, int index) {
|
||||||
itemCount: catSize + goodSize,
|
if (index < catSize) {
|
||||||
itemBuilder: (BuildContext context, int index) {
|
Category category = _categories![index];
|
||||||
if (index < catSize) {
|
return AddCategoryListItem(
|
||||||
Category category = _categories![index];
|
name: category.name,
|
||||||
return AddCategoryListItem(
|
key: Key('category_${category.id}'),
|
||||||
name: category.name,
|
onPress: () => onCategoryPress(category),
|
||||||
isOdd: index % 2 == 0,
|
|
||||||
key: Key('category_${category.id}'),
|
|
||||||
onPress: () => onCategoryPress(category),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Good good = _goods![index - catSize];
|
|
||||||
return AddProductListItem(
|
|
||||||
key: Key('product_${good.id}'),
|
|
||||||
ean: good.ean,
|
|
||||||
isOdd: index % 2 == 0,
|
|
||||||
name: good.name,
|
|
||||||
price: good.price,
|
|
||||||
categoryName: _history?.last?.name,
|
|
||||||
onPress: () {
|
|
||||||
onGoodPress(good);
|
|
||||||
} ,
|
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
),
|
Good good = _goods![index - catSize];
|
||||||
|
return AddProductListItem(
|
||||||
|
key: Key('product_${good.id}'),
|
||||||
|
ean: good.ean,
|
||||||
|
name: good.name,
|
||||||
|
price: good.price,
|
||||||
|
categoryName: _history?.last?.name,
|
||||||
|
onPress: () {
|
||||||
|
onGoodPress(good);
|
||||||
|
} ,
|
||||||
|
);
|
||||||
|
}, separatorBuilder: (BuildContext context, int index) {
|
||||||
|
return Divider(height: 1.0, color: disableColor,);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
@ -118,18 +117,6 @@ class _AddProductViewState extends State<AddProductView> {
|
||||||
_navigatorService.pop();
|
_navigatorService.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> actions() {
|
|
||||||
return [
|
|
||||||
if(_history!.length > 1)
|
|
||||||
TextButton(onPressed: () {
|
|
||||||
_history!.removeLast();
|
|
||||||
navigateCategory(_history!.last.id!);
|
|
||||||
}, child: Text('Назад', style: TextStyle(color: Colors.black),),),
|
|
||||||
|
|
||||||
TextButton(onPressed: reset, child: Text('Сбросить', style: TextStyle(color: Colors.black),),)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
_history = [Category()
|
_history = [Category()
|
||||||
..id = 0
|
..id = 0
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,9 @@ import 'package:satu/shared/ui_helpers.dart';
|
||||||
|
|
||||||
class AddCategoryListItem extends StatelessWidget {
|
class AddCategoryListItem extends StatelessWidget {
|
||||||
final String? name;
|
final String? name;
|
||||||
final bool? isOdd;
|
|
||||||
final Function? onPress;
|
final Function? onPress;
|
||||||
|
|
||||||
const AddCategoryListItem({Key? key, this.name, this.isOdd, this.onPress }) : super(key: key);
|
const AddCategoryListItem({Key? key, this.name, this.onPress }) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -32,7 +31,6 @@ class AddCategoryListItem extends StatelessWidget {
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
tileColor: !isOdd! ? whiteColor : backgroundColor,
|
|
||||||
trailing: Icon(
|
trailing: Icon(
|
||||||
Icons.arrow_right,
|
Icons.arrow_right,
|
||||||
color: primaryColor,
|
color: primaryColor,
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,56 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
import 'package:satu/shared/app_colors.dart';
|
import 'package:satu/shared/app_colors.dart';
|
||||||
import 'package:satu/shared/shared_styles.dart';
|
import 'package:satu/shared/shared_styles.dart';
|
||||||
import 'package:satu/shared/ui_helpers.dart';
|
import 'package:satu/shared/ui_helpers.dart';
|
||||||
|
import 'package:satu/widgets/ui/product_title_widget.dart';
|
||||||
|
|
||||||
class AddProductListItem extends StatelessWidget {
|
class AddProductListItem extends StatelessWidget {
|
||||||
final String? name;
|
final String name;
|
||||||
final String? ean;
|
final String? ean;
|
||||||
final String? categoryName;
|
final String? categoryName;
|
||||||
final num? price;
|
final num? price;
|
||||||
final num? count;
|
final num? count;
|
||||||
final bool? isOdd;
|
|
||||||
final Function? onPress;
|
final Function? onPress;
|
||||||
|
|
||||||
const AddProductListItem({Key? key, this.name, this.ean, this.categoryName, this.price, this.count, this.isOdd, this.onPress}) : super(key: key);
|
const AddProductListItem({Key? key, required this.name, this.ean, this.categoryName, this.price, this.count, this.onPress}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Card(
|
return Material(
|
||||||
child: ListTile(
|
color: Colors.transparent,
|
||||||
|
child: InkWell(
|
||||||
onTap: () => onPress!(),
|
onTap: () => onPress!(),
|
||||||
contentPadding: const EdgeInsets.symmetric( horizontal: 8.0 ,vertical: 4.0 ),
|
child: Container(
|
||||||
title: Padding(
|
decoration: BoxDecoration(
|
||||||
padding: const EdgeInsets.all(4.0),
|
color: whiteColor
|
||||||
child: Row(
|
),
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
child: Padding(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
padding: const EdgeInsets.all(4.0),
|
||||||
children: [
|
child: Row(
|
||||||
Flexible(
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
flex: 3,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
child: Column(
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
Flexible(
|
||||||
children: [
|
flex: 3,
|
||||||
Text(name! , style: TextStyle(
|
child: ProductTitleWidget( name: name, ean: ean, categoryName: categoryName, ),
|
||||||
fontWeight: FontWeight.w600, color: Colors.black, fontSize: 15), overflow: TextOverflow.ellipsis, maxLines: 2,),
|
|
||||||
verticalSpaceTiny,
|
|
||||||
if(ean!=null)
|
|
||||||
Text('Штрих-код: $ean' , style: TextStyle(
|
|
||||||
fontWeight: FontWeight.w600, color: Colors.black, fontSize: 12),),
|
|
||||||
if(categoryName!=null)
|
|
||||||
Text(categoryName!, style: TextStyle(
|
|
||||||
fontWeight: FontWeight.w600, color: Colors.black, fontSize: 12),),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
Flexible(
|
||||||
Flexible(
|
flex: 1,
|
||||||
flex: 1,
|
child: Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
children: [
|
Text('${price} ₸', style: TextStyle( fontSize: ScreenUtil().setSp(18.0), fontWeight: FontWeight.bold ),),
|
||||||
Text('${price} ₸', style: const TextStyle( fontSize: 20, fontWeight: FontWeight.bold ),),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
tileColor: !isOdd! ? whiteColor : backgroundColor,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:satu/core/services/navigator_service.dart';
|
|
||||||
import 'package:satu/core/utils/locator.dart';
|
|
||||||
import 'package:satu/shared/app_colors.dart';
|
|
||||||
|
|
||||||
class AddProductAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|
||||||
final String? title;
|
|
||||||
final List<Widget>? actions;
|
|
||||||
|
|
||||||
const AddProductAppBar({Key? key, this.title, this.actions}) : super(key: key);
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return AppBar(
|
|
||||||
title: Text(title!, style: const TextStyle(fontWeight: FontWeight.w700, color: Colors.black, fontSize: 25)),
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
elevation: 0.0,
|
|
||||||
actions: actions
|
|
||||||
,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Size get preferredSize {
|
|
||||||
return new Size.fromHeight(60.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:satu/core/services/navigator_service.dart';
|
import 'package:satu/core/services/navigator_service.dart';
|
||||||
import 'package:satu/core/utils/locator.dart';
|
import 'package:satu/core/utils/locator.dart';
|
||||||
import 'package:satu/routes/route_names.dart';
|
import 'package:satu/routes/route_names.dart';
|
||||||
import 'package:satu/views/work/tabs/component/products_app_bar.dart';
|
import 'package:satu/widgets/bar/products_app_bar.dart';
|
||||||
|
|
||||||
import 'component/setting_item.dart';
|
import 'component/setting_item.dart';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import 'package:satu/core/services/navigator_service.dart';
|
||||||
import 'package:satu/core/utils/locator.dart';
|
import 'package:satu/core/utils/locator.dart';
|
||||||
import 'package:satu/shared/shared_styles.dart';
|
import 'package:satu/shared/shared_styles.dart';
|
||||||
|
|
||||||
import 'component/products_app_bar.dart';
|
import '../../../widgets/bar/products_app_bar.dart';
|
||||||
|
|
||||||
class BuyView extends StatelessWidget {
|
class BuyView extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,10 @@ import 'package:satu/shared/app_colors.dart';
|
||||||
import 'package:satu/shared/shared_styles.dart';
|
import 'package:satu/shared/shared_styles.dart';
|
||||||
import 'package:satu/shared/ui_helpers.dart';
|
import 'package:satu/shared/ui_helpers.dart';
|
||||||
import 'package:satu/views/add_by_barcode/add_by_barcode_view.dart';
|
import 'package:satu/views/add_by_barcode/add_by_barcode_view.dart';
|
||||||
|
import 'package:satu/widgets/ui/product_title_widget.dart';
|
||||||
|
|
||||||
class ProductListItem extends StatefulWidget {
|
class ProductListItem extends StatefulWidget {
|
||||||
final String? name;
|
final String name;
|
||||||
final String? ean;
|
final String? ean;
|
||||||
final String? categoryName;
|
final String? categoryName;
|
||||||
final num? price;
|
final num? price;
|
||||||
|
|
@ -21,7 +22,7 @@ class ProductListItem extends StatefulWidget {
|
||||||
final int? transactionId;
|
final int? transactionId;
|
||||||
|
|
||||||
const ProductListItem(
|
const ProductListItem(
|
||||||
{Key? key, this.name, this.ean, this.categoryName, this.price, this.count, this.isOdd, this.transactionId})
|
{Key? key, this.name = '', this.ean, this.categoryName, this.price, this.count, this.isOdd, this.transactionId})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -73,7 +74,7 @@ class _ProductListItemState extends State<ProductListItem> {
|
||||||
print(direction);
|
print(direction);
|
||||||
Redux.store!.dispatch(removeSellItem(transactionId: this.widget.transactionId!));
|
Redux.store!.dispatch(removeSellItem(transactionId: this.widget.transactionId!));
|
||||||
},
|
},
|
||||||
key: Key(widget.name ?? ''),
|
key: Key(widget.name ),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
//onTap: () => _onItemTapped(context),
|
//onTap: () => _onItemTapped(context),
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
|
|
@ -83,27 +84,7 @@ class _ProductListItemState extends State<ProductListItem> {
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: ProductTitleWidget(name: widget.name, ean: widget.ean, categoryName: widget.categoryName, ),
|
||||||
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.categoryName}',
|
|
||||||
style: TextStyle(color: placeholderColor, fontSize: 8.sp),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 100.w,
|
width: 100.w,
|
||||||
|
|
@ -131,7 +112,7 @@ class _ProductListItemState extends State<ProductListItem> {
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: whiteColor,
|
//color: whiteColor,
|
||||||
borderRadius: BorderRadius.circular(ScreenUtil().radius(5)),
|
borderRadius: BorderRadius.circular(ScreenUtil().radius(5)),
|
||||||
border: Border.all(width: 1.0.sp, color: successColor)),
|
border: Border.all(width: 1.0.sp, color: successColor)),
|
||||||
child: Icon(
|
child: Icon(
|
||||||
|
|
@ -171,7 +152,7 @@ class _ProductListItemState extends State<ProductListItem> {
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: whiteColor,
|
//color: whiteColor,
|
||||||
borderRadius: BorderRadius.circular(ScreenUtil().radius(5)),
|
borderRadius: BorderRadius.circular(ScreenUtil().radius(5)),
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
width: 1.0.sp, color: widget.count! <= 1.0 ? disableColor : dangerColor)),
|
width: 1.0.sp, color: widget.count! <= 1.0 ? disableColor : dangerColor)),
|
||||||
|
|
@ -195,3 +176,5 @@ class _ProductListItemState extends State<ProductListItem> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:satu/views/work/tabs/component/products_app_bar.dart';
|
import 'package:satu/widgets/bar/products_app_bar.dart';
|
||||||
|
|
||||||
import 'component/custom_field.dart';
|
import 'component/custom_field.dart';
|
||||||
import 'component/option_pill.dart';
|
import 'component/option_pill.dart';
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ import 'package:satu/routes/route_names.dart';
|
||||||
import 'package:satu/shared/app_colors.dart';
|
import 'package:satu/shared/app_colors.dart';
|
||||||
import 'package:satu/shared/ui_helpers.dart';
|
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/product_list_item.dart';
|
||||||
import 'package:satu/views/work/tabs/component/products_app_bar.dart';
|
import 'package:satu/widgets/bar/products_app_bar.dart';
|
||||||
import 'package:satu/views/work/tabs/component/products_header_bar.dart';
|
import 'package:satu/widgets/bar/products_header_bar.dart';
|
||||||
import 'package:satu/views/work/tabs/component/products_title_bar.dart';
|
import 'package:satu/widgets/bar/products_title_bar.dart';
|
||||||
import 'package:satu/views/work/tabs/utils/ProductUtils.dart';
|
import 'package:satu/views/work/tabs/utils/ProductUtils.dart';
|
||||||
|
|
||||||
import 'component/contagent_select_bar.dart';
|
import 'component/contagent_select_bar.dart';
|
||||||
|
|
@ -43,7 +43,7 @@ class SellView extends StatelessWidget {
|
||||||
ContragentSelectBar(
|
ContragentSelectBar(
|
||||||
value: 'Частное лицо',
|
value: 'Частное лицо',
|
||||||
),
|
),
|
||||||
Visibility(child: ProductsTitleBarBar(itemsExist: true), visible: state.items!.isNotEmpty,),
|
Visibility(child: ProductsTitleBarBar(itemsExist: true, title: 'Товары',), visible: state.items!.isNotEmpty,),
|
||||||
ListView.separated(
|
ListView.separated(
|
||||||
shrinkWrap: true,
|
shrinkWrap: true,
|
||||||
physics: BouncingScrollPhysics(),
|
physics: BouncingScrollPhysics(),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:satu/core/services/navigator_service.dart';
|
import 'package:satu/core/services/navigator_service.dart';
|
||||||
import 'package:satu/core/utils/locator.dart';
|
import 'package:satu/core/utils/locator.dart';
|
||||||
import 'package:satu/shared/app_colors.dart';
|
import 'package:satu/shared/app_colors.dart';
|
||||||
import 'package:satu/views/work/tabs/component/products_header_bar.dart';
|
import 'package:satu/widgets/bar/products_header_bar.dart';
|
||||||
|
|
||||||
class ProductsAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class ProductsAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
final String? title;
|
final String? title;
|
||||||
|
|
@ -8,8 +8,9 @@ import 'package:satu/widgets/dialog/modal_select_dialog.dart';
|
||||||
|
|
||||||
class ProductsTitleBarBar extends StatelessWidget {
|
class ProductsTitleBarBar extends StatelessWidget {
|
||||||
final bool itemsExist;
|
final bool itemsExist;
|
||||||
|
final String title;
|
||||||
|
|
||||||
const ProductsTitleBarBar({Key? key, required this.itemsExist}) : super(key: key);
|
const ProductsTitleBarBar({Key? key, this.itemsExist = false, required this.title}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -20,9 +21,9 @@ class ProductsTitleBarBar extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.symmetric( vertical: 16.w ),
|
padding: EdgeInsets.symmetric( vertical: 10.w ),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Товары',
|
title,
|
||||||
style: TextStyle(fontSize: ScreenUtil().setSp(14), color: placeholderColor),
|
style: TextStyle(fontSize: ScreenUtil().setSp(14), color: placeholderColor),
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
|
|
@ -54,7 +54,7 @@ class InputField extends StatefulWidget {
|
||||||
class _InputFieldState extends State<InputField> {
|
class _InputFieldState extends State<InputField> {
|
||||||
late bool isPassword;
|
late bool isPassword;
|
||||||
late bool isSearch;
|
late bool isSearch;
|
||||||
double fieldHeight = 45;
|
double fieldHeight = 40;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -87,6 +87,29 @@ class _InputFieldState extends State<InputField> {
|
||||||
widget.isReadOnly ? disabledFieldDecoration : fieldDecoration,
|
widget.isReadOnly ? disabledFieldDecoration : fieldDecoration,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () {
|
||||||
|
if(isSearch) {
|
||||||
|
widget.fieldFocusNode!.requestFocus();
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
isSearch = !isSearch;
|
||||||
|
});
|
||||||
|
FocusScope.of(context).requestFocus(new FocusNode()); //remove focus
|
||||||
|
WidgetsBinding.instance!.addPostFrameCallback((_) => widget.controller.clear()); // clear content
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
child: widget.search
|
||||||
|
? Container(
|
||||||
|
width: fieldHeight,
|
||||||
|
height: fieldHeight,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Icon(isSearch
|
||||||
|
? Icons.search
|
||||||
|
: Icons.search_off, color: placeholderColor))
|
||||||
|
: Container(),
|
||||||
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
style: TextStyle( color: textColor, fontSize: widget.smallVersion ? ScreenUtil().setSp(12) : ScreenUtil().setSp(15) ),
|
style: TextStyle( color: textColor, fontSize: widget.smallVersion ? ScreenUtil().setSp(12) : ScreenUtil().setSp(15) ),
|
||||||
|
|
@ -135,28 +158,6 @@ class _InputFieldState extends State<InputField> {
|
||||||
: Icons.visibility_off, color: textColor))
|
: Icons.visibility_off, color: textColor))
|
||||||
: Container(),
|
: Container(),
|
||||||
),
|
),
|
||||||
GestureDetector(
|
|
||||||
onTap: () {
|
|
||||||
if(isSearch) {
|
|
||||||
widget.fieldFocusNode!.requestFocus();
|
|
||||||
} else {
|
|
||||||
FocusScope.of(context).requestFocus(new FocusNode()); //remove focus
|
|
||||||
WidgetsBinding.instance!.addPostFrameCallback((_) => widget.controller.clear()); // clear content
|
|
||||||
}
|
|
||||||
setState(() {
|
|
||||||
isSearch = !isSearch;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: widget.search
|
|
||||||
? Container(
|
|
||||||
width: fieldHeight,
|
|
||||||
height: fieldHeight,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Icon(isSearch
|
|
||||||
? Icons.search
|
|
||||||
: Icons.search_off, color: textColor))
|
|
||||||
: Container(),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||||
|
import 'package:satu/shared/app_colors.dart';
|
||||||
|
import 'package:satu/shared/ui_helpers.dart';
|
||||||
|
import 'package:satu/views/work/tabs/component/product_list_item.dart';
|
||||||
|
|
||||||
|
class ProductTitleWidget extends StatelessWidget {
|
||||||
|
const ProductTitleWidget({Key? key, required this.name, this.ean, this.categoryName}) : super(key: key);
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
final String? ean;
|
||||||
|
final String? categoryName;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
name,
|
||||||
|
style: TextStyle(fontSize: 12.sp, color: textColor),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
maxLines: 2,
|
||||||
|
),
|
||||||
|
verticalSpaceTiny,
|
||||||
|
if (ean != null)
|
||||||
|
Text(
|
||||||
|
'Штрих-код: ${ean}',
|
||||||
|
style: TextStyle(color: placeholderColor, fontSize: 8.sp),
|
||||||
|
),
|
||||||
|
if (categoryName != null)
|
||||||
|
Text(
|
||||||
|
'Категория: ${categoryName}',
|
||||||
|
style: TextStyle(color: placeholderColor, fontSize: 8.sp),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue