68 lines
1.7 KiB
Dart
68 lines
1.7 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/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 _controller = AnimationController(
|
||
|
duration: const Duration(milliseconds: 400),
|
||
|
vsync: this,
|
||
|
);
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
tabController = TabController(length: 3, vsync: this);
|
||
|
tabController.addListener(() {
|
||
|
setState(() {
|
||
|
tabController.index == 2
|
||
|
? _controller.forward()
|
||
|
: _controller.reverse();
|
||
|
});
|
||
|
});
|
||
|
super.initState();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
void dispose() {
|
||
|
tabController.dispose();
|
||
|
_controller.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,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
class ChangeTab {
|
||
|
ChangeTab(this.onPress);
|
||
|
final ValueChanged<int> onPress;
|
||
|
}
|