Skip to content

Commit

Permalink
Merge pull request #1 from Dilivva/development
Browse files Browse the repository at this point in the history
Add readme for places lib
  • Loading branch information
ayodelekehinde committed Apr 19, 2024
2 parents e2eb07a + bfb962f commit 8ee4ccc
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions places/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

# Google Places
This lets you launch the google places widget from your compose multiplatform code

## Getting Started

1. **Add to your dependencies:**

```kotlin
// In your root build.gradle.kts file
repositories {
mavenCentral()
}
kotlin{
sourceSets {
commonMain.dependencies{
implementation("com.dilivva:google-places:${version}")
}
}
}
```

2. **Explore the API:**

## Usage Example

```kotlin
//Initialize places sdk
GooglePlace.initialize("key")

//in your composable
@Composable
fun SearchScreen(){
val googlePlaces = rememberGooglePlaces(
config = PlacesConfig(fields = PlacesFields.entries.toList(), countries = listOf("ng")),
onResult = {
when(it){
is PlaceResult.Cancelled -> println("Closed")
is PlaceResult.Failure -> it.error
is PlaceResult.Success -> it.place
}
})

//Launch the search widget
Button(
onClick = { googlePlaces.launch() },
enabled = true
) {
Text("Search place")
}
}
```

0 comments on commit 8ee4ccc

Please sign in to comment.