|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:info_tren/models.dart';
|
|
|
|
import 'package:info_tren/stations_list.dart.old';
|
|
|
|
|
|
|
|
class TrainInfoDisplayData extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
|
|
|
|
const TrainInfoDisplayData(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(8.0),
|
|
|
|
child: TrainName(trainData),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: TrainRoute(trainData),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: TrainOperator(trainData),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: TotalDetails(trainData),
|
|
|
|
),
|
|
|
|
const CustomDivider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: Destination(trainData),
|
|
|
|
),
|
|
|
|
const CustomDivider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: LastUpdate(trainData),
|
|
|
|
),
|
|
|
|
// if (trainData.nextStop.station.isNotEmpty)
|
|
|
|
// ...[
|
|
|
|
// CustomDivider(),
|
|
|
|
// Padding(
|
|
|
|
// padding: const EdgeInsets.all(4.0),
|
|
|
|
// child: NextStop(trainData),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
const CustomDivider(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: TrainStatus(trainData),
|
|
|
|
),
|
|
|
|
Divider(color: Theme.of(context).colorScheme.secondary,),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(4.0),
|
|
|
|
child: StationsList(trainData),
|
|
|
|
),
|
|
|
|
SafeArea(
|
|
|
|
bottom: true,
|
|
|
|
left: false,
|
|
|
|
right: false,
|
|
|
|
top: false,
|
|
|
|
child: Container(),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class TrainName extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
const TrainName(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Text(
|
|
|
|
"${trainData.rank} ${trainData.number}",
|
|
|
|
style: Theme.of(context).textTheme.displaySmall,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TrainRoute extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
const TrainRoute(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Row(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
trainData.route.from,
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(fontStyle: FontStyle.italic),
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"-",
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(fontStyle: FontStyle.italic),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
trainData.route.to,
|
|
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(fontStyle: FontStyle.italic),
|
|
|
|
textAlign: TextAlign.right,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TrainOperator extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
const TrainOperator(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Text(
|
|
|
|
"Operat de ${trainData.operator}",
|
|
|
|
style: Theme.of(context).textTheme.bodyMedium,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TrainStatus extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
const TrainStatus(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Text(
|
|
|
|
trainData.status.toString(),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Destination extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
const Destination(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final destinationStation = trainData.stations.last;
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
"Destinația: ${destinationStation.name}",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Sosește la ${destinationStation.arrival!.scheduleTime}",
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LastUpdate extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
const LastUpdate(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
if (trainData.status == null) {
|
|
|
|
return Container();
|
|
|
|
}
|
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(2.0),
|
|
|
|
child: Text("Ultima informație", style: Theme.of(context).textTheme.headlineSmall,),
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(2.0),
|
|
|
|
child: Text(trainData.status!.station, textAlign: TextAlign.left,),
|
|
|
|
),
|
|
|
|
Expanded(child: Container(),),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(2.0),
|
|
|
|
child: Text(trainData.status!.state.toString(), textAlign: TextAlign.right,),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.all(2.0),
|
|
|
|
child: trainData.status!.delay == 0
|
|
|
|
? Text("Fără întârziere", style: Theme.of(context).textTheme.bodySmall,)
|
|
|
|
: trainData.status!.delay > 0
|
|
|
|
? Text("${trainData.status!.delay} minute întârziere", style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.red.shade700),)
|
|
|
|
: Text("${-(trainData.status!.delay)} minute mai devreme", style: Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.green.shade700),)
|
|
|
|
),
|
|
|
|
// TODO: Implement status report time detection
|
|
|
|
// Padding(
|
|
|
|
// padding: const EdgeInsets.all(2.0),
|
|
|
|
// child: Text("Raportat la ${trainData.lastInfo.dateAndTime}"),
|
|
|
|
// ),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// class NextStop extends StatelessWidget {
|
|
|
|
// final TrainData trainData;
|
|
|
|
// NextStop(this.trainData);
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
// return Column(
|
|
|
|
// mainAxisSize: MainAxisSize.min,
|
|
|
|
// children: <Widget>[
|
|
|
|
// Padding(
|
|
|
|
// padding: const EdgeInsets.all(2.0),
|
|
|
|
// child: Text("Următoarea oprire", style: Theme.of(context).textTheme.headline5,),
|
|
|
|
// ),
|
|
|
|
// Row(
|
|
|
|
// children: <Widget>[
|
|
|
|
// Padding(
|
|
|
|
// padding: const EdgeInsets.all(2.0),
|
|
|
|
// child: Text(trainData.nextStop.station, textAlign: TextAlign.left,),
|
|
|
|
// ),
|
|
|
|
// Expanded(child: Container(),),
|
|
|
|
// Padding(
|
|
|
|
// padding: const EdgeInsets.all(2.0),
|
|
|
|
// child: Text(trainData.nextStop.dateAndTime, textAlign: TextAlign.right,),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
class TotalDetails extends StatelessWidget {
|
|
|
|
final TrainData trainData;
|
|
|
|
const TotalDetails(this.trainData, {super.key,});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
'${trainData.stations.last.km} km',
|
|
|
|
style: Theme.of(context).textTheme.bodySmall,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Container()
|
|
|
|
),
|
|
|
|
// Text(
|
|
|
|
// trainData.tripLength,
|
|
|
|
// style: Theme.of(context).textTheme.caption,
|
|
|
|
// textAlign: TextAlign.right,
|
|
|
|
// )
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class CustomDivider extends StatelessWidget {
|
|
|
|
const CustomDivider({super.key});
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Container(height: 4,),
|
|
|
|
const Divider(),
|
|
|
|
Container(height: 4,),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|