117 lines
4.4 KiB
Dart
117 lines
4.4 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_redux/flutter_redux.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:satu/core/models/flow/product_dao.dart';
|
|
import 'package:satu/core/redux/actions/sell_actions.dart';
|
|
import 'package:satu/core/redux/state/sell_state.dart';
|
|
import 'package:satu/core/redux/store.dart';
|
|
import 'package:satu/core/services/navigator_service.dart';
|
|
import 'package:satu/core/utils/locator.dart';
|
|
import 'package:satu/routes/route_names.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';
|
|
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/utils/ProductUtils.dart';
|
|
|
|
class SellView extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return StoreConnector<AppState, SellState>(
|
|
converter: (store) => store.state.sellState,
|
|
builder: (_, state) {
|
|
return Scaffold(
|
|
appBar: ProductsAppBar(
|
|
title: 'Продажа',
|
|
actions: actions(),
|
|
elevation: 2.0,
|
|
child: ProductHeaderBar(
|
|
count: state.items.length,
|
|
sum: sumProducts(state.items),
|
|
),
|
|
backgroundColor: backgroundColor,
|
|
childHeight: 80,
|
|
),
|
|
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,
|
|
);
|
|
},
|
|
),
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
floatingActionButton: floatingActionButtonRender(),
|
|
);
|
|
});
|
|
}
|
|
|
|
Widget floatingActionButtonRender() {
|
|
return StoreConnector<AppState, SellState>(
|
|
converter: (store) => store.state.sellState,
|
|
builder: (_, snapshot) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12.0, vertical: 16.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
children: <Widget>[
|
|
Visibility(
|
|
visible: snapshot.items.isNotEmpty,
|
|
child: FloatingActionButton(
|
|
elevation: 2,
|
|
backgroundColor: greenColor,
|
|
onPressed: () => print('check'),
|
|
child: Icon(
|
|
Icons.check,
|
|
color: whiteColor,
|
|
size: 30.sp
|
|
),
|
|
)),
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
children: [
|
|
FloatingActionButton(
|
|
elevation: 2,
|
|
onPressed: () => locator<NavigatorService>().push(AddProductViewRoute),
|
|
child: Icon(Icons.add, size: 30.sp,),
|
|
),
|
|
verticalSpaceMedium,
|
|
FloatingActionButton(
|
|
elevation: 2,
|
|
onPressed: () => locator<NavigatorService>().push(AddByBarcodeViewRoute),
|
|
child: Icon(Icons.qr_code_rounded, size: 30.sp),
|
|
),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
);
|
|
});
|
|
}
|
|
|
|
List<Widget> 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);
|
|
}),
|
|
)
|
|
];
|
|
}
|
|
}
|