Skip to content

Commit

Permalink
feat: Changed Look and Feel
Browse files Browse the repository at this point in the history
  • Loading branch information
tayormi committed Mar 17, 2020
1 parent 1b6a26c commit 7c4892c
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 255 deletions.
12 changes: 12 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
PODS:
- Flutter (1.0.0)
- path_provider (0.0.1):
- Flutter
- path_provider_macos (0.0.1):
- Flutter
- shared_preferences (0.0.1):
- Flutter
- shared_preferences_macos (0.0.1):
Expand All @@ -17,6 +21,8 @@ PODS:

DEPENDENCIES:
- Flutter (from `Flutter`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- path_provider_macos (from `.symlinks/plugins/path_provider_macos/ios`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
Expand All @@ -28,6 +34,10 @@ DEPENDENCIES:
EXTERNAL SOURCES:
Flutter:
:path: Flutter
path_provider:
:path: ".symlinks/plugins/path_provider/ios"
path_provider_macos:
:path: ".symlinks/plugins/path_provider_macos/ios"
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_macos:
Expand All @@ -45,6 +55,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
path_provider: fb74bd0465e96b594bb3b5088ee4a4e7bb1f2a9d
path_provider_macos: f760a3c5b04357c380e2fddb6f9db6f3015897e0
shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
Expand Down
132 changes: 82 additions & 50 deletions lib/home.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

import 'package:covid_tracker/pages/screens/home_screen.dart';
import 'package:covid_tracker/theme/color/light_color.dart';
import 'package:covid_tracker/theme/theme.dart';
import 'package:ff_navigation_bar/ff_navigation_bar.dart';
import 'package:covid_tracker/utils/margin.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'package:line_icons/line_icons.dart';

import 'blocs/blocs.dart';
import 'pages/screens/information.dart';
Expand All @@ -18,43 +20,19 @@ class Home extends StatefulWidget {
}

class _HomeState extends State<Home> {

int selectedIndex = 0;


void addPostFrameCallback(FrameCallback callback) {
// Load data on widget load
BlocProvider.of<CaseBloc>(context).add(FetchCase());
}

List<FFNavigationBarItem> buildBottomNavBarItems() {
return [
FFNavigationBarItem(
iconData: Icons.home,
label: 'Home',
),
FFNavigationBarItem(
iconData: Icons.speaker_notes,
label: 'News',
),
FFNavigationBarItem(
iconData: Icons.note,
label: 'Guides',
),
FFNavigationBarItem(
iconData: Icons.settings,
label: 'Settings',
),
];
}

PageController pageController = PageController(
initialPage: 0,
keepPage: true,
);

Widget buildPageView() {

return PageView(
controller: pageController,
onPageChanged: (index) {
Expand Down Expand Up @@ -86,31 +64,85 @@ class _HomeState extends State<Home> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: LightColor.background,
appBar: AppBar(
centerTitle: false,
elevation: 0,
backgroundColor: LightColor.background,
title: Text('Covid-19 Tracker',
style: AppTheme.h1Style.copyWith(color: LightColor.darkgrey))),
body: buildPageView(),
bottomNavigationBar: FFNavigationBar(
theme: FFNavigationBarTheme(
barBackgroundColor: Colors.white,
selectedItemBorderColor: Color(0xFFfee9e8),
selectedItemBackgroundColor: Color(0xFF62bd80),
selectedItemIconColor: Colors.white,
selectedItemLabelColor: Colors.black,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: Column(
children: <Widget>[
const YMargin(60),
Text(
'Covid-19',
style: GoogleFonts.cabin(
textStyle:
TextStyle(fontSize: 21, color: Color(0xff989CAC)),
),
),
const YMargin(4),
Text(
'Tracker',
style: GoogleFonts.cabin(
textStyle: TextStyle(
fontSize: 27,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
],
),
),
const YMargin(10),
Expanded(child: buildPageView()),
],
),
bottomNavigationBar: Container(
decoration: BoxDecoration(color: Colors.white, boxShadow: [
BoxShadow(blurRadius: 20, color: Colors.black.withOpacity(.1))
]),
child: SafeArea(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0)
.add(EdgeInsets.only(top: 20)),
child: GNav(
gap: 10,
activeColor: Colors.white,
color: Colors.grey[400],
iconSize: 24,
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 5),
duration: Duration(milliseconds: 800),
tabBackgroundColor: Colors.grey[800],
tabs: [
GButton(
icon: LineIcons.home,
text: 'Home',
backgroundColor: CardColors.red,
),
GButton(
icon: LineIcons.newspaper_o,
text: 'News',
backgroundColor: CardColors.cyan,
),
GButton(
icon: LineIcons.list_ul,
text: 'Guides',
backgroundColor: CardColors.blue,
),
GButton(
icon: LineIcons.cog,
text: 'Settings',
backgroundColor: CardColors.green,
),
],
selectedIndex: selectedIndex,
onTabChange: (index) {
setState(() {
pageController.jumpToPage(index);
});
}),
),
),
selectedIndex: selectedIndex,
onSelectTab: (index) {
// if (index == 0) {
// BlocProvider.of<CaseBloc>(context).add(FetchCase());
// }
bottomTapped(index);
},
items: buildBottomNavBarItems(),
),
);
}
}
}
77 changes: 32 additions & 45 deletions lib/pages/screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import 'dart:async';

import 'package:covid_tracker/blocs/blocs.dart';
import 'package:covid_tracker/pages/widgets/global_card.dart';
import 'package:covid_tracker/theme/color/light_color.dart';
import 'package:covid_tracker/utils/calculateGrowth.dart';
import 'package:covid_tracker/utils/margin.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:responsive_screen/responsive_screen.dart';
import 'package:shimmer/shimmer.dart';

class HomeScreen extends StatefulWidget {
@override
Expand All @@ -27,27 +30,21 @@ class _HomeScreenState extends State<HomeScreen> {
final Function wp = Screen(context).wp;
final Function hp = Screen(context).hp;
return SingleChildScrollView(
padding: EdgeInsets.only(left: 20, right: 20, top: 20),
padding: EdgeInsets.only(top: 20),
child: BlocBuilder<CaseBloc, CaseState>(
builder: (BuildContext context, CaseState state) {
print(state);
if (state is CaseLoading) {
return SizedBox(
width: wp(100),
height: hp(20),
child: Shimmer.fromColors(
baseColor: Colors.grey.withOpacity(0.3),
highlightColor: Colors.white38,
child: GlobalSituationCard(
cardTitle: 'loading',
caseTitle: 'loading',
currentData: 2344,
newData: null,
percentChange: calculateGrowthPercentage(234, 5678),
icon: showGrowthIcon(234, 5678),
color: showGrowthColor(234, 5678),
),
),
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
YMargin(hp(29)),
Center(
child: SpinKitSquareCircle(
color: CardColors.green,
size: 50.0,
)),
],
);
}
if (state is CaseLoaded) {
Expand All @@ -57,7 +54,7 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column(
children: <Widget>[
GlobalSituationCard(
cardTitle: 'TOTAL CASES',
cardTitle: 'Total CASES',
caseTitle: 'Total',
currentData: currentData.totalCases,
newData: currentData.totalNewCasesToday,
Expand All @@ -68,22 +65,25 @@ class _HomeScreenState extends State<HomeScreen> {
currentData.totalNewCasesToday),
color: Colors.red,
),
SizedBox(height: hp(3)),

GlobalSituationCard(
cardTitle: 'RECOVERED CASES',
cardTitle: 'Recovered CASES',
caseTitle: 'Recovered',
currentData: currentData.totalRecovered,
newData:
currentData.totalRecovered - firstData.totalRecovered,
percentChange: calculateGrowthPercentage(
currentData.totalRecovered, currentData.totalRecovered - firstData.totalRecovered),
icon: Icon(Icons.arrow_upward, color: Colors.green,),
currentData.totalRecovered,
currentData.totalRecovered -
firstData.totalRecovered),
cardColor: CardColors.blue,
icon: Icon(
Icons.arrow_upward,
color: Colors.green,
),
color: Colors.green,
),
SizedBox(height: hp(3)),
GlobalSituationCard(
cardTitle: 'DEATH CASES',
cardTitle: 'Death CASES',
caseTitle: 'Deaths',
currentData: currentData.totalDeaths,
newData: currentData.totalNewDeathsToday,
Expand All @@ -93,10 +93,11 @@ class _HomeScreenState extends State<HomeScreen> {
icon: showGrowthIcon(currentData.totalDeaths,
currentData.totalNewDeathsToday),
color: Colors.red,
cardColor: CardColors.red,
),
SizedBox(height: hp(3)),
GlobalSituationCard(
cardTitle: 'SERIOUS CASES',
cardTitle: 'Serious CASES',
caseTitle: 'Serious',
currentData: currentData.totalSeriousCases,
newData: currentData.totalSeriousCases -
Expand All @@ -108,23 +109,8 @@ class _HomeScreenState extends State<HomeScreen> {
icon: showGrowthIcon(currentData.totalSeriousCases,
firstData.totalSeriousCases),
color: Colors.red,
cardColor: CardColors.cyan,
),
// GlobalSituationCard(
// cardTitle: 'DEATH CASES',
// caseTitle: 'Deaths',
// currentData: currentData.deathCases,
// newData: 1457, percentChange: calculateGrowthPercentage(currentData.deathCases, firstData.deathCases),
// icon: showGrowthIcon(currentData.deathCases, firstData.deathCases), color: showGrowthColor(currentData.deathCases, firstData.deathCases),
// ),
// SizedBox(height: hp(3)),
// GlobalSituationCard(
// cardTitle: 'RECOVERED CASES',
// caseTitle: 'Recovered',
// currentData: currentData.recoveredCases,
// newData: 1457, percentChange: calculateGrowthPercentage(currentData.recoveredCases, firstData.recoveredCases),
// icon: showGrowthIcon(currentData.recoveredCases, firstData.recoveredCases),
// color: showGrowthColor(currentData.recoveredCases, firstData.recoveredCases),
// ),
SizedBox(height: hp(3)),
],
),
Expand All @@ -137,7 +123,8 @@ class _HomeScreenState extends State<HomeScreen> {
if (state is CaseError) {
return Text(
'Something went wrong!',
style: TextStyle(color: Colors.red),
style:
GoogleFonts.cabin(textStyle: TextStyle(color: Colors.red)),
);
}
return Center(
Expand All @@ -156,4 +143,4 @@ class _HomeScreenState extends State<HomeScreen> {
// }
));
}
}
}
Loading

0 comments on commit 7c4892c

Please sign in to comment.