WIP: tor settings view for mobile

This commit is contained in:
ryleedavis 2023-09-01 16:50:17 -06:00
parent f0767141e4
commit f6a0950c24
9 changed files with 260 additions and 0 deletions

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

@ -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/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/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/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/pages/settings_views/sub_widgets/settings_list_button.dart';
import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/stack_colors.dart';
@ -159,6 +160,18 @@ class GlobalSettingsView extends StatelessWidget {
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
SettingsListButton(
iconAssetName: Assets.svg.tor,
iconSize: 18,
title: "Tor Settings",
onPressed: () {
Navigator.of(context)
.pushNamed(TorSettingsView.routeName);
},
),
const SizedBox(
height: 8,
),
SettingsListButton( SettingsListButton(
iconAssetName: Assets.svg.node, iconAssetName: Assets.svg.node,
iconSize: 16, iconSize: 16,

View file

@ -0,0 +1,200 @@
/*
* 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/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> {
@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:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
"Sed sit amet nulla accumsan, ornare felis pellentesque, auctor nulla.",
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: SvgPicture.asset(
Assets.svg.tor,
height: 200,
width: 200,
),
),
],
),
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(),
Text(
"Tor network status",
style: STextStyles.itemSubtitle(context),
),
],
),
),
),
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),
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

@ -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_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/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/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_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_network_settings_view/wallet_network_settings_view.dart';
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_view.dart'; import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_view.dart';
@ -654,6 +655,12 @@ class RouteGenerator {
builder: (_) => const LanguageSettingsView(), builder: (_) => const LanguageSettingsView(),
settings: RouteSettings(name: settings.name)); settings: RouteSettings(name: settings.name));
case TorSettingsView.routeName:
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => const TorSettingsView(),
settings: RouteSettings(name: settings.name));
case AboutView.routeName: case AboutView.routeName:
return getRoute( return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute, shouldUseMaterialRoute: useMaterialPageRoute,

View file

@ -92,6 +92,9 @@ class _SVG {
final coinControl = const _COIN_CONTROL(); final coinControl = const _COIN_CONTROL();
String get torConnected => "assets/svg/tor-synced.svg";
String get torConnecting => "assets/svg/tor-syncing.svg";
String get tor => "assets/svg/tor.svg";
String get monkey => "assets/svg/monkey.svg"; String get monkey => "assets/svg/monkey.svg";
String get circleSliders => "assets/svg/configuration.svg"; String get circleSliders => "assets/svg/configuration.svg";
String get circlePlus => "assets/svg/plus-circle.svg"; String get circlePlus => "assets/svg/plus-circle.svg";

View file

@ -42,6 +42,7 @@ class Prefs extends ChangeNotifier {
_lastUnlocked = await _getLastUnlocked(); _lastUnlocked = await _getLastUnlocked();
_lastUnlockedTimeout = await _getLastUnlockedTimeout(); _lastUnlockedTimeout = await _getLastUnlockedTimeout();
_showTestNetCoins = await _getShowTestNetCoins(); _showTestNetCoins = await _getShowTestNetCoins();
_torKillswitch = await _getTorKillswitch();
_isAutoBackupEnabled = await _getIsAutoBackupEnabled(); _isAutoBackupEnabled = await _getIsAutoBackupEnabled();
_autoBackupLocation = await _getAutoBackupLocation(); _autoBackupLocation = await _getAutoBackupLocation();
_backupFrequencyType = await _getBackupFrequencyType(); _backupFrequencyType = await _getBackupFrequencyType();
@ -393,6 +394,27 @@ class Prefs extends ChangeNotifier {
0; 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 // show testnet coins
bool _showTestNetCoins = false; bool _showTestNetCoins = false;

View file

@ -342,6 +342,9 @@ flutter:
- assets/svg/send.svg - assets/svg/send.svg
- assets/svg/ordinal.svg - assets/svg/ordinal.svg
- assets/svg/monkey.svg - assets/svg/monkey.svg
- assets/svg/tor.svg
- assets/svg/tor-syncing.svg
- assets/svg/tor-synced.svg
# coin control icons # coin control icons
- assets/svg/coin_control/ - assets/svg/coin_control/