Skip to content

Commit 9c3f5e7

Browse files
authored
Merge pull request #54 from CodandoTV/feature/include-mkdocs-setup
MKdocs support
2 parents 64bcd8f + 529f381 commit 9c3f5e7

17 files changed

Lines changed: 651 additions & 21 deletions
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: documentation
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
paths:
7+
- 'docs/**'
8+
permissions:
9+
contents: write
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Configure Git Credentials
16+
run: |
17+
git config user.name github-actions[bot]
18+
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: 3.x
22+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
23+
- uses: actions/cache@v4
24+
with:
25+
key: mkdocs-material-${{ env.cache_id }}
26+
path: .cache
27+
restore-keys: |
28+
mkdocs-material-
29+
- run: pip install mkdocs-material
30+
- run: mkdocs gh-deploy --force

docs/assets/img/logo.png

1.63 MB
Loading
1.94 MB
Loading

docs/assets/video/flutter.gif

1.11 MB
Loading

docs/assets/video/swift-ui.gif

9.74 MB
Loading
1.94 MB
Loading

docs/contributors.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Contributors
2+
3+
> We would like to thank everyone who made this possible and helped > the CodandoTV community grow stronger. This project exists thanks > to all the people who contribute
4+
5+
_Signed by Rods_
6+
7+
This project exists thanks to all the people who contribute.
8+
9+
<a href="https://github.com/CodandoTV/CraftD"><img src="https://opencollective.com/craftd/contributors.svg?width=890" /></a>

docs/how-to-use/compose.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Jetpack Compose
2+
3+
- Create your ComponentPropertyClass with properties that you need. In this example, I used checkbox component:
4+
5+
!!! warning "Immutable and Stable annotations"
6+
Here we have some points to consider To avoid unnecessary recompositions at your component. We recommend use the `@Immutable` and `@Stable` annotations in your properties.
7+
8+
```kotlin
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
@Immutable
11+
@Stable
12+
data class CheckBoxProperties(
13+
@JsonProperty("text") val text: String? = null,
14+
... define your properties here
15+
)
16+
```
17+
18+
- Add your Component json object in `Dymanic.json`:
19+
20+
```json
21+
{
22+
"key": "CraftDCheckBox",
23+
"value": {
24+
... define your properties here
25+
}
26+
}
27+
```
28+
29+
- Create your Component
30+
31+
!!! tip "Your component must have three properties"
32+
33+
- componentProperties: The mapped properties from json
34+
- modifier: Default for composable componets
35+
- behaviour: This make reference to the component's behaviour, for example: onclick -> for buttons, onchange -> for checkbox etc...
36+
37+
```kotlin
38+
class CraftDCheckBoxBuilder(
39+
override val key: String = CraftDComponentKey.CHECK_BOX_COMPONENT.key
40+
) :
41+
CraftDBuilder {
42+
@Composable
43+
override fun craft(model: SimpleProperties, listener: CraftDViewListener) {
44+
val checkBoxProperties = model.value.convertToVO<CheckBoxProperties>()
45+
CraftDCheckBox(checkBoxProperties) {
46+
checkBoxProperties.actionProperties?.let { listener.invoke(it) }
47+
}
48+
}
49+
}
50+
```
51+
52+
- Create your Component Builder:
53+
54+
!!! tip "Note"
55+
56+
This Builder must extend CraftBuilder Class and override craft method.
57+
58+
```kotlin
59+
class CraftDCheckBoxBuilder(
60+
override val key: String = CraftDComponentKey.CHECK_BOX_COMPONENT.key
61+
) :
62+
CraftDBuilder {
63+
@Composable
64+
override fun craft(model: SimpleProperties, listener: CraftDViewListener) {
65+
val checkBoxProperties = model.value.convertToVO<CheckBoxProperties>()
66+
CraftDCheckBox(checkBoxProperties) {
67+
checkBoxProperties.actionProperties?.let { listener.invoke(it) }
68+
}
69+
}
70+
}
71+
```
72+
73+
- In your screen you can add the builder inside of `CraftBuilderManager`
74+
75+
```kotlin
76+
@Composable
77+
fun InitialScreen(
78+
vm: SampleCraftDComposeViewModel
79+
) {
80+
val properties by vm.properties.collectAsStateWithLifecycle()
81+
val dynamicBuilder = remember {
82+
CraftDBuilderManager().add(
83+
CraftDCheckBoxBuilder()
84+
)
85+
}
86+
LaunchedEffect(Unit) {
87+
vm.loadProperties()
88+
}
89+
90+
CraftDynamic(
91+
properties = properties,
92+
dynamicBuilder = dynamicBuilder
93+
) {
94+
//Component click return to do something
95+
}
96+
}
97+
```
98+
99+
So now enjoy your component!

docs/how-to-use/futter.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Flutter
2+
3+
- Create your ComponentPropertyClass with properties that you need
4+
5+
```dart
6+
class ButtonProperties {
7+
const ButtonProperties({
8+
required this.text,
9+
... place your construtor properties
10+
});
11+
12+
final String text;
13+
... place your properties
14+
}
15+
```
16+
17+
- Add your Component json object in `Dymanic.json`
18+
19+
```json
20+
{
21+
"key": "CraftDBbutton",
22+
"value": {
23+
"text": "Knife",
24+
... place your properties
25+
}
26+
}
27+
```
28+
29+
- Create your Component
30+
31+
!!! tip "Your component must have three properties"
32+
- ButtonProperties: The mapped properties from json
33+
- callback: This make reference to the component's behaviour, for example: onclick -> for buttons, onchange -> for checkbox etc...
34+
35+
```dart
36+
class CraftDButton extends StatelessWidget {
37+
const CraftDButton(
38+
{super.key, required this.buttonProperties, required this.callback}
39+
);
40+
41+
//... place your code
42+
}
43+
```
44+
45+
- Create your Component Builder
46+
47+
!!! tip "This Builder must extend `CraftBuilder` Class and override craft and fromJson methods."
48+
```dart
49+
class CraftDButtonBuilder extends CraftDBuilder<ButtonProperties> {
50+
CraftDButtonBuilder() : super(key: key);
51+
52+
@override
53+
Widget craft(ButtonProperties model, CraftDViewListener listener) {
54+
//... place your code
55+
}
56+
57+
@override
58+
ButtonProperties fromJson(properties) {
59+
return ButtonProperties(
60+
text: properties["text"],
61+
//... rest of tour code
62+
)
63+
}
64+
65+
static String key = "CraftDButton";
66+
}
67+
```
68+
69+
- In your Page, create your `CraftDBuilder` declaration and put it into `CraftDynamic` Widget
70+
71+
```dart
72+
// You can put it in your dependency injection
73+
final craftdBuilderManager = CraftDBuilderManager();
74+
75+
return CraftDynamic(
76+
simplePropertiesList: simplePropertiesList,
77+
craftDBuilderManager : craftdBuilderManager,
78+
onAction: (actionProperties) {
79+
print(
80+
"categoria ${actionProperties.analyticsProperties?.category} "
81+
"label ${actionProperties.analyticsProperties?.label} - "
82+
"track ${actionProperties.analyticsProperties?.track}");
83+
});
84+
}
85+
```

docs/how-to-use/swift-ui.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Swift UI
2+
3+
- Create your ComponentPropertyClass with properties that you need
4+
5+
```swift
6+
public struct TextProperties: Decodable {
7+
public let text: String?
8+
public let textColorHex: String?
9+
public let textSize: String?
10+
public let backgroundHex: String?
11+
public let textAllCaps: Bool?
12+
public let textHtml: String?
13+
}
14+
```
15+
16+
- Add your Component json object in `Dymanic.json``
17+
18+
```json
19+
[
20+
{
21+
"key": "MyCraftDText",
22+
"value": {
23+
"text": "Knife",
24+
"backgroundHex": "#9A71F6",
25+
"textSize": "30",
26+
"textColorHex": "#000000"
27+
}
28+
}
29+
]
30+
```
31+
32+
- Create your Component
33+
34+
!!! tip "This Builder must extend `CraftBuilder` Class and override craft method."
35+
```swift
36+
public class MyCraftDTextBuilder: CraftDBuilder {
37+
public let key = "MyCraftDText"
38+
39+
let decoder = JSONDecoder()
40+
41+
public func craft(
42+
model: SimpleProperties,
43+
listener: CraftDViewListener
44+
) -> any View {
45+
do {
46+
let properties = try model.decodeValue(TextProperties.self, using: decoder)
47+
return Text(properties.text ?? "")
48+
} catch {
49+
return EmptyView()
50+
}
51+
}
52+
}
53+
```
54+
55+
- In your add your builder inside of `CraftBuilderManager`
56+
57+
```swift
58+
@main
59+
struct CraftDSampleApp: App {
60+
var body: some Scene {
61+
WindowGroup {
62+
//Or another View
63+
let craftDBuilderManager = CraftDBuilderManager()
64+
.add(builder: <#T##any CraftDBuilder#> like MyCraftDTextBuilder)
65+
CraftDynamic(craftDBuilderManager: CraftDBuilderManager)
66+
}
67+
}
68+
}
69+
```

0 commit comments

Comments
 (0)