Skip to content

feat: add gnome style type to search #1164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions lib/app/app_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class AppModel extends SafeChangeNotifier {
bool? _updateAvailable;
bool? get updateAvailable => _updateAvailable;
String? _onlineVersion;

String? get onlineVersion => _onlineVersion;
Future<void> checkForUpdate({
required bool isOnline,
Expand Down
88 changes: 66 additions & 22 deletions lib/app/view/desktop_home_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:watch_it/watch_it.dart';

import '../../app_config.dart';
import '../../common/page_ids.dart';
import '../../common/view/ui_constants.dart';
import '../../custom_content/view/backup_dialog.dart';
import '../../extensions/build_context_x.dart';
Expand All @@ -12,6 +14,7 @@ import '../../player/player_model.dart';
import '../../player/view/player_view.dart';
import '../../podcasts/download_model.dart';
import '../../podcasts/podcast_model.dart';
import '../../search/search_model.dart';
import '../../podcasts/view/podcast_state_stream_handler.dart';
import '../app_model.dart';
import '../connectivity_model.dart';
Expand Down Expand Up @@ -58,6 +61,37 @@ class _DesktopHomePageState extends State<DesktopHomePage> {
});
}

void _onTypeHandler(KeyEvent event) {
if (!AppConfig.isGtkApp || event.logicalKey == LogicalKeyboardKey.control) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please also check for mac os (CMD) and windows (control)

return;
}

final character = event.character;
if (event is! KeyDownEvent || character == null || character.isEmpty) {
return;
}

if (FocusManager.instance.primaryFocus?.context?.widget is! FocusScope) {
return;
}

_performSearch(character);
}

void _performSearch([String? query]) {
final libraryModel = di<LibraryModel>();
final audioType = libraryModel.getCurrentAudioType();
final searchModel = di<SearchModel>()..setAudioType(audioType);

if (query != null) {
searchModel.setSearchQuery(query);
}

searchModel.search();
libraryModel.push(pageId: PageIDs.searchPage);
}

final keyboardListenerFocus = FocusNode();
@override
Widget build(BuildContext context) {
final playerToTheRight = context.mediaQuerySize.width > kSideBarThreshHold;
Expand All @@ -84,33 +118,43 @@ class _DesktopHomePageState extends State<DesktopHomePage> {
handler: onConnectivityChangedHandler,
);

return Stack(
alignment: Alignment.center,
children: [
Row(
return KeyboardListener(
focusNode: keyboardListenerFocus,
onKeyEvent: _onTypeHandler,
child: CallbackShortcuts(
bindings: {
LogicalKeySet(LogicalKeyboardKey.control, LogicalKeyboardKey.keyF):
() => _performSearch(),
},
child: Stack(
alignment: Alignment.center,
children: [
Expanded(
child: Column(
children: [
const Expanded(child: MasterDetailPage()),
if (!playerToTheRight || AppConfig.isMobilePlatform)
const PlayerView(position: PlayerPosition.bottom),
],
),
Row(
children: [
Expanded(
child: Column(
children: [
const Expanded(child: MasterDetailPage()),
if (!playerToTheRight || AppConfig.isMobilePlatform)
const PlayerView(position: PlayerPosition.bottom),
],
),
),
if (playerToTheRight)
const SizedBox(
width: kSideBarPlayerWidth,
child: PlayerView(position: PlayerPosition.sideBar),
),
],
),
if (playerToTheRight)
const SizedBox(
width: kSideBarPlayerWidth,
child: PlayerView(position: PlayerPosition.sideBar),
if (isFullScreen == true)
Scaffold(
backgroundColor: isVideo ? Colors.black : null,
body: const PlayerView(position: PlayerPosition.fullWindow),
),
],
),
if (isFullScreen == true)
Scaffold(
backgroundColor: isVideo ? Colors.black : null,
body: const PlayerView(position: PlayerPosition.fullWindow),
),
],
),
);
}
}
7 changes: 7 additions & 0 deletions lib/library/library_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:safe_change_notifier/safe_change_notifier.dart';
import '../app/view/mobile_page.dart';
import '../app_config.dart';
import '../common/data/audio.dart';
import '../common/data/audio_type.dart';
import '../common/logging.dart';
import '../common/page_ids.dart';
import '../common/view/back_gesture.dart';
Expand Down Expand Up @@ -311,4 +312,10 @@ class LibraryModel extends SafeChangeNotifier implements NavigatorObserver {
final GlobalKey<NavigatorState> _masterNavigatorKey =
GlobalKey<NavigatorState>();
GlobalKey<NavigatorState> get masterNavigatorKey => _masterNavigatorKey;

AudioType getCurrentAudioType() => switch (selectedPageId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this sadly doesnt always work, as starred stations and subbed podcasts also are put into the sidebar and can be selected :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but you could add a function which uses something like isPageInLibrary like checking playlists, podcasts, starredStations, pinnedAlbums and the main page ids

PageIDs.podcasts => AudioType.podcast,
PageIDs.radio => AudioType.radio,
_ => AudioType.local
};
}
2 changes: 2 additions & 0 deletions lib/search/search_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ class SearchModel extends SafeChangeNotifier {
}

SearchResult? _podcastChartsPeak;

FocusNode fieldFocusNode = FocusNode();
SearchResult? get podcastChartsPeak => _podcastChartsPeak;
Future<void> fetchPodcastChartsPeak({int limit = 3}) async {
_podcastChartsPeak =
Expand Down