mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 02:23:46 +02:00
fix: add loading indicator on creating post
This commit is contained in:
parent
6273a9e686
commit
ddb73cf631
4 changed files with 21 additions and 5 deletions
|
@ -134,6 +134,7 @@ Widget _defaultButtonBuilder({
|
|||
required String title,
|
||||
required Function() onPressed,
|
||||
required BuildContext context,
|
||||
required bool loading,
|
||||
}) {
|
||||
var theme = Theme.of(context);
|
||||
return SafeArea(
|
||||
|
@ -145,10 +146,17 @@ Widget _defaultButtonBuilder({
|
|||
minimumSize: const Size(254, 50),
|
||||
),
|
||||
onPressed: onPressed,
|
||||
child: Text(
|
||||
title,
|
||||
style: theme.textTheme.displayLarge,
|
||||
),
|
||||
child: loading
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: CircularProgressIndicator(
|
||||
color: theme.textTheme.displayLarge?.color,
|
||||
),
|
||||
)
|
||||
: Text(
|
||||
title,
|
||||
style: theme.textTheme.displayLarge,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -179,6 +187,7 @@ typedef ButtonBuilder = Widget Function({
|
|||
required String title,
|
||||
required Function() onPressed,
|
||||
required BuildContext context,
|
||||
required bool loading,
|
||||
});
|
||||
|
||||
typedef PostBuilder = Widget Function({
|
||||
|
|
|
@ -195,6 +195,7 @@ class _TimelineAddPostInformationScreenState
|
|||
widget.onTapOverview();
|
||||
},
|
||||
context: context,
|
||||
loading: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -100,6 +100,7 @@ class TimelineChooseCategoryScreen extends StatelessWidget {
|
|||
if (context.mounted)
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
loading: false,
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
|
|
|
@ -19,6 +19,7 @@ class TimelinePostOverview extends StatefulWidget {
|
|||
|
||||
class _TimelinePostOverviewState extends State<TimelinePostOverview> {
|
||||
bool isLoading = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var currentPost = widget.timelineService.getCurrentPost();
|
||||
|
@ -59,12 +60,16 @@ class _TimelinePostOverviewState extends State<TimelinePostOverview> {
|
|||
title: widget.options.translations.postButtonTitle,
|
||||
onPressed: () async {
|
||||
if (isLoading) return;
|
||||
isLoading = true;
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
await widget.timelineService.createPost(currentPost);
|
||||
widget.options.onCreatePost?.call(currentPost);
|
||||
widget.onTapCreatePost(currentPost);
|
||||
},
|
||||
context: context,
|
||||
loading: isLoading,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue