Skip to content

Commit

Permalink
Adding support for saving & loading pages with proportions (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlklink authored May 14, 2024
2 parents 7f41e66 + 2e96d8f commit 738bf36
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 45 deletions.
18 changes: 17 additions & 1 deletion lib/entities/parameter_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,32 @@ class ParameterPage {
return CommentEntry(from["text"]!, id: from["entryid"]);

case "Parameter":
return ParameterEntry(from["text"], id: from["entryid"]);
return _hydrateParameterEntry(from: from);

case "Expression":
return CommentEntry(from["text"]!, id: from["entryid"]);

case "Mult":
return MultEntry(
numberOfEntries: int.parse(from["numberOfEntries"]!),
description: from["description"]);

default:
throw UnimplementedError("Unexpected PageEntry type");
}
}

PageEntry _hydrateParameterEntry({required Map<String, dynamic> from}) {
final proportion = double.parse(from["proportion"]);

if (proportion == 1.0) {
return ParameterEntry("${from["text"]}", id: from["entryid"]);
} else {
return ParameterEntry("${from["text"]}",
id: from["entryid"], proportion: proportion);
}
}

List<_SubSystem> _pageData = _initialPageStructure;

List<_SubSystem> _undoPageData = _initialPageStructure;
Expand Down
28 changes: 27 additions & 1 deletion lib/services/parameter_page/mock_parameter_page_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ class MockParameterPageService extends ParameterPageService {
newEntries.add({
"pageid": id,
"entryid": DateTime.now().microsecondsSinceEpoch.toString(),
"proportion": "${entry.proportion}",
"position": "$position",
"text": entry.entryText(),
"type": entry is CommentEntry ? "Comment" : "Parameter"
"type": entry.typeAsString,
"numberOfEntries":
entry is MultEntry ? "${entry.numberOfEntries}" : "0",
"description": entry is MultEntry ? entry.description : ""
});
position += 1;
}
Expand Down Expand Up @@ -160,20 +164,23 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "1",
"pageid": "1",
"position": "0",
"proportion": "1.0",
"text": "this is entry to east tower",
"type": "Comment"
},
{
"entryid": "2",
"pageid": "1",
"position": "1",
"proportion": "1.0",
"text": "graph route",
"type": "Comment"
},
{
"entryid": "3",
"pageid": "1",
"position": "2",
"proportion": "1.0",
"text": "graph route",
"type": "Comment"
}
Expand Down Expand Up @@ -201,27 +208,31 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "4",
"pageid": "3",
"position": "0",
"proportion": "1.0",
"text": "this is comment #1",
"type": "Comment"
},
{
"entryid": "5",
"pageid": "3",
"position": "1",
"proportion": "1.0",
"text": "I:BEAM",
"type": "Parameter"
},
{
"entryid": "6",
"pageid": "3",
"position": "2",
"proportion": "1.0",
"text": "R:BEAM",
"type": "Parameter"
},
{
"entryid": "5",
"pageid": "3",
"position": "1",
"proportion": "1.0",
"text": "this is comment #2",
"type": "Comment"
}
Expand All @@ -235,6 +246,7 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "7",
"pageid": "3",
"position": "1",
"proportion": "1.0",
"text": "this is comment #3",
"type": "Comment"
}
Expand All @@ -247,6 +259,7 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "17",
"pageid": "3",
"position": "1",
"proportion": "1.0",
"text": "this sub-page has no title",
"type": "Comment"
}
Expand All @@ -265,6 +278,7 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "16",
"pageid": "3",
"position": "0",
"proportion": "1.0",
"text": "This is Tab 2",
"type": "Comment"
}
Expand All @@ -288,6 +302,7 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "4",
"pageid": "3",
"position": "0",
"proportion": "1.0",
"text": "this is Sub-system 2 / Tab 1 / Sub-page One",
"type": "Comment"
}
Expand Down Expand Up @@ -315,69 +330,79 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "6",
"pageid": "4",
"position": "0",
"proportion": "1.0",
"text": "M:OUTTMP@e,02",
"type": "Parameter"
},
{
"entryid": "7",
"pageid": "4",
"position": "1",
"proportion": "1.0",
"text": "This is our first comment!",
"type": "Comment"
},
{
"entryid": "8",
"pageid": "4",
"position": "2",
"proportion": "1.0",
"text": "G:AMANDA",
"type": "Parameter"
},
{
"entryid": "9",
"pageid": "4",
"position": "3",
"proportion": "1.0",
"text": "Z:NO_ALARMS",
"type": "Parameter"
},
{
"entryid": "10",
"pageid": "4",
"position": "4",
"proportion": "1.0",
"text": "PIP2:SSR1:SUBSYSTEMA:SUBSUBSYSTEM:TEMPERATURE",
"type": "Parameter"
},
{
"entryid": "11",
"pageid": "4",
"position": "5",
"proportion": "1.0",
"text": "PIP2:SSR1:SUBSYSTEMA:SUBSUBSYSTEM:HUMIDITY",
"type": "Parameter"
},
{
"entryid": "12",
"pageid": "4",
"position": "6",
"proportion": "1.0",
"text": "Z:BTE200_TEMP",
"type": "Parameter"
},
{
"entryid": "13",
"pageid": "4",
"position": "7",
"proportion": "1.0",
"text": "Z:INC_SETTING",
"type": "Parameter"
},
{
"entryid": "14",
"pageid": "4",
"position": "8",
"proportion": "1.0",
"text": "Z:NO_SET",
"type": "Parameter"
},
{
"entryid": "15",
"pageid": "4",
"position": "9",
"proportion": "1.0",
"text": "Z:NO_READ",
"type": "Parameter"
}
Expand Down Expand Up @@ -405,6 +430,7 @@ class MockParameterPageService extends ParameterPageService {
"entryid": "17",
"pageid": "5",
"position": "1",
"proportion": "1.0",
"text": "This is Tab One",
"type": "Comment"
}
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/display_settings_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class _DisplaySettingsState extends State<DisplaySettingsWidget> {
SettingsThemeData _themeData(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return SettingsThemeData(
settingsListBackground: colorScheme.background,
titleTextColor: colorScheme.onBackground,
settingsListBackground: colorScheme.surface,
titleTextColor: colorScheme.onSurface,
settingsTileTextColor: colorScheme.primary,
dividerColor: colorScheme.background,
dividerColor: colorScheme.surface,
tileDescriptionTextColor: colorScheme.secondary,
settingsSectionBackground: colorScheme.surface,
leadingIconsColor: colorScheme.onSurface);
Expand Down
3 changes: 1 addition & 2 deletions lib/widgets/parameter_alarm_status_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class ParameterAlarmStatusWidget extends StatelessWidget {
? "By-pass Alarm"
: "Not Alarming (enable settings to by-pass)",
child: Icon(Icons.notifications,
size: iconSize,
color: Theme.of(context).colorScheme.background));
size: iconSize, color: Theme.of(context).colorScheme.surface));
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/parameter_beam_inhibit_status_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ParameterBeamInhibitStatusWidget extends StatelessWidget {
return Tooltip(
message: "Does not inhibit beam",
child: Icon(Icons.pan_tool,
size: 16, color: Theme.of(context).colorScheme.background));
size: 16, color: Theme.of(context).colorScheme.surface));

case BeamInhibitState.willInhibit:
return Tooltip(
Expand Down
32 changes: 16 additions & 16 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -476,26 +476,26 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.dev"
source: hosted
version: "10.0.0"
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
version: "3.0.1"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -540,10 +540,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.12.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -849,26 +849,26 @@ packages:
dependency: "direct dev"
description:
name: test
sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f
sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
url: "https://pub.dev"
source: hosted
version: "1.24.9"
version: "1.25.2"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.dev"
source: hosted
version: "0.6.1"
version: "0.7.0"
test_core:
dependency: transitive
description:
name: test_core
sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a
sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
url: "https://pub.dev"
source: hosted
version: "0.5.9"
version: "0.6.0"
typed_data:
dependency: transitive
description:
Expand Down Expand Up @@ -961,10 +961,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.dev"
source: hosted
version: "13.0.0"
version: "14.2.1"
watcher:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions test/integration_tests/helpers/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,17 @@ Future<void> knobUp(WidgetTester tester, {required int steps}) async {
for (int i = 0; i != steps; i++) {
await tester.sendKeyDownEvent(LogicalKeyboardKey.f5);
await tester.pumpAndSettle();
await tester.sendKeyUpEvent(LogicalKeyboardKey.f5);
await tester.pumpAndSettle();
}
}

Future<void> knobDown(WidgetTester tester, {required int steps}) async {
for (int i = 0; i != steps; i++) {
await tester.sendKeyDownEvent(LogicalKeyboardKey.f4);
await tester.pumpAndSettle();
await tester.sendKeyUpEvent(LogicalKeyboardKey.f4);
await tester.pumpAndSettle();
}
}

Expand Down
3 changes: 1 addition & 2 deletions test/integration_tests/helpers/assertions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,7 @@ void assertDigitalAlarmBeamInhibitStatus(WidgetTester tester,
final icon = tester.widget<Icon>(iconFinder);
switch (isInState) {
case BeamInhibitState.wontInhibit:
expect(
icon.color, equals(_getCurrentTheme(tester).colorScheme.background));
expect(icon.color, equals(_getCurrentTheme(tester).colorScheme.surface));

case BeamInhibitState.willInhibit:
expect(icon.color, equals(_getCurrentTheme(tester).colorScheme.primary));
Expand Down
Loading

0 comments on commit 738bf36

Please sign in to comment.