Merge pull request #132 from WDI-Ideas/RegroupPriyanka
leave community api done
This commit is contained in:
@@ -90,6 +90,8 @@ class ApiUrls {
|
||||
|
||||
static const getComPostdetail = "${baseUrl}fetch-community-all-posts";
|
||||
|
||||
static const postleavecommunity = "${baseUrl}leave-community";
|
||||
|
||||
|
||||
|
||||
static const getrequestedcommunity =
|
||||
|
||||
@@ -14,8 +14,42 @@ import 'package:regroup/onboarding/Signup/view_model/postmethod.dart';
|
||||
import 'package:regroup/resources/routes/route_name.dart';
|
||||
import 'package:remove_emoji_input_formatter/remove_emoji_input_formatter.dart';
|
||||
|
||||
int? _firstSelectedIndex;
|
||||
bool _isFirstSelectionActive = false;
|
||||
class ActivityController extends GetxController {
|
||||
var selectedIndices = <int>[].obs;
|
||||
var firstSelectedIndex = Rxn<int>();
|
||||
var isFirstSelectionActive = false.obs;
|
||||
|
||||
void onContainerTap(int index) {
|
||||
if (selectedIndices.contains(index)) {
|
||||
selectedIndices.remove(index);
|
||||
if (firstSelectedIndex.value == index) {
|
||||
// If the first selected container is unselected, reset the active state
|
||||
firstSelectedIndex.value = null;
|
||||
isFirstSelectionActive.value = false;
|
||||
selectedIndices.clear();
|
||||
}
|
||||
} else {
|
||||
if (firstSelectedIndex.value == null) {
|
||||
// The first item is being selected
|
||||
firstSelectedIndex.value = index;
|
||||
isFirstSelectionActive.value = true;
|
||||
}
|
||||
selectedIndices.add(index);
|
||||
}
|
||||
}
|
||||
|
||||
Color getGradientColor(int index) {
|
||||
if (selectedIndices.isEmpty) {
|
||||
return Colors.transparent;
|
||||
} else if (firstSelectedIndex.value == index &&
|
||||
isFirstSelectionActive.value) {
|
||||
return Color(0XFFD90B2E);
|
||||
} else if (selectedIndices.contains(index)) {
|
||||
return Color(0xFF009DAB);
|
||||
}
|
||||
return Colors.transparent;
|
||||
}
|
||||
}
|
||||
|
||||
class SelectIndividualActivity extends StatefulWidget {
|
||||
const SelectIndividualActivity({super.key});
|
||||
@@ -26,8 +60,8 @@ class SelectIndividualActivity extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
|
||||
final List<int> _selectedIndices = [];
|
||||
TextEditingController otheractivitycontroller = TextEditingController();
|
||||
final ActivityController controller = Get.put(ActivityController());
|
||||
|
||||
// to select only two containers
|
||||
// void _onContainerTap(int index) {
|
||||
@@ -44,40 +78,6 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
|
||||
// });
|
||||
// }
|
||||
|
||||
void _onContainerTap(int index) {
|
||||
setState(() {
|
||||
if (_selectedIndices.contains(index)) {
|
||||
_selectedIndices.remove(index);
|
||||
if (_firstSelectedIndex == index) {
|
||||
// If the first selected container is unselected, reset the active state
|
||||
_firstSelectedIndex = null;
|
||||
_isFirstSelectionActive = false;
|
||||
_selectedIndices.clear();
|
||||
}
|
||||
} else {
|
||||
if (_firstSelectedIndex == null) {
|
||||
// The first item is being selected
|
||||
_firstSelectedIndex = index;
|
||||
_isFirstSelectionActive = true;
|
||||
}
|
||||
_selectedIndices.add(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Color _getGradientColor(int index) {
|
||||
if (_selectedIndices.isEmpty) {
|
||||
return Colors.transparent;
|
||||
} else if (_firstSelectedIndex == index && _isFirstSelectionActive) {
|
||||
// Apply Color(0XFFD90B2E) to the first selected item
|
||||
return Color(0XFFD90B2E);
|
||||
} else if (_selectedIndices.contains(index)) {
|
||||
// Apply Color(0xFF009DAB) to all other selected items
|
||||
return Color(0xFF009DAB);
|
||||
}
|
||||
return Colors.transparent;
|
||||
}
|
||||
|
||||
// void _onContainerTap(int id) {
|
||||
// setState(() {
|
||||
// if (_selectedIndices.contains(id)) {
|
||||
@@ -114,7 +114,7 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
|
||||
|
||||
Uploadata() async {
|
||||
utils.loader();
|
||||
String selectedIndicesString = '[${_selectedIndices.join(',')}]';
|
||||
String selectedIndicesString = '[${controller.selectedIndices.join(',')}]';
|
||||
Map<String, dynamic> updata = {
|
||||
"manage_interest_xid": selectedIndicesString,
|
||||
"other_interest": otheractivitycontroller.text,
|
||||
@@ -145,11 +145,11 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
|
||||
child: CustomButton(
|
||||
text: "Continue",
|
||||
onPressed: () {
|
||||
if (_selectedIndices.isEmpty &&
|
||||
if (controller.selectedIndices.isEmpty &&
|
||||
otheractivitycontroller.text.isEmpty) {
|
||||
utils.showToast('Please select activity');
|
||||
} else {
|
||||
print(_selectedIndices.toString());
|
||||
print(controller.selectedIndices.toString());
|
||||
// String selectedIndicesString =
|
||||
// _selectedIndices.join(',');
|
||||
// print(
|
||||
@@ -292,8 +292,7 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
|
||||
text20400white(
|
||||
'What are your interests?'),
|
||||
// sizedBoxHeight(5.w),
|
||||
|
||||
_isFirstSelectionActive
|
||||
controller.isFirstSelectionActive.value
|
||||
? text13400A7A7A7(
|
||||
'Select your secondary interests')
|
||||
: text13400A7A7A7(
|
||||
@@ -336,13 +335,7 @@ class _SelectIndividualActivityState extends State<SelectIndividualActivity> {
|
||||
image: indiactivityobj!
|
||||
.data![index].image,
|
||||
// 'assets/images/svg/individualact7.svg',
|
||||
isSelected: _selectedIndices
|
||||
.contains(indiactivityobj!
|
||||
.data![index].id!),
|
||||
gradientColor: _getGradientColor(
|
||||
indiactivityobj!
|
||||
.data![index].id!),
|
||||
onTap: _onContainerTap,
|
||||
controller: controller,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -556,103 +549,92 @@ class ActivityContainer extends StatelessWidget {
|
||||
final int index;
|
||||
final String titleString;
|
||||
final String? image;
|
||||
final bool isSelected;
|
||||
final Color gradientColor;
|
||||
final Function(int) onTap;
|
||||
final ActivityController controller;
|
||||
|
||||
ActivityContainer({
|
||||
required this.index,
|
||||
required this.titleString,
|
||||
required this.image,
|
||||
required this.isSelected,
|
||||
required this.gradientColor,
|
||||
required this.onTap,
|
||||
required this.controller,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => onTap(index),
|
||||
child: Container(
|
||||
// width: 110.w,
|
||||
// height: 120.h,
|
||||
decoration: ShapeDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: const Alignment(0.98, 0.10),
|
||||
end: const Alignment(-0.40, -0.70),
|
||||
colors: isSelected
|
||||
? _firstSelectedIndex == index &&
|
||||
_isFirstSelectionActive == true
|
||||
? [
|
||||
Color(0xFF009DAB).withOpacity(0.80),
|
||||
Color(0xFF009DAB).withOpacity(0.77),
|
||||
gradientColor.withOpacity(0.70),
|
||||
gradientColor.withOpacity(0.50),
|
||||
]
|
||||
return Obx(
|
||||
() {
|
||||
bool isSelected = controller.selectedIndices.contains(index);
|
||||
Color gradientColor = controller.getGradientColor(index);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => controller.onContainerTap(index),
|
||||
child: Container(
|
||||
decoration: ShapeDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: const Alignment(0.98, 0.10),
|
||||
end: const Alignment(-0.40, -0.70),
|
||||
colors: isSelected
|
||||
? controller.firstSelectedIndex.value == index &&
|
||||
controller.isFirstSelectionActive.value
|
||||
? [
|
||||
Color(0xFF009DAB).withOpacity(0.80),
|
||||
Color(0xFF009DAB).withOpacity(0.77),
|
||||
gradientColor.withOpacity(0.70),
|
||||
gradientColor.withOpacity(0.50),
|
||||
]
|
||||
: [
|
||||
Colors.white.withOpacity(0.06),
|
||||
Colors.white.withOpacity(0.08),
|
||||
]
|
||||
: [
|
||||
Colors.white.withOpacity(0.06),
|
||||
Colors.white.withOpacity(0.08),
|
||||
]
|
||||
: [
|
||||
Colors.white.withOpacity(0.06),
|
||||
Colors.white.withOpacity(0.08),
|
||||
],
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
side: isSelected
|
||||
? _firstSelectedIndex == index &&
|
||||
_isFirstSelectionActive == true
|
||||
? BorderSide(width: 0.4.w, color: Colors.transparent)
|
||||
: BorderSide(width: 3.w, color: gradientColor)
|
||||
: BorderSide(width: 2.w, color: Color(0xFF434A53)),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 10.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// image.isEmpty
|
||||
// ? SvgPicture.asset(
|
||||
// "assets/images/svg/individualact7.svg",
|
||||
// width: 50.w,
|
||||
// height: 50.h,
|
||||
// )
|
||||
// : Image.network(image),
|
||||
image == null || image!.isEmpty
|
||||
? Image.asset(
|
||||
'assets/images/png/redregroup.png',
|
||||
color: Colors.white,
|
||||
width: 50.w,
|
||||
height: 50.h,
|
||||
)
|
||||
// SvgPicture.asset(
|
||||
// "assets/images/svg/individualact7.svg",
|
||||
// width: 50.w,
|
||||
// height: 50.h,
|
||||
// )
|
||||
: Image.network(
|
||||
image!,
|
||||
width: 50.w,
|
||||
height: 50.h,
|
||||
),
|
||||
const Spacer(flex: 3),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
titleString,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
shape: RoundedRectangleBorder(
|
||||
side: isSelected
|
||||
? controller.firstSelectedIndex.value == index &&
|
||||
controller.isFirstSelectionActive.value
|
||||
? BorderSide(width: 0.4.w, color: Colors.transparent)
|
||||
: BorderSide(width: 3.w, color: gradientColor)
|
||||
: BorderSide(width: 2.w, color: Color(0xFF434A53)),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 0.w, vertical: 10.h),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
image == null || image!.isEmpty
|
||||
? Image.asset(
|
||||
'assets/images/png/redregroup.png',
|
||||
color: Colors.white,
|
||||
width: 50.w,
|
||||
height: 50.h,
|
||||
)
|
||||
: Image.network(
|
||||
image!,
|
||||
width: 50.w,
|
||||
height: 50.h,
|
||||
),
|
||||
const Spacer(flex: 3),
|
||||
SizedBox(
|
||||
child: Text(
|
||||
titleString,
|
||||
style: TextStyle(
|
||||
fontSize: 14.sp,
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:regroup/Common/CommonGlassmorphism.dart';
|
||||
import 'package:regroup/Common/CommonTabBar.dart';
|
||||
import 'package:regroup/Common/CommonWidget.dart';
|
||||
import 'package:regroup/Common/ConvertServerDateToUserDate.dart';
|
||||
import 'package:regroup/Common/base_manager.dart';
|
||||
import 'package:regroup/Main_Screens/Community/Model/CommonDatumObjModel.dart';
|
||||
import 'package:regroup/Main_Screens/Community/Model/fetchicons.dart';
|
||||
import 'package:regroup/Main_Screens/Community/ViewModel/getmethod.dart';
|
||||
@@ -13,6 +14,7 @@ import 'package:regroup/Main_Screens/Community_HomePage/Community.dart';
|
||||
import 'package:regroup/Main_Screens/Community_HomePage/view_model/CountersHelper.dart';
|
||||
import 'package:regroup/Utils/Common/CommonAppbar.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:regroup/sidemenu/Community/MyCommunity/view_model/ComDetails.dart';
|
||||
@@ -39,6 +41,22 @@ class _CommunityDetailsState extends State<CommunityDetails> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
leaveCommunity() async {
|
||||
utils.loader();
|
||||
Map<String, dynamic> updata = {};
|
||||
final data =
|
||||
await CommunityDetail().postLeaveCommunity(updata, CommunityId);
|
||||
if (data.status == ResponseStatus.SUCCESS) {
|
||||
Get.back();
|
||||
Get.offNamed(RouteName.mycommunity);
|
||||
// toggleSelectedIndex(tagid);
|
||||
return utils.showToast(data.message);
|
||||
} else {
|
||||
Get.back();
|
||||
return utils.showToast(data.message);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -50,7 +68,7 @@ class _CommunityDetailsState extends State<CommunityDetails> {
|
||||
titleTxt: "",
|
||||
customActionWidget: PopupMenuButton(
|
||||
surfaceTintColor: const Color(0xFF222935),
|
||||
constraints: BoxConstraints.tightFor(width: 180.w),
|
||||
constraints: BoxConstraints.tightFor(width: 190.w),
|
||||
offset: const Offset(0, 40),
|
||||
color: const Color(0xFF222935),
|
||||
tooltip: "",
|
||||
@@ -147,18 +165,16 @@ class _CommunityDetailsState extends State<CommunityDetails> {
|
||||
const PopupMenuDivider(),
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.communitysetting, arguments: {
|
||||
'communityid': CommunityId,
|
||||
});
|
||||
leaveCommunity();
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8.w),
|
||||
child: Row(
|
||||
children: [
|
||||
text14w400white("Edit community"),
|
||||
text14w400white("Leave community"),
|
||||
const Spacer(),
|
||||
Image.asset(
|
||||
"assets/images/png/setting2.png",
|
||||
"assets/images/png/logout 1 (traced).png",
|
||||
height: 18.h,
|
||||
width: 18.w,
|
||||
)
|
||||
|
||||
@@ -71,78 +71,84 @@ class _MyCommunityState extends State<MyCommunity> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
// key: _scaffoldKey1,
|
||||
backgroundColor: const Color(0xFF222935),
|
||||
extendBody: true,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: CommonAppbar(
|
||||
titleTxt: "My Communities",
|
||||
customActionWidget: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.newcommunity);
|
||||
},
|
||||
child: Container(
|
||||
height: 30.h,
|
||||
width: 30.w,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFD90B2E),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0x40000000),
|
||||
offset: Offset(0, 6),
|
||||
blurRadius: 8,
|
||||
spreadRadius: 0,
|
||||
),
|
||||
],
|
||||
shape: BoxShape.circle),
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
Get.toNamed(RouteName.mainscreen, arguments: 0);
|
||||
return true;
|
||||
},
|
||||
child: Scaffold(
|
||||
// key: _scaffoldKey1,
|
||||
backgroundColor: const Color(0xFF222935),
|
||||
extendBody: true,
|
||||
resizeToAvoidBottomInset: false,
|
||||
appBar: CommonAppbar(
|
||||
titleTxt: "My Communities",
|
||||
customActionWidget: Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.newcommunity);
|
||||
},
|
||||
child: Container(
|
||||
height: 30.h,
|
||||
width: 30.w,
|
||||
decoration: const BoxDecoration(
|
||||
color: Color(0xFFD90B2E),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Color(0x40000000),
|
||||
offset: Offset(0, 6),
|
||||
blurRadius: 8,
|
||||
spreadRadius: 0,
|
||||
),
|
||||
],
|
||||
shape: BoxShape.circle),
|
||||
child: const Icon(
|
||||
Icons.add,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
sizedBoxWidth(12.w),
|
||||
Image.asset(
|
||||
"assets/images/png/Frame 9.png",
|
||||
height: 22.h,
|
||||
width: 22.w,
|
||||
)
|
||||
],
|
||||
sizedBoxWidth(12.w),
|
||||
Image.asset(
|
||||
"assets/images/png/Frame 9.png",
|
||||
height: 22.h,
|
||||
width: 22.w,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: myfuture,
|
||||
builder: (ctx, snapshot) {
|
||||
if (snapshot.data == null) {
|
||||
return const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFFC18948),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text(
|
||||
'${snapshot.error} occured',
|
||||
style: TextStyle(fontSize: 18.spMin),
|
||||
),
|
||||
body: FutureBuilder(
|
||||
future: myfuture,
|
||||
builder: (ctx, snapshot) {
|
||||
if (snapshot.data == null) {
|
||||
return const Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: Color(0xFFC18948),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
return myCommunityobj!.data!.isEmpty
|
||||
? _buildNoDataBody(context)
|
||||
: _buildBody(context);
|
||||
},
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
if (snapshot.hasError) {
|
||||
return Center(
|
||||
child: Text(
|
||||
'${snapshot.error} occured',
|
||||
style: TextStyle(fontSize: 18.spMin),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
return myCommunityobj!.data!.isEmpty
|
||||
? _buildNoDataBody(context)
|
||||
: _buildBody(context);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -200,7 +206,9 @@ class _MyCommunityState extends State<MyCommunity> {
|
||||
padding: EdgeInsets.only(bottom: 25.h),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.communityDetails, arguments: {"CommunityID" : joinnedComData.manageCommunityXid});
|
||||
Get.toNamed(RouteName.communityDetails, arguments: {
|
||||
"CommunityID": joinnedComData.manageCommunityXid
|
||||
});
|
||||
},
|
||||
child: commonGlassUI(
|
||||
borderwidth: 0.9,
|
||||
|
||||
@@ -41,4 +41,15 @@ class CommunityDetail {
|
||||
response.data['message'], ResponseStatus.FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
Future<ResponseData<dynamic>> postLeaveCommunity(updata, comId) async {
|
||||
final response = await NetworkApiServices().postApi(
|
||||
updata,
|
||||
"${ApiUrls.postleavecommunity}?manage_community_xid=$comId",
|
||||
);
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
|
||||
}
|
||||
return response;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user