feat: Add settings to control play button visibility on home shelves

This commit introduces new functionality to customize the visibility of the
play button on home page shelves.

Key changes:

- Added `HomePageSettings` to `AppSettings` to store your preferences:
    - `showPlayButtonOnContinueShelves`: Controls visibility on "Continue Listening" and "Continue Series" shelves (default: true).
    - `showPlayButtonOnAllShelves`: Controls visibility on other shelves (default: false).
- Modified `BookHomeShelf` to respect these settings when rendering books.
- Created a new "Home Page Settings" page under "Appearance" in App Settings, allowing you to toggle these two options.
- Added comprehensive unit and widget tests to cover the new settings model, the conditional logic in `BookHomeShelf`, and the functionality of the new settings page.
This commit is contained in:
google-labs-jules[bot] 2025-05-22 00:44:06 +00:00
parent 23e5d73bea
commit cc9a94de62
9 changed files with 457 additions and 0 deletions

View file

@ -19,12 +19,24 @@ class AppSettings with _$AppSettings {
@Default(NotificationSettings()) NotificationSettings notificationSettings,
@Default(ShakeDetectionSettings())
ShakeDetectionSettings shakeDetectionSettings,
@Default(HomePageSettings()) HomePageSettings homePageSettings,
}) = _AppSettings;
factory AppSettings.fromJson(Map<String, dynamic> json) =>
_$AppSettingsFromJson(json);
}
@freezed
class HomePageSettings with _$HomePageSettings {
const factory HomePageSettings({
@Default(true) bool showPlayButtonOnContinueShelves,
@Default(false) bool showPlayButtonOnAllShelves,
}) = _HomePageSettings;
factory HomePageSettings.fromJson(Map<String, dynamic> json) =>
_$HomePageSettingsFromJson(json);
}
@freezed
class ThemeSettings with _$ThemeSettings {
const factory ThemeSettings({

View file

@ -120,6 +120,16 @@ class AppSettingsPage extends HookConsumerWidget {
context.pushNamed(Routes.notificationSettings.name);
},
),
SettingsTile.navigation(
leading: const Icon(Icons.home_filled),
title: const Text('Home Page Settings'),
description: const Text(
'Customize the home page shelves',
),
onPressed: (context) {
context.pushNamed(Routes.homePageSettings.name);
},
),
],
),

View file

@ -0,0 +1,53 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:settings_ui/settings_ui.dart';
import 'package:vaani/settings/app_settings_provider.dart';
import 'package:vaani/settings/widgets/simple_settings_page.dart';
class HomePageSettingsPage extends HookConsumerWidget {
const HomePageSettingsPage({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
final appSettings = ref.watch(appSettingsProvider);
final appSettingsNotifier = ref.read(appSettingsProvider.notifier);
return SimpleSettingsPage(
title: 'Home Page Settings',
child: SettingsList(
sections: [
SettingsSection(
tiles: [
SettingsTile.switchTile(
title: const Text('Show play button on continue shelves'),
initialValue: appSettings.homePageSettings.showPlayButtonOnContinueShelves,
onToggle: (value) {
appSettingsNotifier.update(
appSettings.copyWith(
homePageSettings: appSettings.homePageSettings.copyWith(
showPlayButtonOnContinueShelves: value,
),
),
);
},
),
SettingsTile.switchTile(
title: const Text('Show play button on all shelves'),
initialValue: appSettings.homePageSettings.showPlayButtonOnAllShelves,
onToggle: (value) {
appSettingsNotifier.update(
appSettings.copyWith(
homePageSettings: appSettings.homePageSettings.copyWith(
showPlayButtonOnAllShelves: value,
),
),
);
},
),
],
),
],
),
);
}
}