import 'package:flutter/widgets.dart'; import 'package:info_tren/models/ui_design.dart'; import 'package:info_tren/pages/main/main_page_cupertino.dart'; import 'package:info_tren/pages/main/main_page_material.dart'; import 'package:info_tren/pages/station_arrdep_page/select_station/select_station.dart'; import 'package:info_tren/pages/train_info_page/select_train/select_train.dart'; import 'package:info_tren/utils/default_ui_design.dart'; class MainPage extends StatelessWidget { final UiDesign? uiDesign; const MainPage({ Key? key, this.uiDesign }) : super(key: key); @override Widget build(BuildContext context) { final uiDesign = this.uiDesign ?? defaultUiDesign; switch (uiDesign) { case UiDesign.MATERIAL: return MainPageMaterial(); case UiDesign.CUPERTINO: return MainPageCupertino(); default: throw UnmatchedUiDesignException(uiDesign); } } } abstract class MainPageShared extends StatelessWidget { final String pageTitle = 'Info Tren'; List get options => [ MainPageOption( name: 'Informații despre tren', action: (BuildContext context) { onTrainInfoPageInvoke(context); }, ), MainPageOption( name: 'Tabelă plecari/sosiri', action: (context) { onStationBoardPageInvoke(context); }, ), MainPageOption( name: 'Planificare rută', // TODO: Implement route planning action: null, ), ]; onTrainInfoPageInvoke(BuildContext context) { Navigator.of(context).pushNamed(SelectTrainPage.routeName); } onStationBoardPageInvoke(BuildContext context) { Navigator.of(context).pushNamed(SelectStationPage.routeName); } onRoutePlanPageInvoke(BuildContext context) { } } class MainPageOption { final String name; final void Function(BuildContext context)? action; MainPageOption({required this.name, this.action}); }