Skip to content

Feature Request: Compose Wear OS UI #1284

@rohankhayech

Description

@rohankhayech

It would be useful to have an in-built LibrariesContainer that uses the Compose Wear M3 components, for displaying third-party libraries in Wear OS apps. Ideally this would be in its own module to avoid depending on the regular Compose M3 library.

Currently I am using the following example component using the compose-core-android module but it would be nice to have something more robust:

Image
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.TitleCard
import androidx.wear.compose.material3.ListHeader
import com.mikepenz.aboutlibraries.ui.compose.android.produceLibraries
import com.mikepenz.aboutlibraries.ui.compose.util.author

@Composable
fun ExampleWearLicenseScreen() {
  val listState = rememberScalingLazyListState()
  
  ScreenScaffold(
      scrollState = listState
  ) { padding ->
      val libs by produceLibraries()
      val uriHandler = LocalUriHandler.current

      ScalingLazyColumn(
          state = listState,
          contentPadding = padding
      ) {
          item { ListHeader {
              Text("Third-Party Licenses")
          }}
          items(libs?.libraries ?: emptyList(), key = { it.uniqueId }) {
              TitleCard(
                  title = {
                      Text("${it.name} ${it.artifactVersion ?: ""}")
                  },
                  time = {
                      Text(it.author)
                  },
                  subtitle = {
                      Text(it.licenses.joinToString(", ") { l -> l.name })
                  },
                  onClick = {
                      // Open license on browser or connected phone.
                      it.licenses.first().apply {
                          if (!url.isNullOrBlank()) uriHandler.openUri(url!!)
                      }
                  }
              )
          }
      }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions