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,174 +226,225 @@ class LiveInformation {
|
|||||||
// Multi device support
|
// Multi device support
|
||||||
|
|
||||||
Future<void> createRoom(String roomCode) async {
|
Future<void> createRoom(String roomCode) async {
|
||||||
print("Creating room with code $roomCode");
|
|
||||||
|
|
||||||
// Update the room code
|
{
|
||||||
this.roomCode = roomCode;
|
// Local Room
|
||||||
|
await networkingModule.startWebSocketServer();
|
||||||
// Enable host mode
|
inRoom = true;
|
||||||
isHost = true;
|
_listenerReciept = networkingModule.onMessageReceived?.addListener(
|
||||||
|
(p0) {
|
||||||
// Access the database
|
print("Received local command: $p0");
|
||||||
final client = auth.client;
|
ExecuteCommand(p0);
|
||||||
final databases = appwrite.Databases(client);
|
}
|
||||||
|
|
||||||
// Remove any existing documents
|
|
||||||
final existingDocuments = await databases.listDocuments(
|
|
||||||
databaseId: "6633e85400036415ab0f",
|
|
||||||
collectionId: "6633e85d0020f52f3771",
|
|
||||||
queries: [
|
|
||||||
appwrite.Query.search("SessionID", roomCode)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
for (var document in existingDocuments.documents) {
|
|
||||||
await databases.deleteDocument(
|
|
||||||
databaseId: "6633e85400036415ab0f",
|
|
||||||
collectionId: "6633e85d0020f52f3771",
|
|
||||||
documentId: document.$id
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the document
|
{
|
||||||
final document = await databases.createDocument(
|
// Cloud Room
|
||||||
databaseId: "6633e85400036415ab0f",
|
print("Creating room with code $roomCode");
|
||||||
collectionId: "6633e85d0020f52f3771",
|
|
||||||
documentId: appwrite.ID.unique(),
|
|
||||||
data: {
|
|
||||||
"SessionID": roomCode,
|
|
||||||
"LastUpdater": auth.userID,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Listen for changes
|
// Update the room code
|
||||||
// { Breaks due to bug in appwrite
|
this.roomCode = roomCode;
|
||||||
// final realtime = appwrite.Realtime(client);
|
|
||||||
//
|
// Enable host mode
|
||||||
// if (_subscription != null) {
|
isHost = true;
|
||||||
// _subscription!.close();
|
inRoom = true;
|
||||||
// }
|
// Access the database
|
||||||
//
|
final client = auth.client;
|
||||||
// _subscription = realtime.subscribe(
|
final databases = appwrite.Databases(client);
|
||||||
// ['databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}']
|
|
||||||
// );
|
// Remove any existing documents
|
||||||
// _subscription!.stream.listen(ServerListener);
|
final existingDocuments = await databases.listDocuments(
|
||||||
// }
|
databaseId: "6633e85400036415ab0f",
|
||||||
// Listen for changes
|
collectionId: "6633e85d0020f52f3771",
|
||||||
if (_keepAliveConnection != null) {
|
queries: [
|
||||||
try {
|
appwrite.Query.search("SessionID", roomCode)
|
||||||
_keepAliveConnection!.close();
|
]
|
||||||
} catch (e) {
|
);
|
||||||
print("Failed to close connection... oh well");
|
for (var document in existingDocuments.documents) {
|
||||||
|
await databases.deleteDocument(
|
||||||
|
databaseId: "6633e85400036415ab0f",
|
||||||
|
collectionId: "6633e85d0020f52f3771",
|
||||||
|
documentId: document.$id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create the document
|
||||||
|
final document = await databases.createDocument(
|
||||||
|
databaseId: "6633e85400036415ab0f",
|
||||||
|
collectionId: "6633e85d0020f52f3771",
|
||||||
|
documentId: appwrite.ID.unique(),
|
||||||
|
data: {
|
||||||
|
"SessionID": roomCode,
|
||||||
|
"LastUpdater": auth.userID,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Listen for changes
|
||||||
|
if (_keepAliveConnection != null) {
|
||||||
|
try {
|
||||||
|
_keepAliveConnection!.close();
|
||||||
|
} catch (e) {
|
||||||
|
print("Failed to close connection... oh well");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String APPWRITE_ENDPOINT_URL = "https://cloud.appwrite.io/v1";
|
||||||
|
String domain = APPWRITE_ENDPOINT_URL.replaceAll("https://", "").trim();
|
||||||
|
_keepAliveConnection = RealtimeKeepAliveConnection(
|
||||||
|
channels: ['databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}'],
|
||||||
|
onData: ServerListener,
|
||||||
|
domain: domain,
|
||||||
|
client: auth.client,
|
||||||
|
onError: (e) {
|
||||||
|
print("Workarround Error: $e");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
_keepAliveConnection!.initialize();
|
||||||
|
|
||||||
|
|
||||||
|
// Update the room document ID
|
||||||
|
roomDocumentID = document.$id;
|
||||||
|
|
||||||
|
print("Created room with code $roomCode");
|
||||||
}
|
}
|
||||||
|
|
||||||
String APPWRITE_ENDPOINT_URL = "https://cloud.appwrite.io/v1";
|
|
||||||
String domain = APPWRITE_ENDPOINT_URL.replaceAll("https://", "").trim();
|
|
||||||
_keepAliveConnection = RealtimeKeepAliveConnection(
|
|
||||||
channels: ['databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}'],
|
|
||||||
onData: ServerListener,
|
|
||||||
domain: domain,
|
|
||||||
client: auth.client,
|
|
||||||
onError: (e) {
|
|
||||||
print("Workarround Error: $e");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
_keepAliveConnection!.initialize();
|
|
||||||
|
|
||||||
|
|
||||||
// Update the room document ID
|
|
||||||
roomDocumentID = document.$id;
|
|
||||||
|
|
||||||
print("Created room with code $roomCode");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> joinRoom(String roomCode) async {
|
Future<void> joinRoom(String infoJson) async {
|
||||||
print("Joining room with code $roomCode");
|
|
||||||
|
|
||||||
// Disable host mode
|
try {
|
||||||
isHost = false;
|
{
|
||||||
|
// sync
|
||||||
|
String routeNumber = jsonDecode(infoJson)["sync"]["route"];
|
||||||
|
int routeVariantIndex = jsonDecode(infoJson)["sync"]["routeVariant"];
|
||||||
|
|
||||||
// Update the room code
|
setRouteVariantQuery(routeNumber, routeVariantIndex);
|
||||||
this.roomCode = roomCode;
|
|
||||||
|
|
||||||
// Access the database
|
LiveInformation().announcementModule.queueAnnouncementByRouteVariant(routeVariant: _currentRouteVariant!, sendToServer: false);
|
||||||
final client = auth.client;
|
}
|
||||||
final databases = appwrite.Databases(client);
|
} catch (e) {
|
||||||
|
print("Failed to sync route");
|
||||||
// Get the document
|
|
||||||
final response = await databases.listDocuments(
|
|
||||||
databaseId: "6633e85400036415ab0f",
|
|
||||||
collectionId: "6633e85d0020f52f3771",
|
|
||||||
queries: [
|
|
||||||
appwrite.Query.search("SessionID", roomCode)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.documents.isEmpty) {
|
|
||||||
throw Exception("Room not found");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final document = response.documents.first;
|
{
|
||||||
|
// Local Room
|
||||||
|
|
||||||
// Listen for changes
|
String host = jsonDecode(infoJson)["local"]["host"];
|
||||||
// {
|
|
||||||
// final realtime = appwrite.Realtime(client);
|
if (await networkingModule.connectToWebSocketServer(host)){
|
||||||
//
|
print("Connected to local room at $host");
|
||||||
// if (_subscription != null) {
|
|
||||||
// _subscription!.close();
|
_listenerReciept = networkingModule.onMessageReceived?.addListener(
|
||||||
// }
|
(p0) {
|
||||||
//
|
print("Received local command: $p0");
|
||||||
// _subscription = realtime.subscribe([
|
ExecuteCommand(p0);
|
||||||
// 'databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}'
|
}
|
||||||
// ]);
|
);
|
||||||
//
|
inRoom = true;
|
||||||
// _subscription!.stream.listen(ServerListener);
|
return; // We dont need to connect to the cloud room if we are connected to the local room.
|
||||||
// }
|
} else {
|
||||||
// Listen for changes
|
print("Failed to connect to local room at $host");
|
||||||
if (_keepAliveConnection != null) {
|
print("Falling back to cloud room");
|
||||||
try {
|
|
||||||
_keepAliveConnection!.close();
|
|
||||||
} catch (e) {
|
|
||||||
print("Failed to close connection... oh well");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String APPWRITE_ENDPOINT_URL = "https://cloud.appwrite.io/v1";
|
{
|
||||||
String domain = APPWRITE_ENDPOINT_URL.replaceAll("https://", "").trim();
|
// Cloud Room
|
||||||
_keepAliveConnection = RealtimeKeepAliveConnection(
|
|
||||||
channels: ['databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}'],
|
|
||||||
onData: ServerListener,
|
|
||||||
domain: domain,
|
|
||||||
client: auth.client,
|
|
||||||
onError: (e) {
|
|
||||||
print("Workarround Error: $e");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
_keepAliveConnection!.initialize();
|
|
||||||
|
|
||||||
// Update the room document ID
|
String roomCode = jsonDecode(infoJson)["cloud"]["roomCode"];
|
||||||
roomDocumentID = document.$id;
|
|
||||||
|
|
||||||
// Get the current route
|
print("Joining cloud room with code $roomCode");
|
||||||
try {
|
|
||||||
String routeNumber = document.data["CurrentRoute"];
|
|
||||||
int routeVariantIndex = document.data["CurrentRouteVariant"];
|
|
||||||
|
|
||||||
await setRouteVariantQuery(routeNumber, routeVariantIndex);
|
// Disable host mode
|
||||||
print("Set route to $routeNumber $routeVariantIndex");
|
isHost = false;
|
||||||
} catch (e) {
|
|
||||||
print("Failed to set route");
|
// Update the room code
|
||||||
|
this.roomCode = roomCode;
|
||||||
|
|
||||||
|
// Access the database
|
||||||
|
final client = auth.client;
|
||||||
|
final databases = appwrite.Databases(client);
|
||||||
|
|
||||||
|
// Get the document
|
||||||
|
final response = await databases.listDocuments(
|
||||||
|
databaseId: "6633e85400036415ab0f",
|
||||||
|
collectionId: "6633e85d0020f52f3771",
|
||||||
|
queries: [
|
||||||
|
appwrite.Query.search("SessionID", roomCode)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.documents.isEmpty) {
|
||||||
|
throw Exception("Room not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
final document = response.documents.first;
|
||||||
|
|
||||||
|
// Listen for changes
|
||||||
|
if (_keepAliveConnection != null) {
|
||||||
|
try {
|
||||||
|
_keepAliveConnection!.close();
|
||||||
|
} catch (e) {
|
||||||
|
print("Failed to close connection... oh well");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String APPWRITE_ENDPOINT_URL = "https://cloud.appwrite.io/v1";
|
||||||
|
String domain = APPWRITE_ENDPOINT_URL.replaceAll("https://", "").trim();
|
||||||
|
_keepAliveConnection = RealtimeKeepAliveConnection(
|
||||||
|
channels: ['databases.6633e85400036415ab0f.collections.6633e85d0020f52f3771.documents.${document.$id}'],
|
||||||
|
onData: ServerListener,
|
||||||
|
domain: domain,
|
||||||
|
client: auth.client,
|
||||||
|
onError: (e) {
|
||||||
|
print("Workarround Error: $e");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
_keepAliveConnection!.initialize();
|
||||||
|
|
||||||
|
// Update the room document ID
|
||||||
|
roomDocumentID = document.$id;
|
||||||
|
|
||||||
|
// Get the current route
|
||||||
|
try {
|
||||||
|
String routeNumber = document.data["CurrentRoute"];
|
||||||
|
int routeVariantIndex = document.data["CurrentRouteVariant"];
|
||||||
|
|
||||||
|
await setRouteVariantQuery(routeNumber, routeVariantIndex);
|
||||||
|
print("Set route to $routeNumber $routeVariantIndex");
|
||||||
|
} catch (e) {
|
||||||
|
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,34 +636,48 @@ class LiveInformation {
|
|||||||
|
|
||||||
Future<void> SendCommand(String command) async {
|
Future<void> SendCommand(String command) async {
|
||||||
|
|
||||||
final client = auth.client;
|
{
|
||||||
final databases = appwrite.Databases(client);
|
// Local Commands
|
||||||
|
|
||||||
final response = await databases.listDocuments(
|
networkingModule.sendMessage(command);
|
||||||
databaseId: "6633e85400036415ab0f",
|
}
|
||||||
collectionId: "6633e85d0020f52f3771",
|
|
||||||
queries: [
|
|
||||||
appwrite.Query.search("SessionID", roomCode!)
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
List<String> pastCommands = [];
|
|
||||||
|
|
||||||
response.documents.first.data["Commands"].forEach((element) {
|
{
|
||||||
pastCommands.add(element);
|
// Cloud Commands
|
||||||
});
|
|
||||||
|
final client = auth.client;
|
||||||
|
final databases = appwrite.Databases(client);
|
||||||
|
|
||||||
|
final response = await databases.listDocuments(
|
||||||
|
databaseId: "6633e85400036415ab0f",
|
||||||
|
collectionId: "6633e85d0020f52f3771",
|
||||||
|
queries: [
|
||||||
|
appwrite.Query.search("SessionID", roomCode!)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
List<String> pastCommands = [];
|
||||||
|
|
||||||
|
response.documents.first.data["Commands"].forEach((element) {
|
||||||
|
pastCommands.add(element);
|
||||||
|
});
|
||||||
|
|
||||||
|
pastCommands.add(command);
|
||||||
|
|
||||||
|
final document = await databases.updateDocument(
|
||||||
|
databaseId: "6633e85400036415ab0f",
|
||||||
|
collectionId: "6633e85d0020f52f3771",
|
||||||
|
documentId: roomDocumentID!,
|
||||||
|
data: {
|
||||||
|
"Commands": pastCommands,
|
||||||
|
"LastUpdater": auth.userID,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pastCommands.add(command);
|
|
||||||
|
|
||||||
final document = await databases.updateDocument(
|
|
||||||
databaseId: "6633e85400036415ab0f",
|
|
||||||
collectionId: "6633e85d0020f52f3771",
|
|
||||||
documentId: roomDocumentID!,
|
|
||||||
data: {
|
|
||||||
"Commands": pastCommands,
|
|
||||||
"LastUpdater": auth.userID,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> _splitCommand(String command) {
|
List<String> _splitCommand(String 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,260 +20,207 @@ 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");
|
||||||
|
}
|
||||||
|
|
||||||
body: Container(
|
|
||||||
child: Row(
|
|
||||||
|
|
||||||
children: [
|
},
|
||||||
|
|
||||||
const SizedBox(
|
child: Scaffold(
|
||||||
width: 10,
|
|
||||||
),
|
|
||||||
|
|
||||||
Container(
|
body: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
child: Row(
|
||||||
vertical: 10,
|
|
||||||
|
children: [
|
||||||
|
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
),
|
),
|
||||||
|
|
||||||
child: IntrinsicWidth(
|
Container(
|
||||||
child: Column(
|
padding: const EdgeInsets.symmetric(
|
||||||
children: [
|
vertical: 10,
|
||||||
|
),
|
||||||
|
|
||||||
if (LiveInformation().roomDocumentID != null)
|
child: IntrinsicWidth(
|
||||||
Tooltip(
|
child: Column(
|
||||||
child: ShadButton(
|
children: [
|
||||||
icon: const Icon(Icons.network_check),
|
|
||||||
|
ShadButton.outline(
|
||||||
|
icon: const Icon(Icons.menu),
|
||||||
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) {
|
builder: (context) {
|
||||||
return ShadSheet(
|
return ShadSheet(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(0),
|
||||||
content: Column(
|
content: Container(
|
||||||
children: [
|
width: 225,
|
||||||
Text("Room ID: ${LiveInformation().roomDocumentID}"),
|
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) {
|
||||||
|
return ShadSheet(
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
content: Column(
|
||||||
|
children: [
|
||||||
|
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"),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
],
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
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');
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
message: "Room information",
|
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 220,
|
height: 220,
|
||||||
child: RotatedBox(
|
child: RotatedBox(
|
||||||
quarterTurns: 3,
|
quarterTurns: 3,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
ShadButton(
|
ShadButton(
|
||||||
text: const Text("Manual Announcements"),
|
text: const Text("Manual Announcements"),
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
||||||
List<Widget> announcements = [];
|
List<Widget> announcements = [];
|
||||||
|
|
||||||
for (var announcement in LiveInformation().announcementModule.manualAnnouncements) {
|
for (var announcement in LiveInformation().announcementModule.manualAnnouncements) {
|
||||||
|
|
||||||
announcements.add(
|
announcements.add(
|
||||||
ShadButton(
|
ShadButton(
|
||||||
text: SizedBox(
|
text: SizedBox(
|
||||||
width: 200-42,
|
width: 200-42,
|
||||||
child: Text(announcement.shortName),
|
child: Text(announcement.shortName),
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
|
|
||||||
if (closeDialogWidget.closeDialog) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
LiveInformation().announcementModule.queueAnnouncementByInfoIndex(
|
|
||||||
infoIndex: LiveInformation().announcementModule.manualAnnouncements.indexOf(announcement),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
print(announcements.length);
|
|
||||||
|
|
||||||
showShadSheet(
|
|
||||||
context: context,
|
|
||||||
side: ShadSheetSide.left,
|
|
||||||
|
|
||||||
builder: (context) {
|
|
||||||
return ShadSheet(
|
|
||||||
padding: const EdgeInsets.all(0),
|
|
||||||
|
|
||||||
content: Container(
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
SizedBox(
|
|
||||||
width: 5,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
vertical: 10,
|
|
||||||
),
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
height: double.infinity,
|
|
||||||
width: 35,
|
|
||||||
child: RotatedBox(
|
|
||||||
quarterTurns: 3,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Manual Ann'",
|
|
||||||
style: ShadTheme.of(context).textTheme.h3
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
width: 16,
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
width: 1,
|
|
||||||
height: 200,
|
|
||||||
color: Colors.grey,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
closeDialogWidget
|
|
||||||
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
|
|
||||||
// width: 220,
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
|
|
||||||
child: Scrollbar(
|
|
||||||
thumbVisibility: true,
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
reverse: true,
|
|
||||||
child: Container(
|
|
||||||
margin: const EdgeInsets.fromLTRB(
|
|
||||||
0,
|
|
||||||
10,
|
|
||||||
10,
|
|
||||||
10
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
children: announcements.reversed.toList(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
onPressed: () {
|
||||||
|
|
||||||
|
if (closeDialogWidget.closeDialog) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
LiveInformation().announcementModule.queueAnnouncementByInfoIndex(
|
||||||
|
infoIndex: LiveInformation().announcementModule.manualAnnouncements.indexOf(announcement),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
},
|
print(announcements.length);
|
||||||
),
|
|
||||||
ShadButton(
|
|
||||||
text: const Text("Bus Stop Announcements"),
|
|
||||||
width: double.infinity,
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
|
||||||
onPressed: () {
|
|
||||||
|
|
||||||
showShadSheet(
|
showShadSheet(
|
||||||
context: context,
|
context: context,
|
||||||
side: ShadSheetSide.left,
|
side: ShadSheetSide.left,
|
||||||
|
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
|
|
||||||
List<Widget> announcements = [];
|
|
||||||
|
|
||||||
LiveInformation info = LiveInformation();
|
|
||||||
|
|
||||||
for (var busStop in info.getRouteVariant()!.busStops) {
|
|
||||||
|
|
||||||
if (info.trackerModule.nearestStop == busStop) {
|
|
||||||
announcements.add(
|
|
||||||
ShadButton(
|
|
||||||
text: SizedBox(
|
|
||||||
width: 200-42,
|
|
||||||
child: Text(
|
|
||||||
"-> ${busStop.formattedStopName}",
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
backgroundColor: Colors.amber,
|
|
||||||
onPressed: () {
|
|
||||||
if (closeDialogWidget.closeDialog) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
LiveInformation().announcementModule.queueAnnounceByAudioName(
|
|
||||||
displayText: busStop.formattedStopName,
|
|
||||||
audioNames: [busStop.getAudioFileName()],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
announcements.add(
|
|
||||||
ShadButton(
|
|
||||||
text: SizedBox(
|
|
||||||
width: 200-42,
|
|
||||||
child: Text(
|
|
||||||
busStop.formattedStopName,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onPressed: () {
|
|
||||||
if (closeDialogWidget.closeDialog) {
|
|
||||||
Navigator.pop(context);
|
|
||||||
}
|
|
||||||
LiveInformation().announcementModule.queueAnnounceByAudioName(
|
|
||||||
displayText: busStop.formattedStopName,
|
|
||||||
audioNames: [busStop.getAudioFileName()],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollController controller = ScrollController();
|
|
||||||
|
|
||||||
// Scroll to the current bus stop
|
|
||||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
|
||||||
|
|
||||||
double offset = (info.getRouteVariant()!.busStops.indexOf(info.trackerModule.nearestStop!) * 50);
|
|
||||||
|
|
||||||
// Offset the offset so that its in the middle of the screen
|
|
||||||
offset -= (MediaQuery.of(context).size.height / 2) - 25;
|
|
||||||
|
|
||||||
// controller.jumpTo(offset);
|
|
||||||
});
|
|
||||||
|
|
||||||
return ShadSheet(
|
return ShadSheet(
|
||||||
padding: const EdgeInsets.all(0),
|
padding: const EdgeInsets.all(0),
|
||||||
|
|
||||||
@@ -297,8 +247,8 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Bus Stops",
|
"Manual Ann'",
|
||||||
style: ShadTheme.of(context).textTheme.h3
|
style: ShadTheme.of(context).textTheme.h3
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 16,
|
width: 16,
|
||||||
@@ -324,16 +274,14 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
|
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
thumbVisibility: true,
|
thumbVisibility: true,
|
||||||
controller: controller,
|
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
reverse: true,
|
reverse: true,
|
||||||
controller: controller,
|
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: const EdgeInsets.fromLTRB(
|
margin: const EdgeInsets.fromLTRB(
|
||||||
0,
|
0,
|
||||||
10,
|
10,
|
||||||
10,
|
10,
|
||||||
10
|
10
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: announcements.reversed.toList(),
|
children: announcements.reversed.toList(),
|
||||||
@@ -347,108 +295,272 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
ShadButton(
|
||||||
|
text: const Text("Bus Stop Announcements"),
|
||||||
|
enabled: LiveInformation().getRouteVariant() != null,
|
||||||
|
width: double.infinity,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
|
onPressed: () {
|
||||||
|
|
||||||
|
showShadSheet(
|
||||||
|
context: context,
|
||||||
|
side: ShadSheetSide.left,
|
||||||
|
|
||||||
|
builder: (context) {
|
||||||
|
|
||||||
|
List<Widget> announcements = [];
|
||||||
|
|
||||||
|
LiveInformation info = LiveInformation();
|
||||||
|
|
||||||
|
for (var busStop in info.getRouteVariant()!.busStops) {
|
||||||
|
|
||||||
|
if (info.trackerModule.nearestStop == busStop) {
|
||||||
|
announcements.add(
|
||||||
|
ShadButton(
|
||||||
|
text: SizedBox(
|
||||||
|
width: 200-42,
|
||||||
|
child: Text(
|
||||||
|
"-> ${busStop.formattedStopName}",
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
backgroundColor: Colors.amber,
|
||||||
|
onPressed: () {
|
||||||
|
if (closeDialogWidget.closeDialog) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
LiveInformation().announcementModule.queueAnnounceByAudioName(
|
||||||
|
displayText: busStop.formattedStopName,
|
||||||
|
audioNames: [busStop.getAudioFileName()],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
announcements.add(
|
||||||
|
ShadButton(
|
||||||
|
text: SizedBox(
|
||||||
|
width: 200-42,
|
||||||
|
child: Text(
|
||||||
|
busStop.formattedStopName,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
if (closeDialogWidget.closeDialog) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
LiveInformation().announcementModule.queueAnnounceByAudioName(
|
||||||
|
displayText: busStop.formattedStopName,
|
||||||
|
audioNames: [busStop.getAudioFileName()],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollController controller = ScrollController();
|
||||||
|
|
||||||
|
// Scroll to the current bus stop
|
||||||
|
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||||
|
|
||||||
|
double offset = (info.getRouteVariant()!.busStops.indexOf(info.trackerModule.nearestStop!) * 50);
|
||||||
|
|
||||||
|
// Offset the offset so that its in the middle of the screen
|
||||||
|
offset -= (MediaQuery.of(context).size.height / 2) - 25;
|
||||||
|
|
||||||
|
// controller.jumpTo(offset);
|
||||||
|
});
|
||||||
|
|
||||||
|
return ShadSheet(
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
|
||||||
|
content: Container(
|
||||||
|
height: MediaQuery.of(context).size.height,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: 5,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
vertical: 10,
|
||||||
|
),
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
height: double.infinity,
|
||||||
|
width: 35,
|
||||||
|
child: RotatedBox(
|
||||||
|
quarterTurns: 3,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Bus Stops",
|
||||||
|
style: ShadTheme.of(context).textTheme.h3
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 1,
|
||||||
|
height: 200,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
|
||||||
|
closeDialogWidget
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
|
||||||
|
// width: 220,
|
||||||
|
height: MediaQuery.of(context).size.height,
|
||||||
|
|
||||||
|
child: Scrollbar(
|
||||||
|
thumbVisibility: true,
|
||||||
|
controller: controller,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
reverse: true,
|
||||||
|
controller: controller,
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.fromLTRB(
|
||||||
|
0,
|
||||||
|
10,
|
||||||
|
10,
|
||||||
|
10
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: announcements.reversed.toList(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
const ShadButton(
|
||||||
|
icon: Icon(Icons.stop),
|
||||||
|
width: double.infinity,
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
|
),
|
||||||
|
|
||||||
|
ShadButton(
|
||||||
|
// text: const Text("Announce Destination"),
|
||||||
|
icon: const Icon(Icons.bus_alert),
|
||||||
|
width: double.infinity,
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
|
onPressed: () {
|
||||||
|
LiveInformation info = LiveInformation();
|
||||||
|
|
||||||
|
BusRouteVariant? routeVariant = info.getRouteVariant();
|
||||||
|
|
||||||
|
if (routeVariant != null) {
|
||||||
|
info.announcementModule.queueAnnouncementByRouteVariant(
|
||||||
|
routeVariant: routeVariant,
|
||||||
|
sendToServer: ModalRoute.of(context)!.settings.name!.contains("multi")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
|
||||||
|
decoration: const BoxDecoration(
|
||||||
|
color: Colors.black,
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
|
|
||||||
|
),
|
||||||
|
|
||||||
|
margin: const EdgeInsets.all(10),
|
||||||
|
padding: const EdgeInsets.all(10),
|
||||||
|
|
||||||
|
width: double.infinity,
|
||||||
|
height: double.infinity,
|
||||||
|
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
|
||||||
|
alignment: Alignment.center,
|
||||||
|
|
||||||
|
child: ibus_display(
|
||||||
|
hasBorder: false,
|
||||||
|
),
|
||||||
|
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
|
||||||
|
alignment: Alignment.bottomRight,
|
||||||
|
|
||||||
|
child: ShadButton.ghost(
|
||||||
|
icon: const Icon(Icons.fullscreen),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pushNamed(context, '/display');
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
|
||||||
|
alignment: Alignment.bottomLeft,
|
||||||
|
|
||||||
|
child: ShadButton.ghost(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.popUntil(context, (route) {
|
||||||
|
return route.settings.name == '/multi' || route.settings.name == '/routes';
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
)
|
)
|
||||||
),
|
],
|
||||||
|
),
|
||||||
const ShadButton(
|
|
||||||
icon: Icon(Icons.stop),
|
|
||||||
width: double.infinity,
|
|
||||||
),
|
|
||||||
|
|
||||||
ShadButton(
|
|
||||||
// text: const Text("Announce Destination"),
|
|
||||||
icon: const Icon(Icons.location_on),
|
|
||||||
width: double.infinity,
|
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
|
||||||
onPressed: () {
|
|
||||||
LiveInformation info = LiveInformation();
|
|
||||||
|
|
||||||
BusRouteVariant? routeVariant = info.getRouteVariant();
|
|
||||||
|
|
||||||
if (routeVariant != null) {
|
|
||||||
info.announcementModule.queueAnnouncementByRouteVariant(
|
|
||||||
routeVariant: routeVariant,
|
|
||||||
sendToServer: false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
|
|
||||||
),
|
],
|
||||||
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
|
|
||||||
decoration: const BoxDecoration(
|
|
||||||
color: Colors.black,
|
|
||||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
|
||||||
|
|
||||||
),
|
|
||||||
|
|
||||||
margin: const EdgeInsets.all(10),
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
|
|
||||||
alignment: Alignment.center,
|
|
||||||
|
|
||||||
child: ibus_display(
|
|
||||||
hasBorder: false,
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
|
|
||||||
alignment: Alignment.bottomRight,
|
|
||||||
|
|
||||||
child: ShadButton.ghost(
|
|
||||||
icon: const Icon(Icons.fullscreen),
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pushNamed(context, '/display');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
|
|
||||||
alignment: Alignment.bottomLeft,
|
|
||||||
|
|
||||||
child: ShadButton.ghost(
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
|
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,105 +174,172 @@ class _page2State extends State<_page2> {
|
|||||||
height: 16,
|
height: 16,
|
||||||
),
|
),
|
||||||
|
|
||||||
ShadCard(
|
SingleChildScrollView(
|
||||||
width: double.infinity,
|
scrollDirection: Axis.horizontal,
|
||||||
title: Text(
|
child: Row(
|
||||||
"Location",
|
|
||||||
),
|
|
||||||
description: Text(
|
|
||||||
"Your location is required for automatically updating your nearest bus stop."
|
|
||||||
),
|
|
||||||
content: Container(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
|
|
||||||
SizedBox(
|
// mainAxisSize: MainAxisSize.min,
|
||||||
height: 4,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
|
||||||
|
children: [
|
||||||
|
ShadCard(
|
||||||
|
width: 300,
|
||||||
|
height: 200,
|
||||||
|
title: Text(
|
||||||
|
"Location",
|
||||||
),
|
),
|
||||||
|
description: Text(
|
||||||
FutureBuilder(
|
"Your location is required for automatically updating your nearest bus stop."
|
||||||
future: Permission.location.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.location.request();
|
|
||||||
setState(() {
|
|
||||||
|
|
||||||
});
|
|
||||||
},
|
|
||||||
enabled: isEnabled,
|
|
||||||
backgroundColor: color,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
],
|
content: Container(
|
||||||
),
|
child: Column(
|
||||||
),
|
children: [
|
||||||
),
|
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 16,
|
height: 4,
|
||||||
),
|
),
|
||||||
|
|
||||||
ShadCard(
|
FutureBuilder(
|
||||||
width: double.infinity,
|
future: Permission.location.isGranted,
|
||||||
title: Text(
|
builder: (context, val) {
|
||||||
"Storage",
|
bool isEnabled = true;
|
||||||
),
|
String text = "Request permission";
|
||||||
description: Text(
|
Color color = Colors.white;
|
||||||
"Storage access is required to access recorded announcements."
|
|
||||||
),
|
|
||||||
content: Container(
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
|
|
||||||
SizedBox(
|
if (val.hasData) {
|
||||||
height: 4,
|
isEnabled = !val.data!;
|
||||||
|
}
|
||||||
|
if (!isEnabled) {
|
||||||
|
text = "Permission granted!";
|
||||||
|
color = Colors.green.shade400;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ShadButton(
|
||||||
|
text: Text(text),
|
||||||
|
onPressed: () async {
|
||||||
|
await Permission.location.request();
|
||||||
|
setState(() {
|
||||||
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
enabled: isEnabled,
|
||||||
|
backgroundColor: color,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
|
||||||
FutureBuilder(
|
SizedBox(
|
||||||
future: Permission.manageExternalStorage.isGranted,
|
width: 16,
|
||||||
builder: (context, val) {
|
),
|
||||||
bool isEnabled = true;
|
|
||||||
String text = "Request permission";
|
|
||||||
Color color = Colors.white;
|
|
||||||
|
|
||||||
if (val.hasData) {
|
ShadCard(
|
||||||
isEnabled = !val.data!;
|
width: 300,
|
||||||
}
|
height: 200,
|
||||||
if (!isEnabled) {
|
title: Text(
|
||||||
text = "Permission granted!";
|
"Storage",
|
||||||
color = Colors.green.shade400;
|
),
|
||||||
}
|
description: Text(
|
||||||
|
"Storage access is required to access recorded announcements."
|
||||||
|
),
|
||||||
|
content: Container(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
|
||||||
return ShadButton(
|
SizedBox(
|
||||||
text: Text(text),
|
height: 4,
|
||||||
onPressed: () async {
|
),
|
||||||
await Permission.manageExternalStorage.request();
|
|
||||||
setState(() {
|
|
||||||
|
|
||||||
});
|
FutureBuilder(
|
||||||
},
|
future: Permission.manageExternalStorage.isGranted,
|
||||||
enabled: isEnabled,
|
builder: (context, val) {
|
||||||
backgroundColor: color,
|
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(
|
||||||
|
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,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
@@ -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();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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