mac OS compatibility

This commit is contained in:
2024-11-08 23:20:09 +01:00
parent c03e9556b7
commit c7233daec7
4 changed files with 64 additions and 7 deletions

1
buildandpush.sh Normal file
View File

@@ -0,0 +1 @@
flutter build web --release && docker buildx build --platform linux/amd64 -t git.degnedict.de/bene/ifrbuddy --push .

View File

@@ -1,3 +1,5 @@
// ignore_for_file: prefer_const_constructors
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'comparison_page.dart'; import 'comparison_page.dart';
@@ -5,6 +7,7 @@ import 'final_clearance_page.dart'; // Import final clearance page
import '../utils/frequency_input_formatter.dart'; // Ensure this path is correct import '../utils/frequency_input_formatter.dart'; // Ensure this path is correct
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'dart:convert'; import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
class ExpectationInputPage extends StatefulWidget { class ExpectationInputPage extends StatefulWidget {
final bool isDarkMode; final bool isDarkMode;
@@ -41,6 +44,38 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
final FocusNode _frequencyFocusNode = FocusNode(); final FocusNode _frequencyFocusNode = FocusNode();
final FocusNode _squawkFocusNode = FocusNode(); final FocusNode _squawkFocusNode = FocusNode();
// Neue Variablen
bool _saveSimbriefId = false;
static const String _simbriefIdKey = 'simbrief_id';
@override
void initState() {
super.initState();
_loadSavedSimbriefId();
}
// Methode zum Laden der gespeicherten ID
Future<void> _loadSavedSimbriefId() async {
final prefs = await SharedPreferences.getInstance();
final savedId = prefs.getString(_simbriefIdKey);
if (savedId != null) {
setState(() {
_simbriefIdController.text = savedId;
_saveSimbriefId = true;
});
}
}
// Methode zum Speichern der ID
Future<void> _saveSimbriefIdToPrefs() async {
final prefs = await SharedPreferences.getInstance();
if (_saveSimbriefId) {
await prefs.setString(_simbriefIdKey, _simbriefIdController.text);
} else {
await prefs.remove(_simbriefIdKey);
}
}
@override @override
void dispose() { void dispose() {
_expectedClearanceLimitController.dispose(); _expectedClearanceLimitController.dispose();
@@ -58,34 +93,36 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
Future<void> _fetchSimbriefData() async { Future<void> _fetchSimbriefData() async {
try { try {
if (_saveSimbriefId) {
await _saveSimbriefIdToPrefs();
}
final response = await http.get( final response = await http.get(
Uri.parse('https://www.simbrief.com/api/xml.fetcher.php?userid=${_simbriefIdController.text}&json=1'), Uri.parse('https://www.simbrief.com/api/xml.fetcher.php?userid=${_simbriefIdController.text}&json=1'),
); );
// Prüfe ob Widget noch mounted ist
if (!mounted) return;
if (response.statusCode == 200) { if (response.statusCode == 200) {
final data = json.decode(response.body); final data = json.decode(response.body);
// Debug-Ausgabe
print('SimBrief API Response: ${response.body}');
// Extrahiere die komplette Route
String fullRoute = data['general']['route'] ?? ''; String fullRoute = data['general']['route'] ?? '';
// Hole nur den ersten Teil der Route (SID)
String sid = fullRoute.split(' ').first; String sid = fullRoute.split(' ').first;
setState(() { setState(() {
_expectedClearanceLimitController.text = data['destination']['icao_code'] ?? ''; _expectedClearanceLimitController.text = data['destination']['icao_code'] ?? '';
_expectedRouteController.text = sid; _expectedRouteController.text = sid;
// Altitude und Frequency bleiben leer
_expectedAltitudeController.text = ''; _expectedAltitudeController.text = '';
_expectedFrequencyController.text = ''; _expectedFrequencyController.text = '';
}); });
if (!mounted) return; // Zweiter Check vor ScaffoldMessenger
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('SimBrief Daten erfolgreich geladen')), const SnackBar(content: Text('SimBrief Daten erfolgreich geladen')),
); );
} }
} catch (e) { } catch (e) {
if (!mounted) return; // Check vor Error-SnackBar
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Fehler beim Laden der SimBrief Daten: $e')), SnackBar(content: Text('Fehler beim Laden der SimBrief Daten: $e')),
); );
@@ -273,6 +310,20 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
), ),
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
Row(
children: [
Checkbox(
value: _saveSimbriefId,
onChanged: (bool? value) {
setState(() {
_saveSimbriefId = value ?? false;
});
_saveSimbriefIdToPrefs();
},
),
const Text('Save SimBrief ID'),
],
),
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: ElevatedButton( child: ElevatedButton(
@@ -303,7 +354,7 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
), ),
const SizedBox(height: 10), const SizedBox(height: 10),
const Text( const Text(
'Enter your expected clearance information below. ' 'Enter your expected clearance information below (Or use the SimBrief import). '
'Use the listening page or skip to the readback page.', 'Use the listening page or skip to the readback page.',
style: TextStyle(fontSize: 16), style: TextStyle(fontSize: 16),
textAlign: TextAlign.left, textAlign: TextAlign.left,

View File

@@ -8,5 +8,7 @@
<true/> <true/>
<key>com.apple.security.network.server</key> <key>com.apple.security.network.server</key>
<true/> <true/>
<key>com.apple.security.network.client</key>
<true/>
</dict> </dict>
</plist> </plist>

View File

@@ -4,5 +4,8 @@
<dict> <dict>
<key>com.apple.security.app-sandbox</key> <key>com.apple.security.app-sandbox</key>
<true/> <true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>w
</dict> </dict>
</plist> </plist>