Houshan-Basa/lib/ui/screens/main/assistant/assistant_screen.dart

146 lines
5.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:hoshan/core/gen/assets.gen.dart';
import 'package:hoshan/core/routes/route_generator.dart';
import 'package:hoshan/ui/screens/main/assistant/bloc/personal_assistants_bloc.dart';
import 'package:hoshan/ui/screens/main/assistant/global_assistants_screen.dart';
import 'package:hoshan/ui/screens/main/assistant/personal_assistants_screen.dart';
import 'package:hoshan/ui/theme/colors.dart';
import 'package:hoshan/ui/widgets/components/button/tab_btn.dart';
class AssistantScreen extends StatefulWidget {
const AssistantScreen({super.key});
@override
State<AssistantScreen> createState() => _AssistantScreenState();
}
class _AssistantScreenState extends State<AssistantScreen>
with AutomaticKeepAliveClientMixin {
@override
bool get wantKeepAlive => true;
int selectedIndex = 0;
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
floatingActionButton: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
if ((selectedIndex == 1 &&
context.watch<PersonalAssistantsBloc>().state
is PersonalAssistantsEmpty))
IgnorePointer(
child: Container(
padding: const EdgeInsets.only(right: 10, bottom: 12),
child:
Assets.icon.gif.flash.image(fit: BoxFit.fill, scale: 1.5),
),
),
FloatingActionButton(
heroTag: 'create-assistants-fb',
onPressed: () {
context.go(Routes.createAssistant);
},
backgroundColor: AppColors.primaryColor.defaultShade,
shape: const CircleBorder(),
child: Assets.icon.bold.createAssistant
.svg(color: Colors.white, width: 20, height: 20),
)
.animate(
autoPlay: true,
onPlay: (controller) => controller.repeat(reverse: true),
)
.scale(
begin: const Offset(1, 1),
end: const Offset(1.2, 1.2),
duration: 600.ms,
curve: Curves.easeInOut,
delay: 1.seconds),
],
),
body: Column(
children: [
tabBars(context),
Expanded(
child: IndexedStack(
index: selectedIndex,
children: const [
GlobalAssistantsScreen(),
PersonalAssistantsScreen()
],
),
)
],
),
);
}
Widget tabBars(BuildContext context) {
return Directionality(
textDirection: TextDirection.rtl,
child: Column(
children: [
// AiBanner(),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
margin: const EdgeInsets.symmetric(vertical: 8),
decoration:
BoxDecoration(color: Theme.of(context).scaffoldBackgroundColor),
child: Column(
children: [
Row(
children: [
Expanded(
child: InkWell(
borderRadius: BorderRadius.circular(10),
onTap: () => setState(() => selectedIndex = 0),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 0.0),
child: TabBtn(
title: 'دستیارهای هوشان',
icon: Assets.icon.bold.globalAssistant,
active: selectedIndex == 0,
click: () => setState(() => selectedIndex = 0),
),
),
),
),
const SizedBox(width: 8),
Expanded(
child: InkWell(
borderRadius: BorderRadius.circular(10),
onTap: () => setState(() => selectedIndex = 1),
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 0.0, horizontal: 0.0),
child: TabBtn(
title: 'دستیارهای من',
icon: Assets.icon.bold.myAssistant,
active: selectedIndex == 1,
click: () => setState(() => selectedIndex = 1),
),
),
),
),
],
),
Container(
height: 2,
width: double.infinity,
color: AppColors.gray.defaultShade,
),
],
),
),
],
),
);
}
}