This commit is contained in:
ImBenji
2024-05-17 17:38:34 +01:00
parent 1f48f8f4b0
commit 3556639acc
10 changed files with 636 additions and 49 deletions

View File

@@ -26,6 +26,7 @@ class _ibus_displayState extends State<ibus_display> {
late final ListenerReceipt<AnnouncementQueueEntry> _receipt;
_ibus_displayState(){
LiveInformation liveInformation = LiveInformation();
@@ -42,8 +43,12 @@ class _ibus_displayState extends State<ibus_display> {
});
topLine = liveInformation.announcementModule.currentAnnouncement?.displayText ?? liveInformation.announcementModule.defaultText;
}
String _padString(String input){
if (input.length < 30){
@@ -68,6 +73,8 @@ class _ibus_displayState extends State<ibus_display> {
LiveInformation().announcementModule.onAnnouncement.removeListener(_receipt);
super.dispose();
}
@@ -157,25 +164,11 @@ class _ibus_displayState extends State<ibus_display> {
),
Transform.translate(
offset: Offset(0, -6),
offset: Offset(0, -3.5),
child: Container(
alignment: Alignment.center,
width: 32*4*3,
child: TextScroll(
_padString(bottomLine),
velocity: Velocity(pixelsPerSecond: Offset(120, 0)),
style: const TextStyle(
fontSize: 20,
color: Colors.orange,
fontFamily: "ibus",
shadows: [
Shadow(
color: Colors.orange,
blurRadius: 5,
),
],
),
),
child: _timeComponent(),
),
),
],
@@ -200,4 +193,90 @@ class _ibus_displayState extends State<ibus_display> {
),
);
}
}
class _timeComponent extends StatefulWidget {
@override
State<_timeComponent> createState() => _timeComponentState();
}
class _timeComponentState extends State<_timeComponent> {
late Timer timeTimer;
String bottomLine = "";
@override
void initState() {
// TODO: implement initState
super.initState();
bottomLine = _getTime();
timeTimer = Timer.periodic(Duration(seconds: 1), (timer) {
if (mounted){
setState(() {
bottomLine = _getTime();
});
}
});
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
timeTimer.cancel();
}
String _getTime(){
// Get the current time HH:MM AM/PM
DateTime now = DateTime.now();
bool is24Hour = false;
// if 16 then 4...
String timeString = "${now.hour % 12}:${now.minute.toString().padLeft(2, "0")} ${now.hour < 12 ? "AM" : "PM"}";
return timeString;
}
String _padString(String input){
if (input.length < 30){
print("Input is too short");
return input;
}
String prefix = "";
String suffix = "";
for (int i = 0; i < 80; i++){
prefix += " ";
}
input = input.replaceAll("©", "(c)");
return prefix + input + suffix;
}
@override
Widget build(BuildContext context) {
return TextScroll(
_padString(bottomLine),
velocity: Velocity(pixelsPerSecond: Offset(120, 0)),
style: const TextStyle(
fontSize: 20,
color: Colors.orange,
fontFamily: "ibus",
shadows: [
Shadow(
color: Colors.orange,
blurRadius: 5,
),
],
),
);
}
}

View File

@@ -67,7 +67,7 @@ class pages_Home extends StatelessWidget {
outlineColor: Colors.white70,
onPressed: (){
LiveInformation liveInformation = LiveInformation();
liveInformation.announcementModule.queueAnnounementByInfoIndex(
liveInformation.announcementModule.queueAnnouncementByInfoIndex(
infoIndex: liveInformation.announcementModule.manualAnnouncements.indexOf(announcement),
sendToServer: true
);