- Added flutter_linkify package to auto-detect and linkify URLs in chat messages. - Implemented LinkHandler class to manage link tap confirmations and URL launching. - Updated chat_screen.dart to use Linkify for displaying message text with links. - Registered url_launcher plugin for handling URL launches across platforms. - Updated pubspec.yaml and pubspec.lock to include new dependencies. - Cleaned up untranslated.json by removing unused translations.chore/offband-rebrand
parent
1cc887e5bb
commit
a0be63b2e7
@ -0,0 +1,76 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import '../l10n/l10n.dart';
|
||||||
|
|
||||||
|
class LinkHandler {
|
||||||
|
static Future<void> handleLinkTap(BuildContext context, String url) async {
|
||||||
|
// Show confirmation dialog
|
||||||
|
final shouldOpen = await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: Text(context.l10n.chat_openLink),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
context.l10n.chat_openLinkConfirmation,
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: SelectableText(
|
||||||
|
url,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
fontFamily: 'monospace',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context, false),
|
||||||
|
child: Text(context.l10n.common_cancel),
|
||||||
|
),
|
||||||
|
FilledButton(
|
||||||
|
onPressed: () => Navigator.pop(context, true),
|
||||||
|
child: Text(context.l10n.chat_open),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (shouldOpen != true) return;
|
||||||
|
|
||||||
|
// Launch URL
|
||||||
|
try {
|
||||||
|
final uri = Uri.parse(url);
|
||||||
|
if (!await launchUrl(uri, mode: LaunchMode.externalApplication)) {
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(context.l10n.chat_couldNotOpenLink(url)),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(context.l10n.chat_invalidLink),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,121 +1 @@
|
|||||||
{
|
{}
|
||||||
"bg": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"de": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"es": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"fr": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"it": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"nl": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"pl": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"pt": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"sk": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"sl": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"sv": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
],
|
|
||||||
|
|
||||||
"zh": [
|
|
||||||
"community_regenerateSecret",
|
|
||||||
"community_regenerateSecretConfirm",
|
|
||||||
"community_regenerate",
|
|
||||||
"community_secretRegenerated",
|
|
||||||
"community_updateSecret",
|
|
||||||
"community_secretUpdated",
|
|
||||||
"community_scanToUpdateSecret"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Loading…
Reference in new issue