Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:coocafe_tecnico_app/pages/home_page.dart';
- import 'package:coocafe_tecnico_app/pages/lista-produtor-page.dart';
- import 'package:coocafe_tecnico_app/pages/login_page.dart';
- import 'package:coocafe_tecnico_app/pages/notificacoes-page.dart';
- import 'package:coocafe_tecnico_app/services/sync.service.dart';
- import 'package:coocafe_tecnico_app/widgets/drawer_tile.dart';
- import 'package:flutter/material.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'package:date_format/date_format.dart';
- class DrawerPage extends StatelessWidget {
- final PageController pageCtrl;
- SyncService sync = SyncService();
- DrawerPage({this.pageCtrl});
- @override
- Widget build(BuildContext context) {
- return Drawer(
- child: new ListView(
- children: <Widget> [
- Container(
- height: 80.0,
- child: DrawerHeader(
- child: new Text('Menu', style: TextStyle(fontSize: 20.0, color: Colors.white, fontWeight: FontWeight.bold),),
- decoration: BoxDecoration(color: Colors.blueGrey),
- ),
- ),
- DrawerTile(Icons.home, "Início", pageCtrl, 0),
- DrawerTile(Icons.people, "Produtores", pageCtrl, 1),
- DrawerTile(Icons.notifications, "Notificações", pageCtrl, 2),
- ListTile(
- leading: Icon(Icons.refresh, color: Colors.white,),
- title: Text("Sincronizar", style: TextStyle(color: Colors.white),),
- onTap: (){
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return AlertDialog(
- title: Text("Sincronizar Dados"),
- content: Text("Deseja sincronizar os dados com o servidor?"),
- actions: <Widget>[
- FlatButton(
- child: Text("Não"),
- onPressed: () {
- Navigator.of(context).pop();
- Navigator.of(context).pop();
- },
- ),
- FlatButton(
- child: Text("Sim"),
- onPressed: () async {
- Navigator.of(context).pop();
- Navigator.of(context).pop();
- SharedPreferences prefs = await SharedPreferences.getInstance();
- sync.getListaSafra(context);
- sync.getListaCultura(context);
- sync.getListaFilial(context);
- sync.getListaTipoTitulo(context);
- sync.getListaNotificacoesTecnico(context);
- sync.getListaProdutor(context);
- String _dataRefresh = "Atualizado em " + formatDate(
- DateTime.now(), [dd, '/', mm, '/', yyyy]) + " às " +
- formatDate(DateTime.now(), [HH, ':', nn, ':', ss]);
- prefs.setString("TextoAtualizacao", _dataRefresh);
- },
- )
- ],
- );
- }
- );
- },
- ),
- ListTile(
- leading: Icon(Icons.exit_to_app, color: Colors.white,),
- title: Text("Sair", style: TextStyle(color: Colors.white),),
- onTap: () async {
- SharedPreferences prefs = await SharedPreferences.getInstance();
- await prefs.setString('user', '');
- await prefs.setString('pass', '');
- await prefs.setString('key', '');
- await prefs.setString('TextoAtualizacao', '');
- Navigator.pushReplacementNamed(context, LoginPage.tag);
- },
- ),
- ],
- )
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement