Compare commits

..

5 Commits

Author SHA1 Message Date
c7233daec7 mac OS compatibility 2024-11-08 23:20:09 +01:00
c03e9556b7 UI cleanup 2024-11-08 23:05:01 +01:00
bcd10ed512 simbrief own card in ui 2024-11-08 23:02:28 +01:00
4ab8b70524 simrbrief integration 2024-11-08 22:59:47 +01:00
10377a2a0a removed squawk from expected clearance page 2024-11-08 22:38:29 +01:00
5 changed files with 183 additions and 39 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

@@ -184,7 +184,7 @@ class ComparisonPageState extends State<ComparisonPage> {
child: Padding(
padding: EdgeInsets.all(16.0),
child: Text(
'Use this Page while receiving your clearance. The arrow button copies the expected value. Same if left empty.',
'Use this Page while receiving your clearance.\nThe arrow button copies the expected value. If left empty, expected values are still copied. the arrow buttons are a help for the Brain :)',
style: TextStyle(fontSize: 16),
textAlign: TextAlign.center,
),
@@ -214,7 +214,7 @@ class ComparisonPageState extends State<ComparisonPage> {
buildExpectedClearanceField('Route', widget.expectedRoute),
buildExpectedClearanceField('Altitude', widget.expectedAltitude),
buildExpectedClearanceField('Frequency', widget.expectedFrequency),
buildExpectedClearanceField('Transponder (Squawk)', widget.expectedSquawk),
// buildExpectedClearanceField('Transponder (Squawk)', widget.expectedSquawk),
],
),
),

View File

@@ -1,8 +1,13 @@
// ignore_for_file: prefer_const_constructors
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'comparison_page.dart';
import 'final_clearance_page.dart'; // Import final clearance page
import '../utils/frequency_input_formatter.dart'; // Ensure this path is correct
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'package:shared_preferences/shared_preferences.dart';
class ExpectationInputPage extends StatefulWidget {
final bool isDarkMode;
@@ -30,6 +35,7 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
TextEditingController();
final TextEditingController _expectedFrequencyController =
TextEditingController();
final TextEditingController _simbriefIdController = TextEditingController();
// FocusNodes for each field
final FocusNode _clearanceLimitFocusNode = FocusNode();
@@ -38,6 +44,38 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
final FocusNode _frequencyFocusNode = 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
void dispose() {
_expectedClearanceLimitController.dispose();
@@ -53,6 +91,44 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
super.dispose();
}
Future<void> _fetchSimbriefData() async {
try {
if (_saveSimbriefId) {
await _saveSimbriefIdToPrefs();
}
final response = await http.get(
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) {
final data = json.decode(response.body);
String fullRoute = data['general']['route'] ?? '';
String sid = fullRoute.split(' ').first;
setState(() {
_expectedClearanceLimitController.text = data['destination']['icao_code'] ?? '';
_expectedRouteController.text = sid;
_expectedAltitudeController.text = '';
_expectedFrequencyController.text = '';
});
if (!mounted) return; // Zweiter Check vor ScaffoldMessenger
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('SimBrief Daten erfolgreich geladen')),
);
}
} catch (e) {
if (!mounted) return; // Check vor Error-SnackBar
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text('Fehler beim Laden der SimBrief Daten: $e')),
);
}
}
void _navigateToComparisonPage() {
if (_formKey.currentState?.validate() ?? false) {
Navigator.push(
@@ -181,27 +257,86 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
const Card(
elevation: 2,
child: Padding(
padding: EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Welcome to IFR Buddy!',
style: TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
textAlign: TextAlign.left,
// IntrinsicHeight Widget hinzufügen
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch, // Stretch hinzufügen
children: [
// Welcome Card - nimmt 60% der Breite
Expanded(
flex: 3,
child: Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
Text(
'Welcome to IFR Buddy!',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 10),
Text(
'Just an easy tool for writing down IFR clearances without a pen.',
style: TextStyle(fontSize: 16),
),
],
),
),
),
SizedBox(height: 10),
Text(
'Just an easy tool for writing down IFR clearances without a pen.',
style: TextStyle(fontSize: 16),
textAlign: TextAlign.left,
),
const SizedBox(width: 16), // Abstand zwischen den Cards
// SimBrief Card - nimmt 40% der Breite
Expanded(
flex: 2,
child: Card(
elevation: 2,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'SimBrief Import',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(height: 10),
TextFormField(
controller: _simbriefIdController,
decoration: const InputDecoration(
labelText: 'SimBrief Pilot ID',
border: OutlineInputBorder(),
),
),
const SizedBox(height: 10),
Row(
children: [
Checkbox(
value: _saveSimbriefId,
onChanged: (bool? value) {
setState(() {
_saveSimbriefId = value ?? false;
});
_saveSimbriefIdToPrefs();
},
),
const Text('Save SimBrief ID'),
],
),
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: _fetchSimbriefData,
child: const Text('Load SimBrief Data'),
),
),
],
),
),
),
],
),
),
],
),
),
const SizedBox(height: 16),
@@ -219,12 +354,15 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
),
const SizedBox(height: 10),
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.',
style: TextStyle(fontSize: 16),
textAlign: TextAlign.left,
),
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.all(8.0),
),
Form(
key: _formKey,
child: Column(
@@ -287,23 +425,23 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
enableIMEPersonalizedLearning:
false, // iOS-specific
),
buildTextField(
label: 'Transponder (Squawk)', // Now last field
controller: _expectedSquawkController,
currentFocus: _squawkFocusNode,
isLastField: true, // Mark as last field
keyboardType: TextInputType.text, // Standard keyboard
inputFormatters: [
// Allow only digits 0-7 and limit to 4 characters
FilteringTextInputFormatter.allow(
RegExp(r'[0-7]')),
LengthLimitingTextInputFormatter(4),
],
enableAutocorrect: false, // Disable autocorrect
enableSuggestions: false, // Disable suggestions
enableIMEPersonalizedLearning:
false, // iOS-specific
),
// buildTextField(
// label: 'Transponder (Squawk)', // Now last field
// controller: _expectedSquawkController,
// currentFocus: _squawkFocusNode,
// isLastField: true, // Mark as last field
// keyboardType: TextInputType.text, // Standard keyboard
// inputFormatters: [
// // Allow only digits 0-7 and limit to 4 characters
// FilteringTextInputFormatter.allow(
// RegExp(r'[0-7]')),
// LengthLimitingTextInputFormatter(4),
// ],
// enableAutocorrect: false, // Disable autocorrect
// enableSuggestions: false, // Disable suggestions
// enableIMEPersonalizedLearning:
// false, // iOS-specific
// ),
const SizedBox(height: 20),
ElevatedButton(
onPressed: _navigateToComparisonPage,

View File

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

View File

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