This commit is contained in:
Ricardo Markiewicz
2020-01-28 23:55:02 -03:00
parent cc3145d44e
commit 4f2f7a66ba
12 changed files with 238 additions and 45 deletions
+5
View File
@@ -59,6 +59,8 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CFACD96C23E07D4800D7C471 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Main.strings; sourceTree = "<group>"; };
CFACD96D23E07D4800D7C471 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
CFF572AC227F58EC009AA360 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../Downloads/GoogleService-Info.plist"; sourceTree = "<group>"; }; CFF572AC227F58EC009AA360 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "../../../../Downloads/GoogleService-Info.plist"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@@ -200,6 +202,7 @@
English, English,
en, en,
Base, Base,
es,
); );
mainGroup = 97C146E51CF9000F007C117D; mainGroup = 97C146E51CF9000F007C117D;
productRefGroup = 97C146EF1CF9000F007C117D /* Products */; productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
@@ -328,6 +331,7 @@
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
97C146FB1CF9000F007C117D /* Base */, 97C146FB1CF9000F007C117D /* Base */,
CFACD96C23E07D4800D7C471 /* es */,
); );
name = Main.storyboard; name = Main.storyboard;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -336,6 +340,7 @@
isa = PBXVariantGroup; isa = PBXVariantGroup;
children = ( children = (
97C147001CF9000F007C117D /* Base */, 97C147001CF9000F007C117D /* Base */,
CFACD96D23E07D4800D7C471 /* es */,
); );
name = LaunchScreen.storyboard; name = LaunchScreen.storyboard;
sourceTree = "<group>"; sourceTree = "<group>";
+1
View File
@@ -0,0 +1 @@
+1
View File
@@ -0,0 +1 @@
+31
View File
@@ -0,0 +1,31 @@
home:
emptyList: Add an expense to begin
add:
category: Category
today: Today
categories:
- Shoppint
- Alcohol
- Fast food
- Bills
- Transport
- Other
currency: $
add: Add expense
settings:
title: Settings
dark_mode: Use dark mode?
signout: Sign Out
months:
jan: January
feb: February
mar: March
apr: April
may: May
jun: June
jul: July
aug: August
sep: September
oct: October
nov: November
dec: December
+31
View File
@@ -0,0 +1,31 @@
home:
emptyList: Agregue un gasto para comenzar
add:
category: Categoría
today: Hoy
categories:
- Compras
- Alcohol
- Comida Rápida
- Facturas
- Transporte
- Otros
currency: $
add: Agregar Gasto
settings:
title: Opciones
dark_mode: Usar modo oscuro?
signout: Salir
months:
jan: Enero
feb: Febrero
mar: Marzo
apr: Abril
may: Mayo
jun: Junio
jul: Julio
aug: Agosto
sep: Septiembre
oct: Octubre
nov: Noviembre
dec: Diciembre
+81
View File
@@ -0,0 +1,81 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:yaml/yaml.dart';
class ComoGastoLocalizations {
final String localeName;
ComoGastoLocalizations(this.localeName);
static const LocalizationsDelegate<ComoGastoLocalizations> delegate =
_ComoGastoLocalizationsDelegate();
YamlMap translations;
YamlMap translationsFallback;
Future load() async {
String yamlString = await rootBundle.loadString('lang/$localeName.yml');
translations = loadYaml(yamlString);
String yamlString1 = await rootBundle.loadString('lang/en.yml');
translationsFallback = loadYaml(yamlString1);
}
dynamic t(String key) {
try {
var keys = key.split(".");
dynamic translated = translations;
keys.forEach((k) => translated = translated[k]);
if (translated == null) {
return _fallback(key);
}
return translated;
} catch (e) {
return _fallback(key);
}
}
dynamic _fallback(String key) {
try {
var keys = key.split(".");
dynamic translated = translationsFallback;
keys.forEach((k) => translated = translated[k]);
if (translated == null) {
return "Key not found....: $key";
}
return translated;
} catch (e) {
return "Key not found: $key";
}
}
static ComoGastoLocalizations of(BuildContext context) {
return Localizations.of<ComoGastoLocalizations>(
context, ComoGastoLocalizations);
}
}
class _ComoGastoLocalizationsDelegate
extends LocalizationsDelegate<ComoGastoLocalizations> {
const _ComoGastoLocalizationsDelegate();
@override
bool isSupported(Locale locale) {
print(locale.languageCode);
return ['es', 'en'].contains(locale.languageCode);
}
@override
Future<ComoGastoLocalizations> load(Locale locale) async {
var t = ComoGastoLocalizations(locale.languageCode);
await t.load();
return t;
}
@override
bool shouldReload(LocalizationsDelegate<ComoGastoLocalizations> old) {
return false;
}
}
+12
View File
@@ -6,8 +6,10 @@ import 'package:como_gasto/pages/details_page_container.dart';
import 'package:como_gasto/pages/home_page.dart'; import 'package:como_gasto/pages/home_page.dart';
import 'package:como_gasto/pages/login_page.dart'; import 'package:como_gasto/pages/login_page.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'como_gasto_localizations.dart';
import 'expenses_repository.dart'; import 'expenses_repository.dart';
import 'states/theme_state.dart'; import 'states/theme_state.dart';
@@ -73,6 +75,16 @@ class MyApp extends StatelessWidget {
} }
}, },
}, },
supportedLocales: [
Locale('en'),
Locale('es'),
],
localizationsDelegates: [
ComoGastoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
); );
}, },
), ),
+29 -19
View File
@@ -1,11 +1,13 @@
import 'dart:io'; import 'dart:io';
import 'package:como_gasto/como_gasto_localizations.dart';
import 'package:como_gasto/others/category_selection_widget.dart'; import 'package:como_gasto/others/category_selection_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:local_auth/local_auth.dart'; import 'package:local_auth/local_auth.dart';
import 'package:yaml/yaml.dart';
import '../como_gasto_icons.dart'; import '../como_gasto_icons.dart';
import '../expenses_repository.dart'; import '../expenses_repository.dart';
@@ -27,7 +29,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
String category; String category;
int value = 0; int value = 0;
String dateStr = "hoy"; String dateStr = null;
DateTime date = DateTime.now(); DateTime date = DateTime.now();
File _selectedPicture; File _selectedPicture;
@@ -71,6 +73,11 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ComoGastoLocalizations localizations = ComoGastoLocalizations.of(context);
if (dateStr == null) {
dateStr = localizations.t('add.today');
}
var h = MediaQuery.of(context).size.height; var h = MediaQuery.of(context).size.height;
return Stack( return Stack(
children: [ children: [
@@ -88,7 +95,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
elevation: 0.0, elevation: 0.0,
title: Text( title: Text(
"Category ($dateStr)", "${localizations.t('add.category')} ($dateStr)",
style: TextStyle( style: TextStyle(
color: Colors.grey, color: Colors.grey,
), ),
@@ -130,25 +137,25 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
) )
], ],
), ),
body: _body(), body: _body(localizations),
), ),
), ),
_submit(), _submit(localizations),
], ],
); );
} }
Widget _body() { Widget _body(ComoGastoLocalizations localizations) {
var h = MediaQuery.of(context).size.height; var h = MediaQuery.of(context).size.height;
return Column( return Column(
children: <Widget>[ children: <Widget>[
_categorySelector(), _categorySelector(localizations),
if (_selectedPicture != null) if (_selectedPicture != null)
SizedBox( SizedBox(
height: 100, height: 100,
child: Image.file(_selectedPicture), child: Image.file(_selectedPicture),
), ),
_currentValue(), _currentValue(localizations),
_numpad(), _numpad(),
SizedBox( SizedBox(
height: h - widget.buttonRect.top, height: h - widget.buttonRect.top,
@@ -157,30 +164,33 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
); );
} }
Widget _categorySelector() { Widget _categorySelector(ComoGastoLocalizations localizations) {
YamlList categories = localizations.t('add.categories');
print(categories);
return Container( return Container(
height: 80.0, height: 80.0,
child: CategorySelectionWidget( child: CategorySelectionWidget(
categories: { categories: {
"Shopping": Icons.shopping_cart, categories[0]: Icons.shopping_cart,
"Alcohol": FontAwesomeIcons.beer, categories[1]: FontAwesomeIcons.beer,
"Fast food": FontAwesomeIcons.hamburger, categories[2]: FontAwesomeIcons.hamburger,
"Bills": FontAwesomeIcons.wallet, categories[3]: FontAwesomeIcons.wallet,
"Transport": FontAwesomeIcons.carAlt, categories[4]: FontAwesomeIcons.carAlt,
"Other": FontAwesomeIcons.infinity, categories[5]: FontAwesomeIcons.infinity,
}, },
onValueChanged: (newCategory) => category = newCategory, onValueChanged: (newCategory) => category = newCategory,
), ),
); );
} }
Widget _currentValue() { Widget _currentValue(ComoGastoLocalizations localizations) {
var realValue = value / 100.0; var realValue = value / 100.0;
return Padding( return Padding(
padding: const EdgeInsets.symmetric(vertical: 32.0), padding: const EdgeInsets.symmetric(vertical: 32.0),
child: Text( child: Text(
"\$${realValue.toStringAsFixed(2)}", "${localizations.t('add.currency')}${realValue.toStringAsFixed(2)}",
style: TextStyle( style: TextStyle(
fontSize: 50.0, fontSize: 50.0,
color: Colors.blueAccent, color: Colors.blueAccent,
@@ -271,7 +281,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
); );
} }
Widget _submit() { Widget _submit(ComoGastoLocalizations localizations) {
if (_controller.value < 1) { if (_controller.value < 1) {
var buttonWidth = widget.buttonRect.right - widget.buttonRect.left; var buttonWidth = widget.buttonRect.right - widget.buttonRect.left;
var w = MediaQuery.of(context).size.width; var w = MediaQuery.of(context).size.width;
@@ -298,7 +308,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
child: MaterialButton( child: MaterialButton(
onPressed: () {}, onPressed: () {},
child: Text( child: Text(
"Add expense", localizations.t("add.add"),
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 20.0, fontSize: 20.0,
@@ -321,7 +331,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Text( Text(
"Add expense", localizations.t("add.add"),
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: 20.0, fontSize: 20.0,
+17 -15
View File
@@ -1,5 +1,6 @@
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:como_gasto/como_gasto_icons.dart'; import 'package:como_gasto/como_gasto_icons.dart';
import 'package:como_gasto/como_gasto_localizations.dart';
import 'package:como_gasto/others/month_widget.dart'; import 'package:como_gasto/others/month_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@@ -99,10 +100,11 @@ class _HomePageState extends State<HomePage> {
} }
Widget _body() { Widget _body() {
ComoGastoLocalizations localizations = Localizations.of<ComoGastoLocalizations>(context, ComoGastoLocalizations);
return SafeArea( return SafeArea(
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
_selector(), _selector(localizations),
StreamBuilder<QuerySnapshot>( StreamBuilder<QuerySnapshot>(
stream: _query, stream: _query,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> data) { builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> data) {
@@ -122,7 +124,7 @@ class _HomePageState extends State<HomePage> {
Image.asset('assets/no_data.png'), Image.asset('assets/no_data.png'),
SizedBox(height: 80), SizedBox(height: 80),
Text( Text(
"Add an expense to begin", localizations.t('home.emptyList'),
style: Theme.of(context).textTheme.caption, style: Theme.of(context).textTheme.caption,
) )
], ],
@@ -173,7 +175,7 @@ class _HomePageState extends State<HomePage> {
); );
} }
Widget _selector() { Widget _selector(ComoGastoLocalizations localizations) {
return SizedBox.fromSize( return SizedBox.fromSize(
size: Size.fromHeight(70.0), size: Size.fromHeight(70.0),
child: PageView( child: PageView(
@@ -187,18 +189,18 @@ class _HomePageState extends State<HomePage> {
}, },
controller: _controller, controller: _controller,
children: <Widget>[ children: <Widget>[
_pageItem("January", 0), _pageItem(localizations.t("months.jan"), 0),
_pageItem("February", 1), _pageItem(localizations.t("months.feb"), 1),
_pageItem("March", 2), _pageItem(localizations.t("months.mar"), 2),
_pageItem("April", 3), _pageItem(localizations.t("months.apr"), 3),
_pageItem("May", 4), _pageItem(localizations.t("months.may"), 4),
_pageItem("June", 5), _pageItem(localizations.t("months.jun"), 5),
_pageItem("July", 6), _pageItem(localizations.t("months.jul"), 6),
_pageItem("August", 7), _pageItem(localizations.t("months.aug"), 7),
_pageItem("September", 8), _pageItem(localizations.t("months.sep"), 8),
_pageItem("October", 9), _pageItem(localizations.t("months.oct"), 9),
_pageItem("November", 10), _pageItem(localizations.t("months.nov"), 10),
_pageItem("December", 11), _pageItem(localizations.t("months.dec"), 11),
], ],
), ),
); );
+5 -3
View File
@@ -1,3 +1,4 @@
import 'package:como_gasto/como_gasto_localizations.dart';
import 'package:como_gasto/states/theme_state.dart'; import 'package:como_gasto/states/theme_state.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
@@ -5,9 +6,10 @@ import 'package:provider/provider.dart';
class SettingsPage extends StatelessWidget { class SettingsPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ComoGastoLocalizations localizations = ComoGastoLocalizations.of(context);
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("Settings"), title: Text(localizations.t('settings.title')),
), ),
body: Padding( body: Padding(
padding: const EdgeInsets.all(12.0), padding: const EdgeInsets.all(12.0),
@@ -20,7 +22,7 @@ class SettingsPage extends StatelessWidget {
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Text("Use Dark mode?"), child: Text(localizations.t('settings.dark_mode')),
), ),
Switch( Switch(
value: state.isDarkModeEnabled, value: state.isDarkModeEnabled,
@@ -41,7 +43,7 @@ class SettingsPage extends StatelessWidget {
onPressed: () { onPressed: () {
//Provider.of<LoginState>(context).logout(); //Provider.of<LoginState>(context).logout();
}, },
child: Text("Sign Out"), child: Text(localizations.t('settings.signout')),
), ),
) )
], ],
+18 -6
View File
@@ -42,14 +42,14 @@ packages:
name: charts_common name: charts_common
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.0" version: "0.8.1"
charts_flutter: charts_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
name: charts_flutter name: charts_flutter
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.0" version: "0.8.1"
cloud_firestore: cloud_firestore:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -91,7 +91,7 @@ packages:
name: datetime_picker_formfield name: datetime_picker_formfield
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.0" version: "1.0.0"
firebase_auth: firebase_auth:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -132,6 +132,13 @@ packages:
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
flutter_cupertino_localizations:
dependency: "direct main"
description:
name: flutter_cupertino_localizations
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
flutter_launcher_icons: flutter_launcher_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -146,6 +153,11 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.8.0" version: "0.8.0"
flutter_localizations:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@@ -185,7 +197,7 @@ packages:
name: intl name: intl
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.15.8" version: "0.16.0"
local_auth: local_auth:
dependency: "direct main" dependency: "direct main"
description: description:
@@ -346,12 +358,12 @@ packages:
source: hosted source: hosted
version: "3.5.0" version: "3.5.0"
yaml: yaml:
dependency: transitive dependency: "direct main"
description: description:
name: yaml name: yaml
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.16" version: "2.2.0"
sdks: sdks:
dart: ">=2.4.0 <3.0.0" dart: ">=2.4.0 <3.0.0"
flutter: ">=1.10.0 <2.0.0" flutter: ">=1.10.0 <2.0.0"
+7 -2
View File
@@ -19,7 +19,10 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
charts_flutter: ^0.6.0 flutter_localizations:
sdk: flutter
flutter_cupertino_localizations: ^1.0.1
charts_flutter: ^0.8.1
font_awesome_flutter: ^8.4.0 font_awesome_flutter: ^8.4.0
cloud_firestore: ^0.13.0+1 cloud_firestore: ^0.13.0+1
firebase_storage: ^3.0.8 firebase_storage: ^3.0.8
@@ -39,8 +42,9 @@ dependencies:
rect_getter: ^0.0.1 rect_getter: ^0.0.1
flutter_launcher_icons: ^0.7.2+1 flutter_launcher_icons: ^0.7.2+1
flutter_local_notifications: ^0.8.0 flutter_local_notifications: ^0.8.0
datetime_picker_formfield: ^0.4.0 datetime_picker_formfield: ^1.0.0
flare_flutter: flare_flutter:
yaml: ^2.2.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@@ -66,6 +70,7 @@ flutter:
# To add assets to your application, add an assets section, like this: # To add assets to your application, add an assets section, like this:
assets: assets:
- assets/ - assets/
- lang/
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware. # https://flutter.io/assets-and-images/#resolution-aware.