2019-06-29 22:56:11 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
2019-07-04 21:45:05 +00:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
2019-07-11 06:32:17 +00:00
|
|
|
import 'repositories/grpc_credentials_client.dart';
|
|
|
|
import 'repositories/secure_storage_config.dart';
|
2019-06-29 22:56:11 +00:00
|
|
|
|
|
|
|
import 'screens/authentication.dart';
|
2019-07-07 04:14:09 +00:00
|
|
|
import 'screens/credential.dart';
|
2019-06-29 22:56:11 +00:00
|
|
|
import 'screens/credentials.dart';
|
2019-07-05 09:15:57 +00:00
|
|
|
import 'screens/config.dart';
|
2019-07-04 21:45:05 +00:00
|
|
|
import 'screens/home.dart';
|
|
|
|
|
|
|
|
import 'types/abstracts.dart';
|
2019-07-07 04:14:09 +00:00
|
|
|
import 'types/screen_arguments.dart';
|
2019-06-29 22:56:11 +00:00
|
|
|
|
|
|
|
void main() => runApp(Selfpass());
|
|
|
|
|
|
|
|
class Selfpass extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2019-07-04 21:45:05 +00:00
|
|
|
return Provider<ConfigRepo>(
|
2019-07-11 06:32:17 +00:00
|
|
|
builder: (BuildContext context) => SecureStorageConfig(),
|
2019-07-04 21:45:05 +00:00
|
|
|
child: CupertinoApp(
|
|
|
|
title: 'Selfpass',
|
|
|
|
onGenerateRoute: (RouteSettings settings) {
|
|
|
|
String title;
|
|
|
|
WidgetBuilder builder;
|
|
|
|
|
|
|
|
switch (settings.name) {
|
|
|
|
case '/':
|
|
|
|
title = 'Authentication';
|
|
|
|
builder = (BuildContext context) => Authentication();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/home':
|
2019-07-07 04:14:09 +00:00
|
|
|
title = 'Hosts';
|
2019-07-04 21:45:05 +00:00
|
|
|
builder = (BuildContext context) => Provider<CredentialsRepo>(
|
|
|
|
builder: (BuildContext context) =>
|
2019-07-11 06:32:17 +00:00
|
|
|
GRPCCredentialsClient.cached(config: settings.arguments),
|
2019-07-04 21:45:05 +00:00
|
|
|
child: Home(),
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/credentials':
|
2019-07-05 09:15:57 +00:00
|
|
|
title = 'Credentials';
|
2019-07-07 04:14:09 +00:00
|
|
|
builder = (BuildContext context) => Provider<CredentialsRepo>(
|
|
|
|
builder: (BuildContext context) =>
|
2019-07-11 06:32:17 +00:00
|
|
|
GRPCCredentialsClient.cached(),
|
2019-07-07 04:14:09 +00:00
|
|
|
child: Credentials(settings.arguments),
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '/credential':
|
|
|
|
title = 'Credential';
|
|
|
|
builder = (BuildContext context) => Provider<CredentialsRepo>(
|
|
|
|
builder: (BuildContext context) =>
|
2019-07-11 06:32:17 +00:00
|
|
|
GRPCCredentialsClient.cached(),
|
2019-07-07 04:14:09 +00:00
|
|
|
child: Credential(settings.arguments),
|
|
|
|
);
|
2019-07-04 21:45:05 +00:00
|
|
|
break;
|
2019-07-05 09:15:57 +00:00
|
|
|
|
|
|
|
case '/config':
|
2019-07-09 02:03:44 +00:00
|
|
|
final ConfigScreenArguments arguments = settings.arguments == null
|
|
|
|
? ConfigScreenArguments()
|
|
|
|
: settings.arguments;
|
2019-07-11 06:32:17 +00:00
|
|
|
|
2019-07-05 09:15:57 +00:00
|
|
|
title = 'Configuration';
|
2019-07-07 04:14:09 +00:00
|
|
|
builder = (BuildContext context) =>
|
|
|
|
Config(arguments.connectionConfig, arguments.privateKey);
|
2019-07-05 09:15:57 +00:00
|
|
|
break;
|
2019-07-04 21:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return CupertinoPageRoute(builder: builder, title: title);
|
|
|
|
},
|
|
|
|
),
|
2019-06-29 22:56:11 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|