ToLaptop
This commit is contained in:
410
lib/pages/home.dart
Normal file
410
lib/pages/home.dart
Normal file
@@ -0,0 +1,410 @@
|
||||
|
||||
|
||||
import 'package:bus_infotainment/pages/components/ibus_display.dart';
|
||||
import 'package:bus_infotainment/singletons/live_information.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class pages_Home extends StatelessWidget {
|
||||
const pages_Home({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Container(
|
||||
|
||||
width: double.infinity,
|
||||
|
||||
margin: const EdgeInsets.all(10),
|
||||
|
||||
child: Column(
|
||||
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
children: [
|
||||
|
||||
// Text("Home Page"),
|
||||
|
||||
ibus_display(),
|
||||
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
|
||||
_QuickAnnouncements(),
|
||||
|
||||
],
|
||||
)
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _QuickAnnouncements extends StatefulWidget {
|
||||
|
||||
|
||||
_QuickAnnouncements({super.key});
|
||||
|
||||
@override
|
||||
State<_QuickAnnouncements> createState() => _QuickAnnouncementsState();
|
||||
}
|
||||
|
||||
class _QuickAnnouncementsState extends State<_QuickAnnouncements> {
|
||||
|
||||
List<Widget> announcements = [];
|
||||
|
||||
int _currentIndex = 0;
|
||||
|
||||
_QuickAnnouncementsState() {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
|
||||
for (ManualAnnouncementEntry announcement in liveInformation.manualAnnouncements) {
|
||||
announcements.add(
|
||||
_QuickAnnouncement(announcement: announcement, index: liveInformation.manualAnnouncements.indexOf(announcement))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
|
||||
return Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: Border.all(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
),
|
||||
|
||||
|
||||
|
||||
),
|
||||
|
||||
padding: const EdgeInsets.all(2),
|
||||
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
if (_currentIndex < announcements.length)
|
||||
announcements[_currentIndex + 0]
|
||||
else
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
if (_currentIndex + 1 < announcements.length)
|
||||
announcements[_currentIndex + 1]
|
||||
else
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
if (_currentIndex + 2 < announcements.length)
|
||||
announcements[_currentIndex + 2]
|
||||
else
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
if (_currentIndex + 3 < announcements.length)
|
||||
announcements[_currentIndex + 3]
|
||||
else
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
Container(
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
|
||||
alignment: Alignment.centerRight,
|
||||
|
||||
child: Row(
|
||||
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
children: [
|
||||
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4
|
||||
),
|
||||
|
||||
child: Container(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Icon(
|
||||
Icons.arrow_upward,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
_currentIndex = wrap(_currentIndex - 4, 0, announcements.length);
|
||||
setState(() {});
|
||||
print(_currentIndex);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
foregroundColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
),
|
||||
child: const Text(""),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
|
||||
margin: const EdgeInsets.symmetric(
|
||||
horizontal: 4
|
||||
),
|
||||
|
||||
child: Container(
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
child: Icon(
|
||||
Icons.arrow_downward,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
_currentIndex = wrap(_currentIndex + 4, 0, announcements.length);
|
||||
setState(() {});
|
||||
print(_currentIndex);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
foregroundColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
),
|
||||
child: const Text(""),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
]
|
||||
|
||||
),
|
||||
|
||||
),
|
||||
Container(
|
||||
height: 2,
|
||||
color: Colors.black,
|
||||
),
|
||||
|
||||
]
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int wrap(int i, int j, int length) {
|
||||
return ((i - j) % length + length) % length;
|
||||
}
|
||||
|
||||
class _QuickAnnouncement extends StatelessWidget {
|
||||
|
||||
final ManualAnnouncementEntry announcement;
|
||||
final int index;
|
||||
|
||||
const _QuickAnnouncement({super.key, required this.announcement, required this.index});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
Container(
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.lightGreen.shade100,
|
||||
border: const Border.symmetric(
|
||||
vertical: BorderSide(
|
||||
color: Colors.black,
|
||||
width: 2
|
||||
)
|
||||
),
|
||||
),
|
||||
|
||||
padding: const EdgeInsets.all(5),
|
||||
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
announcement.shortName,
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.black,
|
||||
fontFamily: "lcd",
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
|
||||
alignment: Alignment.centerRight,
|
||||
|
||||
child: Text(
|
||||
(index+1).toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.black,
|
||||
fontFamily: "lcd",
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
Positioned.fill(
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
liveInformation.queueAnnouncement(announcement);
|
||||
},
|
||||
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.transparent,
|
||||
shadowColor: Colors.transparent,
|
||||
surfaceTintColor: Colors.transparent,
|
||||
foregroundColor: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0),
|
||||
),
|
||||
),
|
||||
|
||||
child: const Text("More"),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user