mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 02:23:46 +02:00
feat: add TimelinePaddingOptions for all the paddings
This commit is contained in:
parent
ab0f96121e
commit
5f6bb26404
10 changed files with 69 additions and 40 deletions
|
@ -11,6 +11,7 @@
|
||||||
- Use the adaptive variants of the material elements in the timeline
|
- Use the adaptive variants of the material elements in the timeline
|
||||||
- Change the default blue color to the primary color of the Theme.of(context) in the timeline
|
- Change the default blue color to the primary color of the Theme.of(context) in the timeline
|
||||||
- Change the TimelineTranslations constructor to require all translations or use the TimelineTranslations.empty constructor if you don't want to specify all translations
|
- Change the TimelineTranslations constructor to require all translations or use the TimelineTranslations.empty constructor if you don't want to specify all translations
|
||||||
|
- Add a TimelinePaddingOptions class to store the padding options for the timeline
|
||||||
|
|
||||||
## 3.0.1
|
## 3.0.1
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@ TimelineUserStoryConfiguration getConfig(TimelineService service) {
|
||||||
|
|
||||||
var options = TimelineOptions(
|
var options = TimelineOptions(
|
||||||
textInputBuilder: null,
|
textInputBuilder: null,
|
||||||
padding: const EdgeInsets.all(20).copyWith(top: 28),
|
paddings: TimelinePaddingOptions(
|
||||||
|
mainPadding: const EdgeInsets.all(20).copyWith(top: 28),
|
||||||
|
),
|
||||||
allowAllDeletion: true,
|
allowAllDeletion: true,
|
||||||
categoriesOptions: CategoriesOptions(
|
categoriesOptions: CategoriesOptions(
|
||||||
categoriesBuilder: (context) => [
|
categoriesBuilder: (context) => [
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
library flutter_timeline_view;
|
library flutter_timeline_view;
|
||||||
|
|
||||||
export 'src/config/timeline_options.dart';
|
export 'src/config/timeline_options.dart';
|
||||||
|
export 'src/config/timeline_paddings.dart';
|
||||||
export 'src/config/timeline_styles.dart';
|
export 'src/config/timeline_styles.dart';
|
||||||
export 'src/config/timeline_theme.dart';
|
export 'src/config/timeline_theme.dart';
|
||||||
export 'src/config/timeline_translations.dart';
|
export 'src/config/timeline_translations.dart';
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_image_picker/flutter_image_picker.dart';
|
import 'package:flutter_image_picker/flutter_image_picker.dart';
|
||||||
import 'package:flutter_timeline_interface/flutter_timeline_interface.dart';
|
import 'package:flutter_timeline_interface/flutter_timeline_interface.dart';
|
||||||
|
import 'package:flutter_timeline_view/src/config/timeline_paddings.dart';
|
||||||
import 'package:flutter_timeline_view/src/config/timeline_theme.dart';
|
import 'package:flutter_timeline_view/src/config/timeline_theme.dart';
|
||||||
import 'package:flutter_timeline_view/src/config/timeline_translations.dart';
|
import 'package:flutter_timeline_view/src/config/timeline_translations.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
@ -13,6 +14,7 @@ class TimelineOptions {
|
||||||
const TimelineOptions({
|
const TimelineOptions({
|
||||||
this.theme = const TimelineTheme(),
|
this.theme = const TimelineTheme(),
|
||||||
this.translations = const TimelineTranslations.empty(),
|
this.translations = const TimelineTranslations.empty(),
|
||||||
|
this.paddings = const TimelinePaddingOptions(),
|
||||||
this.imagePickerConfig = const ImagePickerConfig(),
|
this.imagePickerConfig = const ImagePickerConfig(),
|
||||||
this.imagePickerTheme = const ImagePickerTheme(),
|
this.imagePickerTheme = const ImagePickerTheme(),
|
||||||
this.timelinePostHeight,
|
this.timelinePostHeight,
|
||||||
|
@ -37,12 +39,8 @@ class TimelineOptions {
|
||||||
this.userAvatarBuilder,
|
this.userAvatarBuilder,
|
||||||
this.anonymousAvatarBuilder,
|
this.anonymousAvatarBuilder,
|
||||||
this.nameBuilder,
|
this.nameBuilder,
|
||||||
this.padding =
|
|
||||||
const EdgeInsets.only(left: 12.0, top: 24.0, right: 12.0, bottom: 12.0),
|
|
||||||
this.iconSize = 26,
|
this.iconSize = 26,
|
||||||
this.postWidgetHeight,
|
this.postWidgetHeight,
|
||||||
this.postPadding =
|
|
||||||
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
|
||||||
this.filterOptions = const FilterOptions(),
|
this.filterOptions = const FilterOptions(),
|
||||||
this.categoriesOptions = const CategoriesOptions(),
|
this.categoriesOptions = const CategoriesOptions(),
|
||||||
this.requireImageForPost = false,
|
this.requireImageForPost = false,
|
||||||
|
@ -79,8 +77,12 @@ class TimelineOptions {
|
||||||
/// The height of a post in the timeline
|
/// The height of a post in the timeline
|
||||||
final double? timelinePostHeight;
|
final double? timelinePostHeight;
|
||||||
|
|
||||||
|
/// Class that contains all the translations used in the timeline
|
||||||
final TimelineTranslations translations;
|
final TimelineTranslations translations;
|
||||||
|
|
||||||
|
/// Class that contains all the paddings used in the timeline
|
||||||
|
final TimelinePaddingOptions paddings;
|
||||||
|
|
||||||
final ButtonBuilder? buttonBuilder;
|
final ButtonBuilder? buttonBuilder;
|
||||||
|
|
||||||
final TextInputBuilder? textInputBuilder;
|
final TextInputBuilder? textInputBuilder;
|
||||||
|
@ -116,18 +118,12 @@ class TimelineOptions {
|
||||||
/// The builder for the divider
|
/// The builder for the divider
|
||||||
final Widget Function()? dividerBuilder;
|
final Widget Function()? dividerBuilder;
|
||||||
|
|
||||||
/// The padding between posts in the timeline
|
|
||||||
final EdgeInsets padding;
|
|
||||||
|
|
||||||
/// Size of icons like the comment and like icons. Dafualts to 26
|
/// Size of icons like the comment and like icons. Dafualts to 26
|
||||||
final double iconSize;
|
final double iconSize;
|
||||||
|
|
||||||
/// Sets a predefined height for the postWidget.
|
/// Sets a predefined height for the postWidget.
|
||||||
final double? postWidgetHeight;
|
final double? postWidgetHeight;
|
||||||
|
|
||||||
/// Padding of each post
|
|
||||||
final EdgeInsets postPadding;
|
|
||||||
|
|
||||||
/// Options for filtering
|
/// Options for filtering
|
||||||
final FilterOptions filterOptions;
|
final FilterOptions filterOptions;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
/// This class contains the paddings used in the timeline options
|
||||||
|
class TimelinePaddingOptions {
|
||||||
|
const TimelinePaddingOptions({
|
||||||
|
this.mainPadding =
|
||||||
|
const EdgeInsets.only(left: 12.0, top: 24.0, right: 12.0, bottom: 12.0),
|
||||||
|
this.postPadding =
|
||||||
|
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 12.0),
|
||||||
|
this.postOverviewButtonBottomPadding = 30.0,
|
||||||
|
});
|
||||||
|
|
||||||
|
/// The padding between posts in the timeline
|
||||||
|
final EdgeInsets mainPadding;
|
||||||
|
|
||||||
|
/// The padding of each post
|
||||||
|
final EdgeInsets postPadding;
|
||||||
|
|
||||||
|
/// The bottom padding of the button on the post overview screen
|
||||||
|
final double postOverviewButtonBottomPadding;
|
||||||
|
}
|
|
@ -121,7 +121,7 @@ class _TimelinePostCreationScreenState
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => FocusScope.of(context).unfocus(),
|
onTap: () => FocusScope.of(context).unfocus(),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.options.padding,
|
padding: widget.options.paddings.mainPadding,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
|
|
@ -19,9 +19,11 @@ class TimelinePostOverviewScreen extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var buttonText = '${options.translations.postIn} ${timelinePost.category}';
|
||||||
return Column(
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
children: [
|
children: [
|
||||||
Flexible(
|
Expanded(
|
||||||
child: TimelinePostScreen(
|
child: TimelinePostScreen(
|
||||||
userId: timelinePost.creatorId,
|
userId: timelinePost.creatorId,
|
||||||
options: options,
|
options: options,
|
||||||
|
@ -36,11 +38,17 @@ class TimelinePostOverviewScreen extends StatelessWidget {
|
||||||
() {
|
() {
|
||||||
onPostSubmit(timelinePost);
|
onPostSubmit(timelinePost);
|
||||||
},
|
},
|
||||||
'${options.translations.postIn} ${timelinePost.category}',
|
buttonText,
|
||||||
) ??
|
) ??
|
||||||
Padding(
|
options.buttonBuilder?.call(
|
||||||
padding: const EdgeInsets.only(bottom: 30.0),
|
context,
|
||||||
child: ElevatedButton(
|
() {
|
||||||
|
onPostSubmit(timelinePost);
|
||||||
|
},
|
||||||
|
buttonText,
|
||||||
|
enabled: true,
|
||||||
|
) ??
|
||||||
|
ElevatedButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
MaterialStatePropertyAll(Theme.of(context).primaryColor),
|
MaterialStatePropertyAll(Theme.of(context).primaryColor),
|
||||||
|
@ -51,7 +59,7 @@ class TimelinePostOverviewScreen extends StatelessWidget {
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(12.0),
|
padding: const EdgeInsets.all(12.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
'${options.translations.postIn} ${timelinePost.category}',
|
buttonText,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
|
@ -60,7 +68,7 @@ class TimelinePostOverviewScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
SizedBox(height: options.paddings.postOverviewButtonBottomPadding),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,7 +176,7 @@ class _TimelinePostScreenState extends State<_TimelinePostScreen> {
|
||||||
},
|
},
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: widget.options.padding,
|
padding: widget.options.paddings.mainPadding,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -147,14 +147,14 @@ class _TimelineScreenState extends State<TimelineScreen> {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: widget.options.padding.top,
|
height: widget.options.paddings.mainPadding.top,
|
||||||
),
|
),
|
||||||
if (widget.filterEnabled) ...[
|
if (widget.filterEnabled) ...[
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
// left: widget.options.padding.left,
|
// left: widget.options.padding.left,
|
||||||
// right: widget.options.padding.right,
|
// right: widget.options.padding.right,
|
||||||
horizontal: widget.options.padding.horizontal,
|
horizontal: widget.options.paddings.mainPadding.horizontal,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
@ -240,7 +240,7 @@ class _TimelineScreenState extends State<TimelineScreen> {
|
||||||
const SizedBox.shrink(),
|
const SizedBox.shrink(),
|
||||||
...posts.map(
|
...posts.map(
|
||||||
(post) => Padding(
|
(post) => Padding(
|
||||||
padding: widget.options.postPadding,
|
padding: widget.options.paddings.postPadding,
|
||||||
child: widget.postWidgetBuilder?.call(post) ??
|
child: widget.postWidgetBuilder?.call(post) ??
|
||||||
TimelinePostWidget(
|
TimelinePostWidget(
|
||||||
service: service,
|
service: service,
|
||||||
|
@ -303,7 +303,7 @@ class _TimelineScreenState extends State<TimelineScreen> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: widget.options.padding.bottom,
|
height: widget.options.paddings.mainPadding.bottom,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -37,7 +37,7 @@ class _CategorySelectorState extends State<CategorySelector> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: widget.options.categoriesOptions
|
width: widget.options.categoriesOptions
|
||||||
.categorySelectorHorizontalPadding ??
|
.categorySelectorHorizontalPadding ??
|
||||||
max(widget.options.padding.left - 20, 0),
|
max(widget.options.paddings.mainPadding.left - 20, 0),
|
||||||
),
|
),
|
||||||
for (var category in categories) ...[
|
for (var category in categories) ...[
|
||||||
widget.options.categoriesOptions.categoryButtonBuilder?.call(
|
widget.options.categoriesOptions.categoryButtonBuilder?.call(
|
||||||
|
@ -61,7 +61,7 @@ class _CategorySelectorState extends State<CategorySelector> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: widget.options.categoriesOptions
|
width: widget.options.categoriesOptions
|
||||||
.categorySelectorHorizontalPadding ??
|
.categorySelectorHorizontalPadding ??
|
||||||
max(widget.options.padding.right - 4, 0),
|
max(widget.options.paddings.mainPadding.right - 4, 0),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue