From 55e276b1894c1b4d964e6e3a89db460883f5bf51 Mon Sep 17 00:00:00 2001 From: suvaissov Date: Thu, 5 Aug 2021 11:23:41 +0600 Subject: [PATCH] bottom bar release --- assets/images/svg/buy.svg | 6 +++ assets/images/svg/journal.svg | 10 ++++ assets/images/svg/sell.svg | 13 +++++ lib/views/work/work_view.dart | 48 ++++++++--------- lib/widgets/bar/bottom_bar.dart | 92 +++++++++++++++++++++++++++++++++ pubspec.lock | 35 +++++++++++++ pubspec.yaml | 2 + 7 files changed, 183 insertions(+), 23 deletions(-) create mode 100644 assets/images/svg/buy.svg create mode 100644 assets/images/svg/journal.svg create mode 100644 assets/images/svg/sell.svg create mode 100644 lib/widgets/bar/bottom_bar.dart diff --git a/assets/images/svg/buy.svg b/assets/images/svg/buy.svg new file mode 100644 index 0000000..799f01f --- /dev/null +++ b/assets/images/svg/buy.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/assets/images/svg/journal.svg b/assets/images/svg/journal.svg new file mode 100644 index 0000000..cf0c479 --- /dev/null +++ b/assets/images/svg/journal.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/images/svg/sell.svg b/assets/images/svg/sell.svg new file mode 100644 index 0000000..5c8450a --- /dev/null +++ b/assets/images/svg/sell.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/lib/views/work/work_view.dart b/lib/views/work/work_view.dart index 105bf1a..19e10dc 100644 --- a/lib/views/work/work_view.dart +++ b/lib/views/work/work_view.dart @@ -7,6 +7,7 @@ import 'package:satu/shared/app_colors.dart'; import 'package:satu/views/work/tabs/buy_view.dart'; import 'package:satu/views/work/tabs/journal_view.dart'; import 'package:satu/views/work/tabs/sell_view.dart'; +import 'package:satu/widgets/bar/bottom_bar.dart'; class WorkView extends StatefulWidget { final String? text; @@ -44,29 +45,30 @@ class _WorkViewState extends State { Widget build(BuildContext context) { return Scaffold( body: _widgetOptions.elementAt(_selectedIndex), - bottomNavigationBar: BottomNavigationBar( - items: const [ - 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,), + // bottomNavigationBar: BottomNavigationBar( + // items: const [ + // 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, + // ), ); } } diff --git a/lib/widgets/bar/bottom_bar.dart b/lib/widgets/bar/bottom_bar.dart new file mode 100644 index 0000000..71ff912 --- /dev/null +++ b/lib/widgets/bar/bottom_bar.dart @@ -0,0 +1,92 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:satu/shared/app_colors.dart'; + +class BottomBar extends StatelessWidget { + const BottomBar({required this.selectedIndex, required this.onTap, Key? key}) + : super(key: key); + + final int selectedIndex; + final void Function(int index) onTap; + + @override + Widget build(BuildContext context) { + return Material( + elevation: 8.0, + child: SafeArea( + child: SizedBox( + height: 60.0, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + BottomButton( + active: selectedIndex == 0, + onTap: () => onTap(0), + svgFile: 'sell', + ), + BottomButton( + active: selectedIndex == 1, + onTap: () => onTap(1), + svgFile: 'buy', + ), + BottomButton( + active: selectedIndex == 2, + onTap: () => onTap(2), + svgFile: 'journal', + ), + ], + ), + ), + ), + ); + } +} + +class BottomButton extends StatelessWidget { + const BottomButton({ + required this.svgFile, + required this.onTap, + required this.active, + Key? key, + }) : super(key: key); + + final String svgFile; + final void Function() onTap; + final bool active; + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + Positioned.fill( + child: Container( + decoration: BoxDecoration( + border: Border( + top: BorderSide( + width: 3.0, + color: active ? primaryColor : Colors.transparent), + )), + ), + ), + ClipRRect( + borderRadius: BorderRadius.circular(50), + child: Material( + color: Colors.transparent, + child: InkWell( + onTap: onTap, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: SvgPicture.asset( + 'assets/images/svg/$svgFile.svg', + height: 30, + width: 30, + color: active ? primaryColor : placeholderColor, + ), + ), + ), + ), + ), + ], + ); + } +} diff --git a/pubspec.lock b/pubspec.lock index 6ee5602..110c6b2 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -160,6 +160,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "5.0.0+2" + flutter_svg: + dependency: "direct main" + description: + name: flutter_svg + url: "https://pub.dartlang.org" + source: hosted + version: "0.22.0" flutter_test: dependency: "direct dev" description: flutter @@ -282,6 +289,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" + path_drawing: + dependency: transitive + description: + name: path_drawing + url: "https://pub.dartlang.org" + source: hosted + version: "0.5.1" + path_parsing: + dependency: transitive + description: + name: path_parsing + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.1" path_provider: dependency: "direct main" description: @@ -338,6 +359,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.6.1" + petitparser: + dependency: transitive + description: + name: petitparser + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" platform: dependency: transitive description: @@ -623,6 +651,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.2.0" + xml: + dependency: transitive + description: + name: xml + url: "https://pub.dartlang.org" + source: hosted + version: "5.1.2" sdks: dart: ">=2.13.0 <3.0.0" flutter: ">=2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 0d18a02..2782f7d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -56,6 +56,7 @@ dependencies: charset_converter: ^2.0.0 ai_barcode: ^3.0.1 permission_handler: ^8.1.4+2 + flutter_svg: ^0.22.0 dev_dependencies: flutter_test: sdk: flutter @@ -77,6 +78,7 @@ flutter: assets: - assets/images/ - assets/images/drawer/ + - assets/images/svg/ - assets/lang/en.json - assets/lang/ru.json - assets/google_fonts/