Move DisplayTrainStation out of main file
Next step is to break it up in small parts
This commit is contained in:
parent
59fd435bd7
commit
f30c2a4dde
3 changed files with 226 additions and 220 deletions
|
@ -3,6 +3,7 @@ import 'package:info_tren/models/train_data.dart';
|
||||||
import 'package:info_tren/train_info_page/train_info.dart';
|
import 'package:info_tren/train_info_page/train_info.dart';
|
||||||
import 'package:info_tren/train_info_page/train_info_animation_helpers.dart';
|
import 'package:info_tren/train_info_page/train_info_animation_helpers.dart';
|
||||||
import 'package:info_tren/train_info_page/train_info_constants.dart';
|
import 'package:info_tren/train_info_page/train_info_constants.dart';
|
||||||
|
import 'package:info_tren/train_info_page/train_info_cupertino_DisplayTrainStation.dart';
|
||||||
import 'package:info_tren/utils/stream_list.dart';
|
import 'package:info_tren/utils/stream_list.dart';
|
||||||
|
|
||||||
class TrainInfoCupertino extends StatefulWidget {
|
class TrainInfoCupertino extends StatefulWidget {
|
||||||
|
@ -962,223 +963,6 @@ class DisplayTrainStations extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class DisplayTrainStation extends StatelessWidget {
|
|
||||||
final OnDemandStation station;
|
|
||||||
|
|
||||||
DisplayTrainStation({@required this.station});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: <Widget>[
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.all(8),
|
|
||||||
child: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
border: Border.all(
|
|
||||||
width: 2,
|
|
||||||
color: FOREGROUND_WHITE,
|
|
||||||
),
|
|
||||||
// color: CupertinoColors.activeOrange,
|
|
||||||
),
|
|
||||||
width: 48,
|
|
||||||
height: 48,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(
|
|
||||||
child: Center(
|
|
||||||
child: FutureDisplay<int>(
|
|
||||||
future: station.km,
|
|
||||||
builder: (context, value) {
|
|
||||||
return Text(
|
|
||||||
value.toString(),
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
fontSize: 18,
|
|
||||||
fontWeight: FontWeight.w100,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"km",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(fontSize: 10),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: FutureDisplay<List<String>>(
|
|
||||||
future: Future.wait([
|
|
||||||
station.stationName,
|
|
||||||
station.observations
|
|
||||||
]),
|
|
||||||
builder: (context, items) {
|
|
||||||
return Text(
|
|
||||||
items[0],
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
fontSize: 22,
|
|
||||||
fontWeight: FontWeight.w100,
|
|
||||||
fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
FutureDisplay<List<String>>(
|
|
||||||
future: Future.wait([
|
|
||||||
station.arrivalTime,
|
|
||||||
station.stopsFor,
|
|
||||||
station.departureTime
|
|
||||||
]),
|
|
||||||
builder: (context, items) {
|
|
||||||
if (items[0].isEmpty) {
|
|
||||||
// Plecare
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(child: Container(),),
|
|
||||||
Text("plecare la ${items[2]}"),
|
|
||||||
Container(width: 2,),
|
|
||||||
Text(
|
|
||||||
"→",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
fontSize: 22,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (items[2].isEmpty) {
|
|
||||||
// Sosire
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Text(
|
|
||||||
"→",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
fontSize: 22,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(width: 2,),
|
|
||||||
Text("sosire la ${items[0]}"),
|
|
||||||
Expanded(child: Container(),),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Text(
|
|
||||||
"→",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
fontSize: 22,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(width: 2,),
|
|
||||||
Text(items[0]),
|
|
||||||
Expanded(child: Container(),),
|
|
||||||
Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: <Widget>[
|
|
||||||
Builder(
|
|
||||||
builder: (context) {
|
|
||||||
if (items[1].isEmpty || items[1] == "0") {
|
|
||||||
return Container();
|
|
||||||
}
|
|
||||||
if (items[1] == "1") {
|
|
||||||
return Text(
|
|
||||||
"staționează pentru\n1 minut",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Text(
|
|
||||||
"staționează pentru\n${items[1]} minute",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
),
|
|
||||||
FutureBuilder<String>(
|
|
||||||
future: station.observations,
|
|
||||||
builder: (context, snapshot) {
|
|
||||||
if (snapshot.data == "ONI") {
|
|
||||||
return Text(
|
|
||||||
"oprire ne-itinerarică",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
fontStyle: FontStyle.italic,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Container();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Expanded(child: Container(),),
|
|
||||||
Text(items[2]),
|
|
||||||
Container(width: 2,),
|
|
||||||
Text(
|
|
||||||
"→",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
fontSize: 22,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
FutureDisplay<int>(
|
|
||||||
future: station.delay,
|
|
||||||
builder: (context, delay) {
|
|
||||||
if (delay == 0) return Container();
|
|
||||||
|
|
||||||
else if (delay > 0) {
|
|
||||||
return Text(
|
|
||||||
"$delay minute întârziere",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
color: CupertinoColors.destructiveRed,
|
|
||||||
fontSize: 12,
|
|
||||||
fontStyle: FontStyle.italic,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (delay < 0) {
|
|
||||||
return Text(
|
|
||||||
"${-delay} minute mai devreme",
|
|
||||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
|
||||||
color: CupertinoColors.activeGreen,
|
|
||||||
fontSize: 12,
|
|
||||||
fontStyle: FontStyle.italic,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Container();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class CupertinoDivider extends StatelessWidget {
|
class CupertinoDivider extends StatelessWidget {
|
||||||
final Color color;
|
final Color color;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,219 @@
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:info_tren/models/train_data.dart';
|
||||||
|
|
||||||
|
class DisplayTrainStation extends StatelessWidget {
|
||||||
|
final OnDemandStation station;
|
||||||
|
|
||||||
|
DisplayTrainStation({@required this.station});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(
|
||||||
|
width: 2,
|
||||||
|
color: FOREGROUND_WHITE,
|
||||||
|
),
|
||||||
|
// color: CupertinoColors.activeOrange,
|
||||||
|
),
|
||||||
|
width: 48,
|
||||||
|
height: 48,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Center(
|
||||||
|
child: FutureDisplay<int>(
|
||||||
|
future: station.km,
|
||||||
|
builder: (context, value) {
|
||||||
|
return Text(
|
||||||
|
value.toString(),
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
fontSize: 18,
|
||||||
|
fontWeight: FontWeight.w100,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
"km",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(fontSize: 10),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: FutureDisplay<List<String>>(
|
||||||
|
future: Future.wait([
|
||||||
|
station.stationName,
|
||||||
|
station.observations
|
||||||
|
]),
|
||||||
|
builder: (context, items) {
|
||||||
|
return Text(
|
||||||
|
items[0],
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: FontWeight.w100,
|
||||||
|
fontStyle: items[1] == "ONI" ? FontStyle.italic : FontStyle.normal,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
FutureDisplay<List<String>>(
|
||||||
|
future: Future.wait([
|
||||||
|
station.arrivalTime,
|
||||||
|
station.stopsFor,
|
||||||
|
station.departureTime
|
||||||
|
]),
|
||||||
|
builder: (context, items) {
|
||||||
|
if (items[0].isEmpty) {
|
||||||
|
// Plecare
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(child: Container(),),
|
||||||
|
Text("plecare la ${items[2]}"),
|
||||||
|
Container(width: 2,),
|
||||||
|
Text(
|
||||||
|
"→",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
fontSize: 22,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (items[2].isEmpty) {
|
||||||
|
// Sosire
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
"→",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
fontSize: 22,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(width: 2,),
|
||||||
|
Text("sosire la ${items[0]}"),
|
||||||
|
Expanded(child: Container(),),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
"→",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
fontSize: 22,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(width: 2,),
|
||||||
|
Text(items[0]),
|
||||||
|
Expanded(child: Container(),),
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: <Widget>[
|
||||||
|
Builder(
|
||||||
|
builder: (context) {
|
||||||
|
if (items[1].isEmpty || items[1] == "0") {
|
||||||
|
return Container();
|
||||||
|
}
|
||||||
|
if (items[1] == "1") {
|
||||||
|
return Text(
|
||||||
|
"staționează pentru\n1 minut",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Text(
|
||||||
|
"staționează pentru\n${items[1]} minute",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
FutureBuilder<String>(
|
||||||
|
future: station.observations,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.data == "ONI") {
|
||||||
|
return Text(
|
||||||
|
"oprire ne-itinerarică",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
fontStyle: FontStyle.italic,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Expanded(child: Container(),),
|
||||||
|
Text(items[2]),
|
||||||
|
Container(width: 2,),
|
||||||
|
Text(
|
||||||
|
"→",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
fontSize: 22,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
FutureDisplay<int>(
|
||||||
|
future: station.delay,
|
||||||
|
builder: (context, delay) {
|
||||||
|
if (delay == 0) return Container();
|
||||||
|
|
||||||
|
else if (delay > 0) {
|
||||||
|
return Text(
|
||||||
|
"$delay minute întârziere",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
color: CupertinoColors.destructiveRed,
|
||||||
|
fontSize: 12,
|
||||||
|
fontStyle: FontStyle.italic,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (delay < 0) {
|
||||||
|
return Text(
|
||||||
|
"${-delay} minute mai devreme",
|
||||||
|
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||||
|
color: CupertinoColors.activeGreen,
|
||||||
|
fontSize: 12,
|
||||||
|
fontStyle: FontStyle.italic,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -331,9 +331,12 @@ class _TrainInfoPromptCupertinoState extends State<TrainInfoPromptCupertino> wit
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: getOperatorsListView(context, currentInput: trainNoController.text, onTrainSelected: (number) {
|
child: getOperatorsListView(
|
||||||
onTrainSelected(context, number);
|
context,
|
||||||
})
|
currentInput: trainNoController.text, onTrainSelected: (number) {
|
||||||
|
onTrainSelected(context, number);
|
||||||
|
}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Reference in a new issue