commit
c666ae73b5
10 changed files with 32 additions and 24 deletions
|
@ -64,8 +64,9 @@ dependencies {
|
||||||
implementation(activityCompose)
|
implementation(activityCompose)
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation("androidx.glance:glance-appwidget:1.0.0-SNAPSHOT")
|
with(Deps.Glance) {
|
||||||
|
implementation(appwidget)
|
||||||
|
}
|
||||||
|
|
||||||
with(Deps.Compose) {
|
with(Deps.Compose) {
|
||||||
implementation(compiler)
|
implementation(compiler)
|
||||||
|
@ -79,8 +80,6 @@ dependencies {
|
||||||
implementation(uiTooling)
|
implementation(uiTooling)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
with(Deps.Koin) {
|
with(Deps.Koin) {
|
||||||
implementation(core)
|
implementation(core)
|
||||||
implementation(android)
|
implementation(android)
|
||||||
|
|
|
@ -7,13 +7,14 @@ import androidx.compose.ui.unit.ExperimentalUnitApi
|
||||||
import androidx.compose.ui.unit.TextUnit
|
import androidx.compose.ui.unit.TextUnit
|
||||||
import androidx.compose.ui.unit.TextUnitType
|
import androidx.compose.ui.unit.TextUnitType
|
||||||
import androidx.glance.GlanceModifier
|
import androidx.glance.GlanceModifier
|
||||||
import androidx.glance.action.actionLaunchActivity
|
import androidx.glance.Image
|
||||||
|
import androidx.glance.ImageProvider
|
||||||
|
import androidx.glance.action.actionStartActivity
|
||||||
import androidx.glance.action.clickable
|
import androidx.glance.action.clickable
|
||||||
import androidx.glance.background
|
import androidx.glance.background
|
||||||
import androidx.glance.layout.Box
|
import androidx.glance.layout.Box
|
||||||
import androidx.glance.layout.ImageProvider
|
|
||||||
import androidx.glance.layout.Text
|
|
||||||
import androidx.glance.layout.fillMaxSize
|
import androidx.glance.layout.fillMaxSize
|
||||||
|
import androidx.glance.text.Text
|
||||||
import androidx.glance.text.TextStyle
|
import androidx.glance.text.TextStyle
|
||||||
import androidx.glance.unit.ColorProvider
|
import androidx.glance.unit.ColorProvider
|
||||||
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
||||||
|
@ -81,12 +82,12 @@ class ISSMapWidget : BaseGlanceAppWidget<ISSMapWidget.Data>() {
|
||||||
override fun Content(data: Data?) {
|
override fun Content(data: Data?) {
|
||||||
Box(
|
Box(
|
||||||
modifier = GlanceModifier.background(Color.DarkGray).fillMaxSize().clickable(
|
modifier = GlanceModifier.background(Color.DarkGray).fillMaxSize().clickable(
|
||||||
actionLaunchActivity<MainActivity>()
|
actionStartActivity<MainActivity>()
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
val bitmap = data?.bitmap
|
val bitmap = data?.bitmap
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
androidx.glance.layout.Image(
|
Image(
|
||||||
modifier = GlanceModifier.fillMaxSize(),
|
modifier = GlanceModifier.fillMaxSize(),
|
||||||
provider = ImageProvider(bitmap),
|
provider = ImageProvider(bitmap),
|
||||||
contentDescription = "ISS Location"
|
contentDescription = "ISS Location"
|
||||||
|
|
|
@ -7,13 +7,12 @@ import androidx.compose.ui.unit.TextUnit
|
||||||
import androidx.compose.ui.unit.TextUnitType
|
import androidx.compose.ui.unit.TextUnitType
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.glance.GlanceModifier
|
import androidx.glance.GlanceModifier
|
||||||
import androidx.glance.appwidget.layout.LazyColumn
|
import androidx.glance.appwidget.lazy.LazyColumn
|
||||||
import androidx.glance.appwidget.layout.items
|
|
||||||
import androidx.glance.background
|
import androidx.glance.background
|
||||||
import androidx.glance.layout.Row
|
import androidx.glance.layout.Row
|
||||||
import androidx.glance.layout.Text
|
|
||||||
import androidx.glance.layout.padding
|
import androidx.glance.layout.padding
|
||||||
import androidx.glance.text.FontWeight
|
import androidx.glance.text.FontWeight
|
||||||
|
import androidx.glance.text.Text
|
||||||
import androidx.glance.text.TextStyle
|
import androidx.glance.text.TextStyle
|
||||||
import androidx.glance.unit.ColorProvider
|
import androidx.glance.unit.ColorProvider
|
||||||
import com.surrus.common.remote.Assignment
|
import com.surrus.common.remote.Assignment
|
||||||
|
@ -49,10 +48,10 @@ class PeopleInSpaceWidget : BaseGlanceAppWidget<PeopleInSpaceWidget.Data>() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
items(data.people) {
|
items(data.people.size) {
|
||||||
Row {
|
Row {
|
||||||
Text(
|
Text(
|
||||||
text = it.name,
|
text = data.people[it].name,
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
color = ColorProvider(Color.White),
|
color = ColorProvider(Color.White),
|
||||||
fontSize = TextUnit(10f, TextUnitType.Sp)
|
fontSize = TextUnit(10f, TextUnitType.Sp)
|
||||||
|
|
|
@ -7,10 +7,10 @@ import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.runtime.snapshotFlow
|
import androidx.compose.runtime.snapshotFlow
|
||||||
import androidx.compose.ui.unit.DpSize
|
import androidx.compose.ui.unit.DpSize
|
||||||
|
import androidx.glance.GlanceId
|
||||||
|
import androidx.glance.LocalGlanceId
|
||||||
import androidx.glance.LocalSize
|
import androidx.glance.LocalSize
|
||||||
import androidx.glance.appwidget.GlanceAppWidget
|
import androidx.glance.appwidget.GlanceAppWidget
|
||||||
import androidx.glance.appwidget.GlanceId
|
|
||||||
import androidx.glance.appwidget.LocalGlanceId
|
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import kotlinx.coroutines.flow.filterNotNull
|
import kotlinx.coroutines.flow.filterNotNull
|
||||||
import kotlinx.coroutines.flow.firstOrNull
|
import kotlinx.coroutines.flow.firstOrNull
|
||||||
|
|
|
@ -33,9 +33,7 @@ allprojects {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
|
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
|
||||||
maven(url = "https://jitpack.io")
|
maven(url = "https://jitpack.io")
|
||||||
maven(url = "https://androidx.dev/snapshots/builds/7888785/artifacts/repository")
|
|
||||||
maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven")
|
maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven")
|
||||||
maven(url = "https://maven.pkg.jetbrains.space/public/p/ktor/eap")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,4 +156,9 @@ object Deps {
|
||||||
const val logback = "ch.qos.logback:logback-classic:${Versions.logback}"
|
const val logback = "ch.qos.logback:logback-classic:${Versions.logback}"
|
||||||
const val kermit = "co.touchlab:kermit:${Versions.kermit}"
|
const val kermit = "co.touchlab:kermit:${Versions.kermit}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object Glance {
|
||||||
|
const val tiles = "androidx.glance:glance-wear-tiles:1.0.0-alpha02"
|
||||||
|
const val appwidget = "androidx.glance:glance-appwidget:1.0.0-alpha02"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
|
|
||||||
}
|
}
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
eachPlugin {
|
eachPlugin {
|
||||||
|
|
|
@ -85,7 +85,9 @@ dependencies {
|
||||||
debugImplementation(composeUiTestManifest)
|
debugImplementation(composeUiTestManifest)
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation("androidx.glance:glance-wear:1.0.0-SNAPSHOT")
|
with(Deps.Glance) {
|
||||||
|
implementation(tiles)
|
||||||
|
}
|
||||||
|
|
||||||
implementation(project(":common"))
|
implementation(project(":common"))
|
||||||
}
|
}
|
|
@ -8,16 +8,16 @@ import androidx.compose.ui.unit.TextUnitType
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.glance.GlanceModifier
|
import androidx.glance.GlanceModifier
|
||||||
import androidx.glance.layout.Column
|
import androidx.glance.layout.Column
|
||||||
import androidx.glance.layout.Text
|
|
||||||
import androidx.glance.layout.padding
|
import androidx.glance.layout.padding
|
||||||
import androidx.glance.text.FontWeight
|
import androidx.glance.text.FontWeight
|
||||||
|
import androidx.glance.text.Text
|
||||||
import androidx.glance.text.TextStyle
|
import androidx.glance.text.TextStyle
|
||||||
import androidx.glance.unit.ColorProvider
|
import androidx.glance.unit.ColorProvider
|
||||||
import com.surrus.common.remote.Assignment
|
import com.surrus.common.remote.Assignment
|
||||||
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
import com.surrus.common.repository.PeopleInSpaceRepositoryInterface
|
||||||
import com.surrus.peopleinspace.tile.util.BaseGlanceTileService
|
import com.surrus.peopleinspace.tile.util.BaseGlanceTileService
|
||||||
import kotlinx.coroutines.flow.first
|
import kotlinx.coroutines.flow.first
|
||||||
import org.koin.android.ext.android.inject
|
import org.koin.core.component.inject
|
||||||
|
|
||||||
class PeopleInSpaceTile : BaseGlanceTileService<PeopleInSpaceTile.Data>() {
|
class PeopleInSpaceTile : BaseGlanceTileService<PeopleInSpaceTile.Data>() {
|
||||||
val repository: PeopleInSpaceRepositoryInterface by inject()
|
val repository: PeopleInSpaceRepositoryInterface by inject()
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package com.surrus.peopleinspace.tile.util
|
package com.surrus.peopleinspace.tile.util
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.glance.wear.GlanceTileService
|
import androidx.glance.wear.tiles.GlanceTileService
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import org.koin.core.component.KoinComponent
|
||||||
|
import org.koin.core.component.inject
|
||||||
|
|
||||||
|
abstract class BaseGlanceTileService<T> : GlanceTileService(), KoinComponent {
|
||||||
|
val context: Context by inject()
|
||||||
|
|
||||||
abstract class BaseGlanceTileService<T> : GlanceTileService() {
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun Content() {
|
override fun Content() {
|
||||||
// Terrible hack for lack of suspend load function
|
// Terrible hack for lack of suspend load function
|
||||||
|
|
Loading…
Reference in a new issue