revert changes of community latest post api
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// 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';
|
||||
@@ -7,6 +9,7 @@ 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';
|
||||
@@ -87,10 +90,7 @@ class _CommunityScreenState extends State<CommunityScreen> {
|
||||
sizedBoxWidth(16.w),
|
||||
],
|
||||
),
|
||||
body:
|
||||
|
||||
|
||||
Stack(clipBehavior: Clip.none, children: [
|
||||
body: Stack(clipBehavior: Clip.none, children: [
|
||||
Container(
|
||||
decoration: const BoxDecoration(
|
||||
image: DecorationImage(
|
||||
@@ -122,9 +122,9 @@ class _CommunityScreenState extends State<CommunityScreen> {
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
children: [
|
||||
feedTab(),
|
||||
feedTabData(),
|
||||
popularTab(),
|
||||
latestTab(),
|
||||
const LatestTab(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -158,8 +158,7 @@ class _CommunityScreenState extends State<CommunityScreen> {
|
||||
child: Image.asset(
|
||||
"assets/images/png/iconamoon_edit-thin.png",
|
||||
height: 30.h,
|
||||
width: 30.w
|
||||
,
|
||||
width: 30.w,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -169,13 +168,19 @@ class _CommunityScreenState extends State<CommunityScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
Widget feedTab() {
|
||||
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",
|
||||
@@ -188,6 +193,12 @@ Widget feedTab() {
|
||||
'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",
|
||||
@@ -200,6 +211,12 @@ Widget feedTab() {
|
||||
'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",
|
||||
@@ -212,75 +229,58 @@ Widget feedTab() {
|
||||
'Marathon',
|
||||
'Events'
|
||||
],
|
||||
"desciption": "",
|
||||
"create_at": '1 hour',
|
||||
"total_comments": 20,
|
||||
"total_likes": 20,
|
||||
"total_save": 10,
|
||||
"community_name": 'text',
|
||||
},
|
||||
];
|
||||
|
||||
return Column(children: [
|
||||
sizedBoxHeight(16.h),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: feedTabData.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 1) {
|
||||
return announcecardtile(
|
||||
profileImg: 'assets/images/png/Ellipse 48.png',
|
||||
title: 'Jocelyn Dokidis',
|
||||
mainImg: 'assets/images/png/Rectangle 46.png',
|
||||
containerTitle: [
|
||||
'Race',
|
||||
'Swimming',
|
||||
'Events',
|
||||
'Marathon',
|
||||
'Events'
|
||||
]);
|
||||
} else {
|
||||
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"]),
|
||||
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)
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
// normalcardtile2(
|
||||
// profileImg: 'assets/images/png/Ellipse 43.png',
|
||||
// title: 'Edward Hackket',
|
||||
// mainImg: 'assets/images/png/Rectangle 24.png',
|
||||
// containerTitle: ['Cycle', 'Marathon', 'Events', 'Marathon', 'Events']),
|
||||
// sizedBoxHeight(20.h),
|
||||
// announcecardtile(
|
||||
// profileImg: 'assets/images/png/Ellipse 48.png',
|
||||
// title: 'Jocelyn Dokidis',
|
||||
// mainImg: 'assets/images/png/Rectangle 46.png',
|
||||
// containerTitle: ['Race', 'Swimming', 'Events', 'Marathon', 'Events']),
|
||||
// sizedBoxHeight(20.h),
|
||||
// normalcardtile2(
|
||||
// profileImg: 'assets/images/png/Ellipse 52.png',
|
||||
// title: 'Ryan Dorwat',
|
||||
// mainImg: 'assets/images/png/Rectangle 25.png',
|
||||
// containerTitle: [
|
||||
// 'Football',
|
||||
// 'Teams player',
|
||||
// 'Events',
|
||||
// 'Marathon',
|
||||
// 'Events'
|
||||
// ]),
|
||||
// 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) {
|
||||
@@ -295,7 +295,7 @@ Widget normalcardtile2({
|
||||
|
||||
return commonGlassUI(
|
||||
width: double.infinity,
|
||||
height: 570.h,
|
||||
height: 760.h,
|
||||
mainOpacity: 1,
|
||||
borderRadius: BorderRadius.circular(1),
|
||||
customWidget: Column(
|
||||
@@ -307,7 +307,7 @@ Widget normalcardtile2({
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CircleAvatar(
|
||||
foregroundImage: AssetImage(profileImg),
|
||||
foregroundImage: NetworkImage(profileImg),
|
||||
radius: 25.r,
|
||||
),
|
||||
sizedBoxWidth(12.w),
|
||||
@@ -324,7 +324,7 @@ Widget normalcardtile2({
|
||||
width: 14.w,
|
||||
),
|
||||
sizedBoxWidth(7.w),
|
||||
text12w400_FCFCFC('Active alliance network'),
|
||||
text12w400_FCFCFC(community_name),
|
||||
sizedBoxWidth(7.w),
|
||||
Icon(
|
||||
Icons.circle,
|
||||
@@ -332,7 +332,7 @@ Widget normalcardtile2({
|
||||
size: 4.sp,
|
||||
),
|
||||
sizedBoxWidth(6.w),
|
||||
text12w400_FCFCFC('1 Hour ago'),
|
||||
text12w400_FCFCFC(create_at!),
|
||||
],
|
||||
)
|
||||
],
|
||||
@@ -435,17 +435,21 @@ Widget normalcardtile2({
|
||||
),
|
||||
sizedBoxHeight(20.h),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.postdetailsScreen);
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 163.h,
|
||||
width: double.infinity,
|
||||
child: Image.asset(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.postdetailsScreen);
|
||||
},
|
||||
child: Container(
|
||||
height: 360,
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(
|
||||
mainImg,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
sizedBoxHeight(20.h),
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||||
@@ -470,14 +474,21 @@ Widget normalcardtile2({
|
||||
),
|
||||
),
|
||||
sizedBoxHeight(20.h),
|
||||
text16w400_FCFCFC(
|
||||
"Lorem Ipsum has been the industry's standard dummy text ever since the 1500s . . ."),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
text16w400_FCFCFC(description),
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(RouteName.reactionview);
|
||||
},
|
||||
child: stackReaction(number: '20', containerImages: [
|
||||
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'
|
||||
@@ -501,7 +512,7 @@ Widget normalcardtile2({
|
||||
),
|
||||
),
|
||||
sizedBoxWidth(12.w),
|
||||
text14w400_FCFCFC('20'),
|
||||
text14w400_FCFCFC(total_comments),
|
||||
sizedBoxWidth(20.w),
|
||||
commonContainer(
|
||||
width: 30.w,
|
||||
@@ -520,7 +531,7 @@ Widget normalcardtile2({
|
||||
),
|
||||
),
|
||||
sizedBoxWidth(12.w),
|
||||
text14w400_FCFCFC('10'),
|
||||
text14w400_FCFCFC(total_save),
|
||||
]),
|
||||
sizedBoxHeight(12.h),
|
||||
commonDivider(),
|
||||
@@ -641,11 +652,11 @@ Widget normalcardtile({
|
||||
}
|
||||
}
|
||||
|
||||
return commonGlassUI(
|
||||
return commonGlassContainer(
|
||||
width: double.infinity,
|
||||
height: 570.h,
|
||||
borderwidth: 0,
|
||||
borderRadius: BorderRadius.circular( 1),
|
||||
border: 0,
|
||||
borderradius: 1,
|
||||
customWidget: Column(
|
||||
children: [
|
||||
sizedBoxHeight(25.h),
|
||||
@@ -832,13 +843,13 @@ Widget normalcardtile({
|
||||
]),
|
||||
),
|
||||
const Spacer(),
|
||||
commonGlassUI(
|
||||
borderwidth: 0.43,
|
||||
commonGlassContainer(
|
||||
border: 0.43,
|
||||
width: 30.w,
|
||||
height: 30.h,
|
||||
opacity1: 0.05,
|
||||
opacity2: 0.06,
|
||||
borderRadius: BorderRadius.circular( 100),
|
||||
borderradius: 100,
|
||||
customWidget: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/png/Frame 1000004088.png',
|
||||
@@ -850,11 +861,11 @@ Widget normalcardtile({
|
||||
sizedBoxWidth(12.w),
|
||||
text14w400_FCFCFC('20'),
|
||||
sizedBoxWidth(20.w),
|
||||
commonGlassUI(
|
||||
borderwidth: 0.43,
|
||||
commonGlassContainer(
|
||||
border: 0.43,
|
||||
width: 30.w,
|
||||
height: 30.h,
|
||||
borderRadius: BorderRadius.circular( 100),
|
||||
borderradius: 100,
|
||||
opacity1: 0.05,
|
||||
opacity2: 0.06,
|
||||
customWidget: Center(
|
||||
@@ -1354,11 +1365,11 @@ Widget _buildReactionsIcon(String assetPath) {
|
||||
}
|
||||
|
||||
Widget containertile({required String text}) {
|
||||
return commonGlassUI(
|
||||
borderwidth: 1,
|
||||
return commonGlassContainer(
|
||||
border: 1,
|
||||
width: 130.w,
|
||||
height: 30.h,
|
||||
borderRadius: BorderRadius.circular( 30.r),
|
||||
borderradius: 30.r,
|
||||
borderColor: const Color(0xFFD90B2E),
|
||||
customWidget: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 10.w),
|
||||
@@ -1387,6 +1398,12 @@ Widget popularTab() {
|
||||
"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",
|
||||
@@ -1399,6 +1416,12 @@ Widget popularTab() {
|
||||
'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",
|
||||
@@ -1411,6 +1434,12 @@ Widget popularTab() {
|
||||
'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",
|
||||
@@ -1423,6 +1452,12 @@ Widget popularTab() {
|
||||
'Marathon',
|
||||
'Events'
|
||||
],
|
||||
"desciption": "",
|
||||
"create_at": '1 hour',
|
||||
"total_comments": 20,
|
||||
"total_likes": 20,
|
||||
"total_save": 10,
|
||||
"community_name": 'text',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1437,10 +1472,17 @@ Widget popularTab() {
|
||||
return Column(
|
||||
children: [
|
||||
normalcardtile2(
|
||||
profileImg: popularTabData[index]["profileImg"],
|
||||
title: popularTabData[index]["title"],
|
||||
mainImg: popularTabData[index]["mainImg"],
|
||||
containerTitle: popularTabData[index]["containerTitle"]),
|
||||
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)
|
||||
],
|
||||
);
|
||||
@@ -1451,98 +1493,168 @@ Widget popularTab() {
|
||||
);
|
||||
}
|
||||
|
||||
Widget latestTab() {
|
||||
List latestTabData = [
|
||||
{
|
||||
"profileImg": "assets/images/png/Ellipse 43.png",
|
||||
"title": "Edward Hackket",
|
||||
"mainImg": "assets/images/png/Rectangle 24.png",
|
||||
"containerTitle": ['Cycle', 'Marathon', 'Events', 'Marathon', 'Events'],
|
||||
},
|
||||
{
|
||||
"profileImg": "assets/images/png/Ellipse 52.png",
|
||||
"title": "Ryan Dorwat",
|
||||
"mainImg": "assets/images/png/Rectangle 25.png",
|
||||
"containerTitle": [
|
||||
'Football',
|
||||
'Teams player',
|
||||
'Events',
|
||||
'Marathon',
|
||||
'Events'
|
||||
],
|
||||
},
|
||||
{
|
||||
"profileImg": "assets/images/png/Ellipse 52.png",
|
||||
"title": "Ryan Dorwat",
|
||||
"mainImg": "assets/images/png/Rectangle 25.png",
|
||||
"containerTitle": [
|
||||
'Football',
|
||||
'Teams player',
|
||||
'Events',
|
||||
'Marathon',
|
||||
'Events'
|
||||
],
|
||||
},
|
||||
{
|
||||
"profileImg": "assets/images/png/Ellipse 52.png",
|
||||
"title": "Ryan Dorwat",
|
||||
"mainImg": "assets/images/png/Rectangle 25.png",
|
||||
"containerTitle": [
|
||||
'Football',
|
||||
'Teams player',
|
||||
'Events',
|
||||
'Marathon',
|
||||
'Events'
|
||||
],
|
||||
},
|
||||
];
|
||||
class LatestTab extends StatefulWidget {
|
||||
const LatestTab({super.key});
|
||||
|
||||
return Column(children: [
|
||||
sizedBoxHeight(16.h),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: latestTabData.length,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 1) {
|
||||
return announcecardtile(
|
||||
profileImg: 'assets/images/png/Ellipse 48.png',
|
||||
title: 'Jocelyn Dokidis',
|
||||
mainImg: 'assets/images/png/Rectangle 46.png',
|
||||
containerTitle: [
|
||||
'Race',
|
||||
'Swimming',
|
||||
'Events',
|
||||
'Marathon',
|
||||
'Events'
|
||||
]);
|
||||
} else {
|
||||
return Column(
|
||||
children: [
|
||||
normalcardtile2(
|
||||
profileImg: latestTabData[index]["profileImg"],
|
||||
title: latestTabData[index]["title"],
|
||||
mainImg: latestTabData[index]["mainImg"],
|
||||
containerTitle: latestTabData[index]["containerTitle"]),
|
||||
sizedBoxHeight(20.h)
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// normalcardtile2(
|
||||
// profileImg: 'assets/images/png/Ellipse 43.png',
|
||||
// title: 'Edward Hackket',
|
||||
// mainImg: 'assets/images/png/Rectangle 24.png',
|
||||
// containerTitle: ['Cycle', 'Marathon', 'Events', 'Marathon', 'Events']),
|
||||
// sizedBoxHeight(20.h),
|
||||
// announcecardtile(
|
||||
// profileImg: 'assets/images/png/Ellipse 48.png',
|
||||
// title: 'Jocelyn Dokidis',
|
||||
// mainImg: 'assets/images/png/Rectangle 46.png',
|
||||
// containerTitle: ['Race', 'Swimming', 'Events', 'Marathon', 'Events']),
|
||||
// sizedBoxHeight(20.h),
|
||||
]);
|
||||
@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();
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
183
lib/Main_Screens/Community/Model/LatestPostModel.dart
Normal file
183
lib/Main_Screens/Community/Model/LatestPostModel.dart
Normal file
@@ -0,0 +1,183 @@
|
||||
class Latestpost {
|
||||
String? status;
|
||||
int? statusCode;
|
||||
String? message;
|
||||
List<Data>? data;
|
||||
|
||||
Latestpost({this.status, this.statusCode, this.message, this.data});
|
||||
|
||||
Latestpost.fromJson(Map<String, dynamic> json) {
|
||||
status = json['status'];
|
||||
statusCode = json['status_code'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = <Data>[];
|
||||
json['data'].forEach((v) {
|
||||
data!.add(Data.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['status'] = status;
|
||||
data['status_code'] = statusCode;
|
||||
data['message'] = message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data!.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Data {
|
||||
int? id;
|
||||
int? likecount;
|
||||
List<int>? tagsXid;
|
||||
bool? isILiked;
|
||||
int? totalComment;
|
||||
int? totalSave;
|
||||
int? iamPrincipalXid;
|
||||
int? postIn;
|
||||
String? caption;
|
||||
String? image;
|
||||
String? manageTagsXids;
|
||||
String? postAs;
|
||||
String? ctaTitle;
|
||||
String? ctaLink;
|
||||
String? createdAt;
|
||||
List<String>? tagNames;
|
||||
String? likeIcon;
|
||||
IamPrincipal? iamPrincipal;
|
||||
Community? community;
|
||||
|
||||
Data(
|
||||
{this.id,
|
||||
this.likecount,
|
||||
this.tagsXid,
|
||||
this.isILiked,
|
||||
this.totalComment,
|
||||
this.totalSave,
|
||||
this.iamPrincipalXid,
|
||||
this.postIn,
|
||||
this.caption,
|
||||
this.image,
|
||||
this.manageTagsXids,
|
||||
this.postAs,
|
||||
this.ctaTitle,
|
||||
this.ctaLink,
|
||||
this.createdAt,
|
||||
this.tagNames,
|
||||
this.likeIcon,
|
||||
this.iamPrincipal,
|
||||
this.community});
|
||||
|
||||
Data.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
likecount = json['likecount'];
|
||||
tagsXid = json['tags_xid'].cast<int>();
|
||||
isILiked = json['is_i_liked'];
|
||||
totalComment = json['total_comment'];
|
||||
totalSave = json['total_save'];
|
||||
iamPrincipalXid = json['iam_principal_xid'];
|
||||
postIn = json['post_in'];
|
||||
caption = json['caption'];
|
||||
image = json['image'];
|
||||
manageTagsXids = json['manage_tags_xids'];
|
||||
postAs = json['post_as'];
|
||||
ctaTitle = json['cta_title'];
|
||||
ctaLink = json['cta_link'];
|
||||
createdAt = json['created_at'];
|
||||
tagNames = json['tag_names'].cast<String>();
|
||||
likeIcon = json['likeIcon'];
|
||||
iamPrincipal = json['iam_principal'] != null
|
||||
? IamPrincipal.fromJson(json['iam_principal'])
|
||||
: null;
|
||||
community = json['community'] != null
|
||||
? Community.fromJson(json['community'])
|
||||
: null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['likecount'] = likecount;
|
||||
data['tags_xid'] = tagsXid;
|
||||
data['is_i_liked'] = isILiked;
|
||||
data['total_comment'] = totalComment;
|
||||
data['total_save'] = totalSave;
|
||||
data['iam_principal_xid'] = iamPrincipalXid;
|
||||
data['post_in'] = postIn;
|
||||
data['caption'] = caption;
|
||||
data['image'] = image;
|
||||
data['manage_tags_xids'] = manageTagsXids;
|
||||
data['post_as'] = postAs;
|
||||
data['cta_title'] = ctaTitle;
|
||||
data['cta_link'] = ctaLink;
|
||||
data['created_at'] = createdAt;
|
||||
data['tag_names'] = tagNames;
|
||||
data['likeIcon'] = likeIcon;
|
||||
if (iamPrincipal != null) {
|
||||
data['iam_principal'] = iamPrincipal!.toJson();
|
||||
}
|
||||
if (community != null) {
|
||||
data['community'] = community!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class IamPrincipal {
|
||||
int? id;
|
||||
int? principalTypeXid;
|
||||
String? userName;
|
||||
String? fullName;
|
||||
String? profilePhoto;
|
||||
|
||||
IamPrincipal(
|
||||
{this.id,
|
||||
this.principalTypeXid,
|
||||
this.userName,
|
||||
this.fullName,
|
||||
this.profilePhoto});
|
||||
|
||||
IamPrincipal.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
principalTypeXid = json['principal_type_xid'];
|
||||
userName = json['user_name'];
|
||||
fullName = json['full_name'];
|
||||
profilePhoto = json['profile_photo'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['principal_type_xid'] = principalTypeXid;
|
||||
data['user_name'] = userName;
|
||||
data['full_name'] = fullName;
|
||||
data['profile_photo'] = profilePhoto;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class Community {
|
||||
int? id;
|
||||
String? communityProfilePhoto;
|
||||
String? communityName;
|
||||
|
||||
Community({this.id, this.communityProfilePhoto, this.communityName});
|
||||
|
||||
Community.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
communityProfilePhoto = json['community_profile_photo'];
|
||||
communityName = json['community_name'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['id'] = id;
|
||||
data['community_profile_photo'] = communityProfilePhoto;
|
||||
data['community_name'] = communityName;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
26
lib/Main_Screens/Community/ViewModel/LatestPost.dart
Normal file
26
lib/Main_Screens/Community/ViewModel/LatestPost.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
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/Community/Modal/LatestPost.dart';
|
||||
|
||||
Latestpost? latestpostobj;
|
||||
|
||||
class LatespostApi {
|
||||
LatespostApi();
|
||||
|
||||
Future<ResponseData<dynamic>> getLatestPostApi() async {
|
||||
final response = await NetworkApiServices().getApi(ApiUrls.latestpost);
|
||||
|
||||
if (response.status == ResponseStatus.SUCCESS) {
|
||||
if (response.data["status"] == "success") {
|
||||
latestpostobj = Latestpost.fromJson(response.data);
|
||||
}
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.SUCCESS,
|
||||
data: response.data);
|
||||
} else {
|
||||
return ResponseData<dynamic>(
|
||||
response.data['message'], ResponseStatus.FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
@@ -9,7 +10,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:regroup/Utils/dialogs.dart';
|
||||
import 'package:regroup/Utils/Common/NoInternet.dart';
|
||||
import 'package:regroup/firebase_options.dart';
|
||||
import 'package:regroup/resources/routes/route_name.dart';
|
||||
import 'package:regroup/resources/routes/routes.dart';
|
||||
@@ -123,7 +123,7 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
||||
),
|
||||
debugShowCheckedModeBanner: false,
|
||||
// initialRoute: RouteName.individualactivitystep2,
|
||||
initialRoute: RouteName.individualactivitystep2,
|
||||
initialRoute: RouteName.splashScreen,
|
||||
|
||||
getPages: AppRoutes.appRoutes(),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user