2022-08-29 20:38:28 -06:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/gestures.dart';
|
2023-09-06 20:09:50 -06:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
2022-08-29 20:38:28 -06:00
|
|
|
import 'package:wonders/common_libs.dart';
|
2023-09-06 20:09:50 -06:00
|
|
|
import 'package:wonders/logic/common/platform_info.dart';
|
2022-08-29 20:38:28 -06:00
|
|
|
import 'package:wonders/ui/common/modals/fullscreen_web_view.dart';
|
|
|
|
|
|
|
|
class AboutDialogContent extends StatelessWidget {
|
2024-02-20 13:56:39 -08:00
|
|
|
const AboutDialogContent({super.key});
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2023-09-06 20:09:50 -06:00
|
|
|
void handleTap(String url) {
|
2023-12-04 14:54:00 -07:00
|
|
|
if (PlatformInfo.isDesktopOrWeb) {
|
2023-09-06 20:09:50 -06:00
|
|
|
launchUrl(Uri.parse(url));
|
|
|
|
} else {
|
|
|
|
Navigator.push(context, CupertinoPageRoute(builder: (_) => FullscreenWebView(url)));
|
|
|
|
}
|
|
|
|
}
|
2022-08-29 20:38:28 -06:00
|
|
|
|
|
|
|
List<TextSpan> buildSpan(String text, {Map<String, List<String>>? linkSupplants}) {
|
|
|
|
if (linkSupplants?.isNotEmpty ?? false) {
|
|
|
|
final r = RegExp(r'\{\w+\}');
|
|
|
|
final matches = r.allMatches(text);
|
|
|
|
final a = text.split(r);
|
|
|
|
|
|
|
|
final supplantKeys = matches.map((x) => x.group(0));
|
|
|
|
final sortedEntries = supplantKeys.map((x) => linkSupplants?.entries.firstWhere((e) => e.key == x));
|
|
|
|
|
|
|
|
final spans = <TextSpan>[];
|
|
|
|
for (var i = 0; i < a.length; i++) {
|
|
|
|
spans.add(TextSpan(text: a[i]));
|
|
|
|
if (i < sortedEntries.length) {
|
|
|
|
final label = sortedEntries.elementAt(i)!.value[0];
|
|
|
|
final link = sortedEntries.elementAt(i)!.value[1];
|
|
|
|
spans.add(TextSpan(
|
|
|
|
text: label,
|
|
|
|
recognizer: TapGestureRecognizer()..onTap = () => handleTap(link),
|
|
|
|
style: TextStyle(fontWeight: FontWeight.bold, color: $styles.colors.accent1),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return spans;
|
|
|
|
} else {
|
|
|
|
return [TextSpan(text: text)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-01 14:32:43 -07:00
|
|
|
double fontSize = $styles.text.body.fontSize!;
|
2022-09-01 21:04:25 -06:00
|
|
|
fontSize *= MediaQuery.textScaleFactorOf(context);
|
2022-08-29 20:38:28 -06:00
|
|
|
return SingleChildScrollView(
|
|
|
|
child: Column(children: [
|
|
|
|
Gap($styles.insets.sm),
|
|
|
|
RichText(
|
|
|
|
text: TextSpan(
|
2022-09-01 21:04:25 -06:00
|
|
|
style: $styles.text.bodySmall.copyWith(color: Colors.black, fontSize: fontSize),
|
2022-08-29 20:38:28 -06:00
|
|
|
children: [
|
|
|
|
...buildSpan($strings.homeMenuAboutWonderous),
|
2022-11-29 22:05:14 -07:00
|
|
|
...buildSpan($strings.homeMenuAboutBuilt('{flutterUrl}', '{gskinnerUrl}'), linkSupplants: {
|
2022-12-03 12:36:06 -07:00
|
|
|
'{flutterUrl}': [$strings.homeMenuAboutFlutter, 'https://flutter.dev'],
|
|
|
|
'{gskinnerUrl}': [$strings.homeMenuAboutGskinner, 'https://gskinner.com/flutter'],
|
2022-08-29 20:38:28 -06:00
|
|
|
}),
|
|
|
|
...buildSpan('\n\n'),
|
2022-12-12 09:32:25 -07:00
|
|
|
...buildSpan('${$strings.homeMenuAboutLearn('{wonderousUrl}')} ', linkSupplants: {
|
2022-12-12 10:12:50 -07:00
|
|
|
'{wonderousUrl}': [$strings.homeMenuAboutApp, 'https://flutter.gskinner.com/wonderous/'],
|
2022-08-29 20:38:28 -06:00
|
|
|
}),
|
2022-12-03 12:36:06 -07:00
|
|
|
...buildSpan($strings.homeMenuAboutSource('{githubUrl}'), linkSupplants: {
|
2022-12-12 09:33:26 -07:00
|
|
|
'{githubUrl}': [($strings.homeMenuAboutRepo), 'https://github.com/gskinnerTeam/flutter-wonderous-app'],
|
2022-08-29 20:38:28 -06:00
|
|
|
}),
|
2023-01-05 15:43:51 -07:00
|
|
|
...buildSpan(' ${$strings.privacyStatement('{privacyUrl}')}', linkSupplants: {
|
|
|
|
'{privacyUrl}': [$strings.privacyPolicy, 'https://flutter.gskinner.com/wonderous/privacy/'],
|
|
|
|
}),
|
2022-08-29 20:38:28 -06:00
|
|
|
...buildSpan('\n\n'),
|
2022-12-12 09:32:25 -07:00
|
|
|
...buildSpan('${$strings.homeMenuAboutPublic('{metUrl}')} ', linkSupplants: {
|
2022-12-03 12:36:06 -07:00
|
|
|
'{metUrl}': [
|
2022-08-29 20:38:28 -06:00
|
|
|
$strings.homeMenuAboutMet,
|
|
|
|
'https://www.metmuseum.org/about-the-met/policies-and-documents/open-access'
|
|
|
|
],
|
|
|
|
}),
|
2022-12-03 12:36:06 -07:00
|
|
|
...buildSpan($strings.homeMenuAboutPhotography('{unsplashUrl}'), linkSupplants: {
|
|
|
|
'{unsplashUrl}': [$strings.homeMenuAboutUnsplash, 'https://unsplash.com/@gskinner/collections'],
|
2022-08-29 20:38:28 -06:00
|
|
|
}),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|