stack_wallet/lib/pages/buy_view/buy_view.dart

91 lines
2.3 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
2022-08-26 08:11:35 +00:00
import 'package:flutter/material.dart';
2023-09-12 22:59:07 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
import 'package:stackwallet/pages/buy_view/buy_form.dart';
2023-09-12 22:59:07 +00:00
import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
2023-09-12 22:59:07 +00:00
import 'package:stackwallet/widgets/stack_dialog.dart';
2022-08-26 08:11:35 +00:00
2023-09-12 22:59:07 +00:00
class BuyView extends ConsumerStatefulWidget {
const BuyView({
Key? key,
this.coin,
this.tokenContract,
}) : super(key: key);
2022-08-26 08:11:35 +00:00
final Coin? coin;
final EthContract? tokenContract;
2023-09-12 22:59:07 +00:00
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();
}
2022-08-26 08:11:35 +00:00
@override
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType");
2023-09-12 22:59:07 +00:00
return Stack(
children: [
SafeArea(
child: Padding(
padding: const EdgeInsets.only(
left: 16,
right: 16,
top: 16,
),
child: BuyForm(
coin: coin,
tokenContract: tokenContract,
),
),
),
2023-09-12 22:59:07 +00:00
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: const StackDialog(
title: "Tor is enabled",
message: "Purchasing not available while Tor is enabled",
),
),
],
);
2022-08-26 08:11:35 +00:00
}
}