From df5d8c187a49976fd59f23a613a3f56f55b1b54d Mon Sep 17 00:00:00 2001 From: cialloo Date: Sun, 21 Jul 2024 17:40:57 +0800 Subject: [PATCH] feat: l10n about page --- lib/about_page.dart | 86 +++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 54 deletions(-) diff --git a/lib/about_page.dart b/lib/about_page.dart index 85ee6c6..9fc2a81 100644 --- a/lib/about_page.dart +++ b/lib/about_page.dart @@ -1,64 +1,42 @@ -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:url_launcher/url_launcher.dart'; +const _enContent = ''' +'''; // TODO + +const _zhContent = ''' +项目基于 n2n , 一款优秀的跨平台开源p2p VPN软件 +winui_n2n软件开源地址 https://github.com/moemoequte/winui_n2n +分发和使用请遵循 GPL-3.0 license 开源协议 + +作者信息 +网站 https://www.cialloo.com +邮箱 admin@cialloo.com +'''; + class AboutPage extends StatelessWidget { const AboutPage({super.key}); @override Widget build(BuildContext context) { - TextStyle defaultStyle = const TextStyle(fontSize: 16.0); - TextStyle linkStyle = const TextStyle(color: Colors.blue); - return Center( - child: SelectableText.rich( - TextSpan( - style: defaultStyle, - children: [ - const TextSpan( - text: '项目基于 n2n , 一款优秀的跨平台开源p2p VPN软件\n', - ), - const TextSpan( - text: 'winui_n2n软件开源地址 ', - ), - TextSpan( - text: 'https://github.com/moemoequte/winui_n2n\n', - style: linkStyle, - recognizer: TapGestureRecognizer() - ..onTap = () { - launchUrl( - Uri.parse('https://github.com/moemoequte/winui_n2n')); - }, - ), - const TextSpan( - text: '分发和使用请遵循 GPL-3.0 license 开源协议\n\n', - ), - const TextSpan( - text: '作者信息\n', - ), - const TextSpan(text: '网站 '), - TextSpan( - text: 'https://www.cialloo.com\n', - style: linkStyle, - recognizer: TapGestureRecognizer() - ..onTap = () { - launchUrl(Uri.parse('https://www.cialloo.com')); - }, - ), - const TextSpan(text: '邮箱 '), - TextSpan( - text: 'admin@cialloo.com', - style: linkStyle, - recognizer: TapGestureRecognizer() - ..onTap = () { - launchUrl(Uri( - scheme: 'mailto', - path: 'admin@cialloo.com', - )); - }, - ), - ], - ), - ), - ); + switch (Localizations.localeOf(context).toString()) { + case 'en': + return Markdown( + data: _enContent, + onTapLink: (text, href, title) { + launchUrl(Uri.parse(href!)); + }, + ); + case 'zh': + return Markdown( + data: _zhContent, + onTapLink: (text, href, title) { + launchUrl(Uri.parse(href!)); + }, + ); + } + + return const SizedBox(); } }