didvan-app/lib/views/widgets/hoshan_app_bar.dart

134 lines
4.5 KiB
Dart

import 'package:didvan/config/theme_data.dart';
import 'package:didvan/constants/app_icons.dart';
import 'package:didvan/constants/assets.dart';
import 'package:didvan/views/ai/history_ai_chat_state.dart';
import 'package:didvan/views/widgets/didvan/icon_button.dart';
import 'package:didvan/views/widgets/hoshan_home_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:provider/provider.dart';
class HoshanAppBar extends StatelessWidget implements PreferredSizeWidget {
final Function()? onBack;
final bool withInfo;
final bool withActions;
const HoshanAppBar(
{Key? key, this.onBack, this.withActions = true, this.withInfo = true})
: super(key: key);
@override
Widget build(BuildContext context) {
return Container(
color: Theme.of(context).colorScheme.surface,
padding: const EdgeInsets.all(16),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
SvgPicture.asset(
Assets.horizontalLogoWithText,
height: 60,
width: 60,
)
// DidvanText(
// 'هوشان',
// fontSize: 14,
// color: Theme.of(context).colorScheme.title,
// fontWeight: FontWeight.bold,
// ),
],
),
Row(
children: [
// if (withInfo)
// DidvanIconButton(
// icon: DidvanIcons.info_circle_light,
// size: 32,
// onPressed: () {
// Navigator.pushNamed(context, Routes.info);
// }),
// if (withActions)
// Stack(
// children: [
// DidvanIconButton(
// icon: DidvanIcons.ai_regular,
// size: 32,
// onPressed: () {
// context.read<BotAssistantsState>().getMyAssissmant();
// Navigator.pushNamed(context, Routes.botAssistants);
// },
// ),
// Icon(
// CupertinoIcons.plus,
// color: Theme.of(context).colorScheme.primary,
// size: 16,
// )
// ],
// ),
GestureDetector(
onTap: () {
print('history bottom tapped');
final historyState = context.read<HistoryAiChatState>();
if (historyState.chats.isEmpty) {
historyState.getChats();
}
showHistoryDrawer(context);
},
child: Container(
padding: const EdgeInsets.all(8),
child: SvgPicture.asset(
'lib/assets/icons/history.svg',
color: Theme.of(context).colorScheme.inputText,
height: 24,
),
),
),
const SizedBox(
width: 5,
),
if (withInfo)
DidvanIconButton(
icon: DidvanIcons.angle_left_light,
color: Theme.of(context).colorScheme.inputText,
size: 32,
onPressed: () => onBack?.call(),
),
],
)
],
));
}
void showHistoryDrawer(BuildContext context) {
showGeneralDialog(
context: context,
barrierDismissible: true,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
barrierColor: Colors.black54,
transitionDuration: const Duration(milliseconds: 300),
pageBuilder: (context, animation, secondaryAnimation) {
return const HistoryDrawerContent();
},
transitionBuilder: (context, animation, secondaryAnimation, child) {
return SlideTransition(
position: Tween<Offset>(
begin: const Offset(-1, 0),
end: Offset.zero,
).animate(CurvedAnimation(
parent: animation,
curve: Curves.easeInOut,
)),
child: child,
);
},
);
}
@override
Size get preferredSize => const Size(double.infinity, 144);
}