diff --git a/lib/pages/views/creatematch.dart b/lib/pages/views/creatematch.dart index 4b1472a..cd4f3e5 100644 --- a/lib/pages/views/creatematch.dart +++ b/lib/pages/views/creatematch.dart @@ -67,9 +67,6 @@ class _CreateMatchPageState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text('Create Match'), - ), body: Center( child: Padding( padding: const EdgeInsets.all(16.0), diff --git a/lib/pages/views/joinmatch.dart b/lib/pages/views/joinmatch.dart index ee76187..e823d46 100644 --- a/lib/pages/views/joinmatch.dart +++ b/lib/pages/views/joinmatch.dart @@ -15,11 +15,9 @@ class _JoinMatchPageState extends State { bool _isLoading = false; int _player1Score = 0; int _player2Score = 0; + String? _player1name; + String? _player2name; String? _matchId; - bool _showJoinAsCheckbox = false; - bool _joinAsPlayer2 = false; - bool _joinAsPlayer3 = false; - bool _joinAsPlayer4 = false; final String _joinMatchApiUrl = '$apiurl/joinmatch'; final String _endMatchApiUrl = '$apiurl/endmatch'; @@ -49,8 +47,11 @@ class _JoinMatchPageState extends State { ); if (response.statusCode == 200) { + final responseData = json.decode(response.body); setState(() { _isJoined = true; + _player1name = responseData['player1_name']; + _player2name = responseData['player2_name']; _player1Score = 0; _player2Score = 0; _matchId = matchId; @@ -125,79 +126,115 @@ 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( - appBar: AppBar( - title: Text('Join Match'), - ), body: Padding( padding: const EdgeInsets.all(16.0), child: _isLoading ? Center(child: CircularProgressIndicator()) : _isJoined - ? Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - IconButton( - icon: Icon(Icons.remove), - onPressed: () => _updateScore(1, -1), + ? Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // Player 1 + Text( + _player1name ?? 'Player 1', + style: TextStyle( + fontSize: 18, + color: Colors.white, ), - Text( - 'Player 1 Score: $_player1Score', - style: TextStyle(fontSize: 20), + ), + SizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + icon: Icon(Icons.remove, color: Colors.white), + onPressed: () => _updateScore(1, -1), + ), + Container( + width: 100, + height: 50, + decoration: BoxDecoration( + border: + Border.all(color: Colors.white, width: 2), + borderRadius: BorderRadius.circular(8), + ), + child: Center( + child: Text( + '$_player1Score', + style: TextStyle( + fontSize: 24, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + IconButton( + icon: Icon(Icons.add, color: Colors.white), + onPressed: () => _updateScore(1, 1), + ), + ], + ), + SizedBox(height: 8), + Divider( + color: Colors.white, + thickness: 2, + indent: 80, + endIndent: 80, + ), + SizedBox(height: 8), + // Player 2 + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + icon: Icon(Icons.remove, color: Colors.white), + onPressed: () => _updateScore(2, -1), + ), + Container( + width: 100, + height: 50, + decoration: BoxDecoration( + border: + Border.all(color: Colors.white, width: 2), + borderRadius: BorderRadius.circular(8), + ), + child: Center( + child: Text( + '$_player2Score', + style: TextStyle( + fontSize: 24, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ), + ), + IconButton( + icon: Icon(Icons.add, color: Colors.white), + onPressed: () => _updateScore(2, 1), + ), + ], + ), + SizedBox(height: 8), + Text( + _player2name ?? 'Player 2', + style: TextStyle( + fontSize: 18, + color: Colors.white, ), - IconButton( - icon: Icon(Icons.add), - onPressed: () => _updateScore(1, 1), - ), - ], - ), - SizedBox(height: 16), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - IconButton( - icon: Icon(Icons.remove), - onPressed: () => _updateScore(2, -1), - ), - Text( - 'Player 2 Score: $_player2Score', - style: TextStyle(fontSize: 20), - ), - IconButton( - icon: Icon(Icons.add), - onPressed: () => _updateScore(2, 1), - ), - ], - ), - SizedBox(height: 32), - ElevatedButton( - onPressed: _endMatch, - child: Text('End Match'), - ), - ], + ), + SizedBox(height: 32), + ElevatedButton( + onPressed: _endMatch, + child: Text('End Match'), + ), + ], + ), ) : Column( mainAxisAlignment: MainAxisAlignment.center, @@ -222,40 +259,6 @@ 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; - }); - }, - ), - ], - ), ], ), ), diff --git a/lib/pages/views/myprofile.dart b/lib/pages/views/myprofile.dart index 3a8cfb7..3a26efd 100644 --- a/lib/pages/views/myprofile.dart +++ b/lib/pages/views/myprofile.dart @@ -74,6 +74,17 @@ class _ProfilePageState extends State { ); } + String getRankImage(int? elo) { + if (elo == null) return 'ranks/none.png'; + if (elo > 1000) return 'ranks/u.png'; + if (elo > 750) return 'ranks/s.png'; + if (elo > 400) return 'ranks/a.png'; + if (elo > 200) return 'ranks/b.png'; + if (elo > 100) return 'ranks/c.png'; + if (elo > 30) return 'ranks/d.png'; + return 'ranks/none.png'; + } + @override Widget build(BuildContext context) { return Scaffold( @@ -88,7 +99,6 @@ class _ProfilePageState extends State { padding: EdgeInsets.all(16.0), child: Row( children: [ - // Profile Icon CircleAvatar( backgroundColor: _generateRandomColor(), child: Text( @@ -99,6 +109,7 @@ class _ProfilePageState extends State { ), radius: 40, ), + SizedBox(width: 16), // Profile Info Column( @@ -116,10 +127,15 @@ class _ProfilePageState extends State { Text('ELO: ${_elo ?? 'N/A'}'), ], ), + SizedBox(width: 25), + Image.asset( + getRankImage(_elo), + width: 137, + height: 137, + ), ], ), ), - SizedBox(height: 16), // Recent Matches Expanded( child: _matches.isEmpty diff --git a/pubspec.yaml b/pubspec.yaml index 83f722c..c1ed1a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: pingpongapp description: "DTH Ping Pong Score tracking app" publish_to: 'none' -version: 0.0.34+1 +version: 0.0.51+2 environment: sdk: '>=3.4.3 <4.0.0' @@ -17,6 +17,7 @@ dependencies: package_info: ^2.0.2 font_awesome_flutter: ^10.8.0 url_launcher: ^6.3.1 + fl_chart: ^0.70.2 dev_dependencies: flutter_test: @@ -26,8 +27,14 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg + assets: + - ranks/none.png + - ranks/A.png + - ranks/B.png + - ranks/C.png + - ranks/D.png + - ranks/S.png + - ranks/U.png # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see diff --git a/ranks/A.png b/ranks/A.png new file mode 100644 index 0000000..2110bf1 Binary files /dev/null and b/ranks/A.png differ diff --git a/ranks/B.png b/ranks/B.png new file mode 100644 index 0000000..36083e0 Binary files /dev/null and b/ranks/B.png differ diff --git a/ranks/C.png b/ranks/C.png new file mode 100644 index 0000000..4ef7ace Binary files /dev/null and b/ranks/C.png differ diff --git a/ranks/D.png b/ranks/D.png new file mode 100644 index 0000000..a2c2596 Binary files /dev/null and b/ranks/D.png differ diff --git a/ranks/S.png b/ranks/S.png new file mode 100644 index 0000000..b06a99a Binary files /dev/null and b/ranks/S.png differ diff --git a/ranks/U.png b/ranks/U.png new file mode 100644 index 0000000..062ee37 Binary files /dev/null and b/ranks/U.png differ diff --git a/ranks/none.png b/ranks/none.png new file mode 100644 index 0000000..206af9d Binary files /dev/null and b/ranks/none.png differ