From 355fe96b2a4c7821256d9e8828d2cb9539904878 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 05 五月 2022 19:29:16 +0800 Subject: [PATCH] 功能完善 --- flutter_module/lib/utils/setting_util.dart | 50 +++++++++++++++++++++++++------------------------- 1 files changed, 25 insertions(+), 25 deletions(-) diff --git a/flutter_module/lib/utils/setting_util.dart b/flutter_module/lib/utils/setting_util.dart index cf0b872..d74dd60 100644 --- a/flutter_module/lib/utils/setting_util.dart +++ b/flutter_module/lib/utils/setting_util.dart @@ -1,46 +1,46 @@ - +import 'package:makemoney/utils/share_preference.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SettingUtil { //璁剧疆鎺ㄩ�� static Future<bool> setPush(bool enable) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setBool("setting_push", enable); + await _setSetting("pushUnDisturb", enable); + return true; } ///鏄惁鍏佽鎺ㄩ�� - static Future<bool> isEnablePush() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - bool? result = prefs.getBool("setting_push"); - result ??= true; - return result; + static Future<bool?> isEnablePush() async { + return await _getSetting("pushUnDisturb"); } //璁剧疆鎺ㄨ崘骞垮憡 static Future<bool> setRecommendAd(bool enable) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setBool("setting_recommend_ad", enable); + await _setSetting("adRecommend", enable); + return true; } ///鏄惁鍏佽鎺ㄨ崘骞垮憡 - static Future<bool> isEnableRecommendAd() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - bool? result = prefs.getBool("setting_recommend_ad"); - result ??= true; - return result; + static Future<bool?> isEnableRecommendAd() async { + return await _getSetting("adRecommend"); } - //璁剧疆鎺ㄨ崘骞垮憡 - static Future<bool> setLocationSpan(int second) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - return await prefs.setInt("setting_location_span", second); + //璁剧疆鎺ㄨ崘鍐呭 + static Future<bool> setRecommendContent(bool enable) async { + await _setSetting("contentRecommend", enable); + return true; } - ///鏄惁鍏佽鎺ㄨ崘骞垮憡 - static Future<int> getLocationSpan() async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - int? result = prefs.getInt("setting_location_span"); - result ??= 30; - return result; + ///鏄惁鍏佽鎺ㄨ崘鍐呭 + static Future<bool?> isEnableRecommendContent() async { + return await _getSetting("contentRecommend"); + } + + static _setSetting(String key, bool value) async { + await dataMethodChannel + .invokeMethod("setSetting", {"key": key, "value": value}); + } + + static Future<bool?> _getSetting(String key) async { + return await dataMethodChannel.invokeMethod("getSetting", key); } } -- Gitblit v1.8.0