Jefferson Rodrigues

Added lang directory that contains the translations_service class and two langua…

…ges, english and portuguese, configured to use the device system language and use the english like default case the device language is'nt listed on the lang files.
  1 +const Map<String, String> en_US = {
  2 + 'covid': 'Corona Virus',
  3 + 'total_confirmed': 'Total Confirmed',
  4 + 'total_deaths': 'Total Deaths',
  5 + 'fetch_country': 'Fetch by country',
  6 + 'corona_by_country': 'Corona by country',
  7 + 'total_infecteds': 'Total Infecteds',
  8 + 'details': 'Details',
  9 + 'total_recovered': 'Total Recovered',
  10 +};
  1 +const Map<String, String> pt_BR = {
  2 + 'covid': 'Corona Vírus',
  3 + 'total_confirmed': 'Total confirmado',
  4 + 'total_deaths': 'Total de mortes',
  5 + 'fetch_country': 'Listar por país',
  6 + 'corona_by_country': 'Corona por país',
  7 + 'total_infecteds': 'Total de infectados',
  8 + 'details': 'Detalhes',
  9 + 'total_recovered': 'Total de recuperados'
  10 +};
  1 +import 'package:flutter/material.dart';
  2 +import 'package:get/get.dart';
  3 +
  4 +import 'en_US.dart';
  5 +import 'pt_BR.dart';
  6 +
  7 +class TranslationService extends Translations {
  8 + static final locale = Get.deviceLocale;
  9 + static final fallbackLocale = Locale('en', 'US');
  10 + @override
  11 + Map<String, Map<String, String>> get keys => {
  12 + 'en_US': en_US,
  13 + 'pt_BR': pt_BR,
  14 + };
  15 +}
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 import 'package:get/get.dart'; 2 import 'package:get/get.dart';
  3 +import 'lang/translation_service.dart';
3 import 'routes/app_pages.dart'; 4 import 'routes/app_pages.dart';
4 import 'shared/logger/logger_utils.dart'; 5 import 'shared/logger/logger_utils.dart';
5 6
@@ -18,6 +19,9 @@ class MyApp extends StatelessWidget { @@ -18,6 +19,9 @@ class MyApp extends StatelessWidget {
18 logWriterCallback: Logger.write, 19 logWriterCallback: Logger.write,
19 initialRoute: AppPages.INITIAL, 20 initialRoute: AppPages.INITIAL,
20 getPages: AppPages.routes, 21 getPages: AppPages.routes,
  22 + locale: TranslationService.locale,
  23 + fallbackLocale: TranslationService.fallbackLocale,
  24 + translations: TranslationService(),
21 ); 25 );
22 } 26 }
23 } 27 }
@@ -22,7 +22,7 @@ class CountryView extends GetView<HomeController> { @@ -22,7 +22,7 @@ class CountryView extends GetView<HomeController> {
22 child: Scaffold( 22 child: Scaffold(
23 backgroundColor: Colors.transparent, 23 backgroundColor: Colors.transparent,
24 appBar: AppBar( 24 appBar: AppBar(
25 - title: Text("Corona By Country"), 25 + title: Text('corona_by_country'.tr),
26 backgroundColor: Colors.transparent, 26 backgroundColor: Colors.transparent,
27 elevation: 0, 27 elevation: 0,
28 centerTitle: true, 28 centerTitle: true,
@@ -43,7 +43,7 @@ class CountryView extends GetView<HomeController> { @@ -43,7 +43,7 @@ class CountryView extends GetView<HomeController> {
43 ), 43 ),
44 title: Text(country.country), 44 title: Text(country.country),
45 subtitle: 45 subtitle:
46 - Text("Total infecteds: ${country.totalConfirmed}"), 46 + Text('total_infecteds'.tr +' ${country.totalConfirmed}'),
47 ); 47 );
48 }), 48 }),
49 ), 49 ),
@@ -25,7 +25,7 @@ class DetailsView extends StatelessWidget { @@ -25,7 +25,7 @@ class DetailsView extends StatelessWidget {
25 child: Scaffold( 25 child: Scaffold(
26 backgroundColor: Colors.transparent, 26 backgroundColor: Colors.transparent,
27 appBar: AppBar( 27 appBar: AppBar(
28 - title: Text("Details"), 28 + title: Text('details'.tr),
29 backgroundColor: Colors.black12, 29 backgroundColor: Colors.black12,
30 elevation: 0, 30 elevation: 0,
31 centerTitle: true, 31 centerTitle: true,
@@ -42,7 +42,7 @@ class DetailsView extends StatelessWidget { @@ -42,7 +42,7 @@ class DetailsView extends StatelessWidget {
42 height: 35, 42 height: 35,
43 ), 43 ),
44 Text( 44 Text(
45 - "Total Confirmed", 45 + 'total_confirmed'.tr,
46 style: TextStyle( 46 style: TextStyle(
47 fontSize: 25, 47 fontSize: 25,
48 ), 48 ),
@@ -55,7 +55,7 @@ class DetailsView extends StatelessWidget { @@ -55,7 +55,7 @@ class DetailsView extends StatelessWidget {
55 height: 10, 55 height: 10,
56 ), 56 ),
57 Text( 57 Text(
58 - "Total Deaths", 58 + 'total_deaths'.tr,
59 style: TextStyle( 59 style: TextStyle(
60 fontSize: 25, 60 fontSize: 25,
61 ), 61 ),
@@ -68,7 +68,7 @@ class DetailsView extends StatelessWidget { @@ -68,7 +68,7 @@ class DetailsView extends StatelessWidget {
68 height: 10, 68 height: 10,
69 ), 69 ),
70 Text( 70 Text(
71 - "Total Recovered", 71 + 'total_recovered'.tr,
72 style: TextStyle( 72 style: TextStyle(
73 fontSize: 25, 73 fontSize: 25,
74 ), 74 ),
@@ -21,7 +21,7 @@ class HomeView extends GetView<HomeController> { @@ -21,7 +21,7 @@ class HomeView extends GetView<HomeController> {
21 child: Scaffold( 21 child: Scaffold(
22 backgroundColor: Colors.transparent, 22 backgroundColor: Colors.transparent,
23 appBar: AppBar( 23 appBar: AppBar(
24 - title: Text("Corona Virus"), 24 + title: Text('covid'.tr),
25 backgroundColor: Colors.white10, 25 backgroundColor: Colors.white10,
26 elevation: 0, 26 elevation: 0,
27 centerTitle: true, 27 centerTitle: true,
@@ -36,7 +36,7 @@ class HomeView extends GetView<HomeController> { @@ -36,7 +36,7 @@ class HomeView extends GetView<HomeController> {
36 height: 100, 36 height: 100,
37 ), 37 ),
38 Text( 38 Text(
39 - "Total Confirmed", 39 + 'total_confirmed'.tr,
40 style: TextStyle( 40 style: TextStyle(
41 fontSize: 30, 41 fontSize: 30,
42 ), 42 ),
@@ -49,7 +49,7 @@ class HomeView extends GetView<HomeController> { @@ -49,7 +49,7 @@ class HomeView extends GetView<HomeController> {
49 height: 10, 49 height: 10,
50 ), 50 ),
51 Text( 51 Text(
52 - "Total Deaths", 52 + 'total_deaths'.tr,
53 style: TextStyle( 53 style: TextStyle(
54 fontSize: 30, 54 fontSize: 30,
55 ), 55 ),
@@ -71,7 +71,7 @@ class HomeView extends GetView<HomeController> { @@ -71,7 +71,7 @@ class HomeView extends GetView<HomeController> {
71 Get.toNamed('/home/country'); 71 Get.toNamed('/home/country');
72 }, 72 },
73 child: Text( 73 child: Text(
74 - "Fetch by country", 74 + 'fetch_country'.tr,
75 style: TextStyle(fontWeight: FontWeight.bold), 75 style: TextStyle(fontWeight: FontWeight.bold),
76 ), 76 ),
77 ) 77 )
  1 +// This is a basic Flutter widget test.
  2 +//
  3 +// To perform an interaction with a widget in your test, use the WidgetTester
  4 +// utility that Flutter provides. For example, you can send tap and scroll
  5 +// gestures. You can also use WidgetTester to find child widgets in the widget
  6 +// tree, read text, and verify that the values of widget properties are correct.
  7 +
  8 +import 'package:flutter/material.dart';
  9 +import 'package:flutter_test/flutter_test.dart';
  10 +
  11 +import '../lib/main.dart';
  12 +
  13 +void main() {
  14 + testWidgets('Counter increments smoke test', (WidgetTester tester) async {
  15 + // Build our app and trigger a frame.
  16 + await tester.pumpWidget(MyApp());
  17 +
  18 + // Verify that our counter starts at 0.
  19 + expect(find.text('0'), findsOneWidget);
  20 + expect(find.text('1'), findsNothing);
  21 +
  22 + // Tap the '+' icon and trigger a frame.
  23 + await tester.tap(find.byIcon(Icons.add));
  24 + await tester.pump();
  25 +
  26 + // Verify that our counter has incremented.
  27 + expect(find.text('0'), findsNothing);
  28 + expect(find.text('1'), findsOneWidget);
  29 + });
  30 +}