Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the share package instead #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/screens/GC_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ class _GroundCoverResultState extends State<GroundCoverResult> {
TaxonomyTerm percentUnit = TaxonomyTerm(tid: 15, name: "%", description: "percentage", parent: [], parents_all: []);
TaxonomyTerm cmUnit = TaxonomyTerm(tid: 18, name: "cm", description: "Center meters", parent: [], parents_all: []);
TaxonomyTerm countUnit = TaxonomyTerm(tid: 69, name: "count", description: "Number of items", parent: [], parents_all: []);
TaxonomyTerm mUnit = TaxonomyTerm(tid: 99, name: "m", description: "Meters", parent: [], parents_all: []);

List<Quantity> selectedQuanties = [
//Location stuff
Quantity(measure: "value", value: pos.altitude, units: mUnit, label: "altitude"),
Quantity(measure: "value", value: pos.accuracy, units: mUnit, label: "accuracy"),
// percentages
Quantity(measure: "value", value: coverPercentage, units: percentUnit, label: "Cover Percentage"),
Quantity(measure: "value", value: weedsRatio, units: percentUnit, label: "Weed Ratio"),
Expand Down Expand Up @@ -507,7 +511,7 @@ class _GroundCoverTileState extends State<GroundCoverTile> {
return SampleListTile(
sampleLog: gcLog,
color: _getColor(quantityMap["Cover Percentage"].toInt()),
excludeList: ignoreSpecies,
excludeList: ignoreSpecies + ["accuracy", "altitude"],
boxname: GC_LOGS,
);
},
Expand Down
5 changes: 4 additions & 1 deletion lib/screens/sample_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ class _SampleListState extends State<SampleList> {

TaxonomyTerm percentUnit = TaxonomyTerm(tid: 15, name: "%", description: "percentage", parent: [], parents_all: []);
TaxonomyTerm cmUnit = TaxonomyTerm(tid: 18, name: "cm", description: "Center meters", parent: [], parents_all: []);
TaxonomyTerm mUnit = TaxonomyTerm(tid: 99, name: "m", description: "Meters", parent: [], parents_all: []);

List<Quantity> selectedQuanties = [
Quantity(measure: "value", value: pos.altitude, units: mUnit, label: "altitude"),
Quantity(measure: "value", value: pos.accuracy, units: mUnit, label: "accuracy"),
Quantity(measure: "value", value: selectedTexture.sand.toDouble(), units: percentUnit, label: "sand"),
Quantity(measure: "value", value: selectedTexture.silt.toDouble(), units: percentUnit, label: "silt"),
Quantity(measure: "value", value: selectedTexture.clay.toDouble(), units: percentUnit, label: "clay"),
Expand Down Expand Up @@ -452,7 +455,7 @@ class _TextureListState extends State<TextureList> {
return SampleListTile(
sampleLog: tLog,
color: getColor(quantityMap["sand"].toInt(), quantityMap["silt"].toInt(), quantityMap["clay"].toInt()),
excludeList: ["sand", "silt", "clay"],
excludeList: ["sand", "silt", "clay", "accuracy", "altitude"],
boxname: "texture_logs",
);
},
Expand Down
38 changes: 7 additions & 31 deletions lib/services/send_email.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:csv/csv.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:async';
import 'dart:io';
import 'package:flutter_mailer/flutter_mailer.dart';
import 'package:share/share.dart';
import 'package:soil_mate/models/log.dart';


Expand All @@ -29,36 +29,8 @@ Future<String> writeCSV(String csvString) async {

Future<void> createEmailWithCSV(String csvContents, List<String> images) async {
String path = await writeCSV(csvContents);
Share.shareFiles([path] + images, text: 'See attached the samples', subject: 'Soil LogR samples');

final MailOptions mailOptions = MailOptions(
body: 'See attached the samples',
subject: 'Soil LogR samples',
// recipients: ['example@example.com'],
// isHTML: true,
// bccRecipients: ['other@example.com'],
// ccRecipients: ['third@example.com'],
attachments: [path] + images,
);

final MailerResponse response = await FlutterMailer.send(mailOptions);
print(response);

// switch (response) {
// case MailerResponse.saved: /// ios only
// platformResponse = 'mail was saved to draft';
// break;
// case MailerResponse.sent: /// ios only
// platformResponse = 'mail was sent';
// break;
// case MailerResponse.cancelled: /// ios only
// platformResponse = 'mail was cancelled';
// break;
// case MailerResponse.android:
// platformResponse = 'intent was successful';
// break;
// default:
// platformResponse = 'unknown';
// break;
}


Expand Down Expand Up @@ -87,7 +59,11 @@ void sendEmail(List<Log> logs){
l.images[0].split("/").last
];

attachImages.add(l.images[0]);
if (l.images[0].split("/").last != "placeholder.png"){
attachImages.add(l.images[0]);

}



l.quantity.forEach((q) {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.3.01+11.3
version: 0.3.5+15

environment:
sdk: ">=2.7.0 <3.0.0"
Expand All @@ -29,7 +29,7 @@ dependencies:
hive: ^2.0.0
path_provider: ^2.0.0
hive_flutter: ^1.0.0
flutter_mailer: ^1.0.1
share: ^2.0.1
csv: ^4.1.0
url_launcher: ^5.7.10
geolocator: ^6.1.14
Expand Down