Skip to content

Commit 75196b4

Browse files
committed
Update ReadMe
- Updated section for injecting data into Codelessly CloudUI™ widgets. - Updated section for calling functions in Codelessly SDK.
1 parent a845917 commit 75196b4

File tree

1 file changed

+38
-30
lines changed

1 file changed

+38
-30
lines changed

README.md

+38-30
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# Codelessly CloudUI™ SDK
33
[![Pub release](https://img.shields.io/pub/v/codelessly_sdk.svg?style=flat-square)](https://pub.dev/packages/codelessly_sdk) [![GitHub Release Date](https://img.shields.io/github/release-date/Codelessly/CodelesslySDK.svg?style=flat-square)](https://github.com/Codelessly/CodelesslySDK) [![GitHub issues](https://img.shields.io/github/issues/Codelessly/CodelesslySDK.svg?style=flat-square)](https://github.com/Codelessly/CodelesslySDK/issues) [![GitHub top language](https://img.shields.io/github/languages/top/Codelessly/CodelesslySDK.svg?style=flat-square)](https://github.com/Codelessly/CodelesslySDK)
44

5-
![Codelessly Publish UI](packages/Codelessly-Cover.png)
6-
75
> ### Dynamic UI and real-time updates for Flutter apps
86
7+
![Codelessly Publish UI](packages/Codelessly-Cover.png)
8+
99
Supercharge your Flutter apps with dynamic UI and real-time updates. Build and publish UI without code!
1010

1111
- **Real-Time UI Updates:** Adjust your UI as often as you need, all in real-time. Adapt to trends, feedback, and business needs on the fly.
@@ -15,14 +15,13 @@ Supercharge your Flutter apps with dynamic UI and real-time updates. Build and p
1515
## Quickstart
1616
[![Pub release](https://img.shields.io/pub/v/codelessly_sdk.svg?style=flat-square)](https://pub.dev/packages/codelessly_sdk)
1717

18-
#### Step 1: Import Library
18+
#### **Step 1: Import Library**
1919

20-
Import this library into your project:
2120
```yaml
2221
codelessly_sdk: ^latest_version
2322
```
2423
25-
#### Step 2: Initialize the SDK
24+
#### **Step 2: Initialize the SDK**
2625
2726
Initialize Codelessly before calling `runApp()`.
2827

@@ -43,29 +42,25 @@ void main() {
4342
```
4443
The `authToken`can be found for each project under `Publish > Settings > Settings`.
4544

46-
Information on customizing SDK initialization can be found later in the documentation.
45+
#### **Step 3: Embed the CodelesslyWidget**
4746

48-
#### Step 3: Get a Layout ID from the Codelessly Editor
49-
50-
Easily embed a design from the Codelessly Editor into your app with a `layoutID`. The `CodelesslyWidget` enables your app to update its UI over the air.
47+
Easily embed any design from the Codelessly Editor into your app using the `layoutID`.
5148

5249
```dart
5350
CodelesslyWidget(
5451
layoutID: LAYOUT_ID,
5552
)
5653
```
5754

55+
**How to obtain a Layout ID**
56+
5857
1. In the Codelessly Editor, select the **canvas** of your layout.
5958
2. Press the **Preview Icon** in the toolbar. ![CloudUI Preview Icon](packages/preview_icon.png)
6059
3. Copy the **layoutID**.
6160

6261
![Codelessly Widget Code](packages/codelessly_widget_code.png)
6362

64-
Refer to the later sections for how to pass variables and functions to the CodelesslyWidget.
65-
66-
#### Full Example: Putting it All Together
67-
68-
The `CodelesslyWidget` can be used like any other widget and embedded anywhere in your app. It can even be used to render entire pages as the root widget!
63+
### Complete Example
6964

7065
Here is a complete example:
7166

@@ -87,25 +82,38 @@ class MyApp extends StatelessWidget {
8782
}
8883
```
8984

85+
The `CodelesslyWidget` can be used like any other widget and embedded anywhere in your app. It can even be used to render entire pages as the root widget!
86+
9087
From dynamic forms to constantly changing sales and marketing pages, any design or layout can be streamed to your app via the `CodelesslyWidget`.
9188

9289
To learn how to use the Codelessly editor to publish layouts, check out our [3-minute Quickstart Guide](https://docs.codelessly.com/getting-started/3-minute-quick-start).
9390

94-
## Data
91+
## Injecting Data
9592

96-
Customize Codelessly CloudUI™ widgets by passing data into your layout. The UI will dynamically replace any variables defined in the Codelessly editor with the provided values.
93+
Customize Codelessly CloudUI™ widgets by passing data values into your layout. The UI will dynamically replace any variables defined in the Codelessly editor with the provided values.
9794

98-
![Data](packages/ui_with_data_linking.png)
95+
```dart
96+
CodelesslyWidget(
97+
layoutID: LAYOUT_ID,
98+
data: {
99+
// A map of variables, Map<String, dynamic>
100+
},
101+
),
102+
```
99103

100-
**Step 1:** Use the `${}` templating syntax in input fields to link data from the Codelessly editor to layouts as shown below.
104+
#### **Step 1:** Define variables in the Codelessly Editor
105+
106+
Use the `${}` templating syntax in input fields to link data from the Codelessly editor to layouts as shown below.
107+
108+
![Data](packages/ui_with_data_linking.png)
101109

102110
To link the title of a text widget to the `title` variable in the Codelessly editor, put `${data.title}` in the text widget’s text field.
103111

104-
> The `data` object contains all the variables passed to the CodelesslyWidget.
112+
> **Note:** The `data` object contains all the variables passed to the CodelesslyWidget.
105113
>
106114
> Use `${data.title}` to access the `title` variable passed from the client. `${title}` alone is a Codelessly variable and will try to load variables defined in Codelessly, not your client.
107115

108-
**Step 2:** Once this is set from the editor, you can provide the data to the layout from your app.
116+
#### **Step 2:** Pass data to the layout from your app.
109117

110118
```dart
111119
CodelesslyWidget(
@@ -127,22 +135,22 @@ This how it looks with populated data:
127135

128136
## Functions
129137

130-
Codelessly SDK also supports providing callback functions for user actions such as onClick, onLongPress, etc.
138+
Codelessly SDK also supports calling functions for user actions such as onClick, onLongPress, etc.
131139

132140
```dart
133141
CodelesslyWidget(
134142
layoutID: LAYOUT_ID,
135143
functions: {
136-
'onNextButtonClicked': CodelesslyFunction((CodelesslyContext context) {
137-
print('onNextButtonClicked function called');
144+
'functionName': (context, reference, params) {
138145
// TODO: Implement your function here
139146
}),
140147
},
141148
),
142149
```
143-
The `functions` parameter takes a map of type `Map<String, CodelesslyFunction>` which is used to execute functions defined as action calls in the Codelessly editor.
144150

145-
Here, we define an `onNextButtonClicked` function that can be invoked by the widget. Once a function is provided, it can be referenced by name in the Codelessly Editor.
151+
#### **Step 1:** Add a "Call Function" Action in the Codelessly Editor
152+
153+
Here, we tell the button to call the native `onNextButtonClicked` function when pressed.
146154

147155
![Defining call function action](packages/defining_call_function_action.png)
148156

@@ -155,11 +163,11 @@ In the Codelessly Editor, you can easily add an Action to a widget. Use the `Cal
155163
4. Click on the `Settings` button to bring up the `Action Settings` popup.
156164
5. Reference the function name in the `Function Name` field. For example, `onNextButtonClicked`.
157165

158-
The `CodelesslyFunction` provides a `CodelesslyContext` which provides internal access to the widget's data, variables, conditions, functions, etc.
166+
**Note:** The `CodelesslyFunction` provides a `CodelesslyContext` which provides internal access to the widget's data, variables, conditions, functions, etc.
159167

160-
**Note** You can declare `data` and `functions` in the global `Codelessly` instance to make them globally accessible to all `CodelesslyWidget`s.
168+
**Note 2:** You can declare `data` and `functions` in the global `Codelessly` instance to make them globally accessible to all `CodelesslyWidget`s.
161169

162-
## CodelesslyWidget Customization
170+
## CodelesslyWidget Options
163171

164172
```dart
165173
CodelesslyWidget(
@@ -180,7 +188,7 @@ CodelesslyWidget(
180188

181189
**Note:** Setting a `CodelesslyConfig` on a CodelesslyWidget overrides the global Codelessly instance settings. This lets you embed layouts from other projects with different auth tokens.
182190

183-
## Configuring Environments
191+
## Environment Configuration
184192

185193
The CodelesslyWidget supports **Preview** and **Published** environments via the `isPreview` boolean.
186194

@@ -195,7 +203,7 @@ Codelessly.instance.initialize(
195203
// Widget level. Overrides global settings for this widget.
196204
CodelesslyWidget(
197205
isPreview: true
198-
)
206+
);
199207
```
200208

201209
### Preview Mode

0 commit comments

Comments
 (0)