mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-19 05:00:21 +02:00
Added settings page
This commit is contained in:
@@ -51,7 +51,8 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> notify(int id, String title, String message, String channelCode,
|
||||
String channelName, String channelDescription) {
|
||||
String channelName, String channelDescription,
|
||||
{bool important = true}) {
|
||||
return downloaderNotifications.show(
|
||||
id,
|
||||
title,
|
||||
@@ -59,8 +60,8 @@ class AppsProvider with ChangeNotifier {
|
||||
NotificationDetails(
|
||||
android: AndroidNotificationDetails(channelCode, channelName,
|
||||
channelDescription: channelDescription,
|
||||
importance: Importance.max,
|
||||
priority: Priority.max,
|
||||
importance: important ? Importance.max : Importance.min,
|
||||
priority: important ? Priority.max : Priority.min,
|
||||
groupKey: 'dev.imranr.obtainium.$channelCode')));
|
||||
}
|
||||
|
||||
@@ -98,6 +99,7 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
if (!isForeground) {
|
||||
await downloaderNotifications.cancel(1);
|
||||
await notify(
|
||||
1,
|
||||
'Complete App Installation',
|
||||
|
47
lib/services/settings_provider.dart
Normal file
47
lib/services/settings_provider.dart
Normal file
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
enum ThemeSettings { system, light, dark }
|
||||
|
||||
enum ColourSettings { basic, materialYou }
|
||||
|
||||
class SettingsProvider with ChangeNotifier {
|
||||
SharedPreferences? prefs;
|
||||
|
||||
String sourceUrl = 'https://github.com/ImranR98/Obtainium';
|
||||
|
||||
// Not done in constructor as we want to be able to await it
|
||||
Future<void> initializeSettings() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
ThemeSettings get theme {
|
||||
return ThemeSettings
|
||||
.values[prefs?.getInt('theme') ?? ThemeSettings.system.index];
|
||||
}
|
||||
|
||||
set theme(ThemeSettings t) {
|
||||
print(t);
|
||||
prefs?.setInt('theme', t.index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
ColourSettings get colour {
|
||||
return ColourSettings
|
||||
.values[prefs?.getInt('colour') ?? ColourSettings.basic.index];
|
||||
}
|
||||
|
||||
set colour(ColourSettings t) {
|
||||
prefs?.setInt('colour', t.index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
checkAndFlipFirstRun() {
|
||||
bool result = prefs?.getBool('firstRun') ?? true;
|
||||
if (result) {
|
||||
prefs?.setBool('firstRun', false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user