-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Nek-12/ci
Configured CI
- Loading branch information
Showing
37 changed files
with
283 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8 -XX:+UseParallelGC | ||
android.useAndroidX=true | ||
kotlin.code.style=official | ||
org.gradle.caching=true | ||
org.gradle.parallel=true | ||
android.enableR8.fullMode=true | ||
org.gradle.configureondemand=true | ||
org.gradle.unsafe.configuration-cache=false | ||
android.enableJetifier=false | ||
kotlin.incremental.usePreciseJavaTracking=true | ||
android.nonTransitiveRClass=true | ||
warningsAsErrors=true | ||
org.gradle.daemon=false | ||
org.gradle.workers.max=2 | ||
#kotlin.incremental=false | ||
#kotlin.compiler.execution.strategy=in-process |
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,58 @@ | ||
name: CI | ||
|
||
on: | ||
# push: | ||
# branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Copy CI gradle.properties | ||
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | ||
|
||
- name: set up JDK | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 17 | ||
|
||
- name: Make files executable | ||
run: chmod +x ./gradlew && chmod +x ./scripts/checksum.sh | ||
|
||
- name: Generate cache key | ||
run: ./scripts/checksum.sh checksum.txt | ||
|
||
- name: Create local properties | ||
env: | ||
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES }} | ||
run: echo "$LOCAL_PROPERTIES" > local.properties | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches/modules-* | ||
~/.gradle/caches/jars-* | ||
~/.gradle/caches/build-cache-* | ||
key: gradle-${{ hashFiles('checksum.txt') }} | ||
|
||
# - name: Lint | ||
# run: ./gradlew lintDebug --stacktrace | ||
|
||
- name: Run detekt | ||
run: ./gradlew detektAll | ||
|
||
- name: Build debug | ||
run: ./gradlew assembleDebug --stacktrace | ||
|
||
- name: Build release | ||
run: ./gradlew assembleRelease --stacktrace | ||
|
||
- name: Unit tests | ||
run: ./gradlew test --stacktrace |
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 |
---|---|---|
|
@@ -60,7 +60,6 @@ hs_err_pid* | |
[Ll]ib | ||
[Ll]ib64 | ||
[Ll]ocal | ||
[Ss]cripts | ||
pyvenv.cfg | ||
.venv | ||
pip-selfcheck.json | ||
|
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 |
---|---|---|
|
@@ -15,7 +15,6 @@ android { | |
} | ||
} | ||
|
||
|
||
dependencies { | ||
api(project(":android")) | ||
|
||
|
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
27 changes: 22 additions & 5 deletions
27
android-compose/src/main/kotlin/com/nek12/flowMVI/android/compose/MVIComposable.kt
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 |
---|---|---|
@@ -1,29 +1,46 @@ | ||
package com.nek12.flowMVI.android.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.Stable | ||
import androidx.compose.runtime.getValue | ||
import androidx.lifecycle.Lifecycle | ||
import com.nek12.flowMVI.MVIAction | ||
import com.nek12.flowMVI.MVIIntent | ||
import com.nek12.flowMVI.MVIProvider | ||
import com.nek12.flowMVI.MVIState | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
@Composable | ||
/** | ||
* A function that introduces MVIIntentScope to the content and ensures safe lifecycle-aware and efficient collection | ||
* of states and actions. | ||
* Usage: | ||
* ``` | ||
* @Composable | ||
* fun HomeScreen() = MVIComposable(getViewModel<HomeViewModel>()) { state -> | ||
* consume { action -> | ||
* when(action) { | ||
* /*...*/ | ||
* } | ||
* } | ||
* when(state) { | ||
* //use state to render content | ||
* } | ||
* } | ||
* ``` | ||
* @param provider an MVIProvider (usually a viewModel) that handles this screen's logic | ||
* @param lifecycleState the minimum lifecycle state, in which the activity must be to receive actions/states | ||
* @param content the actual screen content. Will be recomposed each time you receive a new state | ||
* @param content the actual screen content. Will be recomposed each time a new state is received. | ||
*/ | ||
fun <S: MVIState, I: MVIIntent, A: MVIAction, VM: MVIProvider<S, I, A>> MVIComposable( | ||
@Composable | ||
fun <S : MVIState, I : MVIIntent, A : MVIAction, VM : MVIProvider<S, I, A>> MVIComposable( | ||
provider: VM, | ||
lifecycleState: Lifecycle.State = Lifecycle.State.STARTED, | ||
content: @Composable MVIIntentScope<I, A>.(state: S) -> Unit, | ||
) { | ||
|
||
val scope = rememberScope(provider, lifecycleState) | ||
|
||
val state by provider.states.collectAsStateOnLifecycle(lifecycleState = lifecycleState) | ||
// see [LifecycleOwner.subscribe] in :android for reasoning behind the dispatcher | ||
val state by provider.states.collectAsStateOnLifecycle(Dispatchers.Main.immediate, lifecycleState) | ||
|
||
content(scope, state) | ||
} |
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
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
Oops, something went wrong.