Corrections

This commit is contained in:
Gregory
2024-01-03 14:39:33 +03:00
parent c9e17ed42b
commit b74bf86277
10 changed files with 60 additions and 50 deletions

View File

@@ -4,8 +4,8 @@ import 'package:flutter/services.dart';
class NativeFeatures {
static const MethodChannel _channel = MethodChannel('native');
static bool _callbacksApplied = false;
static bool _systemFontLoaded = false;
static bool _callbacksApplied = false;
static int _resPermShizuku = -2; // not set
static Future<ByteData> _readFileBytes(String path) async {
@@ -34,15 +34,15 @@ class NativeFeatures {
return completer.future;
}
static Future<bool> tryLoadSystemFont() async {
if (_systemFontLoaded) { return true; }
var font = await _channel.invokeMethod('getSystemFont');
if (font == null) { return false; }
static Future<String> loadSystemFont() async {
if (_systemFontLoaded) { return "ok"; }
var getFontRes = await _channel.invokeMethod('getSystemFont');
if (getFontRes[0] != '/') { return getFontRes; } // Error
var fontLoader = FontLoader('SystemFont');
fontLoader.addFont(_readFileBytes(font));
fontLoader.addFont(_readFileBytes(getFontRes));
await fontLoader.load();
_systemFontLoaded = true;
return true;
return "ok";
}
static Future<int> checkPermissionShizuku() async {

View File

@@ -51,21 +51,12 @@ class SettingsProvider with ChangeNotifier {
notifyListeners();
}
String get appFont {
return prefs?.getString('appFont') ?? 'Metropolis';
bool get useSystemFont {
return prefs?.getBool('useSystemFont') ?? false;
}
set appFont(String appFont) {
prefs?.setString('appFont', appFont);
notifyListeners();
}
bool get tryUseSystemFont {
return prefs?.getBool('tryUseSystemFont') ?? false;
}
set tryUseSystemFont(bool tryUseSystemFont) {
prefs?.setBool('tryUseSystemFont', tryUseSystemFont);
set useSystemFont(bool useSystemFont) {
prefs?.setBool('useSystemFont', useSystemFont);
notifyListeners();
}