Skip to content

Commit

Permalink
Open flutter release page when user clicks on the fl_chart version on…
Browse files Browse the repository at this point in the history
… app_menu
  • Loading branch information
imaNNeo committed Nov 24, 2023
1 parent 60c6434 commit ba68376
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 8 additions & 0 deletions example/lib/cubits/app/app_cubit.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -17,6 +19,12 @@ class AppCubit extends Cubit<AppState> {
usingFlChartVersion: BuildConstants.usingFlChartVersion,
));
}

void onVersionClicked() {
AppUtils().tryToLaunchUrl(
Urls.getVersionReleaseUrl(state.usingFlChartVersion),
);
}
}

class BuildConstants {
Expand Down
4 changes: 4 additions & 0 deletions example/lib/presentation/menu/app_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -111,6 +112,9 @@ class _AppVersionRow extends StatelessWidget {
style: const TextStyle(
fontWeight: FontWeight.bold,
),
recognizer: TapGestureRecognizer()
..onTap = BlocProvider.of<AppCubit>(context)
.onVersionClicked,
),
]
],
Expand Down
7 changes: 6 additions & 1 deletion example/lib/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
}

0 comments on commit ba68376

Please sign in to comment.