Transition to Material 3, main page redesign
This commit is contained in:
parent
bf654ea837
commit
7fcbdc18bd
13 changed files with 493 additions and 349 deletions
|
@ -1,3 +1,10 @@
|
|||
v2.7.6
|
||||
Transitioned to Material 3.
|
||||
Redesigned main page on Material.
|
||||
On Android (Material), tapping station card in train information screen opens departures/arrivals board.
|
||||
Added past tense to trains already arrived/departed.
|
||||
Fixed download button on Android.
|
||||
|
||||
v2.7.5
|
||||
Added about page and in-app changelog.
|
||||
On Android, added download buttons.
|
||||
|
|
157
lib/components/badge.dart
Normal file
157
lib/components/badge.dart
Normal file
|
@ -0,0 +1,157 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:info_tren/pages/train_info_page/train_info_constants.dart';
|
||||
import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart';
|
||||
|
||||
class MaterialBadge extends StatelessWidget {
|
||||
final String text;
|
||||
final String caption;
|
||||
final bool isNotScheduled;
|
||||
final bool isOnTime;
|
||||
final bool isDelayed;
|
||||
|
||||
MaterialBadge({
|
||||
required this.text,
|
||||
required this.caption,
|
||||
this.isNotScheduled = false,
|
||||
this.isOnTime = false,
|
||||
this.isDelayed = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color foregroundColor = Colors.white70;
|
||||
Color? backgroundColor;
|
||||
|
||||
if (isNotScheduled) {
|
||||
foregroundColor = Colors.orange.shade300;
|
||||
backgroundColor = Colors.orange.shade900.withOpacity(0.3);
|
||||
}
|
||||
else if (isOnTime) {
|
||||
foregroundColor = Colors.green.shade300;
|
||||
backgroundColor = Colors.green.shade900.withOpacity(0.3);
|
||||
}
|
||||
else if (isDelayed) {
|
||||
foregroundColor = Colors.red.shade300;
|
||||
backgroundColor = Colors.red.shade900.withOpacity(0.3);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: foregroundColor,
|
||||
),
|
||||
color: backgroundColor,
|
||||
),
|
||||
width: isSmallScreen(context) ? 42 : 48,
|
||||
height: isSmallScreen(context) ? 42 : 48,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
fontSize: isSmallScreen(context) ? 16 : 20,
|
||||
fontWeight: MediaQuery.of(context).boldText ? FontWeight.w400 : FontWeight.w200,
|
||||
color: MediaQuery.of(context).boldText ? Colors.white70 : foregroundColor,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
caption,
|
||||
style: Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
fontSize: 10,
|
||||
color: MediaQuery.of(context).boldText ? Colors.white70 : foregroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class CupertinoBadge extends StatelessWidget {
|
||||
final String text;
|
||||
final String caption;
|
||||
final bool isNotScheduled;
|
||||
final bool isOnTime;
|
||||
final bool isDelayed;
|
||||
|
||||
CupertinoBadge({
|
||||
required this.text,
|
||||
required this.caption,
|
||||
this.isNotScheduled = false,
|
||||
this.isOnTime = false,
|
||||
this.isDelayed = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color foregroundColor = FOREGROUND_WHITE;
|
||||
Color? backgroundColor;
|
||||
|
||||
if (isNotScheduled) {
|
||||
foregroundColor = Color.fromRGBO(225, 175, 30, 1);
|
||||
backgroundColor = Color.fromRGBO(80, 40, 10, 1);
|
||||
}
|
||||
else if (isOnTime) {
|
||||
foregroundColor = Color.fromRGBO(130, 175, 65, 1);
|
||||
backgroundColor = Color.fromRGBO(40, 80, 10, 1);
|
||||
}
|
||||
else if (isDelayed) {
|
||||
foregroundColor = Color.fromRGBO(225, 75, 30, 1);
|
||||
backgroundColor = Color.fromRGBO(80, 20, 10, 1);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: foregroundColor,
|
||||
),
|
||||
color: backgroundColor,
|
||||
// color: CupertinoColors.activeOrange,
|
||||
),
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 20,
|
||||
fontWeight: MediaQuery.of(context).boldText ? FontWeight.w400 : FontWeight.w200,
|
||||
color: MediaQuery.of(context).boldText ? FOREGROUND_WHITE : foregroundColor,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
caption,
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: MediaQuery.of(context).boldText ? FOREGROUND_WHITE : foregroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -97,6 +97,7 @@ class StartPoint extends StatelessWidget {
|
|||
primarySwatch: Colors.blue,
|
||||
accentColor: Colors.blue.shade700,
|
||||
),
|
||||
useMaterial3: true,
|
||||
// fontFamily: 'Atkinson Hyperlegible',
|
||||
),
|
||||
routes: routesByUiDesign(UiDesign.MATERIAL),
|
||||
|
|
|
@ -100,7 +100,10 @@ class AboutPageStateCupertino extends AboutPageState {
|
|||
padding: EdgeInsets.all(4),
|
||||
minSize: 0,
|
||||
onPressed: () {
|
||||
launchUrl(log.apkLink!);
|
||||
launchUrl(
|
||||
log.apkLink!,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
child: Icon(CupertinoIcons.arrow_down_circle),
|
||||
),
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:info_tren/pages/about/about_page.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
|
@ -85,12 +87,33 @@ class AboutPageStateMaterial extends AboutPageState {
|
|||
),
|
||||
),
|
||||
if (AboutPageState.DOWNLOAD == 'apk' && log.apkLink != null)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
launchUrl(log.apkLink!);
|
||||
GestureDetector(
|
||||
onSecondaryTap: () {
|
||||
Clipboard.setData(ClipboardData(text: log.apkLink!.toString()));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Link copied to clipboard'),
|
||||
));
|
||||
},
|
||||
icon: Icon(Icons.download),
|
||||
tooltip: 'Download APK',
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(text: log.apkLink!.toString()));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text('Link copied to clipboard'),
|
||||
));
|
||||
},
|
||||
onTap: () {
|
||||
launchUrl(
|
||||
log.apkLink!,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
behavior: HitTestBehavior.translucent,
|
||||
child: Tooltip(
|
||||
message: 'Download APK',
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Icon(Icons.download),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -43,18 +43,21 @@ abstract class MainPageShared extends StatelessWidget {
|
|||
List<MainPageAction> get options => [
|
||||
MainPageAction(
|
||||
name: 'Informații despre tren',
|
||||
description: 'Află informații despre parcursul unui anumit tren',
|
||||
action: (context) {
|
||||
onTrainInfoPageInvoke(context);
|
||||
},
|
||||
),
|
||||
MainPageAction(
|
||||
name: 'Tabelă plecari/sosiri',
|
||||
description: 'Vezi trenurile care pleacă și sosesc dintr-o gară',
|
||||
action: (context) {
|
||||
onStationBoardPageInvoke(context);
|
||||
},
|
||||
),
|
||||
MainPageAction(
|
||||
name: 'Planificare rută',
|
||||
description: 'Găsește trenurile disponibile pentru călătoria între două gări',
|
||||
// TODO: Implement route planning
|
||||
action: null,
|
||||
),
|
||||
|
@ -75,7 +78,8 @@ abstract class MainPageShared extends StatelessWidget {
|
|||
|
||||
class MainPageAction {
|
||||
final String name;
|
||||
final String? description;
|
||||
final void Function(BuildContext context)? action;
|
||||
|
||||
MainPageAction({required this.name, this.action});
|
||||
MainPageAction({required this.name, this.action, this.description});
|
||||
}
|
||||
|
|
|
@ -26,12 +26,29 @@ class MainPageMaterial extends MainPageShared {
|
|||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: options.map((option) => ElevatedButton(
|
||||
children: options.map((option) => Card(
|
||||
color: option.action != null ? Theme.of(context).colorScheme.secondaryContainer : null,
|
||||
child: InkWell(
|
||||
onTap: option.action != null ? () => option.action!(context) : null,
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
option.name,
|
||||
style: Theme.of(context).textTheme.button?.copyWith(fontSize: 18),
|
||||
style: Theme.of(context).textTheme.headline4?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(option.description!),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
onPressed: option.action != null ? () => option.action!(context) : null,
|
||||
)).map((w) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 2, 4, 2),
|
||||
child: SizedBox(
|
||||
|
|
|
@ -33,7 +33,9 @@ abstract class ViewStationPageState extends State<ViewStationPage> {
|
|||
static const departures = 'Pleacări';
|
||||
static const loadingText = 'Se încarcă...';
|
||||
static const arrivesFrom = 'Sosește de la';
|
||||
static const arrivedFrom = 'A sosit de la';
|
||||
static const departsTo = 'Pleacă către';
|
||||
static const departedTo = 'A plecat către';
|
||||
|
||||
ViewStationPageTab tab = ViewStationPageTab.departures;
|
||||
late String stationName;
|
||||
|
|
|
@ -13,7 +13,11 @@ class ViewStationPageStateMaterial extends ViewStationPageState {
|
|||
title: Text(snapshot.hasData ? snapshot.data!.stationName : stationName),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: snapshot.state == RefreshFutureBuilderState.waiting ? Loading(text: ViewStationPageState.loadingText, uiDesign: widget.uiDesign,) : CustomScrollView(
|
||||
body: snapshot.state == RefreshFutureBuilderState.waiting
|
||||
? Loading(text: ViewStationPageState.loadingText, uiDesign: widget.uiDesign,)
|
||||
: snapshot.state == RefreshFutureBuilderState.error
|
||||
? Container()
|
||||
: CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: SafeArea(child: Container(), left: false, bottom: false, right: false,),),
|
||||
SliverList(
|
||||
|
@ -64,7 +68,7 @@ class ViewStationPageStateMaterial extends ViewStationPageState {
|
|||
subtitle: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: ViewStationPageState.arrivesFrom),
|
||||
TextSpan(text: item.time.compareTo(DateTime.now()) < 0 ? ViewStationPageState.arrivedFrom : ViewStationPageState.arrivesFrom),
|
||||
TextSpan(text: ' '),
|
||||
TextSpan(text: item.train.origin),
|
||||
],
|
||||
|
@ -95,7 +99,7 @@ class ViewStationPageStateMaterial extends ViewStationPageState {
|
|||
subtitle: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: ViewStationPageState.departsTo),
|
||||
TextSpan(text: item.time.compareTo(DateTime.now()) < 0 ? ViewStationPageState.departedTo : ViewStationPageState.departsTo),
|
||||
TextSpan(text: ' '),
|
||||
TextSpan(text: item.train.destination),
|
||||
],
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:info_tren/models/train_data.dart';
|
||||
import 'package:info_tren/pages/train_info_page/train_info_constants.dart';
|
||||
import 'package:info_tren/components/badge.dart';
|
||||
|
||||
class DisplayTrainStation extends StatelessWidget {
|
||||
final Station station;
|
||||
|
@ -47,7 +47,7 @@ class DisplayTrainStation extends StatelessWidget {
|
|||
final isOnTime = delay <= 0 && real == true;
|
||||
final isNotScheduled = false;
|
||||
|
||||
return Badge(
|
||||
return CupertinoBadge(
|
||||
text: station.km.toString(),
|
||||
caption: 'km',
|
||||
isNotScheduled: isNotScheduled,
|
||||
|
@ -65,7 +65,7 @@ class DisplayTrainStation extends StatelessWidget {
|
|||
flex: 1,
|
||||
child: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: station.platform == null ? Container() : Badge(text: station.platform!, caption: 'linia'),
|
||||
child: station.platform == null ? Container() : CupertinoBadge(text: station.platform!, caption: 'linia'),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -81,83 +81,6 @@ class DisplayTrainStation extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class Badge extends StatelessWidget {
|
||||
final String text;
|
||||
final String caption;
|
||||
final bool isNotScheduled;
|
||||
final bool isOnTime;
|
||||
final bool isDelayed;
|
||||
|
||||
Badge({
|
||||
required this.text,
|
||||
required this.caption,
|
||||
this.isNotScheduled = false,
|
||||
this.isOnTime = false,
|
||||
this.isDelayed = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color foregroundColor = FOREGROUND_WHITE;
|
||||
Color? backgroundColor;
|
||||
|
||||
if (isNotScheduled) {
|
||||
foregroundColor = Color.fromRGBO(225, 175, 30, 1);
|
||||
backgroundColor = Color.fromRGBO(80, 40, 10, 1);
|
||||
}
|
||||
else if (isOnTime) {
|
||||
foregroundColor = Color.fromRGBO(130, 175, 65, 1);
|
||||
backgroundColor = Color.fromRGBO(40, 80, 10, 1);
|
||||
}
|
||||
else if (isDelayed) {
|
||||
foregroundColor = Color.fromRGBO(225, 75, 30, 1);
|
||||
backgroundColor = Color.fromRGBO(80, 20, 10, 1);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: foregroundColor,
|
||||
),
|
||||
color: backgroundColor,
|
||||
// color: CupertinoColors.activeOrange,
|
||||
),
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 20,
|
||||
fontWeight: MediaQuery.of(context).boldText ? FontWeight.w400 : FontWeight.w200,
|
||||
color: MediaQuery.of(context).boldText ? FOREGROUND_WHITE : foregroundColor,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
caption,
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 12,
|
||||
color: MediaQuery.of(context).boldText ? FOREGROUND_WHITE : foregroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Title extends StatelessWidget {
|
||||
final Station station;
|
||||
|
||||
|
|
|
@ -3,18 +3,24 @@ import 'package:flutter/material.dart';
|
|||
import 'package:info_tren/components/slim_app_bar.dart';
|
||||
import 'package:info_tren/models/train_data.dart' hide State;
|
||||
import 'package:info_tren/models/ui_design.dart';
|
||||
import 'package:info_tren/pages/station_arrdep_page/view_station/view_station.dart';
|
||||
import 'package:info_tren/pages/train_info_page/view_train/train_info.dart';
|
||||
import 'package:info_tren/pages/train_info_page/view_train/train_info_material_DisplayTrainStation.dart';
|
||||
import 'package:info_tren/utils/state_to_string.dart';
|
||||
|
||||
class TrainInfoLoadingMaterial extends TrainInfoLoading {
|
||||
TrainInfoLoadingMaterial({required String title, String? loadingText}) : super(title: title, loadingText: loadingText, uiDesign: UiDesign.MATERIAL);
|
||||
TrainInfoLoadingMaterial({required String title, String? loadingText})
|
||||
: super(
|
||||
title: title,
|
||||
loadingText: loadingText,
|
||||
uiDesign: UiDesign.MATERIAL);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: loadingWidget,
|
||||
|
@ -28,7 +34,11 @@ class TrainInfoErrorMaterial extends TrainInfoError {
|
|||
required Object error,
|
||||
required String title,
|
||||
Future Function()? refresh,
|
||||
}) : super(error: error, title: title, refresh: refresh,);
|
||||
}) : super(
|
||||
error: error,
|
||||
title: title,
|
||||
refresh: refresh,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -56,23 +66,31 @@ class TrainInfoErrorMaterial extends TrainInfoError {
|
|||
}
|
||||
}
|
||||
|
||||
bool isSmallScreen(BuildContext context) => MediaQuery.of(context).size.height <= 425;
|
||||
bool isSmallScreen(BuildContext context) =>
|
||||
MediaQuery.of(context).size.height <= 425;
|
||||
|
||||
class TrainInfoMaterial extends StatelessWidget {
|
||||
final TrainData trainData;
|
||||
final Future Function()? refresh;
|
||||
final void Function()? onViewYesterdayTrain;
|
||||
|
||||
TrainInfoMaterial({required this.trainData, this.refresh, this.onViewYesterdayTrain,});
|
||||
TrainInfoMaterial({
|
||||
required this.trainData,
|
||||
this.refresh,
|
||||
this.onViewYesterdayTrain,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
return Scaffold(
|
||||
appBar: isSmallScreen(context) ? null : AppBar(
|
||||
appBar: isSmallScreen(context)
|
||||
? null
|
||||
: AppBar(
|
||||
centerTitle: true,
|
||||
title: Text("Informații despre ${trainData.rank} ${trainData.number}"),
|
||||
title: Text(
|
||||
"Informații despre ${trainData.rank} ${trainData.number}"),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
|
@ -82,8 +100,8 @@ class TrainInfoMaterial extends StatelessWidget {
|
|||
left: false,
|
||||
right: false,
|
||||
child: SlimAppBar(
|
||||
title: 'INFO TREN - ${trainData.rank} ${trainData.number}'
|
||||
),
|
||||
title:
|
||||
'INFO TREN - ${trainData.rank} ${trainData.number}'),
|
||||
),
|
||||
Expanded(
|
||||
child: SafeArea(
|
||||
|
@ -94,19 +112,27 @@ class TrainInfoMaterial extends StatelessWidget {
|
|||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
SliverToBoxAdapter(
|
||||
child: DisplayTrainID(trainData: trainData,),
|
||||
child: DisplayTrainID(
|
||||
trainData: trainData,
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: DisplayTrainOperator(trainData: trainData,),
|
||||
child: DisplayTrainOperator(
|
||||
trainData: trainData,
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.only(left: 2, right: 2),
|
||||
sliver: SliverToBoxAdapter(
|
||||
child: DisplayTrainRoute(trainData: trainData,),
|
||||
child: DisplayTrainRoute(
|
||||
trainData: trainData,
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: DisplayTrainDeparture(trainData: trainData,),
|
||||
child: DisplayTrainDeparture(
|
||||
trainData: trainData,
|
||||
),
|
||||
),
|
||||
// SliverToBoxAdapter(
|
||||
// child: Divider(
|
||||
|
@ -115,7 +141,9 @@ class TrainInfoMaterial extends StatelessWidget {
|
|||
// ),
|
||||
// ),
|
||||
SliverToBoxAdapter(
|
||||
child: DisplayTrainLastInfo(trainData: trainData,),
|
||||
child: DisplayTrainLastInfo(
|
||||
trainData: trainData,
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: IntrinsicHeight(
|
||||
|
@ -123,8 +151,15 @@ class TrainInfoMaterial extends StatelessWidget {
|
|||
children: <Widget>[
|
||||
// Expanded(child: DisplayTrainNextStop(trainData: trainData,)),
|
||||
// Expanded(child: DisplayTrainDestination(trainData: trainData,)),
|
||||
Expanded(child: DisplayTrainRouteDuration(trainData: trainData,)),
|
||||
Expanded(child: DisplayTrainRouteDistance(trainData: trainData,),),
|
||||
Expanded(
|
||||
child: DisplayTrainRouteDuration(
|
||||
trainData: trainData,
|
||||
)),
|
||||
Expanded(
|
||||
child: DisplayTrainRouteDistance(
|
||||
trainData: trainData,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -146,9 +181,13 @@ class TrainInfoMaterial extends StatelessWidget {
|
|||
height: isSmallScreen(context) ? 8 : 16,
|
||||
),
|
||||
),
|
||||
if (onViewYesterdayTrain != null && trainData.stations.first.departure!.scheduleTime.compareTo(DateTime.now()) > 0) ...[
|
||||
if (onViewYesterdayTrain != null &&
|
||||
trainData.stations.first.departure!.scheduleTime
|
||||
.compareTo(DateTime.now()) >
|
||||
0) ...[
|
||||
SliverToBoxAdapter(
|
||||
child: DisplayTrainYesterdayWarningMaterial(onViewYesterdayTrain!),
|
||||
child: DisplayTrainYesterdayWarningMaterial(
|
||||
onViewYesterdayTrain!),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Divider(
|
||||
|
@ -191,16 +230,21 @@ class DisplayTrainID extends StatelessWidget {
|
|||
TextSpan(
|
||||
text: trainData.rank,
|
||||
style: TextStyle(
|
||||
color: trainData.rank.startsWith('IR') ? Color.fromARGB(255, 255, 0, 0) : null,
|
||||
color: trainData.rank.startsWith('IR')
|
||||
? Color.fromARGB(255, 255, 0, 0)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
TextSpan(text: ' '),
|
||||
TextSpan(text: trainData.number,),
|
||||
TextSpan(
|
||||
text: trainData.number,
|
||||
),
|
||||
],
|
||||
),
|
||||
style: (isSmallScreen(context)
|
||||
? Theme.of(context).textTheme.headline4
|
||||
: Theme.of(context).textTheme.headline3)?.copyWith(
|
||||
: Theme.of(context).textTheme.headline3)
|
||||
?.copyWith(
|
||||
color: Theme.of(context).textTheme.bodyText2?.color,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
|
@ -333,7 +377,9 @@ class DisplayTrainLastInfo extends StatelessWidget {
|
|||
textAlign: TextAlign.left,
|
||||
),
|
||||
),
|
||||
Expanded(child: Container(),),
|
||||
Expanded(
|
||||
child: Container(),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Text(
|
||||
|
@ -359,7 +405,9 @@ class DisplayTrainLastInfo extends StatelessWidget {
|
|||
// );
|
||||
// },
|
||||
// ),
|
||||
Expanded(child: Container(),),
|
||||
Expanded(
|
||||
child: Container(),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final data = trainData.status!.delay;
|
||||
|
@ -370,16 +418,17 @@ class DisplayTrainLastInfo extends StatelessWidget {
|
|||
if (data > 0) {
|
||||
return Text(
|
||||
"$data ${data == 1 ? 'minut' : 'minute'} întârziere",
|
||||
style: Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
fontSize: isSmallScreen(context) ? 14 : 16,
|
||||
color: Colors.red.shade300,
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return Text(
|
||||
"${-data} ${data == -1 ? 'minut' : 'minute'} mai devreme",
|
||||
style: Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
style:
|
||||
Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
fontSize: isSmallScreen(context) ? 14 : 16,
|
||||
color: Colors.green.shade300,
|
||||
),
|
||||
|
@ -520,9 +569,12 @@ class DisplayTrainDestination extends StatelessWidget {
|
|||
Builder(
|
||||
builder: (context) {
|
||||
final arrival = destination.arrival!.scheduleTime.toLocal();
|
||||
final delay = trainData.stations.last.arrival!.status?.delay ?? 0;
|
||||
final arrivalWithDelay = arrival.add(Duration(minutes: delay));
|
||||
final arrivalWithDelayString = '${arrivalWithDelay.hour}:${arrivalWithDelay.minute.toString().padLeft(2, "0")}';
|
||||
final delay =
|
||||
trainData.stations.last.arrival!.status?.delay ?? 0;
|
||||
final arrivalWithDelay =
|
||||
arrival.add(Duration(minutes: delay));
|
||||
final arrivalWithDelayString =
|
||||
'${arrivalWithDelay.hour}:${arrivalWithDelay.minute.toString().padLeft(2, "0")}';
|
||||
// const months = ["ian", "feb", "mar", "apr", "mai", "iun", "iul", "aug", "sep", "oct", "noi", "dec"];
|
||||
|
||||
return Column(
|
||||
|
@ -542,8 +594,11 @@ class DisplayTrainDestination extends StatelessWidget {
|
|||
children: [
|
||||
TextSpan(text: ' '),
|
||||
TextSpan(
|
||||
text: '${arrival.hour.toString().padLeft(2, '0')}:${arrival.minute.toString().padLeft(2, '0')}',
|
||||
style: delay == 0 ? null : TextStyle(
|
||||
text:
|
||||
'${arrival.hour.toString().padLeft(2, '0')}:${arrival.minute.toString().padLeft(2, '0')}',
|
||||
style: delay == 0
|
||||
? null
|
||||
: TextStyle(
|
||||
decoration: TextDecoration.lineThrough,
|
||||
),
|
||||
),
|
||||
|
@ -552,7 +607,9 @@ class DisplayTrainDestination extends StatelessWidget {
|
|||
TextSpan(
|
||||
text: '$arrivalWithDelayString',
|
||||
style: TextStyle(
|
||||
color: delay > 0 ? Colors.red.shade300 : Colors.green.shade300,
|
||||
color: delay > 0
|
||||
? Colors.red.shade300
|
||||
: Colors.green.shade300,
|
||||
),
|
||||
),
|
||||
]
|
||||
|
@ -636,15 +693,19 @@ class DisplayTrainRouteDuration extends StatelessWidget {
|
|||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
var duration = trainData.stations.last.arrival!.scheduleTime.difference(trainData.stations.first.departure!.scheduleTime);
|
||||
var duration = trainData.stations.last.arrival!.scheduleTime
|
||||
.difference(
|
||||
trainData.stations.first.departure!.scheduleTime);
|
||||
var durationString = StringBuffer();
|
||||
|
||||
bool firstWritten = false;
|
||||
|
||||
if (duration.inDays > 0) {
|
||||
firstWritten = true;
|
||||
if (duration.inDays == 1) durationString.write("1 zi");
|
||||
else durationString.write("${duration.inDays} zile");
|
||||
if (duration.inDays == 1)
|
||||
durationString.write("1 zi");
|
||||
else
|
||||
durationString.write("${duration.inDays} zile");
|
||||
duration -= Duration(days: duration.inDays);
|
||||
}
|
||||
|
||||
|
@ -653,8 +714,10 @@ class DisplayTrainRouteDuration extends StatelessWidget {
|
|||
durationString.write(", ");
|
||||
}
|
||||
firstWritten = true;
|
||||
if (duration.inHours == 1) durationString.write("1 oră");
|
||||
else durationString.write("${duration.inHours} ore");
|
||||
if (duration.inHours == 1)
|
||||
durationString.write("1 oră");
|
||||
else
|
||||
durationString.write("${duration.inHours} ore");
|
||||
duration -= Duration(hours: duration.inHours);
|
||||
}
|
||||
|
||||
|
@ -663,8 +726,10 @@ class DisplayTrainRouteDuration extends StatelessWidget {
|
|||
durationString.write(", ");
|
||||
}
|
||||
firstWritten = true;
|
||||
if (duration.inMinutes == 1) durationString.write("1 minut");
|
||||
else durationString.write("${duration.inMinutes} minute");
|
||||
if (duration.inMinutes == 1)
|
||||
durationString.write("1 minut");
|
||||
else
|
||||
durationString.write("${duration.inMinutes} minute");
|
||||
duration -= Duration(minutes: duration.inMinutes);
|
||||
}
|
||||
|
||||
|
@ -685,8 +750,10 @@ class DisplayTrainRouteDuration extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
class DisplayTrainYesterdayWarningMaterial extends DisplayTrainYesterdayWarningCommon {
|
||||
DisplayTrainYesterdayWarningMaterial(void Function() onViewYesterdayTrain) : super(onViewYesterdayTrain);
|
||||
class DisplayTrainYesterdayWarningMaterial
|
||||
extends DisplayTrainYesterdayWarningCommon {
|
||||
DisplayTrainYesterdayWarningMaterial(void Function() onViewYesterdayTrain)
|
||||
: super(onViewYesterdayTrain);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -698,7 +765,9 @@ class DisplayTrainYesterdayWarningMaterial extends DisplayTrainYesterdayWarningC
|
|||
child: Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(text: DisplayTrainYesterdayWarningCommon.trainDidNotDepart,),
|
||||
TextSpan(
|
||||
text: DisplayTrainYesterdayWarningCommon.trainDidNotDepart,
|
||||
),
|
||||
TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
text: DisplayTrainYesterdayWarningCommon.seeYesterdayTrain,
|
||||
|
@ -730,6 +799,12 @@ class DisplayTrainStations extends StatelessWidget {
|
|||
return IndexedSemantics(
|
||||
child: DisplayTrainStation(
|
||||
station: trainData.stations[index],
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
ViewStationPage.routeName,
|
||||
arguments: trainData.stations[index].name,
|
||||
);
|
||||
},
|
||||
),
|
||||
index: index,
|
||||
);
|
||||
|
@ -740,4 +815,3 @@ class DisplayTrainStations extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:info_tren/models/train_data.dart';
|
||||
import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart' show isSmallScreen;
|
||||
import 'package:info_tren/components/badge.dart';
|
||||
import 'package:info_tren/pages/train_info_page/view_train/train_info_material.dart';
|
||||
|
||||
class DisplayTrainStation extends StatelessWidget {
|
||||
final Station station;
|
||||
final void Function()? onTap;
|
||||
|
||||
DisplayTrainStation({required this.station});
|
||||
DisplayTrainStation({required this.station, this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Column(
|
||||
|
@ -50,7 +54,7 @@ class DisplayTrainStation extends StatelessWidget {
|
|||
final isOnTime = delay <= 0 && real == true;
|
||||
final isNotScheduled = false;
|
||||
|
||||
return Badge(
|
||||
return MaterialBadge(
|
||||
text: station.km.toString(),
|
||||
caption: 'km',
|
||||
isNotScheduled: isNotScheduled,
|
||||
|
@ -70,7 +74,7 @@ class DisplayTrainStation extends StatelessWidget {
|
|||
? Container()
|
||||
: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Badge(text: station.platform!, caption: 'linia',),
|
||||
child: MaterialBadge(text: station.platform!, caption: 'linia',),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
@ -84,81 +88,6 @@ class DisplayTrainStation extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Badge extends StatelessWidget {
|
||||
final String text;
|
||||
final String caption;
|
||||
final bool isNotScheduled;
|
||||
final bool isOnTime;
|
||||
final bool isDelayed;
|
||||
|
||||
Badge({
|
||||
required this.text,
|
||||
required this.caption,
|
||||
this.isNotScheduled = false,
|
||||
this.isOnTime = false,
|
||||
this.isDelayed = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Color foregroundColor = Colors.white70;
|
||||
Color? backgroundColor;
|
||||
|
||||
if (isNotScheduled) {
|
||||
foregroundColor = Colors.orange.shade300;
|
||||
backgroundColor = Colors.orange.shade900.withOpacity(0.3);
|
||||
}
|
||||
else if (isOnTime) {
|
||||
foregroundColor = Colors.green.shade300;
|
||||
backgroundColor = Colors.green.shade900.withOpacity(0.3);
|
||||
}
|
||||
else if (isDelayed) {
|
||||
foregroundColor = Colors.red.shade300;
|
||||
backgroundColor = Colors.red.shade900.withOpacity(0.3);
|
||||
}
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
width: 2,
|
||||
color: foregroundColor,
|
||||
),
|
||||
color: backgroundColor,
|
||||
),
|
||||
width: isSmallScreen(context) ? 42 : 48,
|
||||
height: isSmallScreen(context) ? 42 : 48,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
fontSize: isSmallScreen(context) ? 16 : 20,
|
||||
fontWeight: MediaQuery.of(context).boldText ? FontWeight.w400 : FontWeight.w200,
|
||||
color: MediaQuery.of(context).boldText ? Colors.white70 : foregroundColor,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
caption,
|
||||
style: Theme.of(context).textTheme.bodyText2?.copyWith(
|
||||
fontSize: 10,
|
||||
color: MediaQuery.of(context).boldText ? Colors.white70 : foregroundColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ description: O aplicație de vizualizare a datelor puse la dispoziție de Inform
|
|||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 2.7.4
|
||||
version: 2.7.6
|
||||
|
||||
environment:
|
||||
sdk: ">=2.15.0 <3.0.0"
|
||||
|
|
Loading…
Add table
Reference in a new issue