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.

179 lines
5.1 KiB

import 'dart:io' show Platform;
import 'package:flutter/cupertino.dart';
5 years ago
import 'package:flutter/material.dart';
import 'package:info_tren/train_info_page/train_info.dart';
import 'package:info_tren/train_info_page/train_info_cupertino.dart';
import 'package:info_tren/train_info_page/train_info_material.dart';
import 'package:info_tren/train_info_page/train_info_prompt.dart';
5 years ago
void main() => runApp(StartPoint());
5 years ago
class StartPoint extends StatelessWidget {
5 years ago
@override
Widget build(BuildContext context) {
if (Platform.isAndroid) {
return MaterialApp(
title: 'Info Tren',
theme: ThemeData(
primarySwatch: Colors.blue,
brightness: Brightness.dark,
primaryColor: Colors.blue.shade600,
accentColor: Colors.blue.shade700,
),
// home: MainPageMaterial(),
routes: {
Navigator.defaultRouteName: (context) {
return MainPageMaterial();
},
TrainInfoPromptCommon.routeName: (context) {
return TrainInfoPromptMaterial();
},
TrainInfo.routeName: (context) {
return TrainInfoMaterial(
trainNumber: ModalRoute.of(context).settings.arguments as int,
);
},
},
);
}
else if (Platform.isIOS) {
return CupertinoApp(
title: "Info Tren",
theme: CupertinoThemeData(
primaryColor: Colors.blue.shade600,
brightness: Brightness.dark,
),
// home: MainPageCupertino(),
routes: {
Navigator.defaultRouteName: (context) {
return MainPageCupertino();
},
TrainInfoPromptCommon.routeName: (context) {
return TrainInfoPromptCupertino();
},
TrainInfo.routeName: (context) {
return TrainInfoCupertino(
trainNumber: ModalRoute.of(context).settings.arguments as int,
);
},
}
);
}
return null;
5 years ago
}
}
mixin MainPageAction {
onTrainInfoPageInvoke(BuildContext context) {
Navigator.of(context).pushNamed(TrainInfoPromptCommon.routeName);
}
5 years ago
onStationBoardPageInvoke(BuildContext context) {
5 years ago
}
onRoutePlanPageInvoke(BuildContext context) {
5 years ago
}
}
5 years ago
class MainPageMaterial extends StatelessWidget with MainPageAction {
5 years ago
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Info Tren"),
centerTitle: true,
),
body: SafeArea(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
5 years ago
children: <Widget>[
RaisedButton(
child: Text(
"Informații despre tren",
style: Theme.of(context).textTheme.button.copyWith(fontSize: 18),
),
onPressed: () {
onTrainInfoPageInvoke(context);
},
),
RaisedButton(
child: Text(
"Tabelă plecari/sosiri",
style: Theme.of(context).textTheme.button.copyWith(fontSize: 18),
5 years ago
),
onPressed: () {
onStationBoardPageInvoke(context);
},
5 years ago
),
RaisedButton(
child: Text(
"Planificare rută",
style: Theme.of(context).textTheme.button.copyWith(fontSize: 18),
5 years ago
),
onPressed: () {
onRoutePlanPageInvoke(context);
},
5 years ago
)
].map((w) => Padding(
padding: const EdgeInsets.fromLTRB(4, 2, 4, 2),
child: SizedBox(
width: double.infinity,
child: w,
),
)).toList(),
5 years ago
),
),
5 years ago
),
);
}
}
class MainPageCupertino extends StatelessWidget with MainPageAction {
5 years ago
@override
Widget build(BuildContext context) {
return CupertinoPageScaffold(
navigationBar: CupertinoNavigationBar(
middle: Text("Info Tren"),
),
child: SafeArea(
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
CupertinoButton.filled(
child: Text("Informații despre tren"),
onPressed: () {
onTrainInfoPageInvoke(context);
},
5 years ago
),
CupertinoButton.filled(
child: Text("Tabelă plecari/sosiri"),
onPressed: () {
onStationBoardPageInvoke(context);
},
),
CupertinoButton.filled(
child: Text("Planificare rută"),
onPressed: () {
onRoutePlanPageInvoke(context);
},
),
].map((w) => Padding(
padding: const EdgeInsets.fromLTRB(4, 2, 4, 2),
child: SizedBox(
width: double.infinity,
child: w,
),
)).toList(),
),
),
),
5 years ago
);
}
}