selfprivacy.org.app/lib/ui/pages/rootRoute.dart

75 lines
2 KiB
Dart
Raw Normal View History

2020-11-29 20:07:46 +00:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
2020-12-30 14:13:25 +00:00
import 'package:selfprivacy/logic/cubit/initializing/initializing_cubit.dart';
2020-12-10 20:33:19 +00:00
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
2020-11-29 20:07:46 +00:00
import 'package:selfprivacy/ui/components/brand_tab_bar/brand_tab_bar.dart';
2020-12-10 20:33:19 +00:00
import 'package:selfprivacy/ui/components/brand_text/brand_text.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
class RootPage extends StatefulWidget {
const RootPage({Key key}) : super(key: key);
@override
_RootPageState createState() => _RootPageState();
}
class _RootPageState extends State<RootPage>
with SingleTickerProviderStateMixin {
TabController tabController;
@override
void initState() {
tabController = TabController(length: 4, vsync: this);
super.initState();
}
@override
void dispose() {
super.dispose();
2020-12-10 20:33:19 +00:00
tabController.dispose();
2020-11-29 20:07:46 +00:00
}
@override
Widget build(BuildContext context) {
2020-12-30 14:13:25 +00:00
var isUserFilled =
context.watch<InitializingCubit>().state.isFullyInitilized;
2020-12-10 20:33:19 +00:00
2020-11-29 20:07:46 +00:00
return SafeArea(
child: Scaffold(
body: TabBarView(
controller: tabController,
children: [
2020-12-30 14:13:25 +00:00
ProvidersPage(),
ServicesPage(),
isUserFilled ? UsersPage() : _NotReady(),
2020-12-02 09:16:23 +00:00
MorePage(),
2020-11-29 20:07:46 +00:00
],
),
2020-12-08 19:26:51 +00:00
bottomNavigationBar: BrandTabBar(
2020-11-29 20:07:46 +00:00
controller: tabController,
),
),
);
}
}
2020-12-10 20:33:19 +00:00
class _NotReady extends StatelessWidget {
const _NotReady({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
BrandText.h3('Not ready'),
BrandText.body2('Finish providers initialization first'),
],
),
);
}
}