Sfoglia il codice sorgente

Sprint 2 // User Story

Translate a  English y Spanish el app
carlos.perez25 3 anni fa
parent
commit
8b97f8a042
1 ha cambiato i file con 109 aggiunte e 0 eliminazioni
  1. 109
    0
      Carlos/main.dart.rtf

+ 109
- 0
Carlos/main.dart.rtf Vedi File

@@ -0,0 +1,109 @@
1
+{\rtf1\ansi\ansicpg1252\cocoartf2577
2
+\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;\f1\fnil\fcharset0 Menlo-Italic;}
3
+{\colortbl;\red255\green255\blue255;\red191\green100\blue38;\red32\green32\blue32;\red88\green118\blue71;
4
+\red254\green187\blue91;\red153\green168\blue186;\red173\green169\blue32;\red133\green96\blue154;\red86\green132\blue173;
5
+}
6
+{\*\expandedcolortbl;;\csgenericrgb\c74902\c39216\c14902;\csgenericrgb\c12549\c12549\c12549;\csgenericrgb\c34510\c46275\c27843;
7
+\csgenericrgb\c99608\c73333\c35686;\csgenericrgb\c60000\c65882\c72941;\csgenericrgb\c67843\c66275\c12549;\csgenericrgb\c52157\c37647\c60392;\csgenericrgb\c33725\c51765\c67843;
8
+}
9
+\margl1440\margr1440\vieww11520\viewh8400\viewkind0
10
+\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
11
+
12
+\f0\fs24 \cf2 \cb3 import \cf4 'package:flutter/material.dart'\cf2 ;\
13
+import \cf4 'package:userstory2translate/localization/localization.dart'\cf2 ;\
14
+import \cf4 'package:userstory2translate/router/custom_router.dart'\cf2 ;\
15
+import \cf4 'package:userstory2translate/router/route_constants.dart'\cf2 ;\
16
+import \cf4 'package:flutter_localizations/flutter_localizations.dart'\cf2 ;\
17
+\
18
+import \cf4 'localization/language_constants.dart'\cf2 ;\
19
+\
20
+void \cf5 main\cf6 () => runApp(\cf5 MyApp\cf6 ())\cf2 ;\
21
+\
22
+class \cf6 MyApp \cf2 extends \cf6 StatefulWidget \{\
23
+  \cf2 const \cf6 MyApp(\{Key key\}) : \cf2 super\cf6 (key: key)\cf2 ;\
24
+  static void 
25
+\f1\i \cf5 setLocale
26
+\f0\i0 \cf6 (BuildContext context\cf2 , \cf6 Locale newLocale) \{\
27
+    _MyAppState state = context.findAncestorStateOfType<_MyAppState>()\cf2 ;\
28
+    \cf6 state.setLocale(newLocale)\cf2 ;\
29
+  \cf6 \}\
30
+\
31
+  \cf7 @override\
32
+  \cf6 _MyAppState \cf5 createState\cf6 () => \cf5 _MyAppState\cf6 ()\cf2 ;\
33
+\cf6 \}\
34
+\
35
+\cf2 class \cf6 _MyAppState \cf2 extends \cf6 State<MyApp> \{\
36
+  Locale \cf8 _locale\cf2 ;\
37
+  \cf5 setLocale\cf6 (Locale locale) \{\
38
+    setState(() \{\
39
+      \cf8 _locale \cf6 = locale\cf2 ;\
40
+    \cf6 \})\cf2 ;\
41
+  \cf6 \}\
42
+\
43
+  \cf7 @override\
44
+  \cf2 void \cf5 didChangeDependencies\cf6 () \{\
45
+    getLocale().then((locale) \{\
46
+      setState(() \{\
47
+        \cf2 this\cf6 .\cf8 _locale \cf6 = locale\cf2 ;\
48
+      \cf6 \})\cf2 ;\
49
+    \cf6 \})\cf2 ;\
50
+    super\cf6 .didChangeDependencies()\cf2 ;\
51
+  \cf6 \}\
52
+\
53
+  \cf7 @override\
54
+  \cf6 Widget \cf5 build\cf6 (BuildContext context) \{\
55
+    \cf2 if \cf6 (\cf2 this\cf6 .\cf8 _locale \cf6 == \cf2 null\cf6 ) \{\
56
+      \cf2 return \cf5 Container\cf6 (\
57
+        child: \cf5 Center\cf6 (\
58
+          child: \cf5 CircularProgressIndicator\cf6 (\
59
+              valueColor: \cf5 AlwaysStoppedAnimation\cf6 <Color>(Colors.
60
+\f1\i \cf8 blue
61
+\f0\i0 \cf6 [\cf9 800\cf6 ]))\cf2 ,\
62
+        \cf6 )\cf2 ,\
63
+      \cf6 )\cf2 ;\
64
+    \cf6 \} \cf2 else \cf6 \{\
65
+      \cf2 return \cf5 MaterialApp\cf6 (\
66
+        debugShowCheckedModeBanner: \cf2 false,\
67
+        \cf6 title: \cf4 "Flutter Localization Demo"\cf2 ,\
68
+        \cf6 theme: \cf5 ThemeData\cf6 (primarySwatch: Colors.
69
+\f1\i \cf8 blue
70
+\f0\i0 \cf6 )\cf2 ,\
71
+        \cf6 locale: \cf8 _locale\cf2 ,\
72
+        \cf6 supportedLocales: [\
73
+          \cf5 Locale\cf6 (\cf4 "en"\cf2 , \cf4 "US"\cf6 )\cf2 ,\
74
+          \cf5 Locale\cf6 (\cf4 "fa"\cf2 , \cf4 "IR"\cf6 )\cf2 ,\
75
+          \cf5 Locale\cf6 (\cf4 "es"\cf2 , \cf4 "SP"\cf6 )\cf2 ,\
76
+          \cf5 Locale\cf6 (\cf4 "hi"\cf2 , \cf4 "IN"\cf6 )\
77
+        ]\cf2 ,\
78
+        \cf6 localizationsDelegates: [\
79
+          DemoLocalization.
80
+\f1\i \cf8 delegate
81
+\f0\i0 \cf2 ,\
82
+          \cf6 GlobalMaterialLocalizations.
83
+\f1\i \cf8 delegate
84
+\f0\i0 \cf2 ,\
85
+          \cf6 GlobalWidgetsLocalizations.
86
+\f1\i \cf8 delegate
87
+\f0\i0 \cf2 ,\
88
+          \cf6 GlobalCupertinoLocalizations.
89
+\f1\i \cf8 delegate
90
+\f0\i0 \cf2 ,\
91
+        \cf6 ]\cf2 ,\
92
+        \cf6 localeResolutionCallback: (locale\cf2 , \cf6 supportedLocales) \{\
93
+          \cf2 for \cf6 (\cf2 var \cf6 supportedLocale \cf2 in \cf6 supportedLocales) \{\
94
+            \cf2 if \cf6 (supportedLocale.\cf8 languageCode \cf6 == locale.\cf8 languageCode \cf6 &&\
95
+                supportedLocale.\cf8 countryCode \cf6 == locale.\cf8 countryCode\cf6 ) \{\
96
+              \cf2 return \cf6 supportedLocale\cf2 ;\
97
+            \cf6 \}\
98
+          \}\
99
+          \cf2 return \cf6 supportedLocales.\cf8 first\cf2 ;\
100
+        \cf6 \}\cf2 ,\
101
+        \cf6 onGenerateRoute: CustomRouter.
102
+\f1\i \cf5 generatedRoute
103
+\f0\i0 \cf2 ,\
104
+        \cf6 initialRoute: homeRoute\cf2 ,\
105
+      \cf6 )\cf2 ;\
106
+    \cf6 \}\
107
+  \}\
108
+\}\
109
+}