From 233743010184d99e67d6d6a4700ee88e8624671b Mon Sep 17 00:00:00 2001 From: Rajshinde046 Date: Thu, 2 May 2024 13:09:20 +0530 Subject: [PATCH 1/4] contact us final --- lib/controller/contact_us_controller.dart | 12 + .../Sidemenu/contactUs/contact_us_main.dart | 867 +++++------------- pubspec.lock | 30 +- pubspec.yaml | 1 + 4 files changed, 253 insertions(+), 657 deletions(-) diff --git a/lib/controller/contact_us_controller.dart b/lib/controller/contact_us_controller.dart index 34559a5..f814f91 100644 --- a/lib/controller/contact_us_controller.dart +++ b/lib/controller/contact_us_controller.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:get/get.dart'; +import 'package:intl/intl.dart'; import 'package:traderscircuit/model/ContactUsModel/contact_us_cat_model.dart'; import 'package:traderscircuit/model/ContactUsModel/contact_us_model.dart'; @@ -20,6 +21,17 @@ class ContactUsController extends GetxController { RxBool onDropTap = false.obs; RxString selectedValue = "".obs; + RxInt allC = 0.obs; + RxInt openC = 0.obs; + RxInt closeC = 0.obs; + RxInt resolvedC = 0.obs; + + String formatedDateTimeMethod(String originalDateTimeString) { + DateTime dateTime = DateTime.parse(originalDateTimeString); + + return DateFormat("dd MMM yyyy, hh:mm a").format(dateTime.toLocal()); + } + RxList contactUsDetailsChatContent = [ { "initial_name": "SM", diff --git a/lib/view/Sidemenu/contactUs/contact_us_main.dart b/lib/view/Sidemenu/contactUs/contact_us_main.dart index 9e82b70..365c3a7 100644 --- a/lib/view/Sidemenu/contactUs/contact_us_main.dart +++ b/lib/view/Sidemenu/contactUs/contact_us_main.dart @@ -1,20 +1,16 @@ -import 'dart:developer'; -import 'dart:ffi'; - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:get/get.dart'; import 'package:traderscircuit/controller/contact_us_controller.dart'; import 'package:traderscircuit/model/ContactUsModel/contact_us_cat_model.dart'; -import 'package:traderscircuit/model/ContactUsModel/contact_us_model.dart' - as ContactModel; import 'package:traderscircuit/model/ContactUsModel/contact_us_model.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; import 'package:traderscircuit/view_model/ContactUsApi/contact_us_api.dart'; import '../../../Utils/Common/CommonAppbar.dart'; import '../../../Utils/Common/commonBotton.dart'; import '../../../Utils/text.dart'; +import '../../../view_model/ProfileAPI/GetProfileApi.dart'; import '../../onBoarding/splashScreen1.dart'; import 'create_ticket_bottom_sheet.dart'; @@ -25,13 +21,10 @@ class ContactUsMainScreen extends StatefulWidget { State createState() => _ContactUsMainScreenState(); } -Map> status1Map = {}; -Map> status2Map = {}; -Map> status3Map = {}; - class _ContactUsMainScreenState extends State { ContactUsController contactUsController = Get.put(ContactUsController()); + RxBool isEmpty = false.obs; @override void initState() { contactUsController.isLoading.value == true; @@ -40,33 +33,36 @@ class _ContactUsMainScreenState extends State { ContactUsCatModel.fromJson(value.data); ContactUsApi().getContactUsData().then((value) { - contactUsController.contactModel = ContactUsModel.fromJson(value.data); - contactUsController.isLoading.value = false; - log(contactUsController.isLoading.value.toString()); - status1Map.clear(); - status2Map.clear(); - status3Map.clear(); - // Iterate over the data and categorize them based on their status - for (var item in contactUsController.contactModel!.data!) { - if (item.status == 1) { - status1Map.putIfAbsent(item.status!, () => []).add(item); - } else if (item.status == 2) { - status2Map.putIfAbsent(item.status!, () => []).add(item); - } else if (item.status == 3) { - status3Map.putIfAbsent(item.status!, () => []).add(item); + Map responseData = + Map.from(value.data); + if (responseData["message"] == "Data not found.") { + isEmpty.value = true; + } else { + contactUsController.allC.value = 0; + contactUsController.openC.value = 0; + contactUsController.closeC.value = 0; + contactUsController.resolvedC.value = 0; + + contactUsController.contactModel = + ContactUsModel.fromJson(value.data); + for (var a in contactUsController.contactModel.data!) { + if (a.status == 1) { + contactUsController.openC.value += 1; + contactUsController.allC.value += 1; + } else if (a.status == 2) { + contactUsController.closeC.value += 1; + contactUsController.allC.value += 1; + } else if (a.status == 3) { + contactUsController.resolvedC.value += 1; + contactUsController.allC.value += 1; + } } } + contactUsController.isLoading.value = false; }); }); - super.initState(); - } - @override - void dispose() { - status1Map.clear(); - status2Map.clear(); - status3Map.clear(); - super.dispose(); + super.initState(); } @override @@ -106,19 +102,20 @@ class _ContactUsMainScreenState extends State { padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 16), child: contactUsController.isLoading.value - ? Center( + ? const Center( child: CircularProgressIndicator( color: Colors.redAccent, )) - : contactUsController.contactModel.data!.isEmpty - ? Text("No Data Available") + : isEmpty.value + ? Center(child: text18W800("No Data Available")) : ListView( physics: const NeverScrollableScrollPhysics(), children: [ text25W600("Contact Us"), const Gap(20), - text16W400("Hi Afrid"), - text16W400("We are here to help you Us"), + text16W400( + "Hi ${ProfileObj!.data!.userName}"), + text16W400("We are here to help you"), const Gap(12), TabBar( tabAlignment: TabAlignment.start, @@ -141,16 +138,16 @@ class _ContactUsMainScreenState extends State { tabs: [ Tab( text: - "All Tickets (${contactUsController.contactModel.data!.length.toString()})"), + "All Tickets (${contactUsController.allC.value})"), Tab( text: - "Open Tickets (${status1Map.values.expand((list) => list).length.toString()})"), + "Open Tickets (${contactUsController.openC.value})"), Tab( text: - "Closed (${status2Map.values.expand((list) => list).length.toString()})"), + "Closed (${contactUsController.closeC.value})"), Tab( text: - "Resolved (${status3Map.values.expand((list) => list).length.toString()})"), + "Resolved (${contactUsController.resolvedC.value})"), ], ), SizedBox( @@ -164,28 +161,43 @@ class _ContactUsMainScreenState extends State { index, "ALL"); }), ListView.builder( - itemCount: status1Map.values - .expand((list) => list) - .length, + itemCount: contactUsController + .contactModel.data!.length, itemBuilder: (ctx, index) { - return ticketCardWidget( - index, "OPEN"); + return contactUsController + .contactModel + .data![index] + .status == + 1 + ? ticketCardWidget( + index, "OPEN") + : const SizedBox(); }), ListView.builder( - itemCount: status2Map.values - .expand((list) => list) - .length, + itemCount: contactUsController + .contactModel.data!.length, itemBuilder: (ctx, index) { - return ticketCardWidget( - index, "CLOSED"); + return contactUsController + .contactModel + .data![index] + .status == + 2 + ? ticketCardWidget( + index, "CLOSED") + : const SizedBox(); }), ListView.builder( - itemCount: status3Map.values - .expand((list) => list) - .length, + itemCount: contactUsController + .contactModel.data!.length, itemBuilder: (ctx, index) { - return ticketCardWidget( - index, "RESOLVED"); + return contactUsController + .contactModel + .data![index] + .status == + 3 + ? ticketCardWidget( + index, "RESOLVED") + : const SizedBox(); }), ]), ) @@ -201,598 +213,169 @@ class _ContactUsMainScreenState extends State { Widget ticketCardWidget(index, type) { ContactUsController contactUsController = Get.put(ContactUsController()); - return contactUsController.contactModel.data!.elementAt(index).status != 0 && - type == "ALL" - ? InkWell( - onTap: () { - contactUsController.attachmentFileDetailsList.clear(); - contactUsController.attachmentPathNameDetailsList.clear(); - Get.toNamed(RouteName.contactUsMainDetails); - }, - child: Container( - width: Get.width, - height: 190, - margin: EdgeInsets.only(bottom: 18, top: index == 0 ? 15 : 0), - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.98, -0.21), - end: const Alignment(-0.98, 0.21), - colors: [ - Colors.white.withOpacity(0.03999999910593033), - Colors.white.withOpacity(0.05999999865889549) - ], - ), - shape: RoundedRectangleBorder( - side: const BorderSide(width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 15, - horizontal: 10, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - text16W600(contactUsController.contactModel.data! - .elementAt(index) - .uniqueTicketId - .toString()), - Row( - children: [ - text16W500( - contactUsController.contactModel.data! - .elementAt(index) - .status == - 1 - ? "Open" - : contactUsController.contactModel.data! - .elementAt(index) - .status == - 2 - ? "Closed" - : "Resolved", - clr: contactUsController.contactModel.data! - .elementAt(index) - .status == - 1 - ? const Color(0xFFFFAD31) - : contactUsController.contactModel.data! - .elementAt(index) - .status == - 2 - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759)), - const Gap(8), - CircleAvatar( - radius: 10, - backgroundColor: contactUsController - .contactModel.data! + return InkWell( + onTap: () async { + contactUsController.attachmentFileDetailsList.clear(); + contactUsController.attachmentPathNameDetailsList.clear(); + + var result = await Get.toNamed(RouteName.contactUsMainDetails, + arguments: { + "id": contactUsController.contactModel.data! + .elementAt(index) + .id + .toString() + }); + + if (result != null && result) { + contactUsController.isLoading.value = true; + ContactUsApi().getContactUsData().then((value) { + contactUsController.allC.value = 0; + contactUsController.openC.value = 0; + contactUsController.closeC.value = 0; + contactUsController.resolvedC.value = 0; + + contactUsController.contactModel = + ContactUsModel.fromJson(value.data); + for (var a in contactUsController.contactModel.data!) { + if (a.status == 1) { + contactUsController.openC.value += 1; + contactUsController.allC.value += 1; + } else if (a.status == 2) { + contactUsController.closeC.value += 1; + contactUsController.allC.value += 1; + } else if (a.status == 3) { + contactUsController.resolvedC.value += 1; + contactUsController.allC.value += 1; + } + } + + contactUsController.isLoading.value = false; + }); + } + }, + child: Container( + width: Get.width, + height: 195, + margin: EdgeInsets.only(bottom: 18, top: index == 0 ? 15 : 0), + decoration: ShapeDecoration( + gradient: LinearGradient( + begin: const Alignment(0.98, -0.21), + end: const Alignment(-0.98, 0.21), + colors: [ + Colors.white.withOpacity(0.03999999910593033), + Colors.white.withOpacity(0.05999999865889549) + ], + ), + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFF393939)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Padding( + padding: const EdgeInsets.symmetric( + vertical: 15, + horizontal: 10, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + text16W600(contactUsController.contactModel.data! + .elementAt(index) + .uniqueTicketId + .toString()), + Row( + children: [ + text16W500( + contactUsController.contactModel.data! + .elementAt(index) + .status == + 1 + ? "Open" + : contactUsController.contactModel.data! .elementAt(index) .status == - 1 - ? const Color(0xFFFFAD31) - : contactUsController.contactModel.data! - .elementAt(index) - .status == - 2 - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759), - child: const Center( - child: Icon( - Icons.check_rounded, - size: 15, - color: Colors.white, - ), - ), - ) - ], - ), - ], - ), - const Gap(10), - text16W600(contactUsController.contactModel.data! - .elementAt(index) - .createdAt - .toString()), - const Gap(5), - text16W400(contactUsController.contactModel.data! - .elementAt(index) - .ticketCategory! - .name - .toString()), - const Gap(22), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - ), - width: Get.width, - height: 50, - decoration: ShapeDecoration( - color: Colors.black.withOpacity(0.03999999910593033), - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Center( - child: text16W400( - contactUsController.contactModel.data! - .elementAt(index) - .description - .toString(), - clr: const Color(0xFF9E9E9E), - textOver: TextOverflow.ellipsis), - ), - ) - ], - ), - ), - ), - ) - : type == "OPEN" - ? InkWell( - onTap: () { - contactUsController.attachmentFileDetailsList.clear(); - contactUsController.attachmentPathNameDetailsList.clear(); - Get.toNamed(RouteName.contactUsMainDetails); - }, - child: Container( - width: Get.width, - height: 190, - margin: EdgeInsets.only(bottom: 18, top: index == 0 ? 15 : 0), - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.98, -0.21), - end: const Alignment(-0.98, 0.21), - colors: [ - Colors.white.withOpacity(0.03999999910593033), - Colors.white.withOpacity(0.05999999865889549) - ], - ), - shape: RoundedRectangleBorder( - side: const BorderSide(width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 15, - horizontal: 10, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - text16W600(status1Map.values - .expand((list) => list) - .elementAt(index) - .ticketCategoryXid - .toString()), - Row( - children: [ - text16W500( - status1Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "1" - ? "OPEN" - : "Open", - clr: status1Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "1" - ? const Color(0xFFFFAD31) - : status1Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "2" - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759)), - const Gap(8), - CircleAvatar( - radius: 10, - backgroundColor: status1Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "1" - ? const Color(0xFFFFAD31) - : status1Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "2" - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759), - child: const Center( - child: Icon( - Icons.check_rounded, - size: 15, - color: Colors.white, - ), - ), - ) - ], - ), - ], - ), - const Gap(10), - text16W600(status1Map.values - .expand((list) => list) - .elementAt(index) - .createdAt - .toString()), - const Gap(5), - text16W400(status1Map.values - .expand((list) => list) - .elementAt(index) - .ticketCategory! - .name - .toString()), - const Gap(22), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - ), - width: Get.width, - height: 50, - decoration: ShapeDecoration( - color: Colors.black.withOpacity(0.03999999910593033), - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Center( - child: text16W400( - status1Map.values - .expand((list) => list) + 2 + ? "Closed" + : "Resolved", + clr: contactUsController.contactModel.data! + .elementAt(index) + .status == + 1 + ? const Color(0xFFFFAD31) + : contactUsController.contactModel.data! + .elementAt(index) + .status == + 2 + ? const Color(0xFF95CCFF) + : const Color(0xFF34C759)), + const Gap(8), + CircleAvatar( + radius: 10, + backgroundColor: contactUsController.contactModel.data! .elementAt(index) - .description - .toString(), - clr: const Color(0xFF9E9E9E), - textOver: TextOverflow.ellipsis), - ), - ) - ], - ), - ), - ), - ) - : type == "CLOSED" - ? InkWell( - onTap: () { - contactUsController.attachmentFileDetailsList.clear(); - contactUsController.attachmentPathNameDetailsList.clear(); - Get.toNamed(RouteName.contactUsMainDetails); - }, - child: Container( - width: Get.width, - height: 190, - margin: - EdgeInsets.only(bottom: 18, top: index == 0 ? 15 : 0), - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.98, -0.21), - end: const Alignment(-0.98, 0.21), - colors: [ - Colors.white.withOpacity(0.03999999910593033), - Colors.white.withOpacity(0.05999999865889549) - ], - ), - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 15, - horizontal: 10, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - text16W600(status2Map.values - .expand((list) => list) - .elementAt(index) - .ticketCategoryXid - .toString()), - Row( - children: [ - text16W500( - status2Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "2" - ? "CLOSED" - : "Closed", - clr: status2Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "1" - ? const Color(0xFFFFAD31) - : status2Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "2" - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759)), - const Gap(8), - CircleAvatar( - radius: 10, - backgroundColor: status2Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "1" - ? const Color(0xFFFFAD31) - : status2Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "2" - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759), - child: const Center( - child: Icon( - Icons.check_rounded, - size: 15, - color: Colors.white, - ), - ), - ) - ], - ), - ], - ), - const Gap(10), - text16W600(status2Map.values - .expand((list) => list) - .elementAt(index) - .createdAt - .toString()), - const Gap(5), - text16W400(status2Map.values - .expand((list) => list) - .elementAt(index) - .ticketCategory! - .name - .toString()), - const Gap(22), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - ), - width: Get.width, - height: 50, - decoration: ShapeDecoration( - color: - Colors.black.withOpacity(0.03999999910593033), - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Center( - child: text16W400( - status2Map.values - .expand((list) => list) + .status == + 1 + ? const Color(0xFFFFAD31) + : contactUsController.contactModel.data! .elementAt(index) - .description - .toString(), - clr: const Color(0xFF9E9E9E), - textOver: TextOverflow.ellipsis), - ), - ) - ], - ), - ), - ), - ) - : type == "RESOLVED" - ? InkWell( - onTap: () { - contactUsController.attachmentFileDetailsList.clear(); - contactUsController.attachmentPathNameDetailsList - .clear(); - Get.toNamed(RouteName.contactUsMainDetails); - }, - child: Container( - width: Get.width, - height: 190, - margin: EdgeInsets.only( - bottom: 18, top: index == 0 ? 15 : 0), - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.98, -0.21), - end: const Alignment(-0.98, 0.21), - colors: [ - Colors.white.withOpacity(0.03999999910593033), - Colors.white.withOpacity(0.05999999865889549) - ], - ), - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Padding( - padding: const EdgeInsets.symmetric( - vertical: 15, - horizontal: 10, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - text16W600(status3Map.values - .expand((list) => list) - .elementAt(index) - .ticketCategoryXid - .toString()), - Row( - children: [ - text16W500( - status3Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "3" - ? "RESOLVED" - : "Resolved", - clr: status3Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "1" - ? const Color(0xFFFFAD31) - : status3Map.values - .expand( - (list) => list) - .elementAt(index) - .status - .toString() == - "2" - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759)), - const Gap(8), - CircleAvatar( - radius: 10, - backgroundColor: status3Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "1" - ? const Color(0xFFFFAD31) - : status3Map.values - .expand((list) => list) - .elementAt(index) - .status - .toString() == - "2" - ? const Color(0xFF95CCFF) - : const Color(0xFF34C759), - child: const Center( - child: Icon( - Icons.check_rounded, - size: 15, - color: Colors.white, - ), - ), - ) - ], - ), - ], - ), - const Gap(10), - text16W600(status3Map.values - .expand((list) => list) - .elementAt(index) - .createdAt - .toString()), - const Gap(5), - text16W400(status3Map.values - .expand((list) => list) - .elementAt(index) - .ticketCategory! - .name - .toString()), - const Gap(22), - Container( - padding: const EdgeInsets.symmetric( - horizontal: 12, - ), - width: Get.width, - height: 50, - decoration: ShapeDecoration( - color: Colors.black - .withOpacity(0.03999999910593033), - shape: RoundedRectangleBorder( - side: const BorderSide( - width: 1, color: Color(0xFF393939)), - borderRadius: BorderRadius.circular(8), - ), - ), - child: Center( - child: text16W400( - status3Map.values - .expand((list) => list) - .elementAt(index) - .description - .toString(), - clr: const Color(0xFF9E9E9E), - textOver: TextOverflow.ellipsis), - ), - ) - ], - ), + .status == + 2 + ? const Color(0xFF95CCFF) + : const Color(0xFF34C759), + child: const Center( + child: Icon( + Icons.check_rounded, + size: 15, + color: Colors.white, ), ), ) - : SizedBox(); + ], + ), + ], + ), + const Gap(10), + text16W600(contactUsController.formatedDateTimeMethod( + contactUsController.contactModel.data! + .elementAt(index) + .createdAt + .toString())), + const Gap(5), + text16W400(contactUsController.contactModel.data! + .elementAt(index) + .ticketCategory! + .name + .toString()), + const Gap(22), + Container( + padding: const EdgeInsets.symmetric( + horizontal: 12, + ), + width: Get.width, + height: 50, + decoration: ShapeDecoration( + color: Colors.black.withOpacity(0.03999999910593033), + shape: RoundedRectangleBorder( + side: const BorderSide(width: 1, color: Color(0xFF393939)), + borderRadius: BorderRadius.circular(8), + ), + ), + child: Center( + child: text16W400( + contactUsController.contactModel.data! + .elementAt(index) + .description + .toString(), + clr: const Color(0xFF9E9E9E), + textOver: TextOverflow.ellipsis), + ), + ) + ], + ), + ), + ), + ); } - -List dataL = [ - { - "id": "#13569412", - "date": "16 Feb 2024, 11 : 35PM", - "category": "Account Management", - "desc": - "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500. Lorem Ipsum has been the industry's standard dummy text ever since the 1500", - "type": "OPEN" - }, - { - "id": "#13569412", - "date": "16 Feb 2024, 11 : 35PM", - "category": "Technical Support", - "desc": - "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500. Lorem Ipsum has been the industry's standard dummy text ever since the 1500", - "type": "CLOSED" - }, - { - "id": "#13569412", - "date": "16 Feb 2024, 11 : 35PM", - "category": "Feedback and Suggestions", - "desc": - "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500. Lorem Ipsum has been the industry's standard dummy text ever since the 1500", - "type": "RESOLVED" - } -]; diff --git a/pubspec.lock b/pubspec.lock index 0a94cf1..0ae5645 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -553,13 +553,13 @@ packages: source: hosted version: "1.5.4" intl: - dependency: transitive + dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.19.0" js: dependency: transitive description: @@ -612,10 +612,10 @@ packages: dependency: "direct main" description: name: local_auth - sha256: "27679ed8e0d7daab2357db6bb7076359e083a56b295c0c59723845301da6aed9" + sha256: "280421b416b32de31405b0a25c3bd42dfcef2538dfbb20c03019e02a5ed55ed0" url: "https://pub.dev" source: hosted - version: "2.1.8" + version: "2.2.0" local_auth_android: dependency: transitive description: @@ -624,14 +624,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.37" - local_auth_ios: + local_auth_darwin: dependency: transitive description: - name: local_auth_ios - sha256: eb283b530029b334698918f1e282d4483737cbca972ff21b9193be3d6de8e2b8 + name: local_auth_darwin + sha256: "33381a15b0de2279523eca694089393bb146baebdce72a404555d03174ebc1e9" url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "1.2.2" local_auth_platform_interface: dependency: transitive description: @@ -993,18 +993,18 @@ packages: dependency: transitive description: name: syncfusion_flutter_pdf - sha256: e97daea47f9ac4cf25cc8fc11a0475580ad9c592056d9c2bdc809c73e276decf + sha256: a42186922a416c2c9634a8f221aee261101babc2d30b1a1e908a7f034e743046 url: "https://pub.dev" source: hosted - version: "21.2.10" + version: "21.2.4" syncfusion_flutter_pdfviewer: dependency: "direct main" description: name: syncfusion_flutter_pdfviewer - sha256: fdd2ff565cd42247b8e86e26304329bae924fdfe8ddc1f4a3a264916f6c1ff1f + sha256: "2dc016f251c675f8e4923135c485356473b4d89c677670164292159cd1dd4f45" url: "https://pub.dev" source: hosted - version: "21.2.10" + version: "21.2.3" syncfusion_pdfviewer_macos: dependency: transitive description: @@ -1295,5 +1295,5 @@ packages: source: hosted version: "6.3.0" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" - flutter: ">=3.13.0" + dart: ">=3.2.3 <4.0.0" + flutter: ">=3.16.6" diff --git a/pubspec.yaml b/pubspec.yaml index cdbbd7d..0213fd9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,7 @@ dependencies: audio_video_progress_bar: ^2.0.2 syncfusion_flutter_pdfviewer: flutter_html: ^3.0.0-beta.2 + intl: ^0.19.0 dev_dependencies: flutter_test: From 1b6fd639935baec707e49778b100e94acabcb102 Mon Sep 17 00:00:00 2001 From: Rajshinde046 Date: Thu, 2 May 2024 13:11:24 +0530 Subject: [PATCH 2/4] contact us final --- lib/controller/contact_us_controller.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/controller/contact_us_controller.dart b/lib/controller/contact_us_controller.dart index f814f91..cf9cb8e 100644 --- a/lib/controller/contact_us_controller.dart +++ b/lib/controller/contact_us_controller.dart @@ -26,6 +26,7 @@ class ContactUsController extends GetxController { RxInt closeC = 0.obs; RxInt resolvedC = 0.obs; + //date format String formatedDateTimeMethod(String originalDateTimeString) { DateTime dateTime = DateTime.parse(originalDateTimeString); From ecc7087239a8a6cfc23563d330ffb8b57b117973 Mon Sep 17 00:00:00 2001 From: Rajshinde046 Date: Thu, 2 May 2024 13:13:06 +0530 Subject: [PATCH 3/4] contact us final --- lib/controller/contact_us_controller.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/controller/contact_us_controller.dart b/lib/controller/contact_us_controller.dart index cf9cb8e..b69064f 100644 --- a/lib/controller/contact_us_controller.dart +++ b/lib/controller/contact_us_controller.dart @@ -26,7 +26,7 @@ class ContactUsController extends GetxController { RxInt closeC = 0.obs; RxInt resolvedC = 0.obs; - //date format + //formated date String formatedDateTimeMethod(String originalDateTimeString) { DateTime dateTime = DateTime.parse(originalDateTimeString); From c0ad2d6b91cac2c9b63f4e10ffa8a1b7acb5a23e Mon Sep 17 00:00:00 2001 From: rajshinde046 Date: Thu, 2 May 2024 16:56:33 +0530 Subject: [PATCH 4/4] bloc --- .vscode/settings.json | 3 +- lib/data/network/network_api_services.dart | 2 +- lib/main.dart | 15 +- lib/resources/routes/routes.dart | 2 +- lib/view/login/LoginScreen.dart | 695 +++++++++++--------- lib/view/login/VerifyOtp.dart | 2 +- lib/view_model/LoginPage/Loginbloc.dart | 24 + lib/view_model/LoginPage/Loginobserver.dart | 14 + lib/view_model/SendOtp/sendOtpObserver.dart | 24 + lib/view_model/SendOtp/sendOtpbloc.dart | 33 + pubspec.lock | 24 + pubspec.yaml | 2 + 12 files changed, 513 insertions(+), 327 deletions(-) create mode 100644 lib/view_model/LoginPage/Loginbloc.dart create mode 100644 lib/view_model/LoginPage/Loginobserver.dart create mode 100644 lib/view_model/SendOtp/sendOtpObserver.dart create mode 100644 lib/view_model/SendOtp/sendOtpbloc.dart diff --git a/.vscode/settings.json b/.vscode/settings.json index c5f3f6b..2a96dec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "java.configuration.updateBuildConfiguration": "interactive" + "java.configuration.updateBuildConfiguration": "interactive", + "dart.flutterSdkPath": "D:\\pooja\\fluttersdk\\flutter_3.16.9\\flutter" } \ No newline at end of file diff --git a/lib/data/network/network_api_services.dart b/lib/data/network/network_api_services.dart index 297b210..a669ce5 100644 --- a/lib/data/network/network_api_services.dart +++ b/lib/data/network/network_api_services.dart @@ -7,7 +7,7 @@ import 'package:traderscircuit/Utils/utils.dart'; import '../../Utils/base_manager.dart'; import 'base_api_services.dart'; -class NetworkApiServices extends BaseApiServices { +class NetworkApiServices { Dio dio = Dio(); String basicAuth = 'Basic ' + base64.encode( diff --git a/lib/main.dart b/lib/main.dart index 9624b71..fd04b83 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -13,6 +14,9 @@ import 'package:firebase_core/firebase_core.dart'; import 'package:traderscircuit/resources/routes/routes.dart'; import 'package:onesignal_flutter/onesignal_flutter.dart'; +import 'view_model/LoginPage/Loginbloc.dart'; +import 'view_model/SendOtp/sendOtpbloc.dart'; + Future main() async { WidgetsFlutterBinding.ensureInitialized(); @@ -39,7 +43,16 @@ Future main() async { ); SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, - ]).then((value) => runApp(const MyApp())); + ]).then((value) => runApp(MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => CounterBloc(), + ), + BlocProvider( + create: (context) => SendOtpBloc(), + ), + // Add more BlocProviders for other Blocs here if needed + ],child: const MyApp()))); } class MyApp extends StatefulWidget { diff --git a/lib/resources/routes/routes.dart b/lib/resources/routes/routes.dart index 485fc74..283d539 100644 --- a/lib/resources/routes/routes.dart +++ b/lib/resources/routes/routes.dart @@ -86,7 +86,7 @@ class AppRoutes { ), GetPage( name: RouteName.verifyotp, - page: () => const VerifyOTP(), + page: () => VerifyOTP(), ), //secureaccess diff --git a/lib/view/login/LoginScreen.dart b/lib/view/login/LoginScreen.dart index e0cfb95..c61bad2 100644 --- a/lib/view/login/LoginScreen.dart +++ b/lib/view/login/LoginScreen.dart @@ -2,6 +2,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:glassmorphism/glassmorphism.dart'; @@ -11,9 +12,15 @@ import 'package:traderscircuit/Utils/base_manager.dart'; import 'package:traderscircuit/Utils/text.dart'; import 'package:traderscircuit/Utils/utils.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; +import 'package:traderscircuit/view/login/VerifyOtp.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; import 'package:traderscircuit/view_model/Login/send_otp_api.dart'; import 'package:traderscircuit/Utils/Dialogs.dart'; +import 'package:traderscircuit/view_model/LoginPage/Loginbloc.dart'; + +import '../../view_model/LoginPage/Loginobserver.dart'; +import '../../view_model/SendOtp/sendOtpObserver.dart'; +import '../../view_model/SendOtp/sendOtpbloc.dart'; class LoginScreen extends StatefulWidget { const LoginScreen({super.key}); @@ -33,6 +40,9 @@ class _LoginScreenState extends State { @override Widget build(BuildContext context) { + // final CounterBloc counterbloc = BlocProvider.of(context); + //final sendOtpBloc = context.read(); + return WillPopScope( onWillPop: () async { _onBackButtonPressed(context); @@ -41,343 +51,383 @@ class _LoginScreenState extends State { child: Scaffold( backgroundColor: Colors.black, extendBody: true, - body: Stack( - children: [ - const CommonBlurLeft(), - const CommonBlurRight(), - Stack( - children: [ - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 16, vertical: 16), - child: Form( - key: _sendotpform, - child: ListView( - physics: const BouncingScrollPhysics(), - // mainAxisAlignment: MainAxisAlignment.start, - // crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 20.h, - ), - const Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Traders Circuit", - style: TextStyle( - fontFamily: 'hiragino', - color: Colors.white, - fontSize: 25, - fontWeight: FontWeight.w600), - ), - ], - ), - SizedBox( - height: 42.h, - ), - const Text( - "Lets get started ", - style: TextStyle( - fontFamily: 'hiragino', - color: Colors.white, - fontSize: 24, - fontWeight: FontWeight.w700), - ), - SizedBox( - height: 10.h, - ), - text18W800("Enter your mobile number to get otp"), - SizedBox( - height: 35.h, - ), - Row( - children: [ - Expanded( - child: GlassmorphicContainer( - width: 60, - height: 50, - borderRadius: 8, - blur: 10, - alignment: Alignment.center, - border: 0.8, - linearGradient: LinearGradient( + body: BlocProvider( + create: (context) => SendOtpBloc(), + child: Stack( + children: [ + const CommonBlurLeft(), + const CommonBlurRight(), + Stack( + children: [ + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 16, vertical: 16), + child: Form( + key: _sendotpform, + child: ListView( + physics: const BouncingScrollPhysics(), + // mainAxisAlignment: MainAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 20.h, + ), + const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Traders Circuit", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 25, + fontWeight: FontWeight.w600), + ), + ], + ), + SizedBox( + height: 42.h, + ), + //bloc implementation + /* GestureDetector( + onTap: () { + counterbloc.add(NumberIncreaseEvent()); + }, + child: SizedBox( + height: 80.h, + child: Text( + "click me", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.w700), + ), + ), + ), + if (state is UpdateState) + Text( + "${state.counter}", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.w700), + ), + */ + const Text( + "Lets get started ", + style: TextStyle( + fontFamily: 'hiragino', + color: Colors.white, + fontSize: 24, + fontWeight: FontWeight.w700), + ), + SizedBox( + height: 10.h, + ), + text18W800("Enter your mobile number to get otp"), + SizedBox( + height: 35.h, + ), + Row( + children: [ + Expanded( + child: GlassmorphicContainer( + width: 60, + height: 50, + borderRadius: 8, + blur: 10, + alignment: Alignment.center, + border: 0.8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Colors.white.withOpacity(0.1), + const Color(0xFFFFFFFF) + .withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + borderGradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ - Colors.white.withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xff9A0000).withOpacity(0.5), + const Color(0xFFffffff).withOpacity(0.5), ], - stops: const [ - 0.1, - 1, - ]), - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xff9A0000).withOpacity(0.5), - const Color(0xFFffffff).withOpacity(0.5), - ], - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // SvgPicture.asset("assets/images/svg/india.svg"), - Image.asset( - "assets/images/png/india.png", - height: 25.h, - width: 25.h, - ), - const SizedBox( - width: 2, - ), - const Text( - "+91", - style: TextStyle( - fontFamily: 'hiragino', - fontSize: 15, - color: Colors.white, + ), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // SvgPicture.asset("assets/images/svg/india.svg"), + Image.asset( + "assets/images/png/india.png", + height: 25.h, + width: 25.h, ), - ) - ], + const SizedBox( + width: 2, + ), + const Text( + "+91", + style: TextStyle( + fontFamily: 'hiragino', + fontSize: 15, + color: Colors.white, + ), + ) + ], + ), ), ), - ), - const SizedBox( - width: 10, - ), - SizedBox( - width: 285.w, - child: CustomTextFormField( - texttype: TextInputType.phone, - textEditingController: phonecontroller, - // validator: (value) { - // if (value.isEmpty) { - // return 'Enter your phone number'; - // } else if (!RegExp(r'(^(?:[+0]9)?[0-9]{10}$)') - // .hasMatch(value)) { - // return 'Enter a valid phone number'; - // } else if (!isValidPhoneNumber(value)) { - // return 'Phone number cannot contain 10 zeros'; - // } - // return null; - // }, - inputFormatters: [ - LengthLimitingTextInputFormatter(10), - FilteringTextInputFormatter.allow( - RegExp('[0-9]')), + const SizedBox( + width: 10, + ), + SizedBox( + width: 285.w, + child: CustomTextFormField( + texttype: TextInputType.phone, + textEditingController: phonecontroller, + // validator: (value) { + // if (value.isEmpty) { + // return 'Enter your phone number'; + // } else if (!RegExp(r'(^(?:[+0]9)?[0-9]{10}$)') + // .hasMatch(value)) { + // return 'Enter a valid phone number'; + // } else if (!isValidPhoneNumber(value)) { + // return 'Phone number cannot contain 10 zeros'; + // } + // return null; + // }, + inputFormatters: [ + LengthLimitingTextInputFormatter(10), + FilteringTextInputFormatter.allow( + RegExp('[0-9]')), + ], + ), + ) + ], + ), + const SizedBox( + height: 10, + ), + text14W300( + "We’ll send six digit code to the registered number. Standard data rates may apply"), + SizedBox( + height: 65.h, + ), + + BlocConsumer( + listener: (context, state) { + if (state == SendOtpState.success) { + WidgetsBinding.instance + ?.addPostFrameCallback((_) { + Get.toNamed(RouteName.verifyotp, arguments: { + "phonenumber": phonecontroller.text, + }); + }); + } else if (state == SendOtpState.failure) { + Utils.showToast("Oops something went wrong"); + } + }, builder: (context, state) { + print(state); + if (state == SendOtpState.loading) { + return Center( + child: Container( + height: 40, + width: 40, + child: CircularProgressIndicator())); + } + return CommonBtn( + text: "Login/Signup", + onTap: () async { + final isValid = + _sendotpform.currentState?.validate(); + if (isValid!) { + FocusManager.instance.primaryFocus + ?.unfocus(); + if (isValid != null && isValid) { + Map myLoginData = { + "mobile_number": phonecontroller.text, + }; + context + .read() + .add(SendOtp(myLoginData)); + } else { + ScaffoldMessenger.of(context) + .showSnackBar( + SnackBar( + content: Text( + 'Please enter valid phone number'), + ), + ); + } + } + }); + }), + + SizedBox( + height: 10.h, + ), + text14W300( + "By continuing, you agree to our Terms & Conditions"), + SizedBox( + height: 45.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + height: 0.2.h, + width: 108.w, + color: Colors.white, + ), + SizedBox( + width: 22.w, + ), + text18W600("OR"), + SizedBox( + width: 22.w, + ), + Container( + height: 0.2.h, + width: 108.w, + color: Colors.white, + ), + ], + ), + SizedBox( + height: 40.h, + ), + GlassmorphicContainer( + width: double.infinity, + height: 55.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.3, + blur: 10, + borderGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFAF2E89).withOpacity(0.2), + const Color(0xFFA23E31).withOpacity(0.2), + const Color(0xFF0000).withOpacity(0.2), + ], + stops: const [ + 0.3, + 0.6, + 1, + ]), + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + "assets/images/png/apple.png", + height: 30.h, + width: 30.w, + ), + SizedBox( + width: 7.h, + ), + text16W400("Continue with apple"), ], ), - ) - ], - ), - const SizedBox( - height: 10, - ), - text14W300( - "We’ll send six digit code to the registered number. Standard data rates may apply"), - SizedBox( - height: 65.h, - ), - CommonBtn( - text: "Login/Signup", - onTap: () async { - final isValid = - _sendotpform.currentState?.validate(); - if (isValid!) { - utils.loader(); - FocusManager.instance.primaryFocus?.unfocus(); - - Map myLoginData = { - "mobile_number": phonecontroller.text, - }; - - var resp = - await SendOtpAPI(myLoginData).sendOtpApi(); - print(resp.status); - print('Api msg : ${resp.message}'); - - if (resp.status == ResponseStatus.SUCCESS) { - Get.back(); - print("api response is ${resp.data}"); - Utils.showToast("OTP sent successfully"); - - Map res = resp.data; - print(res); - - Get.toNamed(RouteName.verifyotp, arguments: { - "phonenumber": phonecontroller.text - }); - } else { - Get.back(); - Utils.showToast(resp.message); - print('Api msg : ${resp.message}'); - } - } else { - Get.snackbar( - "Error", "Please Enter Login Credentials", - margin: EdgeInsets.all(8), - snackStyle: SnackStyle.FLOATING, - snackPosition: SnackPosition.BOTTOM); - } - }), - SizedBox( - height: 10.h, - ), - text14W300( - "By continuing, you agree to our Terms & Conditions"), - SizedBox( - height: 45.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - height: 0.2.h, - width: 108.w, - color: Colors.white, - ), - SizedBox( - width: 22.w, - ), - text18W600("OR"), - SizedBox( - width: 22.w, - ), - Container( - height: 0.2.h, - width: 108.w, - color: Colors.white, - ), - ], - ), - SizedBox( - height: 40.h, - ), - GlassmorphicContainer( - width: double.infinity, - height: 55.h, - borderRadius: 8, - linearGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), - ], - stops: const [ - 0.1, - 1, - ]), - border: 0.3, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFAF2E89).withOpacity(0.2), - const Color(0xFFA23E31).withOpacity(0.2), - const Color(0xFF0000).withOpacity(0.2), - ], - stops: const [ - 0.3, - 0.6, - 1, - ]), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - "assets/images/png/apple.png", - height: 30.h, - width: 30.w, - ), - SizedBox( - width: 7.h, - ), - text16W400("Continue with apple"), - ], ), ), - ), - SizedBox( - height: 15.h, - ), - GlassmorphicContainer( - width: double.infinity, - height: 55.h, - borderRadius: 8, - linearGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFffffff).withOpacity(0.1), - const Color(0xFFFFFFFF).withOpacity(0.05), - ], - stops: const [ - 0.1, - 1, - ]), - border: 0.5, - blur: 10, - borderGradient: LinearGradient( - begin: Alignment.topLeft, - end: Alignment.bottomRight, - colors: [ - const Color(0xFFAF2E89).withOpacity(0.2), - const Color(0xFFA23E31).withOpacity(0.2), - const Color(0xFF0000).withOpacity(0.2), - ], - stops: const [ - 0.3, - 0.6, - 1, - ]), - child: Center( - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - "assets/images/png/google.png", - height: 30.h, - width: 30.w, - ), - SizedBox( - width: 7.h, - ), - text16W400( - "Continue with google", - ), - ], - ), + SizedBox( + height: 15.h, ), - ), - SizedBox( - height: 45.h, - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - InkWell( - onTap: () { - Get.toNamed(RouteName.mainscreen); - }, - child: text16W700( - "Continue as guest", + GlassmorphicContainer( + width: double.infinity, + height: 55.h, + borderRadius: 8, + linearGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.1), + const Color(0xFFFFFFFF).withOpacity(0.05), + ], + stops: const [ + 0.1, + 1, + ]), + border: 0.5, + blur: 10, + borderGradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFAF2E89).withOpacity(0.2), + const Color(0xFFA23E31).withOpacity(0.2), + const Color(0xFF0000).withOpacity(0.2), + ], + stops: const [ + 0.3, + 0.6, + 1, + ]), + child: Center( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + "assets/images/png/google.png", + height: 30.h, + width: 30.w, + ), + SizedBox( + width: 7.h, + ), + text16W400( + "Continue with google", + ), + ], ), ), - ], - ) - ], + ), + SizedBox( + height: 45.h, + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + InkWell( + onTap: () { + Get.toNamed(RouteName.mainscreen); + }, + child: text16W700( + "Continue as guest", + ), + ), + ], + ) + ], + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); @@ -419,4 +469,5 @@ class _LoginScreenState extends State { ); }); return exitApp ?? false; - }} + } +} diff --git a/lib/view/login/VerifyOtp.dart b/lib/view/login/VerifyOtp.dart index 6582545..88b1dcd 100644 --- a/lib/view/login/VerifyOtp.dart +++ b/lib/view/login/VerifyOtp.dart @@ -20,7 +20,7 @@ int? isKycUpdated; int? isSecuredAccess; class VerifyOTP extends StatefulWidget { - const VerifyOTP({super.key}); + VerifyOTP({super.key}); @override State createState() => _VerifyOTPState(); diff --git a/lib/view_model/LoginPage/Loginbloc.dart b/lib/view_model/LoginPage/Loginbloc.dart new file mode 100644 index 0000000..19cb21d --- /dev/null +++ b/lib/view_model/LoginPage/Loginbloc.dart @@ -0,0 +1,24 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; + +import 'Loginobserver.dart'; + +class CounterBloc extends Bloc { + int counter = 0; + + CounterBloc() : super(UpdateState(0)) { + on(onNumberIncrease); + on(onNumberDecrease); + } + + void onNumberIncrease( + NumberIncreaseEvent event, Emitter emit) async { + counter = counter + 1; + emit(UpdateState(counter)); + } + + void onNumberDecrease( + NumberDecreaseEvent event, Emitter emit) async { + counter = counter - 1; + emit(UpdateState(counter)); + } +} \ No newline at end of file diff --git a/lib/view_model/LoginPage/Loginobserver.dart b/lib/view_model/LoginPage/Loginobserver.dart new file mode 100644 index 0000000..1bcea4a --- /dev/null +++ b/lib/view_model/LoginPage/Loginobserver.dart @@ -0,0 +1,14 @@ +class CounterEvents {} + +class NumberIncreaseEvent extends CounterEvents {} + +class NumberDecreaseEvent extends CounterEvents {} + +class CounterStates {} + +class InitialState extends CounterStates {} + +class UpdateState extends CounterStates { + final int counter; + UpdateState(this.counter); +} \ No newline at end of file diff --git a/lib/view_model/SendOtp/sendOtpObserver.dart b/lib/view_model/SendOtp/sendOtpObserver.dart new file mode 100644 index 0000000..a0b7bc7 --- /dev/null +++ b/lib/view_model/SendOtp/sendOtpObserver.dart @@ -0,0 +1,24 @@ +import 'package:equatable/equatable.dart'; + +// Define events +abstract class SendOtpEvent { + const SendOtpEvent(); + + @override + List get props => []; +} + +class SendOtp extends SendOtpEvent { + final Map loginData; + SendOtp(this.loginData){ + + } + + @override + List get props => [loginData]; + +} + +// Define states +enum SendOtpState { initial, loading, success, failure } + diff --git a/lib/view_model/SendOtp/sendOtpbloc.dart b/lib/view_model/SendOtp/sendOtpbloc.dart new file mode 100644 index 0000000..0ba9db0 --- /dev/null +++ b/lib/view_model/SendOtp/sendOtpbloc.dart @@ -0,0 +1,33 @@ +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:get/get.dart'; + +import '../../Utils/base_manager.dart'; +import '../../resources/routes/route_name.dart'; +import '../Login/send_otp_api.dart'; +import 'sendOtpObserver.dart'; + +class SendOtpBloc extends Bloc { + SendOtpBloc() : super(SendOtpState.initial) { + on(mapEventToState); + } + Future mapEventToState( + SendOtp event, Emitter emit) async { + if (event is SendOtp) { + emit(SendOtpState.loading); + try { + final loginData = event.loginData; + var resp = await SendOtpAPI(loginData).sendOtpApi(); + + if (resp.status == ResponseStatus.SUCCESS) { + emit(SendOtpState.success); + } else { + emit(SendOtpState.failure); + } + } catch (e) { + emit(SendOtpState.failure); + } + } + } +} + + diff --git a/pubspec.lock b/pubspec.lock index 0a94cf1..cfbb997 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.2" + bloc: + dependency: transitive + description: + name: bloc + sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e" + url: "https://pub.dev" + source: hosted + version: "8.1.4" boolean_selector: dependency: transitive description: @@ -217,6 +225,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.3.9" + equatable: + dependency: "direct main" + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" expansion_tile_group: dependency: "direct main" description: @@ -318,6 +334,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: f0ecf6e6eb955193ca60af2d5ca39565a86b8a142452c5b24d96fb477428f4d2 + url: "https://pub.dev" + source: hosted + version: "8.1.5" flutter_branch_sdk: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index cdbbd7d..bbf3bac 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -48,6 +48,8 @@ dependencies: audio_video_progress_bar: ^2.0.2 syncfusion_flutter_pdfviewer: flutter_html: ^3.0.0-beta.2 + flutter_bloc: ^8.1.5 + equatable: ^2.0.5 dev_dependencies: flutter_test: