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); final _debouncer = Debouncer(milliseconds: kMillisecondsToDebounceSave);
bool _isSaving = false; bool _isSaving = false;
bool _showLogo = false;
bool _isSubdomainUnique = false; bool _isSubdomainUnique = false;
bool _isCheckingSubdomain = false; bool _isCheckingSubdomain = false;
bool _hasCheckedSubdomain = false; bool _hasCheckedSubdomain = false;
@ -143,7 +144,6 @@ class _SettingsWizardState extends State<SettingsWizard> {
} }
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final navigator = Navigator.of(context);
final state = store.state; final state = store.state;
passwordCallback( passwordCallback(
@ -154,10 +154,15 @@ class _SettingsWizardState extends State<SettingsWizard> {
completer.future.then((value) { completer.future.then((value) {
final toastCompleter = final toastCompleter =
snackBarCompleter<Null>(context, localization.savedSettings); snackBarCompleter<Null>(context, localization.savedSettings);
toastCompleter.future toastCompleter.future.then((value) {
.then((value) => navigator.pop()) setState(() {
.catchError((Object error) { _isSaving = false;
setState(() => _isSaving = false); _showLogo = true;
});
}).catchError((Object error) {
setState(() {
_isSaving = false;
});
}); });
store.dispatch( store.dispatch(
SaveCompanyRequest( SaveCompanyRequest(
@ -326,80 +331,91 @@ class _SettingsWizardState extends State<SettingsWizard> {
? LoadingIndicator( ? LoadingIndicator(
height: 200, height: 200,
) )
: Column( : _showLogo
crossAxisAlignment: CrossAxisAlignment.start, ? Center(
mainAxisSize: MainAxisSize.min, child: Text(
children: isMobile(context) localization.setupWizardLogo,
? [ textAlign: TextAlign.center,
Padding( style: Theme.of(context).textTheme.headline6,
padding: const EdgeInsets.only(bottom: 8), ),
child: Text( )
localization.welcomeToInvoiceNinja, : Column(
style: Theme.of(context).textTheme.headline6, crossAxisAlignment: CrossAxisAlignment.start,
), mainAxisSize: MainAxisSize.min,
), children: isMobile(context)
companyName, ? [
if (state.isHosted) subdomain, Padding(
if (showNameFields) ...[ padding: const EdgeInsets.only(bottom: 8),
firstName, child: Text(
lastName, localization.welcomeToInvoiceNinja,
], style:
language, Theme.of(context).textTheme.headline6,
currency, ),
SizedBox(height: 16), ),
darkMode, companyName,
if (state.isHosted) if (state.isHosted) subdomain,
Padding( if (showNameFields) ...[
padding: const EdgeInsets.only(top: 32), firstName,
child: Text(localization.subdomainGuide), lastName,
)
]
: [
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),
], ],
), language,
Row( currency,
children: [ SizedBox(height: 16),
Expanded(child: language), darkMode,
SizedBox(width: kTableColumnGap), if (state.isHosted)
Expanded(child: currency), 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(), onPressed: () => Navigator.of(context).pop(),
child: Text(localization.close.toUpperCase()), child: Text(localization.close.toUpperCase()),
), ),
TextButton( if (_showLogo)
onPressed: _onSavePressed, TextButton(
child: Text(localization.save.toUpperCase()), 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 = { static final Map<String, Map<String, String>> _localizedValues = {
'en': { 'en': {
// STARTER: lang key - do not remove comment // STARTER: lang key - do not remove comment
'setup_wizard_logo': 'Would you like to upload your logo?',
'upload': 'Upload',
'installed_version': 'Installed Version', 'installed_version': 'Installed Version',
'notify_vendor_when_paid': 'Notify Vendor When Paid', 'notify_vendor_when_paid': 'Notify Vendor When Paid',
'notify_vendor_when_paid_help': 'notify_vendor_when_paid_help':
@ -92949,6 +92951,15 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['installed_version'] ?? _localizedValues[localeCode]['installed_version'] ??
_localizedValues['en']['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 // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {