mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 10:33:44 +02:00
merge
This commit is contained in:
parent
e61da6873d
commit
06ea5f0281
3 changed files with 50 additions and 40 deletions
|
@ -39,6 +39,8 @@ class TimelineOptions {
|
|||
this.nameBuilder,
|
||||
this.padding = const EdgeInsets.symmetric(vertical: 12.0),
|
||||
this.iconSize = 26,
|
||||
this.postWidgetheight,
|
||||
this.postPadding = const EdgeInsets.all(12.0),
|
||||
});
|
||||
|
||||
/// Theming options for the timeline
|
||||
|
@ -105,6 +107,12 @@ class TimelineOptions {
|
|||
|
||||
/// Size of icons like the comment and like icons. Dafualts to 26
|
||||
final double iconSize;
|
||||
|
||||
/// Sets a predefined height for the postWidget.
|
||||
final double? postWidgetheight;
|
||||
|
||||
/// Padding of each post
|
||||
final EdgeInsets postPadding;
|
||||
}
|
||||
|
||||
typedef ButtonBuilder = Widget Function(
|
||||
|
|
|
@ -18,6 +18,7 @@ class TimelineScreen extends StatefulWidget {
|
|||
this.onUserTap,
|
||||
this.posts,
|
||||
this.timelineCategoryFilter,
|
||||
this.postWidget,
|
||||
super.key,
|
||||
});
|
||||
|
||||
|
@ -30,7 +31,7 @@ class TimelineScreen extends StatefulWidget {
|
|||
/// All the configuration options for the timelinescreens and widgets
|
||||
final TimelineOptions options;
|
||||
|
||||
/// The controller for the scroll view
|
||||
/// The controller for the scroll view
|
||||
final ScrollController? scrollController;
|
||||
|
||||
/// The string to filter the timeline by category
|
||||
|
@ -46,6 +47,9 @@ class TimelineScreen extends StatefulWidget {
|
|||
/// If this is not null, the user can tap on the user avatar or name
|
||||
final Function(String userId)? onUserTap;
|
||||
|
||||
/// Override the standard postwidget
|
||||
final Widget Function(TimelinePost post)? postWidget;
|
||||
|
||||
@override
|
||||
State<TimelineScreen> createState() => _TimelineScreenState();
|
||||
}
|
||||
|
@ -95,43 +99,43 @@ class _TimelineScreenState extends State<TimelineScreen> {
|
|||
children: [
|
||||
...posts.map(
|
||||
(post) => Padding(
|
||||
padding: widget.options.padding,
|
||||
child: TimelinePostWidget(
|
||||
service: widget.service,
|
||||
userId: widget.userId,
|
||||
options: widget.options,
|
||||
post: post,
|
||||
height: widget.options.timelinePostHeight,
|
||||
onTap: () async {
|
||||
if (widget.onPostTap != null) {
|
||||
widget.onPostTap!.call(post);
|
||||
return;
|
||||
}
|
||||
padding: widget.options.postPadding,
|
||||
child: widget.postWidget?.call(post) ??
|
||||
TimelinePostWidget(
|
||||
service: widget.service,
|
||||
userId: widget.userId,
|
||||
options: widget.options,
|
||||
post: post,
|
||||
onTap: () async {
|
||||
if (widget.onPostTap != null) {
|
||||
widget.onPostTap!.call(post);
|
||||
return;
|
||||
}
|
||||
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Scaffold(
|
||||
body: TimelinePostScreen(
|
||||
userId: widget.userId,
|
||||
service: widget.service,
|
||||
options: widget.options,
|
||||
post: post,
|
||||
onPostDelete: () {
|
||||
widget.service.deletePost(post);
|
||||
},
|
||||
await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Scaffold(
|
||||
body: TimelinePostScreen(
|
||||
userId: widget.userId,
|
||||
service: widget.service,
|
||||
options: widget.options,
|
||||
post: post,
|
||||
onPostDelete: () {
|
||||
widget.service.deletePost(post);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
onTapLike: () async =>
|
||||
service.likePost(widget.userId, post),
|
||||
onTapUnlike: () async =>
|
||||
service.unlikePost(widget.userId, post),
|
||||
onPostDelete: () async => service.deletePost(post),
|
||||
onUserTap: widget.onUserTap,
|
||||
),
|
||||
);
|
||||
},
|
||||
onTapLike: () async =>
|
||||
service.likePost(widget.userId, post),
|
||||
onTapUnlike: () async =>
|
||||
service.unlikePost(widget.userId, post),
|
||||
onPostDelete: () async => service.deletePost(post),
|
||||
onUserTap: widget.onUserTap,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (posts.isEmpty)
|
||||
|
|
|
@ -13,7 +13,6 @@ class TimelinePostWidget extends StatefulWidget {
|
|||
required this.userId,
|
||||
required this.options,
|
||||
required this.post,
|
||||
required this.height,
|
||||
required this.onTap,
|
||||
required this.onTapLike,
|
||||
required this.onTapUnlike,
|
||||
|
@ -30,7 +29,6 @@ class TimelinePostWidget extends StatefulWidget {
|
|||
final TimelinePost post;
|
||||
|
||||
/// Optional max height of the post
|
||||
final double? height;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback onTapLike;
|
||||
final VoidCallback onTapUnlike;
|
||||
|
@ -51,7 +49,7 @@ class _TimelinePostWidgetState extends State<TimelinePostWidget> {
|
|||
return InkWell(
|
||||
onTap: widget.onTap,
|
||||
child: SizedBox(
|
||||
height: widget.post.imageUrl != null ? widget.height : null,
|
||||
height: widget.post.imageUrl != null ? widget.options.postWidgetheight : null,
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -145,7 +143,7 @@ class _TimelinePostWidgetState extends State<TimelinePostWidget> {
|
|||
if (widget.post.imageUrl != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Flexible(
|
||||
flex: widget.height != null ? 1 : 0,
|
||||
flex: widget.options.postWidgetheight != null ? 1 : 0,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
child: widget.options.doubleTapTolike
|
||||
|
|
Loading…
Reference in a new issue