import 'dart:async'; import 'package:bus_infotainment/backend/live_information.dart'; import 'package:bus_infotainment/utils/delegates.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:text_scroll/text_scroll.dart'; class ibus_display extends StatefulWidget { bool hasBorder = true; ibus_display({ this.hasBorder = true }); @override State createState() => _ibus_displayState(); } class _ibus_displayState extends State { String topLine = "*** NO MESSAGE ***"; String bottomLine = ""; late final ListenerReceipt _receipt; _ibus_displayState(){ LiveInformation liveInformation = LiveInformation(); _receipt = liveInformation.announcementModule.onAnnouncement.addListener((value) { if (topLine == value.displayText){ return; } topLine = value.displayText; setState(() { }); }); topLine = liveInformation.announcementModule.currentAnnouncement?.displayText ?? liveInformation.announcementModule.defaultText; } 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 void dispose() { LiveInformation().announcementModule.onAnnouncement.removeListener(_receipt); super.dispose(); } @override Widget build(BuildContext context) { return Container( width: double.infinity, color: Colors.black, child: FittedBox( alignment: Alignment.center, child: Stack( children: [ Positioned.fill( child: Container( alignment: Alignment.bottomCenter, margin: EdgeInsets.all(1), child: Text( "© ImBenji.net - all rights reserved | © Transport for London - all rights reserved", style: GoogleFonts.teko( fontSize: 10, color: Colors.white.withOpacity(0.01), height: 1, shadows: [ Shadow( color: Colors.black, blurRadius: 5, ) ] ) ), ), ), Container( // width: double.infinity, // height: 100, decoration: BoxDecoration( 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", shadows: [ Shadow( color: Colors.orange, blurRadius: 5, ), ], ), ), ), ), Transform.translate( offset: Offset(0, -6), 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, ), ], ), ), ), ), ], ), ), ) ), Positioned.fill( child: Container( decoration: BoxDecoration( color: Colors.transparent, border: widget.hasBorder ? Border.all(color: Colors.grey.shade900, width: 2) : null, ), ), ) ], ), ), ); } }