Simplified message values, added a couple of debugging helpers
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build Flutter Web App (push) Successful in 3m17s
All checks were successful
Build Flutter Web and Docker Image for Local Registry / Build Flutter Web App (push) Successful in 3m17s
This commit is contained in:
parent
f475c69402
commit
2c0c6cc79e
@ -1,5 +1,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:web_socket_channel/web_socket_channel.dart';
|
import 'package:web_socket_channel/web_socket_channel.dart';
|
||||||
@ -18,6 +19,7 @@ class StatusPage extends StatefulWidget {
|
|||||||
class StatusPageState extends State<StatusPage> {
|
class StatusPageState extends State<StatusPage> {
|
||||||
final WebSocketChannel channel = WebSocketChannel.connect(
|
final WebSocketChannel channel = WebSocketChannel.connect(
|
||||||
Uri.parse('wss://api.pogdark.com:8889/ws'),
|
Uri.parse('wss://api.pogdark.com:8889/ws'),
|
||||||
|
//Uri.parse('ws://localhost:8080/ws'),
|
||||||
);
|
);
|
||||||
|
|
||||||
late final Stream<dynamic> broadcastStream;
|
late final Stream<dynamic> broadcastStream;
|
||||||
@ -76,7 +78,7 @@ class StatusPageState extends State<StatusPage> {
|
|||||||
|
|
||||||
messages.removeWhere((msg) => msg['Id'] == incomingId);
|
messages.removeWhere((msg) => msg['Id'] == incomingId);
|
||||||
|
|
||||||
if (status == 'expired') {
|
if (status == 'expired' && incomingId == prefsProvider.getUserId()) {
|
||||||
await prefsProvider.setCurrentStatus('');
|
await prefsProvider.setCurrentStatus('');
|
||||||
} else {
|
} else {
|
||||||
messages.add(message);
|
messages.add(message);
|
||||||
@ -169,9 +171,9 @@ class StatusPageState extends State<StatusPage> {
|
|||||||
jsonDecode(snapshot.data as String) as Map<String, dynamic>;
|
jsonDecode(snapshot.data as String) as Map<String, dynamic>;
|
||||||
_handleIncomingMessage(newMessage);
|
_handleIncomingMessage(newMessage);
|
||||||
}
|
}
|
||||||
|
var status = prefsProvider.getCurrentStatus();
|
||||||
final onTheWayMessages = _getMessagesByStatus('is on the way');
|
final onTheWayMessages = _getMessagesByStatus('otw');
|
||||||
final arrivedMessages = _getMessagesByStatus('has arrived');
|
final arrivedMessages = _getMessagesByStatus('here');
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
@ -204,7 +206,7 @@ class StatusPageState extends State<StatusPage> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
const Text(
|
const Text(
|
||||||
'Arrived',
|
'At the Pogdark',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18, fontWeight: FontWeight.bold),
|
fontSize: 18, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
@ -228,26 +230,24 @@ class StatusPageState extends State<StatusPage> {
|
|||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: getButtonColor('is on the way'),
|
backgroundColor: getButtonColor('otw'),
|
||||||
),
|
),
|
||||||
onPressed: () => _sendStatus(
|
onPressed: () =>
|
||||||
userId, userName, userLogo, 'is on the way'),
|
_sendStatus(userId, userName, userLogo, 'otw'),
|
||||||
child: Text(
|
child: Text(
|
||||||
'On the Way',
|
'On the Way',
|
||||||
style: TextStyle(
|
style: TextStyle(color: getButtonTextColor('otw')),
|
||||||
color: getButtonTextColor('is on the way')),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: getButtonColor('has arrived'),
|
backgroundColor: getButtonColor('here'),
|
||||||
),
|
),
|
||||||
onPressed: () => _sendStatus(
|
onPressed: () =>
|
||||||
userId, userName, userLogo, 'has arrived'),
|
_sendStatus(userId, userName, userLogo, 'here'),
|
||||||
child: Text(
|
child: Text(
|
||||||
'Arrived',
|
'Arrived',
|
||||||
style:
|
style: TextStyle(color: getButtonTextColor('here')),
|
||||||
TextStyle(color: getButtonTextColor('has arrived')),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
@ -255,6 +255,13 @@ class StatusPageState extends State<StatusPage> {
|
|||||||
onPressed: widget.toggleProfile,
|
onPressed: widget.toggleProfile,
|
||||||
tooltip: 'Edit Profile',
|
tooltip: 'Edit Profile',
|
||||||
),
|
),
|
||||||
|
if (kDebugMode) ...[
|
||||||
|
const SizedBox(height: 20),
|
||||||
|
Text(
|
||||||
|
status,
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user