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';
|
2023-03-28 23:17:59 +00:00
|
|
|
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
2023-01-10 21:25:20 +00:00
|
|
|
import 'package:stackwallet/pages/buy_view/buy_form.dart';
|
2023-09-15 15:25:18 +00:00
|
|
|
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart';
|
|
|
|
import 'package:stackwallet/services/tor_service.dart';
|
2023-09-12 22:59:07 +00:00
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
2024-05-15 21:20:45 +00:00
|
|
|
import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart';
|
2023-09-12 22:59:07 +00:00
|
|
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
2023-09-15 15:25:18 +00:00
|
|
|
import 'package:stackwallet/widgets/tor_subscription.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2023-09-12 22:59:07 +00:00
|
|
|
class BuyView extends ConsumerStatefulWidget {
|
2023-01-27 19:47:41 +00:00
|
|
|
const BuyView({
|
2024-05-15 21:20:45 +00:00
|
|
|
super.key,
|
2023-01-27 19:47:41 +00:00
|
|
|
this.coin,
|
2023-03-28 23:17:59 +00:00
|
|
|
this.tokenContract,
|
2024-05-15 21:20:45 +00:00
|
|
|
});
|
2022-08-26 08:11:35 +00:00
|
|
|
|
2024-05-15 21:20:45 +00:00
|
|
|
final CryptoCurrency? coin;
|
2023-03-28 23:17:59 +00:00
|
|
|
final EthContract? tokenContract;
|
2023-01-27 19:47:41 +00:00
|
|
|
|
2023-09-12 22:59:07 +00:00
|
|
|
static const String routeName = "/stackBuyView";
|
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<BuyView> createState() => _BuyViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _BuyViewState extends ConsumerState<BuyView> {
|
2024-05-15 21:20:45 +00:00
|
|
|
CryptoCurrency? coin;
|
2023-09-12 22:59:07 +00:00
|
|
|
EthContract? tokenContract;
|
2023-09-15 19:51:20 +00:00
|
|
|
|
|
|
|
late bool torEnabled;
|
2023-09-12 22:59:07 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
coin = widget.coin;
|
|
|
|
tokenContract = widget.tokenContract;
|
|
|
|
|
2023-09-15 19:51:20 +00:00
|
|
|
torEnabled =
|
|
|
|
ref.read(pTorService).status != TorConnectionStatus.disconnected;
|
2023-09-12 22:59:07 +00:00
|
|
|
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-01-14 16:41:02 +00:00
|
|
|
debugPrint("BUILD: $runtimeType");
|
2023-01-10 21:25:20 +00:00
|
|
|
|
2023-09-15 15:25:18 +00:00
|
|
|
return TorSubscription(
|
|
|
|
onTorStatusChanged: (status) {
|
|
|
|
setState(() {
|
|
|
|
torEnabled = status != TorConnectionStatus.disconnected;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: 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
|
|
|
),
|
|
|
|
),
|
2023-09-15 15:25:18 +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",
|
|
|
|
),
|
2023-09-12 22:59:07 +00:00
|
|
|
),
|
2023-09-15 15:25:18 +00:00
|
|
|
],
|
|
|
|
),
|
2023-01-14 16:41:02 +00:00
|
|
|
);
|
2022-08-26 08:11:35 +00:00
|
|
|
}
|
|
|
|
}
|