feat: vibration
This commit is contained in:
12
lib/utils/feed_back.dart
Normal file
12
lib/utils/feed_back.dart
Normal file
@ -0,0 +1,12 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/utils/storage.dart';
|
||||
|
||||
Box setting = GStrorage.setting;
|
||||
void feedBack() {
|
||||
// 设置中是否开启
|
||||
bool enable = setting.get(SettingBoxKey.feedBackEnable, defaultValue: false);
|
||||
if (enable) {
|
||||
HapticFeedback.lightImpact();
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,7 @@ class GStrorage {
|
||||
static late final Box hotKeyword;
|
||||
static late final Box historyword;
|
||||
static late final Box localCache;
|
||||
static late final Box setting;
|
||||
|
||||
static Future<void> init() async {
|
||||
final dir = await getApplicationDocumentsDirectory();
|
||||
@ -27,6 +28,8 @@ class GStrorage {
|
||||
userInfo = await Hive.openBox('userInfo');
|
||||
// 本地缓存
|
||||
localCache = await Hive.openBox('localCache');
|
||||
// 设置
|
||||
setting = await Hive.openBox('setting');
|
||||
}
|
||||
|
||||
static regAdapter() {
|
||||
@ -61,6 +64,7 @@ class UserBoxKey {
|
||||
|
||||
class SettingBoxKey {
|
||||
static const String themeMode = 'themeMode';
|
||||
static const String feedBackEnable = 'feedBackEnable';
|
||||
}
|
||||
|
||||
class LocalCacheKey {
|
||||
|
||||
Reference in New Issue
Block a user