| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 | import 'package:flutter/material.dart';import 'package:gap/gap.dart';import 'package:tp5/roster/models/duty.dart';import 'package:tp5/roster/widgets/w_airport.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';class WDuty extends StatelessWidget {  const WDuty({super.key, required this.duty, this.date, this.onTap});  final Duty duty;  final String? date;  final dynamic onTap;  Widget _checkDutyType() {    final String widgetdate = date ?? duty.date;    if (duty.type == "flight") {      return Card(        color: Colors.grey[800],        shape: RoundedRectangleBorder(          borderRadius: BorderRadius.circular(6.0),        ),        elevation: 8.0,        margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),        child: SizedBox(          child: ListTile(            contentPadding:                const EdgeInsets.symmetric(horizontal: 20.0, vertical: 0.0),            leading: Icon(duty.icon),            title: Row(              children: [                WCitypair(iata1: duty.data["dep"], iata2: duty.data["des"]),                if (duty.data["req"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  const Text("Requested",                      style: TextStyle(color: Colors.white38, fontSize: 12))                ],              ],            ),            subtitle: Row(              children: [                WFnum(al: duty.data["al"], fnum: duty.data["fnum"]),                const Gap(20),                if (duty.data["actype"] != null)                  Text("${duty.data["actype"] ?? ""}",                      style: const TextStyle(                          color: Colors.yellow, fontWeight: FontWeight.w700)),                if (duty.data["remark"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  _text(duty.data["remark"])                ],              ],            ),            trailing: Row(mainAxisSize: MainAxisSize.min, children: [              WHour(jiffy: duty.start!, hide: duty.date != widgetdate),              const Gap(10),              WHour(                  jiffy: duty.end!,                  color: duty.end!.format(pattern: "yyyy-MM-dd") == widgetdate                      ? null                      : Colors.black)            ]),          ),        ),      );    } else if (duty.type == "dhflight") {      return Card(        color: Colors.blueGrey[800],        shape: RoundedRectangleBorder(          borderRadius: BorderRadius.circular(6.0),        ),        elevation: 8.0,        margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),        child: SizedBox(          child: ListTile(            contentPadding:                const EdgeInsets.symmetric(horizontal: 20.0, vertical: 0.0),            leading: Icon(duty.icon),            title: Row(              children: [                Container(                  padding: const EdgeInsets.all(2),                  color: Colors.blueGrey[900],                  child: const Text("DH",                      style:                          TextStyle(fontWeight: FontWeight.w400, fontSize: 12)),                ),                const Gap(10),                WCitypair(iata1: duty.data["dep"], iata2: duty.data["des"]),                if (duty.data["req"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  const Text("Requested",                      style: TextStyle(color: Colors.white38, fontSize: 12))                ],              ],            ),            subtitle: Row(              children: [                WFnum(al: duty.data["al"], fnum: duty.data["fnum"]),                if (duty.data["remark"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  _text(duty.data["remark"])                ],              ],            ),            trailing: Row(mainAxisSize: MainAxisSize.min, children: [              WHour(jiffy: duty.start!, hide: duty.date != widgetdate),              const Gap(10),              WHour(                  jiffy: duty.end!,                  color: duty.end!.format(pattern: "yyyy-MM-dd") == widgetdate                      ? null                      : Colors.black)            ]),          ),        ),      );    } else if (duty.type == "dhlimo") {      return Card(        color: Colors.blueGrey[800],        shape: RoundedRectangleBorder(          borderRadius: BorderRadius.circular(6.0),        ),        elevation: 8.0,        margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),        child: SizedBox(          child: ListTile(            contentPadding:                const EdgeInsets.symmetric(horizontal: 20.0, vertical: 0.0),            leading: Icon(duty.icon),            title: Row(              children: [                Container(                  padding: const EdgeInsets.all(2),                  color: Colors.blueGrey[900],                  child: const Text("DH",                      style:                          TextStyle(fontWeight: FontWeight.w400, fontSize: 12)),                ),                const Gap(10),                WCitypair(iata1: duty.data["dep"], iata2: duty.data["des"]),                if (duty.data["req"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  const Text("Requested",                      style: TextStyle(color: Colors.white38, fontSize: 12))                ],              ],            ),            subtitle: Row(              children: [                const WFnum(al: "", fnum: "LIMO"),                if (duty.data["remark"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  _text(duty.data["remark"])                ],              ],            ),            trailing: Row(mainAxisSize: MainAxisSize.min, children: [              WHour(jiffy: duty.start!, hide: duty.date != widgetdate),              const Gap(10),              WHour(                  jiffy: duty.end!,                  color: duty.end!.format(pattern: "yyyy-MM-dd") == widgetdate                      ? null                      : Colors.black)            ]),          ),        ),      );    } else if (duty.type == "wholeday" ||        (duty.data["hdep"] == "0100" && duty.data["hdes"] == "2300") ||        (duty.data["hdep"] == "0001" && duty.data["hdes"] == "2300")) {      return Card(        color: Colors.white10,        shape: RoundedRectangleBorder(          borderRadius: BorderRadius.circular(6.0),        ),        elevation: 2.0,        margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),        child: SizedBox(          child: ListTile(            contentPadding:                const EdgeInsets.symmetric(horizontal: 20.0, vertical: 0.0),            title: Row(              mainAxisAlignment: MainAxisAlignment.center,              mainAxisSize: MainAxisSize.max,              children: [                Text(                  duty.data["label"],                  style: TextStyle(                      fontSize: (duty.data["label"]).toString().length < 16                          ? 24                          : 12),                ),                const Gap(10),                WAirport(                  iata: duty.data["dep"],                  size: 12,                ),                const Gap(5),                if (duty.data["req"] != null) ...[                  const Gap(10),                  const Text("Requested",                      style: TextStyle(color: Colors.white38, fontSize: 12))                ],              ],            ),            subtitle: Row(              children: [                if (duty.data["remark"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  _text(duty.data["remark"])                ],              ],            ),          ),        ),      );    } else if (duty.type == "ground") {      return Card(        color: Colors.blueGrey[700],        shape: RoundedRectangleBorder(          borderRadius: BorderRadius.circular(6.0),        ),        elevation: 8.0,        margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),        child: SizedBox(          child: ListTile(            contentPadding:                const EdgeInsets.symmetric(horizontal: 20.0, vertical: 0.0),            leading: Icon(duty.icon),            title: Row(              children: [                Text(                  duty.data["label"],                  style: TextStyle(                      fontSize: (duty.data["label"]).toString().length < 16                          ? 24                          : 12),                ),                const Gap(10),                WAirport(                  iata: duty.data["dep"],                  size: 12,                ),                const Gap(5),                if (duty.data["req"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  const Text("Requested",                      style: TextStyle(color: Colors.white38, fontSize: 12))                ],              ],            ),            subtitle: Row(              children: [                if (duty.data["actype"] != null) ...[                  const Text("SIMU"),                  const Gap(10),                  Text("${duty.data["actype"] ?? ""}",                      style: const TextStyle(                          color: Colors.yellow, fontWeight: FontWeight.w700))                ],                if (duty.data["remark"] != null) ...[                  const Gap(10),                  Expanded(child: Container()),                  _text(duty.data["remark"])                ],              ],            ),            trailing: Row(mainAxisSize: MainAxisSize.min, children: [              WHour(jiffy: duty.start!, hide: duty.date != widgetdate),              const Gap(10),              WHour(                  jiffy: duty.end!,                  color: duty.end!.format(pattern: "yyyy-MM-dd") == widgetdate                      ? null                      : Colors.black)            ]),          ),        ),      );    } else if (duty.type == "checkin") {      return Row(mainAxisAlignment: MainAxisAlignment.start, children: [        Container(          padding: const EdgeInsets.symmetric(horizontal: 5),          color: Colors.white10,          child: Text(            ">>> C/I   ${duty.data["station"]}   ${duty.data["time"]}",            style: const TextStyle(letterSpacing: 2, color: Colors.white54),          ),        )      ]);    } else if (duty.type == "checkout") {      return Row(mainAxisAlignment: MainAxisAlignment.end, children: [        Container(          padding: const EdgeInsets.symmetric(horizontal: 5),          color: Colors.white10,          child: Text(            "${duty.data["time"]}   ${duty.data["station"]}   C/O <<<",            style: const TextStyle(letterSpacing: 2, color: Colors.white54),          ),        )      ]);    } else if (duty.type == "credit") {      return Column(crossAxisAlignment: CrossAxisAlignment.end, children: [        // const Divider(),        Text(          "credit: [${duty.data["credit"]}]",          style: TextStyle(              fontSize: 12, letterSpacing: 2, color: Colors.blue[400]),        )      ]);    } else if (duty.type == "changed") {      return Card(        color: Colors.orange.shade800,        shape: RoundedRectangleBorder(          borderRadius: BorderRadius.circular(5.0),        ),        elevation: 2.0,        margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 6.0),        child: const SizedBox(          child: ListTile(            contentPadding:                EdgeInsets.symmetric(horizontal: 20.0, vertical: 0.0),            title: Row(                mainAxisAlignment: MainAxisAlignment.center,                mainAxisSize: MainAxisSize.max,                children: [                  Text(                    "CHANGED",                    style: TextStyle(fontSize: 24),                  ),                ]),          ),        ),      );    } else if (duty.type == "unknown") {      return Tooltip(          message: "${duty.data["unknown"]}",          child: Text(              overflow: TextOverflow.fade,              "${duty.data["unknown"]}",              style: const TextStyle(fontSize: 10)));    } else {      return Tooltip(          message: "${duty.data}",          child: Text(              overflow: TextOverflow.fade,              "${duty.data}",              style: const TextStyle(fontSize: 10)));    }  }  @override  Widget build(BuildContext context) {    return InkWell(      onTap: onTap,      child: _checkDutyType(),    );  }  Widget _text(String? msg) => Flexible(      child: Tooltip(          message: msg ?? "",          child: Text(msg ?? "",              overflow: TextOverflow.ellipsis,              style: const TextStyle(color: Colors.white38, fontSize: 12))));}
 |