near final
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:bus_infotainment/singletons/live_information.dart';
|
||||
import 'package:bus_infotainment/backend/live_information.dart';
|
||||
import 'package:bus_infotainment/utils/delegates.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:text_scroll/text_scroll.dart';
|
||||
|
||||
class ibus_display extends StatefulWidget {
|
||||
@@ -21,13 +22,14 @@ class ibus_display extends StatefulWidget {
|
||||
class _ibus_displayState extends State<ibus_display> {
|
||||
|
||||
String topLine = "*** NO MESSAGE ***";
|
||||
String bottomLine = "";
|
||||
|
||||
late final ListenerReceipt<AnnouncementQueueEntry> _receipt;
|
||||
|
||||
_ibus_displayState(){
|
||||
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
_receipt = liveInformation.announcementDelegate.addListener((value) {
|
||||
_receipt = liveInformation.announcementModule.onAnnouncement.addListener((value) {
|
||||
|
||||
if (topLine == value.displayText){
|
||||
return;
|
||||
@@ -38,7 +40,7 @@ class _ibus_displayState extends State<ibus_display> {
|
||||
|
||||
});
|
||||
});
|
||||
topLine = liveInformation.currentAnnouncement;
|
||||
topLine = liveInformation.announcementModule.currentAnnouncement?.displayText ?? liveInformation.announcementModule.defaultText;
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +57,8 @@ class _ibus_displayState extends State<ibus_display> {
|
||||
prefix += " ";
|
||||
}
|
||||
|
||||
input = input.replaceAll("©", "(c)");
|
||||
|
||||
return prefix + input + suffix;
|
||||
|
||||
}
|
||||
@@ -62,7 +66,7 @@ class _ibus_displayState extends State<ibus_display> {
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
LiveInformation().announcementDelegate.removeListener(_receipt);
|
||||
LiveInformation().announcementModule.onAnnouncement.removeListener(_receipt);
|
||||
|
||||
super.dispose();
|
||||
|
||||
@@ -75,19 +79,45 @@ class _ibus_displayState extends State<ibus_display> {
|
||||
return Container(
|
||||
|
||||
width: double.infinity,
|
||||
color: Colors.black,
|
||||
|
||||
child: FittedBox(
|
||||
alignment: Alignment.center,
|
||||
|
||||
child: Stack(
|
||||
children: [
|
||||
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
|
||||
alignment: Alignment.bottomCenter,
|
||||
|
||||
margin: EdgeInsets.all(1),
|
||||
|
||||
child: Text(
|
||||
"© ImBenji.net - all rights reserved | © Transport for London - all rights reserved",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 10,
|
||||
color: Colors.white.withOpacity(0.01),
|
||||
height: 1,
|
||||
shadows: [
|
||||
Shadow(
|
||||
color: Colors.black,
|
||||
blurRadius: 5,
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
|
||||
// width: double.infinity,
|
||||
// height: 100,
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
border: widget.hasBorder ? Border.all(color: Colors.grey.shade900, width: 2) : null,
|
||||
),
|
||||
|
||||
@@ -127,17 +157,27 @@ class _ibus_displayState extends State<ibus_display> {
|
||||
),
|
||||
|
||||
Transform.translate(
|
||||
offset: Offset(0, -7),
|
||||
child: Text(
|
||||
"",
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.orange,
|
||||
fontFamily: "ibus",
|
||||
height: 1.5
|
||||
offset: Offset(0, -6),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 32*4*3,
|
||||
child: TextScroll(
|
||||
_padString(bottomLine),
|
||||
velocity: Velocity(pixelsPerSecond: Offset(120, 0)),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.orange,
|
||||
fontFamily: "ibus",
|
||||
shadows: [
|
||||
Shadow(
|
||||
color: Colors.orange,
|
||||
blurRadius: 5,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -145,6 +185,8 @@ class _ibus_displayState extends State<ibus_display> {
|
||||
|
||||
),
|
||||
|
||||
|
||||
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:bus_infotainment/pages/components/ibus_display.dart';
|
||||
import 'package:bus_infotainment/pages/tfl_dataset_test.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class pages_Display extends StatefulWidget {
|
||||
|
||||
@@ -30,23 +31,29 @@ class _pages_DisplayState extends State<pages_Display> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: RotatedBox(
|
||||
quarterTurns: 1,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
ibus_display(
|
||||
hasBorder: false,
|
||||
),
|
||||
|
||||
if (MediaQuery.of(context).size.width < 600)
|
||||
Expanded(
|
||||
child: RotatedBox(
|
||||
quarterTurns: 1,
|
||||
child: ibus_display(
|
||||
hasBorder: false,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: ibus_display(
|
||||
hasBorder: false,
|
||||
if (widget._tfL_Dataset_TestState.hideUI)
|
||||
Container(
|
||||
alignment: Alignment.bottomLeft,
|
||||
height: double.infinity,
|
||||
width: double.infinity,
|
||||
|
||||
margin: EdgeInsets.all(5),
|
||||
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:bus_infotainment/pages/components/ibus_display.dart';
|
||||
import 'package:bus_infotainment/singletons/live_information.dart';
|
||||
import 'package:bus_infotainment/backend/live_information.dart';
|
||||
import 'package:bus_infotainment/tfl_datasets.dart';
|
||||
import 'package:bus_infotainment/utils/OrdinanceSurveyUtils.dart';
|
||||
import 'package:bus_infotainment/utils/audio%20wrapper.dart';
|
||||
import 'package:bus_infotainment/utils/delegates.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
class pages_Home extends StatelessWidget {
|
||||
@@ -18,226 +22,343 @@ class pages_Home extends StatelessWidget {
|
||||
|
||||
|
||||
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade900,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
blurRadius: 2,
|
||||
spreadRadius: 4
|
||||
)
|
||||
]
|
||||
),
|
||||
|
||||
margin: EdgeInsets.all(20),
|
||||
|
||||
child: ibus_display(),
|
||||
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Container(
|
||||
|
||||
margin: EdgeInsets.all(20),
|
||||
|
||||
child: Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade900,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
blurRadius: 2,
|
||||
spreadRadius: 4
|
||||
)
|
||||
]
|
||||
),
|
||||
|
||||
child: ManualAnnouncementPicker(
|
||||
backgroundColor: Colors.grey.shade900,
|
||||
outlineColor: Colors.white70,
|
||||
announcements: [
|
||||
...LiveInformation().manualAnnouncements
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Container(
|
||||
|
||||
margin: EdgeInsets.all(20),
|
||||
|
||||
child: Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade900,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.3),
|
||||
blurRadius: 2,
|
||||
spreadRadius: 4
|
||||
)
|
||||
]
|
||||
),
|
||||
|
||||
child: DelegateBuilder<BusRouteVariant>(
|
||||
delegate: LiveInformation().routeVariantDelegate,
|
||||
builder: (context, routeVariant) {
|
||||
print("rebuilt stop announcement picker");
|
||||
return StopAnnouncementPicker(
|
||||
routeVariant: routeVariant,
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Row(
|
||||
|
||||
children: [
|
||||
|
||||
Speedometer(),
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
Container(
|
||||
|
||||
margin: EdgeInsets.all(10),
|
||||
|
||||
child: Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade900,
|
||||
),
|
||||
|
||||
child: AnnouncementPicker(
|
||||
backgroundColor: Colors.grey.shade900,
|
||||
outlineColor: Colors.white70,
|
||||
);
|
||||
},
|
||||
defaultBuilder: (context) {
|
||||
BusRouteVariant? routeVariant = LiveInformation().getRouteVariant();
|
||||
if (routeVariant == null) {
|
||||
return Container(
|
||||
color: Colors.grey.shade900,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No route selected",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 25,
|
||||
color: Colors.white70
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return StopAnnouncementPicker(
|
||||
routeVariant: routeVariant,
|
||||
backgroundColor: Colors.grey.shade900,
|
||||
outlineColor: Colors.white70,
|
||||
);
|
||||
}
|
||||
},
|
||||
announcements: [
|
||||
for (NamedAnnouncementQueueEntry announcement in LiveInformation().announcementModule.manualAnnouncements)
|
||||
_AnnouncementEntry(
|
||||
label: announcement.shortName,
|
||||
index: LiveInformation().announcementModule.manualAnnouncements.indexOf(announcement),
|
||||
outlineColor: Colors.white70,
|
||||
onPressed: (){
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
liveInformation.announcementModule.queueAnnounementByInfoIndex(
|
||||
infoIndex: liveInformation.announcementModule.manualAnnouncements.indexOf(announcement),
|
||||
sendToServer: true
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Container(
|
||||
|
||||
margin: EdgeInsets.all(10),
|
||||
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade900,
|
||||
),
|
||||
|
||||
child: DelegateBuilder<BusRouteVariant>(
|
||||
delegate: LiveInformation().routeVariantDelegate,
|
||||
builder: (context, routeVariant) {
|
||||
print("rebuilt stop announcement picker");
|
||||
return StopAnnouncementPicker(
|
||||
routeVariant: routeVariant,
|
||||
backgroundColor: Colors.grey.shade900,
|
||||
outlineColor: Colors.white70,
|
||||
);
|
||||
},
|
||||
defaultBuilder: (context) {
|
||||
BusRouteVariant? routeVariant = LiveInformation().getRouteVariant();
|
||||
if (routeVariant == null) {
|
||||
return Container(
|
||||
color: Colors.grey.shade900,
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No route selected",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 25,
|
||||
color: Colors.white70
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return StopAnnouncementPicker(
|
||||
routeVariant: routeVariant,
|
||||
backgroundColor: Colors.grey.shade900,
|
||||
outlineColor: Colors.white70,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
final commandModule = liveInformation.commandModule;
|
||||
|
||||
// commandModule.executeCommand(
|
||||
// "announce dest"
|
||||
// );
|
||||
|
||||
liveInformation.announcementModule.queueAnnouncementByRouteVariant(
|
||||
routeVariant: liveInformation.getRouteVariant()!
|
||||
);
|
||||
|
||||
},
|
||||
child: Text("Announce current destination"),
|
||||
),
|
||||
|
||||
|
||||
// Container(
|
||||
//
|
||||
// margin: EdgeInsets.all(20),
|
||||
//
|
||||
// height: 300-45,
|
||||
//
|
||||
// child: ListView(
|
||||
//
|
||||
// scrollDirection: Axis.vertical,
|
||||
//
|
||||
// children: [
|
||||
//
|
||||
// ElevatedButton(
|
||||
// onPressed: () async {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.queueAnnouncement(await liveInformation.getDestinationAnnouncement(liveInformation.getRouteVariant()!, sendToServer: false));
|
||||
// },
|
||||
// child: Text("Test announcement"),
|
||||
// ),
|
||||
//
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.updateServer();
|
||||
// },
|
||||
// child: Text("Update server"),
|
||||
// ),
|
||||
//
|
||||
// SizedBox(
|
||||
//
|
||||
// width: 100,
|
||||
//
|
||||
// child: TextField(
|
||||
// onChanged: (String value) {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// // liveInformation.documentID = value;
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// SizedBox(
|
||||
//
|
||||
// width: 200,
|
||||
//
|
||||
// child: TextField(
|
||||
// onSubmitted: (String value) {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.queueAnnouncement(AnnouncementQueueEntry(
|
||||
// displayText: value,
|
||||
// audioSources: []
|
||||
// ));
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.pullServer();
|
||||
// },
|
||||
// child: Text("Pull server"),
|
||||
// ),
|
||||
//
|
||||
// ],
|
||||
//
|
||||
// ),
|
||||
//
|
||||
// ),
|
||||
|
||||
],
|
||||
),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
liveInformation.queueAnnouncement(await liveInformation.getDestinationAnnouncement(liveInformation.getRouteVariant()!, sendToServer: true));
|
||||
},
|
||||
child: Text("Announce Destination"),
|
||||
),
|
||||
|
||||
|
||||
// Container(
|
||||
//
|
||||
// margin: EdgeInsets.all(20),
|
||||
//
|
||||
// height: 300-45,
|
||||
//
|
||||
// child: ListView(
|
||||
//
|
||||
// scrollDirection: Axis.vertical,
|
||||
//
|
||||
// children: [
|
||||
//
|
||||
// ElevatedButton(
|
||||
// onPressed: () async {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.queueAnnouncement(await liveInformation.getDestinationAnnouncement(liveInformation.getRouteVariant()!, sendToServer: false));
|
||||
// },
|
||||
// child: Text("Test announcement"),
|
||||
// ),
|
||||
//
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.updateServer();
|
||||
// },
|
||||
// child: Text("Update server"),
|
||||
// ),
|
||||
//
|
||||
// SizedBox(
|
||||
//
|
||||
// width: 100,
|
||||
//
|
||||
// child: TextField(
|
||||
// onChanged: (String value) {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// // liveInformation.documentID = value;
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// SizedBox(
|
||||
//
|
||||
// width: 200,
|
||||
//
|
||||
// child: TextField(
|
||||
// onSubmitted: (String value) {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.queueAnnouncement(AnnouncementQueueEntry(
|
||||
// displayText: value,
|
||||
// audioSources: []
|
||||
// ));
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// ElevatedButton(
|
||||
// onPressed: () {
|
||||
// LiveInformation liveInformation = LiveInformation();
|
||||
// liveInformation.pullServer();
|
||||
// },
|
||||
// child: Text("Pull server"),
|
||||
// ),
|
||||
//
|
||||
// ],
|
||||
//
|
||||
// ),
|
||||
//
|
||||
// ),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ManualAnnouncementPicker extends StatefulWidget {
|
||||
class Speedometer extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<Speedometer> createState() => _SpeedometerState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class _SpeedometerState extends State<Speedometer> {
|
||||
|
||||
double speed = 0;
|
||||
double arrivalTime = 0;
|
||||
|
||||
BusRouteStop? nearestStop;
|
||||
double speed2 = 0;
|
||||
|
||||
_SpeedometerState(){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
Timer.periodic(Duration(milliseconds: 250), (timer) {
|
||||
|
||||
Position? newPosition = LiveInformation().trackerModule.position;
|
||||
|
||||
speed = newPosition?.speed ?? 0;
|
||||
|
||||
arrivalTime -= 0.25;
|
||||
arrivalTime = arrivalTime < 0 ? 0 : arrivalTime;
|
||||
|
||||
setState(() {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Container(
|
||||
|
||||
margin: EdgeInsets.all(8),
|
||||
|
||||
height: 74,
|
||||
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
// width: 60,
|
||||
height: double.infinity,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.white70,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
children: [
|
||||
|
||||
Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.white70,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
|
||||
width: 30,
|
||||
height: 30,
|
||||
|
||||
alignment: Alignment.center,
|
||||
|
||||
child: Text(
|
||||
"${((speed) * 2.237).toInt()}",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
color: Colors.white70,
|
||||
height: 1
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
||||
Text(
|
||||
"MPH",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
color: Colors.white70,
|
||||
height: 1
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AnnouncementPicker extends StatefulWidget {
|
||||
|
||||
final Color backgroundColor;
|
||||
final Color outlineColor;
|
||||
final List<NamedAnnouncementQueueEntry> announcements;
|
||||
final List<Widget> announcements;
|
||||
|
||||
const ManualAnnouncementPicker({super.key, required this.backgroundColor, required this.outlineColor, required this.announcements});
|
||||
const AnnouncementPicker({super.key, required this.backgroundColor, required this.outlineColor, required this.announcements});
|
||||
|
||||
@override
|
||||
State<ManualAnnouncementPicker> createState() => _ManualAnnouncementPickerState();
|
||||
State<AnnouncementPicker> createState() => _AnnouncementPickerState();
|
||||
}
|
||||
|
||||
class _ManualAnnouncementPickerState extends State<ManualAnnouncementPicker> {
|
||||
class _AnnouncementPickerState extends State<AnnouncementPicker> {
|
||||
|
||||
List<Widget> announcementWidgets = [];
|
||||
|
||||
@@ -255,13 +376,9 @@ class _ManualAnnouncementPickerState extends State<ManualAnnouncementPicker> {
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (NamedAnnouncementQueueEntry announcement in widget.announcements!) {
|
||||
for (Widget announcement in widget.announcements!) {
|
||||
announcementWidgets.add(
|
||||
_ManualAnnouncementEntry(
|
||||
announcement: announcement,
|
||||
index: i,
|
||||
outlineColor: Colors.white70
|
||||
)
|
||||
announcement
|
||||
);
|
||||
i++;
|
||||
}
|
||||
@@ -436,7 +553,7 @@ class _ManualAnnouncementPickerState extends State<ManualAnnouncementPicker> {
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
_currentIndex = wrap(_currentIndex - 4, 0, announcementWidgets.length);
|
||||
_currentIndex = wrap(_currentIndex - 4, 0, announcementWidgets.length, increment: 4);
|
||||
setState(() {});
|
||||
print(_currentIndex);
|
||||
},
|
||||
@@ -489,7 +606,7 @@ class _ManualAnnouncementPickerState extends State<ManualAnnouncementPicker> {
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
_currentIndex = wrap(_currentIndex + 4, 0, announcementWidgets.length);
|
||||
_currentIndex = wrap(_currentIndex + 4, 0, announcementWidgets.length, increment: 4);
|
||||
setState(() {});
|
||||
print(_currentIndex);
|
||||
},
|
||||
@@ -529,7 +646,7 @@ class _ManualAnnouncementPickerState extends State<ManualAnnouncementPicker> {
|
||||
}
|
||||
}
|
||||
|
||||
class StopAnnouncementPicker extends ManualAnnouncementPicker {
|
||||
class StopAnnouncementPicker extends AnnouncementPicker {
|
||||
final BusRouteVariant routeVariant;
|
||||
|
||||
StopAnnouncementPicker({
|
||||
@@ -542,29 +659,52 @@ class StopAnnouncementPicker extends ManualAnnouncementPicker {
|
||||
backgroundColor: backgroundColor,
|
||||
outlineColor: outlineColor,
|
||||
announcements: [
|
||||
for (BusRouteStops stop in routeVariant.busStops)
|
||||
ManualAnnouncementEntry(
|
||||
shortName: stop.formattedStopName,
|
||||
informationText: stop.formattedStopName,
|
||||
audioFileNames: [
|
||||
stop.getAudioFileName()
|
||||
]
|
||||
for (BusRouteStop stop in routeVariant.busStops)
|
||||
_AnnouncementEntry(
|
||||
label: stop.formattedStopName,
|
||||
onPressed: () {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
liveInformation.announcementModule.queueAnnounceByAudioName(
|
||||
displayText: stop.formattedStopName,
|
||||
audioNames: [stop.getAudioFileName()],
|
||||
);
|
||||
},
|
||||
index: routeVariant.busStops.indexOf(stop),
|
||||
outlineColor: outlineColor,
|
||||
alert: LiveInformation().announcementModule.announcementCache[stop.getAudioFileName()] == null,
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
int wrap(int i, int j, int length) {
|
||||
return ((i - j) % length + length) % length;
|
||||
int wrap(int i, int j, int length, {int increment = -1}) {
|
||||
if (increment == -1) {
|
||||
return ((i - j) % length + length) % length;
|
||||
} else {
|
||||
if (i >= length) {
|
||||
return 0;
|
||||
} else if (i < 0) {
|
||||
double d = length / increment;
|
||||
int n = d.toInt();
|
||||
|
||||
return (n-1) * increment;
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class _ManualAnnouncementEntry extends StatelessWidget {
|
||||
class _AnnouncementEntry extends StatelessWidget {
|
||||
|
||||
final NamedAnnouncementQueueEntry announcement;
|
||||
final String label;
|
||||
|
||||
final Function onPressed;
|
||||
final int index;
|
||||
final Color outlineColor;
|
||||
|
||||
_ManualAnnouncementEntry({super.key, required this.announcement, required this.index, required this.outlineColor});
|
||||
bool alert = false;
|
||||
|
||||
_AnnouncementEntry({super.key, required this.label, required this.onPressed, required this.index, required this.outlineColor, this.alert = false});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -591,35 +731,60 @@ class _ManualAnnouncementEntry extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
|
||||
|
||||
child: Transform.translate(
|
||||
child: Row(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
|
||||
offset: Offset(0, 4),
|
||||
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
announcement.shortName,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 25,
|
||||
color: outlineColor,
|
||||
)
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
|
||||
alignment: Alignment.centerRight,
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 260
|
||||
),
|
||||
|
||||
child: Text(
|
||||
(index+1).toString(),
|
||||
label,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 25,
|
||||
color: outlineColor,
|
||||
)
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
if (alert)
|
||||
const SizedBox(
|
||||
width: 4,
|
||||
),
|
||||
|
||||
if (alert)
|
||||
Icon(
|
||||
Icons.error,
|
||||
color: Colors.red.shade800,
|
||||
size: 25,
|
||||
shadows: const [
|
||||
Shadow(
|
||||
color: Colors.black,
|
||||
blurRadius: 2,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
|
||||
alignment: Alignment.centerRight,
|
||||
|
||||
child: Text(
|
||||
(index+1).toString(),
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 25,
|
||||
color: outlineColor,
|
||||
)
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
),
|
||||
@@ -627,8 +792,7 @@ class _ManualAnnouncementEntry extends StatelessWidget {
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
liveInformation.queueAnnouncement(announcement);
|
||||
onPressed();
|
||||
},
|
||||
|
||||
style: ElevatedButton.styleFrom(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
import 'package:bus_infotainment/singletons/live_information.dart';
|
||||
import 'package:bus_infotainment/backend/live_information.dart';
|
||||
import 'package:bus_infotainment/pages/components/ibus_display.dart';
|
||||
import 'package:bus_infotainment/tfl_datasets.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
@@ -20,7 +21,19 @@ class _pages_RoutesState extends State<pages_Routes> {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
|
||||
List<Widget> routes = [];
|
||||
routes.add(SizedBox(height: 10));
|
||||
// routes.add(Container(
|
||||
// width: double.infinity,
|
||||
// height: 16,
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.grey.shade900,
|
||||
// border: const Border.symmetric(
|
||||
// horizontal: BorderSide(
|
||||
// color: Colors.white70,
|
||||
// width: 2,
|
||||
// ),
|
||||
// )
|
||||
// ),
|
||||
// ));
|
||||
for (BusRoute route in liveInformation.busSequences!.routes.values) {
|
||||
|
||||
if (!route.routeNumber.toLowerCase().contains(_controller.text.toLowerCase())) {
|
||||
@@ -28,53 +41,81 @@ class _pages_RoutesState extends State<pages_Routes> {
|
||||
}
|
||||
|
||||
routes.add(_Route(route, this));
|
||||
routes.add(SizedBox(height: 10));
|
||||
routes.add(Container(
|
||||
width: double.infinity,
|
||||
height: 16,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade900,
|
||||
border: const Border.symmetric(
|
||||
horizontal: BorderSide(
|
||||
color: Colors.white70,
|
||||
width: 2,
|
||||
),
|
||||
)
|
||||
),
|
||||
));
|
||||
}
|
||||
if(!routes.isEmpty){
|
||||
routes.removeLast();
|
||||
}
|
||||
|
||||
return Container(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
width: double.infinity,
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Column(
|
||||
|
||||
children: [
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade900,
|
||||
),
|
||||
|
||||
width: double.infinity,
|
||||
|
||||
child: Column(
|
||||
|
||||
Container(
|
||||
children: [
|
||||
|
||||
padding: const EdgeInsets.all(10),
|
||||
Container(
|
||||
|
||||
margin: const EdgeInsets.all(10),
|
||||
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
child: TextField(
|
||||
controller: _controller,
|
||||
onChanged: (String value) {
|
||||
setState(() {});
|
||||
},
|
||||
child: TextField(
|
||||
controller: _controller,
|
||||
decoration: InputDecoration(
|
||||
hintText: ">",
|
||||
),
|
||||
onChanged: (String value) {
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
if (routes.isNotEmpty)
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: routes,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
"No routes found",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 50,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white70,
|
||||
height: 1
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
],
|
||||
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
@@ -93,28 +134,23 @@ class _Route extends StatelessWidget {
|
||||
List<Widget> Variants = [];
|
||||
|
||||
for (BusRouteVariant variant in route.routeVariants.values) {
|
||||
Variants.add(const SizedBox(height: 10));
|
||||
Variants.add(_Variant(route, variant, tfL_Dataset_TestState));
|
||||
|
||||
if (route.routeVariants.values.last != variant) {
|
||||
Variants.add(Container(
|
||||
width: double.infinity,
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Container(
|
||||
|
||||
alignment: Alignment.center,
|
||||
|
||||
decoration: BoxDecoration(
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 4,
|
||||
),
|
||||
],
|
||||
color: Colors.grey.shade900,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
|
||||
margin: const EdgeInsets.symmetric(horizontal: 10),
|
||||
padding: const EdgeInsets.all(10),
|
||||
color: Colors.grey.shade900,
|
||||
|
||||
width: 100,
|
||||
|
||||
@@ -125,21 +161,27 @@ class _Route extends StatelessWidget {
|
||||
|
||||
children: [
|
||||
|
||||
|
||||
|
||||
Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade800,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: Colors.transparent,
|
||||
border: Border.all(
|
||||
color: Colors.white70,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
|
||||
padding: const EdgeInsets.all(8),
|
||||
margin: const EdgeInsets.all(4),
|
||||
|
||||
child: Text(
|
||||
"Route: ${route.routeNumber}",
|
||||
style: GoogleFonts.montserrat(
|
||||
fontSize: 20,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
color: Colors.white70,
|
||||
height: 1
|
||||
),
|
||||
|
||||
@@ -147,12 +189,35 @@ class _Route extends StatelessWidget {
|
||||
|
||||
),
|
||||
|
||||
ListView(
|
||||
children: Variants,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 2,
|
||||
color: Colors.white70
|
||||
|
||||
),
|
||||
|
||||
Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
border: Border.all(
|
||||
color: Colors.white70,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
|
||||
margin: const EdgeInsets.all(4),
|
||||
|
||||
child: ListView(
|
||||
children: Variants,
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
@@ -181,7 +246,7 @@ class _Variant extends StatelessWidget {
|
||||
Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade800,
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
),
|
||||
|
||||
@@ -198,10 +263,10 @@ class _Variant extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
"Start:",
|
||||
style: GoogleFonts.montserrat(
|
||||
fontSize: 15,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
color: Colors.white70,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
@@ -210,14 +275,14 @@ class _Variant extends StatelessWidget {
|
||||
|
||||
Expanded(
|
||||
child: TextScroll(
|
||||
"${variant.busStops.first.formattedStopName}",
|
||||
variant.busStops.first.formattedStopName,
|
||||
mode: TextScrollMode.bouncing,
|
||||
pauseBetween: const Duration(seconds: 2),
|
||||
pauseOnBounce: const Duration(seconds: 2),
|
||||
style: GoogleFonts.montserrat(
|
||||
fontSize: 15,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.white,
|
||||
color: Colors.white70,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
@@ -232,10 +297,11 @@ class _Variant extends StatelessWidget {
|
||||
children: [
|
||||
Text(
|
||||
"End:",
|
||||
style: GoogleFonts.montserrat(
|
||||
fontSize: 15,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
color: Colors.white70,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -247,10 +313,10 @@ class _Variant extends StatelessWidget {
|
||||
mode: TextScrollMode.bouncing,
|
||||
pauseBetween: const Duration(seconds: 2),
|
||||
pauseOnBounce: const Duration(seconds: 2),
|
||||
style: GoogleFonts.montserrat(
|
||||
fontSize: 15,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.white,
|
||||
color: Colors.white70,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
@@ -338,13 +404,12 @@ class _Variant extends StatelessWidget {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
liveInformation.setRouteVariant(variant);
|
||||
await liveInformation.setRouteVariant(variant);
|
||||
|
||||
liveInformation.queueAnnouncement(
|
||||
await liveInformation.getDestinationAnnouncement(
|
||||
variant,
|
||||
sendToServer: true,
|
||||
)
|
||||
liveInformation.announcementModule.queueAnnouncementByRouteVariant(
|
||||
routeVariant: variant,
|
||||
scheduledTime: liveInformation.syncedTimeModule.Now(),
|
||||
sendToServer: false
|
||||
);
|
||||
|
||||
tfL_Dataset_TestState.setState(() {});
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
|
||||
|
||||
import 'package:bus_infotainment/singletons/live_information.dart';
|
||||
import 'package:bus_infotainment/backend/live_information.dart';
|
||||
import 'package:bus_infotainment/backend/modules/commands.dart';
|
||||
import 'package:bus_infotainment/utils/delegates.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:text_scroll/text_scroll.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
class pages_Settings extends StatefulWidget {
|
||||
@@ -14,22 +17,87 @@ class pages_Settings extends StatefulWidget {
|
||||
|
||||
class _pages_SettingsState extends State<pages_Settings> {
|
||||
|
||||
late final Widget _loginPage;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
if (!LiveInformation().auth.isAuthenticated()){
|
||||
_loginPage = _LoginPage(
|
||||
onLogin: () {
|
||||
setState(() {});
|
||||
},
|
||||
);
|
||||
} else {
|
||||
_loginPage = Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: ElevatedButton(
|
||||
onPressed: (){
|
||||
setState(() {});
|
||||
LiveInformation().auth.deleteSession();
|
||||
|
||||
},
|
||||
|
||||
// make the corner radius 4, background color match the theme, and text colour white, fill to width of parent
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4)
|
||||
),
|
||||
minimumSize: Size(double.infinity, 48)
|
||||
),
|
||||
|
||||
child: Text(
|
||||
"Sign out",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
letterSpacing: 0.5
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
if (LiveInformation().auth.isAuthenticated()){
|
||||
return Container(
|
||||
return Container(
|
||||
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
|
||||
children: [
|
||||
|
||||
Container(
|
||||
margin: const EdgeInsets.all(8),
|
||||
child: Console()
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
width: double.infinity,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
);
|
||||
} else {
|
||||
return _LoginPage(
|
||||
onLogin: () {
|
||||
Container(
|
||||
|
||||
},
|
||||
);
|
||||
}
|
||||
padding: const EdgeInsets.all(8),
|
||||
|
||||
child: _loginPage,
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,4 +694,118 @@ class PW_TextField extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Console widget
|
||||
class Console extends StatefulWidget {
|
||||
|
||||
Console({super.key});
|
||||
|
||||
@override
|
||||
State<Console> createState() => _ConsoleState();
|
||||
}
|
||||
|
||||
class _ConsoleState extends State<Console> {
|
||||
|
||||
ListenerReceipt? _listenerReceipt;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
|
||||
_listenerReceipt = LiveInformation().commandModule.onCommandReceived.addListener((p0) {
|
||||
print("Command received, updating console");
|
||||
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<Widget> commands = [];
|
||||
|
||||
TextEditingController commandController = TextEditingController();
|
||||
|
||||
commands.add(
|
||||
Text("Command History:")
|
||||
);
|
||||
|
||||
for (int i = 0; i < LiveInformation().commandModule.commandHistory.length; i++){
|
||||
CommandInfo command = LiveInformation().commandModule.commandHistory[i];
|
||||
|
||||
commands.add(
|
||||
TextScroll(
|
||||
command.command,
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.grey.shade300,
|
||||
letterSpacing: 0.1,
|
||||
),
|
||||
mode: TextScrollMode.bouncing,
|
||||
pauseBetween: const Duration(seconds: 2),
|
||||
pauseOnBounce: const Duration(seconds: 1),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white70, width: 2),
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
child: Column(
|
||||
|
||||
children: [
|
||||
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
|
||||
height: 300,
|
||||
|
||||
child: ListView(
|
||||
children: commands,
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
width: double.infinity,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 50,
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: TextField(
|
||||
controller: commandController,
|
||||
decoration: const InputDecoration(
|
||||
hintText: ">",
|
||||
),
|
||||
style: GoogleFonts.teko(
|
||||
height: 1,
|
||||
),
|
||||
onSubmitted: (value) {
|
||||
commandController.clear();
|
||||
LiveInformation().commandModule.executeCommand(value);
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,15 @@ import 'package:bus_infotainment/pages/display.dart';
|
||||
import 'package:bus_infotainment/pages/home.dart';
|
||||
import 'package:bus_infotainment/pages/routes.dart';
|
||||
import 'package:bus_infotainment/pages/settings.dart';
|
||||
import 'package:bus_infotainment/singletons/live_information.dart';
|
||||
import 'package:bus_infotainment/backend/live_information.dart';
|
||||
import 'package:bus_infotainment/tfl_datasets.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:text_scroll/text_scroll.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
import 'components/ibus_display.dart';
|
||||
|
||||
class TfL_Dataset_Test extends StatefulWidget {
|
||||
|
||||
@@ -19,11 +23,13 @@ class TfL_Dataset_Test extends StatefulWidget {
|
||||
|
||||
class TfL_Dataset_TestState extends State<TfL_Dataset_Test> {
|
||||
|
||||
int _selectedIndex = 0;
|
||||
int _selectedIndex = 1;
|
||||
|
||||
bool hideUI = false;
|
||||
bool shouldCurve = false;
|
||||
bool rotated = false;
|
||||
|
||||
late final List<Widget> Pages;
|
||||
late final List<Widget> Pages;
|
||||
|
||||
TfL_Dataset_TestState() {
|
||||
Pages = [
|
||||
@@ -42,111 +48,434 @@ class TfL_Dataset_TestState extends State<TfL_Dataset_Test> {
|
||||
_selectedIndex = min(_selectedIndex, Pages.length - 1);
|
||||
_selectedIndex = max(_selectedIndex, 0);
|
||||
|
||||
hideUI = _selectedIndex == 2 ? hideUI : false;
|
||||
|
||||
// print the window size
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
shouldCurve = true;
|
||||
} else {
|
||||
rotated = _selectedIndex == 2;
|
||||
|
||||
print("Window size: ${MediaQuery.of(context).size}");
|
||||
|
||||
windowManager.getSize().then((value) {
|
||||
double aspectRatio = value.width / value.height;
|
||||
double targetAspectRatio = rotated ? 850.3 / 411.4 : 411.4 / 850.3;
|
||||
|
||||
if ((aspectRatio - targetAspectRatio).abs() > 0.01) { // Add a tolerance value
|
||||
if (aspectRatio != targetAspectRatio) {
|
||||
windowManager.setSize(Size(value.height * targetAspectRatio, value.height));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
return Scaffold(
|
||||
|
||||
appBar: !hideUI ? AppBar(
|
||||
// appBar: !hideUI ? AppBar(
|
||||
//
|
||||
// surfaceTintColor: Colors.transparent,
|
||||
//
|
||||
// title: Container(
|
||||
//
|
||||
// child: Column(
|
||||
//
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
//
|
||||
// children: [
|
||||
//
|
||||
// Text(
|
||||
// "Bus Infotainment",
|
||||
// style: GoogleFonts.teko(
|
||||
// fontSize: 25,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: Colors.white,
|
||||
// height: 1,
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// Row(
|
||||
//
|
||||
// children: [
|
||||
//
|
||||
// Text(
|
||||
// "Selected: ",
|
||||
// style: GoogleFonts.teko(
|
||||
// fontSize: 20,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: Colors.white,
|
||||
// height: 1,
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// if (liveInformation.getRouteVariant() != null)
|
||||
// Container(
|
||||
//
|
||||
// decoration: BoxDecoration(
|
||||
// color: Colors.black,
|
||||
// ),
|
||||
//
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
|
||||
//
|
||||
// child: Text(
|
||||
// "${liveInformation.getRouteVariant()!.busRoute.routeNumber} to ${liveInformation.getRouteVariant()!.busStops.last.formattedStopName}",
|
||||
// style: GoogleFonts.montserrat(
|
||||
// fontSize: 20,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// color: Colors.orange.shade900,
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// )
|
||||
// else
|
||||
// Text(
|
||||
// "None",
|
||||
// style: GoogleFonts.teko(
|
||||
// fontSize: 20,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// color: Colors.white,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
//
|
||||
// )
|
||||
//
|
||||
// ],
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
// ) : null,
|
||||
body: Container(
|
||||
|
||||
surfaceTintColor: Colors.transparent,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
|
||||
title: Container(
|
||||
child: RotatedBox(
|
||||
quarterTurns: rotated ? 3 : 0,
|
||||
child: FittedBox(
|
||||
|
||||
child: Column(
|
||||
alignment: Alignment.topCenter,
|
||||
fit: BoxFit.fitWidth,
|
||||
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Container(
|
||||
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"Bus Infotainment",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 25,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
maxWidth: 411.4,
|
||||
maxHeight: 850.3,
|
||||
),
|
||||
|
||||
Row(
|
||||
child: Container(
|
||||
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"Selected: ",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
height: 1,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: shouldCurve ? const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(15),
|
||||
bottomRight: Radius.circular(15),
|
||||
) : null,
|
||||
border: Border.all(
|
||||
color: Colors.white70,
|
||||
width: 2,
|
||||
),
|
||||
color: Colors.grey.shade900,
|
||||
),
|
||||
|
||||
if (liveInformation.getRouteVariant() != null)
|
||||
margin: const EdgeInsets.all(6),
|
||||
|
||||
|
||||
child: Column(
|
||||
|
||||
children: [
|
||||
|
||||
if (!hideUI)
|
||||
Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
),
|
||||
margin: const EdgeInsets.all(6),
|
||||
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 2),
|
||||
child: ibus_display(),
|
||||
),
|
||||
|
||||
child: Text(
|
||||
"${liveInformation.getRouteVariant()!.busRoute.routeNumber} to ${liveInformation.getRouteVariant()!.busStops.last.formattedStopName}",
|
||||
style: GoogleFonts.montserrat(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.orange.shade900,
|
||||
if (!hideUI)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Container(
|
||||
|
||||
margin: const EdgeInsets.all(8),
|
||||
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.white70,
|
||||
width: 2,
|
||||
),
|
||||
color: Colors.grey.shade900,
|
||||
borderRadius: hideUI && shouldCurve ? const BorderRadius.only(
|
||||
bottomLeft: Radius.circular(7),
|
||||
bottomRight: Radius.circular(7),
|
||||
) : null,
|
||||
),
|
||||
),
|
||||
|
||||
)
|
||||
else
|
||||
Text(
|
||||
"None",
|
||||
style: GoogleFonts.teko(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
child: ClipRRect(
|
||||
|
||||
// curved corners
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: Radius.circular(7),
|
||||
bottomRight: Radius.circular(7),
|
||||
),
|
||||
|
||||
child: Pages[_selectedIndex],
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
)
|
||||
if (!hideUI)
|
||||
Container(
|
||||
width: double.infinity,
|
||||
height: 2,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
],
|
||||
if (!hideUI)
|
||||
Container(
|
||||
height: 50,
|
||||
|
||||
child: Row(
|
||||
|
||||
children: [
|
||||
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.all(10),
|
||||
child: Text(
|
||||
"Home",
|
||||
style: GoogleFonts.teko(
|
||||
color: Colors.white70,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
),
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedIndex = 0;
|
||||
});
|
||||
},
|
||||
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
foregroundColor: Colors.transparent,
|
||||
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
child: Container()
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
width: 2,
|
||||
height: double.infinity,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.all(10),
|
||||
child: Text(
|
||||
"Routes",
|
||||
style: GoogleFonts.teko(
|
||||
color: Colors.white70,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
),
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedIndex = 1;
|
||||
});
|
||||
},
|
||||
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
foregroundColor: Colors.transparent,
|
||||
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
child: Container()
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
width: 2,
|
||||
height: double.infinity,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.all(10),
|
||||
child: Text(
|
||||
"Display",
|
||||
style: GoogleFonts.teko(
|
||||
color: Colors.white70,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
),
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedIndex = 2;
|
||||
});
|
||||
},
|
||||
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
foregroundColor: Colors.transparent,
|
||||
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
child: Container()
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
width: 2,
|
||||
height: double.infinity,
|
||||
color: Colors.white70,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
margin: const EdgeInsets.all(10),
|
||||
child: Text(
|
||||
"Settings",
|
||||
style: GoogleFonts.teko(
|
||||
color: Colors.white70,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
),
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_selectedIndex = 3;
|
||||
});
|
||||
},
|
||||
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
foregroundColor: Colors.transparent,
|
||||
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
child: Container()
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
) : null,
|
||||
body: Pages[_selectedIndex],
|
||||
),
|
||||
|
||||
|
||||
bottomNavigationBar: !hideUI ? NavigationBar(
|
||||
selectedIndex: _selectedIndex,
|
||||
destinations: const [
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.home),
|
||||
label: "Home",
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.bus_alert),
|
||||
label: "Routes",
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.tv),
|
||||
label: "Display",
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.settings),
|
||||
label: "Settings",
|
||||
),
|
||||
],
|
||||
onDestinationSelected: (int index) {
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
},
|
||||
|
||||
) : null,
|
||||
// bottomNavigationBar: !hideUI ? NavigationBar(
|
||||
// selectedIndex: _selectedIndex,
|
||||
// destinations: const [
|
||||
// NavigationDestination(
|
||||
// icon: Icon(Icons.home),
|
||||
// label: "Home",
|
||||
// ),
|
||||
// NavigationDestination(
|
||||
// icon: Icon(Icons.bus_alert),
|
||||
// label: "Routes",
|
||||
// ),
|
||||
// NavigationDestination(
|
||||
// icon: Icon(Icons.tv),
|
||||
// label: "Display",
|
||||
// ),
|
||||
// NavigationDestination(
|
||||
// icon: Icon(Icons.settings),
|
||||
// label: "Settings",
|
||||
// ),
|
||||
// ],
|
||||
// onDestinationSelected: (int index) {
|
||||
// setState(() {
|
||||
// _selectedIndex = index;
|
||||
// });
|
||||
// },
|
||||
//
|
||||
// ) : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user