From d3618b1535bb8b3c8796d0c78e95af9839292637 Mon Sep 17 00:00:00 2001 From: Shubhamshirva Date: Mon, 22 Jul 2024 11:14:34 +0530 Subject: [PATCH 1/2] api integratrd for block,timeline,delete ,logout delete timeline ,sungroups,edit timeline half done --- lib/Common/CommonWidget.dart | 2 +- lib/Common/api_urls.dart | 20 + .../EditProfile/Model/GetEditProfileIndi.dart | 165 +- .../EditProfile/View/ProfileTab.dart | 521 +++++- .../EditProfile/ViewModel/EditProfileApi.dart | 8 + .../ProfileTab/Following/Following.dart | 20 - .../ProfileTab/Model/editTimelineModel.dart | 116 ++ .../Model/timelineabilityModel.dart | 51 + .../ProfileTab/Settings/AccountSetting.dart | 55 +- .../ProfileTab/Settings/DeleteAccount.dart | 158 +- .../ProfileTab/Settings/Settings.dart | 42 +- .../Settings/View/BlockedUsers.dart | 406 ++++- .../Settings/ViewModel/BlockedUserApi.dart | 55 +- .../ProfileTab/TimeLine/AddTimeline.dart | 1529 +++++++++++++++-- .../view_model/gettimelineability.dart | 32 + .../view_model/profileGetmethod.dart | 15 + .../view_model/profilePostmethod.dart | 137 ++ lib/Login/View/loginscreen.dart | 650 +++---- lib/Utils/Common/CommonDropdown.dart | 9 +- 19 files changed, 3310 insertions(+), 681 deletions(-) create mode 100644 lib/Feed Module/Main_Screens/ProfileTab/Model/editTimelineModel.dart create mode 100644 lib/Feed Module/Main_Screens/ProfileTab/Model/timelineabilityModel.dart create mode 100644 lib/Feed Module/Main_Screens/ProfileTab/view_model/gettimelineability.dart diff --git a/lib/Common/CommonWidget.dart b/lib/Common/CommonWidget.dart index e6cceea..c0ed6d9 100644 --- a/lib/Common/CommonWidget.dart +++ b/lib/Common/CommonWidget.dart @@ -171,7 +171,7 @@ Future datePicker( ); if (picked != null) { - controller.text = DateFormat('dd-MM-yyyy').format(picked); + controller.text = DateFormat('yyyy-MM-dd').format(picked); } } diff --git a/lib/Common/api_urls.dart b/lib/Common/api_urls.dart index 057a17c..591351c 100644 --- a/lib/Common/api_urls.dart +++ b/lib/Common/api_urls.dart @@ -59,6 +59,26 @@ class ApiUrls { static const postchangepassverify = "${baseUrl}verify-update-password-otp"; + static const gettimelineabilitylist = "${baseUrl}list-of-abilities"; + + static const posttimeline = "${baseUrl}create-timeline"; + + static const postaccountvisibility = "${baseUrl}account-visibility"; + + static const postdeleteaccount = "${baseUrl}delete-my-account"; + + static const postlogoutaccount = "${baseUrl}logout"; + + static const getedittimeline = "${baseUrl}get-timeline-data"; + + static const postedittimeline = "${baseUrl}update-timeline"; + + static const postremovetimeline = "${baseUrl}delete-timeline"; + + + + + static const postnotification = "${baseUrl}update-notification-settings"; diff --git a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/GetEditProfileIndi.dart b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/GetEditProfileIndi.dart index 9558581..2422a2a 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/GetEditProfileIndi.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/Model/GetEditProfileIndi.dart @@ -29,6 +29,7 @@ class Data { int? id; String? userName; String? fullName; + String? profileImage; String? gender; String? dateOfBirth; List? interest; @@ -39,11 +40,16 @@ class Data { String? weight; String? battingAverage; Follows? follows; + List? timelines; + int? accountVisibility; + List? myJoinedSubgroups; + Data( {this.id, this.userName, this.fullName, + this.profileImage, this.gender, this.dateOfBirth, this.interest, @@ -53,12 +59,17 @@ class Data { this.height, this.weight, this.battingAverage, - this.follows}); + this.follows, + this.timelines, + this.accountVisibility, + this.myJoinedSubgroups + }); Data.fromJson(Map json) { id = json['id']; userName = json['user_name']; fullName = json['full_name']; + profileImage = json['profile_image']; gender = json['gender']; dateOfBirth = json['date_of_birth']; if (json['interest'] != null) { @@ -75,6 +86,19 @@ class Data { battingAverage = json['batting_average']; follows = json['follows'] != null ? new Follows.fromJson(json['follows']) : null; + if (json['timelines'] != null) { + timelines = []; + json['timelines'].forEach((v) { + timelines!.add(new Timelines.fromJson(v)); + }); + } + accountVisibility = json['account_visibility']; + if (json['my_joined_subgroups'] != null) { + myJoinedSubgroups = []; + json['my_joined_subgroups'].forEach((v) { + myJoinedSubgroups!.add(new MyJoinedSubgroups.fromJson(v)); + }); + } } Map toJson() { @@ -82,6 +106,7 @@ class Data { data['id'] = this.id; data['user_name'] = this.userName; data['full_name'] = this.fullName; + data['profile_image'] = this.profileImage; data['gender'] = this.gender; data['date_of_birth'] = this.dateOfBirth; if (this.interest != null) { @@ -95,6 +120,14 @@ class Data { data['batting_average'] = this.battingAverage; if (this.follows != null) { data['follows'] = this.follows!.toJson(); + } + if (this.timelines != null) { + data['timelines'] = this.timelines!.map((v) => v.toJson()).toList(); + } + data['account_visibility'] = this.accountVisibility; + if (this.myJoinedSubgroups != null) { + data['my_joined_subgroups'] = + this.myJoinedSubgroups!.map((v) => v.toJson()).toList(); } return data; } @@ -119,6 +152,77 @@ class Interest { } } +class Timelines { + int? id; + String? clubName; + String? roleName; + String? teamName; + String? startDate; + String? endDate; + String? abilitiesXids; + List? abilities; + + Timelines( + {this.id, + this.clubName, + this.roleName, + this.teamName, + this.startDate, + this.endDate, + this.abilitiesXids, + this.abilities}); + + Timelines.fromJson(Map json) { + id = json['id']; + clubName = json['club_name']; + roleName = json['role_name']; + teamName = json['team_name']; + startDate = json['start_date']; + endDate = json['end_date']; + abilitiesXids = json['abilities_xids']; + if (json['abilities'] != null) { + abilities = []; + json['abilities'].forEach((v) { + abilities!.add(new Abilities.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['club_name'] = this.clubName; + data['role_name'] = this.roleName; + data['team_name'] = this.teamName; + data['start_date'] = this.startDate; + data['end_date'] = this.endDate; + data['abilities_xids'] = this.abilitiesXids; + if (this.abilities != null) { + data['abilities'] = this.abilities!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Abilities { + int? id; + String? name; + + Abilities({this.id, this.name}); + + Abilities.fromJson(Map json) { + id = json['id']; + name = json['name']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + return data; + } +} + class Follows { int? following; int? followers; @@ -137,3 +241,62 @@ class Follows { return data; } } + +class MyJoinedSubgroups { + int? id; + int? iamPrincipalXid; + int? manageGroupXid; + int? manageSubGroupXid; + SubGroupData? subGroupData; + + MyJoinedSubgroups( + {this.id, + this.iamPrincipalXid, + this.manageGroupXid, + this.manageSubGroupXid, + this.subGroupData}); + + MyJoinedSubgroups.fromJson(Map json) { + id = json['id']; + iamPrincipalXid = json['iam_principal_xid']; + manageGroupXid = json['manage_group_xid']; + manageSubGroupXid = json['manage_sub_group_xid']; + subGroupData = json['sub_group_data'] != null + ? new SubGroupData.fromJson(json['sub_group_data']) + : null; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['iam_principal_xid'] = this.iamPrincipalXid; + data['manage_group_xid'] = this.manageGroupXid; + data['manage_sub_group_xid'] = this.manageSubGroupXid; + if (this.subGroupData != null) { + data['sub_group_data'] = this.subGroupData!.toJson(); + } + return data; + } +} + +class SubGroupData { + int? id; + String? title; + String? subGroupImage; + + SubGroupData({this.id, this.title, this.subGroupImage}); + + SubGroupData.fromJson(Map json) { + id = json['id']; + title = json['title']; + subGroupImage = json['sub_group_image']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['title'] = this.title; + data['sub_group_image'] = this.subGroupImage; + return data; + } +} 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 6267de2..c4167f8 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/View/ProfileTab.dart @@ -5,13 +5,17 @@ import 'package:get/get.dart'; import 'package:regroup/Common/CommonBottomNavigationBar.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.dart'; 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/Utils/Common/blureffect.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:intl/intl.dart'; class ProfileTab extends StatefulWidget { const ProfileTab({super.key}); @@ -124,6 +128,25 @@ class _ProfileTabState extends State { } } + int? timelineremoveid; + + RemoveTimelineUploadata() async { + utils.loader(); + Map updata = { + "timeline_id": timelineremoveid, + }; + final data = await Profilepostmethod().postRemoveTimeline(updata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("block done"); + return utils.showToast(data.message); + } else { + Get.back(); + print("block not done"); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { return Scaffold( @@ -485,23 +508,6 @@ class _ProfileTabState extends State { ], ), ), - SizedBox( - height: 190.h, - child: ListView.builder( - shrinkWrap: true, - scrollDirection: Axis.horizontal, - padding: EdgeInsets.only(left: 16.w), - itemCount: cardtile.length, - itemBuilder: (context, index) { - return Padding( - padding: EdgeInsets.only(right: 20.w), - child: profilecardtile( - imagePath: cardtile[index]["imagePath"], - title: cardtile[index]["title"]), - ); - }, - ), - ), sizedBoxHeight(20.h), Padding( padding: EdgeInsets.symmetric(horizontal: 16.w), @@ -514,7 +520,11 @@ class _ProfileTabState extends State { Spacer(), InkWell( onTap: () { - Get.toNamed(RouteName.addtimeline); + Get.toNamed(RouteName.addtimeline, + arguments: { + 'id': 0, + 'edit': false, + }); }, child: Image.asset( "assets/images/png/iconamoon_edit-thin.png", @@ -525,23 +535,339 @@ class _ProfileTabState extends State { ], ), sizedBoxHeight(20.h), - SizedBox( - height: 300.h, - child: ListView.builder( - shrinkWrap: true, - itemCount: timeline.length, - itemBuilder: (context, index) { - return commonTimelineCard( - imagePath: timeline[index] - ["imagePath"], - title: timeline[index] - ["title"]); - }, - )), + getEditProfileIndi!.data!.timelines!.isEmpty + ? Center( + child: + text18w700white("Add timeline")) + : SizedBox( + height: 200.h, + child: ListView.builder( + shrinkWrap: true, + itemCount: getEditProfileIndi! + .data!.timelines!.length, + itemBuilder: (context, index) { + DateTime startDate = + DateTime.parse( + getEditProfileIndi! + .data! + .timelines![index] + .startDate!); + DateTime endDate = + DateTime.parse( + getEditProfileIndi! + .data! + .timelines![index] + .endDate!); + + String formattedStartDate = + DateFormat('dd MMMM yyyy') + .format(startDate); + String formattedEndDate = + DateFormat('dd MMMM yyyy') + .format(endDate); + + // Combine formatted dates + String startToEnd = + '$formattedStartDate - $formattedEndDate'; + + var timeline = + getEditProfileIndi!.data! + .timelines![index]; + + List> + abilities = + timeline.abilities! + .map((ability) => { + 'id': ability.id, + 'name': + ability.name, + }) + .toList(); + return + // commonTimelineCard( + // imagePath: getEditProfileIndi + // ?.data + // ?.profileImage ?? + // '', + // title: getEditProfileIndi! + // .data! + // .timelines![index] + // .clubName!, + // role: getEditProfileIndi! + // .data! + // .timelines![index] + // .roleName!, + // teamname: getEditProfileIndi! + // .data! + // .timelines![index] + // .teamName!, + // abilities: abilities, + // id: getEditProfileIndi!.data! + // .timelines![index].id, + // starttoend: startToEnd, + // ); + Row( + children: [ + Container( + width: 10, + height: 170.h, + child: Stack( + clipBehavior: Clip.none, + children: [ + Positioned( + top: 50.h, + child: Container( + height: 11.h, + width: 11.w, + decoration: BoxDecoration( + color: Colors + .white, + shape: BoxShape + .circle)), + ), + Positioned( + right: 3.w, + child: Container( + width: 1.w, + height: 170.h, + decoration: + BoxDecoration( + color: Colors + .white), + ), + ), + ], + ), + ), + sizedBoxWidth(20.w), + Expanded( + child: Column( + children: [ + commonGlassUI( + width: + double.infinity, + height: 155.h, + borderRadius: + BorderRadius + .circular( + 10.r), + customWidget: + Padding( + padding: EdgeInsets + .only( + left: + 16.w, + right: + 16.w, + top: + 10.h), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + mainAxisAlignment: + MainAxisAlignment + .center, + children: [ + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Row( + children: [ + getEditProfileIndi?.data?.profileImage == null || getEditProfileIndi!.data!.profileImage!.isEmpty + ? CircleAvatar(radius: 10.r, backgroundImage: AssetImage('assets/images/png/cimg1.png')) + : CircleAvatar(radius: 10.r, backgroundImage: NetworkImage(getEditProfileIndi!.data!.profileImage!)), + sizedBoxWidth( + 8.w), + getEditProfileIndi!.data!.timelines![index].clubName == null || getEditProfileIndi!.data!.timelines![index].clubName!.isEmpty + ? text14700white('Regroup') + : text14700white(getEditProfileIndi!.data!.timelines![index].clubName!) + ], + ), + InkWell( + onTap: + () { + // setState( + // () { + // timelineremoveid = + // getEditProfileIndi!.data!.timelines![index].id ?? 0; + // getEditProfileIndi!.data!.timelines!.removeWhere((item) => + // item.id! == + // timelineremoveid); + // // .removeAt(index); + // RemoveTimelineUploadata(); + // }); + + Get.toNamed(RouteName.addtimeline, arguments: { + 'id': getEditProfileIndi!.data!.timelines![index].id, + 'edit': true, + }); + }, + child: + SizedBox( + width: + 20.w, + height: + 20.h, + child: + Image.asset( + "assets/images/png/iconamoon_edit-thin.png", + height: + 14.h, + width: + 14.w, + ), + ), + ) + ], + ), + sizedBoxHeight( + 10.h), + getEditProfileIndi!.data!.timelines![index].roleName == + null || + getEditProfileIndi! + .data! + .timelines![ + index] + .roleName! + .isEmpty + ? text12700white( + 'regroup') + : text12700white(getEditProfileIndi! + .data! + .timelines![ + index] + .roleName!), + sizedBoxHeight( + 10.h), + getEditProfileIndi!.data!.timelines![index].teamName == + null || + getEditProfileIndi! + .data! + .timelines![ + index] + .teamName! + .isEmpty + ? text12700white( + 'regroup') + : text12700white(getEditProfileIndi! + .data! + .timelines![ + index] + .teamName!), + sizedBoxHeight( + 10.h), + + startToEnd + .isEmpty + ? text12400white( + 'No date') + : text12400white( + startToEnd), + sizedBoxHeight( + 10.h), + + abilities + .isEmpty + ? text10400whiteblur( + 'No data') + : + // ListView.builder( + // shrinkWrap: true, + // scrollDirection: Axis.horizontal, + // padding: EdgeInsets.only(left: 16.w), + // itemCount: abilities.length, + // itemBuilder: (context, index) { + // return + // text10400whiteblur(abilities.toString()); + + // }, + // ), + + Container( + height: + 30.h, // Adjust the height as needed + child: + ListView.builder( + shrinkWrap: + true, + scrollDirection: + Axis.horizontal, + itemCount: + abilities.length, + itemBuilder: + (context, index) { + if (index < abilities.length) { + String abilityName = abilities[index]['name']; + return Padding( + padding: EdgeInsets.only(right: 8.w), + child: text10400whiteblur(abilityName), + ); + } else { + return SizedBox(); + } + }, + ), + ), + ], + ), + ), + // border: 1 + ), + ], + ), + ), + ], + ); + }, + )), sizedBoxHeight(30.h), - text18w700white("Posts"), ]), ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + text18w700white("Subgroups"), + ], + ), + ), + sizedBoxHeight(20.h), + SizedBox( + height: 190.h, + width: double.infinity, + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + padding: EdgeInsets.only(left: 16.w), + itemCount: getEditProfileIndi! + .data!.myJoinedSubgroups!.length, + itemBuilder: (context, index) { + return Padding( + padding: EdgeInsets.only(right: 20.w), + child: profilecardtile( + imagePath: getEditProfileIndi! + .data! + .myJoinedSubgroups![index] + .subGroupData! + .subGroupImage ?? + '', + // cardtile[index]["imagePath"], + title: getEditProfileIndi! + .data! + .myJoinedSubgroups![index] + .subGroupData! + .title! + + // cardtile[index]["title"] + ), + ); + }, + ), + ), normalcardtile( profileImg: 'assets/images/png/Ellipse 48.png', title: 'Jocelyn Dokidis', @@ -973,8 +1299,15 @@ class _ProfileTabState extends State { ); } - Widget commonTimelineCard( - {required String imagePath, required String title}) { + Widget commonTimelineCard({ + required String? imagePath, + required String? title, + required String? role, + required String? teamname, + required String? starttoend, + required int? id, + required List>? abilities, + }) { return Row( children: [ Container( @@ -1008,31 +1341,104 @@ class _ProfileTabState extends State { children: [ commonGlassUI( width: double.infinity, - height: 145.h, + height: 155.h, borderRadius: BorderRadius.circular(10.r), customWidget: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), + padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.h), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - CircleAvatar( - radius: 10.r, - backgroundImage: AssetImage(imagePath), + Row( + children: [ + imagePath == null || imagePath.isEmpty + ? CircleAvatar( + radius: 10.r, + backgroundImage: AssetImage( + 'assets/images/png/cimg1.png')) + : CircleAvatar( + radius: 10.r, + backgroundImage: NetworkImage(imagePath)), + sizedBoxWidth(8.w), + title == null || title.isEmpty + ? text14700white('Regroup') + : text14700white(title) + ], ), - sizedBoxWidth(8.w), - text14700white(title) + InkWell( + onTap: () { + setState(() { + timelineremoveid = id; + }); + + // Get.toNamed(RouteName.addtimeline, arguments: { + // 'id': id, + // 'edit': true, + // }); + }, + child: SizedBox( + width: 20.w, + height: 20.h, + child: Image.asset( + "assets/images/png/iconamoon_edit-thin.png", + height: 14.h, + width: 14.w, + ), + ), + ) ], ), sizedBoxHeight(10.h), - text12700white("Team captain"), - sizedBoxHeight(8.h), - text12400white("April 2023 - May 2024"), + role == null || role.isEmpty + ? text12700white('regroup') + : text12700white(role), sizedBoxHeight(10.h), - text10400whiteblur( - "Lorem Ipsum is simply dummy text of the printing and typesetting industry.") + teamname == null || teamname.isEmpty + ? text12700white('regroup') + : text12700white(teamname), + sizedBoxHeight(10.h), + starttoend == null || starttoend.isEmpty + ? text12400white('No date') + : text12400white(starttoend), + sizedBoxHeight(10.h), + abilities == null || abilities.isEmpty + ? text10400whiteblur('No data') + : + // ListView.builder( + // shrinkWrap: true, + // scrollDirection: Axis.horizontal, + // padding: EdgeInsets.only(left: 16.w), + // itemCount: abilities.length, + // itemBuilder: (context, index) { + // return + // text10400whiteblur(abilities.toString()); + + // }, + // ), + + Container( + height: 30.h, // Adjust the height as needed + child: ListView.builder( + shrinkWrap: true, + scrollDirection: Axis.horizontal, + itemCount: abilities.length, + itemBuilder: (context, index) { + if (index < abilities.length) { + String abilityName = + abilities[index]['name']; + return Padding( + padding: EdgeInsets.only(right: 8.w), + child: text10400whiteblur(abilityName), + ); + } else { + return SizedBox(); + } + }, + ), + ), ], ), ), @@ -1409,19 +1815,24 @@ class _ProfileTabState extends State { )); } - Widget profilecardtile({required String imagePath, required String title}) { + Widget profilecardtile({required String? imagePath, required String? title}) { return Column( children: [ Container( - height: 109.h, - width: 100.w, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10.r), - ), - child: Image.asset(imagePath), - ), + height: 109.h, + width: 100.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.r), + ), + child: imagePath == null || imagePath.isEmpty + ? Image.asset('assets/images/png/Rectangle 29ss.png') + : Image.network(imagePath)), sizedBoxHeight(10.h), - SizedBox(width: 100.w, child: text12w700_FCFCFC(title)), + SizedBox( + width: 100.w, + child: title == null || title.isEmpty + ? text12w700_FCFCFC('Reegroup') + : text12w700_FCFCFC(title)), ], ); } 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 f31a781..aee5e5d 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart @@ -8,6 +8,8 @@ import 'package:shared_preferences/shared_preferences.dart'; GetEditProfileIndi? getEditProfileIndi; GetEditProfileBus? getEditProfileBus; +bool accountvisibility = true; + class EditProfileApi { EditProfileApi(); @@ -34,6 +36,12 @@ class EditProfileApi { if (response.status == ResponseStatus.SUCCESS) { if (response.data["status"] == "success") { print("Success---->"); + if (getEditProfileIndi!.data!.accountVisibility == 1) { + accountvisibility = true; + } else { + accountvisibility = false; + } + print(accountvisibility.toString()); return ResponseData( response.data['message'], ResponseStatus.SUCCESS, data: response.data); diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart b/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart index ea23321..f10c855 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart @@ -141,26 +141,6 @@ class _FollowingState extends State { }, itemBuilder: (context, index) { return - // Column( - // children: [ - // Followinglist( - // imagePath: followingobj?.data?[index] - // .following?.profilePhoto ?? - // '', - // title: followingobj! - // .data?[index].following?.fullName ?? - // '', - // subtitle: followingobj! - // .data?[index].following?.userName ?? - // '', - // unfollowontap: (id) => Uploadata(id), - // unfollowindex: followingobj! - // .data![index].following!.id!, - // ), - // if (index != followingobj!.data!.length - 1) - // commonDivider(), - // ], - // ); Column( children: [ Padding( diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Model/editTimelineModel.dart b/lib/Feed Module/Main_Screens/ProfileTab/Model/editTimelineModel.dart new file mode 100644 index 0000000..67cfe5e --- /dev/null +++ b/lib/Feed Module/Main_Screens/ProfileTab/Model/editTimelineModel.dart @@ -0,0 +1,116 @@ +class GetEditTimelineModel { + String? status; + int? statusCode; + String? message; + Data? data; + + GetEditTimelineModel({this.status, this.statusCode, this.message, this.data}); + + GetEditTimelineModel.fromJson(Map json) { + status = json['status']; + statusCode = json['status_code']; + message = json['message']; + data = json['data'] != null ? new Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = new Map(); + data['status'] = this.status; + data['status_code'] = this.statusCode; + data['message'] = this.message; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + List? abilities; + TimelineData? timelineData; + + Data({this.abilities, this.timelineData}); + + Data.fromJson(Map json) { + if (json['abilities'] != null) { + abilities = []; + json['abilities'].forEach((v) { + abilities!.add(new Abilities.fromJson(v)); + }); + } + timelineData = json['timeline_data'] != null + ? new TimelineData.fromJson(json['timeline_data']) + : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.abilities != null) { + data['abilities'] = this.abilities!.map((v) => v.toJson()).toList(); + } + if (this.timelineData != null) { + data['timeline_data'] = this.timelineData!.toJson(); + } + return data; + } +} + +class Abilities { + int? id; + String? name; + + Abilities({this.id, this.name}); + + Abilities.fromJson(Map json) { + id = json['id']; + name = json['name']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + return data; + } +} + +class TimelineData { + int? id; + String? clubName; + String? roleName; + String? teamName; + String? startDate; + String? endDate; + String? abilitiesXids; + + TimelineData( + {this.id, + this.clubName, + this.roleName, + this.teamName, + this.startDate, + this.endDate, + this.abilitiesXids}); + + TimelineData.fromJson(Map json) { + id = json['id']; + clubName = json['club_name']; + roleName = json['role_name']; + teamName = json['team_name']; + startDate = json['start_date']; + endDate = json['end_date']; + abilitiesXids = json['abilities_xids']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['club_name'] = this.clubName; + data['role_name'] = this.roleName; + data['team_name'] = this.teamName; + data['start_date'] = this.startDate; + data['end_date'] = this.endDate; + data['abilities_xids'] = this.abilitiesXids; + return data; + } +} diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Model/timelineabilityModel.dart b/lib/Feed Module/Main_Screens/ProfileTab/Model/timelineabilityModel.dart new file mode 100644 index 0000000..18b3f0f --- /dev/null +++ b/lib/Feed Module/Main_Screens/ProfileTab/Model/timelineabilityModel.dart @@ -0,0 +1,51 @@ +class TimelineAbilityListModel { + String? status; + int? statusCode; + String? message; + List? data; + + TimelineAbilityListModel( + {this.status, this.statusCode, this.message, this.data}); + + TimelineAbilityListModel.fromJson(Map json) { + status = json['status']; + statusCode = json['status_code']; + message = json['message']; + if (json['data'] != null) { + data = []; + json['data'].forEach((v) { + data!.add(new Data.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['status'] = this.status; + data['status_code'] = this.statusCode; + data['message'] = this.message; + if (this.data != null) { + data['data'] = this.data!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class Data { + int? id; + String? name; + + Data({this.id, this.name}); + + Data.fromJson(Map json) { + id = json['id']; + name = json['name']; + } + + Map toJson() { + final Map data = new Map(); + data['id'] = this.id; + data['name'] = this.name; + return data; + } +} diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Settings/AccountSetting.dart b/lib/Feed Module/Main_Screens/ProfileTab/Settings/AccountSetting.dart index a37e0aa..9e9d517 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/Settings/AccountSetting.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/Settings/AccountSetting.dart @@ -3,11 +3,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.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/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/blureffect.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class AccountSettings extends StatefulWidget { const AccountSettings({super.key}); @@ -17,7 +22,46 @@ class AccountSettings extends StatefulWidget { } class _AccountSettingsState extends State { - bool swichvalue = false; + // bool swichvalue = false; + + Future UploadData() async { + print("upload data called"); + SharedPreferences prefs = await SharedPreferences.getInstance(); + + int? accountype ; + if (accountvisibility == false) { + accountype = 0; + } + else if (accountvisibility == true) { + accountype = 1; + } + Map updata = { + "is_account_visibility": accountype, + }; + + final data = await Profilepostmethod().postAccountvisibility(updata); + + if (data.status == ResponseStatus.SUCCESS) { + String? accountype; + +accountype = prefs.getString('accountTypefromLogin'); + +if (accountype == "1") { + EditProfileApi() + .getEditProfileIndividual(); +} +else if (accountype == "2") { + EditProfileApi() + .getEditProfileBusiness(); +} + + + + return utils.showToast(data.message); + } else { + return utils.showToast(data.message); + } + } @override Widget build(BuildContext context) { return Scaffold( @@ -62,12 +106,15 @@ class _AccountSettingsState extends State { Transform.scale( scale: 0.9, child: CupertinoSwitch( - value: swichvalue, + value: accountvisibility, trackColor: Colors.white.withOpacity(0.4), activeColor: Color(0xFF34C759), - onChanged: (bool? value) { + onChanged: (bool value) { setState(() { - swichvalue = value ?? false; + accountvisibility = value; + UploadData(); + + // swichvalue = value ?? false; }); })) ]), diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Settings/DeleteAccount.dart b/lib/Feed Module/Main_Screens/ProfileTab/Settings/DeleteAccount.dart index 513816c..de96830 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/Settings/DeleteAccount.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/Settings/DeleteAccount.dart @@ -1,11 +1,20 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:get/get.dart'; import 'package:regroup/Common/CommonButton.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/blureffect.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; +import 'package:regroup/resources/routes/route_name.dart'; +import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class DeleteAccount extends StatefulWidget { const DeleteAccount({super.key}); @@ -15,54 +24,113 @@ class DeleteAccount extends StatefulWidget { } class _DeleteAccountState extends State { + TextEditingController leavingcontroller = TextEditingController(); + + Uploadata() async { + utils.loader(); + Map updata = { + "reason": leavingcontroller.text, + }; + final data = await Profilepostmethod().postDeleteaccount(updata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("delete done"); + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.remove('access-token'); + await prefs.remove('fullname'); + await prefs.remove('username'); + await prefs.remove('email'); + await prefs.remove('phone'); + await prefs.remove('accountTypefromLogin'); + await prefs.remove('principal_xid'); + await prefs.remove('accountTypeValue'); + + await prefs.clear(); + + Get.offNamed(RouteName.loginScreen); + + return utils.showToast(data.message); + } else { + Get.back(); + print("delete not done"); + return utils.showToast(data.message); + } + } + @override Widget build(BuildContext context) { - return Scaffold( - // key: _scaffoldKey1, - resizeToAvoidBottomInset: false, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "", - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), fit: BoxFit.fill)), + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // key: _scaffoldKey1, + // resizeToAvoidBottomInset: false, + backgroundColor: Color(0xFF222935), + extendBody: true, + appBar: CommonAppbar( + titleTxt: "", ), - SingleChildScrollView( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: Column(children: [ - sizedBoxHeight(25.h), - text20400white("Sad to see you go"), - sizedBoxHeight(16.h), - Image.asset( - "assets/images/png/Frame 1.png", - height: 119.h, - width: 119.w, - ), - sizedBoxHeight(20.h), - SizedBox( - width: 311.w, - child: text16400white( - "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type ", - textAlign: TextAlign.center), - ), - sizedBoxHeight(30.h), - text18w400white("Tell us why you are leaving ?"), - sizedBoxHeight(10.h), - CustomTextFormField2( - maxlines: 3, - ), - sizedBoxHeight(20.h), - CommonBtn(text: "I don’t want to delete"), - sizedBoxHeight(18.h), - text16400white("Yes I am ready to delete my account"), - ]), + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), ), - ) - ])); + SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column(children: [ + sizedBoxHeight(25.h), + text20400white("Sad to see you go"), + sizedBoxHeight(16.h), + Image.asset( + "assets/images/png/Frame 1.png", + height: 119.h, + width: 119.w, + ), + sizedBoxHeight(20.h), + SizedBox( + width: 311.w, + child: text16400white( + "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type ", + textAlign: TextAlign.center), + ), + sizedBoxHeight(30.h), + text18w400white("Tell us why you are leaving ?"), + sizedBoxHeight(10.h), + CustomTextFormField2( + maxlines: 3, + hintText: "Enter why are you leaving", + validator: (value) { + if (value!.isEmpty) { + return 'Enter your full name '; + } + return null; + }, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + FilteringTextInputFormatter.allow(RegExp('[a-zA-Z ]')) + ], + textEditingController: leavingcontroller, + ), + sizedBoxHeight(20.h), + CommonBtn(text: "I don’t want to delete"), + sizedBoxHeight(18.h), + GestureDetector( + onTap: () { + if (leavingcontroller.text.isBlank!) { + utils.showToast('Please tell us why are you leaving'); + } else { + Uploadata(); + } + }, + child: text16400white( + "Yes I am ready to delete my account")), + ]), + ), + ) + ])), + ); } } diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Settings/Settings.dart b/lib/Feed Module/Main_Screens/ProfileTab/Settings/Settings.dart index c9ce84e..f0fa363 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/Settings/Settings.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/Settings/Settings.dart @@ -5,9 +5,12 @@ import 'package:get/get.dart'; import 'package:glassmorphism/glassmorphism.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/blureffect.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; import 'package:regroup/resources/routes/route_name.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -20,6 +23,36 @@ class Settings extends StatefulWidget { } class _SettingsState extends State { + + Uploadata() async { + utils.loader(); + final data = await Profilepostmethod().postLogoutaccount(); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("delete done"); + SharedPreferences prefs = await SharedPreferences.getInstance(); + await prefs.remove('access-token'); + await prefs.remove('fullname'); + await prefs.remove('username'); + await prefs.remove('email'); + await prefs.remove('phone'); + await prefs.remove('accountTypefromLogin'); + await prefs.remove('principal_xid'); + await prefs.remove('accountTypeValue'); + + await prefs.clear(); + + Get.offNamed(RouteName.loginScreen); + + return utils.showToast(data.message); + } else { + Get.back(); + print("delete not done"); + return utils.showToast(data.message); + } + } + + @override Widget build(BuildContext context) { return Scaffold( @@ -150,10 +183,11 @@ class _SettingsState extends State { children: [ GestureDetector( onTap: () async { - SharedPreferences prefs = - await SharedPreferences.getInstance(); - await prefs.clear(); - Get.offAllNamed(RouteName.loginScreen); + // SharedPreferences prefs = + // await SharedPreferences.getInstance(); + // await prefs.clear(); + // Get.offAllNamed(RouteName.loginScreen); + Uploadata(); }, child: commonGlassContainer( width: 130.w, diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Settings/View/BlockedUsers.dart b/lib/Feed Module/Main_Screens/ProfileTab/Settings/View/BlockedUsers.dart index 89623a6..edfb5b6 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/Settings/View/BlockedUsers.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/Settings/View/BlockedUsers.dart @@ -1,3 +1,6 @@ +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -5,11 +8,13 @@ import 'package:get/get.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Settings/Model/FetchBlockUser.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Settings/ViewModel/BlockedUserApi.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; import 'package:regroup/Utils/texts.dart'; +import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; import 'package:shared_preferences/shared_preferences.dart'; class BlockedUsers extends StatefulWidget { @@ -57,13 +62,16 @@ class _BlockedUsersState extends State { "subtitle": "Lorem ipsum dummy text", }, ]; - late Future myfuture; + + // late Future myfuture; double? blockedXid; + StreamController searchcontroller = StreamController(); + unblockDone(int index) async { SharedPreferences prefs = await SharedPreferences.getInstance(); await prefs.setInt('blockedprincipalxid', - fetchblockuser!.data![index].blockedIamPrincipalXid!); + fetchblockuserobj!.data![index].blockedIamPrincipalXid!); blockedXid = prefs.getInt('blockedprincipalxid')!.toDouble(); Map updata = { "blocked_iam_principal_xid": blockedXid.toString(), @@ -83,7 +91,7 @@ class _BlockedUsersState extends State { // utils.showToast('Unblock user successfully'); setState(() { - fetchblockuser!.data!.removeAt(index); + fetchblockuserobj!.data!.removeAt(index); }); print('success'); } else { @@ -104,11 +112,19 @@ class _BlockedUsersState extends State { @override void initState() { - myfuture = BlockUserAPI().fetchBlockUser(); + var updata = ""; + // myfuture = BlockUserAPI().fetchBlockUser(); + BlockUserAPI().getBlockedusers(updata, streamController: searchcontroller); // TODO: implement initState super.initState(); } + @override + void dispose() { + searchcontroller.close(); + super.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -119,96 +135,301 @@ class _BlockedUsersState extends State { appBar: CommonAppbar( titleTxt: "Blocked users", ), - body: FutureBuilder( - future: myfuture, - builder: (ctx, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting) { - return Center( - child: CircularProgressIndicator( - color: Colors.blue, + body: Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage("assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), + ), + SingleChildScrollView( + child: + Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + sizedBoxHeight(25.h), + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: CustomTextFormField( + leadingIcon: SizedBox( + height: 23, + width: 23, + child: Center( + child: Image.asset( + "assets/images/png/ion_search-outline.png", + height: 23, + width: 23, + ), + ), ), - ); - } + hintText: "Search people", + texttype: TextInputType.text, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + ], + onInput: (value) { + // Onboard().postGroupsearch({"search": value}, + // streamController: searchcontroller); + // searchGroups(value!); + BlockUserAPI().getBlockedusers(value, + streamController: searchcontroller); + }, + ), + ), + sizedBoxHeight(25.h), - if (snapshot.hasError) { - return Center( - child: Text( - '${snapshot.error} occurred', - style: TextStyle(fontSize: 18.spMin), - ), - ); - } - - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - print("Data fetched-->"); - return Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage( - "assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - sizedBoxHeight(25.h), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: CustomTextFormField( - leadingIcon: SizedBox( - height: 23, - width: 23, - child: Center( - child: Image.asset( - "assets/images/png/ion_search-outline.png", - height: 23, - width: 23, - ), - ), - ), - hintText: "Search people", - ), - ), - sizedBoxHeight(25.h), - Expanded( - child: ListView.builder( + // Expanded( + // child: ListView.builder( + // shrinkWrap: true, + // itemCount: fetchblockuser!.data!.length, + // itemBuilder: (context, index) { + // return Column( + // children: [ + // blockedUser( + // imagePath: fetchblockuser!.data![index] + // .blockedProfile!.profilePhoto ?? + // '', + // title: fetchblockuser!.data![index] + // .blockedProfile!.fullName ?? + // '', + // subtitle: fetchblockuser!.data![index] + // .blockedProfile!.userName ?? + // '', + // index: index), + // // blockedUser( + // // imagePath: blockedUserData[index] + // // ["imagePath"], + // // title: blockedUserData[index]["title"], + // // subtitle: blockedUserData[index] + // // ["subtitle"]), + // if (index != fetchblockuser!.data!.length - 1) + // commonDivider(), + // ], + // ); + // }, + // ), + // ), + StreamBuilder( + stream: searchcontroller.stream, + builder: (ctx, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + // Display shimmer effect while waiting for data + return Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + // Handle error state + return Center( + child: Text( + '${snapshot.error} occurred', + style: TextStyle(fontSize: 18), + ), + ); + } else { + // Data has been loaded, show actual UI + return fetchblockuserobj!.data!.isEmpty + ? _buildNoDataBody(context) + : ListView.separated( + physics: ScrollPhysics(), shrinkWrap: true, - itemCount: fetchblockuser!.data!.length, + itemCount: fetchblockuserobj!.data!.length, + separatorBuilder: + (BuildContext context, int index) { + return commonDivider(); + }, itemBuilder: (context, index) { return Column( children: [ blockedUser( - imagePath: fetchblockuser!.data![index] + imagePath: fetchblockuserobj!.data![index] .blockedProfile!.profilePhoto ?? '', - title: fetchblockuser!.data![index] + title: fetchblockuserobj!.data![index] .blockedProfile!.fullName ?? '', - subtitle: fetchblockuser!.data![index] + subtitle: fetchblockuserobj!.data![index] .blockedProfile!.userName ?? '', index: index), - // blockedUser( - // imagePath: blockedUserData[index] - // ["imagePath"], - // title: blockedUserData[index]["title"], - // subtitle: blockedUserData[index] - // ["subtitle"]), - if (index != fetchblockuser!.data!.length - 1) - commonDivider(), ], ); + + // Column( + // children: [ + // Padding( + // padding: EdgeInsets.symmetric( + // vertical: 16.h, horizontal: 16.w), + // child: Row( + // children: [ + // followingobj!.data![index].following! + // .profilePhoto == + // null || + // followingobj! + // .data![index] + // .following! + // .profilePhoto! + // .isEmpty + // ? CircleAvatar( + // backgroundImage: AssetImage( + // 'assets/images/png/Ellipse 43.png'), + // radius: 25.r, + // ) + // : CircleAvatar( + // backgroundImage: NetworkImage( + // followingobj! + // .data![index] + // .following! + // .profilePhoto!), + // radius: 25.r, + // ), + // sizedBoxWidth(10.w), + // Column( + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // followingobj! + // .data![index] + // .following! + // .fullName == + // null || + // followingobj! + // .data![index] + // .following! + // .fullName! + // .isEmpty + // ? text16w400_FCFCFC("Regroup") + // : text16w400_FCFCFC( + // followingobj!.data![index] + // .following!.fullName!), + // sizedBoxHeight(4.h), + // followingobj! + // .data![index] + // .following! + // .userName == + // null || + // followingobj! + // .data![index] + // .following! + // .userName! + // .isEmpty + // ? text12w400_FCFCFC_blur( + // "regroup") + // : text12w400_FCFCFC_blur( + // followingobj!.data![index] + // .following!.userName!) + // ], + // ), + // Spacer(), + // PopupMenuButton( + // surfaceTintColor: Color(0xFF222935), + // constraints: + // BoxConstraints.tightFor( + // width: 176.w), + // offset: Offset(0, 20), + // color: Color(0xFF222935), + // tooltip: "", + // itemBuilder: (BuildContext + // context) => + // [ + // PopupMenuItem( + // onTap: () async { + // setState(() { + // unfollowid = + // followingobj! + // .data![ + // index] + // .following! + // .id ?? + // 0; + // // followingobj!.data!.removeAt(index); + // followingobj!.data! + // .removeWhere((item) => + // item.following! + // .id == + // unfollowid); + // Uploadata(); + // }); + // }, + // child: Padding( + // padding: + // EdgeInsets.symmetric( + // horizontal: 12.w), + // child: Row( + // children: [ + // text14400white( + // "Unfollow user"), + // Spacer(), + // Image.asset( + // "assets/images/png/Black1323e.png", + // height: 20.h, + // width: 20.w, + // ) + // ], + // ), + // ), + // ), + // PopupMenuDivider(), + // PopupMenuItem( + // onTap: () {}, + // child: Padding( + // padding: + // EdgeInsets.symmetric( + // horizontal: 12.w), + // child: Row( + // children: [ + // text14400white( + // "Message user"), + // Spacer(), + // Image.asset( + // "assets/images/png/fluent_chat-20-22.png", + // height: 20.h, + // width: 20.w, + // ) + // ], + // ), + // ), + // ), + // ], + // child: Container( + // height: 20, + // width: 20, + // child: Center( + // child: Image.asset( + // "assets/images/png/Group 1000004071.png", + // height: 22.h, + // width: 4.w, + // ), + // ), + // )), + // ], + // ), + // ), + // ], + // ); }, - ), - ), - sizedBoxHeight(20.h) - ]) - ]); - } - return Container(); - })); + ); + } + }, + ), + sizedBoxHeight(20.h) + ]), + ) + ])); + } + + Widget _buildNoDataBody(context) { + return Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Text( + "No Data Found", + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w600), + ) + ], + ), + ); } dialogwidget({required int index}) { @@ -273,28 +494,39 @@ class _BlockedUsersState extends State { } Widget blockedUser({ - required String imagePath, - required String title, - required String subtitle, + required String? imagePath, + required String? title, + required String? subtitle, required int index, }) { return Padding( padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 16.w), child: Row( children: [ - CircleAvatar( - backgroundImage: NetworkImage(imagePath), + imagePath == null || imagePath.isEmpty + ? CircleAvatar( + backgroundImage: AssetImage("assets/images/png/cimg3.png"), - // AssetImage(imagePath), - radius: 25.r, - ), + // AssetImage(imagePath), + radius: 25.r, + ) + : CircleAvatar( + backgroundImage: NetworkImage(imagePath), + + // AssetImage(imagePath), + radius: 25.r, + ), sizedBoxWidth(10.w), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - text16w400_FCFCFC(title), + title == null || title.isEmpty + ? text16w400_FCFCFC("Regroup") + : text16w400_FCFCFC(title), sizedBoxHeight(4.h), - text12w400_FCFCFC_blur(subtitle), + subtitle == null || subtitle.isEmpty + ? text12w400_FCFCFC_blur('regroup') + : text12w400_FCFCFC_blur(subtitle), ], ), Spacer(), diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Settings/ViewModel/BlockedUserApi.dart b/lib/Feed Module/Main_Screens/ProfileTab/Settings/ViewModel/BlockedUserApi.dart index 7d8640d..10b0369 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/Settings/ViewModel/BlockedUserApi.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/Settings/ViewModel/BlockedUserApi.dart @@ -1,32 +1,34 @@ +import 'dart:async'; + 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/Settings/Model/FetchBlockUser.dart'; -FetchBlockedUser? fetchblockuser; +FetchBlockedUser? fetchblockuserobj; class BlockUserAPI { BlockUserAPI(); - Future> fetchBlockUser() async { - final response = await NetworkApiServices().getApi( - ApiUrls.getblockuser, - ); - fetchblockuser = FetchBlockedUser.fromJson(response.data); - if (response.status == ResponseStatus.SUCCESS) { - if (response.data["status"] == "success") { - print("Success---->"); - return ResponseData( - response.data['message'], ResponseStatus.SUCCESS, - data: response.data); - } else { - return ResponseData( - response.data['message'], ResponseStatus.FAILED); - } - } + // Future> fetchBlockUser() async { + // final response = await NetworkApiServices().getApi( + // ApiUrls.getblockuser, + // ); + // fetchblockuser = FetchBlockedUser.fromJson(response.data); + // if (response.status == ResponseStatus.SUCCESS) { + // if (response.data["status"] == "success") { + // print("Success---->"); + // return ResponseData( + // response.data['message'], ResponseStatus.SUCCESS, + // data: response.data); + // } else { + // return ResponseData( + // response.data['message'], ResponseStatus.FAILED); + // } + // } - return response; - } + // return response; + // } Future> postBlockApi(var data) async { final response = await NetworkApiServices().postApi( @@ -50,4 +52,19 @@ class BlockUserAPI { return response; } + Future> getBlockedusers(updata, + {required StreamController streamController}) async { + final response = + await NetworkApiServices().getApi( + "${ApiUrls.getblockuser}?search=$updata", + + ); + + if (response.status == ResponseStatus.SUCCESS) { + fetchblockuserobj = FetchBlockedUser.fromJson(response.data); + if (!streamController.isClosed) streamController.sink.add(fetchblockuserobj!); + } + return response; + } + } diff --git a/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart b/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart index f9ca64d..5ce669c 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/TimeLine/AddTimeline.dart @@ -1,16 +1,28 @@ +import 'dart:developer'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; -import 'package:regroup/Common/CommonButton.dart'; import 'package:regroup/Common/CommonGlassmorphism.dart'; import 'package:regroup/Common/CommonWidget.dart'; +import 'package:regroup/Common/base_manager.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/EditProfile/ViewModel/EditProfileApi.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Model/timelineabilityModel.dart' + as timelineabilist; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/view_model/gettimelineability.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/view_model/profileGetmethod.dart'; +import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart'; import 'package:regroup/Utils/Common/CommonAppbar.dart'; import 'package:regroup/Utils/Common/CommonDropdown.dart'; +import 'package:regroup/Utils/Common/CustomNextButton.dart'; import 'package:regroup/Utils/Common/CustomTextformfield.dart'; -import 'package:regroup/Utils/Common/blureffect.dart'; import 'package:regroup/Utils/Common/sized_box.dart'; +import 'package:regroup/Utils/dialogs.dart'; import 'package:regroup/Utils/texts.dart'; +import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart'; import 'package:intl/intl.dart'; +import 'package:async/src/future_group.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class AddTimeline extends StatefulWidget { const AddTimeline({super.key}); @@ -22,167 +34,1372 @@ class AddTimeline extends StatefulWidget { class _AddTimelineState extends State { TextEditingController dateController = TextEditingController(); TextEditingController dateController2 = TextEditingController(); + TextEditingController clubNameController = TextEditingController(); + TextEditingController rollnameController = TextEditingController(); + TextEditingController teamnameController = TextEditingController(); - final List _dropdownProductItems = [ - 'Individual', - 'Business', - ]; - - String _selectedAccountType = ''; - - void _onItemSelected(String value) { - setState(() { - _selectedAccountType = value; - }); - } + int id = Get.arguments["id"]; + bool edited = Get.arguments["edit"]; RxBool isChecked = false.obs; + + timelineabilist.TimelineAbilityListModel? abilityModel; + List timeline = []; + List _abilitydrop = []; + + Future fetchABilitylist() async { + TimelineAbilityListApi abilityLsitAPI = TimelineAbilityListApi(); + ResponseData response = await abilityLsitAPI.getAbilitylistApi(); + + if (response.status == ResponseStatus.SUCCESS) { + abilityModel = + timelineabilist.TimelineAbilityListModel.fromJson(response.data!); + setState(() { + timeline = abilityModel!.data ?? []; // Store the fetched cities + _abilitydrop = + timeline.map((platform) => platform.name.toString()).toList(); + }); + log(timeline.toString()); + } else { + print('Failed to fetch abilities'); + } + } + + List selectedabilityid = []; + + void getCatIdFromName(List selectedAbilities) { + selectedabilityid.clear(); // Clear existing selections + for (var name in selectedAbilities) { + for (var i = 0; i < timeline.length; i++) { + if (name == timeline[i].name) { + selectedabilityid.add(timeline[i].id!); + break; // Assuming each name is unique, we break after finding a match + } + } + } + } + + // late Future myfuture; + FutureGroup futureGroup = FutureGroup(); + RxBool isloading = true.obs; + + @override + void initState() { + // TODO: implement initState + + if (edited == true) { + // futureGroup.add( + Profilegetmethod().getEditTimeline(id).then((value) { + clubNameController.text = + edittimelineobj!.data!.timelineData!.clubName ?? ""; + rollnameController.text = + edittimelineobj!.data!.timelineData!.roleName ?? ""; + teamnameController.text = + edittimelineobj!.data!.timelineData!.teamName ?? ""; + ""; + dateController.text = + edittimelineobj!.data!.timelineData!.startDate ?? ""; + dateController2.text = + edittimelineobj!.data!.timelineData!.endDate ?? ""; + String abilitiesXids = + edittimelineobj!.data!.timelineData!.abilitiesXids ?? ""; + abilitiesIds = abilitiesXids + .split(',') + .map((e) => int.tryParse(e.trim()) ?? 0) // Trim spaces around IDs + .toList(); + selectedabilityid = abilitiesIds; + + print(selectedabilityid.toList()); + + for (int i = 0; i < _abilitydrop.length; i++) { + _abilityMap.add({ + "id": i + 1, + "name": _abilitydrop[i], + }); + } + // futureGroup.add( + fetchABilitylist().then((value) { + isloading = false.obs; + }); + // ); + }); + // ); + // myfuture = Profilegetmethod().getEditTimeline(id); + } + + // futureGroup.add( + // ); + // futureGroup.close(); + fetchABilitylist().then((value) { + isloading = false.obs; + }); + + // WidgetsBinding.instance.addPostFrameCallback((_) { + // fetchABilitylist(); + // }); + + // setValues(); + super.initState(); + } + + List abilitiesIds = []; + + UploadData() async { + // SharedPreferences prefs = await SharedPreferences.getInstance(); + utils.loader(); + String abilitiesIds = selectedabilityid.join(','); + print(abilitiesIds); + Map updata = { + "club_name": clubNameController.text, + "role_name": rollnameController.text, + "team_name": teamnameController.text, + "start_date": dateController.text, + "end_date": dateController2.text, + "abilities_xids": abilitiesIds, + }; + final data = await Profilepostmethod().postTimeline(updata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + // String? accountype; + + // accountype = prefs.getString('accountTypefromLogin'); + + // if (accountype == "1") { + // EditProfileApi().getEditProfileIndividual(); + // } + Get.back(); + print("timeline done"); + return utils.showToast(data.message); + } else { + Get.back(); + print("timeline not done"); + return utils.showToast(data.message); + } + } + + EdituploadData() async { + utils.loader(); + String abilitiesIds = selectedabilityid.join(','); + print(abilitiesIds); + Map updata = { + "club_name": clubNameController.text, + "role_name": rollnameController.text, + "team_name": teamnameController.text, + "start_date": dateController.text, + "end_date": dateController2.text, + "abilities_xids": abilitiesIds, + "timeline_id": id, + }; + final data = await Profilepostmethod().postEditTimeline(updata); + if (data.status == ResponseStatus.SUCCESS) { + Get.back(); + print("timeline done"); + return utils.showToast(data.message); + } else { + Get.back(); + print("timeline not done"); + return utils.showToast(data.message); + } + } + +// List> _abilityMap = []; + List> _abilityMap = []; + List listData = []; + +// Function to get names from selected IDs + List getSelectedNames(List selectedIds) { + List selectedNames = []; + for (int id in selectedIds) { + for (Map ability in _abilityMap) { + if (ability["id"] == id) { + selectedNames.add(ability["name"]); + break; + } + } + _abilitydrop = + _abilityMap.map((ability) => ability["name"] as String).toList(); + } + return selectedNames; + } + @override Widget build(BuildContext context) { - return Scaffold( - resizeToAvoidBottomInset: false, - // key: _scaffoldKey1, - backgroundColor: Color(0xFF222935), - extendBody: true, - appBar: CommonAppbar( - titleTxt: "Add timeline", - ), - body: Stack(children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Ellipse 1496.png"), - fit: BoxFit.fill)), + return GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + // resizeToAvoidBottomInset: false, + // key: _scaffoldKey1, + backgroundColor: Color(0xFF222935), + extendBody: true, + appBar: CommonAppbar( + titleTxt: "Add timeline", ), - SingleChildScrollView( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - sizedBoxHeight(20.h), - text16400white("Club name"), - sizedBoxHeight(15.h), - CustomTextFormField(), - sizedBoxHeight(25.h), - text16400white("Role in the club"), - sizedBoxHeight(15.h), - CustomTextFormField(), - sizedBoxHeight(25.h), - text16400white("Team name"), - sizedBoxHeight(15.h), - CustomTextFormField(), - sizedBoxHeight(25.h), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16400white("Start date "), - sizedBoxHeight(10.h), - GestureDetector( - onTap: () => datePicker(context, dateController), - child: AbsorbPointer( - child: CustomTextFormField( - textEditingController: dateController, - leadingIcon: Container( - height: 20.h, - width: 20.w, - child: Center( - child: Image.asset( - "assets/images/png/calender.png", - height: 20.h, - width: 20.w, + body: + // edited == true + // ? FutureBuilder( + // future: futureGroup.future, + // builder: (ctx, snapshot) { + // if (snapshot.data == null) { + // return Center( + // child: CircularProgressIndicator( + // color: Colors.blue, + // ), + // ); + // } + // if (snapshot.connectionState == ConnectionState.done) { + // if (snapshot.hasError) { + // return Center( + // child: Text( + // '${snapshot.error} occured', + // style: TextStyle(fontSize: 18.spMin), + // ), + // ); + // } else if (snapshot.hasData) { + // clubNameController.text = + // edittimelineobj!.data!.timelineData!.clubName ?? ""; + // rollnameController.text = + // edittimelineobj!.data!.timelineData!.roleName ?? ""; + // teamnameController.text = + // edittimelineobj!.data!.timelineData!.teamName ?? ""; + // ""; + // dateController.text = + // edittimelineobj!.data!.timelineData!.startDate ?? + // ""; + // dateController2.text = + // edittimelineobj!.data!.timelineData!.endDate ?? ""; + + // // String abilitiesXids = edittimelineobj! + // // .data!.timelineData!.abilitiesXids ?? + // // ""; + // // List abilitiesIds = abilitiesXids + // // .split(',') + // // .map((e) => int.tryParse(e) ?? 0) + // // .toList(); + // String abilitiesXids = edittimelineobj! + // .data!.timelineData!.abilitiesXids ?? + // ""; + // abilitiesIds = abilitiesXids + // .split(',') + // .map((e) => + // int.tryParse(e.trim()) ?? + // 0) // Trim spaces around IDs + // .toList(); + // selectedabilityid = abilitiesIds; + + // print(selectedabilityid.toList()); + + // for (int i = 0; i < _abilitydrop.length; i++) { + // _abilityMap.add({ + // "id": i + 1, + // "name": _abilitydrop[i], + // }); + // } + // } + // } + // return Stack(children: [ + // Container( + // decoration: const BoxDecoration( + // image: DecorationImage( + // image: AssetImage( + // "assets/images/png/Ellipse 1496.png"), + // fit: BoxFit.fill)), + // ), + // ListView(physics: ScrollPhysics(), children: [ + // Padding( + // padding: EdgeInsets.symmetric(horizontal: 16.w), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // sizedBoxHeight(20.h), + // text16400white("Club name"), + // sizedBoxHeight(15.h), + // CustomTextFormField( + // textEditingController: clubNameController, + // texttype: TextInputType.text, + // hintText: 'Enter club name', + // validator: (value) { + // if (value!.isEmpty) { + // return 'Enter your full name '; + // } + // return null; + // }, + // inputFormatters: [ + // // LengthLimitingTextInputFormatter(20), + // RemoveEmojiInputFormatter(), + // FilteringTextInputFormatter.allow( + // RegExp('[a-zA-Z ]')) + // ], + // ), + // sizedBoxHeight(25.h), + // text16400white("Role in the club"), + // sizedBoxHeight(15.h), + // CustomTextFormField( + // textEditingController: rollnameController, + // texttype: TextInputType.text, + // hintText: 'Enter club name', + // validator: (value) { + // if (value!.isEmpty) { + // return 'Enter your full name '; + // } + // return null; + // }, + // inputFormatters: [ + // // LengthLimitingTextInputFormatter(20), + // RemoveEmojiInputFormatter(), + // FilteringTextInputFormatter.allow( + // RegExp('[a-zA-Z ]')) + // ], + // ), + // sizedBoxHeight(25.h), + // text16400white("Team name"), + // sizedBoxHeight(15.h), + // CustomTextFormField( + // textEditingController: teamnameController, + // texttype: TextInputType.text, + // hintText: 'Enter club name', + // validator: (value) { + // if (value!.isEmpty) { + // return 'Enter your full name '; + // } + // return null; + // }, + // inputFormatters: [ + // // LengthLimitingTextInputFormatter(20), + // RemoveEmojiInputFormatter(), + // FilteringTextInputFormatter.allow( + // RegExp('[a-zA-ZS0-9 ]')), + // ], + // ), + // sizedBoxHeight(25.h), + // Row( + // mainAxisAlignment: + // MainAxisAlignment.spaceBetween, + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Expanded( + // child: Column( + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // text16400white("Start date "), + // sizedBoxHeight(10.h), + // GestureDetector( + // onTap: () => datePicker( + // context, dateController), + // child: AbsorbPointer( + // child: CustomTextFormField( + // textEditingController: + // dateController, + // leadingIcon: Container( + // height: 20.h, + // width: 20.w, + // child: Center( + // child: Image.asset( + // "assets/images/png/calender.png", + // height: 20.h, + // width: 20.w, + // ), + // ), + // ), + // ), + // ), + // ) + // ], + // ), + // ), + // sizedBoxWidth(10.h), + // Expanded( + // child: Column( + // crossAxisAlignment: + // CrossAxisAlignment.start, + // children: [ + // text16400white("End date"), + // sizedBoxHeight(10.h), + // GestureDetector( + // onTap: () => datePicker( + // context, dateController2), + // child: AbsorbPointer( + // child: CustomTextFormField( + // textEditingController: + // dateController2, + // leadingIcon: Container( + // height: 20.h, + // width: 20.w, + // child: Center( + // child: Image.asset( + // "assets/images/png/calender.png", + // height: 20.h, + // width: 20.w, + // ), + // ), + // ), + // ), + // ), + // ), + // sizedBoxHeight(10.h), + // Row( + // children: [ + // Obx(() { + // return commonGlassContainer( + // border: 1, + // borderradius: 2, + // height: 20.h, + // width: 20.w, + // opacity1: 0.24, + // opacity2: 0.24, + // customWidget: Transform.scale( + // scale: 1.2, + // child: Checkbox( + // side: BorderSide( + // color: Color( + // 0xFF434A53)), + // value: isChecked.value, + // activeColor: + // Colors.transparent, + // checkColor: Colors.white, + // onChanged: ((value) { + // // isChecked.value = value!; + // isChecked.value = + // value!; + // if (isChecked.value) { + // // Set end date to today's date + // dateController2 + // .text = DateFormat( + // 'yyyy-MM-dd') + // .format(DateTime + // .now()); + // } else { + // // Clear end date when checkbox is unchecked + // dateController2 + // .clear(); + // } + // }), + // ), + // ), + // ); + // }), + // sizedBoxWidth(8.w), + // text10400white("Present") + // ], + // ), + // ], + // ), + // ) + // ], + // ), + // text16400white("Ability"), + // sizedBoxHeight(15.h), + // // CustomDropDownCheckBoxTimeline( + // // header: 'Select ability', + // // title: '', + // // listData: _abilitydrop, + // // onItemSelected: getCatIdFromName, + // // initiallySelected: abilitiesIds + // // .map((id) => id.toString()) + // // .toList(), + // // ), + // CustomDropDownCheckBoxTimeline( + // header: 'Select ability', + // title: '', + // listData: listData, + // // _abilityMap.map((ability) => ability["name"]).toList(), + // onItemSelected: getCatIdFromName, + // // (selectedNames) { + // // // Convert selected names back to IDs if needed + // // List selectedIds = []; + // // for (String name in selectedNames) { + // // for (Map ability + // // in _abilityMap) { + // // if (ability["name"] == name) { + // // selectedIds.add(ability["id"]); + // // break; + // // } + // // } + // // } + // // // Use selectedIds as needed + // // print(selectedIds); + // // }, + // initiallySelected: getSelectedNames( + // abilitiesIds), // Pass initially selected names + // ), + // sizedBoxHeight(80.h), + // Padding( + // padding: + // EdgeInsets.symmetric(horizontal: 20.w), + // child: CustomButton( + // text: "Add timeline", + // onPressed: () { + // if (clubNameController.text.isBlank! || + // rollnameController.text.isBlank! || + // teamnameController.text.isBlank! || + // dateController.text.isBlank! || + // dateController2.text.isBlank! || + // selectedabilityid.isEmpty) { + // utils.showToast( + // 'Please fill all fields'); + // } else { + // print(selectedabilityid.toString()); + + // EdituploadData(); + // } + // }, + // ), + // ), + // ]), + // ) + // ]) + // ]); + // }, + // ) + // : + Obx(() + // { + => + isloading.value + ? Center( + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircularProgressIndicator(), + ], + )) + : edited == true + ? Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), ), - ), - ), - ), - ), - ) - ], - ), - ), - sizedBoxWidth(10.h), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16400white("End date"), - sizedBoxHeight(10.h), - GestureDetector( - onTap: () => datePicker(context, dateController2), - child: AbsorbPointer( - child: CustomTextFormField( - textEditingController: dateController2, - leadingIcon: Container( - height: 20.h, - width: 20.w, - child: Center( - child: Image.asset( - "assets/images/png/calender.png", - height: 20.h, - width: 20.w, + ListView(physics: ScrollPhysics(), children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + sizedBoxHeight(20.h), + text16400white("Club name"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: + clubNameController, + texttype: TextInputType.text, + hintText: 'Enter club name', + validator: (value) { + if (value!.isEmpty) { + return 'Enter your full name '; + } + return null; + }, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + FilteringTextInputFormatter + .allow(RegExp('[a-zA-Z ]')) + ], + ), + sizedBoxHeight(25.h), + text16400white("Role in the club"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: + rollnameController, + texttype: TextInputType.text, + hintText: 'Enter club name', + validator: (value) { + if (value!.isEmpty) { + return 'Enter your full name '; + } + return null; + }, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + FilteringTextInputFormatter + .allow(RegExp('[a-zA-Z ]')) + ], + ), + sizedBoxHeight(25.h), + text16400white("Team name"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: + teamnameController, + texttype: TextInputType.text, + hintText: 'Enter club name', + validator: (value) { + if (value!.isEmpty) { + return 'Enter your full name '; + } + return null; + }, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + FilteringTextInputFormatter + .allow(RegExp( + '[a-zA-ZS0-9 ]')), + ], + ), + sizedBoxHeight(25.h), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16400white( + "Start date "), + sizedBoxHeight(10.h), + GestureDetector( + onTap: () => datePicker( + context, + dateController), + child: AbsorbPointer( + child: + CustomTextFormField( + textEditingController: + dateController, + leadingIcon: + Container( + height: 20.h, + width: 20.w, + child: Center( + child: + Image.asset( + "assets/images/png/calender.png", + height: 20.h, + width: 20.w, + ), + ), + ), + ), + ), + ) + ], + ), + ), + sizedBoxWidth(10.h), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16400white( + "End date"), + sizedBoxHeight(10.h), + GestureDetector( + onTap: () => datePicker( + context, + dateController2), + child: AbsorbPointer( + child: + CustomTextFormField( + textEditingController: + dateController2, + leadingIcon: + Container( + height: 20.h, + width: 20.w, + child: Center( + child: + Image.asset( + "assets/images/png/calender.png", + height: 20.h, + width: 20.w, + ), + ), + ), + ), + ), + ), + sizedBoxHeight(10.h), + Row( + children: [ + Obx(() { + return commonGlassContainer( + border: 1, + borderradius: 2, + height: 20.h, + width: 20.w, + opacity1: 0.24, + opacity2: 0.24, + customWidget: + Transform + .scale( + scale: 1.2, + child: Checkbox( + side: BorderSide( + color: Color( + 0xFF434A53)), + value: + isChecked + .value, + activeColor: + Colors + .transparent, + checkColor: + Colors + .white, + onChanged: + ((value) { + // isChecked.value = value!; + isChecked + .value = + value!; + if (isChecked + .value) { + // Set end date to today's date + dateController2 + .text = DateFormat( + 'yyyy-MM-dd') + .format( + DateTime.now()); + } else { + // Clear end date when checkbox is unchecked + dateController2 + .clear(); + } + }), + ), + ), + ); + }), + sizedBoxWidth(8.w), + text10400white( + "Present") + ], + ), + ], + ), + ) + ], + ), + text16400white("Ability"), + sizedBoxHeight(15.h), + // CustomDropDownCheckBoxTimeline( + // header: 'Select ability', + // title: '', + // listData: _abilitydrop, + // onItemSelected: getCatIdFromName, + // initiallySelected: abilitiesIds + // .map((id) => id.toString()) + // .toList(), + // ), + CustomDropDownCheckBoxTimeline( + header: 'Select ability', + title: '', + listData: _abilitydrop, + // _abilityMap.map((ability) => ability["name"]).toList(), + onItemSelected: getCatIdFromName, + // (selectedNames) { + // // Convert selected names back to IDs if needed + // List selectedIds = []; + // for (String name in selectedNames) { + // for (Map ability + // in _abilityMap) { + // if (ability["name"] == name) { + // selectedIds.add(ability["id"]); + // break; + // } + // } + // } + // // Use selectedIds as needed + // print(selectedIds); + // }, + initiallySelected: getSelectedNames( + abilitiesIds), // Pass initially selected names + ), + sizedBoxHeight(80.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 20.w), + child: CustomButton( + text: "Add timeline", + onPressed: () { + if (clubNameController.text.isBlank! || + rollnameController + .text.isBlank! || + teamnameController + .text.isBlank! || + dateController + .text.isBlank! || + dateController2 + .text.isBlank! || + selectedabilityid + .isEmpty) { + utils.showToast( + 'Please fill all fields'); + } else { + print(selectedabilityid + .toString()); + + EdituploadData(); + } + }, + ), + ), + ]), + ) + ]) + ]) + : Stack(children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: AssetImage( + "assets/images/png/Ellipse 1496.png"), + fit: BoxFit.fill)), ), - ), - ), - ), - ), - ), - sizedBoxHeight(10.h), - Row( - children: [ - Obx(() { - return commonGlassContainer( - border: 1, - borderradius: 2, - height: 20.h, - width: 20.w, - opacity1: 0.24, - opacity2: 0.24, - customWidget: Transform.scale( - scale: 1.2, - child: Checkbox( - side: BorderSide(color: Color(0xFF434A53)), - value: isChecked.value, - activeColor: Colors.transparent, - checkColor: Colors.white, - onChanged: ((value) { - isChecked.value = value!; - }), - ), - ), - ); - }), - sizedBoxWidth(8.w), - text10400white("Present") - ], - ), - ], - ), - ) - ], - ), - text16400white("Ability"), - sizedBoxHeight(15.h), - CustomDropDownWidgetSignup( - header: 'Select ability', - title: '', - listData: _dropdownProductItems, - onItemSelected: _onItemSelected, - // leadingImage: - // Image.asset( - // 'assets/images/png/user.png', - // ), - ), - sizedBoxHeight(80.h), - Padding( - padding: EdgeInsets.symmetric(horizontal: 20.w), - child: CommonBtn(text: "Add timeline"), - ), - ]), - )) - ])); + ListView(physics: ScrollPhysics(), children: [ + Padding( + padding: EdgeInsets.symmetric( + horizontal: 16.w), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + sizedBoxHeight(20.h), + text16400white("Club name"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: + clubNameController, + texttype: TextInputType.text, + hintText: 'Enter club name', + validator: (value) { + if (value!.isEmpty) { + return 'Enter your full name '; + } + return null; + }, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + FilteringTextInputFormatter + .allow(RegExp('[a-zA-Z ]')) + ], + ), + sizedBoxHeight(25.h), + text16400white("Role in the club"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: + rollnameController, + texttype: TextInputType.text, + hintText: 'Enter club name', + validator: (value) { + if (value!.isEmpty) { + return 'Enter your full name '; + } + return null; + }, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + FilteringTextInputFormatter + .allow(RegExp('[a-zA-Z ]')) + ], + ), + sizedBoxHeight(25.h), + text16400white("Team name"), + sizedBoxHeight(15.h), + CustomTextFormField( + textEditingController: + teamnameController, + texttype: TextInputType.text, + hintText: 'Enter club name', + validator: (value) { + if (value!.isEmpty) { + return 'Enter your full name '; + } + return null; + }, + inputFormatters: [ + // LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter(), + FilteringTextInputFormatter + .allow(RegExp( + '[a-zA-ZS0-9 ]')), + ], + ), + sizedBoxHeight(25.h), + Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16400white( + "Start date "), + sizedBoxHeight(10.h), + GestureDetector( + onTap: () => datePicker( + context, + dateController), + child: AbsorbPointer( + child: + CustomTextFormField( + textEditingController: + dateController, + leadingIcon: + Container( + height: 20.h, + width: 20.w, + child: Center( + child: + Image.asset( + "assets/images/png/calender.png", + height: 20.h, + width: 20.w, + ), + ), + ), + ), + ), + ) + ], + ), + ), + sizedBoxWidth(10.h), + Expanded( + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + text16400white( + "End date"), + sizedBoxHeight(10.h), + GestureDetector( + onTap: () => datePicker( + context, + dateController2), + child: AbsorbPointer( + child: + CustomTextFormField( + textEditingController: + dateController2, + leadingIcon: + Container( + height: 20.h, + width: 20.w, + child: Center( + child: + Image.asset( + "assets/images/png/calender.png", + height: 20.h, + width: 20.w, + ), + ), + ), + ), + ), + ), + sizedBoxHeight(10.h), + Row( + children: [ + Obx(() { + return commonGlassContainer( + border: 1, + borderradius: 2, + height: 20.h, + width: 20.w, + opacity1: 0.24, + opacity2: 0.24, + customWidget: + Transform + .scale( + scale: 1.2, + child: Checkbox( + side: BorderSide( + color: Color( + 0xFF434A53)), + value: + isChecked + .value, + activeColor: + Colors + .transparent, + checkColor: + Colors + .white, + onChanged: + ((value) { + // isChecked.value = value!; + isChecked + .value = + value!; + if (isChecked + .value) { + // Set end date to today's date + dateController2 + .text = DateFormat( + 'yyyy-MM-dd') + .format( + DateTime.now()); + } else { + // Clear end date when checkbox is unchecked + dateController2 + .clear(); + } + }), + ), + ), + ); + }), + sizedBoxWidth(8.w), + text10400white( + "Present") + ], + ), + ], + ), + ) + ], + ), + text16400white("Ability"), + sizedBoxHeight(15.h), + CustomDropDownChexkBox( + header: 'Select ability', + title: '', + listData: _abilitydrop, + onItemSelected: getCatIdFromName, + initiallySelected: [], // or pass initial values if needed + ), + sizedBoxHeight(80.h), + Padding( + padding: EdgeInsets.symmetric( + horizontal: 20.w), + child: CustomButton( + text: "Add timeline", + onPressed: () { + if (clubNameController.text.isBlank! || + rollnameController + .text.isBlank! || + teamnameController + .text.isBlank! || + dateController + .text.isBlank! || + dateController2 + .text.isBlank! || + selectedabilityid + .isEmpty) { + utils.showToast( + 'Please fill all fields'); + } else { + print(selectedabilityid + .toString()); + + UploadData(); + } + }, + ), + ), + ]), + ) + ]) + ]) + + // } + )), + ); + } +} + +class CustomDropDownCheckBoxTimeline extends StatefulWidget { + const CustomDropDownCheckBoxTimeline({ + Key? key, + required this.header, + required this.title, + required this.listData, + required this.onItemSelected, + this.leadingImage, + this.showOtherOption = false, + required this.initiallySelected, + }) : super(key: key); + + final String header; + final String title; + final List listData; + final Function(List) onItemSelected; + final Widget? leadingImage; + final bool showOtherOption; + final List initiallySelected; + + @override + State createState() => + _CustomDropDownCheckBoxTimelineState(); +} + +class _CustomDropDownCheckBoxTimelineState + extends State { + RxBool onDropTap = false.obs; + RxList selectedValues = [].obs; + final TextEditingController _textController = TextEditingController(); + + @override + void initState() { + super.initState(); + selectedValues + .addAll(widget.initiallySelected); // Initialize selectedValues + } + + List> _buildDropdownMenuItems() { + List> items = + widget.listData.asMap().entries.map((entry) { + int index = entry.key; + String item = entry.value; + return DropdownMenuItem( + value: item, + child: InkWell( + onTap: () { + setState(() { + if (selectedValues.contains(item)) { + selectedValues.remove(item); + } else { + selectedValues.add(item); + } + _textController.clear(); + widget.onItemSelected( + selectedValues.toList()); // Convert RxList to List + }); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Row( + children: [ + Obx(() { + return Checkbox( + value: selectedValues.contains(item), + activeColor: Colors.white, + checkColor: const Color(0xFFD90B2E), + onChanged: (bool? value) { + setState(() { + if (value == true) { + selectedValues.add(item); + } else { + selectedValues.remove(item); + } + _textController.clear(); + widget.onItemSelected(selectedValues.toList()); + }); + }, + ); + }), + const SizedBox(width: 8), + Text( + item, + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontFamily: 'Helvetica', + fontWeight: FontWeight.w500, + ), + overflow: TextOverflow.ellipsis, + ), + ], + ), + if (index != widget.listData.length - 1) + const Divider(thickness: 1, color: Color(0xFF434A53)), + ], + ), + ), + ); + }).toList(); + + if (widget.showOtherOption) { + items.add( + DropdownMenuItem( + value: _textController.text, + child: Column( + children: [ + const Divider(thickness: 1, color: Color(0xFF434A53)), + Row( + children: [ + Obx(() { + return Checkbox( + value: selectedValues.contains(_textController.text), + activeColor: Colors.white, + onChanged: (bool? value) { + setState(() { + if (value == true && + _textController.text.trim().isNotEmpty) { + selectedValues.add(_textController.text); + } else { + selectedValues.remove(_textController.text); + } + widget.onItemSelected(selectedValues.toList()); + }); + }, + ); + }), + const SizedBox(width: 8), + const Text( + "Other: ", + style: TextStyle( + color: Colors.white, + fontSize: 16, + fontFamily: 'Helvetica', + fontWeight: FontWeight.w500, + ), + overflow: TextOverflow.ellipsis, + ), + Expanded( + child: TextField( + controller: _textController, + style: const TextStyle( + color: Colors.white, + fontSize: 16, + fontFamily: 'Helvetica', + fontWeight: FontWeight.w500, + ), + decoration: const InputDecoration( + hintText: '', + hintStyle: TextStyle(color: Colors.white70), + border: UnderlineInputBorder(), + ), + ), + ), + TextButton( + onPressed: () { + setState(() { + if (_textController.text.trim().isNotEmpty) { + selectedValues.add(_textController.text); + widget.onItemSelected(selectedValues.toList()); + } + }); + }, + child: const Text( + 'OK', + style: TextStyle( + color: Colors.white, + fontSize: 16, + fontFamily: 'Helvetica', + fontWeight: FontWeight.w500, + ), + ), + ), + ], + ), + SizedBox(height: 10), + ], + ), + ), + ); + } + return items; + } + + @override + Widget build(BuildContext context) { + return Obx( + () => Column( + 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, + ), + 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: [ + widget.leadingImage == null + ? SizedBox() + : widget.leadingImage!, + const SizedBox(width: 12), + 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'), + ], + ), + ), + ), + ), + if (onDropTap.value) + Scrollbar( + child: Container( + width: double.infinity, + decoration: BoxDecoration( + color: const Color(0xFFFFFFFF).withOpacity(0.10), + borderRadius: const BorderRadius.vertical( + bottom: Radius.circular(30), + ), + border: Border.all(color: const Color(0xFF434A53)), + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + const Color(0xFFffffff).withOpacity(0.50), + const Color(0xFFFFFFFF).withOpacity(0.50), + ], + ), + ), + child: Column( + children: _buildDropdownMenuItems(), + ), + ), + ), + ], + ), + ); } } diff --git a/lib/Feed Module/Main_Screens/ProfileTab/view_model/gettimelineability.dart b/lib/Feed Module/Main_Screens/ProfileTab/view_model/gettimelineability.dart new file mode 100644 index 0000000..37223ee --- /dev/null +++ b/lib/Feed Module/Main_Screens/ProfileTab/view_model/gettimelineability.dart @@ -0,0 +1,32 @@ + + + +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/Model/timelineabilityModel.dart'; + +class TimelineAbilityListApi { + TimelineAbilityListApi(); + var data = ""; + Future> getAbilitylistApi() async { + final response = await NetworkApiServices().getApi( + ApiUrls.gettimelineabilitylist, + + ); + + if (response.status == ResponseStatus.SUCCESS) { + Map responseData = + Map.from(response.data); + if (responseData['status'] == "success") { + print("success"); + TimelineAbilityListModel timelineabilitylistobj = + TimelineAbilityListModel.fromJson(responseData); + } else { + // return ResponseData( + // responseData['message'], ResponseStatus.FAILED); + } + } + return response; + } +} diff --git a/lib/Feed Module/Main_Screens/ProfileTab/view_model/profileGetmethod.dart b/lib/Feed Module/Main_Screens/ProfileTab/view_model/profileGetmethod.dart index 254111f..58f48e3 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/view_model/profileGetmethod.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/view_model/profileGetmethod.dart @@ -4,19 +4,24 @@ import 'dart:developer'; 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/Model/editTimelineModel.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Model/faqModel.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Model/followersModel.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Model/followingModel.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Model/privacyPolicyModel.dart'; import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Model/termsconditionsModel.dart'; +// import 'package:regroup/Feed%20Module/Main_Screens/ProfileTab/Model/timelineabilityModel.dart'; FaqModel? faqobj; PrivacypolicyModel? privacyobj; TermsConditionsModel? termsobj; FollowersModel? followersobj; FollowingModel? followingobj; +GetEditTimelineModel? edittimelineobj; + class Profilegetmethod { + // Profilegetmethod(); Future> getFaqs() async { final response = await NetworkApiServices().getApi( ApiUrls.getfaqs, @@ -78,4 +83,14 @@ class Profilegetmethod { } return response; } + + Future> getEditTimeline(int data) async { + final response = await NetworkApiServices().getApi(ApiUrls.getedittimeline + "/?timeline_id=${data}"); + + if (response.status == ResponseStatus.SUCCESS) { + edittimelineobj = GetEditTimelineModel.fromJson(response.data); + log(edittimelineobj!.data.toString()); + } + return response; + } } diff --git a/lib/Feed Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart b/lib/Feed Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart index 064b81d..526fe47 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/view_model/profilePostmethod.dart @@ -1,9 +1,20 @@ +import 'dart:convert'; +import 'dart:developer'; + +import 'package:dio/dio.dart'; 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:shared_preferences/shared_preferences.dart'; class Profilepostmethod { Profilepostmethod(); + Dio dio = Dio(); + + String basicAuth = 'Basic ' + + base64.encode( + utf8.encode('RegroupUserName:71%@L%es^bUX94`J9XT*@bh,._WWM{\$%^^&&')); + Future> postContactus(updata) async { print("updata is $updata"); @@ -81,4 +92,130 @@ class Profilepostmethod { print("response message is ${response.message}"); return response; } + + Future> postTimeline(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.posttimeline, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } + + Future> postAccountvisibility(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postaccountvisibility, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } + + Future> postDeleteaccount(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postdeleteaccount, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } + + + Future> postLogoutaccount() async { + Response response; + SharedPreferences prefs = await SharedPreferences.getInstance(); + String? token = prefs.getString('access-token'); + + try { + response = await dio.post( + ApiUrls.postlogoutaccount, + options: + Options( + headers: {'authorization': basicAuth, 'access-token': token}, + ), + ); + log(response.toString()); + } on Exception catch (e) { + if (e is DioException) { + log(e.response.toString()); + if (e.response == null) { + return ResponseData( + 'Oops something Went Wrong, Please try again!', + ResponseStatus.FAILED, + ); + } + if (e.response!.statusCode == 401) { + prefs.remove('token'); + prefs.remove('refreshToken'); + // Get.toNamed(RouteName.login); + return ResponseData( + 'Oops something Went Wrong, Please try again!', + ResponseStatus.FAILED, + ); + } + if (e.response!.statusCode == 403) { + if (e.response!.data['message'] is List) { + return ResponseData( + e.response!.data['message'][0]!, ResponseStatus.FAILED, + data: e.response!.data); + } else { + return ResponseData( + e.response!.data['message'], ResponseStatus.FAILED, + data: e.response!.data); + } + } + } + return ResponseData( + 'Oops something Went Wrong', + ResponseStatus.FAILED, + ); + } + + if (response.statusCode == 200 || response.statusCode == 201) { + return ResponseData("success", ResponseStatus.SUCCESS, + data: response.data); + } else if (response.statusCode == 203) { + print(response.data); + return ResponseData("success", ResponseStatus.PRIVATE, + data: response.data); + } else { + try { + return ResponseData( + response.data['message'].toString(), ResponseStatus.FAILED); + } catch (_) { + return ResponseData( + response.statusMessage!, ResponseStatus.FAILED); + } + } + + } + + Future> postEditTimeline(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.posttimeline, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } + + Future> postRemoveTimeline(updata) async { + print("updata is $updata"); + final response = await NetworkApiServices().postApi( + updata, + ApiUrls.postremovetimeline, + ); + print("response is ${response.data}"); + print("response message is ${response.message}"); + return response; + } + } diff --git a/lib/Login/View/loginscreen.dart b/lib/Login/View/loginscreen.dart index 72314d1..31555dd 100644 --- a/lib/Login/View/loginscreen.dart +++ b/lib/Login/View/loginscreen.dart @@ -196,311 +196,387 @@ class _LoginScreenState extends State { } } + Future _onBackButtonPressed( + BuildContext context, + TextEditingController emailController, + TextEditingController passwordController) async { + bool? exitApp = await showDialog( + barrierDismissible: false, + context: context, + builder: (context) { + return AlertDialog( + backgroundColor: Color(0xff222935), + title: Text( + 'Exit App', + style: TextStyle( + color: Colors.white, + fontSize: 16.sp, + fontWeight: FontWeight.w500), + ), + content: Text( + 'Do you really want to close the app?', + style: TextStyle( + color: Colors.white, + fontSize: 14.sp, + fontWeight: FontWeight.w500), + ), + actions: [ + TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: const Text( + 'No', + style: TextStyle( + color: Colors.white, + ), + ), + ), + TextButton( + onPressed: () { + emailController.clear(); + passwordController.clear(); + + // Reset form state to remove error borders + + SystemNavigator.pop(); + Navigator.pop(context); + }, + child: const Text( + 'Yes', + style: TextStyle( + color: Color(0xFFD90B2E), + ), + ), + ) + ], + ); + }); + return exitApp ?? false; + } + @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), - child: Scaffold( - resizeToAvoidBottomInset: - false, // Prevent resizing when the keyboard opens - backgroundColor: const Color.fromARGB(255, 18, 32, 47), - body: Stack( - clipBehavior: Clip.none, - children: [ - Container( - decoration: const BoxDecoration( - image: DecorationImage( - image: AssetImage("assets/images/png/Choice screen.png"), - fit: BoxFit.cover)), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox( - height: 150.h, - ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: Align( - alignment: Alignment.center, - child: Container( - width: 107.w, - height: 70.h, - child: SvgPicture.asset( - "assets/images/svg/onboarding2.svg", - fit: BoxFit.cover, + return WillPopScope( + onWillPop: () async { + _onBackButtonPressed(context, _emailController, _passwordController); + + return true; + }, + child: GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + resizeToAvoidBottomInset: + false, // Prevent resizing when the keyboard opens + backgroundColor: const Color.fromARGB(255, 18, 32, 47), + body: Stack( + clipBehavior: Clip.none, + children: [ + Container( + decoration: const BoxDecoration( + image: DecorationImage( + image: + AssetImage("assets/images/png/Choice screen.png"), + fit: BoxFit.cover)), + ), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox( + height: 150.h, + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: Align( + alignment: Alignment.center, + child: Container( + width: 107.w, + height: 70.h, + child: SvgPicture.asset( + "assets/images/svg/onboarding2.svg", + fit: BoxFit.cover, + ), ), ), ), - ), - sizedBoxHeight(20.h), - Align( - alignment: Alignment.center, - child: text22400FCFCFC("Find your community")), - sizedBoxHeight(40.h), - Expanded( - child: Padding( - padding: EdgeInsets.symmetric(horizontal: 16.w), - child: SingleChildScrollView( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text16400white('Email address'), - sizedBoxHeight(10.h), - CustomTextFormField( - textEditingController: _emailController, - hintText: "Enter your email address", - leadingIcon: - // const Icon(Icons.mail_outline), - SizedBox( - width: 22.w, - height: 17.h, - child: Image.asset( - 'assets/images/png/mail.png', + sizedBoxHeight(20.h), + Align( + alignment: Alignment.center, + child: text22400FCFCFC("Find your community")), + sizedBoxHeight(40.h), + Expanded( + child: Padding( + padding: EdgeInsets.symmetric(horizontal: 16.w), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + text16400white('Email address'), + sizedBoxHeight(10.h), + CustomTextFormField( + textEditingController: _emailController, + hintText: "Enter your email address", + leadingIcon: + // const Icon(Icons.mail_outline), + SizedBox( + width: 22.w, + height: 17.h, + child: Image.asset( + 'assets/images/png/mail.png', + width: 22.w, + height: 17.h, + ), + ), + // validationMessage: errormsg.value, + validator: (value) { + if (value!.isEmpty) { + return 'Enter your e-mail address'; + } + if (!RegExp( + r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$') + .hasMatch(value)) { + return 'Enter a valid e-mail address'; + } + return null; + }, + // onInput: (p0) { + // if (p0!.isEmpty) { + // errormsg.value = 'Enter your e-mail address'; + // } + // if (!RegExp( + // r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$') + // .hasMatch(p0!)) { + // errormsg.value = 'Enter a valid e-mail address'; + // } + // return null; + // }, + // validatorText: "Email Id", + + inputFormatters: [ + LengthLimitingTextInputFormatter(30), + RemoveEmojiInputFormatter() + ], + ), + sizedBoxHeight(10.h), + text16400white('Password'), + sizedBoxHeight(10.h), + CustomTextFormField( + isInputPassword: true, + textEditingController: _passwordController, + hintText: 'Enter your password', + leadingIcon: Image.asset( + 'assets/images/png/lock.png', width: 22.w, height: 17.h, ), - ), - // validationMessage: errormsg.value, - validator: (value) { - if (value!.isEmpty) { - return 'Enter your e-mail address'; - } - if (!RegExp( - r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$') - .hasMatch(value)) { - return 'Enter a valid e-mail address'; - } - return null; - }, - // onInput: (p0) { - // if (p0!.isEmpty) { - // errormsg.value = 'Enter your e-mail address'; - // } - // if (!RegExp( - // r'^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$') - // .hasMatch(p0!)) { - // errormsg.value = 'Enter a valid e-mail address'; - // } - // return null; - // }, - // validatorText: "Email Id", - - inputFormatters: [ - LengthLimitingTextInputFormatter(30), - RemoveEmojiInputFormatter() - ], - ), - sizedBoxHeight(10.h), - text16400white('Password'), - sizedBoxHeight(10.h), - CustomTextFormField( - isInputPassword: true, - textEditingController: _passwordController, - hintText: 'Enter your password', - leadingIcon: Image.asset( - 'assets/images/png/lock.png', - width: 22.w, - height: 17.h, - ), - // validationMessage: errormsgpass.value, - validator: (value) { - if (value!.isEmpty) { - return 'Please enter your password'; - } - if (!RegExp( - r'^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$') - .hasMatch(value)) { - return 'Enter a valid password'; - } - - return null; - }, - // onInput: (p0) { - // if (p0 == null || p0.isEmpty) { - // errormsgpass.value = - // 'Please enter your password'; - // } - // return null; - // }, - inputFormatters: [ - LengthLimitingTextInputFormatter(20), - RemoveEmojiInputFormatter() - ], - ), - sizedBoxHeight(10.h), - Align( - alignment: Alignment.centerRight, - child: Padding( - padding: EdgeInsets.only(right: 6.w), - child: GestureDetector( - onTap: () { - Get.toNamed(RouteName.forgotpass); - }, - child: text14400white('Forgot password ?')), - )), - sizedBoxHeight(40.h), - CustomButton( - text: "Login", - onPressed: () { - _logincheck(); - }), - sizedBoxHeight(20.h), - GestureDetector( - onTap: () { - Get.toNamed(RouteName.signupscreen); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - text14400white('Don’t have account ? '), - sizedBoxWidth(5.w), - text14700white('Sign up') + // validationMessage: errormsgpass.value, + validator: (value) { + if (value!.isEmpty) { + return 'Please enter your password'; + } + if (!RegExp( + r'^(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{8,}$') + .hasMatch(value)) { + return 'Enter a valid password'; + } + + return null; + }, + // onInput: (p0) { + // if (p0 == null || p0.isEmpty) { + // errormsgpass.value = + // 'Please enter your password'; + // } + // return null; + // }, + inputFormatters: [ + LengthLimitingTextInputFormatter(20), + RemoveEmojiInputFormatter() ], ), - ), - sizedBoxHeight(30.h), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: 160, - decoration: const ShapeDecoration( - shape: RoundedRectangleBorder( - side: BorderSide( - width: 0.50, - strokeAlign: BorderSide.strokeAlignCenter, - color: Color(0xFF434A53), - ), - ), - ), - ), - sizedBoxWidth(6.w), - text14400white('Or'), - sizedBoxWidth(6.w), - Container( - width: 160, - decoration: const ShapeDecoration( - shape: RoundedRectangleBorder( - side: BorderSide( - width: 0.50, - strokeAlign: BorderSide.strokeAlignCenter, - color: Color(0xFF434A53), - ), - ), - ), - ), - ], - ), - sizedBoxHeight(20.h), - Center( - child: SizedBox( - width: 220.w, + sizedBoxHeight(10.h), + Align( + alignment: Alignment.centerRight, + child: Padding( + padding: EdgeInsets.only(right: 6.w), + child: GestureDetector( + onTap: () { + Get.toNamed(RouteName.forgotpass); + }, + child: + text14400white('Forgot password ?')), + )), + sizedBoxHeight(40.h), + CustomButton( + text: "Login", + onPressed: () { + _logincheck(); + }), + sizedBoxHeight(20.h), + GestureDetector( + onTap: () { + Get.toNamed(RouteName.signupscreen); + }, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (Platform.isIOS) - GestureDetector( - onTap: () { - _loginWithApple(); - }, - child: Container( - width: 55, - height: 55, - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.71, -0.70), - end: const Alignment(-0.71, 0.7), - colors: [ - Colors.white.withOpacity( - 0.07999999821186066), - Colors.white.withOpacity( - 0.12999999523162842) - ], - ), - shape: const OvalBorder( - side: BorderSide( - width: 0.50, - color: Color(0xFF434A53)), - ), - image: const DecorationImage( - image: AssetImage( - 'assets/images/png/login2.png'))), - ), - ), - // const Spacer(), - if (Platform.isAndroid) - GestureDetector( - onTap: () { - _loginWithGoogle(); - }, - child: Container( - width: 55, - height: 55, - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.71, -0.70), - end: const Alignment(-0.71, 0.7), - colors: [ - Colors.white.withOpacity( - 0.07999999821186066), - Colors.white.withOpacity( - 0.12999999523162842) - ], - ), - shape: const OvalBorder( - side: BorderSide( - width: 0.50, - color: Color(0xFF434A53)), - ), - image: const DecorationImage( - image: AssetImage( - 'assets/images/png/login3.png'))), - ), - ), - // const Spacer(), - GestureDetector( - onTap: () async { - _checkIfisLoggedIn(); - }, - child: Container( - width: 55, - height: 55, - decoration: ShapeDecoration( - gradient: LinearGradient( - begin: const Alignment(0.71, -0.70), - end: const Alignment(-0.71, 0.7), - colors: [ - Colors.white.withOpacity( - 0.07999999821186066), - Colors.white.withOpacity( - 0.12999999523162842) - ], - ), - shape: const OvalBorder( - side: BorderSide( - width: 0.50, - color: Color(0xFF434A53)), - ), - image: const DecorationImage( - image: AssetImage( - 'assets/images/png/login4.png'))), - ), - ), + text14400white('Don’t have account ? '), + sizedBoxWidth(5.w), + text14700white('Sign up') ], ), ), - ), - // sizedBoxHeight(100) - ], + sizedBoxHeight(30.h), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 160, + decoration: const ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide( + width: 0.50, + strokeAlign: + BorderSide.strokeAlignCenter, + color: Color(0xFF434A53), + ), + ), + ), + ), + sizedBoxWidth(6.w), + text14400white('Or'), + sizedBoxWidth(6.w), + Container( + width: 160, + decoration: const ShapeDecoration( + shape: RoundedRectangleBorder( + side: BorderSide( + width: 0.50, + strokeAlign: + BorderSide.strokeAlignCenter, + color: Color(0xFF434A53), + ), + ), + ), + ), + ], + ), + sizedBoxHeight(20.h), + Center( + child: SizedBox( + width: 220.w, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceAround, + children: [ + if (Platform.isIOS) + GestureDetector( + onTap: () { + _loginWithApple(); + }, + child: Container( + width: 55, + height: 55, + decoration: ShapeDecoration( + gradient: LinearGradient( + begin: const Alignment( + 0.71, -0.70), + end: + const Alignment(-0.71, 0.7), + colors: [ + Colors.white.withOpacity( + 0.07999999821186066), + Colors.white.withOpacity( + 0.12999999523162842) + ], + ), + shape: const OvalBorder( + side: BorderSide( + width: 0.50, + color: Color(0xFF434A53)), + ), + image: const DecorationImage( + image: AssetImage( + 'assets/images/png/login2.png'))), + ), + ), + // const Spacer(), + if (Platform.isAndroid) + GestureDetector( + onTap: () { + _loginWithGoogle(); + }, + child: Container( + width: 55, + height: 55, + decoration: ShapeDecoration( + gradient: LinearGradient( + begin: const Alignment( + 0.71, -0.70), + end: + const Alignment(-0.71, 0.7), + colors: [ + Colors.white.withOpacity( + 0.07999999821186066), + Colors.white.withOpacity( + 0.12999999523162842) + ], + ), + shape: const OvalBorder( + side: BorderSide( + width: 0.50, + color: Color(0xFF434A53)), + ), + image: const DecorationImage( + image: AssetImage( + 'assets/images/png/login3.png'))), + ), + ), + // const Spacer(), + GestureDetector( + onTap: () async { + _checkIfisLoggedIn(); + }, + child: Container( + width: 55, + height: 55, + decoration: ShapeDecoration( + gradient: LinearGradient( + begin: + const Alignment(0.71, -0.70), + end: const Alignment(-0.71, 0.7), + colors: [ + Colors.white.withOpacity( + 0.07999999821186066), + Colors.white.withOpacity( + 0.12999999523162842) + ], + ), + shape: const OvalBorder( + side: BorderSide( + width: 0.50, + color: Color(0xFF434A53)), + ), + image: const DecorationImage( + image: AssetImage( + 'assets/images/png/login4.png'))), + ), + ), + ], + ), + ), + ), + // sizedBoxHeight(100) + ], + ), ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), ), ); diff --git a/lib/Utils/Common/CommonDropdown.dart b/lib/Utils/Common/CommonDropdown.dart index ac68a99..018e2f5 100644 --- a/lib/Utils/Common/CommonDropdown.dart +++ b/lib/Utils/Common/CommonDropdown.dart @@ -759,7 +759,7 @@ class CustomDropDownChexkBox extends StatefulWidget { required this.title, required this.listData, required this.onItemSelected, - required this.leadingImage, + this.leadingImage, this.showOtherOption = false, required this.initiallySelected, // Added this line }) : super(key: key); @@ -965,7 +965,12 @@ class _CustomDropDownChexkBoxState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - if (widget.leadingImage != null) widget.leadingImage!, + // if (widget.leadingImage != null) widget.leadingImage!, + widget.leadingImage == null + ? + SizedBox() + : + widget.leadingImage!, const SizedBox(width: 12), Text( selectedValues.isEmpty From 157ce0b4a9a917b827cbc5ecbf0a962075257545 Mon Sep 17 00:00:00 2001 From: Shubhamshirva Date: Mon, 22 Jul 2024 11:33:10 +0530 Subject: [PATCH 2/2] conflicts resolved --- .../ProfileTab/Following/Following.dart | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart b/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart index 88aab2b..549f50c 100644 --- a/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart +++ b/lib/Feed Module/Main_Screens/ProfileTab/Following/Following.dart @@ -288,23 +288,35 @@ class _FollowingState extends State { ), ), + ] ), - )), + ] + ) + ), ], - ), - ), - ], - ), - ); - }, - ); + ); + } + ); } - }, - ), - ]) - ])) - ], - ), + } + ) + + + ], + + ), + ] + ) + )] + + + ) + ); + } + + + + // Stack( // children: [ @@ -556,8 +568,6 @@ class _FollowingState extends State { // ])) // ], // ), - ); - } Widget _buildNoDataBody(context) { return Center(