Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
moazelsawaf committed Mar 3, 2023
0 parents commit 7b4db7f
Show file tree
Hide file tree
Showing 58 changed files with 2,354 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
30 changes: 30 additions & 0 deletions .metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.

version:
revision: 9944297138845a94256f1cf37beb88ff9a8e811a
channel: stable

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
- platform: android
create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a
base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* Initial release 🎉
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright 2022 Moaz El-sawaf. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
125 changes: 125 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<img src="https://raw.githubusercontent.com/moazelsawaf/dash_bubble/main/doc/assets/package_banner.png" width="100%" alt="Dash Flags Banner" />
<h2 align="center">
Dash Bubble
</h2>

<p align="center">
<a href="https://flutter.dev">
<img src="https://img.shields.io/badge/Platform-Flutter-02569B?logo=flutter" alt="Platform">
</a>
<a href="https://pub.dartlang.org/packages/dash_bubble">
<img alt="Pub Package" src="https://img.shields.io/pub/v/dash_bubble.svg?color=blue">
</a>
<a href="https://opensource.org/licenses/BSD-3-Clause"
rel="ugc"><img src="https://img.shields.io/badge/License-BSD_3--Clause-red.svg" alt="License: BSD-3-Clause"></a>
<br>
<a href="https://github.com/moazelsawaf/dash_bubble" rel="ugc"><img src="https://img.shields.io/github/languages/code-size/moazelsawaf/dash_bubble.svg" alt="GitHub code size in bytes"></a>
<a href="https://github.com/moazelsawaf/dash_bubble">
<img src="https://img.shields.io/github/stars/moazelsawaf/dash_bubble.svg?style=flat&logo=github&colorB=ffcc00&label=stars" alt="Star on GitHub">
</a>
<a href="https://github.com/moazelsawaf/dash_bubble/issues" rel="ugc"><img src="https://img.shields.io/github/issues/moazelsawaf/dash_bubble.svg?color=DF1304" alt="GitHub Open Issues"></a>
<a href="https://github.com/moazelsawaf/dash_bubble/commits/main" rel="ugc"><img src="https://img.shields.io/github/last-commit/moazelsawaf/dash_bubble.svg" alt="GitHub Last Commit Date"></a>
</p>

---

## 💡 Overview

A Flutter plugin that allows you to create a floating bubble on the screen built on top of [Floating-Bubble-View](https://github.com/TorryDo/Floating-Bubble-View) library by [TorryDo](https://github.com/TorryDo) 💙

*The plugin currently supports **Android** only.*

<br>
<p align="center">
<img src="https://raw.githubusercontent.com/moazelsawaf/dash_bubble/main/doc/assets/animated_example.webp" width="50%" alt="Animated Example" />
<br>
This GIF is taken from the <a href="https://github.com/moazelsawaf/dash_bubble/tree/main/example">Example Project</a>
</p>

## 🔧 Setup
Set the minimum SDK version to `21` or higher in your `android/app/build.gradle` file:

```gradle
android {
defaultConfig {
...
minSdkVersion 21 // Set this to 21 or higher
...
}
}
```

The plugin uses these two permissions but you don't need to add them to your `AndroidManifest.xml` file because the plugin will add them automatically:

```xml
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
```

## 💻 Usage

Import the package:

```dart
import 'package:dash_bubble/dash_bubble.dart';
```

Use the singleton instance of `DashBubble` to access all the available methods, for example:

```dart
DashBubble.instance.requestPermission()
DashBubble.instance.startBubble()
```

📘 You can checkout the complete API Reference [here](https://pub.dev/documentation/dash_bubble/latest/)

## 🧰 Available Methods

**Note**: All the methods are asynchronous and has a return type of `Future<bool>`.

| Method | Description | Parameters | Behavior | Notes |
| --- | --- | --- | --- | --- |
| `requestPermission()` | Requests the permission to draw over other apps | - | Returns `true` if the permission is granted, `false` otherwise | If the permission is already granted, this method will return `true` without asking the user<br><br>In Android versions prior to `Android 6.0 (M)`, this method will return `true` without asking the user |
| `hasPermission()` | Checks if the permission to draw over other apps is granted | - | Returns `true` if the permission is granted, `false` otherwise | - |
| `isRunning()` | Checks if the bubble is currently running | - | Returns `true` if the bubble is running, `false` otherwise | The bubble is considered running if it is visible on the screen |
| `startBubble()` | Starts the bubble | BubbleOptions? options<br><br>Function()? onBubbleTap | Returns `true` if the bubble started successfully, `false` otherwise | If the bubble is already running or the permission is not granted, this method will return `false` |
| `stopBubble()` | Stops the bubble | - | Returns `true` if the bubble stopped successfully, `false` otherwise | If the bubble is not running, this method will return `false` |

## 📝 Bubble Customization Options

**Note**: All the options are optional and you can pass only the options you want to customize.

| Option | Description | Default |
| --- | --- | --- |
| `notificationTitle` | The title of the service notification | `null` |
| `notificationText` | The text of the service notification | `null` |
| `notificationIcon` | The icon of the service notification | `null` |
| `bubbleIcon` | The icon of the bubble | `null` |
| `closeIcon` | The icon of the close button | `null` |
| `startLocationX` | The initial starting position of the bubble on the x axis | `0` |
| `startLocationY` | The initial starting position of the bubble on the y axis | `200` |
| `bubbleSize` | The size of the bubble | `60` |
| `enableClose` | Whether to show the close button or not | `true` |
| `enableAnimateToEdge` | Whether to animate the bubble to the edge of the screen when it is dragged to the edge of the screen or not | `true` |
| `enableBottomShadow` | Whether to show the bottom shadow behind the close button of the bubble or not | `true` |
| `keepAliveWhenAppExit` | Whether to keep the bubble alive when the app is closed or not | `false` |

## ✅ Roadmap

- [ ] Add Tests 🧪
- [ ] Implement a ready-to-use `AppBubble` which starts automatically when the app is on the background and stops when the app is on the foreground and has the ability to bring the app to the foreground when the bubble is tapped 📱
- [ ] Ability to pass a `Widget` as the `bubbleIcon` and `closeIcon` 💪🏻
- [ ] Implement the `ExpandableView` feature in the original library ⚡

## 💪🏻 Contribution Guide

I would be happy to have your contributions 💙

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an [Issue](https://github.com/moazelsawaf/dash_bubble/issues).
If you fixed a bug or implemented a feature, please send a [Pull Request](https://github.com/moazelsawaf/dash_bubble/pulls).

<a href="https://github.com/moazelsawaf/dash_bubble/graphs/contributors">
<img src="https://contrib.rocks/image?repo=moazelsawaf/dash_bubble" />
</a>

Made with [contrib.rocks](https://contrib.rocks).
4 changes: 4 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
9 changes: 9 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.cxx
58 changes: 58 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
group 'dev.moaz.dash_bubble'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
mavenCentral()
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
minSdkVersion 21
}
}

dependencies {
// def lifecycle_version = "2.5.1"

implementation "androidx.core:core-ktx:1.9.0"
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
implementation("io.github.torrydo:floating-bubble-view:0.4.1")

// implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version"
// implementation "androidx.lifecycle:lifecycle-common:$lifecycle_version"
}
Binary file added android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 7b4db7f

Please sign in to comment.