mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 02:23:46 +02:00
feat: add getter for the userId in the timeline userstory configuration
This commit is contained in:
parent
933386623a
commit
deaca5b126
4 changed files with 11 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
- Add a serviceBuilder to the userstory configuration
|
||||
- Add a listHeaderBuilder for showing a header at the top of the list of posts in the timeline
|
||||
- Add a getUserId function to retrieve the userId when needed in the userstory configuration
|
||||
|
||||
## 3.0.1
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ List<GoRoute> getTimelineStoryRoutes({
|
|||
pageBuilder: (context, state) {
|
||||
var service = config.serviceBuilder?.call(context) ?? config.service;
|
||||
var timelineScreen = TimelineScreen(
|
||||
userId: config.userId,
|
||||
userId: config.getUserId?.call(context) ?? config.userId,
|
||||
onUserTap: (user) => config.onUserTap?.call(context, user),
|
||||
service: service,
|
||||
options: config.optionsBuilder(context),
|
||||
|
@ -134,7 +134,7 @@ List<GoRoute> getTimelineStoryRoutes({
|
|||
var post = service.postService.getPost(state.pathParameters['post']!);
|
||||
|
||||
var timelinePostWidget = TimelinePostScreen(
|
||||
userId: config.userId,
|
||||
userId: config.getUserId?.call(context) ?? config.userId,
|
||||
options: config.optionsBuilder(context),
|
||||
service: service,
|
||||
post: post!,
|
||||
|
@ -177,7 +177,7 @@ List<GoRoute> getTimelineStoryRoutes({
|
|||
var category = state.pathParameters['category'];
|
||||
var service = config.serviceBuilder?.call(context) ?? config.service;
|
||||
var timelinePostCreationWidget = TimelinePostCreationScreen(
|
||||
userId: config.userId,
|
||||
userId: config.getUserId?.call(context) ?? config.userId,
|
||||
options: config.optionsBuilder(context),
|
||||
service: service,
|
||||
onPostCreated: (post) async {
|
||||
|
|
|
@ -45,7 +45,7 @@ Widget _timelineScreenRoute({
|
|||
);
|
||||
|
||||
var timelineScreen = TimelineScreen(
|
||||
userId: config.userId,
|
||||
userId: config.getUserId?.call(context) ?? config.userId,
|
||||
onUserTap: (user) => config.onUserTap?.call(context, user),
|
||||
service: config.service,
|
||||
options: config.optionsBuilder(context),
|
||||
|
@ -121,7 +121,7 @@ Widget _postDetailScreenRoute({
|
|||
);
|
||||
|
||||
var timelinePostScreen = TimelinePostScreen(
|
||||
userId: config.userId,
|
||||
userId: config.getUserId?.call(context) ?? config.userId,
|
||||
options: config.optionsBuilder(context),
|
||||
service: config.service,
|
||||
post: post,
|
||||
|
@ -176,7 +176,7 @@ Widget _postCreationScreenRoute({
|
|||
);
|
||||
|
||||
var timelinePostCreationScreen = TimelinePostCreationScreen(
|
||||
userId: config.userId,
|
||||
userId: config.getUserId?.call(context) ?? config.userId,
|
||||
options: config.optionsBuilder(context),
|
||||
service: config.service,
|
||||
onPostCreated: (post) async {
|
||||
|
|
|
@ -48,6 +48,7 @@ class TimelineUserStoryConfiguration {
|
|||
const TimelineUserStoryConfiguration({
|
||||
required this.service,
|
||||
required this.optionsBuilder,
|
||||
this.getUserId,
|
||||
this.serviceBuilder,
|
||||
this.userId = 'test_user',
|
||||
this.homeOpenPageBuilder,
|
||||
|
@ -67,6 +68,9 @@ class TimelineUserStoryConfiguration {
|
|||
/// The ID of the user associated with this user story configuration.
|
||||
final String userId;
|
||||
|
||||
/// A function to get the userId only when needed and with a context
|
||||
final String Function(BuildContext context)? getUserId;
|
||||
|
||||
/// The TimelineService responsible for fetching user story data.
|
||||
final TimelineService service;
|
||||
|
||||
|
|
Loading…
Reference in a new issue