WIP: tor enabled dialog on buy view

This commit is contained in:
ryleedavis 2023-09-12 16:59:07 -06:00
parent 6fe0bfef81
commit 3fa0997754
2 changed files with 170 additions and 65 deletions

View file

@ -9,38 +9,82 @@
*/ */
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
import 'package:stackwallet/pages/buy_view/buy_form.dart'; import 'package:stackwallet/pages/buy_view/buy_form.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
class BuyView extends StatelessWidget { class BuyView extends ConsumerStatefulWidget {
const BuyView({ const BuyView({
Key? key, Key? key,
this.coin, this.coin,
this.tokenContract, this.tokenContract,
}) : super(key: key); }) : super(key: key);
static const String routeName = "/stackBuyView";
final Coin? coin; final Coin? coin;
final EthContract? tokenContract; final EthContract? tokenContract;
static const String routeName = "/stackBuyView";
@override
ConsumerState<BuyView> createState() => _BuyViewState();
}
class _BuyViewState extends ConsumerState<BuyView> {
Coin? coin;
EthContract? tokenContract;
late bool torEnabled = false;
@override
void initState() {
coin = widget.coin;
tokenContract = widget.tokenContract;
WidgetsBinding.instance.addPostFrameCallback((_) async {
setState(() {
torEnabled = ref.read(prefsChangeNotifierProvider).useTor;
});
});
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType"); debugPrint("BUILD: $runtimeType");
return SafeArea( return Stack(
child: Padding( children: [
padding: const EdgeInsets.only( SafeArea(
left: 16, child: Padding(
right: 16, padding: const EdgeInsets.only(
top: 16, left: 16,
right: 16,
top: 16,
),
child: BuyForm(
coin: coin,
tokenContract: tokenContract,
),
),
), ),
child: BuyForm( if (torEnabled)
coin: coin, Container(
tokenContract: tokenContract, color: Theme.of(context)
), .extension<StackColors>()!
), .overlay
.withOpacity(0.7),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: const StackDialog(
title: "Tor is enabled",
message: "Purchasing not available while Tor is enabled",
),
),
],
); );
} }
} }

View file

@ -9,76 +9,137 @@
*/ */
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/pages/buy_view/buy_form.dart'; import 'package:stackwallet/pages/buy_view/buy_form.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
class DesktopBuyView extends StatefulWidget { class DesktopBuyView extends ConsumerStatefulWidget {
const DesktopBuyView({Key? key}) : super(key: key); const DesktopBuyView({Key? key}) : super(key: key);
static const String routeName = "/desktopBuyView"; static const String routeName = "/desktopBuyView";
@override @override
State<DesktopBuyView> createState() => _DesktopBuyViewState(); ConsumerState<DesktopBuyView> createState() => _DesktopBuyViewState();
} }
class _DesktopBuyViewState extends State<DesktopBuyView> { class _DesktopBuyViewState extends ConsumerState<DesktopBuyView> {
late bool torEnabled = false;
@override
void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
setState(() {
torEnabled = ref.read(prefsChangeNotifierProvider).useTor;
});
});
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return DesktopScaffold( return Stack(
appBar: DesktopAppBar( children: [
isCompactHeight: true, DesktopScaffold(
leading: Padding( appBar: DesktopAppBar(
padding: const EdgeInsets.only( isCompactHeight: true,
left: 24, leading: Padding(
), padding: const EdgeInsets.only(
child: Text( left: 24,
"Buy crypto", ),
style: STextStyles.desktopH3(context), child: Text(
), "Buy crypto",
), style: STextStyles.desktopH3(context),
),
body: Padding(
padding: const EdgeInsets.only(
left: 24,
right: 24,
bottom: 24,
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: const [
SizedBox(
height: 16,
),
RoundedWhiteContainer(
padding: EdgeInsets.all(24),
child: BuyForm(),
),
],
), ),
), ),
const SizedBox( ),
width: 16, body: Padding(
padding: const EdgeInsets.only(
left: 24,
right: 24,
bottom: 24,
), ),
// Expanded( child: Row(
// child: Row( crossAxisAlignment: CrossAxisAlignment.start,
// children: const [ children: [
// Expanded( Expanded(
// child: DesktopTradeHistory(), child: Column(
// ), mainAxisSize: MainAxisSize.min,
// ], crossAxisAlignment: CrossAxisAlignment.start,
// ), children: const [
// ), SizedBox(
], height: 16,
),
RoundedWhiteContainer(
padding: EdgeInsets.all(24),
child: BuyForm(),
),
],
),
),
const SizedBox(
width: 16,
),
// Expanded(
// child: Row(
// children: const [
// Expanded(
// child: DesktopTradeHistory(),
// ),
// ],
// ),
// ),
],
),
),
), ),
), if (torEnabled)
Container(
color: Theme.of(context)
.extension<StackColors>()!
.overlay
.withOpacity(0.7),
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: DesktopDialog(
maxHeight: 200,
maxWidth: 350,
child: Padding(
padding: const EdgeInsets.all(
15.0,
),
child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Tor is enabled",
textAlign: TextAlign.center,
style: STextStyles.pageTitleH1(context),
),
const SizedBox(
height: 30,
),
Text(
"Purchasing not available while Tor is enabled",
textAlign: TextAlign.center,
style: STextStyles.desktopTextMedium(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.infoItemLabel,
),
),
],
),
),
),
),
],
); );
} }
} }