This commit is contained in:
ImBenji
2024-05-17 17:36:02 +01:00
parent 1f48f8f4b0
commit fff8de13c0
6 changed files with 5734 additions and 358 deletions

View File

@@ -231,7 +231,7 @@ class RoutePage extends StatelessWidget {
],
),
if (!kIsWeb)
Text(
"Nearby routes",
style: ShadTheme.of(context).textTheme.h4,
@@ -315,23 +315,23 @@ class _RouteSearchState extends State<RouteSearch> {
return Expanded(
child: Column(
children: [
ShadInput(
placeholder: const Text("Search for a route..."),
controller: controller,
onChanged: (value) {
setState(() {
});
},
),
const SizedBox(
height: 4,
),
Expanded(
child: Scrollbar(
interactive: true,
@@ -347,7 +347,7 @@ class _RouteSearchState extends State<RouteSearch> {
),
),
)
],
),
);
@@ -649,11 +649,23 @@ class _dash extends StatelessWidget {
],
),
),
)
),
// SizedBox(
// height: 8,
// ),
SizedBox(
height: 8,
),
Container(
padding: const EdgeInsets.all(8),
child: ShadButton(
text: const Text("Fullscreen display"),
onPressed: () {
Navigator.pushNamed(context, "/display");
},
icon: const Icon(Icons.fullscreen),
width: double.infinity,
),
),
//
// ShadCard(
// title: Text("Stop announcements"),
@@ -961,199 +973,83 @@ class _MultiModeEnrouteState extends State<MultiModeEnroute> {
LiveInformation liveInformation = LiveInformation();
return Scaffold(
return PopScope(
canPop: false,
onPopInvoked: (didPop) {
body: Column(
children: [
if (didPop){
print("Compensating for pop");
liveInformation.leaveRoom();
return;
}
Container(
padding: const EdgeInsets.all(16),
height: 200,
child: ShadCard(
title: liveInformation.isHost ? const Text("Hosting group") : const Text("Joined group"),
border: Border.all(
color: Colors.amber,
width: 1
),
padding: const EdgeInsets.all(16),
width: double.infinity,
description: liveInformation.isHost ? const Text(
"You are hosting a group. \nShare the room code with others to join"
) : const Text(
"You have joined a group."
),
content: Column(
children: [
const SizedBox(
height: 4,
),
FutureBuilder(
future: Future.delayed(const Duration(seconds: 1)),
builder: (context, snapshot) {
return Row(
children: [
Expanded(
child: ShadButton(
text: Text(
liveInformation.roomCode!,
),
icon: const Icon(Icons.copy),
padding: const EdgeInsets.all(8),
onPressed: () {
Clipboard.setData(ClipboardData(text: liveInformation.roomCode!));
ShadToaster.of(context).show(
const ShadToast(
title: Text("Copied to clipboard"),
description: Text("Room code copied to clipboard"),
duration: Duration(seconds: 5),
)
);
},
),
),
ShadButton(
icon: const Icon(Icons.qr_code),
onPressed: () {
showShadDialog(
context: context,
builder: (context) {
return ShadDialog(
title: const Text("QR Code"),
content: Container(
width: 200,
height: 225,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
QrImageView(
data: liveInformation.roomCode!,
size: 200,
backgroundColor: Colors.white,
),
const SizedBox(
height: 8,
),
Text("Scan QR code to join the group")
],
),
),
actions: [
ShadButton(
text: const Text("Close"),
onPressed: () {
Navigator.pop(context);
},
)
],
);
}
);
},
)
],
);
// return;
// Ask the user to confirm if they want to leave the group
showShadDialog(
context: context,
builder: (context) {
return ShadDialog(
title: const Text("Leave group?"),
content: const Text("Are you sure you want to leave the group?"),
actions: [
ShadButton(
text: const Text("Leave"),
onPressed: () {
liveInformation.leaveRoom();
Navigator.pop(context);
Navigator.pop(context);
},
),
ShadButton(
text: const Text("Cancel"),
onPressed: () {
Navigator.pop(context);
},
)
],
);
}
);
},
child: Scaffold(
body: Column(
children: [
const Divider(
height: 1,
),
Container(
padding: EdgeInsets.all(8),
child: ibus_display()
),
const Divider(
height: 1,
),
Container(
padding: EdgeInsets.all(8),
child: Text(
"* Swipe left and right below for more options!",
textAlign: TextAlign.center,
),
),
),
const Divider(
height: 1,
),
Container(
padding: EdgeInsets.all(8),
child: ibus_display()
),
const Divider(
height: 1,
),
Container(
padding: EdgeInsets.all(8),
child: Text(
"* Swipe left and right below for more options!",
textAlign: TextAlign.center,
const Divider(
height: 1,
),
),
const Divider(
height: 1,
),
SizedBox(
height: 16,
),
SizedBox(
height: 16,
),
Expanded(
child: FlutterCarousel(
items: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(8)
),
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.only(
left: 16,
right: 16,
),
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: const EdgeInsets.only(
top: 4,
left: 8,
right: 8,
bottom: 4
),
child: Text(
"Nearby routes",
style: ShadTheme.of(context).textTheme.h4,
),
),
if (!kIsWeb)
Expanded(
child: Scrollbar(
interactive: true,
radius: const Radius.circular(8),
thickness: 8,
thumbVisibility: true,
child: GridView.count(
crossAxisCount: 3,
children: [
..._getNearbyRoutes(multiMode: true)
],
shrinkWrap: true,
),
),
)
],
)
),
Container(
Expanded(
child: FlutterCarousel(
items: [
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
@@ -1166,160 +1062,321 @@ class _MultiModeEnrouteState extends State<MultiModeEnroute> {
left: 16,
right: 16,
),
width: double.infinity,
child: Expanded(child: RouteSearch(multiMode: true,))
),
Container(
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: Colors.white
),
borderRadius: BorderRadius.all(Radius.circular(8))
),
margin: const EdgeInsets.only(
left: 16,
right: 16,
),
padding: EdgeInsets.all(8),
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
EasyAnnouncementPicker(
announcements: LiveInformation().announcementModule.manualAnnouncements,
title: "Manual",
outlineColor: ShadTheme.of(context).colorScheme.secondary
),
if (liveInformation.getRouteVariant() != null)
SizedBox(
height: 16,
if (!kIsWeb)
Container(
padding: const EdgeInsets.only(
top: 4,
left: 8,
right: 8,
bottom: 4
),
if (liveInformation.getRouteVariant() != null)
Container(
child: StopAnnouncementPicker(
routeVariant: LiveInformation().getRouteVariant()!,
backgroundColor: Colors.transparent,
outlineColor: ShadTheme.of(context).colorScheme.secondary,
label: "Bus Stops",
)
child: Text(
"Nearby routes",
style: ShadTheme.of(context).textTheme.h4,
),
),
if (!kIsWeb)
Expanded(
child: Scrollbar(
interactive: true,
radius: const Radius.circular(8),
thickness: 8,
thumbVisibility: true,
child: GridView.count(
crossAxisCount: 3,
children: [
..._getNearbyRoutes(multiMode: true)
],
shrinkWrap: true,
),
),
)
],
)
),
Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.white,
width: 1
),
borderRadius: BorderRadius.circular(8)
),
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.only(
left: 16,
right: 16,
),
child: Expanded(child: RouteSearch(multiMode: true,))
),
Container(
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: Colors.white
),
borderRadius: BorderRadius.all(Radius.circular(8))
),
margin: const EdgeInsets.only(
left: 16,
right: 16,
),
padding: EdgeInsets.all(8),
child: SingleChildScrollView(
child: Column(
children: [
EasyAnnouncementPicker(
announcements: LiveInformation().announcementModule.manualAnnouncements,
title: "Manual",
outlineColor: ShadTheme.of(context).colorScheme.secondary
),
if (liveInformation.getRouteVariant() != null)
SizedBox(
height: 16,
),
if (liveInformation.getRouteVariant() != null)
Container(
child: StopAnnouncementPicker(
routeVariant: LiveInformation().getRouteVariant()!,
backgroundColor: Colors.transparent,
outlineColor: ShadTheme.of(context).colorScheme.secondary,
label: "Bus Stops",
)
)
],
),
),
),
),
Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: ShadTheme.of(context).colorScheme.primary,
width: 1
)
),
margin: const EdgeInsets.only(
left: 16,
right: 16,
),
padding: const EdgeInsets.all(4),
child: Container(
Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(4),
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: ShadTheme.of(context).colorScheme.primary,
width: 1
)
),
child: Column(
children: [
margin: const EdgeInsets.only(
left: 16,
right: 16,
),
padding: const EdgeInsets.all(4),
child: Container(
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(4),
border: Border.all(
color: ShadTheme.of(context).colorScheme.primary,
width: 1
)
),
child: Column(
children: [
if (!kIsWeb)
AnnouncementEntry(
label: "Display next stop",
index: 0,
outlineColor: ShadTheme.of(context).colorScheme.primary,
onPressed: () {
LiveInformation liveInformation = LiveInformation();
TrackerModule trackerModule = liveInformation.trackerModule;
BusRouteStop? stop = trackerModule.nearestStop;
if (stop != null) {
liveInformation.announcementModule.queueAnnounceByAudioName(displayText: stop.formattedStopName);
} else {
ShadToaster.of(context).show(
const ShadToast(
title: Text("No bus stop found"),
description: Text("No bus stop found nearby"),
duration: Duration(seconds: 5),
)
);
}
},
),
if (!kIsWeb)
Container(
height: 1,
color: ShadTheme.of(context).colorScheme.primary,
),
if (!kIsWeb)
AnnouncementEntry(
label: "Display next stop",
index: 0,
label: "Announce destination",
index: 1,
outlineColor: ShadTheme.of(context).colorScheme.primary,
onPressed: () {
LiveInformation liveInformation = LiveInformation();
TrackerModule trackerModule = liveInformation.trackerModule;
BusRouteStop? stop = trackerModule.nearestStop;
if (stop != null) {
liveInformation.announcementModule.queueAnnounceByAudioName(displayText: stop.formattedStopName);
} else {
ShadToaster.of(context).show(
const ShadToast(
title: Text("No bus stop found"),
description: Text("No bus stop found nearby"),
duration: Duration(seconds: 5),
)
);
}
liveInformation.announcementModule.queueAnnouncementByRouteVariant(
routeVariant:
liveInformation.getRouteVariant()!
);
},
),
if (!kIsWeb)
Container(
height: 1,
color: ShadTheme.of(context).colorScheme.primary,
),
AnnouncementEntry(
label: "Announce destination",
index: 1,
outlineColor: ShadTheme.of(context).colorScheme.primary,
onPressed: () {
LiveInformation liveInformation = LiveInformation();
liveInformation.announcementModule.queueAnnouncementByRouteVariant(
routeVariant:
liveInformation.getRouteVariant()!
);
},
),
Container(
height: 1,
color: ShadTheme.of(context).colorScheme.primary,
),
],
Container(
height: 1,
color: ShadTheme.of(context).colorScheme.primary,
),
],
),
),
),
],
options: CarouselOptions(
showIndicator: false,
viewportFraction: 1,
height: double.infinity,
enableInfiniteScroll: true
),
],
options: CarouselOptions(
showIndicator: false,
viewportFraction: 1,
height: double.infinity,
enableInfiniteScroll: true
),
),
),
Container(
padding: const EdgeInsets.all(8),
child: ShadButton(
text: const Text("Fullscreen display"),
onPressed: () {
Navigator.pushNamed(context, "/display");
},
icon: const Icon(Icons.fullscreen),
width: double.infinity,
Container(
padding: const EdgeInsets.all(8),
child: ShadButton(
text: const Text("Fullscreen display"),
onPressed: () {
Navigator.pushNamed(context, "/display");
},
icon: const Icon(Icons.fullscreen),
width: double.infinity,
),
),
const Divider(
height: 1,
),
),
const Divider(
height: 1,
),
NavigationBar()
],
),
Container(
padding: const EdgeInsets.all(16),
// height: 200,
child: ShadCard(
title: liveInformation.isHost ? const Text("Currently hosting group") : const Text("Successfully joined group"),
border: Border.all(
color: Colors.amber,
width: 1
),
padding: const EdgeInsets.all(16),
width: double.infinity,
description: liveInformation.isHost ? const Text(
"You are hosting a group. \nShare the room code with others to join"
) : const Text(
"You have joined a group."
),
content: Column(
children: [
const SizedBox(
height: 4,
),
FutureBuilder(
future: Future.delayed(const Duration(seconds: 1)),
builder: (context, snapshot) {
return Row(
children: [
Expanded(
child: ShadButton(
text: Text(
liveInformation.roomCode!,
),
icon: const Icon(Icons.copy),
padding: const EdgeInsets.all(8),
onPressed: () {
Clipboard.setData(ClipboardData(text: liveInformation.roomCode!));
ShadToaster.of(context).show(
const ShadToast(
title: Text("Copied to clipboard"),
description: Text("Room code copied to clipboard"),
duration: Duration(seconds: 5),
)
);
},
),
),
ShadButton(
icon: const Icon(Icons.qr_code),
onPressed: () {
showShadDialog(
context: context,
builder: (context) {
return ShadDialog(
title: const Text("QR Code"),
content: Container(
width: 200,
height: 225,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
QrImageView(
data: liveInformation.roomCode!,
size: 200,
backgroundColor: Colors.white,
),
const SizedBox(
height: 8,
),
Text("Scan QR code to join the group")
],
),
),
actions: [
ShadButton(
text: const Text("Close"),
onPressed: () {
Navigator.pop(context);
},
)
],
);
}
);
},
)
],
);
},
),
],
),
),
),
const Divider(
height: 1,
),
NavigationBar()
],
),
),
);
}
@@ -1377,7 +1434,7 @@ class _MultiModeJoinState extends State<MultiModeJoin> {
liveInformation.setRouteVariant(null);
await liveInformation.JoinRoom(controller.text);
await liveInformation.joinRoom(controller.text);
Navigator.popAndPushNamed(context, "/multi/enroute");
@@ -1426,7 +1483,7 @@ class FullscreenDisplay extends StatefulWidget {
class _FullscreenDisplayState extends State<FullscreenDisplay> {
@override
Widget build(BuildContext context) {
@@ -1447,12 +1504,12 @@ class _FullscreenDisplayState extends State<FullscreenDisplay> {
}
},
child: Scaffold(
body: Container(
color: Colors.black,
alignment: Alignment.center,
child: Row(
children: [
Expanded(
@@ -1469,9 +1526,9 @@ class _FullscreenDisplayState extends State<FullscreenDisplay> {
)
],
),
),
),
);
}
@@ -1616,17 +1673,17 @@ class MultiModeRegister extends StatelessWidget {
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Register",
style: ShadTheme.of(context).textTheme.h2,
),
ShadForm(
key: formKey,
child: Column(
@@ -1685,7 +1742,7 @@ class MultiModeRegister extends StatelessWidget {
],
),
),
ShadButton(
text: const Text("Register"),
width: double.infinity,
@@ -1693,7 +1750,7 @@ class MultiModeRegister extends StatelessWidget {
if (formKey.currentState!.validate()) {
formKey.currentState!.save();
print("Logging in...");
LiveInformation liveInformation = LiveInformation();
await liveInformation.auth.createUser(
displayName: formKey.currentState!.value["email"],
@@ -1720,7 +1777,7 @@ class MultiModeRegister extends StatelessWidget {
}
},
),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
@@ -1734,9 +1791,9 @@ class MultiModeRegister extends StatelessWidget {
)
],
)
],
),
),
@@ -1755,6 +1812,11 @@ class MultiModeRegister extends StatelessWidget {
}
class NavigationBar extends StatefulWidget {
final Widget? content;
NavigationBar({this.content = null});
@override
State<NavigationBar> createState() => _NavigationBarState();
}
@@ -1807,7 +1869,7 @@ List<Widget> _getNearbyRoutes({bool multiMode = false}) {
if (kDebugMode) {
currentVector = OSGrid.toNorthingEasting(51.583781262560926, -0.020359583104595073);
// currentVector = OSGrid.toNorthingEasting(51.583781262560926, -0.020359583104595073);
}
for (BusRoute route in busSequences.routes.values) {