Skip to content

Commit

Permalink
Merge pull request #61 from EnsembleUI/ruthUpdates
Browse files Browse the repository at this point in the history
Edits and New Files
  • Loading branch information
RuthLHanan authored Dec 11, 2023
2 parents 378eefa + 973a52a commit bde1270
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 17 deletions.
14 changes: 7 additions & 7 deletions build/user-interface/1-page-structure.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ensemble Page Structure

An Ensemble app comprises a series of pages and assets. Each page starts with a [View](#menu), followed by an optional [header](#header), an optional [menu](#menu), and a single widget for the body. There can be one of two things on ensemble page either a [View](#view) or group of multiple views together as [ViewGroup](#viewGroup).
An Ensemble app comprises a series of pages and assets. Each page starts with a [View](#view), followed by an optional [header](#header), an optional [menu](#menu), and a single widget for the body. There can be one of two things on ensemble page either a [View](#view) or group of multiple views together as [ViewGroup](#view-group).

List of things you will find reference and details here.

Expand All @@ -20,7 +20,7 @@ The ViewGroup widget allows you to group multiple Views together and organize th

### Example

let us take an example with a `Bottom Navigation Bar` menu type.
Let's look at an example with a `Bottom Navigation Bar` menu type.

<div class="code-container" markdown=1>
<button onclick="copyCode()" class="copy-code-button">Copy Code</button>
Expand All @@ -47,15 +47,15 @@ ViewGroup:
</div>
where each page denotes an individual `view`. Complete example can be found [here](https://studio.ensembleui.com/app/3vEZBIhDyYnIQo6BLN2O/screen/Wewvp6ZUyb0PBwkTAltQ?propertyPanelEnabled=true&instantPreviewDisabled=false)
Check it out in [studio](https://studio.ensembleui.com/app/3vEZBIhDyYnIQo6BLN2O/screen/Wewvp6ZUyb0PBwkTAltQ?propertyPanelEnabled=true&instantPreviewDisabled=false)
##### Output
<img src="/images/page_structure_1.png" style="border-radius:8px;" alt="BottomNavBar" height="500"/>
## View
The View widget defines the overall structure of a page, encompassing properties like header, body and more, to create a cohesive layout and presentation within your application. View requires only body while other components like [header](#header) and [menu](#menu) are optional.
The View widget defines the overall structure of a page, including properties like header, body and more, to create a cohesive layout and presentation within your application. View requires only body while other components like [header](#header) and [menu](#menu) are optional.
#### Properties
Expand Down Expand Up @@ -83,7 +83,7 @@ The View widget defines the overall structure of a page, encompassing properties
| Property | Type | Description |
| :-------- | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
| source | string | The Image URL to fill the background |
| fit | string | How to fit the image within our width/height or our parent (if dimension is not specified) . [see options](#fit-options-for-stylesbackgroundimage) |
| fit | string | How to fit the image within our width/height or our parent (if dimension is not specified) . [see options](#fit-options-for-stylesbackgroundImage) |
| alignment | string | Alignment of the background image |

#### Fit options for styles.backgroundImage
Expand Down Expand Up @@ -391,7 +391,7 @@ API provides a convenient way to interact with external services or data sources
| onError | Action | The action to handle errors |
| inputs | Array | The input values |

You can find many great example [here](/build/make-it-interactive/actions-and-events/1-invokeAPI)
You can find many great example [here](/actions/1-invokeAPI)

## Global

Expand Down Expand Up @@ -496,4 +496,4 @@ menu:

![Alt text](image-4.png)

You can check the complete App [here](https://studio.ensembleui.com/app/gVHb1fcLAjm373WtCK4l/screen/WEov9pB3G4nmuFLl0qx3?propertyPanelEnabled=true&instantPreviewDisabled=false&editorV2Enabled=true)
You can check the complete App [here](https://studio.ensembleui.com/app/iM58Wgr7bgzTxEi7rV40/screen/cYMnCfhOya8Vq1QG6aCC?propertyPanelEnabled=true&instantPreviewDisabled=false)
2 changes: 1 addition & 1 deletion build/user-interface/2-widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ Ensemble widgets enable you to build both simple and complex applications. Here
| Widget | Documentation | Kitchen sink example |
| ------------------ | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Progress indicator | [Link](/widget-reference/progressindicator) | [Link](https://studio.ensembleui.com/app/e24402cb-75e2-404c-866c-29e6c3dd7992/screen/c2c248f2-a289-40d3-acd5-65a1a7f3c5a2) |
| Toast message | [Link](/build/make-it-interactive/actions-and-events/6-showToast) | [Link](https://studio.ensembleui.com/app/e24402cb-75e2-404c-866c-29e6c3dd7992/screen/9a576805-019a-4bd3-953f-3c623fbfb905) |
| Toast message | [Link](/actions/6-showToast) | [Link](https://studio.ensembleui.com/app/e24402cb-75e2-404c-866c-29e6c3dd7992/screen/9a576805-019a-4bd3-953f-3c623fbfb905) |
File renamed without changes.
15 changes: 15 additions & 0 deletions tips-and-tricks/calling-api-response-to-fill-an-array.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Calling an API and Using It's Response to Fill an Array

**Objective**
To retrieve the API response, modify an array containing user details through a designated function each time the API is called, and subsequently update this array whenever the API is invoked using a code block triggered by the onTap event on an Icon. Finally, to visualize these user details by generating icons from the updated array using an item template.

To achieve this, consider the following steps:

1. Storage Handling:
Store the user details array as a variable in ensemble.storage.
2. Binding with Item Template:
Bind your item template to the stored array. This ensures that any manipulation of the array automatically triggers changes in the associated widget.
3. Array Update Mechanism:
After modifying the array values, make sure to set the array again. This step is crucial for triggering the binding mechanism and updating the widget accordingly.

By following this approach, you can integrate API responses, array manipulation, and visual representation using Ensemble, creating a dynamic and responsive user interface.
30 changes: 30 additions & 0 deletions tips-and-tricks/custom-card-component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Customizable Card Component

**Objective**

To construct a card component with individualized backgroundGradient or backgroundImage for each instance.

To achieve this, consider the following steps:

1. Define View Structure:
Begin by setting up the View component to establish a flexible layout that accommodates multiple card instances.

2. Create Test Widget:
Develop the Test component to serve as the card. Ensure it has the necessary structure to receive customizable inputs.

3. Pass Colors as Input:
Within the instantiation of the Test component in the View, employ the inputs attribute to provide an array of colors:
```yaml
- Test:
inputs:
colors: [0xFFFF0000, 0xFFFF00FF]
```
4. Apply BackgroundGradient Styles:
Inside the Test component's implementation, utilize the passed colors to define the backgroundGradient styles for the relevant container, e.g., a Row:
```yaml
Row:
styles:
backgroundGradient:
colors: ${colors}
```
24 changes: 15 additions & 9 deletions tips-and-tricks/directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ Welcome to our Tips and Tricks page! Here, you'll find a collection of expert in

## Index

- [Custom BottomNavBar item styling](/tips-and-tricks/custom-navbar-items)
- [Generalized Color All Button across an App ](/tips-and-tricks/general_primary_color-theme)
- [Making Progress Bars](/tips-and-tricks/progress-bars)
- [Background Color issue in EnsembleUI Preview](/tips-and-tricks/background-color-ensemble-preview)
- [Inputs to ChartJs](/tips-and-tricks/inputs-chartjs)
- [How to get ListView/GridView to take up all available height](/tips-and-tricks/list-gridview-stretch-to-available-height)
- [How to modify the BottomNavBar with custom styling and widgets](/tips-and-tricks/how-to-modify-bottom-navbar)
- [Using navigate Screen with BottomNavBar](/tips-and-tricks/navigateScreen-with-bottomNavBar)
- [Open a custom progress dialog and then close it on an event such as an API response](/tips-and-tricks/custom-progress-dialog-close-on-an-event.md)
- [Custom BottomNavBar item styling](/ensemble_docs/tips-and-tricks/custom-navbar-items)
- [Generalized Color All Button across an App ](/ensemble_docs/tips-and-tricks/general_primary_color-theme)
- [Making Progress Bars](/ensemble_docs/tips-and-tricks/progress-bars)
- [Background Color issue in EnsembleUI Preview](/ensemble_docs/tips-and-tricks/background-color-ensemble-preview)
- [Inputs to ChartJs](/ensemble_docs/tips-and-tricks/inputs-chartjs)
- [How to get ListView/GridView to take up all available height](/ensemble_docs/tips-and-tricks/list-gridview-stretch-to-available-height)
- [How to modify the BottomNavBar with custom styling and widgets](/ensemble_docs/tips-and-tricks/how-to-modify-bottom-navbar)
- [Using navigate Screen with BottomNavBar](/ensemble_docs/tips-and-tricks/navigateScreen-with-bottomNavBar)
- [Calling an API to fill and array](/ensemble_docs/tips-and-tricks/calling-api-response-to-fill-an-array)
- [Dynamic color modification](/ensemble_docs/tips-and-tricks/dymanic-color-modification)
- [Custom card component](/ensemble_docs/tips-and-tricks/custom-card-component)
- [Icons in bottomNavBar](/ensemble_docs/tips-and-tricks/icons-in-bottomNavBar)
- [InvokeHaptic](/ensemble_docs/tips-and-tricks/invoke-haptic.md)
- [Lottie Animations](/ensemble_docs/tips-and-tricks/lottie-animations.md)
- [HTML Widget](/ensemble_docs/tips-and-tricks/html-widget.md)
25 changes: 25 additions & 0 deletions tips-and-tricks/dynamic-color-modification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Dynamic Color Modification in JavaScript

**Objective**

To dynamically change the color of a Text widget based on a JavaScript variable. The goal is to customize the color property of the Text widget's style.

To achieve this, consider the following steps:

1. Access Text Widget:
Obtain a reference to the Text widget that you want to modify. In the provided example, it can be accessed using the identifier (id).
```yaml
- Text:
text: Hi there!
styles:
textStyle:
fontSize: 24
color: blue
id: helloUser
```
2. Modify Color Property:
Directly modify the color property of the Text widget's style using the assigned identifier.
```javascript
helloUser.color = 'red';
```
31 changes: 31 additions & 0 deletions tips-and-tricks/html-widget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# HTML Widget with maxLines Support and Enhanced Styling

The HTML widget allows you to apply CSS-like styles to specific elements within the HTML content. Customize text color, font size, and font weight effortlessly using both CSS tags and the box wrapper, providing increased styling flexibility.

The <div> with an id of "hello" and the <p> with an id of "tag2" are styled with various properties such as border, borderRadius, padding, color, fontWeight, backgroundColor, maxLines, and textOverflow.

- Html:
id: myHtml
cssStyles:
- selector: "#hello"
properties:
border: 10px solid red
borderRadius: 10px
padding: 20px
- selector: "#tag2"
properties:
color: white
fontWeight: "900"
backgroundColor: red
maxLines: 2
textOverflow: ellipsis
text: |
<div id="hello">
<p id="tag2">Until recently, the prevailing view assumed lorem ipsum was born as a nonsense text. “It's not Latin, though it looks like it, and it actually says nothing,” Before & After magazine answered a curious reader, “Its ‘words’ loosely approximate the frequency with which letters occur in English, which is why at a glance it looks pretty real.”</p>

As Cicero would put it, “Um, not so fast.”

The placeholder text, beginning with the line “Lorem ipsum dolor sit amet, consectetur adipiscing elit”, looks like Latin because in its youth, centuries ago, it was Latin.

Richard McClintock, a Latin scholar from Hampden-Sydney College, is credited with discovering the source behind the ubiquitous filler text. In seeing a sample of lorem ipsum, his interest was piqued by consectetur—a genuine, albeit rare, Latin word. Consulting a Latin dictionary led McClintock to a passage from De Finibus Bonorum et Malorum (“On the Extremes of Good and Evil”), a first-century B.C. text from the Roman philosopher Cicero.
</div>
34 changes: 34 additions & 0 deletions tips-and-tricks/icons-in-bottomNavBar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Configuring BottomNavBar Icons

**Objective**
To add a heart icon to a BottomNavBar item, ensuring correct rendering. If using a default icon, no additional library specification is needed; however, for non-default icons like Font Awesome, it's crucial to specify the library.

To achieve this, consider the following steps:

1. Default Icons:
If using default icons (e.g., "home," "search," "shopping_cart"), no library specification is required. Simply provide the icon name.
```yaml
BottomNavBar:
styles:
backgroundColor: 0xFF1F2128
items:
- label: Home
icon: search
screen: Home
```
2. fontAwesome Icons:
For non-default icons, particularly those from Font Awesome, ensure to specify the library using the iconLibrary attribute.
```yaml
BottomNavBar:
styles:
backgroundColor: 0xFF1F2128
items:
- label: Favourite
icon: heart
screen: Home
iconLibrary: fontAwesome
```
3. Active Icons:
If an active state icon is needed (e.g., a different icon when the item is selected), use the activeIcon attribute.
37 changes: 37 additions & 0 deletions tips-and-tricks/invoke-haptic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Invoke Haptics

We can use the invokeHaptic action to provide haptic feedback in your app. This feature enhances the user experience by providing tactile responses for different interactions.

The invokeHaptic action is utilized to trigger haptic feedback, and it supports various types such as heavyImpact, mediumImpact, lightImpact, and vibrate.
Buttons are used to demonstrate different haptic types, and the last button showcases using JavaScript code to invoke the lightImpact haptic.

Please note that haptics will only work on native apps.

invokeHaptic action is utilized to trigger haptic feedback, and it supports various types.
- Button:
label: Heavy Impact
onTap:
invokeHaptic:
type: heavyImpact

Additionally "Vibrate" button demonstrates chaining actions by using the onComplete property to execute additional JavaScript code after the haptic feedback is played.
- Button:
label: Vibrate (Using onComplete action to chain)
onTap:
invokeHaptic:
type: vibrate
onComplete:
executeCode:
body: |
//@code
console.log("Vibrate Haptic played")

Furthermore, the onTapHaptic property is used for the "Selection Click" button, demonstrating an alternative way to trigger haptic feedback.
- Button:
label: Selection Click (Using onTapHaptic property)
onTapHaptic: selectionClick
onTap:
executeCode:
body: |
//@code
console.log("Button Pressed")
39 changes: 39 additions & 0 deletions tips-and-tricks/lottie-animations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Custom Lottie Animations with Events and Controls

With features like onStart, onPause, onComplete, and control buttons, you can create interactive animations tailored to your application.

The Lottie animations have events such as onForward, onReverse, onPause, and onComplete. Control buttons are provided to trigger these events dynamically.
- Lottie:
id: MyLottie
autoPlay: false
repeat: false
onForward: |
//@code
console.log("Forward");
onReverse: |
//@code
console.log("Reverse");
onPause: |
//@code
console.log("Pause");
onComplete: |
//@code
console.log("Completed");
source: https://assets6.lottiefiles.com/private_files/lf30_rnpgzd17.json
styles:
width: 400
height: 200

- Button:
styles:
outline: true
borderColor: 0xffed5742
borderRadius: 20
backgroundColor: 0xffaad6de
labelStyle:
color: 0xffed5742
label: Forward
onTap: |
//@code
console.log("Forward");
MyLottie.forward();
22 changes: 22 additions & 0 deletions tips-and-tricks/specifying-icons.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Specify library icons for start and end

**Objective**
To specify library icons for startingIcon and endingIcon on a Button

To achieve this, consider the following steps:

1. To specify library icons in shorthand notation for startingIcon and endingIcon on a Button, you can use the following syntax:
```yaml
Button:
startingIcon: wifi
endingIcon: addressBook fontAwesome
```
2. Icons can be represented with a more verbose syntax on a Button using the following structure:
```yaml
Button:
endingIcon:
name: addressBook
library: fontAwesome
size: 50
color: red
```

0 comments on commit bde1270

Please sign in to comment.