mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-23 02:54:30 +00:00
tap the onion to connect/disconnect
This commit is contained in:
parent
50466ff509
commit
f53bd53af4
1 changed files with 76 additions and 31 deletions
|
@ -17,6 +17,7 @@ import 'package:stackwallet/services/tor_service.dart';
|
||||||
import 'package:stackwallet/themes/stack_colors.dart';
|
import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
|
@ -41,40 +42,84 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
|
||||||
Widget _buildTorIcon(TorConnectionStatus status) {
|
Widget _buildTorIcon(TorConnectionStatus status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case TorConnectionStatus.disconnected:
|
case TorConnectionStatus.disconnected:
|
||||||
return Stack(
|
return GestureDetector(
|
||||||
|
child: Stack(
|
||||||
alignment: AlignmentDirectional.center,
|
alignment: AlignmentDirectional.center,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
Assets.svg.tor,
|
Assets.svg.tor,
|
||||||
color: Theme.of(context).extension<StackColors>()!.textSubtitle3,
|
color:
|
||||||
|
Theme.of(context).extension<StackColors>()!.textSubtitle3,
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 200,
|
height: 200,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"CONNECT",
|
"CONNECT",
|
||||||
style: STextStyles.smallMed14(context).copyWith(
|
style: STextStyles.smallMed14(context).copyWith(
|
||||||
color: Theme.of(context).extension<StackColors>()!.popupBG),
|
color:
|
||||||
|
Theme.of(context).extension<StackColors>()!.popupBG),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
// Init the Tor service if it hasn't already been.
|
||||||
|
ref.read(pTorService).init();
|
||||||
|
|
||||||
|
// Start the Tor service.
|
||||||
|
try {
|
||||||
|
await ref.read(pTorService).start();
|
||||||
|
|
||||||
|
// Toggle the useTor preference on success.
|
||||||
|
ref.read(prefsChangeNotifierProvider).useTor = true;
|
||||||
|
} catch (e, s) {
|
||||||
|
Logging.instance.log(
|
||||||
|
"Error starting tor: $e\n$s",
|
||||||
|
level: LogLevel.Error,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
_networkStatus = TorConnectionStatus.connecting;
|
||||||
|
});
|
||||||
|
});
|
||||||
case TorConnectionStatus.connected:
|
case TorConnectionStatus.connected:
|
||||||
return Stack(
|
return GestureDetector(
|
||||||
|
child: Stack(
|
||||||
alignment: AlignmentDirectional.center,
|
alignment: AlignmentDirectional.center,
|
||||||
children: [
|
children: [
|
||||||
SvgPicture.asset(
|
SvgPicture.asset(
|
||||||
Assets.svg.tor,
|
Assets.svg.tor,
|
||||||
color:
|
color: Theme.of(context)
|
||||||
Theme.of(context).extension<StackColors>()!.accentColorGreen,
|
.extension<StackColors>()!
|
||||||
|
.accentColorGreen,
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 200,
|
height: 200,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"CONNECTED",
|
"CONNECTED",
|
||||||
style: STextStyles.smallMed14(context).copyWith(
|
style: STextStyles.smallMed14(context).copyWith(
|
||||||
color: Theme.of(context).extension<StackColors>()!.popupBG),
|
color:
|
||||||
|
Theme.of(context).extension<StackColors>()!.popupBG),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
),
|
||||||
|
onTap: () async {
|
||||||
|
// Init the Tor service if it hasn't already been.
|
||||||
|
ref.read(pTorService).init();
|
||||||
|
|
||||||
|
// Start the Tor service.
|
||||||
|
try {
|
||||||
|
await ref.read(pTorService).start();
|
||||||
|
|
||||||
|
// Toggle the useTor preference on success.
|
||||||
|
ref.read(prefsChangeNotifierProvider).useTor = true;
|
||||||
|
} catch (e, s) {
|
||||||
|
Logging.instance.log(
|
||||||
|
"Error starting tor: $e\n$s",
|
||||||
|
level: LogLevel.Error,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
case TorConnectionStatus.connecting:
|
case TorConnectionStatus.connecting:
|
||||||
return Stack(
|
return Stack(
|
||||||
alignment: AlignmentDirectional.center,
|
alignment: AlignmentDirectional.center,
|
||||||
|
|
Loading…
Reference in a new issue