2021-04-01 23:45:12 +02:00
|
|
|
// Copyright (C) 2020 Axiom-Team.
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2021-02-22 08:49:29 +01:00
|
|
|
import 'dart:async';
|
2021-02-27 20:29:35 +01:00
|
|
|
import 'package:flutter/services.dart';
|
2021-01-26 21:00:26 +01:00
|
|
|
import 'package:gecko/globals.dart';
|
2021-02-02 20:33:09 +01:00
|
|
|
import 'package:gecko/models/cesiumPlus.dart';
|
2021-02-08 13:36:50 +01:00
|
|
|
import 'package:gecko/models/changePin.dart';
|
2021-01-26 21:00:26 +01:00
|
|
|
import 'package:gecko/models/generateWallets.dart';
|
2021-01-23 16:38:03 +01:00
|
|
|
import 'package:gecko/models/history.dart';
|
2021-01-26 21:00:26 +01:00
|
|
|
import 'package:gecko/models/home.dart';
|
2021-01-23 16:38:03 +01:00
|
|
|
import 'package:gecko/models/myWallets.dart';
|
2021-01-28 15:10:09 +01:00
|
|
|
import 'package:gecko/models/walletOptions.dart';
|
2021-01-28 15:26:26 +01:00
|
|
|
import 'package:gecko/screens/home.dart';
|
2020-12-13 05:43:52 +01:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2021-03-06 22:26:30 +01:00
|
|
|
import 'package:gecko/screens/myWallets/walletsHome.dart';
|
2020-12-21 03:59:25 +01:00
|
|
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
2021-09-12 07:15:51 +02:00
|
|
|
import 'package:hive/hive.dart';
|
2021-01-23 16:38:03 +01:00
|
|
|
import 'package:provider/provider.dart';
|
2021-01-06 21:17:01 +01:00
|
|
|
import 'package:flutter/foundation.dart';
|
2021-02-28 18:28:43 +01:00
|
|
|
import 'package:responsive_framework/responsive_framework.dart';
|
2021-01-30 15:24:08 +01:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2021-02-18 04:42:57 +01:00
|
|
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
2020-12-18 23:54:43 +01:00
|
|
|
|
2021-02-18 04:42:57 +01:00
|
|
|
final bool enableSentry = true;
|
2021-01-11 19:13:28 +01:00
|
|
|
|
2021-01-06 05:04:54 +01:00
|
|
|
Future<void> main() async {
|
2021-02-18 07:54:35 +01:00
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2021-01-26 21:00:26 +01:00
|
|
|
|
2021-02-18 07:54:35 +01:00
|
|
|
HomeProvider _homeProvider = HomeProvider();
|
2021-03-11 07:08:45 +01:00
|
|
|
MyWalletsProvider _walletsProvider = MyWalletsProvider();
|
2021-02-18 07:54:35 +01:00
|
|
|
await _homeProvider.getAppPath();
|
|
|
|
await _homeProvider.createDefaultAvatar();
|
2021-03-19 06:33:48 +01:00
|
|
|
await _walletsProvider.initWalletFolder();
|
2021-04-04 15:35:38 +02:00
|
|
|
// _walletsProvider.getDefaultWallet();
|
2021-02-18 07:54:35 +01:00
|
|
|
appVersion = await _homeProvider.getAppVersion();
|
|
|
|
prefs = await SharedPreferences.getInstance();
|
2021-09-12 07:15:51 +02:00
|
|
|
|
|
|
|
Hive.init(appPath.path);
|
|
|
|
await Hive.openBox("walletBox");
|
|
|
|
|
2021-03-21 23:04:11 +01:00
|
|
|
// final HiveStore _store =
|
|
|
|
// await HiveStore.open(path: '${appPath.path}/gqlCache');
|
2021-01-26 21:00:26 +01:00
|
|
|
|
2021-02-18 07:54:35 +01:00
|
|
|
// Get a valid GVA endpoint
|
2021-09-12 07:12:24 +02:00
|
|
|
endPointGVA = 'https://g1.librelois.fr/gva';
|
|
|
|
// await _homeProvider.getValidEndpoint();
|
2021-02-18 04:42:57 +01:00
|
|
|
|
2021-09-12 06:47:50 +02:00
|
|
|
// if (endPointGVA == 'HS') {
|
|
|
|
// _homeProvider.playSound('faché', 0.8);
|
|
|
|
// } else {
|
|
|
|
// _homeProvider.playSound('start', 0.2);
|
|
|
|
// }
|
2021-04-04 21:17:29 +02:00
|
|
|
|
2021-02-18 07:54:35 +01:00
|
|
|
if (kReleaseMode && enableSentry) {
|
2021-02-22 08:49:29 +01:00
|
|
|
// CatcherOptions debugOptions = CatcherOptions(DialogReportMode(), [
|
|
|
|
// SentryHandler(SentryClient(SentryOptions(
|
|
|
|
// dsn:
|
|
|
|
// "https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110")))
|
2021-02-18 07:54:35 +01:00
|
|
|
// ]);
|
2021-02-22 08:49:29 +01:00
|
|
|
// // CatcherOptions releaseOptions = CatcherOptions(NotificationReportMode(), [
|
|
|
|
// // EmailManualHandler(["poka@p2p.legal"])
|
|
|
|
// // ]);
|
|
|
|
// Catcher(rootWidget: Gecko(endPointGVA, _store), debugConfig: debugOptions);
|
|
|
|
|
|
|
|
await SentryFlutter.init((options) {
|
|
|
|
options.dsn =
|
|
|
|
'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110';
|
2021-03-21 23:04:11 +01:00
|
|
|
}, appRunner: () => runApp(Gecko(endPointGVA)));
|
2021-02-18 04:42:57 +01:00
|
|
|
|
2021-02-22 08:49:29 +01:00
|
|
|
// runZoned<Future<void>>(
|
|
|
|
// () async {
|
|
|
|
// runApp(Gecko(endPointGVA, _store));
|
|
|
|
// },
|
|
|
|
// onError: (dynamic error, StackTrace stackTrace) {
|
|
|
|
// print("=================== CAUGHT DART ERROR");
|
|
|
|
// // Sentry.captureException(
|
|
|
|
// // error,
|
|
|
|
// // stackTrace: stackTrace,
|
|
|
|
// // );
|
|
|
|
// },
|
|
|
|
// ));
|
2021-02-18 07:54:35 +01:00
|
|
|
} else {
|
|
|
|
print('Debug mode enabled: No sentry alerte');
|
2021-02-18 04:42:57 +01:00
|
|
|
|
2021-03-21 23:04:11 +01:00
|
|
|
runApp(Gecko(endPointGVA));
|
2021-01-06 21:17:01 +01:00
|
|
|
}
|
2021-01-06 05:04:54 +01:00
|
|
|
}
|
2020-12-13 05:43:52 +01:00
|
|
|
|
2020-12-21 01:05:00 +01:00
|
|
|
class Gecko extends StatelessWidget {
|
2021-03-21 23:04:11 +01:00
|
|
|
Gecko(this.randomEndpoint);
|
2021-01-11 19:13:28 +01:00
|
|
|
final String randomEndpoint;
|
|
|
|
|
2020-12-13 05:43:52 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-02-27 20:29:35 +01:00
|
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
2020-12-21 03:59:25 +01:00
|
|
|
final _httpLink = HttpLink(
|
2021-01-11 19:13:28 +01:00
|
|
|
randomEndpoint,
|
2020-12-21 03:59:25 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
final _client = ValueNotifier(
|
|
|
|
GraphQLClient(
|
2021-03-21 23:04:11 +01:00
|
|
|
cache: GraphQLCache(),
|
2020-12-21 03:59:25 +01:00
|
|
|
link: _httpLink,
|
|
|
|
),
|
|
|
|
);
|
2021-02-18 04:42:57 +01:00
|
|
|
|
2021-02-22 08:49:29 +01:00
|
|
|
// HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
|
|
|
|
// HistoryProvider('').snackNode(context);
|
2021-01-28 15:10:09 +01:00
|
|
|
return MultiProvider(
|
|
|
|
providers: [
|
|
|
|
// Provider(create: (context) => HistoryProvider()),
|
|
|
|
ChangeNotifierProvider(create: (_) => HomeProvider()),
|
|
|
|
ChangeNotifierProvider(create: (_) => HistoryProvider('')),
|
|
|
|
ChangeNotifierProvider(create: (_) => MyWalletsProvider()),
|
|
|
|
ChangeNotifierProvider(create: (_) => GenerateWalletsProvider()),
|
2021-02-02 20:33:09 +01:00
|
|
|
ChangeNotifierProvider(create: (_) => WalletOptionsProvider()),
|
2021-02-08 13:36:50 +01:00
|
|
|
ChangeNotifierProvider(create: (_) => ChangePinProvider()),
|
2021-02-02 20:33:09 +01:00
|
|
|
ChangeNotifierProvider(create: (_) => CesiumPlusProvider())
|
2021-01-28 15:10:09 +01:00
|
|
|
],
|
|
|
|
child: GraphQLProvider(
|
2021-02-28 18:28:43 +01:00
|
|
|
client: _client,
|
|
|
|
child: MaterialApp(
|
|
|
|
builder: (context, widget) => ResponsiveWrapper.builder(
|
|
|
|
BouncingScrollWrapper.builder(context, widget),
|
|
|
|
maxWidth: 1200,
|
|
|
|
minWidth: 480,
|
|
|
|
defaultScale: true,
|
|
|
|
breakpoints: [
|
|
|
|
ResponsiveBreakpoint.resize(480, name: MOBILE),
|
|
|
|
ResponsiveBreakpoint.autoScale(800, name: TABLET),
|
|
|
|
ResponsiveBreakpoint.resize(1000, name: DESKTOP),
|
|
|
|
],
|
|
|
|
background: Container(color: Color(0xFFF5F5F5))),
|
|
|
|
title: 'Ğecko',
|
|
|
|
theme: ThemeData(
|
2021-11-06 20:19:27 +01:00
|
|
|
appBarTheme: AppBarTheme(
|
|
|
|
color: const Color(0xffFFD58D),
|
|
|
|
foregroundColor: const Color(0xFF000000),
|
|
|
|
),
|
2021-02-28 18:28:43 +01:00
|
|
|
primaryColor: Color(0xffFFD58D),
|
|
|
|
textTheme: TextTheme(
|
|
|
|
bodyText1: TextStyle(),
|
|
|
|
bodyText2: TextStyle(),
|
|
|
|
).apply(
|
|
|
|
bodyColor: Color(0xff855F2D),
|
2021-01-24 08:53:03 +01:00
|
|
|
),
|
2021-09-12 06:52:18 +02:00
|
|
|
colorScheme: ColorScheme.fromSwatch()
|
|
|
|
.copyWith(secondary: Colors.grey[850]),
|
2021-02-28 18:28:43 +01:00
|
|
|
),
|
|
|
|
home: HomeScreen(),
|
|
|
|
initialRoute: "/",
|
2021-03-06 22:26:30 +01:00
|
|
|
routes: {
|
|
|
|
'/mywallets': (context) => WalletsHome(),
|
|
|
|
},
|
2021-02-28 18:28:43 +01:00
|
|
|
),
|
|
|
|
));
|
2020-12-13 05:43:52 +01:00
|
|
|
}
|
|
|
|
}
|