Added settings page

This commit is contained in:
Imran Remtulla
2022-08-23 21:41:45 -04:00
parent 1a56806113
commit 0f7e3ec41d
6 changed files with 293 additions and 18 deletions

View File

@@ -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',

View 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;
}
}