Skip to content

Commit

Permalink
Simplified tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 30, 2024
1 parent a656128 commit c4497d4
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 651 deletions.
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import 'package:elastic_dashboard/services/log.dart';
import 'package:elastic_dashboard/services/nt_connection.dart';
import 'package:elastic_dashboard/services/nt_widget_builder.dart';
import 'package:elastic_dashboard/services/settings.dart';
import 'package:elastic_dashboard/services/update_checker.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -217,7 +216,6 @@ class _ElasticState extends State<Elastic> {
ntConnection: widget.ntConnection,
preferences: widget.preferences,
version: widget.version,
updateChecker: UpdateChecker(currentVersion: widget.version),
onColorChanged: (color) => setState(() {
teamColor = color;
widget.preferences.setInt(PrefKeys.teamColor, color.value);
Expand Down
20 changes: 12 additions & 8 deletions lib/pages/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DashboardPage extends StatefulWidget {
final String version;
final NTConnection ntConnection;
final SharedPreferences preferences;
final UpdateChecker updateChecker;
final UpdateChecker? updateChecker;
final ElasticLayoutDownloader? layoutDownloader;
final Function(Color color)? onColorChanged;
final Function(FlexSchemeVariant variant)? onThemeVariantChanged;
Expand All @@ -93,7 +93,7 @@ class DashboardPage extends StatefulWidget {
required this.ntConnection,
required this.preferences,
required this.version,
required this.updateChecker,
this.updateChecker,
this.layoutDownloader,
this.onColorChanged,
this.onThemeVariantChanged,
Expand All @@ -106,6 +106,7 @@ class DashboardPage extends StatefulWidget {
class _DashboardPageState extends State<DashboardPage> with WindowListener {
SharedPreferences get preferences => widget.preferences;
late final RobotNotificationsListener _robotNotificationListener;
late final UpdateChecker _updateChecker;
late final ElasticLayoutDownloader _layoutDownloader;

bool _seenShuffleboardWarning = false;
Expand Down Expand Up @@ -279,11 +280,6 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
apiListener.initializeListeners();
});

if (!isWPILib) {
Future(
() => _checkForUpdates(notifyIfLatest: false, notifyIfError: false));
}

_robotNotificationListener = RobotNotificationsListener(
ntConnection: widget.ntConnection,
onNotification: (title, description, icon, time, width, height) {
Expand Down Expand Up @@ -319,6 +315,14 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {

_layoutDownloader =
widget.layoutDownloader ?? ElasticLayoutDownloader(Client());

_updateChecker =
widget.updateChecker ?? UpdateChecker(currentVersion: widget.version);

if (!isWPILib) {
Future(
() => _checkForUpdates(notifyIfLatest: false, notifyIfError: false));
}
}

@override
Expand Down Expand Up @@ -415,7 +419,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
ButtonThemeData buttonTheme = ButtonTheme.of(context);

UpdateCheckerResponse updateResponse =
await widget.updateChecker.isUpdateAvailable();
await _updateChecker.isUpdateAvailable();

if (mounted) {
setState(() => lastUpdateResponse = updateResponse);
Expand Down
Loading

0 comments on commit c4497d4

Please sign in to comment.