2021-09-07 00:05:33 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'main.dart';
|
2021-12-01 23:09:53 +01:00
|
|
|
import 'view/screens/search/kanji_result_page.dart';
|
|
|
|
import 'view/screens/search/search_results_page.dart';
|
2021-09-07 00:05:33 +02:00
|
|
|
|
2021-12-01 23:09:53 +01:00
|
|
|
Route<dynamic> generateRoute(RouteSettings settings) {
|
|
|
|
final args = settings.arguments;
|
2021-09-07 00:05:33 +02:00
|
|
|
|
2021-12-01 23:09:53 +01:00
|
|
|
switch (settings.name) {
|
|
|
|
case '/':
|
|
|
|
return MaterialPageRoute(builder: (_) => const Home());
|
2021-09-07 00:05:33 +02:00
|
|
|
|
2021-12-01 23:09:53 +01:00
|
|
|
case '/search':
|
|
|
|
final searchTerm = args as String;
|
|
|
|
return MaterialPageRoute(
|
|
|
|
builder: (_) => SearchResultsPage(searchTerm: searchTerm),
|
|
|
|
);
|
2021-09-07 00:05:33 +02:00
|
|
|
|
2021-12-01 23:09:53 +01:00
|
|
|
case '/kanjiSearch':
|
|
|
|
final searchTerm = args as String;
|
|
|
|
return MaterialPageRoute(
|
|
|
|
builder: (_) => KanjiResultPage(kanjiSearchTerm: searchTerm),
|
|
|
|
);
|
2021-09-07 00:05:33 +02:00
|
|
|
|
2021-12-01 23:09:53 +01:00
|
|
|
default:
|
|
|
|
return MaterialPageRoute(
|
|
|
|
builder: (_) => const Text('ERROR: this route does not exist'),
|
|
|
|
);
|
2021-09-07 00:05:33 +02:00
|
|
|
}
|
|
|
|
}
|