|
|
@ -1,5 +1,8 @@ |
|
|
|
|
|
|
|
import 'dart:math'; |
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:info_tren/components/cupertino_divider.dart'; |
|
|
|
import 'package:info_tren/components/cupertino_divider.dart'; |
|
|
|
|
|
|
|
import 'package:info_tren/components/sliver_persistent_header_padding.dart'; |
|
|
|
import 'package:info_tren/models/train_data.dart' hide State; |
|
|
|
import 'package:info_tren/models/train_data.dart' hide State; |
|
|
|
import 'package:info_tren/models/ui_design.dart'; |
|
|
|
import 'package:info_tren/models/ui_design.dart'; |
|
|
|
import 'package:info_tren/pages/train_info_page/train_info_constants.dart'; |
|
|
|
import 'package:info_tren/pages/train_info_page/train_info_constants.dart'; |
|
|
@ -58,8 +61,9 @@ class TrainInfoErrorCupertino extends TrainInfoError { |
|
|
|
|
|
|
|
|
|
|
|
class TrainInfoCupertino extends StatelessWidget { |
|
|
|
class TrainInfoCupertino extends StatelessWidget { |
|
|
|
final TrainData trainData; |
|
|
|
final TrainData trainData; |
|
|
|
|
|
|
|
final Future Function()? refresh; |
|
|
|
|
|
|
|
|
|
|
|
TrainInfoCupertino({required this.trainData}); |
|
|
|
TrainInfoCupertino({required this.trainData, this.refresh,}); |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
@ -74,84 +78,153 @@ class TrainInfoCupertino extends StatelessWidget { |
|
|
|
builder: (context) { |
|
|
|
builder: (context) { |
|
|
|
final topPadding = MediaQuery.of(context).padding.top; |
|
|
|
final topPadding = MediaQuery.of(context).padding.top; |
|
|
|
|
|
|
|
|
|
|
|
return CustomScrollView( |
|
|
|
return NestedScrollView( |
|
|
|
slivers: <Widget>[ |
|
|
|
headerSliverBuilder: (context, innerBoxIsScrolled) { |
|
|
|
SliverToBoxAdapter( |
|
|
|
return [ |
|
|
|
child: Padding( |
|
|
|
// SliverPadding( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
// padding: EdgeInsets.only( |
|
|
|
top: topPadding, |
|
|
|
// top: topPadding, |
|
|
|
), |
|
|
|
// ), |
|
|
|
child: Container(), |
|
|
|
// ), |
|
|
|
), |
|
|
|
SliverPersistentHeaderPadding(maxHeight: topPadding,) |
|
|
|
), |
|
|
|
]; |
|
|
|
DisplayTrainID(trainData: trainData,), |
|
|
|
}, |
|
|
|
DisplayTrainOperator(trainData: trainData,), |
|
|
|
body: Builder( |
|
|
|
DisplayTrainRoute(trainData: trainData,), |
|
|
|
builder: (context) { |
|
|
|
DisplayTrainDeparture(trainData: trainData,), |
|
|
|
return CustomScrollView( |
|
|
|
SliverToBoxAdapter( |
|
|
|
slivers: <Widget>[ |
|
|
|
child: CupertinoDivider( |
|
|
|
if (refresh != null) |
|
|
|
color: FOREGROUND_WHITE, |
|
|
|
CupertinoSliverRefreshControl( |
|
|
|
), |
|
|
|
builder: (context, mode, pulledExtent, refreshTriggerPullDistance, refreshIndicatorExtent) { |
|
|
|
), |
|
|
|
return Column( |
|
|
|
DisplayTrainLastInfo(trainData: trainData,), |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
SliverToBoxAdapter( |
|
|
|
children: [ |
|
|
|
child: CupertinoDivider(), |
|
|
|
Container( |
|
|
|
), |
|
|
|
height: pulledExtent, |
|
|
|
SliverToBoxAdapter( |
|
|
|
child: Column( |
|
|
|
child: IntrinsicHeight( |
|
|
|
children: [ |
|
|
|
child: Row( |
|
|
|
Container( |
|
|
|
children: <Widget>[ |
|
|
|
height: min(refreshIndicatorExtent, pulledExtent), |
|
|
|
// Expanded( |
|
|
|
child: Center( |
|
|
|
// child: DisplayTrainNextStop(trainData: trainData,), |
|
|
|
child: Builder( |
|
|
|
// ), |
|
|
|
builder: (context) { |
|
|
|
Expanded( |
|
|
|
if (mode == RefreshIndicatorMode.inactive) { |
|
|
|
child: DisplayTrainDestination(trainData: trainData,), |
|
|
|
return Container(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (mode == RefreshIndicatorMode.done) { |
|
|
|
|
|
|
|
return Text('Refreshed!'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (mode == RefreshIndicatorMode.drag) { |
|
|
|
|
|
|
|
return Row( |
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
CupertinoActivityIndicator(animating: false,), |
|
|
|
|
|
|
|
Text('Pull to refresh...'), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (mode == RefreshIndicatorMode.armed) { |
|
|
|
|
|
|
|
return Row( |
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
CupertinoActivityIndicator(animating: false,), |
|
|
|
|
|
|
|
Text('Release to refresh...'), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return Row( |
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
CupertinoActivityIndicator(), |
|
|
|
|
|
|
|
Text('Refreshing'), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
Expanded(child: Container(),), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
onRefresh: refresh, |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox( |
|
|
|
DisplayTrainID(trainData: trainData,), |
|
|
|
height: double.infinity, |
|
|
|
DisplayTrainOperator(trainData: trainData,), |
|
|
|
child: CupertinoVerticalDivider(), |
|
|
|
DisplayTrainRoute(trainData: trainData,), |
|
|
|
|
|
|
|
DisplayTrainDeparture(trainData: trainData,), |
|
|
|
|
|
|
|
SliverToBoxAdapter( |
|
|
|
|
|
|
|
child: CupertinoDivider( |
|
|
|
|
|
|
|
color: FOREGROUND_WHITE, |
|
|
|
), |
|
|
|
), |
|
|
|
Expanded(child: DisplayTrainRouteDistance(trainData: trainData,),), |
|
|
|
), |
|
|
|
], |
|
|
|
DisplayTrainLastInfo(trainData: trainData,), |
|
|
|
), |
|
|
|
SliverToBoxAdapter( |
|
|
|
), |
|
|
|
child: CupertinoDivider(), |
|
|
|
), |
|
|
|
), |
|
|
|
// SliverToBoxAdapter( |
|
|
|
SliverToBoxAdapter( |
|
|
|
// child: CupertinoDivider(), |
|
|
|
child: IntrinsicHeight( |
|
|
|
// ), |
|
|
|
child: Row( |
|
|
|
// SliverToBoxAdapter( |
|
|
|
children: <Widget>[ |
|
|
|
// child: IntrinsicHeight( |
|
|
|
// Expanded( |
|
|
|
// child: Row( |
|
|
|
// child: DisplayTrainNextStop(trainData: trainData,), |
|
|
|
// children: <Widget>[ |
|
|
|
// ), |
|
|
|
// // Expanded( |
|
|
|
Expanded( |
|
|
|
// // child: DisplayTrainRouteDuration(trainData: trainData,), |
|
|
|
child: DisplayTrainDestination(trainData: trainData,), |
|
|
|
// // ), |
|
|
|
), |
|
|
|
// Expanded(child: Container(),), |
|
|
|
SizedBox( |
|
|
|
// SizedBox( |
|
|
|
height: double.infinity, |
|
|
|
// height: double.infinity, |
|
|
|
child: CupertinoVerticalDivider(), |
|
|
|
// child: CupertinoVerticalDivider(), |
|
|
|
), |
|
|
|
// ), |
|
|
|
Expanded(child: DisplayTrainRouteDistance(trainData: trainData,),), |
|
|
|
// Expanded( |
|
|
|
], |
|
|
|
// child: DisplayTrainRouteDistance(trainData: trainData,), |
|
|
|
), |
|
|
|
// ) |
|
|
|
), |
|
|
|
// ], |
|
|
|
), |
|
|
|
// ), |
|
|
|
// SliverToBoxAdapter( |
|
|
|
// ), |
|
|
|
// child: CupertinoDivider(), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
SliverToBoxAdapter( |
|
|
|
// SliverToBoxAdapter( |
|
|
|
child: CupertinoDivider( |
|
|
|
// child: IntrinsicHeight( |
|
|
|
color: FOREGROUND_WHITE, |
|
|
|
// child: Row( |
|
|
|
), |
|
|
|
// children: <Widget>[ |
|
|
|
), |
|
|
|
// // Expanded( |
|
|
|
DisplayTrainStations( |
|
|
|
// // child: DisplayTrainRouteDuration(trainData: trainData,), |
|
|
|
trainData: trainData, |
|
|
|
// // ), |
|
|
|
), |
|
|
|
// Expanded(child: Container(),), |
|
|
|
SliverToBoxAdapter( |
|
|
|
// SizedBox( |
|
|
|
child: Container( |
|
|
|
// height: double.infinity, |
|
|
|
height: MediaQuery.of(context).viewPadding.bottom, |
|
|
|
// child: CupertinoVerticalDivider(), |
|
|
|
), |
|
|
|
// ), |
|
|
|
), |
|
|
|
// Expanded( |
|
|
|
], |
|
|
|
// child: DisplayTrainRouteDistance(trainData: trainData,), |
|
|
|
|
|
|
|
// ) |
|
|
|
|
|
|
|
// ], |
|
|
|
|
|
|
|
// ), |
|
|
|
|
|
|
|
// ), |
|
|
|
|
|
|
|
// ), |
|
|
|
|
|
|
|
SliverToBoxAdapter( |
|
|
|
|
|
|
|
child: CupertinoDivider( |
|
|
|
|
|
|
|
color: FOREGROUND_WHITE, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
DisplayTrainStations( |
|
|
|
|
|
|
|
trainData: trainData, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SliverToBoxAdapter( |
|
|
|
|
|
|
|
child: Container( |
|
|
|
|
|
|
|
height: MediaQuery.of(context).viewPadding.bottom, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
), |
|
|
|
), |
|
|
|