Skip to content

Commit d5cfd9e

Browse files
committed
add treegrowth animation
1 parent db6b80f commit d5cfd9e

22 files changed

Lines changed: 559 additions & 155 deletions

File tree

composeApp/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ kotlin {
4747
implementation(libs.androidx.activity.compose)
4848

4949
implementation(libs.ktor.client.android)
50+
implementation("io.ktor:ktor-client-okhttp:3.0.1")
5051
}
5152
commonMain.dependencies {
5253
implementation(compose.runtime)
@@ -63,15 +64,22 @@ kotlin {
6364
implementation(libs.coil.network.ktor)
6465
implementation(libs.ktor.client.content.negotiation)
6566
implementation(libs.ktor.serialization.json)
67+
68+
implementation("com.squareup.okio:okio:3.9.0")
69+
implementation("io.github.kdroidfilter:composemediaplayer:0.8.6")
6670
}
6771
commonTest.dependencies {
6872
implementation(libs.kotlin.test)
6973
}
74+
iosMain.dependencies {
75+
implementation("io.ktor:ktor-client-darwin:3.0.1")
76+
}
7077
jvmMain.dependencies {
7178
implementation(compose.desktop.currentOs)
7279
implementation(libs.kotlinx.coroutinesSwing)
7380

7481
implementation(libs.ktor.client.java)
82+
implementation("io.ktor:ktor-client-okhttp:3.0.1")
7583
}
7684
}
7785
}

composeApp/src/androidMain/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3-
3+
<uses-permission android:name="android.permission.INTERNET"/>
44
<application
55
android:allowBackup="true"
66
android:icon="@mipmap/ic_launcher"

composeApp/src/androidMain/kotlin/neth/iecal/trease/MainActivity.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,22 @@ import android.os.Bundle
44
import androidx.activity.ComponentActivity
55
import androidx.activity.compose.setContent
66
import androidx.activity.enableEdgeToEdge
7+
import androidx.compose.foundation.background
8+
import androidx.compose.foundation.layout.fillMaxSize
79
import androidx.compose.runtime.Composable
10+
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.graphics.Color
12+
import androidx.compose.ui.layout.ContentScale
813
import androidx.compose.ui.tooling.preview.Preview
14+
import androidx.compose.ui.zIndex
15+
import io.github.kdroidfilter.composemediaplayer.SurfaceType
16+
import io.github.kdroidfilter.composemediaplayer.VideoPlayerSurface
917

1018
class MainActivity : ComponentActivity() {
1119
override fun onCreate(savedInstanceState: Bundle?) {
1220
enableEdgeToEdge()
1321
super.onCreate(savedInstanceState)
14-
22+
TreaseContext.init(this)
1523
setContent {
1624
App()
1725
}
Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,68 @@
11
package neth.iecal.trease
22

3+
import android.annotation.SuppressLint
4+
import android.content.Context
35
import android.os.Build
6+
import androidx.compose.foundation.background
7+
import androidx.compose.foundation.layout.fillMaxSize
8+
import androidx.compose.runtime.Composable
9+
import androidx.compose.ui.Modifier
10+
import androidx.compose.ui.graphics.Color
11+
import androidx.compose.ui.layout.ContentScale
12+
import androidx.compose.ui.zIndex
13+
import io.github.kdroidfilter.composemediaplayer.SurfaceType
14+
import io.github.kdroidfilter.composemediaplayer.VideoPlayerState
15+
import io.github.kdroidfilter.composemediaplayer.VideoPlayerSurface
16+
import io.ktor.client.HttpClient
17+
import io.ktor.client.engine.android.Android
18+
import io.ktor.client.engine.okhttp.OkHttp
19+
import okio.FileSystem
20+
import java.io.File
421

5-
class AndroidPlatform : Platform {
6-
override val name: String = "Android ${Build.VERSION.SDK_INT}"
22+
@SuppressLint("StaticFieldLeak")
23+
object TreaseContext {
24+
private var _context: Context? = null
25+
val context: Context
26+
get() = _context ?: throw IllegalStateException(
27+
"Android context not initialized. Call TreaseContext.init(context) in your Application class."
28+
)
29+
30+
fun init(context: Context) {
31+
_context = context.applicationContext
32+
}
33+
}
34+
35+
36+
actual fun getPlatform(): Platform = Platform.ANDROID
37+
38+
actual fun getCacheDir(): String {
39+
val cacheDir = File(TreaseContext.context.cacheDir, "trease_cache")
40+
if (!cacheDir.exists()) {
41+
cacheDir.mkdirs()
42+
}
43+
return cacheDir.absolutePath
44+
}
45+
46+
actual fun getPlatformHttpClient(): HttpClient {
47+
return HttpClient(OkHttp) {
48+
engine {
49+
config {
50+
followRedirects(true)
51+
}
52+
}
53+
}
54+
}
55+
56+
actual fun getFileSystem(): FileSystem {
57+
return FileSystem.SYSTEM
758
}
859

9-
actual fun getPlatform(): Platform = AndroidPlatform()
60+
@Composable
61+
actual fun PlatformVideoPlayer(state: VideoPlayerState, modifier: Modifier) {
62+
VideoPlayerSurface(
63+
state ,
64+
contentScale = ContentScale.Crop,
65+
modifier = modifier,
66+
surfaceType = SurfaceType.TextureView
67+
)
68+
}
337 KB
Binary file not shown.
336 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
package neth.iecal.trease
22

3-
interface Platform {
4-
val name: String
3+
import androidx.compose.foundation.background
4+
import androidx.compose.foundation.layout.fillMaxSize
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.ui.Modifier
7+
import androidx.compose.ui.graphics.Color
8+
import androidx.compose.ui.layout.ContentScale
9+
import androidx.compose.ui.zIndex
10+
import io.github.kdroidfilter.composemediaplayer.VideoPlayerState
11+
import io.github.kdroidfilter.composemediaplayer.VideoPlayerSurface
12+
import okio.FileSystem
13+
14+
enum class Platform {
15+
ANDROID,
16+
DESKTOP,
17+
IOS,
18+
WEB,
19+
UNKNOWN
520
}
621

7-
expect fun getPlatform(): Platform
22+
23+
expect fun getPlatform(): Platform
24+
25+
@Composable
26+
expect fun PlatformVideoPlayer(state: VideoPlayerState, modifier: Modifier)
27+
expect fun getCacheDir(): String
28+
expect fun getPlatformHttpClient(): io.ktor.client.HttpClient
29+
expect fun getFileSystem(): FileSystem

0 commit comments

Comments
 (0)