@@ -37,13 +37,14 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
|
||||||
applicationId "ar.com.p39.como_gasto"
|
applicationId "ar.com.p39.como_gasto"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -62,6 +63,11 @@ flutter {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
androidTestImplementation 'androidx.test:runner:1.2.1'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||||
|
|
||||||
|
implementation 'com.google.firebase:firebase-core:17.0.0'
|
||||||
|
implementation 'com.android.support:multidex:1.0.3'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: 'com.google.gms.google-services'
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
{
|
||||||
|
"project_info": {
|
||||||
|
"project_number": "173215752753",
|
||||||
|
"firebase_url": "https://comogastoyt-bf4bb.firebaseio.com",
|
||||||
|
"project_id": "comogastoyt-bf4bb",
|
||||||
|
"storage_bucket": "comogastoyt-bf4bb.appspot.com"
|
||||||
|
},
|
||||||
|
"client": [
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:173215752753:android:957bb64f9e6aa927",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "ar.com.p39.como_gasto"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "173215752753-9oqdkfcniomj2otlaab0ti4v6gbd0c3m.apps.googleusercontent.com",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_info": {
|
||||||
|
"package_name": "ar.com.p39.como_gasto",
|
||||||
|
"certificate_hash": "e408700297e4e8f89ebe9b5bd2d851a60213912f"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "173215752753-sm27hsjfa9bdh4ko0itaf7539r31cl1c.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyA22xlzsq3xgI2gSocZM5f-AmCblT5X-L4"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "173215752753-sm27hsjfa9bdh4ko0itaf7539r31cl1c.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "173215752753-sfdf5d19ospsuphvgaclfsie0vp873lb.apps.googleusercontent.com",
|
||||||
|
"client_type": 2,
|
||||||
|
"ios_info": {
|
||||||
|
"bundle_id": "ar.com.p39.comoGasto"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration_version": "1"
|
||||||
|
}
|
||||||
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 5.3 KiB |
@@ -1,13 +1,14 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.71'
|
ext.kotlin_version = '1.3.31'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
classpath 'com.google.gms:google-services:4.2.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
org.gradle.jvmargs=-Xmx1536M
|
org.gradle.jvmargs=-Xmx1536M
|
||||||
|
android.enableJetifier=true
|
||||||
|
android.useAndroidX=true
|
||||||
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
|
||||||
|
|||||||
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 31 KiB |
@@ -66,6 +66,8 @@ PODS:
|
|||||||
- GoogleUtilities/Environment (~> 6.0)
|
- GoogleUtilities/Environment (~> 6.0)
|
||||||
- GoogleUtilities/UserDefaults (~> 6.0)
|
- GoogleUtilities/UserDefaults (~> 6.0)
|
||||||
- Flutter (1.0.0)
|
- Flutter (1.0.0)
|
||||||
|
- flutter_local_notifications (0.0.1):
|
||||||
|
- Flutter
|
||||||
- google_sign_in (0.0.1):
|
- google_sign_in (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
- GoogleSignIn (~> 4.0)
|
- GoogleSignIn (~> 4.0)
|
||||||
@@ -137,6 +139,7 @@ DEPENDENCIES:
|
|||||||
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
|
- firebase_auth (from `.symlinks/plugins/firebase_auth/ios`)
|
||||||
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
|
||||||
- Flutter (from `.symlinks/flutter/ios`)
|
- Flutter (from `.symlinks/flutter/ios`)
|
||||||
|
- flutter_local_notifications (from `.symlinks/plugins/flutter_local_notifications/ios`)
|
||||||
- google_sign_in (from `.symlinks/plugins/google_sign_in/ios`)
|
- google_sign_in (from `.symlinks/plugins/google_sign_in/ios`)
|
||||||
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
||||||
|
|
||||||
@@ -170,6 +173,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/firebase_core/ios"
|
:path: ".symlinks/plugins/firebase_core/ios"
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: ".symlinks/flutter/ios"
|
:path: ".symlinks/flutter/ios"
|
||||||
|
flutter_local_notifications:
|
||||||
|
:path: ".symlinks/plugins/flutter_local_notifications/ios"
|
||||||
google_sign_in:
|
google_sign_in:
|
||||||
:path: ".symlinks/plugins/google_sign_in/ios"
|
:path: ".symlinks/plugins/google_sign_in/ios"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
@@ -188,6 +193,7 @@ SPEC CHECKSUMS:
|
|||||||
FirebaseFirestore: 0537b2a960a4819fae2834e688e5daeb571c81d6
|
FirebaseFirestore: 0537b2a960a4819fae2834e688e5daeb571c81d6
|
||||||
FirebaseInstanceID: 0e0348a3c00a734fa376a070f5ad4533ad975cb5
|
FirebaseInstanceID: 0e0348a3c00a734fa376a070f5ad4533ad975cb5
|
||||||
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
|
Flutter: 58dd7d1b27887414a370fcccb9e645c08ffd7a6a
|
||||||
|
flutter_local_notifications: 9e4738ce2471c5af910d961a6b7eadcf57c50186
|
||||||
google_sign_in: 27e70a98b529f0b076d4b19f231b81da28b1750b
|
google_sign_in: 27e70a98b529f0b076d4b19f231b81da28b1750b
|
||||||
GoogleAppMeasurement: 7f028ea162b72c8f326daec74afc95d94f7a47d6
|
GoogleAppMeasurement: 7f028ea162b72c8f326daec74afc95d94f7a47d6
|
||||||
GoogleSignIn: 7ff245e1a7b26d379099d3243a562f5747e23d39
|
GoogleSignIn: 7ff245e1a7b26d379099d3243a562f5747e23d39
|
||||||
|
|||||||
@@ -256,6 +256,7 @@
|
|||||||
"${BUILT_PRODUCTS_DIR}/GoogleToolboxForMac/GoogleToolboxForMac.framework",
|
"${BUILT_PRODUCTS_DIR}/GoogleToolboxForMac/GoogleToolboxForMac.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
|
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
|
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
|
||||||
|
"${BUILT_PRODUCTS_DIR}/flutter_local_notifications/flutter_local_notifications.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/gRPC-C++/grpcpp.framework",
|
"${BUILT_PRODUCTS_DIR}/gRPC-C++/grpcpp.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework",
|
"${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework",
|
||||||
"${BUILT_PRODUCTS_DIR}/leveldb-library/leveldb.framework",
|
"${BUILT_PRODUCTS_DIR}/leveldb-library/leveldb.framework",
|
||||||
@@ -270,6 +271,7 @@
|
|||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleToolboxForMac.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleToolboxForMac.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
|
||||||
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_local_notifications.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpcpp.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpcpp.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework",
|
||||||
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
|
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 564 B After Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 730 B |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 4.3 KiB |
@@ -41,5 +41,18 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<!-- TODO Replace this value: -->
|
||||||
|
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
|
||||||
|
<string>com.googleusercontent.apps.173215752753-sfdf5d19ospsuphvgaclfsie0vp873lb</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
|
||||||
|
class ExpensesRepository {
|
||||||
|
final String userId;
|
||||||
|
|
||||||
|
ExpensesRepository(this.userId);
|
||||||
|
|
||||||
|
Stream<QuerySnapshot> queryByCategory(int month, String categoryName) {
|
||||||
|
return Firestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.document(userId)
|
||||||
|
.collection('expenses')
|
||||||
|
.where("month", isEqualTo: month)
|
||||||
|
.where("category", isEqualTo: categoryName)
|
||||||
|
.snapshots();
|
||||||
|
}
|
||||||
|
|
||||||
|
Stream<QuerySnapshot> queryByMonth(int month) {
|
||||||
|
return Firestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.document(userId)
|
||||||
|
.collection('expenses')
|
||||||
|
.where("month", isEqualTo: month)
|
||||||
|
.snapshots();
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(String documentId) {
|
||||||
|
Firestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.document(userId)
|
||||||
|
.collection('expenses')
|
||||||
|
.document(documentId)
|
||||||
|
.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
add(String categoryName, double value, DateTime date) {
|
||||||
|
Firestore.instance
|
||||||
|
.collection('users')
|
||||||
|
.document(userId)
|
||||||
|
.collection('expenses')
|
||||||
|
.document()
|
||||||
|
.setData({
|
||||||
|
"category": categoryName,
|
||||||
|
"value": value,
|
||||||
|
"month": date.month,
|
||||||
|
"day": date.day,
|
||||||
|
"year": date.year,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,6 +48,9 @@ class LoginState with ChangeNotifier {
|
|||||||
|
|
||||||
Future<FirebaseUser> _handleSignIn() async {
|
Future<FirebaseUser> _handleSignIn() async {
|
||||||
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
|
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
|
||||||
|
if (googleUser == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
|
final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
|
||||||
|
|
||||||
final AuthCredential credential = GoogleAuthProvider.getCredential(
|
final AuthCredential credential = GoogleAuthProvider.getCredential(
|
||||||
|
|||||||
@@ -1,19 +1,35 @@
|
|||||||
import 'package:como_gasto/add_page_transition.dart';
|
import 'package:como_gasto/add_page_transition.dart';
|
||||||
import 'package:como_gasto/login_state.dart';
|
import 'package:como_gasto/login_state.dart';
|
||||||
import 'package:como_gasto/pages/add_page.dart';
|
import 'package:como_gasto/pages/add_page.dart';
|
||||||
import 'package:como_gasto/pages/details_page.dart';
|
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:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'expenses_repository.dart';
|
||||||
|
|
||||||
void main() => runApp(MyApp());
|
void main() => runApp(MyApp());
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ChangeNotifierProvider<LoginState>(
|
return MultiProvider(
|
||||||
builder: (BuildContext context) => LoginState(),
|
providers: [
|
||||||
|
ChangeNotifierProvider<LoginState>(
|
||||||
|
builder: (BuildContext context) => LoginState(),
|
||||||
|
),
|
||||||
|
ProxyProvider<LoginState, ExpensesRepository>(
|
||||||
|
builder: (_, LoginState value, __) {
|
||||||
|
if (value.isLoggedIn()) {
|
||||||
|
return ExpensesRepository(value
|
||||||
|
.currentUser()
|
||||||
|
.uid);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
title: 'Flutter Demo',
|
title: 'Flutter Demo',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
@@ -23,7 +39,7 @@ class MyApp extends StatelessWidget {
|
|||||||
if (settings.name == '/details') {
|
if (settings.name == '/details') {
|
||||||
DetailsParams params = settings.arguments;
|
DetailsParams params = settings.arguments;
|
||||||
return MaterialPageRoute(builder: (BuildContext context) {
|
return MaterialPageRoute(builder: (BuildContext context) {
|
||||||
return DetailsPage(
|
return DetailsPageContainer(
|
||||||
params: params,
|
params: params,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -36,6 +52,7 @@ class MyApp extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
routes: {
|
routes: {
|
||||||
'/': (BuildContext context) {
|
'/': (BuildContext context) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:como_gasto/graph_widget.dart';
|
import 'package:como_gasto/graph_widget.dart';
|
||||||
import 'package:como_gasto/pages/details_page.dart';
|
import 'package:como_gasto/pages/details_page_container.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,6 +99,9 @@ class _MonthWidgetState extends State<MonthWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _item(IconData icon, String name, int percent, double value) {
|
Widget _item(IconData icon, String name, int percent, double value) {
|
||||||
|
if (name == null) {
|
||||||
|
name = "";
|
||||||
|
}
|
||||||
return ListTile(
|
return ListTile(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed("/details",
|
Navigator.of(context).pushNamed("/details",
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
|
||||||
import 'package:como_gasto/category_selection_widget.dart';
|
import 'package:como_gasto/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:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../login_state.dart';
|
import '../expenses_repository.dart';
|
||||||
|
|
||||||
class AddPage extends StatefulWidget {
|
class AddPage extends StatefulWidget {
|
||||||
final Rect buttonRect;
|
final Rect buttonRect;
|
||||||
@@ -23,6 +22,9 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
String category;
|
String category;
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
|
String dateStr = "hoy";
|
||||||
|
DateTime date = DateTime.now();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -52,7 +54,10 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var h = MediaQuery.of(context).size.height;
|
var h = MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.height;
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
Transform.translate(
|
Transform.translate(
|
||||||
@@ -62,10 +67,27 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
elevation: 0.0,
|
elevation: 0.0,
|
||||||
title: Text(
|
title: GestureDetector(
|
||||||
"Category",
|
onTap: () {
|
||||||
style: TextStyle(
|
showDatePicker(
|
||||||
color: Colors.grey,
|
context: context,
|
||||||
|
initialDate: DateTime.now(),
|
||||||
|
firstDate: DateTime.now().subtract(Duration(hours: 24*30)),
|
||||||
|
lastDate: DateTime.now(),
|
||||||
|
).then((newDate) {
|
||||||
|
if (newDate != null) {
|
||||||
|
setState(() {
|
||||||
|
date = newDate;
|
||||||
|
dateStr = "${date.year.toString()}-${date.month.toString().padLeft(2,'0')}-${date.day.toString().padLeft(2,'0')}";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
"Category ($dateStr)",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
centerTitle: false,
|
centerTitle: false,
|
||||||
@@ -90,7 +112,10 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _body() {
|
Widget _body() {
|
||||||
var h = MediaQuery.of(context).size.height;
|
var h = MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.size
|
||||||
|
.height;
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
_categorySelector(),
|
_categorySelector(),
|
||||||
@@ -167,60 +192,63 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
return Expanded(
|
return Expanded(
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
var height = constraints.biggest.height / 4;
|
var height = constraints.biggest.height / 4;
|
||||||
|
|
||||||
return Table(
|
return Table(
|
||||||
border: TableBorder.all(
|
border: TableBorder.all(
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
width: 1.0,
|
width: 1.0,
|
||||||
),
|
),
|
||||||
children: [
|
children: [
|
||||||
TableRow(children: [
|
TableRow(children: [
|
||||||
_num("1", height),
|
_num("1", height),
|
||||||
_num("2", height),
|
_num("2", height),
|
||||||
_num("3", height),
|
_num("3", height),
|
||||||
]),
|
]),
|
||||||
TableRow(children: [
|
TableRow(children: [
|
||||||
_num("4", height),
|
_num("4", height),
|
||||||
_num("5", height),
|
_num("5", height),
|
||||||
_num("6", height),
|
_num("6", height),
|
||||||
]),
|
]),
|
||||||
TableRow(children: [
|
TableRow(children: [
|
||||||
_num("7", height),
|
_num("7", height),
|
||||||
_num("8", height),
|
_num("8", height),
|
||||||
_num("9", height),
|
_num("9", height),
|
||||||
]),
|
]),
|
||||||
TableRow(children: [
|
TableRow(children: [
|
||||||
_num(",", height),
|
_num(",", height),
|
||||||
_num("0", height),
|
_num("0", height),
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
value = value ~/ 10;
|
value = value ~/ 10;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: height,
|
height: height,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.backspace,
|
Icons.backspace,
|
||||||
color: Colors.grey,
|
color: Colors.grey,
|
||||||
size: 40,
|
size: 40,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
]),
|
||||||
),
|
],
|
||||||
]),
|
);
|
||||||
],
|
}),
|
||||||
);
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _submit() {
|
Widget _submit() {
|
||||||
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;
|
||||||
|
|
||||||
return Positioned(
|
return Positioned(
|
||||||
left: widget.buttonRect.left * (1 - _buttonAnimation.value),
|
left: widget.buttonRect.left * (1 - _buttonAnimation.value),
|
||||||
@@ -230,8 +258,11 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
top: widget.buttonRect.top,
|
top: widget.buttonRect.top,
|
||||||
//<-- Margin from top
|
//<-- Margin from top
|
||||||
bottom:
|
bottom:
|
||||||
(MediaQuery.of(context).size.height - widget.buttonRect.bottom) *
|
(MediaQuery
|
||||||
(1 - _buttonAnimation.value),
|
.of(context)
|
||||||
|
.size
|
||||||
|
.height - widget.buttonRect.bottom) *
|
||||||
|
(1 - _buttonAnimation.value),
|
||||||
//<-- Margin from bottom
|
//<-- Margin from bottom
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@@ -270,37 +301,27 @@ class _AddPageState extends State<AddPage> with SingleTickerProviderStateMixin {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var today = DateTime.now();
|
var db = Provider.of<ExpensesRepository>(context);
|
||||||
var user = Provider.of<LoginState>(context).currentUser();
|
|
||||||
if (value > 0 && category != "") {
|
if (value > 0 && category != "") {
|
||||||
Firestore.instance
|
db.add(category, value / 100.0, date);
|
||||||
.collection('users')
|
|
||||||
.document(user.uid)
|
|
||||||
.collection('expenses')
|
|
||||||
.document()
|
|
||||||
.setData({
|
|
||||||
"category": category,
|
|
||||||
"value": value / 100.0,
|
|
||||||
"month": today.month,
|
|
||||||
"day": today.day,
|
|
||||||
"year": today.year,
|
|
||||||
});
|
|
||||||
|
|
||||||
_controller.reverse();
|
_controller.reverse();
|
||||||
} else {
|
} else {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) =>
|
||||||
content: Text("You need to select a category and a value greater than zero."),
|
AlertDialog(
|
||||||
actions: <Widget>[
|
content: Text(
|
||||||
FlatButton(
|
"You need to select a category and a value greater than zero."),
|
||||||
child: Text('Ok'),
|
actions: <Widget>[
|
||||||
onPressed: () {
|
FlatButton(
|
||||||
Navigator.of(context).pop();
|
child: Text('Ok'),
|
||||||
},
|
onPressed: () {
|
||||||
),
|
Navigator.of(context).pop();
|
||||||
],
|
},
|
||||||
)
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,110 +1,35 @@
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:como_gasto/pages/ui/day_expense_list_tile.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
|
||||||
|
|
||||||
import '../login_state.dart';
|
class DetailsPage extends StatelessWidget {
|
||||||
|
|
||||||
class DetailsParams {
|
|
||||||
final String categoryName;
|
final String categoryName;
|
||||||
final int month;
|
final List<DocumentSnapshot> documents;
|
||||||
|
final Function(String) onDelete;
|
||||||
|
|
||||||
DetailsParams(this.categoryName, this.month);
|
const DetailsPage({Key key, this.categoryName, this.documents, this.onDelete})
|
||||||
}
|
: super(key: key);
|
||||||
|
|
||||||
class DetailsPage extends StatefulWidget {
|
|
||||||
final DetailsParams params;
|
|
||||||
|
|
||||||
const DetailsPage({Key key, this.params}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_DetailsPageState createState() => _DetailsPageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DetailsPageState extends State<DetailsPage> {
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Consumer<LoginState>(
|
return Scaffold(
|
||||||
builder: (BuildContext context, LoginState state, Widget child) {
|
appBar: AppBar(
|
||||||
var user = Provider.of<LoginState>(context).currentUser();
|
title: Text(categoryName),
|
||||||
var _query = Firestore.instance
|
),
|
||||||
.collection('users')
|
body: ListView.builder(
|
||||||
.document(user.uid)
|
itemCount: documents.length,
|
||||||
.collection('expenses')
|
itemBuilder: (BuildContext context, int index) {
|
||||||
.where("month", isEqualTo: widget.params.month + 1)
|
var document = documents[index];
|
||||||
.where("category", isEqualTo: widget.params.categoryName)
|
|
||||||
.snapshots();
|
|
||||||
|
|
||||||
return Scaffold(
|
return Dismissible(
|
||||||
appBar: AppBar(
|
key: Key(document.documentID),
|
||||||
title: Text(widget.params.categoryName),
|
onDismissed: (direction) {
|
||||||
),
|
onDelete(document.documentID);
|
||||||
body: StreamBuilder<QuerySnapshot>(
|
},
|
||||||
stream: _query,
|
child: new DayExpenseListTile(document: document),
|
||||||
builder:
|
);
|
||||||
(BuildContext context, AsyncSnapshot<QuerySnapshot> data) {
|
},
|
||||||
if (data.hasData) {
|
),
|
||||||
return ListView.builder(
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
var document = data.data.documents[index];
|
|
||||||
|
|
||||||
return Dismissible(
|
|
||||||
key: Key(document.documentID),
|
|
||||||
onDismissed: (direction) {
|
|
||||||
Firestore.instance
|
|
||||||
.collection('users')
|
|
||||||
.document(user.uid)
|
|
||||||
.collection('expenses')
|
|
||||||
.document(document.documentID)
|
|
||||||
.delete();
|
|
||||||
},
|
|
||||||
child: ListTile(
|
|
||||||
leading: Stack(
|
|
||||||
children: <Widget>[
|
|
||||||
Icon(
|
|
||||||
Icons.calendar_today,
|
|
||||||
size: 40,
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
bottom: 8,
|
|
||||||
child: Text(
|
|
||||||
document["day"].toString(),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
title: Container(
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: Colors.blueAccent.withOpacity(0.2),
|
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
|
||||||
),
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Text(
|
|
||||||
"\$${document["value"]}",
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.blueAccent,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: 16.0,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
itemCount: data.data.documents.length,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
));
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import '../expenses_repository.dart';
|
||||||
|
import 'details_page.dart';
|
||||||
|
|
||||||
|
class DetailsParams {
|
||||||
|
final String categoryName;
|
||||||
|
final int month;
|
||||||
|
|
||||||
|
DetailsParams(this.categoryName, this.month);
|
||||||
|
}
|
||||||
|
|
||||||
|
class DetailsPageContainer extends StatefulWidget {
|
||||||
|
final DetailsParams params;
|
||||||
|
|
||||||
|
const DetailsPageContainer({Key key, this.params}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_DetailsPageContainerState createState() => _DetailsPageContainerState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DetailsPageContainerState extends State<DetailsPageContainer> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Consumer<ExpensesRepository>(
|
||||||
|
builder: (BuildContext context, ExpensesRepository db, Widget child) {
|
||||||
|
var _query = db.queryByCategory(
|
||||||
|
widget.params.month + 1, widget.params.categoryName);
|
||||||
|
|
||||||
|
return StreamBuilder<QuerySnapshot>(
|
||||||
|
stream: _query,
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> data) {
|
||||||
|
if (data.hasData) {
|
||||||
|
return DetailsPage(
|
||||||
|
categoryName: widget.params.categoryName,
|
||||||
|
documents: data.data.documents,
|
||||||
|
onDelete: (documentId) {
|
||||||
|
db.delete(documentId);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
import 'package:como_gasto/add_page_transition.dart';
|
|
||||||
import 'package:como_gasto/month_widget.dart';
|
import 'package:como_gasto/month_widget.dart';
|
||||||
import 'package:como_gasto/pages/add_page.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:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:rect_getter/rect_getter.dart';
|
import 'package:rect_getter/rect_getter.dart';
|
||||||
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
|
|
||||||
|
import '../expenses_repository.dart';
|
||||||
import '../login_state.dart';
|
import '../login_state.dart';
|
||||||
import '../utils.dart';
|
import '../utils.dart';
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ class HomePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _HomePageState extends State<HomePage> {
|
class _HomePageState extends State<HomePage> {
|
||||||
|
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
|
||||||
var globalKey = RectGetter.createGlobalKey();
|
var globalKey = RectGetter.createGlobalKey();
|
||||||
Rect buttonRect;
|
Rect buttonRect;
|
||||||
|
|
||||||
@@ -32,6 +33,8 @@ class _HomePageState extends State<HomePage> {
|
|||||||
initialPage: currentPage,
|
initialPage: currentPage,
|
||||||
viewportFraction: 0.4,
|
viewportFraction: 0.4,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setupNotificationPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _bottomAction(IconData icon, Function callback) {
|
Widget _bottomAction(IconData icon, Function callback) {
|
||||||
@@ -46,15 +49,9 @@ class _HomePageState extends State<HomePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Consumer<LoginState>(
|
return Consumer<ExpensesRepository>(
|
||||||
builder: (BuildContext context, LoginState state, Widget child) {
|
builder: (BuildContext context, ExpensesRepository db, Widget child) {
|
||||||
var user = Provider.of<LoginState>(context).currentUser();
|
_query = db.queryByMonth(currentPage + 1);
|
||||||
_query = Firestore.instance
|
|
||||||
.collection('users')
|
|
||||||
.document(user.uid)
|
|
||||||
.collection('expenses')
|
|
||||||
.where("month", isEqualTo: currentPage + 1)
|
|
||||||
.snapshots();
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
bottomNavigationBar: BottomAppBar(
|
bottomNavigationBar: BottomAppBar(
|
||||||
@@ -179,16 +176,11 @@ class _HomePageState extends State<HomePage> {
|
|||||||
size: Size.fromHeight(70.0),
|
size: Size.fromHeight(70.0),
|
||||||
child: PageView(
|
child: PageView(
|
||||||
onPageChanged: (newPage) {
|
onPageChanged: (newPage) {
|
||||||
var user = Provider.of<LoginState>(context).currentUser();
|
var db = Provider.of<ExpensesRepository>(context);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
currentPage = newPage;
|
currentPage = newPage;
|
||||||
_query = Firestore.instance
|
_query = db.queryByMonth(currentPage + 1);
|
||||||
.collection('users')
|
|
||||||
.document(user.uid)
|
|
||||||
.collection('expenses')
|
|
||||||
.where("month", isEqualTo: currentPage + 1)
|
|
||||||
.snapshots();
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
@@ -209,4 +201,68 @@ class _HomePageState extends State<HomePage> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setupNotificationPlugin() {
|
||||||
|
flutterLocalNotificationsPlugin = new FlutterLocalNotificationsPlugin();
|
||||||
|
|
||||||
|
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
|
||||||
|
var initializationSettingsAndroid =
|
||||||
|
new AndroidInitializationSettings('app_icon');
|
||||||
|
var initializationSettingsIOS = new IOSInitializationSettings(
|
||||||
|
onDidReceiveLocalNotification: onDidReceiveLocalNotification,
|
||||||
|
);
|
||||||
|
var initializationSettings = new InitializationSettings(
|
||||||
|
initializationSettingsAndroid,
|
||||||
|
initializationSettingsIOS,
|
||||||
|
);
|
||||||
|
|
||||||
|
flutterLocalNotificationsPlugin
|
||||||
|
.initialize(
|
||||||
|
initializationSettings,
|
||||||
|
onSelectNotification: onSelectNotification,
|
||||||
|
)
|
||||||
|
.then((init) {
|
||||||
|
setupNotification();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future onSelectNotification(String payload) async {
|
||||||
|
if (payload != null) {
|
||||||
|
debugPrint('notification payload: ' + payload);
|
||||||
|
}
|
||||||
|
await Navigator.push(
|
||||||
|
context,
|
||||||
|
new MaterialPageRoute(builder: (context) => HomePage()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future onDidReceiveLocalNotification(
|
||||||
|
int id, String title, String body, String payload) async {
|
||||||
|
// display a dialog with the notification details, tap ok to go to another page
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
content: Text("Don't forget to add your expenses"),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Ok'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupNotification() async {
|
||||||
|
var time = new Time(16, 11, 0);
|
||||||
|
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
|
||||||
|
'daily-notifications', 'Daily Notifications', 'Daily Notifications');
|
||||||
|
var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
|
||||||
|
var platformChannelSpecifics = new NotificationDetails(
|
||||||
|
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
|
||||||
|
|
||||||
|
await flutterLocalNotificationsPlugin.showDailyAtTime(0, 'Spend-o-meter',
|
||||||
|
"Don't forget to add your expenses", time, platformChannelSpecifics);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,135 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
import '../login_state.dart';
|
import '../login_state.dart';
|
||||||
|
|
||||||
class LoginPage extends StatelessWidget {
|
class LoginPage extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_LoginPageState createState() => _LoginPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LoginPageState extends State<LoginPage> {
|
||||||
|
TapGestureRecognizer _recognizer1;
|
||||||
|
TapGestureRecognizer _recognizer2;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: Center(
|
body: SafeArea(
|
||||||
child: Consumer<LoginState>(
|
child: Column(
|
||||||
builder: (BuildContext context, LoginState value, Widget child) {
|
children: <Widget>[
|
||||||
if (value.isLoading()) {
|
Expanded(
|
||||||
return CircularProgressIndicator();
|
flex: 1,
|
||||||
} else {
|
child: Container(),
|
||||||
return child;
|
),
|
||||||
}
|
Text(
|
||||||
},
|
"Spend-o-meter",
|
||||||
child: RaisedButton(
|
style: Theme.of(context).textTheme.display1,
|
||||||
child: Text("Sign In"),
|
),
|
||||||
onPressed: () {
|
Padding(
|
||||||
Provider.of<LoginState>(context).login();
|
padding: const EdgeInsets.all(32.0),
|
||||||
},
|
child: Image.asset('assets/login_background.png'),
|
||||||
),
|
),
|
||||||
|
Text(
|
||||||
|
"Your personal finance app",
|
||||||
|
style: Theme.of(context).textTheme.caption,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: Container(),
|
||||||
|
),
|
||||||
|
Consumer<LoginState>(
|
||||||
|
builder: (BuildContext context, LoginState value, Widget child) {
|
||||||
|
if (value.isLoading()) {
|
||||||
|
return CircularProgressIndicator();
|
||||||
|
} else {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: RaisedButton(
|
||||||
|
child: Text("Sign in with Google"),
|
||||||
|
onPressed: () {
|
||||||
|
Provider.of<LoginState>(context).login();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Container(),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(32.0),
|
||||||
|
child: RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(
|
||||||
|
style: Theme.of(context).textTheme.body1,
|
||||||
|
text: "To use this app you need to agree to our ",
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: "Terms of Service",
|
||||||
|
recognizer: _recognizer1,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.body1
|
||||||
|
.copyWith(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
TextSpan(text: " and "),
|
||||||
|
TextSpan(
|
||||||
|
text: "Privacy Policy",
|
||||||
|
recognizer: _recognizer2,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.body1
|
||||||
|
.copyWith(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
_recognizer1 = TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
showHelp(
|
||||||
|
"This service is provided AS IS and has no current warranty on how the"
|
||||||
|
" data and uptime is managed. The final terms will be released when the final version of the app"
|
||||||
|
" will be released.");
|
||||||
|
};
|
||||||
|
_recognizer2 = TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
showHelp(
|
||||||
|
"All your data is saved anonymously on Firebase Firestore database and will be remain that way."
|
||||||
|
" no other users will have access to it.");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
_recognizer1.dispose();
|
||||||
|
_recognizer2.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void showHelp(String s) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
content: Text(s),
|
||||||
|
actions: <Widget>[
|
||||||
|
FlatButton(
|
||||||
|
child: Text('Ok'),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class DayExpenseListTile extends StatelessWidget {
|
||||||
|
const DayExpenseListTile({
|
||||||
|
Key key,
|
||||||
|
@required this.document,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final DocumentSnapshot document;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ListTile(
|
||||||
|
leading: Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.calendar_today,
|
||||||
|
size: 40,
|
||||||
|
),
|
||||||
|
Positioned(
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 8,
|
||||||
|
child: Text(
|
||||||
|
document["day"].toString(),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
title: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.blueAccent.withOpacity(0.2),
|
||||||
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text(
|
||||||
|
"\$${document["value"]}",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.blueAccent,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontSize: 16.0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,27 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://www.dartlang.org/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
archive:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: archive
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.10"
|
||||||
|
args:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: args
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.5.2"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.2.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -50,6 +64,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.14.11"
|
version: "1.14.11"
|
||||||
|
convert:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: convert
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.1"
|
||||||
|
crypto:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: crypto
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.6"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -57,6 +85,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.2"
|
version: "0.1.2"
|
||||||
|
datetime_picker_formfield:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: datetime_picker_formfield
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.0"
|
||||||
firebase_auth:
|
firebase_auth:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -76,6 +111,20 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_launcher_icons:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_launcher_icons
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.7.2+1"
|
||||||
|
flutter_local_notifications:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: flutter_local_notifications
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.8.0"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -95,6 +144,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.1+3"
|
version: "4.0.1+3"
|
||||||
|
image:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: image
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.4"
|
||||||
intl:
|
intl:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -136,21 +192,35 @@ packages:
|
|||||||
name: pedantic
|
name: pedantic
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.5.0"
|
version: "1.7.0"
|
||||||
|
petitparser:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: petitparser
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.1"
|
||||||
|
platform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: platform
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
provider:
|
provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: provider
|
name: provider
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "3.0.0+1"
|
||||||
quiver:
|
quiver:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: quiver
|
name: quiver
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.2"
|
version: "2.0.3"
|
||||||
rect_getter:
|
rect_getter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -211,7 +281,7 @@ packages:
|
|||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.4"
|
version: "0.2.5"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -226,6 +296,20 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.0.8"
|
||||||
|
xml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: xml
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.4.1"
|
||||||
|
yaml:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: yaml
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.16"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.2.0 <3.0.0"
|
dart: ">=2.2.2 <3.0.0"
|
||||||
flutter: ">=1.2.0 <2.0.0"
|
flutter: ">=1.5.0 <2.0.0"
|
||||||
|
|||||||
@@ -26,16 +26,24 @@ dependencies:
|
|||||||
# The following adds the Cupertino Icons font to your application.
|
# The following adds the Cupertino Icons font to your application.
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^0.1.2
|
cupertino_icons: ^0.1.2
|
||||||
provider: ^2.0.1
|
provider: ^3.0.0+1
|
||||||
google_sign_in: ^4.0.1+3
|
google_sign_in: ^4.0.1+3
|
||||||
firebase_auth: ^0.11.1
|
firebase_auth: ^0.11.1
|
||||||
shared_preferences: ^0.5.2
|
shared_preferences: ^0.5.2
|
||||||
rect_getter: ^0.0.1
|
rect_getter: ^0.0.1
|
||||||
|
flutter_launcher_icons: ^0.7.2+1
|
||||||
|
flutter_local_notifications: ^0.8.0
|
||||||
|
datetime_picker_formfield: ^0.4.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
||||||
|
flutter_icons:
|
||||||
|
android: true
|
||||||
|
ios: true
|
||||||
|
image_path: "assets/launcher_icon_base.png"
|
||||||
|
image_path_ios: "assets/launcher_icon_ios.png"
|
||||||
|
|
||||||
# For information on the generic Dart part of this file, see the
|
# For information on the generic Dart part of this file, see the
|
||||||
# following page: https://www.dartlang.org/tools/pub/pubspec
|
# following page: https://www.dartlang.org/tools/pub/pubspec
|
||||||
|
|||||||