-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20eccd5
commit 88efb1c
Showing
12 changed files
with
179 additions
and
34 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:saavn/apis/song_api.dart'; | ||
import 'package:saavn/models/song_model.dart'; | ||
|
||
final searchControllerProvider = | ||
StateNotifierProvider<SearchController, bool>((ref) { | ||
return SearchController( | ||
songAPI: ref.watch(songAPIProvider), | ||
); | ||
}); | ||
|
||
class SearchController extends StateNotifier<bool> { | ||
final SongAPI _songAPI; | ||
|
||
SearchController({required SongAPI songAPI}) | ||
: _songAPI = songAPI, | ||
super(false); | ||
|
||
// ADD SEARCH METHODS | ||
|
||
Future<List<SongModel>> searchSong({required String query}) async { | ||
List<SongModel> songs = []; | ||
final fetchedsongs = await _songAPI.fetchSearchData(query: query); | ||
|
||
fetchedsongs.fold((l) { | ||
throw Error.throwWithStackTrace(l.message, l.stackTrace); | ||
}, (r) => songs = r); | ||
|
||
return songs; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:saavn/functions/search/widgets/searchbar.dart'; | ||
|
||
class SearchView extends ConsumerStatefulWidget { | ||
const SearchView({super.key}); | ||
|
||
@override | ||
ConsumerState<ConsumerStatefulWidget> createState() => _SearchViewState(); | ||
} | ||
|
||
class _SearchViewState extends ConsumerState<SearchView> { | ||
final TextEditingController _searchController = TextEditingController(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Column( | ||
children: [ | ||
BaseSearchBar( | ||
controller: _searchController, | ||
onChanged: (value) {}, | ||
onSubmit: (value) {}, | ||
), | ||
const Expanded( | ||
child: Center( | ||
child: Text('Search results will be displayed here!'), | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class BaseSearchBar extends StatelessWidget { | ||
final TextEditingController controller; | ||
final void Function(String)? onSubmit; | ||
final void Function(String)? onChanged; | ||
|
||
const BaseSearchBar({ | ||
super.key, | ||
required this.controller, | ||
required this.onSubmit, | ||
required this.onChanged, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Container( | ||
decoration: BoxDecoration( | ||
border: Border.all( | ||
width: 2, | ||
color: Theme.of(context).primaryColorDark.withOpacity(.2), | ||
), | ||
borderRadius: BorderRadius.circular(25), | ||
), | ||
margin: const EdgeInsets.all(16), | ||
padding: const EdgeInsets.symmetric(horizontal: 7), | ||
child: TextField( | ||
decoration: InputDecoration( | ||
hintText: 'Search', | ||
border: InputBorder.none, | ||
contentPadding: const EdgeInsets.all(10), | ||
suffixIcon: IconButton( | ||
onPressed: () {}, | ||
icon: const Icon(Icons.search), | ||
), | ||
), | ||
controller: controller, | ||
onSubmitted: onSubmit, | ||
onChanged: onChanged, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:audio_session/audio_session.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:system_theme/system_theme.dart'; | ||
import 'package:window_manager/window_manager.dart'; | ||
|
||
Future<void> initialiseAppFunctions() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
await SystemTheme.accentColor.load(); | ||
await initWindowManager(); | ||
final session = await AudioSession.instance; | ||
await session.configure(const AudioSessionConfiguration.speech()); | ||
} | ||
|
||
Future<void> initWindowManager() async { | ||
await windowManager.ensureInitialized(); | ||
|
||
WindowOptions windowOptions = const WindowOptions( | ||
center: true, | ||
title: "Saavn Music Desktop", | ||
); | ||
windowManager.waitUntilReadyToShow(windowOptions, () async { | ||
await windowManager.show(); | ||
await windowManager.focus(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters