import 'package:flutter/material.dart'; import 'package:selfprivacy/logic/appsettingscubit.dart'; import 'package:selfprivacy/ui/brandtabbar.dart'; import 'package:selfprivacy/ui/courierspage.dart'; import 'package:selfprivacy/ui/fabs/addcourierfab.dart'; import 'package:selfprivacy/ui/fabs/additemfab.dart'; import 'package:selfprivacy/ui/fabs/addorderfab.dart'; import 'package:selfprivacy/ui/itemspage.dart'; import 'package:selfprivacy/ui/orderspage.dart'; class RootPage extends StatefulWidget { const RootPage({super.key}); @override State createState() => _RootPageState(); } class _RootPageState extends State with TickerProviderStateMixin { late TabController tabController; late final AnimationController _controllerCouriers = AnimationController( duration: const Duration(milliseconds: 400), vsync: this, ); late final Animation _animationCouriers = CurvedAnimation( parent: _controllerCouriers, curve: Curves.fastOutSlowIn, ); late final AnimationController _controllerItems = AnimationController( duration: const Duration(milliseconds: 400), vsync: this, ); late final Animation _animationItems = CurvedAnimation( parent: _controllerItems, curve: Curves.fastOutSlowIn, ); late final AnimationController _controllerOrders = AnimationController( duration: const Duration(milliseconds: 400), vsync: this, ); late final Animation _animationOrders = CurvedAnimation( parent: _controllerOrders, curve: Curves.fastOutSlowIn, ); @override void initState() { tabController = TabController(length: 3, vsync: this); tabController.addListener(() { setState(() { tabController.index == 0 ? _controllerItems.forward() : _controllerItems.reverse(); tabController.index == 1 ? _controllerCouriers.forward() : _controllerCouriers.reverse(); tabController.index == 2 ? _controllerOrders.forward() : _controllerOrders.reverse(); }); }); super.initState(); } @override void dispose() { tabController.dispose(); _controllerItems.dispose(); _controllerOrders.dispose(); _controllerCouriers.dispose(); super.dispose(); } @override Widget build(final BuildContext context) => SafeArea( child: Provider( create: (final _) => ChangeTab(tabController.animateTo), child: Scaffold( body: TabBarView( controller: tabController, children: const [ ItemsPage(), CouriersPage(), OrdersPage(), ], ), bottomNavigationBar: BrandTabBar( controller: tabController, ), floatingActionButton: SizedBox( height: 104 + 16, child: Column( crossAxisAlignment: CrossAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end, children: [ ScaleTransition( scale: _animationItems, child: const AddItemFab(), ), ScaleTransition( scale: _animationCouriers, child: const AddCourierFab(), ), ScaleTransition( scale: _animationOrders, child: const AddOrderFab(), ), ], ), ), ), ), ); } class ChangeTab { ChangeTab(this.onPress); final ValueChanged onPress; }