Skip to content
Snippets Groups Projects
home.dart 5.14 KiB
Newer Older
poka's avatar
poka committed
import 'package:gecko/globals.dart';
import 'package:gecko/models/history.dart';
poka's avatar
poka committed
import 'package:gecko/models/home.dart';
import 'dart:ui';
import 'package:gecko/screens/settings.dart';
poka's avatar
poka committed
import 'package:provider/provider.dart';
poka's avatar
poka committed
class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
poka's avatar
poka committed
    HomeProvider _homeProvider = Provider.of<HomeProvider>(context);
    HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
      drawer: Drawer(
        child: Column(
          children: <Widget>[
            Expanded(
                child: ListView(padding: EdgeInsets.zero, children: <Widget>[
              DrawerHeader(
                child: Column(children: <Widget>[
                  SizedBox(height: 0),
                  Image(
                      image: AssetImage('assets/icon/gecko_final.png'),
                      height: 130),
                ]),
                decoration: BoxDecoration(
                  color: Color(0xffD28928),
                ),
              ),
              ListTile(
                title: Text('Paramètres'),
                onTap: () {
                  Navigator.pop(context);
                  Navigator.push(
                    context,
                    MaterialPageRoute(builder: (context) {
                      return SettingsScreen();
                    }),
                  );
                },
              ),
              ListTile(
                title: Text('A propos'),
                onTap: () {
                  // Update the state of the app.
                  // ...
                },
              ),
            ])),
            Container(
                child: Align(
                    alignment: FractionalOffset.bottomCenter,
poka's avatar
poka committed
                    child: Text('Ğecko v$appVersion'))),
            SizedBox(height: 20)
          ],
        ),
      ),
      appBar: AppBar(
        leading: Builder(
            builder: (context) => IconButton(
                  icon: new Icon(Icons.menu, color: Colors.grey[850]),
                  onPressed: () => Scaffold.of(context).openDrawer(),
                )),
poka's avatar
poka committed
        title: _homeProvider.appBarTitle,
poka's avatar
poka committed
              padding: EdgeInsets.symmetric(horizontal: 16),
              child: IconButton(
                  icon: _homeProvider.searchIcon,
                  color: Colors.grey[850],
                  onPressed: () {
                    // Navigator.push(
                    //   context,
                    //   MaterialPageRoute(builder: (context) {
                    //     return SearchList();
                    //   }),
                    // );

poka's avatar
poka committed
                    if (_homeProvider.searchIcon.icon == Icons.search) {
                      _homeProvider.searchIcon = Icon(
                        Icons.close,
                        color: Colors.grey[850],
                      );
                      _homeProvider.appBarTitle = TextField(
                        autofocus: true,
poka's avatar
poka committed
                        controller: _homeProvider.searchQuery,
                        onChanged: (text) {
                          print("Clé tappé: $text");
                          final String searchResult =
                              _historyProvider.isPubkey(context, text);
                          if (searchResult != '') {
                            _homeProvider.currentIndex = 0;
                          }
                        },
                        style: TextStyle(
                          color: Colors.grey[850],
poka's avatar
poka committed
                        ),
                        decoration: InputDecoration(
poka's avatar
poka committed
                            prefixIcon:
                                Icon(Icons.search, color: Colors.grey[850]),
                            hintText: "Rechercher ...",
                            hintStyle: TextStyle(color: Colors.grey[850])),
poka's avatar
poka committed
                      );
                      _homeProvider.handleSearchStart();
                    } else {
                      _homeProvider.handleSearchEnd();
                    }
                  }))
      body: _homeProvider.currentTab[_homeProvider.currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Color(0xffFFD58D),
        fixedColor: Colors.grey[850],
        unselectedItemColor: Color(0xffBD935C),
        type: BottomNavigationBarType.fixed,
poka's avatar
poka committed
        onTap: (index) {
          _homeProvider.currentIndex = index;
        },
        currentIndex: _homeProvider.currentIndex,
        items: [
          BottomNavigationBarItem(
            icon: Padding(
                padding: EdgeInsets.symmetric(horizontal: 86),
                child: Image.asset('assets/blockchain.png')),
            activeIcon: Padding(
                padding: EdgeInsets.symmetric(horizontal: 86),
                child: Image.asset('assets/blockchain.png')),
            label: 'Explorateur',
          BottomNavigationBarItem(
            label: 'Mes portefeuilles',