Compare commits
3 Commits
c7233daec7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 412556b3f3 | |||
| b58571e52b | |||
| a857648c48 |
@@ -44,7 +44,6 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
final FocusNode _frequencyFocusNode = FocusNode();
|
||||
final FocusNode _squawkFocusNode = FocusNode();
|
||||
|
||||
// Neue Variablen
|
||||
bool _saveSimbriefId = false;
|
||||
static const String _simbriefIdKey = 'simbrief_id';
|
||||
|
||||
@@ -54,7 +53,6 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
_loadSavedSimbriefId();
|
||||
}
|
||||
|
||||
// Methode zum Laden der gespeicherten ID
|
||||
Future<void> _loadSavedSimbriefId() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final savedId = prefs.getString(_simbriefIdKey);
|
||||
@@ -66,7 +64,6 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
}
|
||||
}
|
||||
|
||||
// Methode zum Speichern der ID
|
||||
Future<void> _saveSimbriefIdToPrefs() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
if (_saveSimbriefId) {
|
||||
@@ -100,7 +97,6 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
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) {
|
||||
@@ -116,15 +112,15 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
_expectedFrequencyController.text = '';
|
||||
});
|
||||
|
||||
if (!mounted) return; // Zweiter Check vor ScaffoldMessenger
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('SimBrief Daten erfolgreich geladen')),
|
||||
const SnackBar(content: Text('SimBrief data successfully loaded')),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (!mounted) return; // Check vor Error-SnackBar
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Fehler beim Laden der SimBrief Daten: $e')),
|
||||
SnackBar(content: Text('Error loading SimBrief data: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -250,22 +246,60 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: GestureDetector(
|
||||
// Dismiss the keyboard when tapping outside
|
||||
body: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
// ConstrainedBox hinzufügen
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: constraints.maxHeight - 100, // AppBar-Höhe abziehen
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// IntrinsicHeight Widget hinzufügen
|
||||
if (constraints.maxWidth > 600)
|
||||
// Desktop Layout
|
||||
IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch, // Stretch hinzufügen
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Welcome Card - nimmt 60% der Breite
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Card(
|
||||
child: _buildWelcomeCard(),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: _buildSimbriefCard(),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
// Mobile Layout
|
||||
Column(
|
||||
children: [
|
||||
_buildWelcomeCard(),
|
||||
const SizedBox(height: 16),
|
||||
_buildSimbriefCard(),
|
||||
],
|
||||
),
|
||||
_buildMainContent(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
// Hilfsmethoden zum Erstellen der Cards
|
||||
Widget _buildWelcomeCard() {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -284,13 +318,11 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16), // Abstand zwischen den Cards
|
||||
// SimBrief Card - nimmt 40% der Breite
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Card(
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSimbriefCard() {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -334,13 +366,11 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMainContent() {
|
||||
return Card(
|
||||
elevation: 2,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
@@ -458,11 +488,6 @@ class ExpectationInputPageState extends State<ExpectationInputPage> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pocketbase/pocketbase.dart'; // Import the PocketBase package
|
||||
import 'expectation_input_page.dart';
|
||||
import '../widgets/clearance_field.dart';
|
||||
|
||||
@@ -33,7 +32,6 @@ class FinalClearanceDisplayState extends State<FinalClearanceDisplay> {
|
||||
late String altitude;
|
||||
late String squawk;
|
||||
late String frequency;
|
||||
final PocketBase pb = PocketBase('https://backend.degnedict.de'); // Initialize PocketBase
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -43,22 +41,6 @@ class FinalClearanceDisplayState extends State<FinalClearanceDisplay> {
|
||||
altitude = widget.altitude;
|
||||
squawk = widget.squawk;
|
||||
frequency = widget.frequency;
|
||||
|
||||
_createPageViewRecord(); // Create a record with the current timestamp
|
||||
}
|
||||
|
||||
// Function to create a new record with a timestamp in epoch milliseconds in your PocketBase collection
|
||||
Future<void> _createPageViewRecord() async {
|
||||
try {
|
||||
// Get the current time in epoch milliseconds
|
||||
int currentTimeInMillis = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
// Create a new record in the collection with the current epoch time
|
||||
await pb.collection('IFRbuddyUsage').create(body: {
|
||||
'timestamp': currentTimeInMillis, // Save current timestamp as epoch time (milliseconds)
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Navigate back to the first page (ExpectationInputPage)
|
||||
|
||||
@@ -1,29 +1,55 @@
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class FrequencyInputFormatter extends TextInputFormatter {
|
||||
static const int maxDigits = 5;
|
||||
|
||||
@override
|
||||
TextEditingValue formatEditUpdate(
|
||||
TextEditingValue oldValue, TextEditingValue newValue) {
|
||||
String digitsOnly = newValue.text.replaceAll(RegExp(r'[^0-9]'), '');
|
||||
TextEditingValue oldValue,
|
||||
TextEditingValue newValue,
|
||||
) {
|
||||
// Skip formatting if deleting
|
||||
if (oldValue.text.length > newValue.text.length) {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
if (digitsOnly.length > maxDigits) {
|
||||
// Allow only numbers and decimal point
|
||||
String filteredText = newValue.text.replaceAll(RegExp(r'[^\d.]'), '');
|
||||
|
||||
// Only allow one decimal point
|
||||
if (filteredText.split('.').length > 2) {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
String formatted = digitsOnly;
|
||||
if (digitsOnly.length > 3) {
|
||||
formatted = '${digitsOnly.substring(0, 3)}.${digitsOnly.substring(3)}';
|
||||
// Format for three decimal places and auto-insert decimal point
|
||||
if (filteredText.contains('.')) {
|
||||
List<String> parts = filteredText.split('.');
|
||||
String whole = parts[0];
|
||||
String fraction = parts[1];
|
||||
|
||||
// Limit to three decimal places
|
||||
if (fraction.length > 3) {
|
||||
fraction = fraction.substring(0, 3);
|
||||
}
|
||||
|
||||
if (formatted.endsWith('.') && digitsOnly.length <= 3) {
|
||||
formatted = formatted.substring(0, formatted.length - 1);
|
||||
// Reconstruct the text
|
||||
filteredText = "$whole.$fraction";
|
||||
} else {
|
||||
// Auto-insert decimal point after the third digit
|
||||
if (filteredText.length > 3) {
|
||||
String whole = filteredText.substring(0, 3);
|
||||
String fraction = filteredText.substring(3);
|
||||
|
||||
// Limit fraction to three digits
|
||||
if (fraction.length > 3) {
|
||||
fraction = fraction.substring(0, 3);
|
||||
}
|
||||
|
||||
filteredText = "$whole.$fraction";
|
||||
}
|
||||
}
|
||||
|
||||
return TextEditingValue(
|
||||
text: formatted,
|
||||
selection: TextSelection.collapsed(offset: formatted.length),
|
||||
text: filteredText,
|
||||
selection: TextSelection.collapsed(offset: filteredText.length),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,14 +288,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
pocketbase:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: pocketbase
|
||||
sha256: "1d2958a3a7cb1e0050f425f179bd6557441fafcf740a79d5b8b80d6954149790"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.18.1"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
@@ -37,7 +37,6 @@ dependencies:
|
||||
http: ^1.2.2
|
||||
shared_preferences: ^2.3.2
|
||||
flutter_launcher_icons: ^0.14.1
|
||||
pocketbase: ^0.18.1
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
|
||||
<title>ifrbuddy</title>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
|
||||
<!-- Umami Analytics -->
|
||||
<script defer src="https://umami.degnedict.de/script.js" data-website-id="82ee3dc6-dc80-42d3-8583-d6824aebfed5"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script src="flutter_bootstrap.js" async></script>
|
||||
|
||||
Reference in New Issue
Block a user