-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore:
disable link glancing on mobile browsers
- Loading branch information
Showing
10 changed files
with
145 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<component name="ProjectRunConfigurationManager"> | ||
<configuration default="false" name="TEST_LIBRARY" type="FlutterTestConfigType" factoryName="Flutter Test"> | ||
<option name="testDir" value="$PROJECT_DIR$/test" /> | ||
<option name="useRegexp" value="false" /> | ||
<option name="additionalArgs" value="" /> | ||
<method v="2" /> | ||
</configuration> | ||
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class BrowserDetection { | ||
BrowserDetection._(); | ||
|
||
static final BrowserDetection instance = BrowserDetection._(); | ||
|
||
/// Returns the User Agent of the current browser. | ||
/// | ||
/// This is made available for testing purposes and to enable the option of | ||
/// disabling [LinkTargetRegion] on browser on mobile without breaking other | ||
/// non web platform. | ||
bool get isMobile => false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:link_target/link_target.dart'; | ||
|
||
import 'package:link_target/src/helpers/browser_detection.dart' | ||
if (dart.library.html) 'dart:ui_web'; | ||
|
||
@immutable | ||
final class LinkTargetPlatformWidget extends StatelessWidget { | ||
/// Decided whether the overlay should be applied or not depending on the | ||
/// platform. | ||
/// | ||
/// [LinkTargetRegion] should ever only be applied on web browsers with the | ||
/// exception of web browsers running on mobile devices. | ||
/// | ||
/// NOTE: Intended for internal use only. | ||
const LinkTargetPlatformWidget({ | ||
required this.onNoRegion, | ||
required this.onApplyRegion, | ||
super.key, | ||
}); | ||
|
||
final Widget onNoRegion; | ||
final Widget onApplyRegion; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
if (!kIsWeb && !Platform.environment.containsKey('FLUTTER_TEST')) { | ||
return onNoRegion; | ||
} | ||
|
||
if (BrowserDetection.instance.isMobile) return onNoRegion; | ||
|
||
return onApplyRegion; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters