Add Firestore support

This commit is contained in:
Ricardo Markiewicz
2019-04-21 01:51:43 -03:00
parent 30324991f5
commit ced7aa91d7
13 changed files with 558 additions and 96 deletions
+1
View File
@@ -1 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
+1
View File
@@ -1 +1,2 @@
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
+71
View File
@@ -0,0 +1,71 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end
target 'Runner' do
use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
# Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
}
# Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
+178
View File
@@ -0,0 +1,178 @@
PODS:
- BoringSSL-GRPC (0.0.2):
- BoringSSL-GRPC/Implementation (= 0.0.2)
- BoringSSL-GRPC/Interface (= 0.0.2)
- BoringSSL-GRPC/Implementation (0.0.2):
- BoringSSL-GRPC/Interface (= 0.0.2)
- BoringSSL-GRPC/Interface (0.0.2)
- cloud_firestore (0.0.1):
- Firebase/Auth
- Firebase/Core
- Firebase/Database
- Firebase/Firestore
- Flutter
- Firebase/Auth (5.18.0):
- Firebase/CoreOnly
- FirebaseAuth (= 5.4.0)
- Firebase/Core (5.18.0):
- Firebase/CoreOnly
- FirebaseAnalytics (= 5.7.0)
- Firebase/CoreOnly (5.18.0):
- FirebaseCore (= 5.3.1)
- Firebase/Database (5.18.0):
- Firebase/CoreOnly
- FirebaseDatabase (= 5.1.0)
- Firebase/Firestore (5.18.0):
- Firebase/CoreOnly
- FirebaseFirestore (= 1.0.2)
- firebase_core (0.0.1):
- Firebase/Core
- Flutter
- FirebaseAnalytics (5.7.0):
- FirebaseCore (~> 5.3)
- FirebaseInstanceID (~> 3.6)
- GoogleAppMeasurement (= 5.7.0)
- GoogleUtilities/AppDelegateSwizzler (~> 5.2)
- GoogleUtilities/MethodSwizzler (~> 5.2)
- GoogleUtilities/Network (~> 5.2)
- "GoogleUtilities/NSData+zlib (~> 5.2)"
- nanopb (~> 0.3)
- FirebaseAuth (5.4.0):
- FirebaseAuthInterop (~> 1.0)
- FirebaseCore (~> 5.2)
- GoogleUtilities/Environment (~> 5.2)
- GTMSessionFetcher/Core (~> 1.1)
- FirebaseAuthInterop (1.0.0)
- FirebaseCore (5.3.1):
- GoogleUtilities/Logger (~> 5.2)
- FirebaseDatabase (5.1.0):
- FirebaseAuthInterop (~> 1.0)
- FirebaseCore (~> 5.2)
- leveldb-library (~> 1.18)
- FirebaseFirestore (1.0.2):
- FirebaseAuthInterop (~> 1.0)
- FirebaseCore (~> 5.2)
- FirebaseFirestore/abseil-cpp (= 1.0.2)
- "gRPC-C++ (= 0.0.6)"
- leveldb-library (~> 1.20)
- nanopb (~> 0.3.901)
- Protobuf (~> 3.1)
- FirebaseFirestore/abseil-cpp (1.0.2):
- FirebaseAuthInterop (~> 1.0)
- FirebaseCore (~> 5.2)
- "gRPC-C++ (= 0.0.6)"
- leveldb-library (~> 1.20)
- nanopb (~> 0.3.901)
- Protobuf (~> 3.1)
- FirebaseInstanceID (3.7.0):
- FirebaseCore (~> 5.2)
- GoogleUtilities/Environment (~> 5.2)
- GoogleUtilities/UserDefaults (~> 5.2)
- Flutter (1.0.0)
- GoogleAppMeasurement (5.7.0):
- GoogleUtilities/AppDelegateSwizzler (~> 5.2)
- GoogleUtilities/MethodSwizzler (~> 5.2)
- GoogleUtilities/Network (~> 5.2)
- "GoogleUtilities/NSData+zlib (~> 5.2)"
- nanopb (~> 0.3)
- GoogleUtilities/AppDelegateSwizzler (5.3.7):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (5.3.7)
- GoogleUtilities/Logger (5.3.7):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (5.3.7):
- GoogleUtilities/Logger
- GoogleUtilities/Network (5.3.7):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (5.3.7)"
- GoogleUtilities/Reachability (5.3.7):
- GoogleUtilities/Logger
- GoogleUtilities/UserDefaults (5.3.7):
- GoogleUtilities/Logger
- "gRPC-C++ (0.0.6)":
- "gRPC-C++/Implementation (= 0.0.6)"
- "gRPC-C++/Interface (= 0.0.6)"
- "gRPC-C++/Implementation (0.0.6)":
- "gRPC-C++/Interface (= 0.0.6)"
- gRPC-Core (= 1.17.0)
- nanopb (~> 0.3)
- "gRPC-C++/Interface (0.0.6)"
- gRPC-Core (1.17.0):
- gRPC-Core/Implementation (= 1.17.0)
- gRPC-Core/Interface (= 1.17.0)
- gRPC-Core/Implementation (1.17.0):
- BoringSSL-GRPC (= 0.0.2)
- gRPC-Core/Interface (= 1.17.0)
- nanopb (~> 0.3)
- gRPC-Core/Interface (1.17.0)
- GTMSessionFetcher/Core (1.2.1)
- leveldb-library (1.20)
- nanopb (0.3.901):
- nanopb/decode (= 0.3.901)
- nanopb/encode (= 0.3.901)
- nanopb/decode (0.3.901)
- nanopb/encode (0.3.901)
- Protobuf (3.7.0)
DEPENDENCIES:
- cloud_firestore (from `.symlinks/plugins/cloud_firestore/ios`)
- firebase_core (from `.symlinks/plugins/firebase_core/ios`)
- Flutter (from `.symlinks/flutter/ios`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
- BoringSSL-GRPC
- Firebase
- FirebaseAnalytics
- FirebaseAuth
- FirebaseAuthInterop
- FirebaseCore
- FirebaseDatabase
- FirebaseFirestore
- FirebaseInstanceID
- GoogleAppMeasurement
- GoogleUtilities
- "gRPC-C++"
- gRPC-Core
- GTMSessionFetcher
- leveldb-library
- nanopb
- Protobuf
EXTERNAL SOURCES:
cloud_firestore:
:path: ".symlinks/plugins/cloud_firestore/ios"
firebase_core:
:path: ".symlinks/plugins/firebase_core/ios"
Flutter:
:path: ".symlinks/flutter/ios"
SPEC CHECKSUMS:
BoringSSL-GRPC: 2a230d9cd93e7ce39916044f645cebb31f37dde6
cloud_firestore: 980813a98d8beb5c321b589845fabf6c4c5bd571
Firebase: 02f3281965c075426141a0ce1277e9de6649cab9
firebase_core: c96aa8b2fcf7f5167d32f22034f502f9304952b8
FirebaseAnalytics: 23851fe602c872130a2c5c55040b302120346cc2
FirebaseAuth: d85d052354447f30b4b2a805ab91b511458b56a6
FirebaseAuthInterop: 0ffa57668be100582bb7643d4fcb7615496c41fc
FirebaseCore: 52f851b30e11360f1e67cf04b1edfebf0a47a2d3
FirebaseDatabase: 23acb0c53cd4d4070a427b60100b2e4aaa97c45d
FirebaseFirestore: ccdaffb8a73c591ff61872b8f7905ad0c237ef50
FirebaseInstanceID: bd6fc5a258884e206fd5c474ebe4f5b00e21770e
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
GoogleAppMeasurement: 6cf307834da065863f9faf4c0de0a936d81dd832
GoogleUtilities: 111a012f4c3a29c9e7c954c082fafd6ee3c999c0
"gRPC-C++": e76441995900ac90e9bd98644ab4733f12521edf
gRPC-Core: 4028031ed2c5267cca0d846c876d8046b1ecb9b6
GTMSessionFetcher: 32aeca0aa144acea523e1c8e053089dec2cb98ca
leveldb-library: 08cba283675b7ed2d99629a4bc5fd052cd2bb6a5
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
Protobuf: 7a877b7f3e5964e3fce995e2eb323dbc6831bb5a
PODFILE CHECKSUM: ebd43b443038e611b86ede96e613bd6033c49497
COCOAPODS: 1.5.3
+79 -1
View File
@@ -11,6 +11,7 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
714068D5226768AA00F32532 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 714068D4226768AA00F32532 /* GoogleService-Info.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -18,6 +19,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
A6A775CC0410D5E148B36BC7 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EC1352646DE8B1C75FB9257 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -40,6 +42,8 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
6EC1352646DE8B1C75FB9257 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
714068D4226768AA00F32532 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
@@ -60,12 +64,21 @@
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
A6A775CC0410D5E148B36BC7 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
3EDE91530A60A71D8507CD40 /* Frameworks */ = {
isa = PBXGroup;
children = (
6EC1352646DE8B1C75FB9257 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
@@ -85,6 +98,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
B2B921052E5B0B1DDFA66EF4 /* Pods */,
3EDE91530A60A71D8507CD40 /* Frameworks */,
);
sourceTree = "<group>";
};
@@ -102,6 +117,7 @@
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
714068D4226768AA00F32532 /* GoogleService-Info.plist */,
97C147021CF9000F007C117D /* Info.plist */,
97C146F11CF9000F007C117D /* Supporting Files */,
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
@@ -119,6 +135,13 @@
name = "Supporting Files";
sourceTree = "<group>";
};
B2B921052E5B0B1DDFA66EF4 /* Pods */ = {
isa = PBXGroup;
children = (
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -126,12 +149,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
C56CF6F65155FD2794DB029E /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
7ABCEBC0434A5B0DE57E84C1 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -162,6 +187,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
@@ -185,6 +211,7 @@
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
714068D5226768AA00F32532 /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -205,6 +232,40 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
};
7ABCEBC0434A5B0DE57E84C1 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/BoringSSL-GRPC/openssl_grpc.framework",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/GTMSessionFetcher/GTMSessionFetcher.framework",
"${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework",
"${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework",
"${BUILT_PRODUCTS_DIR}/gRPC-C++/grpcpp.framework",
"${BUILT_PRODUCTS_DIR}/gRPC-Core/grpc.framework",
"${BUILT_PRODUCTS_DIR}/leveldb-library/leveldb.framework",
"${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/openssl_grpc.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GTMSessionFetcher.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Protobuf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpcpp.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/grpc.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/leveldb.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -219,6 +280,24 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
C56CF6F65155FD2794DB029E /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -508,7 +587,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
+3
View File
@@ -4,4 +4,7 @@
<FileRef
location = "group:Runner.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>390267660807-qkjge0jrqtiemplads9qs6juj0k9pg47.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.390267660807-qkjge0jrqtiemplads9qs6juj0k9pg47</string>
<key>API_KEY</key>
<string>AIzaSyAKf5pzsDEvql_siuuKagSS9PEb7PwQXSw</string>
<key>GCM_SENDER_ID</key>
<string>390267660807</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>ar.com.p39.comoGasto</string>
<key>PROJECT_ID</key>
<string>comogastoyt-9add1</string>
<key>STORAGE_BUCKET</key>
<string>comogastoyt-9add1.appspot.com</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:390267660807:ios:9746ee227887bd3a</string>
<key>DATABASE_URL</key>
<string>https://comogastoyt-9add1.firebaseio.com</string>
</dict>
</plist>
+5 -12
View File
@@ -4,22 +4,15 @@ import 'package:flutter/material.dart';
import 'package:charts_flutter/flutter.dart';
class GraphWidget extends StatefulWidget {
final List<double> data;
const GraphWidget({Key key, this.data}) : super(key: key);
@override
_GraphWidgetState createState() => _GraphWidgetState();
}
class _GraphWidgetState extends State<GraphWidget> {
var data;
@override
void initState() {
super.initState();
var r = Random();
data = List<double>.generate(30, (i) => r.nextDouble() * 1500);
}
_onSelectionChanged(SelectionModel model) {
final selectedDatum = model.selectedDatum;
@@ -56,7 +49,7 @@ class _GraphWidgetState extends State<GraphWidget> {
colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
domainFn: (value, index) => index,
measureFn: (value, _) => value,
data: data,
data: widget.data,
strokeWidthPxFn: (_, __) => 4,
)
];
+25 -83
View File
@@ -1,6 +1,8 @@
import 'package:como_gasto/graph_widget.dart';
import 'package:como_gasto/month_widget.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
void main() => runApp(MyApp());
@@ -25,12 +27,18 @@ class HomePage extends StatefulWidget {
class _HomePageState extends State<HomePage> {
PageController _controller;
int currentPage = 9;
Stream<QuerySnapshot> _query;
@override
void initState() {
super.initState();
_query = Firestore.instance
.collection('expenses')
.where("month", isEqualTo: currentPage + 1)
.snapshots();
_controller = PageController(
initialPage: currentPage,
viewportFraction: 0.4,
@@ -79,13 +87,20 @@ class _HomePageState extends State<HomePage> {
child: Column(
children: <Widget>[
_selector(),
_expenses(),
_graph(),
Container(
color: Colors.blueAccent.withOpacity(0.15),
height: 24.0,
StreamBuilder<QuerySnapshot>(
stream: _query,
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> data) {
if (data.hasData) {
return MonthWidget(
documents: data.data.documents,
);
}
return Center(
child: CircularProgressIndicator(),
);
},
),
_list(),
],
),
);
@@ -127,6 +142,10 @@ class _HomePageState extends State<HomePage> {
onPageChanged: (newPage) {
setState(() {
currentPage = newPage;
_query = Firestore.instance
.collection('expenses')
.where("month", isEqualTo: currentPage + 1)
.snapshots();
});
},
controller: _controller,
@@ -147,81 +166,4 @@ class _HomePageState extends State<HomePage> {
),
);
}
Widget _expenses() {
return Column(
children: <Widget>[
Text("\$2361,41",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 40.0,
),
),
Text("Total expenses",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16.0,
color: Colors.blueGrey,
),
),
],
);
}
Widget _graph() {
return Container(
height: 250.0,
child: GraphWidget(),
);
}
Widget _item(IconData icon, String name, int percent, double value) {
return ListTile(
leading: Icon(icon, size: 32.0,),
title: Text(name,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0
),
),
subtitle: Text("$percent% of expenses",
style: TextStyle(
fontSize: 16.0,
color: Colors.blueGrey,
),
),
trailing: Container(
decoration: BoxDecoration(
color: Colors.blueAccent.withOpacity(0.2),
borderRadius: BorderRadius.circular(5.0),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("\$$value",
style: TextStyle(
color: Colors.blueAccent,
fontWeight: FontWeight.w500,
fontSize: 16.0,
),
),
),
),
);
}
Widget _list() {
return Expanded(
child: ListView.separated(
itemCount: 15,
itemBuilder: (BuildContext context, int index) =>
_item(FontAwesomeIcons.shoppingCart, "Shopping", 14, 145.12),
separatorBuilder: (BuildContext context, int index) {
return Container(
color: Colors.blueAccent.withOpacity(0.15),
height: 8.0,
);
},
),
);
}
}
+135
View File
@@ -0,0 +1,135 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:como_gasto/graph_widget.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class MonthWidget extends StatefulWidget {
final List<DocumentSnapshot> documents;
final double total;
final List<double> perDay;
final Map<String, double> categories;
MonthWidget({Key key, this.documents})
:
total = documents.map((doc) => doc['value'])
.fold(0.0, (a, b) => a + b),
perDay = List.generate(30, (int index) {
return documents.where((doc) => doc['day'] == (index + 1))
.map((doc) => doc['value'])
.fold(0.0, (a, b) => a + b);
}),
categories = documents.fold({}, (Map<String, double> map, document) {
if (!map.containsKey(document['category'])) {
map[document['category']] = 0.0;
}
map[document['category']] += document['value'];
return map;
}),
super(key: key);
@override
_MonthWidgetState createState() => _MonthWidgetState();
}
class _MonthWidgetState extends State<MonthWidget> {
@override
Widget build(BuildContext context) {
print(widget.categories);
return Expanded(
child: Column(
children: <Widget>[
_expenses(),
_graph(),
Container(
color: Colors.blueAccent.withOpacity(0.15),
height: 24.0,
),
_list(),
],
),
);
}
Widget _expenses() {
return Column(
children: <Widget>[
Text("\$${widget.total.toStringAsFixed(2)}",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 40.0,
),
),
Text("Total expenses",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 16.0,
color: Colors.blueGrey,
),
),
],
);
}
Widget _graph() {
return Container(
height: 250.0,
child: GraphWidget(
data: widget.perDay,
),
);
}
Widget _item(IconData icon, String name, int percent, double value) {
return ListTile(
leading: Icon(icon, size: 32.0,),
title: Text(name,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0
),
),
subtitle: Text("$percent% of expenses",
style: TextStyle(
fontSize: 16.0,
color: Colors.blueGrey,
),
),
trailing: Container(
decoration: BoxDecoration(
color: Colors.blueAccent.withOpacity(0.2),
borderRadius: BorderRadius.circular(5.0),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text("\$$value",
style: TextStyle(
color: Colors.blueAccent,
fontWeight: FontWeight.w500,
fontSize: 16.0,
),
),
),
),
);
}
Widget _list() {
return Expanded(
child: ListView.separated(
itemCount: widget.categories.keys.length,
itemBuilder: (BuildContext context, int index) {
var key = widget.categories.keys.elementAt(index);
var data = widget.categories[key];
return _item(FontAwesomeIcons.shoppingCart, key, 100 * data ~/ widget.total, data);
},
separatorBuilder: (BuildContext context, int index) {
return Container(
color: Colors.blueAccent.withOpacity(0.15),
height: 8.0,
);
},
),
);
}
}
+15
View File
@@ -36,6 +36,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0"
cloud_firestore:
dependency: "direct main"
description:
name: cloud_firestore
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.13+1"
collection:
dependency: transitive
description:
@@ -50,6 +57,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
firebase_core:
dependency: transitive
description:
name: firebase_core
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.4"
flutter:
dependency: "direct main"
description: flutter
@@ -179,3 +193,4 @@ packages:
version: "2.0.8"
sdks:
dart: ">=2.1.0 <3.0.0"
flutter: ">=1.2.0 <2.0.0"
+1
View File
@@ -21,6 +21,7 @@ dependencies:
sdk: flutter
charts_flutter: ^0.6.0
font_awesome_flutter: ^8.4.0
cloud_firestore: ^0.9.13+1
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.