calls/lib/views/lcd.dart

181 lines
6.1 KiB
Dart
Raw Permalink Normal View History

2024-08-20 09:11:21 -04:00
import 'package:intl/intl.dart';
2024-08-08 18:31:24 -04:00
import 'package:flutter/material.dart';
2024-10-19 23:26:55 -04:00
import 'package:provider/provider.dart';
2024-08-17 12:04:42 -04:00
import '../controller/stillbox.dart';
import '../pb/stillbox.pb.dart';
2024-08-08 18:31:24 -04:00
2024-08-17 16:51:47 -04:00
class LCD extends StatelessWidget {
final Color _lcdColor;
final SBCall? _call;
2024-08-17 21:53:19 -04:00
final int queueLen;
2024-08-20 09:11:21 -04:00
final DateFormat timeFormat;
const LCD(this._call, this._lcdColor, this.queueLen, this.timeFormat,
{super.key});
2024-08-17 13:43:26 -04:00
2024-08-08 18:31:24 -04:00
@override
Widget build(BuildContext context) {
return Container(
2024-08-17 13:43:26 -04:00
decoration: BoxDecoration(
color: _lcdColor,
border: const Border(
2024-08-21 15:01:14 -04:00
top: BorderSide(width: 3.0, color: Color.fromARGB(255, 94, 94, 94)),
2024-10-19 23:26:55 -04:00
left:
BorderSide(width: 3.0, color: Color.fromARGB(255, 63, 63, 63)),
2024-08-21 09:11:27 -04:00
bottom: BorderSide(width: 3.0, color: Colors.white),
2024-10-19 23:26:55 -04:00
right: BorderSide(
width: 3.0, color: Color.fromARGB(255, 229, 229, 229)),
2024-08-08 18:31:24 -04:00
),
),
margin: const EdgeInsets.all(16.0),
alignment: Alignment.topCenter,
width: double.infinity,
child: AspectRatio(
aspectRatio: 16 / 9,
2024-08-17 12:04:42 -04:00
child: Padding(
padding: const EdgeInsets.all(10.0),
child: DefaultTextStyle(
style: const TextStyle(
color: Colors.black,
),
2024-08-17 13:43:26 -04:00
child: lcdContents(),
2024-08-17 12:04:42 -04:00
),
),
2024-08-08 18:31:24 -04:00
));
}
2024-08-17 13:43:26 -04:00
Widget lcdContents() {
2024-08-20 09:11:21 -04:00
String callTime = '';
if (_call != null) {
2024-08-20 12:48:25 -04:00
callTime =
timeFormat.format(_call.call.dateTime.toDateTime(toLocal: true));
2024-08-20 09:11:21 -04:00
}
return FutureBuilder(
future: _call?.tg,
builder: (BuildContext context, AsyncSnapshot<TalkgroupInfo> tgi) {
2024-08-20 12:48:25 -04:00
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
2024-08-21 09:11:27 -04:00
children: [
2024-08-20 12:48:25 -04:00
Text(callTime),
Text(
'${tgi.data?.systemName ?? (_call?.call.system ?? '')}'),
Text('Q: $queueLen'),
]),
2024-10-19 23:26:55 -04:00
Row(children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
2024-08-21 15:01:14 -04:00
children: [
2024-10-19 23:26:55 -04:00
Row(
children: [
ConstrainedBox(
constraints: BoxConstraints(
maxWidth:
MediaQuery.sizeOf(context).width / 1.6),
child: Text(
'${tgi.data?.name ?? (_call?.call.talkgroup ?? '')}${tgi.data?.learned ?? false ? ' 📓' : ''}',
style: const TextStyle(
fontSize: 20.0,
overflow: TextOverflow.ellipsis,
)),
2024-08-21 15:01:14 -04:00
),
2024-10-19 23:26:55 -04:00
Text(_call != null ? '${_call.call.talkgroup}' : '',
textAlign: TextAlign.end,
style: const TextStyle(
fontSize: 10,
overflow: TextOverflow.ellipsis,
)),
],
),
Text(tgi.data != null ? tgi.data!.group : ''),
])
]),
2024-08-20 12:48:25 -04:00
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2024-10-19 23:26:55 -04:00
Text(_call != null
? '${(_call.call.frequency.toDouble() / 1024 / 1024).toStringAsFixed(4)} MHz'
: ''),
2024-08-20 12:48:25 -04:00
Text(_call != null ? 'S: ${_call.call.source}' : ''),
]),
]);
2024-08-20 09:11:21 -04:00
});
2024-08-17 13:43:26 -04:00
}
2024-08-08 18:31:24 -04:00
}
2024-08-17 16:51:47 -04:00
class LED extends StatelessWidget {
final Color _ledColor;
2024-08-20 12:48:25 -04:00
const LED(this._ledColor, {super.key});
2024-08-08 18:31:24 -04:00
@override
2024-08-17 16:51:47 -04:00
Widget build(BuildContext context) {
return Container(
width: 20.0,
height: 20.0,
2024-08-20 12:48:25 -04:00
margin: const EdgeInsets.only(top: 4.0, right: 10.0),
2024-08-17 16:51:47 -04:00
decoration: BoxDecoration(
2024-10-19 23:26:55 -04:00
color: _ledColor,
shape: BoxShape.circle,
border: const Border(
2024-08-21 09:11:27 -04:00
top: BorderSide(width: 1.0, color: Colors.white),
left: BorderSide(width: 1.0, color: Colors.white),
2024-10-19 23:26:55 -04:00
),
boxShadow: [
BoxShadow(
color: const Color.fromARGB(255, 151, 151, 151),
offset: Offset.fromDirection(1, 3.0),
blurRadius: 4.0,
spreadRadius: 2.0)
]),
2024-08-17 16:51:47 -04:00
);
}
2024-08-08 18:31:24 -04:00
}
2024-08-17 16:51:47 -04:00
class ScannerLabel extends StatelessWidget {
final String _label;
2024-08-08 18:31:24 -04:00
2024-08-17 16:51:47 -04:00
const ScannerLabel(this._label, {super.key});
2024-08-08 18:31:24 -04:00
@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 10),
alignment: Alignment.topLeft,
2024-10-19 23:26:55 -04:00
child: GestureDetector(
onTap: () {
final version = Provider.of<Stillbox>(context, listen: false).version;
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
elevation: 5.0,
backgroundColor: Colors.grey,
child: Container(
padding: EdgeInsets.all(20.0),
child: Text(
'Server info:\n${version.serverName} ${version.version}\nbuilt ${version.built}\nrunning on ${version.platform}',
style: TextStyle(color: Colors.black),
),
),
);
},
);
},
child: Text(_label,
textAlign: TextAlign.left,
style: const TextStyle(
fontSize: 22.0,
fontWeight: FontWeight.bold,
fontFamily: "Warnes",
)),
),
2024-08-08 18:31:24 -04:00
);
}
}