Email signature
This commit is contained in:
parent
fcab49c3fa
commit
8349f2ec4b
|
|
@ -23,18 +23,17 @@ class EmailSettings extends StatefulWidget {
|
||||||
_EmailSettingsState createState() => _EmailSettingsState();
|
_EmailSettingsState createState() => _EmailSettingsState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _EmailSettingsState extends State<EmailSettings>
|
class _EmailSettingsState extends State<EmailSettings> {
|
||||||
with SingleTickerProviderStateMixin {
|
|
||||||
static final GlobalKey<FormState> _formKey =
|
static final GlobalKey<FormState> _formKey =
|
||||||
GlobalKey<FormState>(debugLabel: '_emailSettings');
|
GlobalKey<FormState>(debugLabel: '_emailSettings');
|
||||||
|
|
||||||
TabController _tabController;
|
|
||||||
FocusScopeNode _focusNode;
|
FocusScopeNode _focusNode;
|
||||||
bool autoValidate = false;
|
bool autoValidate = false;
|
||||||
|
|
||||||
final _replyToEmailController = TextEditingController();
|
final _replyToEmailController = TextEditingController();
|
||||||
final _bccEmailController = TextEditingController();
|
final _bccEmailController = TextEditingController();
|
||||||
final _emailStyleCustomController = TextEditingController();
|
final _emailStyleCustomController = TextEditingController();
|
||||||
|
final _emailFooterController = TextEditingController();
|
||||||
|
|
||||||
List<TextEditingController> _controllers = [];
|
List<TextEditingController> _controllers = [];
|
||||||
|
|
||||||
|
|
@ -42,13 +41,11 @@ class _EmailSettingsState extends State<EmailSettings>
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
_tabController = TabController(vsync: this, length: 2);
|
|
||||||
_focusNode = FocusScopeNode();
|
_focusNode = FocusScopeNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_tabController.dispose();
|
|
||||||
_focusNode.dispose();
|
_focusNode.dispose();
|
||||||
_controllers.forEach((dynamic controller) {
|
_controllers.forEach((dynamic controller) {
|
||||||
controller.removeListener(_onChanged);
|
controller.removeListener(_onChanged);
|
||||||
|
|
@ -63,17 +60,17 @@ class _EmailSettingsState extends State<EmailSettings>
|
||||||
_replyToEmailController,
|
_replyToEmailController,
|
||||||
_bccEmailController,
|
_bccEmailController,
|
||||||
_emailStyleCustomController,
|
_emailStyleCustomController,
|
||||||
|
_emailFooterController,
|
||||||
];
|
];
|
||||||
|
|
||||||
_controllers
|
_controllers
|
||||||
.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
.forEach((dynamic controller) => controller.removeListener(_onChanged));
|
||||||
|
|
||||||
final settings = widget.viewModel.settings;
|
final settings = widget.viewModel.settings;
|
||||||
//final signature = settings.emailFooter;
|
|
||||||
|
|
||||||
_replyToEmailController.text = settings.replyToEmail;
|
_replyToEmailController.text = settings.replyToEmail;
|
||||||
_bccEmailController.text = settings.bccEmail;
|
_bccEmailController.text = settings.bccEmail;
|
||||||
_emailStyleCustomController.text = settings.emailStyleCustom;
|
_emailStyleCustomController.text = settings.emailStyleCustom;
|
||||||
|
_emailFooterController.text = settings.emailFooter;
|
||||||
|
|
||||||
_controllers
|
_controllers
|
||||||
.forEach((dynamic controller) => controller.addListener(_onChanged));
|
.forEach((dynamic controller) => controller.addListener(_onChanged));
|
||||||
|
|
@ -85,7 +82,8 @@ class _EmailSettingsState extends State<EmailSettings>
|
||||||
final settings = widget.viewModel.settings.rebuild((b) => b
|
final settings = widget.viewModel.settings.rebuild((b) => b
|
||||||
..replyToEmail = _replyToEmailController.text.trim()
|
..replyToEmail = _replyToEmailController.text.trim()
|
||||||
..bccEmail = _bccEmailController.text.trim()
|
..bccEmail = _bccEmailController.text.trim()
|
||||||
..emailStyleCustom = _emailStyleCustomController.text.trim());
|
..emailStyleCustom = _emailStyleCustomController.text.trim()
|
||||||
|
..emailFooter = _emailFooterController.text.trim());
|
||||||
if (settings != widget.viewModel.settings) {
|
if (settings != widget.viewModel.settings) {
|
||||||
widget.viewModel.onSettingsChanged(settings);
|
widget.viewModel.onSettingsChanged(settings);
|
||||||
}
|
}
|
||||||
|
|
@ -95,121 +93,107 @@ class _EmailSettingsState extends State<EmailSettings>
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final localization = AppLocalization.of(context);
|
final localization = AppLocalization.of(context);
|
||||||
final viewModel = widget.viewModel;
|
final viewModel = widget.viewModel;
|
||||||
final state = viewModel.state;
|
|
||||||
final settings = viewModel.settings;
|
final settings = viewModel.settings;
|
||||||
|
|
||||||
return EditScaffold(
|
return EditScaffold(
|
||||||
title: localization.emailSettings,
|
title: localization.emailSettings,
|
||||||
onSavePressed: viewModel.onSavePressed,
|
onSavePressed: viewModel.onSavePressed,
|
||||||
appBarBottom: TabBar(
|
body: AppForm(
|
||||||
key: ValueKey(state.settingsUIState.updatedAt),
|
|
||||||
controller: _tabController,
|
|
||||||
tabs: [
|
|
||||||
Tab(
|
|
||||||
text: localization.settings,
|
|
||||||
),
|
|
||||||
Tab(
|
|
||||||
text: localization.emailSignature,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
body: AppTabForm(
|
|
||||||
tabController: _tabController,
|
|
||||||
formKey: _formKey,
|
formKey: _formKey,
|
||||||
focusNode: _focusNode,
|
focusNode: _focusNode,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ListView(
|
FormCard(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
FormCard(
|
AppDropdownButton<String>(
|
||||||
children: <Widget>[
|
labelText: localization.emailDesign,
|
||||||
AppDropdownButton<String>(
|
value: viewModel.settings.emailStyle,
|
||||||
labelText: localization.emailDesign,
|
onChanged: (dynamic value) => viewModel.onSettingsChanged(
|
||||||
value: viewModel.settings.emailStyle,
|
settings.rebuild((b) => b..emailStyle = value)),
|
||||||
onChanged: (dynamic value) => viewModel.onSettingsChanged(
|
items: [
|
||||||
settings.rebuild((b) => b..emailStyle = value)),
|
DropdownMenuItem(
|
||||||
items: [
|
child: Text(localization.plain),
|
||||||
DropdownMenuItem(
|
value: kEmailDesignPlain,
|
||||||
child: Text(localization.plain),
|
|
||||||
value: kEmailDesignPlain,
|
|
||||||
),
|
|
||||||
DropdownMenuItem(
|
|
||||||
child: Text(localization.light),
|
|
||||||
value: kEmailDesignLight,
|
|
||||||
),
|
|
||||||
DropdownMenuItem(
|
|
||||||
child: Text(localization.dark),
|
|
||||||
value: kEmailDesignDark,
|
|
||||||
),
|
|
||||||
DropdownMenuItem(
|
|
||||||
child: Text(localization.custom),
|
|
||||||
value: kEmailDesignCustom,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
if (settings.emailStyle == kEmailDesignCustom) ...[
|
DropdownMenuItem(
|
||||||
SizedBox(height: 10),
|
child: Text(localization.light),
|
||||||
DecoratedFormField(
|
value: kEmailDesignLight,
|
||||||
label: localization.custom,
|
|
||||||
controller: _emailStyleCustomController,
|
|
||||||
maxLines: 6,
|
|
||||||
),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
),
|
|
||||||
FormCard(
|
|
||||||
children: <Widget>[
|
|
||||||
DecoratedFormField(
|
|
||||||
label: localization.replyToEmail,
|
|
||||||
controller: _replyToEmailController,
|
|
||||||
keyboardType: TextInputType.emailAddress,
|
|
||||||
),
|
),
|
||||||
DecoratedFormField(
|
DropdownMenuItem(
|
||||||
label: localization.bccEmail,
|
child: Text(localization.dark),
|
||||||
controller: _bccEmailController,
|
value: kEmailDesignDark,
|
||||||
keyboardType: TextInputType.emailAddress,
|
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
DropdownMenuItem(
|
||||||
BoolDropdownButton(
|
child: Text(localization.custom),
|
||||||
label: localization.enableMarkup,
|
value: kEmailDesignCustom,
|
||||||
helpLabel: localization.enableMarkupHelp,
|
|
||||||
value: settings.enableEmailMarkup,
|
|
||||||
iconData:
|
|
||||||
kIsWeb ? Icons.email : FontAwesomeIcons.solidEnvelope,
|
|
||||||
onChanged: (value) => viewModel.onSettingsChanged(
|
|
||||||
settings.rebuild((b) => b..enableEmailMarkup = value)),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
FormCard(
|
if (settings.emailStyle == kEmailDesignCustom) ...[
|
||||||
children: <Widget>[
|
SizedBox(height: 10),
|
||||||
BoolDropdownButton(
|
DecoratedFormField(
|
||||||
label: localization.attachPdf,
|
label: localization.custom,
|
||||||
value: settings.pdfEmailAttachment,
|
controller: _emailStyleCustomController,
|
||||||
iconData: FontAwesomeIcons.fileInvoice,
|
maxLines: 6,
|
||||||
onChanged: (value) => viewModel.onSettingsChanged(
|
),
|
||||||
settings.rebuild((b) => b..pdfEmailAttachment = value)),
|
]
|
||||||
),
|
],
|
||||||
BoolDropdownButton(
|
),
|
||||||
label: localization.attachDocuments,
|
FormCard(
|
||||||
value: settings.documentEmailAttachment,
|
children: <Widget>[
|
||||||
iconData: FontAwesomeIcons.fileImage,
|
DecoratedFormField(
|
||||||
onChanged: (value) => viewModel.onSettingsChanged(settings
|
label: localization.replyToEmail,
|
||||||
.rebuild((b) => b..documentEmailAttachment = value)),
|
controller: _replyToEmailController,
|
||||||
),
|
keyboardType: TextInputType.emailAddress,
|
||||||
BoolDropdownButton(
|
),
|
||||||
label: localization.attachUbl,
|
DecoratedFormField(
|
||||||
value: settings.ublEmailAttachment,
|
label: localization.bccEmail,
|
||||||
iconData: FontAwesomeIcons.fileArchive,
|
controller: _bccEmailController,
|
||||||
onChanged: (value) => viewModel.onSettingsChanged(
|
keyboardType: TextInputType.emailAddress,
|
||||||
settings.rebuild((b) => b..ublEmailAttachment = value)),
|
),
|
||||||
),
|
SizedBox(height: 10),
|
||||||
],
|
BoolDropdownButton(
|
||||||
|
label: localization.enableMarkup,
|
||||||
|
helpLabel: localization.enableMarkupHelp,
|
||||||
|
value: settings.enableEmailMarkup,
|
||||||
|
iconData: kIsWeb ? Icons.email : FontAwesomeIcons.solidEnvelope,
|
||||||
|
onChanged: (value) => viewModel.onSettingsChanged(
|
||||||
|
settings.rebuild((b) => b..enableEmailMarkup = value)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Container(
|
FormCard(
|
||||||
color: Colors.grey.shade100,
|
children: <Widget>[
|
||||||
child: SizedBox(),
|
DecoratedFormField(
|
||||||
|
label: localization.emailSignature,
|
||||||
|
controller: _emailFooterController,
|
||||||
|
maxLines: 6,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
FormCard(
|
||||||
|
children: <Widget>[
|
||||||
|
BoolDropdownButton(
|
||||||
|
label: localization.attachPdf,
|
||||||
|
value: settings.pdfEmailAttachment,
|
||||||
|
iconData: FontAwesomeIcons.fileInvoice,
|
||||||
|
onChanged: (value) => viewModel.onSettingsChanged(
|
||||||
|
settings.rebuild((b) => b..pdfEmailAttachment = value)),
|
||||||
|
),
|
||||||
|
BoolDropdownButton(
|
||||||
|
label: localization.attachDocuments,
|
||||||
|
value: settings.documentEmailAttachment,
|
||||||
|
iconData: FontAwesomeIcons.fileImage,
|
||||||
|
onChanged: (value) => viewModel.onSettingsChanged(settings
|
||||||
|
.rebuild((b) => b..documentEmailAttachment = value)),
|
||||||
|
),
|
||||||
|
BoolDropdownButton(
|
||||||
|
label: localization.attachUbl,
|
||||||
|
value: settings.ublEmailAttachment,
|
||||||
|
iconData: FontAwesomeIcons.fileArchive,
|
||||||
|
onChanged: (value) => viewModel.onSettingsChanged(
|
||||||
|
settings.rebuild((b) => b..ublEmailAttachment = value)),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue