forked from lxm_flutter/FlutterUnit
✨ 过时组件显示优化,数据库结构优化
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_unit/app/res/cons.dart';
|
||||
import 'package:flutter_unit/app/res/sp.dart';
|
||||
import 'package:flutter_unit/repositories/app_storage.dart';
|
||||
import 'package:flutter_unit/repositories/app_start.dart';
|
||||
import 'package:flutter_unit/repositories/local_storage.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'global_event.dart';
|
||||
@@ -13,11 +14,11 @@ import 'global_state.dart';
|
||||
|
||||
class GlobalBloc extends Bloc<GlobalEvent, GlobalState> {
|
||||
|
||||
final AppStorage storage;
|
||||
final AppStart storage;
|
||||
|
||||
GlobalBloc(this.storage):super(GlobalState());
|
||||
|
||||
Future<SharedPreferences> get sp => storage.sp;
|
||||
Future<SharedPreferences> get sp => LocalStorage.sp;
|
||||
|
||||
@override
|
||||
Stream<GlobalState> mapEventToState(GlobalEvent event) async* {
|
||||
@@ -29,8 +30,7 @@ class GlobalBloc extends Bloc<GlobalEvent, GlobalState> {
|
||||
// 切换字体事件处理 : 固化索引 + 产出新状态
|
||||
if (event is EventSwitchFontFamily) {
|
||||
int familyIndex = Cons.fontFamilySupport.indexOf(event.family);
|
||||
await sp
|
||||
..setInt(SP.fontFamily, familyIndex);
|
||||
await sp..setInt(SP.fontFamily, familyIndex);
|
||||
yield state.copyWith(fontFamily: event.family);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user