mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-24 16:04:43 +01:00
Refactoring: extract generic widget class
This commit is contained in:
parent
6a394cc93a
commit
39eae6dd1f
2 changed files with 74 additions and 31 deletions
|
@ -29,6 +29,7 @@ import 'package:nc_photos/widget/album_browser_util.dart' as album_browser_util;
|
||||||
import 'package:nc_photos/widget/empty_list_indicator.dart';
|
import 'package:nc_photos/widget/empty_list_indicator.dart';
|
||||||
import 'package:nc_photos/widget/processing_dialog.dart';
|
import 'package:nc_photos/widget/processing_dialog.dart';
|
||||||
import 'package:nc_photos/widget/shared_file_viewer.dart';
|
import 'package:nc_photos/widget/shared_file_viewer.dart';
|
||||||
|
import 'package:nc_photos/widget/unbounded_list_tile.dart';
|
||||||
|
|
||||||
class SharingBrowserArguments {
|
class SharingBrowserArguments {
|
||||||
SharingBrowserArguments(this.account);
|
SharingBrowserArguments(this.account);
|
||||||
|
@ -379,38 +380,16 @@ class _ListTile extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
build(BuildContext context) {
|
build(BuildContext context) {
|
||||||
return InkWell(
|
return UnboundedListTile(
|
||||||
onTap: onTap,
|
leading: leading,
|
||||||
child: Padding(
|
title: Text(
|
||||||
padding: const EdgeInsets.all(16),
|
label,
|
||||||
child: Row(
|
maxLines: 1,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
overflow: TextOverflow.ellipsis,
|
||||||
children: [
|
|
||||||
leading,
|
|
||||||
const SizedBox(width: 16),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
label,
|
|
||||||
style: Theme.of(context).textTheme.subtitle1,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
description,
|
|
||||||
style: TextStyle(
|
|
||||||
color: AppTheme.getSecondaryTextColor(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (trailing != null) trailing!,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
subtitle: Text(description),
|
||||||
|
trailing: trailing,
|
||||||
|
onTap: onTap,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
64
lib/widget/unbounded_list_tile.dart
Normal file
64
lib/widget/unbounded_list_tile.dart
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
import 'package:nc_photos/theme.dart';
|
||||||
|
|
||||||
|
/// A [ListTile]-like widget with unbounded height
|
||||||
|
class UnboundedListTile extends StatelessWidget {
|
||||||
|
const UnboundedListTile({
|
||||||
|
Key? key,
|
||||||
|
this.leading,
|
||||||
|
required this.title,
|
||||||
|
this.subtitle,
|
||||||
|
this.trailing,
|
||||||
|
this.onTap,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
build(BuildContext context) {
|
||||||
|
final content = Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
if (leading != null) ...[
|
||||||
|
leading!,
|
||||||
|
const SizedBox(width: 16),
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
DefaultTextStyle(
|
||||||
|
style: Theme.of(context).textTheme.subtitle1!,
|
||||||
|
child: title,
|
||||||
|
),
|
||||||
|
if (subtitle != null)
|
||||||
|
DefaultTextStyle(
|
||||||
|
style: TextStyle(
|
||||||
|
color: AppTheme.getSecondaryTextColor(context),
|
||||||
|
),
|
||||||
|
child: subtitle!,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (trailing != null) trailing!,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (onTap != null) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
child: content,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Widget? leading;
|
||||||
|
final Widget title;
|
||||||
|
final Widget? subtitle;
|
||||||
|
final Widget? trailing;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue