Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate first two codelab projects to Appyx 2.0 #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
645 changes: 2 additions & 643 deletions .gitignore

Large diffs are not rendered by default.

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

This file was deleted.

9 changes: 0 additions & 9 deletions CustomAnimation/.idea/misc.xml

This file was deleted.

2 changes: 1 addition & 1 deletion HelloAppyx/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
.cxx
local.properties
.idea/*
**/.DS_Store
**/.DS_Store
4 changes: 2 additions & 2 deletions HelloAppyx/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId = "com.example.helloappyx"
minSdk = libs.versions.androidMinSdk.get().toInt()
targetSdk = libs.versions.androidTargetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "2.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
5 changes: 2 additions & 3 deletions HelloAppyx/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# keep sorted please, use Edit -> Sort Lines

[versions]
androidCompileSdk = "32"
androidCompileSdk = "33"
androidMinSdk = "21"
androidTargetSdk = "32"
androidTargetSdk = "33"
composeUi = "1.2.1"
composeCompiler = "1.3.1"

[libraries]
appyx-core = "com.bumble.appyx:core:1.0-alpha09"
androidx-core = "androidx.core:core-ktx:1.7.0"
androidx-lifecycle = "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
androidx-activity-compose = "androidx.activity:activity-compose:1.3.1"
Expand Down
2 changes: 1 addition & 1 deletion HelloAppyx/solution/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ android {
dependencies {

// Appyx
implementation("com.bumble.appyx:core:1.0.0-rc02")
implementation("com.bumble.appyx:appyx-navigation:2.0.0-alpha01")

implementation(libs.androidx.core)
implementation(libs.androidx.lifecycle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.solution.helloappyx

import android.os.Bundle
import androidx.activity.compose.setContent
import com.bumble.appyx.core.integration.NodeHost
import com.bumble.appyx.core.integrationpoint.NodeActivity
import com.bumble.appyx.navigation.integration.NodeHost
import com.bumble.appyx.navigation.integrationpoint.NodeActivity
import com.solution.helloappyx.ui.theme.HelloAppyxTheme

class MainActivity : NodeActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
HelloAppyxTheme {
NodeHost(integrationPoint = appyxIntegrationPoint) {
NodeHost(integrationPoint = appyxV2IntegrationPoint) {
RootNode(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package com.solution.helloappyx

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
Expand All @@ -14,10 +18,10 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.ExperimentalUnitApi
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bumble.appyx.core.integration.NodeHost
import com.bumble.appyx.core.integrationpoint.IntegrationPointStub
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import com.bumble.appyx.navigation.integration.NodeHost
import com.bumble.appyx.navigation.integrationpoint.IntegrationPointStub
import com.bumble.appyx.navigation.modality.BuildContext
import com.bumble.appyx.navigation.node.Node

class RootNode(
buildContext: BuildContext
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Appyx codelabs

This respository contains codelabs to learn about Appyx. You will also find one project for each codelab so you can easily follow them.
This repository contains codelabs to learn about Appyx. You will also find one project for each codelab so you can easily follow them.


## Appyx
Expand All @@ -13,16 +13,19 @@ Find out by checking the oficial doc:
https://bumble-tech.github.io/appyx/


## Codelabs
## Appyx 2.x Codelabs

### [Hello World with Appyx](https://bumble-tech.github.io/appyx-codelabs/appyx-hello-world)

Learn the basics of Appyx
Learn the basics of Appyx navigation

### [Navigation](https://bumble-tech.github.io/appyx-codelabs/appyx-navigation)

Learn how Appyx navigation works


## Appyx 1.x Codelabs

### [Custom animation](https://bumble-tech.github.io/appyx-codelabs/appyx-custom-animation)

Learn how to unleash powerful transitions
Expand Down
5 changes: 3 additions & 2 deletions SimpleApp/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ android {

dependencies {

// Core
implementation(libs.appyx.core)
// Appyx navigation
implementation(libs.appyx.navigation)
implementation(libs.appyx.backstack)

// Test rules and utility classes for testing on Android
androidTestImplementation(libs.appyx.testing.ui)
Expand Down
32 changes: 17 additions & 15 deletions SimpleApp/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
# keep sorted please, use Edit -> Sort Lines

[versions]
appyx = "1.0.0-rc02"
androidCompileSdk = "32"
appyx = "2.0.0-alpha01"
androidCompileSdk = "33"
androidMinSdk = "21"
androidTargetSdk = "32"
androidTargetSdk = "33"
composeUi = "1.2.1"
composeCompiler = "1.3.1"

[libraries]
androidx-core = "androidx.core:core-ktx:1.7.0"
androidx-lifecycle = "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
androidx-activity-compose = "androidx.activity:activity-compose:1.3.1"
androidx-material = "androidx.compose.material:material:1.1.1"
junit = "junit:junit:4.13.2"
androidx-test-ext-junit = "androidx.test.ext:junit:1.1.3"
androidx-test-espresso = "androidx.test.espresso:espresso-core:3.4.0"
appyx-navigation = { module = "com.bumble.appyx:appyx-navigation", version.ref = "appyx" }
appyx-backstack = { module = "com.bumble.appyx:backstack-android", version.ref = "appyx" }
appyx-testing-ui = { module = "com.bumble.appyx:utils-testing-ui", version.ref = "appyx" }
appyx-testing-ui-common = { module = "com.bumble.appyx:utils-testing-unit-common", version.ref = "appyx" }
appyx-testing-junit4 = { module = "com.bumble.appyx:utils-testing-junit4", version.ref = "appyx" }
appyx-testing-junit5 = { module = "com.bumble.appyx:utils-testing-junit5", version.ref = "appyx" }

appyx-core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
appyx-testing-ui = { module = "com.bumble.appyx:testing-ui", version.ref = "appyx" }
appyx-testing-ui-common = { module = "com.bumble.appyx:testing-unit-common", version.ref = "appyx" }
appyx-testing-junit4 = { module = "com.bumble.appyx:testing-junit4", version.ref = "appyx" }
appyx-testing-junit5 = { module = "com.bumble.appyx:testing-junit5", version.ref = "appyx" }
androidx-activity-compose = "androidx.activity:activity-compose:1.3.1"
androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "composeUi" }
androidx-compose-ui-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "composeUi" }
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "composeUi" }
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "composeUi" }
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "composeUi" }
androidx-core = "androidx.core:core-ktx:1.7.0"
androidx-lifecycle = "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
androidx-material = "androidx.compose.material:material:1.1.1"
androidx-test-espresso = "androidx.test.espresso:espresso-core:3.4.0"
androidx-test-ext-junit = "androidx.test.ext:junit:1.1.3"
junit = "junit:junit:4.13.2"

[plugins]

9 changes: 5 additions & 4 deletions SimpleApp/solution/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId = "com.bumble.appyx_codelabs.simple_app.solution"
minSdk = libs.versions.androidMinSdk.get().toInt()
targetSdk = libs.versions.androidTargetSdk.get().toInt()
versionCode = 1
versionName = "1.0"
versionCode = 2
versionName = "2.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -44,8 +44,9 @@ android {

dependencies {

// Core
implementation(libs.appyx.core)
// Appyx navigation
implementation(libs.appyx.navigation)
implementation(libs.appyx.backstack)

// Test rules and utility classes for testing on Android
androidTestImplementation(libs.appyx.testing.ui)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.bumble.appyx_codelabs.simple_app.solution

import android.os.Bundle
import androidx.activity.compose.setContent
import com.bumble.appyx.core.integration.NodeHost
import com.bumble.appyx.core.integrationpoint.NodeActivity
import com.bumble.appyx.navigation.integration.NodeHost
import com.bumble.appyx.navigation.integrationpoint.NodeActivity
import com.bumble.appyx_codelabs.simple_app.solution.root.RootNode
import com.bumble.appyx_codelabs.simple_app.solution.ui.theme.SimpleAppTheme

Expand All @@ -12,7 +12,7 @@ class MainActivity : NodeActivity() {
super.onCreate(savedInstanceState)
setContent {
SimpleAppTheme {
NodeHost(integrationPoint = appyxIntegrationPoint) {
NodeHost(integrationPoint = appyxV2IntegrationPoint) {
RootNode(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import com.bumble.appyx.navigation.modality.BuildContext
import com.bumble.appyx.navigation.node.Node
import com.bumble.appyx_codelabs.simple_app.solution.ui.theme.appyx_dark
import com.bumble.appyx_codelabs.simple_app.solution.ui.theme.appyx_yellow1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import com.bumble.appyx.navigation.modality.BuildContext
import com.bumble.appyx.navigation.node.Node

class Child2Node(buildContext: BuildContext) : Node(buildContext) {
class Child2Node(
buildContext: BuildContext
) : Node(buildContext) {

@Composable
override fun View(modifier: Modifier) {
Expand All @@ -39,4 +41,4 @@ class Child2Node(buildContext: BuildContext) : Node(buildContext) {
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
package com.bumble.appyx_codelabs.simple_app.solution.root

import androidx.compose.animation.core.spring
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.bumble.appyx.core.composable.Children
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.ParentNode
import com.bumble.appyx.navmodel.backstack.BackStack
import com.bumble.appyx.navmodel.backstack.operation.push
import com.bumble.appyx.navmodel.backstack.transitionhandler.rememberBackstackFader
import com.bumble.appyx.components.backstack.BackStack
import com.bumble.appyx.components.backstack.BackStackModel
import com.bumble.appyx.components.backstack.operation.push
import com.bumble.appyx.components.backstack.ui.fader.BackStackFader
import com.bumble.appyx.navigation.composable.AppyxComponent
import com.bumble.appyx.navigation.modality.BuildContext
import com.bumble.appyx.navigation.node.Node
import com.bumble.appyx.navigation.node.ParentNode
import com.bumble.appyx_codelabs.simple_app.solution.R
import com.bumble.appyx_codelabs.simple_app.solution.child.Child1Node
import com.bumble.appyx_codelabs.simple_app.solution.child.Child2Node
Expand All @@ -28,11 +35,14 @@ import com.bumble.appyx_codelabs.simple_app.solution.ui.theme.appyx_dark
class RootNode(
buildContext: BuildContext,
private val backStack: BackStack<NavTarget> = BackStack(
initialElement = Child1,
savedStateMap = buildContext.savedStateMap
model = BackStackModel(
initialTarget = Child1,
savedStateMap = buildContext.savedStateMap
),
motionController = { BackStackFader(it) },
),
) : ParentNode<RootNode.NavTarget>(
navModel = backStack,
appyxComponent = backStack,
buildContext = buildContext
) {

Expand All @@ -41,11 +51,8 @@ class RootNode(
object Child2 : NavTarget()
}

override fun resolve(
navTarget: NavTarget,
buildContext: BuildContext
) =
when (navTarget) {
override fun resolve(interactionTarget: NavTarget, buildContext: BuildContext): Node =
when (interactionTarget) {
is Child1 -> Child1Node(buildContext) { backStack.push(Child2) }
is Child2 -> Child2Node(buildContext)
}
Expand All @@ -70,9 +77,8 @@ class RootNode(
modifier = Modifier.padding(16.dp)
)
}
Children(
navModel = backStack,
transitionHandler = rememberBackstackFader(transitionSpec = { spring() }),
AppyxComponent(
appyxComponent = backStack,
modifier = Modifier.fillMaxSize()
)
}
Expand Down