Offer to upload logo after completing the wizard

This commit is contained in:
Hillel Coren 2023-01-09 17:03:16 +02:00
parent fd32ab6f0c
commit f98cb377e4
2 changed files with 119 additions and 81 deletions

View File

@ -49,6 +49,7 @@ class _SettingsWizardState extends State<SettingsWizard> {
final _debouncer = Debouncer(milliseconds: kMillisecondsToDebounceSave);
bool _isSaving = false;
bool _showLogo = false;
bool _isSubdomainUnique = false;
bool _isCheckingSubdomain = false;
bool _hasCheckedSubdomain = false;
@ -143,7 +144,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
}
final store = StoreProvider.of<AppState>(context);
final navigator = Navigator.of(context);
final state = store.state;
passwordCallback(
@ -154,10 +154,15 @@ class _SettingsWizardState extends State<SettingsWizard> {
completer.future.then((value) {
final toastCompleter =
snackBarCompleter<Null>(context, localization.savedSettings);
toastCompleter.future
.then((value) => navigator.pop())
.catchError((Object error) {
setState(() => _isSaving = false);
toastCompleter.future.then((value) {
setState(() {
_isSaving = false;
_showLogo = true;
});
}).catchError((Object error) {
setState(() {
_isSaving = false;
});
});
store.dispatch(
SaveCompanyRequest(
@ -326,80 +331,91 @@ class _SettingsWizardState extends State<SettingsWizard> {
? LoadingIndicator(
height: 200,
)
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: isMobile(context)
? [
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
localization.welcomeToInvoiceNinja,
style: Theme.of(context).textTheme.headline6,
),
),
companyName,
if (state.isHosted) subdomain,
if (showNameFields) ...[
firstName,
lastName,
],
language,
currency,
SizedBox(height: 16),
darkMode,
if (state.isHosted)
Padding(
padding: const EdgeInsets.only(top: 32),
child: Text(localization.subdomainGuide),
)
]
: [
Row(
children: [
Expanded(
child: Text(
localization.welcomeToInvoiceNinja,
style: Theme.of(context).textTheme.headline6,
)),
if (state.isHosted) ...[
SizedBox(width: kTableColumnGap),
Flexible(child: darkMode),
]
],
),
SizedBox(height: 16),
Row(
children: [
Expanded(child: companyName),
SizedBox(width: kTableColumnGap),
Expanded(
child:
state.isHosted ? subdomain : darkMode),
],
),
if (showNameFields)
Row(
children: [
Expanded(child: firstName),
SizedBox(width: kTableColumnGap),
Expanded(child: lastName),
: _showLogo
? Center(
child: Text(
localization.setupWizardLogo,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6,
),
)
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: isMobile(context)
? [
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Text(
localization.welcomeToInvoiceNinja,
style:
Theme.of(context).textTheme.headline6,
),
),
companyName,
if (state.isHosted) subdomain,
if (showNameFields) ...[
firstName,
lastName,
],
),
Row(
children: [
Expanded(child: language),
SizedBox(width: kTableColumnGap),
Expanded(child: currency),
language,
currency,
SizedBox(height: 16),
darkMode,
if (state.isHosted)
Padding(
padding: const EdgeInsets.only(top: 32),
child: Text(localization.subdomainGuide),
)
]
: [
Row(
children: [
Expanded(
child: Text(
localization.welcomeToInvoiceNinja,
style:
Theme.of(context).textTheme.headline6,
)),
if (state.isHosted) ...[
SizedBox(width: kTableColumnGap),
Flexible(child: darkMode),
]
],
),
SizedBox(height: 16),
Row(
children: [
Expanded(child: companyName),
SizedBox(width: kTableColumnGap),
Expanded(
child: state.isHosted
? subdomain
: darkMode),
],
),
if (showNameFields)
Row(
children: [
Expanded(child: firstName),
SizedBox(width: kTableColumnGap),
Expanded(child: lastName),
],
),
Row(
children: [
Expanded(child: language),
SizedBox(width: kTableColumnGap),
Expanded(child: currency),
],
),
if (state.isHosted)
Padding(
padding: const EdgeInsets.only(top: 32),
child: Text(localization.subdomainGuide),
),
],
),
if (state.isHosted)
Padding(
padding: const EdgeInsets.only(top: 32),
child: Text(localization.subdomainGuide),
),
],
),
),
),
),
),
@ -409,10 +425,21 @@ class _SettingsWizardState extends State<SettingsWizard> {
onPressed: () => Navigator.of(context).pop(),
child: Text(localization.close.toUpperCase()),
),
TextButton(
onPressed: _onSavePressed,
child: Text(localization.save.toUpperCase()),
),
if (_showLogo)
TextButton(
onPressed: () {
store.dispatch(ViewSettings(
section: kSettingsCompanyDetails,
tabIndex: 2,
));
Navigator.of(context).pop();
},
child: Text(localization.upload.toUpperCase()))
else
TextButton(
onPressed: _onSavePressed,
child: Text(localization.save.toUpperCase()),
),
]
],
);

View File

@ -16,6 +16,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
// STARTER: lang key - do not remove comment
'setup_wizard_logo': 'Would you like to upload your logo?',
'upload': 'Upload',
'installed_version': 'Installed Version',
'notify_vendor_when_paid': 'Notify Vendor When Paid',
'notify_vendor_when_paid_help':
@ -92949,6 +92951,15 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['installed_version'] ??
_localizedValues['en']['installed_version'];
String get setupWizardLogo =>
_localizedValues[localeCode]['setup_wizard_logo'] ??
_localizedValues['en']['setup_wizard_logo'];
String get upload =>
_localizedValues[localeCode]['upload'] ??
_localizedValues['en']['upload'];
// STARTER: lang field - do not remove comment
String lookup(String key) {