|
|
@ -25,7 +25,10 @@ class TrainInfo extends StatelessWidget { |
|
|
|
|
|
|
|
|
|
|
|
return RefreshFutureBuilder<TrainData>( |
|
|
|
return RefreshFutureBuilder<TrainData>( |
|
|
|
futureCreator: () => getTrain(trainNumber), |
|
|
|
futureCreator: () => getTrain(trainNumber), |
|
|
|
builder: (context, refresh, snapshot) { |
|
|
|
builder: (context, refresh, replaceFutureBuilder, snapshot) { |
|
|
|
|
|
|
|
void onViewYesterdayTrain() { |
|
|
|
|
|
|
|
replaceFutureBuilder(() => getTrain(trainNumber, date: DateTime.now().subtract(const Duration(days: 1)))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (uiDesign) { |
|
|
|
switch (uiDesign) { |
|
|
|
case UiDesign.MATERIAL: |
|
|
|
case UiDesign.MATERIAL: |
|
|
@ -36,7 +39,11 @@ class TrainInfo extends StatelessWidget { |
|
|
|
return TrainInfoErrorMaterial(title: '$trainNumber - Error', error: snapshot.error!, refresh: refresh,); |
|
|
|
return TrainInfoErrorMaterial(title: '$trainNumber - Error', error: snapshot.error!, refresh: refresh,); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return TrainInfoMaterial(trainData: snapshot.data!, refresh: refresh,); |
|
|
|
return TrainInfoMaterial( |
|
|
|
|
|
|
|
trainData: snapshot.data!, |
|
|
|
|
|
|
|
refresh: refresh, |
|
|
|
|
|
|
|
onViewYesterdayTrain: onViewYesterdayTrain, |
|
|
|
|
|
|
|
); |
|
|
|
case UiDesign.CUPERTINO: |
|
|
|
case UiDesign.CUPERTINO: |
|
|
|
if ([RefreshFutureBuilderState.none, RefreshFutureBuilderState.waiting].contains(snapshot.state)) { |
|
|
|
if ([RefreshFutureBuilderState.none, RefreshFutureBuilderState.waiting].contains(snapshot.state)) { |
|
|
|
return TrainInfoLoadingCupertino(title: trainNumber.toString(), loadingText: "Se încarcă...",); |
|
|
|
return TrainInfoLoadingCupertino(title: trainNumber.toString(), loadingText: "Se încarcă...",); |
|
|
@ -45,7 +52,12 @@ class TrainInfo extends StatelessWidget { |
|
|
|
return TrainInfoErrorCupertino(title: '$trainNumber - Error', error: snapshot.error!, refresh: refresh,); |
|
|
|
return TrainInfoErrorCupertino(title: '$trainNumber - Error', error: snapshot.error!, refresh: refresh,); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return TrainInfoCupertino(trainData: snapshot.data!, refresh: refresh, isRefreshing: snapshot.state == RefreshFutureBuilderState.refreshing,); |
|
|
|
return TrainInfoCupertino( |
|
|
|
|
|
|
|
trainData: snapshot.data!, |
|
|
|
|
|
|
|
refresh: refresh, |
|
|
|
|
|
|
|
isRefreshing: snapshot.state == RefreshFutureBuilderState.refreshing, |
|
|
|
|
|
|
|
onViewYesterdayTrain: onViewYesterdayTrain, |
|
|
|
|
|
|
|
); |
|
|
|
default: |
|
|
|
default: |
|
|
|
throw UnmatchedUiDesignException(uiDesign); |
|
|
|
throw UnmatchedUiDesignException(uiDesign); |
|
|
|
} |
|
|
|
} |
|
|
@ -68,3 +80,12 @@ abstract class TrainInfoError extends StatelessWidget { |
|
|
|
|
|
|
|
|
|
|
|
TrainInfoError({required this.title, required this.error, this.refresh}); |
|
|
|
TrainInfoError({required this.title, required this.error, this.refresh}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class DisplayTrainYesterdayWarningCommon extends StatelessWidget { |
|
|
|
|
|
|
|
static const trainDidNotDepart = 'Acest tren nu a plecat încă din prima gară.'; |
|
|
|
|
|
|
|
static const seeYesterdayTrain = 'Apasă aici pentru a vedea trenul care a plecat ieri.'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final void Function() onViewYesterdayTrain; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DisplayTrainYesterdayWarningCommon(this.onViewYesterdayTrain); |
|
|
|
|
|
|
|
} |
|
|
|