Skip to content

Commit

Permalink
Merge pull request #4 from JosLuna98/master
Browse files Browse the repository at this point in the history
plugin v1 is completely discontinued
  • Loading branch information
JosLuna98 committed Nov 1, 2020
2 parents b5a7302 + 6aac97b commit 7fcf966
Show file tree
Hide file tree
Showing 47 changed files with 579 additions and 314 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
gen_doc.sh

# IntelliJ related
*.iml
Expand Down Expand Up @@ -72,4 +73,4 @@ build/
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
6 changes: 3 additions & 3 deletions .metadata
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 0b8abb4724aa590dd0f429683339b1e045a1594d
channel: stable
revision: e6b34c2b5c96bb95325269a29a84e83ed8909b5f
channel: beta

project_type: package
project_type: plugin
80 changes: 8 additions & 72 deletions CHANGELOG.md
@@ -1,77 +1,13 @@
## [1.3.5+1]
## 1.4.2

* discontinued
* Add explicit dialog context like a parameter in the onDone function

## [1.3.5]
## 1.4.1

* The *onCleaned* function parameter added in **AddressSearchTextField** and **AddressSearchBox**.
* Fix possible bug from useless conditional

## [1.3.4]
## 1.4.0

* Limiter sufix icon in **AddressSearchBox** to search for an address removed.
* The search for an address is optimized.
* New *city*, *hintText* and *noResultsText* parameters added in **AddressSearchTextField** and **AddressSearchBox**.

## [1.3.3+2]

* A bug when the user selects their reference in **AddressSearchBox** widget fixed.

## [1.3.3]

* A *barrierDismissible* parameter added in **AddressSearchTextField**.
* The *onEditingComplete* and *onChanged* internal functions in **AddressSearchBox** adapted to new functionalities.
* The *onDone* function is no longer required.

## [1.3.2]

* sufix icon in **AddressSearchBox** modified to can limit addresses requests.

## [1.3.1]

* Limiter to search for an address removed.

## [1.3.0+1]

* Static method *widget* removed from **AddressSearchTextField**, it's a stateless widget now.
* **AddressSearchTextField** widget doesn't need context parameter.

## [1.2.2]

* **AddressPoint** returns valid latitude and longitude values when *found* is false.
* UI issues in **AddressSearchBox** fixed.

## [1.2.1]

* Dependency in example app fixed.
* *coordForRef* boolean added, if **AddressSearchBox** finds coordinates by a written reference but not nearby places and the user selects the reference, then those coordinates can be used.

## [1.2.0]

* Parameter for the controller added to **AddressSearchTextField**
* Private *_AddressSearch* widget is now public and is named **AddressSearchBox**, it can be used independently.
* *onDone* function in **AddressSearchBox** can now be asynchronous and have a CircularProgressIndicator while it's running.
* *onDone* function now doesn't pop the widget, you have to add the code to close it.
* **AddressPoint** object has a new method to find an address from passed latitude and longitude values.

## [1.1.0]

* Optimized
* Class name changed to **AddressSearchTextField**
* *country* parameter added to AddressPoint object
* AddressPoint object only has *getters* for its values

## [1.0.0]

* Static functions issue fixed.
* *result* getter function removed.
* Callback with *result* added.
* parameter for TextStyle added.

## [0.1.0+1]

* *values* is now named *result*.
* Update documentation.

## [0.0.1]

* First release.
* Remake of [AddressSearchTextField](https://pub.dev/packages/address_search_text_field) Plugin due to the update of Flutter 1.17 and Dart 2.8
* `LocationService` class is now an async static function called `initLocationService`
* Updated the [README.md](https://pub.dev/packages/address_search_field#-readme-tab-) for a better explanation of plugin.
143 changes: 66 additions & 77 deletions README.md
@@ -1,36 +1,24 @@
# Address Search Text Field
# This plugin is discontinued, please see [Address Search Field](https://pub.dev/packages/address_search_field)
# Address Search Field

A text field that displays an address search box that finds a location by typing a reference and gets nearby addresses. Selecting the desired address returns an object with the latitude, longitude, and full address of the place.
A text field that displays an address search box to find a location by typing a reference and gets nearby addresses. Selecting the desired address returns an object with the latitude, longitude, and full address of the place.
It uses [location](https://pub.dev/packages/location), [geolocator](https://pub.dev/packages/geolocator), [geocoder](https://pub.dev/packages/geocoder) plugins.

## Getting Started

To use this plugin, add `address_search_text_field` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). For example:
![](https://raw.githubusercontent.com/JosLuna98/address_search_field/master/screenshot/untitled.gif)

**NOTE:** This package was made with Flutter 1.17 and Dart 2.8, make sure you have your environment within the version range.
```yaml
dependencies:
address_search_text_field: ^1.3.5+1
environment:
sdk: ">=2.7.0 <3.0.0"
flutter: ">=1.10.0"
```

### Android

**NOTE:** As plugins switched to the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found [here](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility).

1. Add the following to your "gradle.properties" file:

```
android.useAndroidX=true
android.enableJetifier=true
```
2. Make sure you set the `compileSdkVersion` in your "android/app/build.gradle" file to 28:
## Getting Started

```
android {
compileSdkVersion 28
To use this plugin, add `address_search_field` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). For example:

...
}
```yaml
dependencies:
address_search_field: ^1.4.2
```

## Permissions
Expand All @@ -43,7 +31,7 @@ On Android you'll need to add either the `ACCESS_COARSE_LOCATION` or the `ACCESS
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
```
Also you should add internet permission
Also you have to add internet permission
``` xml
<uses-permission android:name="android.permission.INTERNET"/>
```
Expand All @@ -61,86 +49,72 @@ On iOS you'll need to add the `NSLocationWhenInUseUsageDescription` to your Info

Import the package:
```dart
import 'package:address_search_text_field/address_search_text_field.dart';
import 'package:address_search_field/address_search_field.dart';
```

**NOTE:** *coordForRef* parameter will set the first data in the list of found addresses to *point* in *OnDone* function if user select their reference like an address.
* This widget is a search box to write a reference about a place and find an address.

```dart
Widget addressSearchTextField = AddressSearchTextField(
AddressSearchBox(
controller: TextEditingController(),
decoration: InputDecoration(),
style: TextStyle(),
barrierDismissible: bool,
country: String,
city: String,
hintText: String,
noResultsText: String,
noResultText: String,
exceptions: <String>[],
coordForRef: bool,
onDone: (AddressPoint point) {},
onDone: (BuildContext dialogContext, AddressPoint point) {},
onCleaned: () {},
);
```

| Parameters | Description |
|------------|-------------|
| controller | TextEditingController (optional)
| decoration | InputDecoration (optional)|
| style | TextStyle (optional) |
| barrierDismissible | bool (optional) |
| country | String (Not Null) (required) |
| city | String (optional) |
| hintText | String (required) |
| noResultsText | String (required) |
| exceptions | List < String > (optional)|
| coordForRef | bool (optional) |
| onDone | Function(AddressPoint) (optional) |
| onCleaned | Function() (optional) |
| Parameters | Type | Description |
|------------|------|-------------|
| controller | Optional | The controller allows you to interact with the text in the field. |
| country | Required, Not Null | You have to set in which country to search. |
| city | Optional | You may set in which city to search. |
| hintText | Required, Not Null | Text suggestion according to your language in the search box. |
| noResultsText | Required, Not Null | Message according to your language when the search box doesn't find anything. |
| exceptions | Optional| Results you don't want to show. |
| coordForRef | Optional | It's false by default. With the value true, it will use what the user typed in the search box as a valid Address. |
| onDone | Optional | When the search stops, it gives you an AddressPoint object with confirmation if a place has been found, full address, and coordinates. |
| onCleaned | Optional | When the search box is closed with an empty text field, this function is executed. |

* This widget is a `TextField` that displays a` AddressSearchBox` by tapping it. It has 3 more parameters to personalize the `TextField`.

```dart
Widget addressSearchBox = AddressSearchBox(
AddressSearchField(
controller: TextEditingController(),
decoration: InputDecoration(),
style: TextStyle(),
barrierDismissible: bool,
country: String,
city: String,
hintText: String,
noResultText: String,
noResultsText: String,
exceptions: <String>[],
coordForRef: bool,
onDone: (AddressPoint point) {},
onDone: (BuildContext dialogContext, AddressPoint point) {},
onCleaned: () {},
);
```

| Parameters | Description |
|------------|-------------|
| controller | TextEditingController (optional)
| country | String (Not Null) (required) |
| city | String (optional) |
| hintText | String (required) |
| noResultsText | String (required) |
| exceptions | List < String > (optional)|
| coordForRef | bool (optional) |
| onDone | Function(AddressPoint) (optional) |
| onCleaned | Function() (optional) |

At *onDone* function you get an AddressPoint object with confirmation if place has been found (in *found* method), full address and coordinates. [Example](https://pub.dev/packages/address_search_text_field#-example-tab-)

This plugin also has a **LocationService** class with an async static function called *init* to check and ask for location permissions, and a static variable called *controller* to use the [Location Package](https://pub.dev/packages/location) methods anywhere in your code.

**Example**

```dart
() async => await LocationService.init();
LocationService.controller.getLocation();
```
| Parameters | Type | Description |
|------------|------|-------------|
| decoration | Optional | The decoration to show around the text field. |
| style | Optional | The style to use for the text being edited. |
| barrierDismissible | Optional | It's true by default. With the value false, it won't close the search box when you tap outside it. |

## Outcomes
* When the address search is complete, you can get an `AddressPoint` object that provides the following values:

```dart
onDone: (AddressPoint point) {
print(point.toString());
onDone: (BuildContext dialogContext, AddressPoint point) {
bool found = point.found;
String address = point.address;
String country = point.country;
double latitude = point.latitude;
double longitude = point.longitude;
Navigator.of(dialogContext).pop(); // Use it JUST in a AddressSearchField widget to close the dialog.
}
```

Expand All @@ -149,8 +123,23 @@ There are three possible outcomes:
2. If a place has been found from the reference, all the variables will be initialized.
3. If the desired location has not been found and the reference entered by the user is selected, there will be no latitude and longitude values ​​and the address will be the user's reference since nothing was found.

![](https://raw.githubusercontent.com/JosLuna98/address_search_text_field/master/screenshot/untitled.gif)
**NOTE:** You can also find an address by it's coordinates using `await AddressPoint.fromPoint(latitude, longitude)`. If the address is not found, it will return `null`.

```dart
() async {
AddressPoint point = await AddressPoint.fromPoint(latitude, longitude);
if (point != null) print(point.address);
}
```

* This plugin also has an async static function called **initLocationService** to verify and request location permissions. You can use optional callbacks when location service is not enabled or if permission is not granted.

```dart
() async => await initLocationService(
noServiceEnabled: () {},
noPermissionGranted: () {},
);
```

## License

Expand Down
8 changes: 8 additions & 0 deletions android/.gitignore
@@ -0,0 +1,8 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
43 changes: 43 additions & 0 deletions android/build.gradle
@@ -0,0 +1,43 @@
group 'dev.jostech.address_search_field'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

rootProject.allprojects {
repositories {
google()
jcenter()
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
minSdkVersion 16
}
lintOptions {
disable 'InvalidPackage'
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
4 changes: 4 additions & 0 deletions android/gradle.properties
@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
5 changes: 5 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
1 change: 1 addition & 0 deletions android/settings.gradle
@@ -0,0 +1 @@
rootProject.name = 'address_search_field'
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifest.xml
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.jostech.address_search_field">
</manifest>

0 comments on commit 7fcf966

Please sign in to comment.