All dem changes
This commit is contained in:
@@ -17,6 +17,19 @@ class ArcDashboard extends StatefulWidget {
|
||||
State<ArcDashboard> createState() => _ArcDashboardState();
|
||||
}
|
||||
|
||||
String _rmconString(RoomConnectionMethod method) {
|
||||
switch (method) {
|
||||
case RoomConnectionMethod.Cloud:
|
||||
return "Cloud";
|
||||
case RoomConnectionMethod.Local:
|
||||
return "Local";
|
||||
case RoomConnectionMethod.P2P:
|
||||
return "P2P";
|
||||
case RoomConnectionMethod.None:
|
||||
return "None";
|
||||
}
|
||||
}
|
||||
|
||||
class _ArcDashboardState extends State<ArcDashboard> {
|
||||
_closeDialogueChecker closeDialogWidget = _closeDialogueChecker();
|
||||
|
||||
@@ -91,6 +104,8 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
||||
onPressed: () {
|
||||
bool multiMode = ModalRoute.of(context)!.settings.name!.contains("multi");
|
||||
|
||||
LiveInformation().p2pModule.startDiscovery();
|
||||
|
||||
showShadSheet(
|
||||
context: context,
|
||||
side: ShadSheetSide.left,
|
||||
@@ -120,28 +135,149 @@ class _ArcDashboardState extends State<ArcDashboard> {
|
||||
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"),
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
content: Container(
|
||||
width: 400,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"Room Information",
|
||||
style: ShadTheme.of(context).textTheme.h2
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
if (LiveInformation().isHost)
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.amber,
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
),
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Hosting room",
|
||||
style: ShadTheme.of(context).textTheme.h4.copyWith(
|
||||
height: 0.9
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
)
|
||||
else
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.amber,
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
),
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Connected to room via:",
|
||||
style: ShadTheme.of(context).textTheme.h4.copyWith(
|
||||
height: 0.9
|
||||
)
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(
|
||||
_rmconString(LiveInformation().connectionMethod) + " connection",
|
||||
style: ShadTheme.of(context).textTheme.p.copyWith(
|
||||
height: 0.9
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
ShadButton(
|
||||
text: Text("Show room QR Code"),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
onPressed: () {
|
||||
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ShadDialog(
|
||||
|
||||
title: Text("Room QR Code"),
|
||||
content: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: QrImageView(
|
||||
data: LiveInformation().generateRoomInfo(),
|
||||
size: 200,
|
||||
backgroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
ShadButton(
|
||||
text: Text("Copy Room Info"),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: LiveInformation().generateRoomInfo()));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text("Copied room info to clipboard"),
|
||||
)
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
),
|
||||
|
||||
ShadButton(
|
||||
text: Text("Make nearby discoverable"),
|
||||
onPressed: () {
|
||||
LiveInformation().p2pModule.startDiscovery();
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast(
|
||||
title: Text("Discoverable"),
|
||||
description: Text("If it wasnt before, your device is now discoverable to nearby devices"),
|
||||
duration: const Duration(seconds: 3),
|
||||
)
|
||||
);
|
||||
},
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -138,6 +137,12 @@ class _page2State extends State<_page2> {
|
||||
await Permission.location.isGranted
|
||||
]);
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
perms.add(
|
||||
await Permission.nearbyWifiDevices.isGranted
|
||||
);
|
||||
}
|
||||
|
||||
return !perms.contains(false);
|
||||
}
|
||||
|
||||
@@ -154,8 +159,6 @@ class _page2State extends State<_page2> {
|
||||
|
||||
child: SizedBox(
|
||||
|
||||
// width: double.infinity,
|
||||
|
||||
child: Column(
|
||||
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -174,172 +177,232 @@ class _page2State extends State<_page2> {
|
||||
height: 16,
|
||||
),
|
||||
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
Container(
|
||||
height: 210,
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
children: [
|
||||
ShadCard(
|
||||
width: 300,
|
||||
height: 200,
|
||||
title: Text(
|
||||
"Location",
|
||||
),
|
||||
description: Text(
|
||||
"Your location is required for automatically updating your nearest bus stop."
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
children: [
|
||||
ShadCard(
|
||||
width: 300,
|
||||
height: double.infinity,
|
||||
title: Text(
|
||||
"Location",
|
||||
),
|
||||
description: Text(
|
||||
"Your location is required for automatically updating your nearest bus stop."
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
||||
FutureBuilder(
|
||||
future: Permission.location.isGranted,
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Request permission";
|
||||
Color color = Colors.white;
|
||||
FutureBuilder(
|
||||
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;
|
||||
}
|
||||
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(() {
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
await Permission.location.request();
|
||||
setState(() {
|
||||
|
||||
});
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
});
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
|
||||
ShadCard(
|
||||
width: 300,
|
||||
height: 200,
|
||||
title: Text(
|
||||
"Storage",
|
||||
if (!kIsWeb)
|
||||
SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
description: Text(
|
||||
"Storage access is required to access recorded announcements."
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
if (!kIsWeb)
|
||||
ShadCard(
|
||||
width: 300,
|
||||
height: double.infinity,
|
||||
title: Text(
|
||||
"Storage",
|
||||
),
|
||||
description: Text(
|
||||
"Storage access is required to access recorded announcements."
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
FutureBuilder(
|
||||
future: Permission.manageExternalStorage.isGranted,
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Request permission";
|
||||
Color color = Colors.white;
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
||||
if (val.hasData) {
|
||||
isEnabled = !val.data!;
|
||||
}
|
||||
if (!isEnabled) {
|
||||
text = "Permission granted!";
|
||||
color = Colors.green.shade400;
|
||||
}
|
||||
FutureBuilder(
|
||||
future: Permission.manageExternalStorage.isGranted,
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Request permission";
|
||||
Color color = Colors.white;
|
||||
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
await Permission.manageExternalStorage.request();
|
||||
setState(() {
|
||||
if (val.hasData) {
|
||||
isEnabled = !val.data!;
|
||||
}
|
||||
if (!isEnabled) {
|
||||
text = "Permission granted!";
|
||||
color = Colors.green.shade400;
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
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",
|
||||
if (defaultTargetPlatform == TargetPlatform.android)
|
||||
SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
description: Text(
|
||||
"Network access is required for commincation between devices for multi mode."
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
if (defaultTargetPlatform == TargetPlatform.android)
|
||||
ShadCard(
|
||||
width: 300,
|
||||
height: double.infinity,
|
||||
title: Text(
|
||||
"Nearby Devices",
|
||||
),
|
||||
description: Text(
|
||||
"Nearby Devices access is required to find nearby devices, and to establish connections with them."
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
FutureBuilder(
|
||||
future: Permission.nearbyWifiDevices.isGranted,
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Request permission";
|
||||
Color color = Colors.white;
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
||||
if (val.hasData) {
|
||||
isEnabled = !val.data!;
|
||||
}
|
||||
if (!isEnabled) {
|
||||
text = "Permission granted!";
|
||||
color = Colors.green.shade400;
|
||||
}
|
||||
FutureBuilder(
|
||||
future: Permission.nearbyWifiDevices.isGranted,
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Request permission";
|
||||
Color color = Colors.white;
|
||||
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
await Permission.manageExternalStorage.request();
|
||||
setState(() {
|
||||
if (val.hasData) {
|
||||
isEnabled = !val.data!;
|
||||
}
|
||||
if (!isEnabled) {
|
||||
text = "Permission granted!";
|
||||
color = Colors.green.shade400;
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
await Permission.nearbyWifiDevices.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,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),*/
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -388,6 +451,8 @@ class _page3 extends InitialStartupPage {
|
||||
State<_page3> createState() => _page3State();
|
||||
}
|
||||
|
||||
|
||||
|
||||
class _page3State extends State<_page3> {
|
||||
|
||||
bool _loadingAudio = false;
|
||||
|
||||
320
lib/remaster/JoinGroup.dart
Normal file
320
lib/remaster/JoinGroup.dart
Normal file
@@ -0,0 +1,320 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:bus_infotainment/backend/live_information.dart';
|
||||
import 'package:bus_infotainment/remaster/dashboard.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart' hide NavigationBar;
|
||||
import 'package:native_qr/native_qr.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
class JoinGroup extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<JoinGroup> createState() => _JoinGroupState();
|
||||
}
|
||||
|
||||
class _JoinGroupState extends State<JoinGroup> {
|
||||
|
||||
Future<void> _joinGroup(String data) async {
|
||||
|
||||
if (data.isEmpty) {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast(
|
||||
title: Text("Error connecting to room"),
|
||||
description: Text("Nothing was found."),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (await LiveInformation().joinRoom(data)) {
|
||||
Navigator.pushNamed(context, "/multi/enroute");
|
||||
} else {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast(
|
||||
title: Text("Error connecting to room"),
|
||||
description: Text("The room could not be found."),
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android) {
|
||||
LiveInformation().p2pModule.startDiscovery();
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
|
||||
child: Row(
|
||||
|
||||
children: [
|
||||
|
||||
Expanded(
|
||||
|
||||
child: Container(
|
||||
|
||||
|
||||
|
||||
alignment: Alignment.center,
|
||||
|
||||
child: Row(
|
||||
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
children: [
|
||||
|
||||
Container(
|
||||
margin: EdgeInsets.all(20),
|
||||
width: 100,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
||||
Expanded(
|
||||
|
||||
child: RotatedBox(
|
||||
quarterTurns: 3,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
NativeQr nativeQr = NativeQr();
|
||||
String? result = await nativeQr.get();
|
||||
|
||||
_joinGroup(result!);
|
||||
},
|
||||
child: Text(
|
||||
"Join from QR code",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
|
||||
child: RotatedBox(
|
||||
quarterTurns: 3,
|
||||
child: Container(
|
||||
height: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
child: Text(
|
||||
"Join from clipboard",
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
width: 2,
|
||||
color: Colors.grey.shade300,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"EXPERIMENTAL",
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade700.withOpacity(0.9),
|
||||
fontSize: 100,
|
||||
fontWeight: FontWeight.bold,
|
||||
height: 1
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Working proof of concept - Rewrite iminent",
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade700.withOpacity(0.9),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Certain parts may not work as expected. I am aware of all issues.",
|
||||
style: TextStyle(
|
||||
color: Colors.grey.shade700.withOpacity(0.9),
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
||||
Row(
|
||||
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"Nearby devices",
|
||||
style: ShadTheme.of(context).textTheme.h1
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
width: 20,
|
||||
),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
setState(() {});
|
||||
},
|
||||
child: Text("Refresh"),
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.android)
|
||||
FutureBuilder(
|
||||
future: LiveInformation().p2pModule.getDiscoveredDevices(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return CircularProgressIndicator();
|
||||
}
|
||||
if (snapshot.hasError) {
|
||||
return Text("Error: ${snapshot.error}");
|
||||
}
|
||||
|
||||
List<Widget> peers = [];
|
||||
|
||||
for (var peer in snapshot.data!) {
|
||||
|
||||
print("Info: ");
|
||||
print(jsonEncode(peer.info.toJson()));
|
||||
|
||||
peers.add(
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await LiveInformation().p2pModule.connectToDevice(peer);
|
||||
LiveInformation().inRoom = true;
|
||||
LiveInformation().connectionMethod = RoomConnectionMethod.P2P;
|
||||
Navigator.pushNamed(context, "/multi/enroute");
|
||||
},
|
||||
child: Text(peer.info.displayName),
|
||||
style: ElevatedButton.styleFrom(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
print(peers.length);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
...peers
|
||||
],
|
||||
);
|
||||
},
|
||||
)
|
||||
else
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text("This feature is not available on this platform."),
|
||||
Text("Please use the QR code or clipboard method.")
|
||||
],
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
),
|
||||
|
||||
Container(
|
||||
width: 2,
|
||||
color: Colors.grey.shade300,
|
||||
),
|
||||
|
||||
RotatedBox(
|
||||
quarterTurns: 3,
|
||||
child: NavigationBar()
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,14 @@
|
||||
import 'package:bus_infotainment/pages/tfl_dataset_test.dart';
|
||||
import 'package:bus_infotainment/remaster/DashboardArc.dart';
|
||||
import 'package:bus_infotainment/remaster/InitialStartup.dart';
|
||||
import 'package:bus_infotainment/remaster/JoinGroup.dart';
|
||||
import 'package:bus_infotainment/remaster/SearchArc.dart';
|
||||
import 'package:bus_infotainment/remaster/dashboard.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:keep_screen_on/keep_screen_on.dart';
|
||||
|
||||
import 'WebSocketTest.dart';
|
||||
|
||||
@@ -36,6 +38,8 @@ class RemasteredApp extends StatelessWidget {
|
||||
SystemUiOverlay.top,
|
||||
]);
|
||||
|
||||
// Stop the screen from turning off
|
||||
KeepScreenOn.turnOn();
|
||||
|
||||
|
||||
return ShadApp(
|
||||
@@ -68,7 +72,7 @@ class RemasteredApp extends StatelessWidget {
|
||||
'/multi/login': (context) => MultiModeLogin(),
|
||||
'/multi/register': (context) => MultiModeRegister(),
|
||||
'/display': (context) => FullscreenDisplay(),
|
||||
'/multi/join': (context) => MultiModeJoin(),
|
||||
'/multi/join': (context) => JoinGroup(),
|
||||
'/websocket': (context) => WebSocketWidget(),
|
||||
|
||||
},
|
||||
|
||||
@@ -1671,11 +1671,33 @@ class _MultiModeJoinState extends State<MultiModeJoin> {
|
||||
onPressed: () async {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
|
||||
liveInformation.setRouteVariant(null);
|
||||
|
||||
await liveInformation.joinRoom(controller.text);
|
||||
|
||||
Navigator.popAndPushNamed(context, "/multi/enroute");
|
||||
if (controller.text.isNotEmpty ? await liveInformation.joinRoom(controller.text) : false) {
|
||||
liveInformation.setRouteVariant(null);
|
||||
Navigator.popAndPushNamed(context, "/multi/enroute");
|
||||
} else {
|
||||
showShadDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return ShadDialog(
|
||||
title: const Text("Failed to join group"),
|
||||
content: const Text("Failed to join group. Please check the room code and try again"),
|
||||
actions: [
|
||||
ShadButton(
|
||||
text: const Text("Close"),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user