Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Jul 3, 2024
2 parents ed607eb + cee9dac commit 9e6a4b0
Show file tree
Hide file tree
Showing 18 changed files with 462 additions and 330 deletions.
3 changes: 3 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const String kSharedPrefUrl = 'url';
const String kSharedPrefToken = 'checksum';
const String kSharedPrefWidth = 'width';
const String kSharedPrefHeight = 'height';
const String kSharedPrefMaximized = 'maximized';

const String kProductProPlanMonth = 'pro_plan';
const String kProductEnterprisePlanMonth_2 = 'enterprise_plan';
Expand Down Expand Up @@ -954,6 +955,8 @@ List<String> kCustomLabels = [
'payment_date',
'phone',
'po_number',
'product',
'products',
'quantity',
'quote',
'rate',
Expand Down
3 changes: 3 additions & 0 deletions lib/data/models/settings_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@ abstract class SettingsEntity
@BuiltValueField(wireName: 'quote_late_fee_percent1')
double? get quoteLateFeePercent1;

@BuiltValueField(wireName: 'merge_e_invoice_to_pdf')
bool? get mergeEInvoiceToPdf;

bool? get taskRoundingEnabled =>
taskRoundToNearest == null ? null : taskRoundToNearest != 1;

Expand Down
32 changes: 28 additions & 4 deletions lib/data/models/settings_model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ void main({bool isTesting = false}) async {
), () async {
await windowManager.show();
await windowManager.focus();

if (prefs.getBool(kSharedPrefMaximized) == true) {
windowManager.maximize();
}
});
}

Expand Down
9 changes: 8 additions & 1 deletion lib/ui/app/menu_drawer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Dart imports:
import 'dart:convert';
import 'dart:io';

// Flutter imports:
import 'package:flutter/foundation.dart';
Expand All @@ -16,6 +17,7 @@ import 'package:invoiceninja_flutter/ui/app/sms_verification.dart';
import 'package:invoiceninja_flutter/ui/app/upgrade_dialog.dart';
import 'package:invoiceninja_flutter/utils/app_review.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
import 'package:redux/redux.dart';
import 'package:url_launcher/url_launcher.dart';
Expand Down Expand Up @@ -1396,10 +1398,15 @@ void _showAbout(BuildContext context) async {
builder: (context) => UpgradeDialog(),
);
} else {
final directory =
await getApplicationDocumentsDirectory();
showMessageDialog(
message: FLUTTER_VERSION['channel']!.toUpperCase() +
' • ' +
FLUTTER_VERSION['frameworkVersion']!,
FLUTTER_VERSION['frameworkVersion']! +
'\n\n${directory.path}' +
Platform.pathSeparator +
'invoiceninja',
secondaryActions: [
TextButton(
child: Text(localization.logout.toUpperCase()),
Expand Down
37 changes: 27 additions & 10 deletions lib/ui/app/window_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ class _WindowManagerState extends State<WindowManager> with WindowListener {
_initManager();
}

if (isApple()) {
_initWidgets();
}

super.initState();
}

Expand All @@ -37,12 +33,6 @@ class _WindowManagerState extends State<WindowManager> with WindowListener {
setState(() {});
}

void _initWidgets() async {
//print("## SET DATA");
//await UserDefaults.setString('widgetData', 'hello', 'group.com.invoiceninja.app');
//await WidgetKit.reloadAllTimelines();
}

@override
void onWindowResize() async {
if (!isDesktopOS()) {
Expand Down Expand Up @@ -73,6 +63,33 @@ class _WindowManagerState extends State<WindowManager> with WindowListener {
}
}

@override
void onWindowMaximize() async {
if (!isDesktopOS()) {
return;
}

final prefs = await SharedPreferences.getInstance();
prefs.setBool(kSharedPrefMaximized, true);
}

@override
void onWindowUnmaximize() async {
if (!isDesktopOS()) {
return;
}

// This method is auto called when the app starts, we skip it
// if the app state hasn't been loaded yet
final store = StoreProvider.of<AppState>(navigatorKey.currentContext!);
if (!store.state.isLoaded) {
return;
}

final prefs = await SharedPreferences.getInstance();
prefs.setBool(kSharedPrefMaximized, false);
}

@override
void dispose() {
if (isDesktopOS()) {
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/expense/edit/expense_edit_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ class ExpenseEditSettingsState extends State<ExpenseEditSettings> {
(b) => b..paymentDate = convertDateTimeToSqlDate()));
}
} else {
viewModel
.onChanged!(expense.rebuild((b) => b..paymentDate = ''));
viewModel.onChanged!(expense.rebuild((b) => b
..paymentDate = ''
..paymentTypeId = ''
..transactionReference = ''));
WidgetsBinding.instance.addPostFrameCallback((duration) {
_transactionReferenceController.text = '';
});
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/payment_term/payment_term_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class PaymentTermScreen extends StatelessWidget {
return ListScaffold(
entityType: EntityType.paymentTerm,
onHamburgerLongPress: () => store.dispatch(StartPaymentTermMultiselect()),
onCancelSettingsSection: kSettingsCompanyDetails,
onCancelSettingsIndex: 3,
onCancelSettingsSection: kSettingsPaymentSettings,
onCancelSettingsIndex: 1,
appBarTitle: ListFilter(
key: ValueKey(
'__filter_${state.paymentTermListState.filterClearedAt}__'),
Expand Down
81 changes: 0 additions & 81 deletions lib/ui/settings/company_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:file_picker/file_picker.dart';
// Project imports:
import 'package:invoiceninja_flutter/data/models/entities.dart';
import 'package:invoiceninja_flutter/main_app.dart';
import 'package:invoiceninja_flutter/redux/payment_term/payment_term_selectors.dart';
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
import 'package:invoiceninja_flutter/redux/static/static_selectors.dart';
import 'package:invoiceninja_flutter/ui/app/blank_screen.dart';
Expand All @@ -23,7 +22,6 @@ import 'package:invoiceninja_flutter/ui/app/entity_dropdown.dart';
import 'package:invoiceninja_flutter/ui/app/form_card.dart';
import 'package:invoiceninja_flutter/ui/app/forms/app_dropdown_button.dart';
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
import 'package:invoiceninja_flutter/ui/app/forms/bool_dropdown_button.dart';
import 'package:invoiceninja_flutter/ui/app/forms/custom_field.dart';
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
import 'package:invoiceninja_flutter/ui/app/forms/design_picker.dart';
Expand All @@ -33,7 +31,6 @@ import 'package:invoiceninja_flutter/ui/settings/company_details_vm.dart';
import 'package:invoiceninja_flutter/utils/completers.dart';
import 'package:invoiceninja_flutter/utils/dialogs.dart';
import 'package:invoiceninja_flutter/utils/files.dart';
import 'package:invoiceninja_flutter/utils/icons.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';

class CompanyDetails extends StatefulWidget {
Expand Down Expand Up @@ -592,70 +589,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
ScrollableListView(
primary: true,
children: <Widget>[
FormCard(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (company.isModuleEnabled(EntityType.invoice))
AppDropdownButton<String>(
showBlank: true,
labelText: localization.invoicePaymentTerms,
items: memoizedDropdownPaymentTermList(
state.paymentTermState.map,
state.paymentTermState.list)
.map((paymentTermId) {
final paymentTerm =
state.paymentTermState.map[paymentTermId]!;
return DropdownMenuItem<String>(
child: Text(paymentTerm.numDays == 0
? localization.dueOnReceipt
: paymentTerm.name),
value: paymentTerm.numDays.toString(),
);
}).toList(),
value: '${settings.defaultPaymentTerms}',
onChanged: (dynamic numDays) {
viewModel.onSettingsChanged(settings.rebuild((b) => b
..defaultPaymentTerms =
numDays == null ? null : '$numDays'));
},
),
if (company.isModuleEnabled(EntityType.quote))
AppDropdownButton<String>(
showBlank: true,
labelText: localization.quoteValidUntil,
items: memoizedDropdownPaymentTermList(
state.paymentTermState.map,
state.paymentTermState.list)
.map((paymentTermId) {
final paymentTerm =
state.paymentTermState.map[paymentTermId]!;
return DropdownMenuItem<String>(
child: Text(paymentTerm.numDays == 0
? localization.dueOnReceipt
: paymentTerm.name),
value: paymentTerm.numDays.toString(),
);
}).toList(),
value: '${settings.defaultValidUntil}',
onChanged: (dynamic numDays) {
viewModel.onSettingsChanged(settings.rebuild((b) => b
..defaultValidUntil =
numDays == null ? null : '$numDays'));
},
),
],
),
if (!state.uiState.settingsUIState.isFiltered)
Padding(
padding:
const EdgeInsets.only(bottom: 10, left: 16, right: 16),
child: AppButton(
iconData: Icons.settings,
label: localization.configurePaymentTerms.toUpperCase(),
onPressed: () =>
viewModel.onConfigurePaymentTermsPressed(context),
),
),
if (!state.isProPlan)
FormCard(children: <Widget>[
if (company.isModuleEnabled(EntityType.invoice))
Expand Down Expand Up @@ -691,20 +624,6 @@ class _CompanyDetailsState extends State<CompanyDetails>
b..defaultPurchaseOrderDesignId = value!.id)),
),
]),
if (!state.settingsUIState.isFiltered)
FormCard(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
BoolDropdownButton(
value: company.useQuoteTermsOnConversion,
onChanged: (value) => viewModel.onCompanyChanged(
company.rebuild(
(b) => b..useQuoteTermsOnConversion = value)),
label: localization.useQuoteTerms,
helpLabel: localization.useQuoteTermsHelp,
iconData: getEntityIcon(EntityType.quote),
),
]),
FormCard(
isLast: true,
children: <Widget>[
Expand Down
9 changes: 0 additions & 9 deletions lib/ui/settings/company_details_vm.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class CompanyDetailsVM {
required this.onSavePressed,
required this.onUploadLogo,
required this.onDeleteLogo,
required this.onConfigurePaymentTermsPressed,
required this.onUploadDocuments,
});

Expand Down Expand Up @@ -141,13 +140,6 @@ class CompanyDetailsVM {
store.dispatch(UploadLogoRequest(
completer: completer, multipartFile: multipartFile, type: type));
},
onConfigurePaymentTermsPressed: (context) {
if (state.paymentTermState.list.isEmpty) {
store.dispatch(ViewSettings(section: kSettingsPaymentTermEdit));
} else {
store.dispatch(ViewSettings(section: kSettingsPaymentTerms));
}
},
onUploadDocuments: (BuildContext context,
List<MultipartFile> multipartFile, bool isPrivate) {
final completer = Completer<List<DocumentEntity>>();
Expand Down Expand Up @@ -176,6 +168,5 @@ class CompanyDetailsVM {
final Function(BuildContext) onSavePressed;
final Function(BuildContext, MultipartFile) onUploadLogo;
final Function(BuildContext) onDeleteLogo;
final Function(BuildContext) onConfigurePaymentTermsPressed;
final Function(BuildContext, List<MultipartFile>, bool) onUploadDocuments;
}
Loading

0 comments on commit 9e6a4b0

Please sign in to comment.