Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ignore_for_file: prefer_const_constructors, prefer_const_literals_to_create_immutables
- import 'package:flutter/material.dart';
- import 'package:plantual_1/scenes/primary.dart';
- import 'dart:core';
- import 'package:plantual_1/scenes/myPlants.dart';
- import 'package:plantual_1/scenes/more.dart';
- class Home extends StatefulWidget {
- @override
- State<Home> createState() => _HomeState();
- }
- class _HomeState extends State<Home> {
- int _selectedIndex = 0;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: Colors.white,
- bottomNavigationBar: NavigationBar(
- selectedIndex: _selectedIndex,
- onDestinationSelected: (int index){
- setState(() {
- _selectedIndex = index;
- });
- },
- destinations: <NavigationDestination>[
- NavigationDestination(
- selectedIcon: Icon(Icons.home, color: Colors.lightGreen),
- icon: Icon(Icons.home),
- label: 'Главная'
- ),
- NavigationDestination(
- selectedIcon: Icon(Icons.energy_savings_leaf, color: Colors.lightGreen),
- icon: Icon(Icons.energy_savings_leaf),
- label: 'Мои растения'
- ),
- NavigationDestination(
- selectedIcon: Icon(Icons.more_horiz, color: Colors.lightGreen),
- icon: Icon(Icons.more_horiz),
- label: 'Больше'
- ),
- ],
- ),
- appBar: AppBar(
- flexibleSpace: Container(
- decoration: const BoxDecoration(
- gradient: LinearGradient(
- begin: Alignment.topLeft,
- end: Alignment.bottomRight,
- colors: <Color>[Colors.green, Color.fromRGBO(141, 166, 134, 100)]),
- ),
- ),
- centerTitle: true,
- title: _selectedIndex == 1 ? Text('Мои растения') : Text('Plantual'),
- actions: _selectedIndex == 0 ? [
- IconButton(
- onPressed: (){
- showSearch(
- context: context,
- delegate: CustomSearchDelegateAll()
- );
- },
- icon: Icon(Icons.search))
- ] : [],
- backgroundColor: Colors.lightGreenAccent[100],
- automaticallyImplyLeading: false,),
- body: SafeArea(
- child: IndexedStack(
- index: _selectedIndex,
- children: [
- primary(),
- myPlants(),
- settings(),
- ],
- ),
- )
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement