diff --git a/lib/status_page.dart b/lib/status_page.dart index 5b74df4..e35ab25 100644 --- a/lib/status_page.dart +++ b/lib/status_page.dart @@ -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 { final WebSocketChannel channel = WebSocketChannel.connect( Uri.parse('wss://api.pogdark.com:8889/ws'), + //Uri.parse('ws://localhost:8080/ws'), ); late final Stream broadcastStream; @@ -76,7 +78,7 @@ class StatusPageState extends State { 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 { jsonDecode(snapshot.data as String) as Map; _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 { child: Column( children: [ const Text( - 'Arrived', + 'At the Pogdark', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold), ), @@ -228,26 +230,24 @@ class StatusPageState extends State { 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 { onPressed: widget.toggleProfile, tooltip: 'Edit Profile', ), + if (kDebugMode) ...[ + const SizedBox(height: 20), + Text( + status, + style: TextStyle(color: Colors.red), + ), + ], ], ), ],