Skip to content

Commit

Permalink
Merge pull request #51 from FRC2706/dev
Browse files Browse the repository at this point in the history
v1.1.1
  • Loading branch information
jwt2706 authored Mar 16, 2024
2 parents e3ed2e8 + 9f3c353 commit 49fd3aa
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 51 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# MergeData
We mergin' the data fr.

A scouting app developed by FRC Team 2706 Merge Robotics.
Robot scouting app developed by FRC Team 2706 Merge Robotics.
<br>Now featuring... a working Google Sheets integration!!!

## Documentation
we will update this as we work on stuff
Coming soon <sup>TM</sup>

## License
This project is under the Apache 2.0 license, please read the `LICENSE` file for more information.
Expand Down
94 changes: 47 additions & 47 deletions lib/screens/send_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,64 +94,64 @@ class _SendDataState extends State<SendData> {
Future<void> sendDataToGoogleSheets() async {
String message = '';

//try {
final ss = await _gsheets.spreadsheet(_spreadsheetId);
var sheet;
if (widget.isGame) {
sheet = ss.worksheetByTitle(_gameWorksheetName);
} else {
sheet = ss.worksheetByTitle(_pitWorksheetName);
}
try {
final ss = await _gsheets.spreadsheet(_spreadsheetId);
var sheet;
if (widget.isGame) {
sheet = ss.worksheetByTitle(_gameWorksheetName);
} else {
sheet = ss.worksheetByTitle(_pitWorksheetName);
}

if (sheet != null) {
// Check for locally stored games
final prefs = await SharedPreferences.getInstance();
final savedGames = prefs.getStringList('savedGames') ?? [];
if (sheet != null) {
// Check for locally stored games
final prefs = await SharedPreferences.getInstance();
final savedGames = prefs.getStringList('savedGames') ?? [];

if (savedGames.isEmpty && widget.data.isEmpty) {
message =
"Shep couldn\'t find any saved games to send! That means IT'S TIME TO GO SCOUTING SOME MORE!!1!11!";
} else {
if (widget.isGame) {
// Send locally stored games
for (final savedGame in savedGames) {
Map gameData = jsonDecode(savedGame);
var curSheet = ss.worksheetByTitle(_pitWorksheetName);
try {
if (gameData["isGame"] == "y") {
curSheet = ss.worksheetByTitle(_gameWorksheetName);
if (savedGames.isEmpty && widget.data.isEmpty) {
message =
"Shep couldn\'t find any saved games to send! That means IT'S TIME TO GO SCOUTING SOME MORE!!1!11!";
} else {
if (widget.isGame) {
// Send locally stored games
for (final savedGame in savedGames) {
Map gameData = jsonDecode(savedGame);
var curSheet = ss.worksheetByTitle(_pitWorksheetName);
try {
if (gameData["isGame"] == "y") {
curSheet = ss.worksheetByTitle(_gameWorksheetName);
}
} catch (e) {
message = "Invalid Save Data";
}
try {
gameData.remove("isGame");
} catch (e) {}
List<dynamic> values = gameData.values.toList();
final curRes = await curSheet!.values.appendRow(values);
if (curRes) {
message = "Successfully sent saved data!";
}
} catch (e) {
message = "Invalid Save Data";
}
try {
gameData.remove("isGame");
} catch (e) {}
List<dynamic> values = gameData.values.toList();
final curRes = await curSheet!.values.appendRow(values);
if (curRes) {
message = "Successfully sent saved data!";
}
// Clear the saved games after sending them
final a = await prefs.setStringList('savedGames', []);
}
// Clear the saved games after sending them
final a = await prefs.setStringList('savedGames', []);
}

if (widget.data.values.isNotEmpty) {
// Send current game
final values = widget.data.values.toList();
print(values);
final result = await sheet.values.appendRow(values);
if (result) {
message = 'Shep collected the data, thanks scout! o7';
if (widget.data.values.isNotEmpty) {
// Send current game
final values = widget.data.values.toList();
print(values);
final result = await sheet.values.appendRow(values);
if (result) {
message = 'Shep collected the data, thanks scout! o7';
}
}
}
}
}
/*} catch (e) {
} catch (e) {
message = 'Could not send data to sheets!';
print(e);
}*/
}

ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(message)));
Expand Down

0 comments on commit 49fd3aa

Please sign in to comment.