diff --git a/lib/pages/home.dart b/lib/pages/home.dart index ff20d5a..a91e98b 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -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 { int _selectedIndex = 0; - // Define the pages for each section final List _pages = [ LeaderboardPage(), JoinMatchPage(), @@ -40,14 +42,46 @@ class _HomePageState extends State { ); } + Future> 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 _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), diff --git a/lib/pages/views/creatematch.dart b/lib/pages/views/creatematch.dart index 0ec1afb..a68a789 100644 --- a/lib/pages/views/creatematch.dart +++ b/lib/pages/views/creatematch.dart @@ -90,6 +90,12 @@ class _CreateMatchPageState extends State { 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(