mirror of
https://github.com/amigan/calls.git
synced 2024-11-21 12:29:47 -05:00
wip
This commit is contained in:
parent
ce3523fbd1
commit
38943343ea
3 changed files with 35 additions and 13 deletions
|
@ -20,8 +20,8 @@ class Stillbox extends ChangeNotifier {
|
|||
Filter? currentFilter;
|
||||
SBCall? _currentCall;
|
||||
Uri? baseUri = Uri.base;
|
||||
final StreamController<SBCall> callStream =
|
||||
StreamController<SBCall>.broadcast();
|
||||
int queueLen = 0;
|
||||
final StreamController<SBCall> callStream = StreamController<SBCall>();
|
||||
|
||||
set state(LiveState newState) {
|
||||
channel.sink.add(Live(state: newState, filter: currentFilter));
|
||||
|
@ -109,11 +109,16 @@ class Stillbox extends ChangeNotifier {
|
|||
setUris();
|
||||
}
|
||||
|
||||
void dispatchCall(SBCall call) {
|
||||
queueLen++;
|
||||
callStream.add(call);
|
||||
}
|
||||
|
||||
void _handleData(dynamic event) {
|
||||
final msg = Message.fromBuffer(event);
|
||||
switch (msg.whichToClientMessage()) {
|
||||
case Message_ToClientMessage.call:
|
||||
callStream.add(SBCall(
|
||||
dispatchCall(SBCall(
|
||||
msg.call, tgCache.getTg(msg.call.system, msg.call.talkgroup)));
|
||||
case Message_ToClientMessage.notification:
|
||||
case Message_ToClientMessage.popup:
|
||||
|
|
|
@ -6,7 +6,8 @@ import '../pb/stillbox.pb.dart';
|
|||
class LCD extends StatelessWidget {
|
||||
final Color _lcdColor;
|
||||
final SBCall? _call;
|
||||
const LCD(this._call, this._lcdColor, {super.key});
|
||||
final int queueLen;
|
||||
const LCD(this._call, this._lcdColor, this.queueLen, {super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -39,12 +40,18 @@ class LCD extends StatelessWidget {
|
|||
}
|
||||
|
||||
Widget lcdContents() {
|
||||
return FutureBuilder(
|
||||
future: _call?.tg,
|
||||
builder: (BuildContext context, AsyncSnapshot<TalkgroupInfo> tgi) {
|
||||
return Text(
|
||||
'${tgi.data?.name ?? (_call?.call.talkgroup ?? '')}${tgi.data?.learned ?? false ? ' 📓' : ''}');
|
||||
});
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
FutureBuilder(
|
||||
future: _call?.tg,
|
||||
builder:
|
||||
(BuildContext context, AsyncSnapshot<TalkgroupInfo> tgi) {
|
||||
return Text(
|
||||
'${tgi.data?.name ?? (_call?.call.talkgroup ?? '')}${tgi.data?.learned ?? false ? ' 📓' : ''}');
|
||||
}),
|
||||
Text('Q: $queueLen'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ class _MainRadioState extends State<MainRadio> {
|
|||
Color _ledColor = Colors.black;
|
||||
Timer? _lcdTimer;
|
||||
SBCall? _call;
|
||||
Future<bool> completion;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -39,14 +40,22 @@ class _MainRadioState extends State<MainRadio> {
|
|||
});
|
||||
}
|
||||
});
|
||||
sb.callStream.stream.listen((call) async {
|
||||
_callLoop(sb);
|
||||
// sb.callStream.stream.listen((call) async {
|
||||
}
|
||||
|
||||
void _callLoop(Stillbox sb) async {
|
||||
await for (final call in sb.callStream.stream) {
|
||||
lcdOn();
|
||||
setState(() {
|
||||
_call = call;
|
||||
sb.queueLen--;
|
||||
});
|
||||
print("bef");
|
||||
await player.play(call.call);
|
||||
print("aft");
|
||||
lcdOff();
|
||||
});
|
||||
} //);
|
||||
}
|
||||
|
||||
void lcdOn() {
|
||||
|
@ -88,7 +97,8 @@ class _MainRadioState extends State<MainRadio> {
|
|||
const ScannerLabel('Stillbox'),
|
||||
LED(_ledColor),
|
||||
]),
|
||||
LCD(_call, _lcdColor),
|
||||
LCD(_call, _lcdColor,
|
||||
Provider.of<Stillbox>(context, listen: false).queueLen),
|
||||
const Keypad(),
|
||||
],
|
||||
)),
|
||||
|
|
Loading…
Reference in a new issue