desktop push
This commit is contained in:
@@ -42,5 +42,6 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -15,9 +15,8 @@ class AudioCache {
|
|||||||
|
|
||||||
Uint8List? operator [](String key) {
|
Uint8List? operator [](String key) {
|
||||||
// ignore case
|
// ignore case
|
||||||
key = key.toLowerCase();
|
|
||||||
for (var k in _audioCache.keys) {
|
for (var k in _audioCache.keys) {
|
||||||
if (k.toLowerCase() == key) {
|
if (k.toLowerCase() == key.toLowerCase()) {
|
||||||
return _audioCache[k];
|
return _audioCache[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +34,7 @@ class AnnouncementCache extends AudioCache {
|
|||||||
// remove any announcements that are already loaded
|
// remove any announcements that are already loaded
|
||||||
for (var announcement in announcements) {
|
for (var announcement in announcements) {
|
||||||
if (!_audioCache.containsKey(announcement.toLowerCase())) {
|
if (!_audioCache.containsKey(announcement.toLowerCase())) {
|
||||||
_announements.add(announcement);
|
_announements.add(announcement.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ class AnnouncementCache extends AudioCache {
|
|||||||
filename = filename.split("/").last;
|
filename = filename.split("/").last;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_announements.contains(filename)) {
|
if (_announements.contains(filename.toLowerCase())) {
|
||||||
_audioCache[filename.toLowerCase()] = file.content;
|
_audioCache[filename.toLowerCase()] = file.content;
|
||||||
print("Loaded announcement: $filename");
|
print("Loaded announcement: $filename");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'package:bus_infotainment/auth/api_constants.dart';
|
|||||||
import 'package:bus_infotainment/auth/auth_api.dart';
|
import 'package:bus_infotainment/auth/auth_api.dart';
|
||||||
import 'package:bus_infotainment/backend/modules/announcement.dart';
|
import 'package:bus_infotainment/backend/modules/announcement.dart';
|
||||||
import 'package:bus_infotainment/backend/modules/commands.dart';
|
import 'package:bus_infotainment/backend/modules/commands.dart';
|
||||||
|
import 'package:bus_infotainment/backend/modules/networking.dart';
|
||||||
import 'package:bus_infotainment/backend/modules/synced_time.dart';
|
import 'package:bus_infotainment/backend/modules/synced_time.dart';
|
||||||
import 'package:bus_infotainment/backend/modules/tracker.dart';
|
import 'package:bus_infotainment/backend/modules/tracker.dart';
|
||||||
import 'package:bus_infotainment/backend/modules/tube_info.dart';
|
import 'package:bus_infotainment/backend/modules/tube_info.dart';
|
||||||
@@ -75,6 +76,8 @@ class LiveInformation {
|
|||||||
if (!auth.isAuthenticated()) {
|
if (!auth.isAuthenticated()) {
|
||||||
auth.loadAnonymousUser();
|
auth.loadAnonymousUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
networkingModule = NetworkingModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> initTrackerModule() async {
|
Future<void> initTrackerModule() async {
|
||||||
@@ -90,9 +93,12 @@ class LiveInformation {
|
|||||||
String? roomCode;
|
String? roomCode;
|
||||||
String? roomDocumentID;
|
String? roomDocumentID;
|
||||||
bool isHost = false;
|
bool isHost = false;
|
||||||
|
bool inRoom = false;
|
||||||
appwrite.RealtimeSubscription? _subscription;
|
appwrite.RealtimeSubscription? _subscription;
|
||||||
RealtimeKeepAliveConnection? _keepAliveConnection; // This is a workaround for a bug in the appwrite SDK
|
RealtimeKeepAliveConnection? _keepAliveConnection; // This is a workaround for a bug in the appwrite SDK
|
||||||
|
|
||||||
|
// Local room stuff
|
||||||
|
ListenerReceipt<String>? _listenerReciept;
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
// late CommandModule commandModule; This needs to be deprecated
|
// late CommandModule commandModule; This needs to be deprecated
|
||||||
@@ -101,6 +107,7 @@ class LiveInformation {
|
|||||||
late SyncedTimeModule syncedTimeModule;
|
late SyncedTimeModule syncedTimeModule;
|
||||||
late TrackerModule trackerModule;
|
late TrackerModule trackerModule;
|
||||||
late TubeStations tubeStations;
|
late TubeStations tubeStations;
|
||||||
|
late NetworkingModule networkingModule;
|
||||||
|
|
||||||
// Important variables
|
// Important variables
|
||||||
BusRouteVariant? _currentRouteVariant;
|
BusRouteVariant? _currentRouteVariant;
|
||||||
@@ -114,7 +121,7 @@ class LiveInformation {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> setRouteVariant(BusRouteVariant? routeVariant) async {
|
Future<void> setRouteVariant(BusRouteVariant? routeVariant, {bool sendToServer = false}) async {
|
||||||
|
|
||||||
if (routeVariant == null) {
|
if (routeVariant == null) {
|
||||||
_currentRouteVariant = null;
|
_currentRouteVariant = null;
|
||||||
@@ -160,6 +167,11 @@ class LiveInformation {
|
|||||||
print("Failed to update route on server");
|
print("Failed to update route on server");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (inRoom && sendToServer) {
|
||||||
|
|
||||||
|
SendCommand("setroute ${routeVariant.busRoute.routeNumber} ${routeVariant.busRoute.routeVariants.values.toList().indexOf(routeVariant)}");
|
||||||
|
|
||||||
}
|
}
|
||||||
Continuation:
|
Continuation:
|
||||||
|
|
||||||
@@ -200,12 +212,13 @@ class LiveInformation {
|
|||||||
return _currentRouteVariant;
|
return _currentRouteVariant;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setRouteVariantQuery(String routeNumber, int routeVariantIndex) async {
|
Future<void> setRouteVariantQuery(String routeNumber, int routeVariantIndex, {bool sendToServer = false}) async {
|
||||||
BusRoute route = busSequences.routes[routeNumber]!;
|
BusRoute route = busSequences.routes[routeNumber]!;
|
||||||
BusRouteVariant routeVariant = route.routeVariants.values.toList()[routeVariantIndex];
|
BusRouteVariant routeVariant = route.routeVariants.values.toList()[routeVariantIndex];
|
||||||
|
|
||||||
await setRouteVariant(
|
await setRouteVariant(
|
||||||
routeVariant
|
routeVariant,
|
||||||
|
sendToServer: sendToServer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +226,21 @@ class LiveInformation {
|
|||||||
// Multi device support
|
// Multi device support
|
||||||
|
|
||||||
Future<void> createRoom(String roomCode) async {
|
Future<void> createRoom(String roomCode) async {
|
||||||
|
|
||||||
|
{
|
||||||
|
// Local Room
|
||||||
|
await networkingModule.startWebSocketServer();
|
||||||
|
inRoom = true;
|
||||||
|
_listenerReciept = networkingModule.onMessageReceived?.addListener(
|
||||||
|
(p0) {
|
||||||
|
print("Received local command: $p0");
|
||||||
|
ExecuteCommand(p0);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Cloud Room
|
||||||
print("Creating room with code $roomCode");
|
print("Creating room with code $roomCode");
|
||||||
|
|
||||||
// Update the room code
|
// Update the room code
|
||||||
@@ -220,7 +248,7 @@ class LiveInformation {
|
|||||||
|
|
||||||
// Enable host mode
|
// Enable host mode
|
||||||
isHost = true;
|
isHost = true;
|
||||||
|
inRoom = true;
|
||||||
// Access the database
|
// Access the database
|
||||||
final client = auth.client;
|
final client = auth.client;
|
||||||
final databases = appwrite.Databases(client);
|
final databases = appwrite.Databases(client);
|
||||||
@@ -252,19 +280,6 @@ class LiveInformation {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Listen for changes
|
|
||||||
// { Breaks due to bug in appwrite
|
|
||||||
// final realtime = appwrite.Realtime(client);
|
|
||||||
//
|
|
||||||
// if (_subscription != null) {
|
|
||||||
// _subscription!.close();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// _subscription = realtime.subscribe(
|
|
||||||
// ['databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}']
|
|
||||||
// );
|
|
||||||
// _subscription!.stream.listen(ServerListener);
|
|
||||||
// }
|
|
||||||
// Listen for changes
|
// Listen for changes
|
||||||
if (_keepAliveConnection != null) {
|
if (_keepAliveConnection != null) {
|
||||||
try {
|
try {
|
||||||
@@ -294,8 +309,52 @@ class LiveInformation {
|
|||||||
print("Created room with code $roomCode");
|
print("Created room with code $roomCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> joinRoom(String roomCode) async {
|
}
|
||||||
print("Joining room with code $roomCode");
|
|
||||||
|
Future<void> joinRoom(String infoJson) async {
|
||||||
|
|
||||||
|
try {
|
||||||
|
{
|
||||||
|
// sync
|
||||||
|
String routeNumber = jsonDecode(infoJson)["sync"]["route"];
|
||||||
|
int routeVariantIndex = jsonDecode(infoJson)["sync"]["routeVariant"];
|
||||||
|
|
||||||
|
setRouteVariantQuery(routeNumber, routeVariantIndex);
|
||||||
|
|
||||||
|
LiveInformation().announcementModule.queueAnnouncementByRouteVariant(routeVariant: _currentRouteVariant!, sendToServer: false);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print("Failed to sync route");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Local Room
|
||||||
|
|
||||||
|
String host = jsonDecode(infoJson)["local"]["host"];
|
||||||
|
|
||||||
|
if (await networkingModule.connectToWebSocketServer(host)){
|
||||||
|
print("Connected to local room at $host");
|
||||||
|
|
||||||
|
_listenerReciept = networkingModule.onMessageReceived?.addListener(
|
||||||
|
(p0) {
|
||||||
|
print("Received local command: $p0");
|
||||||
|
ExecuteCommand(p0);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
inRoom = true;
|
||||||
|
return; // We dont need to connect to the cloud room if we are connected to the local room.
|
||||||
|
} else {
|
||||||
|
print("Failed to connect to local room at $host");
|
||||||
|
print("Falling back to cloud room");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Cloud Room
|
||||||
|
|
||||||
|
String roomCode = jsonDecode(infoJson)["cloud"]["roomCode"];
|
||||||
|
|
||||||
|
print("Joining cloud room with code $roomCode");
|
||||||
|
|
||||||
// Disable host mode
|
// Disable host mode
|
||||||
isHost = false;
|
isHost = false;
|
||||||
@@ -322,20 +381,6 @@ class LiveInformation {
|
|||||||
|
|
||||||
final document = response.documents.first;
|
final document = response.documents.first;
|
||||||
|
|
||||||
// Listen for changes
|
|
||||||
// {
|
|
||||||
// final realtime = appwrite.Realtime(client);
|
|
||||||
//
|
|
||||||
// if (_subscription != null) {
|
|
||||||
// _subscription!.close();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// _subscription = realtime.subscribe([
|
|
||||||
// 'databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}'
|
|
||||||
// ]);
|
|
||||||
//
|
|
||||||
// _subscription!.stream.listen(ServerListener);
|
|
||||||
// }
|
|
||||||
// Listen for changes
|
// Listen for changes
|
||||||
if (_keepAliveConnection != null) {
|
if (_keepAliveConnection != null) {
|
||||||
try {
|
try {
|
||||||
@@ -371,16 +416,35 @@ class LiveInformation {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("Failed to set route");
|
print("Failed to set route");
|
||||||
}
|
}
|
||||||
|
inRoom = true;
|
||||||
|
print("Joined cloud room with code $roomCode");
|
||||||
|
}
|
||||||
|
|
||||||
print("Joined room with code $roomCode");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> leaveRoom() async {
|
Future<void> leaveRoom() async {
|
||||||
|
|
||||||
if (roomCode == null) {
|
if (!inRoom) {
|
||||||
throw Exception("Not in a room");
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Local Room
|
||||||
|
networkingModule.stopWebSocketServer();
|
||||||
|
inRoom = false;
|
||||||
|
networkingModule.onMessageReceived?.removeListener(_listenerReciept!);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Cloud Room
|
||||||
|
if (_keepAliveConnection != null) {
|
||||||
|
_keepAliveConnection!.close();
|
||||||
|
_keepAliveConnection = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inRoom = false;
|
||||||
|
|
||||||
if (isHost) {
|
if (isHost) {
|
||||||
// Access the database
|
// Access the database
|
||||||
final client = auth.client;
|
final client = auth.client;
|
||||||
@@ -406,7 +470,7 @@ class LiveInformation {
|
|||||||
roomCode = null;
|
roomCode = null;
|
||||||
roomDocumentID = null;
|
roomDocumentID = null;
|
||||||
isHost = false;
|
isHost = false;
|
||||||
|
inRoom = false;
|
||||||
_keepAliveConnection?.close();
|
_keepAliveConnection?.close();
|
||||||
_keepAliveConnection = null;
|
_keepAliveConnection = null;
|
||||||
|
|
||||||
@@ -414,6 +478,42 @@ class LiveInformation {
|
|||||||
setRouteVariant(null);
|
setRouteVariant(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String generateRoomInfo() {
|
||||||
|
|
||||||
|
// Room Info Example
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"cloud": {
|
||||||
|
"roomCode": "6633e85d0020f52f3771"
|
||||||
|
},
|
||||||
|
"local":
|
||||||
|
{
|
||||||
|
"host": "ws://192.168.0.123:8080"
|
||||||
|
},
|
||||||
|
"sync":
|
||||||
|
{
|
||||||
|
"route": "W11",
|
||||||
|
"routeVariant": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return jsonEncode({
|
||||||
|
"cloud": {
|
||||||
|
"roomCode": roomCode,
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"host": "ws://${networkingModule.localIP}:8080"
|
||||||
|
},
|
||||||
|
if (_currentRouteVariant != null)
|
||||||
|
"sync": {
|
||||||
|
"route": _currentRouteVariant!.busRoute.routeNumber,
|
||||||
|
"routeVariant": _currentRouteVariant!.busRoute.routeVariants.values.toList().indexOf(_currentRouteVariant!),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
String? lastCommand;
|
String? lastCommand;
|
||||||
Future<void> ServerListener(appwrite.RealtimeMessage response) async {
|
Future<void> ServerListener(appwrite.RealtimeMessage response) async {
|
||||||
print("Session update");
|
print("Session update");
|
||||||
@@ -454,8 +554,11 @@ class LiveInformation {
|
|||||||
// Execute the command
|
// Execute the command
|
||||||
List<String> commands = response.payload["Commands"].cast<String>();
|
List<String> commands = response.payload["Commands"].cast<String>();
|
||||||
|
|
||||||
String? command = commands.last;
|
ExecuteCommand(commands.last);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExecuteCommand(String command) {
|
||||||
if (command == lastCommand) {
|
if (command == lastCommand) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -516,6 +619,12 @@ class LiveInformation {
|
|||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else if (commandName == "setroute") {
|
||||||
|
print("Set route command received");
|
||||||
|
String routeNumber = commandParts[1];
|
||||||
|
int routeVariantIndex = int.parse(commandParts[2]);
|
||||||
|
|
||||||
|
setRouteVariantQuery(routeNumber, routeVariantIndex, sendToServer: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,6 +636,16 @@ class LiveInformation {
|
|||||||
|
|
||||||
Future<void> SendCommand(String command) async {
|
Future<void> SendCommand(String command) async {
|
||||||
|
|
||||||
|
{
|
||||||
|
// Local Commands
|
||||||
|
|
||||||
|
networkingModule.sendMessage(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
// Cloud Commands
|
||||||
|
|
||||||
final client = auth.client;
|
final client = auth.client;
|
||||||
final databases = appwrite.Databases(client);
|
final databases = appwrite.Databases(client);
|
||||||
|
|
||||||
@@ -557,6 +676,10 @@ class LiveInformation {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
List<String> _splitCommand(String command) {
|
List<String> _splitCommand(String command) {
|
||||||
var regex = RegExp(r'([^\s"]+)|"([^"]*)"');
|
var regex = RegExp(r'([^\s"]+)|"([^"]*)"');
|
||||||
var matches = regex.allMatches(command);
|
var matches = regex.allMatches(command);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class AnnouncementModule extends InfoModule {
|
|||||||
// Files
|
// Files
|
||||||
String _bundleLocation = "assets/ibus_recordings.zip";
|
String _bundleLocation = "assets/ibus_recordings.zip";
|
||||||
Uint8List? _bundleBytes;
|
Uint8List? _bundleBytes;
|
||||||
void setBundleBytes(Uint8List bytes) {
|
void setBundleBytes(Uint8List? bytes) {
|
||||||
_bundleBytes = bytes;
|
_bundleBytes = bytes;
|
||||||
}
|
}
|
||||||
Future<Uint8List> getBundleBytes() async {
|
Future<Uint8List> getBundleBytes() async {
|
||||||
@@ -35,7 +35,6 @@ class AnnouncementModule extends InfoModule {
|
|||||||
if (_bundleBytes != null) {
|
if (_bundleBytes != null) {
|
||||||
return _bundleBytes!;
|
return _bundleBytes!;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Try to load them from shared preferences
|
// Try to load them from shared preferences
|
||||||
try {
|
try {
|
||||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
@@ -47,17 +46,7 @@ class AnnouncementModule extends InfoModule {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Exception("Loading announcements from assets has been deprecated.");
|
throw Exception("Loading announcements from assets has been deprecated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if (kIsWeb) {
|
|
||||||
// throw Exception("Cannot load bundle bytes on web");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// final bytes = await rootBundle.load(_bundleLocation);
|
|
||||||
// return bytes.buffer.asUint8List();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Queue
|
// Queue
|
||||||
@@ -165,7 +154,14 @@ class AnnouncementModule extends InfoModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
int get defaultAnnouncementDelay => liveInformation.auth.isAuthenticated() ? 1 : 0;
|
Duration get defaultAnnouncementDelay {
|
||||||
|
if (liveInformation.inRoom) {
|
||||||
|
return Duration(milliseconds: 500);
|
||||||
|
} else {
|
||||||
|
print("Not in room");
|
||||||
|
return Duration.zero;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
Future<void> queueAnnounceByAudioName({
|
Future<void> queueAnnounceByAudioName({
|
||||||
@@ -177,7 +173,9 @@ class AnnouncementModule extends InfoModule {
|
|||||||
|
|
||||||
if (sendToServer && _shouldSendToServer()) {
|
if (sendToServer && _shouldSendToServer()) {
|
||||||
|
|
||||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
|
||||||
|
|
||||||
|
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(defaultAnnouncementDelay);
|
||||||
|
|
||||||
String audioNamesString = "";
|
String audioNamesString = "";
|
||||||
|
|
||||||
@@ -232,7 +230,7 @@ class AnnouncementModule extends InfoModule {
|
|||||||
|
|
||||||
if (sendToServer && _shouldSendToServer()) {
|
if (sendToServer && _shouldSendToServer()) {
|
||||||
|
|
||||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(defaultAnnouncementDelay);
|
||||||
|
|
||||||
liveInformation.SendCommand("announce info $infoIndex ${scheduledTime.millisecondsSinceEpoch}");
|
liveInformation.SendCommand("announce info $infoIndex ${scheduledTime.millisecondsSinceEpoch}");
|
||||||
queueAnnouncementByInfoIndex(
|
queueAnnouncementByInfoIndex(
|
||||||
@@ -262,7 +260,9 @@ class AnnouncementModule extends InfoModule {
|
|||||||
|
|
||||||
if (sendToServer && _shouldSendToServer()) {
|
if (sendToServer && _shouldSendToServer()) {
|
||||||
|
|
||||||
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(Duration(seconds: defaultAnnouncementDelay));
|
print("Sending route announcement to server");
|
||||||
|
|
||||||
|
scheduledTime ??= liveInformation.syncedTimeModule.Now().add(defaultAnnouncementDelay);
|
||||||
|
|
||||||
String routeNumber = routeVariant.busRoute.routeNumber;
|
String routeNumber = routeVariant.busRoute.routeNumber;
|
||||||
int routeVariantIndex = routeVariant.busRoute.routeVariants.values.toList().indexOf(routeVariant);
|
int routeVariantIndex = routeVariant.busRoute.routeVariants.values.toList().indexOf(routeVariant);
|
||||||
@@ -326,7 +326,7 @@ class AnnouncementModule extends InfoModule {
|
|||||||
|
|
||||||
// Server check
|
// Server check
|
||||||
bool _shouldSendToServer() {
|
bool _shouldSendToServer() {
|
||||||
bool condition = liveInformation.roomCode != null;
|
bool condition = liveInformation.inRoom;
|
||||||
|
|
||||||
print("Should send to server? " + (condition.toString()));
|
print("Should send to server? " + (condition.toString()));
|
||||||
return condition;
|
return condition;
|
||||||
|
|||||||
196
lib/backend/modules/networking.dart
Normal file
196
lib/backend/modules/networking.dart
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:network_info_plus/network_info_plus.dart';
|
||||||
|
import 'package:shelf/shelf.dart';
|
||||||
|
import 'package:shelf/shelf_io.dart' as io;
|
||||||
|
import 'package:shelf_web_socket/shelf_web_socket.dart';
|
||||||
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
|
import 'package:bus_infotainment/backend/modules/info_module.dart';
|
||||||
|
import 'package:bus_infotainment/utils/delegates.dart';
|
||||||
|
|
||||||
|
class NetworkingModule extends InfoModule {
|
||||||
|
// Host websocket server
|
||||||
|
String host = "ws://0.0.0.0:8080";
|
||||||
|
HttpServer? _server;
|
||||||
|
WebSocketChannel? _channel;
|
||||||
|
|
||||||
|
// Store connected WebSocket channels
|
||||||
|
final List<WebSocketChannel> _connectedClients = [];
|
||||||
|
|
||||||
|
EventDelegate<String>? onMessageReceived = EventDelegate();
|
||||||
|
|
||||||
|
NetworkingModule() {
|
||||||
|
_refresh();
|
||||||
|
refreshTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> startWebSocketServer() async {
|
||||||
|
try {
|
||||||
|
var handler = webSocketHandler((WebSocketChannel webSocket) {
|
||||||
|
_connectedClients.add(webSocket); // Add the client to the list
|
||||||
|
print('Client connected: ${webSocket}'); // Log client connection
|
||||||
|
|
||||||
|
webSocket.stream.listen((message) {
|
||||||
|
// Handle messages from the client here
|
||||||
|
print('Received message: $message');
|
||||||
|
|
||||||
|
// Forward message to all clients except the sender
|
||||||
|
for (var client in _connectedClients) {
|
||||||
|
if (client != webSocket) {
|
||||||
|
client.sink.add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_onMessageReceived(message);
|
||||||
|
}, onDone: () {
|
||||||
|
_connectedClients.remove(webSocket); // Remove client on disconnect
|
||||||
|
print('Client disconnected: ${webSocket}'); // Log client disconnection
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
_server = await io.serve(handler, InternetAddress.anyIPv4, 8080);
|
||||||
|
print('WebSocket server started at ${_server?.address.address}:${_server?.port}');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to start WebSocket server: $e');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool stopWebSocketServer() {
|
||||||
|
if (_server == null) {
|
||||||
|
throw Exception('WebSocket server is not running');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (var client in _connectedClients) {
|
||||||
|
client.sink.close();
|
||||||
|
}
|
||||||
|
_connectedClients.clear();
|
||||||
|
_server?.close(force: true);
|
||||||
|
_server = null;
|
||||||
|
print('WebSocket server stopped');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to stop WebSocket server: $e');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> connectToWebSocketServer(String url) async {
|
||||||
|
try {
|
||||||
|
_channel = await WebSocketChannel.connect(Uri.parse(url));
|
||||||
|
_channel?.stream.listen((message) {
|
||||||
|
// Handle messages from the server here
|
||||||
|
print('Received message from server: $message');
|
||||||
|
_onMessageReceived(message);
|
||||||
|
});
|
||||||
|
|
||||||
|
print('Connected to WebSocket server at $url');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to connect to WebSocket server: $e');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool disconnectFromWebSocketServer() {
|
||||||
|
if (_channel == null) {
|
||||||
|
throw Exception('No active WebSocket connection');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
_channel?.sink.close();
|
||||||
|
_channel = null;
|
||||||
|
print('Disconnected from WebSocket server');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to disconnect from WebSocket server: $e');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sendMessage(String message) {
|
||||||
|
|
||||||
|
// If hosting a server, send message to all clients
|
||||||
|
if (_server != null) {
|
||||||
|
return sendMessageToClients(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_channel == null) {
|
||||||
|
throw Exception('No active WebSocket connection');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
_channel?.sink.add(message);
|
||||||
|
print('Sent message: $message');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to send message: $e');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sendMessageToClients(String message) {
|
||||||
|
if (_connectedClients.isEmpty) {
|
||||||
|
print('No clients connected');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (var client in _connectedClients) {
|
||||||
|
client.sink.add(message);
|
||||||
|
}
|
||||||
|
print('Sent message to all clients: $message');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
print('Failed to send message to clients: $e');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _onMessageReceived(String message) {
|
||||||
|
// Notify all listeners that a message has been received.
|
||||||
|
onMessageReceived?.trigger(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Useful boilerplate
|
||||||
|
String _localIP = "";
|
||||||
|
String get localIP => _localIP;
|
||||||
|
|
||||||
|
Timer refreshTimer() => Timer.periodic(const Duration(seconds: 10), (timer) {
|
||||||
|
if (kIsWeb) return;
|
||||||
|
_refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
Future<void> _refresh() async {
|
||||||
|
print("Refreshing network info...");
|
||||||
|
{
|
||||||
|
// Update the local IP address
|
||||||
|
|
||||||
|
// First try NetworkInfo
|
||||||
|
_localIP = (await NetworkInfo().getWifiIP()) ?? "";
|
||||||
|
|
||||||
|
// If null, try NetworkInterface
|
||||||
|
// Only look for ethernet. Wifi would have been found by NetworkInfo
|
||||||
|
if (_localIP.isEmpty) {
|
||||||
|
for (var interface in await NetworkInterface.list()) {
|
||||||
|
if (!interface.name.toLowerCase().contains("eth") || interface.name.contains(" ")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var addr in interface.addresses) {
|
||||||
|
print('Interface ${interface.name} has address ${addr.address}');
|
||||||
|
if (addr.type == InternetAddressType.IPv4 && !addr.isLoopback) {
|
||||||
|
_localIP = addr.address;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,8 +9,10 @@ import 'package:bus_infotainment/remaster/dashboard.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:shelf/shelf.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
import 'package:bus_infotainment/remaster/InitialStartup.dart' as remaster;
|
import 'package:bus_infotainment/remaster/InitialStartup.dart' as remaster;
|
||||||
|
import 'package:shelf/shelf_io.dart' as shelf_io;
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
@@ -19,10 +21,11 @@ void main() async {
|
|||||||
await windowManager.ensureInitialized();
|
await windowManager.ensureInitialized();
|
||||||
|
|
||||||
WindowOptions options = WindowOptions(
|
WindowOptions options = WindowOptions(
|
||||||
size: Size(411.4, 850.3),
|
title: 'Bus Infotainment',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
windowManager.setAspectRatio(411.4 / 850.3);
|
// windowManager.setAspectRatio(411.4 / 850.3);
|
||||||
|
|
||||||
await windowManager.waitUntilReadyToShow(options, () async {
|
await windowManager.waitUntilReadyToShow(options, () async {
|
||||||
await windowManager.show();
|
await windowManager.show();
|
||||||
@@ -30,22 +33,31 @@ void main() async {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// {
|
||||||
|
// // Web server test
|
||||||
|
//
|
||||||
|
// var handler = const Pipeline().addMiddleware(logRequests()).addHandler((Request request) {
|
||||||
|
// return Response.ok('Hello, world!');
|
||||||
|
// });
|
||||||
|
// var server = await shelf_io.serve(handler, '0.0.0.0', 8080);
|
||||||
|
// server.autoCompress = true;
|
||||||
|
//
|
||||||
|
// print('Serving at http://${server.address.host}:${server.port}');
|
||||||
|
//
|
||||||
|
// // get the IP address
|
||||||
|
// for (var interface in await NetworkInterface.list()) {
|
||||||
|
// for (var addr in interface.addresses) {
|
||||||
|
// print('Interface ${interface.name} has address ${addr.address}');
|
||||||
|
// print('Try http://${addr.address}:${server.port}');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
LiveInformation liveInformation = LiveInformation();
|
LiveInformation liveInformation = LiveInformation();
|
||||||
await liveInformation.initialize();
|
await liveInformation.initialize();
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
|
|
||||||
// Disalow screen to turn off on android
|
|
||||||
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
|
|
||||||
// Disalow landscape mode
|
|
||||||
await SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
DeviceOrientation.portraitDown,
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class _ibus_displayState extends State<ibus_display> {
|
|||||||
String _padString(String input){
|
String _padString(String input){
|
||||||
|
|
||||||
if (input.length < 30){
|
if (input.length < 30){
|
||||||
print("Input is too short");
|
// print("Input is too short");
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,12 +241,14 @@ class _timeComponentState extends State<_timeComponent> {
|
|||||||
|
|
||||||
String timeString = "${now.hour % 12}:${now.minute.toString().padLeft(2, "0")} ${now.hour < 12 ? "AM" : "PM"}";
|
String timeString = "${now.hour % 12}:${now.minute.toString().padLeft(2, "0")} ${now.hour < 12 ? "AM" : "PM"}";
|
||||||
|
|
||||||
|
timeString = timeString.replaceAll("0:", "12:");
|
||||||
|
|
||||||
return timeString;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
String _padString(String input){
|
String _padString(String input){
|
||||||
if (input.length < 30){
|
if (input.length < 30){
|
||||||
print("Input is too short");
|
// print("Input is too short");
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,11 +74,6 @@ class _pages_DisplayState extends State<pages_Display> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Hide the notification bar and make the app full screen and display over notch
|
// Hide the notification bar and make the app full screen and display over notch
|
||||||
if (widget._tfL_Dataset_TestState.hideUI) {
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
|
|
||||||
} else {
|
|
||||||
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ import 'package:bus_infotainment/backend/live_information.dart';
|
|||||||
import 'package:bus_infotainment/pages/components/ibus_display.dart';
|
import 'package:bus_infotainment/pages/components/ibus_display.dart';
|
||||||
import 'package:bus_infotainment/remaster/dashboard.dart';
|
import 'package:bus_infotainment/remaster/dashboard.dart';
|
||||||
import 'package:bus_infotainment/tfl_datasets.dart';
|
import 'package:bus_infotainment/tfl_datasets.dart';
|
||||||
|
import 'package:bus_infotainment/utils/delegates.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_scroll_shadow/flutter_scroll_shadow.dart';
|
import 'package:flutter_scroll_shadow/flutter_scroll_shadow.dart';
|
||||||
|
import 'package:network_info_plus/network_info_plus.dart';
|
||||||
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||||
|
|
||||||
class ArcDashboard extends StatefulWidget {
|
class ArcDashboard extends StatefulWidget {
|
||||||
@@ -17,18 +20,46 @@ class ArcDashboard extends StatefulWidget {
|
|||||||
class _ArcDashboardState extends State<ArcDashboard> {
|
class _ArcDashboardState extends State<ArcDashboard> {
|
||||||
_closeDialogueChecker closeDialogWidget = _closeDialogueChecker();
|
_closeDialogueChecker closeDialogWidget = _closeDialogueChecker();
|
||||||
|
|
||||||
|
late ListenerReceipt<BusRouteVariant?> onRouteVariantChange;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
// TODO: implement initState
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
onRouteVariantChange = LiveInformation().routeVariantDelegate.addListener((value) {
|
||||||
|
print("Route variant changed");
|
||||||
|
setState(() {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
// TODO: implement dispose
|
||||||
|
super.dispose();
|
||||||
|
|
||||||
|
LiveInformation().routeVariantDelegate.removeListener(onRouteVariantChange);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
return PopScope(
|
||||||
|
|
||||||
// Force landscape mode
|
onPopInvoked: (isPop) {
|
||||||
Future.delayed(Duration(seconds: 1), () {
|
|
||||||
SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.landscapeRight,
|
|
||||||
DeviceOrientation.landscapeLeft,
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
return Scaffold(
|
try {
|
||||||
|
LiveInformation().leaveRoom();
|
||||||
|
print("Left room");
|
||||||
|
} catch (e) {
|
||||||
|
print("Error leaving room: $e");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
child: Scaffold(
|
||||||
|
|
||||||
body: Container(
|
body: Container(
|
||||||
child: Row(
|
child: Row(
|
||||||
@@ -48,28 +79,102 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
if (LiveInformation().roomDocumentID != null)
|
ShadButton.outline(
|
||||||
Tooltip(
|
icon: const Icon(Icons.menu),
|
||||||
child: ShadButton(
|
|
||||||
icon: const Icon(Icons.network_check),
|
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
border: Border.all(
|
||||||
|
width: 2,
|
||||||
|
color: Colors.grey.shade400,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
bool multiMode = ModalRoute.of(context)!.settings.name!.contains("multi");
|
||||||
|
|
||||||
showShadSheet(
|
showShadSheet(
|
||||||
context: context,
|
context: context,
|
||||||
|
side: ShadSheetSide.left,
|
||||||
|
|
||||||
|
builder: (context) {
|
||||||
|
return ShadSheet(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
content: Container(
|
||||||
|
width: 225,
|
||||||
|
height: MediaQuery.of(context).size.height,
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
|
||||||
|
ShadButton(
|
||||||
|
text: Text("Rooom Information"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
showShadSheet(
|
||||||
|
context: context,
|
||||||
|
side: ShadSheetSide.left,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return ShadSheet(
|
return ShadSheet(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
content: Column(
|
content: Column(
|
||||||
children: [
|
children: [
|
||||||
Text("Room ID: ${LiveInformation().roomDocumentID}"),
|
Text("Room ID: ${LiveInformation().roomDocumentID}"),
|
||||||
|
Text("IP Address: ${LiveInformation().networkingModule.localIP}"),
|
||||||
|
QrImageView(
|
||||||
|
data: LiveInformation().generateRoomInfo(),
|
||||||
|
size: 270,
|
||||||
|
backgroundColor: Colors.white,
|
||||||
|
),
|
||||||
|
ShadButton(
|
||||||
|
text: Text("Copy Room Info"),
|
||||||
|
onPressed: () {
|
||||||
|
Clipboard.setData(ClipboardData(text: LiveInformation().generateRoomInfo()));
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text("Copied room info to clipboard"),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
],
|
],
|
||||||
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
],
|
||||||
|
)
|
||||||
),
|
),
|
||||||
message: "Room information",
|
|
||||||
|
if (!multiMode)
|
||||||
|
ShadButton(
|
||||||
|
text: Text("Return to route selection"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
else
|
||||||
|
ShadButton(
|
||||||
|
text: Text("Route selection"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.popAndPushNamed(context, '/multi/routes');
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -196,6 +301,7 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
),
|
),
|
||||||
ShadButton(
|
ShadButton(
|
||||||
text: const Text("Bus Stop Announcements"),
|
text: const Text("Bus Stop Announcements"),
|
||||||
|
enabled: LiveInformation().getRouteVariant() != null,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -359,11 +465,12 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
const ShadButton(
|
const ShadButton(
|
||||||
icon: Icon(Icons.stop),
|
icon: Icon(Icons.stop),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
),
|
),
|
||||||
|
|
||||||
ShadButton(
|
ShadButton(
|
||||||
// text: const Text("Announce Destination"),
|
// text: const Text("Announce Destination"),
|
||||||
icon: const Icon(Icons.location_on),
|
icon: const Icon(Icons.bus_alert),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -374,12 +481,14 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
if (routeVariant != null) {
|
if (routeVariant != null) {
|
||||||
info.announcementModule.queueAnnouncementByRouteVariant(
|
info.announcementModule.queueAnnouncementByRouteVariant(
|
||||||
routeVariant: routeVariant,
|
routeVariant: routeVariant,
|
||||||
sendToServer: false
|
sendToServer: ModalRoute.of(context)!.settings.name!.contains("multi")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
)
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -434,7 +543,9 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.popUntil(context, (route) {
|
||||||
|
return route.settings.name == '/multi' || route.settings.name == '/routes';
|
||||||
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -449,6 +560,7 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class _page2State extends State<_page2> {
|
|||||||
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
|
||||||
width: double.infinity,
|
// width: double.infinity,
|
||||||
|
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
||||||
@@ -162,7 +162,6 @@ class _page2State extends State<_page2> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
"Permissions",
|
"Permissions",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
@@ -175,8 +174,17 @@ class _page2State extends State<_page2> {
|
|||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(
|
||||||
|
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|
||||||
|
children: [
|
||||||
ShadCard(
|
ShadCard(
|
||||||
width: double.infinity,
|
width: 300,
|
||||||
|
height: 200,
|
||||||
title: Text(
|
title: Text(
|
||||||
"Location",
|
"Location",
|
||||||
),
|
),
|
||||||
@@ -225,11 +233,12 @@ class _page2State extends State<_page2> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 16,
|
width: 16,
|
||||||
),
|
),
|
||||||
|
|
||||||
ShadCard(
|
ShadCard(
|
||||||
width: double.infinity,
|
width: 300,
|
||||||
|
height: 200,
|
||||||
title: Text(
|
title: Text(
|
||||||
"Storage",
|
"Storage",
|
||||||
),
|
),
|
||||||
@@ -277,6 +286,63 @@ class _page2State extends State<_page2> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
|
||||||
|
ShadCard(
|
||||||
|
width: 300,
|
||||||
|
height: 200,
|
||||||
|
title: Text(
|
||||||
|
"Network",
|
||||||
|
),
|
||||||
|
description: Text(
|
||||||
|
"Network access is required for commincation between devices for multi mode."
|
||||||
|
),
|
||||||
|
content: Container(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
|
||||||
|
FutureBuilder(
|
||||||
|
future: Permission.nearbyWifiDevices.isGranted,
|
||||||
|
builder: (context, val) {
|
||||||
|
bool isEnabled = true;
|
||||||
|
String text = "Request permission";
|
||||||
|
Color color = Colors.white;
|
||||||
|
|
||||||
|
if (val.hasData) {
|
||||||
|
isEnabled = !val.data!;
|
||||||
|
}
|
||||||
|
if (!isEnabled) {
|
||||||
|
text = "Permission granted!";
|
||||||
|
color = Colors.green.shade400;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ShadButton(
|
||||||
|
text: Text(text),
|
||||||
|
onPressed: () async {
|
||||||
|
await Permission.manageExternalStorage.request();
|
||||||
|
setState(() {
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
enabled: isEnabled,
|
||||||
|
backgroundColor: color,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
@@ -306,7 +372,6 @@ class _page2State extends State<_page2> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,15 +4,40 @@
|
|||||||
import 'package:bus_infotainment/pages/tfl_dataset_test.dart';
|
import 'package:bus_infotainment/pages/tfl_dataset_test.dart';
|
||||||
import 'package:bus_infotainment/remaster/DashboardArc.dart';
|
import 'package:bus_infotainment/remaster/DashboardArc.dart';
|
||||||
import 'package:bus_infotainment/remaster/InitialStartup.dart';
|
import 'package:bus_infotainment/remaster/InitialStartup.dart';
|
||||||
|
import 'package:bus_infotainment/remaster/SearchArc.dart';
|
||||||
import 'package:bus_infotainment/remaster/dashboard.dart';
|
import 'package:bus_infotainment/remaster/dashboard.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||||
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
|
import 'WebSocketTest.dart';
|
||||||
|
|
||||||
class RemasteredApp extends StatelessWidget {
|
class RemasteredApp extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// TODO: implement build
|
|
||||||
|
// Force landscape mode
|
||||||
|
SystemChrome.setPreferredOrientations([
|
||||||
|
DeviceOrientation.landscapeLeft,
|
||||||
|
DeviceOrientation.landscapeRight,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Hide navigation bar and status bar
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive, overlays: [
|
||||||
|
SystemUiOverlay.bottom,
|
||||||
|
SystemUiOverlay.top,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Hide the gesture navigation bar
|
||||||
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky, overlays: [
|
||||||
|
SystemUiOverlay.bottom,
|
||||||
|
SystemUiOverlay.top,
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ShadApp(
|
return ShadApp(
|
||||||
darkTheme: ShadThemeData(
|
darkTheme: ShadThemeData(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
@@ -20,16 +45,22 @@ class RemasteredApp extends StatelessWidget {
|
|||||||
background: Colors.grey.shade900,
|
background: Colors.grey.shade900,
|
||||||
primary: Colors.grey.shade50,
|
primary: Colors.grey.shade50,
|
||||||
primaryForeground: Colors.grey.shade900,
|
primaryForeground: Colors.grey.shade900,
|
||||||
border: Colors.grey.shade900,
|
border: Colors.grey.shade400,
|
||||||
|
input: Colors.grey.shade400,
|
||||||
),
|
),
|
||||||
// force dark mode
|
|
||||||
),
|
),
|
||||||
themeMode: ThemeMode.dark,
|
themeMode: ThemeMode.dark,
|
||||||
|
|
||||||
|
// remove debug banner
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
|
||||||
routes: {
|
routes: {
|
||||||
'/setup': (context) => InitialStartup(),
|
'/setup': (context) => InitialStartup(),
|
||||||
'/': (context) => HomePage_Re(),
|
'/': (context) => HomePage_Re(),
|
||||||
'/routes': (context) => RoutePage(),
|
|
||||||
|
'/routes': (context) => SearchArc(),
|
||||||
|
'/multi/routes': (context) => RoutePage(),
|
||||||
|
|
||||||
'/enroute': (context) => ArcDashboard(),
|
'/enroute': (context) => ArcDashboard(),
|
||||||
'/legacy': (context) => TfL_Dataset_Test(),
|
'/legacy': (context) => TfL_Dataset_Test(),
|
||||||
'/multi': (context) => MultiModeSetup(),
|
'/multi': (context) => MultiModeSetup(),
|
||||||
@@ -38,6 +69,7 @@ class RemasteredApp extends StatelessWidget {
|
|||||||
'/multi/register': (context) => MultiModeRegister(),
|
'/multi/register': (context) => MultiModeRegister(),
|
||||||
'/display': (context) => FullscreenDisplay(),
|
'/display': (context) => FullscreenDisplay(),
|
||||||
'/multi/join': (context) => MultiModeJoin(),
|
'/multi/join': (context) => MultiModeJoin(),
|
||||||
|
'/websocket': (context) => WebSocketWidget(),
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
346
lib/remaster/SearchArc.dart
Normal file
346
lib/remaster/SearchArc.dart
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
|
||||||
|
|
||||||
|
import 'package:bus_infotainment/backend/live_information.dart';
|
||||||
|
import 'package:bus_infotainment/remaster/dashboard.dart';
|
||||||
|
import 'package:bus_infotainment/tfl_datasets.dart';
|
||||||
|
import 'package:bus_infotainment/utils/OrdinanceSurveyUtils.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
import 'package:flutter/material.dart' hide NavigationBar;
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:geolocator/geolocator.dart';
|
||||||
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||||
|
import 'package:vector_math/vector_math.dart' hide Colors;
|
||||||
|
|
||||||
|
import '../backend/modules/tube_info.dart';
|
||||||
|
|
||||||
|
class SearchArc extends StatefulWidget {
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SearchArc> createState() => _SearchArcState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SearchArcState extends State<SearchArc> {
|
||||||
|
TextEditingController searchController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
List<Widget> nearbyRoutes = _getNearbyRoutes(context);
|
||||||
|
List<Widget> pastRoutes = _getPastRoutes(context);
|
||||||
|
|
||||||
|
List<Widget> routeCards = [];
|
||||||
|
|
||||||
|
if (searchController.text.isNotEmpty) {
|
||||||
|
// Detect if the search query is a route number
|
||||||
|
// Examples of route numbers: 1, A1, 1A, A1A ...
|
||||||
|
// If it isnt a route number, it is a stop name
|
||||||
|
// Examples of stop names: "Euston Station", "Baker Street", "Kings Cross"
|
||||||
|
bool containsNumber = RegExp(r'\d').hasMatch(searchController.text);
|
||||||
|
|
||||||
|
List<BusRoute> searchResults = [];
|
||||||
|
|
||||||
|
// Loop through all bus routes
|
||||||
|
for (BusRoute route in LiveInformation().busSequences.routes.values) {
|
||||||
|
if (containsNumber) {
|
||||||
|
if (route.routeNumber.contains(searchController.text) && !searchResults.contains(route)) {
|
||||||
|
routeCards.add(_getRouteCard(context, route));
|
||||||
|
searchResults.add(route);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (BusRouteVariant variant in route.routeVariants.values) {
|
||||||
|
for (BusRouteStop stop in variant.busStops) {
|
||||||
|
if (stop.formattedStopName.toLowerCase().contains(
|
||||||
|
searchController.text.toLowerCase()) && !searchResults.contains(route)) {
|
||||||
|
routeCards.add(_getRouteCard(context, route));
|
||||||
|
searchResults.add(route);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routeCards.isEmpty){
|
||||||
|
routeCards.add(
|
||||||
|
Text("No results found", style: ShadTheme.of(context).textTheme.h3,)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
body: Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.fromLTRB(32, 16, 32, 0),
|
||||||
|
height: MediaQuery.of(context).size.height,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
ShadInput(
|
||||||
|
placeholder: Text("Search for route or stop (Can be laggy)"),
|
||||||
|
controller: searchController,
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
// Update search results
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SizedBox(height: 8),
|
||||||
|
if (routeCards.isNotEmpty)
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Search results",
|
||||||
|
style: ShadTheme.of(context).textTheme.h3,
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Expanded(
|
||||||
|
child: GridView.extent(
|
||||||
|
shrinkWrap: true,
|
||||||
|
maxCrossAxisExtent: 100,
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
crossAxisSpacing: 8,
|
||||||
|
mainAxisSpacing: 8,
|
||||||
|
children: routeCards,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Expanded(
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Nearby routes",
|
||||||
|
style: ShadTheme.of(context).textTheme.h3,
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Expanded(
|
||||||
|
child: GridView.extent(
|
||||||
|
shrinkWrap: true,
|
||||||
|
maxCrossAxisExtent: 100,
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
crossAxisSpacing: 8,
|
||||||
|
mainAxisSpacing: 8,
|
||||||
|
children: _getNearbyRoutes(context, multiMode: true),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Container(
|
||||||
|
width: 2,
|
||||||
|
color: Colors.grey.shade300,
|
||||||
|
),
|
||||||
|
|
||||||
|
RotatedBox(
|
||||||
|
quarterTurns: 3,
|
||||||
|
child: NavigationBar(),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _getNearbyRoutes(context, {bool multiMode = false}) {
|
||||||
|
|
||||||
|
print("Getting nearby routes");
|
||||||
|
|
||||||
|
LiveInformation liveInformation = LiveInformation();
|
||||||
|
BusSequences busSequences = liveInformation.busSequences;
|
||||||
|
|
||||||
|
List<BusRoute> nearbyRoutes = [];
|
||||||
|
|
||||||
|
Position? currentLocation = liveInformation.trackerModule.position;
|
||||||
|
|
||||||
|
Vector2 currentVector = Vector2(0, 0);
|
||||||
|
|
||||||
|
if (currentLocation == null && !kDebugMode) {
|
||||||
|
return [];
|
||||||
|
} else if (currentLocation != null){
|
||||||
|
currentVector = OSGrid.toNorthingEasting(currentLocation!.latitude, currentLocation.longitude);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (kDebugMode) {
|
||||||
|
currentVector = OSGrid.toNorthingEasting(51.583781262560926, -0.020359583104595073);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BusRoute route in busSequences.routes.values) {
|
||||||
|
for (BusRouteVariant variant in route.routeVariants.values) {
|
||||||
|
for (BusRouteStop stop in variant.busStops) {
|
||||||
|
|
||||||
|
Vector2 stopVector = Vector2(stop.easting.toDouble(), stop.northing.toDouble());
|
||||||
|
|
||||||
|
double distance = currentVector.distanceTo(stopVector);
|
||||||
|
|
||||||
|
if (distance < 1000) {
|
||||||
|
nearbyRoutes.add(route);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nearbyRoutes.contains(route)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nearbyRoutes.contains(route)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> routeCards = [];
|
||||||
|
|
||||||
|
for (BusRoute route in nearbyRoutes) {
|
||||||
|
routeCards.add(_getRouteCard(context, route, multiMode: multiMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
return routeCards;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _getRouteCard(context, BusRoute route, {bool multiMode = false}) {
|
||||||
|
|
||||||
|
String rr = "";
|
||||||
|
|
||||||
|
if (route.routeNumber.toLowerCase().startsWith("ul")) {
|
||||||
|
|
||||||
|
rr = "Rail replacement";
|
||||||
|
|
||||||
|
TubeLine? line = LiveInformation().tubeStations.getClosestLine(route.routeVariants.values.first);
|
||||||
|
|
||||||
|
rr = line?.name ?? rr;
|
||||||
|
|
||||||
|
if (!["London Overground", "DLR", "Rail replacement", "Elizabeth Line"].contains(rr)) {
|
||||||
|
rr += " line";
|
||||||
|
}
|
||||||
|
if (rr == "Hammersmith and City line") {
|
||||||
|
rr = "Hammersmith & City";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ElevatedButton(
|
||||||
|
onPressed: () {
|
||||||
|
showShadSheet(
|
||||||
|
side: ShadSheetSide.right,
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
|
||||||
|
List<Widget> variantWidgets = [];
|
||||||
|
|
||||||
|
for (BusRouteVariant variant in route.routeVariants.values) {
|
||||||
|
variantWidgets.add(
|
||||||
|
ShadButton.outline(
|
||||||
|
text: SizedBox(
|
||||||
|
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text("${variant.busStops.first.formattedStopName} ->"),
|
||||||
|
const SizedBox(
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
|
Text(variant.busStops.last.formattedStopName)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
height: 50,
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
onPressed: () async {
|
||||||
|
LiveInformation liveInformation = LiveInformation();
|
||||||
|
await liveInformation.setRouteVariant(variant);
|
||||||
|
|
||||||
|
if (!multiMode) {
|
||||||
|
Navigator.popAndPushNamed(context, "/enroute");
|
||||||
|
} else {
|
||||||
|
Navigator.popAndPushNamed(context, "/multi/enroute");
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
variantWidgets.add(const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ShadSheet(
|
||||||
|
title: Text("Route ${route.routeNumber} - Variants"),
|
||||||
|
|
||||||
|
content: Container(
|
||||||
|
width: 300,
|
||||||
|
height: MediaQuery.of(context).size.height - 52,
|
||||||
|
child: Scrollbar(
|
||||||
|
thumbVisibility: true,
|
||||||
|
child: ListView(
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: [
|
||||||
|
...variantWidgets
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
|
||||||
|
Text(
|
||||||
|
"Route \n ${route.routeNumber}",
|
||||||
|
style: ShadTheme.of(context).textTheme.h4.copyWith(
|
||||||
|
height: 1.1
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
if (route.routeNumber.toLowerCase().startsWith("ul"))
|
||||||
|
Text(rr, style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w400, height: 1), textAlign: TextAlign.center,)
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> _getPastRoutes(context) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
189
lib/remaster/WebSocketTest.dart
Normal file
189
lib/remaster/WebSocketTest.dart
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
import 'dart:isolate';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
|
import 'package:web_socket_channel/status.dart' as status;
|
||||||
|
import 'package:network_info_plus/network_info_plus.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||||
|
|
||||||
|
import '../utils/web_socket_server.dart';
|
||||||
|
|
||||||
|
class WebSocketWidget extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_WebSocketWidgetState createState() => _WebSocketWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _WebSocketWidgetState extends State<WebSocketWidget> {
|
||||||
|
WebSocketChannel? _channel;
|
||||||
|
TextEditingController _controller = TextEditingController();
|
||||||
|
TextEditingController _urlController = TextEditingController(text: 'ws://localhost:8080');
|
||||||
|
List<String> _messages = [];
|
||||||
|
Isolate? _serverIsolate;
|
||||||
|
bool _isServerRunning = false;
|
||||||
|
String? _localIpAddress;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_getLocalIpAddress().then((ip) {
|
||||||
|
setState(() {
|
||||||
|
_localIpAddress = ip;
|
||||||
|
_urlController.text = 'ws://$_localIpAddress:8080';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> _getLocalIpAddress() async {
|
||||||
|
if (kIsWeb) {
|
||||||
|
return '127.0.0.1'; // Web does not support getting the local IP address
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
|
final info = NetworkInfo();
|
||||||
|
String? ip = await info.getWifiIP();
|
||||||
|
return ip ?? '127.0.0.1'; // Fallback to localhost if no IP is found
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var interface in await NetworkInterface.list()) {
|
||||||
|
for (var addr in interface.addresses) {
|
||||||
|
if (addr.type == InternetAddressType.IPv4 && !addr.isLoopback) {
|
||||||
|
return addr.address;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '127.0.0.1'; // Fallback to localhost if no IP is found
|
||||||
|
}
|
||||||
|
|
||||||
|
void _startServer() async {
|
||||||
|
final receivePort = ReceivePort();
|
||||||
|
_serverIsolate = await Isolate.spawn(webSocketServer, receivePort.sendPort);
|
||||||
|
receivePort.listen((message) {
|
||||||
|
print(message);
|
||||||
|
setState(() {
|
||||||
|
_isServerRunning = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _stopServer() {
|
||||||
|
_serverIsolate?.kill(priority: Isolate.immediate);
|
||||||
|
setState(() {
|
||||||
|
_isServerRunning = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _joinWebSocket() {
|
||||||
|
if (_channel != null) {
|
||||||
|
_channel!.sink.close();
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
_channel = WebSocketChannel.connect(Uri.parse(_urlController.text));
|
||||||
|
_channel!.stream.listen((message) {
|
||||||
|
setState(() {
|
||||||
|
_messages.add(message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _sendMessage(String message) {
|
||||||
|
if (_channel != null) {
|
||||||
|
_channel!.sink.add(message);
|
||||||
|
setState(() {
|
||||||
|
_messages.add('You: $message'); // Display the sent message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _closeConnection() {
|
||||||
|
if (_channel != null) {
|
||||||
|
_channel!.sink.close(status.goingAway);
|
||||||
|
setState(() {
|
||||||
|
_channel = null;
|
||||||
|
_messages.clear();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_closeConnection();
|
||||||
|
_stopServer();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
// force portrait mode
|
||||||
|
SystemChrome.setPreferredOrientations([
|
||||||
|
DeviceOrientation.portraitUp,
|
||||||
|
DeviceOrientation.portraitDown,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('WebSocket Demo'),
|
||||||
|
actions: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.close),
|
||||||
|
onPressed: _closeConnection,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
if (!_isServerRunning)
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _startServer,
|
||||||
|
child: Text('Start WebSocket Server'),
|
||||||
|
)
|
||||||
|
else
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _stopServer,
|
||||||
|
child: Text('Stop WebSocket Server'),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
if (_localIpAddress != null)
|
||||||
|
Text('Server URL: ws://$_localIpAddress:8080'),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
TextField(
|
||||||
|
controller: _urlController,
|
||||||
|
decoration: InputDecoration(labelText: 'WebSocket URL'),
|
||||||
|
onSubmitted: (value) => _joinWebSocket(),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _joinWebSocket,
|
||||||
|
child: Text('Join WebSocket'),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: _messages.length,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
return ListTile(
|
||||||
|
title: Text(_messages[index]),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextField(
|
||||||
|
controller: _controller,
|
||||||
|
decoration: InputDecoration(labelText: 'Send a message'),
|
||||||
|
onSubmitted: (text) {
|
||||||
|
_sendMessage(text);
|
||||||
|
_controller.clear();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ import 'package:flutter_carousel_widget/flutter_carousel_widget.dart';
|
|||||||
import 'package:geolocator/geolocator.dart';
|
import 'package:geolocator/geolocator.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
import 'package:vector_math/vector_math.dart' hide Colors;
|
import 'package:vector_math/vector_math.dart' hide Colors;
|
||||||
|
|
||||||
@@ -65,7 +66,7 @@ class _HomePage_ReState extends State<HomePage_Re> {
|
|||||||
print("Bundle: $shouldRedirectB");
|
print("Bundle: $shouldRedirectB");
|
||||||
print("Permissions_indv: $perms");
|
print("Permissions_indv: $perms");
|
||||||
|
|
||||||
return !shouldRedirectA || !shouldRedirectB;
|
return (!shouldRedirectA || !shouldRedirectB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -84,39 +85,43 @@ class _HomePage_ReState extends State<HomePage_Re> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Container(
|
body: Container(
|
||||||
|
|
||||||
padding: const EdgeInsets.all(16),
|
padding: const EdgeInsets.all(16),
|
||||||
|
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
|
|
||||||
child: SizedBox(
|
|
||||||
|
|
||||||
width: double.infinity,
|
|
||||||
|
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
const Text(
|
Text(
|
||||||
"Choose mode:",
|
"Choose mode:",
|
||||||
style: TextStyle(
|
style: ShadTheme.of(context).textTheme.h1.copyWith(),
|
||||||
fontSize: 32,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
SingleChildScrollView(
|
||||||
|
scrollDirection: Axis.horizontal,
|
||||||
|
child: Row(
|
||||||
|
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
|
||||||
ShadCard(
|
ShadCard(
|
||||||
title: const Text("Solo mode"),
|
title: const Text("Solo mode"),
|
||||||
width: double.infinity,
|
width: 300,
|
||||||
description: const Text(
|
description: const Text(
|
||||||
"Choose this mode if you are only using this device. (No internet required)"
|
"Choose this mode if you are only using this device. (No internet required)"
|
||||||
),
|
),
|
||||||
@@ -142,47 +147,199 @@ class _HomePage_ReState extends State<HomePage_Re> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(
|
SizedBox(
|
||||||
height: 16,
|
width: 16,
|
||||||
),
|
),
|
||||||
|
|
||||||
ShadCard(
|
ShadCard(
|
||||||
title: const Text("Multi mode"),
|
title: const Text("Multi mode"),
|
||||||
width: double.infinity,
|
width: 300,
|
||||||
description: const Text(
|
description: const Text(
|
||||||
"Choose this mode if you are using multiple devices. (Internet required)"
|
"Choose this mode if you are using multiple devices. (Internet required)"
|
||||||
),
|
),
|
||||||
content: Column(
|
content: Column(
|
||||||
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
|
|
||||||
ShadButton.secondary(
|
ShadButton.secondary(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pushNamed(context, "/multi");
|
Navigator.pushNamed(context, "/multi");
|
||||||
},
|
},
|
||||||
text: const Text("Continue"),
|
text: const Text("Continue"),
|
||||||
)
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
|
||||||
|
ShadCard(
|
||||||
|
title: const Text("Setup"),
|
||||||
|
width: 300,
|
||||||
|
description: const Text(
|
||||||
|
"This button is only for debug mode. If you see this button in production, please contact support."
|
||||||
|
),
|
||||||
|
content: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
ShadButton.secondary(
|
||||||
|
onPressed: () async {
|
||||||
|
LiveInformation().announcementModule.setBundleBytes(null);
|
||||||
|
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
|
prefs.remove("AnnouncementsFileLocation");
|
||||||
|
Navigator.pushNamed(context, "/setup");
|
||||||
|
},
|
||||||
|
text: const Text("Continue"),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
ShadCard(
|
||||||
|
title: const Text("Websocket test"),
|
||||||
|
width: 300,
|
||||||
|
description: const Text(
|
||||||
|
"This button is only for debug mode. If you see this button in production, please contact support."
|
||||||
|
),
|
||||||
|
content: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 4,
|
||||||
|
),
|
||||||
|
ShadButton.secondary(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pushNamed(context, "/websocket");
|
||||||
|
},
|
||||||
|
text: const Text("Continue"),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
),
|
),
|
||||||
)
|
|
||||||
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// return Scaffold(
|
||||||
|
// body: Container(
|
||||||
|
//
|
||||||
|
// padding: const EdgeInsets.all(16),
|
||||||
|
//
|
||||||
|
// alignment: Alignment.center,
|
||||||
|
//
|
||||||
|
// child: SizedBox(
|
||||||
|
//
|
||||||
|
// // width: double.infinity,
|
||||||
|
// height: double.infinity,
|
||||||
|
//
|
||||||
|
// child: Column(
|
||||||
|
// children: [
|
||||||
|
//
|
||||||
|
// const Text(
|
||||||
|
// "Choose mode:",
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 32,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// )
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// Row(
|
||||||
|
//
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
//
|
||||||
|
// children: [
|
||||||
|
//
|
||||||
|
// Text("Test"),
|
||||||
|
//
|
||||||
|
// ShadCard(
|
||||||
|
// title: const Text("Solo mode"),
|
||||||
|
// width: double.infinity,
|
||||||
|
// description: const Text(
|
||||||
|
// "Choose this mode if you are only using this device. (No internet required)"
|
||||||
|
// ),
|
||||||
|
// content: Column(
|
||||||
|
//
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
//
|
||||||
|
// children: [
|
||||||
|
//
|
||||||
|
// const SizedBox(
|
||||||
|
// height: 4,
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// ShadButton.secondary(
|
||||||
|
// onPressed: () {
|
||||||
|
// Navigator.pushNamed(context, "/routes");
|
||||||
|
// },
|
||||||
|
// text: const Text("Continue"),
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// const SizedBox(
|
||||||
|
// width: 16,
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// ShadCard(
|
||||||
|
// title: const Text("Multi mode"),
|
||||||
|
// width: double.infinity,
|
||||||
|
// description: const Text(
|
||||||
|
// "Choose this mode if you are using multiple devices. (Internet required)"
|
||||||
|
// ),
|
||||||
|
// content: Column(
|
||||||
|
//
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
// mainAxisSize: MainAxisSize.min,
|
||||||
|
//
|
||||||
|
// children: [
|
||||||
|
//
|
||||||
|
// const SizedBox(
|
||||||
|
// height: 4,
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// ShadButton.secondary(
|
||||||
|
// onPressed: () {
|
||||||
|
// Navigator.pushNamed(context, "/multi");
|
||||||
|
// },
|
||||||
|
// text: const Text("Continue"),
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
//
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -194,92 +351,210 @@ class RoutePage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Column(
|
body: Row(
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
|
Container(
|
||||||
|
height: double.infinity,
|
||||||
|
|
||||||
|
child: Row(
|
||||||
|
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.fromLTRB(
|
||||||
|
8,
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
8
|
||||||
|
),
|
||||||
|
child: RotatedBox(
|
||||||
|
quarterTurns: 3,
|
||||||
|
child: Text(
|
||||||
|
"Routes - Nearby",
|
||||||
|
style: ShadTheme.of(context).textTheme.h3.copyWith(
|
||||||
|
height: 0.8
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Container(
|
||||||
|
width: 230,
|
||||||
|
child: Scrollbar(
|
||||||
|
thumbVisibility: true,
|
||||||
|
child: GridView.count(
|
||||||
|
crossAxisCount: 2,
|
||||||
|
padding: const EdgeInsets.fromLTRB(
|
||||||
|
4,
|
||||||
|
4,
|
||||||
|
4,
|
||||||
|
4
|
||||||
|
),
|
||||||
|
shrinkWrap: true,
|
||||||
|
children: [
|
||||||
|
..._getNearbyRoutes(
|
||||||
|
multiMode: ModalRoute.of(context)!.settings.name!.contains("multi")
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Container(
|
||||||
|
width: 2,
|
||||||
|
height: double.infinity,
|
||||||
|
color: Colors.grey.shade400,
|
||||||
|
),
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
|
height: double.infinity,
|
||||||
|
child: Row(
|
||||||
|
|
||||||
padding: const EdgeInsets.all(16),
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
|
||||||
alignment: Alignment.center,
|
|
||||||
|
|
||||||
child: SizedBox(
|
|
||||||
|
|
||||||
width: double.infinity,
|
|
||||||
|
|
||||||
child: Column(
|
|
||||||
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
Row(
|
Container(
|
||||||
children: [
|
padding: const EdgeInsets.fromLTRB(
|
||||||
|
8,
|
||||||
Text(
|
8,
|
||||||
"Routes",
|
8,
|
||||||
style: ShadTheme.of(context).textTheme.h1.copyWith(),
|
8
|
||||||
|
),
|
||||||
|
child: RotatedBox(
|
||||||
|
quarterTurns: 3,
|
||||||
|
child: Text(
|
||||||
|
"Routes - All",
|
||||||
|
style: ShadTheme.of(context).textTheme.h3.copyWith(
|
||||||
|
height: 0.8
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(),
|
child: RouteSearch(
|
||||||
|
multiMode: ModalRoute.of(context)!.settings.name!.contains("multi"),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
Container(
|
||||||
|
width: 2,
|
||||||
|
height: double.infinity,
|
||||||
|
color: Colors.grey.shade400,
|
||||||
|
),
|
||||||
|
|
||||||
|
RotatedBox(
|
||||||
|
quarterTurns: 3,
|
||||||
|
child: NavigationBar()
|
||||||
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (!kIsWeb)
|
|
||||||
Text(
|
|
||||||
"Nearby routes",
|
|
||||||
style: ShadTheme.of(context).textTheme.h4,
|
|
||||||
),
|
|
||||||
if (!kIsWeb)
|
|
||||||
FlutterCarousel(
|
|
||||||
options: CarouselOptions(
|
|
||||||
// height: 130,
|
|
||||||
viewportFraction: 0.33,
|
|
||||||
aspectRatio: 3 / 1,
|
|
||||||
enableInfiniteScroll: true,
|
|
||||||
initialPage: 1,
|
|
||||||
autoPlay: true,
|
|
||||||
autoPlayInterval: const Duration(seconds: 2),
|
|
||||||
pauseAutoPlayOnTouch: true,
|
|
||||||
pauseAutoPlayOnManualNavigate: true,
|
|
||||||
showIndicator: false,
|
|
||||||
slideIndicator: const CircularSlideIndicator(),
|
|
||||||
autoPlayAnimationDuration: const Duration(milliseconds: 800),
|
|
||||||
autoPlayCurve: Curves.bounceOut,
|
|
||||||
|
|
||||||
|
|
||||||
),
|
|
||||||
items: [
|
|
||||||
..._getNearbyRoutes()
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const Divider(),
|
|
||||||
|
|
||||||
RouteSearch(multiMode: false)
|
|
||||||
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const Divider(
|
|
||||||
height: 1,
|
|
||||||
),
|
|
||||||
NavigationBar()
|
|
||||||
],
|
],
|
||||||
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// return Scaffold(
|
||||||
|
// body: Column(
|
||||||
|
// children: [
|
||||||
|
// Expanded(
|
||||||
|
// child: Container(
|
||||||
|
//
|
||||||
|
// padding: const EdgeInsets.all(16),
|
||||||
|
//
|
||||||
|
// alignment: Alignment.center,
|
||||||
|
//
|
||||||
|
// child: SizedBox(
|
||||||
|
//
|
||||||
|
// width: double.infinity,
|
||||||
|
//
|
||||||
|
// child: Column(
|
||||||
|
//
|
||||||
|
// mainAxisSize: MainAxisSize.max,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
//
|
||||||
|
// children: [
|
||||||
|
//
|
||||||
|
// Row(
|
||||||
|
// children: [
|
||||||
|
//
|
||||||
|
// Text(
|
||||||
|
// "Routes",
|
||||||
|
// style: ShadTheme.of(context).textTheme.h1.copyWith(),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// Expanded(
|
||||||
|
// child: Container(),
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// if (!kIsWeb)
|
||||||
|
// Text(
|
||||||
|
// "Nearby routes",
|
||||||
|
// style: ShadTheme.of(context).textTheme.h4,
|
||||||
|
// ),
|
||||||
|
// if (!kIsWeb)
|
||||||
|
// FlutterCarousel(
|
||||||
|
// options: CarouselOptions(
|
||||||
|
// // height: 130,
|
||||||
|
// viewportFraction: 0.33,
|
||||||
|
// aspectRatio: 3 / 1,
|
||||||
|
// enableInfiniteScroll: true,
|
||||||
|
// initialPage: 1,
|
||||||
|
// autoPlay: true,
|
||||||
|
// autoPlayInterval: const Duration(seconds: 2),
|
||||||
|
// pauseAutoPlayOnTouch: true,
|
||||||
|
// pauseAutoPlayOnManualNavigate: true,
|
||||||
|
// showIndicator: false,
|
||||||
|
// slideIndicator: const CircularSlideIndicator(),
|
||||||
|
// autoPlayAnimationDuration: const Duration(milliseconds: 800),
|
||||||
|
// autoPlayCurve: Curves.bounceOut,
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ),
|
||||||
|
// items: [
|
||||||
|
// ..._getNearbyRoutes()
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
//
|
||||||
|
// const Divider(),
|
||||||
|
//
|
||||||
|
// RouteSearch(multiMode: false)
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ],
|
||||||
|
//
|
||||||
|
// ),
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// const Divider(
|
||||||
|
// height: 1,
|
||||||
|
// ),
|
||||||
|
// NavigationBar()
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -318,7 +593,14 @@ class _RouteSearchState extends State<RouteSearch> {
|
|||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
ShadInput(
|
Padding(
|
||||||
|
padding: const EdgeInsets.fromLTRB(
|
||||||
|
4,
|
||||||
|
4,
|
||||||
|
4,
|
||||||
|
0
|
||||||
|
),
|
||||||
|
child: ShadInput(
|
||||||
placeholder: const Text("Search for a route..."),
|
placeholder: const Text("Search for a route..."),
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
@@ -327,25 +609,26 @@ class _RouteSearchState extends State<RouteSearch> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(
|
|
||||||
height: 4,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
interactive: true,
|
|
||||||
radius: const Radius.circular(8),
|
|
||||||
thickness: 8,
|
|
||||||
thumbVisibility: true,
|
thumbVisibility: true,
|
||||||
child: GridView.count(
|
trackVisibility: true,
|
||||||
crossAxisCount: 3,
|
scrollbarOrientation: ScrollbarOrientation.bottom,
|
||||||
|
child: GridView.extent(
|
||||||
|
// padding: const EdgeInsets.all(4),
|
||||||
|
scrollDirection: Axis.vertical,
|
||||||
|
maxCrossAxisExtent: 120,
|
||||||
children: [
|
children: [
|
||||||
...routes
|
...routes
|
||||||
],
|
],
|
||||||
shrinkWrap: true,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
SizedBox(
|
||||||
|
height: 4,
|
||||||
)
|
)
|
||||||
|
|
||||||
],
|
],
|
||||||
@@ -397,11 +680,9 @@ class RouteCard extends StatelessWidget {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
return AspectRatio(
|
return ShadButton.secondary(
|
||||||
aspectRatio: 1,
|
|
||||||
child: Container(
|
|
||||||
child: ShadButton.secondary(
|
|
||||||
text: Column(
|
text: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Route \n ${route.routeNumber}",
|
"Route \n ${route.routeNumber}",
|
||||||
@@ -414,12 +695,13 @@ class RouteCard extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
width: 105,
|
width: 100,
|
||||||
height: 105,
|
height: 100,
|
||||||
|
size: ShadButtonSize.icon,
|
||||||
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showShadSheet(
|
showShadSheet(
|
||||||
side: ShadSheetSide.bottom,
|
side: ShadSheetSide.right,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
|
|
||||||
@@ -451,15 +733,7 @@ class RouteCard extends StatelessWidget {
|
|||||||
if (!multiMode) {
|
if (!multiMode) {
|
||||||
Navigator.popAndPushNamed(context, "/enroute");
|
Navigator.popAndPushNamed(context, "/enroute");
|
||||||
} else {
|
} else {
|
||||||
// Navigator.popAndPushNamed(context, "/multi/enroute");
|
Navigator.popAndPushNamed(context, "/multi/enroute");
|
||||||
Navigator.pop(context);
|
|
||||||
ShadToaster.of(context).show(
|
|
||||||
ShadToast(
|
|
||||||
title: Text("Route selected"),
|
|
||||||
description: Text("Set route to ${variant.busRoute.routeNumber} - ${variant.busStops.first.formattedStopName} -> ${variant.busStops.last.formattedStopName}"),
|
|
||||||
duration: Duration(seconds: 5),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -475,7 +749,7 @@ class RouteCard extends StatelessWidget {
|
|||||||
title: Text("Route ${route.routeNumber} - Variants"),
|
title: Text("Route ${route.routeNumber} - Variants"),
|
||||||
|
|
||||||
content: Container(
|
content: Container(
|
||||||
width: 2000,
|
width: 350,
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
maxHeight: 400
|
maxHeight: 400
|
||||||
),
|
),
|
||||||
@@ -500,8 +774,6 @@ class RouteCard extends StatelessWidget {
|
|||||||
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -826,21 +1098,24 @@ class _MultiModeSetupState extends State<MultiModeSetup> {
|
|||||||
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
const Text(
|
Text(
|
||||||
"Multi mode options:",
|
"Multi mode options:",
|
||||||
style: TextStyle(
|
style: ShadTheme.of(context).textTheme.h1.copyWith(),
|
||||||
fontSize: 32,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
Row(
|
||||||
|
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
|
||||||
ShadCard(
|
ShadCard(
|
||||||
title: const Text("Host a group"),
|
title: const Text("Host a group"),
|
||||||
width: double.infinity,
|
width: 300,
|
||||||
description: const Text(
|
description: const Text(
|
||||||
""
|
""
|
||||||
),
|
),
|
||||||
@@ -880,12 +1155,12 @@ class _MultiModeSetupState extends State<MultiModeSetup> {
|
|||||||
),
|
),
|
||||||
|
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 16,
|
width: 16,
|
||||||
),
|
),
|
||||||
|
|
||||||
ShadCard(
|
ShadCard(
|
||||||
title: const Text("Join existing group"),
|
title: const Text("Join existing group"),
|
||||||
width: double.infinity,
|
width: 300,
|
||||||
description: const Text(
|
description: const Text(
|
||||||
""
|
""
|
||||||
),
|
),
|
||||||
@@ -913,6 +1188,10 @@ class _MultiModeSetupState extends State<MultiModeSetup> {
|
|||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -1491,32 +1770,7 @@ class _FullscreenDisplayState extends State<FullscreenDisplay> {
|
|||||||
// Get the current screen orientation
|
// Get the current screen orientation
|
||||||
final Orientation orientation = MediaQuery.of(context).orientation;
|
final Orientation orientation = MediaQuery.of(context).orientation;
|
||||||
|
|
||||||
|
return Scaffold(
|
||||||
// Make the screen landscape
|
|
||||||
SystemChrome.setPreferredOrientations([
|
|
||||||
DeviceOrientation.landscapeRight,
|
|
||||||
DeviceOrientation.landscapeLeft
|
|
||||||
]);
|
|
||||||
|
|
||||||
return PopScope(
|
|
||||||
onPopInvoked: (isPop) {
|
|
||||||
if (isPop) {
|
|
||||||
// SystemChrome.setPreferredOrientations([
|
|
||||||
// DeviceOrientation.portraitUp,
|
|
||||||
// DeviceOrientation.portraitDown
|
|
||||||
// ]);
|
|
||||||
|
|
||||||
// Set the orientation back to whatever it was before
|
|
||||||
SystemChrome.setPreferredOrientations(orientation == Orientation.portrait ? [
|
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
DeviceOrientation.portraitDown
|
|
||||||
] : [
|
|
||||||
DeviceOrientation.landscapeRight,
|
|
||||||
DeviceOrientation.landscapeLeft
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Scaffold(
|
|
||||||
|
|
||||||
body: Container(
|
body: Container(
|
||||||
|
|
||||||
@@ -1547,7 +1801,6 @@ class _FullscreenDisplayState extends State<FullscreenDisplay> {
|
|||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1887,7 +2140,7 @@ List<Widget> _getNearbyRoutes({bool multiMode = false}) {
|
|||||||
|
|
||||||
|
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
// currentVector = OSGrid.toNorthingEasting(51.583781262560926, -0.020359583104595073);
|
currentVector = OSGrid.toNorthingEasting(51.583781262560926, -0.020359583104595073);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BusRoute route in busSequences.routes.values) {
|
for (BusRoute route in busSequences.routes.values) {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class AudioWrapper {
|
|||||||
|
|
||||||
print("AudioWrapper mode: $mode");
|
print("AudioWrapper mode: $mode");
|
||||||
|
|
||||||
mode = AudioWrapper_Mode.Web;
|
// mode = AudioWrapper_Mode.Web;
|
||||||
}
|
}
|
||||||
|
|
||||||
justaudio.AudioSource _convertSource_JustAudio(AudioWrapperSource source){
|
justaudio.AudioSource _convertSource_JustAudio(AudioWrapperSource source){
|
||||||
|
|||||||
38
lib/utils/web_socket_server.dart
Normal file
38
lib/utils/web_socket_server.dart
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import 'dart:isolate';
|
||||||
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:shelf/shelf.dart' as shelf;
|
||||||
|
import 'package:shelf/shelf_io.dart' as shelf_io;
|
||||||
|
import 'package:shelf_web_socket/shelf_web_socket.dart';
|
||||||
|
import 'package:web_socket_channel/io.dart'; // Import IOWebSocketChannel
|
||||||
|
|
||||||
|
void webSocketServer(SendPort sendPort) async {
|
||||||
|
final clients = <IOWebSocketChannel>[]; // Use IOWebSocketChannel
|
||||||
|
|
||||||
|
final handler = webSocketHandler((webSocket) {
|
||||||
|
clients.add(webSocket);
|
||||||
|
webSocket.stream.listen(
|
||||||
|
(message) {
|
||||||
|
print('Received: $message');
|
||||||
|
for (var client in clients) {
|
||||||
|
if (client != webSocket) {
|
||||||
|
client.sink.add(message); // Broadcast the message to other clients
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onDone: () {
|
||||||
|
clients.remove(webSocket);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
final server = await shelf_io.serve(
|
||||||
|
shelf.Pipeline().addMiddleware(shelf.logRequests()).addHandler(handler),
|
||||||
|
'0.0.0.0',
|
||||||
|
8080,
|
||||||
|
);
|
||||||
|
|
||||||
|
print('WebSocket server running at ws://${server.address.host}:${server.port}');
|
||||||
|
sendPort.send('Server running at ws://${server.address.host}:${server.port}');
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import device_info_plus
|
|||||||
import flutter_web_auth_2
|
import flutter_web_auth_2
|
||||||
import geolocator_apple
|
import geolocator_apple
|
||||||
import just_audio
|
import just_audio
|
||||||
|
import network_info_plus
|
||||||
import package_info_plus
|
import package_info_plus
|
||||||
import path_provider_foundation
|
import path_provider_foundation
|
||||||
import rive_common
|
import rive_common
|
||||||
@@ -27,6 +28,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
|||||||
FlutterWebAuth2Plugin.register(with: registry.registrar(forPlugin: "FlutterWebAuth2Plugin"))
|
FlutterWebAuth2Plugin.register(with: registry.registrar(forPlugin: "FlutterWebAuth2Plugin"))
|
||||||
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
|
GeolocatorPlugin.register(with: registry.registrar(forPlugin: "GeolocatorPlugin"))
|
||||||
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
|
JustAudioPlugin.register(with: registry.registrar(forPlugin: "JustAudioPlugin"))
|
||||||
|
NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin"))
|
||||||
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||||
RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin"))
|
RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin"))
|
||||||
|
|||||||
88
pubspec.lock
88
pubspec.lock
@@ -137,6 +137,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.18.0"
|
||||||
|
convert:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: convert
|
||||||
|
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.1.1"
|
||||||
cookie_jar:
|
cookie_jar:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -185,6 +193,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "9.0.1"
|
version: "9.0.1"
|
||||||
|
dbus:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: dbus
|
||||||
|
sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.10"
|
||||||
device_info_plus:
|
device_info_plus:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -429,6 +445,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.1"
|
||||||
|
http_methods:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http_methods
|
||||||
|
sha256: "6bccce8f1ec7b5d701e7921dca35e202d425b57e317ba1a37f2638590e29e566"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.1"
|
||||||
http_parser:
|
http_parser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -573,6 +597,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.0"
|
version: "2.0.0"
|
||||||
|
mime:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: mime
|
||||||
|
sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.5"
|
||||||
native_qr:
|
native_qr:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -581,6 +613,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.3"
|
version: "0.0.3"
|
||||||
|
network_info_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: network_info_plus
|
||||||
|
sha256: "5bd4b86e28fed5ed4e6ac7764133c031dfb7d3f46aa2a81b46f55038aa78ecc0"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.0.3"
|
||||||
|
network_info_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: network_info_plus_platform_interface
|
||||||
|
sha256: "2e193d61d3072ac17824638793d3b89c6d581ce90c11604f4ca87311b42f2706"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.0"
|
||||||
|
nm:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: nm
|
||||||
|
sha256: "2c9aae4127bdc8993206464fcc063611e0e36e72018696cd9631023a31b24254"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.5.0"
|
||||||
ntp:
|
ntp:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -869,6 +925,38 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.3.2"
|
version: "2.3.2"
|
||||||
|
shelf:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shelf
|
||||||
|
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.4.1"
|
||||||
|
shelf_router:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shelf_router
|
||||||
|
sha256: f5e5d492440a7fb165fe1e2e1a623f31f734d3370900070b2b1e0d0428d59864
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.4"
|
||||||
|
shelf_static:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shelf_static
|
||||||
|
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.2"
|
||||||
|
shelf_web_socket:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shelf_web_socket
|
||||||
|
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.0"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ dependencies:
|
|||||||
intl: any
|
intl: any
|
||||||
text_scroll: ^0.2.0
|
text_scroll: ^0.2.0
|
||||||
flutter_map: ^6.1.0
|
flutter_map: ^6.1.0
|
||||||
appwrite: ^12.0.1
|
appwrite: ^12.0.3
|
||||||
shared_preferences: ^2.2.2
|
shared_preferences: ^2.2.2
|
||||||
url_launcher: ^6.2.2
|
url_launcher: ^6.2.2
|
||||||
ntp: ^2.0.0
|
ntp: ^2.0.0
|
||||||
@@ -56,6 +56,12 @@ dependencies:
|
|||||||
native_qr: ^0.0.3
|
native_qr: ^0.0.3
|
||||||
qr_flutter: ^4.1.0
|
qr_flutter: ^4.1.0
|
||||||
flutter_scroll_shadow: ^1.2.4
|
flutter_scroll_shadow: ^1.2.4
|
||||||
|
network_info_plus: ^5.0.3
|
||||||
|
shelf: ^1.4.1
|
||||||
|
shelf_router: ^1.1.4
|
||||||
|
shelf_static: ^1.1.2
|
||||||
|
shelf_web_socket: ^2.0.0
|
||||||
|
# web_socket_channel: ^3.0.0
|
||||||
|
|
||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
|
|||||||
Reference in New Issue
Block a user