Files
Regroup/lib/Feed Module/Main_Screens/Community/Community.dart
2024-08-01 13:33:57 +05:30

1660 lines
60 KiB
Dart

// ignore_for_file: unused_local_variable, non_constant_identifier_names, avoid_print, file_names
import 'package:flutter/material.dart';
import 'package:flutter_reaction_button/flutter_reaction_button.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:regroup/Common/CommonBottomNavigationBar.dart';
import 'package:regroup/Common/CommonGlassmorphism.dart';
import 'package:regroup/Common/CommonTabBar.dart';
import 'package:regroup/Common/CommonWidget.dart';
import 'package:regroup/Common/controller/MainScreen.dart';
import 'package:regroup/Feed%20Module/Main_Screens/Community/ViewModal/LatesPost.dart';
import 'package:regroup/Feed%20Module/sidemenu/sidemenu.dart';
import 'package:regroup/Utils/Common/sized_box.dart';
import 'package:regroup/Utils/texts.dart';
import 'package:regroup/resources/routes/route_name.dart';
class CommunityScreen extends StatefulWidget {
const CommunityScreen({super.key});
@override
State<CommunityScreen> createState() => _CommunityScreenState();
}
final List<String> titles = [
'Race',
'Swimming',
'Events',
'Swimming',
'Events',
];
class _CommunityScreenState extends State<CommunityScreen> {
final GlobalKey<ScaffoldState> _scaffoldKey1 = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
key: _scaffoldKey1,
backgroundColor: const Color(0xFF222935),
// drawerEnableOpenDragGesture: false,
drawer: SizedBox(width: 300.w, child: const SideMenu()),
extendBody: true,
appBar: AppBar(
scrolledUnderElevation: 0.0,
backgroundColor: const Color(0xff222935),
elevation: 0,
automaticallyImplyLeading: false,
titleSpacing: 0,
leading: InkWell(
onTap: () {
_scaffoldKey1.currentState?.openDrawer();
},
child: Center(
child: Image.asset(
'assets/images/png/menu.png',
height: 15.h,
width: 20.w,
),
),
),
title: Image.asset(
'assets/images/png/Group.png',
width: 26.w,
height: 25.h,
),
actions: [
GestureDetector(
onTap: () {
Get.toNamed(RouteName.explorescreen);
},
child: Image.asset(
'assets/images/png/ion_search-outline.png',
height: 25.h,
width: 25.w,
),
),
sizedBoxWidth(10.w),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.notificaationpage);
},
child: Image.asset(
'assets/images/png/Frame 9.png',
height: 25.h,
width: 25.w,
),
),
sizedBoxWidth(16.w),
],
),
body: Stack(clipBehavior: Clip.none, children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(
'assets/images/png/HomeScreenBackground.png',
))),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Column(children: [
Expanded(
child: DefaultTabController(
length: 3,
// initialIndex: selectedIndex.value,
child: Column(
children: [
const CommonTabBar(tabs: [
Tab(
text: 'Feed',
),
Tab(
text: 'Popular',
),
Tab(
text: 'Latest',
),
]),
Expanded(
child: TabBarView(
children: [
feedTabData(),
popularTab(),
const LatestTab(),
],
),
),
sizedBoxHeight(90.h)
],
),
),
),
]))
]),
floatingActionButton: Container(
height: 55.h,
width: 55.w,
decoration: const BoxDecoration(
shape: BoxShape.circle,
boxShadow: [
BoxShadow(
color: Color(0x40000000), // Hex color with 40% opacity
offset: Offset(0, 6),
blurRadius: 8,
),
],
),
child: FloatingActionButton(
onPressed: () {
Get.toNamed(RouteName.postscreen);
},
backgroundColor: const Color(0xFFD90B2E),
autofocus: true,
shape: const CircleBorder(),
child: Image.asset(
"assets/images/png/iconamoon_edit-thin.png",
height: 30.h,
width: 30.w,
),
),
),
bottomNavigationBar: bottomnavigationbar(mainController),
);
}
}
Widget feedTabData() {
List feedTabData = [
{
"profileImg": "assets/images/png/Ellipse 43.png",
"title": "Edward Hackket",
"mainImg": "assets/images/png/Rectangle 24.png",
"containerTitle": ['Cycle', 'Marathon', 'Events', 'Marathon', 'Events'],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
{
"profileImg": "assets/images/png/Ellipse 52.png",
"title": "Ryan Dorwat",
"mainImg": "assets/images/png/Rectangle 25.png",
"containerTitle": [
'Football',
'Teams player',
'Events',
'Marathon',
'Events'
],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
{
"profileImg": "assets/images/png/Ellipse 52.png",
"title": "Ryan Dorwat",
"mainImg": "assets/images/png/Rectangle 25.png",
"containerTitle": [
'Football',
'Teams player',
'Events',
'Marathon',
'Events'
],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
{
"profileImg": "assets/images/png/Ellipse 52.png",
"title": "Ryan Dorwat",
"mainImg": "assets/images/png/Rectangle 25.png",
"containerTitle": [
'Football',
'Teams player',
'Events',
'Marathon',
'Events'
],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
];
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: feedTabData.length,
itemBuilder: (context, index) {
return Column(
children: [
normalcardtile2(
profileImg: feedTabData[index]["profileImg"],
title: feedTabData[index]["title"],
mainImg: feedTabData[index]["mainImg"],
containerTitle: feedTabData[index]["containerTitle"],
description: 'test',
create_at: '1 hour',
total_comments: '20',
total_likes: '20',
total_save: '10',
community_name: 'text',
),
sizedBoxHeight(20.h)
],
);
},
),
),
],
);
}
Widget normalcardtile2({
required String profileImg,
required String title,
required String mainImg,
required String description,
required List<String> containerTitle,
required String community_name,
required String total_comments,
required String total_likes,
required String total_save,
required String? create_at,
}) {
var mainImage = 'assets/images/png/uiw_like-o.png'.obs;
void updateImage(String reaction) {
if (reaction == 'like') {
mainImage.value = 'assets/images/png/f7_hand-thumbsup.png';
} else if (reaction == 'heart') {
mainImage.value = 'assets/images/png/heart 2.png';
} else if (reaction == 'party') {
mainImage.value = 'assets/images/png/party-popper 2.png';
}
}
return commonGlassUI(
width: double.infinity,
height: 760.h,
mainOpacity: 1,
borderRadius: BorderRadius.circular(1),
customWidget: Column(
children: [
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
foregroundImage: NetworkImage(profileImg),
radius: 25.r,
),
sizedBoxWidth(12.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC(title),
sizedBoxHeight(5.h),
Row(
children: [
Image.asset(
'assets/images/png/community 1 (traced).png',
height: 14.w,
width: 14.w,
),
sizedBoxWidth(7.w),
text12w400_FCFCFC(community_name),
sizedBoxWidth(7.w),
Icon(
Icons.circle,
color: const Color(0xFFFCFCFC),
size: 4.sp,
),
sizedBoxWidth(6.w),
text12w400_FCFCFC(create_at!),
],
)
],
),
const Spacer(),
PopupMenuButton(
surfaceTintColor: const Color(0xFF222935),
constraints: BoxConstraints.tightFor(width: 176.w),
offset: const Offset(0, 50),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Report Post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/Vector (5).png",
height: 15.h,
width: 15.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Share post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/share.png",
height: 20.h,
width: 20.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Pin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 25.h,
width: 25.w,
)
],
),
),
),
],
child: Image.asset(
'assets/images/png/Group 1000004071.png',
width: 16.w,
height: 18.h,
),
),
sizedBoxWidth(5.w)
],
),
),
sizedBoxHeight(20.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.postdetailsScreen);
},
child: Container(
height: 360,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.cover,
image: NetworkImage(
mainImg,
),
)),
),
),
sizedBoxHeight(20.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(children: [
SizedBox(
height: 30.h,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: containerTitle.length,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(right: 12.w),
child: GestureDetector(
onTap: () {
Get.toNamed(RouteName.cyclescreen);
},
child: containertile2(
text: ("#${containerTitle[index]}"))),
);
},
),
),
sizedBoxHeight(20.h),
SizedBox(
width: double.infinity,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC(description),
],
),
),
Row(children: [
InkWell(
onTap: () {
Get.toNamed(RouteName.reactionview);
},
child: stackReaction(number: total_likes, containerImages: [
'assets/images/png/f7_hand-thumbsup.png',
'assets/images/png/heart 2.png',
'assets/images/png/party-popper 2.png'
]),
),
const Spacer(),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 13.h,
width: 13.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC(total_comments),
sizedBoxWidth(20.w),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Vector (1).png',
height: 12.h,
width: 12.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC(total_save),
]),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Obx(() {
return ReactionButton<String>(
onReactionChanged: (reaction) {
updateImage(reaction?.value ?? 'like');
debugPrint('Selected value: ${reaction?.value}');
},
reactions: <Reaction<String>?>[
Reaction<String>(
value: 'like',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/f7_hand-thumbsup.png'),
icon: _buildReactionsIcon(
'assets/images/png/f7_hand-thumbsup.png',
),
),
Reaction<String>(
value: 'heart',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/heart 2.png'),
icon: _buildReactionsIcon(
'assets/images/png/heart 2.png'),
),
Reaction<String>(
value: 'party',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/party-popper 2.png'),
icon: _buildReactionsIcon(
'assets/images/png/party-popper 2.png'),
),
],
selectedReaction: Reaction<String>(
value: 'like',
icon: _buildReactionsIcon(
'assets/images/png/f7_hand-thumbs.png'),
),
boxColor: Colors.white,
boxElevation: 2,
boxRadius: 30,
itemsSpacing: 8,
itemScale: 0.4,
itemSize: const Size(45, 45),
boxPadding: const EdgeInsets.all(8),
boxAnimationDuration:
const Duration(milliseconds: 200),
itemAnimationDuration:
const Duration(milliseconds: 500),
hoverDuration: const Duration(milliseconds: 700),
// toggle: false,
direction: ReactionsBoxAlignment.rtl,
child: _buildReactionsIcon(mainImage.value),
);
})
],
),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.postdetailsScreen);
},
child: Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Comment')
],
),
),
Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004089.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Save')
],
)
],
),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
]),
),
],
));
}
Widget normalcardtile({
required String profileImg,
required String title,
required String mainImg,
required List<String> containerTitle,
}) {
var mainImage = 'assets/images/png/uiw_like-o.png'.obs;
void updateImage(String reaction) {
if (reaction == 'like') {
mainImage.value = 'assets/images/png/f7_hand-thumbsup.png';
} else if (reaction == 'heart') {
mainImage.value = 'assets/images/png/heart 2.png';
} else if (reaction == 'party') {
mainImage.value = 'assets/images/png/party-popper 2.png';
}
}
return commonGlassContainer(
width: double.infinity,
height: 570.h,
border: 0,
borderradius: 1,
customWidget: Column(
children: [
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
foregroundImage: AssetImage(profileImg),
radius: 25.r,
),
sizedBoxWidth(12.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC(title),
sizedBoxHeight(5.h),
Row(
children: [
Image.asset(
'assets/images/png/community 1 (traced).png',
height: 14.w,
width: 14.w,
),
sizedBoxWidth(7.w),
text12w400_FCFCFC('Active alliance network'),
sizedBoxWidth(7.w),
Icon(
Icons.circle,
color: const Color(0xFFFCFCFC),
size: 4.sp,
),
sizedBoxWidth(6.w),
text12w400_FCFCFC('1 Hour ago'),
],
)
],
),
const Spacer(),
PopupMenuButton(
surfaceTintColor: const Color(0xFF222935),
constraints: BoxConstraints.tightFor(width: 176.w),
offset: const Offset(0, 50),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Report Post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/Vector (5).png",
height: 15.h,
width: 15.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Share post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/share.png",
height: 20.h,
width: 20.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Pin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 25.h,
width: 25.w,
)
],
),
),
),
],
child: Image.asset(
'assets/images/png/Group 1000004071.png',
width: 16.w,
height: 18.h,
),
),
sizedBoxWidth(5.w)
],
),
),
sizedBoxHeight(20.h),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.postdetailsScreen);
},
child: SizedBox(
height: 163.h,
width: double.infinity,
child: Image.asset(
mainImg,
fit: BoxFit.cover,
),
)),
sizedBoxHeight(20.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(children: [
SizedBox(
height: 30.h,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: containerTitle.length,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(right: 12.w),
child: GestureDetector(
onTap: () {
Get.toNamed(RouteName.cyclescreen);
},
child: containertile(
text: ("#${containerTitle[index]}"))),
);
},
),
),
sizedBoxHeight(20.h),
text16w400_FCFCFC(
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."),
Row(children: [
InkWell(
onTap: () {
Get.toNamed(RouteName.reactionview);
},
child: stackReaction(number: '20', containerImages: [
'assets/images/png/f7_hand-thumbsup.png',
'assets/images/png/heart 2.png',
'assets/images/png/party-popper 2.png'
]),
),
const Spacer(),
commonGlassContainer(
border: 0.43,
width: 30.w,
height: 30.h,
opacity1: 0.05,
opacity2: 0.06,
borderradius: 100,
customWidget: Center(
child: Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 13.h,
width: 13.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC('20'),
sizedBoxWidth(20.w),
commonGlassContainer(
border: 0.43,
width: 30.w,
height: 30.h,
borderradius: 100,
opacity1: 0.05,
opacity2: 0.06,
customWidget: Center(
child: Image.asset(
'assets/images/png/Vector (1).png',
height: 12.h,
width: 12.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC('10'),
]),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Obx(() {
return ReactionButton<String>(
onReactionChanged: (reaction) {
updateImage(reaction?.value ?? 'like');
debugPrint('Selected value: ${reaction?.value}');
},
reactions: <Reaction<String>?>[
Reaction<String>(
value: 'like',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/f7_hand-thumbsup.png'),
icon: _buildReactionsIcon(
'assets/images/png/f7_hand-thumbsup.png',
),
),
Reaction<String>(
value: 'heart',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/heart 2.png'),
icon: _buildReactionsIcon(
'assets/images/png/heart 2.png'),
),
Reaction<String>(
value: 'party',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/party-popper 2.png'),
icon: _buildReactionsIcon(
'assets/images/png/party-popper 2.png'),
),
],
selectedReaction: Reaction<String>(
value: 'like',
icon: _buildReactionsIcon(
'assets/images/png/f7_hand-thumbs.png'),
),
boxColor: Colors.white,
boxElevation: 2,
boxRadius: 30,
itemsSpacing: 8,
itemScale: 0.4,
itemSize: const Size(45, 45),
boxPadding: const EdgeInsets.all(8),
boxAnimationDuration:
const Duration(milliseconds: 200),
itemAnimationDuration:
const Duration(milliseconds: 500),
hoverDuration: const Duration(milliseconds: 700),
// toggle: false,
direction: ReactionsBoxAlignment.rtl,
child: _buildReactionsIcon(mainImage.value),
);
})
],
),
GestureDetector(
onTap: () {
Get.toNamed(RouteName.postdetailsScreen);
},
child: Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Comment')
],
),
),
Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004089.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Save')
],
)
],
),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
]),
),
],
));
}
Widget announcecardtile({
required String profileImg,
required String title,
required String mainImg,
required List<String> containerTitle,
}) {
var mainImage = 'assets/images/png/uiw_like-o.png'.obs;
void updateImage(String reaction) {
if (reaction == 'like') {
mainImage.value = 'assets/images/png/f7_hand-thumbsup.png';
} else if (reaction == 'heart') {
mainImage.value = 'assets/images/png/heart 2.png';
} else if (reaction == 'party') {
mainImage.value = 'assets/images/png/party-popper 2.png';
}
}
// MediaQuery.of(context).size.height
return Column(
children: [
commonGlassUIBlue(
width: double.infinity,
height: 610.h,
borderRadius: BorderRadius.circular(1),
customWidget: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.only(left: 16.w),
child: text16w700_FCFCFC("#Announcement"),
),
sizedBoxHeight(25.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
foregroundImage: AssetImage(profileImg),
radius: 25.r,
),
sizedBoxWidth(12.w),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
text16w400_FCFCFC(title),
sizedBoxHeight(5.h),
Row(
children: [
Image.asset(
'assets/images/png/community 1 (traced).png',
height: 14.w,
width: 14.w,
),
sizedBoxWidth(7.w),
text12w400_FCFCFC('Active alliance network'),
sizedBoxWidth(7.w),
Icon(
Icons.circle,
color: const Color(0xFFFCFCFC),
size: 4.sp,
),
sizedBoxWidth(6.w),
text12w400_FCFCFC('1 Hour ago'),
],
)
],
),
const Spacer(),
PopupMenuButton(
surfaceTintColor: const Color(0xFF222935),
constraints: BoxConstraints.tightFor(width: 176.w),
offset: const Offset(0, 50),
color: const Color(0xFF222935),
tooltip: "",
itemBuilder: (BuildContext context) => <PopupMenuEntry>[
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Report Post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/Vector (5).png",
height: 15.h,
width: 15.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Share post',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/share.png",
height: 20.h,
width: 20.w,
)
],
),
),
),
const PopupMenuDivider(),
PopupMenuItem(
onTap: () {},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Row(
children: [
Text(
'Pin',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
fontWeight: FontWeight.w800,
fontFamily: "Nunito Sans",
),
),
const Spacer(),
Image.asset(
"assets/images/png/f7_pin-fill (2).png",
height: 25.h,
width: 25.w,
)
],
),
),
),
],
child: Image.asset(
'assets/images/png/Group 1000004071.png',
width: 16.w,
height: 18.h,
),
),
sizedBoxWidth(5.w)
],
),
),
sizedBoxHeight(20.h),
GestureDetector(
onTap: () {
// Get.toNamed(RouteName.postdetailsScreen);
},
child: SizedBox(
height: 163.h,
width: double.infinity,
child: Image.asset(
mainImg,
fit: BoxFit.cover,
),
)),
sizedBoxHeight(20.h),
Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Column(children: [
SizedBox(
height: 30.h,
child: ListView.builder(
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemCount: containerTitle.length,
itemBuilder: (context, index) {
return Padding(
padding: EdgeInsets.only(right: 12.w),
child: GestureDetector(
onTap: () {
// Get.toNamed(RouteName.cyclescreen);
},
child:
containertile2(text: containerTitle[index])),
);
},
),
),
sizedBoxHeight(20.h),
text16w400_FCFCFC(
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."),
Row(children: [
InkWell(
onTap: () {
// Get.toNamed(RouteName.reactionview);
},
child: stackReaction(number: '20', containerImages: [
'assets/images/png/f7_hand-thumbsup.png',
'assets/images/png/heart 2.png',
'assets/images/png/party-popper 2.png'
]),
),
const Spacer(),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 13.h,
width: 13.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC('20'),
sizedBoxWidth(20.w),
commonContainer(
width: 30.w,
height: 30.h,
borderColor: const Color(0xFF434A53),
borderwidth: 0.43,
opacity1: 0.2,
opacity2: 0.2,
boxShape: BoxShape.circle,
customWidget: Center(
child: Image.asset(
'assets/images/png/Vector (1).png',
height: 12.h,
width: 12.w,
),
),
),
sizedBoxWidth(12.w),
text14w400_FCFCFC('10'),
]),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Obx(() {
return ReactionButton<String>(
onReactionChanged: (reaction) {
updateImage(reaction?.value ?? 'like');
debugPrint(
'Selected value: ${reaction?.value}');
},
reactions: <Reaction<String>?>[
Reaction<String>(
value: 'like',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/f7_hand-thumbsup.png'),
icon: _buildReactionsIcon(
'assets/images/png/f7_hand-thumbsup.png'),
),
Reaction<String>(
value: 'heart',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/heart 2.png'),
icon: _buildReactionsIcon(
'assets/images/png/heart 2.png'),
),
Reaction<String>(
value: 'party',
previewIcon: _buildReactionsPreviewIcon(
'assets/images/png/party-popper 2.png'),
icon: _buildReactionsIcon(
'assets/images/png/party-popper 2.png'),
),
],
selectedReaction: Reaction<String>(
value: 'like',
icon: _buildReactionsIcon(
'assets/images/png/f7_hand-thumbsup.png'),
),
boxColor: Colors.white,
boxElevation: 9,
boxRadius: 30,
itemsSpacing: 8,
itemScale: 0.4,
itemSize: const Size(45, 45),
boxPadding: const EdgeInsets.all(8),
boxAnimationDuration:
const Duration(milliseconds: 200),
itemAnimationDuration:
const Duration(milliseconds: 500),
hoverDuration: const Duration(milliseconds: 700),
// toggle: false,
child: _buildReactionsIcon(mainImage.value),
);
})
],
),
GestureDetector(
onTap: () {
// Get.toNamed(RouteName.postdetailsScreen);
},
child: Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004088.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Comment')
],
),
),
Column(
children: [
Image.asset(
'assets/images/png/Frame 1000004089.png',
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Save')
],
)
],
),
sizedBoxHeight(12.h),
commonDivider(),
sizedBoxHeight(12.h),
]),
),
],
)),
sizedBoxHeight(20.h),
],
);
}
Widget _buildReactionsPreviewIcon(String assetPath) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Image.asset(
assetPath,
height: 40.h,
width: 40.w,
),
);
}
Widget _buildReactionsIcon(String assetPath) {
return Column(
children: [
Image.asset(
assetPath,
height: 19.h,
width: 19.w,
),
sizedBoxHeight(8.h),
text11w400_FCFCFC('Like')
],
);
}
Widget containertile({required String text}) {
return commonGlassContainer(
border: 1,
width: 130.w,
height: 30.h,
borderradius: 30.r,
borderColor: const Color(0xFFD90B2E),
customWidget: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Center(child: text14w400_FCFCFC(text)),
));
}
Widget containertile2({required String text}) {
return commonContainer(
width: 130.w,
height: 30.h,
borderRadius: BorderRadius.circular(30.r),
borderColor: const Color(0xFFD90B2E),
opacity1: 0.04,
opacity2: 0.05,
customWidget: Padding(
padding: EdgeInsets.symmetric(horizontal: 10.w),
child: Center(child: text14w400_FCFCFC(text)),
));
}
Widget popularTab() {
List popularTabData = [
{
"profileImg": "assets/images/png/Ellipse 43.png",
"title": "Edward Hackket",
"mainImg": "assets/images/png/Rectangle 24.png",
"containerTitle": ['Cycle', 'Marathon', 'Events', 'Marathon', 'Events'],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
{
"profileImg": "assets/images/png/Ellipse 52.png",
"title": "Ryan Dorwat",
"mainImg": "assets/images/png/Rectangle 25.png",
"containerTitle": [
'Football',
'Teams player',
'Events',
'Marathon',
'Events'
],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
{
"profileImg": "assets/images/png/Ellipse 52.png",
"title": "Ryan Dorwat",
"mainImg": "assets/images/png/Rectangle 25.png",
"containerTitle": [
'Football',
'Teams player',
'Events',
'Marathon',
'Events'
],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
{
"profileImg": "assets/images/png/Ellipse 52.png",
"title": "Ryan Dorwat",
"mainImg": "assets/images/png/Rectangle 25.png",
"containerTitle": [
'Football',
'Teams player',
'Events',
'Marathon',
'Events'
],
"desciption": "",
"create_at": '1 hour',
"total_comments": 20,
"total_likes": 20,
"total_save": 10,
"community_name": 'text',
},
];
return Column(
children: [
sizedBoxHeight(20.h),
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: popularTabData.length,
itemBuilder: (context, index) {
return Column(
children: [
normalcardtile2(
profileImg: popularTabData[index]["profileImg"],
title: popularTabData[index]["title"],
mainImg: popularTabData[index]["mainImg"],
containerTitle: popularTabData[index]["containerTitle"],
description: 'test',
create_at: '1 hour',
total_comments: '20',
total_likes: '20',
total_save: '10',
community_name: 'text',
),
sizedBoxHeight(20.h)
],
);
},
),
),
],
);
}
class LatestTab extends StatefulWidget {
const LatestTab({super.key});
@override
State<LatestTab> createState() => _LatestTabState();
}
class _LatestTabState extends State<LatestTab> {
late Future latestfuture;
@override
void initState() {
latestfuture = LatespostApi().getLatestPostApi();
super.initState();
}
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: latestfuture,
builder: (ctx, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return
// ShimmerCommon();
const Center(
child: CircularProgressIndicator(
color: Colors.blue,
),
);
}
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(
clipBehavior: Clip.none,
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/png/Ellipse 1496.png"),
fit: BoxFit.fill),
),
),
Column(
children: [
sizedBoxHeight(16.h),
Expanded(
child: ListView.builder(
shrinkWrap: true,
itemCount: latestpostobj!.data!.length,
itemBuilder: (context, index) {
if (index == 1) {
return announcecardtile(
profileImg: latestpostobj!.data![index]
.iamPrincipal!.profilePhoto ??
'',
title: latestpostobj!.data![index].caption ?? '',
mainImg: 'assets/images/png/Rectangle 46.png',
containerTitle: [
'Race',
'Swimming',
'Events',
'Marathon',
'Events'
]);
} else {
String? createAtstring =
latestpostobj!.data![index].createdAt;
if (createAtstring == null ||
createAtstring.isEmpty) {
createAtstring = DateTime.now().toIso8601String();
}
String? timeAgo;
try {
DateTime postDateTime =
DateTime.parse(createAtstring);
DateTime now = DateTime.now();
Duration difference = now.difference(postDateTime);
if (difference.inDays > 365) {
timeAgo =
'${(difference.inDays / 365).floor()} years ago';
} else if (difference.inDays > 30) {
timeAgo =
'${(difference.inDays / 30).floor()} months ago';
} else if (difference.inDays > 7) {
timeAgo =
'${(difference.inDays / 7).floor()} weeks ago';
} else if (difference.inDays > 0) {
timeAgo = '${difference.inDays} days ago';
} else if (difference.inHours > 0) {
timeAgo = '${difference.inHours} hours ago';
} else if (difference.inMinutes > 0) {
timeAgo = '${difference.inMinutes} minutes ago';
} else {
timeAgo = '${difference.inSeconds} seconds ago';
}
print("Time ago: $timeAgo");
} catch (e) {
print("Error parsing date: $e");
String timeAgo = 'Unknown';
}
return Column(
children: [
normalcardtile2(
profileImg: latestpostobj!.data![index]
.iamPrincipal!.profilePhoto ??
'',
title: latestpostobj!
.data![index].iamPrincipal!.fullName ??
'',
mainImg:
latestpostobj!.data![index].image ?? '',
containerTitle:
latestpostobj!.data![index].tagNames ??
[''],
description:
latestpostobj!.data![index].caption ?? '',
create_at: timeAgo,
total_comments: latestpostobj!
.data![index].totalComment
.toString() ??
'',
total_likes: latestpostobj!
.data![index].likecount
.toString() ??
'',
total_save: latestpostobj!
.data![index].totalSave
.toString() ??
'',
community_name: latestpostobj!
.data![index].community!.communityName
.toString() ??
'',
),
sizedBoxHeight(20.h)
],
);
}
},
),
),
],
),
],
);
}
return Container();
},
);
}
}