Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahyangnb/overlay_windows_plugin
https://github.com/ahyangnb/overlay_windows_plugin
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/ahyangnb/overlay_windows_plugin
- Owner: ahyangnb
- License: mit
- Created: 2024-11-10T02:37:09.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-10T02:49:01.000Z (2 months ago)
- Last Synced: 2024-11-10T03:27:05.374Z (2 months ago)
- Language: Kotlin
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# overlay_windows_plugin
- The Flutter plugin to integrate with the Window Manager Service in the Android for showing overlay windows over other apps.
- There is no limit to the number of overlays that will be shown at the same time and each overlay window could use a different UI or layout as desired.
- All the overlay windows could be able to communicate with the main view or others via a message channel.This plugin currently supports Android only.
## Demo
![Demo](doc/demo_overlay_plugin.gif 'overlay windows plugin')
## How to use
- Installation:
```
dependencies:
overlay_windows_plugin: any
```- Set up the permission in the AndroidManifest.xml in the Android folder:
```
...
...
...
```
- Indicate the entry points to build the layout & UI of the overlay windows. These entry points must be defined in the `main.dart` file.
```
@pragma("vm:entry-point")
void overlayMain1() {
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: SafeArea(
child: OverlayMain1(),
),
),
);
}@pragma("vm:entry-point")
void overlayMain2() {
runApp(
const MaterialApp(
debugShowCheckedModeBanner: false,
home: OverlayMain2(),
),
);
}
```- Declare the plugin instance
```
final _overlayWindowsPlugin = OverlayWindowsPlugin.defaultInstance;
```- Open a new overlay windows with the specific entry point
```
_overlayWindowsPlugin.showOverlayWindow(
id,
"overlayMain1",
OverlayWindowConfig(
width: 300,
height: 100,
enableDrag: true,
));
```- The available options when opening a overlay window
```
OverlayWindowConfig({
this.height,
this.width,
this.alignment,
this.flag,
this.enableDrag,
this.positionGravity,
});
```- Close the overlay windows
```
_overlayWindowsPlugin.closeOverlayWindow("overlay window id");
```- Send message to all opened overlay windows from main view
```
_overlayWindowsPlugin.sendMessage("", "Hello from main");
```- To receive the messages from overlay windows or Touch events from overlay windows, list the corresponding stream
```
_overlayWindowsPlugin.messageStream.listen((event) {
setState(() {
message.add(event);
});
});_overlayWindowsPlugin.touchEventStream.listen((event) {});
```- on each overlay window view, initiate a view to communicate with the main view
```
final view = OverlayWindowView();
``````
view.stateChangedStream.listen((event) {
setState(() {
viewId = event;
});
});view.messageStream.listen((mes) {
setState(() {
message = mes.message as String;
});
});view.sendMessage('Hello from overlay $viewId');
```
### Overlay window plugin API
```
OverlayWindowApi {
Stream get messageStream;
Stream get touchEventStream;bool isPermissionGranted();
void requestPermission();
void showOverlayWindows(String overlayWindowId, String entryPointName, OverlayWindowConfig config);
void closeOverlayWindows(String overlayWindowId);
bool isActive(String overlayWindowId);
void setFlags(String overlayWindowId, OverlayFlag flag);
void resize(String overlayWindowId, int width, int height);
}
```### Overlay window view API
```
class OverlayWindowView {
Stream get stateChangedStream; //stream for overlay window id changes
Stream get messageStream;Future close();
Future sendMessage(dynamic message);
}
```