2020-11-29 20:07:46 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-05-30 23:06:08 +00:00
|
|
|
import 'package:selfprivacy/logic/cubit/server_installation/server_installation_cubit.dart';
|
2020-11-29 20:07:46 +00:00
|
|
|
import 'package:selfprivacy/ui/components/brand_tab_bar/brand_tab_bar.dart';
|
2020-12-02 09:16:23 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/more/more.dart';
|
2020-12-03 16:52:53 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/providers/providers.dart';
|
2020-12-01 19:08:19 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/services/services.dart';
|
2020-12-03 16:52:53 +00:00
|
|
|
import 'package:selfprivacy/ui/pages/users/users.dart';
|
2020-11-29 20:07:46 +00:00
|
|
|
|
2022-06-05 19:36:32 +00:00
|
|
|
import 'package:selfprivacy/ui/components/pre_styled_buttons/flash_fab.dart';
|
2022-05-16 22:41:00 +00:00
|
|
|
|
2020-11-29 20:07:46 +00:00
|
|
|
class RootPage extends StatefulWidget {
|
2022-10-26 16:26:09 +00:00
|
|
|
const RootPage({super.key});
|
2020-11-29 20:07:46 +00:00
|
|
|
|
|
|
|
@override
|
2022-05-25 12:21:56 +00:00
|
|
|
State<RootPage> createState() => _RootPageState();
|
2020-11-29 20:07:46 +00:00
|
|
|
}
|
|
|
|
|
2022-05-30 13:49:42 +00:00
|
|
|
class _RootPageState extends State<RootPage> with TickerProviderStateMixin {
|
2021-03-18 00:55:38 +00:00
|
|
|
late TabController tabController;
|
2020-11-29 20:07:46 +00:00
|
|
|
|
2022-05-30 13:49:42 +00:00
|
|
|
late final AnimationController _controller = AnimationController(
|
|
|
|
duration: const Duration(milliseconds: 400),
|
|
|
|
vsync: this,
|
|
|
|
);
|
|
|
|
late final Animation<double> _animation = CurvedAnimation(
|
|
|
|
parent: _controller,
|
|
|
|
curve: Curves.fastOutSlowIn,
|
|
|
|
);
|
|
|
|
|
2020-11-29 20:07:46 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
tabController = TabController(length: 4, vsync: this);
|
2022-05-30 13:49:42 +00:00
|
|
|
tabController.addListener(() {
|
|
|
|
setState(() {
|
|
|
|
tabController.index == 2
|
|
|
|
? _controller.forward()
|
|
|
|
: _controller.reverse();
|
|
|
|
});
|
|
|
|
});
|
2020-11-29 20:07:46 +00:00
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
2021-03-18 00:55:38 +00:00
|
|
|
tabController.dispose();
|
2022-05-30 13:49:42 +00:00
|
|
|
_controller.dispose();
|
|
|
|
super.dispose();
|
2020-11-29 20:07:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) {
|
|
|
|
final bool isReady = context.watch<ServerInstallationCubit>().state
|
2022-05-30 23:06:08 +00:00
|
|
|
is ServerInstallationFinished;
|
|
|
|
|
2023-01-31 22:40:42 +00:00
|
|
|
return Provider<ChangeTab>(
|
|
|
|
create: (final _) => ChangeTab(tabController.animateTo),
|
|
|
|
child: Scaffold(
|
|
|
|
body: TabBarView(
|
|
|
|
controller: tabController,
|
|
|
|
children: const [
|
|
|
|
ProvidersPage(),
|
|
|
|
ServicesPage(),
|
|
|
|
UsersPage(),
|
|
|
|
MorePage(),
|
|
|
|
],
|
2020-11-29 20:07:46 +00:00
|
|
|
),
|
2023-01-31 22:40:42 +00:00
|
|
|
bottomNavigationBar: BrandTabBar(
|
|
|
|
controller: tabController,
|
|
|
|
),
|
|
|
|
floatingActionButton: isReady
|
|
|
|
? SizedBox(
|
|
|
|
height: 104 + 16,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
ScaleTransition(
|
|
|
|
scale: _animation,
|
|
|
|
child: const AddUserFab(),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
const BrandFab(),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: null,
|
2020-11-29 20:07:46 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2021-03-18 00:55:38 +00:00
|
|
|
|
|
|
|
class ChangeTab {
|
|
|
|
ChangeTab(this.onPress);
|
2022-06-05 19:36:32 +00:00
|
|
|
final ValueChanged<int> onPress;
|
2021-03-18 00:55:38 +00:00
|
|
|
}
|