234 lines
9.7 KiB
Dart
234 lines
9.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:regroup/Common/CommonGlassmorphism.dart';
|
|
import 'package:regroup/Common/base_manager.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/sidemenu/view_model/getmethod.dart';
|
|
import 'package:regroup/sidemenu/view_model/postmethod.dart';
|
|
|
|
class Communitiespinned extends StatefulWidget {
|
|
const Communitiespinned({super.key});
|
|
|
|
@override
|
|
State<Communitiespinned> createState() => _Communitiespinned();
|
|
}
|
|
|
|
class _Communitiespinned extends State<Communitiespinned> {
|
|
late Future myfuture;
|
|
|
|
@override
|
|
void initState() {
|
|
// TODO: implement initState
|
|
myfuture = Sidegetmethod().getUserpinnedList();
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF222935),
|
|
appBar: const CommonAppbar(
|
|
titleTxt: "Pinned Communities",
|
|
),
|
|
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),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
return userpinnedobj!.data!.pinnedCommunity!.isEmpty
|
|
? _buildNoDataBody(context)
|
|
: _buildBody(context);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
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),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
pinunpinCommunities(int communityid) async {
|
|
utils.loader();
|
|
Map<String, dynamic> updata = {
|
|
"manage_communities_xid": communityid,
|
|
};
|
|
final data = await SidebarTags().postUserpin(updata);
|
|
if (data.status == ResponseStatus.SUCCESS) {
|
|
Get.back();
|
|
return utils.showToast(data.message);
|
|
} else {
|
|
Get.back();
|
|
return utils.showToast(data.message);
|
|
}
|
|
}
|
|
|
|
Widget _buildBody(context) {
|
|
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: [
|
|
userpinnedobj!.data!.pinnedCommunity!.isEmpty
|
|
? Center(child: text16400white("Pinned Communities"))
|
|
: ListView.builder(
|
|
shrinkWrap: true,
|
|
physics: const ScrollPhysics(),
|
|
itemCount: userpinnedobj!.data!.pinnedCommunity!.length,
|
|
itemBuilder: (context, index) {
|
|
final commnityid = userpinnedobj!
|
|
.data!.pinnedCommunity![index].manageCommunitiesXid!;
|
|
|
|
return Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
|
child: commonGlassUI(
|
|
borderwidth: 0.9,
|
|
width: double.infinity,
|
|
height: 101.h,
|
|
borderRadius: BorderRadius.circular(10.r),
|
|
customWidget: Padding(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 16.w, vertical: 16.h),
|
|
child: Row(
|
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Container(
|
|
height: 65.h,
|
|
width: 65.h,
|
|
decoration: BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
// color: Colors.amber,
|
|
),
|
|
child:
|
|
// Center(
|
|
// child: Image.asset(imagepath, fit: BoxFit.cover)),
|
|
userpinnedobj!
|
|
.data!
|
|
.pinnedCommunity![
|
|
index]
|
|
.community!
|
|
.communityProfilePhoto ==
|
|
null ||
|
|
userpinnedobj!
|
|
.data!
|
|
.pinnedCommunity![index]
|
|
.community!
|
|
.communityProfilePhoto!
|
|
.isEmpty
|
|
? CircleAvatar(
|
|
backgroundImage: AssetImage(
|
|
'assets/images/png/sidemenu/rowing 1 (traced).png',
|
|
),
|
|
)
|
|
: CircleAvatar(
|
|
backgroundImage: NetworkImage(
|
|
userpinnedobj!
|
|
.data!
|
|
.pinnedCommunity![
|
|
index]
|
|
.community!
|
|
.communityProfilePhoto!),
|
|
)),
|
|
sizedBoxWidth(13.w),
|
|
userpinnedobj!.data!.pinnedCommunity![index]
|
|
.community ==
|
|
null ||
|
|
userpinnedobj!
|
|
.data!
|
|
.pinnedCommunity![index]
|
|
.community!
|
|
.communityName ==
|
|
null ||
|
|
userpinnedobj!
|
|
.data!
|
|
.pinnedCommunity![index]
|
|
.community!
|
|
.communityName!
|
|
.isEmpty
|
|
? text18w700_FCFCFC('Regroup')
|
|
: SizedBox(
|
|
width: 200.w,
|
|
child: text18w700_FCFCFC(
|
|
userpinnedobj!
|
|
.data!
|
|
.pinnedCommunity![index]
|
|
.community!
|
|
.communityName!),
|
|
),
|
|
// ),
|
|
Spacer(),
|
|
InkWell(
|
|
onTap: () async {
|
|
setState(() {
|
|
pinunpinCommunities(commnityid);
|
|
userpinnedobj!.data!.pinnedCommunity!
|
|
.removeWhere((item) =>
|
|
item.manageCommunitiesXid ==
|
|
commnityid);
|
|
});
|
|
},
|
|
child: Image.asset(
|
|
"assets/images/png/sidemenu/f7_pin-fill.png",
|
|
width: 19,
|
|
height: 19,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
)
|
|
],
|
|
);
|
|
}
|
|
}
|