From 1e8131549d48cc39fba3577136ed164b92e59286 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Sat, 5 Sep 2020 11:38:22 +0200 Subject: [PATCH] Feature Timeline: translate text with link to GitHub --- assets/langs/en.yaml | 1 + lib/screens/feature_timeline_screen.dart | 45 ++++++++++++++---------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/assets/langs/en.yaml b/assets/langs/en.yaml index af8edbbb..3e904a86 100644 --- a/assets/langs/en.yaml +++ b/assets/langs/en.yaml @@ -333,6 +333,7 @@ feature_timeline: title: Feature Timeline progress: In Progress plan: Planned + issues: GitJournal's development is tracked on Github. Please consider voting on the issues you consider important. purchase_screen: title: Pro Version diff --git a/lib/screens/feature_timeline_screen.dart b/lib/screens/feature_timeline_screen.dart index d7b90b8e..d1013015 100644 --- a/lib/screens/feature_timeline_screen.dart +++ b/lib/screens/feature_timeline_screen.dart @@ -159,32 +159,41 @@ class _DevelopmentText extends StatelessWidget { Widget build(BuildContext context) { var style = Theme.of(context).textTheme.bodyText2; + var str = tr('feature_timeline.issues'); + var i = str.toLowerCase().indexOf('github'); + if (i == -1) { + return Padding( + padding: const EdgeInsets.all(16.0), + child: RichText(text: TextSpan(children: [gitHubLink(str)])), + ); + } + + var before = str.substring(0, i); + var after = str.substring(i + 6); + return Padding( padding: const EdgeInsets.all(16.0), child: RichText( text: TextSpan( children: [ - TextSpan( - text: "GitJournal's development is tracked on ", - style: style, - ), - TextSpan( - text: 'GitHub', - style: const TextStyle(color: Colors.blue), - recognizer: TapGestureRecognizer() - ..onTap = () { - launch(githubUrl); - logEvent(Event.FeatureTimelineGithubClicked); - }, - ), - TextSpan( - text: - " Please consider voting on the issues you consider important.", - style: style, - ), + TextSpan(text: before, style: style), + gitHubLink('GitHub'), + TextSpan(text: after, style: style), ], ), ), ); } + + TextSpan gitHubLink(String text) { + return TextSpan( + text: text, + style: const TextStyle(color: Colors.blue), + recognizer: TapGestureRecognizer() + ..onTap = () { + launch(githubUrl); + logEvent(Event.FeatureTimelineGithubClicked); + }, + ); + } }