Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Dec 3, 2024
2 parents 7a229b8 + bb1295b commit b2f60fd
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 23 deletions.
26 changes: 15 additions & 11 deletions lib/redux/app/app_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,6 @@ Middleware<AppState> _createLoadState(
store.dispatch(ViewMainScreen());
}

final prefs = await SharedPreferences.getInstance();
final companyId = prefs.getString(kSharedPrefCompanyId);
if (companyId != null) {
final index = companyStates.indexWhere(
(companyState) => companyState?.company.id == companyId);
if (index > 0) {
store.dispatch(SelectCompany(companyIndex: index));
}
}

WidgetsBinding.instance.addPostFrameCallback((duration) {
store.dispatch(ViewDashboard());
});
Expand Down Expand Up @@ -483,7 +473,21 @@ Middleware<AppState> _createDataRefreshed() {
final response = action.data!;
final loadedStaticData = response.static.currencies.isNotEmpty;
final state = store.state;
final selectedCompanyIndex = state.uiState.selectedCompanyIndex;
int selectedCompanyIndex = state.uiState.selectedCompanyIndex;

// Fallback to ensure the last or primary company is selected
if (state.companies.isEmpty) {
final prefs = await SharedPreferences.getInstance();
String? companyId = prefs.getString(kSharedPrefCompanyId);
companyId ??= store.state.account.defaultCompanyId;
if (companyId.isNotEmpty) {
final index = response.userCompanies
.indexWhere((companyState) => companyState.company.id == companyId);
if (index > 0) {
selectedCompanyIndex = index;
}
}
}

if (loadedStaticData) {
store.dispatch(LoadStaticSuccess(data: response.static));
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/app/forms/decorated_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DecoratedFormField extends StatefulWidget {
this.isPercent = false,
this.showClear = true,
this.inputFormatters,
this.textCapitalization = TextCapitalization.none,
}) : super(key: key);

final TextEditingController? controller;
Expand Down Expand Up @@ -66,6 +67,7 @@ class DecoratedFormField extends StatefulWidget {
final bool isPercent;
final bool showClear;
final List<TextInputFormatter>? inputFormatters;
final TextCapitalization textCapitalization;

@override
_DecoratedFormFieldState createState() => _DecoratedFormFieldState();
Expand Down Expand Up @@ -156,6 +158,7 @@ class _DecoratedFormFieldState extends State<DecoratedFormField> {
: enterShouldSubmit || kIsWeb
? TextInputAction.done
: TextInputAction.next,
textCapitalization: widget.textCapitalization,
onChanged: (value) {
_showClear = true;
if (widget.onChanged != null) {
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/client/edit/client_edit_contacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
: null,
onSavePressed: (_) => _onDoneContactPressed(),
label: localization.firstName,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
controller: _lastNameController,
Expand All @@ -304,7 +305,8 @@ class ContactEditDetailsState extends State<ContactEditDetails> {
? AppLocalization.of(context)!.pleaseEnterAClientOrContactName
: null,
onSavePressed: (_) => _onDoneContactPressed(),
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
controller: _emailController,
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/settings/email_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ class _EmailSettingsState extends State<EmailSettings> {
label: localization.fromName,
controller: _fromNameController,
onSavePressed: _onSavePressed,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
label: localization.replyToEmail,
Expand All @@ -537,7 +538,8 @@ class _EmailSettingsState extends State<EmailSettings> {
label: localization.replyToName,
controller: _replyToNameController,
onSavePressed: _onSavePressed,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
label: localization.bccEmail,
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/settings/settings_wizard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ class _SettingsWizardState extends State<SettingsWizard> {
final firstName = DecoratedFormField(
label: localization.firstName,
controller: _firstNameController,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
autofillHints: [AutofillHints.givenName],
validator: (value) =>
value.isEmpty ? localization.pleaseEnterAValue : null,
Expand All @@ -221,7 +222,8 @@ class _SettingsWizardState extends State<SettingsWizard> {
final lastName = DecoratedFormField(
label: localization.lastName,
controller: _lastNameController,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
autofillHints: [AutofillHints.familyName],
validator: (value) =>
value.isEmpty ? localization.pleaseEnterAValue : null,
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/settings/user_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ class _UserDetailsState extends State<UserDetails>
? localization.pleaseEnterAFirstName
: null,
onSavePressed: _onSavePressed,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
label: localization.lastName,
Expand All @@ -328,7 +329,8 @@ class _UserDetailsState extends State<UserDetails>
? localization.pleaseEnterALastName
: null,
onSavePressed: _onSavePressed,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
label: localization.email,
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/user/edit/user_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ class _UserEditState extends State<UserEdit>
? localization.pleaseEnterAFirstName
: null,
onSavePressed: _onSavePressed,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
label: localization.lastName,
Expand All @@ -203,7 +204,8 @@ class _UserEditState extends State<UserEdit>
? localization.pleaseEnterALastName
: null,
onSavePressed: _onSavePressed,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
label: localization.email,
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/vendor/edit/vendor_edit_contacts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,15 @@ class VendorContactEditDetailsState extends State<VendorContactEditDetails> {
controller: _firstNameController,
onSavePressed: (_) => _onDoneContactPressed(),
label: localization.firstName,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
controller: _lastNameController,
onSavePressed: (_) => _onDoneContactPressed(),
label: localization.lastName,
keyboardType: TextInputType.name,
keyboardType: TextInputType.text,
textCapitalization: TextCapitalization.words,
),
DecoratedFormField(
controller: _emailController,
Expand Down

0 comments on commit b2f60fd

Please sign in to comment.