Adjust loading indicator for email templates

This commit is contained in:
Hillel Coren 2024-01-03 14:30:23 +02:00
parent 11ed6af110
commit aeb2960737
1 changed files with 38 additions and 39 deletions

View File

@ -297,24 +297,18 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
return Container( return Container(
color: Colors.white, color: Colors.white,
height: double.infinity, height: double.infinity,
child: Stack( child: (supportsInlineBrowser())
children: [ ? EmailPreview(
if (_isLoading) LinearProgressIndicator(),
if (supportsInlineBrowser())
EmailPreview(
isLoading: _isLoading, isLoading: _isLoading,
subject: _subjectPreview, subject: _subjectPreview,
body: _emailPreview, body: _emailPreview,
) )
else : IgnorePointer(
IgnorePointer(
child: ExampleEditor( child: ExampleEditor(
value: '### $_subjectPreview\n\n\n' + value: '### $_subjectPreview\n\n\n' +
html2md.convert(_bodyPreview), html2md.convert(_bodyPreview),
), ),
) ),
],
),
); );
} }
@ -372,36 +366,41 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
), ),
), ),
), ),
if (state.company.markdownEmailEnabled) Expanded(
Expanded( child: Stack(
child: ColoredBox( children: [
color: Colors.white, if (state.company.markdownEmailEnabled)
child: IgnorePointer( ColoredBox(
ignoring: !enableCustomEmail, color: Colors.white,
child: ExampleEditor( child: IgnorePointer(
value: _rawBodyPreview, ignoring: !enableCustomEmail,
onChanged: (value) { child: ExampleEditor(
if (value.trim() != _bodyController.text.trim()) { value: _rawBodyPreview,
_bodyController.text = value; onChanged: (value) {
_onChanged(); if (value.trim() != _bodyController.text.trim()) {
} _bodyController.text = value;
}, _onChanged();
}
},
),
),
)
else
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: DecoratedFormField(
controller: _bodyController,
label: localization.body,
maxLines: enableCustomEmail ? 6 : 2,
keyboardType: TextInputType.multiline,
onChanged: (_) => _onChanged(),
enabled: enableCustomEmail,
),
), ),
), if (_isLoading) LinearProgressIndicator(),
), ],
) ),
else ),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: DecoratedFormField(
controller: _bodyController,
label: localization.body,
maxLines: enableCustomEmail ? 6 : 2,
keyboardType: TextInputType.multiline,
onChanged: (_) => _onChanged(),
enabled: enableCustomEmail,
),
)
], ],
); );
} }