ToLaptop
This commit is contained in:
156
lib/pages/components/ibus_display.dart
Normal file
156
lib/pages/components/ibus_display.dart
Normal file
@@ -0,0 +1,156 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:bus_infotainment/singletons/live_information.dart';
|
||||
import 'package:bus_infotainment/utils/delegates.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:text_scroll/text_scroll.dart';
|
||||
|
||||
class ibus_display extends StatefulWidget {
|
||||
|
||||
bool hasBorder = true;
|
||||
|
||||
ibus_display({
|
||||
this.hasBorder = true
|
||||
});
|
||||
|
||||
@override
|
||||
State<ibus_display> createState() => _ibus_displayState();
|
||||
}
|
||||
|
||||
class _ibus_displayState extends State<ibus_display> {
|
||||
|
||||
String topLine = "*** NO MESSAGE ***";
|
||||
|
||||
late final ListenerReceipt<AnnouncementQueueEntry> _receipt;
|
||||
|
||||
_ibus_displayState(){
|
||||
|
||||
LiveInformation liveInformation = LiveInformation();
|
||||
_receipt = liveInformation.announcementDelegate.addListener((value) {
|
||||
topLine = value.displayText;
|
||||
setState(() {
|
||||
|
||||
});
|
||||
});
|
||||
topLine = liveInformation.CurrentAnnouncement;
|
||||
|
||||
}
|
||||
|
||||
Timer _timer() => Timer.periodic(Duration(seconds: 1), (timer) {
|
||||
setState(() {
|
||||
topLine = LiveInformation().CurrentAnnouncement;
|
||||
});
|
||||
});
|
||||
|
||||
String _padString(String input){
|
||||
|
||||
if (input.length < 40){
|
||||
print("Input is too short");
|
||||
return input;
|
||||
}
|
||||
|
||||
String prefix = "";
|
||||
String suffix = "";
|
||||
for (int i = 0; i < 80; i++){
|
||||
prefix += " ";
|
||||
}
|
||||
|
||||
return prefix + input + suffix;
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
|
||||
LiveInformation().announcementDelegate.removeListener(_receipt);
|
||||
|
||||
super.dispose();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
|
||||
return Container(
|
||||
|
||||
width: double.infinity,
|
||||
|
||||
child: FittedBox(
|
||||
alignment: Alignment.center,
|
||||
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
|
||||
// width: double.infinity,
|
||||
// height: 100,
|
||||
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black,
|
||||
border: widget.hasBorder ? Border.all(color: Colors.grey.shade900, width: 2) : null,
|
||||
),
|
||||
|
||||
clipBehavior: Clip.hardEdge,
|
||||
|
||||
child: Transform.scale(
|
||||
scale: 1.3,
|
||||
transformHitTests: false,
|
||||
child: Transform.translate(
|
||||
|
||||
offset: Offset(0, 4),
|
||||
|
||||
child: Column(
|
||||
|
||||
children: [
|
||||
Transform.translate(
|
||||
offset: Offset(0, 5),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
width: 32*4*3,
|
||||
child: TextScroll(
|
||||
_padString(topLine),
|
||||
velocity: Velocity(pixelsPerSecond: Offset(120, 0)),
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.orange,
|
||||
fontFamily: "ibus"
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Transform.translate(
|
||||
offset: Offset(0, -7),
|
||||
child: Text(
|
||||
"Bus Stopping",
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
color: Colors.orange,
|
||||
fontFamily: "ibus",
|
||||
height: 1.5
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
),
|
||||
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
border: widget.hasBorder ? Border.all(color: Colors.grey.shade900, width: 2) : null,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user