diff --git a/lib/data/farm/repositories/harvest_storeData.dart b/lib/data/farm/repositories/harvest_storeData.dart index 25e85c6..3b1c36b 100644 --- a/lib/data/farm/repositories/harvest_storeData.dart +++ b/lib/data/farm/repositories/harvest_storeData.dart @@ -5,10 +5,9 @@ import 'package:intl/intl.dart'; final FirebaseAuth auth = FirebaseAuth.instance; final FirebaseFirestore db = FirebaseFirestore.instance; -User user = auth.currentUser; -final uid = user.uid; - void harvestData(Map obj){ + User user = auth.currentUser; + final uid = user.uid; DateTime harvestDt = obj['harvestDate']; @@ -36,6 +35,8 @@ void harvestData(Map obj){ } void updatePlanting(String id){ + User user = auth.currentUser; + final uid = user.uid; CollectionReference cr = db.collection("planting").doc(uid).collection('month'); diff --git a/lib/data/farm/repositories/storeData.dart b/lib/data/farm/repositories/storeData.dart index d7f54b6..382956b 100644 --- a/lib/data/farm/repositories/storeData.dart +++ b/lib/data/farm/repositories/storeData.dart @@ -28,8 +28,11 @@ void addData(Map obj) { CollectionReference cr = db.collection('planting').doc(uid).collection('month'); + String name = obj['plantName']; + name = name.toLowerCase(); + Map data = { - "name": obj['plantName'], + "name": name, "noOfPlants": obj['plantNumber'], "date": formatted, "estimatedHarvest": obj['plantEstimated'], diff --git a/lib/ui/farm/planting/display_planting.dart b/lib/ui/farm/planting/display_planting.dart index edbc181..969bef9 100644 --- a/lib/ui/farm/planting/display_planting.dart +++ b/lib/ui/farm/planting/display_planting.dart @@ -4,6 +4,7 @@ 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:farmassist/data/farm/utils/weather_strings.dart'; class DisplayPlanting extends StatefulWidget { final String plantName; diff --git a/lib/ui/farm/statistics/utils/getEvents.dart b/lib/ui/farm/statistics/utils/getEvents.dart index 71fd892..14f3cc6 100644 --- a/lib/ui/farm/statistics/utils/getEvents.dart +++ b/lib/ui/farm/statistics/utils/getEvents.dart @@ -4,10 +4,11 @@ import 'package:firebase_auth/firebase_auth.dart'; final FirebaseAuth auth = FirebaseAuth.instance; final FirebaseFirestore db = FirebaseFirestore.instance; -User user = auth.currentUser; -final uid = user.uid; + Map getHarvestEvents(){ + User user = auth.currentUser; + final uid = user.uid; Map _events = new Map(); db.collection('planting').doc(uid).collection('month') diff --git a/lib/ui/farm/statistics/utils/getHarvestingInfo.dart b/lib/ui/farm/statistics/utils/getHarvestingInfo.dart index 306993c..9d57624 100644 --- a/lib/ui/farm/statistics/utils/getHarvestingInfo.dart +++ b/lib/ui/farm/statistics/utils/getHarvestingInfo.dart @@ -4,13 +4,13 @@ import 'package:firebase_auth/firebase_auth.dart'; final FirebaseAuth auth = FirebaseAuth.instance; final FirebaseFirestore db = FirebaseFirestore.instance; -User user = auth.currentUser; -final uid = user.uid; - Map _keys; Map _keys2; Map getHarvesting() { + User user = auth.currentUser; + final uid = user.uid; + Map _harvesting = new Map(); _keys = new Map(); _keys2 = new Map(); diff --git a/lib/ui/farm/weather/weatherHome.dart b/lib/ui/farm/weather/weatherHome.dart index 7343c05..0e81f95 100644 --- a/lib/ui/farm/weather/weatherHome.dart +++ b/lib/ui/farm/weather/weatherHome.dart @@ -1,4 +1,5 @@ import 'package:farmassist/data/farm/models/Weather.dart'; +import 'package:farmassist/data/farm/view_model/cityEntryViewModel.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'; @@ -28,28 +29,35 @@ class _WeatherHomeState extends State { return Consumer( builder: (context, weatherViewModel, child) => Container( height: 225, - child: ListView( - children: [ - CityEntryView(), - weatherViewModel.isRequestPending - ? buildBusyIndicator() - : weatherViewModel.isRequestError - ? Center( - child: Text('Ooops...something went wrong', - style: TextStyle( - fontSize: 21, color: Colors.white))) - : Column(children: [ - WeatherSummary( - condition: weatherViewModel.condition, - temp: weatherViewModel.temp, - feelsLike: weatherViewModel.feelsLike, - isdayTime: weatherViewModel.isDaytime, - iconData: weatherViewModel.iconData, - // weatherModel: model, - ), - ]), - ], - ))); + child: RefreshIndicator( + color: Colors.transparent, + backgroundColor: Colors.transparent, + onRefresh: () => refreshWeather(weatherViewModel, context), + child: ListView( + children: [ + CityEntryView(), + weatherViewModel.isRequestPending + ? buildBusyIndicator() + : weatherViewModel.isRequestError + ? Center( + child: Text('Ooops...something went wrong', + style: TextStyle( + fontSize: 21, color: Colors.white))) + : Column(children: [ + WeatherSummary( + condition: weatherViewModel.condition, + temp: weatherViewModel.temp, + feelsLike: weatherViewModel.feelsLike, + isdayTime: weatherViewModel.isDaytime, + iconData: weatherViewModel.iconData, + // weatherModel: model, + ), + ]), + ], + ), + ) + ) + ); } Widget buildBusyIndicator() { @@ -68,6 +76,13 @@ class _WeatherHomeState extends State { ]); } + Future refreshWeather( + ForecastViewModel weatherVM, BuildContext context) { + // get the current city + String city = Provider.of(context, listen: false).city; + return weatherVM.getLatestWeather(city); + } + GradientContainer _buildGradientContainer( WeatherCondition condition, bool isDayTime, Widget child) { GradientContainer container;