Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:seller_app/prodonsale.dart';
  3. import 'package:seller_app/product.dart';
  4. import 'package:seller_app/video.dart';
  5. import 'package:seller_app/class.dart';
  6. import 'package:seller_app/about.dart';
  7.  
  8.  
  9. class navigationbar extends StatefulWidget {
  10. @override
  11. _navigationbarState createState() => _navigationbarState();
  12. }
  13.  
  14. class _navigationbarState extends State<navigationbar> {
  15. final List<Widget> pages = [
  16. Prodonsale(
  17. key: PageStorageKey('Page1'),
  18. ),
  19. Product(
  20. key: PageStorageKey('Page2'),
  21. ),
  22. Video(
  23. key: PageStorageKey('Page3'),
  24. ),
  25.  
  26. ];
  27. final PageStorageBucket bucket = PageStorageBucket();
  28.  
  29. int _selectedIndex = 0;
  30.  
  31. Widget _bottomNavigationBar(int selectedIndex) => BottomNavigationBar(
  32. onTap: (int index) => setState(() => _selectedIndex = index),
  33. currentIndex: selectedIndex,
  34. items: const <BottomNavigationBarItem>[
  35. BottomNavigationBarItem(
  36. icon: Icon(Icons.account_box), title: Text('My Products')),
  37. BottomNavigationBarItem(
  38. icon: Icon(Icons.store), title: Text('Sell Craft')),
  39. BottomNavigationBarItem(
  40. icon: Icon(Icons.video_library), title: Text('Sell Tutorials')),
  41. ],
  42. );
  43.  
  44. void choiceAction(String choice){
  45. if(choice == Constants.About){
  46. Navigator.push(context, MaterialPageRoute(
  47. builder: (BuildContext context) => About()
  48. ));
  49. }
  50. else if(choice == Constants.SignOut){
  51. Navigator.pop(context);
  52. }
  53. }
  54. @override
  55. Widget build(BuildContext context) {
  56. return Scaffold(
  57. appBar: new AppBar(
  58. leading: new Container(),
  59. title: new Text("Craft House"),
  60. backgroundColor: Colors.red,
  61. actions: <Widget>[
  62. PopupMenuButton<String>(
  63. onSelected: choiceAction,
  64. itemBuilder: (BuildContext context){
  65. return Constants.choices.map((String choice){
  66. return PopupMenuItem<String>(
  67. value: choice,
  68. child: Text(choice),
  69. );
  70. }).toList();
  71. },
  72. )
  73. ],
  74. ),
  75. bottomNavigationBar: _bottomNavigationBar(_selectedIndex),
  76. body: PageStorage(
  77. child: pages[_selectedIndex],
  78. bucket: bucket,
  79. ),
  80. );
  81.  
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement