Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions app/lib/pages/memories/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
}

@override
Widget build(BuildContext context) {

Check warning on line 142 in app/lib/pages/memories/page.dart

View workflow job for this annotation

GitHub Actions / PR Metadata Preflight

Long function

Widget build(BuildContext context) is 264 lines; consider extracting focused helpers over 150 lines.
super.build(context);
return Consumer<MemoriesProvider>(
builder: (context, provider, _) {
Expand Down Expand Up @@ -211,8 +211,6 @@
SizedBox(width: 44, height: 44, child: _buildShimmerButton()),
const SizedBox(width: 8),
SizedBox(width: 44, height: 44, child: _buildShimmerButton()),
const SizedBox(width: 8),
SizedBox(width: 44, height: 44, child: _buildShimmerButton()),
],
),
),
Expand Down Expand Up @@ -293,14 +291,6 @@
},
),
const SizedBox(width: 8),
FilterChip(
label: Text(context.l10n.memoryThisDevice, style: const TextStyle(fontSize: 12)),
selected: provider.filterThisDeviceOnly,
onSelected: provider.setFilterThisDeviceOnly,
visualDensity: VisualDensity.compact,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
const SizedBox(width: 8),
SizedBox(
width: 44,
height: 44,
Expand Down
36 changes: 30 additions & 6 deletions app/lib/pages/memories/widgets/memory_management_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,26 @@ class MemoryManagementSheet extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(20, 16, 16, 8),
child: Text(context.l10n.filterMemories, style: AppStyles.title),
),
_buildFilterOption(context, context.l10n.filterAll, null),
_buildFilterOption(context, context.l10n.filterSystem, MemoryCategory.system),
_buildFilterOption(context, context.l10n.filterInteresting, MemoryCategory.interesting),
_buildFilterOption(context, context.l10n.filterManual, MemoryCategory.manual),
_buildCategoryFilterOption(context, context.l10n.filterAll, null),
_buildCategoryFilterOption(context, context.l10n.filterSystem, MemoryCategory.system),
_buildCategoryFilterOption(context, context.l10n.filterInteresting, MemoryCategory.interesting),
_buildCategoryFilterOption(context, context.l10n.filterManual, MemoryCategory.manual),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 8),
child: Divider(height: 1, color: Colors.white10),
),
_buildFilterOption(
context,
context.l10n.memoryThisDevice,
isSelected: provider.filterThisDeviceOnly,
onTap: () => provider.setFilterThisDeviceOnly(!provider.filterThisDeviceOnly),
),
const SizedBox(height: 16),
],
);
}

Widget _buildFilterOption(BuildContext context, String label, MemoryCategory? category) {
Widget _buildCategoryFilterOption(BuildContext context, String label, MemoryCategory? category) {
// If category is null, it represents "All"
// For "All", it is selected if the set is empty.
final bool isSelected;
Expand All @@ -84,7 +94,10 @@ class MemoryManagementSheet extends StatelessWidget {
isSelected = provider.selectedCategories.contains(category);
}

return InkWell(
return _buildFilterOption(
context,
label,
isSelected: isSelected,
onTap: () {
if (category == null) {
provider.clearCategoryFilter();
Expand All @@ -93,6 +106,17 @@ class MemoryManagementSheet extends StatelessWidget {
}
// Do NOT pop here to allow multiple selections
},
);
}

Widget _buildFilterOption(
BuildContext context,
String label, {
required bool isSelected,
required VoidCallback onTap,
}) {
return InkWell(
onTap: onTap,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
child: Row(
Expand Down
Loading