Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:io';
- import 'package:PhotoReport/blocs/obra_bloc.dart';
- import 'package:PhotoReport/widgets/CustomShowDialog.dart';
- import 'package:PhotoReport/widgets/Drawer.dart';
- import 'package:flutter/material.dart';
- import 'buildings_page.dart';
- import 'configuracoes_page.dart';
- import 'politicas_privacidade.dart';
- import 'termos_uso.dart';
- class HomePage extends StatefulWidget {
- final String origem;
- HomePage(this.origem);
- @override
- _HomePageState createState() => _HomePageState();
- }
- class _HomePageState extends State<HomePage> {
- PageController _pageCtrl = PageController();
- ObrasBloc _bloc = ObrasBloc();
- String title = "Obras";
- final _scaffoldKey = GlobalKey<ScaffoldState>();
- @override
- void initState() {
- super.initState();
- }
- void onChangedIndex(int index) {
- switch (index) {
- case 0:
- setState(() {
- title = "Obras";
- });
- break;
- case 1:
- setState(() {
- title = "Configurações";
- });
- break;
- case 2:
- setState(() {
- title = "Políticas de Privacidade";
- });
- break;
- case 3:
- setState(() {
- title = "Termos de Uso";
- });
- break;
- default:
- }
- }
- @override
- Widget build(BuildContext context) {
- return WillPopScope(
- child: PageView(
- controller: _pageCtrl,
- onPageChanged: onChangedIndex,
- physics: NeverScrollableScrollPhysics(),
- children: <Widget>[
- Scaffold(
- appBar: AppBar(
- title: Text(title),
- ),
- drawer: DrawerPage(
- pageCtrl: _pageCtrl,
- ),
- body: BuildingsPage(
- _pageCtrl,
- widget.origem,
- lista: _bloc.listaObras,
- ),
- ),
- Scaffold(
- appBar: AppBar(
- title: Text(title),
- ),
- drawer: DrawerPage(
- pageCtrl: _pageCtrl,
- ),
- body: ConfiguracoesPage(_pageCtrl)),
- Scaffold(
- appBar: AppBar(
- title: Text(title),
- ),
- drawer: DrawerPage(
- pageCtrl: _pageCtrl,
- ),
- body: PolicitasPrivacidadePage(_pageCtrl)),
- Scaffold(
- appBar: AppBar(
- title: Text(title),
- ),
- drawer: DrawerPage(
- pageCtrl: _pageCtrl,
- ),
- body: TermosUsoPage(_pageCtrl))
- ],
- ),
- onWillPop: () {
- if (_pageCtrl.page != 0)
- _pageCtrl.jumpToPage(0);
- else {
- showDialog(
- context: context,
- barrierDismissible: false,
- builder: (BuildContext context) {
- return WillPopScope(
- onWillPop: () => Future(() => false),
- child: CustomAlertDialog(
- title: Text("Atenção!"),
- content:
- Text("Tem certeza que deseja fechar o aplicativo?"),
- actions: <Widget>[
- FlatButton(
- child: Text("Sim"),
- onPressed: () {
- exit(0);
- },
- ),
- FlatButton(
- child: Text("Não"),
- onPressed: () {
- Navigator.of(context).pop();
- },
- ),
- ],
- ),
- );
- });
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement