Files
Traders_Circuit/lib/view/Sidemenu/Sidemenu.dart

567 lines
18 KiB
Dart
Raw Normal View History

2024-03-19 22:57:32 -07:00
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
2024-04-12 19:34:25 +05:30
import 'package:shared_preferences/shared_preferences.dart';
2024-03-22 04:02:01 -07:00
import 'package:traderscircuit/Utils/Common/commonBotton.dart';
import 'package:traderscircuit/Utils/Common/comonGlassmorphicContainer.dart';
2024-03-19 22:57:32 -07:00
import 'package:traderscircuit/Utils/Common/sized_box.dart';
2024-06-18 11:26:15 +05:30
import 'package:traderscircuit/Utils/base_manager.dart';
2024-03-19 23:09:10 -07:00
import 'package:traderscircuit/Utils/text.dart';
2024-03-20 19:30:42 +05:30
import 'package:traderscircuit/resources/routes/route_name.dart';
2024-06-18 11:26:15 +05:30
import 'package:traderscircuit/view_model/LogoutApi/logout_api.dart';
2024-04-19 13:26:04 +05:30
import 'package:traderscircuit/view_model/ProfileAPI/GetProfileApi.dart';
2024-03-19 22:57:32 -07:00
2024-05-24 18:48:09 +05:30
import 'webview_subscription.dart';
2024-03-19 22:57:32 -07:00
class SideMenu extends StatefulWidget {
const SideMenu({super.key});
@override
State<SideMenu> createState() => _SideMenuState();
}
class _SideMenuState extends State<SideMenu> {
2024-04-25 13:24:58 +05:30
@override
void initState() {
// TODO: implement initState
super.initState();
}
2024-03-19 22:57:32 -07:00
List sideBarData = [
2024-03-22 17:21:40 +05:30
{
"imagePath": "assets/images/svg/sidemenu/Faq.svg",
"text": "FAQs",
},
2024-03-19 22:57:32 -07:00
{
"imagePath": "assets/images/svg/sidemenu/contact.svg",
"text": "Contact Us"
},
{
"imagePath": "assets/images/svg/sidemenu/rate.svg",
"text": "Rate this app"
},
{
"imagePath": "assets/images/svg/sidemenu/terms.svg",
"text": "Terms & Conditions"
},
{
"imagePath": "assets/images/svg/sidemenu/privacy.svg",
"text": "Privacy Policy"
},
{"imagePath": "assets/images/svg/sidemenu/about.svg", "text": "About Us"},
{
"imagePath": "assets/images/svg/sidemenu/settingmenu.svg",
"text": "Settings"
},
{"imagePath": "assets/images/svg/sidemenu/logout.svg", "text": "Logout"},
];
Color sideBarBackgroundColor = const Color(0xFF1B243D);
Color whitecolor = Colors.white;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
toolbarHeight: 60.h,
elevation: 0,
backgroundColor: Colors.black,
leading: Container(
child: Align(
alignment: Alignment.bottomCenter,
child: GestureDetector(
onTap: () {
// Get.back();
Scaffold.of(context).closeDrawer();
},
child: Container(
width: 25.w,
height: 25.h,
2024-03-22 17:21:40 +05:30
decoration: const ShapeDecoration(
2024-03-19 22:57:32 -07:00
color: Colors.black,
2024-03-22 17:21:40 +05:30
shape: OvalBorder(),
2024-03-19 22:57:32 -07:00
),
child: Align(
alignment: Alignment.center,
child: SizedBox(
width: 25.w,
height: 25.h,
child: Icon(
Icons.arrow_back_ios,
color: Colors.white,
size: 25.h,
weight: 25.w,
),
),
),
),
),
),
),
),
body: Stack(
children: [
2024-03-20 19:30:42 +05:30
// CommonBlurLeft(),
// CommonBlurRight(),
2024-03-19 22:57:32 -07:00
Stack(children: [
ListView(children: [
sizedBoxHeight(30.h),
InkWell(
onTap: () {
setState(() {
2024-03-26 16:57:04 +05:30
Get.toNamed(RouteName.myProfileScreen);
2024-03-19 22:57:32 -07:00
});
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: 80.w,
height: 80.h,
2024-04-19 13:26:04 +05:30
decoration: ShapeDecoration(
2024-03-19 22:57:32 -07:00
image: DecorationImage(
image: NetworkImage(ProfileObj == null
2024-04-29 15:35:31 +05:30
? ""
: ProfileObj!.data!.profilePhoto ?? ""),
2024-03-19 22:57:32 -07:00
fit: BoxFit.fill,
),
2024-03-22 17:21:40 +05:30
shape: OvalBorder(),
2024-03-19 22:57:32 -07:00
),
),
sizedBoxWidth(20.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text18W400(ProfileObj!.data!.userName ?? ""),
2024-03-19 22:57:32 -07:00
sizedBoxHeight(4.h),
text18W400('My Profile'),
],
),
],
),
),
),
sizedBoxHeight(25.h),
Container(
height: 1,
margin: EdgeInsets.symmetric(vertical: 10.h),
2024-03-22 17:21:40 +05:30
decoration: const BoxDecoration(
2024-03-19 22:57:32 -07:00
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(176, 176, 176, 0.5),
width: 1,
),
),
),
),
ListTile(
2024-03-22 04:02:01 -07:00
leading:
SvgPicture.asset('assets/images/svg/sidemenu/sub.svg'),
2024-03-19 22:57:32 -07:00
title: text18W400('My Subscription'),
trailing: Container(
height: 35.h,
2024-06-18 11:26:15 +05:30
width: 80.w,
2024-03-19 22:57:32 -07:00
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.r),
2024-03-22 17:21:40 +05:30
color: const Color(0xFF34C759),
2024-03-19 22:57:32 -07:00
),
child: Center(child: text14W500_black('Upgrade')),
),
selected: true,
2024-05-24 18:48:09 +05:30
onTap: () async {
SharedPreferences prefs =
await SharedPreferences.getInstance();
Get.to(WebViewSubscription(
token: prefs.getString('accessToken').toString()));
2024-03-19 22:57:32 -07:00
},
),
Container(
height: 1,
margin: EdgeInsets.symmetric(vertical: 10.h),
2024-03-22 17:21:40 +05:30
decoration: const BoxDecoration(
2024-03-19 22:57:32 -07:00
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(176, 176, 176, 0.5),
width: 1,
),
),
),
),
ListTile(
2024-03-22 04:02:01 -07:00
leading: SvgPicture.asset(
'assets/images/svg/sidemenu/content.svg'),
2024-03-19 22:57:32 -07:00
title: text18W400('Content bytes'),
selected: true,
onTap: () {
setState(() {
2024-03-29 17:59:32 +05:30
Get.toNamed(RouteName.contentbytes);
2024-03-19 22:57:32 -07:00
});
},
),
Container(
height: 1,
margin: EdgeInsets.symmetric(vertical: 10.h),
2024-03-22 17:21:40 +05:30
decoration: const BoxDecoration(
2024-03-19 22:57:32 -07:00
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(176, 176, 176, 0.5),
width: 1,
),
),
),
),
ListTile(
leading: SizedBox(
width: 25.w,
height: 25.h,
child: SvgPicture.asset(
2024-03-22 04:02:01 -07:00
'assets/images/svg/sidemenu/Gray.svg')),
2024-03-19 22:57:32 -07:00
title: text18W400('Update My KYC'),
trailing: Container(
height: 40.h,
2024-06-18 11:26:15 +05:30
width: 80.w,
2024-03-19 22:57:32 -07:00
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.r),
2024-03-22 17:21:40 +05:30
color: const Color(0xFF3A3A3A).withOpacity(0.6),
border: Border.all(color: const Color(0xFF9A0000))),
2024-03-19 22:57:32 -07:00
child: Padding(
2024-06-18 11:26:15 +05:30
padding: EdgeInsets.symmetric(horizontal: 4.w),
2024-03-19 22:57:32 -07:00
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2024-06-18 11:26:15 +05:30
text10W300('Pending'),
2024-03-19 22:57:32 -07:00
Container(
2024-06-18 11:26:15 +05:30
height: 22.h,
width: 22.w,
2024-03-22 17:21:40 +05:30
decoration: const BoxDecoration(
2024-03-19 22:57:32 -07:00
image: DecorationImage(
image: AssetImage(
'assets/images/png/Ellipse 1498.png',
),
fit: BoxFit.cover)),
child: Center(child: text8W400('40%')),
),
],
),
),
),
selected: true,
onTap: () {
Get.toNamed(RouteName.kyc, arguments: {
"fromScreen": "sidemenu-flow",
});
2024-03-19 22:57:32 -07:00
},
),
Container(
height: 1,
margin: EdgeInsets.symmetric(vertical: 10.h),
2024-03-22 17:21:40 +05:30
decoration: const BoxDecoration(
2024-03-19 22:57:32 -07:00
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(176, 176, 176, 0.5),
width: 1,
),
),
),
),
ListTile(
2024-03-22 04:02:01 -07:00
leading: SvgPicture.asset(
'assets/images/svg/sidemenu/Group 51347.svg'),
2024-03-29 17:59:32 +05:30
title: text18W400('My Risk Profile'),
2024-03-19 22:57:32 -07:00
trailing: Container(
height: 35.h,
2024-06-18 11:26:15 +05:30
width: 80.w,
2024-03-19 22:57:32 -07:00
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6.r),
2024-03-22 17:21:40 +05:30
color: const Color(0xFF0093FF),
2024-03-19 22:57:32 -07:00
),
2024-06-18 11:26:15 +05:30
child: Center(child: text10W300('Conservative')),
2024-03-19 22:57:32 -07:00
),
selected: true,
onTap: () {
setState(() {
Get.toNamed(RouteName.updateriskprofile, arguments: {
"fromScreen": "sidemenu-flow",
});
2024-03-19 22:57:32 -07:00
});
},
),
Column(
children: List.generate(sideBarData.length, (index) {
return sideBarTile(
image: sideBarData[index]["imagePath"],
text: sideBarData[index]["text"],
onTap: () {
2024-03-22 17:21:40 +05:30
print(index);
2024-03-19 22:57:32 -07:00
navigateTo(index, context);
},
);
}),
),
// SingleChildScrollView(
// physics: NeverScrollableScrollPhysics(),
// child: ListView.builder(
// shrinkWrap: true,
// padding: EdgeInsets.zero,
// itemCount: sideBarData.length,
// itemBuilder: (_, index) {
// return sideBarTile(
// image: sideBarData[index]["imagePath"],
// text: sideBarData[index]["text"],
// onTap: () {
// navigateTo(index, context);
// },
// );
// },
// ),
// ),
sizedBoxHeight(80.h),
]),
]),
],
));
}
}
LogOutdialog(context) {
return showDialog(
// barrierDismissible: false,
context: context,
builder: (context) => Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
AlertDialog(
insetPadding: EdgeInsets.symmetric(horizontal: 16.w),
backgroundColor:
Get.isDarkMode ? Colors.black : const Color(0XFF1B243D),
contentPadding: EdgeInsets.fromLTRB(29.w, 44.h, 29.w, 35.h),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(5.r)),
),
content: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 87.h,
width: 80.w,
decoration: const BoxDecoration(
shape: BoxShape.circle, color: Color(0xFFC18948)),
child: Align(
alignment: Alignment.topLeft,
child: Container(
height: 79.h,
width: 73.w,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: const Color(0xFFE8C69F).withOpacity(0.5),
),
child: Center(
child: SvgPicture.asset(
'assets/images/svg/apps 1.svg',
// fit: BoxFit.fill,
),
),
),
),
),
sizedBoxHeight(30.h),
Text(
"Are you sure you want to logout ?",
textAlign: TextAlign.center,
style: TextStyle(
2024-04-04 11:45:15 +05:30
fontFamily: "hiragino",
2024-03-19 22:57:32 -07:00
fontWeight: FontWeight.w400,
fontSize: 20.sp,
color: const Color(0xFFFFFFFF)),
),
sizedBoxHeight(40.h),
2024-04-12 19:34:25 +05:30
Row(
2024-03-19 22:57:32 -07:00
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
2024-04-12 19:34:25 +05:30
SizedBox(
width: 140.w,
child: CommonYesNoBtn(
yesonTap: () async {
2024-06-18 11:26:15 +05:30
_handleLogout();
// SharedPreferences prefs =
// await SharedPreferences.getInstance();
// await prefs.clear();
// Get.offNamed(RouteName.loginscreen);
2024-04-12 19:34:25 +05:30
},
)),
SizedBox(
width: 140.w,
child: CommonYesNoBtn(
noonTap: () {
Get.back();
},
),
),
2024-03-19 22:57:32 -07:00
],
)
],
),
),
],
),
);
}
void navigateTo(int index, BuildContext context) {
switch (index) {
case 0:
{
2024-03-22 04:02:01 -07:00
Get.toNamed(RouteName.faqscreen);
2024-03-19 22:57:32 -07:00
}
break;
case 1:
{
2024-03-22 17:21:40 +05:30
Get.toNamed(RouteName.contactUsMain);
2024-03-19 22:57:32 -07:00
}
break;
case 2:
{
// Get.toNamed(RouteName.settingsScreen);
}
break;
case 3:
{
2024-03-22 04:02:01 -07:00
Get.toNamed(RouteName.termsandcondition);
2024-03-19 22:57:32 -07:00
}
break;
case 4:
{
2024-03-22 04:02:01 -07:00
Get.toNamed(RouteName.privacypolicy);
2024-03-19 22:57:32 -07:00
}
break;
case 5:
{
2024-03-22 04:02:01 -07:00
Get.toNamed(RouteName.aboutus);
2024-03-19 22:57:32 -07:00
}
break;
case 6:
2024-03-20 19:30:42 +05:30
{
2024-03-26 15:01:38 +05:30
Get.toNamed(RouteName.settings);
2024-03-20 19:30:42 +05:30
}
break;
case 7:
2024-03-19 22:57:32 -07:00
{
Get.bottomSheet(
2024-03-22 04:02:01 -07:00
commonGlassContainer(
width: double.infinity,
height: 363.h,
borderradius: 4,
customWidget: Center(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Column(
children: [
sizedBoxHeight(60.h),
// Image.asset(
// 'assets/images/png/Group 1000003722.png',
// height: 100.h,
// ),
// sizedBoxHeight(25.h),
text22W600('Confirm Logout'),
sizedBoxHeight(30.h),
text20W400_center(
'Are you sure you want to logout your account?'),
sizedBoxHeight(50.h),
2024-03-29 17:59:32 +05:30
CommonYesNoBtn(
yesonTap: () {
2024-06-18 11:26:15 +05:30
_handleLogout();
// Get.toNamed(RouteName.loginscreen);
2024-03-29 17:59:32 +05:30
},
noonTap: () {
Get.back();
},
),
2024-03-22 04:02:01 -07:00
],
2024-03-19 22:57:32 -07:00
),
),
2024-03-22 04:02:01 -07:00
),
2024-03-19 22:57:32 -07:00
),
2024-03-22 04:02:01 -07:00
backgroundColor: Colors.black.withOpacity(0.3),
2024-03-19 22:57:32 -07:00
);
}
break;
default:
{
null;
}
}
}
class sideBarTile extends StatelessWidget {
final String image;
final String text;
final void Function()? onTap;
sideBarTile({
required this.image,
required this.text,
this.onTap,
super.key,
});
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 1,
margin: EdgeInsets.symmetric(vertical: 10.h),
2024-03-22 17:21:40 +05:30
decoration: const BoxDecoration(
2024-03-19 22:57:32 -07:00
border: Border(
bottom: BorderSide(
color: Color.fromRGBO(176, 176, 176, 0.5),
width: 1,
),
),
),
),
ListTile(
leading: SvgPicture.asset(image),
title: text18W400(text),
selected: true,
onTap: onTap),
],
);
}
}
2024-06-18 11:26:15 +05:30
Future<void> _handleLogout() async {
// Create an instance of the API with required data
var logoutApi = LogoutAPI({
// Add any required data here, e.g., user token or ID
});
// Call the logout API
final response = await logoutApi.logoutApi();
// Handle the response
if (response.status == ResponseStatus.SUCCESS) {
// Clear any user-related data here if necessary
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.clear();
// Navigate to the login screen
Get.offAllNamed(RouteName.loginscreen);
} else {
// Show an error message if logout failed
Get.snackbar('Error', response.message ?? 'Logout failed');
}
}