Rerfactor: extract widget

This commit is contained in:
Ming Ming 2024-08-10 19:13:56 +08:00
parent 06b2c2189b
commit d1d77ab2d2
17 changed files with 57 additions and 34 deletions

View file

@ -12,6 +12,7 @@ import 'package:nc_photos/help_utils.dart' as help_utils;
import 'package:nc_photos/legacy/connect.dart';
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/url_launcher_util.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/home.dart';
import 'package:nc_photos/widget/root_picker.dart';
import 'package:np_codegen/np_codegen.dart';
@ -52,7 +53,7 @@ class _SignInState extends State<SignIn> {
child: SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
),
),
),

View file

@ -14,6 +14,7 @@ import 'package:nc_photos/entity/share/data_source.dart';
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/use_case/create_share.dart';
import 'package:nc_photos/use_case/remove_share.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/empty_list_indicator.dart';
import 'package:nc_photos/widget/network_thumbnail.dart';
import 'package:np_codegen/np_codegen.dart';
@ -291,7 +292,7 @@ class _AlbumShareOutlierBrowserState extends State<AlbumShareOutlierBrowser> {
child: SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
),
);
}

View file

@ -0,0 +1,16 @@
import 'package:flutter/material.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
class AppBarProgressIndicator extends StatelessWidget {
const AppBarProgressIndicator({super.key});
@override
Widget build(BuildContext context) {
return const Center(
child: SizedBox.square(
dimension: 24,
child: AppIntermediateCircularProgressIndicator(),
),
);
}
}

View file

@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class AppIntermediateCircularProgressIndicator extends StatelessWidget {
const AppIntermediateCircularProgressIndicator({super.key});
@override
Widget build(BuildContext context) {
return const CircularProgressIndicator();
}
}

View file

@ -42,6 +42,7 @@ import 'package:nc_photos/object_extension.dart';
import 'package:nc_photos/session_storage.dart';
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/widget/album_share_outlier_browser.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.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';
@ -331,7 +332,7 @@ class _WrappedCollectionBrowserState extends State<_WrappedCollectionBrowser>
return Container(
color: Colors.black.withOpacity(.5),
alignment: Alignment.center,
child: const CircularProgressIndicator(),
child: const AppIntermediateCircularProgressIndicator(),
);
} else {
return const SizedBox.shrink();

View file

@ -21,10 +21,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';
@ -148,8 +148,7 @@ class _AppBar extends StatelessWidget {
builder: (context, state) => SliverAppBar(
title: Text(L10n.global().addItemToCollectionTooltip),
floating: true,
leading:
state.isLoading ? const AppBarCircularProgressIndicator() : null,
leading: state.isLoading ? const AppBarProgressIndicator() : null,
),
);
}

View file

@ -8,6 +8,7 @@ import 'package:nc_photos/controller/account_pref_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:np_ui/np_ui.dart';
/// AppBar for home screens
@ -131,7 +132,7 @@ class _ProfileIconView extends StatelessWidget {
child: Stack(
children: [
isProcessing
? const AppBarCircularProgressIndicator()
? const AppBarProgressIndicator()
: ClipRRect(
borderRadius: BorderRadius.circular(_size / 2),
child: CachedNetworkImage(

View file

@ -8,6 +8,7 @@ import 'package:nc_photos/entity/file_util.dart' as file_util;
import 'package:nc_photos/entity/local_file.dart';
import 'package:nc_photos/share_handler.dart';
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/handler/delete_local_selection_handler.dart';
import 'package:nc_photos/widget/horizontal_page_viewer.dart';
import 'package:nc_photos/widget/image_viewer.dart';
@ -83,7 +84,7 @@ class _LocalFileViewerState extends State<LocalFileViewer> {
!_pageStates[_viewerController.currentPage]!.hasLoaded)
const Align(
alignment: Alignment.center,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
),
HorizontalPageViewer(
pageCount: widget.streamFiles.length,

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
class ProcessingDialog extends StatelessWidget {
const ProcessingDialog({
@ -14,7 +15,7 @@ class ProcessingDialog extends StatelessWidget {
content: Row(
mainAxisSize: MainAxisSize.min,
children: [
const CircularProgressIndicator(),
const AppIntermediateCircularProgressIndicator(),
const SizedBox(width: 24),
Text(text),
],

View file

@ -23,6 +23,7 @@ import 'package:nc_photos/stream_util.dart';
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/url_launcher_util.dart';
import 'package:nc_photos/use_case/list_location_group.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/collection_browser.dart';
import 'package:nc_photos/widget/network_thumbnail.dart';
import 'package:nc_photos/widget/people_browser.dart';
@ -242,7 +243,9 @@ class _PeopleSection extends StatelessWidget {
if (state.isPersonsLoading) {
return const SizedBox(
height: 48,
child: Center(child: CircularProgressIndicator()),
child: Center(
child: AppIntermediateCircularProgressIndicator(),
),
);
} else {
if (state.transformedPersonItems.isEmpty) {
@ -324,7 +327,9 @@ class _PlaceSection extends StatelessWidget {
if (state.isPlacesLoading) {
return const SizedBox(
height: 48,
child: Center(child: CircularProgressIndicator()),
child: Center(
child: AppIntermediateCircularProgressIndicator(),
),
);
} else {
if (state.transformedPlaceItems.isEmpty) {

View file

@ -22,6 +22,7 @@ import 'package:nc_photos/exception_util.dart' as exception_util;
import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/suggester.dart';
import 'package:nc_photos/toast.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:np_codegen/np_codegen.dart';
import 'package:np_string/np_string.dart';
import 'package:to_string/to_string.dart';
@ -221,7 +222,7 @@ class _ShareView extends StatelessWidget {
child: SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
),
);
} else {

View file

@ -11,6 +11,7 @@ import 'package:nc_photos/entity/pref.dart';
import 'package:nc_photos/entity/pref_util.dart' as pref_util;
import 'package:nc_photos/legacy/sign_in.dart' as legacy;
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/connect.dart';
import 'package:nc_photos/widget/home.dart';
import 'package:nc_photos/widget/root_picker.dart';
@ -70,7 +71,7 @@ class _SignInState extends State<SignIn> {
child: SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
),
),
),

View file

@ -16,6 +16,7 @@ import 'package:nc_photos/protected_page_handler.dart';
import 'package:nc_photos/use_case/compat/v29.dart';
import 'package:nc_photos/use_case/compat/v46.dart';
import 'package:nc_photos/use_case/compat/v55.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/changelog.dart';
import 'package:nc_photos/widget/home.dart';
import 'package:nc_photos/widget/setup.dart';
@ -118,7 +119,7 @@ class _SplashState extends State<Splash> {
const SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
)
else
LinearProgressIndicator(

View file

@ -16,6 +16,7 @@ import 'package:nc_photos/k.dart' as k;
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/use_case/restore_trashbin.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/handler/remove_selection_handler.dart';
import 'package:nc_photos/widget/horizontal_page_viewer.dart';
import 'package:nc_photos/widget/image_viewer.dart';
@ -90,7 +91,7 @@ class _TrashbinViewerState extends State<TrashbinViewer> {
!_pageStates[_viewerController.currentPage]!.hasLoaded)
const Align(
alignment: Alignment.center,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
),
HorizontalPageViewer(
pageCount: widget.streamFiles.length,

View file

@ -30,6 +30,7 @@ import 'package:nc_photos/platform/features.dart' as features;
import 'package:nc_photos/share_handler.dart';
import 'package:nc_photos/snack_bar_manager.dart';
import 'package:nc_photos/theme.dart';
import 'package:nc_photos/widget/app_intermediate_circular_progress_indicator.dart';
import 'package:nc_photos/widget/disposable.dart';
import 'package:nc_photos/widget/handler/remove_selection_handler.dart';
import 'package:nc_photos/widget/horizontal_page_viewer.dart';
@ -158,7 +159,7 @@ class _ViewerState extends State<Viewer>
_pageStates[_viewerController.currentPage]?.hasLoaded != true)
const Align(
alignment: Alignment.center,
child: CircularProgressIndicator(),
child: AppIntermediateCircularProgressIndicator(),
),
HorizontalPageViewer(
key: _pageViewerKey,

View file

@ -1,7 +1,6 @@
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/fancy_option_picker.dart';

View file

@ -1,17 +0,0 @@
import 'package:flutter/material.dart';
class AppBarCircularProgressIndicator extends StatelessWidget {
const AppBarCircularProgressIndicator({super.key});
@override
Widget build(BuildContext context) {
return const Center(
child: SizedBox.square(
dimension: 24,
child: CircularProgressIndicator(
strokeWidth: 3,
),
),
);
}
}