add tor network status to desktop home

This commit is contained in:
ryleedavis 2023-09-06 13:43:55 -06:00
parent c3aaf0574b
commit 6377b73deb
2 changed files with 83 additions and 3 deletions

View file

@ -122,7 +122,7 @@ class _HomeViewState extends ConsumerState<HomeView> {
case TorSyncStatus.unableToSync:
return SvgPicture.asset(
Assets.svg.tor,
color: Theme.of(context).extension<StackColors>()!.accentColorRed,
color: Theme.of(context).extension<StackColors>()!.infoItemLabel,
width: 20,
height: 20,
);
@ -261,7 +261,7 @@ class _HomeViewState extends ConsumerState<HomeView> {
color: Theme.of(context)
.extension<StackColors>()!
.backgroundAppBar,
icon: _buildTorIcon(TorSyncStatus.syncing),
icon: _buildTorIcon(TorSyncStatus.unableToSync),
onPressed: () {
Navigator.of(context)
.pushNamed(TorSettingsView.routeName);

View file

@ -14,6 +14,7 @@ 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/providers/desktop/current_desktop_menu_item.dart';
import 'package:stackwallet/themes/stack_colors.dart';
@ -57,6 +58,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>()!.infoItemLabel,
width: 20,
height: 20,
),
Text(
"\tDisconnected",
style: STextStyles.smallMed12(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.infoItemLabel),
)
],
);
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 +205,22 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
),
),
const SizedBox(
height: 60,
height: 5,
),
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
// ref.watch(selectedSettingsMenuItemStateProvider.state).state =
// 4;
// ref.watch(selectedSettingsMenuItemStateProvider.state).state =
// 5;
// Navigator.of(context).pushNamed(DesktopHomeView.routeName);
},
child: _buildTorIcon(TorSyncStatus.unableToSync)),
),
const SizedBox(
height: 40,
),
Expanded(
child: AnimatedContainer(