-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Dilivva/development
Add readme for places lib
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} | ||
``` |