import 'dart:io' show Platform; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; 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_cupertino.dart'; import 'package:info_tren/train_info_page/train_info_material.dart'; import 'package:info_tren/train_info_page/train_info_prompt.dart'; void main() => runApp(StartPoint()); class StartPoint extends StatelessWidget { @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 TrainDataWebViewAdapter( builder: (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 TrainDataWebViewAdapter( builder: (context) { return TrainInfoCupertino( trainNumber: ModalRoute.of(context).settings.arguments as int, ); }, ); }, } ); } return null; } } mixin MainPageAction { onTrainInfoPageInvoke(BuildContext context) { Navigator.of(context).pushNamed(TrainInfoPromptCommon.routeName); } onStationBoardPageInvoke(BuildContext context) { } onRoutePlanPageInvoke(BuildContext context) { } } class MainPageMaterial extends StatelessWidget with MainPageAction { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Info Tren"), centerTitle: true, ), body: SafeArea( child: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ 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), ), onPressed: () { onStationBoardPageInvoke(context); }, ), RaisedButton( child: Text( "Planificare rută", style: Theme.of(context).textTheme.button.copyWith(fontSize: 18), ), onPressed: () { onRoutePlanPageInvoke(context); }, ) ].map((w) => Padding( padding: const EdgeInsets.fromLTRB(4, 2, 4, 2), child: SizedBox( width: double.infinity, child: w, ), )).toList(), ), ), ), ); } } class MainPageCupertino extends StatelessWidget with MainPageAction { @override Widget build(BuildContext context) { return CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( middle: Text("Info Tren"), ), child: SafeArea( child: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ CupertinoButton.filled( child: Text("Informații despre tren"), onPressed: () { onTrainInfoPageInvoke(context); }, ), 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(), ), ), ), ); } }