import 'package:flutter/material.dart'; import 'package:space_traders/models/ship_model.dart'; class ShipPage extends StatelessWidget { final ShipModel ship; ShipPage({required this.ship}); ElevatedButton buildActionButton(String status) { String buttonText = ''; VoidCallback? buttonAction; if (status == 'IN_ORBIT') { buttonText = 'Dock'; buttonAction = () { // Action 1 print('Action 1'); }; } else if (status == 'Status2') { buttonText = 'Action 2'; buttonAction = () { // Action 2 print('Action 2'); }; } else { buttonText = 'Default Action'; buttonAction = () { // Default Action print('Default Action'); }; } return ElevatedButton( onPressed: buttonAction, child: Text(buttonText), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Ship Details'), ), body: Container( decoration: BoxDecoration( color: Colors.grey[300], ), child: Padding( padding: const EdgeInsets.all(16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Card( color: Colors.white, child: Align( alignment: Alignment.topLeft, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Name: ${ship.symbol}', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), Row( children: [ Text('${ship.nav?.status ?? 'N/A'}'), SizedBox(height: 32), SizedBox(width: 32), buildActionButton(ship.nav?.status ?? ''), ], ), Row( children: [ Text('Fuel: ${ship.fuel?.current ?? 'N/A'} / ${ship.fuel?.capacity ?? 'N/A'}'), SizedBox(height: 32), SizedBox(width: 32), ElevatedButton( onPressed: () { }, child: Text('Refuel'), ), ], ), Row( children: [ Column( children:[ Text('${ship.nav?.waypointSymbol ?? 'N/A'}'), Text('Asteroid Field'), ], ), SizedBox(height: 32), SizedBox(width: 32), ElevatedButton( onPressed: () { }, child: Text('Select Destination'), ), SizedBox(width: 32), ElevatedButton( onPressed: () { }, child: Text('View System'), ), ], ), ], ), ), ), Card( color: Colors.white, child: Align( alignment: Alignment.topLeft, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'Cargo: ${ship.cargo?.units ?? 'N/A'} / ${ship.cargo?.capacity ?? 'N/A'}', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), ], ), ), ), ], ), ), ), ); } }