From 50102b9e7b69ee4e6d107675e2821ae96739a4b5 Mon Sep 17 00:00:00 2001 From: kishan06 Date: Mon, 29 Jul 2024 12:00:47 +0530 Subject: [PATCH] edit profile bug fix --- .../EditProfile/Model/InterestModel.dart | 20 +- .../EditProfile/View/EditProfile.dart | 242 ++---------------- .../EditProfile/View/ProfileTab.dart | 20 +- .../EditProfile/ViewModel/EditProfileApi.dart | 82 +----- .../ViewModel/InterestApiList.dart | 31 +-- lib/Global.dart | 3 +- lib/Utils/Common/CommonDropdown.dart | 72 +----- lib/main.dart | 66 +---- .../Signup/view_model/getUserprofile.dart | 53 ++-- lib/onboarding/SplashScreen.dart | 33 +-- 10 files changed, 103 insertions(+), 519 deletions(-) diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart index edcd7e2..c75e49d 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart @@ -13,16 +13,16 @@ class InterestModel { if (json['data'] != null) { data = []; json['data'].forEach((v) { - data!.add(new Data.fromJson(v)); + data!.add(Data.fromJson(v)); }); } } Map toJson() { - final Map data = new Map(); - data['status'] = this.status; - data['status_code'] = this.statusCode; - data['message'] = this.message; + final Map data = {}; + data['status'] = status; + data['status_code'] = statusCode; + data['message'] = message; if (this.data != null) { data['data'] = this.data!.map((v) => v.toJson()).toList(); } @@ -33,7 +33,7 @@ class InterestModel { class Data { int? id; String? name; - Null? image; + String? image; Data({this.id, this.name, this.image}); @@ -44,10 +44,10 @@ class Data { } Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['name'] = this.name; - data['image'] = this.image; + final Map data = {}; + data['id'] = id; + data['name'] = name; + data['image'] = image; return data; } } diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart index d03f584..98bbd9b 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/EditProfile.dart @@ -45,8 +45,6 @@ class _EditProfileState extends State { TextEditingController weightController = TextEditingController(); TextEditingController battingAvgController = TextEditingController(); - // final InterestListApi interestcontroller = Get.put(InterestListApi()); - String profilePicture = ""; bool isImageAdded = false; @@ -72,83 +70,15 @@ class _EditProfileState extends State { }); } - String _selectedsportType = ''; - List _selectedSports = []; - - void _onSportSelected(List selectedValues) { - setState(() { - _selectedSports = selectedValues; - _selectedsportType = _selectedSports.join(', '); - }); - } - - // List getSelectedSportsIds() { - // if (getEditProfileIndi == null || - // getEditProfileIndi!.data!.interest == null) { - // print("No interests found."); - // return []; - // } - - // print("Selected sports: $_selectedSports"); - - // List selectedIds = _selectedSports - // .map((sportName) { - // var interest = getEditProfileIndi!.data!.interest!.firstWhere( - // (interest) => interest.name == sportName, - // orElse: () => Interest(id: -1, name: ''), - // ); - - // if (interest.id == -1) { - // print("No matching interest found for sport: $sportName"); - // } else { - // print( - // "Found interest for sport: $sportName with ID: ${interest.id}"); - // } - - // return interest.id!; - // }) - // .where((id) => id != -1) - // .toList(); - - // print("Selected IDs: $selectedIds"); - // return selectedIds; - // } - - //interestList - - // int id = Get.arguments["id"]; - // bool edited = Get.arguments["edit"]; - - interestlist.InterestModel? interestModel; - List interest = []; - List _interestdrop = []; List selectedinterestid = []; - List selectedNameList = []; RxBool isloading = true.obs; - // Future fetchInterestlist() async { - // InterestListApi interestListAPI = InterestListApi(); - // ResponseData response = await interestListAPI.getinterestlistApi(); - - // if (response.status == ResponseStatus.SUCCESS) { - // interestModel = await interestlist.InterestModel.fromJson(response.data!); - // setState(() { - // interest = interestModel!.data ?? []; - // _interestdrop = - // interest.map((platform) => platform.name.toString()).toList(); - // }); - // log(interest.toString()); - // } else { - // print('Failed to fetch abilities'); - // } - // } - void getCatIdFromName(List selectedInterests) { selectedinterestid.clear(); for (var name in selectedInterests) { - for (var i = 0; i < interest.length; i++) { - if (name == interest[i].name) { - selectedinterestid.add(interest[i].id!); + for (var i = 0; i < interestlistobj!.data!.length; i++) { + if (name == interestlistobj!.data![i].name) { + selectedinterestid.add(interestlistobj!.data![i].id!); break; } } @@ -157,9 +87,6 @@ class _EditProfileState extends State { @override void initState() { - // TODO: implement initState - // if (edited == true) { - myfuture = EditProfileApi() .getEditProfileIndividual() .then((value) => {setValues()}); @@ -175,9 +102,7 @@ class _EditProfileState extends State { _selectedgenderType = getEditProfileIndi!.data!.gender ?? ''; locationController.text = getEditProfileIndi!.data!.location ?? ''; - // _selectedSports = - // getEditProfileIndi!.data!.interest!.map((e) => e.name!).toList(); - // _selectedsportType = _selectedSports.join(', '); + locationController.text = getEditProfileIndi!.data!.about ?? ''; aboutController.text = getEditProfileIndi!.data!.about ?? ''; positionController.text = @@ -191,48 +116,14 @@ class _EditProfileState extends State { battingAvgController.text = getEditProfileIndi!.data!.battingAverage ?? '372'; - log(_interestsMap.length.toString()); - setState(() { - interest = interestlistobj!.data ?? []; - _interestdrop = - interest.map((platform) => platform.name.toString()).toList(); - }); - - String interestsXids = - getEditProfileIndi!.data!.interest!.map((e) => e.id!).toString(); - interestsIds = interestsXids - .split(',') - .map((e) => int.tryParse(e.trim()) ?? 0) - .toList(); - selectedinterestid = interestsIds; - - print(selectedinterestid.toList()); - - for (int i = 0; i < _interestdrop.length; i++) { - _interestsMap.add({ - "id": i + 1, - "name": _interestdrop[i], - }); - } - getSelectedNames(selectedinterestid).then((value) { - selectedNameList = value; - }); isOnce = false; setState(() {}); } } - List interestsIds = []; - List> _interestsMap = []; - void saveEditProfileInd() async { utils.loader(); - // List selectedSportsIds = getSelectedSportsIds(); - // String interestsString = '[' + - // selectedSportsIds.join(', ') + - // ']'; - // print("Interests String: $interestsString"); FormData? updata; var imageFile; @@ -278,9 +169,9 @@ class _EditProfileState extends State { "date_of_birth": dateController.text, "gender": _selectedgenderType, // "interest": "selectedSportsIds", - "interest": - // '[1,2,3,4]', - abilitiesIds, + "interest": + // '[1,2,3,4]', + abilitiesIds, "about": aboutController.text, "position": positionController.text, "training_scores": trainingScoresController.text, @@ -325,19 +216,6 @@ class _EditProfileState extends State { } } - Future> getSelectedNames(List selectedIds) async { - List selectedNames = []; - for (int id in selectedIds) { - for (var interest in interest) { - if (interest.id == id) { - selectedNames.add(interest.name!); - break; - } - } - } - return selectedNames; - } - final UserIndiProfileImageController editProfileImage = Get.put(UserIndiProfileImageController()); @@ -346,7 +224,6 @@ class _EditProfileState extends State { return GestureDetector( onTap: () => FocusManager.instance.primaryFocus?.unfocus(), child: Scaffold( - // key: _scaffoldKey1, backgroundColor: const Color(0xFF222935), extendBody: true, appBar: const CommonAppbar( @@ -390,55 +267,6 @@ class _EditProfileState extends State { sizedBoxHeight(25.h), Stack( children: [ - // profilePicture != "" && isImageAdded - // ? ClipOval( - // child: SizedBox.fromSize( - // size: Size.fromRadius(50.r), - // child: Image.file( - // File(profilePicture), - // fit: BoxFit.cover, - // width: double.infinity, - // errorBuilder: - // (BuildContext context, - // Object exception, - // StackTrace? stackTrace) { - // return CircleAvatar( - // backgroundImage: const AssetImage( - // "assets/images/png/cimg3.png"), - // radius: 50.r, - // ); - // }, - // ), - // ), - // ) - // : getEditProfileIndi - // ?.data?.profilePhoto != - // null && - // getEditProfileIndi!.data! - // .profilePhoto!.isNotEmpty - // ? Container( - // width: 100.w, - // height: 100.h, - // decoration: ShapeDecoration( - // image: DecorationImage( - // image: NetworkImage( - // getEditProfileIndi! - // .data!.profilePhoto!, - // ), - // fit: BoxFit.cover, - // // onError: (error, stackTrace) { - // // // Fallback to default image in case of error - // // return const AssetImage("assets/images/png/cimg3.png"); - // // }, - // ), - // shape: const OvalBorder(), - // ), - // ) - // : CircleAvatar( - // backgroundImage: const AssetImage( - // "assets/images/png/cimg3.png"), - // radius: 50.r, - // ), Obx( () => editProfileImage .usserprofilePicPath.value != @@ -621,7 +449,7 @@ class _EditProfileState extends State { header: _selectedgenderType ?? "Male", title: "", showOtherOption: true, - listData: [ + listData: const [ "Male", "Female", "Prefer not to say" @@ -675,44 +503,22 @@ class _EditProfileState extends State { ], ), sizedBoxHeight(16.h), - // CustomDropDownChexkBox( - // header: _selectedsportType ?? - // "Rowing, Rugby, Swimming", - // title: "", - // listData: [ - // "Rowing", - // "Cycling", - // "Running", - // "Swimming", - // "Triathlon", - // "Hiking", - // "Football", - // "Rugby" - // ], - // onItemSelected: _onSportSelected, - // leadingImage: Image.asset( - // "assets/images/png/Vector (4).png", - // width: 18.w, - // height: 17.h, - // ), - // showOtherOption: true, - // initiallySelected: _selectedSports, - // ), - // Obx(() { - // return CustomDropDownChexkBox( - // header: 'Select interest', - // title: "", - // listData: _interestdrop, - // onItemSelected: getCatIdFromName, - // leadingImage: Image.asset( - // "assets/images/png/Vector (4).png", - // width: 18.w, - // height: 17.h, - // ), - // // showOtherOption: true, - // initiallySelected: selectedNameList, - // ); + //Obx(() { + //return + CustomDropDownChexkBox( + header: 'Select interest', + title: "", + listData: listofInterests, + onItemSelected: getCatIdFromName, + leadingImage: Image.asset( + "assets/images/png/Vector (4).png", + width: 18.w, + height: 17.h, + ), + // showOtherOption: true, + initiallySelected: listofUserInterests, + ), // }), sizedBoxHeight(20.h), @@ -779,7 +585,7 @@ class _EditProfileState extends State { battingAvgController.text.isBlank!) { Get.snackbar( 'Error', - 'Enter your credentials', + 'Please fill missing details', snackPosition: SnackPosition.BOTTOM, backgroundColor: Colors.red, colorText: Colors.white, diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart index e7ca331..2236705 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart @@ -11,6 +11,7 @@ import 'package:regroup/Common/controller/MainScreen.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart'; +import 'package:regroup/Global.dart'; import 'package:regroup/Utils/Common/ShimmerCommon.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; @@ -99,9 +100,6 @@ class _ProfileTabState extends State { String? interestText; @override void initState() { - // TODO: implement initState - setValues(); - individualfuture = EditProfileApi() .getEditProfileIndividual() .then((value) => {setValues()}); @@ -114,14 +112,7 @@ class _ProfileTabState extends State { setValues() async { if (isOnce) { - SharedPreferences prefs = await SharedPreferences.getInstance(); - accountTypeValue = prefs.getString('accountTypeValue'); - accounTypeLogin = prefs.getString('accountTypefromLogin'); - print('account tupe login is $accounTypeLogin'); - print('account tupe value is $accountTypeValue'); - if (getEditProfileIndi!.data!.interest != null) { - // Join all interest names with a comma separator interestText = getEditProfileIndi!.data!.interest!.map((e) => e.name).join(', '); } @@ -198,11 +189,9 @@ class _ProfileTabState extends State { @override Widget build(BuildContext context) { return Scaffold( - // key: _scaffoldKey1, backgroundColor: const Color(0xFF222935), extendBody: true, - // accountTypeValue == '1' || - body: accounTypeLogin == '1' || accountTypeValue == '1' + body: globalAccountType == '1' ? FutureBuilder( future: individualfuture, builder: (ctx, snapshot) { @@ -210,7 +199,7 @@ class _ProfileTabState extends State { return // ShimmerCommon(); - Center( + const Center( child: CircularProgressIndicator( color: Colors.blue, ), @@ -1131,7 +1120,7 @@ class _ProfileTabState extends State { if (snapshot.connectionState == ConnectionState.waiting) { return // ShimmerCommon(); - Center( + const Center( child: CircularProgressIndicator( color: Colors.blue, ), @@ -1524,7 +1513,6 @@ class _ProfileTabState extends State { return Container(); }, ), - bottomNavigationBar: bottomnavigationbar(mainController), ); } diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart index f0ead9e..f0d79f7 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart @@ -13,60 +13,13 @@ import 'package:shared_preferences/shared_preferences.dart'; GetEditProfileIndi? getEditProfileIndi; GetEditProfileBus? getEditProfileBus; +List listofUserInterests = []; bool accountvisibility = true; -class EditProfileApi{ +class EditProfileApi { EditProfileApi(); - // var interestModel = Rx(null); - // var interest = RxList(); - // var interestdrop = RxList(); - // var selectedinterestid = RxList(); - // var selctedNameList = RxList(); - // var isloading = true.obs; - // var interestsIds = RxList(); - // var interestsMap = RxList>(); - - // Future fetchInterestlist() async { - // InterestListApi interestListAPI = InterestListApi(); - // ResponseData response = await interestListAPI.getinterestlistApi(); - - // if (response.status == ResponseStatus.SUCCESS) { - // interestModel.value = interestlist.InterestModel.fromJson(response.data!); - // interest.value = interestModel.value!.data ?? []; - // interestdrop.value = interest.map((platform) => platform.name!).toList(); - // log(interest.toString()); - // } else { - // print('Failed to fetch abilities'); - // } - // } - - // void getCatIdFromName(List selectedInterests) { - // selectedinterestid.clear(); - // for (var name in selectedInterests) { - // for (var i = 0; i < interest.length; i++) { - // if (name == interest[i].name) { - // selectedinterestid.add(interest[i].id!); - // break; - // } - // } - // } - // } - - // Future> getSelectedNames(List selectedIds) async { - // List selectedNames = []; - // for (int id in selectedIds) { - // for (var interest in interest) { - // if (interest.id == id) { - // selectedNames.add(interest.name!); - // break; - // } - // } - // } - // return selectedNames; - // } - Future> postEditProfileIndividual(var data) async { SharedPreferences prefs = await SharedPreferences.getInstance(); final response = @@ -84,28 +37,12 @@ class EditProfileApi{ Future> getEditProfileIndividual() async { final response = await NetworkApiServices().getApi(ApiUrls.geteditprofile); - getEditProfileIndi = GetEditProfileIndi.fromJson(response.data); + if (response.status == ResponseStatus.SUCCESS) { if (response.data["status"] == "success") { + getEditProfileIndi = GetEditProfileIndi.fromJson(response.data); accountvisibility = getEditProfileIndi!.data!.accountVisibility == 1; - // await fetchInterestlist(); - // String interestsXids = - // getEditProfileIndi!.data!.interest!.map((e) => e.id!).join(','); - // interestsIds.value = interestsXids - // .split(',') - // .map((e) => int.tryParse(e.trim()) ?? 0) - // .toList(); - // selectedinterestid.value = interestsIds; - - // for (var interest in interest) { - // interestsMap.add({ - // "id": interest.id!, - // "name": interest.name!, - // }); - // } - - // selctedNameList.value = await getSelectedNames(selectedinterestid); - // } + getUserIntersetFromResponse(); } return ResponseData( response.data['message'], ResponseStatus.SUCCESS, @@ -116,6 +53,12 @@ class EditProfileApi{ } } + getUserIntersetFromResponse() { + for (var interests in getEditProfileIndi!.data!.interest!) { + listofUserInterests.add(interests.name ?? "null"); + } + } + Future> postEditProfileBusiness(var data) async { SharedPreferences prefs = await SharedPreferences.getInstance(); final response = await NetworkApiServices() @@ -135,8 +78,9 @@ class EditProfileApi{ final response = await NetworkApiServices().getApi( ApiUrls.geteditprofilebusiness, ); - getEditProfileBus = GetEditProfileBus.fromJson(response.data); if (response.status == ResponseStatus.SUCCESS) { + getEditProfileBus = GetEditProfileBus.fromJson(response.data); + if (response.data["status"] == "success") { print("Success---->"); return ResponseData( diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart index debd5b1..95eaaf7 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/InterestApiList.dart @@ -1,25 +1,12 @@ +import 'dart:ffi'; + import 'package:regroup/Common/api_urls.dart'; import 'package:regroup/Common/base_manager.dart'; import 'package:regroup/Common/controller/data/network/network_api.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/Model/InterestModel.dart'; -// Future fetchInterestlist() async { -// InterestListApi interestListAPI = InterestListApi(); -// ResponseData response = await interestListAPI.getinterestlistApi(); - -// if (response.status == ResponseStatus.SUCCESS) { -// interestModel = await interestlist.InterestModel.fromJson(response.data!); -// setState(() { -// interest = interestModel!.data ?? []; -// _interestdrop = -// interest.map((platform) => platform.name.toString()).toList(); -// }); -// log(interest.toString()); -// } else { -// print('Failed to fetch abilities'); -// } -// } InterestModel? interestlistobj; +List listofInterests = []; class InterestListApi { InterestListApi(); @@ -33,13 +20,19 @@ class InterestListApi { Map responseData = Map.from(response.data); if (responseData['status'] == "success") { - print("success"); interestlistobj = InterestModel.fromJson(responseData); + getIntersetFromResponse(); } else { - // return ResponseData( - // responseData['message'], ResponseStatus.FAILED); + return ResponseData( + responseData['message'], ResponseStatus.FAILED); } } return response; } + + getIntersetFromResponse() { + for (var interests in interestlistobj!.data!) { + listofInterests.add(interests.name ?? "null"); + } + } } diff --git a/lib/Global.dart b/lib/Global.dart index 563c15c..ca8119d 100644 --- a/lib/Global.dart +++ b/lib/Global.dart @@ -1,5 +1,4 @@ import 'dart:async'; - import 'package:get/get.dart'; String? myusername; @@ -14,3 +13,5 @@ bool OnBoard = false; RxInt notification = 0.obs; late Timer timerhomeglobal; bool isTimerInitialize = false; +String? globalAccountType; + diff --git a/lib/Utils/Common/CommonDropdown.dart b/lib/Utils/Common/CommonDropdown.dart index ca4ba3f..e85d3d3 100644 --- a/lib/Utils/Common/CommonDropdown.dart +++ b/lib/Utils/Common/CommonDropdown.dart @@ -75,7 +75,7 @@ class _CustomDropDownWidgetSignupState // ), widget.leadingImage == null - ? SizedBox() + ? const SizedBox() : widget.leadingImage!, SizedBox(width: 16.w), @@ -713,7 +713,7 @@ class _CustomDropDownRadioState extends State { fontFamily: 'Helvetica', fontWeight: FontWeight.w400), ), - Spacer(), + const Spacer(), onDropTap.value ? Image.asset('assets/images/png/arrowup.png') : Image.asset('assets/images/png/arrowdown.png'), @@ -917,7 +917,7 @@ class _CustomDropDownChexkBoxState extends State { ), ], ), - SizedBox(height: 10), + const SizedBox(height: 10), ], ), ), @@ -933,65 +933,7 @@ class _CustomDropDownChexkBoxState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - // GestureDetector( - // onTap: () { - // onDropTap.value = !onDropTap.value; - // }, - // child: Container( - // width: double.infinity, - // // height: 50, - // padding: - // EdgeInsets.only(right: 22, left: 12, top: 14, bottom: 14), - // decoration: BoxDecoration( - // color: const Color(0xFFFFFFFF).withOpacity(0.10), - // borderRadius: onDropTap.value - // ? const BorderRadius.vertical( - // top: Radius.circular(30), - // ) - // : const BorderRadius.all(Radius.circular(30)), - // gradient: LinearGradient( - // begin: Alignment.topLeft, - // end: Alignment.bottomRight, - // colors: [ - // const Color(0xFFffffff).withOpacity(0.50), - // const Color(0xFFFFFFFF).withOpacity(0.50), - // ], - // ), - // border: Border.all(color: const Color(0xFF434A53)), - // ), - // child: Center( - // child: Row( - // mainAxisAlignment: MainAxisAlignment.start, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // // if (widget.leadingImage != null) widget.leadingImage!, - // widget.leadingImage == null - // ? - // SizedBox() - // : - // widget.leadingImage!, - // const SizedBox(width: 12), - // Expanded( - // child: Text( - // selectedValues.isEmpty - // ? widget.header - // : selectedValues.join(', '), - // style: TextStyle( - // color: Colors.white, - // fontSize: 16, - // fontFamily: 'Helvetica', - // fontWeight: FontWeight.w400), - // ), - // ), - // const Spacer(), - // onDropTap.value - // ? Image.asset('assets/images/png/arrowup.png') - // : Image.asset('assets/images/png/arrowdown.png'), - // ], - // ), - // ), - // ), - // ), + GestureDetector( onTap: () { onDropTap.value = !onDropTap.value; @@ -999,7 +941,7 @@ class _CustomDropDownChexkBoxState extends State { child: Container( width: double.infinity, height: 50, - padding: EdgeInsets.only( + padding: const EdgeInsets.only( right: 22, left: 12, ), @@ -1026,7 +968,7 @@ class _CustomDropDownChexkBoxState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ widget.leadingImage == null - ? SizedBox() + ? const SizedBox() : widget.leadingImage!, const SizedBox(width: 12), Expanded( @@ -1034,7 +976,7 @@ class _CustomDropDownChexkBoxState extends State { selectedValues.isEmpty ? widget.header : selectedValues.join(', '), - style: TextStyle( + style: const TextStyle( color: Colors.white, fontSize: 16, fontFamily: 'Helvetica', diff --git a/lib/main.dart b/lib/main.dart index d1aa8d7..325010a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,16 +20,7 @@ Future main() async { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, - ]).then((value) => - // runApp(MyApp()) - runApp(const MyApp()) - - // StatsFl( - // align: Alignment.center, - // width: 200, - // height: 100, - // child: const MyApp())), - ); + ]).then((value) => runApp(const MyApp())); } final streamController = StreamController.broadcast(); @@ -42,34 +33,13 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State with WidgetsBindingObserver { - // var _connectionStatus = ConnectivityResult.values.toString(); - // final Connectivity _connectivity = Connectivity(); - // late StreamSubscription _connectivitySubscription; - List _connectionStatus = [ConnectivityResult.none]; final Connectivity _connectivity = Connectivity(); late StreamSubscription> _connectivitySubscription; - // Future checkInternet() async { - // final connectivityResult = await (Connectivity().checkConnectivity()); - - // if (connectivityResult == ConnectivityResult.wifi || - // connectivityResult == ConnectivityResult.mobile) { - // setState(() { - // _connectionStatus = connectivityResult.toString(); - // print("has internet"); - // }); - // } else { - // setState(() { - // _connectionStatus = connectivityResult.toString(); - // print("no internet"); - // }); - // } - // } - Future initConnectivity() async { late List result; - // Platform messages may fail, so we use a try/catch PlatformException. + try { result = await _connectivity.checkConnectivity(); print("initconnectivitity"); @@ -85,20 +55,7 @@ class _MyAppState extends State with WidgetsBindingObserver { return _updateConnectionStatus(result); } - // Future _updateConnectionStatus(List result) async { - // setState(() { - // _connectionStatus = result.toString(); - // }); - - // // ignore: avoid_print - // print('Connectivity changed: $_connectionStatus'); - // } - Future _updateConnectionStatus(List result) async { - // setState(() { - // _connectionStatus = result; - // }); - if (result.contains(ConnectivityResult.wifi) || result.contains(ConnectivityResult.mobile)) { setState(() { @@ -110,9 +67,8 @@ class _MyAppState extends State with WidgetsBindingObserver { _connectionStatus = result; Get.toNamed(RouteName.nointernet); }); - // Get.toNamed(RouteName.nointernet); } - // ignore: avoid_print + print('Connectivity changed: $_connectionStatus'); } @@ -121,33 +77,18 @@ class _MyAppState extends State with WidgetsBindingObserver { AndroidDeviceInfo android = await plugin.androidInfo; if (android.version.sdkInt < 33) { if (await Permission.storage.request().isGranted) { - // setState(() { - // permissionGranted = true; - // }); } else if (await Permission.storage.request().isPermanentlyDenied) { await openAppSettings(); await utils.showToast("Permission denied."); } - // else if (await Permission.audio.request().isDenied) { - // // setState(() { - // // permissionGranted = false; - // // }); - // } } else { if (await Permission.photos.request().isGranted) { - // await utils.showToast("Permission granted."); - // setState(() { - // permissionGranted = true; - // }); } else if (await Permission.photos.request().isPermanentlyDenied) { await openAppSettings(); await utils.showToast("Permission denied."); } else if (await Permission.photos.request().isDenied) { await openAppSettings(); await utils.showToast("Permission denied."); - // setState(() { - // permissionGranted = false; - // }); } } } @@ -159,7 +100,6 @@ class _MyAppState extends State with WidgetsBindingObserver { _connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus); -//do not remove this coomented code if (Platform.isAndroid) { _getStoragePermission(); } diff --git a/lib/onboarding/Signup/view_model/getUserprofile.dart b/lib/onboarding/Signup/view_model/getUserprofile.dart index d7ba6b8..effc8b2 100644 --- a/lib/onboarding/Signup/view_model/getUserprofile.dart +++ b/lib/onboarding/Signup/view_model/getUserprofile.dart @@ -12,7 +12,6 @@ import 'package:shared_preferences/shared_preferences.dart'; GetuserdetailsModel? getuserobj; - class Getuserdetails { Getuserdetails(); @@ -27,21 +26,22 @@ class Getuserdetails { // Assuming response data is a map getuserobj = GetuserdetailsModel.fromJson(responseData); - await prefs.setString('fullname', getuserobj?.data?.userData?.fullName ?? ""); - await prefs.setString('username', getuserobj?.data?.userData?.userName ?? ""); - await prefs.setString('email', getuserobj?.data?.userData?.emailAddress ?? ""); - await prefs.setString('phone', getuserobj?.data?.userData?.phoneNumber ?? ""); - await prefs.setString('accountTypefromLogin', + await prefs.setString( + 'fullname', getuserobj?.data?.userData?.fullName ?? ""); + await prefs.setString( + 'username', getuserobj?.data?.userData?.userName ?? ""); + await prefs.setString( + 'email', getuserobj?.data?.userData?.emailAddress ?? ""); + await prefs.setString( + 'phone', getuserobj?.data?.userData?.phoneNumber ?? ""); + await prefs.setString('accountTypefromLogin', getuserobj?.data?.userData?.principalTypeXid.toString() ?? ""); - - emailid = prefs.getString('email'); - myusername = prefs.getString('username'); - fullname = prefs.getString('fullname'); - phonenumber = prefs.getString('phone'); - - + emailid = prefs.getString('email'); + myusername = prefs.getString('username'); + fullname = prefs.getString('fullname'); + phonenumber = prefs.getString('phone'); + globalAccountType = prefs.getString('accountTypefromLogin'); } else if (responseData is String) { - // Parse the JSON string into a map Map jsonMap; try { jsonMap = json.decode(responseData); @@ -51,18 +51,19 @@ class Getuserdetails { ResponseStatus.FAILED); } - - await prefs.setString('fullname', getuserobj?.data?.userData?.fullName ?? ""); - await prefs.setString('username', getuserobj?.data?.userData?.userName ?? ""); - await prefs.setString('email', getuserobj?.data?.userData?.emailAddress ?? ""); - await prefs.setString('phone', getuserobj?.data?.userData?.phoneNumber ?? ""); + await prefs.setString( + 'fullname', getuserobj?.data?.userData?.fullName ?? ""); + await prefs.setString( + 'username', getuserobj?.data?.userData?.userName ?? ""); + await prefs.setString( + 'email', getuserobj?.data?.userData?.emailAddress ?? ""); + await prefs.setString( + 'phone', getuserobj?.data?.userData?.phoneNumber ?? ""); - emailid = prefs.getString('email'); - myusername = prefs.getString('username'); - fullname = prefs.getString('fullname'); - phonenumber = prefs.getString('phone'); - - + emailid = prefs.getString('email'); + myusername = prefs.getString('username'); + fullname = prefs.getString('fullname'); + phonenumber = prefs.getString('phone'); } else { // Handle other types if necessary return ResponseData( @@ -71,4 +72,4 @@ class Getuserdetails { } return response; } -} \ No newline at end of file +} diff --git a/lib/onboarding/SplashScreen.dart b/lib/onboarding/SplashScreen.dart index 8ce0999..841450c 100644 --- a/lib/onboarding/SplashScreen.dart +++ b/lib/onboarding/SplashScreen.dart @@ -32,38 +32,6 @@ class _SplashScreenState extends State { void initState() { super.initState(); - // Future.delayed(const Duration(seconds: 2), () async { - // SharedPreferences prefs = await SharedPreferences.getInstance(); - // token = prefs.getString('access-token'); - // emailid = prefs.getString('email'); - // myusername = prefs.getString('username'); - // fullname = prefs.getString('fullname'); - // phonenumber = prefs.getString('phone'); - - // if (token == null || token!.isEmpty) { - // Get.toNamed(RouteName.onboarding1); - // } else { - // await Getuserdetails().Getuser().then((value) { - // if (getuserobj?.data?.userData?.isProfileUpdated == 0) { - // String? accountype = - // getuserobj?.data?.userData?.principalTypeXid.toString(); - - // if (accountype == "1") { - // Get.toNamed(RouteName.tellusindividualscreen, - // arguments: {'pageroute': "mainscreen"}); - // } else if (accountype == "2") { - // Get.toNamed(RouteName.tellusbusinessscreen, - // arguments: {'pageroute': "mainscreen"}); - // } - // } else { - // Get.toNamed(RouteName.mainscreen); - // } - // }); - // } - // }); - - InterestListApi().getinterestlistApi(); - Future.delayed(const Duration(seconds: 2), () async { SharedPreferences prefs = await SharedPreferences.getInstance(); token = prefs.getString('access-token'); @@ -78,6 +46,7 @@ class _SplashScreenState extends State { if (token == null || token!.isEmpty) { Get.toNamed(RouteName.onboarding1); } else { + await InterestListApi().getinterestlistApi(); await Uploadata(deviceName); await Getuserdetails().Getuser().then((value) { if (getuserobj?.data?.userData?.isProfileUpdated == 0) {