Line data Source code
1 : import 'package:fast_immutable_collections/fast_immutable_collections.dart';
2 : import 'package:freezed_annotation/freezed_annotation.dart';
3 : import 'package:redfire/types.dart';
4 :
5 : import 'organisations/models/organisations_section_model.dart';
6 : import 'projects/models/projects_section.dart';
7 : import 'projects/models/sections_v_m.dart';
8 : import 'teams/models/team_member.dart';
9 :
10 : part 'app_state.freezed.dart';
11 : part 'app_state.g.dart';
12 :
13 : @freezed
14 : class AppState with _$AppState, RedFireState {
15 : factory AppState({
16 : /// RedFire
17 : @PageDataConverter() required IList<PageData> pages,
18 : required IList<ProblemInfo> problems,
19 : required Settings settings,
20 : required AuthState auth,
21 :
22 : /// Profile
23 : ProfileData? profile,
24 :
25 : /// Organisations
26 : required OrganisationsSectionModel organisations,
27 :
28 : /// Projects
29 : required ProjectsSection projects,
30 :
31 : /// Sections
32 : required SectionsVM sections,
33 :
34 : /// Teams
35 : TeamMember? teamMember,
36 : }) = _AppState;
37 :
38 12 : factory AppState.init() => AppState(
39 6 : auth: AuthState.init(),
40 12 : pages: <PageData>[const InitialPageData()].lock,
41 6 : problems: IList(),
42 6 : settings: Settings.init(),
43 :
44 : /// Projects
45 6 : projects: ProjectsSection.init(),
46 :
47 : /// Sections
48 6 : sections: SectionsVM.init(),
49 :
50 : /// Organisations
51 6 : organisations: OrganisationsSectionModel.init(),
52 : );
53 :
54 0 : factory AppState.fromJson(JsonMap json) => _$AppStateFromJson(json);
55 : }
|