import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:gap/gap.dart'; import 'package:get/get.dart'; import 'package:glassmorphism/glassmorphism.dart'; import 'package:traderscircuit/Utils/Common/CommonBottomNavigation.dart'; import 'package:traderscircuit/Utils/Common/CommonTabBar.dart'; import 'package:traderscircuit/Utils/Common/commonBotton.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/Utils/utils.dart'; import 'package:traderscircuit/controller/contact_us_controller.dart'; import 'package:traderscircuit/controller/products_controller.dart'; import 'package:traderscircuit/model/ProductsModel/call_recommendations_model.dart'; import 'package:traderscircuit/view/MainScreen/MainScreen.dart'; import 'package:traderscircuit/view/Sidemenu/Sidemenu.dart'; import 'package:traderscircuit/view/onBoarding/splashScreen1.dart'; import 'package:traderscircuit/view_model/ProductsApi/products_api.dart'; class ShortTrade extends StatefulWidget { const ShortTrade({super.key}); @override State createState() => _ShortTradeState(); } class _ShortTradeState extends State { final GlobalKey _scaffoldKey1 = GlobalKey(); List containerTexts = ["Swing Trade", "Multibagger", "Options"]; ProductsController productsController = Get.put(ProductsController()); @override void initState() { productsController.isLoaded.value = true; ProductsApi().getSwingTradeRecommendationsApi().then((value) { productsController.swingTradeModel = CallRecommendationsModel.fromJson(value.data); ProductsApi().getMultibaggerRecommendationsApi().then((value) { productsController.multibaggerModel = CallRecommendationsModel.fromJson(value.data); ProductsApi().getOptionsRecommendationsApi().then((value) { productsController.optionModel = CallRecommendationsModel.fromJson(value.data); productsController.isLoaded.value = false; }); }); }); super.initState(); } @override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { _onBackButtonPressed(context); return true; // Return true to allow the pop action }, child: Scaffold( key: _scaffoldKey1, backgroundColor: Colors.black, drawerEnableOpenDragGesture: false, drawer: const SideMenu(), extendBody: true, appBar: AppBar( scrolledUnderElevation: 0.0, backgroundColor: Colors.black, elevation: 0, automaticallyImplyLeading: false, titleSpacing: 0, leading: InkWell( onTap: () { _scaffoldKey1.currentState?.openDrawer(); }, child: Center( child: Image.asset( 'assets/images/png/menu.png', height: 15.h, width: 20.w, ), ), ), // title: text22W600('Short'), ), // CommonAppbar( // titleTxt: '', // // preferredSize: Size.fromHeight(60.h), // showLeading: false, // customleading: InkWell( // onTap: () { // _scaffoldKey1.currentState?.openDrawer(); // }, // child: Center( // child: Image.asset( // 'assets/images/png/menu.png', // height: 15.h, // width: 20.w, // ), // ), // // Icon( // // Icons.menu, // // color: Colors.white, // // size: 27.sp, // // ), // ), // ), body: Obx( () => Stack( children: [ const CommonBlurLeft(), const CommonBlurRight(), Stack(children: [ Padding( padding: const EdgeInsets.symmetric( horizontal: 16, vertical: 16), child: ListView( physics: const NeverScrollableScrollPhysics(), children: [ sizedBoxHeight(15.h), SizedBox( height: 60, width: double.infinity, // color: Colors.amber, child: ListView.builder( shrinkWrap: true, scrollDirection: Axis.horizontal, itemCount: containerTexts.length, itemBuilder: (context, index) { return GestureDetector( onTap: () { productsController.selectedIndex.value = index; }, child: Row( children: [ topContainer( containerTexts[index], index), sizedBoxWidth(10.w) ], ), ); }), ), sizedBoxHeight(20.h), productsController.isLoaded.value ? const Center( child: CircularProgressIndicator( color: Color(0xFF0093FF), ), ) : DefaultTabController( length: 2, // initialIndex: selectedIndex.value, child: Column( children: [ MyTabBar(), SizedBox( height: 0.57.sh, child: TabBarView( children: [ ActiveCallsTab(productsController .selectedIndex.value == 0 ? productsController .swingTradeModel : productsController .selectedIndex .value == 1 ? productsController .multibaggerModel : productsController .optionModel), ExitedCallsTab(productsController .selectedIndex.value == 0 ? productsController .swingTradeModel : productsController .selectedIndex .value == 1 ? productsController .multibaggerModel : productsController .optionModel), ], ), ), ], ), ), sizedBoxHeight(20.h), ])) ]) ], ), ), bottomNavigationBar: bottomnavigationbar(mainController), ), ); } Future _onBackButtonPressed(BuildContext context) async { bool? exitApp = await showDialog( context: context, builder: (context) { return AlertDialog( backgroundColor: const Color(0xFFFFF3E4), title: const Text('Exit App'), content: const Text('Do you really want to close the app?'), actions: [ TextButton( onPressed: () { Navigator.of(context).pop(false); }, child: const Text( 'No', style: TextStyle( color: Color(0xff1B243D), ), ), ), TextButton( onPressed: () { SystemNavigator.pop(); Navigator.pop(context); }, child: const Text( 'Yes', style: TextStyle( color: Color(0xff1B243D), ), ), ) ], ); }); return exitApp ?? false; } Widget ActiveCallsTab(CallRecommendationsModel callRecommendationsModel) { return callRecommendationsModel.data!.activeCalls!.isEmpty ? Center( child: Column( children: [ const Gap(200), text22W600("No Data Available !"), ], )) : ListView.builder( itemCount: callRecommendationsModel.data!.activeCalls!.length, itemBuilder: (ctx, index) { return Padding( padding: EdgeInsets.only(top: 20.h, bottom: 5.h), child: productsController.selectedIndex.value == 0 ? cardSwingWidget( pdfLink: "", image: callRecommendationsModel .data!.activeCalls![index].stockImage!, text: callRecommendationsModel .data!.activeCalls![index].stockName!, amount: '₹ 196.50 - ₹ 197', targetamount: '₹ ${callRecommendationsModel.data!.activeCalls![index].targetPrice}', stoploss: '₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}', time: '${callRecommendationsModel.data!.activeCalls![index].duration}', action: callRecommendationsModel .data!.activeCalls![index].actionData!.name!, ) : 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: "₹ ${callRecommendationsModel.data!.activeCalls![index].buyPrice}", date: callRecommendationsModel .data!.activeCalls![index].createdAt!, returns: "₹ ${callRecommendationsModel.data!.activeCalls![index].targetPrice}", stoploss: "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", duration: callRecommendationsModel .data!.activeCalls![index].duration!, pdfname: "Download Pdf", pdfLink: "", ) : cardOptionWidget( pdfLink: "", image: callRecommendationsModel .data!.activeCalls![index].stockImage!, action: callRecommendationsModel .data!.activeCalls![index].actionData!.name!, text: callRecommendationsModel .data!.activeCalls![index].stockName!, optiontype: callRecommendationsModel.data! .activeCalls![index].optionTypeData!.name!, price: "₹ ${callRecommendationsModel.data!.activeCalls![index].buyPrice}", date: callRecommendationsModel .data!.activeCalls![index].createdAt!, premium: "₹ ${callRecommendationsModel.data!.activeCalls![index].currentPrice}", price1: "₹ ${callRecommendationsModel.data!.activeCalls![index].targetPrice}", stoploss: "₹ ${callRecommendationsModel.data!.activeCalls![index].stopLoss}", ), ); }); } void _unlockbottomsheet() { Get.bottomSheet( commonGlassContainer( width: double.infinity, height: 439.h, borderradius: 4, customWidget: Center( child: Padding( padding: EdgeInsets.symmetric(horizontal: 35.w), child: Column( children: [ sizedBoxHeight(50.h), // Image.asset( // 'assets/images/png/Group 1000003722.png', // height: 100.h, // ), // sizedBoxHeight(25.h), text20W400('Please subscribed to unlock'), sizedBoxHeight(30.h), CommonBtn( text: 'Subscribe Now', onTap: () {}, ), const SizedBox( height: 100, ) ], ), ), ), ), backgroundColor: Colors.black.withOpacity(0.3), ); } Widget ExitedCallsTab(CallRecommendationsModel callRecommendationsModel) { 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( pdfLink: callRecommendationsModel .data!.exitedCalls![index].docs!, 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!, ) : 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", pdfLink: callRecommendationsModel .data!.exitedCalls![index].docs!, ) : cardOptionWidget( pdfLink: callRecommendationsModel .data!.exitedCalls![index].docs!, image: callRecommendationsModel .data!.exitedCalls![index].stockImage!, action: callRecommendationsModel .data!.exitedCalls![index].actionData!.name!, text: callRecommendationsModel .data!.exitedCalls![index].stockName!, optiontype: callRecommendationsModel.data! .exitedCalls![index].optionTypeData!.name!, price: "₹ ${callRecommendationsModel.data!.exitedCalls![index].buyPrice}", date: callRecommendationsModel .data!.exitedCalls![index].createdAt!, premium: "₹ ${callRecommendationsModel.data!.exitedCalls![index].currentPrice}", price1: "₹ ${callRecommendationsModel.data!.exitedCalls![index].targetPrice}", stoploss: "₹ ${callRecommendationsModel.data!.exitedCalls![index].stopLoss}", ), ); }); } Widget cardOptionWidget({ required String text, required String optiontype, required String price, required String date, required String premium, required String price1, required String stoploss, required String action, required String pdfLink, required String image, }) { ContactUsController contactUsController = Get.put(ContactUsController()); return commonGlassContainer( width: double.infinity, height: action != "Exit" ? 330.h : 380.h, borderradius: 8, customWidget: Column( children: [ Padding( padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 16.w), child: Row( children: [ GlassmorphicContainer( width: 47.w, height: 47.h, borderRadius: 100, blur: 10, alignment: Alignment.center, border: 0.9, linearGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color(0xff3A3A3A), Color(0xFF3A3A3A), ], ), borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color.fromRGBO(70, 5, 1, 0.8), Color.fromRGBO(102, 102, 102, 0.8), ], ), child: Center( child: CachedNetworkImage( imageUrl: image, width: 26.w, height: 23.h, ), ), ), sizedBoxWidth(15.w), SizedBox(width: 200.w, child: text18W600(text)), const Spacer(), Container( width: 62.w, height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), color: action == "Buy" ? const Color(0xFF00FF19) : action == "Exit" ? const Color(0Xff6C0000) : const Color(0xFFFFAD31), ), child: Center( child: text14W600_1B1B1B(action, clr: action == "Exit" ? Colors.white : const Color(0Xff1B1B1B))), ) ], ), ), Container( width: double.infinity, height: 1.h, color: const Color(0xFF3A3A3A), ), Padding( padding: const EdgeInsets.all(18), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Option Type'), sizedBoxHeight(5.h), SizedBox(width: 150.w, child: text15W600(optiontype)) ], ), sizedBoxWidth(30.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Strike Price'), sizedBoxHeight(5.h), text15W600(price) ], ) ], ), sizedBoxHeight(15.h), Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Expiry Date'), sizedBoxHeight(5.h), SizedBox( width: 150.w, child: text15W600( productsController.dateConverterMethod(date))) ], ), sizedBoxWidth(30.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Premium'), sizedBoxHeight(5.h), text15W600(premium) ], ) ], ), sizedBoxHeight(15.h), Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Target Price'), sizedBoxHeight(5.h), SizedBox(width: 150.w, child: text15W600(price1)) ], ), sizedBoxWidth(30.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Stop Loss'), sizedBoxHeight(5.h), text15W600(stoploss) ], ) ], ), sizedBoxHeight(15.h), action != "Exit" ? const SizedBox() : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Report'), sizedBoxHeight(5.h), GestureDetector( onTap: () { Utils.openFile( url: pdfLink, fileName: "${text}_report.pdf"); }, child: Row( children: [ Image.asset( 'assets/images/png/pdf.png', height: 20.h, width: 20.w, ), text15W600("Download Pdf"), ], ), ) ], ) ], ), ) ], ), ); } Widget cardMultibaggerWidget({ required String text, required String price, required String date, required String returns, required String stoploss, required String duration, required String pdfname, required String action, required String pdfLink, required String image, }) { return commonGlassContainer( width: double.infinity, height: 360.h, borderradius: 8, customWidget: Column( children: [ Padding( padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 16.w), child: Row( children: [ GlassmorphicContainer( width: 47.w, height: 47.h, borderRadius: 100, blur: 10, alignment: Alignment.center, border: 0.9, linearGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color(0xff3A3A3A), Color(0xFF3A3A3A), ], ), borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color.fromRGBO(70, 5, 1, 0.8), Color.fromRGBO(102, 102, 102, 0.8), ], ), child: Center( child: CachedNetworkImage( imageUrl: image, width: 26.w, height: 23.h, ), ), ), sizedBoxWidth(15.w), SizedBox(width: 200.w, child: text18W600(text)), const Spacer(), Container( width: 62.w, height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), color: action == "Buy" ? const Color(0xFF00FF19) : action == "Exit" ? const Color(0Xff6C0000) : const Color(0xFFFFAD31), ), child: Center( child: text14W600_1B1B1B(action, clr: action == "Exit" ? Colors.white : const Color(0Xff1B1B1B))), ) ], ), ), Container( width: double.infinity, height: 1.h, color: const Color(0xFF3A3A3A), ), Padding( padding: const EdgeInsets.all(18), child: Column( children: [ Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Initial Entry Price'), sizedBoxHeight(5.h), SizedBox(width: 150.w, child: text15W600(price)) ], ), sizedBoxWidth(30.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( width: 130.w, child: text14W400_979797('Date of recommendation')), sizedBoxHeight(5.h), text15W600(productsController.dateConverterMethod(date)) ], ) ], ), sizedBoxHeight(15.h), Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Target Price'), sizedBoxHeight(5.h), SizedBox(width: 150.w, child: text15W600(returns)) ], ), sizedBoxWidth(30.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Stop Loss'), sizedBoxHeight(5.h), text15W600(stoploss) ], ) ], ), sizedBoxHeight(15.h), Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Duration'), sizedBoxHeight(5.h), SizedBox(width: 150.w, child: text15W600(duration)) ], ), sizedBoxWidth(30.w), action != "Exit" ? const SizedBox() : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Report'), sizedBoxHeight(5.h), GestureDetector( onTap: () { Utils.openFile( url: pdfLink, fileName: "${text}_report.pdf"); }, child: Row( children: [ Image.asset( 'assets/images/png/pdf.png', height: 20.h, width: 20.w, ), text15W600(pdfname), ], ), ) ], ) ], ), ], ), ) ], ), ); } Widget cardSwingWidget({ required String image, required String text, required String amount, required String targetamount, required String stoploss, required String time, required String pdfLink, required String action, }) { return commonGlassContainer( width: double.infinity, height: action != "Exit" ? 250.h : 300.h, borderradius: 8, customWidget: Column( children: [ Padding( padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 16.w), child: Row( children: [ GlassmorphicContainer( width: 47.w, height: 47.h, borderRadius: 100, blur: 10, alignment: Alignment.center, border: 0.9, linearGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color(0xff3A3A3A), Color(0xFF3A3A3A), ], ), borderGradient: const LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ Color.fromRGBO(70, 5, 1, 0.8), Color.fromRGBO(102, 102, 102, 0.8), ], ), child: Center( child: CachedNetworkImage(imageUrl: image), ), ), sizedBoxWidth(15.w), SizedBox(width: 200.w, child: text18W600(text)), const Spacer(), Container( width: 62.w, height: 25.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4.r), color: action == "Buy" ? const Color(0xFF00FF19) : action == "Exit" ? const Color(0Xff6C0000) : const Color(0xFFFFAD31), ), child: Center( child: text14W600_1B1B1B( action, clr: action == "Exit" ? Colors.white : const Color(0Xff1B1B1B), )), ) ], ), ), Container( width: double.infinity, height: 1.h, color: const Color(0xFF3A3A3A), ), Padding( padding: const EdgeInsets.all(20), child: Column( children: [ Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Entry Price'), sizedBoxHeight(5.h), SizedBox(width: 150.w, child: text15W600(amount)) ], ), sizedBoxWidth(50.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Target Price'), sizedBoxHeight(5.h), text15W600(targetamount) ], ) ], ), sizedBoxHeight(15.h), Row( children: [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Stop Loss'), sizedBoxHeight(5.h), SizedBox(width: 150.w, child: text15W600(stoploss)) ], ), sizedBoxWidth(50.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Time Horizon'), sizedBoxHeight(5.h), text15W600(time) ], ) ], ), sizedBoxHeight(15.h), action != "Exit" ? const SizedBox() : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ text14W400_979797('Report'), sizedBoxHeight(5.h), GestureDetector( onTap: () { Utils.openFile( url: pdfLink, fileName: "${text}_report.pdf"); }, child: Row( children: [ Image.asset( 'assets/images/png/pdf.png', height: 20.h, width: 20.w, ), text15W600("Download Pdf"), ], ), ) ], ) ], ), ) ], ), ); } Widget topContainer(String text, int index) { return Obx(() { return productsController.selectedIndex.value == index ? Container( height: 40.h, width: 126.w, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), color: const Color(0Xff0093FF), ), child: Center(child: text16W500(text)), ) : commonGlassContainer( width: 126.w, height: 40.h, borderradius: 5, customWidget: Center(child: text16W400(text)), ); }); } }