From ba6837652246d44c01b19366e9e3076479d2a0c8 Mon Sep 17 00:00:00 2001 From: imaNNeoFighT Date: Fri, 24 Nov 2023 23:04:11 +0100 Subject: [PATCH] Open flutter release page when user clicks on the fl_chart version on app_menu --- example/lib/cubits/app/app_cubit.dart | 8 ++++++++ example/lib/presentation/menu/app_menu.dart | 4 ++++ example/lib/urls.dart | 7 ++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/example/lib/cubits/app/app_cubit.dart b/example/lib/cubits/app/app_cubit.dart index 317f1969b7..b33f890429 100644 --- a/example/lib/cubits/app/app_cubit.dart +++ b/example/lib/cubits/app/app_cubit.dart @@ -1,3 +1,5 @@ +import 'package:fl_chart_app/urls.dart'; +import 'package:fl_chart_app/util/app_utils.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:package_info_plus/package_info_plus.dart'; import 'package:equatable/equatable.dart'; @@ -17,6 +19,12 @@ class AppCubit extends Cubit { usingFlChartVersion: BuildConstants.usingFlChartVersion, )); } + + void onVersionClicked() { + AppUtils().tryToLaunchUrl( + Urls.getVersionReleaseUrl(state.usingFlChartVersion), + ); + } } class BuildConstants { diff --git a/example/lib/presentation/menu/app_menu.dart b/example/lib/presentation/menu/app_menu.dart index f4deffdf29..344dd43a6a 100644 --- a/example/lib/presentation/menu/app_menu.dart +++ b/example/lib/presentation/menu/app_menu.dart @@ -4,6 +4,7 @@ import 'package:fl_chart_app/presentation/resources/app_resources.dart'; import 'package:fl_chart_app/urls.dart'; import 'package:fl_chart_app/util/app_helper.dart'; import 'package:fl_chart_app/util/app_utils.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -111,6 +112,9 @@ class _AppVersionRow extends StatelessWidget { style: const TextStyle( fontWeight: FontWeight.bold, ), + recognizer: TapGestureRecognizer() + ..onTap = BlocProvider.of(context) + .onVersionClicked, ), ] ], diff --git a/example/lib/urls.dart b/example/lib/urls.dart index 83cb6d95b2..c1af6f5476 100644 --- a/example/lib/urls.dart +++ b/example/lib/urls.dart @@ -2,6 +2,10 @@ import 'package:fl_chart_app/util/app_helper.dart'; class Urls { static const flChartUrl = 'https://flchart.dev'; + static const flChartGithubUrl = 'https://github.com/imaNNeo/fl_chart'; + + static String get aboutUrl => '$flChartUrl/about'; + static String getChartSourceCodeUrl(ChartType chartType, int sampleNumber) { final chartDir = chartType.name.toLowerCase(); return 'https://github.com/imaNNeo/fl_chart/blob/master/example/lib/presentation/samples/$chartDir/${chartDir}_chart_sample$sampleNumber.dart'; @@ -12,5 +16,6 @@ class Urls { return 'https://github.com/imaNNeo/fl_chart/blob/master/repo_files/documentations/${chartDir}_chart.md'; } - static String get aboutUrl => '$flChartUrl/about'; + static String getVersionReleaseUrl(String version) => + '$flChartGithubUrl/releases/tag/$version'; }