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/gps_map.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/share_folder_picker.dart';
|
||||
import 'package:nc_photos/widget/stateful_slider.dart';
|
||||
|
@ -212,8 +213,7 @@ class _SettingsState extends State<Settings> {
|
|||
return ListTile(
|
||||
leading: leading == null
|
||||
? null
|
||||
: SizedBox(
|
||||
height: double.infinity,
|
||||
: ListTileCenterLeading(
|
||||
child: leading,
|
||||
),
|
||||
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/use_case/remove.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;
|
||||
|
||||
class SharedFileViewerArguments {
|
||||
|
@ -158,8 +159,7 @@ class _SharedFileViewerState extends State<SharedFileViewer> {
|
|||
return ListTile(
|
||||
title: Text(_getShareTitle(share)),
|
||||
subtitle: Text(dateStr),
|
||||
leading: SizedBox(
|
||||
height: double.infinity,
|
||||
leading: ListTileCenterLeading(
|
||||
child: Icon(_getShareIcon(share)),
|
||||
),
|
||||
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/handler/add_selection_to_album_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:path/path.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
@ -175,8 +176,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
child: Divider(),
|
||||
),
|
||||
ListTile(
|
||||
leading: SizedBox(
|
||||
height: double.infinity,
|
||||
leading: ListTileCenterLeading(
|
||||
child: Icon(
|
||||
Icons.image_outlined,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
|
@ -187,8 +187,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
),
|
||||
if (!widget.file.isOwned(widget.account.username))
|
||||
ListTile(
|
||||
leading: SizedBox(
|
||||
height: double.infinity,
|
||||
leading: ListTileCenterLeading(
|
||||
child: Icon(
|
||||
Icons.share_outlined,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
|
@ -212,8 +211,7 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
if (widget.file.metadata?.imageWidth != null &&
|
||||
widget.file.metadata?.imageHeight != null)
|
||||
ListTile(
|
||||
leading: SizedBox(
|
||||
height: double.infinity,
|
||||
leading: ListTileCenterLeading(
|
||||
child: Icon(
|
||||
Icons.aspect_ratio,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
|
@ -225,19 +223,15 @@ class _ViewerDetailPaneState extends State<ViewerDetailPane> {
|
|||
)
|
||||
else
|
||||
ListTile(
|
||||
leading: SizedBox(
|
||||
height: double.infinity,
|
||||
child: Icon(
|
||||
leading: Icon(
|
||||
Icons.aspect_ratio,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
),
|
||||
),
|
||||
title: Text(_byteSizeToString(widget.file.contentLength ?? 0)),
|
||||
),
|
||||
if (_model != null)
|
||||
ListTile(
|
||||
leading: SizedBox(
|
||||
height: double.infinity,
|
||||
leading: ListTileCenterLeading(
|
||||
child: Icon(
|
||||
Icons.camera_outlined,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
|
|
Loading…
Reference in a new issue