Minor changes on match creation page, added version retrieval from api
This commit is contained in:
parent
c872e40861
commit
4d27d3be11
|
@ -7,6 +7,9 @@ import 'views/joinmatch.dart';
|
|||
import 'views/creatematch.dart';
|
||||
import 'views/friendlist.dart';
|
||||
import 'views/myprofile.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
import '../globals.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
@override
|
||||
|
@ -16,7 +19,6 @@ class HomePage extends StatefulWidget {
|
|||
class _HomePageState extends State<HomePage> {
|
||||
int _selectedIndex = 0;
|
||||
|
||||
// Define the pages for each section
|
||||
final List<Widget> _pages = [
|
||||
LeaderboardPage(),
|
||||
JoinMatchPage(),
|
||||
|
@ -40,14 +42,46 @@ class _HomePageState extends State<HomePage> {
|
|||
);
|
||||
}
|
||||
|
||||
Future<Map<String, String>> fetchCommitHashes() async {
|
||||
const apiUrl = '$apiurl/latest-commit-hashes';
|
||||
|
||||
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 {
|
||||
final commitHashes = await fetchCommitHashes();
|
||||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => AboutDialog(
|
||||
applicationIcon: const Icon(Icons.code),
|
||||
applicationLegalese: '© 2024 Thomas Bassi @ Defence Tech.',
|
||||
applicationName: 'DTHPP',
|
||||
applicationVersion: '#B22AF349A1',
|
||||
applicationVersion:
|
||||
'API: ${commitHashes['backend']} - UI: ${commitHashes['frontend']}',
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16.0),
|
||||
|
|
|
@ -90,6 +90,12 @@ class _CreateMatchPageState extends State<CreateMatchPage> {
|
|||
textAlign: TextAlign.center,
|
||||
),
|
||||
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
|
||||
? CircularProgressIndicator() // Show loading spinner
|
||||
: ElevatedButton(
|
||||
|
|
Loading…
Reference in a new issue