desktop exchange flow tweaks and show QR code

This commit is contained in:
julian 2022-11-21 16:00:00 -06:00
parent e099089d04
commit c935c590c7
7 changed files with 121 additions and 31 deletions

View file

@ -1024,6 +1024,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
if (isDesktop) {
await showDialog<void>(
context: context,
barrierDismissible: false,
builder: (context) {
return DesktopDialog(
maxWidth: 720,
@ -1052,6 +1053,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
if (isDesktop) {
await showDialog<void>(
context: context,
barrierDismissible: false,
builder: (context) {
return DesktopDialog(
maxWidth: 720,

View file

@ -104,6 +104,7 @@ class DesktopStep1 extends ConsumerWidget {
await showDialog<void>(
context: context,
barrierColor: Colors.transparent,
barrierDismissible: false,
builder: (context) {
return DesktopDialog(
maxWidth: 720,

View file

@ -1,7 +1,10 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/contact_address_entry.dart';
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_3.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart';
import 'package:stackwallet/pages_desktop_specific/home/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart';
import 'package:stackwallet/providers/exchange/exchange_send_from_wallet_id_provider.dart';
@ -13,6 +16,8 @@ import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart';
@ -22,10 +27,6 @@ import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_text_field.dart';
import 'package:stackwallet/widgets/textfield_icon_button.dart';
import '../../../../models/contact_address_entry.dart';
import '../../../../widgets/desktop/desktop_dialog.dart';
import '../../../../widgets/desktop/desktop_dialog_close_button.dart';
class DesktopStep2 extends ConsumerStatefulWidget {
const DesktopStep2({
Key? key,
@ -552,8 +553,25 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
child: PrimaryButton(
label: "Next",
buttonHeight: ButtonHeight.l,
onPressed: () {
// todo
onPressed: () async {
await showDialog<void>(
context: context,
barrierColor: Colors.transparent,
barrierDismissible: false,
builder: (context) {
return DesktopDialog(
maxWidth: 720,
maxHeight: double.infinity,
child: StepScaffold(
step: 3,
model: model,
body: DesktopStep3(
model: model,
),
),
);
},
);
},
),
),

View file

@ -4,8 +4,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_4_view.dart';
import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart';
import 'package:stackwallet/providers/exchange/current_exchange_name_state_provider.dart';
import 'package:stackwallet/providers/exchange/exchange_provider.dart';
@ -16,10 +17,11 @@ import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/custom_loading_overlay.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/desktop/simple_desktop_dialog.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
class DesktopStep3 extends ConsumerStatefulWidget {
const DesktopStep3({
@ -76,14 +78,15 @@ class _DesktopStep3State extends ConsumerState<DesktopStep3> {
Navigator.of(context).pop();
}
unawaited(showDialog<void>(
unawaited(
showDialog<void>(
context: context,
barrierDismissible: true,
builder: (_) => StackDialog(
builder: (_) => SimpleDesktopDialog(
title: "Failed to create trade",
message: response.exception?.toString(),
message: response.exception?.toString() ?? ""),
),
));
);
return;
}
@ -106,7 +109,8 @@ class _DesktopStep3State extends ConsumerState<DesktopStep3> {
Navigator.of(context).pop();
}
unawaited(NotificationApi.showNotification(
unawaited(
NotificationApi.showNotification(
changeNowId: model.trade!.tradeId,
title: status,
body: "Trade ID ${model.trade!.tradeId}",
@ -115,13 +119,30 @@ class _DesktopStep3State extends ConsumerState<DesktopStep3> {
date: model.trade!.timestamp,
shouldWatchForUpdates: true,
coinName: "coinName",
));
),
);
if (mounted) {
unawaited(Navigator.of(context).pushNamed(
Step4View.routeName,
arguments: model,
));
unawaited(
showDialog<void>(
context: context,
barrierColor: Colors.transparent,
barrierDismissible: false,
builder: (context) {
return DesktopDialog(
maxWidth: 720,
maxHeight: double.infinity,
child: StepScaffold(
step: 4,
model: model,
body: DesktopStep4(
model: model,
),
),
);
},
),
);
}
}

View file

@ -2,12 +2,14 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:stackwallet/models/exchange/incomplete_exchange.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/rounded_container.dart';
@ -148,7 +150,7 @@ class _DesktopStep4State extends ConsumerState<DesktopStep4> {
DesktopStepItem(
label: "Amount",
value:
"${model.sendAmount.toString()} ${model.sendTicker.toUpperCase()}",
"${model.sendAmount.toStringAsFixed(8)} ${model.sendTicker.toUpperCase()}",
),
Container(
height: 1,
@ -208,7 +210,50 @@ class _DesktopStep4State extends ConsumerState<DesktopStep4> {
label: "Show QR code",
buttonHeight: ButtonHeight.l,
onPressed: () {
// todo
showDialog<dynamic>(
context: context,
barrierColor: Colors.transparent,
barrierDismissible: true,
builder: (_) {
return DesktopDialog(
maxHeight: 720,
maxWidth: 720,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Send ${model.sendAmount.toStringAsFixed(8)} ${model.sendTicker} to this address",
style: STextStyles.desktopH3(context),
),
const SizedBox(
height: 48,
),
Center(
child: QrImage(
// TODO: grab coin uri scheme from somewhere
// data: "${coin.uriScheme}:$receivingAddress",
data: model.trade!.payInAddress,
size: 290,
foregroundColor: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
),
const SizedBox(
height: 48,
),
SecondaryButton(
label: "Cancel",
width: 310,
buttonHeight: ButtonHeight.l,
onPressed: Navigator.of(context).pop,
),
],
),
);
},
);
},
),
),

View file

@ -24,6 +24,7 @@ class DesktopStepItem extends StatelessWidget {
child: ConditionalParent(
condition: vertical,
builder: (child) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
child,
const SizedBox(

View file

@ -31,6 +31,8 @@ class _DesktopTradeHistoryState extends ConsumerState<DesktopTradeHistory> {
if (hasHistory) {
return ListView.separated(
shrinkWrap: true,
primary: false,
itemBuilder: (context, index) {
return TradeCard(
key: Key("tradeCard_${trades[index].uuid}"),