desktop
This commit is contained in:
@@ -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,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user