Skip to content

Commit 5996702

Browse files
committed
Layout Groups #7
- Refactor conditions and variables model for publishing and bug fixes. - Restore example.
1 parent f5eeae8 commit 5996702

File tree

6 files changed

+133
-267
lines changed

6 files changed

+133
-267
lines changed

example/lib/main.dart

Lines changed: 74 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
import 'package:codelessly_sdk/codelessly_sdk.dart';
2-
import 'package:firebase_core/firebase_core.dart';
32
import 'package:flutter/cupertino.dart';
3+
import 'package:flutter/foundation.dart';
44
import 'package:flutter/material.dart';
55
import 'package:storybook_flutter/storybook_flutter.dart';
66

7-
const FirebaseOptions macos = FirebaseOptions(
8-
apiKey: 'AIzaSyAxDINPf_Iv7JijcNurimH9Qc5sshuI8dU',
9-
appId: '1:950033523579:ios:4b2bc5b87231ea991353de',
10-
messagingSenderId: '950033523579',
11-
projectId: 'codeless-dev',
12-
databaseURL: 'https://codeless-dev-default-rtdb.firebaseio.com',
13-
storageBucket: 'codeless-dev.appspot.com',
14-
androidClientId:
15-
'950033523579-5o82dsg72jv51i9slcj2q1q61c6es41f.apps.googleusercontent.com',
16-
iosClientId:
17-
'950033523579-6apd2e5cn1l192dqr02lovnmonsnuvdc.apps.googleusercontent.com',
18-
iosBundleId: 'com.codelessly.dev',
19-
);
20-
217
void main() async {
228
WidgetsFlutterBinding.ensureInitialized();
239

2410
Codelessly.instance.initialize(
2511
config: CodelesslyConfig(
26-
authToken: "ekk+OTYhJnIqPUNvdzA7enxRejUjN3MoKltAVCV7MStZckEp",
27-
isPreview: false,
12+
authToken: "cSlMIT93cj1lXkBuYk5QNmImSTUsTHw2MDQ4VkdlOCZFLHc7",
13+
isPreview: kDebugMode,
2814
preload: true,
29-
firebaseOptions: macos,
30-
firebaseCloudFunctionsBaseURL:
31-
'https://us-central1-codeless-dev.cloudfunctions.net',
32-
baseURL: 'https://dev.codelessly.com',
3315
),
3416
);
3517

@@ -47,117 +29,90 @@ class _MyAppState extends State<MyApp> {
4729
Map<String, dynamic> licenseData = {'license': 'FREE'};
4830

4931
@override
50-
Widget build(BuildContext context) {
51-
return Directionality(
52-
textDirection: TextDirection.ltr,
53-
child: Stack(
54-
fit: StackFit.expand,
55-
children: [
56-
CodelesslyWidget(
57-
// layoutID: "0RN8MKjwIRfuy1RoqsSO",
58-
layoutID: "0RN8YfpsxiU7nCKEeUON",
59-
loadingBuilder: (context) {
60-
return const CupertinoActivityIndicator();
61-
},
62-
),
63-
Positioned(
64-
top: 8,
65-
right: 8,
66-
child: FilledButton(
67-
onPressed: () {
68-
Codelessly.instance.cacheManager.clearAll();
69-
},
70-
child: const Icon(Icons.clear),
71-
),
72-
),
73-
],
74-
),
75-
);
76-
return Storybook(
77-
initialStory: 'Hello World',
78-
showPanel: true,
79-
wrapperBuilder: (context, child) {
80-
return MaterialApp(
81-
home: child,
82-
);
83-
},
84-
stories: [
85-
Story(
86-
name: 'Hello World',
87-
builder: (context) {
88-
return CodelesslyWidget(
89-
layoutID: "0R0yRfzR23SQfDGrbg3h",
90-
loadingBuilder: (context) {
91-
return const CupertinoActivityIndicator();
92-
},
93-
);
94-
},
95-
),
96-
Story(
97-
name: 'License UI',
32+
Widget build(BuildContext context) => Storybook(
33+
initialStory: 'Hello World',
34+
showPanel: true,
35+
wrapperBuilder: (context, child) {
36+
return MaterialApp(
37+
home: child,
38+
);
39+
},
40+
stories: [
41+
Story(
42+
name: 'Hello World',
9843
builder: (context) {
9944
return CodelesslyWidget(
100-
layoutID: "0R0yeUx1iGDe9kgW5xwn",
101-
data: licenseData,
102-
functions: {
103-
'onFreeSelected': (context, reference, params) {
104-
licenseData['license'] = 'FREE';
105-
setState(() {});
45+
layoutID: "0R0yRfzR23SQfDGrbg3h",
46+
loadingBuilder: (context) {
47+
return const CupertinoActivityIndicator();
48+
},
49+
);
50+
},
51+
),
52+
Story(
53+
name: 'License UI',
54+
builder: (context) {
55+
return CodelesslyWidget(
56+
layoutID: "0R0yeUx1iGDe9kgW5xwn",
57+
data: licenseData,
58+
functions: {
59+
'onFreeSelected': (context, reference, params) {
60+
licenseData['license'] = 'FREE';
61+
setState(() {});
62+
},
63+
'onProSelected': (context, reference, params) {
64+
licenseData['license'] = 'PRO';
65+
setState(() {});
66+
},
67+
'onBusinessSelected': (context, reference, params) {
68+
licenseData['license'] = 'BUSINESS';
69+
setState(() {});
70+
},
10671
},
107-
'onProSelected': (context, reference, params) {
108-
licenseData['license'] = 'PRO';
109-
setState(() {});
72+
loadingBuilder: (context) {
73+
return const CupertinoActivityIndicator();
11074
},
111-
'onBusinessSelected': (context, reference, params) {
112-
licenseData['license'] = 'BUSINESS';
113-
setState(() {});
75+
);
76+
}),
77+
Story(
78+
name: 'Pricing UI',
79+
builder: (context) {
80+
return CodelesslyWidget(
81+
layoutID: "0R0yedXWbqOrI_W7PBlo",
82+
loadingBuilder: (context) {
83+
return const CupertinoActivityIndicator();
11484
},
115-
},
85+
);
86+
}),
87+
Story(
88+
name: 'Pricing Card',
89+
builder: (context) {
90+
return CodelesslyWidget(
91+
layoutID: '0R1xmqF5lXMr6LpLA9h5',
11692
loadingBuilder: (context) {
11793
return const CupertinoActivityIndicator();
11894
},
11995
);
120-
}),
121-
Story(
122-
name: 'Pricing UI',
96+
},
97+
),
98+
Story(
99+
name: 'Fruit Product Card',
123100
builder: (context) {
124101
return CodelesslyWidget(
125-
layoutID: "0R0yedXWbqOrI_W7PBlo",
102+
layoutID: '0R5hf4ABTQmzDb6e8XyR',
103+
data: const {
104+
'name': 'Mango',
105+
'price': 5.99,
106+
'count': 1,
107+
'description':
108+
'Mangos are versatile fruits that can be enjoyed in many ways. You can eat them fresh as a snack or dessert, or add them to salads, smoothies, salsas, curries, cakes, pies, and more. You can also make mango juice, jam, chutney, or pickle.\n\nMangos are a great way to add some tropical flavor and nutrition to your diet.'
109+
},
126110
loadingBuilder: (context) {
127111
return const CupertinoActivityIndicator();
128112
},
129113
);
130-
}),
131-
Story(
132-
name: 'Pricing Card',
133-
builder: (context) {
134-
return CodelesslyWidget(
135-
layoutID: '0R1xmqF5lXMr6LpLA9h5',
136-
loadingBuilder: (context) {
137-
return const CupertinoActivityIndicator();
138-
},
139-
);
140-
},
141-
),
142-
Story(
143-
name: 'Fruit Product Card',
144-
builder: (context) {
145-
return CodelesslyWidget(
146-
layoutID: '0R5hf4ABTQmzDb6e8XyR',
147-
data: const {
148-
'name': 'Mango',
149-
'price': 5.99,
150-
'count': 1,
151-
'description':
152-
'Mangos are versatile fruits that can be enjoyed in many ways. You can eat them fresh as a snack or dessert, or add them to salads, smoothies, salsas, curries, cakes, pies, and more. You can also make mango juice, jam, chutney, or pickle.\n\nMangos are a great way to add some tropical flavor and nutrition to your diet.'
153-
},
154-
loadingBuilder: (context) {
155-
return const CupertinoActivityIndicator();
156-
},
157-
);
158-
},
159-
),
160-
],
161-
);
162-
}
114+
},
115+
),
116+
],
117+
);
163118
}

0 commit comments

Comments
 (0)