initial Wear OS Compose client
This commit is contained in:
parent
aa7d3eb24a
commit
a353496f08
16 changed files with 178 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
Minimal **Kotlin Multiplatform** project with SwiftUI, Jetpack Compose, Compose for Desktop, Compose for Web, and Kotlin/JS + React clients along with Ktor backend. Currently running on
|
||||
* Android (Jetpack Compose)
|
||||
* Wear OS (Jetpack Compose)
|
||||
* iOS (SwiftUI)
|
||||
* watchOS (SwiftUI) (contributed by https://github.com/nealsanche)
|
||||
* macOS (SwiftUI)
|
||||
|
|
|
@ -7,6 +7,7 @@ buildscript {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10")
|
||||
with(Deps.Gradle) {
|
||||
classpath(kotlin)
|
||||
classpath(kotlinSerialization)
|
||||
|
|
|
@ -13,6 +13,7 @@ object Versions {
|
|||
const val kotlinxHtmlJs = "0.7.3"
|
||||
|
||||
const val compose = "1.0.0-rc01"
|
||||
const val wearCompose = "1.0.0-alpha01"
|
||||
const val navCompose = "2.4.0-alpha04"
|
||||
const val accompanist = "0.13.0"
|
||||
|
||||
|
@ -85,6 +86,10 @@ object Deps {
|
|||
const val foundationLayout = "androidx.compose.foundation:foundation-layout:${Versions.compose}"
|
||||
const val material = "androidx.compose.material:material:${Versions.compose}"
|
||||
const val navigation = "androidx.navigation:navigation-compose:${Versions.navCompose}"
|
||||
|
||||
const val wearFoundation = "androidx.wear.compose:compose-foundation:${Versions.wearCompose}"
|
||||
const val wearMaterial = "androidx.wear.compose:compose-material:${Versions.wearCompose}"
|
||||
|
||||
const val accompanistCoil = "com.google.accompanist:accompanist-coil:${Versions.accompanist}"
|
||||
const val accompanistPlaceholder = "com.google.accompanist:accompanist-placeholder:${Versions.accompanist}"
|
||||
}
|
||||
|
|
|
@ -11,4 +11,5 @@ rootProject.name = "PeopleInSpace"
|
|||
include(":app", ":common", ":compose-desktop")
|
||||
include(":web")
|
||||
include(":compose-web")
|
||||
include(":backend")
|
||||
include(":backend")
|
||||
include(":wearApp")
|
||||
|
|
1
wearApp/.gitignore
vendored
Normal file
1
wearApp/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/build
|
46
wearApp/build.gradle.kts
Normal file
46
wearApp/build.gradle.kts
Normal file
|
@ -0,0 +1,46 @@
|
|||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 30
|
||||
buildToolsVersion = "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.surrus.peopleinspace"
|
||||
minSdk = 30
|
||||
targetSdk = 30
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
compose = true
|
||||
}
|
||||
|
||||
composeOptions {
|
||||
kotlinCompilerExtensionVersion = Versions.compose
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
with(Deps.AndroidX) {
|
||||
implementation(activityCompose)
|
||||
}
|
||||
|
||||
with(Deps.Compose) {
|
||||
implementation(wearFoundation)
|
||||
implementation(wearMaterial)
|
||||
}
|
||||
|
||||
implementation(project(":common"))
|
||||
}
|
21
wearApp/proguard-rules.pro
vendored
Normal file
21
wearApp/proguard-rules.pro
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
40
wearApp/src/main/AndroidManifest.xml
Normal file
40
wearApp/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.surrus.peopleinspace">
|
||||
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-feature android:name="android.hardware.type.watch" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@android:style/Theme.DeviceDefault">
|
||||
<uses-library
|
||||
android:name="com.google.android.wearable"
|
||||
android:required="true" />
|
||||
|
||||
<!--
|
||||
Set to true if your app is Standalone, that is, it does not require the handheld
|
||||
app to run.
|
||||
-->
|
||||
<meta-data
|
||||
android:name="com.google.android.wearable.standalone"
|
||||
android:value="true" />
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,55 @@
|
|||
package com.surrus.peopleinspace
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.wear.compose.material.MaterialTheme
|
||||
import androidx.wear.compose.material.Text
|
||||
import com.surrus.common.di.initKoin
|
||||
import com.surrus.common.remote.Assignment
|
||||
import com.surrus.common.remote.PeopleInSpaceApi
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
||||
private val koin = initKoin(enableNetworkLogs = true).koin
|
||||
val peopleInSpaceApi = koin.get<PeopleInSpaceApi>()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
setContent {
|
||||
MaterialTheme {
|
||||
PersonList(peopleInSpaceApi)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun PersonList(peopleInSpaceApi: PeopleInSpaceApi) {
|
||||
var peopleState by remember { mutableStateOf(emptyList<Assignment>()) }
|
||||
|
||||
LaunchedEffect(true) {
|
||||
peopleState = peopleInSpaceApi.fetchPeople().people
|
||||
}
|
||||
|
||||
Column {
|
||||
Text("PeopleInSpace", style = MaterialTheme.typography.title1)
|
||||
Spacer(modifier = Modifier.size(12.dp))
|
||||
|
||||
LazyColumn {
|
||||
items(peopleState) { person ->
|
||||
Text("${person.name} (${person.craft})")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
BIN
wearApp/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
BIN
wearApp/src/main/res/mipmap-hdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
wearApp/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
BIN
wearApp/src/main/res/mipmap-mdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 982 B |
BIN
wearApp/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
BIN
wearApp/src/main/res/mipmap-xhdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
wearApp/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
BIN
wearApp/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
wearApp/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
BIN
wearApp/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
3
wearApp/src/main/res/values-round/strings.xml
Normal file
3
wearApp/src/main/res/values-round/strings.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<string name="hello_world">Hello Round World!</string>
|
||||
</resources>
|
3
wearApp/src/main/res/values/strings.xml
Normal file
3
wearApp/src/main/res/values/strings.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<resources>
|
||||
<string name="app_name">PeopleInSpace</string>
|
||||
</resources>
|
Loading…
Reference in a new issue