36 lines
1.0 KiB
Dart
36 lines
1.0 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:tangocard_reader/models/router_args.dart';
|
|
import 'package:tangocard_reader/screens/flashcard.dart';
|
|
import 'package:tangocard_reader/screens/home.dart';
|
|
import 'package:tangocard_reader/screens/tango_list.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class PageRouter {
|
|
static Route<dynamic> generateRoute(RouteSettings settings) {
|
|
final args = settings.arguments;
|
|
|
|
switch (settings.name) {
|
|
case '/':
|
|
return MaterialPageRoute(builder: (_) => const Home());
|
|
|
|
case '/tangolist':
|
|
final file = args as File;
|
|
return MaterialPageRoute(builder: (_) => TangoList(file: file));
|
|
|
|
case '/benkyou':
|
|
final benkyouArgs = args as BenkyouArgs;
|
|
return MaterialPageRoute(
|
|
builder: (_) => FlashcardView(
|
|
cards: benkyouArgs.cards,
|
|
index: benkyouArgs.index,
|
|
),
|
|
);
|
|
|
|
default:
|
|
return MaterialPageRoute(
|
|
builder: (_) => const Text("ERROR: this route does not exist"));
|
|
}
|
|
}
|
|
}
|