Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tusharhow/connext
π "Introducing Connext: Real-time Connectivity Status in Jetpack Compose!" π
https://github.com/tusharhow/connext
compose connection jetpack library network
Last synced: about 1 month ago
JSON representation
π "Introducing Connext: Real-time Connectivity Status in Jetpack Compose!" π
- Host: GitHub
- URL: https://github.com/tusharhow/connext
- Owner: tusharhow
- License: mit
- Created: 2024-03-14T17:42:58.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-03-15T05:42:48.000Z (10 months ago)
- Last Synced: 2024-03-15T19:16:11.253Z (10 months ago)
- Topics: compose, connection, jetpack, library, network
- Language: Kotlin
- Homepage:
- Size: 20.1 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Connext
![Connext](art/header.png)
π Connext is a Jetpack Compose library to observe live connectivity status in a Compose way!
## π‘Introduction
Observing Live connectivity status in Jetpack Compose way! Connext is a Jetpack Compose library to observe live connectivity status in a Compose way! It provides a simple way to check connectivity status, network type, and internet connection status in Jetpack Compose.
## π Implementation
You can check [/app](/app) directory which includes example application for demonstration.
### Gradle setup
In `settings.gradle` include this```gradle
maven(url = "https://jitpack.io")
```In `build.gradle` of app module, include this dependency
```gradle
dependencies {
implementation ("com.github.tusharhow:Connext:1.0.0")
}
```_You can find latest version and changelogs in the [releases](https://github.com/tusharhow/Connext/releases)_.
### Usage
#### 1. Check Connectivity Status:
```kotlin
CheckConnectivityStatus(
connectedContent = {
Text("Connected")
},
disconnectedContent = {
Text("Disconnected")
}
)
```#### 2. Check Current Connectivity Type:
```kotlin
val context = LocalContext.current
val networkType = context.getNetworkType()when (networkType) {
is NetworkType.WIFI -> {
Text(text = "Connected to wifi")
}
is NetworkType.CELLULAR -> {
Text(text = "Connected to cellular")
}
is NetworkType.NONE -> {
Text(text = "No network")
}
}
```#### 3. Check Connected to the Internet:
```kotlin
val connection by connectivityStatus()
val isConnected = connection === ConnectionStatus.Connectedif (isConnected) {
Text(text = "Connected to internet")
} else {
Text(text = "No internet")
}
```## π License
```
MIT LicenseCopyright (c) 2024 Tushar Mahmud
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```