UI resposiveness fix on mobile
This commit is contained in:
@@ -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> {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user