diff --git a/lib/pages/views/creatematch.dart b/lib/pages/views/creatematch.dart index 39e4a8f..4b1472a 100644 --- a/lib/pages/views/creatematch.dart +++ b/lib/pages/views/creatematch.dart @@ -12,6 +12,7 @@ class CreateMatchPage extends StatefulWidget { class _CreateMatchPageState extends State { String? _matchId; bool _isLoading = false; + bool _isTwoPlayerModeEnabled = false; // Track the toggle state final String _createMatchApiUrl = '$apiurl/creatematch'; @@ -101,6 +102,20 @@ class _CreateMatchPageState extends State { child: Text('Create Match'), ), SizedBox(height: 16), + SwitchListTile( + title: Text('Enable 2 player mode'), + value: _isTwoPlayerModeEnabled, + onChanged: (bool value) { + setState(() { + _isTwoPlayerModeEnabled = value; + }); + if (_isTwoPlayerModeEnabled) { + _showToast( + 'We\'re sorry, this feature isn\'t available yet'); + } + }, + ), + SizedBox(height: 16), if (_matchId != null) Text( 'Your Match ID: $_matchId', diff --git a/lib/pages/views/joinmatch.dart b/lib/pages/views/joinmatch.dart index 58b506f..ee76187 100644 --- a/lib/pages/views/joinmatch.dart +++ b/lib/pages/views/joinmatch.dart @@ -16,6 +16,10 @@ class _JoinMatchPageState extends State { int _player1Score = 0; int _player2Score = 0; String? _matchId; + bool _showJoinAsCheckbox = false; + bool _joinAsPlayer2 = false; + bool _joinAsPlayer3 = false; + bool _joinAsPlayer4 = false; final String _joinMatchApiUrl = '$apiurl/joinmatch'; final String _endMatchApiUrl = '$apiurl/endmatch'; @@ -103,7 +107,6 @@ class _JoinMatchPageState extends State { if (response.statusCode == 200) { _showToast('Match ended successfully!'); - Navigator.pop(context); } else { _showToast('Failed to end match.'); } @@ -122,6 +125,23 @@ class _JoinMatchPageState extends State { ); } + @override + void initState() { + super.initState(); + _matchIdController.addListener(() { + if (_matchIdController.text.contains(RegExp(r'[Dd]'))) { + setState(() { + _showJoinAsCheckbox = true; + }); + _showToast('We\'re sorry, this feature isn\'t available yet'); + } else { + setState(() { + _showJoinAsCheckbox = false; + }); + } + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -155,7 +175,6 @@ class _JoinMatchPageState extends State { ], ), SizedBox(height: 16), - // Player 2 Score Controls Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -174,7 +193,6 @@ class _JoinMatchPageState extends State { ], ), SizedBox(height: 32), - // End Match Button ElevatedButton( onPressed: _endMatch, child: Text('End Match'), @@ -194,7 +212,6 @@ class _JoinMatchPageState extends State { ), ), SizedBox(height: 16), - // Join Match Button ElevatedButton( onPressed: () { if (_matchIdController.text.isNotEmpty) { @@ -205,6 +222,40 @@ class _JoinMatchPageState extends State { }, child: Text('Join Match'), ), + SizedBox(height: 16), + if (_showJoinAsCheckbox) + Column( + children: [ + Text('Join as:'), + CheckboxListTile( + title: Text('Player 2'), + value: _joinAsPlayer2, + onChanged: (bool? value) { + setState(() { + _joinAsPlayer2 = value ?? false; + }); + }, + ), + CheckboxListTile( + title: Text('Player 3'), + value: _joinAsPlayer3, + onChanged: (bool? value) { + setState(() { + _joinAsPlayer3 = value ?? false; + }); + }, + ), + CheckboxListTile( + title: Text('Player 4'), + value: _joinAsPlayer4, + onChanged: (bool? value) { + setState(() { + _joinAsPlayer4 = value ?? false; + }); + }, + ), + ], + ), ], ), ),