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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-01-20 05:10:15 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2023-01-16 00:09:11 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_svg/svg.dart';
|
2023-01-24 17:51:35 +00:00
|
|
|
import 'package:intl/intl.dart';
|
2023-01-16 00:09:11 +00:00
|
|
|
import 'package:stackwallet/models/buy/response_objects/quote.dart';
|
2023-01-16 00:35:20 +00:00
|
|
|
import 'package:stackwallet/pages/buy_view/sub_widgets/buy_warning_popup.dart';
|
2023-05-09 21:57:40 +00:00
|
|
|
import 'package:stackwallet/themes/stack_colors.dart';
|
2023-01-16 00:09:11 +00:00
|
|
|
import 'package:stackwallet/utilities/assets.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
|
|
|
import 'package:stackwallet/utilities/util.dart';
|
|
|
|
import 'package:stackwallet/widgets/background.dart';
|
|
|
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
|
|
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
|
|
|
|
|
|
|
class BuyQuotePreviewView extends StatefulWidget {
|
|
|
|
const BuyQuotePreviewView({
|
|
|
|
Key? key,
|
|
|
|
required this.quote,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final SimplexQuote quote;
|
|
|
|
|
|
|
|
static const String routeName = "/buyQuotePreview";
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<BuyQuotePreviewView> createState() => _BuyQuotePreviewViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _BuyQuotePreviewViewState extends State<BuyQuotePreviewView> {
|
|
|
|
final isDesktop = Util.isDesktop;
|
|
|
|
|
2023-01-16 00:35:20 +00:00
|
|
|
Future<void> _buyWarning() async {
|
|
|
|
await showDialog<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (context) => BuyWarningPopup(
|
2023-01-17 00:17:06 +00:00
|
|
|
quote: widget.quote,
|
2023-01-16 00:35:20 +00:00
|
|
|
),
|
|
|
|
);
|
2023-01-16 00:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-01-24 17:51:35 +00:00
|
|
|
Locale locale = Localizations.localeOf(context);
|
|
|
|
var format = NumberFormat.simpleCurrency(locale: locale.toString());
|
|
|
|
// See https://stackoverflow.com/a/67055685
|
|
|
|
|
2023-01-16 00:09:11 +00:00
|
|
|
return ConditionalParent(
|
|
|
|
condition: !isDesktop,
|
|
|
|
builder: (child) {
|
|
|
|
return Background(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
backgroundColor:
|
|
|
|
Theme.of(context).extension<StackColors>()!.backgroundAppBar,
|
|
|
|
leading: const AppBarBackButton(),
|
|
|
|
title: Text(
|
|
|
|
"Preview quote",
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
body: LayoutBuilder(
|
|
|
|
builder: (builderContext, constraints) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.only(
|
|
|
|
left: 12,
|
|
|
|
top: 12,
|
|
|
|
right: 12,
|
|
|
|
),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
minHeight: constraints.maxHeight - 24,
|
|
|
|
),
|
|
|
|
child: IntrinsicHeight(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Buy ${widget.quote.crypto.ticker.toUpperCase()}",
|
|
|
|
style: STextStyles.pageTitleH1(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 16,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"You pay",
|
|
|
|
style: STextStyles.label(context),
|
|
|
|
),
|
|
|
|
Text(
|
2023-01-24 17:51:35 +00:00
|
|
|
"${format.simpleCurrencySymbol(widget.quote.fiat.ticker.toUpperCase())}${widget.quote.youPayFiatPrice.toStringAsFixed(2)} ${widget.quote.fiat.ticker.toUpperCase()}",
|
2023-01-16 00:09:11 +00:00
|
|
|
style: STextStyles.label(context).copyWith(
|
|
|
|
color: Theme.of(context).extension<StackColors>()!.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
2023-01-24 17:05:30 +00:00
|
|
|
// RoundedWhiteContainer(
|
|
|
|
// child: Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
// children: [
|
|
|
|
// Text(
|
|
|
|
// "You pay with",
|
|
|
|
// style: STextStyles.label(context),
|
|
|
|
// ),
|
|
|
|
// Text(
|
|
|
|
// widget.quote.fiat.name,
|
|
|
|
// style: STextStyles.label(context).copyWith(
|
|
|
|
// color: Theme.of(context).extension<StackColors>()!.textDark,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// const SizedBox(
|
|
|
|
// height: 8,
|
|
|
|
// ),
|
2023-01-16 00:09:11 +00:00
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"You receive",
|
|
|
|
style: STextStyles.label(context),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"${widget.quote.youReceiveCryptoAmount} ${widget.quote.crypto.ticker.toUpperCase()}",
|
|
|
|
style: STextStyles.label(context).copyWith(
|
|
|
|
color: Theme.of(context).extension<StackColors>()!.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Receiving ${widget.quote.crypto.ticker.toUpperCase()} address",
|
|
|
|
style: STextStyles.label(context),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"${widget.quote.receivingAddress} ",
|
|
|
|
style: STextStyles.label(context).copyWith(
|
|
|
|
color: Theme.of(context).extension<StackColors>()!.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
2023-01-24 17:05:19 +00:00
|
|
|
"Quote ID",
|
2023-01-16 00:09:11 +00:00
|
|
|
style: STextStyles.label(context),
|
|
|
|
),
|
|
|
|
Text(
|
2023-01-19 23:47:27 +00:00
|
|
|
widget.quote.id,
|
2023-01-16 00:09:11 +00:00
|
|
|
style: STextStyles.label(context).copyWith(
|
|
|
|
color: Theme.of(context).extension<StackColors>()!.textDark,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
RoundedWhiteContainer(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
"Provider",
|
|
|
|
style: STextStyles.label(context),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 64,
|
2023-01-16 00:35:20 +00:00
|
|
|
height: 32,
|
|
|
|
child: SvgPicture.asset(
|
2023-01-24 17:12:40 +00:00
|
|
|
Assets.buy.simplexLogo(context),
|
2023-01-16 00:35:20 +00:00
|
|
|
),
|
2023-01-16 00:09:11 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
PrimaryButton(
|
|
|
|
label: "Buy",
|
2023-01-16 00:35:20 +00:00
|
|
|
onPressed: _buyWarning,
|
2023-01-16 00:09:11 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|