Skip to content

Commit

Permalink
renamed dashboard_grid to tab_grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold872 committed Dec 11, 2023
1 parent 1fd40af commit 4a8667e
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 87 deletions.
34 changes: 17 additions & 17 deletions lib/pages/dashboard_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import 'package:elastic_dashboard/services/settings.dart';
import 'package:elastic_dashboard/services/shuffleboard_nt_listener.dart';
import 'package:elastic_dashboard/services/update_checker.dart';
import 'package:elastic_dashboard/widgets/custom_appbar.dart';
import 'package:elastic_dashboard/widgets/dashboard_grid.dart';
import 'package:elastic_dashboard/widgets/dialog_widgets/layout_drag_tile.dart';
import 'package:elastic_dashboard/widgets/draggable_containers/draggable_layout_container.dart';
import 'package:elastic_dashboard/widgets/draggable_containers/draggable_nt4_widget_container.dart';
import 'package:elastic_dashboard/widgets/draggable_dialog.dart';
import 'package:elastic_dashboard/widgets/editable_tab_bar.dart';
import 'package:elastic_dashboard/widgets/network_tree/networktables_tree.dart';
import 'package:elastic_dashboard/widgets/settings_dialog.dart';
import 'package:elastic_dashboard/widgets/tab_grid.dart';

class DashboardPage extends StatefulWidget {
final SharedPreferences preferences;
Expand All @@ -52,7 +52,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
late final SharedPreferences _preferences;
late final UpdateChecker updateChecker;

final List<DashboardGrid> grids = [];
final List<TabGrid> grids = [];

final List<TabData> tabData = [];

Expand Down Expand Up @@ -103,15 +103,15 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {

nt4Connection.addConnectedListener(() {
setState(() {
for (DashboardGrid grid in grids) {
for (TabGrid grid in grids) {
grid.onNTConnect();
}
});
});

nt4Connection.addDisconnectedListener(() {
setState(() {
for (DashboardGrid grid in grids) {
for (TabGrid grid in grids) {
grid.onNTDisconnect();
}
});
Expand Down Expand Up @@ -155,7 +155,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {

if (!tabNamesList.contains(tabName)) {
tabData.add(TabData(name: tabName));
grids.add(DashboardGrid(
grids.add(TabGrid(
key: GlobalKey(),
onAddWidgetPressed: displayAddWidgetDialog,
));
Expand Down Expand Up @@ -211,7 +211,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {

for (int i = 0; i < tabData.length; i++) {
TabData data = tabData[i];
DashboardGrid grid = grids[i];
TabGrid grid = grids[i];

gridData.add({
'name': data.name,
Expand Down Expand Up @@ -485,7 +485,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
tabData.add(TabData(name: data['name']));

grids.add(
DashboardGrid.fromJson(
TabGrid.fromJson(
key: GlobalKey(),
jsonData: data['grid_layout'],
onAddWidgetPressed: displayAddWidgetDialog,
Expand All @@ -511,11 +511,11 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
]);

grids.addAll([
DashboardGrid(
TabGrid(
key: GlobalKey(),
onAddWidgetPressed: displayAddWidgetDialog,
),
DashboardGrid(
TabGrid(
key: GlobalKey(),
onAddWidgetPressed: displayAddWidgetDialog,
),
Expand Down Expand Up @@ -657,7 +657,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {

tabData.add(TabData(name: newTabName));
grids.add(
DashboardGrid(
TabGrid(
key: GlobalKey(),
onAddWidgetPressed: displayAddWidgetDialog,
),
Expand Down Expand Up @@ -861,7 +861,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
setState(() {
Settings.cornerRadius = newRadius;

for (DashboardGrid grid in grids) {
for (TabGrid grid in grids) {
grid.refreshAllContainers();
}
});
Expand Down Expand Up @@ -1006,8 +1006,8 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
tabData[currentTabIndex - 1] = tabData[currentTabIndex];
tabData[currentTabIndex] = tempData;

// Swap the dashboard grids
DashboardGrid tempGrid = grids[currentTabIndex - 1];
// Swap the tab grids
TabGrid tempGrid = grids[currentTabIndex - 1];
grids[currentTabIndex - 1] = grids[currentTabIndex];
grids[currentTabIndex] = tempGrid;

Expand All @@ -1030,8 +1030,8 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
tabData[currentTabIndex + 1] = tabData[currentTabIndex];
tabData[currentTabIndex] = tempData;

// Swap the dashboard grids
DashboardGrid tempGrid = grids[currentTabIndex + 1];
// Swap the tab grids
TabGrid tempGrid = grids[currentTabIndex + 1];
grids[currentTabIndex + 1] = grids[currentTabIndex];
grids[currentTabIndex] = tempGrid;

Expand Down Expand Up @@ -1211,7 +1211,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
onTabCreate: (tab) {
setState(() {
tabData.add(tab);
grids.add(DashboardGrid(
grids.add(TabGrid(
key: GlobalKey(),
onAddWidgetPressed: displayAddWidgetDialog,
));
Expand Down Expand Up @@ -1324,7 +1324,7 @@ class _DashboardPageState extends State<DashboardPage> with WindowListener {
}

class AddWidgetDialog extends StatelessWidget {
final DashboardGrid Function() grid;
final TabGrid Function() grid;
final bool visible;

final Function(Offset globalPosition, DraggableNT4WidgetContainer widget)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ abstract class DraggableLayoutContainer extends DraggableWidgetContainer {

DraggableLayoutContainer({
super.key,
required super.dashboardGrid,
required super.tabGrid,
required super.title,
required super.initialPosition,
super.enabled = false,
Expand All @@ -27,7 +27,7 @@ abstract class DraggableLayoutContainer extends DraggableWidgetContainer {

DraggableLayoutContainer.fromJson({
super.key,
required super.dashboardGrid,
required super.tabGrid,
required super.jsonData,
required this.nt4ContainerBuilder,
super.enabled = false,
Expand Down
19 changes: 9 additions & 10 deletions lib/widgets/draggable_containers/draggable_list_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DraggableListLayout extends DraggableLayoutContainer {

DraggableListLayout({
super.key,
required super.dashboardGrid,
required super.tabGrid,
required super.title,
required super.initialPosition,
super.enabled = false,
Expand All @@ -44,7 +44,7 @@ class DraggableListLayout extends DraggableLayoutContainer {

DraggableListLayout.fromJson({
super.key,
required super.dashboardGrid,
required super.tabGrid,
required super.jsonData,
required super.nt4ContainerBuilder,
super.enabled = false,
Expand Down Expand Up @@ -114,8 +114,7 @@ class DraggableListLayout extends DraggableLayoutContainer {
padding: EdgeInsets.zero,
child: ExpansionTile(
title: Text(container.title ?? ''),
subtitle: Text(
container.child.type ?? 'NT4Widget'),
subtitle: Text(container.child.type),
controlAffinity:
ListTileControlAffinity.leading,
trailing: IconButton(
Expand Down Expand Up @@ -256,7 +255,7 @@ class DraggableListLayout extends DraggableLayoutContainer {
for (Map<String, dynamic> childData in jsonData['children']) {
children.add(nt4ContainerBuilder?.call(childData) ??
DraggableNT4WidgetContainer.fromJson(
dashboardGrid: dashboardGrid,
tabGrid: tabGrid,
jsonData: childData,
onJsonLoadingWarning: onJsonLoadingWarning,
));
Expand Down Expand Up @@ -456,7 +455,7 @@ class DraggableListLayout extends DraggableLayoutContainer {
Offset location = details.globalPosition -
Offset(widget.displayRect.width, widget.displayRect.height) / 2;

dashboardGrid.layoutDragOutUpdate(widget, location);
tabGrid.layoutDragOutUpdate(widget, location);
},
onPanEnd: (details) {
Future(() => model?.setDraggable(true));
Expand All @@ -470,14 +469,14 @@ class DraggableListLayout extends DraggableLayoutContainer {
widget.displayRect.height,
);

if ((dashboardGrid.isValidLocation(previewLocation) ||
dashboardGrid
if ((tabGrid.isValidLocation(previewLocation) ||
tabGrid
.isValidLayoutLocation(widget.cursorGlobalLocation)) &&
dashboardGrid.isDraggingInContainer()) {
tabGrid.isDraggingInContainer()) {
children.remove(widget);
}

dashboardGrid.layoutDragOutEnd(widget);
tabGrid.layoutDragOutEnd(widget);
},
onPanCancel: () {
Future(() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DraggableNT4WidgetContainer extends DraggableWidgetContainer {

DraggableNT4WidgetContainer({
super.key,
required super.dashboardGrid,
required super.tabGrid,
required super.title,
required super.initialPosition,
required this.child,
Expand All @@ -32,7 +32,7 @@ class DraggableNT4WidgetContainer extends DraggableWidgetContainer {

DraggableNT4WidgetContainer.fromJson({
super.key,
required super.dashboardGrid,
required super.tabGrid,
required super.jsonData,
super.enabled = false,
super.onUpdate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import 'package:flutter_box_transform/flutter_box_transform.dart';
import 'package:provider/provider.dart';

import 'package:elastic_dashboard/services/settings.dart';
import 'package:elastic_dashboard/widgets/dashboard_grid.dart';
import 'package:elastic_dashboard/widgets/dialog_widgets/dialog_text_input.dart';
import 'package:elastic_dashboard/widgets/tab_grid.dart';

class WidgetContainerModel extends ChangeNotifier {
bool draggable = true;
Expand Down Expand Up @@ -36,7 +36,7 @@ class WidgetContainerModel extends ChangeNotifier {
}

class DraggableWidgetContainer extends StatelessWidget {
final DashboardGrid dashboardGrid;
final TabGrid tabGrid;

String? title;

Expand Down Expand Up @@ -77,7 +77,7 @@ class DraggableWidgetContainer extends StatelessWidget {

DraggableWidgetContainer({
super.key,
required this.dashboardGrid,
required this.tabGrid,
required this.title,
required Rect initialPosition,
this.enabled = false,
Expand All @@ -97,7 +97,7 @@ class DraggableWidgetContainer extends StatelessWidget {

DraggableWidgetContainer.fromJson({
super.key,
required this.dashboardGrid,
required this.tabGrid,
required Map<String, dynamic> jsonData,
this.enabled = false,
this.onUpdate,
Expand Down
10 changes: 5 additions & 5 deletions lib/widgets/editable_tab_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import 'package:provider/provider.dart';
import 'package:transitioned_indexed_stack/transitioned_indexed_stack.dart';

import 'package:elastic_dashboard/services/settings.dart';
import 'package:elastic_dashboard/widgets/dashboard_grid.dart';
import 'package:elastic_dashboard/widgets/dialog_widgets/dialog_text_input.dart';
import 'package:elastic_dashboard/widgets/tab_grid.dart';

class TabData {
String name;
Expand All @@ -16,7 +16,7 @@ class TabData {
}

class EditableTabBar extends StatelessWidget {
final List<DashboardGrid> tabViews;
final List<TabGrid> tabViews;
final List<TabData> tabData;

final Function(TabData tab) onTabCreate;
Expand Down Expand Up @@ -246,7 +246,7 @@ class EditableTabBar extends StatelessWidget {
),
),
),
// Dashboard grid area
// Tab grid area
Flexible(
child: Stack(
children: [
Expand All @@ -265,9 +265,9 @@ class EditableTabBar extends StatelessWidget {
endOpacity: 1.0,
index: currentIndex,
children: [
for (DashboardGrid grid in tabViews)
for (TabGrid grid in tabViews)
ChangeNotifierProvider(
create: (context) => DashboardGridModel(),
create: (context) => TabGridModel(),
child: grid,
),
],
Expand Down
Loading

0 comments on commit 4a8667e

Please sign in to comment.