diff --git a/lib/settings/layouts.dart b/lib/settings/layouts.dart index d75ea77..dfd2881 100644 --- a/lib/settings/layouts.dart +++ b/lib/settings/layouts.dart @@ -3,12 +3,12 @@ import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; import '../local_storage/key_value_storage.dart'; +import '../service/search_api.dart'; import '../state/audio_state.dart'; import '../util/custom_dropdown.dart'; import '../util/custom_widget.dart'; import '../util/episodegrid.dart'; import '../util/extension_helper.dart'; -import '../service/search_api.dart'; import 'popup_menu.dart'; class LayoutSetting extends StatefulWidget { @@ -49,7 +49,7 @@ class _LayoutSettingState extends State { Future _getSearchEngine() async { final storage = KeyValueStorage(searchEngineKey); - final index = await storage.getInt(defaultValue: 1); + final index = await storage.getInt(defaultValue: 0); return SearchEngine.values[index]; } @@ -266,7 +266,7 @@ class _LayoutSettingState extends State { height: 30.0, padding: EdgeInsets.symmetric(horizontal: 70), alignment: Alignment.centerLeft, - child: Text('Podcast search', + child: Text(s.search, style: context.textTheme.bodyText1 .copyWith(color: context.accentColor)), ), @@ -276,8 +276,8 @@ class _LayoutSettingState extends State { builder: (context, snapshot) => ListTile( contentPadding: EdgeInsets.fromLTRB(70, 10, 10, 10), onTap: () => _saveHideDiscovery(!snapshot.data), - title: Text('Hide podcast discovery'), - subtitle: Text('Hide podcast discovery in search page'), + title: Text(s.hidePodcastDiscovery), + subtitle: Text(s.hidePodcastDiscoveryDes), trailing: Transform.scale( scale: 0.9, child: Switch( @@ -290,20 +290,20 @@ class _LayoutSettingState extends State { initialData: SearchEngine.listenNotes, builder: (context, snapshot) => ListTile( contentPadding: EdgeInsets.fromLTRB(70, 10, 10, 10), - title: Text('Default search engine'), - subtitle: Text('Choose default search engine'), + title: Text(s.defaultSearchEngine), + subtitle: Text(s.defaultSearchEngineDes), trailing: MyDropdownButton( hint: Text(''), underline: Center(), elevation: 1, value: snapshot.data, items: [ + DropdownMenuItem( + value: SearchEngine.podcastIndex, + child: Text('Podcastindex')), DropdownMenuItem( value: SearchEngine.listenNotes, child: Text('ListenNotes')), - DropdownMenuItem( - value: SearchEngine.podcastIndex, - child: Text('PodcastIndex')), ], onChanged: (value) => _saveSearchEngine(value)), ), diff --git a/lib/state/setting_state.dart b/lib/state/setting_state.dart index 6274b55..63150f3 100644 --- a/lib/state/setting_state.dart +++ b/lib/state/setting_state.dart @@ -494,6 +494,8 @@ class SettingState extends ChangeNotifier { await KeyValueStorage(notificationLayoutKey).getInt(defaultValue: 0); var showNotesFont = await showNotesFontStorage.getInt(defaultValue: 1); var speedList = await KeyValueStorage(speedListKey).getStringList(); + var hidePodcastDiscovery = await KeyValueStorage(hidePodcastDiscoveryKey) + .getBool(defaultValue: false); return SettingsBackup( theme: theme, @@ -524,7 +526,8 @@ class SettingState extends ChangeNotifier { hideListened: hideListened, notificationLayout: notificationLayout, showNotesFont: showNotesFont, - speedList: speedList); + speedList: speedList, + hidePodcastDiscovery: hidePodcastDiscovery); } Future restore(SettingsBackup backup) async { diff --git a/lib/type/settings_backup.dart b/lib/type/settings_backup.dart index 55684d2..fadc9f3 100644 --- a/lib/type/settings_backup.dart +++ b/lib/type/settings_backup.dart @@ -28,6 +28,8 @@ class SettingsBackup { final int notificationLayout; final int showNotesFont; final List speedList; + final bool hidePodcastDiscovery; + SettingsBackup( {this.theme, this.accentColor, @@ -57,7 +59,8 @@ class SettingsBackup { this.hideListened, this.notificationLayout, this.showNotesFont, - this.speedList}); + this.speedList, + this.hidePodcastDiscovery}); Map toJson() { return { @@ -88,7 +91,8 @@ class SettingsBackup { 'hideListened': hideListened, 'notificationLayout': notificationLayout, 'showNotesFont': showNotesFont, - 'speedList': speedList + 'speedList': speedList, + 'hidePodcastDiscovery': hidePodcastDiscovery }; } @@ -123,6 +127,7 @@ class SettingsBackup { hideListened: json['hideListened'] as bool, notificationLayout: json['notificationLayout'] as int, showNotesFont: json['showNotesFont'] as int, - speedList: speedList); + speedList: speedList, + hidePodcastDiscovery: json['hidePodcastDiscovery'] as bool); } }