Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions extras/webClient/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ linter:
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
prefer_single_quotes: true # Use single quotes for text
always_use_package_imports: true # Use absolute imports for packages instead of relative imports
discarded_futures: true # Don't call async functions in non-async functions
unawaited_futures: true # Mark async functions with await or use 'unawaited'
leading_newlines_in_multiline_strings: true # Start multiline strings with a newline for readability
require_trailing_commas: true # Use trailing commas for all function calls and declarations
sort_pub_dependencies: true #Sort pub dependencies alphabetically for ease of readability

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
7 changes: 4 additions & 3 deletions extras/webClient/lib/components/app_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AppDrawer extends StatelessWidget {

final BuildContext context;

showAlertDialog(String message, BuildContext context) {
showAlertDialog(String message, BuildContext context) async {
// set up the button
Widget okButton = TextButton(
child: const Text('OK'),
Expand All @@ -24,14 +24,15 @@ class AppDrawer extends StatelessWidget {
AlertDialog alert = AlertDialog(
title: Text(message),
content: const Text(
'Error connecting to Tank Controller. This is likely due to an incorrect IP address.'),
'Error connecting to Tank Controller. This is likely due to an incorrect IP address.',
),
actions: [
okButton,
],
);

// show the dialog
showDialog(
await showDialog(
context: context,
builder: (BuildContext context) {
return alert;
Expand Down
6 changes: 4 additions & 2 deletions extras/webClient/lib/components/display.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
Expand All @@ -15,8 +17,8 @@ class Display extends StatelessWidget {
builder: (context, appData, child) {
return InkWell(
splashColor: Colors.grey.shade300,
onTap: () {
appData.refreshDisplay();
onTap: () async {
unawaited(appData.refreshDisplay());
},
child: Container(
margin: const EdgeInsets.only(top: 20, bottom: 20),
Expand Down
36 changes: 19 additions & 17 deletions extras/webClient/lib/components/keypad.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,26 @@ class Keypad extends StatelessWidget {
return Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: color,
border: Border.all(width: 5, color: Colors.white),
borderRadius: const BorderRadius.all(Radius.circular(20))),
color: color,
border: Border.all(width: 5, color: Colors.white),
borderRadius: const BorderRadius.all(Radius.circular(20)),
),
child: TextButton(
style: TextButton.styleFrom(
textStyle: const TextStyle(fontSize: 40),
foregroundColor: Colors.white,
),
onPressed: () {
if (appData.currentTank.isNotEmpty()) {
tcInterface
.post(appData.currentTank.ip, 'key?value=$label')
.then((value) {
appData.display = value;
});
}
},
child: Text(label)),
style: TextButton.styleFrom(
textStyle: const TextStyle(fontSize: 40),
foregroundColor: Colors.white,
),
onPressed: () {
if (appData.currentTank.isNotEmpty()) {
tcInterface
.post(appData.currentTank.ip, 'key?value=$label')
.then((value) {
appData.display = value;
});
}
},
child: Text(label),
),
);
}
}
12 changes: 6 additions & 6 deletions extras/webClient/lib/model/app_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AppData with ChangeNotifier {

Future<void> writeTankList(tankList) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('obj1', jsonEncode(tankList));
await prefs.setString('obj1', jsonEncode(tankList));
}

Future<void> refreshDisplay() async {
Expand Down Expand Up @@ -84,19 +84,19 @@ class AppData with ChangeNotifier {
// ignore result
await TcInterface.instance.get(tank.ip, 'current');
_tankList.add(tank);
refreshDisplay();
unawaited(refreshDisplay());
notifyListeners();
writeTankList(tankList);
unawaited(writeTankList(tankList));
}

void removeTank(tank) {
void removeTank(tank) async {
_tankList.remove(tank);
if (_currentTank == tank) {
clearTank();
refreshDisplay();
unawaited(refreshDisplay());
}
notifyListeners();
writeTankList(tankList);
unawaited(writeTankList(tankList));
}

void clearTank() {
Expand Down
32 changes: 18 additions & 14 deletions extras/webClient/lib/view/files_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ class Files extends StatelessWidget {
DataRow(
cells: <DataCell>[
DataCell(Text(fileName.toString())),
DataCell(Container(
alignment: const Alignment(1.0, 0.0),
child: Text(fileSize.toString().trim()),
)),
DataCell(
Container(
alignment: const Alignment(1.0, 0.0),
child: Text(fileSize.toString().trim()),
),
),
],
),
),
Expand All @@ -35,16 +37,18 @@ class Files extends StatelessWidget {
.toString()
.compareTo(b.cells[0].child.toString()),
);
return ListView(children: <Widget>[
DataTable(
headingRowHeight: 0,
columns: const <DataColumn>[
DataColumn(label: Text('File Name')),
DataColumn(label: Text('File Size')),
],
rows: fileRows,
)
]);
return ListView(
children: <Widget>[
DataTable(
headingRowHeight: 0,
columns: const <DataColumn>[
DataColumn(label: Text('File Name')),
DataColumn(label: Text('File Size')),
],
rows: fileRows,
)
],
);
},
),
);
Expand Down
30 changes: 16 additions & 14 deletions extras/webClient/lib/view/information_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@ class Information extends StatelessWidget {
),
),
);
return ListView(children: <Widget>[
DataTable(
headingRowHeight: 0,
columns: const <DataColumn>[
DataColumn(
label: Text('Key'),
),
DataColumn(
label: Text('Value'),
),
],
rows: informationRows,
)
]);
return ListView(
children: <Widget>[
DataTable(
headingRowHeight: 0,
columns: const <DataColumn>[
DataColumn(
label: Text('Key'),
),
DataColumn(
label: Text('Value'),
),
],
rows: informationRows,
)
],
);
},
),
);
Expand Down
8 changes: 4 additions & 4 deletions extras/webClient/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
cupertino_icons: ^1.0.5
flutter:
sdk: flutter
cupertino_icons: ^1.0.5
google_fonts: ^4.0.3
html: ^0.15.0
http: ^0.13.4
provider: ^6.0.3
shared_preferences: ^2.0.15

dev_dependencies:
dev_dependencies:
build_runner: ^2.3.3
flutter_lints: ^2.0.1
flutter_test:
sdk: flutter
mockito: ^5.1.1
build_runner: ^2.3.3
flutter_lints: ^2.0.1

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
2 changes: 1 addition & 1 deletion extras/webClient/test/app_data_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void main() async {
test('App read tank list', () async {
SharedPreferences prefs = await SharedPreferences.getInstance();
List<Tank> tankList = [Tank('Tank', '192.168.0.2')];
prefs.setString('obj1', jsonEncode(tankList));
await prefs.setString('obj1', jsonEncode(tankList));
await appData.readTankList();
expect(appData.tankList, [Tank('Tank', '192.168.0.2')]);
});
Expand Down