mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-24 11:59:30 +00:00
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.
51 lines
2 KiB
Dart
51 lines
2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:vaani/settings/models/app_settings.dart';
|
|
|
|
void main() {
|
|
group('AppSettings', () {
|
|
test('initializes with default HomePageSettings', () {
|
|
const appSettings = AppSettings();
|
|
expect(appSettings.homePageSettings.showPlayButtonOnContinueShelves, isTrue);
|
|
expect(appSettings.homePageSettings.showPlayButtonOnAllShelves, isFalse);
|
|
});
|
|
|
|
test('HomePageSettings can be updated', () {
|
|
const initialSettings = AppSettings();
|
|
final updatedSettings = initialSettings.copyWith(
|
|
homePageSettings: initialSettings.homePageSettings.copyWith(
|
|
showPlayButtonOnContinueShelves: false,
|
|
showPlayButtonOnAllShelves: true,
|
|
),
|
|
);
|
|
|
|
expect(updatedSettings.homePageSettings.showPlayButtonOnContinueShelves, isFalse);
|
|
expect(updatedSettings.homePageSettings.showPlayButtonOnAllShelves, isTrue);
|
|
});
|
|
|
|
test('HomePageSettings are correctly serialized and deserialized', () {
|
|
const originalSettings = AppSettings(
|
|
homePageSettings: HomePageSettings(
|
|
showPlayButtonOnContinueShelves: false,
|
|
showPlayButtonOnAllShelves: true,
|
|
),
|
|
);
|
|
|
|
final json = originalSettings.toJson();
|
|
final deserializedSettings = AppSettings.fromJson(json);
|
|
|
|
expect(deserializedSettings.homePageSettings.showPlayButtonOnContinueShelves, isFalse);
|
|
expect(deserializedSettings.homePageSettings.showPlayButtonOnAllShelves, isTrue);
|
|
expect(deserializedSettings, originalSettings);
|
|
});
|
|
|
|
test('Default AppSettings serialization and deserialization', () {
|
|
const originalSettings = AppSettings();
|
|
final json = originalSettings.toJson();
|
|
final deserializedSettings = AppSettings.fromJson(json);
|
|
|
|
expect(deserializedSettings.homePageSettings.showPlayButtonOnContinueShelves, isTrue);
|
|
expect(deserializedSettings.homePageSettings.showPlayButtonOnAllShelves, isFalse);
|
|
expect(deserializedSettings, originalSettings);
|
|
});
|
|
});
|
|
}
|