2022-11-09 02:28:48 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-11-17 16:04:14 +00:00
|
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
2022-12-08 18:37:30 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2022-11-09 02:28:48 +00:00
|
|
|
|
2022-11-19 03:49:11 +00:00
|
|
|
import '../controls/app_bottom_nav_bar.dart';
|
2022-12-08 18:37:30 +00:00
|
|
|
import '../controls/padding.dart';
|
2022-11-29 15:33:16 +00:00
|
|
|
import '../controls/timeline/timeline_panel.dart';
|
2022-11-17 16:04:14 +00:00
|
|
|
import '../models/TimelineIdentifiers.dart';
|
2022-12-08 18:37:30 +00:00
|
|
|
import '../models/group_data.dart';
|
|
|
|
import '../services/timeline_manager.dart';
|
2022-11-17 16:04:14 +00:00
|
|
|
|
|
|
|
class HomeScreen extends StatefulWidget {
|
2022-11-19 03:49:11 +00:00
|
|
|
const HomeScreen({super.key});
|
|
|
|
|
2022-11-17 16:04:14 +00:00
|
|
|
@override
|
|
|
|
State<HomeScreen> createState() => _HomeScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
|
|
final _logger = Logger('$HomeScreen');
|
2022-11-09 02:28:48 +00:00
|
|
|
|
|
|
|
final postText = TextEditingController();
|
2022-11-17 16:04:14 +00:00
|
|
|
var currentType = TimelineType.home;
|
2022-12-08 18:37:30 +00:00
|
|
|
GroupData? currentGroup;
|
2022-11-17 16:04:14 +00:00
|
|
|
final types = [
|
2022-12-17 17:17:47 +00:00
|
|
|
TimelineType.self,
|
2022-11-17 16:04:14 +00:00
|
|
|
TimelineType.home,
|
|
|
|
TimelineType.global,
|
|
|
|
TimelineType.local,
|
2022-12-08 18:37:30 +00:00
|
|
|
TimelineType.group,
|
2022-11-17 16:04:14 +00:00
|
|
|
];
|
2022-11-09 02:28:48 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-11-17 16:04:14 +00:00
|
|
|
_logger.finest('Build');
|
2022-12-08 18:37:30 +00:00
|
|
|
final groups = context
|
|
|
|
.watch<TimelineManager>()
|
|
|
|
.getGroups()
|
|
|
|
.getValueOrElse(() => [])
|
|
|
|
.toList();
|
2022-11-09 02:28:48 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
2022-12-08 18:37:30 +00:00
|
|
|
backgroundColor: Theme.of(context).canvasColor,
|
|
|
|
title: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
DropdownButton<TimelineType>(
|
|
|
|
value: currentType,
|
|
|
|
items: types
|
|
|
|
.map((e) => DropdownMenuItem<TimelineType>(
|
|
|
|
value: e,
|
|
|
|
child: Text(e.toLabel()),
|
|
|
|
))
|
|
|
|
.toList(),
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
currentType = value!;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
const HorizontalPadding(),
|
|
|
|
if (currentType == TimelineType.group)
|
|
|
|
DropdownButton<GroupData>(
|
|
|
|
value: currentGroup,
|
|
|
|
items: groups
|
|
|
|
.map((g) => DropdownMenuItem<GroupData>(
|
|
|
|
value: g,
|
|
|
|
child: Text(g.name),
|
|
|
|
))
|
|
|
|
.toList(),
|
|
|
|
onChanged: (value) {
|
|
|
|
setState(() {
|
|
|
|
currentGroup = value;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
),
|
2022-11-10 02:02:26 +00:00
|
|
|
actions: [
|
|
|
|
IconButton(
|
|
|
|
onPressed: () {
|
2022-11-17 16:04:14 +00:00
|
|
|
context.push('/post/new');
|
2022-11-10 02:02:26 +00:00
|
|
|
},
|
2022-12-17 18:33:30 +00:00
|
|
|
icon: Icon(
|
|
|
|
Icons.add,
|
|
|
|
color: Theme.of(context).primaryColor,
|
|
|
|
),
|
2022-11-17 16:04:14 +00:00
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
2022-11-29 15:33:16 +00:00
|
|
|
Expanded(
|
|
|
|
child: TimelinePanel(
|
|
|
|
timeline: TimelineIdentifiers(
|
|
|
|
timeline: currentType,
|
2022-12-08 18:37:30 +00:00
|
|
|
auxData: currentGroup?.id ?? '',
|
2022-11-29 15:33:16 +00:00
|
|
|
),
|
|
|
|
)),
|
2022-11-10 02:02:26 +00:00
|
|
|
],
|
2022-11-09 02:28:48 +00:00
|
|
|
),
|
2022-11-29 15:33:16 +00:00
|
|
|
bottomNavigationBar: const AppBottomNavBar(
|
2022-12-08 19:23:11 +00:00
|
|
|
currentButton: NavBarButtons.timelines,
|
2022-11-19 03:49:11 +00:00
|
|
|
),
|
2022-11-09 02:28:48 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|