-
-
Save edward1986/19aa0e2e9a9acb51a5879648796b47d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:bubble_tab_indicator/bubble_tab_indicator.dart'; | |
import 'package:flutter/material.dart'; | |
import '../charts_widgets/simple_bar_chart.dart'; | |
import '../weather_details_header.dart'; | |
Widget getBarChart(double statusBarHeight) { | |
return new Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new AspectRatio( | |
aspectRatio: 100 / 70, | |
child: WeatherDetailsHeader(statusBarHeight), | |
), | |
new Expanded(child: TabBarControllerHome()), | |
], | |
); | |
} | |
TabBarControllerHome() { | |
return new DefaultTabController( | |
length: 4, | |
child: Scaffold( | |
appBar: new PreferredSize( | |
preferredSize: Size.fromHeight(kToolbarHeight), | |
child: new TabBar( | |
tabs: [ | |
Tab( | |
text: "Day", | |
), | |
Tab( | |
text: "Week", | |
), | |
Tab( | |
text: "Month", | |
), | |
Tab( | |
text: "Year", | |
), | |
], | |
labelColor: Colors.white, | |
unselectedLabelColor: Colors.blue, | |
indicatorSize: TabBarIndicatorSize.tab, | |
indicator: BubbleTabIndicator( | |
indicatorColor: Colors.blue, | |
indicatorHeight: 25.0, | |
tabBarIndicatorSize: TabBarIndicatorSize.tab), | |
), | |
), | |
body: new TabBarView(children: [ | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleBarChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleBarChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleBarChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleBarChart.withRandomData(), | |
), | |
), | |
]), | |
)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class ColoredContainer extends StatelessWidget { | |
Color _color; | |
ColoredContainer(this._color); | |
@override | |
Widget build(BuildContext context) { | |
return Container( | |
color: _color, | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String | |
ANIMATED_SPLASH = '/SplashScreen', | |
HOME = '/Home'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:charts_common/common.dart'; | |
import 'package:flutter/material.dart'; | |
import 'charts_screen/line_chart.dart'; | |
import 'charts_screen/bar_chart.dart'; | |
import 'charts_screen/pie_chart.dart'; | |
import 'package:bubble_tab_indicator/bubble_tab_indicator.dart'; | |
import 'charts_widgets/simple_line_chart.dart'; | |
import 'colored_container.dart'; | |
class Home extends StatefulWidget { | |
@override | |
_HomeState createState() => _HomeState(); | |
} | |
class _HomeState extends State<Home> { | |
int _currentIndex = 0; | |
@override | |
Widget build(BuildContext context) { | |
final double statusBarHeight = 24.00; | |
List<Widget> _children = [ | |
getLineChart(statusBarHeight), | |
getBarChart(statusBarHeight), | |
getPieChart(statusBarHeight) | |
]; | |
return new MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: "Flutter Dev Chart Demo", | |
theme: new ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: new Scaffold( | |
// appBar: new AppBar(title: new Text("Chart Demo with Timer")), | |
body: _children[_currentIndex], | |
bottomNavigationBar: new BottomNavigationBar( | |
onTap: _onTapTab, | |
currentIndex: _currentIndex, | |
items: [ | |
BottomNavigationBarItem( | |
icon: new Image.asset( | |
"assets/images/line.png", | |
height: 32.0, | |
width: 32.0, | |
), | |
title: new Text("Line Chart"), | |
), | |
BottomNavigationBarItem( | |
icon: new Image.asset( | |
"assets/images/bar.png", | |
height: 32.0, | |
width: 32.0, | |
), | |
title: new Text("Bar Chart")), | |
BottomNavigationBarItem( | |
icon: new Image.asset( | |
"assets/images/pie.png", | |
height: 32.0, | |
width: 32.0, | |
), | |
title: new Text("Pie Chart")), | |
]), | |
), | |
); | |
} | |
void _onTapTab(int value) { | |
setState(() { | |
print(value); | |
_currentIndex = value; | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:bubble_tab_indicator/bubble_tab_indicator.dart'; | |
import 'package:flutter/material.dart'; | |
import '../charts_widgets/simple_line_chart.dart'; | |
import '../weather_details_header.dart'; | |
Widget getLineChart(double statusBarHeight) { | |
return new Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new AspectRatio( | |
aspectRatio: 100 / 70, | |
child: WeatherDetailsHeader(statusBarHeight), | |
), | |
new Expanded(child: TabBarControllerHome()), | |
], | |
); | |
} | |
TabBarControllerHome() { | |
return new DefaultTabController( | |
length: 4, | |
child: Scaffold( | |
appBar: new PreferredSize( | |
preferredSize: Size.fromHeight(kToolbarHeight), | |
child: new TabBar( | |
tabs: [ | |
Tab( | |
text: "Day", | |
), | |
Tab( | |
text: "Week", | |
), | |
Tab( | |
text: "Month", | |
), | |
Tab( | |
text: "Year", | |
), | |
], | |
labelColor: Colors.white, | |
unselectedLabelColor: Colors.blue, | |
indicatorSize: TabBarIndicatorSize.tab, | |
indicator: BubbleTabIndicator( | |
indicatorColor: Colors.blue, | |
indicatorHeight: 25.0, | |
tabBarIndicatorSize: TabBarIndicatorSize.tab), | |
), | |
), | |
body: new TabBarView(children: [ | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleLineChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleLineChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleLineChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimpleLineChart.withRandomData(), | |
), | |
), | |
]), | |
)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'home_widget.dart'; | |
import 'colored_container.dart'; | |
import 'Constant/Constant.dart'; | |
import 'Screens/SplashScreen.dart'; | |
main() { | |
runApp(new MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: new ThemeData( | |
accentColor: Colors.black, | |
primaryColor: Colors.black, | |
primaryColorDark: Colors.black | |
), | |
home: new SplashScreen(), | |
routes: <String, WidgetBuilder>{ | |
HOME: (BuildContext context) => new Home(), | |
}, | |
)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:bubble_tab_indicator/bubble_tab_indicator.dart'; | |
import 'package:flutter/material.dart'; | |
import '../charts_widgets/simple_pie_chart.dart'; | |
import '../weather_details_header.dart'; | |
Widget getPieChart(double statusBarHeight) { | |
return new Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new AspectRatio( | |
aspectRatio: 100 / 70, | |
child: WeatherDetailsHeader(statusBarHeight), | |
), | |
new Expanded(child: TabBarControllerHome()), | |
], | |
); | |
} | |
TabBarControllerHome() { | |
return new DefaultTabController( | |
length: 4, | |
child: Scaffold( | |
appBar: new PreferredSize( | |
preferredSize: Size.fromHeight(kToolbarHeight), | |
child: new TabBar( | |
tabs: [ | |
Tab( | |
text: "Day", | |
), | |
Tab( | |
text: "Week", | |
), | |
Tab( | |
text: "Month", | |
), | |
Tab( | |
text: "Year", | |
) | |
], | |
labelColor: Colors.white, | |
unselectedLabelColor: Colors.blue, | |
indicatorSize: TabBarIndicatorSize.tab, | |
indicator: BubbleTabIndicator( | |
indicatorColor: Colors.blue, | |
indicatorHeight: 25.0, | |
tabBarIndicatorSize: TabBarIndicatorSize.tab), | |
), | |
), | |
body: new TabBarView(children: [ | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimplePieChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimplePieChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimplePieChart.withRandomData(), | |
), | |
), | |
new Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: new SizedBox( | |
height: 250.0, | |
child: new SimplePieChart.withRandomData(), | |
), | |
), | |
]), | |
)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:ui'; | |
class $Colors { | |
static const Color empress = const Color(0xFF756C6F); | |
static const Color ghostWhite = const Color(0xFFF6F6F7); | |
static const Color quartz = const Color(0xFFE1E0E8); | |
static const Color blueHaze = const Color(0xFFB3B2C2); | |
static const Color lavender = const Color(0xFFCBCAD6); | |
static const Color blueParis = const Color(0xDD595877); | |
static const Color textColorWheatherHeader = const Color(0xFFFFFFFF); | |
} | |
class $Asset { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'package:charts_flutter/flutter.dart' as charts; | |
import 'package:flutter/material.dart'; | |
class SimpleBarChart extends StatelessWidget { | |
final List<charts.Series> seriesList; | |
final bool animate; | |
SimpleBarChart(this.seriesList, {this.animate}); | |
factory SimpleBarChart.withSampleData() { | |
return new SimpleBarChart( | |
_createSampleData(), | |
animate: false, | |
); | |
} | |
factory SimpleBarChart.withRandomData() { | |
return new SimpleBarChart(_createRandomData()); | |
} | |
static List<charts.Series<OrdinalSales, String>> _createRandomData() { | |
final random = new Random(); | |
final data = [ | |
new OrdinalSales('2014', random.nextInt(100)), | |
new OrdinalSales('2015', random.nextInt(100)), | |
new OrdinalSales('2016', random.nextInt(100)), | |
new OrdinalSales('2017', random.nextInt(100)), | |
]; | |
return [ | |
new charts.Series<OrdinalSales, String>( | |
id: 'Sales', | |
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, | |
domainFn: (OrdinalSales sales, _) => sales.year, | |
measureFn: (OrdinalSales sales, _) => sales.sales, | |
data: data, | |
) | |
]; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new charts.BarChart( | |
seriesList, | |
animate: animate, | |
); | |
} | |
static List<charts.Series<OrdinalSales, String>> _createSampleData() { | |
final data = [ | |
new OrdinalSales('2014', 5), | |
new OrdinalSales('2015', 25), | |
new OrdinalSales('2016', 100), | |
new OrdinalSales('2017', 75), | |
]; | |
return [ | |
new charts.Series<OrdinalSales, String>( | |
id: 'Sales', | |
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, | |
domainFn: (OrdinalSales sales, _) => sales.year, | |
measureFn: (OrdinalSales sales, _) => sales.sales, | |
data: data, | |
) | |
]; | |
} | |
} | |
class OrdinalSales { | |
final String year; | |
final int sales; | |
OrdinalSales(this.year, this.sales); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'package:charts_flutter/flutter.dart' as charts; | |
import 'package:flutter/material.dart'; | |
class SimpleLineChart extends StatelessWidget { | |
final List<charts.Series> seriesList; | |
final bool animate; | |
SimpleLineChart(this.seriesList, {this.animate}); | |
factory SimpleLineChart.withSampleData() { | |
return new SimpleLineChart( | |
_createSampleData(), | |
animate: true, | |
); | |
} | |
factory SimpleLineChart.withRandomData() { | |
return new SimpleLineChart(_createRandomData()); | |
} | |
static List<charts.Series<LinearSales, num>> _createRandomData() { | |
final random = new Random(); | |
final data = [ | |
new LinearSales(0, random.nextInt(100)), | |
new LinearSales(1, random.nextInt(100)), | |
new LinearSales(2, random.nextInt(100)), | |
new LinearSales(3, random.nextInt(100)), | |
]; | |
return [ | |
new charts.Series<LinearSales, int>( | |
id: 'Sales', | |
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, | |
domainFn: (LinearSales sales, _) => sales.year, | |
measureFn: (LinearSales sales, _) => sales.sales, | |
data: data, | |
displayName: "Line Chart", | |
) | |
]; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new charts.LineChart(seriesList, animate: animate); | |
} | |
static List<charts.Series<LinearSales, int>> _createSampleData() { | |
final data = [ | |
new LinearSales(0, 5), | |
new LinearSales(1, 25), | |
new LinearSales(2, 100), | |
new LinearSales(3, 75), | |
]; | |
return [ | |
new charts.Series<LinearSales, int>( | |
id: 'Sales', | |
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, | |
domainFn: (LinearSales sales, _) => sales.year, | |
measureFn: (LinearSales sales, _) => sales.sales, | |
data: data, | |
) | |
]; | |
} | |
} | |
class LinearSales { | |
final int year; | |
final int sales; | |
LinearSales(this.year, this.sales); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
import 'package:charts_flutter/flutter.dart' as charts; | |
import 'package:flutter/material.dart'; | |
class SimplePieChart extends StatelessWidget { | |
final List<charts.Series> seriesList; | |
final bool animate; | |
SimplePieChart(this.seriesList, {this.animate}); | |
factory SimplePieChart.withSampleData() { | |
return new SimplePieChart( | |
_createSampleData(), | |
animate: false, | |
); | |
} | |
factory SimplePieChart.withRandomData() { | |
return new SimplePieChart(_createRandomData()); | |
} | |
static List<charts.Series<LinearSales, int>> _createRandomData() { | |
final random = new Random(); | |
final data = [ | |
new LinearSales(0, random.nextInt(100)), | |
new LinearSales(1, random.nextInt(100)), | |
new LinearSales(2, random.nextInt(100)), | |
new LinearSales(3, random.nextInt(100)), | |
]; | |
return [ | |
new charts.Series<LinearSales, int>( | |
id: 'Sales', | |
domainFn: (LinearSales sales, _) => sales.year, | |
measureFn: (LinearSales sales, _) => sales.sales, | |
data: data, | |
) | |
]; | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new charts.PieChart(seriesList, animate: animate); | |
} | |
static List<charts.Series<LinearSales, int>> _createSampleData() { | |
final data = [ | |
new LinearSales(0, 100), | |
new LinearSales(1, 75), | |
new LinearSales(2, 25), | |
new LinearSales(3, 5), | |
]; | |
return [ | |
new charts.Series<LinearSales, int>( | |
id: 'Sales', | |
domainFn: (LinearSales sales, _) => sales.year, | |
measureFn: (LinearSales sales, _) => sales.sales, | |
data: data, | |
) | |
]; | |
} | |
} | |
class LinearSales { | |
final int year; | |
final int sales; | |
LinearSales(this.year, this.sales); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import '../Constant/Constant.dart'; | |
import 'package:flutter/cupertino.dart'; | |
import 'package:flutter/material.dart'; | |
class SplashScreen extends StatefulWidget { | |
@override | |
SplashScreenState createState() => new SplashScreenState(); | |
} | |
class SplashScreenState extends State<SplashScreen> | |
with SingleTickerProviderStateMixin { | |
var _visible = true; | |
AnimationController animationController; | |
Animation<double> animation; | |
startTime() async { | |
var _duration = new Duration(seconds: 3); | |
return new Timer(_duration, navigationPage); | |
} | |
void navigationPage() { | |
Navigator.of(context).pushReplacementNamed(HOME); | |
} | |
@override | |
void initState() { | |
super.initState(); | |
animationController = new AnimationController( | |
vsync: this, duration: new Duration(seconds: 2)); | |
animation = | |
new CurvedAnimation(parent: animationController, curve: Curves.easeOut); | |
animation.addListener(() => this.setState(() {})); | |
animationController.forward(); | |
setState(() { | |
_visible = !_visible; | |
}); | |
startTime(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Stack( | |
fit: StackFit.expand, | |
children: <Widget>[ | |
new Column( | |
mainAxisAlignment: MainAxisAlignment.end, | |
mainAxisSize: MainAxisSize.min, | |
children: <Widget>[ | |
Padding( | |
padding: EdgeInsets.only(bottom: 30.0), | |
child: new Image.asset( | |
'assets/images/powered_by.png', | |
height: 25.0, | |
fit: BoxFit.scaleDown, | |
)) | |
], | |
), | |
new Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new Image.asset( | |
'assets/images/logo.png', | |
width: animation.value * 250, | |
height: animation.value * 250, | |
), | |
], | |
), | |
], | |
), | |
); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'res/Res.dart'; | |
import 'colored_container.dart'; | |
Widget WeatherDetailsHeader(double statusBarHeight) { | |
String _currentDate = "September 14, 3:33 PM"; | |
String _condition = "Clear Sky"; | |
String _roundedTemperature = "33°C"; | |
String _city = "New York"; | |
return new Container( | |
color: Colors.blue, | |
child: new Center( | |
child: new Column( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: <Widget>[ | |
new Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new Text( | |
_currentDate, | |
style: new TextStyle( | |
fontSize: 18.0, | |
fontWeight: FontWeight.w700, | |
color: $Colors.textColorWheatherHeader), | |
), | |
], | |
), | |
new Center( | |
child: new Row( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: <Widget>[ | |
new Column( | |
mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
children: <Widget>[ | |
new Text( | |
_city, | |
style: new TextStyle( | |
fontSize: 21.0, | |
fontWeight: FontWeight.w700, | |
color: $Colors.textColorWheatherHeader), | |
), | |
new Text( | |
_condition, | |
style: new TextStyle( | |
fontSize: 18.0, | |
color: $Colors.textColorWheatherHeader, | |
), | |
), | |
new Text(_roundedTemperature, | |
style: new TextStyle( | |
fontSize: 45.0, | |
color: $Colors.textColorWheatherHeader, | |
fontFamily: "Roboto")), | |
], | |
), | |
new Column( | |
children: <Widget>[ | |
new Image.asset( | |
'assets/images/sunny.png', width: 100.0, height: 100.0,) | |
], | |
) | |
], | |
), | |
) | |
], | |
), | |
), | |
padding: new EdgeInsets.only(top: statusBarHeight), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment