2024-04-08 15:05:50 +05:30
import ' dart:async ' ;
import ' dart:convert ' ;
2024-06-18 10:36:24 +05:30
import ' dart:developer ' ;
2024-04-08 15:05:50 +05:30
import ' package:async/async.dart ' ;
2024-03-22 16:55:59 +05:30
import ' package:flutter/material.dart ' ;
2024-04-16 16:43:11 +05:30
import ' package:flutter/services.dart ' ;
2024-03-22 16:55:59 +05:30
import ' package:flutter_screenutil/flutter_screenutil.dart ' ;
import ' package:get/get.dart ' ;
2024-06-18 10:36:24 +05:30
import ' package:glassmorphism/glassmorphism.dart ' ;
2024-03-22 16:55:59 +05:30
import ' package:lottie/lottie.dart ' ;
2024-04-08 15:05:50 +05:30
import ' package:scgateway_flutter_plugin/scgateway_flutter_plugin.dart ' ;
2024-03-22 16:55:59 +05:30
import ' package:traderscircuit/Utils/Common/CommonBottomNavigation.dart ' ;
import ' package:traderscircuit/Utils/Common/commonBotton.dart ' ;
2024-06-18 10:36:24 +05:30
import ' package:traderscircuit/Utils/Common/sized_box.dart ' ;
2024-03-22 16:55:59 +05:30
import ' package:traderscircuit/Utils/text.dart ' ;
import ' package:traderscircuit/view/MainScreen/MainScreen.dart ' ;
import ' package:traderscircuit/view/Sidemenu/Sidemenu.dart ' ;
import ' package:traderscircuit/view/onBoarding/splashScreen1.dart ' ;
2024-06-18 10:36:24 +05:30
import ' ../../../Utils/Common/comonGlassmorphicContainer.dart ' ;
2024-04-08 15:05:50 +05:30
import ' ../../../model/SmallCaseModel/broker_account_model.dart ' ;
import ' ../../../view_model/SmallCaseApi/smallcase_api_methods.dart ' ;
2024-06-19 17:47:24 +05:30
int selectedTabIndex = 0 ;
2024-03-22 16:55:59 +05:30
class Portfolio extends StatefulWidget {
const Portfolio ( { super . key } ) ;
@ override
State < Portfolio > createState ( ) = > _PortfolioState ( ) ;
}
class _PortfolioState extends State < Portfolio > {
2024-06-18 10:36:24 +05:30
final GlobalKey < ScaffoldState > _scaffoldKey1 = GlobalKey < ScaffoldState > ( ) ;
2024-03-22 16:55:59 +05:30
final selectedIndex = 0. obs ;
2024-06-18 10:36:24 +05:30
RxBool noBrokerAvailable = true . obs ;
2024-04-08 15:05:50 +05:30
FutureGroup fetchUserIdAndBrokerAccounts = FutureGroup ( ) ;
2024-06-18 10:36:24 +05:30
List < Data > myBrokerAccounts = [ ] ;
2024-04-08 15:05:50 +05:30
@ override
void initState ( ) {
fetchUserIdAndBrokerAccounts . add ( fetchBrokerAccounts ( ) ) ;
fetchUserIdAndBrokerAccounts . close ( ) ;
2024-06-18 10:36:24 +05:30
fetchUserIdAndBrokerAccounts . future . then ( ( value ) {
2024-06-19 17:47:24 +05:30
// log(value.toString());
2024-06-18 10:36:24 +05:30
try {
myBrokerAccounts = value [ 0 ] as List < Data > ;
} catch ( e ) { }
debugPrint ( " myBrokerAccounts.length ${ myBrokerAccounts . length } " ) ;
if ( myBrokerAccounts . isEmpty ) {
noBrokerAvailable . value = true ;
} else {
2024-06-19 17:47:24 +05:30
fetchHoldingForDB ( myBrokerAccounts [ 1 ] . brokerName ! ) . then ( ( value ) {
noBrokerAvailable . value = false ;
} ) ;
2024-06-18 10:36:24 +05:30
}
} ) ;
2024-04-08 15:05:50 +05:30
super . initState ( ) ;
}
2024-06-18 10:36:24 +05:30
Widget holdings ( ) {
return Obx ( ( ) {
WidgetsBinding . instance . addPostFrameCallback ( ( _ ) {
if ( selectedIndex . value = = 1 ) _unlockbottomsheet ( ) ;
} ) ;
return selectedIndex . value = = 0
? Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
sizedBoxHeight ( 25. h ) ,
GestureDetector (
onTap: ( ) {
2024-06-19 17:47:24 +05:30
log ( myBrokerAccounts [ selectedTabIndex ] . brokerName ! ) ;
2024-06-18 10:36:24 +05:30
ScgatewayFlutterPlugin . setConfigEnvironment (
GatewayEnvironment . PRODUCTION ,
' traderscircuit ' ,
false ,
2024-06-19 17:47:24 +05:30
[
myBrokerAccounts . elementAt ( selectedTabIndex ) . brokerName !
] ,
2024-06-18 10:36:24 +05:30
) ;
fetchHoldingsImportTxnId ( myBrokerAccounts
2024-06-19 17:47:24 +05:30
. elementAt ( selectedTabIndex )
2024-06-18 10:36:24 +05:30
. authToken ! )
. then ( ( txnIdResponse ) {
if ( txnIdResponse ! = " Failed " ) {
fetchHoldingsImportTxnId ( myBrokerAccounts
2024-06-19 17:47:24 +05:30
. elementAt ( selectedTabIndex )
2024-06-18 10:36:24 +05:30
. authToken ! )
. then ( ( txnIdResponse ) {
debugPrint ( ' SESSION STARTED ' ) ;
debugPrint (
2024-06-19 17:47:24 +05:30
' AUTH TOKEN: ${ myBrokerAccounts . elementAt ( selectedTabIndex ) . authToken ! } ' ) ;
2024-06-18 10:36:24 +05:30
String txnId = txnIdResponse ;
debugPrint ( ' TXN ID $ txnId ' ) ;
ScgatewayFlutterPlugin . triggerGatewayTransaction (
txnId )
. then (
( txnRes ) {
debugPrint ( ' TXN RES $ txnRes ' ) ;
if ( txnRes ! = null ) {
fetchHoldings (
//holdingsAuthToken
myBrokerAccounts
2024-06-19 17:47:24 +05:30
. elementAt ( selectedTabIndex )
2024-06-18 10:36:24 +05:30
. authToken ! )
. then (
( holdings ) {
setState ( ( ) { } ) ;
} ,
) ;
}
} ,
) ;
} ) ;
} else {
debugPrint ( ' SESSION EXPIRED ' ) ;
onTxnTimeout ( ) ;
}
} ) ;
} ,
child: Align (
alignment: Alignment . centerRight ,
child: Container (
width: 180 ,
padding: const EdgeInsets . all ( 8 ) ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 12 ) ,
color: const Color ( 0xff6C0000 ) ,
) ,
2024-06-19 17:47:24 +05:30
child: Center ( child: text15W600 ( " Refresh Stock's " ) ) ,
2024-06-18 10:36:24 +05:30
) ,
) ,
) ,
sizedBoxHeight ( 25. h ) ,
Table (
children: [
TableRow (
children: [
TableCell (
child: Text (
" Stock Name " ,
textAlign: TextAlign . center ,
style: TextStyle (
fontSize: 16. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
) ,
) ,
TableCell (
child: Text (
" AVG Price " ,
textAlign: TextAlign . center ,
style: TextStyle (
fontSize: 16. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
) ,
) ,
TableCell (
child: Text (
" Quantity " ,
textAlign: TextAlign . center ,
style: TextStyle (
fontSize: 16. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
) ,
) ,
] ,
) ,
] ,
) ,
const Divider (
color: Color ( 0xFF3A3A3A ) ,
) ,
Expanded (
child: ListView . separated (
physics: const BouncingScrollPhysics ( ) ,
shrinkWrap: true ,
itemCount: 16 ,
itemBuilder: ( ( context , index ) {
return Table (
children: [
TableRow (
children: [
TableCell (
child: Text (
" TATA MOTORS " ,
textAlign: TextAlign . center ,
style: TextStyle (
fontSize: 16. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
) ,
) ,
TableCell (
child: Text (
" 416.66 " ,
textAlign: TextAlign . center ,
style: TextStyle (
fontSize: 16. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
) ,
) ,
TableCell (
child: Text (
" 3 " ,
textAlign: TextAlign . center ,
style: TextStyle (
fontSize: 16. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
) ,
) ,
] ,
) ,
] ,
) ;
} ) ,
separatorBuilder: ( BuildContext context , int index ) {
return const Divider ( ) ;
} ,
) ,
) ,
SizedBox (
height: 30. h ,
)
] ,
)
2024-06-19 17:47:24 +05:30
: selectedIndex . value = = 1
2024-06-18 10:36:24 +05:30
? const Column (
children: [ ] ,
)
: const Column (
children: [ ] ,
) ;
} ) ;
}
void onTxnTimeout ( ) {
showDialog (
barrierDismissible: false ,
context: context ,
2024-06-19 17:47:24 +05:30
builder: ( context ) = > AlertDialog (
backgroundColor: const Color ( 0xFFFFF3E4 ) ,
title: const Text (
" Transaction Timeout " ,
) ,
content: const Text ( " You need to login again to continue " ) ,
actions: [
TextButton (
onPressed: ( ) {
Navigator . of ( context ) . pop ( false ) ;
} ,
child: const Text (
' No ' ,
style: TextStyle (
color: Color ( 0xff1B243D ) ,
2024-06-18 10:36:24 +05:30
) ,
2024-06-19 17:47:24 +05:30
) ,
) ,
TextButton (
onPressed: ( ) {
fetchAuthToken ( ) . then ( ( fetchedAuthToken ) {
debugPrint ( " fetchedAuthToken $ fetchedAuthToken " ) ;
fetchBrokerConnectTxnId ( authToken: fetchedAuthToken ) . then (
( txnId ) = > ScgatewayFlutterPlugin . initGateway (
fetchedAuthToken ,
) . then (
( value ) = >
ScgatewayFlutterPlugin . triggerGatewayTransaction (
txnId ,
) . then (
( loginRes ) {
if ( loginRes ! = null ) {
log ( loginRes . toString ( ) ) ;
var data = jsonDecode ( loginRes ) [ ' data ' ] ;
if ( data ! = null ) {
String authToken =
jsonDecode ( data ) [ ' smallcaseAuthToken ' ] ;
String brokerName =
jsonDecode ( data ) [ ' broker ' ] ;
String txnId =
jsonDecode ( data ) [ ' transactionId ' ] ;
postBrokerAccount (
brokerName: brokerName ,
authToken: authToken ,
txnId: txnId )
. then ( ( isPosted ) {
if ( isPosted ) {
Get . back ( ) ;
}
} ) ;
}
}
} ,
) ,
2024-06-18 10:36:24 +05:30
) ,
2024-06-19 17:47:24 +05:30
) ;
} ) ;
} ,
child: const Text (
' Yes ' ,
style: TextStyle (
color: Color ( 0xff1B243D ) ,
) ,
) ,
)
] ,
) ) ;
2024-06-18 10:36:24 +05:30
}
2024-04-08 15:05:50 +05:30
2024-03-22 16:55:59 +05:30
@ override
Widget build ( BuildContext context ) {
2024-04-16 16:43:11 +05:30
return WillPopScope (
onWillPop: ( ) async {
_onBackButtonPressed ( context ) ;
return true ; // Return true to allow the pop action
} ,
child: Scaffold (
key: _scaffoldKey1 ,
2024-03-22 16:55:59 +05:30
backgroundColor: Colors . black ,
2024-04-16 16:43:11 +05:30
drawerEnableOpenDragGesture: false ,
2024-06-18 10:36:24 +05:30
drawer: const SideMenu ( ) ,
2024-04-16 16:43:11 +05:30
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 ,
) ,
2024-03-22 16:55:59 +05:30
) ,
) ,
) ,
2024-06-18 10:36:24 +05:30
body: Obx (
( ) = > Stack (
children: [
const CommonBlurLeft ( ) ,
const CommonBlurRight ( ) ,
! noBrokerAvailable . value
? Stack (
children: [
Padding (
padding: const EdgeInsets . symmetric (
horizontal: 16 , vertical: 16 ) ,
child: ListView (
physics: const NeverScrollableScrollPhysics ( ) ,
children: [
Row (
mainAxisAlignment:
MainAxisAlignment . spaceBetween ,
children: [
text25W600 ( " My Portfolio " ) ,
GestureDetector (
onTap: ( ) {
2024-06-19 11:17:03 +05:30
ScgatewayFlutterPlugin
. setConfigEnvironment (
GatewayEnvironment . PRODUCTION ,
' traderscircuit ' ,
false ,
[ ] ,
) ;
2024-06-18 10:36:24 +05:30
fetchAuthToken ( ) . then ( ( fetchedAuthToken ) {
debugPrint (
" fetchedAuthToken $ fetchedAuthToken " ) ;
fetchBrokerConnectTxnId (
authToken: fetchedAuthToken )
. then (
( txnId ) = > ScgatewayFlutterPlugin
. initGateway ( fetchedAuthToken )
. then (
( value ) = > ScgatewayFlutterPlugin
. triggerGatewayTransaction (
txnId ,
) . then (
( loginRes ) {
log ( loginRes . toString ( ) ) ;
if ( loginRes ! = null ) {
var data = jsonDecode (
loginRes ) [ ' data ' ] ;
if ( data ! = null ) {
String authToken =
jsonDecode ( data ) [
' smallcaseAuthToken ' ] ;
String brokerName =
jsonDecode (
data ) [ ' broker ' ] ;
String txnId = jsonDecode (
data ) [ ' transactionId ' ] ;
postBrokerAccount (
brokerName:
brokerName ,
authToken:
authToken ,
txnId: txnId )
. then ( ( isPosted ) {
2024-06-19 17:47:24 +05:30
fetchUserIdAndBrokerAccounts
. add (
fetchBrokerAccounts ( ) ) ;
fetchUserIdAndBrokerAccounts
. close ( ) ;
fetchUserIdAndBrokerAccounts
. future
. then ( ( value ) {
log ( value . toString ( ) ) ;
try {
myBrokerAccounts =
value [ 0 ]
as List < Data > ;
} catch ( e ) { }
debugPrint (
" myBrokerAccounts.length ${ myBrokerAccounts . length } " ) ;
if ( myBrokerAccounts
. isEmpty ) {
noBrokerAvailable
. value = true ;
} else {
noBrokerAvailable
. value = false ;
}
} ) ;
2024-06-18 10:36:24 +05:30
ScaffoldMessenger . of (
context )
. clearSnackBars ( ) ;
ScaffoldMessenger . of (
context )
. showSnackBar (
const SnackBar (
content: Text (
' New broker account is added ' ) ) ) ;
} ) ;
}
}
} ,
) ,
) ,
) ;
} ) ;
setState ( ( ) { } ) ;
2024-04-16 16:43:11 +05:30
} ,
2024-06-18 10:36:24 +05:30
child: Container (
width: 80 ,
padding: const EdgeInsets . all ( 8 ) ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 12 ) ,
color: const Color ( 0xff6C0000 ) ,
) ,
child: Center ( child: text15W600 ( " ADD " ) ) ,
) ,
2024-04-16 16:43:11 +05:30
) ,
2024-06-18 10:36:24 +05:30
] ,
) ,
const SizedBox (
height: 10 ,
) ,
DefaultTabController (
length: myBrokerAccounts . length ,
// initialIndex: selectedIndex.value,
child: Column (
children: [
PortfolioTabBar (
portfolioLength: myBrokerAccounts . length ,
portoflioName: myBrokerAccounts ,
) ,
SizedBox (
height: 30. h ,
) ,
SizedBox (
height: 570. h ,
child: TabBarView (
children: List . generate (
myBrokerAccounts . length , ( count ) {
return DefaultTabController (
length: 2 ,
child: Column (
children: [
const HoldingsTabBar ( ) ,
Expanded (
child: TabBarView (
children: [
holdings ( ) ,
PortfolioReview ( ) ,
] ,
) ,
) ,
] ,
) ,
) ;
} ) ,
) ,
) ,
] ,
2024-04-08 15:05:50 +05:30
) ,
2024-06-18 10:36:24 +05:30
) ,
sizedBoxHeight ( 40. h ) ,
] ,
) ,
) ,
] ,
)
: Stack (
children: [
Padding (
padding: const EdgeInsets . symmetric (
horizontal: 16 , vertical: 16 ) ,
child: Column (
children: [
Row (
children: [
text25W600 ( " My Portfolio " ) ,
] ,
) ,
SizedBox (
height: 30. h ,
) ,
Text (
' Please click the "Add" button below to add a portfolio. ' ,
textAlign: TextAlign . center ,
style: TextStyle (
fontFamily: ' hiragino ' ,
color: Colors . white ,
fontSize: 16. sp ,
fontWeight: FontWeight . w400 ,
) ,
) ,
const Spacer ( ) ,
LottieBuilder . asset (
" assets/images/png/TAdlX7YnR7 (1).json " ,
width: 200. w ,
height: 200. h ,
) ,
const Spacer ( ) ,
CommonBtn (
text: " Add " ,
onTap: ( ) {
fetchAuthToken ( ) . then ( ( fetchedAuthToken ) {
debugPrint (
" fetchedAuthToken $ fetchedAuthToken " ) ;
fetchBrokerConnectTxnId (
authToken: fetchedAuthToken )
. then (
( txnId ) = >
ScgatewayFlutterPlugin . initGateway (
fetchedAuthToken )
. then (
( value ) = > ScgatewayFlutterPlugin
. triggerGatewayTransaction (
txnId ,
) . then (
( loginRes ) {
log ( loginRes . toString ( ) ) ;
if ( loginRes ! = null ) {
var data = jsonDecode (
loginRes ) [ ' data ' ] ;
if ( data ! = null ) {
String authToken =
jsonDecode ( data ) [
' smallcaseAuthToken ' ] ;
String brokerName =
jsonDecode (
data ) [ ' broker ' ] ;
String txnId = jsonDecode (
data ) [ ' transactionId ' ] ;
postBrokerAccount (
brokerName:
brokerName ,
authToken: authToken ,
txnId: txnId )
. then ( ( isPosted ) {
ScaffoldMessenger . of (
context )
. clearSnackBars ( ) ;
ScaffoldMessenger . of (
context )
. showSnackBar (
const SnackBar (
content: Text (
' New broker account is added ' ) ) ) ;
fetchUserIdAndBrokerAccounts
. add (
fetchBrokerAccounts ( ) ) ;
fetchUserIdAndBrokerAccounts
. close ( ) ;
fetchUserIdAndBrokerAccounts
. future
. then ( ( value ) {
log ( value . toString ( ) ) ;
try {
myBrokerAccounts =
value [ 0 ]
as List < Data > ;
} catch ( e ) { }
debugPrint (
" myBrokerAccounts.length ${ myBrokerAccounts . length } " ) ;
if ( myBrokerAccounts
. isEmpty ) {
noBrokerAvailable
. value = true ;
} else {
noBrokerAvailable
. value = false ;
}
} ) ;
setState ( ( ) { } ) ;
} ) ;
}
}
} ,
) ,
) ,
) ;
} ) ;
} ) ,
const Spacer ( ) ,
] ,
) ,
) ,
] ,
)
] ,
) ,
) ,
bottomNavigationBar: bottomnavigationbar ( mainController ) ,
) ,
) ;
}
Widget topContainer ( String text , int index ) {
return Obx ( ( ) {
return selectedIndex . value = = index
? Container (
height: 40. h ,
width: 126. w ,
decoration: BoxDecoration (
borderRadius: BorderRadius . circular ( 5 ) ,
color: const Color ( 0Xff6C0000 ) ,
) ,
child: Center ( child: text16W500 ( text ) ) ,
)
: commonGlassContainer (
width: 126. w ,
height: 40. h ,
borderradius: 5 ,
customWidget: Center ( child: text16W400 ( text ) ) ,
) ;
} ) ;
}
void _unlockbottomsheet ( ) {
Get . bottomSheet (
SizedBox (
height: 200 ,
child: commonGlassContainer (
width: double . infinity ,
height: 200 ,
borderradius: 2 ,
customWidget: Column (
mainAxisAlignment: MainAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
// 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 ' ) ,
] ,
) ,
) ,
) ,
backgroundColor: Colors . black . withOpacity ( 0.3 ) ,
) ;
}
Widget PortfolioReview ( ) {
List < Map < String , String > > cardSwing = [
{
' text ' : ' Performance Overview: ' ,
' content ' :
' Your portfolio has generated a total return of 15% over the past six months, outperforming the S&P 500 index by 5%. ' ,
} ,
{
' text ' : ' Asset Allocation: ' ,
' content ' :
' Your portfolio is well-diversified, with 60% allocated to equities, 30% to bonds, and 10% to cash equivalents. ' ,
} ,
{
' text ' : ' Individual Holdings Analysis: ' ,
' content ' :
' Your investment in Company XYZ has performed exceptionally well, with a 25% increase in share price since purchase, driven by strong quarterly earnings. ' ,
} ,
] ;
return SingleChildScrollView (
child: Column (
children: [
sizedBoxHeight ( 20. h ) ,
Obx ( ( ) {
return selectedIndex . value = = 0
? Column (
children: List . generate ( cardSwing . length , ( index ) {
return Column (
children: [
PortfolioCard (
text: cardSwing [ index ] [ ' text ' ] ! ,
content: cardSwing [ index ] [ ' content ' ] ! ,
) ,
sizedBoxHeight ( 20. h )
] ,
) ;
} ) ,
)
: selectedIndex . value = = 1
? Column (
children: List . generate ( cardSwing . length , ( index ) {
return Column (
children: [
PortfolioCard (
text: cardSwing [ index ] [ ' text ' ] ! ,
content: cardSwing [ index ] [ ' content ' ] ! ,
) ,
sizedBoxHeight ( 20. h )
] ,
) ;
} ) ,
)
: Column (
children: List . generate ( cardSwing . length , ( index ) {
return Column (
children: [
PortfolioCard (
text: cardSwing [ index ] [ ' text ' ] ! ,
content: cardSwing [ index ] [ ' content ' ] ! ,
) ,
sizedBoxHeight ( 20. h )
] ,
) ;
} ) ,
) ;
} ) ,
sizedBoxHeight ( 200. h )
] ,
) ,
) ;
}
Widget PortfolioCard ( {
required String text ,
required String content ,
} ) {
return commonGlassContainer (
width: double . infinity ,
height: 166. h ,
borderradius: 8 ,
customWidget: Column (
children: [
Padding (
padding: EdgeInsets . symmetric ( vertical: 16. h , horizontal: 16. w ) ,
child: Row (
children: [
Container (
decoration: BoxDecoration (
color: const Color ( 0xFF6C0000 ) ,
borderRadius: BorderRadius . circular ( 2 ) ,
) ,
height: 25. h ,
width: 4. w ,
) ,
sizedBoxWidth ( 15. w ) ,
text18W600 ( text ) ,
const Spacer ( ) ,
] ,
) ,
) ,
Padding (
padding: const EdgeInsets . symmetric ( horizontal: 18 ) ,
child: text16W400 ( content ) ,
)
] ,
) ,
) ;
}
Widget HoldingCard ( {
required String text ,
required String content ,
} ) {
return commonGlassContainer (
width: double . infinity ,
height: 166. 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 ) ,
2024-04-16 16:43:11 +05:30
] ,
) ,
2024-06-18 10:36:24 +05:30
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: Image . asset (
' assets/images/png/TATAMOTORS.NS_BIG 1.png ' ,
width: 26. w ,
height: 23. h ,
) ,
) ,
2024-03-22 16:55:59 +05:30
) ,
2024-06-18 10:36:24 +05:30
sizedBoxWidth ( 15. w ) ,
text18W600 ( text ) ,
const Spacer ( ) ,
2024-04-16 16:43:11 +05:30
] ,
2024-06-18 10:36:24 +05:30
) ,
) ,
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 ( ' Portfolio Value ' ) ,
sizedBoxHeight ( 5. h ) ,
SizedBox ( width: 150. w , child: text15W600 ( " ₹ 40,000 " ) )
] ,
) ,
sizedBoxWidth ( 30. w ) ,
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
text14W400_979797 ( ' %P/L ' ) ,
sizedBoxHeight ( 5. h ) ,
text14W400_00FF19 ( " -36.006% " )
] ,
)
] ,
) ,
] ,
) ,
)
] ,
2024-03-22 16:55:59 +05:30
) ,
) ;
}
2024-04-16 16:43:11 +05:30
Future < bool > _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 ;
}
2024-03-22 16:55:59 +05:30
}
2024-06-18 10:36:24 +05:30
class HoldingsTabBar extends StatelessWidget {
const HoldingsTabBar ( { super . key } ) ;
// Set the desired height
@ override
Widget build ( BuildContext context ) {
return Container (
decoration: BoxDecoration (
border: Border . all ( color: const Color ( 0Xff3A3A3A ) ) ,
borderRadius: BorderRadius . circular ( 8. r ) ,
) ,
padding: const EdgeInsets . all ( 8.0 ) , // Set the desired padding
child: TabBar (
indicator: BoxDecoration (
color: const Color ( 0xff6C0000 ) ,
borderRadius: BorderRadius . circular ( 5 ) ,
) ,
dividerColor: Colors . transparent ,
labelStyle: TextStyle (
fontSize: 16. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
indicatorSize: TabBarIndicatorSize . tab ,
indicatorColor: const Color ( 0xFFFFFFFF ) ,
labelColor: Colors . white ,
unselectedLabelColor: const Color ( 0xffFFFFFF ) ,
2024-06-24 14:55:18 +05:30
overlayColor: MaterialStateProperty . all ( const Color ( 0xFFFFFFFF ) ) ,
2024-06-18 10:36:24 +05:30
tabs: const [
Tab (
text: ' Holdings ' ,
) ,
Tab (
text: ' Portfolio Reviews ' ,
) ,
] ) ,
) ;
}
}
2024-06-19 17:47:24 +05:30
class PortfolioTabBar extends StatefulWidget {
2024-06-18 10:36:24 +05:30
final int portfolioLength ;
final List < Data > portoflioName ;
const PortfolioTabBar ( {
super . key ,
required this . portfolioLength ,
required this . portoflioName ,
} ) ;
2024-06-19 17:47:24 +05:30
@ override
State < PortfolioTabBar > createState ( ) = > _PortfolioTabBarState ( ) ;
}
class _PortfolioTabBarState extends State < PortfolioTabBar >
with SingleTickerProviderStateMixin {
late TabController _tabController ;
@ override
void initState ( ) {
super . initState ( ) ;
_tabController = TabController ( length: widget . portfolioLength , vsync: this ) ;
_tabController . addListener ( ( ) {
selectedTabIndex = _tabController . index ;
} ) ;
}
@ override
void dispose ( ) {
_tabController . dispose ( ) ;
super . dispose ( ) ;
} // Set the desired height
2024-06-18 10:36:24 +05:30
@ override
Widget build ( BuildContext context ) {
return TabBar (
tabAlignment: TabAlignment . start ,
isScrollable: true ,
2024-06-19 17:47:24 +05:30
controller: _tabController ,
2024-06-18 10:36:24 +05:30
dividerColor: Colors . transparent ,
labelStyle: TextStyle (
fontSize: 18. sp ,
color: Colors . white ,
fontWeight: FontWeight . w500 ,
fontFamily: ' hiragino ' ) ,
indicatorSize: TabBarIndicatorSize . tab ,
indicatorWeight: 2 ,
indicatorColor: const Color ( 0xff6C0000 ) ,
labelColor: Colors . white ,
unselectedLabelColor: const Color ( 0xFF464646 ) ,
2024-06-24 14:55:18 +05:30
overlayColor: MaterialStateProperty . all ( const Color ( 0xFFFFFFFF ) ) ,
2024-06-19 17:47:24 +05:30
tabs: List . generate ( widget . portfolioLength , ( counter ) {
2024-06-18 10:36:24 +05:30
return Tab (
2024-06-19 17:47:24 +05:30
text: widget . portoflioName [ counter ] . brokerName ,
2024-06-18 10:36:24 +05:30
) ;
} ) ) ;
}
}