-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
harvesting module done, left statistics module
- Loading branch information
1 parent
5a2056c
commit b5cb3e3
Showing
23 changed files
with
1,198 additions
and
103 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
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){ | ||
var month; | ||
|
||
DateTime harvestDt = obj['harvestDate']; | ||
print(harvestDt.month); | ||
|
||
if(harvestDt.month==1){ | ||
month="January"; | ||
} | ||
else{ | ||
month="February"; | ||
} | ||
|
||
final DateFormat formatter = DateFormat('dd-MM-yyyy'); | ||
final String harvestDate = formatter.format(harvestDt); | ||
|
||
|
||
CollectionReference cr = | ||
db.collection("Harvesting").doc(uid).collection(month); | ||
|
||
Map<String, dynamic> data = { | ||
"name": obj['plantName'], | ||
"noOfPlants": obj['plantNumber'], | ||
"date": obj['plantDate'], | ||
"estimatedHarvest": obj['plantEstimated'], | ||
"month": harvestDt.month, | ||
"year": harvestDt.year, | ||
"day": harvestDt.day, | ||
"week": harvestDt.weekday, | ||
"harvestQuantity": obj['harvestQuantity'], | ||
"harvestDate": harvestDate, | ||
}; | ||
|
||
cr.doc().set(data); | ||
} | ||
|
||
void updatePlanting(int monthInt, String id){ | ||
var month; | ||
|
||
if(monthInt==1){ | ||
month="January"; | ||
} | ||
else{ | ||
month="February"; | ||
} | ||
|
||
CollectionReference cr = | ||
db.collection("Planting").doc(uid).collection(month); | ||
|
||
cr.doc(id).update({ | ||
"harvested": true | ||
}).then((value) => print('success')); | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
import 'package:farmassist/data/farm/repositories/harvest_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'; | ||
|
||
import '../../../app_theme.dart'; | ||
|
||
class DisplayHarvesting extends StatefulWidget { | ||
final String documentID; | ||
final String plantName; | ||
final String plantNo; | ||
final String plantDate; | ||
final double plantEstimate; | ||
final String plantHarvest; | ||
final String plantQuantity; | ||
final int plantMonth; | ||
|
||
DisplayHarvesting({ | ||
this.documentID, | ||
this.plantName, | ||
this.plantNo, | ||
this.plantDate, | ||
this.plantEstimate, | ||
this.plantHarvest, | ||
this.plantMonth, | ||
this.plantQuantity | ||
}); | ||
|
||
@override | ||
_DisplayHarvestingState createState() =>_DisplayHarvestingState( | ||
name:plantName, no:plantNo, date:plantDate, estimate:plantEstimate, harvest: plantHarvest, id: documentID, month: plantMonth, quantity: plantQuantity, | ||
); | ||
} | ||
|
||
class _DisplayHarvestingState extends State<DisplayHarvesting> { | ||
final _formKey = GlobalKey<FormBuilderState>(); | ||
|
||
final String id; | ||
final String name; | ||
final String no; | ||
final String date; | ||
final double estimate; | ||
final String harvest; | ||
final int month; | ||
final String quantity; | ||
|
||
_DisplayHarvestingState({ | ||
this.id, | ||
this.name, | ||
this.no, | ||
this.date, | ||
this.estimate, | ||
this.harvest, | ||
this.month, | ||
this.quantity | ||
}); | ||
|
||
@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 Harvesting Entry", | ||
style: TextStyle( | ||
color: AppTheme.nearlyWhite, | ||
),), | ||
backgroundColor: AppTheme.pastelGreen, | ||
), | ||
body: Container( | ||
padding: EdgeInsets.all(5.0), | ||
child: Column( | ||
children: <Widget>[ | ||
new Expanded( | ||
child: ListView( | ||
padding: EdgeInsets.all(10.0), | ||
children: <Widget>[ | ||
FormBuilder( | ||
key: _formKey, | ||
child: Column( | ||
children: <Widget>[ | ||
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: 'plantDate', | ||
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 (weeks)', | ||
icon: Icon(Icons.timelapse), | ||
), | ||
), | ||
SizedBox(height: 10), | ||
FormBuilderTextField( | ||
name: 'harvestQuantity', | ||
readOnly: true, | ||
initialValue: quantity, | ||
validator: FormBuilderValidators.compose([ | ||
FormBuilderValidators.required(context), | ||
]), | ||
keyboardType: TextInputType.number, | ||
decoration: InputDecoration( | ||
labelText: "Harvest Yield", | ||
icon: Icon(Icons.format_list_numbered), | ||
), | ||
), | ||
SizedBox(height: 10), | ||
FormBuilderTextField( | ||
name: 'harvestDate', | ||
readOnly: true, | ||
initialValue: harvest, | ||
decoration: InputDecoration( | ||
labelText: 'Harvest Date', | ||
icon: Icon(Icons.date_range), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
SizedBox(height: 20), | ||
], | ||
), | ||
) | ||
], | ||
), | ||
) | ||
); | ||
} | ||
} |
Oops, something went wrong.