one time stacy tor dialog

This commit is contained in:
julian 2023-09-20 14:39:06 -06:00
parent 90a913540c
commit 157901e33d
8 changed files with 231 additions and 14 deletions

BIN
assets/gif/stacy_onion.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

View file

@ -46,6 +46,7 @@ class DB {
// in use (keep for now)
static const String boxNameDBInfo = "dbInfo";
static const String boxNamePrefs = "prefs";
static const String boxNameOneTimeDialogsShown = "oneTimeDialogsShown";
String _boxNameTxCache({required Coin coin}) => "${coin.name}_txCache";

View file

@ -33,6 +33,7 @@ import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/onetime_popups/tor_has_been_add_dialog.dart';
import 'package:stackwallet/widgets/small_tor_icon.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
@ -129,19 +130,9 @@ 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;
// }
// }
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
showOneTimeTorHasBeenAddedDialogIfRequired(context);
});
super.initState();
}

View file

@ -12,6 +12,8 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/providers/global/debug_service_provider.dart';
import 'package:stackwallet/providers/providers.dart';
@ -19,6 +21,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/onetime_popups/tor_has_been_add_dialog.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class HiddenSettings extends StatelessWidget {
@ -34,7 +37,7 @@ class HiddenSettings extends StatelessWidget {
appBar: AppBar(
leading: Container(),
title: Text(
"Not so secret anymore",
"Dev options",
style: STextStyles.navBarTitle(context),
),
),
@ -146,6 +149,48 @@ class HiddenSettings extends StatelessWidget {
),
);
}),
const SizedBox(
height: 12,
),
Consumer(builder: (_, ref, __) {
return GestureDetector(
onTap: () async {
await showOneTimeTorHasBeenAddedDialogIfRequired(
context,
);
},
child: RoundedWhiteContainer(
child: Text(
"Test tor stacy popup",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
),
);
}),
const SizedBox(
height: 12,
),
Consumer(builder: (_, ref, __) {
return GestureDetector(
onTap: () async {
final box = await Hive.openBox<bool>(
DB.boxNameOneTimeDialogsShown);
await box.clear();
},
child: RoundedWhiteContainer(
child: Text(
"Reset tor stacy popup",
style: STextStyles.button(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
),
),
);
}),
// const SizedBox(
// height: 12,
// ),

View file

@ -30,6 +30,7 @@ import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/onetime_popups/tor_has_been_add_dialog.dart';
final currentWalletIdProvider = StateProvider<String?>((_) => null);
@ -53,6 +54,11 @@ class _DesktopHomeViewState extends ConsumerState<DesktopHomeView> {
onGenerateRoute: RouteGenerator.generateRoute,
initialRoute: MyStackView.routeName,
);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
showOneTimeTorHasBeenAddedDialogIfRequired(context);
});
super.initState();
}

View file

@ -21,6 +21,7 @@ abstract class Assets {
static const socials = _SOCIALS();
static const exchange = _EXCHANGE();
static const buy = _BUY();
static const gif = _GIF();
}
class _SOCIALS {
@ -260,3 +261,9 @@ class _ANIMATIONS {
String get arrowRotate => "assets/lottie/arrow_rotate.json";
String get onionTor => "assets/lottie/onion_animation.json";
}
class _GIF {
const _GIF();
String get stacyOnion => "assets/gif/stacy_onion.gif";
}

View file

@ -0,0 +1,164 @@
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
const _kOneTimeTorHasBeenAddedDialogWasShown =
"oneTimeTorHasBeenAddedDialogWasShown";
Future<void> showOneTimeTorHasBeenAddedDialogIfRequired(
BuildContext context) async {
final box = await Hive.openBox<bool>(DB.boxNameOneTimeDialogsShown);
if (!box.get(
_kOneTimeTorHasBeenAddedDialogWasShown,
defaultValue: false,
)! &&
context.mounted) {
await showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => const _TorHasBeenAddedDialog(),
);
}
}
class _TorHasBeenAddedDialog extends StatefulWidget {
const _TorHasBeenAddedDialog({super.key});
@override
State<_TorHasBeenAddedDialog> createState() => _TorHasBeenAddedDialogState();
}
class _TorHasBeenAddedDialogState extends State<_TorHasBeenAddedDialog> {
bool _lock = false;
void setDoNotShowAgain() async {
if (_lock) {
return;
}
_lock = true;
try {
final box = await Hive.openBox<bool>(DB.boxNameOneTimeDialogsShown);
await box.put(_kOneTimeTorHasBeenAddedDialogWasShown, true);
} catch (_) {
//
} finally {
_lock = false;
}
}
@override
Widget build(BuildContext context) {
return ConditionalParent(
condition: Util.isDesktop,
builder: (child) => DesktopDialog(
maxHeight: double.infinity,
maxWidth: 450,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(left: 32),
child: Text(
"",
style: STextStyles.desktopH3(context),
),
),
DesktopDialogCloseButton(
onPressedOverride: setDoNotShowAgain,
),
],
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: child,
),
Padding(
padding: const EdgeInsets.all(32),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PrimaryButton(
buttonHeight: ButtonHeight.l,
width: 180,
label: "Ok",
onPressed: () {
setDoNotShowAgain();
Navigator.of(context).pop();
},
),
],
),
)
],
),
),
child: ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => StackDialogBase(
child: Column(
children: [
child,
const SizedBox(
height: 28,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: MediaQuery.of(context).size.width / 2,
child: PrimaryButton(
label: "Ok",
onPressed: () {
setDoNotShowAgain();
Navigator.of(context).pop();
},
),
),
],
),
],
),
),
child: Column(
children: [
const StacyOnion(),
SizedBox(
height: Util.isDesktop ? 24 : 16,
),
Text(
"Tor has been added to help keep your connections private and secure!",
style: Util.isDesktop
? STextStyles.desktopTextMedium(context)
: STextStyles.smallMed14(context),
),
],
),
),
);
}
}
class StacyOnion extends StatelessWidget {
const StacyOnion({super.key});
@override
Widget build(BuildContext context) {
return Image(
height: 200,
image: AssetImage(
Assets.gif.stacyOnion,
),
);
}
}

View file

@ -372,6 +372,9 @@ flutter:
# buy
- assets/svg/buy/
# gif
- assets/gif/
# lottie animations
# basic
- assets/lottie/test2.json