category_view.dart start dev
parent
b7be7ba4e4
commit
f4c74f8b2b
|
|
@ -0,0 +1,107 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:satu/core/entity/category_entity.dart';
|
||||
import 'package:satu/core/entity/goods_entity.dart';
|
||||
import 'package:satu/core/redux/actions/sell_actions.dart';
|
||||
import 'package:satu/core/redux/store.dart';
|
||||
import 'package:satu/core/services/dictionary_service.dart';
|
||||
import 'package:satu/core/services/navigator_service.dart';
|
||||
import 'package:satu/core/utils/locator.dart';
|
||||
import 'package:satu/shared/app_colors.dart';
|
||||
import 'package:satu/shared/ui_helpers.dart';
|
||||
import 'package:satu/views/dictionaries/component/dictionary_list_tile.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';
|
||||
|
||||
|
||||
|
||||
class CategoryDictionaryView extends StatefulWidget {
|
||||
@override
|
||||
_CategoryDictionaryViewState createState() => _CategoryDictionaryViewState();
|
||||
}
|
||||
|
||||
class _CategoryDictionaryViewState extends State<CategoryDictionaryView> {
|
||||
final DictionaryService _dictionaryService = locator<DictionaryService>();
|
||||
final NavigatorService _navigatorService = locator<NavigatorService>();
|
||||
late TextEditingController _searchTextController;
|
||||
final FocusNode _searchFocusNode = new FocusNode();
|
||||
|
||||
final List<Category> _contragents = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_searchTextController = TextEditingController();
|
||||
_searchTextController.addListener(() {
|
||||
if (_searchTextController.text.isNotEmpty) {
|
||||
searchByField(_searchTextController.text);
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchTextController.dispose();
|
||||
_searchFocusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: const ProductsAppBar(
|
||||
title: 'Категории',
|
||||
drawerShow: true,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
InputField(
|
||||
placeholder: 'Поиск по наименованию категории',
|
||||
search: true,
|
||||
controller: _searchTextController,
|
||||
fieldFocusNode: _searchFocusNode,
|
||||
),
|
||||
verticalSpaceTiny,
|
||||
const ProductsTitleBarBar(
|
||||
title: 'Выберите категорию',
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
itemCount: _contragents.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final Category category = _contragents[index];
|
||||
return const DictionaryTile(
|
||||
title: 'category.name',
|
||||
subTitle: 'sub'
|
||||
// key: Key('category_${category.id}'),
|
||||
//onPress: () => () {},
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider(
|
||||
height: 1.0,
|
||||
color: disableColor,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_searchTextController.clear();
|
||||
}
|
||||
|
||||
void searchByField(String query) async {
|
||||
|
||||
List<Good> goods = await _dictionaryService.getGoodsByNameOrEan(query);
|
||||
setState(() {
|
||||
goods;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:satu/shared/app_colors.dart';
|
||||
|
||||
class DictionaryTile extends StatelessWidget {
|
||||
const DictionaryTile(
|
||||
{
|
||||
required this.title,
|
||||
this.subTitle,
|
||||
Key? key
|
||||
})
|
||||
: super(key: key);
|
||||
|
||||
final String title;
|
||||
final String? subTitle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
color: whiteColor
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(title),
|
||||
if(subTitle != null)
|
||||
Text(subTitle!),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import 'package:satu/core/redux/state/nav_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/views/dictionaries/category/category_view.dart';
|
||||
import 'package:satu/views/settings/printer_bluetooth/PrinterSelect.dart';
|
||||
import 'package:satu/views/settings/setting_view.dart';
|
||||
import 'package:satu/views/work/work_view.dart';
|
||||
|
|
@ -16,10 +17,11 @@ class MainView extends StatefulWidget {
|
|||
|
||||
class _MainViewState extends State<MainView> {
|
||||
|
||||
NavigatorService _navigatorService = locator<NavigatorService>();
|
||||
final NavigatorService _navigatorService = locator<NavigatorService>();
|
||||
|
||||
final _workView = new WorkView(text: '1',);
|
||||
final _settingsView = new SettingsView();
|
||||
final _workView = const WorkView();
|
||||
final _settingsView = SettingsView();
|
||||
final _categoryDictView = CategoryDictionaryView();
|
||||
|
||||
Widget _body(Type viewClass) {
|
||||
if(viewClass == WorkView) {
|
||||
|
|
@ -28,6 +30,9 @@ class _MainViewState extends State<MainView> {
|
|||
if(viewClass == SettingsView) {
|
||||
return _settingsView;
|
||||
}
|
||||
if(viewClass == CategoryDictionaryView) {
|
||||
return _categoryDictView;
|
||||
}
|
||||
return _workView;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ import 'package:satu/views/work/tabs/sell_view.dart';
|
|||
import 'package:satu/widgets/bar/bottom_bar.dart';
|
||||
|
||||
class WorkView extends StatefulWidget {
|
||||
final String? text;
|
||||
const WorkView({Key? key}) : super(key: key);
|
||||
|
||||
const WorkView({Key? key, this.text}) : super(key: key);
|
||||
@override
|
||||
_WorkViewState createState() => _WorkViewState();
|
||||
}
|
||||
|
|
@ -20,14 +19,13 @@ class WorkView extends StatefulWidget {
|
|||
class _WorkViewState extends State<WorkView> {
|
||||
int _selectedIndex = 0;
|
||||
static const TextStyle optionStyle =
|
||||
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
||||
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
|
||||
final List<Widget> _widgetOptions = <Widget>[
|
||||
SellView(),
|
||||
BuyView(),
|
||||
JournalView(),
|
||||
];
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -45,30 +43,10 @@ class _WorkViewState extends State<WorkView> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: _widgetOptions.elementAt(_selectedIndex),
|
||||
bottomNavigationBar: BottomBar(selectedIndex: _selectedIndex, onTap: _onItemTapped,),
|
||||
// bottomNavigationBar: BottomNavigationBar(
|
||||
// items: const <BottomNavigationBarItem>[
|
||||
// BottomNavigationBarItem(
|
||||
// icon: Icon(MdiIcons.cartArrowUp),
|
||||
// label: 'Продажа',
|
||||
// ),
|
||||
// BottomNavigationBarItem(
|
||||
// icon: Icon(MdiIcons.cartArrowDown),
|
||||
// label: 'Покупка',
|
||||
// ),
|
||||
// BottomNavigationBarItem(
|
||||
// icon: Icon(MdiIcons.cashRegister),
|
||||
// label: 'Журнал',
|
||||
// ),
|
||||
// ],
|
||||
// currentIndex: _selectedIndex,
|
||||
// unselectedItemColor: Colors.black54,
|
||||
// selectedItemColor: primaryColor,
|
||||
// selectedLabelStyle: const TextStyle( fontWeight: FontWeight.w600 ),
|
||||
// backgroundColor: whiteColor,
|
||||
// elevation: 8.0,
|
||||
// onTap: _onItemTapped,
|
||||
// ),
|
||||
bottomNavigationBar: BottomBar(
|
||||
selectedIndex: _selectedIndex,
|
||||
onTap: _onItemTapped,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:satu/core/redux/store.dart';
|
|||
|
||||
import 'package:satu/shared/app_colors.dart';
|
||||
import 'package:satu/shared/ui_helpers.dart';
|
||||
import 'package:satu/views/dictionaries/category/category_view.dart';
|
||||
import 'package:satu/views/settings/setting_view.dart';
|
||||
import 'package:satu/views/work/work_view.dart';
|
||||
|
||||
|
|
@ -20,19 +21,26 @@ class AppDrawer extends StatelessWidget {
|
|||
padding: EdgeInsets.zero,
|
||||
children: <Widget>[
|
||||
_createHeader(),
|
||||
_createDrawerSectionTitle(text: 'ОСНОВНОЙ РАЗДЕЛ'),
|
||||
_createDrawerItem(
|
||||
icon: Icons.campaign_sharp,
|
||||
text: 'Касса',
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
Redux.store!.dispatch(navigateDrawer(WorkView));
|
||||
}),
|
||||
_createDrawerItem(icon: Icons.check, text: 'Инвентаризация'),
|
||||
_createDrawerSectionTitle(text: 'СПРАВОЧНИКИ'),
|
||||
_createDrawerItem(
|
||||
icon: Icons.list,
|
||||
text: 'Категории',
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
Redux.store!.dispatch(navigateDrawer(WorkView));
|
||||
Redux.store!.dispatch(navigateDrawer(CategoryDictionaryView));
|
||||
}),
|
||||
_createDrawerItem(
|
||||
icon: Icons.production_quantity_limits, text: 'Товары'),
|
||||
_createDrawerItem(icon: Icons.people, text: 'Контрагенты'),
|
||||
_createDrawerSectionTitle(text: 'РАЗДЕЛ'),
|
||||
_createDrawerItem(icon: Icons.check, text: 'Инвентаризация'),
|
||||
_createDrawerSectionTitle(text: 'ИНФОРМАЦИЯ'),
|
||||
_createDrawerItem(icon: Icons.question_answer, text: 'Справочник'),
|
||||
_createDrawerSectionTitle(text: 'ПРОЧЕЕ'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue