Compare commits

...

3 commits
0.0.55 ... main

Author SHA1 Message Date
Mercurio d27ccfacd4 Minor version bump, add rank icons and leaderboard sorting 2025-01-30 21:25:42 +01:00
Mercurio 0041f5bc4c Resized 2v2 matchcontroller 2025-01-27 22:21:32 +01:00
Mercurio ce08cd7eb4 ok so we shouldn't leave the app set on the testing api. 2025-01-25 19:21:58 +01:00
21 changed files with 78 additions and 31 deletions

View file

@ -3,6 +3,7 @@ analyzer:
errors:
library_private_types_in_public_api: ignore
prefer_const_constructors: ignore
prefer_const_literals_to_create_immutables: ignore
prefer_final_fields: ignore
use_build_context_synchronously: ignore
use_key_in_widget_constructors: ignore

BIN
assets/A.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
assets/B.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
assets/C.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
assets/D.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
assets/E.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
assets/S.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
assets/SS.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
assets/infdan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
assets/none.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
assets/player_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/player_0_dp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/player_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/player_1_dp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/player_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/player_2_dp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -1,3 +1,3 @@
// lib/globals.dart
//const String apiurl = "https://api.dthpp.mercurio.moe";
const String apiurl = "http://192.168.1.120:9134";
const String apiurl = "https://api.dthpp.mercurio.moe";
//const String apiurl = "http://192.168.1.120:9134";

View file

@ -214,7 +214,7 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
color: Colors.white),
onPressed: () => _updateScore(1, -1)),
Container(
width: 100,
width: 70,
height: 50,
decoration: BoxDecoration(
border: Border.all(
@ -237,7 +237,7 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
),
],
),
SizedBox(width: 32),
SizedBox(width: 20),
Column(
children: [
Text(_players[1],
@ -249,7 +249,7 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
color: Colors.white),
onPressed: () => _updateScore(2, -1)),
Container(
width: 100,
width: 70,
height: 50,
decoration: BoxDecoration(
border: Border.all(
@ -290,7 +290,7 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
color: Colors.white),
onPressed: () => _updateScore(3, -1)),
Container(
width: 100,
width: 70,
height: 50,
decoration: BoxDecoration(
border: Border.all(
@ -313,7 +313,7 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
),
],
),
SizedBox(width: 32),
SizedBox(width: 20),
Column(
children: [
Text(_players[3],
@ -325,7 +325,7 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
color: Colors.white),
onPressed: () => _updateScore(4, -1)),
Container(
width: 100,
width: 75,
height: 50,
decoration: BoxDecoration(
border: Border.all(

View file

@ -11,6 +11,7 @@ class LeaderboardPage extends StatefulWidget {
class _LeaderboardPageState extends State<LeaderboardPage> {
List<dynamic> _leaderboard = [];
bool _isLoading = true;
bool _sortByOskMu = false;
final String _leaderboardApi = '$apiurl/leaderboards';
@ -26,6 +27,7 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
List<dynamic> data = json.decode(response.body);
setState(() {
_leaderboard = data;
_sortLeaderboard();
_isLoading = false;
});
} else {
@ -42,6 +44,23 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
}
}
void _sortLeaderboard() {
setState(() {
if (_sortByOskMu) {
_leaderboard.sort((a, b) => b['osk_mu'].compareTo(a['osk_mu']));
} else {
_leaderboard.sort((a, b) => b['elo_rating'].compareTo(a['elo_rating']));
}
});
}
void _toggleSort() {
setState(() {
_sortByOskMu = !_sortByOskMu;
_sortLeaderboard();
});
}
void _showError(String message) {
showDialog(
context: context,
@ -69,6 +88,16 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Leaderboard'),
actions: [
IconButton(
icon: Icon(Icons.sort),
onPressed: _toggleSort,
tooltip: _sortByOskMu ? 'Sort by Elo' : 'Sort by Osk_Mu',
),
],
),
body: _isLoading
? Center(child: CircularProgressIndicator())
: RefreshIndicator(
@ -77,16 +106,28 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
itemCount: _leaderboard.length,
itemBuilder: (context, index) {
var player = _leaderboard[index];
String truncatedOskMu = player['osk_mu'].toStringAsFixed(3);
String assetName = _sortByOskMu
? 'assets/player_${index}_dp.png'
: 'assets/player_${index}.png';
return Card(
margin: EdgeInsets.all(8),
child: ListTile(
contentPadding: EdgeInsets.all(10),
leading: CircleAvatar(
child: Text(player['player_name'][0].toUpperCase()),
child: Text(player['player_name'][0].toUpperCase())),
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(player['player_name']),
if (index < 3)
Image.asset(assetName, width: 45, height: 45),
],
),
title: Text(player['player_name']),
subtitle: Text(
'Elo: ${player['elo_rating']} | TSC: ${player['osk_mu']}'),
'Elo: ${player['elo_rating']} | TSC: $truncatedOskMu'),
trailing: Text('UID: ${player['friend_code']}'),
),
);

View file

@ -79,14 +79,15 @@ class _ProfilePageState extends State<ProfilePage> {
}
String getRankImage(int? elo) {
if (elo == null) return '$apiurl/assets/none.png';
if (elo > 1000) return '$apiurl/assets/U.png';
if (elo > 750) return '$apiurl/assets/S.png';
if (elo > 400) return '$apiurl/assets/A.png';
if (elo > 200) return '$apiurl/assets/B.png';
if (elo > 100) return '$apiurl/assets/C.png';
if (elo > 30) return '$apiurl/assets/D.png';
return '$apiurl/assets/none.png';
if (elo == null || elo < -100) return 'assets/none.png';
if (elo >= 120) return 'assets/infdan.png';
if (elo >= 90) return 'assets/SS.png';
if (elo >= 60) return 'assets/S.png';
if (elo >= 30) return 'assets/A.png';
if (elo >= 0) return 'assets/B.png';
if (elo >= -30) return 'assets/C.png';
if (elo >= -60) return 'assets/D.png';
return 'assets/E.png';
}
void _showExplanationDialog() {
@ -182,9 +183,7 @@ class _ProfilePageState extends State<ProfilePage> {
),
radius: 40,
),
SizedBox(width: 16),
// Profile Info
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -196,7 +195,19 @@ class _ProfilePageState extends State<ProfilePage> {
),
),
SizedBox(height: 6),
Row(
children: [
Text('UID: ${_uid ?? 'N/A'}'),
SizedBox(
width: 30,
),
Image.asset(
getRankImage(_elo),
width: 100,
height: 30,
),
],
),
Row(
children: [
Text(
@ -210,12 +221,6 @@ class _ProfilePageState extends State<ProfilePage> {
),
],
),
SizedBox(width: 25),
Image.network(
getRankImage(_elo),
width: 137,
height: 137,
),
],
),
),

View file

@ -2,7 +2,7 @@ name: pingpongapp
description: "DTH Ping Pong Score tracking app"
publish_to: 'none'
version: 0.0.55+1
version: 0.0.57+1
environment:
sdk: '>=3.4.3 <4.0.0'
@ -27,8 +27,8 @@ flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_ham.jpeg
assets:
- assets/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware