diff --git a/assets/images/planting_view.jpg b/assets/images/planting_view.jpg new file mode 100644 index 0000000..31c438a Binary files /dev/null and b/assets/images/planting_view.jpg differ diff --git a/fonts/weathericons-regular-webfont.ttf b/fonts/weathericons-regular-webfont.ttf new file mode 100644 index 0000000..948f0a5 Binary files /dev/null and b/fonts/weathericons-regular-webfont.ttf differ diff --git a/lib/app_theme.dart b/lib/app_theme.dart index 02c2193..90cace2 100644 --- a/lib/app_theme.dart +++ b/lib/app_theme.dart @@ -6,6 +6,7 @@ class AppTheme { static const Color background = Color(0xFFEEEFF4); static const Color nearlyDarkGreen = Color(0xFF2EC821); static const Color nearlyGreen = Color(0xFF24D900); + static const Color pastelGreen = Color(0xFF10d180); static const Color notWhite = Color(0xFFEDF0F2); static const Color nearlyWhite = Color(0xFFFEFEFE); diff --git a/lib/data/farm/models/Forecast.dart b/lib/data/farm/models/Forecast.dart index e53b0ad..458b7b8 100644 --- a/lib/data/farm/models/Forecast.dart +++ b/lib/data/farm/models/Forecast.dart @@ -49,6 +49,7 @@ class Forecast { var currentForcast = Weather( cloudiness: int.parse(json['current']['clouds'].toString()), temp: json['current']['temp'].toDouble(), + iconCode: weather['icon'], condition: Weather.mapStringToWeatherCondition( weather['main'], int.parse(json['current']['clouds'].toString())), description: weather['description'], diff --git a/lib/data/farm/models/Planting.dart b/lib/data/farm/models/Planting.dart index 447f98e..6f45804 100644 --- a/lib/data/farm/models/Planting.dart +++ b/lib/data/farm/models/Planting.dart @@ -1,7 +1,7 @@ class Planting { String _name; int _noOfPlants; - DateTime _date; + String _date; String _estimatedHarvest; String _location; String _fertilizers; @@ -40,9 +40,9 @@ class Planting { _estimatedHarvest = value; } - DateTime get date => _date; + String get date => _date; - set date(DateTime value) { + set date(String value) { _date = value; } diff --git a/lib/data/farm/models/Weather.dart b/lib/data/farm/models/Weather.dart index b681e2f..413ed03 100644 --- a/lib/data/farm/models/Weather.dart +++ b/lib/data/farm/models/Weather.dart @@ -1,4 +1,3 @@ - import 'package:farmassist/data/farm/utils/WeatherIconMapper.dart'; import 'package:flutter/material.dart'; diff --git a/lib/data/farm/repositories/storeData.dart b/lib/data/farm/repositories/storeData.dart index 3a626e8..b4cf564 100644 --- a/lib/data/farm/repositories/storeData.dart +++ b/lib/data/farm/repositories/storeData.dart @@ -1,18 +1,42 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:farmassist/data/farm/models/Planting.dart'; +import 'package:firebase_auth/firebase_auth.dart'; +import 'package:intl/intl.dart'; + void addData(Map obj) { - String month = DateTime.now().month.toString().toLowerCase(); + final FirebaseAuth auth = FirebaseAuth.instance; + final FirebaseFirestore db = FirebaseFirestore.instance; + + User user = auth.currentUser; + final uid = user.uid; + var month; + + DateTime dt = obj['plantDate']; + print(dt.month); + + if(dt.month==1){ + month="January"; + } + else{ + month="February"; + } + + final DateFormat formatter = DateFormat('dd-MM-yyyy'); + final String formatted = formatter.format(dt); - FirebaseFirestore db = FirebaseFirestore.instance; CollectionReference cr = - db.collection("Planting").doc(month).collection("Activity"); + db.collection("Planting").doc(uid).collection(month); Map data = { "name": obj['plantName'], "noOfPlants": obj['plantNumber'], - "date": obj['date'], + "date": formatted, "estimatedHarvest": obj['plantEstimated'], + "month": dt.month, + "year": dt.year, + "day": dt.day, + "week": dt.weekday, }; cr.doc().set(data); diff --git a/lib/data/farm/view_model/weather_app_forecast_viewmodel.dart b/lib/data/farm/view_model/weather_app_forecast_viewmodel.dart index 6b05229..b601301 100644 --- a/lib/data/farm/view_model/weather_app_forecast_viewmodel.dart +++ b/lib/data/farm/view_model/weather_app_forecast_viewmodel.dart @@ -18,6 +18,8 @@ class ForecastViewModel with ChangeNotifier { WeatherCondition _condition; String _description; + String _iconCode; + IconData _iconData; double _minTemp; double _maxTemp; double _temp; @@ -29,10 +31,11 @@ class ForecastViewModel with ChangeNotifier { double _longitude; List _daily; bool _isDayTime; - String _iconData; WeatherCondition get condition => _condition; + IconData get iconData => getIconData(_iconCode); String get description => _description; + String get iconCode => _iconCode; double get minTemp => _minTemp; double get maxTemp => _maxTemp; double get temp => _temp; @@ -44,7 +47,6 @@ class ForecastViewModel with ChangeNotifier { double get latitide => _latitude; bool get isDaytime => _isDayTime; List get daily => _daily; - String get iconData => _iconData; ForecastService forecastService; @@ -85,6 +87,8 @@ class ForecastViewModel with ChangeNotifier { _condition = forecast.current.condition; _city = forecast.city; + _iconCode = forecast.current.iconCode; + _description = Strings.toTitleCase(forecast.current.description); _lastUpdated = forecast.lastUpdated; _temp = TemperatureConvert.kelvinToCelsius(forecast.current.temp); diff --git a/lib/ui/farm/news/Widget/newsCard.dart b/lib/ui/farm/news/Widget/newsCard.dart index 91f2b88..b101370 100644 --- a/lib/ui/farm/news/Widget/newsCard.dart +++ b/lib/ui/farm/news/Widget/newsCard.dart @@ -3,6 +3,8 @@ import 'package:farmassist/ui/farm/news_details/bloc/bloc.dart'; import 'package:farmassist/ui/widgets/news_customWidget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:farmassist/ui/farm/news_details/newsDetailPage.dart'; +import 'package:page_transition/page_transition.dart'; import '../../../../app_theme.dart'; @@ -37,7 +39,12 @@ class NewsCard extends StatelessWidget { onTap: () { BlocProvider.of(context) .add(SelectNewsForDetail(article: artical)); - Navigator.pushNamed(context, '/detail'); + Navigator.push( + context, + PageTransition( + type: PageTransitionType.leftToRightWithFade, + child: NewsDetailPage() + ));; }, child: Container( padding: EdgeInsets.symmetric(horizontal: 20), @@ -54,7 +61,7 @@ class NewsCard extends StatelessWidget { fit: StackFit.expand, children: [ Container( - color: Theme.of(context).primaryColor, + color: Colors.grey, child: artical.urlToImage == null || artical.urlToImage.isEmpty ? Container() @@ -66,38 +73,38 @@ class NewsCard extends StatelessWidget { SizedBox(width: 10), Expanded( child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - SizedBox(), - Container( - height: 52, - child: Text( - artical.title, - style: Theme.of(context).textTheme.body1, - overflow: TextOverflow.fade, - ), - ), - Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ + SizedBox(), Container( - padding: - EdgeInsets.symmetric(horizontal: 10, vertical: 5), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: Theme.of(context).primaryColor, - ), + height: 52, child: Text( - '$type', - style: AppTheme.headline6.copyWith( - color: Theme.of(context).colorScheme.onPrimary), + artical.title, + style: Theme.of(context).textTheme.bodyText1, + overflow: TextOverflow.fade, ), ), - Container( - padding: EdgeInsets.only(left: 10), - child: Text(artical.getDateOnly(), - style: AppTheme.subtitle2), - ), - ], + Row( + children: [ + Container( + padding: + EdgeInsets.symmetric(horizontal: 10, vertical: 5), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(5), + color: Colors.black, + ), + child: Text( + '$type', + style: AppTheme.headline6.copyWith( + color: Colors.white), + ), + ), + Container( + padding: EdgeInsets.only(left: 10), + child: Text(artical.getDateOnly(), + style: AppTheme.subtitle2), + ), + ], ) ], )) diff --git a/lib/ui/farm/news/news_home.dart b/lib/ui/farm/news/news_home.dart index 2f5f844..524e607 100644 --- a/lib/ui/farm/news/news_home.dart +++ b/lib/ui/farm/news/news_home.dart @@ -55,14 +55,13 @@ class HomePage extends StatelessWidget { title: Text( '${type.toUpperCase()} NEWS', style: AppTheme.headline5 - .copyWith(color: Theme.of(context).colorScheme.primaryVariant), + .copyWith(color: Colors.black), ), backgroundColor: Colors.white, + elevation: 10.0, + shadowColor: Colors.grey, pinned: true, ), - SliverToBoxAdapter( - child: _headerNews(list.first), - ), SliverList( delegate: SliverChildBuilderDelegate( (context, index) => NewsCard( diff --git a/lib/ui/farm/news_details/newsDetailPage.dart b/lib/ui/farm/news_details/newsDetailPage.dart index ec4b6c0..766085d 100644 --- a/lib/ui/farm/news_details/newsDetailPage.dart +++ b/lib/ui/farm/news_details/newsDetailPage.dart @@ -29,24 +29,9 @@ class NewsDetailPage extends StatelessWidget { }, icon: Icon( Icons.keyboard_backspace, - color: Theme.of(context).backgroundColor, + color: Colors.blueGrey, ), ), - Expanded(child: SizedBox()), - IconButton( - onPressed: () {}, - icon: Icon( - Icons.favorite_border, - color: Theme.of(context).backgroundColor, - ), - ), - IconButton( - onPressed: () {}, - icon: Icon( - Icons.share, - color: Theme.of(context).backgroundColor, - ), - ) ], ), ) @@ -55,6 +40,7 @@ class NewsDetailPage extends StatelessWidget { } Widget _body(BuildContext context, Article article) { + print(article.content); return CustomScrollView( slivers: [ SliverToBoxAdapter( @@ -62,33 +48,33 @@ class NewsDetailPage extends StatelessWidget { ), SliverToBoxAdapter( child: Padding( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 10, - ), - Text(article.title, style: AppTheme.headline4), - SizedBox( - height: 10, - ), - Row( + padding: EdgeInsets.symmetric(horizontal: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text(article.author ?? '', style: AppTheme.headline4), SizedBox( - width: 10, + height: 10, + ), + Text(article.title, style: AppTheme.headline5), + SizedBox( + height: 10, + ), + Row( + children: [ + Text(article.author ?? '', style: AppTheme.subtitle2), + SizedBox( + width: 10, + ), + Text(article.getTime(), style: AppTheme.subtitle2), + ], ), - Text(article.getTime(), style: AppTheme.headline4), + Divider( + height: 20, + thickness: 1, + ), + Text(article.content ?? '', style: AppTheme.bodyText1) ], ), - Divider( - height: 20, - thickness: 1, - ), - Text(article.content ?? '', style: AppTheme.headline4) - ], - ), )) ], ); @@ -97,7 +83,7 @@ class NewsDetailPage extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: Theme.of(context).backgroundColor, + backgroundColor: Colors.white, body: SafeArea(child: BlocBuilder( builder: (context, state) { if (state == null) { diff --git a/lib/ui/farm/planting/display_planting.dart b/lib/ui/farm/planting/display_planting.dart new file mode 100644 index 0000000..8a2c6f7 --- /dev/null +++ b/lib/ui/farm/planting/display_planting.dart @@ -0,0 +1,132 @@ +import 'package:farmassist/app_theme.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:getwidget/components/appbar/gf_appbar.dart'; +import 'package:getwidget/components/button/gf_icon_button.dart'; +import 'package:getwidget/types/gf_button_type.dart'; + +class DisplayPlanting extends StatefulWidget { + final String plantName; + final String plantNo; + final String plantDate; + final double plantEstimate; + + DisplayPlanting({ + this.plantName, + this.plantNo, + this.plantDate, + this.plantEstimate + }); + + @override + _DisplayPlantingState createState() => _DisplayPlantingState(name:plantName, no:plantNo, date:plantDate, estimate:plantEstimate); +} + +class _DisplayPlantingState extends State { + final String name; + final String no; + final String date; + final double estimate; + + _DisplayPlantingState({ + this.name, + this.no, + this.date, + this.estimate + }); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: GFAppBar( + leading: GFIconButton( + icon: Icon( + Icons.arrow_back, + color: Colors.white, + ), + onPressed: () { + Navigator.pop(context); + }, + type: GFButtonType.transparent, + ), + title: Text("View Planting Entry", + style: TextStyle( + color: AppTheme.nearlyWhite, + ),), + backgroundColor: AppTheme.pastelGreen, + ), + body: Container( + padding: EdgeInsets.all(5.0), + child: Column( + children: [ + new Expanded( + child: ListView( + padding: EdgeInsets.all(10.0), + children: [ + FormBuilder( + child: Column( + children: [ + FormBuilderTextField( + readOnly: true, + initialValue: name, + name: 'plantName', + decoration: InputDecoration( + labelText: "Plant Name", + icon: Icon(Icons.local_florist_outlined), + ), + keyboardType: TextInputType.text, + ), + SizedBox(height: 10), + FormBuilderTextField( + readOnly: true, + name: 'plantNumber', + initialValue: no, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: "No. of Plants", + icon: Icon(Icons.format_list_numbered), + ), + ), + SizedBox(height: 10), + FormBuilderTextField( + readOnly: true, + name: 'plantNumber', + initialValue: date, + keyboardType: TextInputType.number, + decoration: InputDecoration( + labelText: 'Date', + icon: Icon(Icons.date_range), + ), + ), + SizedBox(height: 10), + FormBuilderSlider( + enabled: false, + name: 'plantEstimated', + validator: FormBuilderValidators.compose([ + FormBuilderValidators.min(context, 1), + ]), + min: 1.0, + max: 12.0, + initialValue: estimate, + divisions: 11, + label: 'Weeks', + activeColor: Colors.red, + inactiveColor: Colors.pink[100], + decoration: InputDecoration( + labelText: 'Estimated Harvest Date', + icon: Icon(Icons.timelapse), + ), + ), + SizedBox(height: 20), + ], + ), + ), + ], + ), + ) + ], + ), + ) + ); + } +} diff --git a/lib/ui/farm/planting/form_storePlanting.dart b/lib/ui/farm/planting/form_storePlanting.dart index c76e903..deeeb72 100644 --- a/lib/ui/farm/planting/form_storePlanting.dart +++ b/lib/ui/farm/planting/form_storePlanting.dart @@ -1,9 +1,11 @@ +import 'package:farmassist/app_theme.dart'; import 'package:farmassist/data/farm/repositories/storeData.dart'; import 'package:flutter/material.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:getwidget/components/appbar/gf_appbar.dart'; import 'package:getwidget/components/button/gf_icon_button.dart'; import 'package:getwidget/types/gf_button_type.dart'; +import 'package:intl/intl.dart'; class formStorePlanting extends StatefulWidget { @override @@ -12,6 +14,12 @@ class formStorePlanting extends StatefulWidget { class _formStorePlantingState extends State { final _formKey = GlobalKey(); + final DateTime now = DateTime.now(); + final DateFormat formatter = DateFormat('dd-MM-yyyy'); + + date(){ + return formatter.format(now); + } @override Widget build(BuildContext context) { @@ -20,15 +28,18 @@ class _formStorePlantingState extends State { leading: GFIconButton( icon: Icon( Icons.arrow_back, - color: Colors.grey, + color: Colors.white, ), onPressed: () { Navigator.pop(context); }, type: GFButtonType.transparent, ), - title: Text("Create Planting Entry"), - backgroundColor: Colors.white, + title: Text("Create Planting Entry", + style: TextStyle( + color: AppTheme.nearlyWhite, + ),), + backgroundColor: AppTheme.pastelGreen, ), body: Container( padding: EdgeInsets.all(5.0), diff --git a/lib/ui/farm/planting/planting_list.dart b/lib/ui/farm/planting/planting_list.dart new file mode 100644 index 0000000..8b9d01a --- /dev/null +++ b/lib/ui/farm/planting/planting_list.dart @@ -0,0 +1,146 @@ + import 'dart:async'; + +import 'package:farmassist/data/farm/utils/weather_strings.dart'; +import 'package:farmassist/ui/farm/planting/display_planting.dart'; +import 'package:flutter/material.dart'; +import 'package:cloud_firestore/cloud_firestore.dart'; + import 'package:firebase_auth/firebase_auth.dart'; +import 'package:flutter_form_builder/flutter_form_builder.dart'; +import 'package:getwidget/components/appbar/gf_appbar.dart'; +import 'package:getwidget/components/button/gf_icon_button.dart'; +import 'package:getwidget/components/card/gf_card.dart'; +import 'package:getwidget/components/list_tile/gf_list_tile.dart'; +import 'package:getwidget/types/gf_button_type.dart'; +import 'package:page_transition/page_transition.dart'; + +import '../../../app_theme.dart'; + +class PlantingList extends StatefulWidget { + FirebaseFirestore db = FirebaseFirestore.instance; + + @override + _PlantingListState createState() => _PlantingListState(); +} + +class _PlantingListState extends State { + FirebaseAuth _auth = FirebaseAuth.instance; + + StreamController _streamController; + Stream _stream; + final _monthOptions = ["January","February"]; + var _option; + String uid = ""; + + @override + void initState() { + super.initState(); + + _streamController = StreamController(); + _stream = _streamController.stream; + } + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: GFAppBar( + bottom: PreferredSize( + preferredSize: Size.fromHeight(70.0), + child: Row( + children: [ + Expanded( + child: FormBuilderDropdown( + name: 'month', + // initialValue: "January", + decoration: InputDecoration( + labelText: 'Month', + ), + onChanged: (value){ + print(_option); + User user = _auth.currentUser; + setState(() { + _option = value; + uid = user.uid; + }); + print(_option); + print(uid); + }, + allowClear: true, + hint: Text('Select Month'), + validator: FormBuilderValidators.compose( + [FormBuilderValidators.required(context)]), + items: _monthOptions + .map((month) => DropdownMenuItem( + value: month, + child: Text('$month'), + )) + .toList(), + ), + ) + ], + ), + ), + leading: GFIconButton( + icon: Icon( + Icons.arrow_back, + color: Colors.grey, + ), + onPressed: () { + Navigator.pop(context); + }, + type: GFButtonType.transparent, + ), + title: Text("View Planting Entry", + style: TextStyle( + color: AppTheme.nearlyBlack, + ),), + backgroundColor: AppTheme.nearlyWhite, + ), + body: _option!=null?( + StreamBuilder( + stream: widget.db.collection("Planting").doc(uid).collection(_option).orderBy('date', descending:true).snapshots(), + builder: (context, snapshot){ + if(!snapshot.hasData) { + return Text('Loading...'); + } + return Column( + children: [ + new Expanded(child: ListView.builder( + itemCount: snapshot.data.docs.length, + itemBuilder: (context,index){ + String itemTitle = snapshot.data.docs[index]['name']; + String date = snapshot.data.docs[index]['date']; + String number = snapshot.data.docs[index]['noOfPlants']; + double est = snapshot.data.docs[index]['estimatedHarvest']; + return GFListTile( + padding: EdgeInsets.all(10.0), + titleText: Strings.toTitleCase(itemTitle), + subtitleText: date, + color: Colors.blueGrey[100], + onTap: (){ + Navigator.push( + context, + PageTransition( + type: PageTransitionType.leftToRightWithFade, + child: DisplayPlanting( + plantName: itemTitle, + plantNo: number, + plantDate: date, + plantEstimate: est, + ) + )); + }, + ); + })) + ], + ); + }, + ) + ):Container( + child: Center( + child: Text("Please select a month."), + ), + ), + ); + } +} + diff --git a/lib/ui/farm/planting/planting_menu.dart b/lib/ui/farm/planting/planting_menu.dart index 22fec3c..b788fc5 100644 --- a/lib/ui/farm/planting/planting_menu.dart +++ b/lib/ui/farm/planting/planting_menu.dart @@ -1,4 +1,5 @@ import 'package:farmassist/app_theme.dart'; +import 'package:farmassist/ui/farm/planting/planting_list.dart'; import 'package:flutter/material.dart'; import 'package:getwidget/getwidget.dart'; import 'package:getwidget/components/appbar/gf_appbar.dart'; @@ -22,15 +23,20 @@ class _PlantingMenuState extends State { leading: GFIconButton( icon: Icon( Icons.arrow_back, - color: Colors.grey, + color: Colors.white, ), onPressed: () { Navigator.pop(context); }, type: GFButtonType.transparent, ), - title: Text("Manage Planting"), - backgroundColor: Colors.white, + title: Text( + "Manage Planting", + style: TextStyle( + color: AppTheme.nearlyWhite, + ), + ), + backgroundColor: AppTheme.pastelGreen, ), backgroundColor: Colors.transparent, body: ListView( @@ -64,19 +70,28 @@ class _PlantingMenuState extends State { title: GFListTile( titleText:'Create Planting', subtitle: Text("Record a new planting activity."), + icon: Icon(Icons.arrow_forward), ), ), ) , InkWell( - onTap: (){}, + onTap: (){ + Navigator.push( + context, + PageTransition( + type: PageTransitionType.leftToRightWithFade, + child: PlantingList() + )); + }, child: GFCard( boxFit: BoxFit.cover, image: Image.asset( - 'assets/images/planting_create.jpg' + 'assets/images/planting_view.jpg' ), title: GFListTile( titleText:'View Planting', subtitle: Text("Take a look at all your previous records."), + icon: Icon(Icons.arrow_forward), ), ), ) , diff --git a/lib/ui/farm/weather/gradient.dart b/lib/ui/farm/weather/gradient.dart new file mode 100644 index 0000000..9b911c1 --- /dev/null +++ b/lib/ui/farm/weather/gradient.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; + +import 'package:meta/meta.dart'; + +class GradientContainer extends StatelessWidget { + final Widget child; + final MaterialColor color; + + const GradientContainer({ + Key key, + @required this.color, + @required this.child, + }) : assert(color != null, child != null), + super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + stops: [0, 1.0], + colors: [ + color[800], + color[400], + ], + ), + ), + child: child, + ); + } +} \ No newline at end of file diff --git a/lib/ui/farm/weather/weatherHome.dart b/lib/ui/farm/weather/weatherHome.dart index 8926829..da3a323 100644 --- a/lib/ui/farm/weather/weatherHome.dart +++ b/lib/ui/farm/weather/weatherHome.dart @@ -1,9 +1,11 @@ +import 'package:farmassist/data/farm/models/Weather.dart'; import 'package:farmassist/data/farm/view_model/weather_app_forecast_viewmodel.dart'; import 'package:farmassist/ui/farm/weather/weatherSummaryView.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'cityEntryView.dart'; +import 'gradient.dart'; class WeatherHome extends StatefulWidget { @override @@ -13,9 +15,18 @@ class WeatherHome extends StatefulWidget { class _WeatherHomeState extends State { @override Widget build(BuildContext context) { + return Consumer( + builder: (context, model, child) => Container( + child: _buildGradientContainer( + model.condition, model.isDaytime, buildHomeView(context, model)), + ), + ); + } + + @override + Widget buildHomeView(BuildContext context, model) { return Consumer( builder: (context, weatherViewModel, child) => Container( - color: Colors.red, height: 200, child: ListView( children: [ @@ -29,13 +40,13 @@ class _WeatherHomeState extends State { fontSize: 21, color: Colors.white))) : Column(children: [ WeatherSummary( - model: weatherViewModel, condition: weatherViewModel.condition, temp: weatherViewModel.temp, feelsLike: weatherViewModel.feelsLike, isdayTime: weatherViewModel.isDaytime, - iconData: weatherViewModel.iconData), - SizedBox(height: 20), + iconData: weatherViewModel.iconData, + // weatherModel: model, + ), ]), ], ))); @@ -56,4 +67,39 @@ class _WeatherHomeState extends State { )) ]); } + + GradientContainer _buildGradientContainer( + WeatherCondition condition, bool isDayTime, Widget child) { + GradientContainer container; + + // if night time then just default to a blue/grey + if (isDayTime != null && !isDayTime) + container = GradientContainer(color: Colors.blueGrey, child: child); + else { + switch (condition) { + case WeatherCondition.clear: + case WeatherCondition.lightCloud: + container = GradientContainer(color: Colors.yellow, child: child); + break; + case WeatherCondition.fog: + case WeatherCondition.atmosphere: + case WeatherCondition.rain: + case WeatherCondition.drizzle: + case WeatherCondition.mist: + case WeatherCondition.heavyCloud: + container = GradientContainer(color: Colors.indigo, child: child); + break; + case WeatherCondition.snow: + container = GradientContainer(color: Colors.lightBlue, child: child); + break; + case WeatherCondition.thunderstorm: + container = GradientContainer(color: Colors.deepPurple, child: child); + break; + default: + container = GradientContainer(color: Colors.lightBlue, child: child); + } + } + + return container; + } } diff --git a/lib/ui/farm/weather/weatherSummaryView.dart b/lib/ui/farm/weather/weatherSummaryView.dart index 15e394d..dc401d8 100644 --- a/lib/ui/farm/weather/weatherSummaryView.dart +++ b/lib/ui/farm/weather/weatherSummaryView.dart @@ -1,4 +1,5 @@ import 'package:farmassist/data/farm/models/Weather.dart'; +import 'package:farmassist/data/farm/utils/WeatherIconMapper.dart'; import 'package:farmassist/data/farm/view_model/weather_app_forecast_viewmodel.dart'; import 'package:flutter/material.dart'; @@ -8,7 +9,7 @@ class WeatherSummary extends StatelessWidget { final double temp; final double feelsLike; final bool isdayTime; - final String iconData; + final IconData iconData; WeatherSummary( {Key key, @@ -17,37 +18,43 @@ class WeatherSummary extends StatelessWidget { @required this.temp, @required this.feelsLike, @required this.isdayTime, - @required this.iconData}) + @required this.iconData + }) : super(key: key); @override Widget build(BuildContext context) { return Center( - child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Column( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - Text( - '${_formatTemperature(this.temp)}°ᶜ', - style: TextStyle( - fontSize: 50, - color: Colors.black, - fontWeight: FontWeight.w300, + Container( + padding: EdgeInsets.only(bottom: 20.0), + child: Column( + children: [ + Text( + '${_formatTemperature(this.temp)}°ᶜ', + style: TextStyle( + fontSize: 50, + color: Colors.white, + fontWeight: FontWeight.w300, + ), ), - ), - Text( - 'Feels like ${_formatTemperature(this.feelsLike)}°ᶜ', - style: TextStyle( - fontSize: 18, - color: Colors.black, - fontWeight: FontWeight.w300, + Text( + 'Feels like ${_formatTemperature(this.feelsLike)}°ᶜ', + style: TextStyle( + fontSize: 18, + color: Colors.white, + fontWeight: FontWeight.w300, + ), ), - ), - ], - ), - Icon( - IconData(0xf00d), - size: 70, + ], + ), ), + Container( + padding: EdgeInsets.only(bottom: 30.0), + child: new Icon(iconData, size: 60.0,), + ) ]), ); } diff --git a/pubspec.yaml b/pubspec.yaml index 5fcd380..5130286 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -39,7 +39,8 @@ flutter: uses-material-design: true assets: - assets/images/ + fonts: - family: WeatherIcons fonts: - - asset: fonts/weathericons-regular.ttf + - asset: fonts/weathericons-regular-webfont.ttf