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