mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-09 02:36:31 +01:00
Refactoring: extract widget class
This commit is contained in:
parent
afd859d414
commit
481387e8fb
1 changed files with 82 additions and 54 deletions
|
@ -155,21 +155,8 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
final dateStr = DateFormat(DateFormat.YEAR_ABBR_MONTH_DAY,
|
final dateStr = DateFormat(DateFormat.YEAR_ABBR_MONTH_DAY,
|
||||||
Localizations.localeOf(context).languageCode)
|
Localizations.localeOf(context).languageCode)
|
||||||
.format(shares.first.share.stime.toLocal());
|
.format(shares.first.share.stime.toLocal());
|
||||||
return InkWell(
|
return _ListTile(
|
||||||
onTap: () {
|
leading: shares.first.share.itemType == ShareItemType.folder
|
||||||
Navigator.of(context).pushNamed(SharedFileViewer.routeName,
|
|
||||||
arguments: SharedFileViewerArguments(
|
|
||||||
widget.account,
|
|
||||||
shares.first.file,
|
|
||||||
shares.map((e) => e.share).toList(),
|
|
||||||
));
|
|
||||||
},
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(16),
|
|
||||||
child: Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
shares.first.share.itemType == ShareItemType.folder
|
|
||||||
? const Icon(
|
? const Icon(
|
||||||
Icons.folder_outlined,
|
Icons.folder_outlined,
|
||||||
size: leadingSize,
|
size: leadingSize,
|
||||||
|
@ -189,34 +176,22 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
filterQuality: FilterQuality.high,
|
filterQuality: FilterQuality.high,
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
label: shares.first.share.filename,
|
||||||
Expanded(
|
description: shares.first.share.uidOwner == widget.account.username
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
shares.first.share.filename,
|
|
||||||
style: Theme.of(context).textTheme.subtitle1,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
shares.first.share.uidOwner == widget.account.username
|
|
||||||
? L10n.global().fileLastSharedDescription(dateStr)
|
? L10n.global().fileLastSharedDescription(dateStr)
|
||||||
: L10n.global().fileLastSharedByOthersDescription(
|
: L10n.global().fileLastSharedByOthersDescription(
|
||||||
shares.first.share.displaynameOwner, dateStr),
|
shares.first.share.displaynameOwner, dateStr),
|
||||||
style: TextStyle(
|
trailing: (shares.any((element) => element.share.url?.isNotEmpty == true))
|
||||||
color: AppTheme.getSecondaryTextColor(context),
|
? const Icon(Icons.link)
|
||||||
),
|
: null,
|
||||||
),
|
onTap: () {
|
||||||
],
|
Navigator.of(context).pushNamed(SharedFileViewer.routeName,
|
||||||
),
|
arguments: SharedFileViewerArguments(
|
||||||
),
|
widget.account,
|
||||||
if (shares.any((element) => element.share.url?.isNotEmpty == true))
|
shares.first.file,
|
||||||
const Icon(Icons.link)
|
shares.map((e) => e.share).toList(),
|
||||||
],
|
));
|
||||||
),
|
},
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,3 +245,56 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
|
|
||||||
static final _log = Logger("widget.sharing_browser._SharingBrowserState");
|
static final _log = Logger("widget.sharing_browser._SharingBrowserState");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _ListTile extends StatelessWidget {
|
||||||
|
const _ListTile({
|
||||||
|
required this.leading,
|
||||||
|
required this.label,
|
||||||
|
required this.description,
|
||||||
|
this.trailing,
|
||||||
|
required this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
build(BuildContext context) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
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!,
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Widget leading;
|
||||||
|
final String label;
|
||||||
|
final String description;
|
||||||
|
final Widget? trailing;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue