From 8886cea7a8d55176974b5173ac3eff5af71794cf Mon Sep 17 00:00:00 2001 From: jayesh Date: Fri, 3 May 2024 18:42:55 +0530 Subject: [PATCH 1/3] product recommendations api integration - pending --- lib/Utils/Common/CommonBottomNavigation.dart | 25 +- lib/Utils/Common/MainController.dart | 1 - .../Common/comonGlassmorphicContainer.dart | 7 +- lib/Utils/Common/noInternet.dart | 2 - lib/controller/contact_us_controller.dart | 8 +- lib/controller/content_bytes_controller.dart | 2 - lib/controller/products_controller.dart | 8 + lib/data/network/network_api_services.dart | 1 - lib/model/FAQModel/faq_model.dart | 2 - lib/view/MainScreen/HomeScreen.dart | 42 +- lib/view/MainScreen/ShortTrade.dart | 378 ++++++++---------- pubspec.lock | 44 +- 12 files changed, 239 insertions(+), 281 deletions(-) diff --git a/lib/Utils/Common/CommonBottomNavigation.dart b/lib/Utils/Common/CommonBottomNavigation.dart index 7e34e99..8b29608 100644 --- a/lib/Utils/Common/CommonBottomNavigation.dart +++ b/lib/Utils/Common/CommonBottomNavigation.dart @@ -1,8 +1,5 @@ -import 'dart:ui'; - import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:glassmorphism/glassmorphism.dart'; import 'package:traderscircuit/Utils/Common/MainController.dart'; @@ -19,13 +16,13 @@ GlassmorphicContainer bottomnavigationbar(MainController _mainController) { end: Alignment.bottomRight, colors: [ Colors.white.withOpacity(0.1), - Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xFFFFFFFF).withOpacity(0.05), ], - stops: [ + stops: const [ 0.1, 1, ]), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ @@ -36,18 +33,18 @@ GlassmorphicContainer bottomnavigationbar(MainController _mainController) { child: BottomNavigationBar( // backgroundColor: , type: BottomNavigationBarType.fixed, - backgroundColor: Color(0xFFFFFFFF).withOpacity(0), + backgroundColor: const Color(0xFFFFFFFF).withOpacity(0), showUnselectedLabels: true, selectedItemColor: Colors.white, - unselectedItemColor: Color(0xFF676767), + unselectedItemColor: const Color(0xFF676767), unselectedLabelStyle: TextStyle( fontSize: 10.sp, - color: Color(0xFF676767), + color: const Color(0xFF676767), fontWeight: FontWeight.w400, fontFamily: 'hiragino'), selectedLabelStyle: TextStyle( fontSize: 10.sp, - color: Color(0xFFFFFFFF), + color: const Color(0xFFFFFFFF), fontWeight: FontWeight.w400, fontFamily: 'hiragino'), currentIndex: _mainController.selectedIndex.value, @@ -78,7 +75,7 @@ GlassmorphicContainer bottomnavigationbar(MainController _mainController) { color: Colors.grey.withOpacity(0.4), spreadRadius: 15, blurRadius: 10, - offset: Offset(0, 10), + offset: const Offset(0, 10), ), ], ), @@ -121,7 +118,7 @@ GlassmorphicContainer bottomnavigationbar(MainController _mainController) { color: Colors.grey.withOpacity(0.4), spreadRadius: 15, blurRadius: 10, - offset: Offset(0, 10), + offset: const Offset(0, 10), ), ], ), @@ -163,7 +160,7 @@ GlassmorphicContainer bottomnavigationbar(MainController _mainController) { color: Colors.grey.withOpacity(0.4), spreadRadius: 15, blurRadius: 10, - offset: Offset(0, 10), + offset: const Offset(0, 10), ), ], ), @@ -205,7 +202,7 @@ GlassmorphicContainer bottomnavigationbar(MainController _mainController) { color: Colors.grey.withOpacity(0.4), spreadRadius: 15, blurRadius: 10, - offset: Offset(0, 10), + offset: const Offset(0, 10), ), ], ), diff --git a/lib/Utils/Common/MainController.dart b/lib/Utils/Common/MainController.dart index a0ab397..fc982b5 100644 --- a/lib/Utils/Common/MainController.dart +++ b/lib/Utils/Common/MainController.dart @@ -1,7 +1,6 @@ import 'package:get/get.dart'; import 'package:traderscircuit/view/MainScreen/HomeScreen.dart'; import 'package:traderscircuit/view/MainScreen/PastPerformance.dart'; -import 'package:traderscircuit/view/MainScreen/Portfolio/Holdings.dart'; import 'package:traderscircuit/view/MainScreen/Portfolio/PortfolioEmpty.dart'; import 'package:traderscircuit/view/MainScreen/ShortTrade.dart'; diff --git a/lib/Utils/Common/comonGlassmorphicContainer.dart b/lib/Utils/Common/comonGlassmorphicContainer.dart index fe1ad6d..5f4ec00 100644 --- a/lib/Utils/Common/comonGlassmorphicContainer.dart +++ b/lib/Utils/Common/comonGlassmorphicContainer.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:glassmorphism/glassmorphism.dart'; Widget commonGlassContainer( @@ -19,14 +18,14 @@ Widget commonGlassContainer( end: Alignment.bottomRight, colors: [ Colors.white.withOpacity(0.1), - Color(0xFFFFFFFF).withOpacity(0.05), + const Color(0xFFFFFFFF).withOpacity(0.05), ], - stops: [ + stops: const [ 0.1, 1, ], ), - borderGradient: LinearGradient( + borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ diff --git a/lib/Utils/Common/noInternet.dart b/lib/Utils/Common/noInternet.dart index 536f873..f9c57bf 100644 --- a/lib/Utils/Common/noInternet.dart +++ b/lib/Utils/Common/noInternet.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:traderscircuit/Utils/Common/sized_box.dart'; -import 'package:traderscircuit/Utils/text.dart'; class NoInternet extends StatefulWidget { const NoInternet({super.key}); diff --git a/lib/controller/contact_us_controller.dart b/lib/controller/contact_us_controller.dart index e387258..8b4065c 100644 --- a/lib/controller/contact_us_controller.dart +++ b/lib/controller/contact_us_controller.dart @@ -4,7 +4,6 @@ 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'; -import 'package:intl/intl.dart'; import '../model/ContactUsModel/ticket_details_model.dart'; @@ -20,7 +19,7 @@ class ContactUsController extends GetxController { //contact us page controller RxList attachmentFileList = [File("")].obs; RxList attachmentPathNameList = [""].obs; - RxList contactUsDetailsChatContent = [].obs; + RxList contactUsDetailsChatContent = [].obs; //contact us details page controller RxList attachmentFileDetailsList = [File("")].obs; RxList attachmentPathNameDetailsList = [""].obs; @@ -30,13 +29,10 @@ class ContactUsController extends GetxController { RxString selectedValue = "".obs; - - //formated date String formatedDateTimeMethod(String originalDateTimeString) { DateTime dateTime = DateTime.parse(originalDateTimeString); return DateFormat("dd MMM yyyy, hh:mm a").format(dateTime.toLocal()); } - -} \ No newline at end of file +} diff --git a/lib/controller/content_bytes_controller.dart b/lib/controller/content_bytes_controller.dart index 5aff0d6..0b94ad5 100644 --- a/lib/controller/content_bytes_controller.dart +++ b/lib/controller/content_bytes_controller.dart @@ -1,10 +1,8 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:just_audio/just_audio.dart'; -import 'package:traderscircuit/Utils/base_manager.dart'; import 'package:traderscircuit/model/ContentBytesModel/content_bytes_categories_model.dart'; import 'package:traderscircuit/model/ContentBytesModel/content_bytes_model.dart'; -import 'package:traderscircuit/view_model/ContentBytesApi/content_bytes_api.dart'; import '../view/Sidemenu/ContentByte/ContentBytes.dart'; diff --git a/lib/controller/products_controller.dart b/lib/controller/products_controller.dart index 3abe3e8..1f4f0a8 100644 --- a/lib/controller/products_controller.dart +++ b/lib/controller/products_controller.dart @@ -1,9 +1,17 @@ import 'package:get/get.dart'; import 'package:traderscircuit/model/ProductsModel/call_recommendations_model.dart'; +import 'package:intl/intl.dart'; class ProductsController extends GetxController { RxBool isLoaded = true.obs; CallRecommendationsModel swingTradeModel = CallRecommendationsModel(); CallRecommendationsModel multibaggerModel = CallRecommendationsModel(); CallRecommendationsModel optionModel = CallRecommendationsModel(); + + final selectedIndex = 0.obs; + String dateConverterMethod(String dateV) { + DateTime dateTime = DateTime.parse(dateV); + DateTime newDateTime = DateTime(dateTime.year, 3, 25); + return DateFormat("dd MMMM yyyy").format(newDateTime); + } } diff --git a/lib/data/network/network_api_services.dart b/lib/data/network/network_api_services.dart index a669ce5..85d0a40 100644 --- a/lib/data/network/network_api_services.dart +++ b/lib/data/network/network_api_services.dart @@ -5,7 +5,6 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:dio/dio.dart'; import 'package:traderscircuit/Utils/utils.dart'; import '../../Utils/base_manager.dart'; -import 'base_api_services.dart'; class NetworkApiServices { Dio dio = Dio(); diff --git a/lib/model/FAQModel/faq_model.dart b/lib/model/FAQModel/faq_model.dart index 4822d9b..d983af1 100644 --- a/lib/model/FAQModel/faq_model.dart +++ b/lib/model/FAQModel/faq_model.dart @@ -1,5 +1,3 @@ -import 'package:get/get.dart'; - class FAQModel { String? status; int? statusCode; diff --git a/lib/view/MainScreen/HomeScreen.dart b/lib/view/MainScreen/HomeScreen.dart index 59ded30..af675ab 100644 --- a/lib/view/MainScreen/HomeScreen.dart +++ b/lib/view/MainScreen/HomeScreen.dart @@ -10,6 +10,7 @@ import 'package:traderscircuit/Utils/Common/CommonTabBar.dart'; import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart'; import 'package:traderscircuit/Utils/Common/sized_box.dart'; import 'package:traderscircuit/Utils/text.dart'; +import 'package:traderscircuit/controller/products_controller.dart'; import 'package:traderscircuit/resources/routes/route_name.dart'; import 'package:traderscircuit/view/MainScreen/MainScreen.dart'; import 'package:traderscircuit/view/Sidemenu/ContentByte/PlayerWidget.dart'; @@ -28,6 +29,7 @@ class HomeScreen extends StatefulWidget { class _HomeScreenState extends State { GlobalKey _scaffoldKey1 = GlobalKey(); RxString userName = "User".obs; + ProductsController productsController = Get.put(ProductsController()); @override void initState() { @@ -132,20 +134,44 @@ class _HomeScreenState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - ProductWidget( - text: 'Options', subtext: 'Recommendation'), - ProductWidget( - text: 'Multibagger', subtext: 'Recommendation') + InkWell( + onTap: () { + mainController.selectedIndex.value = 1; + productsController.selectedIndex.value = 2; + }, + child: ProductWidget( + text: 'Options', subtext: 'Recommendation'), + ), + InkWell( + onTap: () { + mainController.selectedIndex.value = 1; + productsController.selectedIndex.value = 1; + }, + child: ProductWidget( + text: 'Multibagger', subtext: 'Recommendation'), + ) ], ), sizedBoxHeight(15.h), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - ProductWidget( - text: 'Swing Trade', subtext: 'Recommendation'), - ProductWidget( - text: 'OP + MB + ST', subtext: 'Recommendation'), + InkWell( + onTap: () { + mainController.selectedIndex.value = 1; + productsController.selectedIndex.value = 0; + }, + child: ProductWidget( + text: 'Swing Trade', subtext: 'Recommendation'), + ), + InkWell( + onTap: () { + mainController.selectedIndex.value = 1; + productsController.selectedIndex.value = 0; + }, + child: ProductWidget( + text: 'OP + MB + ST', subtext: 'Recommendation'), + ), ], ), sizedBoxHeight(25.h), diff --git a/lib/view/MainScreen/ShortTrade.dart b/lib/view/MainScreen/ShortTrade.dart index c5a530c..503b5f2 100644 --- a/lib/view/MainScreen/ShortTrade.dart +++ b/lib/view/MainScreen/ShortTrade.dart @@ -28,7 +28,6 @@ class ShortTrade extends StatefulWidget { class _ShortTradeState extends State { GlobalKey _scaffoldKey1 = GlobalKey(); List containerTexts = ["Swing Trade", "Multibagger", "Options"]; - final selectedIndex = 0.obs; ProductsController productsController = Get.put(ProductsController()); @override @@ -129,7 +128,8 @@ class _ShortTradeState extends State { itemBuilder: (context, index) { return GestureDetector( onTap: () { - selectedIndex.value = index; + productsController.selectedIndex.value = + index; }, child: Row( children: [ @@ -158,24 +158,32 @@ class _ShortTradeState extends State { height: 700.h, child: TabBarView( children: [ - ActiveCallsTab( - selectedIndex.value == 0 + ActiveCallsTab(productsController + .selectedIndex.value == + 0 + ? productsController + .swingTradeModel + : productsController + .selectedIndex + .value == + 1 ? productsController - .swingTradeModel - : selectedIndex.value == 1 - ? productsController - .multibaggerModel - : productsController - .optionModel), - ExitedCallsTab( - selectedIndex.value == 0 + .multibaggerModel + : productsController + .optionModel), + ExitedCallsTab(productsController + .selectedIndex.value == + 0 + ? productsController + .swingTradeModel + : productsController + .selectedIndex + .value == + 1 ? productsController - .swingTradeModel - : selectedIndex.value == 1 - ? productsController - .multibaggerModel - : productsController - .optionModel), + .multibaggerModel + : productsController + .optionModel), ], ), ), @@ -245,7 +253,7 @@ class _ShortTradeState extends State { itemBuilder: (ctx, index) { return Padding( padding: EdgeInsets.only(top: 20.h, bottom: 5.h), - child: selectedIndex.value == 0 + child: productsController.selectedIndex.value == 0 ? cardSwingWidget( image: callRecommendationsModel .data!.activeCalls![index].stockImage!, @@ -261,8 +269,12 @@ class _ShortTradeState extends State { action: callRecommendationsModel .data!.activeCalls![index].actionData!.name!, ) - : selectedIndex.value == 1 + : productsController.selectedIndex.value == 1 ? cardMultibaggerWidget( + image: callRecommendationsModel + .data!.activeCalls![index].stockImage!, + action: callRecommendationsModel + .data!.activeCalls![index].actionData!.name!, text: callRecommendationsModel .data!.activeCalls![index].stockName!, price: @@ -270,14 +282,34 @@ class _ShortTradeState extends State { date: callRecommendationsModel .data!.activeCalls![index].createdAt!, returns: - "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", + "₹ ${callRecommendationsModel.data!.activeCalls![index].targetPrice}", stoploss: "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", duration: callRecommendationsModel .data!.activeCalls![index].duration!, pdfname: "Download Pdf", ) - : SizedBox(), + : cardOptionWidget( + image: callRecommendationsModel + .data!.activeCalls![index].stockImage!, + action: callRecommendationsModel + .data!.activeCalls![index].actionData!.name!, + text: callRecommendationsModel + .data!.activeCalls![index].stockName!, + optiontype: "test", + price: + "₹ ${callRecommendationsModel.data!.activeCalls![index].buyPrice}", + date: callRecommendationsModel + .data!.activeCalls![index].createdAt!, + premium: + "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", + price1: + "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", + price2: + "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", + stoploss: + "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", + ), ); }); } @@ -319,175 +351,78 @@ class _ShortTradeState extends State { } Widget ExitedCallsTab(CallRecommendationsModel callRecommendationsModel) { - List> cardSwing = [ - { - 'text': 'Indiabulls Housing Finance Ltd', - 'amount': '₹ 196.50 - ₹ 197', - 'targetamount': '₹ 204', - 'stoploss': '₹ 190', - 'time': '4-5 Days', - }, - { - 'text': 'Indiabulls Housing Finance Ltd', - 'amount': '₹ 196.50 - ₹ 197', - 'targetamount': '₹ 204', - 'stoploss': '₹ 190', - 'time': '4-5 Days', - }, - { - 'text': 'Indiabulls Housing Finance Ltd', - 'amount': '₹ 196.50 - ₹ 197', - 'targetamount': '₹ 204', - 'stoploss': '₹ 190', - 'time': '4-5 Days', - }, - ]; - - List> cardMultibagger = [ - { - 'text': 'TATA MOTORS', - 'price': '₹ 453 - ₹234', - 'date': '25 March 2024', - 'returns': '103%', - 'stoploss': '₹ 198', - 'duration': '271 Days', - 'pdfname': 'Download Pdf' - }, - { - 'text': 'TATA MOTORS', - 'price': '₹ 453 - ₹234', - 'date': '25 March 2024', - 'returns': '103%', - 'stoploss': '₹ 198', - 'duration': '271 Days', - 'pdfname': 'Download Pdf' - }, - { - 'text': 'TATA MOTORS', - 'price': '₹ 453 - ₹234', - 'date': '25 March 2024', - 'returns': '103%', - 'stoploss': '₹ 198', - 'duration': '271 Days', - 'pdfname': 'Download Pdf' - }, - ]; - - List> cardOptionsbagger = [ - { - 'text': 'NIFTY/ BANK NIFTY', - 'optiontype': 'Call', - 'price': '₹ 46500', - 'date': '6th Mar', - 'premium': 'Buy above₹ 690', - 'price1': '₹ 740', - 'price2': '₹ 780', - 'stoploss': '₹ 645', - }, - { - 'text': 'NIFTY/ BANK NIFTY', - 'optiontype': 'Call', - 'price': '₹ 46500', - 'date': '6th Mar', - 'premium': 'Buy above₹ 690', - 'price1': '₹ 740', - 'price2': '₹ 780', - 'stoploss': '₹ 645', - }, - { - 'text': 'NIFTY/ BANK NIFTY', - 'optiontype': 'Call', - 'price': '₹ 46500', - 'date': '6th Mar', - 'premium': 'Buy above₹ 690', - 'price1': '₹ 740', - 'price2': '₹ 780', - 'stoploss': '₹ 645', - }, - ]; - - return SingleChildScrollView( - child: Column( - children: [ - sizedBoxHeight(20.h), - Obx(() { - return selectedIndex.value == 0 - ? callRecommendationsModel.data!.exitedCalls!.isEmpty - ? Center( - child: Column( - children: [ - const Gap(200), - text22W600("No Data Available !"), - ], - )) - : ListView.builder( - itemCount: - callRecommendationsModel.data!.exitedCalls!.length, - itemBuilder: (ctx, index) { - return Padding( - padding: EdgeInsets.only(top: 20.h, bottom: 5.h), - child: cardSwingWidget( - image: callRecommendationsModel - .data!.exitedCalls![index].stockImage!, - text: callRecommendationsModel - .data!.exitedCalls![index].stockName!, - amount: '₹ 196.50 - ₹ 197', - targetamount: - '₹ ${callRecommendationsModel.data!.exitedCalls![index].targetPrice}', - stoploss: - '₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}', - time: - '${callRecommendationsModel.data!.exitedCalls![index].duration}', - action: callRecommendationsModel - .data!.exitedCalls![index].actionData!.name!, - ), - ); - }) - : selectedIndex == 1 - ? Column( - children: - List.generate(cardMultibagger.length, (index) { - return Column( - children: [ - cardMultibaggerWidget( - text: cardMultibagger[index]['text']!, - price: cardMultibagger[index]['price']!, - date: cardMultibagger[index]['date']!, - returns: cardMultibagger[index]['returns']!, - stoploss: cardMultibagger[index]['stoploss']!, - duration: cardMultibagger[index]['duration']!, - pdfname: cardMultibagger[index]['pdfname']!), - sizedBoxHeight(20.h) - ], - ); - }), + return callRecommendationsModel.data!.exitedCalls!.isEmpty + ? Center( + child: Column( + children: [ + const Gap(200), + text22W600("No Data Available !"), + ], + )) + : ListView.builder( + itemCount: callRecommendationsModel.data!.exitedCalls!.length, + itemBuilder: (ctx, index) { + return Padding( + padding: EdgeInsets.only(top: 20.h, bottom: 5.h), + child: productsController.selectedIndex.value == 0 + ? cardSwingWidget( + image: callRecommendationsModel + .data!.exitedCalls![index].stockImage!, + text: callRecommendationsModel + .data!.exitedCalls![index].stockName!, + amount: '₹ 196.50 - ₹ 197', + targetamount: + '₹ ${callRecommendationsModel.data!.exitedCalls![index].targetPrice}', + stoploss: + '₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}', + time: + '${callRecommendationsModel.data!.exitedCalls![index].duration}', + action: callRecommendationsModel + .data!.exitedCalls![index].actionData!.name!, ) - : Column( - children: - List.generate(cardMultibagger.length, (index) { - return Column( - children: [ - cardOptionWidget( - text: cardOptionsbagger[index]['text']!, - optiontype: cardOptionsbagger[index] - ['optiontype']!, - price: cardOptionsbagger[index]['price']!, - date: cardOptionsbagger[index]['date']!, - premium: cardOptionsbagger[index]['premium']!, - price1: cardOptionsbagger[index]['price1']!, - price2: cardOptionsbagger[index]['price2']!, - stoploss: cardOptionsbagger[index] - ['stoploss']!), - sizedBoxHeight(20.h) - ], - ); - }), - ); - }), - sizedBoxHeight(200.h) - ], - ), - ); + : productsController.selectedIndex.value == 1 + ? cardMultibaggerWidget( + image: callRecommendationsModel + .data!.exitedCalls![index].stockImage!, + action: callRecommendationsModel + .data!.exitedCalls![index].actionData!.name!, + text: callRecommendationsModel + .data!.exitedCalls![index].stockName!, + price: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].buyPrice}", + date: callRecommendationsModel + .data!.exitedCalls![index].createdAt!, + returns: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].targetPrice}", + stoploss: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}", + duration: callRecommendationsModel + .data!.exitedCalls![index].duration!, + pdfname: "Download Pdf", + ) + : cardOptionWidget( + image: callRecommendationsModel + .data!.exitedCalls![index].stockImage!, + action: callRecommendationsModel + .data!.exitedCalls![index].actionData!.name!, + text: callRecommendationsModel + .data!.exitedCalls![index].stockName!, + optiontype: "test", + price: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].buyPrice}", + date: callRecommendationsModel + .data!.exitedCalls![index].createdAt!, + premium: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}", + price1: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}", + price2: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}", + stoploss: + "₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}", + ), + ); + }); } Widget cardOptionWidget({ @@ -499,6 +434,8 @@ class _ShortTradeState extends State { required String price1, required String price2, required String stoploss, + required String action, + required String image, }) { return commonGlassContainer( width: double.infinity, @@ -534,8 +471,8 @@ class _ShortTradeState extends State { ], ), child: Center( - child: Image.asset( - 'assets/images/png/Group 1000004495.png', + child: CachedNetworkImage( + imageUrl: image, width: 26.w, height: 23.h, ), @@ -551,7 +488,7 @@ class _ShortTradeState extends State { borderRadius: BorderRadius.circular(4.r), color: const Color(0xFFFFAD31), ), - child: Center(child: text14W600_1B1B1B('Hold')), + child: Center(child: text14W600_1B1B1B(action)), ) ], ), @@ -657,6 +594,8 @@ class _ShortTradeState extends State { required String stoploss, required String duration, required String pdfname, + required String action, + required String image, }) { return commonGlassContainer( width: double.infinity, @@ -692,8 +631,8 @@ class _ShortTradeState extends State { ], ), child: Center( - child: Image.asset( - 'assets/images/png/TATAMOTORS.NS_BIG 1.png', + child: CachedNetworkImage( + imageUrl: image, width: 26.w, height: 23.h, ), @@ -707,9 +646,11 @@ class _ShortTradeState extends State { height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), - color: const Color(0xFFFFAD31), + color: action == "Buy" + ? const Color(0xFF00FF19) + : const Color(0xFFFFAD31), ), - child: Center(child: text14W600_1B1B1B('Hold')), + child: Center(child: text14W600_1B1B1B(action)), ) ], ), @@ -742,7 +683,7 @@ class _ShortTradeState extends State { width: 130.w, child: text14W400_979797('Date of recommendation')), sizedBoxHeight(5.h), - text15W600(date) + text15W600(productsController.dateConverterMethod(date)) ], ) ], @@ -753,10 +694,9 @@ class _ShortTradeState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - text14W400_979797('% Return'), + text14W400_979797('Target Price'), sizedBoxHeight(5.h), - SizedBox( - width: 150.w, child: text15W600_00FF19(returns)) + SizedBox(width: 150.w, child: text15W600(returns)) ], ), sizedBoxWidth(30.w), @@ -782,23 +722,23 @@ class _ShortTradeState extends State { ], ), sizedBoxWidth(30.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text14W400_979797('Report'), - sizedBoxHeight(5.h), - Row( - children: [ - Image.asset( - 'assets/images/png/pdf.png', - height: 20.h, - width: 20.w, - ), - text15W600(pdfname), - ], - ) - ], - ) + // Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // text14W400_979797('Report'), + // sizedBoxHeight(5.h), + // Row( + // children: [ + // Image.asset( + // 'assets/images/png/pdf.png', + // height: 20.h, + // width: 20.w, + // ), + // text15W600(pdfname), + // ], + // ) + // ], + // ) ], ), ], @@ -934,7 +874,7 @@ class _ShortTradeState extends State { Widget topContainer(String text, int index) { return Obx(() { - return selectedIndex.value == index + return productsController.selectedIndex.value == index ? Container( height: 40.h, width: 126.w, diff --git a/pubspec.lock b/pubspec.lock index 268c297..0938628 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -117,10 +117,10 @@ packages: dependency: transitive description: name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.18.0" + version: "1.17.2" connectivity_plus: dependency: "direct main" description: @@ -580,10 +580,10 @@ packages: dependency: transitive description: name: intl - sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" url: "https://pub.dev" source: hosted - version: "0.19.0" + version: "0.18.1" js: dependency: transitive description: @@ -636,10 +636,10 @@ packages: dependency: "direct main" description: name: local_auth - sha256: "280421b416b32de31405b0a25c3bd42dfcef2538dfbb20c03019e02a5ed55ed0" + sha256: "27679ed8e0d7daab2357db6bb7076359e083a56b295c0c59723845301da6aed9" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.1.8" local_auth_android: dependency: transitive description: @@ -648,14 +648,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.37" - local_auth_darwin: + local_auth_ios: dependency: transitive description: - name: local_auth_darwin - sha256: "33381a15b0de2279523eca694089393bb146baebdce72a404555d03174ebc1e9" + name: local_auth_ios + sha256: eb283b530029b334698918f1e282d4483737cbca972ff21b9193be3d6de8e2b8 url: "https://pub.dev" source: hosted - version: "1.2.2" + version: "1.1.6" local_auth_platform_interface: dependency: transitive description: @@ -700,10 +700,10 @@ packages: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.9.1" mime: dependency: transitive description: @@ -985,18 +985,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.11.0" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.1" string_scanner: dependency: transitive description: @@ -1081,10 +1081,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.6.0" typed_data: dependency: transitive description: @@ -1290,10 +1290,10 @@ packages: dependency: transitive description: name: web - sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 url: "https://pub.dev" source: hosted - version: "0.3.0" + version: "0.1.4-beta" win32: dependency: transitive description: @@ -1319,5 +1319,5 @@ packages: source: hosted version: "6.3.0" sdks: - dart: ">=3.2.3 <4.0.0" - flutter: ">=3.16.6" + dart: ">=3.1.0 <4.0.0" + flutter: ">=3.13.0" From b1474f1694b0c615b28dcb067cba402a963b57f6 Mon Sep 17 00:00:00 2001 From: jayesh Date: Fri, 3 May 2024 19:05:34 +0530 Subject: [PATCH 2/3] product recommendations api integration - pending --- lib/model/ProductsModel/call_recommendations_model.dart | 8 ++++---- lib/view/MainScreen/ShortTrade.dart | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/model/ProductsModel/call_recommendations_model.dart b/lib/model/ProductsModel/call_recommendations_model.dart index 47c1dd0..6243b70 100644 --- a/lib/model/ProductsModel/call_recommendations_model.dart +++ b/lib/model/ProductsModel/call_recommendations_model.dart @@ -68,10 +68,10 @@ class ActiveCalls { String? stockImage; String? qty; String? duration; - int? currentPrice; - int? buyPrice; - int? targetPrice; - int? stopLoss; + String? currentPrice; + String? buyPrice; + String? targetPrice; + String? stopLoss; int? isSendRecommendationNow; Null? scheduleDateTime; String? createdAt; diff --git a/lib/view/MainScreen/ShortTrade.dart b/lib/view/MainScreen/ShortTrade.dart index 503b5f2..e45991b 100644 --- a/lib/view/MainScreen/ShortTrade.dart +++ b/lib/view/MainScreen/ShortTrade.dart @@ -155,7 +155,7 @@ class _ShortTradeState extends State { children: [ MyTabBar(), SizedBox( - height: 700.h, + height: 0.57.sh, child: TabBarView( children: [ ActiveCallsTab(productsController From 2b564aa57fe711825bce696d5510e0b275ad6753 Mon Sep 17 00:00:00 2001 From: jayesh Date: Tue, 7 May 2024 19:27:23 +0530 Subject: [PATCH 3/3] product recommendations api integration, content bytes --- lib/Utils/Common/CustomTextFormField.dart | 1 + lib/Utils/api_urls.dart | 2 + lib/controller/contact_us_controller.dart | 12 + lib/controller/content_bytes_controller.dart | 51 +- .../content_bytes_model.dart | 169 ++++- .../previous_read_user_model.dart | 110 ++++ .../call_recommendations_model.dart | 31 +- lib/view/MainScreen/ShortTrade.dart | 41 +- lib/view/Sidemenu/ContentByte/AudioMore.dart | 408 ++++++++---- .../Sidemenu/ContentByte/ContentBytes.dart | 620 +++++++++++------- lib/view/Sidemenu/ContentByte/ReadMore.dart | 156 ++--- lib/view/Sidemenu/ContentByte/VideosMore.dart | 131 ++-- lib/view/Sidemenu/ContentByte/read_pdf.dart | 2 +- .../ContentBytesApi/content_bytes_api.dart | 38 ++ pubspec.lock | 82 ++- pubspec.yaml | 1 + 16 files changed, 1281 insertions(+), 574 deletions(-) create mode 100644 lib/model/ContentBytesModel/previous_read_user_model.dart diff --git a/lib/Utils/Common/CustomTextFormField.dart b/lib/Utils/Common/CustomTextFormField.dart index 5744920..119f621 100644 --- a/lib/Utils/Common/CustomTextFormField.dart +++ b/lib/Utils/Common/CustomTextFormField.dart @@ -94,6 +94,7 @@ class _CustomTextFormFieldState extends State { obscureText: obscureText, controller: widget.textEditingController, decoration: InputDecoration( + hintStyle: TextStyle(color: Colors.white), hintText: widget.hintText, prefixIconColor: widget.prefixIconColor, // ignore: prefer_null_aware_operators diff --git a/lib/Utils/api_urls.dart b/lib/Utils/api_urls.dart index c4f6719..a253d02 100644 --- a/lib/Utils/api_urls.dart +++ b/lib/Utils/api_urls.dart @@ -49,6 +49,8 @@ class ApiUrls { "${base}getContentByteCategories"; static String getContentBytesApi = "${base}getContentBytes"; static String morevideoApi = "${base}get-content-bytes-of-videos"; + static String getPreviousReadApi = "${base}get-previous-reads-of-user"; + static String storeReadCountApi = "${base}store-content-byte-read-click"; //Profile static String Getprofile = "${base}getuserDetails"; diff --git a/lib/controller/contact_us_controller.dart b/lib/controller/contact_us_controller.dart index ed7377e..a530f58 100644 --- a/lib/controller/contact_us_controller.dart +++ b/lib/controller/contact_us_controller.dart @@ -4,6 +4,7 @@ import 'package:get/get.dart'; import 'package:traderscircuit/model/ContactUsModel/contact_us_cat_model.dart'; import 'package:traderscircuit/model/ContactUsModel/contact_us_model.dart'; +import 'package:timeago/timeago.dart' as timeago; import '../model/ContactUsModel/ticket_details_model.dart'; import 'package:intl/intl.dart'; @@ -35,4 +36,15 @@ class ContactUsController extends GetxController { return DateFormat("dd MMM yyyy, hh:mm a").format(dateTime.toLocal()); } + + String timeAgoConverter(String originalDateTimeString) { + DateTime dateTime = DateTime.parse(originalDateTimeString); + + // Get the difference in days + DateTime now = DateTime.now(); + int differenceInDays = now.difference(dateTime).inDays; + + // Convert to "2 days ago" format + return timeago.format(now.subtract(Duration(days: differenceInDays))); + } } diff --git a/lib/controller/content_bytes_controller.dart b/lib/controller/content_bytes_controller.dart index 0b94ad5..bfb083f 100644 --- a/lib/controller/content_bytes_controller.dart +++ b/lib/controller/content_bytes_controller.dart @@ -1,9 +1,12 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:just_audio/just_audio.dart'; import 'package:traderscircuit/model/ContentBytesModel/content_bytes_categories_model.dart'; import 'package:traderscircuit/model/ContentBytesModel/content_bytes_model.dart'; +import '../model/ContentBytesModel/previous_read_user_model.dart'; import '../view/Sidemenu/ContentByte/ContentBytes.dart'; class ContentBytesController extends GetxController { @@ -11,12 +14,15 @@ class ContentBytesController extends GetxController { ContentBytesCategoriesModel contentBytesCategoriesModel = ContentBytesCategoriesModel(); ContentBytesModel contentBytesModel = ContentBytesModel(); + + PreviousReadOfUserModel previousReadOfUserModel = PreviousReadOfUserModel(); int filterId = 0; RxBool isApiCalling = true.obs; RxBool isAudioSeekBarVisible = false.obs; RxInt indexForAudios = 0.obs; RxBool titlePlaying = false.obs; RxList? titlePlayingList = [].obs; + bool isAudioInitialize = false; final progressNotifier = ValueNotifier( ProgressBarState( @@ -27,22 +33,21 @@ class ContentBytesController extends GetxController { ); final buttonNotifier = ValueNotifier(ButtonState.paused); - late AudioPlayer _audioPlayer; + late AudioPlayer audioPlayer; @override void dispose() { - _audioPlayer.stop(); + audioPlayer.stop(); super.dispose(); } - void getAudio() => _audioPlayer; - void init(index) async { - _audioPlayer = AudioPlayer(); + audioPlayer = AudioPlayer(); + isAudioInitialize = true; + indexForAudios.value = index; try { - await _audioPlayer.setUrl( - //contentBytesModel.data!.audio![index].file ?? - 'https://ghantalele.com/uploads/files/data-78/38825/Besharam%20Rang_192(Ghantalele.com).mp3'); - // await _audioPlayer.setAsset(url); + log(index.toString()); + await audioPlayer.setUrl(contentBytesModel.data!.audio![index].link!); + // await audioPlayer.setAsset(url); } on PlayerException catch (e) { print("Error code: ${e.code}"); // iOS/macOS: maps to NSError.localizedDescription @@ -52,7 +57,7 @@ class ContentBytesController extends GetxController { print("Error message: ${e.message}"); } //Catching errors during playback (e.g. lost network connection) - _audioPlayer.playbackEventStream.listen((event) {}, + audioPlayer.playbackEventStream.listen((event) {}, onError: (Object e, StackTrace st) { if (e is PlayerException) { print('Error code: ${e.code}'); @@ -62,7 +67,7 @@ class ContentBytesController extends GetxController { } }); - _audioPlayer.playerStateStream.listen((playerState) { + audioPlayer.playerStateStream.listen((playerState) { final isPlaying = playerState.playing; final processingState = playerState.processingState; if (!isPlaying) { @@ -72,12 +77,12 @@ class ContentBytesController extends GetxController { } else { _playNextTrack(); - // _audioPlayer.seek(Duration.zero); - // _audioPlayer.pause(); + // audioPlayer.seek(Duration.zero); + // audioPlayer.pause(); } }); - _audioPlayer.positionStream.listen((position) { + audioPlayer.positionStream.listen((position) { final oldState = progressNotifier.value; progressNotifier.value = ProgressBarState( current: position, @@ -86,7 +91,7 @@ class ContentBytesController extends GetxController { ); }); - _audioPlayer.bufferedPositionStream.listen((bufferedPosition) { + audioPlayer.bufferedPositionStream.listen((bufferedPosition) { final oldState = progressNotifier.value; progressNotifier.value = ProgressBarState( current: oldState.current, @@ -95,7 +100,7 @@ class ContentBytesController extends GetxController { ); }); - _audioPlayer.durationStream.listen((totalDuration) { + audioPlayer.durationStream.listen((totalDuration) { final oldState = progressNotifier.value; progressNotifier.value = ProgressBarState( current: oldState.current, @@ -118,8 +123,8 @@ class ContentBytesController extends GetxController { init(nextIndex); play(nextIndex); } else { - _audioPlayer.seek(Duration.zero); - _audioPlayer.pause(); + audioPlayer.seek(Duration.zero); + audioPlayer.pause(); } } @@ -138,26 +143,26 @@ class ContentBytesController extends GetxController { } void play(index) { - _audioPlayer.play(); + audioPlayer.play(); isAudioSeekBarVisible.value = false; isAudioSeekBarVisible.value = true; indexForAudios.value = index; } void pause() { - _audioPlayer.pause(); + audioPlayer.pause(); } void seek(Duration position) { - _audioPlayer.seek(position); + audioPlayer.seek(position); } void stop() { - _audioPlayer.stop(); + audioPlayer.stop(); } bool isPlaying() { - return _audioPlayer.playing; + return audioPlayer.playing; } addTitles() { diff --git a/lib/model/ContentBytesModel/content_bytes_model.dart b/lib/model/ContentBytesModel/content_bytes_model.dart index 22a9d20..b830c8a 100644 --- a/lib/model/ContentBytesModel/content_bytes_model.dart +++ b/lib/model/ContentBytesModel/content_bytes_model.dart @@ -29,8 +29,16 @@ class Data { List