mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
77 lines
2.6 KiB
Dart
77 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
import 'package:wger/l10n/generated/app_localizations.dart';
|
|
|
|
/// Static widget displaying CC BY-SA 4.0 license notice for image uploads
|
|
///
|
|
/// This widget informs users that by uploading images, they agree to release
|
|
/// them under the CC BY-SA 4.0 license. The license name is clickable and
|
|
/// opens the Creative Commons license page.
|
|
///
|
|
/// Being a separate widget allows Flutter to optimize rendering since
|
|
/// this content never changes.
|
|
class LicenseInfoWidget extends StatelessWidget {
|
|
const LicenseInfoWidget({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(
|
|
color: colorScheme.surfaceVariant,
|
|
borderRadius: BorderRadius.circular(4),
|
|
border: Border.all(color: colorScheme.outline),
|
|
),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Icon(
|
|
Icons.info_outline,
|
|
size: 20,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: RichText(
|
|
text: TextSpan(
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: colorScheme.onSurfaceVariant,
|
|
),
|
|
children: [
|
|
TextSpan(
|
|
text: AppLocalizations.of(context).imageDetailsLicenseNoticePrefix,
|
|
),
|
|
WidgetSpan(
|
|
child: GestureDetector(
|
|
onTap: () async {
|
|
final url = Uri.parse('https://creativecommons.org/licenses/by-sa/4.0/');
|
|
if (await canLaunchUrl(url)) {
|
|
await launchUrl(url, mode: LaunchMode.externalApplication);
|
|
}
|
|
},
|
|
child: Text(
|
|
'CC BY-SA 4.0',
|
|
style: TextStyle(
|
|
fontSize: 12,
|
|
color: colorScheme.primary,
|
|
fontWeight: FontWeight.bold,
|
|
decoration: TextDecoration.underline,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
TextSpan(
|
|
text: AppLocalizations.of(context).imageDetailsLicenseNoticeSuffix,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
} |