Compare commits
No commits in common. "main" and "0.0.36+1" have entirely different histories.
|
@ -3,8 +3,6 @@ analyzer:
|
||||||
errors:
|
errors:
|
||||||
library_private_types_in_public_api: ignore
|
library_private_types_in_public_api: ignore
|
||||||
prefer_const_constructors: ignore
|
prefer_const_constructors: ignore
|
||||||
prefer_const_literals_to_create_immutables: ignore
|
|
||||||
prefer_final_fields: ignore
|
|
||||||
use_build_context_synchronously: ignore
|
use_build_context_synchronously: ignore
|
||||||
use_key_in_widget_constructors: ignore
|
use_key_in_widget_constructors: ignore
|
||||||
use_super_parameters: ignore
|
use_super_parameters: ignore
|
||||||
|
|
BIN
assets/A.png
Before Width: | Height: | Size: 6.8 KiB |
BIN
assets/B.png
Before Width: | Height: | Size: 6.9 KiB |
BIN
assets/C.png
Before Width: | Height: | Size: 6.8 KiB |
BIN
assets/D.png
Before Width: | Height: | Size: 6.7 KiB |
BIN
assets/E.png
Before Width: | Height: | Size: 6.6 KiB |
BIN
assets/S.png
Before Width: | Height: | Size: 6.6 KiB |
BIN
assets/SS.png
Before Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 23 KiB |
BIN
assets/none.png
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB |
|
@ -1,3 +1,3 @@
|
||||||
// lib/globals.dart
|
// lib/globals.dart
|
||||||
const String apiurl = "https://api.dthpp.mercurio.moe";
|
const String apiurl = "https://api.dthpp.mercurio.moe";
|
||||||
//const String apiurl = "http://192.168.1.120:9134";
|
//const String apiurl = "http://10.0.0.10:9134";
|
||||||
|
|
|
@ -7,9 +7,6 @@ import 'views/joinmatch.dart';
|
||||||
import 'views/creatematch.dart';
|
import 'views/creatematch.dart';
|
||||||
import 'views/friendlist.dart';
|
import 'views/friendlist.dart';
|
||||||
import 'views/myprofile.dart';
|
import 'views/myprofile.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'dart:convert';
|
|
||||||
import '../globals.dart';
|
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
|
@ -19,6 +16,7 @@ class HomePage extends StatefulWidget {
|
||||||
class _HomePageState extends State<HomePage> {
|
class _HomePageState extends State<HomePage> {
|
||||||
int _selectedIndex = 0;
|
int _selectedIndex = 0;
|
||||||
|
|
||||||
|
// Define the pages for each section
|
||||||
final List<Widget> _pages = [
|
final List<Widget> _pages = [
|
||||||
LeaderboardPage(),
|
LeaderboardPage(),
|
||||||
JoinMatchPage(),
|
JoinMatchPage(),
|
||||||
|
@ -42,46 +40,14 @@ class _HomePageState extends State<HomePage> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, String>> fetchCommitHashes() async {
|
|
||||||
const apiUrl = '$apiurl/version';
|
|
||||||
|
|
||||||
try {
|
|
||||||
final response = await http.get(Uri.parse(apiUrl));
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
final data = jsonDecode(response.body);
|
|
||||||
|
|
||||||
String formatHash(String? hash) {
|
|
||||||
if (hash == null) return 'Unknown';
|
|
||||||
return '#${hash.substring(0, 8).toUpperCase()}';
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
'backend': formatHash(data['backend']),
|
|
||||||
'frontend': formatHash(data['frontend']),
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
throw Exception('Failed to fetch commit hashes');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return {
|
|
||||||
'backend': 'Error fetching hash',
|
|
||||||
'frontend': 'Error fetching hash',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _showOpenSourceLicenses() async {
|
Future<void> _showOpenSourceLicenses() async {
|
||||||
final commitHashes = await fetchCommitHashes();
|
|
||||||
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) => AboutDialog(
|
builder: (BuildContext context) => AboutDialog(
|
||||||
applicationIcon: const Icon(Icons.code),
|
applicationIcon: const Icon(Icons.code),
|
||||||
applicationLegalese: '© 2024 Thomas Bassi @ Defence Tech.',
|
applicationLegalese: '© 2024 Thomas Bassi @ Defence Tech.',
|
||||||
applicationName: 'DTHPP',
|
applicationName: 'DTHPP',
|
||||||
applicationVersion:
|
applicationVersion: '#B22AF349A1',
|
||||||
'API: ${commitHashes['backend']} - UI: ${commitHashes['frontend']}',
|
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 16.0),
|
padding: const EdgeInsets.only(top: 16.0),
|
||||||
|
|
|
@ -4,8 +4,6 @@ import 'package:http/http.dart' as http;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'home.dart';
|
import 'home.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
class LoginPage extends StatefulWidget {
|
class LoginPage extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
|
@ -23,17 +21,6 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
Future<void> _handleAuth() async {
|
Future<void> _handleAuth() async {
|
||||||
final email = _emailController.text.trim();
|
final email = _emailController.text.trim();
|
||||||
final password = _passwordController.text.trim();
|
final password = _passwordController.text.trim();
|
||||||
final displayName = _displayNameController.text.trim();
|
|
||||||
|
|
||||||
// Input validation
|
|
||||||
if (email.isEmpty ||
|
|
||||||
password.isEmpty ||
|
|
||||||
(!_isLogin && displayName.isEmpty)) {
|
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
|
||||||
SnackBar(content: Text('Please fill in all required fields.')),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
@ -49,7 +36,8 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
context, MaterialPageRoute(builder: (context) => HomePage()));
|
context, MaterialPageRoute(builder: (context) => HomePage()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final uid = await _register(email, password, displayName);
|
final uid = await _register(
|
||||||
|
email, password, _displayNameController.text.trim());
|
||||||
if (uid != null) {
|
if (uid != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLogin = true;
|
_isLogin = true;
|
||||||
|
@ -130,61 +118,21 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
decoration: InputDecoration(labelText: 'Display Name'),
|
decoration: InputDecoration(labelText: 'Display Name'),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (_isLoading)
|
_isLoading
|
||||||
CircularProgressIndicator()
|
? CircularProgressIndicator()
|
||||||
else
|
: ElevatedButton(
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
ElevatedButton(
|
|
||||||
onPressed: _handleAuth,
|
onPressed: _handleAuth,
|
||||||
child: Text(_isLogin ? 'Login' : 'Register'),
|
child: Text(_isLogin ? 'Login' : 'Register'),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLogin = !_isLogin;
|
_isLogin = !_isLogin;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Text(_isLogin ? 'Register' : 'Back to Login'),
|
child: Text(_isLogin
|
||||||
),
|
? 'Don\'t have an account? Register'
|
||||||
],
|
: 'Already have an account? Login'),
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(FontAwesomeIcons.github),
|
|
||||||
onPressed: () async {
|
|
||||||
final url = Uri.parse(
|
|
||||||
'https://git.mercurio.moe/Mercury/dth-pingpong-mobileapp');
|
|
||||||
if (await canLaunchUrl(url)) {
|
|
||||||
await launchUrl(
|
|
||||||
url,
|
|
||||||
mode: LaunchMode
|
|
||||||
.externalApplication, // Ensures it opens in the browser
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw 'Could not launch $url';
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(FontAwesomeIcons.chartSimple),
|
|
||||||
onPressed: () async {
|
|
||||||
final url =
|
|
||||||
Uri.parse('https://kuma.mercurio.moe/status/dthpp');
|
|
||||||
if (await canLaunchUrl(url)) {
|
|
||||||
await launchUrl(
|
|
||||||
url,
|
|
||||||
mode: LaunchMode
|
|
||||||
.externalApplication, // Ensures it opens in the browser
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw 'Could not launch $url';
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -12,11 +12,11 @@ class CreateMatchPage extends StatefulWidget {
|
||||||
class _CreateMatchPageState extends State<CreateMatchPage> {
|
class _CreateMatchPageState extends State<CreateMatchPage> {
|
||||||
String? _matchId;
|
String? _matchId;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _isTwoPlayerModeEnabled = false;
|
|
||||||
|
|
||||||
final String _createMatchApiUrl = '$apiurl/creatematch';
|
final String _createMatchApiUrl =
|
||||||
final String _createDoubleMatchUrl = '$apiurl/creatematch_2v2';
|
'$apiurl/creatematch'; // Replace with your API endpoint
|
||||||
|
|
||||||
|
// Method to create a match
|
||||||
Future<void> _createMatch() async {
|
Future<void> _createMatch() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
@ -34,10 +34,8 @@ class _CreateMatchPageState extends State<CreateMatchPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final String apiUrl =
|
|
||||||
_isTwoPlayerModeEnabled ? _createDoubleMatchUrl : _createMatchApiUrl;
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
Uri.parse(apiUrl),
|
Uri.parse(_createMatchApiUrl),
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: json.encode({'token': token}),
|
body: json.encode({'token': token}),
|
||||||
);
|
);
|
||||||
|
@ -45,10 +43,7 @@ class _CreateMatchPageState extends State<CreateMatchPage> {
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
setState(() {
|
setState(() {
|
||||||
_matchId = _isTwoPlayerModeEnabled
|
_matchId = data['match_id'].toString();
|
||||||
? data['match_id'].toString() +
|
|
||||||
'D' // Append "D" for two-player mode
|
|
||||||
: data['match_id'].toString();
|
|
||||||
});
|
});
|
||||||
_showToast('Match created successfully!');
|
_showToast('Match created successfully!');
|
||||||
} else {
|
} else {
|
||||||
|
@ -63,6 +58,7 @@ class _CreateMatchPageState extends State<CreateMatchPage> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show a Toast message (SnackBar in Flutter)
|
||||||
void _showToast(String message) {
|
void _showToast(String message) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(message)),
|
SnackBar(content: Text(message)),
|
||||||
|
@ -72,6 +68,9 @@ class _CreateMatchPageState extends State<CreateMatchPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('Create Match'),
|
||||||
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
@ -91,12 +90,6 @@ class _CreateMatchPageState extends State<CreateMatchPage> {
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
Text(
|
|
||||||
'Due to current limitations in how we handle matchmaking, only the joining player can control the match. This is only a temporary solution to a problem we are actively fixing.',
|
|
||||||
style: TextStyle(fontSize: 14),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
SizedBox(height: 16),
|
|
||||||
_isLoading
|
_isLoading
|
||||||
? CircularProgressIndicator() // Show loading spinner
|
? CircularProgressIndicator() // Show loading spinner
|
||||||
: ElevatedButton(
|
: ElevatedButton(
|
||||||
|
@ -104,16 +97,6 @@ class _CreateMatchPageState extends State<CreateMatchPage> {
|
||||||
child: Text('Create Match'),
|
child: Text('Create Match'),
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
SwitchListTile(
|
|
||||||
title: Text('Enable 2 player mode'),
|
|
||||||
value: _isTwoPlayerModeEnabled,
|
|
||||||
onChanged: (bool value) {
|
|
||||||
setState(() {
|
|
||||||
_isTwoPlayerModeEnabled = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
SizedBox(height: 16),
|
|
||||||
if (_matchId != null)
|
if (_matchId != null)
|
||||||
Text(
|
Text(
|
||||||
'Your Match ID: $_matchId',
|
'Your Match ID: $_matchId',
|
||||||
|
|
|
@ -13,22 +13,12 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
TextEditingController _matchIdController = TextEditingController();
|
TextEditingController _matchIdController = TextEditingController();
|
||||||
bool _isJoined = false;
|
bool _isJoined = false;
|
||||||
bool _isLoading = false;
|
bool _isLoading = false;
|
||||||
bool _is2v2Mode = false;
|
|
||||||
int _selectedSlot = 2;
|
|
||||||
int _player1Score = 0;
|
int _player1Score = 0;
|
||||||
int _player2Score = 0;
|
int _player2Score = 0;
|
||||||
int _player3Score = 0;
|
|
||||||
int _player4Score = 0;
|
|
||||||
String? _matchId;
|
String? _matchId;
|
||||||
String? _player1name;
|
|
||||||
String? _player2name;
|
|
||||||
List<String> _players = [];
|
|
||||||
bool _canEdit = false;
|
|
||||||
|
|
||||||
final String _joinMatchApiUrl = '$apiurl/joinmatch';
|
final String _joinMatchApiUrl = '$apiurl/joinmatch';
|
||||||
final String _joinMatch2v2ApiUrl = '$apiurl/joinmatch_2v2';
|
|
||||||
final String _endMatchApiUrl = '$apiurl/endmatch';
|
final String _endMatchApiUrl = '$apiurl/endmatch';
|
||||||
final String _endFourApiUrl = '$apiurl/endfour';
|
|
||||||
|
|
||||||
Future<void> _joinMatch() async {
|
Future<void> _joinMatch() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -48,52 +38,15 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (_is2v2Mode) {
|
|
||||||
// Joining a 2v2 match
|
|
||||||
final response = await http.post(
|
|
||||||
Uri.parse(_joinMatch2v2ApiUrl),
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: json.encode({
|
|
||||||
'token': token,
|
|
||||||
'match_id': int.parse(matchId),
|
|
||||||
'slot': _selectedSlot,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
final responseData = json.decode(response.body);
|
|
||||||
setState(() {
|
|
||||||
_isJoined = true;
|
|
||||||
_matchId = matchId;
|
|
||||||
_players = List<String>.from(
|
|
||||||
responseData['players'].map((p) => p['name']));
|
|
||||||
_canEdit = responseData['canEdit'];
|
|
||||||
_player1Score = 0;
|
|
||||||
_player2Score = 0;
|
|
||||||
_player3Score = 0;
|
|
||||||
_player4Score = 0;
|
|
||||||
});
|
|
||||||
_showToast('Joined match successfully!');
|
|
||||||
} else {
|
|
||||||
_showToast('Failed to join 2v2 match.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Joining a 1v1 match
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
Uri.parse(_joinMatchApiUrl),
|
Uri.parse(_joinMatchApiUrl),
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: json.encode({
|
body: json.encode({'token': token, 'match_id': int.parse(matchId)}),
|
||||||
'token': token,
|
|
||||||
'match_id': int.parse(matchId),
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final responseData = json.decode(response.body);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_isJoined = true;
|
_isJoined = true;
|
||||||
_player1name = responseData['player1_name'];
|
|
||||||
_player2name = responseData['player2_name'];
|
|
||||||
_player1Score = 0;
|
_player1Score = 0;
|
||||||
_player2Score = 0;
|
_player2Score = 0;
|
||||||
_matchId = matchId;
|
_matchId = matchId;
|
||||||
|
@ -102,7 +55,6 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
} else {
|
} else {
|
||||||
_showToast('Failed to join match.');
|
_showToast('Failed to join match.');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_showToast('Error: $e');
|
_showToast('Error: $e');
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -112,6 +64,16 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _updateScore(int player, int delta) {
|
||||||
|
setState(() {
|
||||||
|
if (player == 1) {
|
||||||
|
_player1Score += delta;
|
||||||
|
} else if (player == 2) {
|
||||||
|
_player2Score += delta;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _endMatch() async {
|
Future<void> _endMatch() async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
|
@ -129,27 +91,6 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (_is2v2Mode) {
|
|
||||||
// End the 2v2 match using the /endfour API
|
|
||||||
final response = await http.post(
|
|
||||||
Uri.parse(_endFourApiUrl),
|
|
||||||
headers: {'Content-Type': 'application/json'},
|
|
||||||
body: json.encode({
|
|
||||||
'match_id': int.parse(_matchId!),
|
|
||||||
'player1_team1_score': _player1Score,
|
|
||||||
'player2_team1_score': _player2Score,
|
|
||||||
'player1_team2_score': _player3Score,
|
|
||||||
'player2_team2_score': _player4Score,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
_showToast('2v2 match ended successfully!');
|
|
||||||
} else {
|
|
||||||
_showToast('Failed to end 2v2 match.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// End the 1v1 match
|
|
||||||
final response = await http.post(
|
final response = await http.post(
|
||||||
Uri.parse(_endMatchApiUrl),
|
Uri.parse(_endMatchApiUrl),
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
@ -162,10 +103,10 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
_showToast('Match ended successfully!');
|
_showToast('Match ended successfully!');
|
||||||
|
Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
_showToast('Failed to end match.');
|
_showToast('Failed to end match.');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_showToast('Error: $e');
|
_showToast('Error: $e');
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -184,244 +125,61 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: Text('Join Match'),
|
||||||
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: _isLoading
|
child: _isLoading
|
||||||
? Center(child: CircularProgressIndicator())
|
? Center(child: CircularProgressIndicator())
|
||||||
: _isJoined
|
: _isJoined
|
||||||
? Center(
|
? Column(
|
||||||
child: Column(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
// Display for 2v2 match
|
IconButton(
|
||||||
if (_is2v2Mode && _canEdit) ...[
|
icon: Icon(Icons.remove),
|
||||||
Text('2v2 Match',
|
onPressed: () => _updateScore(1, -1),
|
||||||
style:
|
),
|
||||||
TextStyle(color: Colors.white, fontSize: 24)),
|
Text(
|
||||||
|
'Player 1 Score: $_player1Score',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.add),
|
||||||
|
onPressed: () => _updateScore(1, 1),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
// First Team
|
// Player 2 Score Controls
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Text(_players[0],
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
Row(
|
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.remove,
|
icon: Icon(Icons.remove),
|
||||||
color: Colors.white),
|
onPressed: () => _updateScore(2, -1),
|
||||||
onPressed: () => _updateScore(1, -1)),
|
|
||||||
Container(
|
|
||||||
width: 70,
|
|
||||||
height: 50,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.white,
|
|
||||||
width: 2),
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(8)),
|
|
||||||
child: Center(
|
|
||||||
child: Text('$_player1Score',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.bold,
|
|
||||||
fontSize: 24)))),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.add,
|
|
||||||
color: Colors.white),
|
|
||||||
onPressed: () => _updateScore(1, 1)),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
Text(
|
||||||
|
'Player 2 Score: $_player2Score',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
),
|
),
|
||||||
SizedBox(width: 20),
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Text(_players[1],
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.remove,
|
icon: Icon(Icons.add),
|
||||||
color: Colors.white),
|
onPressed: () => _updateScore(2, 1),
|
||||||
onPressed: () => _updateScore(2, -1)),
|
|
||||||
Container(
|
|
||||||
width: 70,
|
|
||||||
height: 50,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.white,
|
|
||||||
width: 2),
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(8)),
|
|
||||||
child: Center(
|
|
||||||
child: Text('$_player2Score',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.bold,
|
|
||||||
fontSize: 24)))),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.add,
|
|
||||||
color: Colors.white),
|
|
||||||
onPressed: () => _updateScore(2, 1)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 32),
|
SizedBox(height: 32),
|
||||||
// Second Team
|
// End Match Button
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Text(_players[2],
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.remove,
|
|
||||||
color: Colors.white),
|
|
||||||
onPressed: () => _updateScore(3, -1)),
|
|
||||||
Container(
|
|
||||||
width: 70,
|
|
||||||
height: 50,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.white,
|
|
||||||
width: 2),
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(8)),
|
|
||||||
child: Center(
|
|
||||||
child: Text('$_player3Score',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.bold,
|
|
||||||
fontSize: 24)))),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.add,
|
|
||||||
color: Colors.white),
|
|
||||||
onPressed: () => _updateScore(3, 1)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(width: 20),
|
|
||||||
Column(
|
|
||||||
children: [
|
|
||||||
Text(_players[3],
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.remove,
|
|
||||||
color: Colors.white),
|
|
||||||
onPressed: () => _updateScore(4, -1)),
|
|
||||||
Container(
|
|
||||||
width: 75,
|
|
||||||
height: 50,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(
|
|
||||||
color: Colors.white,
|
|
||||||
width: 2),
|
|
||||||
borderRadius:
|
|
||||||
BorderRadius.circular(8)),
|
|
||||||
child: Center(
|
|
||||||
child: Text('$_player4Score',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight:
|
|
||||||
FontWeight.bold,
|
|
||||||
fontSize: 24)))),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.add,
|
|
||||||
color: Colors.white),
|
|
||||||
onPressed: () => _updateScore(4, 1)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
// 1v1 Match UI
|
|
||||||
if (!_is2v2Mode) ...[
|
|
||||||
Text(_player1name ?? 'Player 1',
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
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(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 24)))),
|
|
||||||
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),
|
|
||||||
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(
|
|
||||||
color: Colors.white,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 24)))),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.add, color: Colors.white),
|
|
||||||
onPressed: () => _updateScore(2, 1)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
SizedBox(height: 8),
|
|
||||||
Text(_player2name ?? 'Player 2',
|
|
||||||
style: TextStyle(color: Colors.white)),
|
|
||||||
],
|
|
||||||
SizedBox(height: 32),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: _endMatch,
|
onPressed: _endMatch,
|
||||||
child: Text('End Match'),
|
child: Text('End Match'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
)
|
)
|
||||||
: Column(
|
: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
@ -436,34 +194,7 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 16),
|
SizedBox(height: 16),
|
||||||
// Toggle for 2v2 Mode
|
// Join Match Button
|
||||||
SwitchListTile(
|
|
||||||
title: Text('Enable 2v2 Mode'),
|
|
||||||
value: _is2v2Mode,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
_is2v2Mode = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
// If 2v2 is selected, display slot selection
|
|
||||||
if (_is2v2Mode) ...[
|
|
||||||
DropdownButton<int>(
|
|
||||||
value: _selectedSlot,
|
|
||||||
items: [2, 3, 4].map((int value) {
|
|
||||||
return DropdownMenuItem<int>(
|
|
||||||
value: value,
|
|
||||||
child: Text('Slot $value'),
|
|
||||||
);
|
|
||||||
}).toList(),
|
|
||||||
onChanged: (int? newValue) {
|
|
||||||
setState(() {
|
|
||||||
_selectedSlot = newValue!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
SizedBox(height: 16),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_matchIdController.text.isNotEmpty) {
|
if (_matchIdController.text.isNotEmpty) {
|
||||||
|
@ -479,18 +210,4 @@ class _JoinMatchPageState extends State<JoinMatchPage> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateScore(int playerIndex, int increment) {
|
|
||||||
setState(() {
|
|
||||||
if (playerIndex == 1) {
|
|
||||||
_player1Score += increment;
|
|
||||||
} else if (playerIndex == 2) {
|
|
||||||
_player2Score += increment;
|
|
||||||
} else if (playerIndex == 3) {
|
|
||||||
_player3Score += increment;
|
|
||||||
} else if (playerIndex == 4) {
|
|
||||||
_player4Score += increment;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ class LeaderboardPage extends StatefulWidget {
|
||||||
class _LeaderboardPageState extends State<LeaderboardPage> {
|
class _LeaderboardPageState extends State<LeaderboardPage> {
|
||||||
List<dynamic> _leaderboard = [];
|
List<dynamic> _leaderboard = [];
|
||||||
bool _isLoading = true;
|
bool _isLoading = true;
|
||||||
bool _sortByOskMu = false;
|
|
||||||
|
|
||||||
final String _leaderboardApi = '$apiurl/leaderboards';
|
final String _leaderboardApi = '$apiurl/leaderboards';
|
||||||
|
|
||||||
|
@ -27,7 +26,6 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
|
||||||
List<dynamic> data = json.decode(response.body);
|
List<dynamic> data = json.decode(response.body);
|
||||||
setState(() {
|
setState(() {
|
||||||
_leaderboard = data;
|
_leaderboard = data;
|
||||||
_sortLeaderboard();
|
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,23 +42,6 @@ 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) {
|
void _showError(String message) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -88,16 +69,6 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
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
|
body: _isLoading
|
||||||
? Center(child: CircularProgressIndicator())
|
? Center(child: CircularProgressIndicator())
|
||||||
: RefreshIndicator(
|
: RefreshIndicator(
|
||||||
|
@ -106,29 +77,16 @@ class _LeaderboardPageState extends State<LeaderboardPage> {
|
||||||
itemCount: _leaderboard.length,
|
itemCount: _leaderboard.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
var player = _leaderboard[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(
|
return Card(
|
||||||
margin: EdgeInsets.all(8),
|
margin: EdgeInsets.all(8),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
contentPadding: EdgeInsets.all(10),
|
contentPadding: EdgeInsets.all(10),
|
||||||
leading: CircleAvatar(
|
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),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
subtitle: Text(
|
title: Text(player['player_name']),
|
||||||
'Elo: ${player['elo_rating']} | TSC: $truncatedOskMu'),
|
subtitle: Text('Elo Rating: ${player['elo_rating']}'),
|
||||||
trailing: Text('UID: ${player['friend_code']}'),
|
trailing: Text('Friend Code: ${player['friend_code']}'),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,8 +15,6 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
String? _name;
|
String? _name;
|
||||||
int? _uid;
|
int? _uid;
|
||||||
int? _elo;
|
int? _elo;
|
||||||
double? _mu;
|
|
||||||
double? _unc;
|
|
||||||
List<dynamic> _matches = [];
|
List<dynamic> _matches = [];
|
||||||
|
|
||||||
final String _getProfileApiUrl = '$apiurl/getprofile';
|
final String _getProfileApiUrl = '$apiurl/getprofile';
|
||||||
|
@ -49,8 +47,6 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
_name = data['name'];
|
_name = data['name'];
|
||||||
_uid = data['uid'];
|
_uid = data['uid'];
|
||||||
_elo = data['elo'];
|
_elo = data['elo'];
|
||||||
_mu = data['osk_mu'];
|
|
||||||
_unc = data['osk_sig'];
|
|
||||||
_matches = data['matches'];
|
_matches = data['matches'];
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
});
|
});
|
||||||
|
@ -78,87 +74,6 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getRankImage(int? elo) {
|
|
||||||
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() {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text('ELO, OSK, and UNC Explanation'),
|
|
||||||
content: SingleChildScrollView(
|
|
||||||
child: ListBody(
|
|
||||||
children: <Widget>[
|
|
||||||
// ELO Section
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"ELO (Elo Rating):",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
SizedBox(height: 4.0),
|
|
||||||
Text(
|
|
||||||
"ELO is a widely-used rating system designed to measure the relative skill levels of players in two-player games. It was my initial pick for a testing environment since I only really thought about 1v1 matches, and because it had a readily available Python implementation. I'm lazy.",
|
|
||||||
),
|
|
||||||
SizedBox(height: 8.0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// OSK Section
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"OSK (OpenSkill Mu):",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
SizedBox(height: 4.0),
|
|
||||||
Text(
|
|
||||||
"OSKmu is a skill rating system based on the OpenSkill model, which is a probabilistic framework for estimating a player's skill. Unlike ELO, which is purely a point-based system, OpenSkill Mu takes into account not just the outcome of matches but also the degree of uncertainty in a player's skill estimation. Since I set up the system to have a 0-base-elo, I had to adapt the OpenSkill implementation to a standard 25 OSK and 8.33 uncertainty.",
|
|
||||||
),
|
|
||||||
SizedBox(height: 8.0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
// UNC Section
|
|
||||||
Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Uncertainty (UNC):",
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
SizedBox(height: 4.0),
|
|
||||||
Text(
|
|
||||||
"This is a measure of how confident the system is about a player's skill rating. A higher uncertainty value means the system is less confident about the accuracy of the player's skill estimation, while a lower uncertainty indicates more confidence in the player's rating.",
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
actions: <Widget>[
|
|
||||||
TextButton(
|
|
||||||
child: Text('Close'),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -173,6 +88,7 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
padding: EdgeInsets.all(16.0),
|
padding: EdgeInsets.all(16.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
// Profile Icon
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
backgroundColor: _generateRandomColor(),
|
backgroundColor: _generateRandomColor(),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -184,6 +100,7 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
radius: 40,
|
radius: 40,
|
||||||
),
|
),
|
||||||
SizedBox(width: 16),
|
SizedBox(width: 16),
|
||||||
|
// Profile Info
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
@ -194,36 +111,15 @@ class _ProfilePageState extends State<ProfilePage> {
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 6),
|
SizedBox(height: 8),
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text('UID: ${_uid ?? 'N/A'}'),
|
Text('UID: ${_uid ?? 'N/A'}'),
|
||||||
SizedBox(
|
Text('ELO: ${_elo ?? 'N/A'}'),
|
||||||
width: 30,
|
|
||||||
),
|
|
||||||
Image.asset(
|
|
||||||
getRankImage(_elo),
|
|
||||||
width: 100,
|
|
||||||
height: 30,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Row(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
'ELO: ${_elo ?? 'N/A'} | OSK: ${_mu != null ? _mu?.toStringAsFixed(3) : 'N/A'} | UNC: ${_unc != null ? _unc?.toStringAsFixed(3) : 'N/A'}'),
|
|
||||||
IconButton(
|
|
||||||
icon: Icon(Icons.help_outline),
|
|
||||||
onPressed: _showExplanationDialog,
|
|
||||||
tooltip: 'What are ELO, OSK, and UNC?',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
SizedBox(height: 16),
|
||||||
// Recent Matches
|
// Recent Matches
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _matches.isEmpty
|
child: _matches.isEmpty
|
||||||
|
|
10
pubspec.yaml
|
@ -2,7 +2,7 @@ name: pingpongapp
|
||||||
description: "DTH Ping Pong Score tracking app"
|
description: "DTH Ping Pong Score tracking app"
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.0.57+1
|
version: 0.0.34+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.4.3 <4.0.0'
|
sdk: '>=3.4.3 <4.0.0'
|
||||||
|
@ -15,9 +15,6 @@ dependencies:
|
||||||
http: ^1.2.2
|
http: ^1.2.2
|
||||||
logger: ^2.5.0
|
logger: ^2.5.0
|
||||||
package_info: ^2.0.2
|
package_info: ^2.0.2
|
||||||
font_awesome_flutter: ^10.8.0
|
|
||||||
url_launcher: ^6.3.1
|
|
||||||
fl_chart: ^0.70.2
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
@ -27,8 +24,9 @@ flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|
||||||
# To add assets to your application, add an assets section, like this:
|
# To add assets to your application, add an assets section, like this:
|
||||||
assets:
|
# assets:
|
||||||
- assets/
|
# - images/a_dot_burr.jpeg
|
||||||
|
# - images/a_dot_ham.jpeg
|
||||||
|
|
||||||
# An image asset can refer to one or more resolution-specific "variants", see
|
# An image asset can refer to one or more resolution-specific "variants", see
|
||||||
# https://flutter.dev/assets-and-images/#resolution-aware
|
# https://flutter.dev/assets-and-images/#resolution-aware
|
||||||
|
|