Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AutoCompleteTextView in react native compatible with both iOS and Android

I need to implement AutoCompleteTextView in react native. The problem is that there is no such built-in component. All the modules and libraries available to mimic this feature is not completely similar. The main issue is the suggestions are not appearing over the view(like that of select box/picker). Even if it is then it is not behaving perfectly withKeyboardAvoidingView. The whole point is it is not working like native AutoCompleteTextView for Android

The other solution is using native UI element. But I want this component for both iOS and Android. Any help would be appreciated.

I want to achieve this option like tag user on the Facebook app I want to achieve this option like tag user on Facebook app I want to achieve this option like tag user on Facebook app

P.S.: Excuse the typos as I am using a mobile device.

like image 668
Ashish Avatar asked Mar 07 '18 18:03

Ashish


People also ask

Is React Native compatible with iOS and Android?

React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces. Use a little—or a lot. You can use React Native today in your existing Android and iOS projects or you can create a whole new app from scratch.

Can you use the same code base for both Android and iOS in React Native?

With React Native, one team can maintain two platforms and share a common technology — React. As you can use the same source code to run on iOS and Android devices, you don't have to hire separate developers to write code for Android and iOS devices.

Is React Native compatible with iOS?

React Native supports building apps for iOS, Android, and web from a single code base. It's a more affordable technology than Swift, yet it allows creating high-quality apps.

Can you use React Native for Android?

Overview. React Native is an open-source mobile application framework created by Facebook. It is used to develop applications for Android, iOS, Web and UWP (Windows) providing native UI controls and full access to the native platform. Working with React Native requires an understanding of JavaScript fundamentals.


1 Answers

After searching a lot for available Libraries and module, I came up with my own implementation of custom AutoCompleteTextView.
I have created a gist for AutoCompleteTextView.
The idea behind:

*There is one input field on the focus of this field keyboard appears.

*When keyboard appears we calculate space from top to input field and from input field till the start of keypad area.

*Will display an absolute positioned scroll view Suggestion area on top or bottom of input field based on the space calculation above.

*When keyboard goes away we hide the suggestion area.

Suggestions are welcome on how to improve this thing.

Suggestions appearing on top of the input field Suggestions appearing below the input field and above keyboard

like image 187
Ashish Avatar answered Oct 24 '22 08:10

Ashish