-
-
Notifications
You must be signed in to change notification settings - Fork 405
Expand file tree
/
Copy pathlicense_info_widget.dart
More file actions
67 lines (63 loc) · 2.41 KB
/
Copy pathlicense_info_widget.dart
File metadata and controls
67 lines (63 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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({super.key});
@override
Widget build(BuildContext context) {
final i18n = AppLocalizations.of(context);
final colorScheme = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: colorScheme.surfaceContainerHighest,
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: i18n.imageDetailsLicenseNotice),
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(
i18n.imageDetailsLicenseNoticeLinkToLicense,
style: TextStyle(
fontSize: 12,
color: colorScheme.primary,
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
),
),
),
],
),
),
),
],
),
);
}
}