Skip to content

Commit

Permalink
Generando Navegación en BottomNavigationBar
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahi Salgado committed Dec 7, 2018
1 parent 30dc909 commit fe03ecd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
3 changes: 2 additions & 1 deletion platzi_trips_app/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'platzi_trips.dart';

void main() => runApp(MyApp());

Expand All @@ -21,7 +22,7 @@ class MyApp extends StatelessWidget {
// is not restarted.
primarySwatch: Colors.blue,
),
home:
home: PlatziTrips()
);
}
}
Expand Down
25 changes: 24 additions & 1 deletion platzi_trips_app/lib/platzi_trips.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
import 'package:flutter/material.dart';
import 'home_trips.dart';
import 'search_trips.dart';
import 'profile_trips.dart';

class PlatziTrips extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return null;
return _PlatziTrips();
}

}

class _PlatziTrips extends State<PlatziTrips> {
int indexTap = 0;
final List<Widget> widgetsChildren = [
HomeTrips(),
SearchTrips(),
ProfileTrips()
];

void onTapTapped(int index){

setState(() {
indexTap = index;
});

}

@override
Widget build(BuildContext context) {
// TODO: implement build


return Scaffold(
body: widgetsChildren[indexTap],
bottomNavigationBar: Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.white,
primaryColor: Colors.purple
),
child: BottomNavigationBar(
onTap: onTapTapped,
currentIndex: indexTap,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
Expand Down
12 changes: 12 additions & 0 deletions platzi_trips_app/lib/profile_trips.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class ProfileTrips extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return Container(
color: Colors.indigo,
);
}

}
12 changes: 12 additions & 0 deletions platzi_trips_app/lib/search_trips.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class SearchTrips extends StatelessWidget{
@override
Widget build(BuildContext context) {
// TODO: implement build
return Container(
color: Colors.greenAccent,
);
}

}

0 comments on commit fe03ecd

Please sign in to comment.