| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- import 'package:flutter/material.dart';
- import 'package:gap/gap.dart';
- import 'package:jiffy/jiffy.dart';
- import 'package:tp5/core/utils.dart';
- import 'package:tp5/lido/model/Lidoapi_list.dart';
- import 'package:tp5/roster/widgets/w_citypair.dart';
- import 'package:tp5/roster/widgets/w_fnum.dart';
- import 'package:tp5/roster/widgets/w_hour.dart';
- import 'package:tp5/widgets/my_row.dart';
- class WLidoflt extends StatelessWidget {
- const WLidoflt(
- {super.key, required this.lidoapilist, this.onTap, this.iata = true});
- final LidoapiList lidoapilist;
- final bool iata;
- final dynamic onTap;
- _estDepTime() => Column(
- children: [
- Text(
- Jiffy.parseFromMillisecondsSinceEpoch(
- lidoapilist.leg?.estimatedDepartureTime ?? 0,
- isUtc: true)
- .format(pattern: "ddMMMyy"),
- style: const TextStyle(fontSize: 12, color: Colors.grey),
- ),
- WHour(
- jiffy: Jiffy.parseFromMillisecondsSinceEpoch(
- lidoapilist.leg?.estimatedDepartureTime ?? 0,
- isUtc: true)),
- ],
- );
- _fnumCitypair() => Row(
- children: [
- WFnum(
- al: iata
- ? (lidoapilist.leg?.commercialAirlineIata ?? "++")
- : (lidoapilist.leg?.commercialAirlineIcao ?? "+++"),
- fnum: lidoapilist.leg?.flightNumber ?? "---"),
- const Gap(10),
- WCitypair(
- iata1: iata
- ? (lidoapilist.leg?.departureAirport ?? "---")
- : (lidoapilist.leg?.departureAirportIcao ?? "----"),
- iata2: iata
- ? (lidoapilist.leg?.destinationAirport ?? "---")
- : (lidoapilist.leg?.destinationAirportIcao ?? "----"),
- size: 14,
- )
- ],
- );
- _aircraft() => Row(children: [
- Text(lidoapilist.leg?.aircraftDetails?.aircraftIcaoType ?? "---",
- style: const TextStyle(
- color: Colors.grey, fontWeight: FontWeight.w600)),
- const Gap(10),
- Text(
- lidoapilist.leg?.aircraftDetails?.aircraftRegistration ?? "---",
- style: const TextStyle(fontSize: 14, color: Colors.yellow),
- ),
- ]);
- _schedCtot() => Row(
- children: [
- if (lidoapilist.leg?.estimatedDepartureTime !=
- lidoapilist.leg?.scheduledDepartureTime) ...[
- const Text(
- "Sched",
- style: TextStyle(color: Colors.white38, fontSize: 10),
- ),
- const Gap(5),
- WHour(
- jiffy: Jiffy.parseFromMillisecondsSinceEpoch(
- lidoapilist.leg?.scheduledDepartureTime ?? 0,
- isUtc: true),
- size: 12,
- color: Colors.grey[500],
- ),
- const Gap(10)
- ],
- if (lidoapilist.leg?.ctot != null) ...[
- const Text(
- "CTOT ",
- style: TextStyle(color: Colors.white24, fontSize: 10),
- ),
- WHour(
- jiffy: Jiffy.parseFromMillisecondsSinceEpoch(
- lidoapilist.leg?.ctot ?? 0,
- isUtc: true),
- size: 12,
- color: Colors.orange,
- )
- ]
- ],
- );
- _fuel() => Column(crossAxisAlignment: CrossAxisAlignment.end, children: [
- Text(
- "ZFW ${kilo2ton(lidoapilist.leg?.weight?.plannedZfw)}",
- style: const TextStyle(color: Colors.grey),
- ),
- Column(
- children: [
- Text(
- "Fuel ${kilo2ton(lidoapilist.leg?.fuel?.blockFuel)}",
- style: const TextStyle(
- color: Colors.cyan, fontWeight: FontWeight.w700),
- ),
- Text(
- "Max xtra +${kilo2ton(lidoapilist.leg?.fuel?.possibleExtra, ceil: true)}",
- style: const TextStyle(color: Colors.amber, fontSize: 10),
- ),
- ],
- ),
- Text(
- "Trip ${kilo2ton(lidoapilist.leg?.fuel?.tripFuel)} / ${Duration(minutes: lidoapilist.leg?.fuel?.totalTripTimeMinutes ?? 0).tohhmm}",
- style: const TextStyle(
- color: Colors.green, fontWeight: FontWeight.w600, fontSize: 10),
- ),
- // Text("Trip ${kilo2ton(lidoapilist.leg?.fuel?.tripFuel)}"),
- ]);
- _ofpVer() => Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
- Text(
- "OFP ${lidoapilist.leg?.ofpNumber}",
- style: const TextStyle(
- color: Colors.white54, fontWeight: FontWeight.w600),
- ),
- Text(
- // ignore: unnecessary_string_interpolations
- "${Jiffy.parseFromMillisecondsSinceEpoch(lidoapilist.lastGenerated ?? 0, isUtc: true).format(pattern: "ddMMMyy")}",
- style: const TextStyle(color: Colors.white, fontSize: 12),
- ),
- Text(
- // ignore: unnecessary_string_interpolations
- "${Jiffy.parseFromMillisecondsSinceEpoch(lidoapilist.lastGenerated ?? 0, isUtc: true).format(pattern: "HH:mm")}",
- style: const TextStyle(color: Colors.white70, fontSize: 14),
- ),
- ]);
- _crew() => Row(children: [
- const Text("Crew: ",
- style: TextStyle(fontSize: 10, color: Colors.white30)),
- if (lidoapilist.leg?.crewMembers.isNotEmpty ?? false)
- Text(
- "${lidoapilist.leg?.crewMembers.map((e) => e.name?.capitalize())}",
- style: const TextStyle(
- color: Colors.white60,
- fontWeight: FontWeight.w400,
- fontSize: 12),
- )
- else
- const Text("-----"),
- ]);
- _fuelOrder() => Row(
- children: [
- const Text("Fuel order: ",
- style: TextStyle(fontSize: 10, color: Colors.white30)),
- Text(
- "${lidoapilist.latestFuelOrder["fuelOrder"]}",
- style: const TextStyle(
- color: Colors.white60,
- fontWeight: FontWeight.w400,
- fontSize: 12),
- ),
- Text(
- " by ${lidoapilist.latestFuelOrder["source"]}",
- style: const TextStyle(
- color: Colors.white54,
- fontWeight: FontWeight.w300,
- fontSize: 12),
- ),
- ],
- );
- @override
- Widget build(BuildContext context) {
- return InkWell(
- onTap: onTap,
- child: Card(
- color: Colors.grey[900],
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(6.0),
- ),
- elevation: 8.0,
- margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),
- child: Padding(
- padding: const EdgeInsets.all(8.0),
- child: MyRow(crossAxisAlignment: CrossAxisAlignment.start, children: [
- _estDepTime(),
- const Gap(20),
- Column(
- children: [
- Row(children: [
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _fnumCitypair(),
- _aircraft(),
- _schedCtot(),
- ],
- ),
- const Gap(20),
- _fuel(),
- const Gap(20),
- _ofpVer(),
- ]),
- const Gap(5),
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- _crew(),
- if (lidoapilist.latestFuelOrder != null) _fuelOrder(),
- ],
- ),
- ],
- )
- ]),
- ),
- ),
- );
- }
- kilo2ton(int? k, {bool ceil = true}) {
- if (k == null) return null;
- const double conversionFactor = 0.001;
- double tons = k * conversionFactor;
- if (ceil) {
- return "${double.parse(((tons * 10).ceilToDouble() / 10).toStringAsFixed(1))}T";
- } else {
- return "${double.parse(((tons * 10).floorToDouble() / 10).toStringAsFixed(1))}T";
- }
- }
- }
|