All Projects → bradleygore → nativescript-textinputlayout

bradleygore / nativescript-textinputlayout

Licence: other
Android Material Design TextInputLayout for NativeScript

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to nativescript-textinputlayout

nativescript-vue-rollup-template
A NativeScript template ready to roll with Vue.js and .vue files.
Stars: ✭ 39 (+11.43%)
Mutual labels:  nativescript
nativescript-pushy
Easy push notifications for your NativeScript app!
Stars: ✭ 19 (-45.71%)
Mutual labels:  nativescript
nativescript-getters
A NativeScript plugin that adds six new getters – in addition to the native "getViewById" method – to retrieve one or more views by tag, type, class, style, value pair or property.
Stars: ✭ 12 (-65.71%)
Mutual labels:  nativescript
nativescript-numeric-keyboard
🔢 Replace the meh default number/phone keyboard with this stylish one
Stars: ✭ 33 (-5.71%)
Mutual labels:  nativescript
nativescript-windowed-modal
Consistent modals for Android and iOS
Stars: ✭ 47 (+34.29%)
Mutual labels:  nativescript
angular2-webpack-advance-starter
An advanced Angular2 Webpack Starter project with support for ngrx/store, ngrx/effects, ng2-translate, angulartics2, lodash, NativeScript (*native* mobile), Electron (Mac, Windows and Linux desktop) and more.
Stars: ✭ 49 (+40%)
Mutual labels:  nativescript
nativescript-menu
A plugin that adds a pop-up menu to NativeScript
Stars: ✭ 17 (-51.43%)
Mutual labels:  nativescript
nativescript-healthcare-app
Healthcare example application built with NativeScript Angular. NativeScript template to quickly prototype your own business idea.
Stars: ✭ 24 (-31.43%)
Mutual labels:  nativescript
nativescript-app-icon-changer
Change the homescreen icon of your NativeScript iOS app at runtime!
Stars: ✭ 16 (-54.29%)
Mutual labels:  nativescript
nativescript-clipboard
📋 NativeScript plugin to copy stuff to the device clipboard, and read from it again
Stars: ✭ 40 (+14.29%)
Mutual labels:  nativescript
nativescript-apple-sign-in
Sign In With Apple, as seen on WWDC 2019, available with iOS 13
Stars: ✭ 37 (+5.71%)
Mutual labels:  nativescript
nativescript-webview-interface
Plugin for bi-directional communication between webView and android/ios
Stars: ✭ 87 (+148.57%)
Mutual labels:  nativescript
nativescript-vue-examples
🍈 NativeScript and Vue code samples.
Stars: ✭ 13 (-62.86%)
Mutual labels:  nativescript
nativescript-dev-webpack
A package to help with webpacking NativeScript apps.
Stars: ✭ 98 (+180%)
Mutual labels:  nativescript
nativescript-star-printer
🌟 Print directly to Star Micronics printers from your NativeScript app! http://www.starmicronics.com/
Stars: ✭ 28 (-20%)
Mutual labels:  nativescript
nativescript-fancy-calendar
Fancy calendar for NativeScript 😄 🍻
Stars: ✭ 21 (-40%)
Mutual labels:  nativescript
nativescript-taptic-engine
📳 Use Apple's Taptic Engine to vibrate your iPhone 6s (and up) in a variety of ways
Stars: ✭ 16 (-54.29%)
Mutual labels:  nativescript
firebase
Modular Firebase 🔥 implementation for NativeScript. Supports both iOS & Android platforms for all Firebase services.
Stars: ✭ 36 (+2.86%)
Mutual labels:  nativescript
code-samples
Find code samples and building blocks for your NativeScript app in the Marketplace
Stars: ✭ 35 (+0%)
Mutual labels:  nativescript
nativescript-snackbar
🍭 🍫 NativeScript plugin for Material Design SnackBar
Stars: ✭ 74 (+111.43%)
Mutual labels:  nativescript

nativescript-textinputlayout

Android Material Design TextInputLayout for NativeScript

Android TextInputLayout Documentation

iOS SkyFloatingLabelTextField Documentation


NO LONGER MAINTAINED

When I built this plugin, I was exploring NativeScript a lot in my spare time for fun. I currently do not have the spare time I used to have, so I will no longer be maintaining this plugin. PRs are welcome, or if you wish to take over maintenance submit an issue with your information and I'll contact you.

- Bradley


Usage

Install the plugin by running this command in your project root: tns plugin add nativescript-textinputlayout

The android and iOS implementations, while very similar in effect, have several differences. The below sections break up usage by platform.

Android

<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:TIL="nativescript-textinputlayout">
    <StackLayout>
        <!--TIL with all possible attrs via bindings-->
        <TIL:TextInputLayout class="demo-text-input-layout"
            hint="{{ hint }}"
            error="{{ error }}"
            errorEnabled="{{ isErrorEnabled }}"
            hintAnimationEnabled="{{ isHintAnimationEnabled }}"
            hintTextAppearance="SpecialTextInputLayout"
            errorTextAppearance="SpecialErrorTextInputLayout"
            counterEnabled="{{ isCounterEnabled }}">

            <!--ONE child element can be added, MUST be either TextField or TextView-->
            <TextField text="{{ demoText }}" />
        </TIL:TextInputLayout>

        <!--TIL with just a static hint-->
        <TIL:TextInputLayout hint="Hint Text">
            <TextField text="" />
        </TIL:TextInputLayout>
    </StackLayout>
</Page>

Attributes

Name Description Value Type Default
hint Text that shows up in the hint, and floating label String ""
error Text that will display as error message and make the widget look invalid String ""
errorEnabled Whether or not an error is enabled for the widget. If no error, it won't pad the bottom so much. However, if you set the error attr, it auto-sets this property under the hood to true Boolean false
hintAnimationEnabled Whether or not the 'float' action of the label should be animated Boolean true
hintTextAppearance Name of the style definition to apply to the floating label String ""
errorTextAppearance Name of the style definition to apply to the error message String ""
counterEnabled Whether or not a char counter should display in bottom-right of widget Boolean false

Styling

Several of the styles for the TextInputLayout need to be declared in the Theme for your app. This top-level set of styles will apply to the entire app. One way to do this is to have a style defined whose parent is AppTheme (the theme that NativeScript generates) and then set the app to use the new theme by updating the AndroidManifest.xml file. There are examples of this in the Demo.

There is one property that you can use to style the floating label. It's power is limited - it only applies when the field is focused - but it's something. Simply create a style rule, such as the one below, and set the TextInputLayout's hintTextAppearance property to the name of that style rule (see sample TextInputLayout XML above):

<!-- app/App_Resources/Android/values/appStyles.xml -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="SpecialTextInputLayout" parent="@android:style/TextAppearance">
        <item name="android:textColor">#F9D02A</item>
        <item name="android:textSize">12dp</item>
    </style>
    <style name="SpecialErrorTextInputLayout" parent="@android:style/TextAppearance">
        <item name="android:textColor">#FF0000</item>
        <item name="android:textSize">12dp</item>
    </style>
</resources>

Demo

To run the demo locally, run the following commands from the root folder after pulling down this repo: npm run setup and npm run demo.android

NativeScript Text Input Layout demo


iOS

The pod in use - pod 'SkyFloatingLabelTextField', '~> 3.3.0' - for the iOS functionality actually allows for a bit nicer markup as it extends UITextField, which NativeScript already has a wrapper for. So, instead of a TextInpuLayout that wraps a TextField, we just need a single element and we get to take advantage of all the normal TextField bindings that comes from NativeScript! Note, however, that there are two different kinds of inputs:

  • TextInputLayout - standard input with floating label, error message capability, etc..
  • TextInputLayoutWithIcon - same as above, with addition of an icon and icon-related properties..

NOTE: This pod relies on Swift 3.0, so I ended up using the NativeScript Swift 3.0 Plugin for this.

<TIL:TextInputLayout
    hint="{{ hint }}"
    isEnabled="{{ isEnabled }}"
    disabledColor="#c3c3c3"
    error="{{ error }}"
    text="{{ demoText }}"
    title="{{ title }}"
    color="{{ error ? '#aa0000' : '#d745ff' }}"
    tintColor="#d745ff"
    lineColor="#d745ff"
    selectedTitleColor="#ff45ca"
    selectedLineColor="#7a45ff"
    lineHeight="1.25"
    selectedLineHeight="3.5" />

<TIL:TextInputLayoutWithIcon
    hint="Is there an error?"
    text="{{ error }}"
    iconFont="{{ iconFont }}"
    iconText="{{ iconText }}"
    iconColor="#48c8ff"
    selectedIconColor="#aa0000"
    iconMarginLeft="2"
    iconMarginBottom="2"
    iconRotationDegrees="45"
    title="Error Text"
    tintColor="#48c8ff"
    lineColor="#48c8ff"
    selectedTitleColor="#6348ff"
    selectedLineColor="#48ff7f"
    lineHeight="0.5"
    selectedLineHeight="1" />

Attributes

Note: Any properties relating to color must be a value that is valid to pass to NativeScript's Color constructor

Note: Any properties relating to icon apply only to the TextInputLayoutWithIcon widget and will not do anything on the regular TextInputLayout widget.

Name Description Value Type Default
hint Text that shows up in the text field's placeholder area String ""
isDisabled Dictates if field is disabled Boolean false
disabledColor Field overall color (label, underline, text) when it's disabled String ""
error Text that will display as error message and make the widget look invalid String ""
title Text that will display in the 'floating label' when there is a value in the field (hint value used if nothing supplied) String ""
tintColor Color of the blinking cursor when field focused String ""
lineColor Color of the line underneath the field String ""
selectedTitleColor Color of the floating label when field is selected String ""
selectedLineColor Color of the line underneath the field when field is selected String ""
lineHeight Thickness of the line underneath the field (set to 0 for no line at all) Number 1
iconFont UIFont to use for the icon. Easiest way is to use the ui/styling/font module and create the font:
Font.default.withFontFamily("FontAwesome").withFontSize(16).getUIFont(null))
UIFont null
iconText Unicode value to pass to the icon. NOTE: I was only able to get this to work by binding it to a view model rather than passing the value in directly:
i.e. viewModel.set('iconText', '\uf06a') vs iconText="&#xf06a;"
String ""
iconColor Color of the icon String ""
selectedIconColor Color of the icon when field focused String ""
iconMarginLeft Margin on the left of the icon Number pod's default
iconMarginBottom Margin on the bottom of the icon Number pod's default
iconRotationDegrees Amount to rotate the icon Number pod's default

Demo

To run the demo locally, run the following commands from the root folder after pulling down this repo: npm run setup and npm run demo.ios

NativeScript Text Input Layout demo


Attributions

Nathanael Anderson - He helped me with what (LayoutBase, ContentView, View, ...) to subclass off of and helped me understand more of the nuances of each.

Brad Martin - I used his {N} plugins as guides for this one, and pestered him when I had questions.

Nathan Walker - I followed his tutorial in setting up this plugin.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].