Skip to content

Commit

Permalink
feat(cat-voices): add constants and URL parsing for supported wallets…
Browse files Browse the repository at this point in the history
… in registration panel. Launching url in new tab (#1127)

Co-authored-by: Dominik Toton <166132265+dtscalac@users.noreply.github.com>
  • Loading branch information
LynxLynxx and dtscalac authored Nov 5, 2024
1 parent d967d27 commit a08cbed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
abstract class VoicesConstants {
/// External urls
static const String supportedWalletsUrl =
'https://docs.projectcatalyst.io/current-fund/voter-registration/supported-wallets';
}
6 changes: 6 additions & 0 deletions catalyst_voices/apps/voices/lib/common/ext/string_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ extension StringExt on String {
}
}
}

extension UrlParser on String {
Uri getUri() {
return Uri.parse(this);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:async';

import 'package:catalyst_voices/common/constants/constants.dart';
import 'package:catalyst_voices/common/ext/string_ext.dart';
import 'package:catalyst_voices/pages/registration/wallet_link/bloc_wallet_link_builder.dart';
import 'package:catalyst_voices/pages/registration/widgets/registration_stage_message.dart';
import 'package:catalyst_voices/widgets/common/infrastructure/voices_result_builder.dart';
Expand All @@ -11,6 +13,7 @@ import 'package:catalyst_voices_models/catalyst_voices_models.dart';
import 'package:catalyst_voices_shared/catalyst_voices_shared.dart';
import 'package:flutter/material.dart';
import 'package:result_type/result_type.dart';
import 'package:url_launcher/url_launcher.dart';

/// Callback called when a [wallet] is selected.
typedef _OnSelectWallet = Future<void> Function(WalletMetadata wallet);
Expand Down Expand Up @@ -57,7 +60,7 @@ class _SelectWalletPanelState extends State<SelectWalletPanel> {
const SizedBox(height: 10),
VoicesTextButton(
trailing: VoicesAssets.icons.externalLink.buildIcon(),
onTap: () {},
onTap: () async => _launchSupportedWalletsLink(),
child: Text(context.l10n.seeAllSupportedWallets),
),
],
Expand All @@ -76,6 +79,13 @@ class _SelectWalletPanelState extends State<SelectWalletPanel> {
registration.nextStep();
}
}

Future<void> _launchSupportedWalletsLink() async {
final url = VoicesConstants.supportedWalletsUrl.getUri();
if (!await launchUrl(url)) {
throw Exception('Could not launch $url');
}
}
}

class _BlocWallets extends StatelessWidget {
Expand Down

0 comments on commit a08cbed

Please sign in to comment.