Skip to content

Commit

Permalink
Updated for Jetpack Compose dev15 and Android Studio 4.2 Canary 5
Browse files Browse the repository at this point in the history
- Updated to kotlin_version = "1.4-M3"
- Cleaned up dependencies and build.gradle files
- Removed redundant Column inside ScrollableColumn
- Optimised imports and updated androidx.ui.foundation.TextFieldValue
- foundation.TextFieldValue is now input.TextFieldValue
  • Loading branch information
madhavajay committed Jul 25, 2020
1 parent dffbe1a commit a6997f9
Show file tree
Hide file tree
Showing 20 changed files with 213 additions and 131 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build
on:
push:
branches:
- "master"
pull_request:
branches:
- "*"

jobs:
validation:
name: Validate Gradle Wrapper
runs-on: ubuntu-latest
steps:
- name: Checkout latest code
uses: actions/checkout@v2
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
gradle:
name: Build Gradle Tasks
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
if: ${{ !contains(github.event.head_commit.message, 'ci skip') }}
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Cache Gradle Caches
uses: actions/cache@v1
with:
path: ~/.gradle/caches/
key: cache-gradle-cache
- name: Cache Gradle Wrapper
uses: actions/cache@v1
with:
path: ~/.gradle/wrapper/
key: cache-gradle-wrapper
- name: Run Gradle tasks
run: ./gradlew build --continue
- name: Stop Gradle
run: ./gradlew --stop
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
![logo](https://i.imgur.com/kKcAHa3.png)

## What's this?

Routing functionality for Jetpack Compose with back stack:

- Helps to map your whole app structure using Compose — not just the UI parts
Expand All @@ -16,7 +17,7 @@ Routing functionality for Jetpack Compose with back stack:
- Can be integrated with automatic scoped `savedInstanceState` persistence
- Supports routing based on deep links (POC impl)

Compatible with Compose version **0.1.0-dev14**
Compatible with Compose version **0.1.0-dev15**

## Sample apps

Expand All @@ -28,7 +29,6 @@ Compatible with Compose version **0.1.0-dev14**

4. **Pokedex** - [compose-pokedex](https://github.com/zsoltk/compose-pokedex) — Using `compose-router` for app structure.


## Download

Available through jitpack.
Expand All @@ -44,12 +44,13 @@ allprojects {
```

Add the dependency:

```groovy
implementation 'com.github.zsoltk:compose-router:{latest-version}'
```


## How to use

On any level where routing functionality is needed, create a sealed class to represent your routing:

```kotlin
Expand Down Expand Up @@ -94,13 +95,13 @@ For more usage examples see the example apps.
To go back in the back stack, you can either call the `.pop()` method programmatically, or just press the back button on the device (see next section for back press integration).

Back stack operations:

- **push()**
- **pushAndDropNested()**
- **pop()**
- **replace()**
- **newRoot()**


## Connect it to back press event

To ensure that back press automatically pops the back stack and restores history, add this to your Activity:
Expand Down
52 changes: 32 additions & 20 deletions app-lifelike/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}

android {
compileSdkVersion 29

compileSdkVersion 30
buildToolsVersion "30.0.0"

defaultConfig {
applicationId "com.example.lifelike"
minSdkVersion 24
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -26,31 +29,40 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
kotlinCompilerExtensionVersion "0.1.0-dev14"
kotlinCompilerVersion "1.4.0-dev-withExperimentalGoogleExtensions-20200720"
kotlinCompilerExtensionVersion compose_version
}
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

// android
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.3.0'
implementation 'androidx.ui:ui-core:0.1.0-dev14'
implementation 'androidx.ui:ui-layout:0.1.0-dev14'
implementation 'androidx.ui:ui-material:0.1.0-dev14'
implementation 'androidx.ui:ui-tooling:0.1.0-dev14'
implementation 'androidx.ui:ui-foundation:0.1.0-dev14'
//implementation 'com.github.zsoltk:compose-router:0.11.1'

// jetpack compose
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.ui:ui-tooling:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"

// compose-router module in the local project scope
implementation project(":router")
testImplementation 'junit:junit:4.12'

// testing
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package com.example.lifelike.composable.loggedin
import androidx.compose.Composable
import androidx.ui.core.Modifier
import androidx.ui.foundation.Box
import androidx.ui.foundation.Clickable
import androidx.ui.foundation.Image
import androidx.ui.foundation.ScrollableColumn
import androidx.ui.foundation.Text
import androidx.ui.foundation.VerticalScroller
import androidx.ui.foundation.clickable
import androidx.ui.layout.Column
import androidx.ui.layout.Row
import androidx.ui.layout.Spacer
import androidx.ui.layout.padding
import androidx.ui.layout.preferredSize
import androidx.ui.layout.preferredWidth
import androidx.ui.material.MaterialTheme
import androidx.ui.material.ripple.ripple
import androidx.ui.res.imageResource
import androidx.ui.text.font.FontWeight
import androidx.ui.tooling.preview.Preview
Expand All @@ -29,11 +28,9 @@ interface AlbumList {
companion object {
@Composable
fun Content(onAlbumSelected: (Album) -> Unit) {
VerticalScroller {
Column {
albums.forEach {
AlbumRow(it, onAlbumSelected)
}
ScrollableColumn {
albums.forEach {
AlbumRow(it, onAlbumSelected)
}
}
}
Expand All @@ -43,7 +40,9 @@ interface AlbumList {
val image = imageResource(R.drawable.placeholder)
val typography = MaterialTheme.typography

Clickable(onClick = { onAlbumSelected(album) }, modifier = Modifier.ripple(true)) {
Box(
modifier = Modifier.clickable(onClick = { onAlbumSelected(album) })
) {
Row(modifier = Modifier.padding(all = 16.dp)) {
Box(modifier = Modifier.preferredSize(40.dp, 40.dp)) {
Image(image)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.example.lifelike.composable.loggedin
import androidx.compose.Composable
import androidx.ui.core.Modifier
import androidx.ui.foundation.Box
import androidx.ui.foundation.Clickable
import androidx.ui.foundation.Text
import androidx.ui.foundation.clickable
import androidx.ui.foundation.shape.corner.RoundedCornerShape
import androidx.ui.layout.Row
import androidx.ui.layout.fillMaxWidth
Expand Down Expand Up @@ -58,8 +58,8 @@ interface Menu {
color = if (isSelected) color.secondary else color.surface,
shape = RoundedCornerShape(topLeft = 4.dp, topRight = 4.dp)
) {
Clickable(
onClick = { onClick.invoke(item) }
Box(
modifier = Modifier.clickable(onClick = { onClick.invoke(item) })
) {
Text(
modifier = Modifier.fillMaxWidth().padding(8.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.example.lifelike.composable.loggedin
import androidx.compose.Composable
import androidx.ui.core.Modifier
import androidx.ui.foundation.Box
import androidx.ui.foundation.ScrollableColumn
import androidx.ui.foundation.Text
import androidx.ui.foundation.VerticalScroller
import androidx.ui.layout.padding
import androidx.ui.tooling.preview.Preview
import androidx.ui.unit.dp
Expand All @@ -16,7 +16,7 @@ interface News {
@Composable
fun Content() {
Box(modifier = Modifier.padding(start = 16.dp, end = 16.dp)) {
VerticalScroller {
ScrollableColumn {
Text(
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Adipiscing elit duis tristique sollicitudin nibh sit amet. Sed lectus vestibulum mattis ullamcorper. Sit amet purus gravida quis blandit turpis cursus. Amet nulla facilisi morbi tempus iaculis urna id volutpat lacus. In nibh mauris cursus mattis molestie a iaculis. Eu turpis egestas pretium aenean pharetra magna ac placerat vestibulum. Sollicitudin tempor id eu nisl. Vitae nunc sed velit dignissim sodales ut eu sem. Vulputate eu scelerisque felis imperdiet proin fermentum. Aliquam ut porttitor leo a diam sollicitudin tempor. Sed sed risus pretium quam.\n" +
"\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import androidx.compose.Composable
import androidx.ui.core.DensityAmbient
import androidx.ui.core.Modifier
import androidx.ui.core.WithConstraints
import androidx.ui.foundation.AdapterList
import androidx.ui.foundation.Box
import androidx.ui.foundation.Image
import androidx.ui.foundation.Text
import androidx.ui.foundation.clickable
import androidx.ui.foundation.lazy.LazyColumnItems
import androidx.ui.layout.aspectRatio
import androidx.ui.layout.Column
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.Row
import androidx.ui.layout.aspectRatio
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.padding
import androidx.ui.layout.width
import androidx.ui.material.MaterialTheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package com.example.lifelike.composable.loggedin
import androidx.compose.Composable
import androidx.ui.core.Modifier
import androidx.ui.foundation.Text
import androidx.ui.graphics.Color
import androidx.ui.layout.Arrangement
import androidx.ui.layout.Column
import androidx.ui.layout.Spacer
import androidx.ui.layout.fillMaxHeight
import androidx.ui.layout.fillMaxWidth
import androidx.ui.layout.padding
import androidx.ui.layout.preferredHeight
import androidx.ui.material.Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.example.lifelike.composable.loggedout
import androidx.compose.Composable
import androidx.compose.state
import androidx.ui.foundation.TextField
import androidx.ui.foundation.TextFieldValue
import androidx.ui.input.TextFieldValue
import androidx.ui.text.TextRange
import com.example.lifelike.composable.loggedout.common.RegFlowPanel

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.example.lifelike.composable.loggedout

import androidx.compose.Composable
import androidx.ui.foundation.TextField
import androidx.ui.foundation.TextFieldValue
import androidx.ui.input.TextFieldValue
import androidx.ui.text.TextRange
import androidx.ui.tooling.preview.Preview
import com.example.lifelike.composable.loggedout.common.RegFlowPanel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.example.lifelike.composable.loggedout

import androidx.compose.Composable
import androidx.ui.foundation.TextField
import androidx.ui.foundation.TextFieldValue
import androidx.ui.input.TextFieldValue
import androidx.ui.text.TextRange
import com.example.lifelike.composable.loggedout.common.RegFlowPanel
import com.example.lifelike.entity.User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.ui.foundation.Text
import androidx.ui.layout.Arrangement
import androidx.ui.layout.Column
import androidx.ui.layout.DpConstraints
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.fillMaxWidth
import androidx.ui.layout.padding
import androidx.ui.layout.preferredSizeIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import androidx.ui.core.Alignment
import androidx.ui.core.Modifier
import androidx.ui.foundation.Box
import androidx.ui.foundation.Text
import androidx.ui.layout.*
import androidx.ui.layout.Arrangement
import androidx.ui.layout.Column
import androidx.ui.layout.DpConstraints
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.padding
import androidx.ui.layout.preferredSizeIn
import androidx.ui.layout.wrapContentHeight
import androidx.ui.layout.wrapContentSize
import androidx.ui.material.MaterialTheme
import androidx.ui.unit.dp
import com.example.lifelike.composable.common.BigButton
Expand All @@ -14,7 +21,7 @@ import com.example.lifelike.composable.common.BigButton
fun RegFlowPanel(
title: String,
onNext: () -> Unit,
content: @Composable() () -> Unit = {}
content: @Composable () -> Unit = {}
) {
Column(
modifier = Modifier.fillMaxSize().padding(40.dp),
Expand Down

0 comments on commit a6997f9

Please sign in to comment.