Skip to content

Commit

Permalink
Flutter upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
hillelcoren committed Oct 10, 2023
1 parent d05e98d commit 1285522
Show file tree
Hide file tree
Showing 37 changed files with 358 additions and 246 deletions.
16 changes: 8 additions & 8 deletions .metadata
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: c07f7888888435fd9df505aa2efc38d3cf65681b
channel: stable
revision: "ead455963c12b453cdb2358cad34969c76daf180"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b
base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b
- platform: linux
create_revision: c07f7888888435fd9df505aa2efc38d3cf65681b
base_revision: c07f7888888435fd9df505aa2efc38d3cf65681b
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
- platform: windows
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180

# User provided section

Expand Down
8 changes: 3 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
# in sync with this file.

analyzer:
strong-mode:
implicit-dynamic: false
errors:
# https://github.com/flutter/flutter/issues/41563#issuecomment-686481533
undefined_prefixed_name: ignore
Expand Down Expand Up @@ -51,7 +49,7 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
- always_require_non_null_named_parameters
# - always_require_non_null_named_parameters # deprecated
# - always_specify_types # not support by built_value
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
Expand Down Expand Up @@ -92,11 +90,11 @@ linter:
# hash_and_equals # For built_value memoized hash
- implementation_imports
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
- iterable_contains_unrelated_type
# - iterable_contains_unrelated_type # deprecated
# - join_return_with_assignment # not yet tested
- library_names
- library_prefixes
- list_remove_unrelated_type
# - list_remove_unrelated_type # deprecated
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
- no_adjacent_strings_in_list
- no_duplicate_case_values
Expand Down
12 changes: 6 additions & 6 deletions lib/data/models/entities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class UserPermission extends EnumClass {
static UserPermission valueOf(String name) => _$permissionValueOf(name);
}

abstract class EntityStatus {
abstract mixin class EntityStatus {
String get id;

String get name;
Expand Down Expand Up @@ -352,7 +352,7 @@ class EntityStats {
}
}

abstract class SelectableEntity {
abstract mixin class SelectableEntity {
String get id;

bool matchesFilter(String? filter) => true;
Expand All @@ -376,7 +376,7 @@ class EntityFields {
static const String isDeleted = 'is_deleted';
}

abstract class BaseEntity implements SelectableEntity {
abstract mixin class BaseEntity implements SelectableEntity {
static int counter = 0;

static String get nextId => '${--counter}';
Expand Down Expand Up @@ -534,7 +534,7 @@ abstract class BaseEntity implements SelectableEntity {
}
}

abstract class HasActivities {
abstract mixin class HasActivities {
BuiltList<ActivityEntity> get activities;

Iterable<ActivityEntity> getActivities({String? invoiceId, String? typeId}) {
Expand All @@ -550,11 +550,11 @@ abstract class HasActivities {
}
}

abstract class BelongsToClient {
abstract mixin class BelongsToClient {
String? get clientId;
}

abstract class BelongsToVendor {
abstract mixin class BelongsToVendor {
String get vendorId;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/data/models/mixins/invoice_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:built_collection/built_collection.dart';
import 'package:invoiceninja_flutter/data/models/invoice_model.dart';
import 'package:invoiceninja_flutter/utils/formatting.dart';

abstract class CalculateInvoiceTotal {
abstract mixin class CalculateInvoiceTotal {
bool get isAmountDiscount;

String get taxName1;
Expand Down
4 changes: 2 additions & 2 deletions lib/data/models/task_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,13 @@ abstract class TaskEntity extends Object
if (taskItem[0] == false || taskItem[0] == null) {
startDate = 0;
} else {
startDate = (taskItem[0]).round();
startDate = taskItem[0].round();
}

if (taskItem[1] == false || taskItem[1] == null) {
endDate = 0;
} else {
endDate = (taskItem[1]).round();
endDate = taskItem[1].round();
}

final taskTime = TaskTime(
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ void main({bool isTesting = false}) async {

event = event.copyWith(
environment: '${store.state.environment}'.split('.').last,
/*
extra: <String, dynamic>{
'server_version': account.currentVersion,
'route': state.uiState.currentRoute,
},
*/
);

return event;
Expand Down
13 changes: 5 additions & 8 deletions lib/main_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,6 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
void initState() {
super.initState();

final window = WidgetsBinding.instance.window;
window.onPlatformBrightnessChanged = () {
WidgetsBinding.instance.handlePlatformBrightnessChanged();
widget.store!.dispatch(UpdateUserPreferences(
enableDarkModeSystem: window.platformBrightness == Brightness.dark));
setState(() {});
};

if (kIsWeb) {
WebUtils.warnChanges(widget.store);
}
Expand Down Expand Up @@ -235,6 +227,11 @@ class InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
if (state.prefState.requireAuthentication && !_authenticated) {
_authenticate();
}

final brightness = MediaQuery.of(context).platformBrightness;
widget.store!.dispatch(UpdateUserPreferences(
enableDarkModeSystem: brightness == Brightness.dark));

super.didChangeDependencies();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/redux/auth/auth_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ Middleware<AppState> _createRefreshRequest(AuthRepository repository) {

String token;
bool hasToken = false;
if ((state.userCompany.token.token).isNotEmpty) {
if (state.userCompany.token.token.isNotEmpty) {
token = state.userCompany.token.token;
hasToken = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/redux/task/task_selectors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ List<String?> taskList(
final list = taskMap.keys.where((taskId) {
final task = taskMap[taskId];
if ((clientId ?? '').isNotEmpty &&
(task!.clientId).isNotEmpty &&
task!.clientId.isNotEmpty &&
task.clientId != clientId) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/redux/ui/entity_ui_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:built_value/built_value.dart';
import 'package:invoiceninja_flutter/data/models/entities.dart';
import 'package:invoiceninja_flutter/redux/ui/list_ui_state.dart';

abstract class EntityUIState {
abstract mixin class EntityUIState {
bool get isCreatingNew;

String get editingId;
Expand Down
7 changes: 6 additions & 1 deletion lib/ui/app/app_webview.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Dart imports:
import 'dart:convert';

// Flutter imports:
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -59,12 +58,17 @@ class _MobileWebViewState extends State<_MobileWebView>
super.didUpdateWidget(oldWidget);

if (widget.html != oldWidget.html) {
_webViewController.loadHtmlString(widget.html!);

/*
_webViewController.loadUrl(Uri.dataFromString(widget.html!,
mimeType: 'text/html', encoding: Encoding.getByName('utf-8'))
.toString());
*/
}
}

/*
@override
Widget build(BuildContext context) {
super.build(context);
Expand All @@ -79,4 +83,5 @@ class _MobileWebViewState extends State<_MobileWebView>
javascriptMode: JavascriptMode.disabled,
);
}
*/
}
28 changes: 15 additions & 13 deletions lib/ui/app/copy_to_clipboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,23 @@ class CopyToClipboard extends StatelessWidget {
)
: child;
final localization = AppLocalization.of(context);
final onTap = () {
Clipboard.setData(ClipboardData(text: value));
final onTap = value == null
? null
: () {
Clipboard.setData(ClipboardData(text: value!));

var valueStr = value!.replaceAll('\n', ' ');
if (value!.length > 20) {
valueStr = value!.substring(0, 20) + '...';
}
var valueStr = value!.replaceAll('\n', ' ');
if (value!.length > 20) {
valueStr = value!.substring(0, 20) + '...';
}

showToast(
localization!.copiedToClipboard.replaceFirst(
':value',
'"$valueStr"',
),
);
};
showToast(
localization!.copiedToClipboard.replaceFirst(
':value',
'"$valueStr"',
),
);
};

if (showBorder) {
return ConstrainedBox(
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/app/invoice/invoice_email_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
return EditScaffold(
entity: invoice,
title: localization!.sendEmail,
onCancelPressed: (context) => viewEntity(entity: invoice!),
onCancelPressed: (context) => viewEntity(entity: invoice),
saveLabel: localization.send,
onSavePressed: (context) {
if (state!.account.accountSmsVerified || state.isSelfHosted) {
Expand Down Expand Up @@ -522,7 +522,7 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
child: EditScaffold(
entity: invoice,
title: localization!.sendEmail,
onCancelPressed: (context) => viewEntity(entity: invoice!),
onCancelPressed: (context) => viewEntity(entity: invoice),
appBarBottom: TabBar(
controller: _controller,
isScrollable: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/app/lists/app_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AppListTile extends StatelessWidget {
return;
}

Clipboard.setData(ClipboardData(text: copyValue ?? title));
Clipboard.setData(ClipboardData(text: copyValue ?? title ?? ''));
showToast(AppLocalization.of(context)!
.copiedToClipboard
.replaceFirst(':value', copyValue ?? title!));
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/app/menu_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class _MenuDrawerState extends State<MenuDrawer> {
items: [
...state.companies
.map((CompanyEntity company) => DropdownMenuItem<String>(
value: (state.companies.indexOf(company)).toString(),
value: state.companies.indexOf(company).toString(),
child: _companyListItem(company)))
.toList(),
if (state.canAddCompany)
Expand Down
3 changes: 3 additions & 0 deletions lib/ui/app/tables/app_data_table.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Expand Down Expand Up @@ -1003,3 +1004,5 @@ class _NullWidget extends Widget {
@override
Element createElement() => throw UnimplementedError();
}
*/
2 changes: 2 additions & 0 deletions lib/ui/app/tables/app_data_table_source.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Expand Down Expand Up @@ -63,3 +64,4 @@ abstract class AppDataTableSource extends ChangeNotifier {
/// If the selected row count changes, call [notifyListeners].
int get selectedRowCount;
}
*/
2 changes: 2 additions & 0 deletions lib/ui/app/tables/app_paginated_data_table.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
Expand Down Expand Up @@ -518,3 +519,4 @@ class AppPaginatedDataTableState extends State<AppPaginatedDataTable> {
);
}
}
*/
10 changes: 4 additions & 6 deletions lib/ui/app/tables/entity_datatable.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Flutter imports:
import 'package:flutter/material.dart' hide DataRow, DataCell, DataColumn;

// Package imports:
import 'package:built_collection/built_collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';

Expand All @@ -14,13 +14,11 @@ import 'package:invoiceninja_flutter/redux/app/app_state.dart';
import 'package:invoiceninja_flutter/redux/ui/pref_state.dart';
import 'package:invoiceninja_flutter/ui/app/actions_menu_button.dart';
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
import 'package:invoiceninja_flutter/ui/app/tables/app_data_table.dart';
import 'package:invoiceninja_flutter/ui/app/tables/app_data_table_source.dart';
import 'package:invoiceninja_flutter/utils/colors.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:invoiceninja_flutter/utils/platforms.dart';

class EntityDataTableSource extends AppDataTableSource {
class EntityDataTableSource extends DataTableSource {
EntityDataTableSource(
{required this.context,
required this.editingId,
Expand Down Expand Up @@ -129,7 +127,7 @@ class EntityDataTableSource extends AppDataTableSource {
],
),
onTap: () => onTap(entity),
backgroundColor: backgroundColor,
//backgroundColor: backgroundColor,
),
...tableColumns!.map(
(field) => DataCell(
Expand All @@ -146,7 +144,7 @@ class EntityDataTableSource extends AppDataTableSource {
),
onTap: () => onTap(entity),
//onLongPress: () => selectEntity(entity: entity, context: context, longPress: true),
backgroundColor: backgroundColor,
//backgroundColor: backgroundColor,
),
)
],
Expand Down
Loading

0 comments on commit 1285522

Please sign in to comment.