Skip to content

Commit

Permalink
DONE
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielChang98 committed Jan 13, 2021
1 parent 199e236 commit 57ab495
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 31 deletions.
7 changes: 4 additions & 3 deletions lib/data/farm/repositories/harvest_storeData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> obj){
User user = auth.currentUser;
final uid = user.uid;

DateTime harvestDt = obj['harvestDate'];

Expand Down Expand Up @@ -36,6 +35,8 @@ void harvestData(Map<String, dynamic> obj){
}

void updatePlanting(String id){
User user = auth.currentUser;
final uid = user.uid;

CollectionReference cr =
db.collection("planting").doc(uid).collection('month');
Expand Down
5 changes: 4 additions & 1 deletion lib/data/farm/repositories/storeData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ void addData(Map<String, dynamic> obj) {
CollectionReference cr =
db.collection('planting').doc(uid).collection('month');

String name = obj['plantName'];
name = name.toLowerCase();

Map<String, dynamic> data = {
"name": obj['plantName'],
"name": name,
"noOfPlants": obj['plantNumber'],
"date": formatted,
"estimatedHarvest": obj['plantEstimated'],
Expand Down
1 change: 1 addition & 0 deletions lib/ui/farm/planting/display_planting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/farm/statistics/utils/getEvents.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTime, List> getHarvestEvents(){
User user = auth.currentUser;
final uid = user.uid;
Map<DateTime, List> _events = new Map();

db.collection('planting').doc(uid).collection('month')
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/farm/statistics/utils/getHarvestingInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, String> _keys;
Map<String, int> _keys2;

Map<int, List> getHarvesting() {
User user = auth.currentUser;
final uid = user.uid;

Map<int, List> _harvesting = new Map();
_keys = new Map();
_keys2 = new Map();
Expand Down
59 changes: 37 additions & 22 deletions lib/ui/farm/weather/weatherHome.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -28,28 +29,35 @@ class _WeatherHomeState extends State<WeatherHome> {
return Consumer<ForecastViewModel>(
builder: (context, weatherViewModel, child) => Container(
height: 225,
child: ListView(
children: <Widget>[
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: <Widget>[
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() {
Expand All @@ -68,6 +76,13 @@ class _WeatherHomeState extends State<WeatherHome> {
]);
}

Future<void> refreshWeather(
ForecastViewModel weatherVM, BuildContext context) {
// get the current city
String city = Provider.of<CityEntryViewModel>(context, listen: false).city;
return weatherVM.getLatestWeather(city);
}

GradientContainer _buildGradientContainer(
WeatherCondition condition, bool isDayTime, Widget child) {
GradientContainer container;
Expand Down

0 comments on commit 57ab495

Please sign in to comment.