diff --git a/app/lib/list_extension.dart b/app/lib/list_extension.dart index a2452b02..7b7fa674 100644 --- a/app/lib/list_extension.dart +++ b/app/lib/list_extension.dart @@ -1,7 +1,7 @@ import 'dart:math' as math; import 'package:collection/collection.dart'; -import 'package:nc_photos/int_extension.dart'; +import 'package:np_math/np_math.dart'; extension ListExtension on List { Iterable takeIndex(List indexes) => indexes.map((e) => this[e]); diff --git a/app/lib/reverse_geocoder.dart b/app/lib/reverse_geocoder.dart index 5b7133b3..0295e7e4 100644 --- a/app/lib/reverse_geocoder.dart +++ b/app/lib/reverse_geocoder.dart @@ -4,10 +4,10 @@ import 'package:collection/collection.dart'; import 'package:kdtree/kdtree.dart'; import 'package:logging/logging.dart'; import 'package:nc_photos/entity/file.dart'; -import 'package:nc_photos/math_util.dart' as math_util; import 'package:nc_photos/mobile/platform.dart' if (dart.library.html) 'package:nc_photos/web/platform.dart' as platform; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_math/np_math.dart'; import 'package:sqlite3/common.dart'; import 'package:to_string/to_string.dart'; @@ -58,10 +58,10 @@ class ReverseGeocoder { _log.info("[call] Nearest point, (lat: $nearestLatF, lng: $nearestLngF)"); try { final distance = _distanceInKm( - math_util.degToRad(latitude), - math_util.degToRad(longitude), - math_util.degToRad(nearestLatF), - math_util.degToRad(nearestLngF), + degToRad(latitude), + degToRad(longitude), + degToRad(nearestLatF), + degToRad(nearestLngF), ); _log.info( "[call] (lat: ${latitude.toStringAsFixed(3)}, lng: ${longitude.toStringAsFixed(3)}) <-> (lat: $nearestLatF, lng: $nearestLngF) = ${distance.toStringAsFixed(3)}km"); diff --git a/app/lib/throttler.dart b/app/lib/throttler.dart index 9aeb6779..4f54c604 100644 --- a/app/lib/throttler.dart +++ b/app/lib/throttler.dart @@ -2,8 +2,8 @@ import 'dart:async'; import 'dart:math' as math; import 'package:logging/logging.dart'; -import 'package:nc_photos/int_util.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_math/np_math.dart'; part 'throttler.g.dart'; diff --git a/app/lib/widget/photo_date_time_edit_dialog.dart b/app/lib/widget/photo_date_time_edit_dialog.dart index b307c5fb..be7dcdb3 100644 --- a/app/lib/widget/photo_date_time_edit_dialog.dart +++ b/app/lib/widget/photo_date_time_edit_dialog.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:nc_photos/app_localizations.dart'; -import 'package:nc_photos/num_extension.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_math/np_math.dart'; part 'photo_date_time_edit_dialog.g.dart'; diff --git a/app/lib/widget/slideshow_dialog.dart b/app/lib/widget/slideshow_dialog.dart index 34017071..228f3046 100644 --- a/app/lib/widget/slideshow_dialog.dart +++ b/app/lib/widget/slideshow_dialog.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:logging/logging.dart'; import 'package:nc_photos/app_localizations.dart'; import 'package:nc_photos/k.dart' as k; -import 'package:nc_photos/num_extension.dart'; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_math/np_math.dart'; import 'package:np_ui/np_ui.dart'; import 'package:to_string/to_string.dart'; diff --git a/app/pubspec.lock b/app/pubspec.lock index d0f2ac92..8c9b36cf 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -983,6 +983,13 @@ packages: relative: true source: path version: "1.0.0" + np_math: + dependency: "direct main" + description: + path: "../np_math" + relative: true + source: path + version: "1.0.0" np_ui: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 8580ddf1..1386c4cd 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -105,6 +105,8 @@ dependencies: path: ../np_common np_log: path: ../np_log + np_math: + path: ../np_math np_ui: path: ../np_ui octo_image: any diff --git a/app/test/entity/file/file_cache_manager_test.dart b/app/test/entity/file/file_cache_manager_test.dart index 4f11798b..07b3d7d5 100644 --- a/app/test/entity/file/file_cache_manager_test.dart +++ b/app/test/entity/file/file_cache_manager_test.dart @@ -3,9 +3,9 @@ import 'package:nc_photos/entity/file.dart'; import 'package:nc_photos/entity/file/data_source.dart'; import 'package:nc_photos/entity/file/file_cache_manager.dart'; import 'package:nc_photos/entity/sqlite/database.dart' as sql; -import 'package:nc_photos/int_extension.dart'; import 'package:nc_photos/list_extension.dart'; import 'package:np_common/or_null.dart'; +import 'package:np_math/np_math.dart'; import 'package:test/test.dart'; import '../../mock_type.dart'; diff --git a/app/test/iterable_extension_test.dart b/app/test/iterable_extension_test.dart index e7279884..c94cb705 100644 --- a/app/test/iterable_extension_test.dart +++ b/app/test/iterable_extension_test.dart @@ -1,5 +1,5 @@ -import 'package:nc_photos/int_extension.dart'; import 'package:nc_photos/iterable_extension.dart'; +import 'package:np_math/np_math.dart'; import 'package:quiver/core.dart'; import 'package:test/test.dart'; import 'package:tuple/tuple.dart'; diff --git a/np_math/.gitignore b/np_math/.gitignore new file mode 100644 index 00000000..3cceda55 --- /dev/null +++ b/np_math/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock diff --git a/np_math/analysis_options.yaml b/np_math/analysis_options.yaml new file mode 100644 index 00000000..f92d2567 --- /dev/null +++ b/np_math/analysis_options.yaml @@ -0,0 +1 @@ +include: package:np_lints/np.yaml diff --git a/np_math/lib/np_math.dart b/np_math/lib/np_math.dart new file mode 100644 index 00000000..6f27d671 --- /dev/null +++ b/np_math/lib/np_math.dart @@ -0,0 +1,6 @@ +library np_math; + +export 'src/int_extension.dart'; +export 'src/int_util.dart'; +export 'src/math_util.dart'; +export 'src/num_extension.dart'; diff --git a/app/lib/int_extension.dart b/np_math/lib/src/int_extension.dart similarity index 100% rename from app/lib/int_extension.dart rename to np_math/lib/src/int_extension.dart diff --git a/app/lib/int_util.dart b/np_math/lib/src/int_util.dart similarity index 100% rename from app/lib/int_util.dart rename to np_math/lib/src/int_util.dart diff --git a/app/lib/math_util.dart b/np_math/lib/src/math_util.dart similarity index 100% rename from app/lib/math_util.dart rename to np_math/lib/src/math_util.dart diff --git a/app/lib/num_extension.dart b/np_math/lib/src/num_extension.dart similarity index 100% rename from app/lib/num_extension.dart rename to np_math/lib/src/num_extension.dart diff --git a/np_math/pubspec.yaml b/np_math/pubspec.yaml new file mode 100644 index 00000000..d95ef7ef --- /dev/null +++ b/np_math/pubspec.yaml @@ -0,0 +1,13 @@ +name: np_math +description: A starting point for Dart libraries or applications. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo +publish_to: none + +environment: + sdk: '>=2.19.6 <3.0.0' + +dev_dependencies: + np_lints: + path: ../np_lints + test: ^1.21.0 diff --git a/app/test/int_extension_test.dart b/np_math/test/int_extension_test.dart similarity index 96% rename from app/test/int_extension_test.dart rename to np_math/test/int_extension_test.dart index de01689e..59db9c0f 100644 --- a/app/test/int_extension_test.dart +++ b/np_math/test/int_extension_test.dart @@ -1,4 +1,4 @@ -import 'package:nc_photos/int_extension.dart'; +import 'package:np_math/src/int_extension.dart'; import 'package:test/test.dart'; void main() { diff --git a/app/test/math_util_test.dart b/np_math/test/math_util_test.dart similarity index 51% rename from app/test/math_util_test.dart rename to np_math/test/math_util_test.dart index a11773f9..4e5d835c 100644 --- a/app/test/math_util_test.dart +++ b/np_math/test/math_util_test.dart @@ -1,15 +1,15 @@ import 'dart:math' as math; -import 'package:nc_photos/math_util.dart' as math_util; +import 'package:np_math/src/math_util.dart'; import 'package:test/test.dart'; void main() { group("math_util", () { test("degToRad", () { - expect(math_util.degToRad(90), closeTo(1.570796, 1e-6)); + expect(degToRad(90), closeTo(1.570796, 1e-6)); }); test("radToDeg", () { - expect(math_util.radToDeg(math.pi), 180); + expect(radToDeg(math.pi), 180); }); }); } diff --git a/app/test/num_extension_test.dart b/np_math/test/num_extension_test.dart similarity index 97% rename from app/test/num_extension_test.dart rename to np_math/test/num_extension_test.dart index 59b4e8cb..88c1a3f3 100644 --- a/app/test/num_extension_test.dart +++ b/np_math/test/num_extension_test.dart @@ -1,4 +1,4 @@ -import 'package:nc_photos/num_extension.dart'; +import 'package:np_math/src/num_extension.dart'; import 'package:test/test.dart'; void main() {