2020-08-02 13:34:42 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2020-09-17 00:25:19 +02:00
|
|
|
import 'package:flutter/services.dart';
|
2020-09-16 23:15:42 +02:00
|
|
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
|
|
|
|
2021-09-23 19:25:03 +02:00
|
|
|
import '../util/extensions/brightness.dart';
|
|
|
|
import 'communities_tab.dart';
|
|
|
|
import 'create_post.dart';
|
|
|
|
import 'home_tab.dart';
|
|
|
|
import 'profile_tab.dart';
|
|
|
|
import 'search_tab.dart';
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2021-09-23 19:25:03 +02:00
|
|
|
class HomePage extends HookWidget {
|
|
|
|
const HomePage();
|
2021-01-03 19:43:39 +01:00
|
|
|
|
|
|
|
static const List<Widget> pages = [
|
2020-10-04 21:52:39 +02:00
|
|
|
HomeTab(),
|
2020-09-19 23:56:07 +02:00
|
|
|
CommunitiesTab(),
|
2021-01-08 17:39:03 +01:00
|
|
|
SearchTab(),
|
2020-09-19 23:56:07 +02:00
|
|
|
UserProfileTab(),
|
|
|
|
];
|
|
|
|
|
2020-08-02 13:34:42 +02:00
|
|
|
@override
|
2020-09-17 00:25:19 +02:00
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final theme = Theme.of(context);
|
2020-09-19 23:56:07 +02:00
|
|
|
final currentTab = useState(0);
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-09-17 00:25:19 +02:00
|
|
|
useEffect(() {
|
2020-09-17 00:29:35 +02:00
|
|
|
Future.microtask(
|
|
|
|
() => SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
|
|
|
systemNavigationBarColor: theme.scaffoldBackgroundColor,
|
2021-02-09 21:36:21 +01:00
|
|
|
systemNavigationBarIconBrightness: theme.brightness.reverse,
|
2020-09-17 00:29:35 +02:00
|
|
|
)),
|
|
|
|
);
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-09-17 00:25:19 +02:00
|
|
|
return null;
|
|
|
|
}, [theme.scaffoldBackgroundColor]);
|
2020-08-02 13:34:42 +02:00
|
|
|
|
2020-09-19 23:56:07 +02:00
|
|
|
var tabCounter = 0;
|
|
|
|
|
|
|
|
tabButton(IconData icon) {
|
|
|
|
final tabNum = tabCounter++;
|
|
|
|
|
|
|
|
return IconButton(
|
|
|
|
icon: Icon(icon),
|
2021-09-12 22:37:07 +02:00
|
|
|
color: tabNum == currentTab.value ? theme.colorScheme.secondary : null,
|
2020-09-19 23:56:07 +02:00
|
|
|
onPressed: () => currentTab.value = tabNum,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Scaffold(
|
2020-09-20 23:27:04 +02:00
|
|
|
extendBody: true,
|
2021-04-06 15:39:19 +02:00
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: IndexedStack(
|
|
|
|
index: currentTab.value,
|
|
|
|
children: pages,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(height: kMinInteractiveDimension / 2),
|
|
|
|
],
|
2020-09-19 23:56:07 +02:00
|
|
|
),
|
2021-01-03 19:43:39 +01:00
|
|
|
floatingActionButton: const CreatePostFab(),
|
2020-09-19 23:56:07 +02:00
|
|
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
|
|
|
bottomNavigationBar: BottomAppBar(
|
2021-01-03 19:43:39 +01:00
|
|
|
shape: const CircularNotchedRectangle(),
|
2020-09-21 20:23:18 +02:00
|
|
|
notchMargin: 7,
|
2021-01-03 18:03:59 +01:00
|
|
|
child: SizedBox(
|
2020-09-19 23:56:07 +02:00
|
|
|
height: 60,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
children: [
|
|
|
|
tabButton(Icons.home),
|
|
|
|
tabButton(Icons.list),
|
2021-01-03 19:43:39 +01:00
|
|
|
const SizedBox.shrink(),
|
|
|
|
const SizedBox.shrink(),
|
2020-09-19 23:56:07 +02:00
|
|
|
tabButton(Icons.search),
|
|
|
|
tabButton(Icons.person),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2020-09-17 00:25:19 +02:00
|
|
|
}
|
2020-08-02 13:34:42 +02:00
|
|
|
}
|