glance wip
This commit is contained in:
parent
1dc279c56b
commit
77798c5ff8
7 changed files with 88 additions and 2 deletions
|
@ -64,6 +64,9 @@ dependencies {
|
|||
implementation(activityCompose)
|
||||
}
|
||||
|
||||
implementation("androidx.glance:glance-appwidget:1.0.0-SNAPSHOT")
|
||||
|
||||
|
||||
with(Deps.Compose) {
|
||||
implementation(ui)
|
||||
implementation(uiGraphics)
|
||||
|
@ -75,6 +78,8 @@ dependencies {
|
|||
implementation(uiTooling)
|
||||
}
|
||||
|
||||
|
||||
|
||||
with(Deps.Koin) {
|
||||
implementation(core)
|
||||
implementation(android)
|
||||
|
|
|
@ -24,6 +24,18 @@
|
|||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name="com.surrus.peopleinspace.glance.MyAppWidgetReceiver"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="android.appwidget.provider"
|
||||
android:resource="@xml/widget_info" />
|
||||
</receiver>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,49 @@
|
|||
package com.surrus.peopleinspace.glance
|
||||
|
||||
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.material.primarySurface
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.glance.GlanceModifier
|
||||
import androidx.glance.appwidget.GlanceAppWidget
|
||||
import androidx.glance.appwidget.layout.LazyColumn
|
||||
import androidx.glance.appwidget.layout.items
|
||||
import androidx.glance.background
|
||||
import androidx.glance.layout.Box
|
||||
import androidx.glance.layout.Text
|
||||
import androidx.glance.layout.fillMaxSize
|
||||
import com.surrus.common.remote.Assignment
|
||||
import com.surrus.common.repository.PeopleInSpaceRepository
|
||||
|
||||
class MyAppWidget : GlanceAppWidget() {
|
||||
|
||||
@Composable
|
||||
override fun Content() {
|
||||
val repo = remember { PeopleInSpaceRepository() }
|
||||
|
||||
var people by remember { mutableStateOf(emptyList<Assignment>()) }
|
||||
|
||||
LaunchedEffect(true) {
|
||||
people = repo.fetchPeople()
|
||||
}
|
||||
|
||||
Text("hey there, count = " + people.size)
|
||||
|
||||
|
||||
val stops = listOf("Stop 1", "Stop 2", "Stop 3")
|
||||
// LazyColumn(
|
||||
// modifier = GlanceModifier.fillMaxSize()
|
||||
// .background(MaterialTheme.colors.background))
|
||||
// {
|
||||
//// items(people) { person ->
|
||||
//// Text(person.name)
|
||||
//// }
|
||||
//
|
||||
// items(stops) { stop ->
|
||||
// Text(stop)
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.surrus.peopleinspace.glance
|
||||
|
||||
|
||||
import androidx.glance.appwidget.GlanceAppWidget
|
||||
import androidx.glance.appwidget.GlanceAppWidgetReceiver
|
||||
|
||||
class MyAppWidgetReceiver : GlanceAppWidgetReceiver() {
|
||||
override val glanceAppWidget: GlanceAppWidget = MyAppWidget()
|
||||
}
|
10
app/src/main/res/xml/widget_info.xml
Normal file
10
app/src/main/res/xml/widget_info.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:minWidth="80dp"
|
||||
android:minHeight="80dp"
|
||||
android:targetCellWidth="2"
|
||||
android:targetCellHeight="2"
|
||||
android:minResizeWidth="40dp"
|
||||
android:minResizeHeight="40dp"
|
||||
android:maxResizeWidth="120dp"
|
||||
android:maxResizeHeight="120dp"
|
||||
android:resizeMode="horizontal|vertical" />
|
|
@ -29,5 +29,6 @@ allprojects {
|
|||
mavenCentral()
|
||||
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
|
||||
maven(url = "https://jitpack.io")
|
||||
maven(url = "https://androidx.dev/snapshots/latest/artifacts/repository")
|
||||
}
|
||||
}
|
|
@ -11,10 +11,10 @@ object Versions {
|
|||
const val kotlinxSerialization = "1.2.2"
|
||||
const val kotlinxHtmlJs = "0.7.3"
|
||||
|
||||
const val compose = "1.0.4"
|
||||
const val compose = "1.1.0-beta01"
|
||||
const val wearCompose = "1.0.0-alpha08"
|
||||
const val navCompose = "2.4.0-alpha10"
|
||||
const val accompanist = "0.19.0"
|
||||
const val accompanist = "0.21.0-beta"
|
||||
|
||||
const val junit = "4.12"
|
||||
const val androidXTestJUnit = "1.1.3"
|
||||
|
|
Loading…
Reference in a new issue