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

Settings rewrite #86

Merged
merged 30 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1db3696
added buttons to refresh field images & open fields folder
DanPeled Aug 19, 2024
9e72cf2
import sort
DanPeled Aug 19, 2024
267264d
Merge branch 'main' into field_files_dialog
DanPeled Aug 27, 2024
19c2946
Merge branch 'main' into field_files_dialog
DanPeled Aug 28, 2024
2038589
moved assets folder dialog to settings
DanPeled Aug 31, 2024
08c13e3
fixed typo (thanks peter)
DanPeled Aug 31, 2024
338d423
added test
DanPeled Aug 31, 2024
2d67a5a
fixed test
DanPeled Aug 31, 2024
e529f25
Merge branch 'main' into field_files_dialog
DanPeled Sep 2, 2024
5c60ce7
Merge branch 'main' into field_files_dialog
DanPeled Sep 7, 2024
0d314bc
Merge branch 'main' into field_files_dialog
DanPeled Sep 25, 2024
f631499
Merge branch 'main' into field_files_dialog
DanPeled Oct 12, 2024
864a4f3
Merge branch 'main' into field_files_dialog
DanPeled Oct 13, 2024
76b9759
Merge branch 'main' into field_files_dialog
DanPeled Nov 17, 2024
d241e53
Merge branch 'main' into field_files_dialog
DanPeled Nov 22, 2024
cd0ea98
Merge branch 'main' into field_files_dialog
DanPeled Dec 9, 2024
bf7c90e
Moved settings to advanced settings, hid by default
DanPeled Dec 9, 2024
a1c184a
Fixed tests :D
DanPeled Dec 9, 2024
4b2ad5a
Merge branch 'main' into field_files_dialog
DanPeled Dec 9, 2024
84d53fb
Moved settings dialog logic to dashboard page
DanPeled Dec 9, 2024
bfd72fb
Mispell fix, style change
DanPeled Dec 9, 2024
9fee9e6
Moved settings dialog into tabs
DanPeled Dec 10, 2024
a5b6274
Restyle and cleanup
Gold872 Dec 10, 2024
bae9f2c
Added padding in tabs
Gold872 Dec 10, 2024
a870816
Fixed unit tests
Gold872 Dec 10, 2024
7382e69
Fix CI issues
Gold872 Dec 10, 2024
8880e8c
Unignore constant identifier names
Gold872 Dec 10, 2024
e4bb73e
Moved team number to network tab
Gold872 Dec 12, 2024
4c3876b
Fixed unit tests
Gold872 Dec 12, 2024
bfe88eb
Removed field resetting
Gold872 Dec 12, 2024
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
8 changes: 8 additions & 0 deletions lib/pages/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:elegant_notification/elegant_notification.dart';
import 'package:elegant_notification/resources/stacked_options.dart';
import 'package:file_selector/file_selector.dart';
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
import 'package:path/path.dart' as path;
import 'package:popover/popover.dart';
import 'package:screen_retriever/screen_retriever.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand Down Expand Up @@ -1173,6 +1174,13 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
},
onColorChanged: widget.onColorChanged,
onThemeVariantChanged: widget.onThemeVariantChanged,
onOpenAssetsFolderPressed: () async {
Uri uri = Uri.file(
'${path.dirname(Platform.resolvedExecutable)}/data/flutter_assets/assets/');
if (await canLaunchUrl(uri)) {
launchUrl(uri);
}
},
),
);
}
Expand Down
22 changes: 5 additions & 17 deletions lib/services/nt_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ class NTConnection {

final ValueNotifier<bool> _ntConnected = ValueNotifier(false);
ValueNotifier<bool> get ntConnected => _ntConnected;
bool _dsConnected = false;

bool get isNT4Connected => _ntConnected.value;

bool get isDSConnected => _dsConnected;
final ValueNotifier<bool> _dsConnected = ValueNotifier(false);
bool get isDSConnected => _dsConnected.value;
ValueNotifier<bool> get dsConnected => _dsConnected;
DSInteropClient get dsClient => _dsClient;

int get serverTime => _ntClient.getServerTimeUS();
Expand Down Expand Up @@ -70,8 +71,8 @@ class NTConnection {
_dsClient = DSInteropClient(
onNewIPAnnounced: onIPAnnounced,
onDriverStationDockChanged: onDriverStationDockChanged,
onConnect: () => _dsConnected = true,
onDisconnect: () => _dsConnected = false,
onConnect: () => _dsConnected.value = true,
onDisconnect: () => _dsConnected.value = false,
);
}

Expand Down Expand Up @@ -132,19 +133,6 @@ class NTConnection {
}
}

Stream<bool> dsConnectionStatus() async* {
yield _dsConnected;
bool lastYielded = _dsConnected;

while (true) {
if (_dsConnected != lastYielded) {
yield _dsConnected;
lastYielded = _dsConnected;
}
await Future.delayed(const Duration(seconds: 1));
}
}

Map<int, NT4Topic> announcedTopics() {
return _ntClient.announcedTopics;
}
Expand Down
9 changes: 6 additions & 3 deletions lib/services/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ class Defaults {
static IPAddressMode ipAddressMode = IPAddressMode.driverStation;

static FlexSchemeVariant themeVariant = FlexSchemeVariant.material3Legacy;
static const String defaultVariantName = 'Material-3 Legacy (Default)';

static const String defaultVariantName = 'Material-3 Legacy (Default)';
static const String ipAddress = '127.0.0.1';

static const int teamNumber = 9999;
static const int gridSize = 128;

static const bool layoutLocked = false;
static const double cornerRadius = 15.0;
static const bool showGrid = true;
static const bool autoResizeToDS = false;
static const bool showOpenAssetsFolderWarning = true;

static const double cornerRadius = 15.0;
static const double defaultPeriod = 0.06;
static const double defaultGraphPeriod = 0.033;
}
Expand All @@ -46,6 +49,6 @@ class PrefKeys {
static String rememberWindowPosition = 'remember_window_position';
static String defaultPeriod = 'default_period';
static String defaultGraphPeriod = 'default_graph_period';

static String showOpenAssetsFolderWarning = "show_assets_folder_warning";
static String windowPosition = 'window_position';
}
4 changes: 3 additions & 1 deletion lib/widgets/dialog_widgets/dialog_color_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ class DialogColorPicker extends StatefulWidget {
final String label;
final Color initialColor;
final Color? defaultColor;
final MainAxisSize rowSize;

const DialogColorPicker({
super.key,
required this.onColorPicked,
required this.label,
required this.initialColor,
this.rowSize = MainAxisSize.min,
this.defaultColor,
});

Expand All @@ -39,7 +41,7 @@ class _DialogColorPickerState extends State<DialogColorPicker> {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
mainAxisSize: widget.rowSize,
children: [
Text(widget.label),
const SizedBox(width: 5),
Expand Down
21 changes: 0 additions & 21 deletions lib/widgets/nt_widgets/multi-topic/combo_box_chooser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ComboBoxChooserModel extends MultiTopicNTWidgetModel {
StringChooserData? previousData;

NT4Topic? _selectedTopic;
NT4Topic? _activeTopic;

bool _sortOptions = false;

Expand Down Expand Up @@ -124,26 +123,6 @@ class ComboBoxChooserModel extends MultiTopicNTWidgetModel {

ntConnection.updateDataFromTopic(_selectedTopic!, selected);
}

void _publishActiveValue(String? active) {
if (active == null || !ntConnection.isNT4Connected) {
return;
}

bool publishTopic = _activeTopic == null;

_activeTopic ??= ntConnection.getTopicFromName(activeTopicName);

if (_activeTopic == null) {
return;
}

if (publishTopic) {
ntConnection.publishTopic(_activeTopic!);
}

ntConnection.updateDataFromTopic(_activeTopic!, active);
}
}

class ComboBoxChooser extends NTWidget {
Expand Down
21 changes: 0 additions & 21 deletions lib/widgets/nt_widgets/multi-topic/split_button_chooser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class SplitButtonChooserModel extends MultiTopicNTWidgetModel {
StringChooserData? previousData;

NT4Topic? _selectedTopic;
NT4Topic? _activeTopic;

SplitButtonChooserModel({
required super.ntConnection,
Expand Down Expand Up @@ -78,26 +77,6 @@ class SplitButtonChooserModel extends MultiTopicNTWidgetModel {

ntConnection.updateDataFromTopic(_selectedTopic!, selected);
}

void _publishActiveValue(String? active) {
if (active == null || !ntConnection.isNT4Connected) {
return;
}

bool publishTopic = _activeTopic == null;

_activeTopic ??= ntConnection.getTopicFromName(activeTopicName);

if (_activeTopic == null) {
return;
}

if (publishTopic) {
ntConnection.publishTopic(_activeTopic!);
}

ntConnection.updateDataFromTopic(_activeTopic!, active);
}
}

class SplitButtonChooser extends NTWidget {
Expand Down
Loading