adding pageview for navigation
parent
1088e168c2
commit
8f3cfdeae3
|
@ -5,7 +5,7 @@ import 'themer.dart';
|
|||
|
||||
class Routes {
|
||||
final routes = <String, WidgetBuilder>{
|
||||
'/home': (BuildContext context) => Home()
|
||||
'/home': (BuildContext context) => Container(child: Home()),
|
||||
};
|
||||
|
||||
final theme = buildTheme();
|
||||
|
@ -15,7 +15,7 @@ class Routes {
|
|||
title: "Beep",
|
||||
theme: theme,
|
||||
routes: routes,
|
||||
home: Home(),
|
||||
home: Container(child: Home()),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,15 +4,47 @@ import "package:frontend_flutter/widgets/top_bar/index.dart";
|
|||
import "package:frontend_flutter/widgets/conversation_list/index.dart";
|
||||
import "package:frontend_flutter/widgets/bottom_bar/index.dart";
|
||||
|
||||
class Home extends StatelessWidget {
|
||||
class Home extends StatefulWidget {
|
||||
@override
|
||||
_HomeState createState() => _HomeState();
|
||||
}
|
||||
|
||||
class _HomeState extends State<Home> {
|
||||
final List<String> titleList = ["Conversations", "Contacts", "Settings"];
|
||||
final PageController controller = PageController();
|
||||
|
||||
int _pageNumber = 0;
|
||||
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
controller.addListener(_updatePageNumber);
|
||||
}
|
||||
|
||||
@override
|
||||
dispose() {
|
||||
controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
_updatePageNumber() {
|
||||
setState(() {
|
||||
_pageNumber = controller.page.round();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Column(children: <Widget>[
|
||||
TopBar("Conversations"),
|
||||
TopBar(title: titleList[_pageNumber], pageNumber: _pageNumber),
|
||||
Expanded(
|
||||
child: ConversationList(
|
||||
items: List<String>.generate(100, (i) => "Item $i"))),
|
||||
child: PageView(controller: controller, children: <Widget>[
|
||||
ConversationList(
|
||||
items: List<String>.generate(100, (i) => "Item $i")),
|
||||
ConversationList(
|
||||
items: List<String>.generate(100, (i) => "Item $i"))
|
||||
]))
|
||||
]),
|
||||
bottomSheet: BottomBar());
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export "contact_item.dart";
|
|
@ -0,0 +1 @@
|
|||
export "contact_list.dart";
|
|
@ -2,10 +2,11 @@ import "package:flutter/material.dart";
|
|||
|
||||
class TopBar extends StatelessWidget {
|
||||
final String title;
|
||||
final int pageNumber;
|
||||
final double barHeight = 100.0;
|
||||
final String logo = "assets/logo.png";
|
||||
|
||||
TopBar(title) : title = title;
|
||||
TopBar({@required this.title, @required this.pageNumber});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -34,16 +35,8 @@ class TopBar extends StatelessWidget {
|
|||
width: 24.0,
|
||||
height: 24.0)),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {
|
||||
print("Pressed");
|
||||
}),
|
||||
IconButton(
|
||||
icon: Icon(Icons.dehaze),
|
||||
onPressed: () {
|
||||
print("Pressed");
|
||||
})
|
||||
IconButton(icon: Icon(Icons.search), onPressed: () {}),
|
||||
IconButton(icon: Icon(Icons.dehaze), onPressed: () {})
|
||||
],
|
||||
),
|
||||
Positioned(
|
||||
|
@ -55,7 +48,7 @@ class TopBar extends StatelessWidget {
|
|||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Opacity(
|
||||
opacity: 1.0,
|
||||
opacity: (pageNumber == 0) ? 1.0 : 0.6,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 5.0),
|
||||
child: Container(
|
||||
|
@ -65,7 +58,7 @@ class TopBar extends StatelessWidget {
|
|||
color: Colors.white,
|
||||
shape: BoxShape.circle)))),
|
||||
Opacity(
|
||||
opacity: 0.6,
|
||||
opacity: (pageNumber == 1) ? 1.0 : 0.6,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 5.0),
|
||||
child: Container(
|
||||
|
@ -75,7 +68,7 @@ class TopBar extends StatelessWidget {
|
|||
color: Colors.white,
|
||||
shape: BoxShape.circle)))),
|
||||
Opacity(
|
||||
opacity: 0.6,
|
||||
opacity: (pageNumber == 2) ? 1.0 : 0.6,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 5.0),
|
||||
child: Container(
|
||||
|
|
Loading…
Reference in New Issue