|
|
|
|
@ -11,56 +11,75 @@ import 'package:mohem_flutter_app/widgets/circular_avatar.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
AppBar ChatAppBarWidget(BuildContext context,
|
|
|
|
|
{required String title,
|
|
|
|
|
bool showHomeButton = true,
|
|
|
|
|
String? image,
|
|
|
|
|
ChatUser? chatUser,
|
|
|
|
|
bool showTyping = false,
|
|
|
|
|
List<Widget>? actions,
|
|
|
|
|
void Function()? onHomeTapped,
|
|
|
|
|
void Function()? onBackTapped}) {
|
|
|
|
|
{required String title, bool showHomeButton = true, ChatUser? chatUser, bool showTyping = false, List<Widget>? actions, void Function()? onHomeTapped, void Function()? onBackTapped}) {
|
|
|
|
|
return AppBar(
|
|
|
|
|
leadingWidth: 0,
|
|
|
|
|
title: Row(
|
|
|
|
|
children: [
|
|
|
|
|
GestureDetector(
|
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
|
onTap: Feedback.wrapForTap(() {
|
|
|
|
|
(onBackTapped == null ? Navigator.maybePop(context) : onBackTapped());
|
|
|
|
|
}, context),
|
|
|
|
|
child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor),
|
|
|
|
|
),
|
|
|
|
|
4.width,
|
|
|
|
|
if (image != null)
|
|
|
|
|
CircularAvatar(
|
|
|
|
|
url: image,
|
|
|
|
|
height: 40,
|
|
|
|
|
width: 40,
|
|
|
|
|
isImageBase64: true,
|
|
|
|
|
title: Consumer<ChatProviderModel>(builder: (BuildContext cxt, ChatProviderModel data, Widget? child) {
|
|
|
|
|
return Row(
|
|
|
|
|
children: [
|
|
|
|
|
GestureDetector(
|
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
|
onTap: Feedback.wrapForTap(() {
|
|
|
|
|
(onBackTapped == null ? Navigator.maybePop(context) : onBackTapped());
|
|
|
|
|
}, context),
|
|
|
|
|
child: const Icon(Icons.arrow_back_ios, color: MyColors.darkIconColor),
|
|
|
|
|
),
|
|
|
|
|
if (image != null) 14.width,
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 40,
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
title.toText20(color: MyColors.darkTextColor, isBold: true).expanded,
|
|
|
|
|
if (showTyping)
|
|
|
|
|
Consumer<ChatProviderModel>(
|
|
|
|
|
builder: (BuildContext cxt, ChatProviderModel data, Widget? child) {
|
|
|
|
|
if (chatUser!.isTyping!) {
|
|
|
|
|
return ("Typing ...").toText10(color: MyColors.textMixColor);
|
|
|
|
|
} else {
|
|
|
|
|
return const SizedBox();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
4.width,
|
|
|
|
|
if (chatUser != null)
|
|
|
|
|
Stack(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
if (chatUser.isImageLoading!)
|
|
|
|
|
const SizedBox(
|
|
|
|
|
height: 48,
|
|
|
|
|
width: 48,
|
|
|
|
|
).toShimmer().circle(30),
|
|
|
|
|
if (!chatUser.isImageLoading! && chatUser.userLocalDownlaodedImage == null)
|
|
|
|
|
SvgPicture.asset(
|
|
|
|
|
"assets/images/user.svg",
|
|
|
|
|
height: 48,
|
|
|
|
|
width: 48,
|
|
|
|
|
),
|
|
|
|
|
if (!chatUser.isImageLoading! && chatUser.userLocalDownlaodedImage != null)
|
|
|
|
|
Container(
|
|
|
|
|
width: 48.0,
|
|
|
|
|
height: 48.0,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
image: FileImage(chatUser.userLocalDownlaodedImage!),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Positioned(
|
|
|
|
|
right: 5,
|
|
|
|
|
bottom: 1,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: 10,
|
|
|
|
|
height: 10,
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: chatUser.userStatus == 1 ? MyColors.green2DColor : Colors.red,
|
|
|
|
|
),
|
|
|
|
|
).circle(10),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
if (chatUser != null) 14.width,
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 40,
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
title.toText20(color: MyColors.darkTextColor, isBold: true).expanded,
|
|
|
|
|
if (showTyping)
|
|
|
|
|
if (chatUser!.isTyping!) ("Typing ...").toText10(color: MyColors.textMixColor) else const SizedBox(),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}),
|
|
|
|
|
centerTitle: false,
|
|
|
|
|
elevation: 0,
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
|