Skip to content

Commit a845917

Browse files
committed
Update CodelesslyAPI v0.0.7
1 parent 516837d commit a845917

File tree

2 files changed

+50
-40
lines changed

2 files changed

+50
-40
lines changed

example/lib/main.dart

+49-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'dart:developer';
2-
31
import 'package:codelessly_sdk/codelessly_sdk.dart';
42
import 'package:flutter/foundation.dart';
53
import 'package:flutter/material.dart';
@@ -15,60 +13,72 @@ void main() async {
1513
),
1614
);
1715

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();
1924
}
2025

21-
class MyStoryBookApp extends StatelessWidget {
22-
const MyStoryBookApp({super.key});
26+
class _MyAppState extends State<MyApp> {
27+
Map<String, dynamic> licenseData = {'license': 'FREE'};
2328

2429
@override
2530
Widget build(BuildContext context) => Storybook(
2631
initialStory: 'Hello World',
2732
showPanel: true,
33+
wrapperBuilder: (context, child) {
34+
return MaterialApp(
35+
home: child,
36+
);
37+
},
2838
stories: [
2939
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+
}),
4146
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(
4850
layoutID: "0R0yeUx1iGDe9kgW5xwn",
51+
data: licenseData,
4952
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(() {});
5260
},
53-
'onUpgrade': (context, ref, params) {
54-
log('Upgrade to ${params['license']} license');
61+
'onBusinessSelected': (context, reference, params) {
62+
licenseData['license'] = 'BUSINESS';
63+
setState(() {});
5564
},
5665
},
57-
),
58-
),
59-
),
60-
),
66+
);
67+
}),
6168
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(
6872
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+
},
7282
),
7383
],
7484
);

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ platforms:
1919
dependencies:
2020
flutter:
2121
sdk: flutter
22-
codelessly_api: 0.0.6
22+
codelessly_api: 0.0.7
2323
equatable: ^2.0.5
2424
google_fonts: ^5.1.0
2525
json_annotation: ^4.8.1

0 commit comments

Comments
 (0)