107 lines
3.1 KiB
Dart
107 lines
3.1 KiB
Dart
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<RootPage> createState() => _RootPageState();
|
|
}
|
|
|
|
class _RootPageState extends State<RootPage> with TickerProviderStateMixin {
|
|
late TabController tabController;
|
|
|
|
late final AnimationController _controllerCouriers = AnimationController(
|
|
duration: const Duration(milliseconds: 400),
|
|
vsync: this,
|
|
);
|
|
late final Animation<double> _animationCouriers = CurvedAnimation(
|
|
parent: _controllerCouriers,
|
|
curve: Curves.fastOutSlowIn,
|
|
);
|
|
|
|
late final AnimationController _controllerItems = AnimationController(
|
|
duration: const Duration(milliseconds: 400),
|
|
vsync: this,
|
|
);
|
|
late final Animation<double> _animationItems = CurvedAnimation(
|
|
parent: _controllerItems,
|
|
curve: Curves.fastOutSlowIn,
|
|
);
|
|
|
|
late final AnimationController _controllerOrders = AnimationController(
|
|
duration: const Duration(milliseconds: 400),
|
|
vsync: this,
|
|
);
|
|
late final Animation<double> _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();
|
|
_controllerItems.forward();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
tabController.dispose();
|
|
_controllerItems.dispose();
|
|
_controllerOrders.dispose();
|
|
_controllerCouriers.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(final BuildContext context) => SafeArea(
|
|
child: Provider<ChangeTab>(
|
|
create: (final _) => ChangeTab(tabController.animateTo),
|
|
child: Scaffold(
|
|
body: TabBarView(
|
|
controller: tabController,
|
|
children: const [
|
|
ItemsPage(),
|
|
CouriersPage(),
|
|
OrdersPage(),
|
|
],
|
|
),
|
|
bottomNavigationBar: BrandTabBar(
|
|
controller: tabController,
|
|
),
|
|
floatingActionButton: tabController.index == 0
|
|
? const AddItemFab()
|
|
: tabController.index == 1
|
|
? const AddCourierFab()
|
|
: const AddOrderFab(),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class ChangeTab {
|
|
ChangeTab(this.onPress);
|
|
final ValueChanged<int> onPress;
|
|
}
|