2022-08-30 22:38:07 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
2022-10-03 19:18:57 +00:00
|
|
|
import 'package:stackwallet/pages/exchange_view/exchange_form.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart';
|
|
|
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
|
|
|
import 'package:stackwallet/utilities/text_styles.dart';
|
2022-09-22 23:48:50 +00:00
|
|
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
2022-11-25 19:24:01 +00:00
|
|
|
import 'package:stackwallet/widgets/background.dart';
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|
|
|
|
|
|
|
class WalletInitiatedExchangeView extends ConsumerStatefulWidget {
|
|
|
|
const WalletInitiatedExchangeView({
|
|
|
|
Key? key,
|
|
|
|
required this.walletId,
|
|
|
|
required this.coin,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
static const String routeName = "/walletInitiatedExchange";
|
|
|
|
|
|
|
|
final String walletId;
|
|
|
|
final Coin coin;
|
|
|
|
|
|
|
|
@override
|
|
|
|
ConsumerState<WalletInitiatedExchangeView> createState() =>
|
|
|
|
_WalletInitiatedExchangeViewState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _WalletInitiatedExchangeViewState
|
|
|
|
extends ConsumerState<WalletInitiatedExchangeView> {
|
|
|
|
late final String walletId;
|
|
|
|
late final Coin coin;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
walletId = widget.walletId;
|
|
|
|
coin = widget.coin;
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
debugPrint("BUILD: $runtimeType");
|
|
|
|
|
2022-11-25 19:24:01 +00:00
|
|
|
return Background(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
|
|
|
appBar: AppBar(
|
|
|
|
leading: AppBarBackButton(
|
|
|
|
onPressed: () async {
|
|
|
|
if (FocusScope.of(context).hasFocus) {
|
|
|
|
FocusScope.of(context).unfocus();
|
|
|
|
await Future<void>.delayed(const Duration(milliseconds: 75));
|
|
|
|
}
|
|
|
|
if (mounted) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
|
|
|
title: Text(
|
|
|
|
"Exchange",
|
|
|
|
style: STextStyles.navBarTitle(context),
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
body: LayoutBuilder(
|
|
|
|
builder: (context, constraints) {
|
|
|
|
final width = MediaQuery.of(context).size.width - 32;
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(12),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
child: ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(
|
|
|
|
minHeight: constraints.maxHeight - 24,
|
|
|
|
),
|
|
|
|
child: IntrinsicHeight(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
|
|
children: [
|
|
|
|
StepRow(
|
|
|
|
count: 4,
|
|
|
|
current: 0,
|
|
|
|
width: width,
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 14,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Exchange amount",
|
|
|
|
style: STextStyles.pageTitleH1(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"Network fees and other exchange charges are included in the rate.",
|
|
|
|
style: STextStyles.itemSubtitle(context),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 24,
|
|
|
|
),
|
|
|
|
ExchangeForm(
|
|
|
|
walletId: walletId,
|
|
|
|
coin: coin,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-11-25 19:24:01 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-08-26 08:11:35 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|