4
4
*/
5
5
6
6
import 'dart:convert' ;
7
- import 'package:firebase_remote_config/firebase_remote_config.dart' ;
8
7
import 'package:flutter/material.dart' ;
9
8
import 'package:flutter_ui_challenges/core/data/favorite_firestore_service.dart' ;
10
9
import 'package:flutter_ui_challenges/core/data/models/menu.dart' ;
11
- import 'package:flutter_ui_challenges/core/data/models/survey.dart' ;
12
10
import 'package:flutter_ui_challenges/core/presentation/widgets/preview.dart' ;
13
- import 'package:flutter_ui_challenges/core/presentation/widgets/survey_widget.dart' ;
14
- import 'package:flutter_ui_challenges/features/announcements/data/model/announcement.dart' ;
15
- import 'package:flutter_ui_challenges/features/announcements/widgets/announcement_slider.dart' ;
16
11
import 'package:flutter_ui_challenges/features/auth/data/model/user.dart' ;
17
12
import 'package:flutter_ui_challenges/features/auth/data/model/user_repository.dart' ;
18
13
import 'package:package_info/package_info.dart' ;
@@ -26,24 +21,20 @@ class MainMenu extends StatefulWidget {
26
21
}
27
22
28
23
class _MainMenuState extends State <MainMenu > {
29
- RemoteConfig remoteConfig;
30
24
Map <String , bool > viewData = < String , bool > {};
31
- List <SubMenuItem > unseen;
32
25
bool viewDataLoaded;
26
+ List <SubMenuItem > unseen;
33
27
bool dialogShowing;
34
28
bool showNewUiDialog;
35
- List <Announcement > announcements;
36
- SurveyItem survey;
29
+
37
30
@override
38
31
void initState () {
39
32
super .initState ();
40
33
unseen = [];
41
34
viewDataLoaded = false ;
42
35
dialogShowing = false ;
43
36
showNewUiDialog = false ;
44
- announcements = [];
45
37
_getViewData ();
46
- _getRemoteConfig ();
47
38
}
48
39
49
40
_getViewData () async {
@@ -59,26 +50,6 @@ class _MainMenuState extends State<MainMenu> {
59
50
return ;
60
51
}
61
52
62
- _getRemoteConfig () async {
63
- if (remoteConfig == null )
64
- remoteConfig = await RemoteConfig .instance;
65
- final Map <String , dynamic > defaults = {
66
- "news" : "[]" ,
67
- "survey" : {},
68
- };
69
- await remoteConfig.setDefaults (defaults);
70
- await remoteConfig.fetch (expiration: const Duration (hours: 12 ));
71
- await remoteConfig.activateFetched ();
72
- final String value = remoteConfig.getString ('news' );
73
- final String surval = remoteConfig.getString ('survey' );
74
- setState (() {
75
- announcements = List <Map <String , dynamic >>.from (json.decode (value))
76
- .map ((data) => Announcement .fromMap (data))
77
- .toList ();
78
- survey = SurveyItem .fromMap (Map <String , dynamic >.from (json.decode (surval)));
79
- });
80
- }
81
-
82
53
_writeViewData () async {
83
54
SharedPreferences prefs = await SharedPreferences .getInstance ();
84
55
await prefs.setString ("page_view_data" , json.encode (viewData));
@@ -88,13 +59,10 @@ class _MainMenuState extends State<MainMenu> {
88
59
Widget build (BuildContext context) => _buildMenuPage ();
89
60
90
61
ListView _buildMenuPage () {
91
- User user = Provider .of <User >(context);
92
62
if (showNewUiDialog && viewDataLoaded) _checkToShowDialog (context);
93
63
return ListView (
94
64
physics: BouncingScrollPhysics (),
95
65
children: < Widget > [
96
- if (announcements.length > 0 ) AnnouncementSlider (news: announcements),
97
- if (survey != null && user != null && ! user.surveys.contains (survey? .id)) SurveyWidget (survey: survey),
98
66
...pages.map ((page) => page is MenuItem
99
67
? _buildExpandableMenu (page, context)
100
68
: _buildSubMenu (page, context))
0 commit comments