Add i18n
This commit is contained in:
+29
-19
@@ -1,11 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:como_gasto/como_gasto_localizations.dart';
|
||||
import 'package:como_gasto/others/category_selection_widget.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
import '../como_gasto_icons.dart';
|
||||
import '../expenses_repository.dart';
|
||||
@@ -27,7 +29,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
String category;
|
||||
int value = 0;
|
||||
|
||||
String dateStr = "hoy";
|
||||
String dateStr = null;
|
||||
DateTime date = DateTime.now();
|
||||
|
||||
File _selectedPicture;
|
||||
@@ -71,6 +73,11 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ComoGastoLocalizations localizations = ComoGastoLocalizations.of(context);
|
||||
if (dateStr == null) {
|
||||
dateStr = localizations.t('add.today');
|
||||
}
|
||||
|
||||
var h = MediaQuery.of(context).size.height;
|
||||
return Stack(
|
||||
children: [
|
||||
@@ -88,7 +95,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
backgroundColor: Colors.transparent,
|
||||
elevation: 0.0,
|
||||
title: Text(
|
||||
"Category ($dateStr)",
|
||||
"${localizations.t('add.category')} ($dateStr)",
|
||||
style: TextStyle(
|
||||
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;
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
_categorySelector(),
|
||||
_categorySelector(localizations),
|
||||
if (_selectedPicture != null)
|
||||
SizedBox(
|
||||
height: 100,
|
||||
child: Image.file(_selectedPicture),
|
||||
),
|
||||
_currentValue(),
|
||||
_currentValue(localizations),
|
||||
_numpad(),
|
||||
SizedBox(
|
||||
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(
|
||||
height: 80.0,
|
||||
child: CategorySelectionWidget(
|
||||
categories: {
|
||||
"Shopping": Icons.shopping_cart,
|
||||
"Alcohol": FontAwesomeIcons.beer,
|
||||
"Fast food": FontAwesomeIcons.hamburger,
|
||||
"Bills": FontAwesomeIcons.wallet,
|
||||
"Transport": FontAwesomeIcons.carAlt,
|
||||
"Other": FontAwesomeIcons.infinity,
|
||||
categories[0]: Icons.shopping_cart,
|
||||
categories[1]: FontAwesomeIcons.beer,
|
||||
categories[2]: FontAwesomeIcons.hamburger,
|
||||
categories[3]: FontAwesomeIcons.wallet,
|
||||
categories[4]: FontAwesomeIcons.carAlt,
|
||||
categories[5]: FontAwesomeIcons.infinity,
|
||||
},
|
||||
onValueChanged: (newCategory) => category = newCategory,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _currentValue() {
|
||||
Widget _currentValue(ComoGastoLocalizations localizations) {
|
||||
var realValue = value / 100.0;
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 32.0),
|
||||
child: Text(
|
||||
"\$${realValue.toStringAsFixed(2)}",
|
||||
"${localizations.t('add.currency')}${realValue.toStringAsFixed(2)}",
|
||||
style: TextStyle(
|
||||
fontSize: 50.0,
|
||||
color: Colors.blueAccent,
|
||||
@@ -271,7 +281,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _submit() {
|
||||
Widget _submit(ComoGastoLocalizations localizations) {
|
||||
if (_controller.value < 1) {
|
||||
var buttonWidth = widget.buttonRect.right - widget.buttonRect.left;
|
||||
var w = MediaQuery.of(context).size.width;
|
||||
@@ -298,7 +308,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
child: MaterialButton(
|
||||
onPressed: () {},
|
||||
child: Text(
|
||||
"Add expense",
|
||||
localizations.t("add.add"),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20.0,
|
||||
@@ -321,7 +331,7 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
"Add expense",
|
||||
localizations.t("add.add"),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20.0,
|
||||
|
||||
+17
-15
@@ -1,5 +1,6 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.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:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
@@ -99,10 +100,11 @@ class _HomePageState extends State<HomePage> {
|
||||
}
|
||||
|
||||
Widget _body() {
|
||||
ComoGastoLocalizations localizations = Localizations.of<ComoGastoLocalizations>(context, ComoGastoLocalizations);
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
_selector(),
|
||||
_selector(localizations),
|
||||
StreamBuilder<QuerySnapshot>(
|
||||
stream: _query,
|
||||
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> data) {
|
||||
@@ -122,7 +124,7 @@ class _HomePageState extends State<HomePage> {
|
||||
Image.asset('assets/no_data.png'),
|
||||
SizedBox(height: 80),
|
||||
Text(
|
||||
"Add an expense to begin",
|
||||
localizations.t('home.emptyList'),
|
||||
style: Theme.of(context).textTheme.caption,
|
||||
)
|
||||
],
|
||||
@@ -173,7 +175,7 @@ class _HomePageState extends State<HomePage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _selector() {
|
||||
Widget _selector(ComoGastoLocalizations localizations) {
|
||||
return SizedBox.fromSize(
|
||||
size: Size.fromHeight(70.0),
|
||||
child: PageView(
|
||||
@@ -187,18 +189,18 @@ class _HomePageState extends State<HomePage> {
|
||||
},
|
||||
controller: _controller,
|
||||
children: <Widget>[
|
||||
_pageItem("January", 0),
|
||||
_pageItem("February", 1),
|
||||
_pageItem("March", 2),
|
||||
_pageItem("April", 3),
|
||||
_pageItem("May", 4),
|
||||
_pageItem("June", 5),
|
||||
_pageItem("July", 6),
|
||||
_pageItem("August", 7),
|
||||
_pageItem("September", 8),
|
||||
_pageItem("October", 9),
|
||||
_pageItem("November", 10),
|
||||
_pageItem("December", 11),
|
||||
_pageItem(localizations.t("months.jan"), 0),
|
||||
_pageItem(localizations.t("months.feb"), 1),
|
||||
_pageItem(localizations.t("months.mar"), 2),
|
||||
_pageItem(localizations.t("months.apr"), 3),
|
||||
_pageItem(localizations.t("months.may"), 4),
|
||||
_pageItem(localizations.t("months.jun"), 5),
|
||||
_pageItem(localizations.t("months.jul"), 6),
|
||||
_pageItem(localizations.t("months.aug"), 7),
|
||||
_pageItem(localizations.t("months.sep"), 8),
|
||||
_pageItem(localizations.t("months.oct"), 9),
|
||||
_pageItem(localizations.t("months.nov"), 10),
|
||||
_pageItem(localizations.t("months.dec"), 11),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:como_gasto/como_gasto_localizations.dart';
|
||||
import 'package:como_gasto/states/theme_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -5,9 +6,10 @@ import 'package:provider/provider.dart';
|
||||
class SettingsPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
ComoGastoLocalizations localizations = ComoGastoLocalizations.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Settings"),
|
||||
title: Text(localizations.t('settings.title')),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
@@ -20,7 +22,7 @@ class SettingsPage extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text("Use Dark mode?"),
|
||||
child: Text(localizations.t('settings.dark_mode')),
|
||||
),
|
||||
Switch(
|
||||
value: state.isDarkModeEnabled,
|
||||
@@ -41,7 +43,7 @@ class SettingsPage extends StatelessWidget {
|
||||
onPressed: () {
|
||||
//Provider.of<LoginState>(context).logout();
|
||||
},
|
||||
child: Text("Sign Out"),
|
||||
child: Text(localizations.t('settings.signout')),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user