mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Refactoring: extract widget class
This commit is contained in:
parent
e965871d4e
commit
352705872a
1 changed files with 23 additions and 5 deletions
|
@ -278,7 +278,25 @@ class _CountryItem {
|
||||||
this.onTap,
|
this.onTap,
|
||||||
});
|
});
|
||||||
|
|
||||||
Widget buildWidget(BuildContext context) {
|
Widget buildWidget(BuildContext context) =>
|
||||||
|
_CountryItemView(thumbUrl, country, account: account, onTap: onTap);
|
||||||
|
|
||||||
|
final Account account;
|
||||||
|
final String country;
|
||||||
|
final String thumbUrl;
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
}
|
||||||
|
|
||||||
|
class _CountryItemView extends StatelessWidget {
|
||||||
|
const _CountryItemView(
|
||||||
|
this.imageUrl,
|
||||||
|
this.text, {
|
||||||
|
required this.account,
|
||||||
|
this.onTap,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
|
@ -289,7 +307,7 @@ class _CountryItem {
|
||||||
children: [
|
children: [
|
||||||
CachedNetworkImage(
|
CachedNetworkImage(
|
||||||
cacheManager: ThumbnailCacheManager.inst,
|
cacheManager: ThumbnailCacheManager.inst,
|
||||||
imageUrl: thumbUrl,
|
imageUrl: imageUrl,
|
||||||
httpHeaders: {
|
httpHeaders: {
|
||||||
"Authorization": Api.getAuthorizationHeaderValue(account),
|
"Authorization": Api.getAuthorizationHeaderValue(account),
|
||||||
},
|
},
|
||||||
|
@ -302,7 +320,7 @@ class _CountryItem {
|
||||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text(country),
|
Text(text),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -332,7 +350,7 @@ class _CountryItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
final Account account;
|
final Account account;
|
||||||
final String country;
|
final String imageUrl;
|
||||||
final String thumbUrl;
|
final String text;
|
||||||
final VoidCallback? onTap;
|
final VoidCallback? onTap;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue