Merge branch 'tor-ui' into arti

This commit is contained in:
sneurlax 2023-09-07 13:12:25 -05:00
commit 796961ddd4
19 changed files with 887 additions and 2 deletions

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.1 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,5 @@
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="48" height="48" rx="24" fill="#E0E3E3"/>
<path d="M19.0284 34.8483C18.826 35.4564 19.1553 36.1134 19.7627 36.3159C19.884 36.3565 20.0097 36.3759 20.1306 36.3759C20.6169 36.3759 21.0689 36.0685 21.2318 35.5826L21.8017 33.8723C21.0171 33.7401 20.2679 33.5325 19.5553 33.27L19.0284 34.8483ZM28.9671 34.8483L28.4412 33.2695C27.7286 33.5322 26.9789 33.7398 26.1948 33.8718L26.7647 35.5821C26.9272 36.0665 27.3767 36.3759 27.865 36.3759C27.9858 36.3759 28.1097 36.357 28.232 36.3162C28.8414 36.1148 29.1266 35.4139 28.9671 34.8483ZM22.8376 34.0024V35.2157C22.8376 35.8586 23.3597 36.3759 23.9978 36.3759C24.6359 36.3759 25.1579 35.8562 25.1579 35.2157V34.0033C24.776 34.0362 24.3893 34.0555 23.9978 34.0555C23.6062 34.0555 23.2195 34.0362 22.8376 34.0024Z" fill="black"/>
<path d="M30.3295 18.0837C33.1429 19.7321 34.8203 22.4053 34.8203 25.2332C34.8203 30.0971 29.9622 34.0552 23.9922 34.0552C18.0222 34.0552 13.1641 30.0962 13.1641 25.2332C13.1641 22.4053 14.8439 19.7321 17.6568 18.0837C17.657 18.0836 17.6575 18.0833 17.6582 18.0828C17.7403 18.033 20.8389 16.1495 21.8067 12.2147C21.8744 11.9329 22.0951 11.7139 22.3776 11.6467C22.6532 11.5787 22.9529 11.6746 23.1414 11.8944L23.9922 12.8833L24.8449 11.8943C25.032 11.6745 25.3356 11.5785 25.6106 11.6465C25.893 11.7137 26.1135 11.9328 26.1815 12.2145C27.1555 16.1847 30.2978 18.0656 30.3295 18.0837Z" fill="black"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,4 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.31521 18.0367C6.16525 18.4871 6.4092 18.9737 6.85912 19.1238C6.949 19.1538 7.04209 19.1682 7.13161 19.1682C7.49183 19.1682 7.82663 18.9405 7.9473 18.5806L8.36947 17.3137C7.78832 17.2157 7.23331 17.062 6.70551 16.8675L6.31521 18.0367ZM13.6772 18.0367L13.2876 16.8672C12.7598 17.0618 12.2044 17.2156 11.6236 17.3133L12.0458 18.5802C12.1661 18.939 12.4991 19.1682 12.8608 19.1682C12.9503 19.1682 13.042 19.1542 13.1327 19.124C13.5841 18.9748 13.7953 18.4556 13.6772 18.0367ZM9.13682 17.41V18.3088C9.13682 18.785 9.52354 19.1682 9.9962 19.1682C10.4689 19.1682 10.8556 18.7832 10.8556 18.3088V17.4107C10.5727 17.4351 10.2862 17.4494 9.9962 17.4494C9.70616 17.4494 9.4197 17.4351 9.13682 17.41Z" fill="#00A578"/>
<path d="M14.6878 5.61724C16.7718 6.83827 18.0143 8.81841 18.0143 10.9131C18.0143 14.5161 14.4157 17.448 9.99349 17.448C5.57129 17.448 1.97266 14.5154 1.97266 10.9131C1.97266 8.81841 3.21696 6.83827 5.30059 5.61724C5.30078 5.61712 5.30113 5.61691 5.30164 5.6166C5.36244 5.57964 7.6577 4.18451 8.37464 1.26979C8.42477 1.0611 8.58827 0.898861 8.79753 0.849054C9.00163 0.798701 9.22363 0.869768 9.36328 1.03255L9.99349 1.76509L10.6251 1.03245C10.7637 0.869643 10.9886 0.798597 11.1923 0.848943C11.4015 0.898715 11.5649 1.06099 11.6152 1.26968C12.3367 4.21053 14.6643 5.60381 14.6878 5.61724Z" fill="#00A578"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,4 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.31521 18.0367C6.16525 18.4871 6.4092 18.9737 6.85912 19.1238C6.949 19.1538 7.04209 19.1682 7.13161 19.1682C7.49183 19.1682 7.82663 18.9405 7.9473 18.5806L8.36947 17.3137C7.78832 17.2157 7.23331 17.062 6.70551 16.8675L6.31521 18.0367ZM13.6772 18.0367L13.2876 16.8672C12.7598 17.0618 12.2044 17.2156 11.6236 17.3133L12.0458 18.5802C12.1661 18.939 12.4991 19.1682 12.8608 19.1682C12.9503 19.1682 13.042 19.1542 13.1327 19.124C13.5841 18.9748 13.7953 18.4556 13.6772 18.0367ZM9.13682 17.41V18.3088C9.13682 18.785 9.52354 19.1682 9.9962 19.1682C10.4689 19.1682 10.8556 18.7832 10.8556 18.3088V17.4107C10.5727 17.4351 10.2862 17.4494 9.9962 17.4494C9.70616 17.4494 9.4197 17.4351 9.13682 17.41Z" fill="#F4C517"/>
<path d="M14.6878 5.61724C16.7718 6.83827 18.0143 8.81841 18.0143 10.9131C18.0143 14.5161 14.4157 17.448 9.99349 17.448C5.57129 17.448 1.97266 14.5154 1.97266 10.9131C1.97266 8.81841 3.21696 6.83827 5.30059 5.61724C5.30078 5.61712 5.30113 5.61691 5.30164 5.6166C5.36244 5.57964 7.6577 4.18451 8.37464 1.26979C8.42477 1.0611 8.58827 0.898861 8.79753 0.849054C9.00163 0.798701 9.22363 0.869768 9.36328 1.03255L9.99349 1.76509L10.6251 1.03245C10.7637 0.869643 10.9886 0.798597 11.1923 0.848943C11.4015 0.898715 11.5649 1.06099 11.6152 1.26968C12.3367 4.21053 14.6643 5.60381 14.6878 5.61724Z" fill="#F4C517"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

4
assets/svg/tor.svg Normal file
View file

@ -0,0 +1,4 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.31521 18.0367C6.16525 18.4871 6.4092 18.9737 6.85912 19.1238C6.949 19.1538 7.04209 19.1682 7.13161 19.1682C7.49183 19.1682 7.82663 18.9405 7.9473 18.5806L8.36947 17.3137C7.78832 17.2157 7.23331 17.062 6.70551 16.8675L6.31521 18.0367ZM13.6772 18.0367L13.2876 16.8672C12.7598 17.0618 12.2044 17.2156 11.6236 17.3133L12.0458 18.5802C12.1661 18.939 12.4991 19.1682 12.8608 19.1682C12.9503 19.1682 13.042 19.1542 13.1327 19.124C13.5841 18.9748 13.7953 18.4556 13.6772 18.0367ZM9.13682 17.41V18.3088C9.13682 18.785 9.52354 19.1682 9.9962 19.1682C10.4689 19.1682 10.8556 18.7832 10.8556 18.3088V17.4107C10.5727 17.4351 10.2862 17.4494 9.9962 17.4494C9.70616 17.4494 9.4197 17.4351 9.13682 17.41Z" fill="#C4C7C7"/>
<path d="M14.6878 5.61724C16.7718 6.83827 18.0143 8.81841 18.0143 10.9131C18.0143 14.5161 14.4157 17.448 9.99349 17.448C5.57129 17.448 1.97266 14.5154 1.97266 10.9131C1.97266 8.81841 3.21696 6.83827 5.30059 5.61724C5.30078 5.61712 5.30113 5.61691 5.30164 5.6166C5.36244 5.57964 7.6577 4.18451 8.37464 1.26979C8.42477 1.0611 8.58827 0.898861 8.79753 0.849054C9.00163 0.798701 9.22363 0.869768 9.36328 1.03255L9.99349 1.76509L10.6251 1.03245C10.7637 0.869643 10.9886 0.798597 11.1923 0.848943C11.4015 0.898715 11.5649 1.06099 11.6152 1.26968C12.3367 4.21053 14.6643 5.60381 14.6878 5.61724Z" fill="#C4C7C7"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -17,9 +17,11 @@ import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/buy_view/buy_view.dart';
import 'package:stackwallet/pages/exchange_view/exchange_view.dart';
import 'package:stackwallet/pages/home_view/sub_widgets/home_view_button_bar.dart';
import 'package:stackwallet/pages/home_view/sub_widgets/tor_sync_status_changed_event.dart';
import 'package:stackwallet/pages/notification_views/notifications_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/global_settings_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart';
import 'package:stackwallet/pages/wallets_view/wallets_view.dart';
import 'package:stackwallet/providers/global/notifications_provider.dart';
import 'package:stackwallet/providers/ui/home_view_index_provider.dart';
@ -55,6 +57,8 @@ class _HomeViewState extends ConsumerState<HomeView> {
bool _exitEnabled = false;
late TorSyncStatus _currentSyncStatus;
// final _buyDataLoadingService = BuyDataLoadingService();
Future<bool> _onWillPop() async {
@ -113,6 +117,32 @@ class _HomeViewState extends ConsumerState<HomeView> {
);
}
Widget _buildTorIcon(TorSyncStatus status) {
switch (status) {
case TorSyncStatus.unableToSync:
return SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.textSubtitle3,
width: 20,
height: 20,
);
case TorSyncStatus.synced:
return SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.accentColorGreen,
width: 20,
height: 20,
);
case TorSyncStatus.syncing:
return SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.accentColorYellow,
width: 20,
height: 20,
);
}
}
@override
void initState() {
_pageController = PageController();
@ -125,6 +155,20 @@ class _HomeViewState extends ConsumerState<HomeView> {
ref.read(notificationsProvider).startCheckingWatchedNotifications();
/// todo change to watch tor network
// if (ref.read(managerProvider).isRefreshing) {
// _currentSyncStatus = WalletSyncStatus.syncing;
// _currentNodeStatus = NodeConnectionStatus.connected;
// } else {
// _currentSyncStatus = WalletSyncStatus.synced;
// if (ref.read(managerProvider).isConnected) {
// _currentNodeStatus = NodeConnectionStatus.connected;
// } else {
// _currentNodeStatus = NodeConnectionStatus.disconnected;
// _currentSyncStatus = WalletSyncStatus.unableToSync;
// }
// }
super.initState();
}
@ -200,6 +244,31 @@ class _HomeViewState extends ConsumerState<HomeView> {
],
),
actions: [
Padding(
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
right: 10,
),
child: AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
semanticsLabel:
"Tor Settings Button. Takes To Tor Settings Page.",
key: const Key("walletsViewTorButton"),
size: 36,
shadows: const [],
color: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
icon: _buildTorIcon(TorSyncStatus.unableToSync),
onPressed: () {
Navigator.of(context)
.pushNamed(TorSettingsView.routeName);
},
),
),
),
Padding(
padding: const EdgeInsets.only(
top: 10,

View file

@ -0,0 +1,22 @@
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:stackwallet/utilities/logger.dart';
enum TorSyncStatus { unableToSync, synced, syncing }
class TorSyncStatusChangedEvent {
TorSyncStatus newStatus;
TorSyncStatusChangedEvent(this.newStatus) {
Logging.instance.log(
"TorSyncStatusChangedEvent fired with arg newStatus = $newStatus",
level: LogLevel.Info);
}
}

View file

@ -25,6 +25,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/stack_back
import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/support_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart';
import 'package:stackwallet/pages/settings_views/sub_widgets/settings_list_button.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/themes/stack_colors.dart';
@ -159,6 +160,18 @@ class GlobalSettingsView extends StatelessWidget {
const SizedBox(
height: 8,
),
SettingsListButton(
iconAssetName: Assets.svg.tor,
iconSize: 18,
title: "Tor Settings",
onPressed: () {
Navigator.of(context)
.pushNamed(TorSettingsView.routeName);
},
),
const SizedBox(
height: 8,
),
SettingsListButton(
iconAssetName: Assets.svg.node,
iconSize: 16,

View file

@ -0,0 +1,302 @@
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/pages/home_view/sub_widgets/tor_sync_status_changed_event.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
class TorSettingsView extends ConsumerStatefulWidget {
const TorSettingsView({Key? key}) : super(key: key);
static const String routeName = "/torSettings";
@override
ConsumerState<TorSettingsView> createState() => _TorSettingsViewState();
}
class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
TorSyncStatus _networkStatus = TorSyncStatus.unableToSync;
Widget _buildTorIcon(TorSyncStatus status) {
switch (status) {
case TorSyncStatus.unableToSync:
return Stack(
alignment: AlignmentDirectional.center,
children: [
SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.textSubtitle3,
width: 200,
height: 200,
),
Text(
"CONNECT",
style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.popupBG),
)
],
);
case TorSyncStatus.synced:
return Stack(
alignment: AlignmentDirectional.center,
children: [
SvgPicture.asset(
Assets.svg.tor,
color:
Theme.of(context).extension<StackColors>()!.accentColorGreen,
width: 200,
height: 200,
),
Text(
"CONNECTED",
style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.popupBG),
)
],
);
case TorSyncStatus.syncing:
return Stack(
alignment: AlignmentDirectional.center,
children: [
SvgPicture.asset(
Assets.svg.tor,
color:
Theme.of(context).extension<StackColors>()!.accentColorYellow,
width: 200,
height: 200,
),
Text(
"CONNECTING",
style: STextStyles.smallMed14(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.popupBG),
)
],
);
}
}
Widget _buildTorStatus(TorSyncStatus status) {
switch (status) {
case TorSyncStatus.unableToSync:
return Text(
"Disconnected",
style: STextStyles.itemSubtitle(context).copyWith(
color: Theme.of(context).extension<StackColors>()!.textSubtitle3),
);
case TorSyncStatus.synced:
return Text(
"Connected",
style: STextStyles.itemSubtitle(context).copyWith(
color:
Theme.of(context).extension<StackColors>()!.accentColorGreen),
);
case TorSyncStatus.syncing:
return Text(
"Connecting",
style: STextStyles.itemSubtitle(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow),
);
}
}
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
final isDesktop = Util.isDesktop;
return Background(
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: AppBar(
automaticallyImplyLeading: false,
backgroundColor:
Theme.of(context).extension<StackColors>()!.backgroundAppBar,
leading: AppBarBackButton(
onPressed: () {
Navigator.of(context).pop();
},
),
title: Text(
"Tor settings",
style: STextStyles.navBarTitle(context),
),
actions: [
AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
icon: SvgPicture.asset(
Assets.svg.circleQuestion,
),
onPressed: () {
showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const StackDialog(
title: "What is Tor?",
message:
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
" to remain anonymous by routing internet traffic through a series of layered nodes,"
" to obscure the origin and destination of data.",
rightButton: SecondaryButton(
label: "Close",
),
);
},
);
},
),
),
],
),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: _buildTorIcon(_networkStatus),
),
],
),
SizedBox(
height: 30,
),
RoundedWhiteContainer(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Row(
children: [
Text(
"Tor status",
style: STextStyles.titleBold12(context),
),
const Spacer(),
_buildTorStatus(_networkStatus),
],
),
),
),
SizedBox(
height: 8,
),
RoundedWhiteContainer(
child: Consumer(
builder: (_, ref, __) {
return RawMaterialButton(
// splashColor: Theme.of(context).extension<StackColors>()!.highlight,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
onPressed: null,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Text(
"Tor killswitch",
style: STextStyles.titleBold12(context),
),
const SizedBox(width: 8),
GestureDetector(
onTap: () {
showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return const StackDialog(
title: "What is Tor killswitch?",
message:
"A security feature that protects your information from accidental exposure by"
" disconnecting your device from the Tor network if your virtual private network (VPN)"
" connection is disrupted or compromised.",
rightButton: SecondaryButton(
label: "Close",
),
);
},
);
},
child: SvgPicture.asset(
Assets.svg.circleInfo,
height: 16,
width: 16,
color: Theme.of(context)
.extension<StackColors>()!
.infoItemLabel,
),
),
],
),
SizedBox(
height: 20,
width: 40,
child: DraggableSwitchButton(
isOn: ref.watch(
prefsChangeNotifierProvider
.select((value) => value.torKillswitch),
),
onValueChanged: (newValue) {
ref
.read(prefsChangeNotifierProvider)
.torKillswitch = newValue;
},
),
),
],
),
),
);
},
),
),
],
),
),
),
);
}
}

View file

@ -14,7 +14,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/pages/home_view/sub_widgets/tor_sync_status_changed_event.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_menu_item.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu.dart';
import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
@ -57,6 +59,70 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
// final _buyDataLoadingService = BuyDataLoadingService();
Widget _buildTorIcon(TorSyncStatus status) {
switch (status) {
case TorSyncStatus.unableToSync:
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.textSubtitle3,
width: 20,
height: 20,
),
Text(
"\tDisconnected",
style: STextStyles.smallMed12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle3),
)
],
);
case TorSyncStatus.synced:
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.svg.tor,
color:
Theme.of(context).extension<StackColors>()!.accentColorGreen,
width: 20,
height: 20,
),
Text(
"\tConnected",
style: STextStyles.smallMed12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen),
)
],
);
case TorSyncStatus.syncing:
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.svg.tor,
color:
Theme.of(context).extension<StackColors>()!.accentColorYellow,
width: 20,
height: 20,
),
Text(
"\tConnecting",
style: STextStyles.smallMed12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow),
)
],
);
}
}
void updateSelectedMenuItem(DesktopMenuItemId idKey) {
widget.onSelectionWillChange?.call(idKey);
@ -140,7 +206,22 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
),
),
const SizedBox(
height: 60,
height: 5,
),
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
ref.read(currentDesktopMenuItemProvider.state).state =
DesktopMenuItemId.settings;
ref
.watch(selectedSettingsMenuItemStateProvider.state)
.state = 4;
},
child: _buildTorIcon(TorSyncStatus.unableToSync)),
),
const SizedBox(
height: 40,
),
Expanded(
child: AnimatedContainer(

View file

@ -19,6 +19,7 @@ import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/langua
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/nodes_settings.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/security_settings.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/text_styles.dart';
@ -56,7 +57,12 @@ class _DesktopSettingsViewState extends ConsumerState<DesktopSettingsView> {
key: Key("settingsLanguageDesktopKey"),
onGenerateRoute: RouteGenerator.generateRoute,
initialRoute: LanguageOptionSettings.routeName,
), //language
),
const Navigator(
key: Key("settingsTorDesktopKey"),
onGenerateRoute: RouteGenerator.generateRoute,
initialRoute: TorSettings.routeName,
), //tor
const Navigator(
key: Key("settingsNodesDesktopKey"),
onGenerateRoute: RouteGenerator.generateRoute,

View file

@ -32,6 +32,7 @@ class _SettingsMenuState extends ConsumerState<SettingsMenu> {
"Security",
"Currency",
"Language",
"Tor settings",
"Nodes",
"Syncing preferences",
"Appearance",

View file

@ -0,0 +1,316 @@
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import '../../../../providers/global/prefs_provider.dart';
import '../../../../themes/stack_colors.dart';
import '../../../../widgets/custom_buttons/draggable_switch_button.dart';
class TorSettings extends ConsumerStatefulWidget {
const TorSettings({Key? key}) : super(key: key);
static const String routeName = "/torDesktopSettings";
@override
ConsumerState<TorSettings> createState() => _TorSettingsState();
}
class _TorSettingsState extends ConsumerState<TorSettings> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
final isDesktop = Util.isDesktop;
/// todo: redo the padding
return Column(
children: [
Padding(
padding: const EdgeInsets.only(
right: 30,
),
child: RoundedWhiteContainer(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: SvgPicture.asset(
Assets.svg.circleTor,
width: 48,
height: 48,
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: SvgPicture.asset(
Assets.svg.disconnectedButton,
width: 48,
height: 48,
),
),
],
),
Padding(
padding: const EdgeInsets.all(10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Tor settings",
style: STextStyles.desktopTextSmall(context),
),
RichText(
textAlign: TextAlign.start,
text: TextSpan(
children: [
TextSpan(
text:
"\nConnect to the Tor Network with one click.",
style: STextStyles.desktopTextExtraExtraSmall(
context),
),
TextSpan(
text: "\tWhat is Tor?",
style: STextStyles.richLink(context).copyWith(
fontSize: 14,
),
recognizer: TapGestureRecognizer()
..onTap = () {
showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return DesktopDialog(
maxWidth: 580,
maxHeight: double.infinity,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
DesktopDialogCloseButton(
onPressedOverride: () =>
Navigator.of(context)
.pop(true),
),
],
),
Padding(
padding:
const EdgeInsets.all(20),
child: Column(
mainAxisSize:
MainAxisSize.max,
children: [
Text(
"What is Tor?",
style:
STextStyles.desktopH2(
context),
),
const SizedBox(
height: 20,
),
Text(
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
" to remain anonymous by routing internet traffic through a series of layered nodes,"
" to obscure the origin and destination of data.",
style: STextStyles
.desktopTextMedium(
context)
.copyWith(
color: Theme.of(context)
.extension<
StackColors>()!
.textDark3,
),
),
],
),
),
],
),
);
});
},
),
],
),
),
],
),
),
const SizedBox(
height: 10,
),
Padding(
padding: const EdgeInsets.all(10.0),
child: SecondaryButton(
label: "Disconnect from Tor",
width: 200,
buttonHeight: ButtonHeight.m,
onPressed: () {},
),
),
const SizedBox(
height: 30,
),
Padding(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
RichText(
textAlign: TextAlign.start,
text: TextSpan(
children: [
TextSpan(
text: "Tor killswitch",
style: STextStyles.desktopTextExtraExtraSmall(
context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
TextSpan(
text: "\nWhat is Tor killswitch?",
style: STextStyles.richLink(context).copyWith(
fontSize: 14,
),
recognizer: TapGestureRecognizer()
..onTap = () {
showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
builder: (context) {
return DesktopDialog(
maxWidth: 580,
maxHeight: double.infinity,
child: Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
DesktopDialogCloseButton(
onPressedOverride: () =>
Navigator.of(
context)
.pop(true),
),
],
),
Padding(
padding:
const EdgeInsets.all(
20),
child: Column(
mainAxisSize:
MainAxisSize.max,
children: [
Text(
"What is Tor killswitch?",
style: STextStyles
.desktopH2(
context),
),
const SizedBox(
height: 20,
),
Text(
"A security feature that protects your information from accidental exposure by"
" disconnecting your device from the Tor network if your virtual private network (VPN)"
" connection is disrupted or compromised.",
style: STextStyles
.desktopTextMedium(
context)
.copyWith(
color: Theme.of(
context)
.extension<
StackColors>()!
.textDark3,
),
),
],
),
),
],
),
);
});
},
),
],
),
),
],
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: SizedBox(
height: 20,
width: 40,
child: DraggableSwitchButton(
isOn: ref.watch(
prefsChangeNotifierProvider
.select((value) => value.torKillswitch),
),
onValueChanged: (newValue) {
ref
.read(prefsChangeNotifierProvider)
.torKillswitch = newValue;
},
),
),
),
],
),
),
const SizedBox(
height: 10,
),
],
),
),
),
],
);
}
}

View file

@ -110,6 +110,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/support_vi
import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart';
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart';
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart';
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_view.dart';
@ -166,6 +167,7 @@ import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/langua
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/nodes_settings.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/security_settings.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart';
import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart';
import 'package:stackwallet/services/coins/manager.dart';
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
@ -654,6 +656,18 @@ class RouteGenerator {
builder: (_) => const LanguageSettingsView(),
settings: RouteSettings(name: settings.name));
case TorSettingsView.routeName:
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => const TorSettingsView(),
settings: RouteSettings(name: settings.name));
case TorSettings.routeName:
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => const TorSettings(),
settings: RouteSettings(name: settings.name));
case AboutView.routeName:
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,

View file

@ -92,6 +92,11 @@ class _SVG {
final coinControl = const _COIN_CONTROL();
String get connectedButton => "assets/svg/connected-button.svg";
String get connectingButton => "assets/svg/connecting-button.svg";
String get disconnectedButton => "assets/svg/disconnected-button.svg";
String get circleTor => "assets/svg/tor-circle.svg";
String get tor => "assets/svg/tor.svg";
String get monkey => "assets/svg/monkey.svg";
String get circleSliders => "assets/svg/configuration.svg";
String get circlePlus => "assets/svg/plus-circle.svg";

View file

@ -44,6 +44,7 @@ class Prefs extends ChangeNotifier {
_lastUnlocked = await _getLastUnlocked();
_lastUnlockedTimeout = await _getLastUnlockedTimeout();
_showTestNetCoins = await _getShowTestNetCoins();
_torKillswitch = await _getTorKillswitch();
_isAutoBackupEnabled = await _getIsAutoBackupEnabled();
_autoBackupLocation = await _getAutoBackupLocation();
_backupFrequencyType = await _getBackupFrequencyType();
@ -396,6 +397,27 @@ class Prefs extends ChangeNotifier {
0;
}
// tor
bool _torKillswitch = false;
bool get torKillswitch => _torKillswitch;
set torKillswitch(bool torKillswitch) {
if (_torKillswitch != showTestNetCoins) {
DB.instance.put<dynamic>(
boxName: DB.boxNamePrefs, key: "torKillswitch", value: torKillswitch);
_torKillswitch = torKillswitch;
notifyListeners();
}
}
Future<bool> _getTorKillswitch() async {
return await DB.instance.get<dynamic>(
boxName: DB.boxNamePrefs, key: "torKillswitch") as bool? ??
false;
}
// show testnet coins
bool _showTestNetCoins = false;

View file

@ -346,6 +346,11 @@ flutter:
- assets/svg/send.svg
- assets/svg/ordinal.svg
- assets/svg/monkey.svg
- assets/svg/tor.svg
- assets/svg/tor-circle.svg
- assets/svg/connected-button.svg
- assets/svg/connecting-button.svg
- assets/svg/disconnected-button.svg
# coin control icons
- assets/svg/coin_control/