mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 02:23: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
|
- Add a TimelinePaddingOptions class to store the padding options for the timeline
|
||||||
- fix the avatar size to match the new design
|
- fix the avatar size to match the new design
|
||||||
- Add the iconbutton for image uploading back to the ReactionBottom
|
- 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
|
## 3.0.1
|
||||||
|
|
||||||
|
|
|
@ -94,12 +94,14 @@ List<GoRoute> getTimelineStoryRoutes({
|
||||||
var timelineSelectionScreen = TimelineSelectionScreen(
|
var timelineSelectionScreen = TimelineSelectionScreen(
|
||||||
options: config.optionsBuilder(context),
|
options: config.optionsBuilder(context),
|
||||||
categories: config
|
categories: config
|
||||||
.optionsBuilder(context)
|
.optionsBuilder(context)
|
||||||
.categoriesOptions
|
.categoriesOptions
|
||||||
.categoriesBuilder!(context),
|
.categoriesBuilder
|
||||||
|
?.call(context) ??
|
||||||
|
[],
|
||||||
onCategorySelected: (category) async {
|
onCategorySelected: (category) async {
|
||||||
await context.push(
|
await context.push(
|
||||||
TimelineUserStoryRoutes.timelinepostCreation(category.title),
|
TimelineUserStoryRoutes.timelinepostCreation(category.key ?? ''),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -177,7 +179,7 @@ List<GoRoute> getTimelineStoryRoutes({
|
||||||
leading: backButton,
|
leading: backButton,
|
||||||
backgroundColor: const Color(0xff212121),
|
backgroundColor: const Color(0xff212121),
|
||||||
title: Text(
|
title: Text(
|
||||||
post.category ?? 'Category',
|
category?.title ?? post.category ?? 'Category',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
|
|
|
@ -156,7 +156,7 @@ Widget _postDetailScreenRoute({
|
||||||
leading: backButton,
|
leading: backButton,
|
||||||
backgroundColor: const Color(0xff212121),
|
backgroundColor: const Color(0xff212121),
|
||||||
title: Text(
|
title: Text(
|
||||||
post.category ?? 'Category',
|
category?.title ?? post.category ?? 'Category',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).primaryColor,
|
color: Theme.of(context).primaryColor,
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
|
@ -193,29 +193,28 @@ Widget _postCreationScreenRoute({
|
||||||
service: config.service,
|
service: config.service,
|
||||||
onPostCreated: (post) async {
|
onPostCreated: (post) async {
|
||||||
var newPost = await config.service.postService.createPost(post);
|
var newPost = await config.service.postService.createPost(post);
|
||||||
if (context.mounted) {
|
if (!context.mounted) return;
|
||||||
if (config.afterPostCreationGoHome) {
|
if (config.afterPostCreationGoHome) {
|
||||||
await Navigator.pushReplacement(
|
await Navigator.pushReplacement(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => _timelineScreenRoute(
|
builder: (context) => _timelineScreenRoute(
|
||||||
configuration: config,
|
configuration: config,
|
||||||
context: context,
|
context: context,
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
} else {
|
);
|
||||||
await Navigator.push(
|
} else {
|
||||||
context,
|
await Navigator.push(
|
||||||
MaterialPageRoute(
|
context,
|
||||||
builder: (context) => _postOverviewScreenRoute(
|
MaterialPageRoute(
|
||||||
configuration: config,
|
builder: (context) => _postOverviewScreenRoute(
|
||||||
context: context,
|
configuration: config,
|
||||||
post: newPost,
|
context: context,
|
||||||
),
|
post: newPost,
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPostOverview: (post) async => Navigator.of(context).push(
|
onPostOverview: (post) async => Navigator.of(context).push(
|
||||||
|
@ -228,7 +227,7 @@ Widget _postCreationScreenRoute({
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
enablePostOverviewScreen: config.enablePostOverviewScreen,
|
enablePostOverviewScreen: config.enablePostOverviewScreen,
|
||||||
postCategory: category.title,
|
postCategory: category.key,
|
||||||
);
|
);
|
||||||
|
|
||||||
var backButton = IconButton(
|
var backButton = IconButton(
|
||||||
|
@ -341,9 +340,11 @@ Widget _postCategorySelectionScreen({
|
||||||
var timelineSelectionScreen = TimelineSelectionScreen(
|
var timelineSelectionScreen = TimelineSelectionScreen(
|
||||||
options: config.optionsBuilder(context),
|
options: config.optionsBuilder(context),
|
||||||
categories: config
|
categories: config
|
||||||
.optionsBuilder(context)
|
.optionsBuilder(context)
|
||||||
.categoriesOptions
|
.categoriesOptions
|
||||||
.categoriesBuilder!(context),
|
.categoriesBuilder
|
||||||
|
?.call(context) ??
|
||||||
|
[],
|
||||||
onCategorySelected: (category) async {
|
onCategorySelected: (category) async {
|
||||||
await Navigator.of(context).push(
|
await Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
|
|
|
@ -9,10 +9,8 @@ class FirebaseTimelineOptions {
|
||||||
const FirebaseTimelineOptions({
|
const FirebaseTimelineOptions({
|
||||||
this.usersCollectionName = 'users',
|
this.usersCollectionName = 'users',
|
||||||
this.timelineCollectionName = 'timeline',
|
this.timelineCollectionName = 'timeline',
|
||||||
this.allTimelineCategories = const [],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final String usersCollectionName;
|
final String usersCollectionName;
|
||||||
final String timelineCollectionName;
|
final String timelineCollectionName;
|
||||||
final List<String> allTimelineCategories;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// ignore_for_file: prefer_expression_function_bodies
|
// ignore_for_file: prefer_expression_function_bodies
|
||||||
|
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_timeline_interface/flutter_timeline_interface.dart';
|
import 'package:flutter_timeline_interface/flutter_timeline_interface.dart';
|
||||||
import 'package:flutter_timeline_view/flutter_timeline_view.dart';
|
import 'package:flutter_timeline_view/flutter_timeline_view.dart';
|
||||||
|
@ -19,7 +20,13 @@ class TimelinePostOverviewScreen extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
|
|
Loading…
Reference in a new issue