Finished export feature!

This commit is contained in:
Raktbastr 2025-02-15 21:39:03 -06:00
parent 9846fffe64
commit 219e668e36
10 changed files with 362 additions and 22 deletions

View file

@ -1,5 +1,6 @@
#Sun Feb 09 20:00:28 EST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip

View file

@ -2,6 +2,10 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UIFileSharingEnabled</key>
<true/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>

View file

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:to_csv/to_csv.dart' as exportCSV;
void getData(String apiKey, String eventCode, Function(List<String>, List<String>) callback) async {
final response = await http.get(
@ -36,7 +37,6 @@ class TeamPicker extends StatefulWidget {
_TeamPickerState createState() => _TeamPickerState();
}
class NotesPage extends StatefulWidget {
final String teamCode;
final String eventCode;
@ -59,9 +59,10 @@ class NotesPage extends StatefulWidget {
}
class _NotesPageState extends State<NotesPage> {
final TextEditingController _controller1 = TextEditingController();
final TextEditingController _checkboxes = TextEditingController();
final TextEditingController _controller2 = TextEditingController();
final TextEditingController _controller3 = TextEditingController();
final TextEditingController _switchvalue = TextEditingController();
double _slidervalue = 0.0;
@override
void initState() {
@ -72,17 +73,19 @@ class _NotesPageState extends State<NotesPage> {
_loadNotes() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
_controller1.text = prefs.getString('${widget.teamCode}_${widget.eventCode}_note1') ?? '';
_checkboxes.text = prefs.getString('${widget.teamCode}_${widget.eventCode}_note1') ?? '';
_controller2.text = prefs.getString('${widget.teamCode}_${widget.eventCode}_note2') ?? '';
_controller3.text = prefs.getString('${widget.teamCode}_${widget.eventCode}_note3') ?? '';
_switchvalue.text = prefs.getString('${widget.teamCode}_${widget.eventCode}_note3') ?? '';
_slidervalue = double.tryParse(prefs.getString('${widget.teamCode}_${widget.eventCode}_note4') ?? '0.0') ?? 0.0;
});
}
_saveNotes() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setString('${widget.teamCode}_${widget.eventCode}_note1', _controller1.text);
await prefs.setString('${widget.teamCode}_${widget.eventCode}_note1', _checkboxes.text);
await prefs.setString('${widget.teamCode}_${widget.eventCode}_note2', _controller2.text);
await prefs.setString('${widget.teamCode}_${widget.eventCode}_note3', _controller3.text);
await prefs.setString('${widget.teamCode}_${widget.eventCode}_note3', _switchvalue.text);
await prefs.setString('${widget.teamCode}_${widget.eventCode}_note4', _slidervalue.toString());
}
@override
@ -100,18 +103,91 @@ class _NotesPageState extends State<NotesPage> {
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
TextField(
controller: _controller1,
decoration: InputDecoration(labelText: 'Note 1'),
children: [
Text('Bot Starting Position', style: TextStyle(fontSize: 20)),
CheckboxListTile(
title: Text('Left'),
value: _checkboxes.text.contains('Left'),
onChanged: (bool? value) {
setState(() {
if (value == true) {
_checkboxes.text += 'Left ';
} else {
_checkboxes.text = _checkboxes.text.replaceAll('Left ', '');
}
});
},
),
CheckboxListTile(
title: Text('Mid'),
value: _checkboxes.text.contains('Mid'),
onChanged: (bool? value) {
setState(() {
if (value == true) {
_checkboxes.text += 'Mid ';
} else {
_checkboxes.text = _checkboxes.text.replaceAll('Mid ', '');
}
});
},
),
CheckboxListTile(
title: Text('Right'),
value: _checkboxes.text.contains('Right'),
onChanged: (bool? value) {
setState(() {
if (value == true) {
_checkboxes.text += 'Right ';
} else {
_checkboxes.text = _checkboxes.text.replaceAll('Right ', '');
}
});
},
),
TextField(
controller: _controller2,
decoration: InputDecoration(labelText: 'Note 2'),
decoration: InputDecoration(labelText: 'Auton Rundown'),
maxLines: null,
keyboardType: TextInputType.multiline,
),
TextField(
controller: _controller3,
decoration: InputDecoration(labelText: 'Note 3'),
CheckboxListTile(
title: Text('Can Score Alge'),
value: _switchvalue.text.contains('Can Score Alge'),
onChanged: (bool? value) {
setState(() {
if (value == true) {
_switchvalue.text = 'Yes ';
} else {
_switchvalue.text = '';
}
});
},
),
CheckboxListTile(
title: Text('Cannot Score Alge'),
value: _switchvalue.text.contains('Cannot Score Alge'),
onChanged: (bool? value) {
setState(() {
if (value == true) {
_switchvalue.text = 'No ';
} else {
_switchvalue.text = '';
}
});
},
),
Text('Coral Level', style: TextStyle(fontSize: 20)),
Slider(
value: _slidervalue,
onChanged: (double value) {
setState(() {
_slidervalue = value;
});
},
min: 0,
max: 3,
divisions: 3,
label: _slidervalue.round().toString(),
),
],
),
@ -121,6 +197,7 @@ class _NotesPageState extends State<NotesPage> {
}
class _TeamPickerState extends State<TeamPicker> {
List<String> teamNames = [];
List<String> teamCodes = [];
@ -135,9 +212,30 @@ class _TeamPickerState extends State<TeamPicker> {
});
}
void _shareEvent() {
// Add your share logic here
print('Share button pressed');
Future<void> makeCSV() async {
List<String> header = [];
header.add('Team Number');
header.add('Bot Position');
header.add('Auton Rundown');
header.add('Can Score Alge');
header.add('Coral Level');
List<List<String>> dataLists = [];
for (int i = 0; i < teamCodes.length; i++) {
List<String> data = [];
data.add(teamCodes[i]);
SharedPreferences prefs = await SharedPreferences.getInstance();
String botPosition = prefs.getString('${teamCodes[i]}_${widget.eventCode}_note1') ?? '';
String autonRundown = prefs.getString('${teamCodes[i]}_${widget.eventCode}_note2') ?? '';
String canScoreAlge = prefs.getString('${teamCodes[i]}_${widget.eventCode}_note3') ?? '';
String coralLevel = prefs.getString('${teamCodes[i]}_${widget.eventCode}_note4') ?? '0.0';
data.add(botPosition);
data.add(autonRundown);
data.add(canScoreAlge);
data.add(coralLevel);
dataLists.add(data);
}
exportCSV.myCSV(header, dataLists, setHeadersInFirstRow: true, emptyRowsConfig: {1: 1}, fileName: '${widget.eventCode}-');
}
@override
@ -150,7 +248,7 @@ class _TeamPickerState extends State<TeamPicker> {
actions: [
IconButton(
icon: Icon(Icons.share),
onPressed: _shareEvent,
onPressed: makeCSV,
),
],
),
@ -176,4 +274,4 @@ class _TeamPickerState extends State<TeamPicker> {
),
);
}
}
}

View file

@ -6,6 +6,14 @@
#include "generated_plugin_registrant.h"
#include <file_saver/file_saver_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) file_saver_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FileSaverPlugin");
file_saver_plugin_register_with_registrar(file_saver_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}

View file

@ -3,6 +3,8 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
file_saver
url_launcher_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View file

@ -5,8 +5,14 @@
import FlutterMacOS
import Foundation
import file_saver
import path_provider_foundation
import share_plus
import shared_preferences_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FileSaverPlugin.register(with: registry.registrar(forPlugin: "FileSaverPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
}

View file

@ -41,6 +41,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.0"
charcode:
dependency: transitive
description:
name: charcode
sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8a
url: "https://pub.dev"
source: hosted
version: "1.4.0"
checked_yaml:
dependency: transitive
description:
@ -73,6 +81,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.19.0"
cross_file:
dependency: transitive
description:
name: cross_file
sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
url: "https://pub.dev"
source: hosted
version: "0.3.4+2"
crypto:
dependency: transitive
description:
@ -81,6 +97,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.6"
csslib:
dependency: transitive
description:
name: csslib
sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e"
url: "https://pub.dev"
source: hosted
version: "1.0.2"
csv:
dependency: transitive
description:
name: csv
sha256: c6aa2679b2a18cb57652920f674488d89712efaf4d3fdf2e537215b35fc19d6c
url: "https://pub.dev"
source: hosted
version: "6.0.0"
cupertino_icons:
dependency: "direct main"
description:
@ -89,6 +121,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.8"
dio:
dependency: transitive
description:
name: dio
sha256: "253a18bbd4851fecba42f7343a1df3a9a4c1d31a2c1b37e221086b4fa8c8dbc9"
url: "https://pub.dev"
source: hosted
version: "5.8.0+1"
dio_web_adapter:
dependency: transitive
description:
name: dio_web_adapter
sha256: e485c7a39ff2b384fa1d7e09b4e25f755804de8384358049124830b04fc4f93a
url: "https://pub.dev"
source: hosted
version: "2.1.0"
fake_async:
dependency: transitive
description:
@ -113,6 +161,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "7.0.1"
file_saver:
dependency: transitive
description:
name: file_saver
sha256: "017a127de686af2d2fbbd64afea97052d95f2a0f87d19d25b87e097407bf9c1e"
url: "https://pub.dev"
source: hosted
version: "0.2.14"
fixnum:
dependency: transitive
description:
name: fixnum
sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
url: "https://pub.dev"
source: hosted
version: "1.1.1"
flutter:
dependency: "direct main"
description: flutter
@ -144,6 +208,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
html:
dependency: transitive
description:
name: html
sha256: "1fc58edeaec4307368c60d59b7e15b9d658b57d7f3125098b6294153c75337ec"
url: "https://pub.dev"
source: hosted
version: "0.15.5"
http:
dependency: "direct main"
description:
@ -168,6 +240,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.5.2"
intl:
dependency: transitive
description:
name: intl
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.dev"
source: hosted
version: "0.20.2"
json_annotation:
dependency: transitive
description:
@ -232,6 +312,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.15.0"
mime:
dependency: transitive
description:
name: mime
sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
path:
dependency: transitive
description:
@ -240,6 +328,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.9.0"
path_provider:
dependency: transitive
description:
name: path_provider
sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd"
url: "https://pub.dev"
source: hosted
version: "2.1.5"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: "4adf4fd5423ec60a29506c76581bc05854c55e3a0b72d35bb28d661c9686edf2"
url: "https://pub.dev"
source: hosted
version: "2.2.15"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
url: "https://pub.dev"
source: hosted
version: "2.4.1"
path_provider_linux:
dependency: transitive
description:
@ -296,6 +408,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.1"
share_plus:
dependency: transitive
description:
name: share_plus
sha256: fce43200aa03ea87b91ce4c3ac79f0cecd52e2a7a56c7a4185023c271fbfa6da
url: "https://pub.dev"
source: hosted
version: "10.1.4"
share_plus_platform_interface:
dependency: transitive
description:
name: share_plus_platform_interface
sha256: cc012a23fc2d479854e6c80150696c4a5f5bb62cb89af4de1c505cf78d0a5d0b
url: "https://pub.dev"
source: hosted
version: "5.0.2"
shared_preferences:
dependency: "direct main"
description:
@ -365,6 +493,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
dependency: transitive
description:
@ -405,6 +541,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.3"
to_csv:
dependency: "direct main"
description:
name: to_csv
sha256: "4e8b71c9a700c34e355010e5ec8fec712f6689b4d52944d767ecf2cb2312cf26"
url: "https://pub.dev"
source: hosted
version: "5.0.0"
typed_data:
dependency: transitive
description:
@ -413,6 +557,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.4.0"
universal_html:
dependency: transitive
description:
name: universal_html
sha256: "56536254004e24d9d8cfdb7dbbf09b74cf8df96729f38a2f5c238163e3d58971"
url: "https://pub.dev"
source: hosted
version: "2.2.4"
universal_io:
dependency: transitive
description:
name: universal_io
sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
sha256: "3ba963161bd0fe395917ba881d320b9c4f6dd3c4a233da62ab18a5025c85f1e9"
url: "https://pub.dev"
source: hosted
version: "2.4.0"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77"
url: "https://pub.dev"
source: hosted
version: "3.1.4"
uuid:
dependency: transitive
description:
name: uuid
sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
url: "https://pub.dev"
source: hosted
version: "4.5.1"
vector_math:
dependency: transitive
description:
@ -437,6 +637,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
win32:
dependency: transitive
description:
name: win32
sha256: daf97c9d80197ed7b619040e86c8ab9a9dad285e7671ee7390f9180cc828a51e
url: "https://pub.dev"
source: hosted
version: "5.10.1"
xdg_directories:
dependency: transitive
description:
@ -463,4 +671,4 @@ packages:
version: "3.1.3"
sdks:
dart: ">=3.6.1 <4.0.0"
flutter: ">=3.24.0"
flutter: ">=3.27.0"

View file

@ -38,6 +38,7 @@ dependencies:
flutter_launcher_icons: ^0.14.3
http: ^0.13.4
to_csv: ^5.0.0
dev_dependencies:
flutter_test:

View file

@ -6,6 +6,15 @@
#include "generated_plugin_registrant.h"
#include <file_saver/file_saver_plugin.h>
#include <share_plus/share_plus_windows_plugin_c_api.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
FileSaverPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSaverPlugin"));
SharePlusWindowsPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

View file

@ -3,6 +3,9 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
file_saver
share_plus
url_launcher_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST