Skip to content

Commit 52cde65

Browse files
LongBoy69ilatham-blipvichrekpeternemeth05
authored
36 polish information about robot in UI (#42)
* created 2 tab approch for sensor page * Update geninfopage.dart * Update geninfopage.dart * altered misc_plot * added A functionality to start streaming * updated plotting * Update main.dart * Update robotinfo.dart * added speed * Got 'Z't o stop distance streaming and 'D' to get current distance * improved speed plotting * added responsiveness for sensor page * added if statement to sensor stream * added sensor logging state * Distance is displaying onto the sensor page Received data for distance from the robot to display onto the screen * distance data reception working now * change speed information displayed * light theme fixed * added heading to fit user reqs * combined robot controls and sensor pages * download csv and fixing graph * got fresh button to work * changed refresh button in scan screen * setup ui fix --------- Co-authored-by: ilatham-blip <irissguyot@gmail.com> Co-authored-by: vichrek <16bamgboyevi@gmail.com> Co-authored-by: peternemeth05 <pnemethasd@gmail.com>
1 parent 4ea63a5 commit 52cde65

14 files changed

Lines changed: 549 additions & 68 deletions

File tree

app/lib/app-state2.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class MyAppState1 extends ChangeNotifier {
5151
notifyListeners();
5252
}
5353

54+
void updateDistance(String newDistance) {
55+
distanceValue = newDistance;
56+
notifyListeners();
57+
}
58+
5459
void togglePath(int time){
5560
pathOngoing = true;
5661
notifyListeners();

app/lib/app_layout.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import 'package:flutter/material.dart';
22
import 'package:provider/provider.dart';
33
import 'package:robot_app/app-state2.dart';
4+
import 'package:robot_app/services/ble_connection/ble_interface.dart';
45
import 'widgets/ble_status_button.dart';
56
import 'widgets/wifi_status_button.dart';
67
import 'pages/landing.dart';
78
import 'pages/setup.dart';
8-
import 'pages/controls_classes/controls.dart';
9+
import 'pages/controls_classes.dart/controls.dart';
910
import 'pages/sensor.dart';
1011
import 'pages/video.dart';
1112

@@ -22,8 +23,7 @@ class _AppLayoutState extends State<AppLayout> {
2223
final pages = [
2324
const LandingPage(),
2425
SetupWizardPage(),
25-
RobotControlsPage(),
26-
SensorLogPage(),
26+
RobotInfoPage(),
2727
const VideoLogPage(),
2828
];
2929
final appState = Provider.of<MyAppState1>(context, listen: true);
@@ -56,10 +56,6 @@ class _AppLayoutState extends State<AppLayout> {
5656
icon: Icon(Icons.gamepad),
5757
label: Text('Robot Controls'),
5858
),
59-
NavigationRailDestination(
60-
icon: Icon(Icons.list_alt),
61-
label: Text('Sensor Log'),
62-
),
6359
NavigationRailDestination(
6460
icon: Icon(Icons.camera),
6561
label: Text('Video Log'),

app/lib/app_state.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class AppState extends ChangeNotifier {
1212
bool _bleConnected = false;
1313
bool get bleConnected => _bleConnected;
1414

15+
bool _sensorLogging = false;
16+
bool get sensorLogging => _sensorLogging;
17+
1518
StreamSubscription<bool>? _bleSubscription;
1619

1720
// subscription for sensor data logging
@@ -48,6 +51,12 @@ class AppState extends ChangeNotifier {
4851
notifyListeners();
4952
}
5053

54+
void _setSensorLogging(bool value) {
55+
if (_sensorLogging == value) return;
56+
_sensorLogging = value;
57+
notifyListeners();
58+
}
59+
5160
void _startSensorLogging(BleInterface ble) {
5261
// Prevent double subscription
5362
if (_sensorSubscription != null) return;
@@ -63,11 +72,13 @@ class AppState extends ChangeNotifier {
6372
const maxEntries = 2000;
6473
if (box.length > maxEntries) box.deleteAt(0);
6574
});
75+
_setSensorLogging(true);
6676
}
6777

6878
Future<void> _stopSensorLogging() async {
6979
await _sensorSubscription?.cancel();
7080
_sensorSubscription = null;
81+
_setSensorLogging(false);
7182
}
7283

7384
@override

app/lib/main.dart

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,37 @@ class MyApp extends StatelessWidget {
5454

5555
theme: ThemeData(
5656
brightness: Brightness.light,
57+
textButtonTheme: TextButtonThemeData(
58+
style: TextButton.styleFrom(
59+
foregroundColor: Colors.black,
60+
textStyle: const TextStyle(fontSize: 18),
61+
),
62+
),
5763
colorScheme: const ColorScheme.light(
58-
primary: Colors.grey,
59-
secondary: Colors.red,
64+
primary: Colors.red,
65+
secondary: Colors.blueGrey,
6066
),
61-
elevatedButtonTheme: ElevatedButtonThemeData(style: ButtonStyle(
62-
foregroundColor: WidgetStateProperty.all(Colors.black),
63-
backgroundColor: WidgetStateProperty.all(const Color.fromRGBO(158, 158, 158, 0.3)),
64-
visualDensity: VisualDensity(horizontal: 3.0,vertical: 3.0))
67+
elevatedButtonTheme: ElevatedButtonThemeData(
68+
style: ButtonStyle(
69+
foregroundColor: WidgetStateProperty.all(Colors.black),
70+
backgroundColor: WidgetStateProperty.all(Colors.red),
71+
textStyle: WidgetStateProperty.all(const TextStyle(fontSize: 18),),
72+
visualDensity: const VisualDensity(
73+
horizontal: 3.0,
74+
vertical: 3.0,
75+
),
6576
),
77+
),
78+
outlinedButtonTheme: OutlinedButtonThemeData(
79+
style: ButtonStyle(
80+
foregroundColor: WidgetStateProperty.all(Colors.blueGrey),
81+
backgroundColor: WidgetStateProperty.all(Colors.white),
82+
visualDensity: VisualDensity(horizontal: 3.0,vertical: 3.0),
83+
textStyle: WidgetStateProperty.all(
84+
const TextStyle(color: Colors.white, fontSize: 18),
85+
),
86+
),
87+
),
6688
tabBarTheme: TabBarThemeData(
6789
indicatorColor: Colors.red,
6890
labelStyle: TextStyle(color: Colors.black)
@@ -76,10 +98,18 @@ class MyApp extends StatelessWidget {
7698
textStyle: const TextStyle(fontSize: 18),
7799
),
78100
),
79-
elevatedButtonTheme: ElevatedButtonThemeData(style: ButtonStyle(
80-
backgroundColor: WidgetStateProperty.all(Colors.red),
81-
visualDensity: VisualDensity(horizontal: 3.0,vertical: 3.0))
101+
elevatedButtonTheme: ElevatedButtonThemeData(
102+
style: ButtonStyle(
103+
foregroundColor: WidgetStateProperty.all(Colors.white),
104+
backgroundColor: WidgetStateProperty.all(Colors.red),
105+
textStyle: WidgetStateProperty.all(const TextStyle(fontSize: 18),),
106+
visualDensity: const VisualDensity(
107+
horizontal: 3.0,
108+
vertical: 3.0,
109+
),
82110
),
111+
),
112+
83113
tabBarTheme: TabBarThemeData(
84114
indicatorColor: Colors.red,
85115
labelStyle: TextStyle(color: Colors.white)

app/lib/pages/robotinfo.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:robot_app/pages/controls_classes.dart/predetermined_paths.dart';
3+
import 'package:robot_app/pages/sensor_pages/geninfopage.dart';
4+
import 'sensor_pages/sensor.dart';
5+
6+
class RobotInfoPage extends StatefulWidget {
7+
const RobotInfoPage({super.key});
8+
9+
@override
10+
State<RobotInfoPage> createState() => _RobotInfoPageState();
11+
}
12+
13+
class _RobotInfoPageState extends State<RobotInfoPage> {
14+
int selectedIndex = 0;
15+
16+
@override
17+
Widget build(BuildContext context) {
18+
return DefaultTabController(
19+
length: 3,
20+
child: Scaffold(
21+
body: SafeArea(
22+
child: Column(
23+
children: [
24+
const TabBar(
25+
tabs: [
26+
Tab(text: 'Main Controls'),
27+
Tab(text: "Automatic Paths"),
28+
Tab(text: 'Plotted Data'),
29+
],
30+
),
31+
32+
const Divider(height: 1),
33+
34+
const Expanded(
35+
child: TabBarView(children: [GeneralInfoPage(), PrederterminedPaths(), SensorLogPage()]),
36+
),
37+
],
38+
),
39+
),
40+
),
41+
);
42+
}
43+
}

app/lib/pages/scan_screen.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class _ScanScreenState extends State<ScanScreen> {
9393

9494
@override
9595
Widget build(BuildContext context) {
96+
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
97+
9698
return Scaffold(
9799
appBar: AppBar(title: const Text("Find Your Robot")),
98100
body: Column(
@@ -173,7 +175,14 @@ class _ScanScreenState extends State<ScanScreen> {
173175
),
174176
],
175177
),
178+
// 2. Updated FloatingActionButton with Dynamic Colors
176179
floatingActionButton: FloatingActionButton(
180+
// Dark Mode: White button (High Contrast). Light Mode: BlueGrey (Standard)
181+
backgroundColor: isDarkMode ? Colors.white : Colors.blueGrey,
182+
183+
// Dark Mode: Black Icon. Light Mode: White Icon
184+
foregroundColor: isDarkMode ? Colors.black : Colors.white,
185+
177186
onPressed: _isScanning ? null : _startScan,
178187
child: const Icon(Icons.refresh),
179188
),

0 commit comments

Comments
 (0)