Initial
This commit is contained in:
142
lib/screens/final_clearance_page.dart
Normal file
142
lib/screens/final_clearance_page.dart
Normal file
@@ -0,0 +1,142 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'expectation_input_page.dart';
|
||||
import 'edit_clearance_page.dart'; // Import the edit clearance page
|
||||
import '../widgets/clearance_field.dart';
|
||||
|
||||
class FinalClearanceDisplay extends StatefulWidget {
|
||||
final String clearanceLimit;
|
||||
final String route;
|
||||
final String altitude;
|
||||
final String squawk;
|
||||
final String frequency;
|
||||
final bool isDarkMode;
|
||||
final Function toggleDarkMode;
|
||||
|
||||
const FinalClearanceDisplay({super.key,
|
||||
required this.clearanceLimit,
|
||||
required this.route,
|
||||
required this.altitude,
|
||||
required this.squawk,
|
||||
required this.frequency,
|
||||
required this.isDarkMode,
|
||||
required this.toggleDarkMode,
|
||||
});
|
||||
|
||||
@override
|
||||
FinalClearanceDisplayState createState() => FinalClearanceDisplayState();
|
||||
}
|
||||
|
||||
class FinalClearanceDisplayState extends State<FinalClearanceDisplay> {
|
||||
late String clearanceLimit;
|
||||
late String route;
|
||||
late String altitude;
|
||||
late String squawk;
|
||||
late String frequency;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
clearanceLimit = widget.clearanceLimit;
|
||||
route = widget.route;
|
||||
altitude = widget.altitude;
|
||||
squawk = widget.squawk;
|
||||
frequency = widget.frequency;
|
||||
}
|
||||
|
||||
// Navigate to Edit Clearance Page and handle returned data
|
||||
Future<void> _navigateToEditClearance() async {
|
||||
final result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => EditClearancePage(
|
||||
clearanceLimit: clearanceLimit,
|
||||
route: route,
|
||||
altitude: altitude,
|
||||
squawk: squawk,
|
||||
frequency: frequency,
|
||||
isDarkMode: widget.isDarkMode,
|
||||
toggleDarkMode: widget.toggleDarkMode,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// If the result contains updated data, update the state with the new values
|
||||
if (result != null && mounted) {
|
||||
setState(() {
|
||||
clearanceLimit = result['clearanceLimit'];
|
||||
route = result['route'];
|
||||
altitude = result['altitude'];
|
||||
squawk = result['squawk'];
|
||||
frequency = result['frequency'];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Navigate back to the first page (ExpectationInputPage)
|
||||
void _navigateHome(BuildContext context) {
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => ExpectationInputPage(
|
||||
isDarkMode: widget.isDarkMode,
|
||||
toggleDarkMode: widget.toggleDarkMode,
|
||||
),
|
||||
),
|
||||
(Route<dynamic> route) => false,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('IFR Buddy'),
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.home), // Home button
|
||||
onPressed: () {
|
||||
_navigateHome(context);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit), // Edit button
|
||||
onPressed: _navigateToEditClearance,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(widget.isDarkMode ? Icons.dark_mode : Icons.light_mode),
|
||||
onPressed: () {
|
||||
widget.toggleDarkMode();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Center(
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Card(
|
||||
elevation: 4,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Clearance Summary',
|
||||
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
buildClearanceField('Clearance Limit', clearanceLimit),
|
||||
buildClearanceField('Route', route),
|
||||
buildClearanceField('Altitude', altitude),
|
||||
buildClearanceField('Transponder (Squawk)', squawk),
|
||||
buildClearanceField('Frequency', frequency),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user