add tor icon to wallet view

This commit is contained in:
sneurlax 2023-09-12 16:45:57 -05:00
parent 7c487c021c
commit 6fe0bfef81
3 changed files with 57 additions and 31 deletions

View file

@ -118,32 +118,6 @@ class _HomeViewState extends ConsumerState<HomeView> {
);
}
Widget _buildTorIcon(TorConnectionStatus status) {
switch (status) {
case TorConnectionStatus.disconnected:
return SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.textSubtitle3,
width: 20,
height: 20,
);
case TorConnectionStatus.connected:
return SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.accentColorGreen,
width: 20,
height: 20,
);
case TorConnectionStatus.connecting:
return SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.accentColorYellow,
width: 20,
height: 20,
);
}
}
@override
void initState() {
_pageController = PageController();

View file

@ -375,6 +375,11 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
// Init the Tor service if it hasn't already been.
ref.read(pTorService).init();
// Update the UI.
setState(() {
_networkStatus = TorConnectionStatus.connecting;
});
// Start the Tor service.
try {
await ref.read(pTorService).start();
@ -388,11 +393,6 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
);
}
// Update the UI.
setState(() {
_networkStatus = TorConnectionStatus.connecting;
});
return;
}

View file

@ -29,6 +29,7 @@ import 'package:stackwallet/pages/paynym/paynym_claim_view.dart';
import 'package:stackwallet/pages/paynym/paynym_home_view.dart';
import 'package:stackwallet/pages/receive_view/receive_view.dart';
import 'package:stackwallet/pages/send_view/send_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_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/special/firo_rescan_recovery_error_dialog.dart';
@ -51,6 +52,7 @@ import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart';
import 'package:stackwallet/services/tor_service.dart';
import 'package:stackwallet/themes/coin_icon_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/themes/theme_providers.dart';
@ -552,6 +554,56 @@ class _WalletViewState extends ConsumerState<WalletView> {
],
),
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: ref.watch(pTorService).enabled
? ref.read(pTorService).proxyInfo.port == -1
? SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorYellow,
width: 20,
height: 20,
)
: SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorGreen,
width: 20,
height: 20,
)
: SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle3,
width: 20,
height: 20,
),
onPressed: () {
Navigator.of(context)
.pushNamed(TorSettingsView.routeName);
},
),
),
),
Padding(
padding: const EdgeInsets.only(
top: 10,