mirror of
https://github.com/Iconica-Development/flutter_timeline.git
synced 2025-05-19 10:33:44 +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 String title,
|
||||||
required Function() onPressed,
|
required Function() onPressed,
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
|
required bool loading,
|
||||||
}) {
|
}) {
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
|
@ -145,7 +146,14 @@ Widget _defaultButtonBuilder({
|
||||||
minimumSize: const Size(254, 50),
|
minimumSize: const Size(254, 50),
|
||||||
),
|
),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: Text(
|
child: loading
|
||||||
|
? Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: theme.textTheme.displayLarge?.color,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: Text(
|
||||||
title,
|
title,
|
||||||
style: theme.textTheme.displayLarge,
|
style: theme.textTheme.displayLarge,
|
||||||
),
|
),
|
||||||
|
@ -179,6 +187,7 @@ typedef ButtonBuilder = Widget Function({
|
||||||
required String title,
|
required String title,
|
||||||
required Function() onPressed,
|
required Function() onPressed,
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
|
required bool loading,
|
||||||
});
|
});
|
||||||
|
|
||||||
typedef PostBuilder = Widget Function({
|
typedef PostBuilder = Widget Function({
|
||||||
|
|
|
@ -195,6 +195,7 @@ class _TimelineAddPostInformationScreenState
|
||||||
widget.onTapOverview();
|
widget.onTapOverview();
|
||||||
},
|
},
|
||||||
context: context,
|
context: context,
|
||||||
|
loading: false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -100,6 +100,7 @@ class TimelineChooseCategoryScreen extends StatelessWidget {
|
||||||
if (context.mounted)
|
if (context.mounted)
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
|
loading: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
|
|
|
@ -19,6 +19,7 @@ class TimelinePostOverview extends StatefulWidget {
|
||||||
|
|
||||||
class _TimelinePostOverviewState extends State<TimelinePostOverview> {
|
class _TimelinePostOverviewState extends State<TimelinePostOverview> {
|
||||||
bool isLoading = false;
|
bool isLoading = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var currentPost = widget.timelineService.getCurrentPost();
|
var currentPost = widget.timelineService.getCurrentPost();
|
||||||
|
@ -59,12 +60,16 @@ class _TimelinePostOverviewState extends State<TimelinePostOverview> {
|
||||||
title: widget.options.translations.postButtonTitle,
|
title: widget.options.translations.postButtonTitle,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (isLoading) return;
|
if (isLoading) return;
|
||||||
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
});
|
||||||
|
|
||||||
await widget.timelineService.createPost(currentPost);
|
await widget.timelineService.createPost(currentPost);
|
||||||
widget.options.onCreatePost?.call(currentPost);
|
widget.options.onCreatePost?.call(currentPost);
|
||||||
widget.onTapCreatePost(currentPost);
|
widget.onTapCreatePost(currentPost);
|
||||||
},
|
},
|
||||||
context: context,
|
context: context,
|
||||||
|
loading: isLoading,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue