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,6 +331,14 @@ class _SettingsWizardState extends State<SettingsWizard> {
? LoadingIndicator( ? LoadingIndicator(
height: 200, height: 200,
) )
: _showLogo
? Center(
child: Text(
localization.setupWizardLogo,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headline6,
),
)
: Column( : Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -335,7 +348,8 @@ class _SettingsWizardState extends State<SettingsWizard> {
padding: const EdgeInsets.only(bottom: 8), padding: const EdgeInsets.only(bottom: 8),
child: Text( child: Text(
localization.welcomeToInvoiceNinja, localization.welcomeToInvoiceNinja,
style: Theme.of(context).textTheme.headline6, style:
Theme.of(context).textTheme.headline6,
), ),
), ),
companyName, companyName,
@ -360,7 +374,8 @@ class _SettingsWizardState extends State<SettingsWizard> {
Expanded( Expanded(
child: Text( child: Text(
localization.welcomeToInvoiceNinja, localization.welcomeToInvoiceNinja,
style: Theme.of(context).textTheme.headline6, style:
Theme.of(context).textTheme.headline6,
)), )),
if (state.isHosted) ...[ if (state.isHosted) ...[
SizedBox(width: kTableColumnGap), SizedBox(width: kTableColumnGap),
@ -374,8 +389,9 @@ class _SettingsWizardState extends State<SettingsWizard> {
Expanded(child: companyName), Expanded(child: companyName),
SizedBox(width: kTableColumnGap), SizedBox(width: kTableColumnGap),
Expanded( Expanded(
child: child: state.isHosted
state.isHosted ? subdomain : darkMode), ? subdomain
: darkMode),
], ],
), ),
if (showNameFields) if (showNameFields)
@ -409,6 +425,17 @@ 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()),
), ),
if (_showLogo)
TextButton(
onPressed: () {
store.dispatch(ViewSettings(
section: kSettingsCompanyDetails,
tabIndex: 2,
));
Navigator.of(context).pop();
},
child: Text(localization.upload.toUpperCase()))
else
TextButton( TextButton(
onPressed: _onSavePressed, onPressed: _onSavePressed,
child: Text(localization.save.toUpperCase()), 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) {