Repository navigation
Expand file tree
/
Copy pathGSYState.dart
More file actions
61 lines (48 loc) · 2.06 KB
/
Copy pathGSYState.dart
File metadata and controls
61 lines (48 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import 'package:flutter/material.dart';
import 'package:gsy_github_app_flutter/common/model/Event.dart';
import 'package:gsy_github_app_flutter/common/model/TrendingRepoModel.dart';
import 'package:gsy_github_app_flutter/common/model/User.dart';
import 'package:gsy_github_app_flutter/common/redux/UserRedux.dart';
import 'package:gsy_github_app_flutter/common/redux/EventRedux.dart';
import 'package:gsy_github_app_flutter/common/redux/TrendRedux.dart';
import 'package:gsy_github_app_flutter/common/redux/ThemeRedux.dart';
import 'package:gsy_github_app_flutter/common/redux/LocaleRedux.dart';
/**
* Redux全局State
* Created by guoshuyu
* Date: 2018-07-16
*/
///全局Redux store 的对象,保存State数据
class GSYState {
///用户信息
User userInfo;
///用户接受到的事件列表
List<Event> eventList = new List();
///用户接受到的事件列表
List<TrendingRepoModel> trendList = new List();
///主题数据
ThemeData themeData;
///语言
Locale locale;
///当前手机平台默认语言
Locale platformLocale;
///构造方法
GSYState({this.userInfo, this.eventList, this.trendList, this.themeData, this.locale});
}
///创建 Reducer
///源码中 Reducer 是一个方法 typedef State Reducer<State>(State state, dynamic action);
///我们自定义了 appReducer 用于创建 store
GSYState appReducer(GSYState state, action) {
return GSYState(
///通过 UserReducer 将 GSYState 内的 userInfo 和 action 关联在一起
userInfo: UserReducer(state.userInfo, action),
///通过 EventReducer 将 GSYState 内的 eventList 和 action 关联在一起
eventList: EventReducer(state.eventList, action),
///通过 TrendReducer 将 GSYState 内的 trendList 和 action 关联在一起
trendList: TrendReducer(state.trendList, action),
///通过 ThemeDataReducer 将 GSYState 内的 themeData 和 action 关联在一起
themeData: ThemeDataReducer(state.themeData, action),
///通过 LocaleReducer 将 GSYState 内的 locale 和 action 关联在一起
locale: LocaleReducer(state.locale, action),
);
}