mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Refactor: extract widget to center ListTile icon
This commit is contained in:
parent
4c88070a7e
commit
83449fa676
4 changed files with 36 additions and 18 deletions
24
lib/widget/list_tile_center_leading.dart
Normal file
24
lib/widget/list_tile_center_leading.dart
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// Center leading widget in ListTile
|
||||||
|
///
|
||||||
|
/// Leading widget in ListTile used to center align vertically, but it was
|
||||||
|
/// changed in an update later. This widget revert to the old behavior
|
||||||
|
///
|
||||||
|
/// This widget is only needed when the content of the ListTile may grow more
|
||||||
|
/// than 1 line
|
||||||
|
class ListTileCenterLeading extends StatelessWidget {
|
||||||
|
const ListTileCenterLeading({
|
||||||
|
Key? key,
|
||||||
|
required this.child,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
build(BuildContext context) => SizedBox(
|
||||||
|
height: double.infinity,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/widget/fancy_option_picker.dart';
|
import 'package:nc_photos/widget/fancy_option_picker.dart';
|
||||||
import 'package:nc_photos/widget/gps_map.dart';
|
import 'package:nc_photos/widget/gps_map.dart';
|
||||||
import 'package:nc_photos/widget/home.dart';
|
import 'package:nc_photos/widget/home.dart';
|
||||||
|
import 'package:nc_photos/widget/list_tile_center_leading.dart';
|
||||||
import 'package:nc_photos/widget/root_picker.dart';
|
import 'package:nc_photos/widget/root_picker.dart';
|
||||||
import 'package:nc_photos/widget/share_folder_picker.dart';
|
import 'package:nc_photos/widget/share_folder_picker.dart';
|
||||||
import 'package:nc_photos/widget/stateful_slider.dart';
|
import 'package:nc_photos/widget/stateful_slider.dart';
|
||||||
|
@ -212,8 +213,7 @@ class _SettingsState extends State<Settings> {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: leading == null
|
leading: leading == null
|
||||||
? null
|
? null
|
||||||
: SizedBox(
|
: ListTileCenterLeading(
|
||||||
height: double.infinity,
|
|
||||||
child: leading,
|
child: leading,
|
||||||
),
|
),
|
||||||
title: Text(label),
|
title: Text(label),
|
||||||
|
|
|
@ -21,6 +21,7 @@ import 'package:nc_photos/snack_bar_manager.dart';
|
||||||
import 'package:nc_photos/theme.dart';
|
import 'package:nc_photos/theme.dart';
|
||||||
import 'package:nc_photos/use_case/remove.dart';
|
import 'package:nc_photos/use_case/remove.dart';
|
||||||
import 'package:nc_photos/use_case/remove_share.dart';
|
import 'package:nc_photos/use_case/remove_share.dart';
|
||||||
|
import 'package:nc_photos/widget/list_tile_center_leading.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
class SharedFileViewerArguments {
|
class SharedFileViewerArguments {
|
||||||
|
@ -158,8 +159,7 @@ class _SharedFileViewerState extends State<SharedFileViewer> {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(_getShareTitle(share)),
|
title: Text(_getShareTitle(share)),
|
||||||
subtitle: Text(dateStr),
|
subtitle: Text(dateStr),
|
||||||
leading: SizedBox(
|
leading: ListTileCenterLeading(
|
||||||
height: double.infinity,
|
|
||||||
child: Icon(_getShareIcon(share)),
|
child: Icon(_getShareIcon(share)),
|
||||||
),
|
),
|
||||||
trailing: Row(
|
trailing: Row(
|
||||||
|
|
|
@ -31,6 +31,7 @@ import 'package:nc_photos/widget/animated_visibility.dart';
|
||||||
import 'package:nc_photos/widget/gps_map.dart';
|
import 'package:nc_photos/widget/gps_map.dart';
|
||||||
import 'package:nc_photos/widget/handler/add_selection_to_album_handler.dart';
|
import 'package:nc_photos/widget/handler/add_selection_to_album_handler.dart';
|
||||||
import 'package:nc_photos/widget/handler/archive_selection_handler.dart';
|
import 'package:nc_photos/widget/handler/archive_selection_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:nc_photos/widget/photo_date_time_edit_dialog.dart';
|
||||||
import 'package:path/path.dart';
|
import 'package:path/path.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
|
@ -175,8 +176,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
||||||
child: Divider(),
|
child: Divider(),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: SizedBox(
|
leading: ListTileCenterLeading(
|
||||||
height: double.infinity,
|
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.image_outlined,
|
Icons.image_outlined,
|
||||||
color: AppTheme.getSecondaryTextColor(context),
|
color: AppTheme.getSecondaryTextColor(context),
|
||||||
|
@ -187,8 +187,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
||||||
),
|
),
|
||||||
if (!widget.file.isOwned(widget.account.username))
|
if (!widget.file.isOwned(widget.account.username))
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: SizedBox(
|
leading: ListTileCenterLeading(
|
||||||
height: double.infinity,
|
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.share_outlined,
|
Icons.share_outlined,
|
||||||
color: AppTheme.getSecondaryTextColor(context),
|
color: AppTheme.getSecondaryTextColor(context),
|
||||||
|
@ -212,8 +211,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
||||||
if (widget.file.metadata?.imageWidth != null &&
|
if (widget.file.metadata?.imageWidth != null &&
|
||||||
widget.file.metadata?.imageHeight != null)
|
widget.file.metadata?.imageHeight != null)
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: SizedBox(
|
leading: ListTileCenterLeading(
|
||||||
height: double.infinity,
|
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.aspect_ratio,
|
Icons.aspect_ratio,
|
||||||
color: AppTheme.getSecondaryTextColor(context),
|
color: AppTheme.getSecondaryTextColor(context),
|
||||||
|
@ -225,19 +223,15 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: SizedBox(
|
leading: Icon(
|
||||||
height: double.infinity,
|
Icons.aspect_ratio,
|
||||||
child: Icon(
|
color: AppTheme.getSecondaryTextColor(context),
|
||||||
Icons.aspect_ratio,
|
|
||||||
color: AppTheme.getSecondaryTextColor(context),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
title: Text(_byteSizeToString(widget.file.contentLength ?? 0)),
|
title: Text(_byteSizeToString(widget.file.contentLength ?? 0)),
|
||||||
),
|
),
|
||||||
if (_model != null)
|
if (_model != null)
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: SizedBox(
|
leading: ListTileCenterLeading(
|
||||||
height: double.infinity,
|
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.camera_outlined,
|
Icons.camera_outlined,
|
||||||
color: AppTheme.getSecondaryTextColor(context),
|
color: AppTheme.getSecondaryTextColor(context),
|
||||||
|
|
Loading…
Reference in a new issue