mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-02 14:56:20 +01:00
Refactoring: extract empty list widget
This commit is contained in:
parent
2b61011b62
commit
f412556f65
2 changed files with 39 additions and 17 deletions
|
@ -11,6 +11,7 @@ import 'package:nc_photos/entity/file/data_source.dart';
|
|||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/use_case/list_album.dart';
|
||||
import 'package:nc_photos/widget/builder/album_grid_item_builder.dart';
|
||||
import 'package:nc_photos/widget/empty_list_indicator.dart';
|
||||
|
||||
/// Search and filter albums (to be replaced by a more universal search in the
|
||||
/// future)
|
||||
|
@ -75,23 +76,9 @@ class AlbumSearchDelegate extends SearchDelegate {
|
|||
|
||||
Widget _buildResultContent(BuildContext context, AlbumSearchBlocState state) {
|
||||
if (state.results.isEmpty) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.mood_bad,
|
||||
size: 72,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
L10n.of(context).listNoResultsText,
|
||||
style: const TextStyle(fontSize: 24),
|
||||
),
|
||||
],
|
||||
),
|
||||
return EmptyListIndicator(
|
||||
icon: Icons.mood_bad,
|
||||
text: L10n.of(context).listNoResultsText,
|
||||
);
|
||||
} else {
|
||||
return StaggeredGridView.extentBuilder(
|
||||
|
|
35
lib/widget/empty_list_indicator.dart
Normal file
35
lib/widget/empty_list_indicator.dart
Normal file
|
@ -0,0 +1,35 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class EmptyListIndicator extends StatelessWidget {
|
||||
const EmptyListIndicator({
|
||||
Key? key,
|
||||
required this.icon,
|
||||
required this.text,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
size: 72,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(fontSize: 24),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final IconData icon;
|
||||
final String text;
|
||||
}
|
Loading…
Reference in a new issue