From 571c88a6683c87e1cd7e74915629e781e5a1dab8 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Mon, 21 Aug 2023 03:04:55 +0800 Subject: [PATCH] Refactor: move some generic widgets out of the main package --- app/lib/theme.dart | 2 +- .../widget/album_share_outlier_browser.dart | 2 +- app/lib/widget/collection_browser.dart | 2 +- app/lib/widget/collection_picker.dart | 2 +- app/lib/widget/dir_picker.dart | 2 +- app/lib/widget/home_app_bar.dart | 3 +- app/lib/widget/home_search.dart | 2 +- app/lib/widget/image_editor.dart | 2 +- .../widget/image_editor/color_toolbar.dart | 2 +- .../widget/image_editor/toolbar_button.dart | 2 +- app/lib/widget/image_enhancer.dart | 2 +- .../widget/settings/enhancement_settings.dart | 2 +- app/lib/widget/settings/photos_settings.dart | 2 +- app/lib/widget/settings/viewer_settings.dart | 2 +- app/lib/widget/sharing_browser.dart | 2 +- app/lib/widget/slideshow_dialog.dart | 2 +- app/lib/widget/slideshow_viewer.dart | 2 +- app/lib/widget/video_viewer.dart | 2 +- app/lib/widget/viewer_detail_pane.dart | 2 +- app/pubspec.lock | 7 +++++ app/pubspec.yaml | 2 ++ np_ui/.gitignore | 30 +++++++++++++++++++ np_ui/.metadata | 10 +++++++ np_ui/analysis_options.yaml | 1 + np_ui/lib/np_ui.dart | 10 +++++++ .../lib/src}/animated_visibility.dart | 11 ++++--- .../app_bar_circular_progress_indicator.dart | 0 .../lib/src}/app_bar_title_container.dart | 2 +- .../widget => np_ui/lib/src}/asset_icon.dart | 1 + .../theme => np_ui/lib/src}/material3.dart | 2 ++ .../lib/src}/stateful_slider.dart | 10 +++---- .../lib/src}/switch_form_field.dart | 0 .../lib/src}/unbounded_list_tile.dart | 4 +-- np_ui/pubspec.yaml | 16 ++++++++++ 34 files changed, 111 insertions(+), 34 deletions(-) create mode 100644 np_ui/.gitignore create mode 100644 np_ui/.metadata create mode 100644 np_ui/analysis_options.yaml create mode 100644 np_ui/lib/np_ui.dart rename {app/lib/widget => np_ui/lib/src}/animated_visibility.dart (86%) rename {app/lib/widget => np_ui/lib/src}/app_bar_circular_progress_indicator.dart (100%) rename {app/lib/widget => np_ui/lib/src}/app_bar_title_container.dart (97%) rename {app/lib/widget => np_ui/lib/src}/asset_icon.dart (92%) rename {app/lib/theme => np_ui/lib/src}/material3.dart (97%) rename {app/lib/widget => np_ui/lib/src}/stateful_slider.dart (85%) rename {app/lib/widget => np_ui/lib/src}/switch_form_field.dart (100%) rename {app/lib/widget => np_ui/lib/src}/unbounded_list_tile.dart (95%) create mode 100644 np_ui/pubspec.yaml diff --git a/app/lib/theme.dart b/app/lib/theme.dart index ef116643..ac313d8c 100644 --- a/app/lib/theme.dart +++ b/app/lib/theme.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:nc_photos/controller/pref_controller.dart'; import 'package:nc_photos/theme/dimension.dart'; -import 'package:nc_photos/theme/material3.dart'; +import 'package:np_ui/np_ui.dart'; const defaultSeedColor = Color(0xFF2196F3); diff --git a/app/lib/widget/album_share_outlier_browser.dart b/app/lib/widget/album_share_outlier_browser.dart index aae5321d..5dd650d7 100644 --- a/app/lib/widget/album_share_outlier_browser.dart +++ b/app/lib/widget/album_share_outlier_browser.dart @@ -19,10 +19,10 @@ import 'package:nc_photos/use_case/create_share.dart'; import 'package:nc_photos/use_case/remove_share.dart'; import 'package:nc_photos/widget/empty_list_indicator.dart'; import 'package:nc_photos/widget/network_thumbnail.dart'; -import 'package:nc_photos/widget/unbounded_list_tile.dart'; import 'package:np_codegen/np_codegen.dart'; import 'package:np_common/ci_string.dart'; import 'package:np_common/string_extension.dart'; +import 'package:np_ui/np_ui.dart'; part 'album_share_outlier_browser.g.dart'; diff --git a/app/lib/widget/collection_browser.dart b/app/lib/widget/collection_browser.dart index dc83847b..0c45de40 100644 --- a/app/lib/widget/collection_browser.dart +++ b/app/lib/widget/collection_browser.dart @@ -46,7 +46,6 @@ import 'package:nc_photos/use_case/archive_file.dart'; import 'package:nc_photos/use_case/inflate_file_descriptor.dart'; import 'package:nc_photos/use_case/remove.dart'; import 'package:nc_photos/widget/album_share_outlier_browser.dart'; -import 'package:nc_photos/widget/asset_icon.dart'; import 'package:nc_photos/widget/collection_picker.dart'; import 'package:nc_photos/widget/draggable_item_list.dart'; import 'package:nc_photos/widget/export_collection_dialog.dart'; @@ -63,6 +62,7 @@ import 'package:nc_photos/widget/shared_album_info_dialog.dart'; import 'package:nc_photos/widget/simple_input_dialog.dart'; import 'package:nc_photos/widget/viewer.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:sliver_tools/sliver_tools.dart'; import 'package:to_string/to_string.dart'; diff --git a/app/lib/widget/collection_picker.dart b/app/lib/widget/collection_picker.dart index 608ed9f1..fc4a7404 100644 --- a/app/lib/widget/collection_picker.dart +++ b/app/lib/widget/collection_picker.dart @@ -22,10 +22,10 @@ import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/np_api_util.dart'; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; -import 'package:nc_photos/widget/app_bar_circular_progress_indicator.dart'; import 'package:nc_photos/widget/collection_grid_item.dart'; import 'package:nc_photos/widget/new_collection_dialog.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:to_string/to_string.dart'; part 'collection_picker.g.dart'; diff --git a/app/lib/widget/dir_picker.dart b/app/lib/widget/dir_picker.dart index 6ea8537c..e705e7c5 100644 --- a/app/lib/widget/dir_picker.dart +++ b/app/lib/widget/dir_picker.dart @@ -13,8 +13,8 @@ import 'package:nc_photos/entity/file_util.dart' as file_util; import 'package:nc_photos/exception_util.dart' as exception_util; import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/snack_bar_manager.dart'; -import 'package:nc_photos/theme/material3.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:path/path.dart' as path_lib; part 'dir_picker.g.dart'; diff --git a/app/lib/widget/home_app_bar.dart b/app/lib/widget/home_app_bar.dart index 288ff149..8f17fbe1 100644 --- a/app/lib/widget/home_app_bar.dart +++ b/app/lib/widget/home_app_bar.dart @@ -7,9 +7,8 @@ import 'package:nc_photos/controller/account_controller.dart'; import 'package:nc_photos/stream_util.dart'; import 'package:nc_photos/theme.dart'; import 'package:nc_photos/widget/account_picker_dialog.dart'; -import 'package:nc_photos/widget/app_bar_circular_progress_indicator.dart'; -import 'package:nc_photos/widget/app_bar_title_container.dart'; import 'package:nc_photos/widget/translucent_sliver_app_bar.dart'; +import 'package:np_ui/np_ui.dart'; /// AppBar for home screens class HomeSliverAppBar extends StatelessWidget { diff --git a/app/lib/widget/home_search.dart b/app/lib/widget/home_search.dart index 5ae8ced7..c20f16c0 100644 --- a/app/lib/widget/home_search.dart +++ b/app/lib/widget/home_search.dart @@ -24,7 +24,6 @@ import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; import 'package:nc_photos/theme/dimension.dart'; import 'package:nc_photos/throttler.dart'; -import 'package:nc_photos/widget/animated_visibility.dart'; import 'package:nc_photos/widget/builder/photo_list_item_builder.dart'; import 'package:nc_photos/widget/handler/add_selection_to_collection_handler.dart'; import 'package:nc_photos/widget/handler/archive_selection_handler.dart'; @@ -39,6 +38,7 @@ import 'package:nc_photos/widget/selectable_item_stream_list_mixin.dart'; import 'package:nc_photos/widget/selection_app_bar.dart'; import 'package:nc_photos/widget/viewer.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; part 'home_search.g.dart'; diff --git a/app/lib/widget/image_editor.dart b/app/lib/widget/image_editor.dart index 6bcb4b8a..f4fa8067 100644 --- a/app/lib/widget/image_editor.dart +++ b/app/lib/widget/image_editor.dart @@ -16,7 +16,6 @@ import 'package:nc_photos/np_api_util.dart'; import 'package:nc_photos/object_extension.dart'; import 'package:nc_photos/pixel_image_provider.dart'; import 'package:nc_photos/theme.dart'; -import 'package:nc_photos/theme/material3.dart'; import 'package:nc_photos/url_launcher_util.dart'; import 'package:nc_photos/widget/handler/permission_handler.dart'; import 'package:nc_photos/widget/image_editor/color_toolbar.dart'; @@ -24,6 +23,7 @@ import 'package:nc_photos/widget/image_editor/crop_controller.dart'; import 'package:nc_photos/widget/image_editor/transform_toolbar.dart'; import 'package:nc_photos/widget/image_editor_persist_option_dialog.dart'; import 'package:nc_photos_plugin/nc_photos_plugin.dart'; +import 'package:np_ui/np_ui.dart'; class ImageEditorArguments { const ImageEditorArguments(this.account, this.file); diff --git a/app/lib/widget/image_editor/color_toolbar.dart b/app/lib/widget/image_editor/color_toolbar.dart index d0a9ba45..cf66ec4d 100644 --- a/app/lib/widget/image_editor/color_toolbar.dart +++ b/app/lib/widget/image_editor/color_toolbar.dart @@ -4,8 +4,8 @@ import 'package:nc_photos/double_extension.dart'; import 'package:nc_photos/iterable_extension.dart'; import 'package:nc_photos/object_extension.dart'; import 'package:nc_photos/widget/image_editor/toolbar_button.dart'; -import 'package:nc_photos/widget/stateful_slider.dart'; import 'package:nc_photos_plugin/nc_photos_plugin.dart'; +import 'package:np_ui/np_ui.dart'; enum ColorToolType { brightness, diff --git a/app/lib/widget/image_editor/toolbar_button.dart b/app/lib/widget/image_editor/toolbar_button.dart index 838efdf8..64e981d1 100644 --- a/app/lib/widget/image_editor/toolbar_button.dart +++ b/app/lib/widget/image_editor/toolbar_button.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:nc_photos/k.dart' as k; -import 'package:nc_photos/theme/material3.dart'; +import 'package:np_ui/np_ui.dart'; /// Button in the image editor toolbar /// diff --git a/app/lib/widget/image_enhancer.dart b/app/lib/widget/image_enhancer.dart index d234c80d..698a74ac 100644 --- a/app/lib/widget/image_enhancer.dart +++ b/app/lib/widget/image_enhancer.dart @@ -28,9 +28,9 @@ import 'package:nc_photos/widget/handler/permission_handler.dart'; import 'package:nc_photos/widget/image_editor_persist_option_dialog.dart'; import 'package:nc_photos/widget/selectable.dart'; import 'package:nc_photos/widget/settings/enhancement_settings.dart'; -import 'package:nc_photos/widget/stateful_slider.dart'; import 'package:nc_photos_plugin/nc_photos_plugin.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; part 'image_enhancer.g.dart'; diff --git a/app/lib/widget/settings/enhancement_settings.dart b/app/lib/widget/settings/enhancement_settings.dart index 8c30e6e6..64411c1d 100644 --- a/app/lib/widget/settings/enhancement_settings.dart +++ b/app/lib/widget/settings/enhancement_settings.dart @@ -11,8 +11,8 @@ import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/size.dart'; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/widget/page_visibility_mixin.dart'; -import 'package:nc_photos/widget/stateful_slider.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:to_string/to_string.dart'; import 'package:tuple/tuple.dart'; diff --git a/app/lib/widget/settings/photos_settings.dart b/app/lib/widget/settings/photos_settings.dart index 33d51feb..de3d9354 100644 --- a/app/lib/widget/settings/photos_settings.dart +++ b/app/lib/widget/settings/photos_settings.dart @@ -12,8 +12,8 @@ import 'package:nc_photos/exception_util.dart' as exception_util; import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/widget/page_visibility_mixin.dart'; -import 'package:nc_photos/widget/stateful_slider.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:to_string/to_string.dart'; part 'photos/bloc.dart'; diff --git a/app/lib/widget/settings/viewer_settings.dart b/app/lib/widget/settings/viewer_settings.dart index 50dfb896..1f12d6ea 100644 --- a/app/lib/widget/settings/viewer_settings.dart +++ b/app/lib/widget/settings/viewer_settings.dart @@ -13,8 +13,8 @@ import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/widget/fancy_option_picker.dart'; import 'package:nc_photos/widget/gps_map.dart'; import 'package:nc_photos/widget/page_visibility_mixin.dart'; -import 'package:nc_photos/widget/stateful_slider.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:screen_brightness/screen_brightness.dart'; import 'package:to_string/to_string.dart'; diff --git a/app/lib/widget/sharing_browser.dart b/app/lib/widget/sharing_browser.dart index fe7b80c2..18b3a927 100644 --- a/app/lib/widget/sharing_browser.dart +++ b/app/lib/widget/sharing_browser.dart @@ -25,8 +25,8 @@ import 'package:nc_photos/widget/collection_browser.dart'; import 'package:nc_photos/widget/empty_list_indicator.dart'; import 'package:nc_photos/widget/network_thumbnail.dart'; import 'package:nc_photos/widget/shared_file_viewer.dart'; -import 'package:nc_photos/widget/unbounded_list_tile.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; part 'sharing_browser.g.dart'; diff --git a/app/lib/widget/slideshow_dialog.dart b/app/lib/widget/slideshow_dialog.dart index d8228d7e..34017071 100644 --- a/app/lib/widget/slideshow_dialog.dart +++ b/app/lib/widget/slideshow_dialog.dart @@ -4,8 +4,8 @@ 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:nc_photos/widget/switch_form_field.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:to_string/to_string.dart'; part 'slideshow_dialog.g.dart'; diff --git a/app/lib/widget/slideshow_viewer.dart b/app/lib/widget/slideshow_viewer.dart index 34a69d8e..dcdb7dc2 100644 --- a/app/lib/widget/slideshow_viewer.dart +++ b/app/lib/widget/slideshow_viewer.dart @@ -8,7 +8,6 @@ import 'package:nc_photos/entity/file_descriptor.dart'; import 'package:nc_photos/entity/file_util.dart' as file_util; import 'package:nc_photos/k.dart' as k; import 'package:nc_photos/theme.dart'; -import 'package:nc_photos/widget/animated_visibility.dart'; import 'package:nc_photos/widget/disposable.dart'; import 'package:nc_photos/widget/horizontal_page_viewer.dart'; import 'package:nc_photos/widget/image_viewer.dart'; @@ -17,6 +16,7 @@ import 'package:nc_photos/widget/video_viewer.dart'; import 'package:nc_photos/widget/viewer_mixin.dart'; import 'package:nc_photos/widget/wakelock_util.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; part 'slideshow_viewer.g.dart'; diff --git a/app/lib/widget/video_viewer.dart b/app/lib/widget/video_viewer.dart index 6735d0bc..5618aa5f 100644 --- a/app/lib/widget/video_viewer.dart +++ b/app/lib/widget/video_viewer.dart @@ -15,10 +15,10 @@ import 'package:nc_photos/np_api_util.dart'; import 'package:nc_photos/platform/k.dart' as platform_k; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/use_case/request_public_link.dart'; -import 'package:nc_photos/widget/animated_visibility.dart'; import 'package:nc_photos/widget/disposable.dart'; import 'package:nc_photos/widget/wakelock_util.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:video_player/video_player.dart'; part 'video_viewer.g.dart'; diff --git a/app/lib/widget/viewer_detail_pane.dart b/app/lib/widget/viewer_detail_pane.dart index b142a84a..83ca3495 100644 --- a/app/lib/widget/viewer_detail_pane.dart +++ b/app/lib/widget/viewer_detail_pane.dart @@ -32,12 +32,12 @@ import 'package:nc_photos/use_case/inflate_file_descriptor.dart'; import 'package:nc_photos/use_case/list_file_tag.dart'; import 'package:nc_photos/use_case/update_property.dart'; import 'package:nc_photos/widget/about_geocoding_dialog.dart'; -import 'package:nc_photos/widget/animated_visibility.dart'; import 'package:nc_photos/widget/gps_map.dart'; import 'package:nc_photos/widget/handler/add_selection_to_collection_handler.dart'; import 'package:nc_photos/widget/list_tile_center_leading.dart'; import 'package:nc_photos/widget/photo_date_time_edit_dialog.dart'; import 'package:np_codegen/np_codegen.dart'; +import 'package:np_ui/np_ui.dart'; import 'package:path/path.dart' as path_lib; import 'package:tuple/tuple.dart'; diff --git a/app/pubspec.lock b/app/pubspec.lock index d6c2604c..d0f2ac92 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -983,6 +983,13 @@ packages: relative: true source: path version: "1.0.0" + np_ui: + dependency: "direct main" + description: + path: "../np_ui" + relative: true + source: path + version: "0.0.1" octo_image: dependency: "direct main" description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index cc5b6765..8580ddf1 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -105,6 +105,8 @@ dependencies: path: ../np_common np_log: path: ../np_log + np_ui: + path: ../np_ui octo_image: any page_view_indicators: ^2.0.0 path: ^1.8.0 diff --git a/np_ui/.gitignore b/np_ui/.gitignore new file mode 100644 index 00000000..96486fd9 --- /dev/null +++ b/np_ui/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/np_ui/.metadata b/np_ui/.metadata new file mode 100644 index 00000000..788b91db --- /dev/null +++ b/np_ui/.metadata @@ -0,0 +1,10 @@ +# 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 and should not be manually edited. + +version: + revision: 4d9e56e694b656610ab87fcf2efbcd226e0ed8cf + channel: stable + +project_type: package diff --git a/np_ui/analysis_options.yaml b/np_ui/analysis_options.yaml new file mode 100644 index 00000000..f92d2567 --- /dev/null +++ b/np_ui/analysis_options.yaml @@ -0,0 +1 @@ +include: package:np_lints/np.yaml diff --git a/np_ui/lib/np_ui.dart b/np_ui/lib/np_ui.dart new file mode 100644 index 00000000..19bd15d0 --- /dev/null +++ b/np_ui/lib/np_ui.dart @@ -0,0 +1,10 @@ +library np_ui; + +export 'src/animated_visibility.dart'; +export 'src/app_bar_circular_progress_indicator.dart'; +export 'src/app_bar_title_container.dart'; +export 'src/asset_icon.dart'; +export 'src/material3.dart'; +export 'src/stateful_slider.dart'; +export 'src/switch_form_field.dart'; +export 'src/unbounded_list_tile.dart'; diff --git a/app/lib/widget/animated_visibility.dart b/np_ui/lib/src/animated_visibility.dart similarity index 86% rename from app/lib/widget/animated_visibility.dart rename to np_ui/lib/src/animated_visibility.dart index 4bd5a251..c7678e0c 100644 --- a/app/lib/widget/animated_visibility.dart +++ b/np_ui/lib/src/animated_visibility.dart @@ -5,18 +5,17 @@ import 'package:flutter/widgets.dart'; /// The point is to disable non-visible buttons class AnimatedVisibility extends StatefulWidget { const AnimatedVisibility({ - Key? key, + super.key, required this.child, required this.opacity, this.curve = Curves.linear, required this.duration, this.onEnd, this.alwaysIncludeSemantics = false, - }) : assert(opacity >= 0.0 && opacity <= 1.0), - super(key: key); + }) : assert(opacity >= 0.0 && opacity <= 1.0); @override - createState() => _AnimatedVisibilityState(); + State createState() => _AnimatedVisibilityState(); final Widget child; final double opacity; @@ -28,13 +27,13 @@ class AnimatedVisibility extends StatefulWidget { class _AnimatedVisibilityState extends State { @override - initState() { + void initState() { super.initState(); _isActive = widget.opacity > 0; } @override - build(BuildContext context) { + Widget build(BuildContext context) { if (!_isActive && widget.opacity > 0) { _isActive = true; } diff --git a/app/lib/widget/app_bar_circular_progress_indicator.dart b/np_ui/lib/src/app_bar_circular_progress_indicator.dart similarity index 100% rename from app/lib/widget/app_bar_circular_progress_indicator.dart rename to np_ui/lib/src/app_bar_circular_progress_indicator.dart diff --git a/app/lib/widget/app_bar_title_container.dart b/np_ui/lib/src/app_bar_title_container.dart similarity index 97% rename from app/lib/widget/app_bar_title_container.dart rename to np_ui/lib/src/app_bar_title_container.dart index 00bc3d87..0ba3b8b3 100644 --- a/app/lib/widget/app_bar_title_container.dart +++ b/np_ui/lib/src/app_bar_title_container.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:nc_photos/theme/material3.dart'; +import 'package:np_ui/src/material3.dart'; /// App bar title with optional subtitle and leading icon class AppBarTitleContainer extends StatelessWidget { diff --git a/app/lib/widget/asset_icon.dart b/np_ui/lib/src/asset_icon.dart similarity index 92% rename from app/lib/widget/asset_icon.dart rename to np_ui/lib/src/asset_icon.dart index 32beec2c..8ccbd411 100644 --- a/app/lib/widget/asset_icon.dart +++ b/np_ui/lib/src/asset_icon.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; +/// Icon using an image in asset class AssetIcon extends StatelessWidget { const AssetIcon( this.assetName, { diff --git a/app/lib/theme/material3.dart b/np_ui/lib/src/material3.dart similarity index 97% rename from app/lib/theme/material3.dart rename to np_ui/lib/src/material3.dart index 55b9a2f8..08df5737 100644 --- a/app/lib/theme/material3.dart +++ b/np_ui/lib/src/material3.dart @@ -1,5 +1,7 @@ import 'package:flutter/material.dart'; +/// Material 3 theming support to provide features not yet supported natively +/// in Flutter class M3 extends ThemeExtension { const M3({ required this.checkbox, diff --git a/app/lib/widget/stateful_slider.dart b/np_ui/lib/src/stateful_slider.dart similarity index 85% rename from app/lib/widget/stateful_slider.dart rename to np_ui/lib/src/stateful_slider.dart index 68d45d34..4d249184 100644 --- a/app/lib/widget/stateful_slider.dart +++ b/np_ui/lib/src/stateful_slider.dart @@ -3,16 +3,16 @@ import 'package:flutter/material.dart'; /// Slider with state class StatefulSlider extends StatefulWidget { const StatefulSlider({ - Key? key, + super.key, required this.initialValue, this.min = 0.0, this.max = 1.0, this.divisions, this.onChangeEnd, - }) : super(key: key); + }); @override - createState() => _StatefulSliderState(); + State createState() => _StatefulSliderState(); final double initialValue; final double min; @@ -23,13 +23,13 @@ class StatefulSlider extends StatefulWidget { class _StatefulSliderState extends State { @override - initState() { + void initState() { super.initState(); _value = widget.initialValue; } @override - build(BuildContext context) { + Widget build(BuildContext context) { return Slider( value: _value, min: widget.min, diff --git a/app/lib/widget/switch_form_field.dart b/np_ui/lib/src/switch_form_field.dart similarity index 100% rename from app/lib/widget/switch_form_field.dart rename to np_ui/lib/src/switch_form_field.dart diff --git a/app/lib/widget/unbounded_list_tile.dart b/np_ui/lib/src/unbounded_list_tile.dart similarity index 95% rename from app/lib/widget/unbounded_list_tile.dart rename to np_ui/lib/src/unbounded_list_tile.dart index 90c45410..657758f1 100644 --- a/app/lib/widget/unbounded_list_tile.dart +++ b/np_ui/lib/src/unbounded_list_tile.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:nc_photos/theme/material3.dart'; +import 'package:np_ui/src/material3.dart'; /// A [ListTile]-like widget with unbounded height class UnboundedListTile extends StatelessWidget { @@ -13,7 +13,7 @@ class UnboundedListTile extends StatelessWidget { }) : super(key: key); @override - build(BuildContext context) { + Widget build(BuildContext context) { final content = Padding( padding: const EdgeInsets.all(16), child: Row( diff --git a/np_ui/pubspec.yaml b/np_ui/pubspec.yaml new file mode 100644 index 00000000..db28288e --- /dev/null +++ b/np_ui/pubspec.yaml @@ -0,0 +1,16 @@ +name: np_ui +description: Generic UI widgets and theming support package +version: 0.0.1 +publish_to: none + +environment: + sdk: '>=2.19.6 <3.0.0' + flutter: ">=3.3.0" + +dependencies: + flutter: + sdk: flutter + +dev_dependencies: + np_lints: + path: ../np_lints