mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-18 18:13:46 +02:00
fix: show category title everywhere and use category key for storing posts
This commit is contained in:
parent
767215a53e
commit
25264ba44b
5 changed files with 43 additions and 34 deletions
|
@ -14,6 +14,7 @@
|
|||
- Add a TimelinePaddingOptions class to store the padding options for the timeline
|
||||
- fix the avatar size to match the new design
|
||||
- Add the iconbutton for image uploading back to the ReactionBottom
|
||||
- Fix category key is correctly used for saving timeline posts and category title is shown everywhere
|
||||
|
||||
## 3.0.1
|
||||
|
||||
|
|
|
@ -94,12 +94,14 @@ List<GoRoute> getTimelineStoryRoutes({
|
|||
var timelineSelectionScreen = TimelineSelectionScreen(
|
||||
options: config.optionsBuilder(context),
|
||||
categories: config
|
||||
.optionsBuilder(context)
|
||||
.categoriesOptions
|
||||
.categoriesBuilder!(context),
|
||||
.optionsBuilder(context)
|
||||
.categoriesOptions
|
||||
.categoriesBuilder
|
||||
?.call(context) ??
|
||||
[],
|
||||
onCategorySelected: (category) async {
|
||||
await context.push(
|
||||
TimelineUserStoryRoutes.timelinepostCreation(category.title),
|
||||
TimelineUserStoryRoutes.timelinepostCreation(category.key ?? ''),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -177,7 +179,7 @@ List<GoRoute> getTimelineStoryRoutes({
|
|||
leading: backButton,
|
||||
backgroundColor: const Color(0xff212121),
|
||||
title: Text(
|
||||
post.category ?? 'Category',
|
||||
category?.title ?? post.category ?? 'Category',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 24,
|
||||
|
|
|
@ -156,7 +156,7 @@ Widget _postDetailScreenRoute({
|
|||
leading: backButton,
|
||||
backgroundColor: const Color(0xff212121),
|
||||
title: Text(
|
||||
post.category ?? 'Category',
|
||||
category?.title ?? post.category ?? 'Category',
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryColor,
|
||||
fontSize: 24,
|
||||
|
@ -193,29 +193,28 @@ Widget _postCreationScreenRoute({
|
|||
service: config.service,
|
||||
onPostCreated: (post) async {
|
||||
var newPost = await config.service.postService.createPost(post);
|
||||
if (context.mounted) {
|
||||
if (config.afterPostCreationGoHome) {
|
||||
await Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => _timelineScreenRoute(
|
||||
configuration: config,
|
||||
context: context,
|
||||
),
|
||||
if (!context.mounted) return;
|
||||
if (config.afterPostCreationGoHome) {
|
||||
await Navigator.pushReplacement(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => _timelineScreenRoute(
|
||||
configuration: config,
|
||||
context: context,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => _postOverviewScreenRoute(
|
||||
configuration: config,
|
||||
context: context,
|
||||
post: newPost,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => _postOverviewScreenRoute(
|
||||
configuration: config,
|
||||
context: context,
|
||||
post: newPost,
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
onPostOverview: (post) async => Navigator.of(context).push(
|
||||
|
@ -228,7 +227,7 @@ Widget _postCreationScreenRoute({
|
|||
),
|
||||
),
|
||||
enablePostOverviewScreen: config.enablePostOverviewScreen,
|
||||
postCategory: category.title,
|
||||
postCategory: category.key,
|
||||
);
|
||||
|
||||
var backButton = IconButton(
|
||||
|
@ -341,9 +340,11 @@ Widget _postCategorySelectionScreen({
|
|||
var timelineSelectionScreen = TimelineSelectionScreen(
|
||||
options: config.optionsBuilder(context),
|
||||
categories: config
|
||||
.optionsBuilder(context)
|
||||
.categoriesOptions
|
||||
.categoriesBuilder!(context),
|
||||
.optionsBuilder(context)
|
||||
.categoriesOptions
|
||||
.categoriesBuilder
|
||||
?.call(context) ??
|
||||
[],
|
||||
onCategorySelected: (category) async {
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
|
|
|
@ -9,10 +9,8 @@ class FirebaseTimelineOptions {
|
|||
const FirebaseTimelineOptions({
|
||||
this.usersCollectionName = 'users',
|
||||
this.timelineCollectionName = 'timeline',
|
||||
this.allTimelineCategories = const [],
|
||||
});
|
||||
|
||||
final String usersCollectionName;
|
||||
final String timelineCollectionName;
|
||||
final List<String> allTimelineCategories;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// ignore_for_file: prefer_expression_function_bodies
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_timeline_interface/flutter_timeline_interface.dart';
|
||||
import 'package:flutter_timeline_view/flutter_timeline_view.dart';
|
||||
|
@ -19,7 +20,13 @@ class TimelinePostOverviewScreen extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var buttonText = '${options.translations.postIn} ${timelinePost.category}';
|
||||
// the timelinePost.category is a key so we need to get the category object
|
||||
var timelineCategoryName = options.categoriesOptions.categoriesBuilder
|
||||
?.call(context)
|
||||
.firstWhereOrNull((element) => element.key == timelinePost.category)
|
||||
?.title ??
|
||||
timelinePost.category;
|
||||
var buttonText = '${options.translations.postIn} $timelineCategoryName';
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
|
|
Loading…
Reference in a new issue