mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 05:03:44 +02:00
feat: add loadingIndicatorBuilder to override CircularProgressIndicator.adaptive()
This commit is contained in:
parent
172b3ff6a8
commit
095eff2c21
3 changed files with 16 additions and 2 deletions
|
@ -19,6 +19,7 @@ class AvailabilityOptions {
|
|||
this.textStyles = const AvailabilityTextStyles(),
|
||||
this.colors = const AvailabilityColors(),
|
||||
this.timePickerBuilder,
|
||||
this.loadingIndicatorBuilder = defaultLoader,
|
||||
AvailabilityDataInterface? dataInterface,
|
||||
}) : dataInterface = dataInterface ?? LocalAvailabilityDataInterface();
|
||||
|
||||
|
@ -53,6 +54,11 @@ class AvailabilityOptions {
|
|||
/// A way to provide your own time picker implementation or customize
|
||||
/// the default time picker
|
||||
final TimePickerBuilder? timePickerBuilder;
|
||||
|
||||
/// A builder to override the loading indicator
|
||||
/// If not provided the [CircularProgressIndicator.adaptive()] will be used
|
||||
/// which shows a platform adaptive loading indicator
|
||||
final WidgetBuilder loadingIndicatorBuilder;
|
||||
}
|
||||
|
||||
/// All configurable paddings and whitespaces withing the userstory
|
||||
|
@ -154,3 +160,9 @@ typedef TimePickerBuilder = Future<TimeOfDay?> Function(
|
|||
BuildContext context,
|
||||
TimeOfDay? initialTime,
|
||||
);
|
||||
|
||||
/// Builder definition for providing a loading indicator implementation
|
||||
Widget defaultLoader(
|
||||
BuildContext context,
|
||||
) =>
|
||||
const CircularProgressIndicator.adaptive();
|
||||
|
|
|
@ -101,6 +101,8 @@ class _TemplateListSection extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
var theme = Theme.of(context);
|
||||
var textTheme = theme.textTheme;
|
||||
var availabilityScope = AvailabilityScope.of(context);
|
||||
var options = availabilityScope.options;
|
||||
|
||||
var templateCreationButton = GestureDetector(
|
||||
onTap: onAddTemplate,
|
||||
|
@ -160,7 +162,7 @@ class _TemplateListSection extends StatelessWidget {
|
|||
),
|
||||
],
|
||||
if (templatesSnapshot.connectionState == ConnectionState.waiting) ...[
|
||||
const Center(child: CircularProgressIndicator.adaptive()),
|
||||
Center(child: options.loadingIndicatorBuilder(context)),
|
||||
],
|
||||
const SizedBox(height: 8),
|
||||
templateCreationButton,
|
||||
|
|
|
@ -179,7 +179,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
|||
(!_templateDrawerOpen || templatesLoading)) ...[
|
||||
const SizedBox(height: 12),
|
||||
if (templatesLoading) ...[
|
||||
const CircularProgressIndicator.adaptive(),
|
||||
options.loadingIndicatorBuilder(context),
|
||||
] else ...[
|
||||
createNewTemplateButton,
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue