mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 13:13: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.textStyles = const AvailabilityTextStyles(),
|
||||||
this.colors = const AvailabilityColors(),
|
this.colors = const AvailabilityColors(),
|
||||||
this.timePickerBuilder,
|
this.timePickerBuilder,
|
||||||
|
this.loadingIndicatorBuilder = defaultLoader,
|
||||||
AvailabilityDataInterface? dataInterface,
|
AvailabilityDataInterface? dataInterface,
|
||||||
}) : dataInterface = dataInterface ?? LocalAvailabilityDataInterface();
|
}) : dataInterface = dataInterface ?? LocalAvailabilityDataInterface();
|
||||||
|
|
||||||
|
@ -53,6 +54,11 @@ class AvailabilityOptions {
|
||||||
/// A way to provide your own time picker implementation or customize
|
/// A way to provide your own time picker implementation or customize
|
||||||
/// the default time picker
|
/// the default time picker
|
||||||
final TimePickerBuilder? timePickerBuilder;
|
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
|
/// All configurable paddings and whitespaces withing the userstory
|
||||||
|
@ -154,3 +160,9 @@ typedef TimePickerBuilder = Future<TimeOfDay?> Function(
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
TimeOfDay? initialTime,
|
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) {
|
Widget build(BuildContext context) {
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
var textTheme = theme.textTheme;
|
var textTheme = theme.textTheme;
|
||||||
|
var availabilityScope = AvailabilityScope.of(context);
|
||||||
|
var options = availabilityScope.options;
|
||||||
|
|
||||||
var templateCreationButton = GestureDetector(
|
var templateCreationButton = GestureDetector(
|
||||||
onTap: onAddTemplate,
|
onTap: onAddTemplate,
|
||||||
|
@ -160,7 +162,7 @@ class _TemplateListSection extends StatelessWidget {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
if (templatesSnapshot.connectionState == ConnectionState.waiting) ...[
|
if (templatesSnapshot.connectionState == ConnectionState.waiting) ...[
|
||||||
const Center(child: CircularProgressIndicator.adaptive()),
|
Center(child: options.loadingIndicatorBuilder(context)),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
templateCreationButton,
|
templateCreationButton,
|
||||||
|
|
|
@ -179,7 +179,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
||||||
(!_templateDrawerOpen || templatesLoading)) ...[
|
(!_templateDrawerOpen || templatesLoading)) ...[
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
if (templatesLoading) ...[
|
if (templatesLoading) ...[
|
||||||
const CircularProgressIndicator.adaptive(),
|
options.loadingIndicatorBuilder(context),
|
||||||
] else ...[
|
] else ...[
|
||||||
createNewTemplateButton,
|
createNewTemplateButton,
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue