131 lines
4.6 KiB
Dart
131 lines
4.6 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:satu/core/redux/actions/nav_actions.dart';
|
|
import 'package:satu/core/redux/actions/user_actions.dart';
|
|
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/settings/setting_view.dart';
|
|
import 'package:satu/views/work/work_view.dart';
|
|
|
|
class AppDrawer extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Drawer(
|
|
child: Container(
|
|
decoration: const BoxDecoration(color: backgroundColor),
|
|
child: ListView(
|
|
padding: EdgeInsets.zero,
|
|
children: <Widget>[
|
|
_createHeader(),
|
|
_createDrawerSectionTitle(text: 'СПРАВОЧНИКИ'),
|
|
_createDrawerItem(
|
|
icon: Icons.list,
|
|
text: 'Категории',
|
|
onTap: () {
|
|
Navigator.of(context).pop();
|
|
Redux.store!.dispatch(navigateDrawer(WorkView));
|
|
}),
|
|
_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: 'ПРОЧЕЕ'),
|
|
_createDrawerItem(icon: Icons.settings, text: 'Настройки'),
|
|
_createDrawerItem(icon: Icons.next_plan, text: 'Перейти на сайт'),
|
|
_createDrawerItem(
|
|
icon: Icons.exit_to_app,
|
|
text: 'Выйти из аккаунта',
|
|
onTap: () async {
|
|
Redux.store!.dispatch(logout);
|
|
}),
|
|
_createDrawerSectionTitle(text: ''),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _createHeader() {
|
|
return SizedBox(
|
|
height: 180.h,
|
|
child: DrawerHeader(
|
|
margin: EdgeInsets.zero,
|
|
padding: EdgeInsets.zero,
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
fit: BoxFit.cover,
|
|
image: AssetImage('assets/images/drawer/background.png'))),
|
|
child: Stack(children: <Widget>[
|
|
Positioned(
|
|
bottom: 12.0,
|
|
left: 16.0,
|
|
child: Row(
|
|
children: [
|
|
SizedBox(
|
|
height: 40,
|
|
width: 40,
|
|
child: Container(
|
|
decoration: const BoxDecoration(
|
|
image: DecorationImage(
|
|
fit: BoxFit.cover,
|
|
image: AssetImage(
|
|
'assets/images/drawer/user.png')))),
|
|
),
|
|
horizontalSpaceSmall,
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: const [
|
|
Text('Хайруллин Тимур',
|
|
style: TextStyle(fontSize: 16.0)),
|
|
Text('Продавец', style: TextStyle(fontSize: 12)),
|
|
],
|
|
),
|
|
],
|
|
)),
|
|
])),
|
|
);
|
|
}
|
|
|
|
Widget _createDrawerItem(
|
|
{required IconData icon,
|
|
required String text,
|
|
GestureTapCallback? onTap}) {
|
|
return Container(
|
|
decoration: const BoxDecoration(color: whiteColor),
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: InkWell(
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding:
|
|
const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0),
|
|
child: Row(
|
|
children: <Widget>[
|
|
Icon(icon),
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 8.0),
|
|
child: Text(text),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _createDrawerSectionTitle({required String text}) {
|
|
return Padding(
|
|
padding: const EdgeInsets.all(20.0),
|
|
child: Text(
|
|
text,
|
|
style: const TextStyle(fontSize: 10.0, color: placeholderColor),
|
|
));
|
|
}
|
|
}
|