From 6c842b4ec30ea5276725cbfb902147a2e3635848 Mon Sep 17 00:00:00 2001 From: Aryan Date: Thu, 11 Jul 2024 20:02:24 +0530 Subject: [PATCH] added guidelines --- .../guidelines_screen/guidelinesscreen.dart | 49 +++++------ .../widgets/guidelines_card.dart | 82 +++++++++++++++++++ 2 files changed, 108 insertions(+), 23 deletions(-) create mode 100644 lib/new_ui/screens/guidelines_screen/widgets/guidelines_card.dart diff --git a/lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart b/lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart index 3f857007..104f898e 100644 --- a/lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart +++ b/lib/new_ui/screens/guidelines_screen/guidelinesscreen.dart @@ -2,6 +2,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:tsec_app/new_ui/screens/guidelines_screen/widgets/FAQCard.dart'; +import 'package:tsec_app/new_ui/screens/guidelines_screen/widgets/guidelines_card.dart'; class GuideLinesScreen extends StatefulWidget { @override @@ -248,36 +249,38 @@ class _GuideLinesScreenState extends State { SizedBox( height: size.height * 0.01, ), - /*ListView.builder( + ListView.builder( padding: EdgeInsets.zero, itemCount: guideLines.length, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), itemBuilder: (context, index) { + //print(guideLines[index]); Map guideline = guideLines[index]; - if (guideline.containsKey("text")) { - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 30, vertical: 10), - child: Text( - "- ${guideline["text"]}", - style: TextStyle(color: Colors.white), - ), - ); - } else { - return Container( - margin: EdgeInsets.symmetric( - horizontal: size.width * 0.1, vertical: 20), - height: size.height * 0.2, - decoration: BoxDecoration( - image: DecorationImage( - image: NetworkImage(guideline['image']), - fit: BoxFit.fill), - ), - ); - } + return GuidelinesCard(inputGuideline: guideline); + // if (guideline.containsKey("text")) { + // return Padding( + // padding: const EdgeInsets.symmetric( + // horizontal: 30, vertical: 10), + // child: Text( + // "- ${guideline["text"]}", + // style: TextStyle(color: Colors.white), + // ), + // ); + // } else { + // return Container( + // margin: EdgeInsets.symmetric( + // horizontal: size.width * 0.1, vertical: 20), + // height: size.height * 0.2, + // decoration: BoxDecoration( + // image: DecorationImage( + // image: NetworkImage(guideline['image']), + // fit: BoxFit.fill), + // ), + // ); + // } }, - ),*/ + ), SizedBox( height: size.height * 0.01, ), diff --git a/lib/new_ui/screens/guidelines_screen/widgets/guidelines_card.dart b/lib/new_ui/screens/guidelines_screen/widgets/guidelines_card.dart new file mode 100644 index 00000000..0b55f341 --- /dev/null +++ b/lib/new_ui/screens/guidelines_screen/widgets/guidelines_card.dart @@ -0,0 +1,82 @@ +import 'package:flutter/material.dart'; +import 'package:tsec_app/new_ui/colors.dart'; + +class GuidelinesCard extends StatelessWidget { + final Map inputGuideline; + const GuidelinesCard({super.key, required this.inputGuideline}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Card( + color: commonbgLightblack, + child: Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 10), + child: Text(inputGuideline['title'], style: TextStyle(fontSize: 18, color: Colors.white, fontWeight: FontWeight.bold),), + ), + if(inputGuideline['content'].runtimeType == String) + Text(inputGuideline['content'], style: TextStyle(fontSize: 14, color: Colors.white),), + if(inputGuideline.containsKey('points')) + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: inputGuideline['points'].length, + itemBuilder: (context, index) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Text(inputGuideline['points'][index], style: TextStyle(fontSize: 14, color: Colors.white),), + ); + }, + ) + else + ListView.builder( + shrinkWrap: true, + itemCount: inputGuideline['content'].length, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + //print(inputGuideline['content'][index]); + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + //sub title and then list of points + if(inputGuideline['content'].runtimeType != String) + Text(inputGuideline['content'][index]['subtitle'], style: TextStyle(fontSize: 16, color: Colors.white, fontWeight: FontWeight.bold),), + if(inputGuideline['content'].runtimeType != String) + ListView.builder( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemCount: inputGuideline['content'][index]['subPoints'].length, + itemBuilder: (context, subindex){ + if(inputGuideline['content'][index]['subPoints'][subindex].containsKey("words")) { + return Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + inputGuideline['content'][index]['subPoints'][subindex]["words"], + style: TextStyle( + fontSize: 12, color: Colors.white),), + ); + } + else { + return Container( + child: Image.network('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png',)); + } + }, + ) + ], + ); + }, + ) + ] + + ), + ), + ), + ); + } +}