-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
possibility to change default music provider
- Loading branch information
Showing
8 changed files
with
687 additions
and
78 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,63 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
enum Service { | ||
spotify( | ||
name: "Spotify", | ||
iconPath: "assets/spotify.svg", | ||
fullName: "Spotify", | ||
searchUrl: 'https://open.spotify.com/search/', | ||
), | ||
apple( | ||
name: "Apple", | ||
iconPath: "assets/apple.svg", | ||
fullName: "Apple Music", | ||
searchUrl: 'https://music.apple.com/us/search?term=', | ||
), | ||
deezer( | ||
name: "Deezer", | ||
iconPath: "assets/deezer.svg", | ||
fullName: "Deezer", | ||
searchUrl: 'https://www.deezer.com/search/', | ||
); | ||
|
||
const Service({ | ||
required this.name, | ||
required this.iconPath, | ||
required this.fullName, | ||
required this.searchUrl, | ||
}); | ||
|
||
final String name; | ||
final String iconPath; | ||
final String fullName; | ||
final String searchUrl; | ||
} | ||
|
||
class ServiceNotifier extends ChangeNotifier { | ||
Service _currentService = Service.spotify; | ||
|
||
ServiceNotifier() { | ||
_initCurrentService(); | ||
} | ||
|
||
void _initCurrentService() async { | ||
final prefs = await SharedPreferences.getInstance(); | ||
|
||
int i = prefs.getInt('service') ?? 0; | ||
|
||
for (Service element in Service.values) { | ||
if (element.index == i) { | ||
currentService = element; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
Service get currentService => _currentService; | ||
|
||
set currentService(Service newService) { | ||
_currentService = newService; | ||
notifyListeners(); | ||
} | ||
} |
Oops, something went wrong.