1
1
import 'package:flutter/material.dart' ;
2
- import 'package:web_dex/bloc/coins_bloc/coins_bloc .dart' ;
2
+ import 'package:web_dex/app_config/app_config .dart' ;
3
3
import 'package:web_dex/model/first_uri_segment.dart' ;
4
4
import 'package:web_dex/router/parsers/base_route_parser.dart' ;
5
5
import 'package:web_dex/router/parsers/bridge_route_parser.dart' ;
@@ -11,26 +11,22 @@ import 'package:web_dex/router/parsers/wallet_route_parser.dart';
11
11
import 'package:web_dex/router/routes.dart' ;
12
12
13
13
class RootRouteInformationParser extends RouteInformationParser <AppRoutePath > {
14
- RootRouteInformationParser (this .coinsBloc);
15
-
16
- final CoinsBloc coinsBloc;
17
-
18
- Map <String , BaseRouteParser > get _parsers => {
19
- firstUriSegment.wallet: WalletRouteParser (coinsBloc),
20
- firstUriSegment.fiat: fiatRouteParser,
21
- firstUriSegment.dex: dexRouteParser,
22
- firstUriSegment.bridge: bridgeRouteParser,
23
- firstUriSegment.nfts: nftRouteParser,
24
- firstUriSegment.settings: settingsRouteParser,
25
- };
14
+ final Map <String , BaseRouteParser > _parsers = {
15
+ firstUriSegment.wallet: walletRouteParser,
16
+ firstUriSegment.fiat: fiatRouteParser,
17
+ firstUriSegment.dex: dexRouteParser,
18
+ firstUriSegment.bridge: bridgeRouteParser,
19
+ firstUriSegment.nfts: nftRouteParser,
20
+ firstUriSegment.settings: settingsRouteParser,
21
+ };
26
22
27
23
@override
28
24
Future <AppRoutePath > parseRouteInformation (
29
25
RouteInformation routeInformation) async {
30
- final BaseRouteParser parser =
31
- _getRoutParser (Uri . parse (routeInformation. uri.path) );
26
+ final uri = Uri . parse (routeInformation.uri.path);
27
+ final BaseRouteParser parser = _getRoutParser (uri);
32
28
33
- return parser.getRoutePath (routeInformation. uri);
29
+ return parser.getRoutePath (uri);
34
30
}
35
31
36
32
@override
@@ -39,7 +35,10 @@ class RootRouteInformationParser extends RouteInformationParser<AppRoutePath> {
39
35
}
40
36
41
37
BaseRouteParser _getRoutParser (Uri uri) {
42
- if (uri.pathSegments.isEmpty) return dexRouteParser;
43
- return _parsers[uri.pathSegments.first] ?? dexRouteParser;
38
+ const defaultRouteParser =
39
+ kIsWalletOnly ? walletRouteParser : dexRouteParser;
40
+
41
+ if (uri.pathSegments.isEmpty) return defaultRouteParser;
42
+ return _parsers[uri.pathSegments.first] ?? defaultRouteParser;
44
43
}
45
44
}
0 commit comments