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

Add link laucher #3

Merged
merged 9 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions packages/zweidenker_heinzelmen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.2 - Added LinkLauncher
* Added LinkLauncher helper


## 0.0.1 - Initial Release
* Added the following helpers
* AppVersion
Expand Down
41 changes: 41 additions & 0 deletions packages/zweidenker_heinzelmen/lib/src/link_laucher.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'dart:io';

import 'package:flutter_web_browser/flutter_web_browser.dart';
import 'package:url_launcher/url_launcher.dart';

soeren-schmaljohann-2denker marked this conversation as resolved.
Show resolved Hide resolved
/// Wrapper class for opening url's inside apps
class LinkLauncher {
/// Creates a LinkLauncher
const LinkLauncher();

/// Opens an url in a modal style on a mobile device or in a new tap on a web client
/// Use [tabsOptions] to customize the Chrome taps on Android
soeren-schmaljohann-2denker marked this conversation as resolved.
Show resolved Hide resolved
/// Use [safariViewControllerOptions] to customize the SafariController on iOS
void openWebPage({
required String url,
CustomTabsOptions? tabsOptions,
SafariViewControllerOptions? safariViewControllerOptions,
}) {
if (Platform.isAndroid || Platform.isIOS) {
soeren-schmaljohann-2denker marked this conversation as resolved.
Show resolved Hide resolved
/// Opens an url in a modal style on a mobile device
FlutterWebBrowser.openWebPage(
url: url,
customTabsOptions: tabsOptions ??
const CustomTabsOptions(
instantAppsEnabled: true,
urlBarHidingEnabled: true,
),
safariVCOptions: safariViewControllerOptions ??
const SafariViewControllerOptions(
barCollapsingEnabled: true,
modalPresentationCapturesStatusBarAppearance: true,
dismissButtonStyle: SafariViewControllerDismissButtonStyle.done,
modalPresentationStyle: UIModalPresentationStyle.fullScreen,
),
);
} else {
/// Opens the url in a new tab in the browser
launch(url);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ library zweidenker_heinzelmen;
export 'package:zweidenker_heinzelmen/src/app_version.dart';
export 'package:zweidenker_heinzelmen/src/feature_toggle.dart';
export 'package:zweidenker_heinzelmen/src/simple_loader_mixin.dart';
export 'package:zweidenker_heinzelmen/src/link_laucher.dart';
4 changes: 3 additions & 1 deletion packages/zweidenker_heinzelmen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: zweidenker_heinzelmen
description: A Flutter Package with useful helpers that are used across Flutter Apps by ZWEIDENKER
version: 0.0.1
version: 0.0.2
repository: https://github.com/zweidenker/flutter-heinzelmen/packages/zweidenker_heinzelmen

environment:
Expand All @@ -10,8 +10,10 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_web_browser: ^0.17.1
package_info_plus: ^1.4.2
universal_platform: ^1.0.0+1
url_launcher: ^6.0.20

dev_dependencies:
flutter_test:
Expand Down