@@ -8,18 +8,21 @@ import 'package:covid_statistic/model/app_state.dart';
88import 'package:covid_statistic/model/covid_info.dart' ;
99import 'package:covid_statistic/model/country_info.dart' ;
1010import 'package:covid_statistic/model/main_info.dart' ;
11+ import 'package:covid_statistic/model/prevention.dart' ;
1112import 'package:covid_statistic/pages/main/main_drop.dart' ;
1213import 'package:covid_statistic/pages/main/precautions/precaution_grid.dart' ;
1314import 'package:covid_statistic/pages/main/stats/pandemic_view.dart' ;
1415import 'package:covid_statistic/pages/main/top_country/country_stats.dart' ;
15- import 'package:covid_statistic/utils/app_theme.dart' ;
16+ import 'package:covid_statistic/utils/themes/app_theme.dart' ;
17+ import 'package:covid_statistic/utils/constant.dart' ;
1618import 'package:covid_statistic/utils/local_utils.dart' ;
1719import 'package:covid_statistic/utils/utility.dart' ;
1820import 'package:covid_statistic/view_model/main_vm.dart' ;
1921import 'package:flutter/cupertino.dart' ;
2022import 'package:flutter/material.dart' ;
2123import 'package:frideos/frideos.dart' ;
2224import 'package:google_fonts/google_fonts.dart' ;
25+ import 'package:shared_preferences/shared_preferences.dart' ;
2326
2427class MainPage extends StatefulWidget {
2528 const MainPage ({Key key}) : super (key: key);
@@ -50,8 +53,6 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
5053 });
5154
5255 super .initState ();
53-
54- addAllListData ();
5556 viewModel.getCountryPandemic ();
5657 }
5758
@@ -73,7 +74,7 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
7374 value: snapshot.data,
7475 onChanged: viewModel.mainInfoChanged,
7576 ),
76- subTxt: 'Details' ,
77+ subTxt: S . of (context).details ,
7778 animation: Tween <double >(begin: 0.0 , end: 1.0 ).animate (
7879 CurvedAnimation (
7980 parent: animationController,
@@ -119,7 +120,7 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
119120 builder: (context, AsyncSnapshot <bool > snapshot) {
120121 if (! snapshot.hasData || ! snapshot.data) {
121122 return Text (
122- 'Top Infected Countries' ,
123+ S . of (context).topInfectedCountries ,
123124 textAlign: TextAlign .left,
124125 style: GoogleFonts .roboto (
125126 fontWeight: FontWeight .w500,
@@ -136,7 +137,7 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
136137 },
137138 ),
138139 ),
139- subTxt: 'More' ,
140+ subTxt: S . of (context).more ,
140141 onViewMore: () {
141142 HUD .showMessage (context, text: 'See more at https://disease.sh/v3' );
142143 },
@@ -170,7 +171,7 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
170171 listViews.add (
171172 TitleView (
172173 title: Text (
173- 'Precautions' ,
174+ S . of (context).precautions ,
174175 textAlign: TextAlign .left,
175176 style: GoogleFonts .roboto (
176177 fontWeight: FontWeight .w500,
@@ -179,7 +180,7 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
179180 color: AppTheme .lightText,
180181 ),
181182 ),
182- subTxt: 'More' ,
183+ subTxt: S . of (context).more ,
183184 onViewMore: () {
184185 HUD .showMessage (context, text: 'View more' );
185186 },
@@ -198,12 +199,40 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
198199 curve:
199200 Interval ((1 / count) * 5 , 1.0 , curve: Curves .fastOutSlowIn))),
200201 animationController: animationController,
202+ preventions: [
203+ Prevention (
204+ prevention: S .of (context).protectiveMask,
205+ description: S .of (context).protectiveMaskDesc,
206+ imagePath: 'assets/prevention/mask.png' ),
207+ Prevention (
208+ prevention: S .of (context).washHands,
209+ description: S .of (context).washHandsDesc,
210+ imagePath: 'assets/prevention/wash.png' ),
211+ Prevention (
212+ prevention: S .of (context).coverCough,
213+ description: S .of (context).coverCoughDesc,
214+ imagePath: 'assets/prevention/coughCover.png' ),
215+ Prevention (
216+ prevention: S .of (context).sanitizeOften,
217+ description: S .of (context).sanitizeOftenDesc,
218+ imagePath: 'assets/prevention/sanitizer.png' ),
219+ Prevention (
220+ prevention: S .of (context).noFaceTouching,
221+ description: S .of (context).noFaceTouchingDesc,
222+ imagePath: 'assets/prevention/touch.png' ),
223+ Prevention (
224+ prevention: S .of (context).socialDistancing,
225+ description: S .of (context).socialDistancingDesc,
226+ imagePath: 'assets/prevention/socialDistance.png' ),
227+ ],
201228 ),
202229 );
203230 }
204231
205232 @override
206233 Widget build (BuildContext context) {
234+ if (listViews.isEmpty) addAllListData ();
235+
207236 final language = AppStateProvider .of <AppState >(context).languageCode;
208237
209238 return WillPopScope (
@@ -220,8 +249,10 @@ class _MainPage extends State<MainPage> with TickerProviderStateMixin {
220249 actions: [
221250 LocaleDropDown (
222251 locale: LocalizationUtils .locale (language.value),
223- onChanged: (String newValue) {
252+ onChanged: (String newValue) async {
224253 language.value = newValue;
254+ var prefs = await SharedPreferences .getInstance ();
255+ prefs.setString (Constant .language, newValue);
225256 },
226257 )
227258 ],
0 commit comments