1
- import 'dart:developer' ;
2
-
3
1
import 'package:codelessly_sdk/codelessly_sdk.dart' ;
4
2
import 'package:flutter/foundation.dart' ;
5
3
import 'package:flutter/material.dart' ;
@@ -15,60 +13,72 @@ void main() async {
15
13
),
16
14
);
17
15
18
- runApp (const MyStoryBookApp ());
16
+ runApp (const MyApp ());
17
+ }
18
+
19
+ class MyApp extends StatefulWidget {
20
+ const MyApp ({super .key});
21
+
22
+ @override
23
+ State <MyApp > createState () => _MyAppState ();
19
24
}
20
25
21
- class MyStoryBookApp extends StatelessWidget {
22
- const MyStoryBookApp ({ super .key}) ;
26
+ class _MyAppState extends State < MyApp > {
27
+ Map < String , dynamic > licenseData = { 'license' : 'FREE' } ;
23
28
24
29
@override
25
30
Widget build (BuildContext context) => Storybook (
26
31
initialStory: 'Hello World' ,
27
32
showPanel: true ,
33
+ wrapperBuilder: (context, child) {
34
+ return MaterialApp (
35
+ home: child,
36
+ );
37
+ },
28
38
stories: [
29
39
Story (
30
- name: 'Hello World' ,
31
- description: 'A simple hello world demo.' ,
32
- builder: (context) => MaterialApp (
33
- theme: Theme .of (context),
34
- home: Center (
35
- child: CodelesslyWidget (
36
- layoutID: "0R0yRfzR23SQfDGrbg3h" ,
37
- ),
38
- ),
39
- ),
40
- ),
40
+ name: 'Hello World' ,
41
+ builder: (context) {
42
+ return CodelesslyWidget (
43
+ layoutID: "0R0yB82iCD4RPZMZYOYZ" ,
44
+ );
45
+ }),
41
46
Story (
42
- name: 'License UI' ,
43
- description: "Demo of Codelessly's license UI." ,
44
- builder: (context) => MaterialApp (
45
- theme: Theme .of (context),
46
- home: Center (
47
- child: CodelesslyWidget (
47
+ name: 'License UI' ,
48
+ builder: (context) {
49
+ return CodelesslyWidget (
48
50
layoutID: "0R0yeUx1iGDe9kgW5xwn" ,
51
+ data: licenseData,
49
52
functions: {
50
- 'onSelected' : (context, ref, params) {
51
- log ('selected license: ${params ['license' ]}' );
53
+ 'onFreeSelected' : (context, reference, params) {
54
+ licenseData['license' ] = 'FREE' ;
55
+ setState (() {});
56
+ },
57
+ 'onProSelected' : (context, reference, params) {
58
+ licenseData['license' ] = 'PRO' ;
59
+ setState (() {});
52
60
},
53
- 'onUpgrade' : (context, ref, params) {
54
- log ('Upgrade to ${params ['license' ]} license' );
61
+ 'onBusinessSelected' : (context, reference, params) {
62
+ licenseData['license' ] = 'BUSINESS' ;
63
+ setState (() {});
55
64
},
56
65
},
57
- ),
58
- ),
59
- ),
60
- ),
66
+ );
67
+ }),
61
68
Story (
62
- name: 'Pricing UI' ,
63
- description: "Demo of Codelessly's pricing UI." ,
64
- builder: (context) => MaterialApp (
65
- theme: Theme .of (context),
66
- home: Center (
67
- child: CodelesslyWidget (
69
+ name: 'Pricing UI' ,
70
+ builder: (context) {
71
+ return CodelesslyWidget (
68
72
layoutID: "0R0yedXWbqOrI_W7PBlo" ,
69
- ),
70
- ),
71
- ),
73
+ );
74
+ }),
75
+ Story (
76
+ name: 'Pricing Card' ,
77
+ builder: (context) {
78
+ return CodelesslyWidget (
79
+ layoutID: '0R1xmqF5lXMr6LpLA9h5' ,
80
+ );
81
+ },
72
82
),
73
83
],
74
84
);
0 commit comments