From c91c9a9b36657f9f7887036d7ba0bcf7c348ba87 Mon Sep 17 00:00:00 2001 From: Anirban Mondal <66185247+animon880@users.noreply.github.com> Date: Sat, 31 May 2025 22:00:36 +0530 Subject: [PATCH] Update main.dart --- example/lib/main.dart | 113 ++++++++---------------------------------- 1 file changed, 21 insertions(+), 92 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index d220e640..73814479 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,15 +1,13 @@ import 'package:codelessly_sdk/codelessly_sdk.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:storybook_flutter/storybook_flutter.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); Codelessly.instance.initialize( config: CodelesslyConfig( - authToken: "cSlMIT93cj1lXkBuYk5QNmImSTUsTHw2MDQ4VkdlOCZFLHc7", + authToken: "cSlMIT93cj1lXkBuYk5QNmImSTUsTHw2MDQ4VkdlOCZFLHc7", // Replace with yours isPreview: kDebugMode, preload: true, ), @@ -18,101 +16,32 @@ void main() async { runApp(const MyApp()); } -class MyApp extends StatefulWidget { +class MyApp extends StatelessWidget { const MyApp({super.key}); @override - State createState() => _MyAppState(); + Widget build(BuildContext context) { + return const MaterialApp( + debugShowCheckedModeBanner: false, + home: CodelesslyLayoutScreen(), + ); + } } -class _MyAppState extends State { - Map licenseData = {'license': 'FREE'}; +class CodelesslyLayoutScreen extends StatelessWidget { + const CodelesslyLayoutScreen({super.key}); @override - Widget build(BuildContext context) => Storybook( - initialStory: 'Hello World', - showPanel: true, - wrapperBuilder: (context, child) { - return MaterialApp( - home: Container(color: Colors.white, child: child), - ); - }, - stories: [ - Story( - name: 'Hello World', - builder: (context) { - return CodelesslyWidget( - layoutID: "0R0yRfzR23SQfDGrbg3h", - loadingBuilder: (context) { - return const CupertinoActivityIndicator(); - }, - ); - }, + Widget build(BuildContext context) { + return const Scaffold( + body: SafeArea( + child: CodelesslyWidget( + layoutID: "0Rxvyp379pTkaqMd0xRj", // Your actual layout ID + loadingBuilder: (context) => Center( + child: CircularProgressIndicator(), ), - Story( - name: 'License UI', - builder: (context) { - return CodelesslyWidget( - layoutID: "0R0yeUx1iGDe9kgW5xwn", - data: licenseData, - functions: { - 'onFreeSelected': (context, reference, params) { - licenseData['license'] = 'FREE'; - setState(() {}); - }, - 'onProSelected': (context, reference, params) { - licenseData['license'] = 'PRO'; - setState(() {}); - }, - 'onBusinessSelected': (context, reference, params) { - licenseData['license'] = 'BUSINESS'; - setState(() {}); - }, - }, - loadingBuilder: (context) { - return const CupertinoActivityIndicator(); - }, - ); - }), - Story( - name: 'Pricing UI', - builder: (context) { - return CodelesslyWidget( - layoutID: "0R0yedXWbqOrI_W7PBlo", - loadingBuilder: (context) { - return const CupertinoActivityIndicator(); - }, - ); - }), - Story( - name: 'Pricing Card', - builder: (context) { - return CodelesslyWidget( - layoutID: '0R1xmqF5lXMr6LpLA9h5', - loadingBuilder: (context) { - return const CupertinoActivityIndicator(); - }, - ); - }, - ), - Story( - name: 'Fruit Product Card', - builder: (context) { - return CodelesslyWidget( - layoutID: '0R5hf4ABTQmzDb6e8XyR', - data: const { - 'name': 'Mango', - 'price': 5.99, - 'count': 1, - 'description': - '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.' - }, - loadingBuilder: (context) { - return const CupertinoActivityIndicator(); - }, - ); - }, - ), - ], - ); + ), + ), + ); + } }