|
|
|
@ -1,5 +1,3 @@
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
@ -14,16 +12,89 @@ import 'package:test_sa/helper/utils.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
|
|
import 'package:test_sa/views/pages/user/notifications/notifications_page.dart';
|
|
|
|
import 'package:test_sa/views/pages/user/notifications/notifications_page.dart';
|
|
|
|
import 'package:test_sa/views/pages/user/notifications/unread_chat_list.dart';
|
|
|
|
import 'package:test_sa/views/pages/user/notifications/unread_chat_list.dart';
|
|
|
|
import 'package:test_sa/views/widgets/dialogs/confirm_dialog.dart';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import '../../controllers/providers/api/user_provider.dart';
|
|
|
|
import '../../controllers/providers/api/user_provider.dart';
|
|
|
|
import '../../models/user.dart';
|
|
|
|
import '../../models/user.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class AppBarWidget extends StatelessWidget {
|
|
|
|
class AppBarWidget extends StatefulWidget {
|
|
|
|
final VoidCallback onDrawerPress; // Made nullable
|
|
|
|
final VoidCallback onDrawerPress;
|
|
|
|
|
|
|
|
|
|
|
|
const AppBarWidget({Key? key, required this.onDrawerPress}) : super(key: key);
|
|
|
|
const AppBarWidget({Key? key, required this.onDrawerPress}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
State<AppBarWidget> createState() => _AppBarWidgetState();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _AppBarWidgetState extends State<AppBarWidget> with TickerProviderStateMixin {
|
|
|
|
|
|
|
|
late AnimationController _leftController;
|
|
|
|
|
|
|
|
late AnimationController _rightController;
|
|
|
|
|
|
|
|
late Animation<Offset> _leftSlideAnimation;
|
|
|
|
|
|
|
|
late Animation<double> _leftFadeAnimation;
|
|
|
|
|
|
|
|
late Animation<Offset> _rightSlideAnimation;
|
|
|
|
|
|
|
|
late Animation<double> _rightFadeAnimation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Profile section animation (left to right with fade)
|
|
|
|
|
|
|
|
_leftController = AnimationController(
|
|
|
|
|
|
|
|
duration: const Duration(milliseconds: 600),
|
|
|
|
|
|
|
|
vsync: this,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_leftSlideAnimation = Tween<Offset>(
|
|
|
|
|
|
|
|
begin: const Offset(-0.3, 0.0),
|
|
|
|
|
|
|
|
end: Offset.zero,
|
|
|
|
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
|
|
|
|
parent: _leftController,
|
|
|
|
|
|
|
|
curve: Curves.easeOutCubic,
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_leftFadeAnimation = Tween<double>(
|
|
|
|
|
|
|
|
begin: 0.0,
|
|
|
|
|
|
|
|
end: 1.0,
|
|
|
|
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
|
|
|
|
parent: _leftController,
|
|
|
|
|
|
|
|
curve: Curves.easeIn,
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Action icons animation (right to left with fade)
|
|
|
|
|
|
|
|
_rightController = AnimationController(
|
|
|
|
|
|
|
|
duration: const Duration(milliseconds: 600),
|
|
|
|
|
|
|
|
vsync: this,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_rightSlideAnimation = Tween<Offset>(
|
|
|
|
|
|
|
|
begin: const Offset(0.3, 0.0),
|
|
|
|
|
|
|
|
end: Offset.zero,
|
|
|
|
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
|
|
|
|
parent: _rightController,
|
|
|
|
|
|
|
|
curve: Curves.easeOutCubic,
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_rightFadeAnimation = Tween<double>(
|
|
|
|
|
|
|
|
begin: 0.0,
|
|
|
|
|
|
|
|
end: 1.0,
|
|
|
|
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
|
|
|
|
parent: _rightController,
|
|
|
|
|
|
|
|
curve: Curves.easeIn,
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start animations with slight delay between them
|
|
|
|
|
|
|
|
_leftController.forward();
|
|
|
|
|
|
|
|
Future.delayed(const Duration(milliseconds: 100), () {
|
|
|
|
|
|
|
|
if (mounted) _rightController.forward();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
|
|
_leftController.dispose();
|
|
|
|
|
|
|
|
_rightController.dispose();
|
|
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return AppBar(
|
|
|
|
return AppBar(
|
|
|
|
@ -35,7 +106,12 @@ class AppBarWidget extends StatelessWidget {
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
CircleAvatar(
|
|
|
|
// Profile section with left-to-right fade animation
|
|
|
|
|
|
|
|
SlideTransition(
|
|
|
|
|
|
|
|
position: _leftSlideAnimation,
|
|
|
|
|
|
|
|
child: FadeTransition(
|
|
|
|
|
|
|
|
opacity: _leftFadeAnimation,
|
|
|
|
|
|
|
|
child: CircleAvatar(
|
|
|
|
radius: 24,
|
|
|
|
radius: 24,
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral50 : AppColor.neutral40,
|
|
|
|
backgroundColor: context.isDark ? AppColor.neutral50 : AppColor.neutral40,
|
|
|
|
child: Padding(
|
|
|
|
child: Padding(
|
|
|
|
@ -48,9 +124,15 @@ class AppBarWidget extends StatelessWidget {
|
|
|
|
: const Icon(Icons.person, size: 24, color: Colors.white),
|
|
|
|
: const Icon(Icons.person, size: 24, color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
).onPress(onDrawerPress), // Handle potential null
|
|
|
|
).onPress(widget.onDrawerPress),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
8.width,
|
|
|
|
8.width,
|
|
|
|
Column(
|
|
|
|
SlideTransition(
|
|
|
|
|
|
|
|
position: _leftSlideAnimation,
|
|
|
|
|
|
|
|
child: FadeTransition(
|
|
|
|
|
|
|
|
opacity: _leftFadeAnimation,
|
|
|
|
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
spacing: 4,
|
|
|
|
spacing: 4,
|
|
|
|
children: [
|
|
|
|
children: [
|
|
|
|
@ -64,8 +146,15 @@ class AppBarWidget extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
).expanded,
|
|
|
|
).expanded,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
const Spacer(),
|
|
|
|
const Spacer(),
|
|
|
|
Consumer<SettingProvider>(builder: (context, settingProvider, child) {
|
|
|
|
// Action icons with right-to-left fade animation
|
|
|
|
|
|
|
|
SlideTransition(
|
|
|
|
|
|
|
|
position: _rightSlideAnimation,
|
|
|
|
|
|
|
|
child: FadeTransition(
|
|
|
|
|
|
|
|
opacity: _rightFadeAnimation,
|
|
|
|
|
|
|
|
child: Consumer<SettingProvider>(builder: (context, settingProvider, child) {
|
|
|
|
return MenuAnchor(
|
|
|
|
return MenuAnchor(
|
|
|
|
style: MenuStyle(
|
|
|
|
style: MenuStyle(
|
|
|
|
backgroundColor: WidgetStateProperty.all(AppColor.background(context)),
|
|
|
|
backgroundColor: WidgetStateProperty.all(AppColor.background(context)),
|
|
|
|
@ -229,7 +318,15 @@ class AppBarWidget extends StatelessWidget {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
16.width,
|
|
|
|
16.width,
|
|
|
|
|
|
|
|
SlideTransition(
|
|
|
|
|
|
|
|
position: _rightSlideAnimation,
|
|
|
|
|
|
|
|
child: FadeTransition(
|
|
|
|
|
|
|
|
opacity: _rightFadeAnimation,
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
if (context.settingProvider.isUserFlowMedical) ...[
|
|
|
|
if (context.settingProvider.isUserFlowMedical) ...[
|
|
|
|
("dashboard/chat").toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)).paddingOnly(top: 0, end: 0).onPress(() {
|
|
|
|
("dashboard/chat").toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)).paddingOnly(top: 0, end: 0).onPress(() {
|
|
|
|
Navigator.of(context).push(CupertinoPageRoute(builder: (_) => UnReadChatList()));
|
|
|
|
Navigator.of(context).push(CupertinoPageRoute(builder: (_) => UnReadChatList()));
|
|
|
|
@ -240,6 +337,10 @@ class AppBarWidget extends StatelessWidget {
|
|
|
|
Navigator.of(context).pushNamed(NotificationsPage.id);
|
|
|
|
Navigator.of(context).pushNamed(NotificationsPage.id);
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
).paddingOnly(start: 16, end: 16);
|
|
|
|
).paddingOnly(start: 16, end: 16);
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|