Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the drawer header logic to always open the landing page #1502

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
11 changes: 10 additions & 1 deletion 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 @@ -105,12 +106,20 @@ class _AppVersionRow extends StatelessWidget {
),
),
if (state.usingFlChartVersion.isNotBlank) ...[
const TextSpan(text: '\nfl_chart: '),
TextSpan(
text: '\nfl_chart: ',
recognizer: TapGestureRecognizer()
..onTap = BlocProvider.of<AppCubit>(context)
.onVersionClicked,
),
TextSpan(
text: 'v${state.usingFlChartVersion}',
style: const TextStyle(
fontWeight: FontWeight.bold,
),
recognizer: TapGestureRecognizer()
..onTap = BlocProvider.of<AppCubit>(context)
.onVersionClicked,
),
]
],
Expand Down
14 changes: 1 addition & 13 deletions example/lib/presentation/pages/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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/foundation.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

Expand Down Expand Up @@ -53,18 +52,7 @@ class HomePage extends StatelessWidget {
Navigator.of(context).pop();
}
},
onBannerClicked: kIsWeb || needsDrawer
? () async {
if (kIsWeb) {
await AppUtils().tryToLaunchUrl(Urls.flChartUrl);
return;
}
if (needsDrawer) {
Navigator.of(context).pop();
return;
}
}
: null,
onBannerClicked: () => AppUtils().tryToLaunchUrl(Urls.flChartUrl),
);
final samplesSectionWidget =
ChartSamplesPage(chartType: showingChartType);
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';
}
2 changes: 0 additions & 2 deletions example/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,5 @@
});
});
</script>

<script data-name="BMC-Widget" data-cfasync="false" src="https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js" data-id="fl_chart" data-description="Support me on Buy me a coffee!" data-message="Your support motivates me to work more on the fl_chart package. Thank you!" data-color="#5F7FFF" data-position="Right" data-x_margin="18" data-y_margin="18"></script>
</body>
</html>