Comments (4)
Hi @jdesbonnet. Thank you for your feedback. There are two approaches to this: 1 is to create a text_color attribute on the DatePicker widget and possibly do the same for the other widgets as well. 2. add an attribute for styling individual widget globally. This attribute would work like Android style. I have created an issue for tracking this here Styling Widgets I would prefer second approach because of the flexibility it offers.
from neat-form.
Hi @jdesbonnet. I have started working on this issue as mentioned in my previous comment. I will be creating a pull request with this fix soon. Here is how it will work.
NOTE: This fix will be available for all the widgets and can be used to override any of the default styles.
Step 1: Declare Style
E.g.
<style name="sampleDatePickerStyle" parent="Widget.AppCompat.EditText">
<item name="android:textSize">18sp</item>
<item name="android:textColor">#4D9D4B</item>
</style>
Step 2: Supply the style to the form builder
Before creating the form supply the style to the FormBuilder
. I have introduced a resourcesMap
that can be accessed via the FormBuilder
. Which is a map of resource name (as defined in the widget's JSON) against the actual Android resource style. E.g. stylesMap["sampleDatePickerStyle"] = R.style.sampleDatePickerStyle
formBuilder.populateResourceMap(R.drawable::class.java)
formBuilder.populateResourceMap(R.style::class.java)
NOTE: we are explicitly calling the populate methods with the resources class in order to get the correct class name for the resources. We can't do this within the library because there R.drawable would only pick drawables available in the library alone but not for the app.
Step 3: Apply the style to the widget
Example:
{
"name": "dob",
"type": "datetime_picker",
"properties": {
"hint": "Enter birth date",
"type": "date_picker",
"display_format": "dd/MM/yyyy",
"min_date": "today-80y",
"max_date": "today",
"style": "sampleDatePickerStyle"
}
}
NOTE: Just make sure the name of the style in the widget's JSON matches the name in
stylesMap
from neat-form.
@jdesbonnet I updated the comment above. I made some slight adjustments. Instead of manually adding individual styles to the resourceMap, I added a utility method to assist with this (populateResourceMap). This will use reflection to fetch all the drawables and styles available in the app. For now it has to be called explicitly before building the form. Afterwards you can apply styling to widget's as supported. I also added background attribute for widget type edit_text that works in a similar way.
from neat-form.
Closed this. Issue fixed in v1.1.3
from neat-form.
Related Issues (20)
- Rules file documented as required but works without HOT 1
- Optimize dynamic calculations in Notifications.
- Support styling widgets
- Migrate to Kotlin Serialization HOT 1
- Recommendation for usage HOT 6
- Migrate to Maven Central
- Skip logic not working for Spinners
- Support Jetpack Compose
- How do i handle a button click?. Also get value of EditText?. And check if EditText value is empty HOT 1
- Some widgets missing the meta_data attribute after saving data HOT 1
- Set view values when data is provided
- Implement passing of custom checkbox attributes via custom xml form layout
- Publish package to JCenter as well
- App crushes when the custom xml layout contains views which are not available in json forms HOT 1
- Fix bug on searchable spinner - app crash on screen orientation changed
- Fix bug with rule engine HOT 1
- Fix memory leaks and optimize code HOT 1
- Implement repeating fields widgets.
- Implement maximum and minimum dates for datepicker dialogue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neat-form.