Skip to content

Commit 21b2d76

Browse files
committed
ui challenge home refactored
1 parent f1022e0 commit 21b2d76

File tree

1 file changed

+36
-64
lines changed

1 file changed

+36
-64
lines changed

lib/core/presentation/pages/home.dart

Lines changed: 36 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import 'package:flutter/material.dart';
77
import 'package:flutter_ui_challenges/core/presentation/pages/favorites.dart';
88
import 'package:flutter_ui_challenges/features/auth/data/model/user_repository.dart';
9-
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
109
import 'package:provider/provider.dart';
1110

1211
import 'main_menu.dart';
@@ -26,70 +25,43 @@ class _HomePageState extends State<HomePage> {
2625

2726
@override
2827
Widget build(BuildContext context) {
29-
return Scaffold(
30-
appBar: PreferredSize(
31-
preferredSize: Size.fromHeight(100),
32-
child: Container(
33-
padding: EdgeInsets.only(top: 30.0),
34-
height: 100,
35-
color: Colors.deepOrange,
36-
child: ListTile(
37-
leading: CircleAvatar(
38-
backgroundColor: Colors.white,
39-
child: Image.asset(
40-
'assets/icon/icon.png',
41-
width: 20,
28+
return Theme(
29+
data: ThemeData(
30+
primarySwatch: Colors.deepOrange,
31+
accentColor: Colors.indigo,
32+
),
33+
child: Scaffold(
34+
appBar: AppBar(
35+
title: Text("UI Challenges"),
36+
),
37+
body: Provider.of<UserRepository>(context).user != null
38+
? _pageIndex == 0 ? MainMenu() : FavoritesTab()
39+
: MainMenu(),
40+
bottomNavigationBar: Provider.of<UserRepository>(context).user == null
41+
? null
42+
: BottomNavigationBar(
43+
selectedItemColor: Theme.of(context).primaryColor,
44+
showUnselectedLabels: false,
45+
showSelectedLabels: false,
46+
backgroundColor: Colors.grey.shade300,
47+
currentIndex: _pageIndex,
48+
onTap: (index) => setState(() {
49+
_pageIndex = index;
50+
}),
51+
items: [
52+
BottomNavigationBarItem(
53+
title: Text(""),
54+
icon: Icon(Icons.home),
4255
),
43-
),
44-
title: Text("Flutter UIs",
45-
style: TextStyle(
46-
color: Colors.white,
47-
fontWeight: FontWeight.bold,
48-
fontSize: 18.0)),
49-
trailing: Row(
50-
mainAxisSize: MainAxisSize.min,
51-
children: <Widget>[
52-
IconButton(
53-
color: Colors.white,
54-
icon: Icon(FontAwesomeIcons.infoCircle),
55-
onPressed: () {
56-
Navigator.pushNamed(context, "about");
57-
},
58-
),
59-
IconButton(
60-
color: Colors.white,
61-
icon: Icon(FontAwesomeIcons.user),
62-
onPressed: () {
63-
(Provider.of<UserRepository>(context).user != null)
64-
? Navigator.pushNamed(context, "profile") : Navigator.pushNamed(context, 'auth_home');
65-
},
66-
),
67-
],
68-
),
69-
),
70-
),
71-
),
72-
body: Provider.of<UserRepository>(context).user != null ? _pageIndex == 0 ? MainMenu() : FavoritesTab() : MainMenu(),
73-
bottomNavigationBar: Provider.of<UserRepository>(context).user == null ? null : BottomNavigationBar(
74-
selectedItemColor: Theme.of(context).primaryColor,
75-
showUnselectedLabels: false,
76-
showSelectedLabels: false,
77-
backgroundColor: Colors.grey.shade300,
78-
currentIndex: _pageIndex,
79-
onTap: (index) => setState((){
80-
_pageIndex = index;
81-
}),
82-
items: [
83-
BottomNavigationBarItem(
84-
title: Text(""),
85-
icon: Icon(Icons.home),
86-
),
87-
BottomNavigationBarItem(
88-
title: Text(""),
89-
icon: Icon( _pageIndex == 1 ? Icons.favorite : Icons.favorite_border),
56+
BottomNavigationBarItem(
57+
title: Text(""),
58+
icon: Icon(_pageIndex == 1
59+
? Icons.favorite
60+
: Icons.favorite_border),
61+
),
62+
],
9063
),
91-
],
92-
),
93-
);
64+
),
65+
);
9466
}
9567
}

0 commit comments

Comments
 (0)