mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
WIP startup privacy options page layout
This commit is contained in:
parent
625144fd7f
commit
bf27f38bb5
2 changed files with 236 additions and 49 deletions
|
@ -2,15 +2,15 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart';
|
import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart';
|
||||||
|
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||||
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
|
|
||||||
import 'package:stackwallet/hive/db.dart';
|
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
|
||||||
|
|
||||||
class StackPrivacyCalls extends ConsumerStatefulWidget {
|
class StackPrivacyCalls extends ConsumerStatefulWidget {
|
||||||
const StackPrivacyCalls({
|
const StackPrivacyCalls({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -73,55 +73,66 @@ class _StackPrivacyCalls extends ConsumerState<StackPrivacyCalls> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 36,
|
height: 36,
|
||||||
),
|
),
|
||||||
Center(
|
const Padding(
|
||||||
child: CustomRadio((bool isEasy) {
|
padding: EdgeInsets.symmetric(
|
||||||
setState(() {
|
horizontal: 16,
|
||||||
this.isEasy = isEasy;
|
),
|
||||||
|
child: PrivacyToggle(),
|
||||||
DB.instance.put<dynamic>(
|
|
||||||
boxName: DB.boxNamePrefs,
|
|
||||||
key: "externalCalls",
|
|
||||||
value: isEasy);
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
|
// Center(
|
||||||
|
// child: CustomRadio((bool isEasy) {
|
||||||
|
// setState(() {
|
||||||
|
// this.isEasy = isEasy;
|
||||||
|
//
|
||||||
|
// DB.instance.put<dynamic>(
|
||||||
|
// boxName: DB.boxNamePrefs,
|
||||||
|
// key: "externalCalls",
|
||||||
|
// value: isEasy);
|
||||||
|
// });
|
||||||
|
// }),
|
||||||
|
// ),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 36,
|
height: 36,
|
||||||
),
|
),
|
||||||
RoundedWhiteContainer(
|
Padding(
|
||||||
child: Center(
|
padding: const EdgeInsets.symmetric(
|
||||||
child: RichText(
|
horizontal: 16,
|
||||||
textAlign: TextAlign.left,
|
),
|
||||||
text: TextSpan(
|
child: RoundedWhiteContainer(
|
||||||
style:
|
child: Center(
|
||||||
STextStyles.label(context).copyWith(fontSize: 12.0),
|
child: RichText(
|
||||||
children: isEasy
|
textAlign: TextAlign.left,
|
||||||
? const [
|
text: TextSpan(
|
||||||
TextSpan(
|
style: STextStyles.label(context)
|
||||||
text:
|
.copyWith(fontSize: 12.0),
|
||||||
"Exchange data preloaded for a seamless experience."),
|
children: isEasy
|
||||||
TextSpan(
|
? const [
|
||||||
text:
|
TextSpan(
|
||||||
"\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."),
|
text:
|
||||||
TextSpan(
|
"Exchange data preloaded for a seamless experience."),
|
||||||
text:
|
TextSpan(
|
||||||
"\n\nRecommended for most crypto users.",
|
text:
|
||||||
style:
|
"\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."),
|
||||||
TextStyle(fontWeight: FontWeight.bold)),
|
TextSpan(
|
||||||
]
|
text:
|
||||||
: const [
|
"\n\nRecommended for most crypto users.",
|
||||||
TextSpan(
|
style: TextStyle(
|
||||||
text:
|
fontWeight: FontWeight.bold)),
|
||||||
"Exchange data not preloaded (slower experience)."),
|
]
|
||||||
TextSpan(
|
: const [
|
||||||
text:
|
TextSpan(
|
||||||
"\n\nCoinGecko disabled (price changes not shown, no wallet value shown in other currencies)."),
|
text:
|
||||||
TextSpan(
|
"Exchange data not preloaded (slower experience)."),
|
||||||
text:
|
TextSpan(
|
||||||
"\n\nRecommended for the privacy conscious.",
|
text:
|
||||||
style:
|
"\n\nCoinGecko disabled (price changes not shown, no wallet value shown in other currencies)."),
|
||||||
TextStyle(fontWeight: FontWeight.bold)),
|
TextSpan(
|
||||||
],
|
text:
|
||||||
|
"\n\nRecommended for the privacy conscious.",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold)),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -153,6 +164,157 @@ class _StackPrivacyCalls extends ConsumerState<StackPrivacyCalls> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PrivacyToggle extends ConsumerStatefulWidget {
|
||||||
|
const PrivacyToggle({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<PrivacyToggle> createState() => _PrivacyToggleState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PrivacyToggleState extends ConsumerState<PrivacyToggle> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: RawMaterialButton(
|
||||||
|
fillColor: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
Constants.size.circularBorderRadius * 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
ref.read(prefsChangeNotifierProvider).externalCalls = true;
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
12,
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.svg.personaEasy,
|
||||||
|
// color: Theme.of(context).extension<StackColors>()!.textWhite,
|
||||||
|
width: 96,
|
||||||
|
height: 96,
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"Easy Crypto",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Text(
|
||||||
|
"Recommended",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: RawMaterialButton(
|
||||||
|
elevation: 0,
|
||||||
|
fillColor: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
side: ref.watch(
|
||||||
|
prefsChangeNotifierProvider.select(
|
||||||
|
(value) => value.externalCalls,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
? BorderSide.none
|
||||||
|
: BorderSide(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.infoItemIcons,
|
||||||
|
width: 2,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(
|
||||||
|
Constants.size.circularBorderRadius * 2,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
ref.read(prefsChangeNotifierProvider).externalCalls = false;
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
12,
|
||||||
|
),
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
SvgPicture.asset(
|
||||||
|
Assets.svg.personaIncognito,
|
||||||
|
width: 96,
|
||||||
|
height: 96,
|
||||||
|
),
|
||||||
|
const Center(
|
||||||
|
child: Text(
|
||||||
|
"Incognito",
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Center(
|
||||||
|
child: Text(
|
||||||
|
"Privacy conscious",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (!ref.watch(
|
||||||
|
prefsChangeNotifierProvider.select(
|
||||||
|
(value) => value.externalCalls,
|
||||||
|
),
|
||||||
|
))
|
||||||
|
Positioned(
|
||||||
|
top: 4,
|
||||||
|
right: 4,
|
||||||
|
child: SvgPicture.asset(
|
||||||
|
Assets.svg.checkCircle,
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.infoItemIcons,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (ref.watch(
|
||||||
|
prefsChangeNotifierProvider.select(
|
||||||
|
(value) => value.externalCalls,
|
||||||
|
),
|
||||||
|
))
|
||||||
|
Positioned(
|
||||||
|
top: 4,
|
||||||
|
right: 4,
|
||||||
|
child: Container(
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(1000),
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textFieldDefaultBG,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ContinueButton extends StatelessWidget {
|
class ContinueButton extends StatelessWidget {
|
||||||
const ContinueButton({Key? key, required this.isDesktop}) : super(key: key);
|
const ContinueButton({Key? key, required this.isDesktop}) : super(key: key);
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ class Prefs extends ChangeNotifier {
|
||||||
_hideBlockExplorerWarning = await _getHideBlockExplorerWarning();
|
_hideBlockExplorerWarning = await _getHideBlockExplorerWarning();
|
||||||
_gotoWalletOnStartup = await _getGotoWalletOnStartup();
|
_gotoWalletOnStartup = await _getGotoWalletOnStartup();
|
||||||
_startupWalletId = await _getStartupWalletId();
|
_startupWalletId = await _getStartupWalletId();
|
||||||
|
_externalCalls = await _getHasExternalCalls();
|
||||||
|
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
@ -544,4 +545,28 @@ class Prefs extends ChangeNotifier {
|
||||||
return await DB.instance.get<dynamic>(
|
return await DB.instance.get<dynamic>(
|
||||||
boxName: DB.boxNamePrefs, key: "startupWalletId") as String?;
|
boxName: DB.boxNamePrefs, key: "startupWalletId") as String?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _externalCalls = false;
|
||||||
|
|
||||||
|
bool get externalCalls => _externalCalls;
|
||||||
|
|
||||||
|
set externalCalls(bool externalCalls) {
|
||||||
|
if (_externalCalls != externalCalls) {
|
||||||
|
DB.instance
|
||||||
|
.put<dynamic>(
|
||||||
|
boxName: DB.boxNamePrefs,
|
||||||
|
key: "externalCalls",
|
||||||
|
value: externalCalls)
|
||||||
|
.then((_) {
|
||||||
|
_externalCalls = externalCalls;
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> _getHasExternalCalls() async {
|
||||||
|
return await DB.instance.get<dynamic>(
|
||||||
|
boxName: DB.boxNamePrefs, key: "externalCalls") as bool? ??
|
||||||
|
false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue