Skip to content

Commit

Permalink
First commit :)
Browse files Browse the repository at this point in the history
  • Loading branch information
svenjacobs committed Nov 24, 2022
0 parents commit 8563063
Show file tree
Hide file tree
Showing 73 changed files with 1,913 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{kt,kts}]
charset = utf-8
indent_style = tab
indent_size = 4
# ktlint configuration
ktlint_code_style = android
#ktlint_disabled_rules =
ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true

[*.md]
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions .github/actions/gradle-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Gradle Cache
description: 'Setup Gradle cache'

runs:
using: 'composite'
steps:
- uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/libs.versions.toml') }}
restore-keys: ${{ runner.os }}-gradle
21 changes: 21 additions & 0 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deploy Release

on:
release:
types: [ published ]

jobs:
deploy:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/gradle-cache
- name: Deploy release
env:
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
run: ./gradlew publishToSonatype closeSonatypeStagingRepository
22 changes: 22 additions & 0 deletions .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Verify Pull Request

on: [ pull_request, workflow_dispatch ]

jobs:
check:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/gradle-cache
- name: Check app
run: ./gradlew check

test:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/gradle-cache
- name: Run tests
run: ./gradlew test
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions .idea/git_toolbox_prj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
The MIT license (MIT)

Copyright (c) 2022 Sven Jacobs

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.
101 changes: 101 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
Reveal is a lightweight, simple reveal effect (also known as coach mark, onboarding, tutorial, etc.)
with a beautiful API for [Jetpack Compose](https://developer.android.com/jetpack/compose).

![Demonstration](./assets/demo.gif)

## Terminology

| Term | Description |
|-------------|--------------------------------------------------------------------------------------------|
| Revealable | An element which is revealed on the screen. |
| Reveal area | The area which is revealed around the revealable. Usually with a slight padding. |
| Overlay | The overlay which greys out all contents except revealable. Can contain explanatory items. |

## Getting started

### Installation

Add Reveal as a dependency to your project. It's available on Maven Central.

```kotlin
dependencies {
implementation("com.svenjacobs.reveal:reveal-core:$REVEAL_VERSION")
}
```

### Compose

Since you probably want the reveal effect to cover the whole screen, the `Reveal` composable should
be one of the top most composables in the hierarchy of your screen-level composable.

```kotlin
@Composable
fun MainScreen(
modifier: Modifier = Modifier,
) {
val revealState = rememberRevealState()

Reveal(
modifier = modifier.fillMaxSize(),
revealState = revealState,
onRevealableClick = {},
onOverlayClick = {},
) {
// Contents
}
}
```

Inside `Reveal` specify revealable items via the `revealable` modifier.

```kotlin
enum class Keys { HelloWorld }

Column {
Text(
modifier = Modifier.revealable(key = Keys.HelloWorld),
text = "Hello world",
)
}
```

Now launch the reveal effect via `revealState.reveal(Keys.HelloWorld)`.

Nice, you just launched your first reveal effect. But what is missing is some explanatory item like
text or image next to the reveal area. So let's add one.

Explanatory items are specified via `overlayContent` of the `Reveal` composable.

```kotlin
Reveal(
overlayContent = { key ->
when (key) {
Keys.HelloWorld -> {
Surface(
modifier = Modifier
.align(RevealOverlayAlignment.Start)
.padding(8.dp),
shape = RoundedCornerShape(4.dp),
color = Color.White,
) {
Text("This is an explanation")
}
}
}
}
) {
// Contents
}
```

The scope of the overlay content composable provides the `align()` modifier to align the item either
to the start, top, end or bottom of the reveal area.

`Reveal` provides two click listeners: `onRevealableClick` is called when the reveal area is clicked
with the key of the current revealable as the first argument. `onOverlayClick` is called when the
overlay is clicked somewhere, also with the key argument. Use any of these click listeners to reveal
the next item, for example for some kind of tutorial, or to hide the effect via
`revealState.hide()`.

That's it for now. For more details have a look at the [demo application](./demo-android) and the
JavaDoc. The library is well documented 😉
Binary file added assets/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask

plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
alias(libs.plugins.nexus.publish)
alias(libs.plugins.ben.manes.versions)
alias(libs.plugins.kotlinter)
}

group = Publication.group
version = Publication.version

subprojects {
apply(plugin = "org.jmailen.kotlinter")

kotlinter {
experimentalRules = true
}
}

nexusPublishing {
repositories {
sonatype()
}
}

tasks.withType<DependencyUpdatesTask> {

fun isNonStable(version: String) =
listOf("alpha", "beta", "rc", "eap", "-m", ".m", "-a", "dev").any {
version.toLowerCase().contains(it)
}

rejectVersionIf {
isNonStable(candidate.version) && !isNonStable(currentVersion)
}
}
1 change: 1 addition & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading

0 comments on commit 8563063

Please sign in to comment.