You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.7 KiB
Dart
79 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:mohem_flutter_app/classes/colors.dart';
|
|
import 'package:mohem_flutter_app/config/routes.dart';
|
|
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
|
|
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
|
|
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';
|
|
import 'package:mohem_flutter_app/models/chat/get_search_user_chat_model.dart';
|
|
import 'package:mohem_flutter_app/provider/chat_provider_model.dart';
|
|
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}) {
|
|
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,
|
|
),
|
|
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.darkTextColor);
|
|
} else {
|
|
return const SizedBox();
|
|
}
|
|
},
|
|
),
|
|
],
|
|
).expanded,
|
|
)
|
|
],
|
|
),
|
|
centerTitle: false,
|
|
elevation: 0,
|
|
backgroundColor: Colors.white,
|
|
actions: [
|
|
if (showHomeButton)
|
|
IconButton(
|
|
onPressed: () {
|
|
onHomeTapped == null ? Navigator.popUntil(context, ModalRoute.withName(AppRoutes.dashboard)) : onHomeTapped();
|
|
},
|
|
icon: const Icon(Icons.home, color: MyColors.darkIconColor),
|
|
),
|
|
...actions ?? []
|
|
],
|
|
);
|
|
}
|