diff --git a/README.md b/README.md index 9f0b4165..6f9e5903 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,6 @@ If you own a Threefold node, you can manage your farm here. If you have Threefold related questions, we provide a support chat where we will answer your questions as soon as possible! -### Planetary network - -It is possible to have a a planetary network IPv6 address. Here you can enable the planetary network connection and your phone will automatically be connected to the p2p network. ### Identity diff --git a/app/lib/events/go_planetary_event.dart b/app/lib/events/go_planetary_event.dart deleted file mode 100644 index 5463d192..00000000 --- a/app/lib/events/go_planetary_event.dart +++ /dev/null @@ -1,3 +0,0 @@ -class GoPlanetaryEvent { - GoPlanetaryEvent(); -} diff --git a/app/lib/jrouter.dart b/app/lib/jrouter.dart index 4f9fea35..d7eafdcd 100644 --- a/app/lib/jrouter.dart +++ b/app/lib/jrouter.dart @@ -3,7 +3,6 @@ import 'package:threebotlogin/app.dart'; import 'package:threebotlogin/apps/chatbot/chatbot.dart'; import 'package:threebotlogin/apps/wallet/wallet.dart'; import 'package:threebotlogin/screens/identity_verification_screen.dart'; -import 'package:threebotlogin/screens/planetary_network_screen.dart'; import 'package:threebotlogin/screens/preference_screen.dart'; import 'package:threebotlogin/screens/registered_screen.dart'; @@ -70,14 +69,6 @@ class JRouter { // view: ReservationScreen(), // ), // app: null), - AppInfo( - route: Route( - path: '/planetary', - name: 'Planetary Network', - icon: Icons.network_check, - view: PlanetaryNetworkScreen(), - ), - app: null), AppInfo( route: Route( path: '/settings', diff --git a/app/lib/screens/planetary_network_screen.dart b/app/lib/screens/planetary_network_screen.dart deleted file mode 100644 index 586e1119..00000000 --- a/app/lib/screens/planetary_network_screen.dart +++ /dev/null @@ -1,222 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:threebotlogin/helpers/globals.dart'; -import 'package:threebotlogin/helpers/vpn_state.dart'; -import 'package:threebotlogin/services/shared_preference_service.dart'; -import 'package:threebotlogin/widgets/layout_drawer.dart'; -import 'package:yggdrasil_plugin/yggdrasil_plugin.dart'; - -class PlanetaryNetworkScreen extends StatefulWidget { - @override - _PlanetaryNetworkScreenState createState() => _PlanetaryNetworkScreenState(); -} - -class _PlanetaryNetworkScreenState extends State { - VpnState _vpnState = new VpnState(); - bool _vpnTimeoutRunning = false; - - String _ipAddress = ''; - Text _statusMessage = Text(''); - - bool isDoneConnecting = false; - - bool _isSwitched = Globals().vpnState.vpnConnected; - - void reportIp(String ip) { - print('RECEVING DATA IN REPORT IP'); - print(ip); - _vpnState.ipAddress = ip; - isDoneConnecting = true; - setState(() {}); - } - - _PlanetaryNetworkScreenState() { - _vpnState = Globals().vpnState; - initPlatformState(); - _vpnState.plugin.setOnReportIp(reportIp); - } - - // Platform messages are asynchronous, so we initialize in an async method. - Future initPlatformState() async { - String platformVersion; - platformVersion = await _vpnState.plugin.platformVersion(); - } - - @override - void initState() { - super.initState(); - - setState(() { - if (_vpnState.vpnConnected) { - print(_vpnState.ipAddress); - - _ipAddress = "IP Address: " + _vpnState.ipAddress; - _statusMessage = - new Text('Connected', style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold, fontSize: 16)); - return; - } - _ipAddress = ''; - _statusMessage = - new Text('Not Connected', style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold, fontSize: 16)); - }); - } - - @override - Widget build(BuildContext context) { - return LayoutDrawer( - titleText: 'Planetary Network', - content: Stack( - children: [ - SvgPicture.asset( - 'assets/bg.svg', - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - ), - Column( - children: [ - Container( - height: 200, - width: MediaQuery.of(context).size.width, - child: Image.asset('assets/planetary-network.png'), - ), - Text('Planetary Network', style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 24)), - Padding( - padding: const EdgeInsets.only(top: 20, left: 40, right: 40), - child: Text( - "Enable to connect to ThreeFold's secure network", - style: const TextStyle(fontSize: 14)), - ), - Padding( - padding: const EdgeInsets.only(left: 40, right: 40, top: 20), - child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - _statusMessage, - Switch( - value: _isSwitched, - // If the user spams the button, the application would crash => use a timeout - onChanged: _vpnTimeoutRunning - ? null - : (value) async { - // Check status => if connected early return - if (_vpnState.vpnConnected) { - return disconnectVpn(); - } - - connectingVpnmessage(); - bool isVPNConnectionStarted = await _vpnState.plugin.startVpn(await getEdCurveKeys()); - - if (!isVPNConnectionStarted) { - return askForVpnPermissions(); - } - - await connectVpn(); - }, - - activeColor: Theme.of(context).primaryColorDark, - ), - ]), - ), - new GestureDetector( - onTap: () async { - if (_vpnState.ipAddress != "") { - Clipboard.setData(new ClipboardData(text: _vpnState.ipAddress)); - - final snackBar = SnackBar( - content: Text('Address copied to clipboard'), - ); - - ScaffoldMessenger.of(context).showSnackBar(snackBar); - } - }, - child: Text(_ipAddress), - ), - ], - ) - ], - ), - ); - } - - void disconnectingVpnMessage() { - _ipAddress = ''; - _vpnTimeoutRunning = true; - _statusMessage = new Text('Disconnecting ...', - style: TextStyle(color: Colors.orange, fontWeight: FontWeight.bold, fontSize: 16)); - - setState(() {}); - } - - void connectingVpnmessage() { - _ipAddress = ''; - _vpnTimeoutRunning = true; - _statusMessage = - new Text('Connecting ...', style: TextStyle(color: Colors.orange, fontWeight: FontWeight.bold, fontSize: 16)); - - setState(() {}); - } - - void disconnectVpn() { - _ipAddress = ''; - _vpnTimeoutRunning = true; - _statusMessage = new Text('Disconnecting ...', - style: TextStyle(color: Colors.orange, fontWeight: FontWeight.bold, fontSize: 16)); - - setState(() {}); - - _vpnState.plugin.stopVpn(); - _vpnState.vpnConnected = false; - _vpnState.plugin = new YggdrasilPlugin(); - _ipAddress = ''; - _isSwitched = false; - - _vpnTimeoutRunning = false; - _statusMessage = - new Text('Not connected', style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold, fontSize: 16)); - - setState(() {}); - } - - void askForVpnPermissions() { - _ipAddress = "Please click connect again after accepting VPN permissions."; - _isSwitched = false; - _vpnTimeoutRunning = false; - _statusMessage = - new Text('Not connected', style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold, fontSize: 16)); - - setState(() {}); - } - - Future connectVpn() async { - _vpnTimeoutRunning = true; - _statusMessage = - new Text('Connecting ...', style: TextStyle(color: Colors.orange, fontWeight: FontWeight.bold, fontSize: 16)); - - setState(() {}); - - connectToYggDrasil(); - } - - Future connectToYggDrasil() async { - int counter = 0; - - while (isDoneConnecting == false && counter <= 10) { - await Future.delayed(Duration(seconds: 1)); - counter++; - setState(() {}); - } - - if (isDoneConnecting == true) { - isDoneConnecting = false; - _vpnTimeoutRunning = false; - _isSwitched = true; - _statusMessage = - new Text('Connected', style: TextStyle(color: Colors.green, fontWeight: FontWeight.bold, fontSize: 16)); - _ipAddress = 'IP Address: ' + _vpnState.ipAddress; - setState(() {}); - _vpnState.vpnConnected = true; - } else { - disconnectVpn(); - } - } -} diff --git a/app/lib/screens/preference_screen.dart b/app/lib/screens/preference_screen.dart index 74fb1e11..65fc9e74 100644 --- a/app/lib/screens/preference_screen.dart +++ b/app/lib/screens/preference_screen.dart @@ -5,7 +5,6 @@ import 'package:package_info_plus/package_info_plus.dart'; import 'package:threebotlogin/app_config.dart'; import 'package:threebotlogin/apps/free_flow_pages/ffp_events.dart'; import 'package:threebotlogin/events/close_socket_event.dart'; -import 'package:threebotlogin/events/close_vpn_event.dart'; import 'package:threebotlogin/events/events.dart'; import 'package:threebotlogin/helpers/environment.dart'; import 'package:threebotlogin/helpers/globals.dart'; @@ -259,7 +258,6 @@ class _PreferenceScreenState extends State { // } catch (e) {} Events().emit(CloseSocketEvent()); Events().emit(FfpClearCacheEvent()); - Events().emit(CloseVpnEvent()); bool result = await clearData(); if (result) { Navigator.pop(context); diff --git a/app/lib/widgets/layout_drawer.dart b/app/lib/widgets/layout_drawer.dart index 1a5abd63..04fc6719 100644 --- a/app/lib/widgets/layout_drawer.dart +++ b/app/lib/widgets/layout_drawer.dart @@ -148,24 +148,6 @@ class _LayoutDrawerState extends State { // globals.tabController.animateTo(4); // }, // ), - if (Globals().isYggdrasilEnabled) - ListTile( - minLeadingWidth: 10, - leading: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Padding(padding: const EdgeInsets.only(left: 30)), - Icon(Icons.network_check, color: Colors.black, size: 18) - ], - ), - title: Text('Planetary Network'), - onTap: () { - Navigator.pop(context); - globals.tabController.animateTo(5); - }, - ) - else - Container(), ListTile( minLeadingWidth: 10, leading: Column( diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 5d1c9dd5..445a4928 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -12,11 +12,6 @@ dependencies: flutter: sdk: flutter - yggdrasil_plugin: - git: - url: https://github.com/threefoldtech/planetary_network_flutter - ref: main - flutter_pkid: git: url: https://github.com/threefoldtech/threefold_connect_flutter_pkid_client