merge-requests/91/head
Aamir Muhammad 3 years ago
parent 0f7afa911a
commit 616e35f2d3

@ -34,13 +34,6 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
final RefreshController _rc = RefreshController(initialRefresh: false); final RefreshController _rc = RefreshController(initialRefresh: false);
void getMoreChat() async {
data.getUserRecentChats();
await Future.delayed(
const Duration(milliseconds: 1000),
);
_rc.loadComplete();
}
@override @override
void initState() { void initState() {
@ -95,135 +88,123 @@ class _ChatHomeScreenState extends State<ChatHomeScreen> {
), ),
).paddingOnly(top: 20, bottom: 14), ).paddingOnly(top: 20, bottom: 14),
if (m.searchedChats != null) if (m.searchedChats != null)
SmartRefresher( ListView.separated(
enablePullDown: true, itemCount: m.searchedChats!.length,
enablePullUp: false, shrinkWrap: true,
onRefresh: (){ physics: const ClampingScrollPhysics(),
getMoreChat(); padding: const EdgeInsets.only(bottom: 80.0),
}, itemBuilder: (BuildContext context, int index) {
header: const MaterialClassicHeader( return SizedBox(
color: MyColors.gradiantEndColor, height: 55,
), child: Row(
controller: _rc, children: [
reverse: false, Stack(
child: ListView.separated( children: <Widget>[
itemCount: m.searchedChats!.length, if (m.searchedChats![index].isImageLoading!)
shrinkWrap: true, const SizedBox(
physics: const ClampingScrollPhysics(), height: 48,
padding: const EdgeInsets.only(bottom: 80.0), width: 48,
itemBuilder: (BuildContext context, int index) { ).toShimmer().circle(30),
return SizedBox( if (m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isNotEmpty)
height: 55, CircularAvatar(
child: Row( radius: 20,
children: [ height: 48,
Stack( width: 48,
children: <Widget>[ url: m.searchedChats![index].image,
if (m.searchedChats![index].isImageLoading!) isImageBase64: true,
const SizedBox( ),
height: 48, if (!m.searchedChats![index].isImageLoading! && m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isEmpty)
width: 48, SvgPicture.asset(
).toShimmer().circle(30), "assets/images/user.svg",
if (m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isNotEmpty) height: 48,
CircularAvatar( width: 48,
radius: 20, ),
height: 48, Positioned(
width: 48, right: 5,
url: m.searchedChats![index].image, bottom: 1,
isImageBase64: true, child: Container(
), width: 10,
if (!m.searchedChats![index].isImageLoading! && m.searchedChats![index].isImageLoaded! && m.searchedChats![index].image.isEmpty) height: 10,
SvgPicture.asset( decoration: BoxDecoration(
"assets/images/user.svg", color: m.searchedChats![index].userStatus == 1 ? MyColors.green2DColor : Colors.red,
height: 48,
width: 48,
), ),
Positioned( ).circle(10),
right: 5, )
bottom: 1, ],
child: Container( ).onPress(() {
width: 10, print(jsonEncode(m.searchedChats![index]));
height: 10, }),
decoration: BoxDecoration( Column(
color: m.searchedChats![index].userStatus == 1 ? MyColors.green2DColor : Colors.red, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(m.searchedChats![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13),
],
).expanded,
SizedBox(
width: 60,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
if (m.searchedChats![index].unreadMessageCount! > 0)
Container(
alignment: Alignment.center,
width: 18,
height: 18,
decoration: const BoxDecoration(
color: MyColors.redColor,
borderRadius: BorderRadius.all(
Radius.circular(20),
),
), ),
).circle(10), child: (m.searchedChats![index].unreadMessageCount!.toString())
) .toText10(
], color: MyColors.white,
).onPress(() { )
print(jsonEncode(m.searchedChats![index])); .center,
}), ).paddingOnly(right: 10).center,
Column( Icon(
mainAxisAlignment: MainAxisAlignment.start, m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == false ? Icons.star_sharp : Icons.star_sharp,
crossAxisAlignment: CrossAxisAlignment.start, color: m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == true ? MyColors.yellowColor : MyColors.grey35Color,
children: [ ).onPress(
(m.searchedChats![index].userName!.replaceFirst(".", " ").capitalizeFirstofEach ?? "").toText14(color: MyColors.darkTextColor).paddingOnly(left: 11, top: 13), () {
if (m.searchedChats![index].isFav == null || m.searchedChats![index].isFav == false) {
m.favoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!,
);
} else if (m.searchedChats![index].isFav == true) {
m.unFavoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!,
);
} else {
m.favoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!,
);
}
},
).center
], ],
).expanded,
SizedBox(
width: 60,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
if (m.searchedChats![index].unreadMessageCount! > 0)
Container(
alignment: Alignment.center,
width: 18,
height: 18,
decoration: const BoxDecoration(
color: MyColors.redColor,
borderRadius: BorderRadius.all(
Radius.circular(20),
),
),
child: (m.searchedChats![index].unreadMessageCount!.toString())
.toText10(
color: MyColors.white,
)
.center,
).paddingOnly(right: 10).center,
Icon(
m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == false ? Icons.star_sharp : Icons.star_sharp,
color: m.searchedChats![index].isFav != null && m.searchedChats![index].isFav == true ? MyColors.yellowColor : MyColors.grey35Color,
).onPress(
() {
if (m.searchedChats![index].isFav == null || m.searchedChats![index].isFav == false) {
m.favoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!,
);
} else if (m.searchedChats![index].isFav == true) {
m.unFavoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!,
);
} else {
m.favoriteUser(
userID: AppState().chatDetails!.response!.id!,
targetUserID: m.searchedChats![index].id!,
);
}
},
).center
],
),
), ),
], ),
), ],
).onPress(() { ),
Navigator.pushNamed( ).onPress(() {
context, Navigator.pushNamed(
AppRoutes.chatDetailed, context,
arguments: {"targetUser": m.searchedChats![index], "isNewChat": false}, AppRoutes.chatDetailed,
).then((Object? value) { arguments: {"targetUser": m.searchedChats![index], "isNewChat": false},
m.clearSelections(); ).then((Object? value) {
m.notifyListeners(); m.clearSelections();
}); m.notifyListeners();
}); });
}, });
separatorBuilder: (BuildContext context, int index) => const Divider(color: MyColors.lightGreyE5Color).paddingOnly(left: 59), },
), separatorBuilder: (BuildContext context, int index) => const Divider(color: MyColors.lightGreyE5Color).paddingOnly(left: 59),
).expanded, ).expanded,
], ],
).paddingOnly(left: 21, right: 21); ).paddingOnly(left: 21, right: 21);

Loading…
Cancel
Save