From wiki.ginstr.com
Revision as of 22:10, 23 July 2015 by Danijel (talk | contribs) (Created page with "{|align=right |__TOC__ |} =Text= Widget is used for textual input of data by user. Value will be stored as datatype TEXT.<br> Back to ginstr app composer reference == P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Text

Widget is used for textual input of data by user. Value will be stored as datatype TEXT.
Back to ginstr app composer reference

Predefined user data

To read specification and understand it better we will assume that

  • name of the page to which widgets are added = "page one"
  • user entered the following data for the widget:
    - label name = "first name"
    - hint for input field = "please enter first name"
    - table name = "users"

Widget internal composition

Internal elements of the widget

Widget references

If widget is added via app composer autogenerated ids will be created according to table below.
Each new widget of this type with identical label added to screen will generate identical ids with increment number +1 at end of id;
id of first widget will have no number at the end, 2nd widget with same label will have "2" at the end, i.e. @+id/pageOneFirstNameLabel on first widget will be @+id/pageOneFirstNameLabel2 on 2nd widget with identical label

Control Attribute Value
TextView android:id @+id/pageOneFirstNameLabel
TextView android:text @string/pageOneFirstNameLabel
GnEditText android:id @+id/pageOnefirstName
GnEditText ek:s_hint @string/pageOneFirstNameHint
TextView ek:style @style/textEditableTextView
GnEditText ek:style @style/textEditableGnEditText

Attributes configuration

TextView

Preset attributes:

Attribute Value
android:id @+id/pageOneFirstNameLabel
android:layout_width match_parent
android:layout_height wrap_content
ek:style @style/textEditableTextView

User defined attributes:

Attribute Value
android:text @string/pageOneFirstName

GnEditText

Represents the internal organization of a widget:

Preset attributes:

Attribute Value
android:id @+id/pageOneFirstName
android:layout_width match_parent
android:layout_height wrap_content
ek:style @style/textGnEditText
ek:s_sourceType input
ek:data_type text

User defined attributes:

Attribute Value
ek:s_hint @string/pageOneFirstNameHint

Changes to other files

When widget is dropped from toolbox to the composer screen in app composer the following file changes will be performed.

strings.xml

Lines to be added for all languages.

<source lang="xml"> <string name="pageOneFirstNameLabel">first name</string> <string name="pageOneFirstNameHint">please enter first name</string> </source>

When dropping widget to screen from toolbox actions

Prompts

  • User will be prompted to write "label" for TextView (label).
  • User will be prompted to write "hint" for GnEditText (input).

Post prompt events

  • Value that user provided for label and page will be used as identifier of widget "pageOne" + "FirstName" + "Label" (+ "2" in case this is 2nd widget with same label)
  • Value that user provided for label and page "pageOne" + "label" will be used as identifier for label string in strings.xml (user entered input will be transformed to adapt to camel case convention, blanks will be removed)
  • Value that user provided for label will and page be added to strings.xml under the identifier as value; leading, trailing and duplicate blanks will be removed;
  • Value that user provided for label will and page be used as identifier of widget "pageOne" + "FirstName" (+ "2" in case this is 2nd widget with same label)
  • value that user provided for label and page + "hint" will be used as identifier for hint string in strings.xml (user entered input will be transformed to adapt to camel case convention)
  • Value that user provided for hint will be added to strings.xml under the identifier as value

Validators

Contains no validators

Logic

Contains no logic

Code snippets

Common widget code:

<source lang="xml"> <TextView

   android:id="@+id/pageOneFirstNameLabel"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="@string/pageOneFirstName"
   ek:style="@style/textTextView"/>

<com.ginstr.widgets.GnEditText

   android:id="@+id/pageOneFirstName"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   ek:s_hint="@string/pageOneFirstNameHint"
   ek:s_sourceType="input"
   ek:data_type="text"/>

</source>

Widget code for r/o variant:

<source lang="xml">

   <include common widget code>
   ek:style="@style/textEditableGnEditText"/>

</source>