You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

289 lines
8.0 KiB

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