Alot of changes
This commit is contained in:
465
lib/remaster/InitialStartup.dart
Normal file
465
lib/remaster/InitialStartup.dart
Normal file
@@ -0,0 +1,465 @@
|
||||
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:bus_infotainment/audio_cache.dart';
|
||||
import 'package:bus_infotainment/backend/live_information.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
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';
|
||||
|
||||
class InitialStartup extends StatefulWidget {
|
||||
|
||||
@override
|
||||
State<InitialStartup> createState() => _InitialStartupState();
|
||||
}
|
||||
|
||||
class _InitialStartupState extends State<InitialStartup> {
|
||||
int _page = 0;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
if (_page == 0 && !kIsWeb) {
|
||||
_page = 1;
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
|
||||
body: [
|
||||
_page1(this),
|
||||
_page2(this),
|
||||
_page3(this)
|
||||
][_page],
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
void setPage(int page) {
|
||||
setState(() {
|
||||
_page = page;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
abstract class InitialStartupPage extends StatefulWidget {
|
||||
|
||||
_InitialStartupState parent;
|
||||
|
||||
InitialStartupPage(this.parent);
|
||||
|
||||
}
|
||||
|
||||
// Cookies page - only for web
|
||||
class _page1 extends InitialStartupPage {
|
||||
|
||||
_page1(super.parent);
|
||||
|
||||
@override
|
||||
State<_page1> createState() => _page1State();
|
||||
}
|
||||
|
||||
class _page1State extends State<_page1> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Container(
|
||||
|
||||
padding: EdgeInsets.all(32),
|
||||
|
||||
alignment: Alignment.center,
|
||||
|
||||
child: Column(
|
||||
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"Cookies",
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w600,
|
||||
)
|
||||
),
|
||||
|
||||
Text(
|
||||
"This website uses first-party cookies for the storage of user data. These cookies are necessary for the functioning of the site and help us provide you with a better browsing experience. By using this website, you consent to the use of these cookies.",
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
ShadButton(
|
||||
onPressed: () {
|
||||
widget.parent.setPage(1);
|
||||
},
|
||||
text: Text(
|
||||
"I understand and agree"
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Permission request page
|
||||
class _page2 extends InitialStartupPage {
|
||||
|
||||
_page2(super.parent);
|
||||
|
||||
@override
|
||||
State<_page2> createState() => _page2State();
|
||||
}
|
||||
|
||||
class _page2State extends State<_page2> {
|
||||
|
||||
Future<bool> _allPermissionsGranted() async {
|
||||
|
||||
List<bool> perms = [];
|
||||
|
||||
perms.addAll([
|
||||
await Permission.manageExternalStorage.isGranted,
|
||||
await Permission.location.isGranted
|
||||
]);
|
||||
|
||||
return !perms.contains(false);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Container(
|
||||
|
||||
padding: EdgeInsets.all(16),
|
||||
|
||||
alignment: Alignment.center,
|
||||
|
||||
|
||||
|
||||
child: SizedBox(
|
||||
|
||||
width: double.infinity,
|
||||
|
||||
child: Column(
|
||||
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"Permissions",
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w600,
|
||||
)
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
|
||||
ShadCard(
|
||||
width: 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,
|
||||
),
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
await Permission.location.request();
|
||||
setState(() {
|
||||
|
||||
});
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
|
||||
ShadCard(
|
||||
width: double.infinity,
|
||||
title: Text(
|
||||
"Storage",
|
||||
),
|
||||
description: Text(
|
||||
"Storage access is required to access recorded announcements."
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
||||
FutureBuilder(
|
||||
future: Permission.manageExternalStorage.isGranted,
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Request permission";
|
||||
Color color = Colors.white;
|
||||
|
||||
if (val.hasData) {
|
||||
isEnabled = !val.data!;
|
||||
}
|
||||
if (!isEnabled) {
|
||||
text = "Permission granted!";
|
||||
color = Colors.green.shade400;
|
||||
}
|
||||
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
await Permission.manageExternalStorage.request();
|
||||
setState(() {
|
||||
|
||||
});
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
|
||||
FutureBuilder(
|
||||
future: _allPermissionsGranted(),
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Continue";
|
||||
Color color = Colors.white;
|
||||
|
||||
if (val.hasData) {
|
||||
isEnabled = val.data!;
|
||||
}
|
||||
if (!isEnabled) {
|
||||
text = "Grant all permissions before continuing";
|
||||
}
|
||||
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
widget.parent.setPage(2);
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
width: double.infinity,
|
||||
);
|
||||
},
|
||||
)
|
||||
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class _page3 extends InitialStartupPage {
|
||||
_page3(super.parent);
|
||||
|
||||
@override
|
||||
State<_page3> createState() => _page3State();
|
||||
}
|
||||
|
||||
class _page3State extends State<_page3> {
|
||||
|
||||
Future<bool> _announcementsUploaded() async {
|
||||
try {
|
||||
Uint8List bytes = await LiveInformation().announcementModule.getBundleBytes();
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Container(
|
||||
|
||||
padding: EdgeInsets.all(16),
|
||||
|
||||
alignment: Alignment.center,
|
||||
|
||||
child: SizedBox(
|
||||
|
||||
width: double.infinity,
|
||||
|
||||
child: Column(
|
||||
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
children: [
|
||||
|
||||
Text(
|
||||
"Prerequisites",
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.w600,
|
||||
)
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
|
||||
ShadCard(
|
||||
width: double.infinity,
|
||||
title: Text(
|
||||
"Announcement files",
|
||||
),
|
||||
description: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"You are required to upload the London iBus announcement files. These files can be acquire by submitting a request to TfL under the Freedom of Information Act (2000)"
|
||||
),
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
Text(
|
||||
"Please upload a zip file."
|
||||
)
|
||||
],
|
||||
),
|
||||
content: Container(
|
||||
child: Column(
|
||||
children: [
|
||||
|
||||
SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
|
||||
FutureBuilder(
|
||||
future: _announcementsUploaded(),
|
||||
builder: (context, val) {
|
||||
bool isEnabled = true;
|
||||
String text = "Upload file";
|
||||
Color color = Colors.white;
|
||||
|
||||
if (val.hasData) {
|
||||
isEnabled = !val.data!;
|
||||
}
|
||||
if (!isEnabled) {
|
||||
text = "File uploaded!";
|
||||
color = Colors.green.shade400;
|
||||
}
|
||||
|
||||
return ShadButton(
|
||||
text: Text(text),
|
||||
onPressed: () async {
|
||||
|
||||
FilePickerResult? result = await FilePicker.platform.pickFiles(
|
||||
type: FileType.custom,
|
||||
allowedExtensions: [
|
||||
"zip"
|
||||
]
|
||||
);
|
||||
|
||||
if (result != null) {
|
||||
late Uint8List bytes;
|
||||
|
||||
if (kIsWeb) {
|
||||
bytes = result.files.single.bytes!;
|
||||
} else {
|
||||
File file = File(result.files.single.path!);
|
||||
|
||||
bytes = file.readAsBytesSync();
|
||||
}
|
||||
|
||||
LiveInformation().announcementModule.setBundleBytes(bytes);
|
||||
|
||||
AnnouncementCache cache = LiveInformation().announcementModule.announcementCache;
|
||||
|
||||
// load a random announcement to ensure that the file is usable
|
||||
await cache.loadAnnouncementsFromBytes(bytes, ["S_WALTHAMSTOW_CENTRAL_001.mp3"]);
|
||||
|
||||
setState(() {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
enabled: isEnabled,
|
||||
backgroundColor: color,
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
26
lib/remaster/RemasteredMain.dart
Normal file
26
lib/remaster/RemasteredMain.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
|
||||
import 'package:bus_infotainment/remaster/InitialStartup.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
class RemasteredApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return ShadApp(
|
||||
darkTheme: ShadThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: ShadSlateColorScheme.dark(),
|
||||
),
|
||||
|
||||
routes: {
|
||||
'/': (context) => InitialStartup()
|
||||
},
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
365
lib/remaster/dashboard.dart
Normal file
365
lib/remaster/dashboard.dart
Normal file
@@ -0,0 +1,365 @@
|
||||
|
||||
import 'package:bus_infotainment/pages/components/ibus_display.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:text_scroll/text_scroll.dart';
|
||||
|
||||
Color rgb(int r, int g, int b) {
|
||||
return Color.fromRGBO(r, g, b, 1);
|
||||
}
|
||||
|
||||
class Dashboard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// TODO: implement build
|
||||
return Scaffold(
|
||||
|
||||
backgroundColor: Colors.grey.shade900,
|
||||
|
||||
bottomNavigationBar: ((defaultTargetPlatform == TargetPlatform.android || defaultTargetPlatform == TargetPlatform.iOS)) ? null : BottomAppBar(
|
||||
|
||||
color: Colors.grey.shade800,
|
||||
|
||||
child: Row(
|
||||
children: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.home),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, "/dashboard");
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, "/search");
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, "/settings");
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
body: Column(
|
||||
children: [
|
||||
|
||||
Container(
|
||||
|
||||
margin: EdgeInsets.all(16),
|
||||
padding: EdgeInsets.all(8),
|
||||
|
||||
decoration: BoxDecoration(
|
||||
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
|
||||
color: Colors.grey.shade800
|
||||
|
||||
),
|
||||
|
||||
// height: 100,
|
||||
|
||||
child: ibus_display()
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Row(
|
||||
|
||||
children: [
|
||||
|
||||
if (false)
|
||||
if (!(defaultTargetPlatform == TargetPlatform.android || defaultTargetPlatform == TargetPlatform.iOS))
|
||||
NavigationRail(
|
||||
|
||||
selectedIndex: 0,
|
||||
|
||||
groupAlignment: 1,
|
||||
|
||||
destinations: [
|
||||
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.home),
|
||||
label: Text("Dashboard"),
|
||||
),
|
||||
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.search),
|
||||
label: Text("Routes")
|
||||
),
|
||||
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.settings),
|
||||
label: Text("Settings")
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Container(
|
||||
|
||||
child: Column(
|
||||
|
||||
children: [
|
||||
|
||||
Container(
|
||||
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 16
|
||||
),
|
||||
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
|
||||
children: [
|
||||
|
||||
Expanded(
|
||||
child: Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
|
||||
color: Colors.grey.shade800
|
||||
|
||||
),
|
||||
|
||||
padding: EdgeInsets.all(16),
|
||||
|
||||
child: IntrinsicWidth(
|
||||
child: Column(
|
||||
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
|
||||
children: [
|
||||
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
|
||||
children: [
|
||||
Text(
|
||||
"Bus Route:",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white
|
||||
)
|
||||
),
|
||||
|
||||
SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
|
||||
Text(
|
||||
"11",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.white
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Destination:",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white
|
||||
)
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
|
||||
Text(
|
||||
"Fullham Broadway",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.white
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
|
||||
Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Next Stop:",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white
|
||||
)
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
|
||||
Text(
|
||||
"St Thomas Hospital / County Hall",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.white
|
||||
),
|
||||
overflow: TextOverflow.fade,
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"Last Stop:",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white
|
||||
),
|
||||
overflow: TextOverflow.fade,
|
||||
),
|
||||
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
|
||||
Text(
|
||||
"Fullham Town Hall",
|
||||
style: GoogleFonts.interTight(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.normal,
|
||||
color: Colors.white
|
||||
),
|
||||
overflow: TextOverflow.fade,
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
// SizedBox(
|
||||
// width: 16,
|
||||
// ),
|
||||
//
|
||||
// Column(
|
||||
//
|
||||
// children: [
|
||||
//
|
||||
// SizedBox(
|
||||
//
|
||||
// width: 150,
|
||||
//
|
||||
// child: FloatingActionButton(
|
||||
// onPressed: () {
|
||||
//
|
||||
// },
|
||||
//
|
||||
// backgroundColor: Colors.red,
|
||||
//
|
||||
// child: Text(
|
||||
// "Bus Stopping",
|
||||
// style: GoogleFonts.interTight(
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: Colors.white
|
||||
// )
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
//
|
||||
// SizedBox(
|
||||
// height: 16
|
||||
// ),
|
||||
//
|
||||
// SizedBox(
|
||||
//
|
||||
// width: 150,
|
||||
// height: 100,
|
||||
//
|
||||
// child: FloatingActionButton(
|
||||
// onPressed: () {
|
||||
//
|
||||
// },
|
||||
//
|
||||
// backgroundColor: Colors.grey.shade600,
|
||||
//
|
||||
// child: Text(
|
||||
// "Acknowledge Bus Stop",
|
||||
// style: GoogleFonts.interTight(
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: Colors.white
|
||||
// ),
|
||||
// textAlign: TextAlign.center,
|
||||
//
|
||||
// ),
|
||||
// ),
|
||||
// )
|
||||
//
|
||||
// ],
|
||||
//
|
||||
// )
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
),
|
||||
)
|
||||
|
||||
],
|
||||
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user