mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 05:03:44 +02:00
fix: improve loading visual for template legend
This commit is contained in:
parent
8b138a8072
commit
71d76bba04
1 changed files with 14 additions and 7 deletions
|
@ -38,11 +38,12 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
||||||
|
|
||||||
var templatesLoading =
|
var templatesLoading =
|
||||||
widget.availabilities.connectionState == ConnectionState.waiting;
|
widget.availabilities.connectionState == ConnectionState.waiting;
|
||||||
var templatesAvailable = widget.availabilities.data?.isNotEmpty ?? false;
|
var templatesAvailable =
|
||||||
|
!templatesLoading && (widget.availabilities.data?.isNotEmpty ?? false);
|
||||||
var templates = widget.availabilities.data?.getUniqueTemplates() ?? [];
|
var templates = widget.availabilities.data?.getUniqueTemplates() ?? [];
|
||||||
|
|
||||||
void onDrawerHeaderClick() {
|
void onDrawerHeaderClick() {
|
||||||
if (!templatesAvailable) {
|
if (!templatesAvailable && !_templateDrawerOpen) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -69,6 +70,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
||||||
);
|
);
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
|
// a button to open/close a drawer with all the templates
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: onDrawerHeaderClick,
|
onTap: onDrawerHeaderClick,
|
||||||
child: ColoredBox(
|
child: ColoredBox(
|
||||||
|
@ -81,8 +83,8 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
||||||
translations.templateLegendTitle,
|
translations.templateLegendTitle,
|
||||||
style: textTheme.titleMedium,
|
style: textTheme.titleMedium,
|
||||||
),
|
),
|
||||||
// a button to open a drawer with all the templates
|
if ((templatesAvailable && !templatesLoading) ||
|
||||||
if (templatesAvailable && !templatesLoading) ...[
|
_templateDrawerOpen) ...[
|
||||||
Icon(
|
Icon(
|
||||||
_templateDrawerOpen
|
_templateDrawerOpen
|
||||||
? Icons.arrow_drop_up
|
? Icons.arrow_drop_up
|
||||||
|
@ -96,6 +98,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 500),
|
duration: const Duration(milliseconds: 500),
|
||||||
|
// TODO(freek): Animation should be used so it doesn't instantly close
|
||||||
constraints: BoxConstraints(maxHeight: _templateDrawerOpen ? 150 : 0),
|
constraints: BoxConstraints(maxHeight: _templateDrawerOpen ? 150 : 0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: _templateDrawerOpen
|
border: _templateDrawerOpen
|
||||||
|
@ -103,7 +106,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.only(right: 2),
|
padding: const EdgeInsets.only(right: 2),
|
||||||
child: _templateDrawerOpen
|
child: _templateDrawerOpen && !templatesLoading
|
||||||
? SingleChildScrollView(
|
? SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -150,9 +153,13 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: const Divider(height: 1),
|
: const Divider(
|
||||||
|
height: 1,
|
||||||
|
thickness: 1,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (!templatesAvailable && !_templateDrawerOpen) ...[
|
if (!templatesAvailable &&
|
||||||
|
(!_templateDrawerOpen || templatesLoading)) ...[
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
if (templatesLoading) ...[
|
if (templatesLoading) ...[
|
||||||
const CircularProgressIndicator.adaptive(),
|
const CircularProgressIndicator.adaptive(),
|
||||||
|
|
Loading…
Reference in a new issue