Skip to content

Fast & Easy Form is an Android form builder library that simplifies creating and managing forms with features like validations, data retrieval, updates, and event listeners.

Notifications You must be signed in to change notification settings

LordSaac/FastEasyForm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast & Easy Form: is a builder forms for your Android project, with this library you will can build forms more fast and easy, using a clear structure for implement in your proyect. This solution offer a different tools like: validations, get data, update data and events listeners.

Build status codecov codebeat badge API Maven Central

Examples

DARK MODE ON Menu Screen Input
Example Example Example

Documentation

Features

  • Reduce development time for forms
  • Create simple and user-friendly forms
  • Implement row-level validation for the form fields
  • Ability to update rows/data within the form
  • Retrieve data based on a unique identifier
  • Implement interactive listeners for form elements
  • Scroll view form
  • Customize text colors
  • Customize icons
  • Change size text
  • Support for Jetpack Compose
  • Support Dark Mode
  • Use Java 11

Requirements

Fast & Easy Form is written in Kotlin & Java and compatible with min Sdk version 26 and min version Java 11. This library is only compatible with phones.

Installation

Settings Gradle

Fast & Easy Form is available through Github. To install it, simply add the following line to your settings gradle:

allprojects {
    repositories {

       maven { url 'https://jitpack.io' }

    }
}

Dependencie

For dependencie version, add the following to your gradle:

 compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
 }

kotlinOptions {
        jvmTarget = '11'
 }

dependencies {

 implementation 'com.github.xprojects-K:FastEasyForm_Android:v1.1.0'

}

Getting Started

Example MainActivity

For classic class activity follow the next code example.

class MainActivity : AppCompatActivity(), FormsListenerIGB {

    private lateinit var rv_main: RecyclerView // Add RecyclerView into xml

    private lateinit var easyForm: EasyForm

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        this.rv_main = findViewById(R.id.rv_main)

        this.init()

    }

    private fun init(){

 this.easyForm = BuildForm(mContext = this) {

    mode = ThemeMode.DARK 

    container = this.rv_main  

    body { 

        section { 

            title = "My Section Number 1"
            description = "Here I put my first section."

            content { 

                Row(RowType.TITLE) { 
                    setText.title = "Getting started"
                    setColor.title = R.color.colorPrimary_aar 
                }

                Row(RowType.INFO) { 
                    setText.title = "Hello world!"
                    setColor.title = R.color.colorGray 
                }

            }

        }

    }

}


    }



    override fun actionFormResponse(result: ResponseFormsIGB) {



    }

}

Example ComposeActivity

For projects JetPack Compose follow the next code example.

class ComposeActivity : ComponentActivity() {

    private val context = this

    private lateinit var easyForm: EasyForm

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        this.easyForm = EasyForm(this)

        setContent {
            FormSimpleIGBTheme {
                // A surface container using the 'background' color from the theme

                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {

                    ComposeScreen(context,easyForm)

                }
            }
        }
    }

}

Composable

Config the composable code into activity or preview screen.

@Composable
fun ComposeScreen(context:Context,customForm: EasyForm) {

    EasyFormCompose(
        customForm = customForm,
        modifier = Modifier.fillMaxWidth(),
        mode = uiMode.dark,
        body = {

         
               Section {

                title = "Configuration Settings"

                description = "Config your configuration setting"

                Content {

                    Row(RType.ACTION) {
                        tag = "FRECUENCIA_VISITA"
                        setText.title = "Sounds & Others"
                        setText.descriptionBottom = "Configuration your sounds & rintongs settings"
                        setText.bubble = "1"
                        setImage.iconLeft = R.drawable.sound_color
                        setText.titleToolbar = "Atras"
                        setSize.title = 14f

                        onClick {




                        }


                    }

                    Row(RType.ACTION) {

                        tag = "GAME_SETTING"
                        setText.title = "Game Setting"
                        setText.descriptionBottom = "Configuration your games settings"
                        setImage.iconLeft = R.drawable.controler_color
                        setSize.title = 14f

                        onClick {




                        }

                    }

                    Row(RType.ACTION) {
                        tag = "FRECUENCIA_VISITA"
                        setText.title = "Notifications"
                        setText.descriptionBottom = "Configuration your favorite ringtone settings"
                        setImage.iconLeft = R.drawable.bell_color
                        setSize.title = 14f

                        onClick {

                        }
                    }

                }

            }
   
         
        }

    )

}

Documentation

Functions

Functions Descriptions Code
start Starts generating the form in the user interface. easyForm.start(your_reciclerview)
validateAll Valid all fields of the form. easyForm.tool.validateAll()
validateByTag Validates a specific field identified by a label. easyForm.tool.validateByTag("Tag Id")
getResultByTag Gets the result of a specific field by its label. easyForm.tool.getResultByTag("Tag Id")
getResult Gets the overall result of the form. easyForm.tool.getResultAll()
updateRow Updates a row or section of the form. easyForm.tool.updateRow("Tag Id",ResponseFormsIGB())
eventChecked Handles item verification or selection events. easyForm.tool.eventChecked(false,0)
finishProgressView close action progress view when execurted a action. easyForm.tool.finishProgressView("YOUR_TAG_ID")
startProgressView start action progress view for execute an any action. easyForm.tool.startProgressView("YOUR_TAG_ID")

Forms Structure

This code sets up a form structure with sections and rows. It configures the theme mode, specifies a container, divides the form into sections, and defines the content within those sections. This structure provide a structured way to create forms with different elements and configurations.

var easyFastForm = BuildForm(mContext = this) {

    mode = uiMode.dark // Config theme with three options: LIGHT, DARK, & AUTO (System theme selected for the user).

    container = MyRecyclerView // Set your RecyclerView; this option is only used when using classic mode, not JetPack Compose.

    body { // Inside this option, you can set Rows or Sections, depending on your form's structure.

        section { // If you want to divide your form into sections, use this option

            title = "My Section Number 1"
            description = "Here I put my first section."

            content { // Inside this option, you can set your rows.

                row(RowType.INFO) {
                    title = "Developer"
                    text = "JIGB-K"
                }

            }

        }

    }

}

Row Descriptions

TITLE

It is a property to invoke rows within the form to declare the section's title below it.

Example code
  Row(RType.TITLE) { // <--- Add Title

            setText.title = "Getting started" //<--- add your title name

            setColor.title = R.color.colorPrimary_aar
        }

ACTIVITY

It's a row that functions to make direct calls to other windows within the project. It is fully configurable and easy to use.

Example code
   Row(RType.ACTIVITY){ // <-- Here Call Any activity
            title = "Test Activity #1"//<-- title .
            activity = ExampleActivity::class.java // <-- Add your activity
        }

MULTIPLE_CHECK_LIST

This functionality allows selecting more than one option, making it great for multiple-choice questionnaires.

Example code
   Row(RType.MULTIPLE_CHECK_LIST){

                tag = "002"
                setText.title = "Favorite Fruit"


                checkList{

                    option(){
                        text = "Banana"

                    }

                    option(){
                        text = "Apple"
                    }

                    option(){
                        text = "Peach"
                    }

                    option(){
                        text = "Papaya"

                    }

                }

                validation = true

            }

CHECK

Specifically for rows needing quick validation, like accepting terms or specific questions.

Example code
     Row(RType.CHECK){

                setText.text= "Are you like you job?" // Add text for the text
                tag = "0012" //tag for identification of the row
                checked = true // Initialize check in false or true

            }

EDIT

For rows requiring various text editions, such as numbers, phones, emails, etc.

Example code
      Row(EDIT){

                setText.title = "Cell Phone"// title row.
                inputTypeEditText = InputType.TYPE_CLASS_PHONE //  To choose type EDITTEXT (https://developer.android.com/reference/android/widget/EditText)
            }

SINGLE_CHECK_LIST

Enables choosing a single option from several available choices.

Example code
       Row(RType.SINGLE_CHECK_LIST){

                tag = "007"
                setText.title = "Favorite Movie"
                setting.rowSingleCheck.activeIconSuccess = true

                checkList{

                    option(){
                        text = "Action"

                    }

                    option(){
                        text = "Drama"
                    }

                    option(){
                        text = "Comedy"
                    }

                    option(){
                        text = "Fantasy"

                    }

                }

                validation = true

            }

ON_CLICK

Use this row for a button actions for config any action.

Example code
       Row(RType.ON_CLICK){

                setText.title = "Click me!"

                onClick {

                    val builder = AlertDialog.Builder(context)
                    builder.setTitle("Hello")
                        .setMessage("I'm here")
                        .setPositiveButton("OK") { dialog, _ ->
                            // Do something when OK button is clicked
                            dialog.dismiss()
                        }
                        .setNegativeButton("Cancel") { dialog, _ ->
                            // Do something when Cancel button is clicked
                            dialog.dismiss()
                        }
                        .show()

                }

            }

INFO

Primarily used to display information without offering special functionalities.

Example code
    Row(RType.INFO){
            setText.title = "Licence"// title row.
            setText.text= "Copyright 2024 José I. Gutiérrez B."
        }

ACTION

This row is use for action like jump to another activity or execute fuction in your main activity.

Example code
    Row(RType.ACTION) {
                            tag = "FRECUENCIA_VISITA"
                            setText.title = "Sounds & Others"
                            setText.descriptionBottom = "Configuration your sounds & rintongs settings"
                            setText.bubble = "1"
                            setImage.iconLeft = R.drawable.sound_color
                            setText.titleToolbar = "Atras"
                            setSize.title = 14f

                            onClick {

                                // Your code Here

                            }

                        }

DATE_PICKER

This row is use for active the date picker native in Android.

Example code
   Row(RType.DATE_PICKER) {
                            tag = "Select Birthday"
                            setText.title = "Birthday"
                            setDatePicker.format = "dd/MM/yyyy"
                            setText.descriptionBottom = "12/01/2024"
                            setImage.iconLeft = R.drawable.calendar_color
                            setSize.title = 14f
                        }

TIME_PICKER

This row is use for active the time picker native in Android.

Example code
    Row(RType.TIME_PICKER) {
                            tag = "Select Time"
                            setText.title = "Check In"
                            setTimePicker.format = "hh:mm a"
                            setTimePicker.is24HourFormat = false
                            setImage.iconLeft = R.drawable.calendar_timer
                            setSize.title = 14f
                        }

SWITCH

This row is use for active the control swtich, you can personalize the the calor.

Example code
      Row(RType.SWITCH) {
                            setText.title = "Terms & Conditions"
                            setText.descriptionBottom = "Are you agree with our terms?"
                            setText.edtHint = "Insert your email"
                            setImage.iconLeft = R.drawable.contract_file
                            setSwitch.active = false
                            tag = "MY_TERMS"
                        }

Parameters and compatibility per row

Description of general parameters

Parameter Row compatibility Description
tag ALL Assigns a unique identifier.
Activity ACTIVITY Used to invoke the desired activity.
bundleActivity ACTIVITY Used to send information between activities.
checked ALL Declares that the field in this row needs validation before processing.
isAvailable EDIT Specifies if the displayed data is enabled for editing.
isSingleList SINGLE_CHECK_LIST Notifies the list that the selection will be one-to-many.
universalContentGravity ALL Adjusts the position of the container confirming the entire row's body.
isEndableImageSelected SINGLE_CHECK_LIST Enables or disables checkboxes.
TypeRow ALL Assigns the type of row to be built.
onClick ACTION Config any action into onclick.

Description of categorized parameters used for SetText

Parameter Row compatibility Description
title ALL Assigns text for the title.
titleToolbar SINGLE_CHECK_LIST, MULTIPLE_CHECK_LIST Assigns text for the title toolbar.
bubble ALL Assign number or text for into bubble text.
text ALL Assigns a description below the title.
descriptionBottom ALL Assigns a title bottom below the title.
btnFinishSelect MULTIPLE_CHECK_LIST Assigns a title bottom below the options to select.
edtHint EDIT Displays informative text inside the edit field.
comment EDIT Adds special comments within the row.
icon ALL Used to assign icons using Font Awesome codes.
errorMessages ALL Displays informative text indicating that this field must be filled.

Description of categorized parameters for Lists

Parameter Row compatibility Description
options SINGLE_CHECK_LIST, MULTIPLE_CHECK_LIST Assigns special lists to choose from one or many options, depending on the list type.
arrayDates CALENDAR Assigns a special list of dates to delimit dates between weeks.

Description of categorized parameters for setValidation

Parameter Row compatibility Description
validationOn SINGLE_CHECK_LIST, MULTIPLE_CHECK_LIST, EDIT Active validation, when you the parameters is important for your form. This important use this option whit funcions validationByTag or validationAll
rulePattern EDIT If you need validation special character, you can using regular expression.

Description of categorized parameters for EditText

Parameter Row compatibility Description
isEditable EDIT Sets whether the data can be edited by the user.
inputTypeEditText EDIT Configures the keyboard type for data capture.
maxLength EDIT Sets the maximum number of characters the user can input.

Description of categorized parameters for Setting

Parameter Row compatibility Description
rowSingleCheck.activeIconSuccess SINGLE_CHECK_LIST When user selected a options will appear icon success.
rowMultipleCheck.activeIconSuccess MULTIPLE_CHECK_LIST When user selected a options will appear icon success.

Description of categorized parameters for Animations

Parameter Row compatibility Description
intentEnter ACTIVITY Assigns an animation for opening an activity.
intentExit ACTIVITY Assigns an animation for closing an activity.

Description of categorized parameters for Set Colors

Parameter Row compatibility Description
title ALL Sets the color for row titles.
descriptions ALL Sets the color for row descriptions.
descriptionBottom ALL Sets the color for row descriptions below the title
icons ALL Sets the color for row icons.
separator ALL Sets the color for lines separating rows.
circle ALL Not enabled at the moment.
letter ALL Sets the color for row titles.
edit ALL Sets the color for text editing titles of a row.
editStyle ALL Not enabled at the moment.
titleToolbar ALL Sets the color for toolbar component titles.
backgroundToolbar ALL Sets the color for the background of the row container.
backgroundContent ALL Sets the color for the background of the row container.
imageEmpty ALL Sets the background color for image containers.
progressView ALL Sets the background color for progress view.
backgroundContentMain ALL Change color background of the row.
btnFinishSelect MULTIPLE_CHECK_LIST Change color background of the button for the list multiple select.

Description of categorized parameters for Set Time Picker

Parameter Row compatibility Description
is24HourFormat TIME_PICKER Set boolean parameter for enable format 24 format for the time picker row.
format TIME_PICKER Set specify format for show the time after selected.

Description of categorized parameters for Set Date Picker

Parameter Row compatibility Description
format DATE_PICKER Set specify format for show the date after selected.

Description of categorized parameters for Size

Parameter Row compatibility Description
title ALL Allows assigning the title size.
description ALL Allows assigning the description size.
description bottom ALL Allows assigning the description bottom size.
bubble ALL Allows assigning the bubble size.
letter ALL Not enabled at the moment.
edit ALL Allows assigning the size of editable texts.
icon ALL Allows assigning the size of icons.
iconLeft ALL Allows assigning the size of icons left.
row ALL Allows assigning the general size of the row.

Description of categorized parameters for Padding

Parameter Row compatibility Description
Content ALL Sets spaces inside the entire container equally.
Content.top ALL Sets spaces inside affecting the top part of the container.
Content.bottom ALL Sets spaces inside affecting the bottom part of the container.
Content.left ALL Sets spaces inside affecting the left part of the container.
Content.right ALL Sets spaces inside affecting the right part of the container.

Description of Categorized Parameters for Margin

Parameter Row compatibility Description
content ALL Sets spaces outside the entire container equally.
content.Top ALL Sets spaces outside affecting the top part of the container.

Description of Categorized Parameters for Alignment

Parameter Row compatibility Description
text ALL Aligns text on different lines, either center, left, or right of the container.
description ALL Aligns the description on different lines, either center, left, or right of the container.

Description of categorized parameters for Visibility

Parameter Row compatibility Description
title ALL Controls the visibility of the title (Visible, Invisible, or Gone depending on the context).
description ALL Controls the visibility of the description (Visible, Invisible, or Gone depending on the context).
icon ALL Controls the visibility of the icon (Visible, Invisible, or Gone depending on the context).
check ALL Controls the visibility of the checkbox (Visible, Invisible, or Gone depending on the context).
editText ALL Controls the visibility of the editable text (Visible, Invisible, or Gone
switch SWTICH Controls the visibility of the switch view text (Visible, Invisible, or Gone
descriptionBottom ALL Controls the visibility of the descroption bottom view text (Visible, Invisible, or Gone
iconLeft ALL Controls the visibility of the icon left (Visible, Invisible, or Gone depending on the context).
btnFinishSelect MULTIPLE_CHECK_LIST Controls the visibility of the bottom finish select (Boolean).
activeBtnCheck MULTIPLE_CHECK_LIST Controls the visibility of the image check (Boolean).
bubble ALL Controls the visibility of the bubble text (Visible, Invisible, or Gone depending on the context).
progressBarRight ALL Controls the visibility of the progress view (Visible, Invisible, or Gone depending on the context).

Example project

The project example is separate from the main project, if you want check the project, you can check click HERE.

Contribution

Thank you for use this library on your project, with you collaboration this project could grow more with improvements and new idea. This project don't have support but you are most welcome to contribute.

Licence

Copyright 2024 José I. Gutiérrez B.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Fast & Easy Form is an Android form builder library that simplifies creating and managing forms with features like validations, data retrieval, updates, and event listeners.

Topics

Resources

Stars

Watchers

Forks

Packages