Skip to content

Commit

Permalink
tabs/depositwithdraw: pull actions out of modals
Browse files Browse the repository at this point in the history
  • Loading branch information
octobocto committed Aug 16, 2024
1 parent 2936d9d commit e8a15c3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,20 @@ class DepositWithdrawTabPage extends StatelessWidget {
spacing: SailStyleValues.padding30,
children: [
DashboardGroup(
title: 'Actions',
title: 'Deposit from parent chain',
widgetEnd: HelpButton(onPressed: () => viewModel.castHelp(context)),
children: [
ActionTile(
title: 'Deposit from parent chain',
category: Category.mainchain,
icon: Icons.add,
onTap: () {
viewModel.pegIn(context);
},
),
ActionTile(
title: 'Withdraw to parent chain',
category: Category.mainchain,
icon: Icons.remove,
onTap: () {
viewModel.pegOut(context);
},
),
if (viewModel._sidechain.rpc.chain.type == SidechainType.ethereum)
const PegInEthAction()
else
const PegInAction(),
],
),
DashboardGroup(
title: 'Withdraw to parent chain',
widgetEnd: HelpButton(onPressed: () => viewModel.castHelp(context)),
children: [
const PegOutAction(),
if (viewModel.localNetwork)
ActionTile(
title: 'Connect sidechain with parent chain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,6 @@ class SendViewModel extends BaseViewModel {
title: 'You sent $amount BTC to $address',
subtitle: 'TXID: $sendTXID',
);
// also pop the info modal
await _router.maybePop();
} catch (error) {
if (!context.mounted) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,8 @@ class PegOutAction extends StatelessWidget {
return ViewModelBuilder.reactive(
viewModelBuilder: () => PegOutViewModel(staticAddress: staticAddress),
builder: ((context, viewModel, child) {
return DashboardActionModal(
'Withdraw to parent chain',
endActionButton: SailButton.primary(
'Execute withdraw',
disabled: viewModel.bitcoinAddressController.text.isEmpty || viewModel.bitcoinAmountController.text.isEmpty,
loading: viewModel.isBusy,
size: ButtonSize.regular,
onPressed: () async {
viewModel.executePegOut(context);
},
),
return SailColumn(
spacing: 0,
children: [
LargeEmbeddedInput(
controller: viewModel.bitcoinAddressController,
Expand All @@ -71,6 +62,16 @@ class PegOutAction extends StatelessWidget {
label: 'Total amount',
value: '${viewModel.totalBitcoinAmount} BTC',
),
SailButton.primary(
'Execute withdraw',
disabled:
viewModel.bitcoinAddressController.text.isEmpty || viewModel.bitcoinAmountController.text.isEmpty,
loading: viewModel.isBusy,
size: ButtonSize.regular,
onPressed: () async {
viewModel.executePegOut(context);
},
),
],
);
}),
Expand Down Expand Up @@ -208,8 +209,6 @@ class PegOutViewModel extends BaseViewModel {
title: 'Submitted withdraw successfully',
subtitle: 'TXID: $withdrawalTxid',
);
// also pop the info modal
await _router.maybePop();
} catch (error) {
log.e('could not execute withdraw: $error', error: error);

Expand All @@ -235,22 +234,22 @@ class PegInAction extends StatelessWidget {
return ViewModelBuilder.reactive(
viewModelBuilder: () => PegInViewModel(),
builder: ((context, viewModel, child) {
return DashboardActionModal(
'Deposit from parent chain',
endActionButton: SailButton.primary(
'Generate new address',
loading: viewModel.isBusy,
size: ButtonSize.regular,
onPressed: () async {
await viewModel.generatePegInAddress();
},
),
return SailColumn(
spacing: SailStyleValues.padding10,
children: [
StaticActionField(
label: 'Address',
value: viewModel.pegInAddress ?? '',
copyable: true,
),
SailButton.primary(
'Generate new address',
loading: viewModel.isBusy,
size: ButtonSize.regular,
onPressed: () async {
await viewModel.generatePegInAddress();
},
),
],
);
}),
Expand Down

0 comments on commit e8a15c3

Please sign in to comment.