Skip to content

Commit

Permalink
Theme
Browse files Browse the repository at this point in the history
  • Loading branch information
aedorado committed Jul 17, 2021
1 parent 59c9185 commit b0efcb1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Social Media',
theme: ThemeData(
primarySwatch: Colors.amber,
accentColor: Colors.purpleAccent,
),
home: Home(),
);
}
Expand Down
50 changes: 41 additions & 9 deletions lib/screens/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Home extends StatefulWidget {

class _HomeState extends State<Home> {
bool auth = false;
int pageIndex = 0;
late PageController pageController;

final gsi = GoogleSignIn();

Expand All @@ -30,8 +32,9 @@ class _HomeState extends State<Home> {
@override
void initState() {
super.initState();
gsi.onCurrentUserChanged.listen((account) => handleSignIn(account));
gsi.signInSilently().then((account) => handleSignIn(account));
pageController = PageController(initialPage: this.pageIndex);
gsi.onCurrentUserChanged.listen((account) => handleSignIn(account));
}

Widget buildUnauthScreen() {
Expand All @@ -41,7 +44,7 @@ class _HomeState extends State<Home> {
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Colors.amber, Colors.purple],
colors: [Theme.of(context).primaryColor, Theme.of(context).accentColor],
),
),
alignment: Alignment.center,
Expand Down Expand Up @@ -74,13 +77,42 @@ class _HomeState extends State<Home> {

buildAuthScreen() {
return Scaffold(
body: Container(
alignment: Alignment.center,
child: ElevatedButton(
onPressed: () {
gsi.signOut();
},
child: Text('Logout')),
appBar: AppBar(
title: Text('Flutter Gram'),
),
body: PageView(
controller: pageController,
children: [
Text('Timeline'),
Text('Search'),
Text('Post'),
Text('Notifications'),
Text('Profile'),
],
physics: NeverScrollableScrollPhysics(),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: this.pageIndex,
type: BottomNavigationBarType.fixed,
selectedItemColor: Theme.of(context).primaryColor,
onTap: (index) {
setState(() {
this.pageIndex = index;
});
pageController.animateToPage(index, duration: Duration(milliseconds: 300), curve: Curves.easeIn);
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Timeline'),
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'Search'),
BottomNavigationBarItem(
icon: Icon(
Icons.photo_camera,
size: 32,
),
label: 'Upload'),
BottomNavigationBarItem(icon: Icon(Icons.notifications), label: 'Notifications'),
BottomNavigationBarItem(icon: Icon(Icons.account_circle), label: 'Profile'),
],
),
);
}
Expand Down

0 comments on commit b0efcb1

Please sign in to comment.