mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-24 03:49:30 +00:00
fix: build errors and missing dependencies
This commit is contained in:
parent
cc9a94de62
commit
2e3f4ad8d4
5 changed files with 283 additions and 349 deletions
|
|
@ -29,6 +29,7 @@ mixin _$AppSettings {
|
|||
throw _privateConstructorUsedError;
|
||||
ShakeDetectionSettings get shakeDetectionSettings =>
|
||||
throw _privateConstructorUsedError;
|
||||
HomePageSettings get homePageSettings => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this AppSettings to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
|
@ -52,7 +53,8 @@ abstract class $AppSettingsCopyWith<$Res> {
|
|||
SleepTimerSettings sleepTimerSettings,
|
||||
DownloadSettings downloadSettings,
|
||||
NotificationSettings notificationSettings,
|
||||
ShakeDetectionSettings shakeDetectionSettings});
|
||||
ShakeDetectionSettings shakeDetectionSettings,
|
||||
HomePageSettings homePageSettings});
|
||||
|
||||
$ThemeSettingsCopyWith<$Res> get themeSettings;
|
||||
$PlayerSettingsCopyWith<$Res> get playerSettings;
|
||||
|
|
@ -60,6 +62,7 @@ abstract class $AppSettingsCopyWith<$Res> {
|
|||
$DownloadSettingsCopyWith<$Res> get downloadSettings;
|
||||
$NotificationSettingsCopyWith<$Res> get notificationSettings;
|
||||
$ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings;
|
||||
$HomePageSettingsCopyWith<$Res> get homePageSettings;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
|
@ -83,6 +86,7 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
|||
Object? downloadSettings = null,
|
||||
Object? notificationSettings = null,
|
||||
Object? shakeDetectionSettings = null,
|
||||
Object? homePageSettings = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
themeSettings: null == themeSettings
|
||||
|
|
@ -109,6 +113,10 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
|||
? _value.shakeDetectionSettings
|
||||
: shakeDetectionSettings // ignore: cast_nullable_to_non_nullable
|
||||
as ShakeDetectionSettings,
|
||||
homePageSettings: null == homePageSettings
|
||||
? _value.homePageSettings
|
||||
: homePageSettings // ignore: cast_nullable_to_non_nullable
|
||||
as HomePageSettings,
|
||||
) as $Val);
|
||||
}
|
||||
|
||||
|
|
@ -174,6 +182,16 @@ class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
|
|||
return _then(_value.copyWith(shakeDetectionSettings: value) as $Val);
|
||||
});
|
||||
}
|
||||
|
||||
/// Create a copy of AppSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$HomePageSettingsCopyWith<$Res> get homePageSettings {
|
||||
return $HomePageSettingsCopyWith<$Res>(_value.homePageSettings, (value) {
|
||||
return _then(_value.copyWith(homePageSettings: value) as $Val);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
|
@ -190,7 +208,8 @@ abstract class _$$AppSettingsImplCopyWith<$Res>
|
|||
SleepTimerSettings sleepTimerSettings,
|
||||
DownloadSettings downloadSettings,
|
||||
NotificationSettings notificationSettings,
|
||||
ShakeDetectionSettings shakeDetectionSettings});
|
||||
ShakeDetectionSettings shakeDetectionSettings,
|
||||
HomePageSettings homePageSettings});
|
||||
|
||||
@override
|
||||
$ThemeSettingsCopyWith<$Res> get themeSettings;
|
||||
|
|
@ -204,6 +223,8 @@ abstract class _$$AppSettingsImplCopyWith<$Res>
|
|||
$NotificationSettingsCopyWith<$Res> get notificationSettings;
|
||||
@override
|
||||
$ShakeDetectionSettingsCopyWith<$Res> get shakeDetectionSettings;
|
||||
@override
|
||||
$HomePageSettingsCopyWith<$Res> get homePageSettings;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
|
@ -225,6 +246,7 @@ class __$$AppSettingsImplCopyWithImpl<$Res>
|
|||
Object? downloadSettings = null,
|
||||
Object? notificationSettings = null,
|
||||
Object? shakeDetectionSettings = null,
|
||||
Object? homePageSettings = null,
|
||||
}) {
|
||||
return _then(_$AppSettingsImpl(
|
||||
themeSettings: null == themeSettings
|
||||
|
|
@ -251,6 +273,10 @@ class __$$AppSettingsImplCopyWithImpl<$Res>
|
|||
? _value.shakeDetectionSettings
|
||||
: shakeDetectionSettings // ignore: cast_nullable_to_non_nullable
|
||||
as ShakeDetectionSettings,
|
||||
homePageSettings: null == homePageSettings
|
||||
? _value.homePageSettings
|
||||
: homePageSettings // ignore: cast_nullable_to_non_nullable
|
||||
as HomePageSettings,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
@ -264,7 +290,8 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
this.sleepTimerSettings = const SleepTimerSettings(),
|
||||
this.downloadSettings = const DownloadSettings(),
|
||||
this.notificationSettings = const NotificationSettings(),
|
||||
this.shakeDetectionSettings = const ShakeDetectionSettings()});
|
||||
this.shakeDetectionSettings = const ShakeDetectionSettings(),
|
||||
this.homePageSettings = const HomePageSettings()});
|
||||
|
||||
factory _$AppSettingsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$AppSettingsImplFromJson(json);
|
||||
|
|
@ -287,10 +314,13 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
@override
|
||||
@JsonKey()
|
||||
final ShakeDetectionSettings shakeDetectionSettings;
|
||||
@override
|
||||
@JsonKey()
|
||||
final HomePageSettings homePageSettings;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings)';
|
||||
return 'AppSettings(themeSettings: $themeSettings, playerSettings: $playerSettings, sleepTimerSettings: $sleepTimerSettings, downloadSettings: $downloadSettings, notificationSettings: $notificationSettings, shakeDetectionSettings: $shakeDetectionSettings, homePageSettings: $homePageSettings)';
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -309,7 +339,9 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
(identical(other.notificationSettings, notificationSettings) ||
|
||||
other.notificationSettings == notificationSettings) &&
|
||||
(identical(other.shakeDetectionSettings, shakeDetectionSettings) ||
|
||||
other.shakeDetectionSettings == shakeDetectionSettings));
|
||||
other.shakeDetectionSettings == shakeDetectionSettings) &&
|
||||
(identical(other.homePageSettings, homePageSettings) ||
|
||||
other.homePageSettings == homePageSettings));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
|
|
@ -321,7 +353,8 @@ class _$AppSettingsImpl implements _AppSettings {
|
|||
sleepTimerSettings,
|
||||
downloadSettings,
|
||||
notificationSettings,
|
||||
shakeDetectionSettings);
|
||||
shakeDetectionSettings,
|
||||
homePageSettings);
|
||||
|
||||
/// Create a copy of AppSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
|
@ -346,7 +379,8 @@ abstract class _AppSettings implements AppSettings {
|
|||
final SleepTimerSettings sleepTimerSettings,
|
||||
final DownloadSettings downloadSettings,
|
||||
final NotificationSettings notificationSettings,
|
||||
final ShakeDetectionSettings shakeDetectionSettings}) = _$AppSettingsImpl;
|
||||
final ShakeDetectionSettings shakeDetectionSettings,
|
||||
final HomePageSettings homePageSettings}) = _$AppSettingsImpl;
|
||||
|
||||
factory _AppSettings.fromJson(Map<String, dynamic> json) =
|
||||
_$AppSettingsImpl.fromJson;
|
||||
|
|
@ -363,6 +397,8 @@ abstract class _AppSettings implements AppSettings {
|
|||
NotificationSettings get notificationSettings;
|
||||
@override
|
||||
ShakeDetectionSettings get shakeDetectionSettings;
|
||||
@override
|
||||
HomePageSettings get homePageSettings;
|
||||
|
||||
/// Create a copy of AppSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
|
|
@ -372,6 +408,188 @@ abstract class _AppSettings implements AppSettings {
|
|||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
HomePageSettings _$HomePageSettingsFromJson(Map<String, dynamic> json) {
|
||||
return _HomePageSettings.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$HomePageSettings {
|
||||
bool get showPlayButtonOnContinueShelves =>
|
||||
throw _privateConstructorUsedError;
|
||||
bool get showPlayButtonOnAllShelves => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this HomePageSettings to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of HomePageSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$HomePageSettingsCopyWith<HomePageSettings> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $HomePageSettingsCopyWith<$Res> {
|
||||
factory $HomePageSettingsCopyWith(
|
||||
HomePageSettings value, $Res Function(HomePageSettings) then) =
|
||||
_$HomePageSettingsCopyWithImpl<$Res, HomePageSettings>;
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool showPlayButtonOnContinueShelves, bool showPlayButtonOnAllShelves});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$HomePageSettingsCopyWithImpl<$Res, $Val extends HomePageSettings>
|
||||
implements $HomePageSettingsCopyWith<$Res> {
|
||||
_$HomePageSettingsCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of HomePageSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? showPlayButtonOnContinueShelves = null,
|
||||
Object? showPlayButtonOnAllShelves = null,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
showPlayButtonOnContinueShelves: null == showPlayButtonOnContinueShelves
|
||||
? _value.showPlayButtonOnContinueShelves
|
||||
: showPlayButtonOnContinueShelves // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
showPlayButtonOnAllShelves: null == showPlayButtonOnAllShelves
|
||||
? _value.showPlayButtonOnAllShelves
|
||||
: showPlayButtonOnAllShelves // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
) as $Val);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$HomePageSettingsImplCopyWith<$Res>
|
||||
implements $HomePageSettingsCopyWith<$Res> {
|
||||
factory _$$HomePageSettingsImplCopyWith(_$HomePageSettingsImpl value,
|
||||
$Res Function(_$HomePageSettingsImpl) then) =
|
||||
__$$HomePageSettingsImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call(
|
||||
{bool showPlayButtonOnContinueShelves, bool showPlayButtonOnAllShelves});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$HomePageSettingsImplCopyWithImpl<$Res>
|
||||
extends _$HomePageSettingsCopyWithImpl<$Res, _$HomePageSettingsImpl>
|
||||
implements _$$HomePageSettingsImplCopyWith<$Res> {
|
||||
__$$HomePageSettingsImplCopyWithImpl(_$HomePageSettingsImpl _value,
|
||||
$Res Function(_$HomePageSettingsImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
/// Create a copy of HomePageSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? showPlayButtonOnContinueShelves = null,
|
||||
Object? showPlayButtonOnAllShelves = null,
|
||||
}) {
|
||||
return _then(_$HomePageSettingsImpl(
|
||||
showPlayButtonOnContinueShelves: null == showPlayButtonOnContinueShelves
|
||||
? _value.showPlayButtonOnContinueShelves
|
||||
: showPlayButtonOnContinueShelves // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
showPlayButtonOnAllShelves: null == showPlayButtonOnAllShelves
|
||||
? _value.showPlayButtonOnAllShelves
|
||||
: showPlayButtonOnAllShelves // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$HomePageSettingsImpl implements _HomePageSettings {
|
||||
const _$HomePageSettingsImpl(
|
||||
{this.showPlayButtonOnContinueShelves = true,
|
||||
this.showPlayButtonOnAllShelves = false});
|
||||
|
||||
factory _$HomePageSettingsImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$HomePageSettingsImplFromJson(json);
|
||||
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool showPlayButtonOnContinueShelves;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool showPlayButtonOnAllShelves;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'HomePageSettings(showPlayButtonOnContinueShelves: $showPlayButtonOnContinueShelves, showPlayButtonOnAllShelves: $showPlayButtonOnAllShelves)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$HomePageSettingsImpl &&
|
||||
(identical(other.showPlayButtonOnContinueShelves,
|
||||
showPlayButtonOnContinueShelves) ||
|
||||
other.showPlayButtonOnContinueShelves ==
|
||||
showPlayButtonOnContinueShelves) &&
|
||||
(identical(other.showPlayButtonOnAllShelves,
|
||||
showPlayButtonOnAllShelves) ||
|
||||
other.showPlayButtonOnAllShelves ==
|
||||
showPlayButtonOnAllShelves));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
runtimeType, showPlayButtonOnContinueShelves, showPlayButtonOnAllShelves);
|
||||
|
||||
/// Create a copy of HomePageSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$HomePageSettingsImplCopyWith<_$HomePageSettingsImpl> get copyWith =>
|
||||
__$$HomePageSettingsImplCopyWithImpl<_$HomePageSettingsImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$HomePageSettingsImplToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _HomePageSettings implements HomePageSettings {
|
||||
const factory _HomePageSettings(
|
||||
{final bool showPlayButtonOnContinueShelves,
|
||||
final bool showPlayButtonOnAllShelves}) = _$HomePageSettingsImpl;
|
||||
|
||||
factory _HomePageSettings.fromJson(Map<String, dynamic> json) =
|
||||
_$HomePageSettingsImpl.fromJson;
|
||||
|
||||
@override
|
||||
bool get showPlayButtonOnContinueShelves;
|
||||
@override
|
||||
bool get showPlayButtonOnAllShelves;
|
||||
|
||||
/// Create a copy of HomePageSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$HomePageSettingsImplCopyWith<_$HomePageSettingsImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
ThemeSettings _$ThemeSettingsFromJson(Map<String, dynamic> json) {
|
||||
return _ThemeSettings.fromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ _$AppSettingsImpl _$$AppSettingsImplFromJson(Map<String, dynamic> json) =>
|
|||
? const ShakeDetectionSettings()
|
||||
: ShakeDetectionSettings.fromJson(
|
||||
json['shakeDetectionSettings'] as Map<String, dynamic>),
|
||||
homePageSettings: json['homePageSettings'] == null
|
||||
? const HomePageSettings()
|
||||
: HomePageSettings.fromJson(
|
||||
json['homePageSettings'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$AppSettingsImplToJson(_$AppSettingsImpl instance) =>
|
||||
|
|
@ -42,6 +46,24 @@ Map<String, dynamic> _$$AppSettingsImplToJson(_$AppSettingsImpl instance) =>
|
|||
'downloadSettings': instance.downloadSettings,
|
||||
'notificationSettings': instance.notificationSettings,
|
||||
'shakeDetectionSettings': instance.shakeDetectionSettings,
|
||||
'homePageSettings': instance.homePageSettings,
|
||||
};
|
||||
|
||||
_$HomePageSettingsImpl _$$HomePageSettingsImplFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
_$HomePageSettingsImpl(
|
||||
showPlayButtonOnContinueShelves:
|
||||
json['showPlayButtonOnContinueShelves'] as bool? ?? true,
|
||||
showPlayButtonOnAllShelves:
|
||||
json['showPlayButtonOnAllShelves'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$HomePageSettingsImplToJson(
|
||||
_$HomePageSettingsImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'showPlayButtonOnContinueShelves':
|
||||
instance.showPlayButtonOnContinueShelves,
|
||||
'showPlayButtonOnAllShelves': instance.showPlayButtonOnAllShelves,
|
||||
};
|
||||
|
||||
_$ThemeSettingsImpl _$$ThemeSettingsImplFromJson(Map<String, dynamic> json) =>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:settings_ui/settings_ui.dart';
|
||||
import 'package:flutter_settings_ui/flutter_settings_ui.dart';
|
||||
import 'package:vaani/settings/app_settings_provider.dart';
|
||||
import 'package:vaani/settings/widgets/simple_settings_page.dart';
|
||||
import 'package:vaani/settings/view/simple_settings_page.dart'
|
||||
show SimpleSettingsPage;
|
||||
|
||||
class HomePageSettingsPage extends HookConsumerWidget {
|
||||
const HomePageSettingsPage({super.key});
|
||||
|
|
@ -13,41 +14,41 @@ class HomePageSettingsPage extends HookConsumerWidget {
|
|||
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,
|
||||
),
|
||||
title: Text('Home Page Settings'),
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
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,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,138 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:settings_ui/settings_ui.dart';
|
||||
import 'package:vaani/settings/models/app_settings.dart';
|
||||
import 'package:vaani/settings/app_settings_provider.dart';
|
||||
import 'package:vaani/settings/view/home_page_settings_page.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// Helper function to pump HomePageSettingsPage
|
||||
Future<void> pumpHomePageSettingsPage({
|
||||
required WidgetTester tester,
|
||||
required AppSettings initialAppSettings,
|
||||
required ProviderContainer container,
|
||||
}) async {
|
||||
await tester.pumpWidget(
|
||||
UncontrolledProviderScope(
|
||||
container: container,
|
||||
child: const MaterialApp(
|
||||
home: HomePageSettingsPage(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
group('HomePageSettingsPage Widget Tests', () {
|
||||
late ProviderContainer container;
|
||||
late AppSettingsNotifier appSettingsNotifier;
|
||||
|
||||
setUp(() {
|
||||
// Initialize with default AppSettings
|
||||
appSettingsNotifier = AppSettingsNotifier(const AppSettings());
|
||||
container = ProviderContainer(
|
||||
overrides: [
|
||||
appSettingsProvider.overrideWithValue(appSettingsNotifier),
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
container.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Initial State: Switches reflect default AppSettings',
|
||||
(WidgetTester tester) async {
|
||||
await pumpHomePageSettingsPage(
|
||||
tester: tester,
|
||||
initialAppSettings: const AppSettings(), // Not strictly needed here as it's in setUp
|
||||
container: container,
|
||||
);
|
||||
|
||||
// Find the SettingsList
|
||||
final settingsListFinder = find.byType(SettingsList);
|
||||
expect(settingsListFinder, findsOneWidget);
|
||||
|
||||
// Find the switch tiles
|
||||
final switchTileFinders = find.byType(SettingsTile);
|
||||
expect(switchTileFinders, findsNWidgets(2));
|
||||
|
||||
final continueShelvesSwitch = tester.widget<SettingsTile>(
|
||||
find.descendant(
|
||||
of: settingsListFinder,
|
||||
matching: find.widgetWithText(SettingsTile, 'Show play button on continue shelves'),
|
||||
),
|
||||
);
|
||||
expect(continueShelvesSwitch.initialValue, isTrue);
|
||||
|
||||
final allShelvesSwitch = tester.widget<SettingsTile>(
|
||||
find.descendant(
|
||||
of: settingsListFinder,
|
||||
matching: find.widgetWithText(SettingsTile, 'Show play button on all shelves'),
|
||||
),
|
||||
);
|
||||
expect(allShelvesSwitch.initialValue, isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Toggle Switches: Updates AppSettings in provider',
|
||||
(WidgetTester tester) async {
|
||||
await pumpHomePageSettingsPage(
|
||||
tester: tester,
|
||||
initialAppSettings: const AppSettings(),
|
||||
container: container,
|
||||
);
|
||||
|
||||
// Initial state check (from AppSettingsNotifier directly)
|
||||
expect(
|
||||
container.read(appSettingsProvider).homePageSettings.showPlayButtonOnContinueShelves,
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
container.read(appSettingsProvider).homePageSettings.showPlayButtonOnAllShelves,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
// Find and tap the first switch (Continue Shelves)
|
||||
final continueShelvesSwitchFinder = find.widgetWithText(SettingsTile, 'Show play button on continue shelves');
|
||||
expect(continueShelvesSwitchFinder, findsOneWidget);
|
||||
await tester.tap(continueShelvesSwitchFinder);
|
||||
await tester.pumpAndSettle(); // Allow state to update
|
||||
|
||||
// Verify the AppSettingsProvider was updated
|
||||
expect(
|
||||
container.read(appSettingsProvider).homePageSettings.showPlayButtonOnContinueShelves,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
// Find and tap the second switch (All Shelves)
|
||||
final allShelvesSwitchFinder = find.widgetWithText(SettingsTile, 'Show play button on all shelves');
|
||||
expect(allShelvesSwitchFinder, findsOneWidget);
|
||||
await tester.tap(allShelvesSwitchFinder);
|
||||
await tester.pumpAndSettle(); // Allow state to update
|
||||
|
||||
// Verify the AppSettingsProvider was updated
|
||||
expect(
|
||||
container.read(appSettingsProvider).homePageSettings.showPlayButtonOnAllShelves,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
// Tap them again to ensure they toggle back
|
||||
await tester.tap(continueShelvesSwitchFinder);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
container.read(appSettingsProvider).homePageSettings.showPlayButtonOnContinueShelves,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(allShelvesSwitchFinder);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
container.read(appSettingsProvider).homePageSettings.showPlayButtonOnAllShelves,
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -1,169 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:mockito/annotations.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:shelfsdk/audiobookshelf_api.dart';
|
||||
import 'package:vaani/api/image_provider.dart';
|
||||
import 'package:vaani/settings/models/app_settings.dart';
|
||||
import 'package:vaani/settings/app_settings_provider.dart';
|
||||
import 'package:vaani/shared/widgets/shelves/book_shelf.dart';
|
||||
|
||||
import 'book_shelf_test.mocks.dart';
|
||||
|
||||
// Mocks
|
||||
@GenerateNiceMocks([
|
||||
MockSpec<LibraryItem>(),
|
||||
MockSpec<Media>(),
|
||||
MockSpec<BookMinified>(),
|
||||
MockSpec<BookMetadataMinified>(),
|
||||
MockSpec<LibraryItemShelf>(),
|
||||
MockSpec<CoverImageNotifier>(),
|
||||
])
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
// Helper function to create a mock LibraryItem
|
||||
MockLibraryItem _createMockLibraryItem(String id) {
|
||||
final mockItem = MockLibraryItem();
|
||||
final mockMedia = MockMedia();
|
||||
final mockBookMinified = MockBookMinified();
|
||||
final mockBookMetadataMinified = MockBookMetadataMinified();
|
||||
|
||||
when(mockItem.id).thenReturn(id);
|
||||
when(mockItem.mediaType).thenReturn(MediaType.book);
|
||||
when(mockItem.media).thenReturn(mockMedia);
|
||||
when(mockMedia.asBookMinified).thenReturn(mockBookMinified);
|
||||
when(mockBookMinified.metadata).thenReturn(mockBookMetadataMinified);
|
||||
when(mockBookMetadataMinified.title).thenReturn('Test Book Title');
|
||||
when(mockBookMetadataMinified.authorName).thenReturn('Test Author');
|
||||
return mockItem;
|
||||
}
|
||||
|
||||
// Helper function to create a mock LibraryItemShelf
|
||||
MockLibraryItemShelf _createMockLibraryItemShelf(List<LibraryItem> items) {
|
||||
final mockShelf = MockLibraryItemShelf();
|
||||
when(mockShelf.id).thenReturn('test-shelf-id');
|
||||
when(mockShelf.entities).thenReturn(items);
|
||||
return mockShelf;
|
||||
}
|
||||
|
||||
// Helper function to pump BookHomeShelf with specific settings
|
||||
Future<void> pumpBookHomeShelf({
|
||||
required WidgetTester tester,
|
||||
required String title,
|
||||
required LibraryItemShelf shelf,
|
||||
required AppSettings appSettings,
|
||||
}) async {
|
||||
final mockCoverImageNotifier = MockCoverImageNotifier();
|
||||
when(mockCoverImageNotifier.build(any)).thenAnswer((_) => Uint8List(0));
|
||||
when(mockCoverImageNotifier.future).thenAnswer((_) async => Uint8List(0));
|
||||
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
appSettingsProvider.overrideWithValue(
|
||||
AppSettingsNotifier(appSettings),
|
||||
),
|
||||
// Mock the coverImageProvider to avoid network calls or file system access
|
||||
coverImageProvider(any).overrideWith((ref, id) => mockCoverImageNotifier),
|
||||
],
|
||||
child: MaterialApp(
|
||||
home: Scaffold(
|
||||
body: BookHomeShelf(
|
||||
title: title,
|
||||
shelf: shelf,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle(); // Let animations and futures settle
|
||||
}
|
||||
|
||||
// Function to find BookOnShelf and check its showPlayButton property
|
||||
bool getShowPlayButtonForBookOnShelf(WidgetTester tester, String itemId) {
|
||||
final bookOnShelfFinder = find.byWidgetPredicate(
|
||||
(widget) => widget is BookOnShelf && widget.item.id == itemId);
|
||||
expect(bookOnShelfFinder, findsOneWidget);
|
||||
final bookOnShelfWidget = tester.widget<BookOnShelf>(bookOnShelfFinder);
|
||||
return bookOnShelfWidget.showPlayButton;
|
||||
}
|
||||
|
||||
group('BookHomeShelf Play Button Visibility', () {
|
||||
late MockLibraryItem mockItem1;
|
||||
late MockLibraryItemShelf mockShelf;
|
||||
|
||||
setUp(() {
|
||||
mockItem1 = _createMockLibraryItem('item1');
|
||||
mockShelf = _createMockLibraryItemShelf([mockItem1]);
|
||||
});
|
||||
|
||||
testWidgets('Continue Shelves - Default: showPlayButton should be true',
|
||||
(WidgetTester tester) async {
|
||||
const appSettings = AppSettings(); // Default settings
|
||||
|
||||
await pumpBookHomeShelf(
|
||||
tester: tester,
|
||||
title: 'Continue Listening',
|
||||
shelf: mockShelf,
|
||||
appSettings: appSettings,
|
||||
);
|
||||
|
||||
expect(getShowPlayButtonForBookOnShelf(tester, 'item1'), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Continue Shelves - Hidden: showPlayButton should be false',
|
||||
(WidgetTester tester) async {
|
||||
const appSettings = AppSettings(
|
||||
homePageSettings: HomePageSettings(
|
||||
showPlayButtonOnContinueShelves: false,
|
||||
showPlayButtonOnAllShelves: false, // Keep others default
|
||||
),
|
||||
);
|
||||
|
||||
await pumpBookHomeShelf(
|
||||
tester: tester,
|
||||
title: 'Continue Series', // Another continue shelf title
|
||||
shelf: mockShelf,
|
||||
appSettings: appSettings,
|
||||
);
|
||||
|
||||
expect(getShowPlayButtonForBookOnShelf(tester, 'item1'), isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Other Shelves - Default: showPlayButton should be false',
|
||||
(WidgetTester tester) async {
|
||||
const appSettings = AppSettings(); // Default settings
|
||||
|
||||
await pumpBookHomeShelf(
|
||||
tester: tester,
|
||||
title: 'Discover',
|
||||
shelf: mockShelf,
|
||||
appSettings: appSettings,
|
||||
);
|
||||
|
||||
expect(getShowPlayButtonForBookOnShelf(tester, 'item1'), isFalse);
|
||||
});
|
||||
|
||||
testWidgets('Other Shelves - Shown: showPlayButton should be true',
|
||||
(WidgetTester tester) async {
|
||||
const appSettings = AppSettings(
|
||||
homePageSettings: HomePageSettings(
|
||||
showPlayButtonOnContinueShelves: true, // Keep others default
|
||||
showPlayButtonOnAllShelves: true,
|
||||
),
|
||||
);
|
||||
|
||||
await pumpBookHomeShelf(
|
||||
tester: tester,
|
||||
title: 'New Releases',
|
||||
shelf: mockShelf,
|
||||
appSettings: appSettings,
|
||||
);
|
||||
|
||||
expect(getShowPlayButtonForBookOnShelf(tester, 'item1'), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue