mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
* refactor: cleanup cake_pay folder * refactor: add My Cards tab on the main screen * ui: add user card item * refactor: cakePay purchase flow * feat: add user card info * refactor: auth flow * refactor: theme data * revert * Update qr_widget.dart * fix: update with new themes * minor fixes * feat: put redemption flow under a feature flag * feat: implement simulated purchasing flow in debug mode * feat: support LTC and MWEB payments * Update savings_page.dart * fix: UI fixes * add Cake Pay transaction sent bottom sheet * localization * Update cake_pay_buy_card_page.dart * addressing review comments * fix marge conflicts
66 lines
1.9 KiB
Dart
66 lines
1.9 KiB
Dart
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
class ClickableLinksText extends StatelessWidget {
|
|
const ClickableLinksText({
|
|
required this.text,
|
|
required this.textStyle,
|
|
this.linkStyle,
|
|
});
|
|
|
|
final String text;
|
|
final TextStyle textStyle;
|
|
final TextStyle? linkStyle;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
List<InlineSpan> spans = [];
|
|
RegExp linkRegExp = RegExp(r'(https?://[^\s]+)');
|
|
Iterable<Match> matches = linkRegExp.allMatches(text);
|
|
|
|
int previousEnd = 0;
|
|
matches.forEach((match) {
|
|
if (match.start > previousEnd) {
|
|
spans.add(TextSpan(text: text.substring(previousEnd, match.start), style: textStyle));
|
|
}
|
|
String url = text.substring(match.start, match.end);
|
|
if (url.toLowerCase().endsWith('.md')) {
|
|
spans.add(
|
|
TextSpan(
|
|
text: url,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.primary,
|
|
fontSize: 18,
|
|
),
|
|
recognizer: TapGestureRecognizer()
|
|
..onTap = () async {
|
|
if (await canLaunchUrl(Uri.parse(url))) {
|
|
await launchUrl(Uri.parse(url), mode: LaunchMode.externalApplication);
|
|
}
|
|
},
|
|
),
|
|
);
|
|
} else {
|
|
spans.add(
|
|
TextSpan(
|
|
text: url,
|
|
style: linkStyle,
|
|
recognizer: TapGestureRecognizer()
|
|
..onTap = () {
|
|
launchUrl(Uri.parse(url));
|
|
},
|
|
),
|
|
);
|
|
}
|
|
previousEnd = match.end;
|
|
});
|
|
|
|
if (previousEnd < text.length) {
|
|
spans.add(TextSpan(text: text.substring(previousEnd), style: textStyle));
|
|
}
|
|
|
|
return RichText(text: TextSpan(children: spans));
|
|
}
|
|
}
|