Compare commits
2 Commits
828d259e2c
...
03c2cd813d
Author | SHA1 | Date |
---|---|---|
majestrate | 03c2cd813d | |
frtget | fd8a35bbe6 |
|
@ -1,15 +1,19 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:lokinet_lib/lokinet_lib.dart';
|
import 'package:lokinet_lib/lokinet_lib.dart';
|
||||||
|
import 'package:lokinet_mobile/src/settings.dart';
|
||||||
import 'package:lokinet_mobile/src/utils/is_dakmode.dart';
|
import 'package:lokinet_mobile/src/utils/is_dakmode.dart';
|
||||||
import 'package:lokinet_mobile/src/widget/lokinet_divider.dart';
|
import 'package:lokinet_mobile/src/widget/lokinet_divider.dart';
|
||||||
import 'package:lokinet_mobile/src/widget/lokinet_power_button.dart';
|
import 'package:lokinet_mobile/src/widget/lokinet_power_button.dart';
|
||||||
import 'package:lokinet_mobile/src/widget/themed_lokinet_logo.dart';
|
import 'package:lokinet_mobile/src/widget/themed_lokinet_logo.dart';
|
||||||
|
|
||||||
void main() {
|
void main() async {
|
||||||
|
//Load settings
|
||||||
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
await Settings.getInstance().initialize();
|
||||||
|
|
||||||
runApp(LokinetApp());
|
runApp(LokinetApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,14 +65,17 @@ class LokinetHomePageState extends State<LokinetHomePage> {
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
key: key,
|
key: key,
|
||||||
|
resizeToAvoidBottomInset:
|
||||||
|
false, //Prevents overflow when keyboard is shown
|
||||||
body: Container(
|
body: Container(
|
||||||
color: darkModeOn ? Colors.black : Colors.white,
|
color: darkModeOn ? Colors.black : Colors.white,
|
||||||
child: Column(children: [ThemedLokinetLogo(), MyForm()])));
|
child: Column(children: [ThemedLokinetLogo(), MyForm()])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final exitInput = TextEditingController();
|
final exitInput = TextEditingController(text: Settings.getInstance().exitNode);
|
||||||
final dnsInput = TextEditingController();
|
final dnsInput =
|
||||||
|
TextEditingController(text: Settings.getInstance().upstreamDNS);
|
||||||
|
|
||||||
// Create a Form widget.
|
// Create a Form widget.
|
||||||
class MyForm extends StatefulWidget {
|
class MyForm extends StatefulWidget {
|
||||||
|
@ -110,12 +117,15 @@ class MyFormState extends State<MyForm> {
|
||||||
await LokinetLib.disconnectFromLokinet();
|
await LokinetLib.disconnectFromLokinet();
|
||||||
await _cancelTimer();
|
await _cancelTimer();
|
||||||
} else {
|
} else {
|
||||||
final String exitNode = exitInput.value.text.trim();
|
//Save the exit node and upstream dns
|
||||||
final String upstreamDNS = dnsInput.value.text.trim();
|
final Settings settings = Settings.getInstance();
|
||||||
|
settings.exitNode = exitInput.value.text.trim();
|
||||||
|
settings.upstreamDNS = dnsInput.value.text.trim();
|
||||||
|
|
||||||
final result = await LokinetLib.prepareConnection();
|
final result = await LokinetLib.prepareConnection();
|
||||||
if (result)
|
if (result)
|
||||||
LokinetLib.connectToLokinet(
|
LokinetLib.connectToLokinet(
|
||||||
exitNode: exitNode, upstreamDNS: upstreamDNS);
|
exitNode: settings.exitNode, upstreamDNS: settings.upstreamDNS);
|
||||||
_startTimer();
|
_startTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class Settings {
|
||||||
|
static Settings _instance;
|
||||||
|
String _exitNode;
|
||||||
|
String _upstreamDNS;
|
||||||
|
|
||||||
|
Settings._();
|
||||||
|
|
||||||
|
Future<void> initialize() async {
|
||||||
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
|
||||||
|
this._exitNode = sharedPreferences.getString("exit-node");
|
||||||
|
this._upstreamDNS = sharedPreferences.getString("upstream-dns");
|
||||||
|
}
|
||||||
|
|
||||||
|
String get exitNode => this._exitNode;
|
||||||
|
|
||||||
|
set exitNode(String exitNode) {
|
||||||
|
this._exitNode = exitNode;
|
||||||
|
SharedPreferences.getInstance().then((sharedPreferences) =>
|
||||||
|
sharedPreferences.setString("exit-node", exitNode));
|
||||||
|
}
|
||||||
|
|
||||||
|
String get upstreamDNS => this._upstreamDNS;
|
||||||
|
|
||||||
|
set upstreamDNS(String upstreamDNS) {
|
||||||
|
this._upstreamDNS = upstreamDNS;
|
||||||
|
SharedPreferences.getInstance().then((sharedPreferences) =>
|
||||||
|
sharedPreferences.setString("upstream-dns", upstreamDNS));
|
||||||
|
}
|
||||||
|
|
||||||
|
static Settings getInstance() {
|
||||||
|
if (Settings._instance == null) {
|
||||||
|
Settings._instance = new Settings._();
|
||||||
|
}
|
||||||
|
return Settings._instance;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,49 +7,49 @@ packages:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.0-nullsafety.1"
|
version: "2.8.2"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: boolean_selector
|
name: boolean_selector
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.1"
|
version: "2.1.0"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0-nullsafety.3"
|
version: "1.2.0"
|
||||||
charcode:
|
charcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0-nullsafety.1"
|
version: "1.3.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0-nullsafety.1"
|
version: "1.1.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0-nullsafety.3"
|
version: "1.15.0"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0-nullsafety.1"
|
version: "1.2.0"
|
||||||
ffi:
|
ffi:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -87,21 +87,21 @@ packages:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.10-nullsafety.1"
|
version: "0.12.11"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0-nullsafety.3"
|
version: "1.7.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0-nullsafety.1"
|
version: "1.8.0"
|
||||||
path_provider:
|
path_provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -169,56 +169,56 @@ packages:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0-nullsafety.2"
|
version: "1.8.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0-nullsafety.1"
|
version: "1.10.0"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.1"
|
version: "2.1.0"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0-nullsafety.1"
|
version: "1.1.0"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0-nullsafety.1"
|
version: "1.2.0"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.19-nullsafety.2"
|
version: "0.4.3"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: typed_data
|
name: typed_data
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0-nullsafety.3"
|
version: "1.3.0"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0-nullsafety.3"
|
version: "2.1.1"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -234,5 +234,5 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.2"
|
version: "0.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.10.0-110 <2.11.0"
|
dart: ">=2.14.0 <3.0.0"
|
||||||
flutter: ">=1.20.0 <2.0.0"
|
flutter: ">=1.20.0"
|
||||||
|
|
Loading…
Reference in New Issue